@smilodon/core 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/README.md +140 -377
- package/dist/index.cjs +4030 -297
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +4014 -298
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/index.umd.js +4030 -297
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/dist/types/src/components/enhanced-select.d.ts +172 -8
- package/dist/types/src/components/native-select.d.ts +1 -1
- package/dist/types/src/components/select-option.d.ts +2 -2
- package/dist/types/src/config/global-config.d.ts +7 -5
- package/dist/types/src/data-loading/public-config.d.ts +3 -0
- package/dist/types/src/data-loading/public-types.d.ts +171 -0
- package/dist/types/src/data-loading/request-coordinator.d.ts +236 -0
- package/dist/types/src/engine/accessibility.d.ts +109 -0
- package/dist/types/src/engine/contracts.d.ts +4 -0
- package/dist/types/src/engine/index.d.ts +9 -0
- package/dist/types/src/engine/item-adapter.d.ts +23 -0
- package/dist/types/src/engine/item-registry.d.ts +31 -0
- package/dist/types/src/engine/select-effects.d.ts +20 -0
- package/dist/types/src/engine/select-events.d.ts +55 -0
- package/dist/types/src/engine/select-machine.d.ts +9 -0
- package/dist/types/src/engine/select-state.d.ts +17 -0
- package/dist/types/src/engine/selection-policy.d.ts +33 -0
- package/dist/types/src/engine/selectors.d.ts +10 -0
- package/dist/types/src/engine/virtualization.d.ts +56 -0
- package/dist/types/src/index.d.ts +6 -0
- package/dist/types/src/native-types.d.ts +5 -0
- package/dist/types/src/platform/web/accessibility-effects.d.ts +19 -0
- package/dist/types/src/platform/web/index.d.ts +2 -0
- package/dist/types/src/platform/web/select-effect-runner.d.ts +15 -0
- package/dist/types/src/platform/web/select-engine-bridge.d.ts +10 -0
- package/dist/types/src/renderers/contracts.d.ts +1 -1
- package/dist/types/src/types/limitation.d.ts +6 -0
- package/dist/types/src/types.d.ts +2 -6
- package/dist/types/src/utils/custom-option-pool.d.ts +1 -1
- package/dist/types/src/utils/virtualizer.d.ts +48 -1
- package/package.json +7 -4
- package/dist/types/src/themes/importer.d.ts +0 -112
- package/dist/types/tests/capabilities-tracking.spec.d.ts +0 -1
- package/dist/types/tests/csp.spec.d.ts +0 -5
- package/dist/types/tests/enhanced-option-renderer.spec.d.ts +0 -1
- package/dist/types/tests/interaction.spec.d.ts +0 -1
- package/dist/types/tests/lifecycle.spec.d.ts +0 -1
- package/dist/types/tests/memory-lifecycle.spec.d.ts +0 -1
- package/dist/types/tests/setup.d.ts +0 -6
- package/dist/types/tests/shadow-dom.spec.d.ts +0 -5
- package/dist/types/tests/smoke.spec.d.ts +0 -1
- package/dist/types/tests/stress.spec.d.ts +0 -5
- package/dist/types/tests/styling-contract.spec.d.ts +0 -1
- package/dist/types/tests/virtualizer.spec.d.ts +0 -1
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DOM-independent coordinator for the opt-in acknowledged data-loading
|
|
3
|
+
* protocol. This module is intentionally not re-exported from the package
|
|
4
|
+
* entry point; public component/adapter integration is a later increment.
|
|
5
|
+
*/
|
|
6
|
+
export type DataRequestId = string;
|
|
7
|
+
export type QueryGeneration = number;
|
|
8
|
+
export type PageCursor = string | number;
|
|
9
|
+
export type DataRequestProtocol = 'legacy' | 'acknowledged';
|
|
10
|
+
export type DataSearchMode = 'local' | 'remote' | 'hybrid';
|
|
11
|
+
export type DataPaginationMode = 'page' | 'cursor';
|
|
12
|
+
export interface DataLoadingConfig {
|
|
13
|
+
protocol?: DataRequestProtocol;
|
|
14
|
+
searchMode?: DataSearchMode;
|
|
15
|
+
paginationMode?: DataPaginationMode;
|
|
16
|
+
firstPage?: number;
|
|
17
|
+
fetchLimit?: number;
|
|
18
|
+
/** Internal acknowledged-cursor policy; not a public component option yet. */
|
|
19
|
+
maxCursorPages?: number;
|
|
20
|
+
/** UTF-8 bytes per opaque cursor; internal until component integration is authorized. */
|
|
21
|
+
maxCursorTokenBytes?: number;
|
|
22
|
+
}
|
|
23
|
+
export interface DataCoordinatorConfig {
|
|
24
|
+
dataLoading?: DataLoadingConfig;
|
|
25
|
+
infiniteScroll?: {
|
|
26
|
+
pageSize?: number;
|
|
27
|
+
initialPage?: number;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export interface DataRequestBase {
|
|
31
|
+
readonly requestId: DataRequestId;
|
|
32
|
+
readonly queryGeneration: QueryGeneration;
|
|
33
|
+
readonly query: string;
|
|
34
|
+
readonly normalizedQuery: string;
|
|
35
|
+
readonly fetchLimit: number;
|
|
36
|
+
readonly position: PagePosition;
|
|
37
|
+
}
|
|
38
|
+
export interface SearchDataRequest extends DataRequestBase {
|
|
39
|
+
readonly kind: 'search';
|
|
40
|
+
readonly mode: 'remote' | 'hybrid';
|
|
41
|
+
}
|
|
42
|
+
export type PagePosition = Readonly<{
|
|
43
|
+
mode: 'page';
|
|
44
|
+
page: number;
|
|
45
|
+
}> | Readonly<{
|
|
46
|
+
mode: 'cursor';
|
|
47
|
+
cursor?: PageCursor;
|
|
48
|
+
ordinal: number;
|
|
49
|
+
}>;
|
|
50
|
+
export interface LoadMoreDataRequest extends DataRequestBase {
|
|
51
|
+
readonly kind: 'loadMore';
|
|
52
|
+
}
|
|
53
|
+
export type DataRequest = SearchDataRequest | LoadMoreDataRequest;
|
|
54
|
+
export interface DataRequestError {
|
|
55
|
+
readonly message: string;
|
|
56
|
+
readonly code?: string;
|
|
57
|
+
readonly retryable?: boolean;
|
|
58
|
+
}
|
|
59
|
+
export interface DataRequestCancelNotification {
|
|
60
|
+
readonly requestId: DataRequestId;
|
|
61
|
+
readonly queryGeneration: QueryGeneration;
|
|
62
|
+
readonly reason: 'query-changed' | 'config-changed' | 'disconnected';
|
|
63
|
+
}
|
|
64
|
+
export type DataRequestCompletion = Readonly<{
|
|
65
|
+
requestId: DataRequestId;
|
|
66
|
+
queryGeneration: QueryGeneration;
|
|
67
|
+
status: 'succeeded';
|
|
68
|
+
items: readonly unknown[];
|
|
69
|
+
hasMore: true;
|
|
70
|
+
nextCursor?: PageCursor;
|
|
71
|
+
}> | Readonly<{
|
|
72
|
+
requestId: DataRequestId;
|
|
73
|
+
queryGeneration: QueryGeneration;
|
|
74
|
+
status: 'empty';
|
|
75
|
+
hasMore: true;
|
|
76
|
+
advance: 'next' | 'retry';
|
|
77
|
+
nextCursor?: PageCursor;
|
|
78
|
+
}> | Readonly<{
|
|
79
|
+
requestId: DataRequestId;
|
|
80
|
+
queryGeneration: QueryGeneration;
|
|
81
|
+
status: 'exhausted';
|
|
82
|
+
items: readonly unknown[];
|
|
83
|
+
hasMore: false;
|
|
84
|
+
}> | Readonly<{
|
|
85
|
+
requestId: DataRequestId;
|
|
86
|
+
queryGeneration: QueryGeneration;
|
|
87
|
+
status: 'failed';
|
|
88
|
+
error: DataRequestError;
|
|
89
|
+
}> | Readonly<{
|
|
90
|
+
requestId: DataRequestId;
|
|
91
|
+
queryGeneration: QueryGeneration;
|
|
92
|
+
status: 'cancelled';
|
|
93
|
+
reason?: 'host-cancelled';
|
|
94
|
+
}>;
|
|
95
|
+
export type DataRequestCompletionResult = 'accepted' | 'stale' | 'unknown-request' | 'invalid' | 'resource-limit';
|
|
96
|
+
export type DataCoordinatorStatus = 'idle' | 'requested' | 'loading' | 'succeeded' | 'empty' | 'exhausted' | 'failed' | 'cancelled' | 'resource-limited';
|
|
97
|
+
export type DataCoordinatorResourceLimit = Readonly<{
|
|
98
|
+
reason: 'cursor-depth';
|
|
99
|
+
maxCursorPages: number;
|
|
100
|
+
requestId?: DataRequestId;
|
|
101
|
+
}> | Readonly<{
|
|
102
|
+
reason: 'cursor-token-size';
|
|
103
|
+
maxCursorTokenBytes: number;
|
|
104
|
+
actualCursorTokenBytes: number;
|
|
105
|
+
requestId: DataRequestId;
|
|
106
|
+
}>;
|
|
107
|
+
export type DataCoordinatorAction = Readonly<{
|
|
108
|
+
type: 'request';
|
|
109
|
+
request: DataRequest;
|
|
110
|
+
}> | Readonly<{
|
|
111
|
+
type: 'cancel';
|
|
112
|
+
notification: DataRequestCancelNotification;
|
|
113
|
+
}>;
|
|
114
|
+
export interface CoordinatorValidationIssue {
|
|
115
|
+
readonly field: string;
|
|
116
|
+
readonly message: string;
|
|
117
|
+
}
|
|
118
|
+
export type ConfigurationValidation = Readonly<{
|
|
119
|
+
valid: true;
|
|
120
|
+
value: ResolvedDataCoordinatorConfig;
|
|
121
|
+
}> | Readonly<{
|
|
122
|
+
valid: false;
|
|
123
|
+
errors: readonly CoordinatorValidationIssue[];
|
|
124
|
+
}>;
|
|
125
|
+
export interface ResolvedDataCoordinatorConfig {
|
|
126
|
+
readonly protocol: DataRequestProtocol;
|
|
127
|
+
readonly searchMode: DataSearchMode;
|
|
128
|
+
readonly paginationMode: DataPaginationMode;
|
|
129
|
+
readonly firstPage: number;
|
|
130
|
+
readonly initialPage: number;
|
|
131
|
+
readonly fetchLimit?: number;
|
|
132
|
+
readonly maxCursorPages: number;
|
|
133
|
+
readonly maxCursorTokenBytes: number;
|
|
134
|
+
}
|
|
135
|
+
export interface DataRequestCoordinatorOptions {
|
|
136
|
+
config?: DataCoordinatorConfig;
|
|
137
|
+
initialQuery?: string;
|
|
138
|
+
initialItems?: readonly unknown[];
|
|
139
|
+
/** Whether another page/position is available for an acknowledged local list. */
|
|
140
|
+
hasMore?: boolean;
|
|
141
|
+
}
|
|
142
|
+
export interface DataCoordinatorSnapshot {
|
|
143
|
+
readonly status: DataCoordinatorStatus;
|
|
144
|
+
readonly connected: boolean;
|
|
145
|
+
readonly busy: boolean;
|
|
146
|
+
readonly query: string;
|
|
147
|
+
readonly normalizedQuery: string;
|
|
148
|
+
readonly queryGeneration: QueryGeneration;
|
|
149
|
+
readonly items: readonly unknown[];
|
|
150
|
+
readonly hasMore: boolean;
|
|
151
|
+
readonly activeRequest: DataRequest | null;
|
|
152
|
+
readonly lastCommittedPage?: number;
|
|
153
|
+
readonly nextEligiblePosition: PagePosition;
|
|
154
|
+
readonly error: DataRequestError | null;
|
|
155
|
+
/** A bounded-resource outcome; never aliases server exhaustion. */
|
|
156
|
+
readonly resourceLimit: DataCoordinatorResourceLimit | null;
|
|
157
|
+
readonly sentinelBlocked: boolean;
|
|
158
|
+
readonly sentinelIntersecting: boolean;
|
|
159
|
+
}
|
|
160
|
+
export type ConfigurationUpdateResult = Readonly<{
|
|
161
|
+
status: 'accepted';
|
|
162
|
+
actions: readonly DataCoordinatorAction[];
|
|
163
|
+
}> | Readonly<{
|
|
164
|
+
status: 'invalid';
|
|
165
|
+
errors: readonly CoordinatorValidationIssue[];
|
|
166
|
+
}>;
|
|
167
|
+
export declare function validateDataCoordinatorConfig(config?: DataCoordinatorConfig): ConfigurationValidation;
|
|
168
|
+
/**
|
|
169
|
+
* Owns request identity and pagination state only. It has no DOM, framework,
|
|
170
|
+
* observer, timer, or network dependencies. Returned actions are instructions
|
|
171
|
+
* for a future facade/host boundary; cancellation never performs transport.
|
|
172
|
+
*/
|
|
173
|
+
export declare class DataRequestCoordinator {
|
|
174
|
+
private readonly instanceId;
|
|
175
|
+
private readonly requestIdSecret;
|
|
176
|
+
private requestSequence;
|
|
177
|
+
private rawConfig;
|
|
178
|
+
private config;
|
|
179
|
+
private connected;
|
|
180
|
+
private hasConnected;
|
|
181
|
+
private query;
|
|
182
|
+
private queryGeneration;
|
|
183
|
+
private items;
|
|
184
|
+
private hasMore;
|
|
185
|
+
private active;
|
|
186
|
+
private status;
|
|
187
|
+
private lastCommittedPage;
|
|
188
|
+
private nextEligiblePosition;
|
|
189
|
+
/**
|
|
190
|
+
* Exact cycle detection for the current pagination epoch. One cursor is
|
|
191
|
+
* retained per accepted advancement; there is intentionally no LRU eviction.
|
|
192
|
+
*/
|
|
193
|
+
private committedCursors;
|
|
194
|
+
private generationHasAcceptedResult;
|
|
195
|
+
private needsInitialRemoteSearch;
|
|
196
|
+
private retryAvailable;
|
|
197
|
+
private retryPosition;
|
|
198
|
+
private retryKind;
|
|
199
|
+
private error;
|
|
200
|
+
private resourceLimit;
|
|
201
|
+
private sentinelBlocked;
|
|
202
|
+
private sentinelIntersecting;
|
|
203
|
+
constructor(options?: DataRequestCoordinatorOptions);
|
|
204
|
+
getSnapshot(): DataCoordinatorSnapshot;
|
|
205
|
+
/** Connect once, dispatching the initial remote/hybrid query when required. */
|
|
206
|
+
connect(query?: string): readonly DataCoordinatorAction[];
|
|
207
|
+
/**
|
|
208
|
+
* Advance the request transition from synchronous `requested` to `loading`
|
|
209
|
+
* immediately before a future facade dispatches event/callback notifications.
|
|
210
|
+
*/
|
|
211
|
+
markNotificationsDispatched(requestId: DataRequestId): boolean;
|
|
212
|
+
setQuery(query: string): readonly DataCoordinatorAction[];
|
|
213
|
+
/** Update effective config; non-protocol changes do not rewrite active requests. */
|
|
214
|
+
updateConfig(update: DataCoordinatorConfig): ConfigurationUpdateResult;
|
|
215
|
+
/** Request another page or explicitly retry the still-eligible position. */
|
|
216
|
+
requestLoadMore(trigger?: 'manual' | 'sentinel'): readonly DataCoordinatorAction[];
|
|
217
|
+
/** Feed observer state into the pure sentinel rearm state machine. */
|
|
218
|
+
setSentinelIntersecting(intersecting: boolean): readonly DataCoordinatorAction[];
|
|
219
|
+
/** Invalidate pending work before returning its best-effort host cancellation action. */
|
|
220
|
+
disconnect(): readonly DataCoordinatorAction[];
|
|
221
|
+
completeDataRequest(completion: unknown): DataRequestCompletionResult;
|
|
222
|
+
private isRemoteMode;
|
|
223
|
+
private initialPosition;
|
|
224
|
+
private resetPaginationForRemoteQuery;
|
|
225
|
+
/** Re-evaluate the local cursor cap without resetting accepted history. */
|
|
226
|
+
private refreshCursorDepthLimit;
|
|
227
|
+
private createSearchRequest;
|
|
228
|
+
private createLoadMoreRequest;
|
|
229
|
+
private createRequest;
|
|
230
|
+
private invalidateActive;
|
|
231
|
+
private classifyInactiveRequest;
|
|
232
|
+
private hasValidCompletionEnvelope;
|
|
233
|
+
private validateCompletionPayload;
|
|
234
|
+
private hasCommittedCursor;
|
|
235
|
+
private advanceFrom;
|
|
236
|
+
}
|
|
@@ -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,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,16 @@ 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 * from './data-loading/public-types.js';
|
|
12
|
+
export { validateDataLoadingConfig } from './data-loading/public-config.js';
|
|
13
|
+
export type { SelectionConfig } from './config/global-config.js';
|
|
14
|
+
export type { SelectionConfig as EngineSelectionConfig } from './engine/selection-policy.js';
|
|
9
15
|
export { FenwickTree } from './utils/fenwick-tree.js';
|
|
10
16
|
export { DOMPool } from './utils/dom-pool.js';
|
|
11
17
|
export { WorkerManager, getWorkerManager } from './utils/worker-manager.js';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform-neutral public configuration types for native adapters.
|
|
3
|
+
* This entry intentionally excludes Core's browser-only component declarations.
|
|
4
|
+
*/
|
|
5
|
+
export type { GlobalSelectConfig, SelectionConfig, MultiSelectDisplayConfig, ScrollToSelectedConfig, StyleConfig, } from './config/global-config.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;
|