@smilodon/core 1.9.2 → 1.10.0

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.
Files changed (52) hide show
  1. package/README.md +10 -6
  2. package/dist/index.cjs +2488 -436
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.js +2473 -437
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.min.js +1 -1
  7. package/dist/index.min.js.map +1 -1
  8. package/dist/index.umd.js +2488 -436
  9. package/dist/index.umd.js.map +1 -1
  10. package/dist/index.umd.min.js +1 -1
  11. package/dist/index.umd.min.js.map +1 -1
  12. package/dist/types/src/components/enhanced-select.d.ts +114 -1
  13. package/dist/types/src/components/native-select.d.ts +2 -1
  14. package/dist/types/src/config/global-config.d.ts +2 -2
  15. package/dist/types/src/engine/accessibility.d.ts +109 -0
  16. package/dist/types/src/engine/contracts.d.ts +4 -0
  17. package/dist/types/src/engine/index.d.ts +9 -0
  18. package/dist/types/src/engine/item-adapter.d.ts +23 -0
  19. package/dist/types/src/engine/item-registry.d.ts +31 -0
  20. package/dist/types/src/engine/select-effects.d.ts +20 -0
  21. package/dist/types/src/engine/select-events.d.ts +55 -0
  22. package/dist/types/src/engine/select-machine.d.ts +9 -0
  23. package/dist/types/src/engine/select-state.d.ts +17 -0
  24. package/dist/types/src/engine/selection-policy.d.ts +33 -0
  25. package/dist/types/src/engine/selectors.d.ts +10 -0
  26. package/dist/types/src/engine/virtualization.d.ts +56 -0
  27. package/dist/types/src/index.d.ts +4 -0
  28. package/dist/types/src/platform/web/accessibility-effects.d.ts +19 -0
  29. package/dist/types/src/platform/web/index.d.ts +2 -0
  30. package/dist/types/src/platform/web/select-effect-runner.d.ts +15 -0
  31. package/dist/types/src/platform/web/select-engine-bridge.d.ts +10 -0
  32. package/dist/types/src/utils/custom-option-pool.d.ts +3 -4
  33. package/dist/types/src/utils/data-source.d.ts +7 -2
  34. package/dist/types/src/utils/dom-pool.d.ts +1 -0
  35. package/dist/types/src/utils/telemetry.d.ts +2 -2
  36. package/dist/types/src/utils/virtualizer.d.ts +50 -1
  37. package/dist/types/tests/accessibility-contract.spec.d.ts +1 -0
  38. package/dist/types/tests/enhanced-select-accessibility-integration.spec.d.ts +1 -0
  39. package/dist/types/tests/enhanced-select-active-authority.spec.d.ts +1 -0
  40. package/dist/types/tests/enhanced-select-active-parity.spec.d.ts +1 -0
  41. package/dist/types/tests/enhanced-select-authority.spec.d.ts +1 -0
  42. package/dist/types/tests/enhanced-select-compatibility-projection.spec.d.ts +1 -0
  43. package/dist/types/tests/enhanced-select-selection-parity.spec.d.ts +1 -0
  44. package/dist/types/tests/enhanced-select-virtualization-integration.spec.d.ts +1 -0
  45. package/dist/types/tests/item-adapter.spec.d.ts +1 -0
  46. package/dist/types/tests/item-registry.spec.d.ts +1 -0
  47. package/dist/types/tests/memory-lifecycle.spec.d.ts +1 -0
  48. package/dist/types/tests/select-accessibility.spec.d.ts +1 -0
  49. package/dist/types/tests/select-selection.spec.d.ts +1 -0
  50. package/dist/types/tests/virtualization-contract.spec.d.ts +1 -0
  51. package/dist/types/tests/web-accessibility-effects.spec.d.ts +1 -0
  52. package/package.json +3 -3
@@ -3,15 +3,18 @@
3
3
  * Implements all advanced features: infinite scroll, load more, busy state,
4
4
  * server-side selection, and full customization
5
5
  *
6
- * ✨ Redesigned with formal elegance, refined microinteractions, and polished UX
6
+ * Redesigned with formal elegance, refined microinteractions, and polished UX
7
7
  */
8
8
  import type { GlobalSelectConfig } from '../config/global-config';
9
9
  import type { GroupedItem, ClassMap, SelectCapabilitiesReport, LimitationState, LimitationPolicyMap, TrackingSnapshot } from '../types';
10
10
  import type { OptionRenderer as OptionRendererFn } from '../renderers/contracts';
