@smilodon/vanilla 1.9.3 → 1.10.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.
package/COMPLETE-GUIDE.md CHANGED
@@ -1,9 +1,13 @@
1
1
  # @smilodon/vanilla - Complete Guide
2
2
 
3
- **Production-ready, accessible Select component for Vanilla JavaScript applications**
3
+ **Vanilla JavaScript select component guide**
4
4
 
5
5
  This guide provides comprehensive documentation for using Smilodon Select with Vanilla JavaScript (no framework), covering all features, styling options, and advanced use cases.
6
6
 
7
+ > Capability caveat: the public `virtualized` option enables chunked rendering for large flat lists, not viewport-windowed virtualization. Older examples below that say “only visible rows” or imply bounded DOM are not current release guarantees. See [Known Limitations](../../docs/KNOWN-LIMITATIONS.md#viewport-virtualization-status).
8
+ >
9
+ > Compatibility note: this long-form guide contains examples from the legacy `NativeSelect` API and is not a reliable current API inventory. For the maintained `EnhancedSelect` and `@smilodon/vanilla` helper signatures, follow the [API reference](../../docs/API-REFERENCE.md) and exported TypeScript declarations. Accessibility verification and manual assistive-technology assessment remain pending; this is not a WCAG conformance statement.
10
+
7
11
  ---
8
12
 
9
13
  ## Table of Contents
@@ -139,30 +143,21 @@ select.addEventListener('change', (event) => {
139
143
  ### Properties
140
144
 
141
145
  ```javascript
142
- // Get/Set items
143
- select.items = [{ value: '1', label: 'Option 1' }];
144
- console.log(select.items); // Array of items
145
-
146
- // Get/Set value
147
- select.value = 'apple';
148
- console.log(select.value); // 'apple'
149
-
150
- // Get/Set multiple values (multi-select)
151
- select.selectedValues = ['apple', 'banana'];
152
- console.log(select.selectedValues); // ['apple', 'banana']
153
-
154
- // Behavior properties
155
- select.multiple = true; // Enable multi-select
156
- select.searchable = true; // Enable search (default: true)
157
- select.disabled = false; // Disable select
158
- select.placeholder = 'Select...'; // Placeholder text
159
-
160
- // Display properties
161
- select.maxHeight = 300; // Max dropdown height (px)
162
- select.estimatedItemHeight = 48; // Item height for virtualization
146
+ // Current helper API
147
+ import { createSelect } from '@smilodon/vanilla';
148
+
149
+ const select = createSelect({
150
+ items: [{ value: '1', label: 'Option 1' }],
151
+ multiple: true,
152
+ searchable: true,
153
+ virtualized: true, // Incremental chunk rendering; not viewport windowing
154
+ });
155
+ document.body.append(select);
163
156
 
164
- // Advanced properties
165
- select.virtualization = true; // Enable virtual scrolling (default: true)
157
+ // Current EnhancedSelect imperative API
158
+ select.setSelectedValues(['1']);
159
+ console.log(select.getSelectedValues());
160
+ select.updateConfig({ virtualize: true });
166
161
  ```
167
162
 
168
163
  ### Methods
@@ -889,7 +884,8 @@ enhanced-select {
889
884
 
890
885
  select.items = users;
891
886
  select.placeholder = 'Select a user';
892
- select.estimatedItemHeight = 60;
887
+ // estimatedItemHeight only configures the guarded viewport-window test path.
888
+ select.updateConfig({ estimatedItemHeight: 60 });
893
889
 
894
890
  // Set custom renderer
895
891
  select.optionTemplate = (item) => `
@@ -929,8 +925,7 @@ enhanced-select {
929
925
  }));
930
926
 
931
927
  select.items = items;
932
- select.virtualization = true;
933
- select.estimatedItemHeight = 48;
928
+ select.updateConfig({ virtualize: true }); // Incremental chunks, not viewport windowing
934
929
  select.searchable = true;
935
930
  select.placeholder = 'Search 100k items...';
936
931
  </script>
@@ -1036,7 +1031,7 @@ enhanced-select {
1036
1031
 
1037
1032
  ## Accessibility
1038
1033
 
1039
- Smilodon is WCAG 2.1 AAA compliant with full keyboard support:
1034
+ Smilodon implements selected keyboard and ARIA behavior. Pinned cross-browser verification and manual assistive-technology assessment remain pending; this is not a WCAG conformance claim.
1040
1035
 
1041
1036
  ### Keyboard Navigation
1042
1037
 
@@ -1053,7 +1048,7 @@ The component automatically includes:
1053
1048
  - `role="combobox"`
1054
1049
  - `aria-expanded`
1055
1050
  - `aria-haspopup`
1056
- - `aria-label` / `aria-labelledby`
1051
+ - `aria-label` / `aria-description` (literal host attributes are forwarded)
1057
1052
  - `aria-activedescendant`
1058
1053
  - `aria-multiselectable` (when `multiple`)
1059
1054
 
@@ -1062,7 +1057,7 @@ The component automatically includes:
1062
1057
  ```html
1063
1058
  <label id="country-label">Country</label>
1064
1059
  <enhanced-select
1065
- aria-labelledby="country-label"
1060
+ aria-label="Country"
1066
1061
  placeholder="Select your country"
1067
1062
  ></enhanced-select>
1068
1063
  ```
@@ -1221,13 +1216,12 @@ select.selectedValues = ['apple', 'banana'];
1221
1216
 
1222
1217
  If you experience slow rendering with large datasets:
1223
1218
 
1224
- 1. Enable virtualization (enabled by default)
1225
- 2. Increase `estimatedItemHeight` if items are taller than 48px
1219
+ 1. `virtualize` enables incremental chunk rendering; it does not bound mounted DOM.
1220
+ 2. Use host-controlled paging if the full result set should not be loaded at once.
1226
1221
  3. Use debouncing for search events
1227
1222
 
1228
1223
  ```javascript
1229
- select.virtualization = true;
1230
- select.estimatedItemHeight = 60;
1224
+ select.updateConfig({ virtualize: true });
1231
1225
 
1232
1226
  // Debounce search
1233
1227
  let searchTimeout;
package/README.md CHANGED
@@ -2,12 +2,22 @@
2
2
 
3
3
  Vanilla JavaScript/TypeScript helpers for Smilodon Select. Part of the [Smilodon](https://github.com/navidrezadoost/smilodon) UI toolkit.
4
4
 
5
+ > Large-list status: the helper's public `virtualized` option maps to legacy chunked rendering for large flat lists; it does not window rows to the viewport. True viewport virtualization remains guarded by a private test seam and is not a supported production mode. See the [current limitation record](../../docs/KNOWN-LIMITATIONS.md#viewport-virtualization-status).
6
+
7
+ > Current API: use the [API reference](../../docs/API-REFERENCE.md) and the package's exported TypeScript declarations. The long-form guide below contains legacy `NativeSelect` examples and is not a current API inventory.
8
+ >
9
+ > **Registration prerequisite:** import `@smilodon/core` before calling `createSelect()` or `initSelect()`. The Vanilla helper creates an `enhanced-select` element and immediately calls its imperative methods; it does not wait for custom-element registration/upgrade. For an existing host, await `customElements.whenDefined('enhanced-select')` before `initSelect()`.
10
+
11
+ ## Acknowledged data-loading adapter status
12
+
13
+ The Phase 2F-D development candidate currently integrates acknowledged data loading through the core API and React adapter only. The `@smilodon/vanilla` helper does not publish a typed helper contract for request identity, completion, cancellation, and projection lifecycle. Passing `dataLoading` through casts or relying on the underlying element is undocumented and unsupported through these helpers. Vanilla adapter parity remains a separate, pending work package; the legacy helper API remains supported.
14
+
5
15
  ## Features
6
16
 
7
17
  - ✨ **Simple API** - Easy-to-use helper functions for vanilla JS
8
18
  - 🔍 **Zero Dependencies** - Only requires @smilodon/core
9
- - ♿ **Fully Accessible** - WCAG 2.1 AAA compliant
10
- - ⚡ **Tiny Bundle** - < 1KB gzipped
19
+ - ♿ **Accessibility behaviors** - The shared core passed its scoped Phase 4 automated browser matrix in Chromium, Firefox, and WebKit. This does not certify every Vanilla integration, minimum browser versions, or WCAG conformance; manual assistive-technology assessment remains pending.
20
+ - ⚡ **Bundle size** - Size depends on the selected package entry, dependency graph, and bundler output. No current version-specific gzipped-size measurement is claimed here.
11
21
  - 🔧 **TypeScript** - Full type safety included
12
22
  - 📦 **Tree-Shakeable** - Import only what you need
13
23
  - 🎯 **Web Standards** - Built on native Web Components
@@ -18,7 +28,7 @@ Vanilla JavaScript/TypeScript helpers for Smilodon Select. Part of the [Smilodon
18
28
 
19
29
  **Framework integration (Vue 3, Nuxt 4, React, SSR, Vite):** [`docs/FRAMEWORK-INTEGRATION.md`](../../docs/FRAMEWORK-INTEGRATION.md)
20
30
 
21
- 👉 **[Complete Vanilla JS Guide](./COMPLETE-GUIDE.md)** 👈
31
+ 👉 **[Legacy Vanilla JS Guide (mixed-era examples)](./COMPLETE-GUIDE.md)** 👈
22
32
 
23
33
  ## Installation
24
34
 
@@ -31,6 +41,7 @@ npm install @smilodon/vanilla @smilodon/core
31
41
  ### Using the Helper Function
32
42
 
33
43
  ```typescript
44
+ import '@smilodon/core';
34
45
  import { createSelect } from '@smilodon/vanilla';
35
46
 
36
47
  const select = createSelect({
@@ -51,6 +62,14 @@ document.body.appendChild(select);
51
62
  ### Direction and option-state controls
52
63
 
53
64
  ```typescript
65
+ import '@smilodon/core';
66
+ import { createSelect } from '@smilodon/vanilla';
67
+
68
+ const items = [
69
+ { value: 'a', label: 'Alpha' },
70
+ { value: 'b', label: 'Beta' },
71
+ ];
72
+
54
73
  const select = createSelect({
55
74
  items,
56
75
  direction: 'rtl',
@@ -84,6 +103,7 @@ Use these when you want advanced core features without writing the whole `update
84
103
  - `config`
85
104
 
86
105
  ```typescript
106
+ import '@smilodon/core';
87
107
  import { createSelect } from '@smilodon/vanilla';
88
108
 
89
109
  const select = createSelect({
@@ -120,6 +140,14 @@ const select = createSelect({
120
140
  #### Full `config` passthrough
121
141
 
122
142
  ```typescript
143
+ import '@smilodon/core';
144
+ import { createSelect } from '@smilodon/vanilla';
145
+
146
+ const items = [
147
+ { value: 'react', label: 'React' },
148
+ { value: 'vue', label: 'Vue' },
149
+ ];
150
+
123
151
  const select = createSelect({
124
152
  items,
125
153
  multiple: true,
@@ -154,8 +182,11 @@ const select = createSelect({
154
182
  #### Global defaults from `@smilodon/vanilla`
155
183
 
156
184
  ```typescript
185
+ import '@smilodon/core';
157
186
  import { configureSelect, createSelect } from '@smilodon/vanilla';
158
187
 
188
+ const items = [{ value: 'react', label: 'React' }];
189
+
159
190
  configureSelect({
160
191
  searchable: true,
161
192
  clearControl: {
@@ -183,15 +214,26 @@ In addition to `open()`, `close()`, `clear()`, `setItems()`, and `setGroupedItem
183
214
  - `clearError(element)`
184
215
  - `setRequired(element, required)`
185
216
  - `validate(element)`
217
+ - `getCapabilities(element)` and `getKnownLimitations(element)`
218
+ - `getTrackingSnapshot(element)`, `clearTracking(element, source?)`, and `setLimitationPolicies(element, policies)`
219
+ - `getValue(element)` and `setValue(element, value)`
220
+ - global `configureSelect(config)`, `resetSelectConfig()`, and `selectConfig`
186
221
 
187
222
  ```typescript
223
+ import '@smilodon/core';
188
224
  import {
225
+ createSelect,
189
226
  clearSearch,
190
227
  updateConfig,
191
228
  setError,
192
229
  validate,
193
230
  } from '@smilodon/vanilla';
194
231
 
232
+ const select = createSelect({
233
+ items: [{ value: 'choice', label: 'Choice' }],
234
+ });
235
+ document.body.appendChild(select);
236
+
195
237
  clearSearch(select);
196
238
  updateConfig(select, { selection: { showSelectedIndicator: false } });
197
239
  setError(select, 'Please choose at least one option');
@@ -204,33 +246,44 @@ console.log(validate(select));
204
246
  <!DOCTYPE html>
205
247
  <html>
206
248
  <head>
249
+ <meta charset="utf-8">
250
+ <title>Smilodon Vanilla example</title>
251
+ </head>
252
+ <body>
253
+ <div id="app">
254
+ <enhanced-select placeholder="Select a language..."></enhanced-select>
255
+ </div>
207
256
  <script type="module">
208
257
  import '@smilodon/core';
209
258
  import { initSelect } from '@smilodon/vanilla';
210
259
 
211
- const select = document.querySelector('enhanced-select');
212
-
260
+ await customElements.whenDefined('enhanced-select');
261
+ const select = document.querySelector<HTMLElement>('enhanced-select');
262
+ if (!select) throw new Error('Expected an enhanced-select element');
263
+
213
264
  initSelect(select, {
214
265
  items: [
215
266
  { value: 'js', label: 'JavaScript' },
216
267
  { value: 'ts', label: 'TypeScript' },
217
268
  { value: 'py', label: 'Python' },
218
269
  ],
219
- value: 'js'
270
+ value: 'js',
271
+ searchable: true,
272
+ placeholder: 'Select a language...'
220
273
  });
221
274
  </script>
222
- </head>
223
- <body>
224
- <enhanced-select placeholder="Select a language..."></enhanced-select>
225
275
  </body>
226
276
  </html>
227
277
  ```
228
278
 
229
279
  ## Examples
230
280
 
281
+ Every standalone helper example below imports `@smilodon/core` before calling `createSelect()`. In an application, one core side-effect import at the browser entry point is sufficient. When initializing an existing host with `initSelect()`, wait for `customElements.whenDefined('enhanced-select')` as shown above.
282
+
231
283
  ### Searchable Select
232
284
 
233
285
  ```typescript
286
+ import '@smilodon/core';
234
287
  import { createSelect } from '@smilodon/vanilla';
235
288
 
236
289
  const select = createSelect({
@@ -244,12 +297,13 @@ const select = createSelect({
244
297
  onChange: (value) => console.log('Country:', value)
245
298
  });
246
299
 
247
- document.getElementById('app').appendChild(select);
300
+ document.body.appendChild(select);
248
301
  ```
249
302
 
250
303
  ### Multi-Select
251
304
 
252
305
  ```typescript
306
+ import '@smilodon/core';
253
307
  import { createSelect } from '@smilodon/vanilla';
254
308
 
255
309
  const select = createSelect({
@@ -265,12 +319,15 @@ const select = createSelect({
265
319
  }
266
320
  });
267
321
 
268
- document.getElementById('app').appendChild(select);
322
+ document.body.appendChild(select);
269
323
  ```
270
324
 
271
325
  ### Grouped Options
272
326
 
327
+ Vanilla's adapter input intentionally uses `{ group, items }`. The core runtime's `setGroupedItems()` contract uses `{ label, options }`; the helper converts the Vanilla shape to the core shape internally. Use the Vanilla shape with `createSelect()` / helper `setGroupedItems()` and the core shape only when calling the core element directly.
328
+
273
329
  ```typescript
330
+ import '@smilodon/core';
274
331
  import { createSelect } from '@smilodon/vanilla';
275
332
 
276
333
  const select = createSelect({
@@ -293,46 +350,56 @@ const select = createSelect({
293
350
  onChange: (value) => console.log('Food:', value)
294
351
  });
295
352
 
296
- document.getElementById('app').appendChild(select);
353
+ document.body.appendChild(select);
297
354
  ```
298
355
 
299
356
  ### Infinite Scroll
300
357
 
301
358
  ```typescript
359
+ import '@smilodon/core';
302
360
  import { createSelect, setItems } from '@smilodon/vanilla';
303
361
 
304
- let items = generateItems(1, 50);
305
- let page = 1;
362
+ const pageSize = 50;
363
+ const total = 500;
364
+ let items = makeItems(1, pageSize);
365
+ let loading = false;
306
366
 
307
367
  const select = createSelect({
308
368
  items,
309
369
  infiniteScroll: true,
310
- pageSize: 50,
370
+ pageSize,
311
371
  placeholder: 'Scroll to load more...',
312
- onLoadMore: (pageNum) => {
313
- page++;
314
- const newItems = generateItems(page * 50 + 1, (page + 1) * 50);
315
- items = [...items, ...newItems];
372
+ onLoadMore: () => {
373
+ if (loading || items.length >= total) return;
374
+
375
+ loading = true;
376
+ const start = items.length + 1;
377
+ const count = Math.min(pageSize, total - items.length);
378
+ items = [...items, ...makeItems(start, count)];
316
379
  setItems(select, items);
380
+ loading = false;
317
381
  }
318
382
  });
319
383
 
320
- function generateItems(start, end) {
321
- return Array.from({ length: end - start + 1 }, (_, i) => ({
384
+ function makeItems(start: number, count: number) {
385
+ return Array.from({ length: count }, (_, i) => ({
322
386
  value: start + i,
323
387
  label: `Item ${start + i}`,
324
388
  }));
325
389
  }
326
390
 
327
- document.getElementById('app').appendChild(select);
391
+ document.body.appendChild(select);
328
392
  ```
329
393
 
330
- ### Virtual Scrolling (Large Datasets)
394
+ For remote data, keep the in-flight flag set until the request settles, detect the server's end-of-data response, and report/retry failures in the host application. The helper invokes `onLoadMore`; it does not own the data source or deduplicate asynchronous requests for you.
395
+
396
+ ### Incremental Chunk Rendering (Large Flat Lists)
331
397
 
332
398
  ```typescript
399
+ import '@smilodon/core';
333
400
  import { createSelect } from '@smilodon/vanilla';
334
401
 
335
- // Generate 100,000 items
402
+ // Generate a large flat item set
336
403
  const items = Array.from({ length: 100000 }, (_, i) => ({
337
404
  value: i + 1,
338
405
  label: `Item ${i + 1}`,
@@ -340,40 +407,59 @@ const items = Array.from({ length: 100000 }, (_, i) => ({
340
407
 
341
408
  const select = createSelect({
342
409
  items,
343
- virtualized: true,
410
+ virtualized: true, // Incremental chunks, not viewport windowing
344
411
  searchable: true,
345
- placeholder: '100k items with virtual scrolling...'
412
+ placeholder: 'Large item list'
346
413
  });
347
414
 
348
- document.getElementById('app').appendChild(select);
415
+ document.body.appendChild(select);
349
416
  ```
350
417
 
351
418
  ### Server-Side Search
352
419
 
353
420
  ```typescript
421
+ import '@smilodon/core';
354
422
  import { createSelect, setItems } from '@smilodon/vanilla';
355
423
 
424
+ let searchRequest = 0;
425
+ let activeController: AbortController | undefined;
426
+
356
427
  const select = createSelect({
357
428
  searchable: true,
358
429
  placeholder: 'Type to search...',
359
430
  onSearch: async (query) => {
431
+ const requestId = ++searchRequest;
432
+ activeController?.abort();
433
+
360
434
  if (!query) {
361
435
  setItems(select, []);
362
436
  return;
363
437
  }
364
438
 
365
- const response = await fetch(`/api/search?q=${query}`);
366
- const data = await response.json();
367
- setItems(select, data.results);
439
+ const controller = new AbortController();
440
+ activeController = controller;
441
+ try {
442
+ const response = await fetch(`/api/search?q=${encodeURIComponent(query)}`, {
443
+ signal: controller.signal,
444
+ });
445
+ if (!response.ok) throw new Error(`Search failed: ${response.status}`);
446
+ const data = await response.json();
447
+ if (requestId === searchRequest) setItems(select, data.results);
448
+ } catch (error) {
449
+ if (!(error instanceof DOMException && error.name === 'AbortError') && requestId === searchRequest) {
450
+ console.error('Unable to search options', error);
451
+ }
452
+ }
368
453
  }
369
454
  });
370
455
 
371
- document.getElementById('app').appendChild(select);
456
+ document.body.appendChild(select);
372
457
  ```
373
458
 
374
459
  ### Programmatic Control
375
460
 
376
461
  ```typescript
462
+ import '@smilodon/core';
377
463
  import { createSelect, getValue, setValue, clear, open, close } from '@smilodon/vanilla';
378
464
 
379
465
  const select = createSelect({
@@ -385,26 +471,32 @@ const select = createSelect({
385
471
  });
386
472
 
387
473
  // Add to DOM
388
- document.getElementById('app').appendChild(select);
474
+ const buttons = Object.entries({ open: 'Open', close: 'Close', set: 'Set value', get: 'Get value', clear: 'Clear' }).map(([id, label]) => {
475
+ const button = document.createElement('button');
476
+ button.id = `btn-${id}`;
477
+ button.textContent = label;
478
+ return button;
479
+ });
480
+ document.body.append(select, ...buttons);
389
481
 
390
482
  // Programmatic API
391
- document.getElementById('btn-open').addEventListener('click', () => {
483
+ document.getElementById('btn-open')!.addEventListener('click', () => {
392
484
  open(select);
393
485
  });
394
486
 
395
- document.getElementById('btn-close').addEventListener('click', () => {
487
+ document.getElementById('btn-close')!.addEventListener('click', () => {
396
488
  close(select);
397
489
  });
398
490
 
399
- document.getElementById('btn-set').addEventListener('click', () => {
491
+ document.getElementById('btn-set')!.addEventListener('click', () => {
400
492
  setValue(select, 'published');
401
493
  });
402
494
 
403
- document.getElementById('btn-get').addEventListener('click', () => {
495
+ document.getElementById('btn-get')!.addEventListener('click', () => {
404
496
  console.log('Current value:', getValue(select));
405
497
  });
406
498
 
407
- document.getElementById('btn-clear').addEventListener('click', () => {
499
+ document.getElementById('btn-clear')!.addEventListener('click', () => {
408
500
  clear(select);
409
501
  });
410
502
  ```
@@ -412,6 +504,7 @@ document.getElementById('btn-clear').addEventListener('click', () => {
412
504
  ### Clear Control (Reset Selection/Search)
413
505
 
414
506
  ```typescript
507
+ import '@smilodon/core';
415
508
  import { createSelect } from '@smilodon/vanilla';
416
509
 
417
510
  const select = createSelect({
@@ -438,11 +531,15 @@ document.body.appendChild(select);
438
531
 
439
532
  Styling hooks: `::part(clear-button)`, `::part(clear-icon)`, and `--select-clear-*` CSS variables.
440
533
 
441
- The default `hideWhenEmpty: true` behavior means an empty clearable select reserves no action-area space. A selection or enabled search query reveals the button and coordinated input/arrow layout; clearing both restores the normal layout. This applies to single, multi-select, LTR, and RTL modes.
534
+ The shared runtime's default `hideWhenEmpty: true` behavior means an empty clearable select reserves no action-area space. A selection or enabled search query reveals the button and coordinated input/arrow layout; clearing both restores the normal layout for single/multi-select and LTR/RTL configurations. This describes the runtime behavior, not exhaustive Vanilla integration certification.
442
535
 
443
536
  Use full config passthrough when a permanently visible disabled-when-empty action is intentional:
444
537
 
445
538
  ```typescript
539
+ import '@smilodon/core';
540
+ import { createSelect } from '@smilodon/vanilla';
541
+
542
+ const items = [{ value: 'selected', label: 'Selected item' }];
446
543
  const select = createSelect({
447
544
  items,
448
545
  clearable: true,
@@ -455,10 +552,14 @@ const select = createSelect({
455
552
  ### With Event Listeners
456
553
 
457
554
  ```typescript
555
+ import '@smilodon/core';
458
556
  import { createSelect } from '@smilodon/vanilla';
459
557
 
460
558
  const select = createSelect({
461
- items: [...],
559
+ items: [
560
+ { value: 'first', label: 'First option' },
561
+ { value: 'second', label: 'Second option' },
562
+ ],
462
563
  onChange: (value, items) => {
463
564
  console.log('Value changed:', value);
464
565
  console.log('Selected items:', items);
@@ -477,16 +578,19 @@ const select = createSelect({
477
578
  }
478
579
  });
479
580
 
480
- document.getElementById('app').appendChild(select);
581
+ document.body.appendChild(select);
481
582
  ```
482
583
 
483
584
  ### Custom Styling
484
585
 
485
586
  ```typescript
587
+ import '@smilodon/core';
486
588
  import { createSelect } from '@smilodon/vanilla';
487
589
 
488
590
  const select = createSelect({
489
- items: [...],
591
+ items: [
592
+ { value: 'custom', label: 'Custom styled option' },
593
+ ],
490
594
  className: 'my-custom-select',
491
595
  style: {
492
596
  width: '300px',
@@ -494,7 +598,7 @@ const select = createSelect({
494
598
  }
495
599
  });
496
600
 
497
- document.getElementById('app').appendChild(select);
601
+ document.body.appendChild(select);
498
602
  ```
499
603
 
500
604
  ```css
@@ -528,11 +632,14 @@ Creates and returns a new select element.
528
632
  | `error` | `boolean` | `false` | Show error state |
529
633
  | `infiniteScroll` | `boolean` | `false` | Enable infinite scroll |
530
634
  | `pageSize` | `number` | `50` | Items per page |
531
- | `virtualized` | `boolean` | `true` | Enable virtual scrolling |
635
+ | `virtualized` | `boolean` | `false` | Enable legacy chunked rendering for large flat lists; not viewport windowing |
532
636
  | `maxSelections` | `number` | `undefined` | Max selections |
533
637
  | `placement` | `'bottom' \| 'top' \| 'auto'` | `'auto'` | Dropdown placement |
534
638
  | `className` | `string` | `''` | Custom CSS class |
535
- | `style` | `CSSStyleDeclaration` | `{}` | Inline styles |
639
+ | `style` | `Partial<CSSStyleDeclaration>` | `{}` | Inline host-element styles |
640
+ | `selectionConfig`, `multiSelectDisplay`, `scrollToSelected`, `styles`, `config` | core configuration types | - | Shared runtime configuration groups |
641
+ | `direction`, `removeButtonIcon`, `disabledOptionBehavior`, `showSelectedIndicator` | documented values/configs | - | Direction, chip, and option-state settings |
642
+ | `clearable`, `clearSelectionOnClear`, `clearSearchOnClear`, `clearAriaLabel`, `clearIcon` | booleans / strings | - | Clear-control configuration |
536
643
  | `onChange` | `(value, items) => void` | `undefined` | Change callback |
537
644
  | `onSelect` | `(item, index) => void` | `undefined` | Select callback |
538
645
  | `onOpen` | `() => void` | `undefined` | Open callback |
@@ -540,6 +647,9 @@ Creates and returns a new select element.
540
647
  | `onSearch` | `(query) => void` | `undefined` | Search callback |
541
648
  | `onLoadMore` | `(page) => void` | `undefined` | Load more callback |
542
649
  | `onCreate` | `(value) => void` | `undefined` | Create callback |
650
+ | `onClear` | `(detail) => void` | `undefined` | Clear result callback |
651
+ | `onDiagnostic` | `(detail) => void` | `undefined` | Diagnostic callback |
652
+ | `trackingEnabled`, `trackEvents`, `trackStyling`, `trackLimitations`, `emitDiagnostics`, `trackingMaxEntries`, `limitationPolicies`, `autoMitigateRuntimeModeSwitch` | tracking/policy types | - | Diagnostic and limitation controls |
543
653
 
544
654
  **Returns:** `HTMLElement`
545
655
 
@@ -548,8 +658,8 @@ Creates and returns a new select element.
548
658
  Initialize an existing select element in the DOM.
549
659
 
550
660
  **Parameters:**
551
- - `element: HTMLElement` - The select element
552
- - `options: { items?, groupedItems?, value? }` - Initialization options
661
+ - `element: HTMLElement` - An `enhanced-select` host whose custom-element definition has already loaded and upgraded.
662
+ - `options` - `initSelect` accepts `items`, Vanilla-shaped `groupedItems`, `value`, `multiple`, `searchable`, `placeholder`, `disabled`, `infiniteScroll`, `pageSize`, `virtualized`, `maxSelections`, `selectionConfig`, `multiSelectDisplay`, `scrollToSelected`, `styles`, `config`, `clearable`, `clearSelectionOnClear`, `clearSearchOnClear`, `clearAriaLabel`, and `clearIcon`. It does not accept the callbacks, `className`, `style`, or diagnostics options available on `createSelect`.
553
663
 
554
664
  ### `getValue(element)`
555
665
 
@@ -630,6 +740,8 @@ enhanced-select {
630
740
 
631
741
  ## Browser Support
632
742
 
743
+ The versions listed below are repository compatibility targets, not browser versions certified by the current Phase 4 matrix. The completed scoped matrix uses current pinned Chromium, Firefox, and WebKit builds; see the [browser support policy](../../docs/compliance/BROWSER-SUPPORT.md) for declared targets.
744
+
633
745
  - Chrome/Edge 90+
634
746
  - Firefox 88+
635
747
  - Safari 14+
@@ -0,0 +1,160 @@
1
+ /**
2
+ * Smilodon Vanilla - Simple helpers for using Smilodon Select with vanilla JavaScript/TypeScript
3
+ *
4
+ * This package provides convenience functions and utilities for working with
5
+ * the Smilodon Select web component in vanilla JavaScript applications.
6
+ */
7
+ import type { GlobalSelectConfig, SelectionConfig, MultiSelectDisplayConfig, ScrollToSelectedConfig, StyleConfig } from '@smilodon/core';
8
+ export { configureSelect, resetSelectConfig, selectConfig } from '@smilodon/core';
9
+ /**
10
+ * Select item interface
11
+ */
12
+ export interface SelectItem {
13
+ value: string | number;
14
+ label: string;
15
+ disabled?: boolean;
16
+ group?: string;
17
+ [key: string]: any;
18
+ }
19
+ /**
20
+ * Grouped items interface
21
+ */
22
+ export interface GroupedItem {
23
+ group: string;
24
+ items: SelectItem[];
25
+ }
26
+ /**
27
+ * Create a select element with options
28
+ */
29
+ export declare function createSelect(options: {
30
+ items?: SelectItem[];
31
+ groupedItems?: GroupedItem[];
32
+ value?: string | number | (string | number)[];
33
+ multiple?: boolean;
34
+ searchable?: boolean;
35
+ placeholder?: string;
36
+ disabled?: boolean;
37
+ required?: boolean;
38
+ error?: boolean;
39
+ infiniteScroll?: boolean;
40
+ pageSize?: number;
41
+ virtualized?: boolean;
42
+ maxSelections?: number;
43
+ selectionConfig?: Partial<SelectionConfig>;
44
+ multiSelectDisplay?: Partial<MultiSelectDisplayConfig>;
45
+ scrollToSelected?: Partial<ScrollToSelectedConfig>;
46
+ styles?: StyleConfig;
47
+ config?: Partial<GlobalSelectConfig>;
48
+ removeButtonIcon?: string;
49
+ disabledOptionBehavior?: {
50
+ selectable?: boolean;
51
+ hoverable?: boolean;
52
+ focusable?: boolean;
53
+ };
54
+ showSelectedIndicator?: boolean;
55
+ direction?: 'ltr' | 'rtl';
56
+ placement?: 'bottom' | 'top' | 'auto';
57
+ clearable?: boolean;
58
+ clearSelectionOnClear?: boolean;
59
+ clearSearchOnClear?: boolean;
60
+ clearAriaLabel?: string;
61
+ clearIcon?: string;
62
+ className?: string;
63
+ style?: Partial<CSSStyleDeclaration>;
64
+ onChange?: (value: any, items: any[]) => void;
65
+ onSelect?: (item: any, index: number) => void;
66
+ onOpen?: () => void;
67
+ onClose?: () => void;
68
+ onSearch?: (query: string) => void;
69
+ onLoadMore?: (page: number) => void;
70
+ onCreate?: (value: string) => void;
71
+ onClear?: (detail: {
72
+ clearedSelection: boolean;
73
+ clearedSearch: boolean;
74
+ }) => void;
75
+ onDiagnostic?: (detail: any) => void;
76
+ trackingEnabled?: boolean;
77
+ trackEvents?: boolean;
78
+ trackStyling?: boolean;
79
+ trackLimitations?: boolean;
80
+ emitDiagnostics?: boolean;
81
+ trackingMaxEntries?: number;
82
+ limitationPolicies?: Record<string, {
83
+ mode: 'default' | 'suppress' | 'strict';
84
+ note?: string;
85
+ }>;
86
+ autoMitigateRuntimeModeSwitch?: boolean;
87
+ }): HTMLElement;
88
+ /**
89
+ * Initialize a select element that already exists in the DOM
90
+ */
91
+ export declare function initSelect(element: HTMLElement, options: {
92
+ items?: SelectItem[];
93
+ groupedItems?: GroupedItem[];
94
+ value?: string | number | (string | number)[];
95
+ multiple?: boolean;
96
+ searchable?: boolean;
97
+ placeholder?: string;
98
+ disabled?: boolean;
99
+ infiniteScroll?: boolean;
100
+ pageSize?: number;
101
+ virtualized?: boolean;
102
+ maxSelections?: number;
103
+ selectionConfig?: Partial<SelectionConfig>;
104
+ multiSelectDisplay?: Partial<MultiSelectDisplayConfig>;
105
+ scrollToSelected?: Partial<ScrollToSelectedConfig>;
106
+ styles?: StyleConfig;
107
+ config?: Partial<GlobalSelectConfig>;
108
+ clearable?: boolean;
109
+ clearSelectionOnClear?: boolean;
110
+ clearSearchOnClear?: boolean;
111
+ clearAriaLabel?: string;
112
+ clearIcon?: string;
113
+ }): void;
114
+ /**
115
+ * Get the selected value(s) from a select element
116
+ */
117
+ export declare function getValue(element: HTMLElement): any;
118
+ /**
119
+ * Set the selected value(s) for a select element
120
+ */
121
+ export declare function setValue(element: HTMLElement, value: string | number | (string | number)[]): void;
122
+ /**
123
+ * Clear the selection
124
+ */
125
+ export declare function clear(element: HTMLElement): void;
126
+ /**
127
+ * Clear the current search query
128
+ */
129
+ export declare function clearSearch(element: HTMLElement): void;
130
+ /**
131
+ * Open the dropdown
132
+ */
133
+ export declare function open(element: HTMLElement): void;
134
+ /**
135
+ * Close the dropdown
136
+ */
137
+ export declare function close(element: HTMLElement): void;
138
+ /**
139
+ * Update items
140
+ */
141
+ export declare function setItems(element: HTMLElement, items: SelectItem[]): void;
142
+ /**
143
+ * Update grouped items
144
+ */
145
+ export declare function setGroupedItems(element: HTMLElement, groups: GroupedItem[]): void;
146
+ export declare function getSelectedItems(element: HTMLElement): any[];
147
+ export declare function updateConfig(element: HTMLElement, config: Partial<GlobalSelectConfig>): void;
148
+ export declare function setError(element: HTMLElement, message: string): void;
149
+ export declare function clearError(element: HTMLElement): void;
150
+ export declare function setRequired(element: HTMLElement, required: boolean): void;
151
+ export declare function validate(element: HTMLElement): boolean;
152
+ export declare function getCapabilities(element: HTMLElement): any;
153
+ export declare function getKnownLimitations(element: HTMLElement): any[];
154
+ export declare function getTrackingSnapshot(element: HTMLElement): any;
155
+ export declare function clearTracking(element: HTMLElement, source?: 'event' | 'style' | 'limitation' | 'all'): void;
156
+ export declare function setLimitationPolicies(element: HTMLElement, policies: Record<string, {
157
+ mode: 'default' | 'suppress' | 'strict';
158
+ note?: string;
159
+ }>): void;
160
+ export type { SelectEventDetail, ChangeEventDetail, SearchEventDetail, LoadMoreEventDetail, ErrorEventDetail, DiagnosticEventDetail, LimitationPolicyMap, TrackingSnapshot, SelectCapabilitiesReport, LimitationState, GlobalSelectConfig, SelectionConfig, MultiSelectDisplayConfig, ScrollToSelectedConfig, StyleConfig, ClearControlConfig, ExpandableConfig, InfiniteScrollConfig, LoadMoreConfig, BusyBucketConfig, ServerSideConfig, TrackingConfig, LimitationsConfig, } from '@smilodon/core';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smilodon/vanilla",
3
- "version": "1.9.3",
3
+ "version": "1.10.1",
4
4
  "description": "Vanilla JavaScript helpers for Smilodon Select - part of the Smilodon UI toolkit",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -19,16 +19,16 @@
19
19
  "COMPLETE-GUIDE.md"
20
20
  ],
21
21
  "scripts": {
22
- "build": "tsc --emitDeclarationOnly --outDir dist/types && vite build",
22
+ "build": "vite build && tsc --emitDeclarationOnly --outDir dist/types && node scripts/cleanup-types.js",
23
23
  "size": "gzip -c dist/index.mjs | wc -c",
24
24
  "prepublishOnly": "npm run build"
25
25
  },
26
26
  "peerDependencies": {
27
- "@smilodon/core": "^1.9.3"
27
+ "@smilodon/core": "^1.10.0"
28
28
  },
29
29
  "devDependencies": {
30
30
  "typescript": "^5.6.2",
31
- "vite": "^5.4.11"
31
+ "vite": "6.4.6"
32
32
  },
33
33
  "keywords": [
34
34
  "vanilla",