content($content); } public static function make(string | Htmlable | Closure | null $content): static { $static = app(static::class, ['content' => $content]); $static->configure(); return $static; } protected function setUp(): void { parent::setUp(); $this->defaultColor('gray'); } public function content(string | Htmlable | Closure | null $content): static { $this->content = $content; return $this; } public function badge(bool | Closure $condition = true): static { $this->isBadge = $condition; return $this; } public function isBadge(): bool { return (bool) $this->evaluate($this->isBadge); } public function js(): static { $this->content(JsContent::make($this->getContent())); return $this; } public function getContent(): string | Htmlable | null { return $this->evaluate($this->content); } public function size(TextSize | Size | string | Closure | null $size): static { $this->size = $size; return $this; } public function getSize(): TextSize | Size | string | null { $size = $this->evaluate($this->size); if (blank($size)) { return null; } if (is_string($size)) { $size = TextSize::tryFrom($size) ?? $size; } return $size; } public function toEmbeddedHtml(): string { $color = $this->getColor(); $content = $this->getContent(); $icon = $this->getIcon(); $iconPosition = $this->getIconPosition(); $iconSize = $this->getIconSize(); $size = $this->getSize(); $tooltip = $this->getTooltip(); $weight = $this->getWeight(); $fontFamily = $this->getFontFamily(); $copyableState = $this->getCopyableState($content) ?? $content; $copyMessage = $this->getCopyMessage($copyableState); $copyMessageDuration = $this->getCopyMessageDuration($copyableState); $isCopyable = $this->isCopyable($copyableState); $hasTooltip = filled($tooltip); if ($this->isBadge()) { if (! $size instanceof Size) { $size = filled($size) ? (is_string($size) ? (Size::tryFrom($size) ?? $size) : $size) : Size::Medium; } if (filled($iconSize) && (! $iconSize instanceof IconSize)) { $iconSize = IconSize::tryFrom($iconSize) ?? $iconSize; } $badgeAttributes = $this->getExtraAttributeBag() ->merge([ 'type' => $isCopyable ? 'button' : null, 'wire:loading.attr' => $isCopyable ? 'disabled' : null, ], escape: false) ->class([ 'fi-sc-text', 'fi-badge', ($size instanceof BackedEnum) ? "fi-size-{$size->value}" : $size, ]) ->color(BadgeComponent::class, $color ?? 'primary'); ob_start(); ?> < x-on:click=" window.navigator.clipboard.writeText() $tooltip(, { theme: $store.theme, timeout: , }) " x-tooltip="{ content: , theme: $store.theme, allowHTML: , }" toHtml() ?> > toHtml() ?> toHtml() ?> > color(TextComponent::class, $color) ->class([ 'fi-sc-text', 'fi-copyable' => $isCopyable, ($size instanceof BackedEnum) ? "fi-size-{$size->value}" : $size, ($weight instanceof FontWeight) ? "fi-font-{$weight->value}" : $weight, ($fontFamily instanceof FontFamily) ? "fi-font-{$fontFamily->value}" : $fontFamily, ]) ->merge($this->getExtraAttributes(), escape: false); ob_start(); ?> role="button" tabindex="0" x-on:click=" window.navigator.clipboard.writeText() $tooltip(, { theme: $store.theme, timeout: , }) " x-on:keydown.enter.prevent="$el.click()" x-on:keydown.space.prevent="$el.click()" x-tooltip="{ content: , theme: $store.theme, allowHTML: , }" toHtml() ?> >