@smilodon/core 1.18.0 → 1.20.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.
@@ -43,6 +43,11 @@ export declare class EnhancedSelect extends HTMLElement implements EnhancedSelec
43
43
  private _engine;
44
44
  private _virtualizationScope;
45
45
  private _renderPlan;
46
+ private _selectedOptionsSelectionAtOpen;
47
+ private _selectedOptionsConfigAtOpen;
48
+ private _scrollToSelectedConfigAtOpen;
49
+ private _closedOptionsViewportAnchor;
50
+ private _openOptionsViewportAnchor;
46
51
  private _emptyStateContext;
47
52
  private _guardedVirtualWindow;
48
53
  private _guardedVirtualizer;
@@ -102,7 +107,7 @@ export declare class EnhancedSelect extends HTMLElement implements EnhancedSelec
102
107
  private _clearControlIcon?;
103
108
  private _pendingFirstRenderMark;
104
109
  private _pendingSearchRenderMark;
105
- private _rangeAnchorIndex;
110
+ private _rangeAnchorKey;
106
111
  /** Chip identity is tracked independently of dropdown option positions. */
107
112
  private _lastRenderedChipKeys;
108
113
  private _latestChipScrollGeneration;
@@ -125,6 +130,9 @@ export declare class EnhancedSelect extends HTMLElement implements EnhancedSelec
125
130
  private _lifecycleTimers;
126
131
  private _lifecycleRafs;
127
132
  private _keyboardActiveChangeGeneration;
133
+ /** Invalidates selected-option positioning scheduled by an earlier opening. */
134
+ private _openSelectedScrollGeneration;
135
+ private _openSelectedScrollCleanup;
128
136
  private _tracking;
129
137
  private _suppressBlurClose;
130
138
  private _renderCycleId;
@@ -250,6 +258,18 @@ export declare class EnhancedSelect extends HTMLElement implements EnhancedSelec
250
258
  private _applyFocusIntent;
251
259
  private _handleOpen;
252
260
  private _handleClose;
261
+ /**
262
+ * Defer the one automatic selected-option positioning operation until the
263
+ * dropdown's own entrance geometry has settled. Logical active/ARIA state
264
+ * remains synchronous in _setInitialActiveOption().
265
+ */
266
+ private _scheduleOpenSelectedScroll;
267
+ private _cancelOpenSelectedScroll;
268
+ private _captureOptionsViewportAnchor;
269
+ /** Restore the previous visible option only when this opening changed order. */
270
+ private _restorePreservedOptionsViewport;
271
+ /** Used only when Element.getAnimations() is unavailable. */
272
+ private _getDropdownEntranceFallbackDurationMs;
253
273
  /** Stop an outstanding exit before reopening, disconnecting or starting another one. */
254
274
  private _cancelDropdownExit;
255
275
  private _finishDropdownExit;
@@ -274,6 +294,12 @@ export declare class EnhancedSelect extends HTMLElement implements EnhancedSelec
274
294
  private _handleSearch;
275
295
  private _handleKeydown;
276
296
  private _moveActive;
297
+ private _usesSelectedFirstVisualOrder;
298
+ private _getVisualNavigationModel;
299
+ private _setActiveForVisualKey;
300
+ private _moveToVisualBoundary;
301
+ private _selectKeyboardRange;
302
+ private _selectVisualRange;
277
303
  /** Return true only when boundary navigation is held for an in-flight/new page. */
278
304
  private _requestKeyboardLoadMore;
279
305
  private _setActive;
@@ -295,6 +321,7 @@ export declare class EnhancedSelect extends HTMLElement implements EnhancedSelec
295
321
  private _isActivelyEditingSearchInput;
296
322
  private _renderOptionsWithAnimation;
297
323
  private _scrollToSelected;
324
+ private _scrollOptionWithinOptionsContainer;
298
325
  private _loadMoreItems;
299
326
  private _setBusy;
300
327
  private _handleError;
@@ -424,6 +451,8 @@ export declare class EnhancedSelect extends HTMLElement implements EnhancedSelec
424
451
  /** Retries only from the canonical accepted coordinator snapshot, never a host payload. */
425
452
  private _retryAcknowledgedProjectionForTest;
426
453
  private _retryAcknowledgedProjection;
454
+ private _acknowledgedSnapshotDiffersFromLoadedItems;
455
+ private _reconcileAcknowledgedSnapshot;
427
456
  private _projectAcknowledgedSnapshot;
428
457
  private _applyAcknowledgedSnapshot;
429
458
  private _recordAcknowledgedProjectionFailure;
@@ -3,6 +3,15 @@
3
3
  * Allows users to define default behaviors that can be overridden at component level
4
4
  */