11
11
  export declare class EnhancedSelect extends HTMLElement {
12
+ static get observedAttributes(): string[];
12
13
  /** live set of all connected instances; used to auto-close siblings */
13
14
  private static _instances;
14
15
  private static readonly _MIRRORED_STYLES_SCOPE_CLASS;
16
+ private static readonly _MIRRORED_STYLESHEET_CACHE_LIMIT;
17
+ private static readonly _mirroredStylesheetTextCache;
15
18
  private _config;
16
19
  private _shadow;
17
20
  private _container;
@@ -23,7 +26,32 @@ export declare class EnhancedSelect extends HTMLElement {
23
26
  private _loadMoreTrigger?;
24
27
  private _busyBucket?;
25
28
  private _liveRegion?;
29
+ private _errorDescription?;
26
30
  private _state;
31
+ private _engine;
32
+ private _virtualizationScope;
33
+ private _renderPlan;
34
+ private _guardedVirtualWindow;
35
+ private _guardedVirtualizer;
36
+ private _guardedVirtualizationRequested;
37
+ private _guardedVirtualizerKeys;
38
+ private _guardedMeasurementQuery;
39
+ private _guardedOptionResizeObserver;
40
+ private _guardedObservedOptions;
41
+ private _guardedObserverSeenOptions;
42
+ private _guardedOptionMeasurements;
43
+ private _guardedMeasurementGeneration;
44
+ private _guardedVirtualScrollTop;
45
+ private _guardedVirtualViewportHeight;
46
+ private _guardedVirtualOverscan;
47
+ private _guardedVirtualWindowRafId;
48
+ private _guardedScrollListenerAttached;
49
+ private _onGuardedVirtualScroll;
50
+ private _effectRunner;
51
+ private _itemAdapter;
52
+ private _itemRegistry;
53
+ private _selectedRecordsByKey;
54
+ private _registryItemsRef;
27
55
  private _pageCache;
28
56
  private _resizeObserver?;
29
57
  private _intersectionObserver?;
@@ -46,11 +74,18 @@ export declare class EnhancedSelect extends HTMLElement {
46
74
  private _classMap?;
47
75
  private _rendererHelpers;
48
76
  private _customOptionBoundElements;
77
+ private _customOptionNormalizedIds;
78
+ private _customOptionNormalizedLabels;
49
79
  private _mirrorGlobalStylesForCustomOptions;
50
80
  private _globalStylesObserver;
51
81
  private _globalStylesContainer;
52
82
  private _themeContextObserver;
53
83
  private _globalStylesSyncToken;
84
+ private _connectionController?;
85
+ private _asyncGeneration;
86
+ private _lifecycleTimers;
87
+ private _lifecycleRafs;
88
+ private _keyboardActiveChangeGeneration;
54
89
  private _tracking;
55
90
  private _suppressBlurClose;
56
91
  private _renderCycleId;
@@ -58,6 +93,7 @@ export declare class EnhancedSelect extends HTMLElement {
58
93
  private _resolvedDropdownPlacement;
59
94
  private _multiScrollDrag;
60
95
  private _liftedAncestors;
96
+ private _onDocumentPointerDown;
61
97
  get classMap(): ClassMap | undefined;
62
98
  set classMap(map: ClassMap | undefined);
63
99
  /**
@@ -69,14 +105,20 @@ export declare class EnhancedSelect extends HTMLElement {
69
105
  set groupHeaderRenderer(renderer: import('../types').GroupHeaderRenderer | undefined);
70
106
  constructor();
71
107
  connectedCallback(): void;
108
+ attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
72
109
  disconnectedCallback(): void;
73
110
  private _setGlobalStylesMirroring;
111
+ private _setLifecycleTimeout;
112
+ private _requestLifecycleFrame;
113
+ private _clearLifecycleTasks;
74
114
  private _setupGlobalStylesMirroring;
75
115
  private _teardownGlobalStylesMirroring;
76
116
  private _mirrorDocumentStylesIntoShadow;
77
117
  private _setupThemeContextMirroring;
78
118
  private _syncMirroredThemeContext;
79
119
  private _createScopedGlobalStyleNode;
120
+ private static _pruneMirroredStylesheetTextCache;
121
+ private _areClassMapsEqual;
80
122
  private _buildScopedStyleElement;
81
123
  private _scopeMirroredCssText;
82
124
  /**
@@ -97,6 +139,40 @@ export declare class EnhancedSelect extends HTMLElement {
97
139
  private _getDisabledOptionBehavior;
98
140
  private _isDisabledOptionSelectable;
99
141
  private _isOptionSelectionBlocked;
142
+ private _isPhase2DevRuntime;
143
+ private _getDuplicateKeyPolicy;
144
+ private _warnPhase2;
145
+ private _getItemValue;
146
+ private _getItemLabel;
147
+ private _createEngineItemAdapter;
148
+ private _getBlockedDisabledKeys;
149
+ private _syncEngineSelectionConfig;
150
+ private _rebuildItemRegistry;
151
+ private _ensureRegistryCurrent;
152
+ private _getRecordByIndex;
153
+ private _getSelectedEntries;
154
+ private _syncLegacySelectionFromEngine;
155
+ private _projectedSelectedKeysSnapshot;
156
+ private _assertSelectionProjection;
157
+ private _projectedActiveKeySnapshot;
158
+ private _syncLegacyActiveFromEngine;
159
+ private _assertActiveProjection;
160
+ private _dispatchActiveKey;
161
+ private _clearDisabledEngineActive;
162
+ /**
163
+ * @deprecated Test/backward-compatibility shim. Production active-state authority is engine.activeKey.
164
+ * Kept for existing renderer tests; component mutation paths dispatch by key.
165
+ */
166
+ private _mirrorLegacyActive;
167
+ private _dispatchSelection;
168
+ /**
169
+ * @deprecated Test/backward-compatibility shim. Production selection authority is engine.selectedKeys.
170
+ * Kept for existing styling tests; dispatches to engine authority.
171
+ */
172
+ private _mirrorLegacySelection;
173
+ private _requestSelectionReplacement;
174
+ private _registerShadowItems;
175
+ private _syncLegacyActiveAria;
100
176
  private _syncStyleConfigVariables;
101
177
  private _resolveDropdownPlacement;
102
178
  private _syncDropdownPlacement;
@@ -114,6 +190,7 @@ export declare class EnhancedSelect extends HTMLElement {
114
190
  private _createDropdown;
115
191
  private _createOptionsContainer;
116
192
  private _createLiveRegion;
193
+ private _createErrorDescription;
117
194
  private _createArrowContainer;
118
195
  private _createClearControl;
119
196
  private _assembleDOM;
@@ -121,6 +198,12 @@ export declare class EnhancedSelect extends HTMLElement {
121
198
  private _attachEventListeners;
122
199
  private _initializeObservers;
123
200
  private _loadInitialSelectedItems;
201
+ private _runEngineEffects;
202
+ private _syncPopupAria;
203
+ private _syncComboboxAccessibility;
204
+ private _syncListboxAccessibility;
205
+ private _syncRenderedOptionAccessibility;
206
+ private _applyFocusIntent;
124
207
  private _handleOpen;
125
208
  private _handleClose;
126
209
  private _updateDropdownVisibility;
@@ -149,6 +232,7 @@ export declare class EnhancedSelect extends HTMLElement {
149
232
  private _handleTypeAhead;
150
233
  private _selectAll;
151
234
  private _selectRange;
235
+ private _getSelectEventDetail;
152
236
  private _setInitialActiveOption;
153
237
  private _announce;
154
238
  private _selectOption;
@@ -175,6 +259,7 @@ export declare class EnhancedSelect extends HTMLElement {
175
259
  * Set items to display in the select
176
260
  */
177
261
  setItems(items: unknown[]): void;
262
+ private _groupItemsByProperty;
178
263
  /**
179
264
  * Set grouped items
180
265
  */
@@ -241,7 +326,35 @@ export declare class EnhancedSelect extends HTMLElement {
241
326
  /**
242
327
  * Render options based on current state
243
328
  */
329
+ private _deriveVirtualizationScope;
330
+ private _getMountedVirtualizationKeys;
331
+ private _refreshMountedVirtualizationScope;
332
+ private _appendMountedVirtualizationTargets;
333
+ private _createLegacyRenderPlan;
334
+ private _createVirtualRenderPlan;
335
+ private _ensureGuardedVirtualizer;
336
+ private _resolveGuardedEstimatedItemHeight;
337
+ private _resolveGuardedViewportHeight;
338
+ private _clampGuardedScrollPosition;
339
+ private _createGuardedSpacer;
340
+ private _appendGuardedTopSpacer;
341
+ private _appendGuardedBottomSpacer;
342
+ private _resolveGuardedOverscan;
343
+ private _applyGuardedWindowUpdate;
344
+ private _scheduleGuardedVirtualWindowUpdate;
345
+ private _cancelGuardedVirtualWindowUpdate;
346
+ private _applyGuardedScrollResult;
347
+ private _updateGuardedVirtualWindow;
348
+ private _destroyGuardedVirtualizer;
349
+ private _invalidateGuardedMeasurements;
350
+ private _createGuardedOptionResizeObserver;
351
+ private _captureGuardedScrollAnchor;
352
+ private _syncGuardedOptionResizeTargets;
353
+ private _teardownGuardedOptionResizeObserver;
354
+ private _materializeGuardedVirtualKey;
355
+ private _refreshVirtualizationScope;
244
356
  private _renderOptions;
357
+ private _unobserveGuardedOptionResizeTargets;
245
358
  private _renderSingleOption;
246
359
  private _normalizeCustomOptionElement;
247
360
  private _addLoadMoreTrigger;
@@ -1,4 +1,4 @@
1
- import { OptionRenderer, OptionTemplate } from '../renderers/contracts';
1
+ import { OptionRenderer, OptionTemplate } from "../renderers/contracts";
2
2
  export declare class NativeSelectElement extends HTMLElement {
3
3
  static get observedAttributes(): string[];
4
4
  private _options;
@@ -14,6 +14,7 @@ export declare class NativeSelectElement extends HTMLElement {
14
14
  private _multi;
15
15
  private _typeBuffer;
16
16
  private _typeTimeout?;
17
+ private _announceTimeout?;
17
18
  private _liveRegion?;
18
19
  constructor();
19
20
  connectedCallback(): void;
@@ -280,9 +280,9 @@ export interface GlobalSelectConfig {
280
280
  searchable?: boolean;
281
281
  /** Placeholder text */
282
282
  placeholder?: string;
283
- /** Virtualization */
283
+ /** Legacy chunked rendering toggle for large flat EnhancedSelect lists; not viewport windowing. */
284
284
  virtualize?: boolean;
285
- /** Estimated item height for virtualization */
285
+ /** Estimated row height used by the guarded EnhancedSelect viewport-windowing test path. */
286
286
  estimatedItemHeight?: number;
287
287
  }
288
288
  /**
@@ -0,0 +1,109 @@
1
+ import type { SelectKey } from './contracts.js';
2
+ import type { SelectState } from './select-state.js';
3
+ export type AccessibilityPopupRole = 'listbox';
4
+ export interface AccessibilityLabelState {
5
+ labelId?: string | null;
6
+ labelledBy?: readonly string[];
7
+ describedBy?: readonly string[];
8
+ ariaLabel?: string | null;
9
+ ariaDescription?: string | null;
10
+ }
11
+ export interface AccessibilityValidationState {
12
+ required: boolean;
13
+ invalid: boolean;
14
+ errorMessage?: string | null;
15
+ errorDescriptionId?: string | null;
16
+ }
17
+ export interface AccessibilityComboboxState<TKey extends SelectKey = SelectKey> {
18
+ expanded: boolean;
19
+ disabled: boolean;
20
+ readonly: boolean;
21
+ searchable: boolean;
22
+ multiple: boolean;
23
+ required: boolean;
24
+ invalid: boolean;
25
+ busy: boolean;
26
+ activeKey: TKey | null;
27
+ selectedKeys: ReadonlySet<TKey>;
28
+ disabledKeys: ReadonlySet<TKey>;
29
+ popupRole: AccessibilityPopupRole;
30
+ label: AccessibilityLabelState;
31
+ validation: AccessibilityValidationState;
32
+ }
33
+ export interface ComboboxAccessibilityIntent<TKey extends SelectKey = SelectKey> {
34
+ role: 'combobox';
35
+ expanded: boolean;
36
+ disabled: boolean;
37
+ readonly: boolean;
38
+ autocomplete: 'none' | 'list';
39
+ multiple: boolean;
40
+ required: boolean;
41
+ invalid: boolean;
42
+ activeKey: TKey | null;
43
+ controlsId: string | null;
44
+ labelledBy: readonly string[];
45
+ describedBy: readonly string[];
46
+ ariaLabel: string | null;
47
+ ariaDescription: string | null;
48
+ }
49
+ export interface ListboxAccessibilityIntent {
50
+ role: AccessibilityPopupRole;
51
+ multiple: boolean;
52
+ busy: boolean;
53
+ labelledBy: readonly string[];
54
+ ariaLabel: string | null;
55
+ }
56
+ export interface OptionAccessibilityIntent<TKey extends SelectKey = SelectKey> {
57
+ key: TKey;
58
+ selected: boolean;
59
+ disabled: boolean;
60
+ active: boolean;
61
+ }
62
+ export interface AccessibilityAnnouncementIntent {
63
+ politeness: 'polite' | 'assertive';
64
+ message: string;
65
+ }
66
+ export interface AccessibilityFocusIntent {
67
+ target: 'input' | 'clear-button' | 'active-option' | 'none';
68
+ reason: string;
69
+ }
70
+ export type AccessibilityEffect<TKey extends SelectKey = SelectKey> = (ComboboxAccessibilityIntent<TKey> & {
71
+ type: 'SYNC_COMBOBOX_ARIA';
72
+ }) | (ListboxAccessibilityIntent & {
73
+ type: 'SYNC_LISTBOX_ARIA';
74
+ }) | (OptionAccessibilityIntent<TKey> & {
75
+ type: 'SYNC_OPTION_ARIA';
76
+ }) | ({
77
+ type: 'ANNOUNCE';
78
+ } & AccessibilityAnnouncementIntent) | ({
79
+ type: 'FOCUS_INTENT';
80
+ } & AccessibilityFocusIntent);
81
+ export interface AccessibilityEffectOptions<TKey extends SelectKey = SelectKey> {
82
+ /** A caller-provided target ID; the engine never generates DOM IDs. */
83
+ controlsId?: string | null;
84
+ /** Keys of options the caller wants accessibility intent for. */
85
+ optionKeys: readonly TKey[];
86
+ announcements?: readonly AccessibilityAnnouncementIntent[];
87
+ focusIntents?: readonly AccessibilityFocusIntent[];
88
+ }
89
+ export interface AccessibilityStateContext {
90
+ readonly?: boolean;
91
+ searchable?: boolean;
92
+ invalid?: boolean;
93
+ label?: AccessibilityLabelState;
94
+ errorMessage?: string | null;
95
+ errorDescriptionId?: string | null;
96
+ }
97
+ /** Projects existing engine state into accessibility semantics without DOM data. */
98
+ export declare function deriveAccessibilityState<TKey extends SelectKey>(state: SelectState<TKey>, context?: AccessibilityStateContext): AccessibilityComboboxState<TKey>;
99
+ /** Computes combobox semantics without reading from or writing to the DOM. */
100
+ export declare function computeComboboxAccessibility<TKey extends SelectKey>(state: AccessibilityComboboxState<TKey>, controlsId?: string | null): ComboboxAccessibilityIntent<TKey>;
101
+ /** Computes listbox semantics; the supplied label IDs remain caller-owned data. */
102
+ export declare function computeListboxAccessibility<TKey extends SelectKey>(state: AccessibilityComboboxState<TKey>): ListboxAccessibilityIntent;
103
+ /** Computes one option's semantic state from stable identity, never its index. */
104
+ export declare function computeOptionAccessibility<TKey extends SelectKey>(state: AccessibilityComboboxState<TKey>, key: TKey): OptionAccessibilityIntent<TKey>;
105
+ /**
106
+ * Produces semantic accessibility effects. IDs and rendered option keys are
107
+ * caller inputs; this function does not inspect the DOM or perform side effects.
108
+ */
109
+ export declare function computeAccessibilityEffects<TKey extends SelectKey>(state: AccessibilityComboboxState<TKey>, options: AccessibilityEffectOptions<TKey>): AccessibilityEffect<TKey>[];
@@ -0,0 +1,4 @@
1
+ export type SelectKey = string | number;
2
+ export type CloseReason = 'escape' | 'outside-pointer' | 'selection' | 'blur' | 'programmatic' | 'disabled' | 'disconnect';
3
+ export type { ItemAdapter } from './item-adapter.js';
4
+ export type SelectionMode = 'single' | 'multi';
@@ -0,0 +1,9 @@
1
+ export * from './contracts.js';
2
+ export * from './item-adapter.js';
3
+ export * from './item-registry.js';
4
+ export * from './select-effects.js';
5
+ export * from './select-events.js';
6
+ export * from './select-machine.js';
7
+ export * from './select-state.js';
8
+ export * from './selectors.js';
9
+ export * from './selection-policy.js';
@@ -0,0 +1,23 @@
1
+ import type { SelectKey } from './contracts.js';
2
+ /** Extract identity separately from the outward value and presentation fields. */
3
+ export interface ItemAdapter<TItem, TKey extends SelectKey = SelectKey, TValue = unknown> {
4
+ getKey(item: TItem, index: number): TKey;
5
+ getValue(item: TItem, index: number): TValue;
6
+ getLabel(item: TItem, index: number): string;
7
+ isDisabled?(item: TItem, index: number): boolean;
8
+ getGroupKey?(item: TItem, index: number): string | null;
9
+ }
10
+ export interface DefaultItemAdapterOptions<TItem = unknown, TValue = unknown> {
11
+ getKey?: (item: TItem, index: number) => SelectKey;
12
+ valueField?: string;
13
+ labelField?: string;
14
+ getValue?: (item: TItem, index: number) => TValue;
15
+ getLabel?: (item: TItem, index: number) => string;
16
+ isDisabled?: (item: TItem, index: number) => boolean;
17
+ getGroupKey?: (item: TItem, index: number) => string | null;
18
+ /** Explicit compatibility opt-in for keyless references; defaults to identity. */
19
+ keyFallback?: 'identity' | 'index';
20
+ onIndexFallback?: (message: string) => void;
21
+ }
22
+ /** Generated reference keys survive reorder, but not replacement with new objects. */
23
+ export declare function createDefaultItemAdapter<TItem = unknown, TValue = unknown>(options?: DefaultItemAdapterOptions<TItem, TValue>): ItemAdapter<TItem>;
@@ -0,0 +1,31 @@
1
+ import type { SelectKey } from './contracts.js';
2
+ import type { ItemAdapter } from './item-adapter.js';
3
+ export type DuplicateKeyPolicy = 'throw' | 'warn' | 'first-wins' | 'last-wins';
4
+ export interface DuplicateKeyDiagnostic<TKey extends SelectKey = SelectKey> {
5
+ readonly key: TKey;
6
+ readonly firstIndex: number;
7
+ readonly duplicateIndex: number;
8
+ }
9
+ export interface ItemRecord<TItem, TKey extends SelectKey = SelectKey> {
10
+ readonly key: TKey;
11
+ readonly item: TItem;
12
+ readonly index: number;
13
+ readonly label: string;
14
+ readonly value: unknown;
15
+ readonly disabled: boolean;
16
+ readonly groupKey: string | null;
17
+ }
18
+ export interface ItemRegistry<TItem, TKey extends SelectKey = SelectKey> {
19
+ /** Every input position, including duplicates; key lookups resolve the winner. */
20
+ readonly records: readonly ItemRecord<TItem, TKey>[];
21
+ readonly keyToRecord: ReadonlyMap<TKey, ItemRecord<TItem, TKey>>;
22
+ readonly indexToKey: ReadonlyMap<number, TKey>;
23
+ readonly keyToIndex: ReadonlyMap<TKey, number>;
24
+ readonly duplicateKeys: readonly DuplicateKeyDiagnostic<TKey>[];
25
+ }
26
+ export interface ItemRegistryOptions<TKey extends SelectKey = SelectKey> {
27
+ duplicateKeyPolicy?: DuplicateKeyPolicy;
28
+ onDuplicateKey?: (diagnostic: DuplicateKeyDiagnostic<TKey>) => void;
29
+ }
30
+ export declare function getDefaultDuplicateKeyPolicy(): DuplicateKeyPolicy;
31
+ export declare function createItemRegistry<TItem, TKey extends SelectKey = SelectKey>(items: readonly TItem[], adapter: ItemAdapter<TItem, TKey>, options?: ItemRegistryOptions<TKey>): ItemRegistry<TItem, TKey>;
@@ -0,0 +1,20 @@
1
+ import type { CloseReason, SelectKey } from './contracts.js';
2
+ import type { ActiveReason, SelectionReason } from './selection-policy.js';
3
+ export type SelectEffect<K extends SelectKey = SelectKey> = {
4
+ type: 'POPUP_OPENED';
5
+ } | {
6
+ type: 'POPUP_CLOSED';
7
+ reason: CloseReason;
8
+ } | {
9
+ type: 'ACTIVE_KEY_CHANGED';
10
+ activeKey: K | null;
11
+ reason: ActiveReason;
12
+ } | {
13
+ type: 'SELECTION_CHANGED';
14
+ selectedKeys: readonly K[];
15
+ reason: SelectionReason;
16
+ } | {
17
+ type: 'FOCUS_TRIGGER';
18
+ } | {
19
+ type: 'SYNC_ARIA';
20
+ };
@@ -0,0 +1,55 @@
1
+ import type { CloseReason, SelectKey } from './contracts.js';
2
+ import type { ActiveReason, SelectionReason } from './selection-policy.js';
3
+ export type SelectEvent<K extends SelectKey = SelectKey> = {
4
+ type: 'CONNECT';
5
+ } | {
6
+ type: 'DISCONNECT';
7
+ } | {
8
+ type: 'OPEN_REQUEST';
9
+ } | {
10
+ type: 'CLOSE_REQUEST';
11
+ reason: CloseReason;
12
+ } | {
13
+ type: 'TOGGLE_REQUEST';
14
+ } | {
15
+ type: 'FOCUS_GAINED';
16
+ } | {
17
+ type: 'FOCUS_LOST';
18
+ } | {
19
+ type: 'DISABLED_CHANGED';
20
+ disabled: boolean;
21
+ } | {
22
+ type: 'ITEMS_REGISTERED';
23
+ keys: readonly K[];
24
+ disabledKeys?: readonly K[];
25
+ } | {
26
+ type: 'SELECTION_CONFIG_CHANGED';
27
+ multiple?: boolean;
28
+ required?: boolean;
29
+ allowDeselect?: boolean;
30
+ maxSelections?: number;
31
+ disabledKeys?: readonly K[];
32
+ } | {
33
+ type: 'ACTIVE_KEY_CHANGED';
34
+ key: K | null;
35
+ reason: ActiveReason;
36
+ } | {
37
+ type: 'SELECT_KEY_REQUEST';
38
+ key: K;
39
+ reason: SelectionReason;
40
+ } | {
41
+ type: 'DESELECT_KEY_REQUEST';
42
+ key: K;
43
+ reason: SelectionReason;
44
+ } | {
45
+ type: 'TOGGLE_KEY_REQUEST';
46
+ key: K;
47
+ reason: SelectionReason;
48
+ } | {
49
+ type: 'CLEAR_SELECTION_REQUEST';
50
+ reason: SelectionReason;
51
+ } | {
52
+ type: 'REPLACE_SELECTION_REQUEST';
53
+ keys: readonly K[];
54
+ reason: SelectionReason;
55
+ };
@@ -0,0 +1,9 @@
1
+ import type { SelectKey } from './contracts.js';
2
+ import type { SelectEffect } from './select-effects.js';
3
+ import type { SelectEvent } from './select-events.js';
4
+ import type { SelectState } from './select-state.js';
5
+ export interface TransitionResult<K extends SelectKey = SelectKey> {
6
+ state: SelectState<K>;
7
+ effects: SelectEffect<K>[];
8
+ }
9
+ export declare function transition<K extends SelectKey>(state: SelectState<K>, event: SelectEvent<K>): TransitionResult<K>;
@@ -0,0 +1,17 @@
1
+ import type { SelectKey } from './contracts.js';
2
+ import type { SelectionConfig } from './selection-policy.js';
3
+ export interface SelectState<K extends SelectKey = SelectKey> {
4
+ lifecycle: 'disconnected' | 'connected';
5
+ popup: 'closed' | 'open';
6
+ disabled: boolean;
7
+ focused: boolean;
8
+ query: string;
9
+ /** Navigation identity; must be registered and enabled, or null. */
10
+ activeKey: K | null;
11
+ /** Selection identity survives absence from the current registered/visible set. */
12
+ selectedKeys: ReadonlySet<K>;
13
+ registeredKeys: ReadonlySet<K>;
14
+ selection: SelectionConfig<K>;
15
+ dataStatus: 'idle' | 'loading' | 'error';
16
+ }
17
+ export declare function createInitialSelectState<K extends SelectKey = SelectKey>(): SelectState<K>;
@@ -0,0 +1,33 @@
1
+ import type { SelectKey } from './contracts.js';
2
+ export type SelectionReason = 'pointer' | 'keyboard' | 'programmatic' | 'form-reset' | 'external-value-sync';
3
+ export type ActiveReason = 'keyboard' | 'pointer' | 'search' | 'open' | 'programmatic';
4
+ export interface SelectionConfig<TKey extends SelectKey = SelectKey> {
5
+ multiple: boolean;
6
+ required: boolean;
7
+ /** Allows toggling off a selected single item; explicit deselect/clear still respect required. */
8
+ allowDeselect: boolean;
9
+ disabledKeys: ReadonlySet<TKey>;
10
+ maxSelections?: number;
11
+ }
12
+ export type SelectionRequest<TKey extends SelectKey = SelectKey> = {
13
+ type: 'select';
14
+ key: TKey;
15
+ reason: SelectionReason;
16
+ } | {
17
+ type: 'deselect';
18
+ key: TKey;
19
+ reason: SelectionReason;
20
+ } | {
21
+ type: 'toggle';
22
+ key: TKey;
23
+ reason: SelectionReason;
24
+ } | {
25
+ type: 'clear';
26
+ reason: SelectionReason;
27
+ } | {
28
+ type: 'replace';
29
+ keys: readonly TKey[];
30
+ reason: SelectionReason;
31
+ };
32
+ /** Pure key policy. Visibility does not constrain selection; disabled keys do. */
33
+ export declare function applySelectionRequest<TKey extends SelectKey>(selectedKeys: ReadonlySet<TKey>, request: SelectionRequest<TKey>, config: SelectionConfig<TKey>): ReadonlySet<TKey>;
@@ -0,0 +1,10 @@
1
+ import type { SelectKey } from './contracts.js';
2
+ import type { SelectState } from './select-state.js';
3
+ export declare function isOpen<K extends SelectKey>(state: SelectState<K>): boolean;
4
+ export declare function isDisabled<K extends SelectKey>(state: SelectState<K>): boolean;
5
+ export declare function isFocused<K extends SelectKey>(state: SelectState<K>): boolean;
6
+ export declare function hasSelection<K extends SelectKey>(state: SelectState<K>): boolean;
7
+ export declare function isSelected<K extends SelectKey>(state: SelectState<K>, key: K): boolean;
8
+ export declare function getSelectedKeys<K extends SelectKey>(state: SelectState<K>): K[];
9
+ export declare function getActiveKey<K extends SelectKey>(state: SelectState<K>): K | null;
10
+ export declare function isRegisteredKey<K extends SelectKey>(state: SelectState<K>, key: K): boolean;
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Pure identity and viewport helpers for virtualization. This module models
3
+ * logical keys and caller-supplied render state; it never inspects the DOM.
4
+ */
5
+ export interface VirtualizationScope<TKey> {
6
+ dataKeys: readonly TKey[];
7
+ filteredKeys: readonly TKey[];
8
+ registeredKeys: readonly TKey[];
9
+ windowKeys: readonly TKey[];
10
+ mountedKeys: readonly TKey[];
11
+ selectedKeys: ReadonlySet<TKey>;
12
+ activeKey: TKey | null;
13
+ }
14
+ export type VirtualizationScopeViolation = 'filtered-key-missing-from-data' | 'registered-key-not-filtered' | 'viewport-key-not-filtered' | 'mounted-key-not-in-viewport';
15
+ export type AriaActiveDescendantEligibility<TKey> = {
16
+ available: true;
17
+ key: TKey;
18
+ optionId: string;
19
+ } | {
20
+ available: false;
21
+ key: TKey | null;
22
+ optionId: null;
23
+ };
24
+ export interface ScrollToKeyIntent<TKey> {
25
+ type: 'SCROLL_TO_KEY';
26
+ key: TKey;
27
+ }
28
+ export interface ScrollToIndexIntent<TGeneration extends string | number> {
29
+ type: 'SCROLL_TO_INDEX';
30
+ index: number;
31
+ dataGeneration: TGeneration;
32
+ }
33
+ /** Returns whether a selected key remains in the filtered result set. */
34
+ export declare function isSelectedKeyVisible<TKey>(scope: VirtualizationScope<TKey>, key: TKey): boolean;
35
+ /** True only when the authoritative active key has a currently mounted target. */
36
+ export declare function isActiveKeyMounted<TKey>(scope: VirtualizationScope<TKey>): boolean;
37
+ /**
38
+ * Produces active-descendant eligibility from mounted keys and caller-provided
39
+ * IDs. A registered or windowed key alone is not a mounted DOM target.
40
+ */
41
+ export declare function getAriaActiveDescendantEligibility<TKey>(scope: VirtualizationScope<TKey>, optionIds: ReadonlyMap<TKey, string>): AriaActiveDescendantEligibility<TKey>;
42
+ /** Copies selected identity without pruning keys absent from the current viewport. */
43
+ export declare function preserveSelectionAcrossWindow<TKey>(selectedKeys: ReadonlySet<TKey>, _windowKeys: readonly TKey[]): Set<TKey>;
44
+ /** Resolves the key's current index, so reorder never reuses a stale index. */
45
+ export declare function resolveKeyIndex<TKey>(keys: readonly TKey[], key: TKey): number;
46
+ /**
47
+ * Returns keys in the half-open index range [startIndex, endIndex), clamped to
48
+ * the source. Bounds are truncated to integers; an end before start is empty.
49
+ */
50
+ export declare function computeWindowKeys<TKey>(filteredKeys: readonly TKey[], startIndex: number, endIndex: number): TKey[];
51
+ /** Creates a DOM-free request to bring a stable key into the rendered range. */
52
+ export declare function createScrollToKeyIntent<TKey>(key: TKey): ScrollToKeyIntent<TKey>;
53
+ /** Creates an index request tied to the data generation that defined it. */
54
+ export declare function createScrollToIndexIntent<TGeneration extends string | number>(index: number, dataGeneration: TGeneration): ScrollToIndexIntent<TGeneration>;
55
+ /** Lists violated subset relationships without changing the supplied scope. */
56
+ export declare function getVirtualizationScopeViolations<TKey>(scope: VirtualizationScope<TKey>): VirtualizationScopeViolation[];
@@ -2,10 +2,14 @@ export * from './types.js';
2
2
  export type { SelectEventDetail, OpenEventDetail, CloseEventDetail, SearchEventDetail, ChangeEventDetail, LoadMoreEventDetail, RemoveEventDetail, ClearEventDetail, ErrorEventDetail, PageLoadedEventDetail, GroupedItem, RemoteConfig, Placement, Strategy, NativeSelectOptions, RendererHelpers, SelectEventsDetailMap, SelectEventName } from './types.js';
3
3
  export type { CustomOptionContract, CustomOptionContext, CustomOptionFactory, ExtendedSelectItem, OptionRendererMode, CustomOptionConfig, CustomOptionEvents } from './types/custom-option.js';
4
4
  export * from './renderers/contracts.js';
5
+ export * from './engine/index.js';
6
+ export * from './platform/web/index.js';
5
7
  export * from './components/native-select.js';
6
8
  export * from './components/enhanced-select.js';
7
9
  export * from './components/select-option.js';
8
10
  export * from './config/global-config.js';
11
+ export type { SelectionConfig } from './config/global-config.js';
12
+ export type { SelectionConfig as EngineSelectionConfig } from './engine/selection-policy.js';
9
13
  export { FenwickTree } from './utils/fenwick-tree.js';
10
14
  export { DOMPool } from './utils/dom-pool.js';
11
15
  export { WorkerManager, getWorkerManager } from './utils/worker-manager.js';
@@ -0,0 +1,19 @@
1
+ import type { SelectKey } from '../../engine/contracts.js';
2
+ import type { AccessibilityEffect } from '../../engine/accessibility.js';
3
+ export interface WebAccessibilityTargets<TKey extends SelectKey = SelectKey> {
4
+ combobox?: HTMLElement | null;
5
+ listbox?: HTMLElement | null;
6
+ getOptionByKey?: (key: TKey) => HTMLElement | null;
7
+ liveRegion?: HTMLElement | null;
8
+ focusTargets?: {
9
+ input?: HTMLElement | null;
10
+ clearButton?: HTMLElement | null;
11
+ getActiveOption?: () => HTMLElement | null;
12
+ };
13
+ }
14
+ export interface ApplyAccessibilityEffectOptions {
15
+ /** Focus is opt-in so applying semantic state does not add focus behavior. */
16
+ applyFocus?: boolean;
17
+ }
18
+ /** Applies engine accessibility effects to caller-owned web DOM targets. */
19
+ export declare function applyAccessibilityEffects<TKey extends SelectKey>(effects: readonly AccessibilityEffect<TKey>[], targets: WebAccessibilityTargets<TKey>, options?: ApplyAccessibilityEffectOptions): void;