@smilodon/core 1.10.0 → 1.10.2
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 +130 -371
- package/dist/index.cjs +1931 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1931 -25
- 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 +1931 -24
- 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 +71 -7
- 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 +5 -3
- 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/index.d.ts +2 -0
- package/dist/types/src/native-types.d.ts +5 -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/package.json +7 -4
- package/dist/types/src/themes/importer.d.ts +0 -112
- package/dist/types/tests/accessibility-contract.spec.d.ts +0 -1
- 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/enhanced-select-accessibility-integration.spec.d.ts +0 -1
- package/dist/types/tests/enhanced-select-active-authority.spec.d.ts +0 -1
- package/dist/types/tests/enhanced-select-active-parity.spec.d.ts +0 -1
- package/dist/types/tests/enhanced-select-authority.spec.d.ts +0 -1
- package/dist/types/tests/enhanced-select-compatibility-projection.spec.d.ts +0 -1
- package/dist/types/tests/enhanced-select-selection-parity.spec.d.ts +0 -1
- package/dist/types/tests/enhanced-select-virtualization-integration.spec.d.ts +0 -1
- package/dist/types/tests/interaction.spec.d.ts +0 -1
- package/dist/types/tests/item-adapter.spec.d.ts +0 -1
- package/dist/types/tests/item-registry.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/select-accessibility.spec.d.ts +0 -1
- package/dist/types/tests/select-selection.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/virtualization-contract.spec.d.ts +0 -1
- package/dist/types/tests/virtualizer.spec.d.ts +0 -1
- package/dist/types/tests/web-accessibility-effects.spec.d.ts +0 -1
package/dist/index.js
CHANGED
|
@@ -2247,6 +2247,96 @@ function resetSelectConfig() {
|
|
|
2247
2247
|
selectConfig.resetConfig();
|
|
2248
2248
|
}
|
|
2249
2249
|
|
|
2250
|
+
const DEFAULT_CONFIG = {
|
|
2251
|
+
protocol: 'legacy',
|
|
2252
|
+
searchMode: 'local',
|
|
2253
|
+
paginationMode: 'page',
|
|
2254
|
+
firstPage: 1,
|
|
2255
|
+
};
|
|
2256
|
+
const ALLOWED_FIELDS = new Set([
|
|
2257
|
+
'protocol',
|
|
2258
|
+
'searchMode',
|
|
2259
|
+
'paginationMode',
|
|
2260
|
+
'firstPage',
|
|
2261
|
+
'fetchLimit',
|
|
2262
|
+
]);
|
|
2263
|
+
function issue(path, code, message) {
|
|
2264
|
+
return { path, code, message };
|
|
2265
|
+
}
|
|
2266
|
+
function isRecord$1(value) {
|
|
2267
|
+
if (value === null || typeof value !== 'object' || Array.isArray(value))
|
|
2268
|
+
return false;
|
|
2269
|
+
const prototype = Object.getPrototypeOf(value);
|
|
2270
|
+
return prototype === Object.prototype || prototype === null;
|
|
2271
|
+
}
|
|
2272
|
+
function validatePositiveSafeInteger(candidate, key, issues) {
|
|
2273
|
+
const value = candidate[key];
|
|
2274
|
+
if (value === undefined)
|
|
2275
|
+
return;
|
|
2276
|
+
if (typeof value !== 'number') {
|
|
2277
|
+
issues.push(issue(key, 'invalid-type', `${key} must be a number.`));
|
|
2278
|
+
return;
|
|
2279
|
+
}
|
|
2280
|
+
if (!Number.isSafeInteger(value) || value <= 0) {
|
|
2281
|
+
issues.push(issue(key, 'invalid-positive-integer', `${key} must be a positive safe integer.`));
|
|
2282
|
+
}
|
|
2283
|
+
}
|
|
2284
|
+
/** Validate a complete effective per-instance data-loading configuration. */
|
|
2285
|
+
function validateDataLoadingConfig(candidate) {
|
|
2286
|
+
if (!isRecord$1(candidate)) {
|
|
2287
|
+
return {
|
|
2288
|
+
valid: false,
|
|
2289
|
+
issues: [issue('dataLoading', 'invalid-type', 'dataLoading must be a plain object.')],
|
|
2290
|
+
};
|
|
2291
|
+
}
|
|
2292
|
+
const issues = [];
|
|
2293
|
+
for (const key of Object.keys(candidate).filter((candidateKey) => !ALLOWED_FIELDS.has(candidateKey)).sort()) {
|
|
2294
|
+
issues.push(issue(key, 'unknown-field', `Unknown dataLoading field: ${key}.`));
|
|
2295
|
+
}
|
|
2296
|
+
const protocolValue = candidate.protocol;
|
|
2297
|
+
const protocol = protocolValue === undefined ? DEFAULT_CONFIG.protocol : protocolValue;
|
|
2298
|
+
if (typeof protocol !== 'string') {
|
|
2299
|
+
issues.push(issue('protocol', 'invalid-type', 'protocol must be a string.'));
|
|
2300
|
+
}
|
|
2301
|
+
else if (protocol !== 'legacy' && protocol !== 'acknowledged') {
|
|
2302
|
+
issues.push(issue('protocol', 'invalid-value', 'protocol must be legacy or acknowledged.'));
|
|
2303
|
+
}
|
|
2304
|
+
const searchModeValue = candidate.searchMode;
|
|
2305
|
+
const searchMode = searchModeValue === undefined ? DEFAULT_CONFIG.searchMode : searchModeValue;
|
|
2306
|
+
if (typeof searchMode !== 'string') {
|
|
2307
|
+
issues.push(issue('searchMode', 'invalid-type', 'searchMode must be a string.'));
|
|
2308
|
+
}
|
|
2309
|
+
else if (searchMode !== 'local' && searchMode !== 'remote' && searchMode !== 'hybrid') {
|
|
2310
|
+
issues.push(issue('searchMode', 'invalid-value', 'searchMode must be local, remote, or hybrid.'));
|
|
2311
|
+
}
|
|
2312
|
+
const paginationModeValue = candidate.paginationMode;
|
|
2313
|
+
const paginationMode = paginationModeValue === undefined ? DEFAULT_CONFIG.paginationMode : paginationModeValue;
|
|
2314
|
+
if (typeof paginationMode !== 'string') {
|
|
2315
|
+
issues.push(issue('paginationMode', 'invalid-type', 'paginationMode must be a string.'));
|
|
2316
|
+
}
|
|
2317
|
+
else if (paginationMode !== 'page' && paginationMode !== 'cursor') {
|
|
2318
|
+
issues.push(issue('paginationMode', 'invalid-value', 'paginationMode must be page or cursor.'));
|
|
2319
|
+
}
|
|
2320
|
+
validatePositiveSafeInteger(candidate, 'firstPage', issues);
|
|
2321
|
+
validatePositiveSafeInteger(candidate, 'fetchLimit', issues);
|
|
2322
|
+
if (protocol === 'legacy' && (searchMode === 'remote' || searchMode === 'hybrid')) {
|
|
2323
|
+
issues.push(issue('searchMode', 'requires-acknowledged-protocol', 'Remote and hybrid search require the acknowledged protocol.'));
|
|
2324
|
+
}
|
|
2325
|
+
if (protocol === 'legacy' && paginationMode === 'cursor') {
|
|
2326
|
+
issues.push(issue('paginationMode', 'requires-acknowledged-protocol', 'Cursor pagination requires the acknowledged protocol.'));
|
|
2327
|
+
}
|
|
2328
|
+
if (issues.length > 0)
|
|
2329
|
+
return { valid: false, issues };
|
|
2330
|
+
const resolved = {
|
|
2331
|
+
protocol: protocol,
|
|
2332
|
+
searchMode: searchMode,
|
|
2333
|
+
paginationMode: paginationMode,
|
|
2334
|
+
firstPage: candidate.firstPage === undefined ? DEFAULT_CONFIG.firstPage : candidate.firstPage,
|
|
2335
|
+
...(candidate.fetchLimit === undefined ? {} : { fetchLimit: candidate.fetchLimit }),
|
|
2336
|
+
};
|
|
2337
|
+
return { valid: true, value: resolved };
|
|
2338
|
+
}
|
|
2339
|
+
|
|
2250
2340
|
/** Returns whether a selected key remains in the filtered result set. */
|
|
2251
2341
|
/**
|
|
2252
2342
|
* Returns keys in the half-open index range [startIndex, endIndex), clamped to
|
|
@@ -3048,6 +3138,798 @@ function arraysEqualByValue(a, b) {
|
|
|
3048
3138
|
return true;
|
|
3049
3139
|
}
|
|
3050
3140
|
|
|
3141
|
+
/**
|
|
3142
|
+
* DOM-independent coordinator for the opt-in acknowledged data-loading
|
|
3143
|
+
* protocol. This module is intentionally not re-exported from the package
|
|
3144
|
+
* entry point; public component/adapter integration is a later increment.
|
|
3145
|
+
*/
|
|
3146
|
+
const DEFAULT_MAX_CURSOR_PAGES = 256;
|
|
3147
|
+
const HARD_MAX_CURSOR_PAGES = 4096;
|
|
3148
|
+
const DEFAULT_MAX_CURSOR_TOKEN_BYTES = 1024;
|
|
3149
|
+
const HARD_MAX_CURSOR_TOKEN_BYTES = 4096;
|
|
3150
|
+
let coordinatorInstanceSequence = 0;
|
|
3151
|
+
function isRecord(value) {
|
|
3152
|
+
if (value === null || typeof value !== 'object' || Array.isArray(value))
|
|
3153
|
+
return false;
|
|
3154
|
+
const prototype = Object.getPrototypeOf(value);
|
|
3155
|
+
return prototype === Object.prototype || prototype === null;
|
|
3156
|
+
}
|
|
3157
|
+
function isPositiveSafeInteger(value) {
|
|
3158
|
+
return Number.isSafeInteger(value) && value > 0;
|
|
3159
|
+
}
|
|
3160
|
+
function isNonNegativeSafeInteger(value) {
|
|
3161
|
+
return Number.isSafeInteger(value) && value >= 0;
|
|
3162
|
+
}
|
|
3163
|
+
function isCursor(value) {
|
|
3164
|
+
return typeof value === 'string' || (typeof value === 'number' && Number.isFinite(value));
|
|
3165
|
+
}
|
|
3166
|
+
/** Count UTF-8 bytes without depending on DOM APIs or Node Buffer. */
|
|
3167
|
+
function cursorTokenByteLength(cursor) {
|
|
3168
|
+
const token = String(cursor);
|
|
3169
|
+
let bytes = 0;
|
|
3170
|
+
for (const character of token) {
|
|
3171
|
+
const codePoint = character.codePointAt(0);
|
|
3172
|
+
if (codePoint <= 0x7f)
|
|
3173
|
+
bytes += 1;
|
|
3174
|
+
else if (codePoint <= 0x7ff)
|
|
3175
|
+
bytes += 2;
|
|
3176
|
+
else if (codePoint <= 0xffff)
|
|
3177
|
+
bytes += 3;
|
|
3178
|
+
else
|
|
3179
|
+
bytes += 4;
|
|
3180
|
+
}
|
|
3181
|
+
return bytes;
|
|
3182
|
+
}
|
|
3183
|
+
function parseRequestId(value) {
|
|
3184
|
+
const match = /^data-(\d+)-generation-(\d+)-request-(\d+)-([a-z0-9]+)$/.exec(value);
|
|
3185
|
+
if (!match)
|
|
3186
|
+
return null;
|
|
3187
|
+
const [, instanceText, generationText, sequenceText, check] = match;
|
|
3188
|
+
const instanceId = Number(instanceText);
|
|
3189
|
+
const queryGeneration = Number(generationText);
|
|
3190
|
+
const sequence = Number(sequenceText);
|
|
3191
|
+
if (!Number.isSafeInteger(instanceId) || instanceId < 1 ||
|
|
3192
|
+
!Number.isSafeInteger(queryGeneration) || queryGeneration < 0 ||
|
|
3193
|
+
!Number.isSafeInteger(sequence) || sequence < 1)
|
|
3194
|
+
return null;
|
|
3195
|
+
return Object.freeze({ instanceId, queryGeneration, sequence, check });
|
|
3196
|
+
}
|
|
3197
|
+
function requestIdCheck(secret, instanceId, queryGeneration, sequence) {
|
|
3198
|
+
// A compact keyed check distinguishes IDs actually minted by this instance
|
|
3199
|
+
// from arbitrary strings without retaining a registry of historical IDs.
|
|
3200
|
+
let hash = 14695981039346656037n;
|
|
3201
|
+
const mask = (1n << 64n) - 1n;
|
|
3202
|
+
const input = `${secret}:${instanceId}:${queryGeneration}:${sequence}`;
|
|
3203
|
+
for (let index = 0; index < input.length; index += 1) {
|
|
3204
|
+
hash ^= BigInt(input.charCodeAt(index));
|
|
3205
|
+
hash = (hash * 1099511628211n) & mask;
|
|
3206
|
+
}
|
|
3207
|
+
return hash.toString(36);
|
|
3208
|
+
}
|
|
3209
|
+
function isQueryMode(value) {
|
|
3210
|
+
return value === 'local' || value === 'remote' || value === 'hybrid';
|
|
3211
|
+
}
|
|
3212
|
+
function isPaginationMode(value) {
|
|
3213
|
+
return value === 'page' || value === 'cursor';
|
|
3214
|
+
}
|
|
3215
|
+
function frozenPosition(position) {
|
|
3216
|
+
return Object.freeze({ ...position });
|
|
3217
|
+
}
|
|
3218
|
+
function exactKeys(record, allowed) {
|
|
3219
|
+
return Object.keys(record).every((key) => allowed.includes(key));
|
|
3220
|
+
}
|
|
3221
|
+
function asFrozenItems(items) {
|
|
3222
|
+
return Object.freeze(Array.from(items));
|
|
3223
|
+
}
|
|
3224
|
+
function immutableActions(actions) {
|
|
3225
|
+
return Object.freeze(actions.slice());
|
|
3226
|
+
}
|
|
3227
|
+
function configInput(config = {}) {
|
|
3228
|
+
const root = isRecord(config) ? config : {};
|
|
3229
|
+
const dataLoading = isRecord(root.dataLoading) ? root.dataLoading : {};
|
|
3230
|
+
const infiniteScroll = isRecord(root.infiniteScroll) ? root.infiniteScroll : {};
|
|
3231
|
+
return {
|
|
3232
|
+
protocol: dataLoading.protocol === undefined ? 'legacy' : dataLoading.protocol,
|
|
3233
|
+
searchMode: dataLoading.searchMode === undefined ? 'local' : dataLoading.searchMode,
|
|
3234
|
+
paginationMode: dataLoading.paginationMode === undefined ? 'page' : dataLoading.paginationMode,
|
|
3235
|
+
firstPage: dataLoading.firstPage === undefined ? 1 : dataLoading.firstPage,
|
|
3236
|
+
initialPage: infiniteScroll.initialPage === undefined ? 1 : infiniteScroll.initialPage,
|
|
3237
|
+
fetchLimit: dataLoading.fetchLimit,
|
|
3238
|
+
maxCursorPages: dataLoading.maxCursorPages === undefined
|
|
3239
|
+
? DEFAULT_MAX_CURSOR_PAGES
|
|
3240
|
+
: dataLoading.maxCursorPages,
|
|
3241
|
+
maxCursorTokenBytes: dataLoading.maxCursorTokenBytes === undefined
|
|
3242
|
+
? DEFAULT_MAX_CURSOR_TOKEN_BYTES
|
|
3243
|
+
: dataLoading.maxCursorTokenBytes,
|
|
3244
|
+
pageSize: infiniteScroll.pageSize,
|
|
3245
|
+
};
|
|
3246
|
+
}
|
|
3247
|
+
function validateDataCoordinatorConfig(config = {}) {
|
|
3248
|
+
const input = configInput(config);
|
|
3249
|
+
const errors = [];
|
|
3250
|
+
const add = (field, message) => errors.push(Object.freeze({ field, message }));
|
|
3251
|
+
const rawConfig = config;
|
|
3252
|
+
if (!isRecord(rawConfig))
|
|
3253
|
+
add('config', 'must be a plain object');
|
|
3254
|
+
else {
|
|
3255
|
+
if (rawConfig.dataLoading !== undefined && !isRecord(rawConfig.dataLoading)) {
|
|
3256
|
+
add('dataLoading', 'must be a plain object when supplied');
|
|
3257
|
+
}
|
|
3258
|
+
if (rawConfig.infiniteScroll !== undefined && !isRecord(rawConfig.infiniteScroll)) {
|
|
3259
|
+
add('infiniteScroll', 'must be a plain object when supplied');
|
|
3260
|
+
}
|
|
3261
|
+
}
|
|
3262
|
+
if (input.protocol !== 'legacy' && input.protocol !== 'acknowledged') {
|
|
3263
|
+
add('dataLoading.protocol', 'must be legacy or acknowledged');
|
|
3264
|
+
}
|
|
3265
|
+
if (!isQueryMode(input.searchMode)) {
|
|
3266
|
+
add('dataLoading.searchMode', 'must be local, remote, or hybrid');
|
|
3267
|
+
}
|
|
3268
|
+
if (!isPaginationMode(input.paginationMode)) {
|
|
3269
|
+
add('dataLoading.paginationMode', 'must be page or cursor');
|
|
3270
|
+
}
|
|
3271
|
+
if (!isPositiveSafeInteger(input.firstPage)) {
|
|
3272
|
+
add('dataLoading.firstPage', 'must be a positive safe integer');
|
|
3273
|
+
}
|
|
3274
|
+
if (!isPositiveSafeInteger(input.initialPage)) {
|
|
3275
|
+
add('infiniteScroll.initialPage', 'must be a positive safe integer');
|
|
3276
|
+
}
|
|
3277
|
+
if (input.protocol === 'acknowledged' &&
|
|
3278
|
+
input.searchMode === 'local' &&
|
|
3279
|
+
input.paginationMode === 'page' &&
|
|
3280
|
+
input.initialPage === Number.MAX_SAFE_INTEGER) {
|
|
3281
|
+
add('infiniteScroll.initialPage', 'must leave room for the next acknowledged page number');
|
|
3282
|
+
}
|
|
3283
|
+
if (input.fetchLimit !== undefined && !isPositiveSafeInteger(input.fetchLimit)) {
|
|
3284
|
+
add('dataLoading.fetchLimit', 'must be a positive safe integer when supplied');
|
|
3285
|
+
}
|
|
3286
|
+
if (!isPositiveSafeInteger(input.maxCursorPages) || input.maxCursorPages > HARD_MAX_CURSOR_PAGES) {
|
|
3287
|
+
add('dataLoading.maxCursorPages', `must be a positive safe integer no greater than ${HARD_MAX_CURSOR_PAGES}`);
|
|
3288
|
+
}
|
|
3289
|
+
if (!isPositiveSafeInteger(input.maxCursorTokenBytes) || input.maxCursorTokenBytes > HARD_MAX_CURSOR_TOKEN_BYTES) {
|
|
3290
|
+
add('dataLoading.maxCursorTokenBytes', `must be a positive safe integer no greater than ${HARD_MAX_CURSOR_TOKEN_BYTES}`);
|
|
3291
|
+
}
|
|
3292
|
+
if (input.pageSize !== undefined && !isPositiveSafeInteger(input.pageSize)) {
|
|
3293
|
+
add('infiniteScroll.pageSize', 'must be a positive safe integer when supplied');
|
|
3294
|
+
}
|
|
3295
|
+
if (input.protocol === 'legacy' &&
|
|
3296
|
+
(input.searchMode === 'remote' || input.searchMode === 'hybrid' || input.paginationMode === 'cursor')) {
|
|
3297
|
+
add('dataLoading.protocol', 'remote/hybrid search and cursor pagination require acknowledged protocol');
|
|
3298
|
+
}
|
|
3299
|
+
const resolvedFetchLimit = typeof input.fetchLimit === 'number' ? input.fetchLimit : typeof input.pageSize === 'number' ? input.pageSize : undefined;
|
|
3300
|
+
if (input.protocol === 'acknowledged' && resolvedFetchLimit === undefined) {
|
|
3301
|
+
add('dataLoading.fetchLimit', 'acknowledged requests require fetchLimit or an effective infiniteScroll.pageSize');
|
|
3302
|
+
}
|
|
3303
|
+
if (errors.length > 0) {
|
|
3304
|
+
return Object.freeze({ valid: false, errors: Object.freeze(errors) });
|
|
3305
|
+
}
|
|
3306
|
+
return Object.freeze({
|
|
3307
|
+
valid: true,
|
|
3308
|
+
value: Object.freeze({
|
|
3309
|
+
protocol: input.protocol,
|
|
3310
|
+
searchMode: input.searchMode,
|
|
3311
|
+
paginationMode: input.paginationMode,
|
|
3312
|
+
firstPage: input.firstPage,
|
|
3313
|
+
initialPage: input.initialPage,
|
|
3314
|
+
fetchLimit: resolvedFetchLimit,
|
|
3315
|
+
maxCursorPages: input.maxCursorPages,
|
|
3316
|
+
maxCursorTokenBytes: input.maxCursorTokenBytes,
|
|
3317
|
+
}),
|
|
3318
|
+
});
|
|
3319
|
+
}
|
|
3320
|
+
function copyCoordinatorConfig(config = {}) {
|
|
3321
|
+
return {
|
|
3322
|
+
dataLoading: config.dataLoading ? { ...config.dataLoading } : {},
|
|
3323
|
+
infiniteScroll: config.infiniteScroll ? { ...config.infiniteScroll } : {},
|
|
3324
|
+
};
|
|
3325
|
+
}
|
|
3326
|
+
function mergeCoordinatorConfig(current, update) {
|
|
3327
|
+
return {
|
|
3328
|
+
dataLoading: { ...(current.dataLoading ?? {}), ...(update.dataLoading ?? {}) },
|
|
3329
|
+
infiniteScroll: { ...(current.infiniteScroll ?? {}), ...(update.infiniteScroll ?? {}) },
|
|
3330
|
+
};
|
|
3331
|
+
}
|
|
3332
|
+
/**
|
|
3333
|
+
* Owns request identity and pagination state only. It has no DOM, framework,
|
|
3334
|
+
* observer, timer, or network dependencies. Returned actions are instructions
|
|
3335
|
+
* for a future facade/host boundary; cancellation never performs transport.
|
|
3336
|
+
*/
|
|
3337
|
+
class DataRequestCoordinator {
|
|
3338
|
+
constructor(options = {}) {
|
|
3339
|
+
this.instanceId = ++coordinatorInstanceSequence;
|
|
3340
|
+
this.requestIdSecret = Math.random().toString(36).slice(2) || '0';
|
|
3341
|
+
this.requestSequence = 0;
|
|
3342
|
+
this.connected = false;
|
|
3343
|
+
this.hasConnected = false;
|
|
3344
|
+
this.queryGeneration = 0;
|
|
3345
|
+
this.active = null;
|
|
3346
|
+
this.status = 'idle';
|
|
3347
|
+
/**
|
|
3348
|
+
* Exact cycle detection for the current pagination epoch. One cursor is
|
|
3349
|
+
* retained per accepted advancement; there is intentionally no LRU eviction.
|
|
3350
|
+
*/
|
|
3351
|
+
this.committedCursors = new Set();
|
|
3352
|
+
this.generationHasAcceptedResult = false;
|
|
3353
|
+
this.retryAvailable = false;
|
|
3354
|
+
this.error = null;
|
|
3355
|
+
this.resourceLimit = null;
|
|
3356
|
+
this.sentinelBlocked = false;
|
|
3357
|
+
this.sentinelIntersecting = false;
|
|
3358
|
+
const initialConfig = options.config === undefined ? {} : options.config;
|
|
3359
|
+
const validation = validateDataCoordinatorConfig(initialConfig);
|
|
3360
|
+
if (!validation.valid) {
|
|
3361
|
+
throw new TypeError(validation.errors.map(({ field, message }) => `${field}: ${message}`).join('; '));
|
|
3362
|
+
}
|
|
3363
|
+
this.rawConfig = copyCoordinatorConfig(initialConfig);
|
|
3364
|
+
this.config = validation.value;
|
|
3365
|
+
this.query = options.initialQuery ?? '';
|
|
3366
|
+
this.items = asFrozenItems(options.initialItems ?? []);
|
|
3367
|
+
const remote = this.isRemoteMode();
|
|
3368
|
+
this.hasMore = remote ? false : options.hasMore ?? false;
|
|
3369
|
+
this.nextEligiblePosition = this.initialPosition();
|
|
3370
|
+
this.lastCommittedPage = this.config.paginationMode === 'page' && !remote
|
|
3371
|
+
? this.config.initialPage
|
|
3372
|
+
: undefined;
|
|
3373
|
+
this.needsInitialRemoteSearch = remote;
|
|
3374
|
+
}
|
|
3375
|
+
getSnapshot() {
|
|
3376
|
+
const activeRequest = this.active?.request ?? null;
|
|
3377
|
+
const nextPosition = frozenPosition(this.nextEligiblePosition);
|
|
3378
|
+
return Object.freeze({
|
|
3379
|
+
status: this.status,
|
|
3380
|
+
connected: this.connected,
|
|
3381
|
+
busy: this.active !== null,
|
|
3382
|
+
query: this.query,
|
|
3383
|
+
normalizedQuery: this.query.trim(),
|
|
3384
|
+
queryGeneration: this.queryGeneration,
|
|
3385
|
+
items: asFrozenItems(this.items),
|
|
3386
|
+
hasMore: this.hasMore,
|
|
3387
|
+
activeRequest,
|
|
3388
|
+
lastCommittedPage: this.lastCommittedPage,
|
|
3389
|
+
nextEligiblePosition: nextPosition,
|
|
3390
|
+
error: this.error ? Object.freeze({ ...this.error }) : null,
|
|
3391
|
+
resourceLimit: this.resourceLimit,
|
|
3392
|
+
sentinelBlocked: this.sentinelBlocked,
|
|
3393
|
+
sentinelIntersecting: this.sentinelIntersecting,
|
|
3394
|
+
});
|
|
3395
|
+
}
|
|
3396
|
+
/** Connect once, dispatching the initial remote/hybrid query when required. */
|
|
3397
|
+
connect(query = this.query) {
|
|
3398
|
+
if (this.connected)
|
|
3399
|
+
return immutableActions([]);
|
|
3400
|
+
const actions = [];
|
|
3401
|
+
if (query !== this.query)
|
|
3402
|
+
actions.push(...this.setQuery(query));
|
|
3403
|
+
if (this.hasConnected)
|
|
3404
|
+
this.queryGeneration += 1;
|
|
3405
|
+
this.connected = true;
|
|
3406
|
+
this.hasConnected = true;
|
|
3407
|
+
if (this.isRemoteMode() && this.needsInitialRemoteSearch) {
|
|
3408
|
+
this.resetPaginationForRemoteQuery(true);
|
|
3409
|
+
const request = this.createSearchRequest();
|
|
3410
|
+
if (request)
|
|
3411
|
+
actions.push(Object.freeze({ type: 'request', request }));
|
|
3412
|
+
}
|
|
3413
|
+
return immutableActions(actions);
|
|
3414
|
+
}
|
|
3415
|
+
/**
|
|
3416
|
+
* Advance the request transition from synchronous `requested` to `loading`
|
|
3417
|
+
* immediately before a future facade dispatches event/callback notifications.
|
|
3418
|
+
*/
|
|
3419
|
+
markNotificationsDispatched(requestId) {
|
|
3420
|
+
if (!this.active || this.active.request.requestId !== requestId || this.active.phase !== 'requested') {
|
|
3421
|
+
return false;
|
|
3422
|
+
}
|
|
3423
|
+
this.active.phase = 'loading';
|
|
3424
|
+
this.status = 'loading';
|
|
3425
|
+
return true;
|
|
3426
|
+
}
|
|
3427
|
+
setQuery(query) {
|
|
3428
|
+
if (typeof query !== 'string' || query === this.query)
|
|
3429
|
+
return immutableActions([]);
|
|
3430
|
+
const actions = [];
|
|
3431
|
+
const cancellation = this.invalidateActive('query-changed');
|
|
3432
|
+
if (cancellation)
|
|
3433
|
+
actions.push(cancellation);
|
|
3434
|
+
this.query = query;
|
|
3435
|
+
this.queryGeneration += 1;
|
|
3436
|
+
this.error = null;
|
|
3437
|
+
this.status = 'idle';
|
|
3438
|
+
this.generationHasAcceptedResult = false;
|
|
3439
|
+
this.retryAvailable = false;
|
|
3440
|
+
this.retryPosition = undefined;
|
|
3441
|
+
this.retryKind = undefined;
|
|
3442
|
+
this.committedCursors.clear();
|
|
3443
|
+
this.resourceLimit = null;
|
|
3444
|
+
this.sentinelBlocked = false;
|
|
3445
|
+
if (this.isRemoteMode()) {
|
|
3446
|
+
this.resetPaginationForRemoteQuery(true);
|
|
3447
|
+
this.needsInitialRemoteSearch = true;
|
|
3448
|
+
if (this.connected) {
|
|
3449
|
+
const request = this.createSearchRequest();
|
|
3450
|
+
if (request)
|
|
3451
|
+
actions.push(Object.freeze({ type: 'request', request }));
|
|
3452
|
+
}
|
|
3453
|
+
}
|
|
3454
|
+
else {
|
|
3455
|
+
this.lastCommittedPage = this.config.paginationMode === 'page' ? this.config.initialPage : undefined;
|
|
3456
|
+
this.nextEligiblePosition = this.initialPosition();
|
|
3457
|
+
this.needsInitialRemoteSearch = false;
|
|
3458
|
+
}
|
|
3459
|
+
return immutableActions(actions);
|
|
3460
|
+
}
|
|
3461
|
+
/** Update effective config; non-protocol changes do not rewrite active requests. */
|
|
3462
|
+
updateConfig(update) {
|
|
3463
|
+
const rawUpdate = update;
|
|
3464
|
+
if (!isRecord(rawUpdate) ||
|
|
3465
|
+
(rawUpdate.dataLoading !== undefined && !isRecord(rawUpdate.dataLoading)) ||
|
|
3466
|
+
(rawUpdate.infiniteScroll !== undefined && !isRecord(rawUpdate.infiniteScroll))) {
|
|
3467
|
+
return Object.freeze({
|
|
3468
|
+
status: 'invalid',
|
|
3469
|
+
errors: Object.freeze([
|
|
3470
|
+
Object.freeze({ field: 'config', message: 'update and nested config groups must be plain objects' }),
|
|
3471
|
+
]),
|
|
3472
|
+
});
|
|
3473
|
+
}
|
|
3474
|
+
const candidate = mergeCoordinatorConfig(this.rawConfig, update);
|
|
3475
|
+
const validation = validateDataCoordinatorConfig(candidate);
|
|
3476
|
+
if (!validation.valid)
|
|
3477
|
+
return Object.freeze({ status: 'invalid', errors: validation.errors });
|
|
3478
|
+
const previous = this.config;
|
|
3479
|
+
const next = validation.value;
|
|
3480
|
+
const protocolChanged = previous.protocol !== next.protocol ||
|
|
3481
|
+
previous.searchMode !== next.searchMode ||
|
|
3482
|
+
previous.paginationMode !== next.paginationMode;
|
|
3483
|
+
this.rawConfig = copyCoordinatorConfig(candidate);
|
|
3484
|
+
this.config = next;
|
|
3485
|
+
if (!protocolChanged) {
|
|
3486
|
+
this.refreshCursorDepthLimit();
|
|
3487
|
+
return Object.freeze({ status: 'accepted', actions: immutableActions([]) });
|
|
3488
|
+
}
|
|
3489
|
+
const actions = [];
|
|
3490
|
+
const cancellation = this.invalidateActive('config-changed');
|
|
3491
|
+
if (cancellation)
|
|
3492
|
+
actions.push(cancellation);
|
|
3493
|
+
this.queryGeneration += 1;
|
|
3494
|
+
this.error = null;
|
|
3495
|
+
this.status = 'idle';
|
|
3496
|
+
this.generationHasAcceptedResult = false;
|
|
3497
|
+
this.retryAvailable = false;
|
|
3498
|
+
this.retryPosition = undefined;
|
|
3499
|
+
this.retryKind = undefined;
|
|
3500
|
+
this.committedCursors.clear();
|
|
3501
|
+
this.resourceLimit = null;
|
|
3502
|
+
this.sentinelBlocked = false;
|
|
3503
|
+
this.hasMore = this.isRemoteMode() ? false : this.hasMore;
|
|
3504
|
+
this.lastCommittedPage = this.config.paginationMode === 'page' && !this.isRemoteMode()
|
|
3505
|
+
? this.config.initialPage
|
|
3506
|
+
: undefined;
|
|
3507
|
+
this.nextEligiblePosition = this.initialPosition();
|
|
3508
|
+
this.needsInitialRemoteSearch = this.isRemoteMode();
|
|
3509
|
+
if (this.connected && this.isRemoteMode()) {
|
|
3510
|
+
const request = this.createSearchRequest();
|
|
3511
|
+
if (request)
|
|
3512
|
+
actions.push(Object.freeze({ type: 'request', request }));
|
|
3513
|
+
}
|
|
3514
|
+
return Object.freeze({ status: 'accepted', actions: immutableActions(actions) });
|
|
3515
|
+
}
|
|
3516
|
+
/** Request another page or explicitly retry the still-eligible position. */
|
|
3517
|
+
requestLoadMore(trigger = 'manual') {
|
|
3518
|
+
if (this.config.protocol !== 'acknowledged' || !this.connected || this.active) {
|
|
3519
|
+
return immutableActions([]);
|
|
3520
|
+
}
|
|
3521
|
+
if (trigger === 'sentinel' && this.sentinelBlocked)
|
|
3522
|
+
return immutableActions([]);
|
|
3523
|
+
if (!this.hasMore && !this.retryAvailable)
|
|
3524
|
+
return immutableActions([]);
|
|
3525
|
+
const position = this.retryAvailable && this.retryPosition
|
|
3526
|
+
? this.retryPosition
|
|
3527
|
+
: this.nextEligiblePosition;
|
|
3528
|
+
if (this.config.paginationMode === 'cursor' &&
|
|
3529
|
+
position.mode === 'cursor' &&
|
|
3530
|
+
position.ordinal > this.config.maxCursorPages) {
|
|
3531
|
+
this.resourceLimit = Object.freeze({
|
|
3532
|
+
reason: 'cursor-depth',
|
|
3533
|
+
maxCursorPages: this.config.maxCursorPages,
|
|
3534
|
+
});
|
|
3535
|
+
this.status = 'resource-limited';
|
|
3536
|
+
this.sentinelBlocked = true;
|
|
3537
|
+
return immutableActions([]);
|
|
3538
|
+
}
|
|
3539
|
+
if (trigger === 'manual')
|
|
3540
|
+
this.sentinelBlocked = false;
|
|
3541
|
+
const retryKind = this.retryAvailable ? this.retryKind : undefined;
|
|
3542
|
+
this.retryAvailable = false;
|
|
3543
|
+
this.retryPosition = undefined;
|
|
3544
|
+
this.retryKind = undefined;
|
|
3545
|
+
const request = retryKind === 'search' && this.isRemoteMode()
|
|
3546
|
+
? this.createSearchRequest(position)
|
|
3547
|
+
: this.createLoadMoreRequest(position);
|
|
3548
|
+
return request ? immutableActions([Object.freeze({ type: 'request', request })]) : immutableActions([]);
|
|
3549
|
+
}
|
|
3550
|
+
/** Feed observer state into the pure sentinel rearm state machine. */
|
|
3551
|
+
setSentinelIntersecting(intersecting) {
|
|
3552
|
+
if (!intersecting) {
|
|
3553
|
+
this.sentinelIntersecting = false;
|
|
3554
|
+
this.sentinelBlocked = false;
|
|
3555
|
+
return immutableActions([]);
|
|
3556
|
+
}
|
|
3557
|
+
if (this.sentinelIntersecting)
|
|
3558
|
+
return immutableActions([]);
|
|
3559
|
+
this.sentinelIntersecting = true;
|
|
3560
|
+
return this.requestLoadMore('sentinel');
|
|
3561
|
+
}
|
|
3562
|
+
/** Invalidate pending work before returning its best-effort host cancellation action. */
|
|
3563
|
+
disconnect() {
|
|
3564
|
+
if (!this.connected)
|
|
3565
|
+
return immutableActions([]);
|
|
3566
|
+
const activeRequest = this.active?.request;
|
|
3567
|
+
const actions = [];
|
|
3568
|
+
if (activeRequest) {
|
|
3569
|
+
if (activeRequest.kind === 'search' && !this.generationHasAcceptedResult) {
|
|
3570
|
+
this.needsInitialRemoteSearch = true;
|
|
3571
|
+
}
|
|
3572
|
+
const cancellation = this.invalidateActive('disconnected');
|
|
3573
|
+
if (cancellation)
|
|
3574
|
+
actions.push(cancellation);
|
|
3575
|
+
this.resourceLimit = null;
|
|
3576
|
+
this.status = 'cancelled';
|
|
3577
|
+
this.sentinelBlocked = true;
|
|
3578
|
+
// Encode invalidation in the generation, so late completions are stale
|
|
3579
|
+
// without retaining one request ID per cancellation.
|
|
3580
|
+
this.queryGeneration += 1;
|
|
3581
|
+
}
|
|
3582
|
+
this.sentinelIntersecting = false;
|
|
3583
|
+
this.connected = false;
|
|
3584
|
+
return immutableActions(actions);
|
|
3585
|
+
}
|
|
3586
|
+
completeDataRequest(completion) {
|
|
3587
|
+
if (!isRecord(completion) || !this.hasValidCompletionEnvelope(completion))
|
|
3588
|
+
return 'invalid';
|
|
3589
|
+
const requestId = completion.requestId;
|
|
3590
|
+
const generation = completion.queryGeneration;
|
|
3591
|
+
if (this.active?.request.requestId !== requestId) {
|
|
3592
|
+
return this.classifyInactiveRequest(requestId, generation);
|
|
3593
|
+
}
|
|
3594
|
+
if (generation !== this.active.request.queryGeneration || this.active.phase !== 'loading')
|
|
3595
|
+
return 'invalid';
|
|
3596
|
+
const validation = this.validateCompletionPayload(completion, this.active.request);
|
|
3597
|
+
if (!validation.valid) {
|
|
3598
|
+
if (validation.resourceLimit === 'cursor-token-size') {
|
|
3599
|
+
const cursor = completion.nextCursor;
|
|
3600
|
+
const actualCursorTokenBytes = cursorTokenByteLength(cursor);
|
|
3601
|
+
this.resourceLimit = Object.freeze({
|
|
3602
|
+
reason: 'cursor-token-size',
|
|
3603
|
+
maxCursorTokenBytes: this.config.maxCursorTokenBytes,
|
|
3604
|
+
actualCursorTokenBytes,
|
|
3605
|
+
requestId,
|
|
3606
|
+
});
|
|
3607
|
+
return 'resource-limit';
|
|
3608
|
+
}
|
|
3609
|
+
return 'invalid';
|
|
3610
|
+
}
|
|
3611
|
+
const request = this.active.request;
|
|
3612
|
+
const status = completion.status;
|
|
3613
|
+
const nextData = status === 'succeeded' || status === 'exhausted'
|
|
3614
|
+
? asFrozenItems(completion.items)
|
|
3615
|
+
: this.items;
|
|
3616
|
+
let nextPosition = this.nextEligiblePosition;
|
|
3617
|
+
let nextLastCommittedPage = this.lastCommittedPage;
|
|
3618
|
+
let nextHasMore = this.hasMore;
|
|
3619
|
+
let nextRetryAvailable = false;
|
|
3620
|
+
let nextRetryPosition;
|
|
3621
|
+
let nextRetryKind;
|
|
3622
|
+
let nextError = null;
|
|
3623
|
+
let nextSentinelBlocked = false;
|
|
3624
|
+
let cursorToCommit;
|
|
3625
|
+
let nextResourceLimit = null;
|
|
3626
|
+
if (status === 'succeeded') {
|
|
3627
|
+
const advances = this.advanceFrom(request, completion);
|
|
3628
|
+
nextPosition = advances.position;
|
|
3629
|
+
nextLastCommittedPage = advances.lastCommittedPage;
|
|
3630
|
+
cursorToCommit = advances.cursorToCommit;
|
|
3631
|
+
nextHasMore = true;
|
|
3632
|
+
}
|
|
3633
|
+
else if (status === 'exhausted') {
|
|
3634
|
+
nextLastCommittedPage = request.position.mode === 'page'
|
|
3635
|
+
? request.position.page
|
|
3636
|
+
: this.lastCommittedPage;
|
|
3637
|
+
nextHasMore = false;
|
|
3638
|
+
}
|
|
3639
|
+
else if (status === 'empty') {
|
|
3640
|
+
nextHasMore = true;
|
|
3641
|
+
nextSentinelBlocked = true;
|
|
3642
|
+
if (completion.advance === 'next') {
|
|
3643
|
+
const advances = this.advanceFrom(request, completion);
|
|
3644
|
+
nextPosition = advances.position;
|
|
3645
|
+
nextLastCommittedPage = advances.lastCommittedPage;
|
|
3646
|
+
cursorToCommit = advances.cursorToCommit;
|
|
3647
|
+
}
|
|
3648
|
+
else {
|
|
3649
|
+
nextRetryAvailable = true;
|
|
3650
|
+
nextRetryPosition = request.position;
|
|
3651
|
+
nextRetryKind = request.kind;
|
|
3652
|
+
}
|
|
3653
|
+
}
|
|
3654
|
+
else if (status === 'failed') {
|
|
3655
|
+
nextRetryAvailable = true;
|
|
3656
|
+
nextRetryPosition = request.position;
|
|
3657
|
+
nextRetryKind = request.kind;
|
|
3658
|
+
nextError = Object.freeze({ ...completion.error });
|
|
3659
|
+
nextSentinelBlocked = true;
|
|
3660
|
+
}
|
|
3661
|
+
else if (status === 'cancelled') {
|
|
3662
|
+
nextRetryAvailable = true;
|
|
3663
|
+
nextRetryPosition = request.position;
|
|
3664
|
+
nextRetryKind = request.kind;
|
|
3665
|
+
nextSentinelBlocked = true;
|
|
3666
|
+
}
|
|
3667
|
+
if (this.config.paginationMode === 'cursor' &&
|
|
3668
|
+
nextHasMore &&
|
|
3669
|
+
nextPosition.mode === 'cursor' &&
|
|
3670
|
+
nextPosition.ordinal > this.config.maxCursorPages) {
|
|
3671
|
+
nextResourceLimit = Object.freeze({
|
|
3672
|
+
reason: 'cursor-depth',
|
|
3673
|
+
maxCursorPages: this.config.maxCursorPages,
|
|
3674
|
+
requestId,
|
|
3675
|
+
});
|
|
3676
|
+
nextSentinelBlocked = true;
|
|
3677
|
+
}
|
|
3678
|
+
// Commit only after identity, generation, status, and every field validate.
|
|
3679
|
+
this.items = nextData;
|
|
3680
|
+
this.nextEligiblePosition = nextPosition;
|
|
3681
|
+
this.lastCommittedPage = nextLastCommittedPage;
|
|
3682
|
+
this.hasMore = nextHasMore;
|
|
3683
|
+
this.retryAvailable = nextRetryAvailable;
|
|
3684
|
+
this.retryPosition = nextRetryPosition;
|
|
3685
|
+
this.retryKind = nextRetryKind;
|
|
3686
|
+
this.error = nextError;
|
|
3687
|
+
this.resourceLimit = nextResourceLimit;
|
|
3688
|
+
this.sentinelBlocked = nextSentinelBlocked;
|
|
3689
|
+
if (cursorToCommit !== undefined)
|
|
3690
|
+
this.committedCursors.add(cursorToCommit);
|
|
3691
|
+
if (status === 'succeeded' || status === 'exhausted')
|
|
3692
|
+
this.generationHasAcceptedResult = true;
|
|
3693
|
+
this.active = null;
|
|
3694
|
+
this.status = nextResourceLimit ? 'resource-limited' : status;
|
|
3695
|
+
return 'accepted';
|
|
3696
|
+
}
|
|
3697
|
+
isRemoteMode() {
|
|
3698
|
+
return this.config.searchMode === 'remote' || this.config.searchMode === 'hybrid';
|
|
3699
|
+
}
|
|
3700
|
+
initialPosition() {
|
|
3701
|
+
if (this.config.paginationMode === 'cursor') {
|
|
3702
|
+
return Object.freeze({ mode: 'cursor', ordinal: 1 });
|
|
3703
|
+
}
|
|
3704
|
+
const page = this.isRemoteMode() ? this.config.firstPage : this.config.initialPage + 1;
|
|
3705
|
+
return Object.freeze({ mode: 'page', page });
|
|
3706
|
+
}
|
|
3707
|
+
resetPaginationForRemoteQuery(clearItems) {
|
|
3708
|
+
this.hasMore = false;
|
|
3709
|
+
this.lastCommittedPage = undefined;
|
|
3710
|
+
this.nextEligiblePosition = this.initialPosition();
|
|
3711
|
+
this.committedCursors.clear();
|
|
3712
|
+
this.retryAvailable = false;
|
|
3713
|
+
this.retryPosition = undefined;
|
|
3714
|
+
this.retryKind = undefined;
|
|
3715
|
+
this.resourceLimit = null;
|
|
3716
|
+
this.sentinelBlocked = false;
|
|
3717
|
+
this.error = null;
|
|
3718
|
+
if (clearItems)
|
|
3719
|
+
this.items = asFrozenItems([]);
|
|
3720
|
+
}
|
|
3721
|
+
/** Re-evaluate the local cursor cap without resetting accepted history. */
|
|
3722
|
+
refreshCursorDepthLimit() {
|
|
3723
|
+
if (this.config.protocol !== 'acknowledged' || this.config.paginationMode !== 'cursor')
|
|
3724
|
+
return;
|
|
3725
|
+
const position = this.retryAvailable && this.retryPosition
|
|
3726
|
+
? this.retryPosition
|
|
3727
|
+
: this.nextEligiblePosition;
|
|
3728
|
+
const overLimit = (this.hasMore || this.retryAvailable) &&
|
|
3729
|
+
position.mode === 'cursor' && position.ordinal > this.config.maxCursorPages;
|
|
3730
|
+
if (overLimit) {
|
|
3731
|
+
this.resourceLimit = Object.freeze({
|
|
3732
|
+
reason: 'cursor-depth',
|
|
3733
|
+
maxCursorPages: this.config.maxCursorPages,
|
|
3734
|
+
});
|
|
3735
|
+
if (!this.active)
|
|
3736
|
+
this.status = 'resource-limited';
|
|
3737
|
+
this.sentinelBlocked = true;
|
|
3738
|
+
return;
|
|
3739
|
+
}
|
|
3740
|
+
if (this.resourceLimit?.reason === 'cursor-depth') {
|
|
3741
|
+
this.resourceLimit = null;
|
|
3742
|
+
if (!this.active && this.status === 'resource-limited')
|
|
3743
|
+
this.status = 'idle';
|
|
3744
|
+
}
|
|
3745
|
+
}
|
|
3746
|
+
createSearchRequest(position = this.nextEligiblePosition) {
|
|
3747
|
+
if (!this.connected || !this.isRemoteMode() || this.config.protocol !== 'acknowledged')
|
|
3748
|
+
return null;
|
|
3749
|
+
const request = this.createRequest({ kind: 'search', mode: this.config.searchMode }, position);
|
|
3750
|
+
if (request) {
|
|
3751
|
+
this.needsInitialRemoteSearch = false;
|
|
3752
|
+
this.status = 'requested';
|
|
3753
|
+
}
|
|
3754
|
+
return request;
|
|
3755
|
+
}
|
|
3756
|
+
createLoadMoreRequest(position) {
|
|
3757
|
+
if (!this.connected || this.config.protocol !== 'acknowledged')
|
|
3758
|
+
return null;
|
|
3759
|
+
const request = this.createRequest({ kind: 'loadMore' }, position);
|
|
3760
|
+
if (request)
|
|
3761
|
+
this.status = 'requested';
|
|
3762
|
+
return request;
|
|
3763
|
+
}
|
|
3764
|
+
createRequest(kind, position) {
|
|
3765
|
+
const fetchLimit = this.config.fetchLimit;
|
|
3766
|
+
if (fetchLimit === undefined || this.active)
|
|
3767
|
+
return null;
|
|
3768
|
+
this.requestSequence += 1;
|
|
3769
|
+
const check = requestIdCheck(this.requestIdSecret, this.instanceId, this.queryGeneration, this.requestSequence);
|
|
3770
|
+
const requestId = `data-${this.instanceId}-generation-${this.queryGeneration}-request-${this.requestSequence}-${check}`;
|
|
3771
|
+
const base = Object.freeze({
|
|
3772
|
+
requestId,
|
|
3773
|
+
queryGeneration: this.queryGeneration,
|
|
3774
|
+
query: this.query,
|
|
3775
|
+
normalizedQuery: this.query.trim(),
|
|
3776
|
+
fetchLimit,
|
|
3777
|
+
position: frozenPosition(position),
|
|
3778
|
+
});
|
|
3779
|
+
const request = kind.kind === 'search'
|
|
3780
|
+
? Object.freeze({ ...base, kind: 'search', mode: kind.mode })
|
|
3781
|
+
: Object.freeze({ ...base, kind: 'loadMore' });
|
|
3782
|
+
this.active = { request, phase: 'requested' };
|
|
3783
|
+
this.status = 'requested';
|
|
3784
|
+
this.error = null;
|
|
3785
|
+
return request;
|
|
3786
|
+
}
|
|
3787
|
+
invalidateActive(reason) {
|
|
3788
|
+
if (!this.active)
|
|
3789
|
+
return null;
|
|
3790
|
+
const { request } = this.active;
|
|
3791
|
+
this.active = null;
|
|
3792
|
+
this.status = 'cancelled';
|
|
3793
|
+
const notification = Object.freeze({
|
|
3794
|
+
requestId: request.requestId,
|
|
3795
|
+
queryGeneration: request.queryGeneration,
|
|
3796
|
+
reason,
|
|
3797
|
+
});
|
|
3798
|
+
return Object.freeze({ type: 'cancel', notification });
|
|
3799
|
+
}
|
|
3800
|
+
classifyInactiveRequest(requestId, completionGeneration) {
|
|
3801
|
+
const parsed = parseRequestId(requestId);
|
|
3802
|
+
if (!parsed ||
|
|
3803
|
+
parsed.instanceId !== this.instanceId ||
|
|
3804
|
+
parsed.check !== requestIdCheck(this.requestIdSecret, parsed.instanceId, parsed.queryGeneration, parsed.sequence) ||
|
|
3805
|
+
parsed.sequence > this.requestSequence)
|
|
3806
|
+
return 'unknown-request';
|
|
3807
|
+
if (parsed.queryGeneration !== completionGeneration)
|
|
3808
|
+
return 'invalid';
|
|
3809
|
+
return parsed.queryGeneration < this.queryGeneration ? 'stale' : 'unknown-request';
|
|
3810
|
+
}
|
|
3811
|
+
hasValidCompletionEnvelope(completion) {
|
|
3812
|
+
return (typeof completion.requestId === 'string' &&
|
|
3813
|
+
completion.requestId.length > 0 &&
|
|
3814
|
+
isNonNegativeSafeInteger(completion.queryGeneration) &&
|
|
3815
|
+
typeof completion.status === 'string' &&
|
|
3816
|
+
['succeeded', 'empty', 'exhausted', 'failed', 'cancelled'].includes(completion.status));
|
|
3817
|
+
}
|
|
3818
|
+
validateCompletionPayload(completion, request) {
|
|
3819
|
+
const common = ['requestId', 'queryGeneration', 'status'];
|
|
3820
|
+
switch (completion.status) {
|
|
3821
|
+
case 'succeeded': {
|
|
3822
|
+
const allowed = [...common, 'items', 'hasMore'];
|
|
3823
|
+
if (request.position.mode === 'cursor')
|
|
3824
|
+
allowed.push('nextCursor');
|
|
3825
|
+
if (!exactKeys(completion, allowed) || !Array.isArray(completion.items) || completion.hasMore !== true) {
|
|
3826
|
+
return { valid: false };
|
|
3827
|
+
}
|
|
3828
|
+
if (request.position.mode === 'cursor') {
|
|
3829
|
+
if (request.position.ordinal >= Number.MAX_SAFE_INTEGER || !isCursor(completion.nextCursor)) {
|
|
3830
|
+
return { valid: false };
|
|
3831
|
+
}
|
|
3832
|
+
if (cursorTokenByteLength(completion.nextCursor) > this.config.maxCursorTokenBytes) {
|
|
3833
|
+
return { valid: false, resourceLimit: 'cursor-token-size' };
|
|
3834
|
+
}
|
|
3835
|
+
if (this.hasCommittedCursor(completion.nextCursor))
|
|
3836
|
+
return { valid: false };
|
|
3837
|
+
}
|
|
3838
|
+
else if ('nextCursor' in completion) {
|
|
3839
|
+
return { valid: false };
|
|
3840
|
+
}
|
|
3841
|
+
else if (request.position.page >= Number.MAX_SAFE_INTEGER) {
|
|
3842
|
+
return { valid: false };
|
|
3843
|
+
}
|
|
3844
|
+
return { valid: true };
|
|
3845
|
+
}
|
|
3846
|
+
case 'empty': {
|
|
3847
|
+
const allowed = [...common, 'hasMore', 'advance'];
|
|
3848
|
+
if (request.position.mode === 'cursor' && completion.advance === 'next')
|
|
3849
|
+
allowed.push('nextCursor');
|
|
3850
|
+
if (!exactKeys(completion, allowed) || completion.hasMore !== true)
|
|
3851
|
+
return { valid: false };
|
|
3852
|
+
if (completion.advance !== 'next' && completion.advance !== 'retry')
|
|
3853
|
+
return { valid: false };
|
|
3854
|
+
if (request.position.mode === 'cursor') {
|
|
3855
|
+
if (completion.advance === 'next') {
|
|
3856
|
+
if (request.position.ordinal >= Number.MAX_SAFE_INTEGER || !isCursor(completion.nextCursor)) {
|
|
3857
|
+
return { valid: false };
|
|
3858
|
+
}
|
|
3859
|
+
if (cursorTokenByteLength(completion.nextCursor) > this.config.maxCursorTokenBytes) {
|
|
3860
|
+
return { valid: false, resourceLimit: 'cursor-token-size' };
|
|
3861
|
+
}
|
|
3862
|
+
if (this.hasCommittedCursor(completion.nextCursor))
|
|
3863
|
+
return { valid: false };
|
|
3864
|
+
}
|
|
3865
|
+
else if ('nextCursor' in completion) {
|
|
3866
|
+
return { valid: false };
|
|
3867
|
+
}
|
|
3868
|
+
}
|
|
3869
|
+
else if ('nextCursor' in completion) {
|
|
3870
|
+
return { valid: false };
|
|
3871
|
+
}
|
|
3872
|
+
else if (completion.advance === 'next' && request.position.page >= Number.MAX_SAFE_INTEGER) {
|
|
3873
|
+
return { valid: false };
|
|
3874
|
+
}
|
|
3875
|
+
return { valid: true };
|
|
3876
|
+
}
|
|
3877
|
+
case 'exhausted': {
|
|
3878
|
+
if (!exactKeys(completion, [...common, 'items', 'hasMore']) ||
|
|
3879
|
+
!Array.isArray(completion.items) ||
|
|
3880
|
+
completion.hasMore !== false) {
|
|
3881
|
+
return { valid: false };
|
|
3882
|
+
}
|
|
3883
|
+
return { valid: true };
|
|
3884
|
+
}
|
|
3885
|
+
case 'failed': {
|
|
3886
|
+
if (!exactKeys(completion, [...common, 'error']) || !isRecord(completion.error))
|
|
3887
|
+
return { valid: false };
|
|
3888
|
+
const error = completion.error;
|
|
3889
|
+
if (!exactKeys(error, ['message', 'code', 'retryable']) ||
|
|
3890
|
+
typeof error.message !== 'string' ||
|
|
3891
|
+
error.message.trim().length === 0 ||
|
|
3892
|
+
(error.code !== undefined && typeof error.code !== 'string') ||
|
|
3893
|
+
(error.retryable !== undefined && typeof error.retryable !== 'boolean')) {
|
|
3894
|
+
return { valid: false };
|
|
3895
|
+
}
|
|
3896
|
+
return { valid: true };
|
|
3897
|
+
}
|
|
3898
|
+
case 'cancelled': {
|
|
3899
|
+
const hasReason = 'reason' in completion;
|
|
3900
|
+
return (exactKeys(completion, hasReason ? [...common, 'reason'] : common) &&
|
|
3901
|
+
(!hasReason || completion.reason === undefined || completion.reason === 'host-cancelled'))
|
|
3902
|
+
? { valid: true }
|
|
3903
|
+
: { valid: false };
|
|
3904
|
+
}
|
|
3905
|
+
default:
|
|
3906
|
+
return { valid: false };
|
|
3907
|
+
}
|
|
3908
|
+
}
|
|
3909
|
+
hasCommittedCursor(cursor) {
|
|
3910
|
+
return this.committedCursors.has(cursor) || (this.nextEligiblePosition.mode === 'cursor' && this.nextEligiblePosition.cursor === cursor);
|
|
3911
|
+
}
|
|
3912
|
+
advanceFrom(request, completion) {
|
|
3913
|
+
if (request.position.mode === 'page') {
|
|
3914
|
+
const page = request.position.page;
|
|
3915
|
+
return {
|
|
3916
|
+
position: Object.freeze({ mode: 'page', page: page + 1 }),
|
|
3917
|
+
lastCommittedPage: page,
|
|
3918
|
+
};
|
|
3919
|
+
}
|
|
3920
|
+
const nextCursor = completion.nextCursor;
|
|
3921
|
+
return {
|
|
3922
|
+
position: Object.freeze({
|
|
3923
|
+
mode: 'cursor',
|
|
3924
|
+
cursor: nextCursor,
|
|
3925
|
+
ordinal: request.position.ordinal + 1,
|
|
3926
|
+
}),
|
|
3927
|
+
lastCommittedPage: this.lastCommittedPage,
|
|
3928
|
+
cursorToCommit: nextCursor,
|
|
3929
|
+
};
|
|
3930
|
+
}
|
|
3931
|
+
}
|
|
3932
|
+
|
|
3051
3933
|
/**
|
|
3052
3934
|
* Enhanced Select Component
|
|
3053
3935
|
* Implements all advanced features: infinite scroll, load more, busy state,
|
|
@@ -3055,9 +3937,72 @@ function arraysEqualByValue(a, b) {
|
|
|
3055
3937
|
*
|
|
3056
3938
|
* Redesigned with formal elegance, refined microinteractions, and polished UX
|
|
3057
3939
|
*/
|
|
3940
|
+
const LEGACY_DATA_LOADING_CONFIG = {
|
|
3941
|
+
protocol: 'legacy',
|
|
3942
|
+
searchMode: 'local',
|
|
3943
|
+
paginationMode: 'page',
|
|
3944
|
+
firstPage: 1,
|
|
3945
|
+
};
|
|
3946
|
+
const DATA_LOADING_CONFIG_FIELDS = ['protocol', 'searchMode', 'paginationMode', 'firstPage', 'fetchLimit'];
|
|
3947
|
+
const INVALID_OBJECT_VALUE = Object.freeze({ kind: 'object' });
|
|
3948
|
+
const INVALID_ARRAY_VALUE = Object.freeze({ kind: 'array' });
|
|
3949
|
+
const INVALID_FUNCTION_VALUE = Object.freeze({ kind: 'function' });
|
|
3950
|
+
function invalidConfigValueSignature(value) {
|
|
3951
|
+
if (value === null || (typeof value !== 'object' && typeof value !== 'function'))
|
|
3952
|
+
return value;
|
|
3953
|
+
if (typeof value === 'function')
|
|
3954
|
+
return INVALID_FUNCTION_VALUE;
|
|
3955
|
+
return Array.isArray(value) ? INVALID_ARRAY_VALUE : INVALID_OBJECT_VALUE;
|
|
3956
|
+
}
|
|
3957
|
+
function createInvalidDataLoadingCandidateSignature(candidate, issues) {
|
|
3958
|
+
const candidatePrototype = candidate !== null && typeof candidate === 'object'
|
|
3959
|
+
? Object.getPrototypeOf(candidate)
|
|
3960
|
+
: undefined;
|
|
3961
|
+
const isRecord = candidate !== null
|
|
3962
|
+
&& typeof candidate === 'object'
|
|
3963
|
+
&& !Array.isArray(candidate)
|
|
3964
|
+
&& (candidatePrototype === Object.prototype || candidatePrototype === null);
|
|
3965
|
+
const recordCandidate = isRecord ? candidate : undefined;
|
|
3966
|
+
const rootKind = isRecord
|
|
3967
|
+
? 'record'
|
|
3968
|
+
: candidate === null
|
|
3969
|
+
? 'null'
|
|
3970
|
+
: Array.isArray(candidate)
|
|
3971
|
+
? 'array'
|
|
3972
|
+
: typeof candidate;
|
|
3973
|
+
return {
|
|
3974
|
+
rootKind,
|
|
3975
|
+
rootValue: candidate === null || typeof candidate !== 'object' ? candidate : undefined,
|
|
3976
|
+
// Compare at most five supported field values. Unknown fields are represented by their
|
|
3977
|
+
// validation issues below; their values are invalid regardless of shape. Signature work is
|
|
3978
|
+
// therefore independent of nested-value depth (and linear only in the already-built issue list).
|
|
3979
|
+
fieldValues: recordCandidate
|
|
3980
|
+
? DATA_LOADING_CONFIG_FIELDS.map((field) => invalidConfigValueSignature(recordCandidate[field]))
|
|
3981
|
+
: [],
|
|
3982
|
+
issues: issues.map(({ path, code, message }) => [path, code, message]),
|
|
3983
|
+
};
|
|
3984
|
+
}
|
|
3985
|
+
function invalidDataLoadingSignaturesEqual(left, right) {
|
|
3986
|
+
if (left.rootKind !== right.rootKind || !Object.is(left.rootValue, right.rootValue))
|
|
3987
|
+
return false;
|
|
3988
|
+
if (left.fieldValues.length !== right.fieldValues.length || left.issues.length !== right.issues.length)
|
|
3989
|
+
return false;
|
|
3990
|
+
for (let index = 0; index < left.fieldValues.length; index += 1) {
|
|
3991
|
+
if (!Object.is(left.fieldValues[index], right.fieldValues[index]))
|
|
3992
|
+
return false;
|
|
3993
|
+
}
|
|
3994
|
+
for (let index = 0; index < left.issues.length; index += 1) {
|
|
3995
|
+
const leftIssue = left.issues[index];
|
|
3996
|
+
const rightIssue = right.issues[index];
|
|
3997
|
+
if (leftIssue[0] !== rightIssue[0] || leftIssue[1] !== rightIssue[1] || leftIssue[2] !== rightIssue[2]) {
|
|
3998
|
+
return false;
|
|
3999
|
+
}
|
|
4000
|
+
}
|
|
4001
|
+
return true;
|
|
4002
|
+
}
|
|
3058
4003
|
class EnhancedSelect extends HTMLElement {
|
|
3059
4004
|
static get observedAttributes() {
|
|
3060
|
-
return ['aria-label', 'aria-description'];
|
|
4005
|
+
return ['aria-label', 'aria-description', 'aria-busy'];
|
|
3061
4006
|
}
|
|
3062
4007
|
get classMap() {
|
|
3063
4008
|
return this._classMap;
|
|
@@ -3096,6 +4041,8 @@ class EnhancedSelect extends HTMLElement {
|
|
|
3096
4041
|
}
|
|
3097
4042
|
constructor() {
|
|
3098
4043
|
super();
|
|
4044
|
+
this._dataLoadingConfig = { ...LEGACY_DATA_LOADING_CONFIG };
|
|
4045
|
+
this._hasLastInvalidDataLoadingCandidate = false;
|
|
3099
4046
|
this._engine = new SelectEngineBridge();
|
|
3100
4047
|
this._virtualizationScope = {
|
|
3101
4048
|
dataKeys: [],
|
|
@@ -3139,6 +4086,29 @@ class EnhancedSelect extends HTMLElement {
|
|
|
3139
4086
|
this._selectedRecordsByKey = new Map();
|
|
3140
4087
|
this._registryItemsRef = [];
|
|
3141
4088
|
this._pageCache = {};
|
|
4089
|
+
// One coordinator owns both acknowledged and legacy-adjacent lifecycle state;
|
|
4090
|
+
// the public protocol remains explicitly opt-in and legacy remains default.
|
|
4091
|
+
this._dataRequestCoordinator = null;
|
|
4092
|
+
this._acknowledgedSearchMode = null;
|
|
4093
|
+
this._acknowledgedReady = false;
|
|
4094
|
+
this._acknowledgedDeferredStart = false;
|
|
4095
|
+
this._hasEverConnected = false;
|
|
4096
|
+
this._acknowledgedStartTask = null;
|
|
4097
|
+
this._clearAcknowledgedCoordinatorAfterProjection = false;
|
|
4098
|
+
this._acknowledgedConfigUpdatePending = false;
|
|
4099
|
+
this._acknowledgedDeferredModeChange = false;
|
|
4100
|
+
this._acknowledgedProjectionPending = false;
|
|
4101
|
+
this._acknowledgedProjectionSettling = false;
|
|
4102
|
+
this._acknowledgedPendingSearchQuery = null;
|
|
4103
|
+
this._acknowledgedProjectionFailureStageForTest = null;
|
|
4104
|
+
this._acknowledgedProjectionRunning = false;
|
|
4105
|
+
this._acknowledgedProjectionTask = null;
|
|
4106
|
+
this._acknowledgedProjectionScrollTop = 0;
|
|
4107
|
+
this._acknowledgedLastRequest = null;
|
|
4108
|
+
this._acknowledgedProjectionCommitsPosition = false;
|
|
4109
|
+
this._acknowledgedProjectionRequest = null;
|
|
4110
|
+
this._acknowledgedProjectionAttempt = 0;
|
|
4111
|
+
this._acknowledgedProjectionDiagnostic = null;
|
|
3142
4112
|
this._typeBuffer = '';
|
|
3143
4113
|
this._hasError = false;
|
|
3144
4114
|
this._errorMessage = '';
|
|
@@ -3161,6 +4131,9 @@ class EnhancedSelect extends HTMLElement {
|
|
|
3161
4131
|
this._tracking = { events: [], styles: [], limitations: [] };
|
|
3162
4132
|
this._suppressBlurClose = false;
|
|
3163
4133
|
this._renderCycleId = 0;
|
|
4134
|
+
this._completedRenderCycleId = 0;
|
|
4135
|
+
this._renderCycleWaiters = new Map();
|
|
4136
|
+
this._renderCycleWaiterTimeouts = new Map();
|
|
3164
4137
|
this._suppressNextOpenClick = false;
|
|
3165
4138
|
this._resolvedDropdownPlacement = 'bottom';
|
|
3166
4139
|
this._multiScrollDrag = {
|
|
@@ -3258,6 +4231,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
3258
4231
|
this._syncListboxAccessibility();
|
|
3259
4232
|
}
|
|
3260
4233
|
connectedCallback() {
|
|
4234
|
+
this._hasEverConnected = true;
|
|
3261
4235
|
// register instance
|
|
3262
4236
|
EnhancedSelect._instances.add(this);
|
|
3263
4237
|
this._runEngineEffects(this._engine.dispatch({ type: 'CONNECT' }));
|
|
@@ -3274,6 +4248,11 @@ class EnhancedSelect extends HTMLElement {
|
|
|
3274
4248
|
// Sync direction attribute (must be in connectedCallback, not constructor)
|
|
3275
4249
|
this._syncDirectionConfig();
|
|
3276
4250
|
this._syncComboboxAccessibility();
|
|
4251
|
+
if (this._dataRequestCoordinator || this._dataLoadingConfig.protocol === 'acknowledged') {
|
|
4252
|
+
// Acknowledged dispatch remains behind the explicit readiness
|
|
4253
|
+
// gate; reconnect only restores observer ownership here.
|
|
4254
|
+
this._initializeObservers();
|
|
4255
|
+
}
|
|
3277
4256
|
if (this._optionRenderer || this._classMap || this._groupHeaderRenderer) {
|
|
3278
4257
|
this._setGlobalStylesMirroring(true);
|
|
3279
4258
|
}
|
|
@@ -3291,15 +4270,33 @@ class EnhancedSelect extends HTMLElement {
|
|
|
3291
4270
|
if (this._config.callbacks.onOpen) {
|
|
3292
4271
|
this._config.callbacks.onOpen();
|
|
3293
4272
|
}
|
|
4273
|
+
if (this._acknowledgedDeferredStart) {
|
|
4274
|
+
this._acknowledgedDeferredStart = false;
|
|
4275
|
+
this.startDataLoading();
|
|
4276
|
+
}
|
|
3294
4277
|
}
|
|
3295
4278
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
3296
|
-
if (oldValue === newValue
|
|
4279
|
+
if (oldValue === newValue)
|
|
4280
|
+
return;
|
|
4281
|
+
if (name === 'aria-busy') {
|
|
4282
|
+
this._syncListboxAccessibility();
|
|
4283
|
+
return;
|
|
4284
|
+
}
|
|
4285
|
+
if (name !== 'aria-label' && name !== 'aria-description')
|
|
3297
4286
|
return;
|
|
3298
4287
|
this._syncComboboxAccessibility();
|
|
3299
4288
|
if (name === 'aria-label')
|
|
3300
4289
|
this._syncListboxAccessibility();
|
|
3301
4290
|
}
|
|
3302
4291
|
disconnectedCallback() {
|
|
4292
|
+
if (this._dataRequestCoordinator) {
|
|
4293
|
+
const actions = this._dataRequestCoordinator.disconnect();
|
|
4294
|
+
this._acknowledgedReady = false;
|
|
4295
|
+
this._dispatchAcknowledgedActions(actions);
|
|
4296
|
+
this._state.isBusy = false;
|
|
4297
|
+
this._state.isSearching = false;
|
|
4298
|
+
this._state.preserveScrollPosition = false;
|
|
4299
|
+
}
|
|
3303
4300
|
// unregister instance
|
|
3304
4301
|
EnhancedSelect._instances.delete(this);
|
|
3305
4302
|
if (this._state.isOpen) {
|
|
@@ -3334,6 +4331,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
3334
4331
|
this._arrowContainer.removeEventListener('click', this._boundArrowClick);
|
|
3335
4332
|
}
|
|
3336
4333
|
this._renderCycleId += 1;
|
|
4334
|
+
this._resolvePendingRenderCycles(false);
|
|
3337
4335
|
this._teardownGlobalStylesMirroring();
|
|
3338
4336
|
}
|
|
3339
4337
|
_setGlobalStylesMirroring(enabled) {
|
|
@@ -3864,9 +4862,9 @@ class EnhancedSelect extends HTMLElement {
|
|
|
3864
4862
|
this._assertActiveProjection('selection config');
|
|
3865
4863
|
}
|
|
3866
4864
|
}
|
|
3867
|
-
_rebuildItemRegistry(items = this._state.loadedItems) {
|
|
4865
|
+
_rebuildItemRegistry(items = this._state.loadedItems, stagedRegistry) {
|
|
3868
4866
|
// Build first so duplicate-key rejection leaves the previous runtime intact.
|
|
3869
|
-
const registry = createItemRegistry(items, this._itemAdapter, {
|
|
4867
|
+
const registry = stagedRegistry ?? createItemRegistry(items, this._itemAdapter, {
|
|
3870
4868
|
duplicateKeyPolicy: this._getDuplicateKeyPolicy(),
|
|
3871
4869
|
});
|
|
3872
4870
|
const activeKey = this._engine.state.activeKey;
|
|
@@ -6161,17 +7159,47 @@ class EnhancedSelect extends HTMLElement {
|
|
|
6161
7159
|
this._intersectionObserver.disconnect();
|
|
6162
7160
|
this._intersectionObserver = undefined;
|
|
6163
7161
|
}
|
|
7162
|
+
if (this._dataLoadingConfig.protocol === 'acknowledged'
|
|
7163
|
+
&& (!this._dataRequestCoordinator || !this._acknowledgedReady))
|
|
7164
|
+
return;
|
|
6164
7165
|
// Intersection observer for infinite scroll
|
|
6165
7166
|
if (this._config.infiniteScroll.enabled) {
|
|
6166
|
-
this.
|
|
6167
|
-
|
|
6168
|
-
|
|
6169
|
-
|
|
7167
|
+
const acknowledged = Boolean(this._dataRequestCoordinator && this._dataLoadingConfig.protocol === 'acknowledged');
|
|
7168
|
+
if (acknowledged && typeof IntersectionObserver === 'undefined')
|
|
7169
|
+
return;
|
|
7170
|
+
let observer;
|
|
7171
|
+
try {
|
|
7172
|
+
observer = new IntersectionObserver((entries) => {
|
|
7173
|
+
if (this._intersectionObserver !== observer)
|
|
7174
|
+
return;
|
|
7175
|
+
entries.forEach((entry) => {
|
|
7176
|
+
if (acknowledged) {
|
|
7177
|
+
if (!this._acknowledgedReady || !this.isConnected || entry.target !== this._loadMoreTrigger)
|
|
7178
|
+
return;
|
|
7179
|
+
if (!entry.isIntersecting) {
|
|
7180
|
+
this._dataRequestCoordinator?.setSentinelIntersecting(false);
|
|
7181
|
+
return;
|
|
7182
|
+
}
|
|
7183
|
+
if (this._acknowledgedProjectionPending || this._acknowledgedProjectionSettling)
|
|
7184
|
+
return;
|
|
7185
|
+
const actions = this._dataRequestCoordinator?.setSentinelIntersecting(true) ?? [];
|
|
7186
|
+
this._dispatchAcknowledgedActions(actions);
|
|
7187
|
+
return;
|
|
7188
|
+
}
|
|
7189
|
+
if (entry.isIntersecting && !this._state.isBusy) {
|
|
6170
7190
|
this._loadMoreItems();
|
|
6171
7191
|
}
|
|
6172
|
-
}
|
|
6173
|
-
}
|
|
6174
|
-
|
|
7192
|
+
});
|
|
7193
|
+
}, acknowledged
|
|
7194
|
+
? { root: this._optionsContainer, threshold: 0.1 }
|
|
7195
|
+
: { threshold: 0.1 });
|
|
7196
|
+
this._intersectionObserver = observer;
|
|
7197
|
+
}
|
|
7198
|
+
catch (error) {
|
|
7199
|
+
this._intersectionObserver = undefined;
|
|
7200
|
+
if (!acknowledged)
|
|
7201
|
+
throw error;
|
|
7202
|
+
}
|
|
6175
7203
|
}
|
|
6176
7204
|
}
|
|
6177
7205
|
async _loadInitialSelectedItems() {
|
|
@@ -6253,7 +7281,10 @@ class EnhancedSelect extends HTMLElement {
|
|
|
6253
7281
|
const accessibilityState = {
|
|
6254
7282
|
...derivedState,
|
|
6255
7283
|
// The component's existing busy lifecycle is not yet mirrored to engine dataStatus.
|
|
6256
|
-
busy
|
|
7284
|
+
// Host presentation busy is additive only for the accepted acknowledged
|
|
7285
|
+
// protocol; legacy host attributes remain inert for listbox semantics.
|
|
7286
|
+
busy: this._state.isBusy || (this._dataLoadingConfig.protocol === 'acknowledged'
|
|
7287
|
+
&& this.getAttribute('aria-busy') === 'true'),
|
|
6257
7288
|
};
|
|
6258
7289
|
const effects = computeAccessibilityEffects(accessibilityState, {
|
|
6259
7290
|
controlsId: this._dropdown.id || null,
|
|
@@ -6519,8 +7550,44 @@ class EnhancedSelect extends HTMLElement {
|
|
|
6519
7550
|
return results;
|
|
6520
7551
|
}
|
|
6521
7552
|
_handleSearch(query) {
|
|
7553
|
+
if (this._dataRequestCoordinator
|
|
7554
|
+
&& (this._acknowledgedProjectionPending || this._acknowledgedProjectionSettling)) {
|
|
7555
|
+
// Keep the committed query/generation stable until the accepted snapshot
|
|
7556
|
+
// has been projected. Coalesce input as a latest-wins intent and dispatch
|
|
7557
|
+
// exactly one new generation after recovery/projection succeeds.
|
|
7558
|
+
this._acknowledgedPendingSearchQuery = query;
|
|
7559
|
+
this._input.value = query;
|
|
7560
|
+
this._syncClearControlState();
|
|
7561
|
+
return;
|
|
7562
|
+
}
|
|
7563
|
+
if (this._dataLoadingConfig.protocol === 'acknowledged'
|
|
7564
|
+
&& (this._dataLoadingConfig.searchMode === 'remote' || this._dataLoadingConfig.searchMode === 'hybrid')) {
|
|
7565
|
+
this._state.searchQuery = query;
|
|
7566
|
+
this._syncClearControlState();
|
|
7567
|
+
this._state.lastNotifiedQuery = query;
|
|
7568
|
+
this._state.lastNotifiedResultCount = 0;
|
|
7569
|
+
if (this._dataRequestCoordinator) {
|
|
7570
|
+
const actions = this._dataRequestCoordinator.setQuery(query);
|
|
7571
|
+
if (this._acknowledgedReady)
|
|
7572
|
+
this._dispatchAcknowledgedActions(actions);
|
|
7573
|
+
else
|
|
7574
|
+
this._renderOptions();
|
|
7575
|
+
}
|
|
7576
|
+
else if (!this._state.isOpen) {
|
|
7577
|
+
this._handleOpen();
|
|
7578
|
+
}
|
|
7579
|
+
else {
|
|
7580
|
+
this._renderOptions();
|
|
7581
|
+
}
|
|
7582
|
+
return;
|
|
7583
|
+
}
|
|
6522
7584
|
this._state.searchQuery = query;
|
|
6523
7585
|
this._syncClearControlState();
|
|
7586
|
+
if (this._dataLoadingConfig.protocol === 'acknowledged' && this._dataRequestCoordinator) {
|
|
7587
|
+
// Local acknowledged search has no remote request, but pagination still
|
|
7588
|
+
// belongs to the coordinator's current query generation.
|
|
7589
|
+
this._dispatchAcknowledgedActions(this._dataRequestCoordinator.setQuery(query));
|
|
7590
|
+
}
|
|
6524
7591
|
if (query.length > 0) {
|
|
6525
7592
|
this._perfMark('smilodon-search-input-last');
|
|
6526
7593
|
this._pendingSearchRenderMark = true;
|
|
@@ -7072,8 +8139,19 @@ class EnhancedSelect extends HTMLElement {
|
|
|
7072
8139
|
this._inputContent.insertBefore(badge, this._input);
|
|
7073
8140
|
});
|
|
7074
8141
|
}
|
|
8142
|
+
// A query typed during an accepted-snapshot projection is a pending user
|
|
8143
|
+
// intent, not part of the committed projection state. Keep it visible even
|
|
8144
|
+
// when selection/display synchronization runs during that transaction.
|
|
8145
|
+
if (this._acknowledgedPendingSearchQuery !== null) {
|
|
8146
|
+
this._input.value = this._acknowledgedPendingSearchQuery;
|
|
8147
|
+
}
|
|
7075
8148
|
this._syncClearControlState();
|
|
7076
8149
|
}
|
|
8150
|
+
_isActivelyEditingSearchInput() {
|
|
8151
|
+
return this._config.searchable === true
|
|
8152
|
+
&& this._state.isOpen
|
|
8153
|
+
&& this._shadow.activeElement === this._input;
|
|
8154
|
+
}
|
|
7077
8155
|
_renderOptionsWithAnimation() {
|
|
7078
8156
|
// Add fade-out animation
|
|
7079
8157
|
this._optionsContainer.style.opacity = '0';
|
|
@@ -7139,7 +8217,24 @@ class EnhancedSelect extends HTMLElement {
|
|
|
7139
8217
|
this._setActive(targetIndex, 'programmatic');
|
|
7140
8218
|
}
|
|
7141
8219
|
}
|
|
7142
|
-
async _loadMoreItems() {
|
|
8220
|
+
async _loadMoreItems(trigger = 'manual') {
|
|
8221
|
+
if (this._dataLoadingConfig.protocol === 'acknowledged') {
|
|
8222
|
+
if (!this._dataRequestCoordinator
|
|
8223
|
+
|| !this._acknowledgedReady
|
|
8224
|
+
|| this._acknowledgedProjectionPending
|
|
8225
|
+
|| this._acknowledgedProjectionSettling)
|
|
8226
|
+
return;
|
|
8227
|
+
const actions = this._dataRequestCoordinator.requestLoadMore(trigger);
|
|
8228
|
+
this._dispatchAcknowledgedActions(actions);
|
|
8229
|
+
return;
|
|
8230
|
+
}
|
|
8231
|
+
if (this._dataRequestCoordinator) {
|
|
8232
|
+
if (!this._acknowledgedReady || this._acknowledgedProjectionPending || this._acknowledgedProjectionSettling)
|
|
8233
|
+
return;
|
|
8234
|
+
const actions = this._dataRequestCoordinator.requestLoadMore(trigger);
|
|
8235
|
+
this._dispatchAcknowledgedActions(actions);
|
|
8236
|
+
return;
|
|
8237
|
+
}
|
|
7143
8238
|
if (this._state.isBusy)
|
|
7144
8239
|
return;
|
|
7145
8240
|
this._setBusy(true);
|
|
@@ -7366,9 +8461,30 @@ class EnhancedSelect extends HTMLElement {
|
|
|
7366
8461
|
const previousLength = this._state.loadedItems.length;
|
|
7367
8462
|
this._rebuildItemRegistry(items);
|
|
7368
8463
|
this._state.groupedItems = this._groupItemsByProperty(items);
|
|
7369
|
-
if (!this._state.searchQuery)
|
|
8464
|
+
if (!this._state.searchQuery && !this._isActivelyEditingSearchInput())
|
|
7370
8465
|
this._updateInputDisplay();
|
|
7371
8466
|
const newLength = this._state.loadedItems.length;
|
|
8467
|
+
if (this._dataRequestCoordinator) {
|
|
8468
|
+
const acknowledgedBusy = this._dataRequestCoordinator.getSnapshot().busy
|
|
8469
|
+
|| this._acknowledgedProjectionPending;
|
|
8470
|
+
this._state.isSearching = false;
|
|
8471
|
+
this._state.isBusy = acknowledgedBusy;
|
|
8472
|
+
if (this._state.preserveScrollPosition && this._dropdown) {
|
|
8473
|
+
const targetScrollTop = this._state.lastScrollPosition;
|
|
8474
|
+
this._renderOptions();
|
|
8475
|
+
this._optionsContainer.scrollTop = targetScrollTop;
|
|
8476
|
+
this._requestLifecycleFrame(() => {
|
|
8477
|
+
if (this._optionsContainer)
|
|
8478
|
+
this._optionsContainer.scrollTop = targetScrollTop;
|
|
8479
|
+
});
|
|
8480
|
+
if (!acknowledgedBusy)
|
|
8481
|
+
this._state.preserveScrollPosition = false;
|
|
8482
|
+
}
|
|
8483
|
+
else {
|
|
8484
|
+
this._renderOptions();
|
|
8485
|
+
}
|
|
8486
|
+
return;
|
|
8487
|
+
}
|
|
7372
8488
|
// When infinite scroll is active (preserveScrollPosition = true),
|
|
7373
8489
|
// we need to maintain scroll position during the update
|
|
7374
8490
|
if (this._state.preserveScrollPosition && this._dropdown) {
|
|
@@ -7426,7 +8542,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
7426
8542
|
this._rebuildItemRegistry(groupedItems.flatMap(group => group.options));
|
|
7427
8543
|
this._state.groupedItems = groupedItems;
|
|
7428
8544
|
this._renderOptions();
|
|
7429
|
-
if (!this._state.searchQuery)
|
|
8545
|
+
if (!this._state.searchQuery && !this._isActivelyEditingSearchInput())
|
|
7430
8546
|
this._updateInputDisplay();
|
|
7431
8547
|
}
|
|
7432
8548
|
/**
|
|
@@ -7544,9 +8660,55 @@ class EnhancedSelect extends HTMLElement {
|
|
|
7544
8660
|
this._invalidateGuardedMeasurements();
|
|
7545
8661
|
const previousMode = this._config.selection.mode;
|
|
7546
8662
|
const previousEnabled = this._config.enabled;
|
|
7547
|
-
|
|
8663
|
+
const previousDataLoadingConfig = this._dataLoadingConfig;
|
|
8664
|
+
const { dataLoading, callbacks, ...legacyConfig } = config;
|
|
8665
|
+
const legacyUpdate = { ...legacyConfig };
|
|
8666
|
+
let configErrorDetail;
|
|
8667
|
+
if (callbacks !== undefined && callbacks !== null) {
|
|
8668
|
+
const callbackInput = callbacks;
|
|
8669
|
+
if (Object.prototype.hasOwnProperty.call(callbackInput, 'onDataLoadingConfigError')) {
|
|
8670
|
+
this._dataLoadingConfigErrorCallback = callbackInput.onDataLoadingConfigError;
|
|
8671
|
+
}
|
|
8672
|
+
if (Object.prototype.hasOwnProperty.call(callbackInput, 'onDataRequestCancel')) {
|
|
8673
|
+
this._dataRequestCancelCallback = callbackInput.onDataRequestCancel;
|
|
8674
|
+
}
|
|
8675
|
+
if (Object.prototype.hasOwnProperty.call(callbackInput, 'onDataProjection')) {
|
|
8676
|
+
this._dataProjectionCallback = callbackInput.onDataProjection;
|
|
8677
|
+
}
|
|
8678
|
+
const legacyCallbacks = { ...callbackInput };
|
|
8679
|
+
delete legacyCallbacks.onDataLoadingConfigError;
|
|
8680
|
+
delete legacyCallbacks.onDataRequestCancel;
|
|
8681
|
+
delete legacyCallbacks.onDataProjection;
|
|
8682
|
+
legacyUpdate.callbacks = legacyCallbacks;
|
|
8683
|
+
}
|
|
8684
|
+
this._config = this._mergeConfig(this._config, legacyUpdate);
|
|
8685
|
+
if (dataLoading !== undefined) {
|
|
8686
|
+
const dataLoadingPrototype = dataLoading !== null && typeof dataLoading === 'object'
|
|
8687
|
+
? Object.getPrototypeOf(dataLoading)
|
|
8688
|
+
: undefined;
|
|
8689
|
+
const candidate = dataLoadingPrototype === Object.prototype || dataLoadingPrototype === null
|
|
8690
|
+
? { ...this._dataLoadingConfig, ...dataLoading }
|
|
8691
|
+
: dataLoading;
|
|
8692
|
+
const validation = validateDataLoadingConfig(candidate);
|
|
8693
|
+
if (validation.valid) {
|
|
8694
|
+
this._dataLoadingConfig = validation.value;
|
|
8695
|
+
this._hasLastInvalidDataLoadingCandidate = false;
|
|
8696
|
+
this._lastInvalidDataLoadingCandidate = undefined;
|
|
8697
|
+
}
|
|
8698
|
+
else {
|
|
8699
|
+
const candidateSignature = createInvalidDataLoadingCandidateSignature(candidate, validation.issues);
|
|
8700
|
+
if (!this._hasLastInvalidDataLoadingCandidate ||
|
|
8701
|
+
!this._lastInvalidDataLoadingCandidate ||
|
|
8702
|
+
!invalidDataLoadingSignaturesEqual(this._lastInvalidDataLoadingCandidate, candidateSignature)) {
|
|
8703
|
+
this._hasLastInvalidDataLoadingCandidate = true;
|
|
8704
|
+
this._lastInvalidDataLoadingCandidate = candidateSignature;
|
|
8705
|
+
configErrorDetail = { issues: validation.issues };
|
|
8706
|
+
}
|
|
8707
|
+
}
|
|
8708
|
+
}
|
|
7548
8709
|
this._rebuildItemRegistry();
|
|
7549
8710
|
if (previousEnabled !== this._config.enabled) {
|
|
8711
|
+
this._input.disabled = !this._config.enabled;
|
|
7550
8712
|
if (!this._config.enabled && this._state.isOpen) {
|
|
7551
8713
|
this._handleClose('disabled');
|
|
7552
8714
|
}
|
|
@@ -7596,14 +8758,301 @@ class EnhancedSelect extends HTMLElement {
|
|
|
7596
8758
|
// Re-initialize observers in case infinite scroll was enabled/disabled
|
|
7597
8759
|
this._initializeObservers();
|
|
7598
8760
|
this._syncClearControlState();
|
|
7599
|
-
this.
|
|
8761
|
+
if (!this._isActivelyEditingSearchInput())
|
|
8762
|
+
this._updateInputDisplay();
|
|
7600
8763
|
this._renderOptions();
|
|
7601
8764
|
}
|
|
7602
8765
|
else {
|
|
7603
8766
|
this._syncInputContainerMode();
|
|
7604
8767
|
this._syncMultiSelectDisplayConfig();
|
|
7605
8768
|
this._syncClearControlState();
|
|
7606
|
-
this.
|
|
8769
|
+
if (!this._isActivelyEditingSearchInput())
|
|
8770
|
+
this._updateInputDisplay();
|
|
8771
|
+
}
|
|
8772
|
+
this._acknowledgedSearchMode = this._dataLoadingConfig.searchMode;
|
|
8773
|
+
if (this._dataLoadingConfig.protocol === 'legacy')
|
|
8774
|
+
this._acknowledgedDeferredStart = false;
|
|
8775
|
+
const coordinator = this._dataRequestCoordinator;
|
|
8776
|
+
const switchesToLegacy = previousDataLoadingConfig.protocol === 'acknowledged'
|
|
8777
|
+
&& this._dataLoadingConfig.protocol === 'legacy';
|
|
8778
|
+
const acknowledgedModeChanged = previousDataLoadingConfig.protocol !== this._dataLoadingConfig.protocol
|
|
8779
|
+
|| previousDataLoadingConfig.searchMode !== this._dataLoadingConfig.searchMode
|
|
8780
|
+
|| previousDataLoadingConfig.paginationMode !== this._dataLoadingConfig.paginationMode;
|
|
8781
|
+
if (coordinator && switchesToLegacy) {
|
|
8782
|
+
if (this._acknowledgedReady && !this._acknowledgedProjectionPending && !this._acknowledgedProjectionSettling) {
|
|
8783
|
+
const update = coordinator.updateConfig(this._createCoordinatorConfig());
|
|
8784
|
+
if (update.status === 'accepted')
|
|
8785
|
+
this._dispatchAcknowledgedActions(update.actions);
|
|
8786
|
+
}
|
|
8787
|
+
this._acknowledgedReady = false;
|
|
8788
|
+
this._dispatchAcknowledgedActions(coordinator.disconnect());
|
|
8789
|
+
if (this._acknowledgedProjectionPending || this._acknowledgedProjectionSettling) {
|
|
8790
|
+
this._clearAcknowledgedCoordinatorAfterProjection = true;
|
|
8791
|
+
}
|
|
8792
|
+
else {
|
|
8793
|
+
this._dataRequestCoordinator = null;
|
|
8794
|
+
this._acknowledgedSearchMode = null;
|
|
8795
|
+
this._state.isBusy = false;
|
|
8796
|
+
this._state.isSearching = false;
|
|
8797
|
+
this._syncListboxAccessibility();
|
|
8798
|
+
this._renderOptions();
|
|
8799
|
+
}
|
|
8800
|
+
}
|
|
8801
|
+
else if (coordinator && this._dataLoadingConfig.protocol === 'acknowledged') {
|
|
8802
|
+
this._clearAcknowledgedCoordinatorAfterProjection = false;
|
|
8803
|
+
if (this._acknowledgedProjectionPending || this._acknowledgedProjectionSettling) {
|
|
8804
|
+
this._acknowledgedConfigUpdatePending = true;
|
|
8805
|
+
this._acknowledgedDeferredModeChange || (this._acknowledgedDeferredModeChange = acknowledgedModeChanged);
|
|
8806
|
+
}
|
|
8807
|
+
else if (this._acknowledgedReady) {
|
|
8808
|
+
const update = coordinator.updateConfig(this._createCoordinatorConfig());
|
|
8809
|
+
if (update.status === 'accepted') {
|
|
8810
|
+
this._dispatchAcknowledgedActions(update.actions);
|
|
8811
|
+
const snapshot = coordinator.getSnapshot();
|
|
8812
|
+
this._state.isBusy = snapshot.busy;
|
|
8813
|
+
this._state.isSearching = snapshot.activeRequest?.kind === 'search';
|
|
8814
|
+
this._syncListboxAccessibility();
|
|
8815
|
+
if (update.actions.every((action) => action.type !== 'request'))
|
|
8816
|
+
this._renderOptions();
|
|
8817
|
+
}
|
|
8818
|
+
}
|
|
8819
|
+
}
|
|
8820
|
+
if (configErrorDetail) {
|
|
8821
|
+
this._emit('dataLoadingConfigError', configErrorDetail);
|
|
8822
|
+
try {
|
|
8823
|
+
this._dataLoadingConfigErrorCallback?.(configErrorDetail);
|
|
8824
|
+
}
|
|
8825
|
+
catch (error) {
|
|
8826
|
+
this._handleError(error);
|
|
8827
|
+
}
|
|
8828
|
+
}
|
|
8829
|
+
}
|
|
8830
|
+
/** Open the acknowledged request lifecycle after the host has installed listeners. */
|
|
8831
|
+
startDataLoading() {
|
|
8832
|
+
const projectionRecoveryOnly = Boolean(this._dataRequestCoordinator && this._acknowledgedProjectionPending);
|
|
8833
|
+
if (this._dataLoadingConfig.protocol !== 'acknowledged' && !projectionRecoveryOnly)
|
|
8834
|
+
return;
|
|
8835
|
+
if (this._dataLoadingConfig.protocol === 'acknowledged' && !this._ensureDataRequestCoordinator())
|
|
8836
|
+
return;
|
|
8837
|
+
if (!this.isConnected) {
|
|
8838
|
+
if (!this._hasEverConnected)
|
|
8839
|
+
this._acknowledgedDeferredStart = true;
|
|
8840
|
+
return;
|
|
8841
|
+
}
|
|
8842
|
+
if (this._acknowledgedReady)
|
|
8843
|
+
return;
|
|
8844
|
+
if (this._acknowledgedStartTask) {
|
|
8845
|
+
// A reconnect can arrive while the previous readiness task is still
|
|
8846
|
+
// unwinding an interrupted render. Preserve the restart request so the
|
|
8847
|
+
// accepted projection is recovered as soon as that task settles.
|
|
8848
|
+
this._acknowledgedDeferredStart = true;
|
|
8849
|
+
return;
|
|
8850
|
+
}
|
|
8851
|
+
const task = this._startAcknowledgedDataLoading();
|
|
8852
|
+
this._acknowledgedStartTask = task;
|
|
8853
|
+
void task.finally(() => {
|
|
8854
|
+
if (this._acknowledgedStartTask !== task)
|
|
8855
|
+
return;
|
|
8856
|
+
this._acknowledgedStartTask = null;
|
|
8857
|
+
if (this._acknowledgedDeferredStart && this.isConnected) {
|
|
8858
|
+
this._acknowledgedDeferredStart = false;
|
|
8859
|
+
this.startDataLoading();
|
|
8860
|
+
}
|
|
8861
|
+
}).catch((error) => this._handleError(error));
|
|
8862
|
+
}
|
|
8863
|
+
/** Return detached coordinator state without exposing its canonical item storage. */
|
|
8864
|
+
getDataLoadingState() {
|
|
8865
|
+
const coordinator = this._dataRequestCoordinator;
|
|
8866
|
+
if (!coordinator) {
|
|
8867
|
+
const isRemote = this._dataLoadingConfig.searchMode === 'remote'
|
|
8868
|
+
|| this._dataLoadingConfig.searchMode === 'hybrid';
|
|
8869
|
+
const nextEligiblePosition = this._dataLoadingConfig.paginationMode === 'cursor'
|
|
8870
|
+
? { mode: 'cursor', ordinal: 1 }
|
|
8871
|
+
: {
|
|
8872
|
+
mode: 'page',
|
|
8873
|
+
page: isRemote
|
|
8874
|
+
? this._dataLoadingConfig.firstPage
|
|
8875
|
+
: (this._config.infiniteScroll.initialPage ?? 1) + 1,
|
|
8876
|
+
};
|
|
8877
|
+
return {
|
|
8878
|
+
status: 'idle',
|
|
8879
|
+
connected: this.isConnected,
|
|
8880
|
+
busy: false,
|
|
8881
|
+
projectionPending: false,
|
|
8882
|
+
queryGeneration: 0,
|
|
8883
|
+
activeRequest: null,
|
|
8884
|
+
hasMore: this._dataLoadingConfig.protocol === 'acknowledged'
|
|
8885
|
+
&& !isRemote
|
|
8886
|
+
&& (this._config.infiniteScroll.enabled || this._config.loadMore.enabled),
|
|
8887
|
+
nextEligiblePosition,
|
|
8888
|
+
error: null,
|
|
8889
|
+
resourceLimit: null,
|
|
8890
|
+
};
|
|
8891
|
+
}
|
|
8892
|
+
const snapshot = coordinator.getSnapshot();
|
|
8893
|
+
const activeRequest = snapshot.activeRequest
|
|
8894
|
+
? {
|
|
8895
|
+
...snapshot.activeRequest,
|
|
8896
|
+
position: { ...snapshot.activeRequest.position },
|
|
8897
|
+
}
|
|
8898
|
+
: null;
|
|
8899
|
+
return {
|
|
8900
|
+
status: snapshot.status,
|
|
8901
|
+
connected: snapshot.connected,
|
|
8902
|
+
busy: snapshot.busy || this._acknowledgedProjectionPending,
|
|
8903
|
+
projectionPending: this._acknowledgedProjectionPending,
|
|
8904
|
+
queryGeneration: snapshot.queryGeneration,
|
|
8905
|
+
activeRequest,
|
|
8906
|
+
hasMore: snapshot.hasMore,
|
|
8907
|
+
nextEligiblePosition: { ...snapshot.nextEligiblePosition },
|
|
8908
|
+
error: snapshot.error ? { ...snapshot.error } : null,
|
|
8909
|
+
resourceLimit: snapshot.resourceLimit ? { ...snapshot.resourceLimit } : null,
|
|
8910
|
+
};
|
|
8911
|
+
}
|
|
8912
|
+
/** Synchronously accept/classify a host completion; DOM projection proceeds asynchronously. */
|
|
8913
|
+
completeDataRequest(completion) {
|
|
8914
|
+
const coordinator = this._dataRequestCoordinator;
|
|
8915
|
+
if (!coordinator) {
|
|
8916
|
+
const candidate = completion;
|
|
8917
|
+
if (candidate === null
|
|
8918
|
+
|| typeof candidate !== 'object'
|
|
8919
|
+
|| !('requestId' in candidate)
|
|
8920
|
+
|| typeof candidate.requestId !== 'string'
|
|
8921
|
+
|| candidate.requestId.length === 0
|
|
8922
|
+
|| !('queryGeneration' in candidate)
|
|
8923
|
+
|| !Number.isSafeInteger(candidate.queryGeneration)
|
|
8924
|
+
|| candidate.queryGeneration < 0
|
|
8925
|
+
|| !('status' in candidate)
|
|
8926
|
+
|| typeof candidate.status !== 'string'
|
|
8927
|
+
|| !['succeeded', 'empty', 'exhausted', 'failed', 'cancelled'].includes(candidate.status))
|
|
8928
|
+
return 'invalid';
|
|
8929
|
+
return 'unknown-request';
|
|
8930
|
+
}
|
|
8931
|
+
const snapshotBefore = coordinator.getSnapshot();
|
|
8932
|
+
const completionRecord = completion && typeof completion === 'object'
|
|
8933
|
+
? completion
|
|
8934
|
+
: null;
|
|
8935
|
+
const activeRequest = snapshotBefore.activeRequest;
|
|
8936
|
+
const request = activeRequest
|
|
8937
|
+
&& completionRecord?.requestId === activeRequest.requestId
|
|
8938
|
+
&& completionRecord?.queryGeneration === activeRequest.queryGeneration
|
|
8939
|
+
? activeRequest
|
|
8940
|
+
: null;
|
|
8941
|
+
const status = completionRecord?.status;
|
|
8942
|
+
const advancesPosition = status === 'succeeded'
|
|
8943
|
+
|| status === 'exhausted'
|
|
8944
|
+
|| (status === 'empty' && completionRecord?.advance === 'next');
|
|
8945
|
+
const result = coordinator.completeDataRequest(completion);
|
|
8946
|
+
if (result === 'accepted' && request) {
|
|
8947
|
+
this._acknowledgedLastRequest = request;
|
|
8948
|
+
this._acknowledgedProjectionRequest = request;
|
|
8949
|
+
this._acknowledgedProjectionAttempt = 0;
|
|
8950
|
+
this._acknowledgedProjectionCommitsPosition = advancesPosition;
|
|
8951
|
+
void this._projectAcknowledgedSnapshot(coordinator.getSnapshot(), request, advancesPosition);
|
|
8952
|
+
}
|
|
8953
|
+
else if (result === 'resource-limit') {
|
|
8954
|
+
const resourceLimit = coordinator.getSnapshot().resourceLimit;
|
|
8955
|
+
this._emit('diagnostic', {
|
|
8956
|
+
timestamp: Date.now(),
|
|
8957
|
+
source: 'event',
|
|
8958
|
+
name: 'acknowledgedDataLoadingResourceLimit',
|
|
8959
|
+
detail: resourceLimit,
|
|
8960
|
+
});
|
|
8961
|
+
}
|
|
8962
|
+
return result;
|
|
8963
|
+
}
|
|
8964
|
+
_createCoordinatorConfig() {
|
|
8965
|
+
return {
|
|
8966
|
+
dataLoading: { ...this._dataLoadingConfig },
|
|
8967
|
+
infiniteScroll: {
|
|
8968
|
+
pageSize: this._config.infiniteScroll.pageSize,
|
|
8969
|
+
initialPage: this._config.infiniteScroll.initialPage,
|
|
8970
|
+
},
|
|
8971
|
+
};
|
|
8972
|
+
}
|
|
8973
|
+
_ensureDataRequestCoordinator() {
|
|
8974
|
+
if (!this._dataRequestCoordinator) {
|
|
8975
|
+
const isRemote = this._dataLoadingConfig.searchMode === 'remote'
|
|
8976
|
+
|| this._dataLoadingConfig.searchMode === 'hybrid';
|
|
8977
|
+
try {
|
|
8978
|
+
this._dataRequestCoordinator = new DataRequestCoordinator({
|
|
8979
|
+
config: this._createCoordinatorConfig(),
|
|
8980
|
+
initialQuery: this._state.searchQuery,
|
|
8981
|
+
initialItems: this._state.loadedItems,
|
|
8982
|
+
hasMore: !isRemote && (this._config.infiniteScroll.enabled || this._config.loadMore.enabled),
|
|
8983
|
+
});
|
|
8984
|
+
}
|
|
8985
|
+
catch (error) {
|
|
8986
|
+
const detail = {
|
|
8987
|
+
issues: [{
|
|
8988
|
+
path: 'dataLoading',
|
|
8989
|
+
code: 'invalid-value',
|
|
8990
|
+
message: `Acknowledged data loading could not start: ${error instanceof Error ? error.message : String(error)}`,
|
|
8991
|
+
}],
|
|
8992
|
+
};
|
|
8993
|
+
this._emit('dataLoadingConfigError', detail);
|
|
8994
|
+
try {
|
|
8995
|
+
this._dataLoadingConfigErrorCallback?.(detail);
|
|
8996
|
+
}
|
|
8997
|
+
catch (callbackError) {
|
|
8998
|
+
this._handleError(callbackError);
|
|
8999
|
+
}
|
|
9000
|
+
return null;
|
|
9001
|
+
}
|
|
9002
|
+
}
|
|
9003
|
+
this._acknowledgedSearchMode = this._dataLoadingConfig.searchMode;
|
|
9004
|
+
return this._dataRequestCoordinator;
|
|
9005
|
+
}
|
|
9006
|
+
async _startAcknowledgedDataLoading() {
|
|
9007
|
+
const coordinator = this._dataRequestCoordinator;
|
|
9008
|
+
const projectionRecoveryOnly = Boolean(coordinator && this._acknowledgedProjectionPending);
|
|
9009
|
+
if (!coordinator
|
|
9010
|
+
|| (this._dataLoadingConfig.protocol !== 'acknowledged' && !projectionRecoveryOnly)
|
|
9011
|
+
|| !this.isConnected)
|
|
9012
|
+
return;
|
|
9013
|
+
if (this._acknowledgedReady)
|
|
9014
|
+
return;
|
|
9015
|
+
if (this._acknowledgedProjectionPending) {
|
|
9016
|
+
const interruptedProjection = this._acknowledgedProjectionTask;
|
|
9017
|
+
if (interruptedProjection)
|
|
9018
|
+
await interruptedProjection;
|
|
9019
|
+
if (!this.isConnected)
|
|
9020
|
+
return;
|
|
9021
|
+
if (this._acknowledgedProjectionPending) {
|
|
9022
|
+
await this._retryAcknowledgedProjection();
|
|
9023
|
+
}
|
|
9024
|
+
if (!this.isConnected || this._acknowledgedProjectionPending)
|
|
9025
|
+
return;
|
|
9026
|
+
}
|
|
9027
|
+
if (this._dataLoadingConfig.protocol !== 'acknowledged'
|
|
9028
|
+
|| !this._dataRequestCoordinator)
|
|
9029
|
+
return;
|
|
9030
|
+
if (this._acknowledgedPendingSearchQuery !== null) {
|
|
9031
|
+
this._state.searchQuery = this._acknowledgedPendingSearchQuery;
|
|
9032
|
+
this._input.value = this._acknowledgedPendingSearchQuery;
|
|
9033
|
+
this._acknowledgedPendingSearchQuery = null;
|
|
9034
|
+
}
|
|
9035
|
+
const configUpdate = coordinator.updateConfig(this._createCoordinatorConfig());
|
|
9036
|
+
if (configUpdate.status !== 'accepted') {
|
|
9037
|
+
this._acknowledgedReady = false;
|
|
9038
|
+
return;
|
|
9039
|
+
}
|
|
9040
|
+
this._acknowledgedConfigUpdatePending = false;
|
|
9041
|
+
this._acknowledgedDeferredModeChange = false;
|
|
9042
|
+
this._clearAcknowledgedCoordinatorAfterProjection = false;
|
|
9043
|
+
this._acknowledgedReady = true;
|
|
9044
|
+
this._initializeObservers();
|
|
9045
|
+
const configActions = configUpdate.actions;
|
|
9046
|
+
this._dispatchAcknowledgedActions(configActions);
|
|
9047
|
+
const connectionActions = coordinator.connect(this._state.searchQuery);
|
|
9048
|
+
this._dispatchAcknowledgedActions(connectionActions);
|
|
9049
|
+
if (configActions.length === 0 && connectionActions.length === 0)
|
|
9050
|
+
this._renderOptions();
|
|
9051
|
+
const readyRenderCycleId = this._renderCycleId;
|
|
9052
|
+
const readyRenderCompleted = await this._waitForRenderCycle(readyRenderCycleId);
|
|
9053
|
+
if (!readyRenderCompleted) {
|
|
9054
|
+
this._acknowledgedReady = false;
|
|
9055
|
+
throw new Error('Acknowledged readiness render was superseded before completion');
|
|
7607
9056
|
}
|
|
7608
9057
|
}
|
|
7609
9058
|
_mergeConfig(target, source) {
|
|
@@ -7657,7 +9106,8 @@ class EnhancedSelect extends HTMLElement {
|
|
|
7657
9106
|
return;
|
|
7658
9107
|
const enabled = this._config.clearControl.enabled === true;
|
|
7659
9108
|
const hasSelection = this._state.selectedIndices.size > 0;
|
|
7660
|
-
const
|
|
9109
|
+
const visibleSearchQuery = this._acknowledgedPendingSearchQuery ?? this._state.searchQuery;
|
|
9110
|
+
const hasSearch = visibleSearchQuery.length > 0;
|
|
7661
9111
|
const clearSelection = this._config.clearControl.clearSelection !== false;
|
|
7662
9112
|
const clearSearch = this._config.clearControl.clearSearch !== false;
|
|
7663
9113
|
const hasSomethingToClear = (clearSelection && hasSelection) || (clearSearch && hasSearch);
|
|
@@ -7928,6 +9378,357 @@ class EnhancedSelect extends HTMLElement {
|
|
|
7928
9378
|
this._guardedVirtualOverscan = 0;
|
|
7929
9379
|
return true;
|
|
7930
9380
|
}
|
|
9381
|
+
/** Test-only activation seam; deliberately absent from public config/types. */
|
|
9382
|
+
_enableAcknowledgedDataLoadingForTest(config, options = {}) {
|
|
9383
|
+
if (this._dataRequestCoordinator) {
|
|
9384
|
+
throw new Error('Acknowledged data loading is already enabled for this test instance');
|
|
9385
|
+
}
|
|
9386
|
+
const dataLoading = config.dataLoading;
|
|
9387
|
+
this._dataLoadingConfig = {
|
|
9388
|
+
protocol: dataLoading?.protocol ?? 'acknowledged',
|
|
9389
|
+
searchMode: dataLoading?.searchMode ?? 'local',
|
|
9390
|
+
paginationMode: dataLoading?.paginationMode ?? 'page',
|
|
9391
|
+
firstPage: dataLoading?.firstPage ?? 1,
|
|
9392
|
+
...(dataLoading?.fetchLimit === undefined ? {} : { fetchLimit: dataLoading.fetchLimit }),
|
|
9393
|
+
};
|
|
9394
|
+
this._acknowledgedSearchMode = config.dataLoading?.searchMode ?? 'local';
|
|
9395
|
+
this._dataRequestCoordinator = new DataRequestCoordinator({
|
|
9396
|
+
config,
|
|
9397
|
+
initialQuery: this._state.searchQuery,
|
|
9398
|
+
initialItems: this._state.loadedItems,
|
|
9399
|
+
hasMore: options.hasMore,
|
|
9400
|
+
});
|
|
9401
|
+
this._acknowledgedReady = false;
|
|
9402
|
+
if (this.isConnected)
|
|
9403
|
+
this._initializeObservers();
|
|
9404
|
+
}
|
|
9405
|
+
/** Listener installation must precede this private test-only readiness gate. */
|
|
9406
|
+
async _setAcknowledgedDataLoadingReadyForTest() {
|
|
9407
|
+
if (!this._dataRequestCoordinator)
|
|
9408
|
+
throw new Error('Enable acknowledged data loading before readiness');
|
|
9409
|
+
if (!this.isConnected)
|
|
9410
|
+
throw new Error('Acknowledged readiness requires a connected test element');
|
|
9411
|
+
if (this._acknowledgedReady)
|
|
9412
|
+
return;
|
|
9413
|
+
if (this._acknowledgedProjectionPending) {
|
|
9414
|
+
const interruptedProjection = this._acknowledgedProjectionTask;
|
|
9415
|
+
if (interruptedProjection)
|
|
9416
|
+
await interruptedProjection;
|
|
9417
|
+
if (this._acknowledgedProjectionPending) {
|
|
9418
|
+
await this._retryAcknowledgedProjectionForTest();
|
|
9419
|
+
}
|
|
9420
|
+
if (this._acknowledgedProjectionPending) {
|
|
9421
|
+
throw new Error('Acknowledged readiness cannot open while snapshot projection is pending');
|
|
9422
|
+
}
|
|
9423
|
+
}
|
|
9424
|
+
if (this._acknowledgedPendingSearchQuery !== null) {
|
|
9425
|
+
this._state.searchQuery = this._acknowledgedPendingSearchQuery;
|
|
9426
|
+
this._input.value = this._acknowledgedPendingSearchQuery;
|
|
9427
|
+
this._acknowledgedPendingSearchQuery = null;
|
|
9428
|
+
}
|
|
9429
|
+
this._acknowledgedReady = true;
|
|
9430
|
+
this._initializeObservers();
|
|
9431
|
+
const actions = this._dataRequestCoordinator.connect(this._state.searchQuery);
|
|
9432
|
+
this._dispatchAcknowledgedActions(actions);
|
|
9433
|
+
if (actions.length === 0)
|
|
9434
|
+
this._renderOptions();
|
|
9435
|
+
const readyRenderCycleId = this._renderCycleId;
|
|
9436
|
+
const readyRenderCompleted = await this._waitForRenderCycle(readyRenderCycleId);
|
|
9437
|
+
if (!readyRenderCompleted) {
|
|
9438
|
+
this._acknowledgedReady = false;
|
|
9439
|
+
throw new Error('Acknowledged readiness render was superseded before completion');
|
|
9440
|
+
}
|
|
9441
|
+
}
|
|
9442
|
+
_dispatchAcknowledgedActions(actions) {
|
|
9443
|
+
for (const action of actions) {
|
|
9444
|
+
if (action.type === 'cancel') {
|
|
9445
|
+
this._dispatchAcknowledgedEvent('dataRequestCancel', action.notification);
|
|
9446
|
+
try {
|
|
9447
|
+
this._dataRequestCancelCallback?.(action.notification);
|
|
9448
|
+
}
|
|
9449
|
+
catch (error) {
|
|
9450
|
+
this._handleError(error);
|
|
9451
|
+
}
|
|
9452
|
+
continue;
|
|
9453
|
+
}
|
|
9454
|
+
const request = action.request;
|
|
9455
|
+
const coordinator = this._dataRequestCoordinator;
|
|
9456
|
+
if (!coordinator || !this._acknowledgedReady)
|
|
9457
|
+
continue;
|
|
9458
|
+
if (request.kind === 'loadMore') {
|
|
9459
|
+
this._state.lastScrollPosition = this._optionsContainer.scrollTop;
|
|
9460
|
+
this._acknowledgedProjectionScrollTop = this._state.lastScrollPosition;
|
|
9461
|
+
this._state.preserveScrollPosition = true;
|
|
9462
|
+
this._state.isSearching = false;
|
|
9463
|
+
}
|
|
9464
|
+
else {
|
|
9465
|
+
this._acknowledgedProjectionScrollTop = 0;
|
|
9466
|
+
this._state.preserveScrollPosition = false;
|
|
9467
|
+
this._state.isSearching = true;
|
|
9468
|
+
}
|
|
9469
|
+
this._state.isBusy = true;
|
|
9470
|
+
this._acknowledgedLastRequest = request;
|
|
9471
|
+
this._syncListboxAccessibility();
|
|
9472
|
+
this._renderOptions();
|
|
9473
|
+
if (request.kind === 'loadMore') {
|
|
9474
|
+
this._optionsContainer.scrollTop = this._state.lastScrollPosition;
|
|
9475
|
+
}
|
|
9476
|
+
if (!coordinator.markNotificationsDispatched(request.requestId))
|
|
9477
|
+
continue;
|
|
9478
|
+
if (request.kind === 'search') {
|
|
9479
|
+
const detail = { query: request.query, results: [], count: 0, request };
|
|
9480
|
+
this._dispatchAcknowledgedEvent('search', detail);
|
|
9481
|
+
try {
|
|
9482
|
+
const callback = this._config.callbacks.onSearch;
|
|
9483
|
+
callback?.(request.query, request);
|
|
9484
|
+
}
|
|
9485
|
+
catch (error) {
|
|
9486
|
+
this._handleError(error);
|
|
9487
|
+
}
|
|
9488
|
+
}
|
|
9489
|
+
else {
|
|
9490
|
+
const page = request.position.mode === 'page'
|
|
9491
|
+
? request.position.page
|
|
9492
|
+
: request.position.ordinal;
|
|
9493
|
+
const detail = { page, items: [], request };
|
|
9494
|
+
this._dispatchAcknowledgedEvent('loadMore', detail);
|
|
9495
|
+
try {
|
|
9496
|
+
const callback = this._config.callbacks.onLoadMore;
|
|
9497
|
+
callback?.(page, request);
|
|
9498
|
+
}
|
|
9499
|
+
catch (error) {
|
|
9500
|
+
this._handleError(error);
|
|
9501
|
+
}
|
|
9502
|
+
}
|
|
9503
|
+
}
|
|
9504
|
+
}
|
|
9505
|
+
_dispatchAcknowledgedEvent(name, detail) {
|
|
9506
|
+
this.dispatchEvent(new CustomEvent(name, { detail, bubbles: true, composed: true }));
|
|
9507
|
+
this._track('event', name, detail);
|
|
9508
|
+
}
|
|
9509
|
+
/** Test-only completion seam; accepted snapshots are projected from coordinator state. */
|
|
9510
|
+
async _completeDataRequestForTest(completion) {
|
|
9511
|
+
const result = this.completeDataRequest(completion);
|
|
9512
|
+
if (result !== 'accepted')
|
|
9513
|
+
return result;
|
|
9514
|
+
await this._acknowledgedProjectionTask;
|
|
9515
|
+
return result;
|
|
9516
|
+
}
|
|
9517
|
+
_failNextAcknowledgedProjectionForTest(stage = 'before-publish') {
|
|
9518
|
+
this._acknowledgedProjectionFailureStageForTest = stage;
|
|
9519
|
+
}
|
|
9520
|
+
/** Retries only from the canonical accepted coordinator snapshot, never a host payload. */
|
|
9521
|
+
_retryAcknowledgedProjectionForTest() {
|
|
9522
|
+
return this._retryAcknowledgedProjection();
|
|
9523
|
+
}
|
|
9524
|
+
_retryAcknowledgedProjection() {
|
|
9525
|
+
if (!this._dataRequestCoordinator || !this._acknowledgedProjectionPending)
|
|
9526
|
+
return Promise.resolve();
|
|
9527
|
+
return this._projectAcknowledgedSnapshot(this._dataRequestCoordinator.getSnapshot(), this._acknowledgedProjectionRequest ?? this._acknowledgedLastRequest, this._acknowledgedProjectionCommitsPosition);
|
|
9528
|
+
}
|
|
9529
|
+
_projectAcknowledgedSnapshot(snapshot, request, commitPosition) {
|
|
9530
|
+
if (this._acknowledgedProjectionRunning) {
|
|
9531
|
+
return this._acknowledgedProjectionTask ?? Promise.resolve();
|
|
9532
|
+
}
|
|
9533
|
+
this._acknowledgedProjectionRequest = request ?? this._acknowledgedProjectionRequest;
|
|
9534
|
+
this._acknowledgedProjectionAttempt += 1;
|
|
9535
|
+
this._acknowledgedProjectionPending = true;
|
|
9536
|
+
const items = Array.from(snapshot.items);
|
|
9537
|
+
let stagedRegistry;
|
|
9538
|
+
let groupedItems;
|
|
9539
|
+
try {
|
|
9540
|
+
stagedRegistry = createItemRegistry(items, this._itemAdapter, {
|
|
9541
|
+
duplicateKeyPolicy: this._getDuplicateKeyPolicy(),
|
|
9542
|
+
});
|
|
9543
|
+
groupedItems = this._groupItemsByProperty(items);
|
|
9544
|
+
if (this._acknowledgedProjectionFailureStageForTest === 'before-publish') {
|
|
9545
|
+
this._acknowledgedProjectionFailureStageForTest = null;
|
|
9546
|
+
throw new Error('Injected acknowledged projection failure before publication');
|
|
9547
|
+
}
|
|
9548
|
+
}
|
|
9549
|
+
catch (error) {
|
|
9550
|
+
this._syncListboxAccessibility();
|
|
9551
|
+
this._recordAcknowledgedProjectionFailure(snapshot, request, error);
|
|
9552
|
+
return Promise.resolve();
|
|
9553
|
+
}
|
|
9554
|
+
this._acknowledgedProjectionRunning = true;
|
|
9555
|
+
const task = this._applyAcknowledgedSnapshot(snapshot, request, commitPosition, items, stagedRegistry, groupedItems);
|
|
9556
|
+
const trackedTask = task.finally(() => {
|
|
9557
|
+
if (this._acknowledgedProjectionTask === trackedTask) {
|
|
9558
|
+
this._acknowledgedProjectionRunning = false;
|
|
9559
|
+
this._acknowledgedProjectionTask = null;
|
|
9560
|
+
}
|
|
9561
|
+
});
|
|
9562
|
+
this._acknowledgedProjectionTask = trackedTask;
|
|
9563
|
+
return trackedTask;
|
|
9564
|
+
}
|
|
9565
|
+
async _applyAcknowledgedSnapshot(snapshot, request, commitPosition, items, stagedRegistry, groupedItems) {
|
|
9566
|
+
let published = false;
|
|
9567
|
+
try {
|
|
9568
|
+
this._rebuildItemRegistry(items, stagedRegistry);
|
|
9569
|
+
this._state.groupedItems = groupedItems;
|
|
9570
|
+
if (commitPosition && request) {
|
|
9571
|
+
this._state.currentPage = snapshot.lastCommittedPage
|
|
9572
|
+
?? (request.position.mode === 'page' ? request.position.page : request.position.ordinal);
|
|
9573
|
+
}
|
|
9574
|
+
this._state.isSearching = false;
|
|
9575
|
+
this._state.isBusy = true;
|
|
9576
|
+
this._state.lastScrollPosition = this._acknowledgedProjectionScrollTop;
|
|
9577
|
+
this._state.preserveScrollPosition = request?.kind === 'loadMore';
|
|
9578
|
+
published = true;
|
|
9579
|
+
if (this._acknowledgedProjectionFailureStageForTest === 'after-publish') {
|
|
9580
|
+
this._acknowledgedProjectionFailureStageForTest = null;
|
|
9581
|
+
throw new Error('Injected acknowledged projection failure after publication');
|
|
9582
|
+
}
|
|
9583
|
+
if (!this._state.searchQuery
|
|
9584
|
+
&& this._acknowledgedPendingSearchQuery === null
|
|
9585
|
+
&& !this._isActivelyEditingSearchInput()) {
|
|
9586
|
+
this._updateInputDisplay();
|
|
9587
|
+
}
|
|
9588
|
+
this._syncListboxAccessibility();
|
|
9589
|
+
this._renderOptions();
|
|
9590
|
+
const renderCycleId = this._renderCycleId;
|
|
9591
|
+
const completed = await this._waitForRenderCycle(renderCycleId);
|
|
9592
|
+
if (!completed)
|
|
9593
|
+
throw new Error('Acknowledged snapshot render was superseded before completion');
|
|
9594
|
+
this._state.isBusy = snapshot.busy;
|
|
9595
|
+
if (!snapshot.busy) {
|
|
9596
|
+
this._optionsContainer.querySelector('.busy-bucket')?.remove();
|
|
9597
|
+
if (this._shouldRenderLoadMoreTrigger())
|
|
9598
|
+
this._addLoadMoreTrigger();
|
|
9599
|
+
}
|
|
9600
|
+
this._optionsContainer.scrollTop = this._acknowledgedProjectionScrollTop;
|
|
9601
|
+
this._syncListboxAccessibility();
|
|
9602
|
+
this._syncRenderedOptionAccessibility();
|
|
9603
|
+
this._syncLegacyActiveAria();
|
|
9604
|
+
this._state.preserveScrollPosition = false;
|
|
9605
|
+
this._acknowledgedProjectionPending = false;
|
|
9606
|
+
this._acknowledgedProjectionDiagnostic = null;
|
|
9607
|
+
this._acknowledgedProjectionSettling = true;
|
|
9608
|
+
try {
|
|
9609
|
+
this._dispatchDataProjectionNotification({
|
|
9610
|
+
requestId: this._acknowledgedProjectionRequest?.requestId ?? request?.requestId ?? 'unknown',
|
|
9611
|
+
queryGeneration: this._acknowledgedProjectionRequest?.queryGeneration ?? snapshot.queryGeneration,
|
|
9612
|
+
attempt: this._acknowledgedProjectionAttempt,
|
|
9613
|
+
status: 'complete',
|
|
9614
|
+
});
|
|
9615
|
+
}
|
|
9616
|
+
finally {
|
|
9617
|
+
this._acknowledgedProjectionSettling = false;
|
|
9618
|
+
}
|
|
9619
|
+
if (this._clearAcknowledgedCoordinatorAfterProjection) {
|
|
9620
|
+
this._dataRequestCoordinator = null;
|
|
9621
|
+
this._acknowledgedSearchMode = null;
|
|
9622
|
+
this._clearAcknowledgedCoordinatorAfterProjection = false;
|
|
9623
|
+
this._acknowledgedProjectionRequest = null;
|
|
9624
|
+
}
|
|
9625
|
+
else {
|
|
9626
|
+
this._acknowledgedProjectionRequest = null;
|
|
9627
|
+
}
|
|
9628
|
+
this._finishAcknowledgedProjectionSettlement();
|
|
9629
|
+
}
|
|
9630
|
+
catch (error) {
|
|
9631
|
+
if (published) {
|
|
9632
|
+
if (this.isConnected)
|
|
9633
|
+
this._state.isBusy = true;
|
|
9634
|
+
this._state.isSearching = false;
|
|
9635
|
+
this._syncListboxAccessibility();
|
|
9636
|
+
}
|
|
9637
|
+
this._acknowledgedProjectionPending = true;
|
|
9638
|
+
this._recordAcknowledgedProjectionFailure(snapshot, request, error);
|
|
9639
|
+
}
|
|
9640
|
+
}
|
|
9641
|
+
_recordAcknowledgedProjectionFailure(snapshot, request, error) {
|
|
9642
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
9643
|
+
const diagnostic = {
|
|
9644
|
+
requestId: this._acknowledgedProjectionRequest?.requestId ?? request?.requestId ?? 'unknown',
|
|
9645
|
+
queryGeneration: this._acknowledgedProjectionRequest?.queryGeneration ?? snapshot.queryGeneration,
|
|
9646
|
+
message,
|
|
9647
|
+
};
|
|
9648
|
+
this._acknowledgedProjectionDiagnostic = diagnostic;
|
|
9649
|
+
this._emit('diagnostic', {
|
|
9650
|
+
timestamp: Date.now(),
|
|
9651
|
+
source: 'event',
|
|
9652
|
+
name: 'acknowledgedProjectionFailed',
|
|
9653
|
+
detail: diagnostic,
|
|
9654
|
+
});
|
|
9655
|
+
if (diagnostic.requestId !== 'unknown') {
|
|
9656
|
+
this._dispatchDataProjectionNotification({
|
|
9657
|
+
requestId: diagnostic.requestId,
|
|
9658
|
+
queryGeneration: diagnostic.queryGeneration,
|
|
9659
|
+
attempt: this._acknowledgedProjectionAttempt,
|
|
9660
|
+
status: 'failed',
|
|
9661
|
+
error: { message },
|
|
9662
|
+
});
|
|
9663
|
+
}
|
|
9664
|
+
}
|
|
9665
|
+
_dispatchDataProjectionNotification(detail) {
|
|
9666
|
+
this._dispatchAcknowledgedEvent('dataProjection', detail);
|
|
9667
|
+
try {
|
|
9668
|
+
this._dataProjectionCallback?.(detail);
|
|
9669
|
+
}
|
|
9670
|
+
catch (error) {
|
|
9671
|
+
this._handleError(error);
|
|
9672
|
+
}
|
|
9673
|
+
}
|
|
9674
|
+
_dispatchPendingAcknowledgedSearchIntent() {
|
|
9675
|
+
const query = this._acknowledgedPendingSearchQuery;
|
|
9676
|
+
if (query === null || !this._acknowledgedReady || !this.isConnected)
|
|
9677
|
+
return;
|
|
9678
|
+
this._acknowledgedPendingSearchQuery = null;
|
|
9679
|
+
this._handleSearch(query);
|
|
9680
|
+
}
|
|
9681
|
+
/** Apply config/query changes coalesced while an accepted snapshot projected. */
|
|
9682
|
+
_finishAcknowledgedProjectionSettlement() {
|
|
9683
|
+
const coordinator = this._dataRequestCoordinator;
|
|
9684
|
+
const query = this._acknowledgedPendingSearchQuery;
|
|
9685
|
+
if (this._dataLoadingConfig.protocol !== 'acknowledged' || !coordinator) {
|
|
9686
|
+
this._acknowledgedConfigUpdatePending = false;
|
|
9687
|
+
this._acknowledgedDeferredModeChange = false;
|
|
9688
|
+
if (this._dataLoadingConfig.protocol === 'legacy' && query !== null && this.isConnected) {
|
|
9689
|
+
this._acknowledgedPendingSearchQuery = null;
|
|
9690
|
+
this._handleSearch(query);
|
|
9691
|
+
}
|
|
9692
|
+
else {
|
|
9693
|
+
this._dispatchPendingAcknowledgedSearchIntent();
|
|
9694
|
+
}
|
|
9695
|
+
return;
|
|
9696
|
+
}
|
|
9697
|
+
if (!this.isConnected || !this._acknowledgedReady)
|
|
9698
|
+
return;
|
|
9699
|
+
if (this._acknowledgedConfigUpdatePending) {
|
|
9700
|
+
const requiresSingleLatestQueryRequest = this._acknowledgedDeferredModeChange && query !== null;
|
|
9701
|
+
if (requiresSingleLatestQueryRequest) {
|
|
9702
|
+
// Apply the mode transition while disconnected, set the latest query,
|
|
9703
|
+
// then reconnect once. This prevents an intermediate request for the
|
|
9704
|
+
// pre-projection query from escaping before the coalesced latest one.
|
|
9705
|
+
this._dispatchAcknowledgedActions(coordinator.disconnect());
|
|
9706
|
+
}
|
|
9707
|
+
const update = coordinator.updateConfig(this._createCoordinatorConfig());
|
|
9708
|
+
if (update.status !== 'accepted') {
|
|
9709
|
+
this._acknowledgedReady = false;
|
|
9710
|
+
return;
|
|
9711
|
+
}
|
|
9712
|
+
this._acknowledgedConfigUpdatePending = false;
|
|
9713
|
+
this._acknowledgedDeferredModeChange = false;
|
|
9714
|
+
if (requiresSingleLatestQueryRequest && query !== null) {
|
|
9715
|
+
this._acknowledgedPendingSearchQuery = null;
|
|
9716
|
+
this._state.searchQuery = query;
|
|
9717
|
+
this._input.value = query;
|
|
9718
|
+
this._dispatchAcknowledgedActions(coordinator.setQuery(query));
|
|
9719
|
+
this._dispatchAcknowledgedActions(coordinator.connect(query));
|
|
9720
|
+
this._syncListboxAccessibility();
|
|
9721
|
+
this._handleSearch(query);
|
|
9722
|
+
return;
|
|
9723
|
+
}
|
|
9724
|
+
this._dispatchAcknowledgedActions(update.actions);
|
|
9725
|
+
const state = coordinator.getSnapshot();
|
|
9726
|
+
this._state.isBusy = state.busy;
|
|
9727
|
+
this._state.isSearching = state.activeRequest?.kind === 'search';
|
|
9728
|
+
this._syncListboxAccessibility();
|
|
9729
|
+
}
|
|
9730
|
+
this._dispatchPendingAcknowledgedSearchIntent();
|
|
9731
|
+
}
|
|
7931
9732
|
_updateGuardedVirtualWindow(scrollTop, viewportHeight) {
|
|
7932
9733
|
this._guardedVirtualizationRequested = true;
|
|
7933
9734
|
const virtualizer = this._ensureGuardedVirtualizer(this._renderPlan.filteredKeys);
|
|
@@ -8115,6 +9916,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
8115
9916
|
const scrollTopBeforeRender = this._optionsContainer.scrollTop;
|
|
8116
9917
|
this._renderCycleId += 1;
|
|
8117
9918
|
const renderCycleId = this._renderCycleId;
|
|
9919
|
+
this._resolvePendingRenderCycles(false, renderCycleId);
|
|
8118
9920
|
if (this._guardedVirtualizer) {
|
|
8119
9921
|
this._guardedVirtualScrollTop = this._optionsContainer.scrollTop;
|
|
8120
9922
|
}
|
|
@@ -8122,6 +9924,8 @@ class EnhancedSelect extends HTMLElement {
|
|
|
8122
9924
|
if (this._loadMoreTrigger && this._intersectionObserver) {
|
|
8123
9925
|
this._intersectionObserver.unobserve(this._loadMoreTrigger);
|
|
8124
9926
|
}
|
|
9927
|
+
if (this._dataRequestCoordinator)
|
|
9928
|
+
this._loadMoreTrigger = undefined;
|
|
8125
9929
|
this._unobserveGuardedOptionResizeTargets();
|
|
8126
9930
|
// Clear options container
|
|
8127
9931
|
this._optionsContainer.innerHTML = '';
|
|
@@ -8150,12 +9954,15 @@ class EnhancedSelect extends HTMLElement {
|
|
|
8150
9954
|
searching.setAttribute('part', 'loading');
|
|
8151
9955
|
searching.textContent = 'Searching...';
|
|
8152
9956
|
this._optionsContainer.appendChild(searching);
|
|
9957
|
+
this._resolveRenderCycle(renderCycleId, true);
|
|
8153
9958
|
return;
|
|
8154
9959
|
}
|
|
8155
9960
|
const getValue = this._config.serverSide.getValueFromItem || ((item) => item?.value ?? item);
|
|
8156
9961
|
const getLabel = this._config.serverSide.getLabelFromItem || ((item) => item?.label ?? String(item));
|
|
8157
9962
|
// Filter items by search query
|
|
8158
|
-
const query = this.
|
|
9963
|
+
const query = this._acknowledgedSearchMode === 'remote'
|
|
9964
|
+
? ''
|
|
9965
|
+
: this._state.searchQuery.toLowerCase();
|
|
8159
9966
|
if (this._guardedMeasurementQuery !== null && this._guardedMeasurementQuery !== query) {
|
|
8160
9967
|
this._invalidateGuardedMeasurements();
|
|
8161
9968
|
}
|
|
@@ -8280,8 +10087,10 @@ class EnhancedSelect extends HTMLElement {
|
|
|
8280
10087
|
}
|
|
8281
10088
|
}
|
|
8282
10089
|
const renderChunk = () => {
|
|
8283
|
-
if (renderCycleId !== this._renderCycleId)
|
|
10090
|
+
if (renderCycleId !== this._renderCycleId) {
|
|
10091
|
+
this._resolveRenderCycle(renderCycleId, false);
|
|
8284
10092
|
return;
|
|
10093
|
+
}
|
|
8285
10094
|
const fragment = document.createDocumentFragment();
|
|
8286
10095
|
const chunkEnd = Math.min(Math.max(cursor + chunkSize, maxRenderTarget), filteredIndices.length);
|
|
8287
10096
|
maxRenderTarget = 0; // Reset after fast-forwarding
|
|
@@ -8299,12 +10108,15 @@ class EnhancedSelect extends HTMLElement {
|
|
|
8299
10108
|
this._requestLifecycleFrame(renderChunk);
|
|
8300
10109
|
}
|
|
8301
10110
|
else {
|
|
8302
|
-
if (renderCycleId !== this._renderCycleId)
|
|
10111
|
+
if (renderCycleId !== this._renderCycleId) {
|
|
10112
|
+
this._resolveRenderCycle(renderCycleId, false);
|
|
8303
10113
|
return;
|
|
8304
|
-
|
|
10114
|
+
}
|
|
10115
|
+
if (!this._state.isBusy && this._shouldRenderLoadMoreTrigger()) {
|
|
8305
10116
|
this._addLoadMoreTrigger();
|
|
8306
10117
|
}
|
|
8307
10118
|
this._finalizePerfMarks();
|
|
10119
|
+
this._resolveRenderCycle(renderCycleId, true);
|
|
8308
10120
|
}
|
|
8309
10121
|
};
|
|
8310
10122
|
renderChunk();
|
|
@@ -8336,7 +10148,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
8336
10148
|
this._optionsContainer.appendChild(busyBucket);
|
|
8337
10149
|
}
|
|
8338
10150
|
// Append Load More Trigger (Button or Sentinel) if enabled and not busy
|
|
8339
|
-
else if ((this.
|
|
10151
|
+
else if ((!this._dataRequestCoordinator || !this._state.isBusy) && this._shouldRenderLoadMoreTrigger()) {
|
|
8340
10152
|
this._addLoadMoreTrigger();
|
|
8341
10153
|
}
|
|
8342
10154
|
// Rebuilding the list temporarily removes its spacer geometry. Browsers
|
|
@@ -8349,6 +10161,43 @@ class EnhancedSelect extends HTMLElement {
|
|
|
8349
10161
|
this._syncLegacyActiveAria();
|
|
8350
10162
|
this._syncGuardedOptionResizeTargets();
|
|
8351
10163
|
this._finalizePerfMarks();
|
|
10164
|
+
this._resolveRenderCycle(renderCycleId, true);
|
|
10165
|
+
}
|
|
10166
|
+
_waitForRenderCycle(renderCycleId) {
|
|
10167
|
+
if (renderCycleId < this._renderCycleId)
|
|
10168
|
+
return Promise.resolve(false);
|
|
10169
|
+
if (renderCycleId <= this._completedRenderCycleId)
|
|
10170
|
+
return Promise.resolve(true);
|
|
10171
|
+
return new Promise((resolve) => {
|
|
10172
|
+
this._renderCycleWaiters.set(renderCycleId, resolve);
|
|
10173
|
+
const timeout = window.setTimeout(() => this._resolveRenderCycle(renderCycleId, false), 120000);
|
|
10174
|
+
this._renderCycleWaiterTimeouts.set(renderCycleId, timeout);
|
|
10175
|
+
});
|
|
10176
|
+
}
|
|
10177
|
+
_resolveRenderCycle(renderCycleId, completed) {
|
|
10178
|
+
if (completed)
|
|
10179
|
+
this._completedRenderCycleId = Math.max(this._completedRenderCycleId, renderCycleId);
|
|
10180
|
+
const resolve = this._renderCycleWaiters.get(renderCycleId);
|
|
10181
|
+
const timeout = this._renderCycleWaiterTimeouts.get(renderCycleId);
|
|
10182
|
+
if (timeout !== undefined)
|
|
10183
|
+
window.clearTimeout(timeout);
|
|
10184
|
+
this._renderCycleWaiterTimeouts.delete(renderCycleId);
|
|
10185
|
+
if (!resolve)
|
|
10186
|
+
return;
|
|
10187
|
+
this._renderCycleWaiters.delete(renderCycleId);
|
|
10188
|
+
resolve(completed);
|
|
10189
|
+
}
|
|
10190
|
+
_resolvePendingRenderCycles(completed, beforeCycleId = Number.POSITIVE_INFINITY) {
|
|
10191
|
+
for (const [renderCycleId, resolve] of this._renderCycleWaiters) {
|
|
10192
|
+
if (renderCycleId >= beforeCycleId)
|
|
10193
|
+
continue;
|
|
10194
|
+
const timeout = this._renderCycleWaiterTimeouts.get(renderCycleId);
|
|
10195
|
+
if (timeout !== undefined)
|
|
10196
|
+
window.clearTimeout(timeout);
|
|
10197
|
+
this._renderCycleWaiterTimeouts.delete(renderCycleId);
|
|
10198
|
+
this._renderCycleWaiters.delete(renderCycleId);
|
|
10199
|
+
resolve(completed);
|
|
10200
|
+
}
|
|
8352
10201
|
}
|
|
8353
10202
|
_unobserveGuardedOptionResizeTargets() {
|
|
8354
10203
|
for (const option of this._guardedObservedOptions) {
|
|
@@ -8561,6 +10410,46 @@ class EnhancedSelect extends HTMLElement {
|
|
|
8561
10410
|
_addLoadMoreTrigger() {
|
|
8562
10411
|
const container = document.createElement('div');
|
|
8563
10412
|
container.className = 'load-more-container';
|
|
10413
|
+
if (this._dataRequestCoordinator) {
|
|
10414
|
+
const shouldObserve = this._config.infiniteScroll.enabled
|
|
10415
|
+
&& Boolean(this._intersectionObserver)
|
|
10416
|
+
&& this._acknowledgedReady;
|
|
10417
|
+
let sentinel;
|
|
10418
|
+
if (shouldObserve) {
|
|
10419
|
+
sentinel = this._acknowledgedSentinel ?? document.createElement('div');
|
|
10420
|
+
sentinel.className = 'infinite-scroll-sentinel';
|
|
10421
|
+
sentinel.style.height = '10px';
|
|
10422
|
+
sentinel.style.width = '100%';
|
|
10423
|
+
sentinel.style.opacity = '0';
|
|
10424
|
+
this._acknowledgedSentinel = sentinel;
|
|
10425
|
+
this._loadMoreTrigger = sentinel;
|
|
10426
|
+
container.appendChild(sentinel);
|
|
10427
|
+
}
|
|
10428
|
+
// Keep an explicit keyboard-accessible path even when automatic
|
|
10429
|
+
// observation is enabled, and use it as the fallback if IO is absent.
|
|
10430
|
+
if (this._config.loadMore.enabled || this._config.infiniteScroll.enabled) {
|
|
10431
|
+
const button = document.createElement('button');
|
|
10432
|
+
button.className = 'load-more-button';
|
|
10433
|
+
button.textContent = `Load ${this._config.loadMore.itemsPerLoad} more`;
|
|
10434
|
+
button.addEventListener('click', () => this._loadMoreItems('manual'));
|
|
10435
|
+
container.appendChild(button);
|
|
10436
|
+
if (!sentinel)
|
|
10437
|
+
this._loadMoreTrigger = button;
|
|
10438
|
+
}
|
|
10439
|
+
this._optionsContainer.appendChild(container);
|
|
10440
|
+
if (sentinel && this._intersectionObserver) {
|
|
10441
|
+
try {
|
|
10442
|
+
this._intersectionObserver.observe(sentinel);
|
|
10443
|
+
}
|
|
10444
|
+
catch (_error) {
|
|
10445
|
+
this._intersectionObserver.disconnect();
|
|
10446
|
+
this._intersectionObserver = undefined;
|
|
10447
|
+
sentinel.remove();
|
|
10448
|
+
this._loadMoreTrigger = container.querySelector('.load-more-button') ?? undefined;
|
|
10449
|
+
}
|
|
10450
|
+
}
|
|
10451
|
+
return;
|
|
10452
|
+
}
|
|
8564
10453
|
if (this._config.infiniteScroll.enabled) {
|
|
8565
10454
|
// Infinite Scroll: Render an invisible sentinel
|
|
8566
10455
|
// It must have some height to be intersected
|
|
@@ -8587,6 +10476,23 @@ class EnhancedSelect extends HTMLElement {
|
|
|
8587
10476
|
this._intersectionObserver.observe(this._loadMoreTrigger);
|
|
8588
10477
|
}
|
|
8589
10478
|
}
|
|
10479
|
+
_shouldRenderLoadMoreTrigger() {
|
|
10480
|
+
if (!this._config.loadMore.enabled && !this._config.infiniteScroll.enabled)
|
|
10481
|
+
return false;
|
|
10482
|
+
if (this._dataLoadingConfig.protocol === 'acknowledged'
|
|
10483
|
+
&& (!this._dataRequestCoordinator || !this._acknowledgedReady))
|
|
10484
|
+
return false;
|
|
10485
|
+
if (!this._dataRequestCoordinator)
|
|
10486
|
+
return this._state.loadedItems.length > 0;
|
|
10487
|
+
const snapshot = this._dataRequestCoordinator.getSnapshot();
|
|
10488
|
+
if (snapshot.status === 'resource-limited')
|
|
10489
|
+
return false;
|
|
10490
|
+
return snapshot.hasMore
|
|
10491
|
+
|| snapshot.error !== null
|
|
10492
|
+
|| snapshot.status === 'empty'
|
|
10493
|
+
|| snapshot.status === 'failed'
|
|
10494
|
+
|| snapshot.status === 'cancelled';
|
|
10495
|
+
}
|
|
8590
10496
|
}
|
|
8591
10497
|
/** live set of all connected instances; used to auto-close siblings */
|
|
8592
10498
|
EnhancedSelect._instances = new Set();
|
|
@@ -9624,5 +11530,5 @@ function warnCSPViolation(feature, fallback) {
|
|
|
9624
11530
|
}
|
|
9625
11531
|
}
|
|
9626
11532
|
|
|
9627
|
-
export { CSPFeatures, CustomOptionPool, DOMPool, DefaultSelectEffectRunner, EnhancedSelect, FenwickTree, NativeSelectElement, OptionRenderer, PerformanceTelemetry, SelectEngineBridge, SelectOption, Virtualizer, WorkerManager, applyClasses, applyDefaultTheme, applySelectionRequest, arrayIncludesValue, arraysEqualByValue, configureSelect, containsSuspiciousPatterns, createDefaultItemAdapter, createElement, createInitialSelectState, createItemRegistry, createRendererHelpers, createTextNode, defaultTheme, detectEnvironment, escapeAttribute, escapeHTML, getActiveKey, getCustomProperty, getDefaultDuplicateKeyPolicy, getHTMLSanitizer, getSelectedKeys, getTelemetry, getWorkerManager, hasOverflowHiddenAncestor, hasSelection, injectShadowStyles, isDisabled, isFocused, isOpen, isRegisteredKey, isSelected, measureAsync, measureSync, removeCustomProperty, renderTemplate, resetSelectConfig, sanitizeHTML, selectConfig, setCSSProperties, setCustomProperties, setHTMLSanitizer, setTextContent, shadowDOMStyles, toggleClass, transition, validateTemplate, valuesEqual, warnCSPViolation };
|
|
11533
|
+
export { CSPFeatures, CustomOptionPool, DOMPool, DefaultSelectEffectRunner, EnhancedSelect, FenwickTree, NativeSelectElement, OptionRenderer, PerformanceTelemetry, SelectEngineBridge, SelectOption, Virtualizer, WorkerManager, applyClasses, applyDefaultTheme, applySelectionRequest, arrayIncludesValue, arraysEqualByValue, configureSelect, containsSuspiciousPatterns, createDefaultItemAdapter, createElement, createInitialSelectState, createItemRegistry, createRendererHelpers, createTextNode, defaultTheme, detectEnvironment, escapeAttribute, escapeHTML, getActiveKey, getCustomProperty, getDefaultDuplicateKeyPolicy, getHTMLSanitizer, getSelectedKeys, getTelemetry, getWorkerManager, hasOverflowHiddenAncestor, hasSelection, injectShadowStyles, isDisabled, isFocused, isOpen, isRegisteredKey, isSelected, measureAsync, measureSync, removeCustomProperty, renderTemplate, resetSelectConfig, sanitizeHTML, selectConfig, setCSSProperties, setCustomProperties, setHTMLSanitizer, setTextContent, shadowDOMStyles, toggleClass, transition, validateDataLoadingConfig, validateTemplate, valuesEqual, warnCSPViolation };
|
|
9628
11534
|
//# sourceMappingURL=index.js.map
|