|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace App\Enums\Examples\V3\Ui; |
| 4 | + |
| 5 | +class ListComponent |
| 6 | +{ |
| 7 | + public const string BASIC = <<<'HTML' |
| 8 | + <x-list> |
| 9 | + <x-list.items name="general" caption="1 server" /> |
| 10 | + <x-list.items name="production" caption="12 servers" /> |
| 11 | + <x-list.items name="staging" caption="3 servers" /> |
| 12 | + </x-list> |
| 13 | +
|
| 14 | + <!-- or --> |
| 15 | +
|
| 16 | + @php |
| 17 | + // `$items` may be an array, a Collection, or any object that implements |
| 18 | + // `Illuminate\Contracts\Support\Arrayable`. Each entry is read with |
| 19 | + // `data_get`, so accessors and array keys both work. The only required |
| 20 | + // key is `name` — every other key is optional and accessible inside |
| 21 | + // `@interact('item_menu', $item)` as `$item['extra_key']`. |
| 22 | + $items = [ |
| 23 | + ['name' => 'general', 'caption' => '1 server'], |
| 24 | + ['name' => 'production', 'caption' => '12 servers'], |
| 25 | + ['name' => 'staging', 'caption' => '3 servers'], |
| 26 | + ]; |
| 27 | + @endphp |
| 28 | +
|
| 29 | + <x-list :items="$items" /> |
| 30 | + HTML; |
| 31 | + |
| 32 | + public const string LABEL_HINT = <<<'HTML' |
| 33 | + <x-list label="Tags" hint="Manage your tags here."> |
| 34 | + <x-list.items name="general" caption="1 server" /> |
| 35 | + <x-list.items name="production" caption="12 servers" /> |
| 36 | + </x-list> |
| 37 | + HTML; |
| 38 | + |
| 39 | + public const string SEARCHABLE = <<<'HTML' |
| 40 | + <x-list label="Tags" searchable> |
| 41 | + <x-list.items name="general" caption="1 server" /> |
| 42 | + <x-list.items name="production" caption="12 servers" /> |
| 43 | + <x-list.items name="staging" caption="3 servers" /> |
| 44 | + </x-list> |
| 45 | + HTML; |
| 46 | + |
| 47 | + public const string SEARCH_PLACEHOLDER = <<<'HTML' |
| 48 | + <x-list label="Tags" searchable search-placeholder="Filter tags by name or caption"> |
| 49 | + <x-list.items name="general" caption="1 server" /> |
| 50 | + <x-list.items name="production" caption="12 servers" /> |
| 51 | + </x-list> |
| 52 | + HTML; |
| 53 | + |
| 54 | + public const string PER_ITEM_MENU = <<<'HTML' |
| 55 | + <x-list label="Tags" hint="Click an ellipsis to act on a tag."> |
| 56 | + <x-list.items name="general" caption="1 server"> |
| 57 | + <x-slot:menu> |
| 58 | + <x-dropdown.items text="Edit" wire:click="edit('general')" /> |
| 59 | + <x-dropdown.items text="Delete" wire:click="delete('general')" /> |
| 60 | + </x-slot:menu> |
| 61 | + </x-list.items> |
| 62 | + <x-list.items name="production" caption="12 servers"> |
| 63 | + <x-slot:menu> |
| 64 | + <x-dropdown.items text="Edit" wire:click="edit('production')" /> |
| 65 | + <x-dropdown.items text="Delete" wire:click="delete('production')" /> |
| 66 | + </x-slot:menu> |
| 67 | + </x-list.items> |
| 68 | + </x-list> |
| 69 | + HTML; |
| 70 | + |
| 71 | + public const string LOOP_ITEMS = <<<'HTML' |
| 72 | + <x-list label="Tags" searchable> |
| 73 | + @foreach ($tags as $tag) |
| 74 | + <x-list.items :name="$tag->name" :caption="$tag->servers_count.' server(s)'"> |
| 75 | + <x-slot:menu> |
| 76 | + <x-dropdown.items text="Edit" wire:click="edit({{ $tag->id }})" /> |
| 77 | + <x-dropdown.items text="Delete" wire:click="delete({{ $tag->id }})" /> |
| 78 | + </x-slot:menu> |
| 79 | + </x-list.items> |
| 80 | + @endforeach |
| 81 | + </x-list> |
| 82 | + HTML; |
| 83 | + |
| 84 | + public const string DATA_DRIVEN = <<<'HTML' |
| 85 | + @php |
| 86 | + $tags = [ |
| 87 | + ['name' => 'general', 'caption' => '1 server'], |
| 88 | + ['name' => 'production', 'caption' => '12 servers'], |
| 89 | + ['name' => 'staging', 'caption' => '3 servers'], |
| 90 | + ]; |
| 91 | + @endphp |
| 92 | +
|
| 93 | + <x-list label="Tags" :items="$tags" searchable /> |
| 94 | + HTML; |
| 95 | + |
| 96 | + public const string DATA_DRIVEN_MENU = <<<'HTML' |
| 97 | + @php |
| 98 | + $tags = [ |
| 99 | + ['id' => 1, 'name' => 'general', 'caption' => '1 server'], |
| 100 | + ['id' => 2, 'name' => 'production', 'caption' => '12 servers'], |
| 101 | + ['id' => 3, 'name' => 'staging', 'caption' => '3 servers'], |
| 102 | + ]; |
| 103 | + @endphp |
| 104 | +
|
| 105 | + <x-list label="Tags" :items="$tags" searchable> |
| 106 | + @interact('item_menu', $item) |
| 107 | + <x-dropdown.items text="Edit" wire:click="edit('{{ $item['id'] }}')" /> |
| 108 | + <x-dropdown.items text="Delete" wire:click="delete('{{ $item['id'] }}')" /> |
| 109 | + @endinteract |
| 110 | + </x-list> |
| 111 | + HTML; |
| 112 | + |
| 113 | + public const string HEIGHT = <<<'HTML' |
| 114 | + <!-- |
| 115 | + The `height` attribute accepts one of `'40'`, `'60'`, `'80'` or `'96'`, |
| 116 | + which translate to `max-h-{n}` plus a custom-styled scrollbar. |
| 117 | + --> |
| 118 | + <x-list label="Tags" :items="$tags" searchable height="60" /> |
| 119 | + HTML; |
| 120 | + |
| 121 | + public const string EMPTY_SLOT = <<<'HTML' |
| 122 | + <!-- |
| 123 | + The empty slot is shown when the list has zero items AND when |
| 124 | + the search filter matches none. The default falls back to the |
| 125 | + `ts-ui::messages.list.empty` translation key. |
| 126 | + --> |
| 127 | + <x-list label="Tags" searchable> |
| 128 | + <x-slot:empty> |
| 129 | + <div class="flex flex-col items-center gap-2 py-4"> |
| 130 | + <p class="text-sm text-secondary-700 dark:text-dark-100">No tags configured yet.</p> |
| 131 | + <x-button text="Create tag" wire:click="create" /> |
| 132 | + </div> |
| 133 | + </x-slot:empty> |
| 134 | + <x-list.items name="general" caption="1 server" /> |
| 135 | + </x-list> |
| 136 | + HTML; |
| 137 | + |
| 138 | + public const string RICH_INLINE = <<<'HTML' |
| 139 | + <x-list label="Features"> |
| 140 | + <x-list.items name="signup-flow"> |
| 141 | + <x-badge color="green" round xs>active</x-badge> |
| 142 | + </x-list.items> |
| 143 | + <x-list.items name="checkout-v2"> |
| 144 | + <x-badge color="amber" round xs>rolling out</x-badge> |
| 145 | + </x-list.items> |
| 146 | + <x-list.items name="legacy-onboarding"> |
| 147 | + <x-badge color="red" round xs>retired</x-badge> |
| 148 | + </x-list.items> |
| 149 | + </x-list> |
| 150 | + HTML; |
| 151 | + |
| 152 | + public const string CUSTOMIZATION = <<<'HTML' |
| 153 | + TallStackUi::customize() |
| 154 | + ->list() |
| 155 | + ->block('block', 'classes'); |
| 156 | + HTML; |
| 157 | + |
| 158 | + public const string CUSTOMIZATION_ITEMS = <<<'HTML' |
| 159 | + TallStackUi::customize() |
| 160 | + ->list('items') |
| 161 | + ->block('block', 'classes'); |
| 162 | + HTML; |
| 163 | +} |
0 commit comments