tam_select 1.2.4 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,740 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Tam Select – Playground</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <script>
9
+ tailwind.config = {
10
+ darkMode: 'class',
11
+ theme: { extend: { fontFamily: { sans: ['Inter', 'system-ui', 'sans-serif'] } } }
12
+ }
13
+ </script>
14
+ <link rel="preconnect" href="https://fonts.googleapis.com">
15
+ <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
16
+ <style>
17
+ *{box-sizing:border-box}
18
+ body{font-family:'Inter',system-ui,sans-serif}
19
+ .dark{color-scheme:dark}
20
+ </style>
21
+ </head>
22
+ <body class="bg-zinc-50 text-zinc-900 dark:bg-zinc-950 dark:text-zinc-100 min-h-screen transition-colors">
23
+
24
+ <!-- Header -->
25
+ <div class="border-b border-zinc-200 dark:border-zinc-800 bg-white dark:bg-zinc-900 sticky top-0 z-50">
26
+ <div class="max-w-6xl mx-auto px-6 py-4 flex items-center justify-between">
27
+ <div>
28
+ <h1 class="text-lg font-bold tracking-tight">tam-select <span class="text-zinc-400 font-normal">playground</span></h1>
29
+ <p class="text-xs text-zinc-400 dark:text-zinc-500 mt-0.5">v1.3.0 — compact design refresh</p>
30
+ </div>
31
+ <div class="flex items-center gap-3">
32
+ <button id="themeToggle" class="inline-flex items-center gap-1.5 rounded-md border border-zinc-200 dark:border-zinc-700 bg-white dark:bg-zinc-800 px-2.5 py-1.5 text-xs font-medium text-zinc-600 dark:text-zinc-300 shadow-sm hover:bg-zinc-50 dark:hover:bg-zinc-700 transition">
33
+ <span id="themeIcon">🌙</span>
34
+ </button>
35
+ </div>
36
+ </div>
37
+ </div>
38
+
39
+ <div class="max-w-6xl mx-auto px-6 py-10 space-y-12">
40
+
41
+ <!-- Height Comparison -->
42
+ <section>
43
+ <h2 class="text-xs font-semibold text-zinc-400 dark:text-zinc-500 uppercase tracking-wider mb-4">Height Match</h2>
44
+ <div class="grid grid-cols-1 md:grid-cols-4 gap-4 items-end">
45
+ <div class="space-y-1.5">
46
+ <label class="block text-xs text-zinc-400">text input</label>
47
+ <input type="text" placeholder="Standard input" class="min-h-11 w-full rounded-lg border border-zinc-200 bg-white px-3 py-2 text-sm font-medium text-zinc-800 shadow-sm dark:border-zinc-700 dark:bg-zinc-900 dark:text-zinc-100">
48
+ </div>
49
+ <div class="space-y-1.5">
50
+ <label class="block text-xs text-zinc-400">tam-select</label>
51
+ <select id="height-cmp" data-placeholder="Standard input"></select>
52
+ </div>
53
+ <div class="space-y-1.5">
54
+ <label class="block text-xs text-zinc-400">select (native)</label>
55
+ <select class="min-h-11 w-full rounded-lg border border-zinc-200 bg-white px-3 py-2 text-sm font-medium text-zinc-800 shadow-sm dark:border-zinc-700 dark:bg-zinc-900 dark:text-zinc-100">
56
+ <option>Choose one…</option>
57
+ <option>Option A</option>
58
+ <option>Option B</option>
59
+ </select>
60
+ </div>
61
+ <div class="space-y-1.5">
62
+ <label class="block text-xs text-zinc-400">textarea</label>
63
+ <textarea rows="1" placeholder="Standard textarea" class="min-h-9 w-full resize-none rounded-md border border-zinc-200 bg-white px-3 py-2 text-sm font-medium text-zinc-800 shadow-sm dark:border-zinc-700 dark:bg-zinc-900 dark:text-zinc-100"></textarea>
64
+ </div>
65
+ </div>
66
+ <p class="text-xs text-zinc-400 mt-2">All four use <code class="text-zinc-500">min-h-11 px-3 py-2 text-sm</code> — identical 44px minimum height</p>
67
+ </section>
68
+
69
+ <!-- Basic Single + Multi -->
70
+ <section>
71
+ <h2 class="text-xs font-semibold text-zinc-400 dark:text-zinc-500 uppercase tracking-wider mb-4">Basic</h2>
72
+ <div class="grid grid-cols-1 md:grid-cols-2 gap-8">
73
+ <div class="space-y-2">
74
+ <label class="block text-sm font-medium text-zinc-700 dark:text-zinc-300">Single Select</label>
75
+ <select id="basic-single" data-placeholder="Choose a fruit…">
76
+ <option value="">Choose a fruit…</option>
77
+ <option value="apple">Apple</option>
78
+ <option value="banana">Banana</option>
79
+ <option value="cherry">Cherry</option>
80
+ <option value="date">Date</option>
81
+ <option value="elderberry">Elderberry</option>
82
+ <option value="fig">Fig</option>
83
+ <option value="grape">Grape</option>
84
+ </select>
85
+ <p class="text-xs text-zinc-400">Click to search · Arrow keys to navigate</p>
86
+ </div>
87
+ <div class="space-y-2">
88
+ <label class="block text-sm font-medium text-zinc-700 dark:text-zinc-300">Multi Select</label>
89
+ <select id="basic-multi" multiple data-placeholder="Pick colors…">
90
+ <option value="red">Red</option>
91
+ <option value="orange">Orange</option>
92
+ <option value="yellow">Yellow</option>
93
+ <option value="green">Green</option>
94
+ <option value="blue">Blue</option>
95
+ <option value="indigo">Indigo</option>
96
+ <option value="violet">Violet</option>
97
+ </select>
98
+ <p class="text-xs text-zinc-400">Select or clear search matches · Live count · Selected colors leave the menu</p>
99
+ </div>
100
+ </div>
101
+ </section>
102
+
103
+ <!-- Details & Meta -->
104
+ <section>
105
+ <h2 class="text-xs font-semibold text-zinc-400 dark:text-zinc-500 uppercase tracking-wider mb-4">Details &amp; Meta</h2>
106
+ <div class="grid grid-cols-1 md:grid-cols-2 gap-8">
107
+ <div class="space-y-2">
108
+ <label class="block text-sm font-medium text-zinc-700 dark:text-zinc-300">Users</label>
109
+ <select id="detail-select" data-placeholder="Select a user…">
110
+ <option value="">Select a user…</option>
111
+ <option value="alice" data-detail="alice@example.com" data-meta="Admin">Alice Johnson</option>
112
+ <option value="bob" data-detail="bob@example.com" data-meta="Editor">Bob Smith</option>
113
+ <option value="carol" data-detail="carol@example.com" data-meta="Viewer">Carol White</option>
114
+ <option value="dave" data-detail="dave@example.com" data-meta="Admin">Dave Brown</option>
115
+ </select>
116
+ </div>
117
+ <div class="space-y-2">
118
+ <label class="block text-sm font-medium text-zinc-700 dark:text-zinc-300">Countries</label>
119
+ <select id="country-select" data-placeholder="Pick countries…">
120
+ <option value="us" data-detail="North America" data-meta="331M">United States</option>
121
+ <option value="uk" data-detail="Europe" data-meta="67M">United Kingdom</option>
122
+ <option value="jp" data-detail="Asia" data-meta="125M">Japan</option>
123
+ <option value="br" data-detail="South America" data-meta="214M">Brazil</option>
124
+ <option value="ng" data-detail="Africa" data-meta="211M">Nigeria</option>
125
+ <option value="in" data-detail="Asia" data-meta="1.4B">India</option>
126
+ </select>
127
+ </div>
128
+ </div>
129
+ </section>
130
+
131
+ <!-- States -->
132
+ <section>
133
+ <h2 class="text-xs font-semibold text-zinc-400 dark:text-zinc-500 uppercase tracking-wider mb-4">States</h2>
134
+ <div class="grid grid-cols-1 md:grid-cols-3 gap-8">
135
+ <div class="space-y-2">
136
+ <label class="block text-sm font-medium text-zinc-700 dark:text-zinc-300">Disabled</label>
137
+ <select id="disabled-select" disabled data-placeholder="Cannot change…">
138
+ <option value="locked" selected>Locked Value</option>
139
+ </select>
140
+ </div>
141
+ <div class="space-y-2">
142
+ <label class="block text-sm font-medium text-zinc-700 dark:text-zinc-300">Non-searchable</label>
143
+ <select id="no-search-select" data-placeholder="Pick one…">
144
+ <option value="">Pick one…</option>
145
+ <option value="a">Option A</option>
146
+ <option value="b">Option B</option>
147
+ <option value="c">Option C</option>
148
+ </select>
149
+ </div>
150
+ <div class="space-y-2">
151
+ <label class="block text-sm font-medium text-zinc-700 dark:text-zinc-300">Creatable</label>
152
+ <select id="creatable-select" data-placeholder="Type to create…">
153
+ <option value="react">React</option>
154
+ <option value="vue">Vue</option>
155
+ <option value="svelte">Svelte</option>
156
+ </select>
157
+ </div>
158
+ </div>
159
+ </section>
160
+
161
+ <!-- Grouped -->
162
+ <section>
163
+ <h2 class="text-xs font-semibold text-zinc-400 dark:text-zinc-500 uppercase tracking-wider mb-4">Grouped Options</h2>
164
+ <div class="grid grid-cols-1 md:grid-cols-2 gap-8">
165
+ <div class="space-y-2">
166
+ <label class="block text-sm font-medium text-zinc-700 dark:text-zinc-300">Frameworks</label>
167
+ <select id="grouped-select" data-placeholder="Select a framework…">
168
+ <option value="">Select a framework…</option>
169
+ <optgroup label="Frontend">
170
+ <option value="react">React</option>
171
+ <option value="vue">Vue</option>
172
+ <option value="angular">Angular</option>
173
+ <option value="svelte">Svelte</option>
174
+ </optgroup>
175
+ <optgroup label="Backend">
176
+ <option value="rails">Ruby on Rails</option>
177
+ <option value="django">Django</option>
178
+ <option value="laravel">Laravel</option>
179
+ <option value="spring">Spring Boot</option>
180
+ </optgroup>
181
+ <optgroup label="Full Stack">
182
+ <option value="next">Next.js</option>
183
+ <option value="nuxt">Nuxt</option>
184
+ </optgroup>
185
+ </select>
186
+ </div>
187
+ <div class="space-y-2">
188
+ <label class="block text-sm font-medium text-zinc-700 dark:text-zinc-300">Timezones</label>
189
+ <select id="tz-select" data-placeholder="Choose timezone…">
190
+ <option value="">Choose timezone…</option>
191
+ <optgroup label="Americas">
192
+ <option value="est">Eastern (UTC-5)</option>
193
+ <option value="cst">Central (UTC-6)</option>
194
+ <option value="mst">Mountain (UTC-7)</option>
195
+ <option value="pst">Pacific (UTC-8)</option>
196
+ </optgroup>
197
+ <optgroup label="Europe">
198
+ <option value="gmt">GMT (UTC+0)</option>
199
+ <option value="cet">CET (UTC+1)</option>
200
+ <option value="eet">EET (UTC+2)</option>
201
+ </optgroup>
202
+ <optgroup label="Asia">
203
+ <option value="ist">IST (UTC+5:30)</option>
204
+ <option value="jst">JST (UTC+9)</option>
205
+ </optgroup>
206
+ </select>
207
+ </div>
208
+ </div>
209
+ </section>
210
+
211
+ <!-- Remote / API Search -->
212
+ <section>
213
+ <h2 class="text-xs font-semibold text-zinc-400 dark:text-zinc-500 uppercase tracking-wider mb-4">Remote / API Search</h2>
214
+ <div class="grid grid-cols-1 md:grid-cols-3 gap-8">
215
+ <!-- GitHub Repos -->
216
+ <div class="space-y-2">
217
+ <label class="block text-sm font-medium text-zinc-700 dark:text-zinc-300">GitHub Repos <span class="text-zinc-400 font-normal">(real API)</span></label>
218
+ <select id="remote-github" data-placeholder="Search repos…"></select>
219
+ <p class="text-xs text-zinc-400">Type ≥ 2 chars · Debounced 300ms · processResults transforms response</p>
220
+ </div>
221
+ <!-- Custom Transport -->
222
+ <div class="space-y-2">
223
+ <label class="block text-sm font-medium text-zinc-700 dark:text-zinc-300">Custom Transport <span class="text-zinc-400 font-normal">(mock API)</span></label>
224
+ <select id="remote-transport" data-placeholder="Search users…"></select>
225
+ <p class="text-xs text-zinc-400">Custom fetch fn · Simulated 400ms delay · Min 1 char</p>
226
+ </div>
227
+ <!-- Paginated -->
228
+ <div class="space-y-2">
229
+ <label class="block text-sm font-medium text-zinc-700 dark:text-zinc-300">Paginated <span class="text-zinc-400 font-normal">(infinite scroll)</span></label>
230
+ <select id="remote-paginated" data-placeholder="Search countries…"></select>
231
+ <p class="text-xs text-zinc-400">Scroll to load more · cacheRemote enabled · Min 1 char</p>
232
+ </div>
233
+ </div>
234
+ <!-- Event Log -->
235
+ <div class="mt-4 rounded-lg border border-zinc-200 dark:border-zinc-800 bg-zinc-50 dark:bg-zinc-900/50 p-3">
236
+ <div class="flex items-center justify-between mb-2">
237
+ <span class="text-[11px] font-semibold uppercase tracking-wider text-zinc-400">Event Log</span>
238
+ <button id="clearLog" class="text-[11px] text-zinc-400 hover:text-zinc-600 dark:hover:text-zinc-300 transition">Clear</button>
239
+ </div>
240
+ <div id="eventLog" class="max-h-32 overflow-y-auto font-mono text-xs text-zinc-500 dark:text-zinc-400 space-y-0.5">
241
+ <div class="text-zinc-300 dark:text-zinc-600 italic">Events will appear here as you interact with the selects above…</div>
242
+ </div>
243
+ </div>
244
+ </section>
245
+
246
+ <!-- Animation Presets -->
247
+ <section>
248
+ <h2 class="text-xs font-semibold text-zinc-400 dark:text-zinc-500 uppercase tracking-wider mb-4">Animation Presets</h2>
249
+ <div class="grid grid-cols-2 md:grid-cols-5 gap-6">
250
+ <div class="space-y-2">
251
+ <label class="block text-sm font-medium text-zinc-700 dark:text-zinc-300">Material</label>
252
+ <select id="anim-material" data-placeholder="Try me…">
253
+ <option value="">Try me…</option>
254
+ <option value="a">Alpha</option><option value="b">Beta</option><option value="c">Gamma</option>
255
+ </select>
256
+ </div>
257
+ <div class="space-y-2">
258
+ <label class="block text-sm font-medium text-zinc-700 dark:text-zinc-300">Spring</label>
259
+ <select id="anim-spring" data-placeholder="Try me…">
260
+ <option value="">Try me…</option>
261
+ <option value="a">Alpha</option><option value="b">Beta</option><option value="c">Gamma</option>
262
+ </select>
263
+ </div>
264
+ <div class="space-y-2">
265
+ <label class="block text-sm font-medium text-zinc-700 dark:text-zinc-300">Snappy</label>
266
+ <select id="anim-snappy" data-placeholder="Try me…">
267
+ <option value="">Try me…</option>
268
+ <option value="a">Alpha</option><option value="b">Beta</option><option value="c">Gamma</option>
269
+ </select>
270
+ </div>
271
+ <div class="space-y-2">
272
+ <label class="block text-sm font-medium text-zinc-700 dark:text-zinc-300">Smooth</label>
273
+ <select id="anim-smooth" data-placeholder="Try me…">
274
+ <option value="">Try me…</option>
275
+ <option value="a">Alpha</option><option value="b">Beta</option><option value="c">Gamma</option>
276
+ </select>
277
+ </div>
278
+ <div class="space-y-2">
279
+ <label class="block text-sm font-medium text-zinc-700 dark:text-zinc-300">Bounce</label>
280
+ <select id="anim-bounce" data-placeholder="Try me…">
281
+ <option value="">Try me…</option>
282
+ <option value="a">Alpha</option><option value="b">Beta</option><option value="c">Gamma</option>
283
+ </select>
284
+ </div>
285
+ </div>
286
+ </section>
287
+
288
+ <!-- Select2 Theme -->
289
+ <section>
290
+ <h2 class="text-xs font-semibold text-zinc-400 dark:text-zinc-500 uppercase tracking-wider mb-4">Select2 Theme</h2>
291
+ <div class="grid grid-cols-1 md:grid-cols-3 gap-8">
292
+ <div class="space-y-2">
293
+ <label class="block text-sm font-medium text-zinc-700 dark:text-zinc-300">Single Select</label>
294
+ <select id="s2-single" data-placeholder="Choose a framework…">
295
+ <option value="">Choose a framework…</option>
296
+ <option value="react" data-detail="Meta · 200k+ stars" data-meta="FE">React</option>
297
+ <option value="vue" data-detail="Evan You · 205k+ stars" data-meta="FE">Vue</option>
298
+ <option value="angular" data-detail="Google · 93k+ stars" data-meta="FE">Angular</option>
299
+ <option value="svelte" data-detail="Rich Harris · 80k+ stars" data-meta="FE">Svelte</option>
300
+ <option value="next" data-detail="Vercel · 125k+ stars" data-meta="FS">Next.js</option>
301
+ <option value="nuxt" data-detail="NuxtLabs · 53k+ stars" data-meta="FS">Nuxt</option>
302
+ </select>
303
+ <p class="text-xs text-zinc-400">Gray border · blue hover fill · rounded-md</p>
304
+ </div>
305
+ <div class="space-y-2">
306
+ <label class="block text-sm font-medium text-zinc-700 dark:text-zinc-300">Multi Select</label>
307
+ <select id="s2-multi" multiple data-placeholder="Pick colors…">
308
+ <option value="red">Red</option>
309
+ <option value="orange">Orange</option>
310
+ <option value="yellow">Yellow</option>
311
+ <option value="green">Green</option>
312
+ <option value="blue">Blue</option>
313
+ <option value="indigo">Indigo</option>
314
+ <option value="violet">Violet</option>
315
+ </select>
316
+ <p class="text-xs text-zinc-400">Gray tags · bordered · gray background</p>
317
+ </div>
318
+ <div class="space-y-2">
319
+ <label class="block text-sm font-medium text-zinc-700 dark:text-zinc-300">With Details</label>
320
+ <select id="s2-detail" data-placeholder="Select a user…">
321
+ <option value="">Select a user…</option>
322
+ <option value="alice" data-detail="alice@example.com" data-meta="Admin">Alice Johnson</option>
323
+ <option value="bob" data-detail="bob@example.com" data-meta="Editor">Bob Smith</option>
324
+ <option value="carol" data-detail="carol@example.com" data-meta="Viewer">Carol White</option>
325
+ <option value="dave" data-detail="dave@example.com" data-meta="Admin">Dave Brown</option>
326
+ </select>
327
+ <p class="text-xs text-zinc-400">Sublabels + role badges</p>
328
+ </div>
329
+ </div>
330
+ <div class="mt-4 p-3 rounded-lg border border-zinc-200 dark:border-zinc-800 bg-zinc-50 dark:bg-zinc-900/50">
331
+ <p class="text-xs text-zinc-500 dark:text-zinc-400"><strong class="text-zinc-600 dark:text-zinc-300">Select2 theme</strong> — Gray palette, blue hover fill, gray bordered tags, compact proportions matching the default theme.</p>
332
+ </div>
333
+ </section>
334
+
335
+ <!-- Virtual Scroll -->
336
+ <section>
337
+ <h2 class="text-xs font-semibold text-zinc-400 dark:text-zinc-500 uppercase tracking-wider mb-4">Virtual Scroll</h2>
338
+ <div class="grid grid-cols-1 md:grid-cols-2 gap-8">
339
+ <div class="space-y-2">
340
+ <label class="block text-sm font-medium text-zinc-700 dark:text-zinc-300">1500 Items <span class="text-zinc-400 font-normal">(virtualized)</span></label>
341
+ <select id="virtual-1500" data-placeholder="Search 1,500 items…"></select>
342
+ <p class="text-xs text-zinc-400">Only visible DOM nodes rendered · smooth 60fps scroll · 32px row height</p>
343
+ </div>
344
+ <div class="space-y-2">
345
+ <label class="block text-sm font-medium text-zinc-700 dark:text-zinc-300">5000 Items <span class="text-zinc-400 font-normal">(large dataset)</span></label>
346
+ <select id="virtual-5000" multiple data-placeholder="Pick from 5,000…"></select>
347
+ <p class="text-xs text-zinc-400">Multi-select · virtualized · type to fuzzy-search the entire set</p>
348
+ </div>
349
+ </div>
350
+ <div class="mt-4 flex items-center gap-4">
351
+ <div id="virtualPerf" class="text-xs text-zinc-400 dark:text-zinc-500 font-mono"></div>
352
+ </div>
353
+ </section>
354
+
355
+ <!-- RTL Layout -->
356
+ <section dir="rtl">
357
+ <h2 class="text-xs font-semibold text-zinc-400 dark:text-zinc-500 uppercase tracking-wider mb-4">RTL Layout</h2>
358
+ <div class="grid grid-cols-1 md:grid-cols-3 gap-8">
359
+ <div class="space-y-2">
360
+ <label class="block text-sm font-medium text-zinc-700 dark:text-zinc-300">عربي <span class="text-zinc-400 font-normal">(Arabic)</span></label>
361
+ <select id="rtl-arabic" data-placeholder="اختر مدينة…"></select>
362
+ <p class="text-xs text-zinc-400 text-left">dir=rtl · arrows, chevron, tags flip correctly</p>
363
+ </div>
364
+ <div class="space-y-2">
365
+ <label class="block text-sm font-medium text-zinc-700 dark:text-zinc-300">עברית <span class="text-zinc-400 font-normal">(Hebrew multi)</span></label>
366
+ <select id="rtl-hebrew" multiple data-placeholder="בחר ערים…"></select>
367
+ <p class="text-xs text-zinc-400 text-left">RTL multi-select · tags flow right-to-left</p>
368
+ </div>
369
+ <div class="space-y-2">
370
+ <label class="block text-sm font-medium text-zinc-700 dark:text-zinc-300">Mixed <span class="text-zinc-400 font-normal">(auto-detect)</span></label>
371
+ <select id="rtl-auto" data-placeholder="Mix of directions…"></select>
372
+ <p class="text-xs text-zinc-400 text-left">English + Arabic labels · dir=auto</p>
373
+ </div>
374
+ </div>
375
+ </section>
376
+
377
+ <!-- Footer -->
378
+ <div class="border-t border-zinc-200 dark:border-zinc-800 pt-8 pb-6 text-center text-xs text-zinc-400 space-y-1">
379
+ <p>tam-select v1.3.0 · compact design refresh</p>
380
+ <p>Theme: <strong>default</strong> · toggle dark mode above</p>
381
+ <p>Remote demos use <a href="https://docs.github.com/en/rest" class="underline hover:text-zinc-600">GitHub API</a> and a mock transport</p>
382
+ </div>
383
+
384
+ </div>
385
+
386
+ <script type="module">
387
+ import { TamSelect } from './tam-select.bundle.js'
388
+
389
+ const instances = []
390
+
391
+ function mount(theme) {
392
+ // Destroy existing
393
+ instances.forEach(i => i.destroy())
394
+ instances.length = 0
395
+
396
+ const opts = { theme }
397
+ const singleOpts = { ...opts }
398
+ const multiOpts = { ...opts }
399
+ const searchOff = { ...opts, searchable: false }
400
+ const creatable = { ...opts, creatable: true }
401
+
402
+ instances.push(new TamSelect(document.getElementById('basic-single'), singleOpts))
403
+ instances.push(new TamSelect(document.getElementById('basic-multi'), {
404
+ ...multiOpts, bulkActions: true, showSelectionCount: true, hideSelected: true, maximumSelectionLength: 4
405
+ }))
406
+ instances.push(new TamSelect(document.getElementById('detail-select'), singleOpts))
407
+ instances.push(new TamSelect(document.getElementById('country-select'), multiOpts))
408
+ instances.push(new TamSelect(document.getElementById('disabled-select'), singleOpts))
409
+ instances.push(new TamSelect(document.getElementById('no-search-select'), searchOff))
410
+ instances.push(new TamSelect(document.getElementById('creatable-select'), creatable))
411
+ instances.push(new TamSelect(document.getElementById('grouped-select'), singleOpts))
412
+ instances.push(new TamSelect(document.getElementById('tz-select'), singleOpts))
413
+
414
+ // Animation presets
415
+ instances.push(new TamSelect(document.getElementById('anim-material'), { ...opts, animationPreset: 'material' }))
416
+ instances.push(new TamSelect(document.getElementById('anim-spring'), { ...opts, animationPreset: 'spring' }))
417
+ instances.push(new TamSelect(document.getElementById('anim-snappy'), { ...opts, animationPreset: 'snappy' }))
418
+ instances.push(new TamSelect(document.getElementById('anim-smooth'), { ...opts, animationPreset: 'smooth' }))
419
+ instances.push(new TamSelect(document.getElementById('anim-bounce'), { ...opts, animationPreset: 'bounce' }))
420
+
421
+ // Height comparison
422
+ const cmpSelect = document.getElementById('height-cmp')
423
+ if (cmpSelect) {
424
+ const opt1 = new Option('Choose one…', '')
425
+ const opt2 = new Option('Option A', 'a')
426
+ const opt3 = new Option('Option B', 'b')
427
+ cmpSelect.add(opt1)
428
+ cmpSelect.add(opt2)
429
+ cmpSelect.add(opt3)
430
+ instances.push(new TamSelect(cmpSelect, { ...opts, searchable: false }))
431
+ }
432
+ }
433
+
434
+ mount('default')
435
+
436
+ // ─── Select2 theme demos (always use select2 theme) ──────
437
+ const s2Single = new TamSelect(document.getElementById('s2-single'), { theme: 'select2' })
438
+ s2Single.on('tam-select:select', (e) => log(`Select2: selected ${e.detail.item.label}`))
439
+ instances.push(s2Single)
440
+ instances.push(new TamSelect(document.getElementById('s2-multi'), { theme: 'select2', closeAfterSelect: false }))
441
+ instances.push(new TamSelect(document.getElementById('s2-detail'), { theme: 'select2' }))
442
+
443
+ // ─── Remote search demos (independent of theme) ───────────
444
+ const logEl = document.getElementById('eventLog')
445
+ const log = (msg) => {
446
+ const line = document.createElement('div')
447
+ line.textContent = `${new Date().toLocaleTimeString()} ${msg}`
448
+ if (logEl.querySelector('.italic')) logEl.replaceChildren()
449
+ logEl.prepend(line)
450
+ if (logEl.children.length > 50) logEl.lastChild.remove()
451
+ }
452
+ document.getElementById('clearLog').addEventListener('click', () => {
453
+ logEl.innerHTML = '<div class="text-zinc-300 dark:text-zinc-600 italic">Cleared.</div>'
454
+ })
455
+
456
+ // 1) GitHub Repos — real API with processResults
457
+ const githubSelect = new TamSelect(document.getElementById('remote-github'), {
458
+ placeholder: 'Search GitHub repos…',
459
+ minQueryLength: 2,
460
+ debounce: 300,
461
+ clearable: true,
462
+ remoteUrl: 'https://api.github.com/search/repositories',
463
+ queryParam: 'q',
464
+ pageParam: 'page',
465
+ processResults: (data) => {
466
+ const items = (data.items || []).slice(0, 15).map(repo => ({
467
+ value: repo.full_name,
468
+ label: repo.name,
469
+ detail: repo.description || 'No description',
470
+ meta: `⭐ ${(repo.stargazers_count || 0).toLocaleString()}`,
471
+ image: repo.owner?.avatar_url || null
472
+ }))
473
+ return { items, pagination: { has_more: data.total_count > items.length } }
474
+ },
475
+ headers: { 'Accept': 'application/vnd.github.v3+json' }
476
+ })
477
+ githubSelect.on('tam-select:load', (e) => log(`GitHub: loaded ${e.detail.items.length} repos`))
478
+ githubSelect.on('tam-select:select', (e) => log(`GitHub: selected ${e.detail.item.label}`))
479
+ githubSelect.on('tam-select:error', (e) => log(`GitHub: error — ${e.detail.error}`))
480
+ instances.push(githubSelect)
481
+
482
+ // 2) Custom Transport — mock API with simulated delay
483
+ const MOCK_USERS = [
484
+ { value: '1', label: 'Alice Johnson', detail: 'alice@example.com', meta: 'Admin', image: 'https://i.pravatar.cc/80?u=1' },
485
+ { value: '2', label: 'Bob Smith', detail: 'bob@example.com', meta: 'Editor', image: 'https://i.pravatar.cc/80?u=2' },
486
+ { value: '3', label: 'Carol White', detail: 'carol@example.com', meta: 'Viewer', image: 'https://i.pravatar.cc/80?u=3' },
487
+ { value: '4', label: 'Dave Brown', detail: 'dave@example.com', meta: 'Admin', image: 'https://i.pravatar.cc/80?u=4' },
488
+ { value: '5', label: 'Eva Martinez', detail: 'eva@example.com', meta: 'Editor', image: 'https://i.pravatar.cc/80?u=5' },
489
+ { value: '6', label: 'Frank Lee', detail: 'frank@example.com', meta: 'Viewer', image: 'https://i.pravatar.cc/80?u=6' },
490
+ { value: '7', label: 'Grace Kim', detail: 'grace@example.com', meta: 'Admin', image: 'https://i.pravatar.cc/80?u=7' },
491
+ { value: '8', label: 'Hiro Tanaka', detail: 'hiro@example.com', meta: 'Editor', image: 'https://i.pravatar.cc/80?u=8' },
492
+ { value: '9', label: 'Iris Chen', detail: 'iris@example.com', meta: 'Viewer', image: 'https://i.pravatar.cc/80?u=9' },
493
+ { value: '10', label: 'Jake Wilson', detail: 'jake@example.com', meta: 'Admin', image: 'https://i.pravatar.cc/80?u=10' },
494
+ { value: '11', label: 'Karen Davis', detail: 'karen@example.com', meta: 'Editor', image: 'https://i.pravatar.cc/80?u=11' },
495
+ { value: '12', label: 'Leo Garcia', detail: 'leo@example.com', meta: 'Viewer', image: 'https://i.pravatar.cc/80?u=12' }
496
+ ]
497
+ const transportSelect = new TamSelect(document.getElementById('remote-transport'), {
498
+ placeholder: 'Search users…',
499
+ minQueryLength: 1,
500
+ debounce: 250,
501
+ clearable: true,
502
+ processResults: (data) => ({ items: data.items, pagination: {} }),
503
+ transport: async ({ url, query, signal }) => {
504
+ log(`Transport: fetching "${query}"…`)
505
+ await new Promise(r => setTimeout(r, 400))
506
+ const q = query.toLowerCase()
507
+ const items = MOCK_USERS.filter(u =>
508
+ u.label.toLowerCase().includes(q) || u.detail.toLowerCase().includes(q)
509
+ ).map(u => ({ ...u }))
510
+ log(`Transport: found ${items.length} results for "${query}"`)
511
+ return { items }
512
+ }
513
+ })
514
+ transportSelect.on('tam-select:select', (e) => log(`Transport: selected ${e.detail.item.label}`))
515
+ instances.push(transportSelect)
516
+
517
+ // 3) Paginated — infinite scroll with cacheRemote
518
+ const MOCK_COUNTRIES = [
519
+ { value: 'af', label: 'Afghanistan', detail: 'Asia', meta: '38.9M' },
520
+ { value: 'al', label: 'Albania', detail: 'Europe', meta: '2.9M' },
521
+ { value: 'dz', label: 'Algeria', detail: 'Africa', meta: '44.6M' },
522
+ { value: 'ar', label: 'Argentina', detail: 'South America', meta: '45.8M' },
523
+ { value: 'au', label: 'Australia', detail: 'Oceania', meta: '25.7M' },
524
+ { value: 'at', label: 'Austria', detail: 'Europe', meta: '9.1M' },
525
+ { value: 'bd', label: 'Bangladesh', detail: 'Asia', meta: '166.3M' },
526
+ { value: 'be', label: 'Belgium', detail: 'Europe', meta: '11.6M' },
527
+ { value: 'br', label: 'Brazil', detail: 'South America', meta: '214.0M' },
528
+ { value: 'bg', label: 'Bulgaria', detail: 'Europe', meta: '6.8M' },
529
+ { value: 'ca', label: 'Canada', detail: 'North America', meta: '38.2M' },
530
+ { value: 'cl', label: 'Chile', detail: 'South America', meta: '19.5M' },
531
+ { value: 'cn', label: 'China', detail: 'Asia', meta: '1.4B' },
532
+ { value: 'co', label: 'Colombia', detail: 'South America', meta: '51.3M' },
533
+ { value: 'hr', label: 'Croatia', detail: 'Europe', meta: '4.0M' },
534
+ { value: 'cz', label: 'Czech Republic', detail: 'Europe', meta: '10.7M' },
535
+ { value: 'dk', label: 'Denmark', detail: 'Europe', meta: '5.9M' },
536
+ { value: 'eg', label: 'Egypt', detail: 'Africa', meta: '104.3M' },
537
+ { value: 'fi', label: 'Finland', detail: 'Europe', meta: '5.5M' },
538
+ { value: 'fr', label: 'France', detail: 'Europe', meta: '67.4M' },
539
+ { value: 'de', label: 'Germany', detail: 'Europe', meta: '83.2M' },
540
+ { value: 'gr', label: 'Greece', detail: 'Europe', meta: '10.4M' },
541
+ { value: 'in', label: 'India', detail: 'Asia', meta: '1.4B' },
542
+ { value: 'id', label: 'Indonesia', detail: 'Asia', meta: '275.5M' },
543
+ { value: 'ie', label: 'Ireland', detail: 'Europe', meta: '5.1M' },
544
+ { value: 'il', label: 'Israel', detail: 'Asia', meta: '9.4M' },
545
+ { value: 'it', label: 'Italy', detail: 'Europe', meta: '59.1M' },
546
+ { value: 'jp', label: 'Japan', detail: 'Asia', meta: '125.7M' },
547
+ { value: 'ke', label: 'Kenya', detail: 'Africa', meta: '54.0M' },
548
+ { value: 'kr', label: 'South Korea', detail: 'Asia', meta: '51.7M' },
549
+ { value: 'mx', label: 'Mexico', detail: 'North America', meta: '128.9M' },
550
+ { value: 'nl', label: 'Netherlands', detail: 'Europe', meta: '17.5M' },
551
+ { value: 'ng', label: 'Nigeria', detail: 'Africa', meta: '211.4M' },
552
+ { value: 'no', label: 'Norway', detail: 'Europe', meta: '5.4M' },
553
+ { value: 'pk', label: 'Pakistan', detail: 'Asia', meta: '225.2M' },
554
+ { value: 'pe', label: 'Peru', detail: 'South America', meta: '33.4M' },
555
+ { value: 'pl', label: 'Poland', detail: 'Europe', meta: '37.7M' },
556
+ { value: 'pt', label: 'Portugal', detail: 'Europe', meta: '10.3M' },
557
+ { value: 'ro', label: 'Romania', detail: 'Europe', meta: '19.0M' },
558
+ { value: 'ru', label: 'Russia', detail: 'Europe', meta: '144.1M' },
559
+ { value: 'sa', label: 'Saudi Arabia', detail: 'Asia', meta: '35.0M' },
560
+ { value: 'za', label: 'South Africa', detail: 'Africa', meta: '60.0M' },
561
+ { value: 'es', label: 'Spain', detail: 'Europe', meta: '47.4M' },
562
+ { value: 'se', label: 'Sweden', detail: 'Europe', meta: '10.4M' },
563
+ { value: 'ch', label: 'Switzerland', detail: 'Europe', meta: '8.7M' },
564
+ { value: 'tr', label: 'Turkey', detail: 'Europe', meta: '85.0M' },
565
+ { value: 'ua', label: 'Ukraine', detail: 'Europe', meta: '43.5M' },
566
+ { value: 'ae', label: 'United Arab Emirates', detail: 'Asia', meta: '10.0M' },
567
+ { value: 'gb', label: 'United Kingdom', detail: 'Europe', meta: '67.3M' },
568
+ { value: 'us', label: 'United States', detail: 'North America', meta: '331.9M' },
569
+ { value: 'vn', label: 'Vietnam', detail: 'Asia', meta: '97.3M' }
570
+ ]
571
+ const PAGE_SIZE = 10
572
+ const paginatedSelect = new TamSelect(document.getElementById('remote-paginated'), {
573
+ placeholder: 'Search countries…',
574
+ minQueryLength: 1,
575
+ debounce: 200,
576
+ clearable: true,
577
+ cacheRemote: true,
578
+ processResults: (data, { page }) => {
579
+ const start = (page - 1) * PAGE_SIZE
580
+ const items = data.items.slice(start, start + PAGE_SIZE)
581
+ return {
582
+ items,
583
+ pagination: { has_more: start + PAGE_SIZE < data.items.length, next_page: page + 1 }
584
+ }
585
+ },
586
+ transport: async ({ query }) => {
587
+ await new Promise(r => setTimeout(r, 250))
588
+ const q = query.toLowerCase()
589
+ return { items: MOCK_COUNTRIES.filter(c => c.label.toLowerCase().includes(q) || c.detail.toLowerCase().includes(q)) }
590
+ }
591
+ })
592
+ paginatedSelect.on('tam-select:load', (e) => log(`Paginated: loaded page of ${e.detail.items.length} countries`))
593
+ paginatedSelect.on('tam-select:select', (e) => log(`Paginated: selected ${e.detail.item.label}`))
594
+ instances.push(paginatedSelect)
595
+
596
+ // ─── Virtual scroll demos ─────────────────────────────────
597
+ // Generate 1,500 items with realistic labels
598
+ const adjectives = ['Alpha','Brave','Calm','Dark','Eager','Fair','Grand','Happy','Icy','Keen','Loud','Mild','Noble','Old','Prime','Quick','Red','Sharp','True','Ultra','Vast','Warm','Young','Bold','Crisp','Deep','Free','Gold','High','Iron','Jade','Lime','Mesa','Neon','Onyx','Pearl','Ruby','Sage','Tidal','Ursa','Vivid','Wren','Xeno','Azure','Coral','Drift','Flint','Glacier','Haven','Indigo','Jasper','Krypton','Lunar','Mango','Nebula','Opal','Phoenix','Quartz','Ripple','Sierra','Topaz','Umber','Vapor','Willow','Zephyr','Aether','Breeze','Cobalt','Dusk','Echo','Fable','Glade','Haze','Ivory','Juniper','Kelp','Lichen','Mirth','Nimbus','Orbit','Pebble','Reed','Solace','Thorn','Unity','Verdant','Wander','Xylem','Yarrow','Zinnia']
599
+ const nouns = ['Falcon','Tiger','Dragon','Phoenix','Wolf','Bear','Eagle','Panther','Hawk','Lynx','Crane','Orca','Viper','Fox','Raven','Lion','Cobra','Stallion','Dolphin','Jaguar','Mantis','Falcon','Osprey','Badger','Cheetah','Coyote','Python','Robin','Sable','Otter','Panda','Gecko','Ibis','Pike','Swift','Wren','Dove','Heron','Marten','Finch','Raven','Crane','Swift','Tern','Moose','Elk','Ram','Puma','Sloth','Toucan','Wombat','Quail','Koala','Chinchilla','Pangolin','Platypus','Sugar Glider','Fennec','Jerboa','Chameleon','Axolotl','Tarantula','Mantis Shrimp','Narwhal','Beluga','Manatee','Dugong','Seahorse','Starfish','Nautilus','Jellyfish','Coral','Anemone','Urchin','Clam','Oyster','Scallop','Mussel','Limpet','Winkle','Cockle','Prawn','Shrimp','Lobster','Crab','Crayfish','Barnacle','Sponge','Worm','Slug','Snail','Leech']
600
+ const categories = ['Mountain','River','Forest','Desert','Ocean','Island','Valley','Canyon','Glacier','Volcano','Lake','Meadow','Prairie','Swamp','Tundra','Cavern','Lagoon','Fjord','Steppe','Savanna','Rainforest','Jungle','Wetland','Plateau','Ridge','Cliff','Gorge','Basin','Spring','Delta','Strait','Bay','Gulf','Cove','Inlet','Sound','Fjord','Atoll','Reef','Shoal','Sandbar','Dune','Oasis','Geyser','Spring','Falls','Rapids','Ridge','Bluff','Butte','Mesa','Knoll','Hill','Peak','Pinnacle','Spire','Tower','Summit','Crest','Crown','Apex','Zenith','Pole','Axis','Core','Nexus','Hub','Node','Link','Edge','Rim','Brink','Verge','Margin','Border','Frontier','Boundary','Threshold','Gateway','Portal','Doorway','Arch','Gate','Bridge','Path','Trail','Road','Way','Route','Course','Track','Lane','Alley','Boulevard','Square','Circle','Loop','Ring','Arc','Spiral','Helix','Wave','Pulse','Beat','Rhythm','Tempo','Cadence','Flow','Drift','Sway','Roll','Toss','Sweep','Glide','Slide','Sail','Fly','Soar','Rise','Lift','Float','Hover']
601
+ const makeItems = (count, elementId) => {
602
+ const select = document.getElementById(elementId)
603
+ for (let i = 0; i < count; i++) {
604
+ const adj = adjectives[i % adjectives.length]
605
+ const noun = nouns[i % nouns.length]
606
+ const cat = categories[Math.floor(i / (adjectives.length * nouns.length)) % categories.length]
607
+ const num = Math.floor(i / (adjectives.length * nouns.length * categories.length))
608
+ const label = num > 0 ? `${adj} ${noun} ${num}` : `${adj} ${noun}`
609
+ const detail = `${cat} · #${String(i + 1).padStart(4, '0')}`
610
+ const meta = i % 7 === 0 ? 'Featured' : i % 13 === 0 ? 'New' : null
611
+ const option = new Option(label, `item-${i}`)
612
+ if (detail) option.dataset.detail = detail
613
+ if (meta) option.dataset.meta = meta
614
+ select.add(option)
615
+ }
616
+ }
617
+ makeItems(1500, 'virtual-1500')
618
+ makeItems(5000, 'virtual-5000')
619
+
620
+ const virtualPerf = document.getElementById('virtualPerf')
621
+
622
+ // 1500 single-select with virtual scroll
623
+ const t0a = performance.now()
624
+ const virtual1500 = new TamSelect(document.getElementById('virtual-1500'), {
625
+ placeholder: 'Search 1,500 items…',
626
+ virtualScroll: true,
627
+ virtualItemHeight: 32,
628
+ virtualScrollBuffer: 5,
629
+ clearable: true,
630
+ cacheRemote: false,
631
+ debounce: 100
632
+ })
633
+ const t1a = performance.now()
634
+ virtual1500.on('tam-select:select', (e) => log(`Virtual 1.5k: selected ${e.detail.item.label}`))
635
+ virtual1500.on('tam-select:open', () => log(`Virtual 1.5k: opened — DOM nodes in listbox: ${virtual1500.results.children.length}`))
636
+ virtual1500.on('tam-select:close', () => log(`Virtual 1.5k: closed`))
637
+ instances.push(virtual1500)
638
+
639
+ // 5000 multi-select with virtual scroll
640
+ const t0b = performance.now()
641
+ const virtual5000 = new TamSelect(document.getElementById('virtual-5000'), {
642
+ placeholder: 'Pick from 5,000…',
643
+ virtualScroll: true,
644
+ virtualItemHeight: 32,
645
+ virtualScrollBuffer: 5,
646
+ clearable: true,
647
+ debounce: 100,
648
+ closeAfterSelect: false
649
+ })
650
+ const t1b = performance.now()
651
+ virtual5000.on('tam-select:select', (e) => log(`Virtual 5k: selected ${e.detail.item.label}`))
652
+ virtual5000.on('tam-select:open', () => log(`Virtual 5k: opened — DOM nodes: ${virtual5000.results.children.length}`))
653
+ instances.push(virtual5000)
654
+
655
+ // Show init perf
656
+ const ms = (t1a - t0a + t1b - t0b).toFixed(1)
657
+ virtualPerf.textContent = `Initialized 6,500 options in ${ms}ms` +
658
+ ` · 1.5k items in ${(t1a - t0a).toFixed(1)}ms` +
659
+ ` · 5k items in ${(t1b - t0b).toFixed(1)}ms`
660
+
661
+ // ─── RTL demos ────────────────────────────────────────────
662
+ const addOption = (selectId, value, label, detail, meta) => {
663
+ const select = document.getElementById(selectId)
664
+ const opt = new Option(label, value)
665
+ if (detail) opt.dataset.detail = detail
666
+ if (meta) opt.dataset.meta = meta
667
+ select.add(opt)
668
+ }
669
+
670
+ // Arabic cities
671
+ addOption('rtl-arabic', 'riyadh', 'الرياض', 'العاصمة', '7.5M')
672
+ addOption('rtl-arabic', 'jeddah', 'جدة', 'ميناء الحجاز', '4.6M')
673
+ addOption('rtl-arabic', 'mecca', 'مكة المكرمة', 'مدينة مقدسة', '2.0M')
674
+ addOption('rtl-arabic', 'medina', 'المدينة المنورة', 'مدينة النبي', '1.5M')
675
+ addOption('rtl-arabic', 'dammam', 'الدمام', 'المنطقة الشرقية', '1.3M')
676
+ addOption('rtl-arabic', 'tabuk', 'تبوك', 'شمال المملكة', '0.6M')
677
+ addOption('rtl-arabic', 'abha', 'أبها', 'منطقة عسير', '0.4M')
678
+ addOption('rtl-arabic', 'khobar', 'الخبر', 'المنطقة الشرقية', '0.4M')
679
+ addOption('rtl-arabic', 'buraidah', 'بريدة', 'منطقة القصيم', '0.6M')
680
+ addOption('rtl-arabic', 'hail', 'حائل', 'منطقة حائل', '0.4M')
681
+
682
+ const rtlArabic = new TamSelect(document.getElementById('rtl-arabic'), {
683
+ dir: 'rtl',
684
+ placeholder: 'اختر مدينة…',
685
+ clearable: true
686
+ })
687
+ rtlArabic.on('tam-select:select', (e) => log(`RTL Arabic: ${e.detail.item.label}`))
688
+ instances.push(rtlArabic)
689
+
690
+ // Hebrew cities
691
+ addOption('rtl-hebrew', 'jerusalem', 'ירושלים', 'בירת ישראל', '980K')
692
+ addOption('rtl-hebrew', 'tel-aviv', 'תל אביב', 'עיר ללא הפסקה', '460K')
693
+ addOption('rtl-hebrew', 'haifa', 'חיפה', 'עיר הכרמל', '285K')
694
+ addOption('rtl-hebrew', 'beer-sheva', 'באר שבע', 'בירת הנגב', '210K')
695
+ addOption('rtl-hebrew', 'netanya', 'נתניה', 'שרון צפוני', '220K')
696
+ addOption('rtl-hebrew', 'rishon-lezion', 'ראשון לציון', 'שפלה', '260K')
697
+ addOption('rtl-hebrew', 'petah-tikva', 'פתח תקווה', 'אם המושבות', '250K')
698
+ addOption('rtl-hebrew', 'ashdod', 'אשדוד', 'דרום', '225K')
699
+ addOption('rtl-hebrew', 'eilat', 'אילת', 'דרום הנגב', '52K')
700
+ addOption('rtl-hebrew', 'nazareth', 'נצרת', 'גליל תחתון', '77K')
701
+
702
+ const rtlHebrew = new TamSelect(document.getElementById('rtl-hebrew'), {
703
+ dir: 'rtl',
704
+ placeholder: 'בחר ערים…',
705
+ clearable: true,
706
+ closeAfterSelect: false
707
+ })
708
+ rtlHebrew.on('tam-select:select', (e) => log(`RTL Hebrew: ${e.detail.item.label}`))
709
+ instances.push(rtlHebrew)
710
+
711
+ // Mixed direction (auto-detect)
712
+ addOption('rtl-auto', 'en-1', 'Hello World', 'English greeting', 'EN')
713
+ addOption('rtl-auto', 'ar-1', 'مرحبا بالعالم', 'تحية عربية', 'AR')
714
+ addOption('rtl-auto', 'en-2', 'Good Morning', 'English morning', 'EN')
715
+ addOption('rtl-auto', 'ar-2', 'صباح الخير', 'تحية صباحية', 'AR')
716
+ addOption('rtl-auto', 'en-3', 'Thank You', 'English gratitude', 'EN')
717
+ addOption('rtl-auto', 'ar-3', 'شكراً جزيلاً', 'امتنان عربي', 'AR')
718
+ addOption('rtl-auto', 'en-4', 'How are you?', 'English question', 'EN')
719
+ addOption('rtl-auto', 'ar-4', 'كيف حالك؟', 'سؤال عربي', 'AR')
720
+ addOption('rtl-auto', 'en-5', 'See You Later', 'English farewell', 'EN')
721
+ addOption('rtl-auto', 'ar-5', 'مع السلامة', 'وداع عربي', 'AR')
722
+
723
+ const rtlAuto = new TamSelect(document.getElementById('rtl-auto'), {
724
+ dir: 'auto',
725
+ placeholder: 'Mix of directions…',
726
+ clearable: true
727
+ })
728
+ rtlAuto.on('tam-select:select', (e) => log(`RTL Auto: ${e.detail.item.label}`))
729
+ instances.push(rtlAuto)
730
+
731
+ // Dark mode toggle
732
+ const toggle = document.getElementById('themeToggle')
733
+ const icon = document.getElementById('themeIcon')
734
+ toggle.addEventListener('click', () => {
735
+ document.documentElement.classList.toggle('dark')
736
+ icon.textContent = document.documentElement.classList.contains('dark') ? '☀️' : '🌙'
737
+ })
738
+ </script>
739
+ </body>
740
+ </html>