5
5
  import type { KnownLimitationId, LimitationPolicy } from '../types/limitation.js';
6
+ export type SelectedOptionsPlacement = 'original' | 'selected-first';
7
+ export type SelectedOptionsGroupedPlacement = 'within-group';
8
+ export type ScrollToSelectedOnOpen = 'preserve' | 'reveal' | 'align';
9
+ export interface SelectedOptionsConfig {
10
+ /** Presentation order; does not mutate the caller's source collection. */
11
+ placement: SelectedOptionsPlacement;
12
+ /** Selected-item presentation policy when source options are grouped. */
13
+ groupedPlacement: SelectedOptionsGroupedPlacement;
14
+ }
6
15
  type ScrollToSelectedBehavior = 'auto' | 'instant' | 'smooth';
7
16
  type ScrollToSelectedBlock = 'start' | 'center' | 'end' | 'nearest';
8
17
  export interface ScrollToSelectedConfig {
@@ -10,6 +19,8 @@ export interface ScrollToSelectedConfig {
10
19
  enabled: boolean;
11
20
  /** Which selected item to scroll to in multi-select mode: 'first' | 'last' */
12
21
  multiSelectTarget: 'first' | 'last';
22
+ /** Positioning policy when the dropdown opens. */
23
+ onOpen: ScrollToSelectedOnOpen;
13
24
  /** Scroll behavior */
14
25
  behavior?: ScrollToSelectedBehavior;
15
26
  /** Scroll block alignment */
@@ -264,6 +275,8 @@ export interface GlobalSelectConfig {
264
275
  multiSelectDisplay: MultiSelectDisplayConfig;
265
276
  /** Scroll to selected configuration */
266
277
  scrollToSelected: ScrollToSelectedConfig;
278
+ /** Selected-option presentation policy */
279
+ selectedOptions: SelectedOptionsConfig;
267
280
  /** Load more configuration */
268
281
  loadMore: LoadMoreConfig;
269
282
  /** Busy bucket configuration */
@@ -295,6 +308,11 @@ export interface GlobalSelectConfig {
295
308
  /** Estimated row height used by the guarded EnhancedSelect viewport-windowing test path. */
296
309
  estimatedItemHeight?: number;
297
310
  }
311
+ /** Partial global/per-instance update shape for nested selected-option settings. */
312
+ export type SelectConfigUpdate = Omit<Partial<GlobalSelectConfig>, 'selectedOptions' | 'scrollToSelected'> & {
313
+ selectedOptions?: Partial<SelectedOptionsConfig>;
314
+ scrollToSelected?: Partial<ScrollToSelectedConfig>;
315
+ };
298
316
  /**
299
317
  * Global configuration instance
300
318
  */
@@ -308,7 +326,7 @@ declare class SelectConfigManager {
308
326
  /**
309
327
  * Update global configuration (deep merge)
310
328
  */
311
- updateConfig(updates: Partial<GlobalSelectConfig>): void;
329
+ updateConfig(updates: SelectConfigUpdate): void;
312
330
  /**
313
331
  * Reset to default configuration
314
332
  */
@@ -317,7 +335,7 @@ declare class SelectConfigManager {
317
335
  * Merge component-level config with global config
318
336
  * Component-level config takes precedence
319
337
  */
320
- mergeWithComponentConfig(componentConfig: Partial<GlobalSelectConfig>): GlobalSelectConfig;
338
+ mergeWithComponentConfig(componentConfig: SelectConfigUpdate): GlobalSelectConfig;
321
339
  private deepClone;
322
340
  private deepMerge;
323
341
  }
@@ -328,7 +346,7 @@ export declare const selectConfig: SelectConfigManager;
328
346
  /**
329
347
  * Helper function to configure select globally
330
348
  */
331
- export declare function configureSelect(config: Partial<GlobalSelectConfig>): void;
349
+ export declare function configureSelect(config: SelectConfigUpdate): void;
332
350
  /**
333
351
  * Helper function to reset select configuration
334
352
  */
@@ -0,0 +1,21 @@
1
+ import type { ScrollToSelectedConfig, SelectedOptionsConfig, SelectConfigUpdate } from './global-config.js';
2
+ export interface PublicConfigIssue {
3
+ path: string;
4
+ code: 'invalid-type' | 'invalid-value' | 'unknown-field';
5
+ message: string;
6
+ }
7
+ export type PublicConfigValidationResult<T> = {
8
+ valid: true;
9
+ value: T;
10
+ } | {
11
+ valid: false;
12
+ issues: readonly PublicConfigIssue[];
13
+ };
14
+ type ConfigPatch<T> = Partial<T>;
15
+ /** Validate a partial selected-options configuration update. */
16
+ export declare function validateSelectedOptionsConfig(candidate: unknown): PublicConfigValidationResult<ConfigPatch<SelectedOptionsConfig>>;
17
+ /** Validate a partial scroll-to-selected configuration update. */
18
+ export declare function validateScrollToSelectedConfig(candidate: unknown): PublicConfigValidationResult<ConfigPatch<ScrollToSelectedConfig>>;
19
+ /** Validate and copy only the new public configuration sections. */
20
+ export declare function validateSelectedOptionsConfigUpdate(config: SelectConfigUpdate): SelectConfigUpdate;
21
+ export {};
@@ -1,4 +1,4 @@
1
- import type { CallbackConfig, GlobalSelectConfig } from '../config/global-config.js';
1
+ import type { CallbackConfig, GlobalSelectConfig, ScrollToSelectedConfig, SelectedOptionsConfig } from '../config/global-config.js';
2
2
  export type DataRequestId = string;
3
3
  export type QueryGeneration = number;
4
4
  export type PageCursor = string | number;
@@ -8,21 +8,26 @@ export interface DataLoadingConfig {
8
8
  paginationMode?: 'page' | 'cursor';
9
9
  firstPage?: number;
10
10
  fetchLimit?: number;
11
+ /** Minimum trimmed Unicode code points before acknowledged remote search dispatches. */
12
+ minSearchCharacters?: number;
11
13
  }
12
14
  export interface ResolvedDataLoadingConfig {
13
15
  readonly protocol: 'legacy' | 'acknowledged';
14
16
  readonly searchMode: 'local' | 'remote' | 'hybrid';
15
17
  readonly paginationMode: 'page' | 'cursor';
16
18
  readonly firstPage: number;
19
+ readonly minSearchCharacters: number;
17
20
  readonly fetchLimit?: number;
18
21
  }
19
22
  export type AcknowledgedCoreCallbacks = Omit<Partial<CallbackConfig>, 'onSearch' | 'onLoadMore'> & {
20
23
  onSearch?: (query: string, request?: SearchDataRequest) => void;
21
24
  onLoadMore?: (page: number, request?: LoadMoreDataRequest) => void;
22
25
  } & AcknowledgedCallbackAdditions;
23
- export type SelectInstanceConfig = Omit<Partial<GlobalSelectConfig>, 'callbacks'> & {
26
+ export type SelectInstanceConfig = Omit<Partial<GlobalSelectConfig>, 'callbacks' | 'selectedOptions' | 'scrollToSelected'> & {
24
27
  callbacks?: AcknowledgedCoreCallbacks;
25
28
  dataLoading?: Partial<DataLoadingConfig>;
29
+ selectedOptions?: Partial<SelectedOptionsConfig>;
30
+ scrollToSelected?: Partial<ScrollToSelectedConfig>;
26
31
  };
27
32
  export type DataLoadingConfigIssueCode = 'unknown-field' | 'invalid-type' | 'invalid-value' | 'invalid-positive-integer' | 'requires-acknowledged-protocol';
28
33
  export interface DataLoadingConfigIssue {
@@ -15,6 +15,7 @@ export interface DataLoadingConfig {
15
15
  paginationMode?: DataPaginationMode;
16
16
  firstPage?: number;
17
17
  fetchLimit?: number;
18
+ minSearchCharacters?: number;
18
19
  /** Internal acknowledged-cursor policy; not a public component option yet. */
19
20
  maxCursorPages?: number;
20
21
  /** UTF-8 bytes per opaque cursor; internal until component integration is authorized. */
@@ -127,6 +128,7 @@ export interface ResolvedDataCoordinatorConfig {
127
128
  readonly searchMode: DataSearchMode;
128
129
  readonly paginationMode: DataPaginationMode;
129
130
  readonly firstPage: number;
131
+ readonly minSearchCharacters: number;
130
132
  readonly initialPage: number;
131
133
  readonly fetchLimit?: number;
132
134
  readonly maxCursorPages: number;
@@ -200,6 +202,8 @@ export declare class DataRequestCoordinator {
200
202
  private resourceLimit;
201
203
  private sentinelBlocked;
202
204
  private sentinelIntersecting;
205
+ /** Unfiltered items and continuation are independent from each filtered query. */
206
+ private browseState;
203
207
  constructor(options?: DataRequestCoordinatorOptions);
204
208
  getSnapshot(): DataCoordinatorSnapshot;
205
209
  /** Connect once, dispatching the initial remote/hybrid query when required. */
@@ -220,7 +224,12 @@ export declare class DataRequestCoordinator {
220
224
  disconnect(): readonly DataCoordinatorAction[];
221
225
  completeDataRequest(completion: unknown): DataRequestCompletionResult;
222
226
  private isRemoteMode;
227
+ private isSearchEligible;
228
+ private captureDataState;
229
+ private restoreBrowseState;
230
+ private resetQueryMetadata;
223
231
  private initialPosition;
232
+ private browseInitialPosition;
224
233
  private resetPaginationForRemoteQuery;
225
234
  /** Re-evaluate the local cursor cap without resetting accepted history. */
226
235
  private refreshCursorDepthLimit;
@@ -8,6 +8,8 @@ export * from './components/native-select.js';
8
8
  export * from './components/enhanced-select.js';
9
9
  export * from './components/select-option.js';
10
10
  export * from './config/global-config.js';
11
+ export { validateScrollToSelectedConfig, validateSelectedOptionsConfig, validateSelectedOptionsConfigUpdate, } from './config/public-config.js';
12
+ export type { PublicConfigIssue, PublicConfigValidationResult } from './config/public-config.js';
11
13
  export type * from './data-loading/public-types.js';
12
14
  export { validateDataLoadingConfig } from './data-loading/public-config.js';
13
15
  export type { SelectionConfig } from './config/global-config.js';
@@ -2,4 +2,4 @@
2
2
  * Platform-neutral public configuration types for native adapters.
3
3
  * This entry intentionally excludes Core's browser-only component declarations.
4
4
  */
5
- export type { GlobalSelectConfig, SelectionConfig, MultiSelectDisplayConfig, ScrollToSelectedConfig, StyleConfig, } from './config/global-config.js';
5
+ export type { GlobalSelectConfig, SelectedOptionsConfig, SelectConfigUpdate, SelectionConfig, MultiSelectDisplayConfig, ScrollToSelectedConfig, StyleConfig, } from './config/global-config.js';
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Return a presentation-only ordering for option keys.
3
+ *
4
+ * The source array and selection set are never mutated. Callers remain
5
+ * responsible for retaining the returned order as the displayed ordering for
6
+ * the relevant render/open transaction.
7
+ */
8
+ export declare function projectSelectedOptionKeys<K>(orderedKeys: readonly K[], selectedKeys: ReadonlySet<K>, placement: 'original' | 'selected-first'): K[];
9
+ export interface GroupedOptionKeys<GroupIdentity, K> {
10
+ /** Opaque identity; labels must not be used as a substitute for identity. */
11
+ groupIdentity: GroupIdentity;
12
+ orderedKeys: readonly K[];
13
+ }
14
+ /**
15
+ * Stably partitions selected keys to the front of each group independently.
16
+ * Group order, identity, membership, and the source arrays are preserved.
17
+ */
18
+ export declare function projectSelectedOptionGroups<GroupIdentity, K>(groups: readonly GroupedOptionKeys<GroupIdentity, K>[], selectedKeys: ReadonlySet<K>): GroupedOptionKeys<GroupIdentity, K>[];
@@ -0,0 +1,2 @@
1
+ /** Resolve the selected key at an edge of the displayed eligible ordering. */
2
+ export declare function resolveSelectedTargetKey<K>(orderedKeys: readonly K[], selectedKeys: ReadonlySet<K>, target: 'first' | 'last'): K | null;
@@ -0,0 +1,15 @@
1
+ /** A stable-key navigation view of the options in their rendered order. */
2
+ export interface VisualNavigationModel<K> {
3
+ orderedKeys: readonly K[];
4
+ selectableKeys: readonly K[];
5
+ /** Zero-based rendered position for every key, including non-selectable keys. */
6
+ positionByKey: ReadonlyMap<K, number>;
7
+ /** Position among keyboard eligible keys. */
8
+ selectablePositionByKey: ReadonlyMap<K, number>;
9
+ }
10
+ export declare function createVisualNavigationModel<K>(orderedKeys: readonly K[], isSelectable: (key: K) => boolean): VisualNavigationModel<K>;
11
+ /** Resolve a clamped keyboard movement in visual order. */
12
+ export declare function resolveVisualMovement<K>(model: VisualNavigationModel<K>, currentKey: K | null, delta: number): K | null;
13
+ export declare function resolveVisualBoundary<K>(model: VisualNavigationModel<K>, boundary: 'first' | 'last'): K | null;
14
+ /** Return selectable keys in the inclusive visual interval between two keys. */
15
+ export declare function resolveVisualRange<K>(model: VisualNavigationModel<K>, startKey: K, endKey: K): K[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smilodon/core",
3
- "version": "1.18.0",
3
+ "version": "1.20.0",
4
4
  "description": "High-performance native select component with extreme-scale virtualization - React, Vue, Svelte, Vanilla JS",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",