@smilodon/react 1.12.0 → 1.12.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 CHANGED
@@ -2,7 +2,9 @@
2
2
 
3
3
  Select component for React applications. The shared core has scoped automated Phase 4 browser coverage; complete React integration parity and manual assistive-technology certification remain unverified.
4
4
 
5
- > **Upcoming web release:** React `1.12.0` and Core `1.17.0` are release candidates, not yet available from npm. Their cumulative changes and qualification limits are tracked in the [web release checklist](../../docs/releases/WEB-1.17.0-RELEASE.md).
5
+ > **Published package versions:** React `1.12.1` and Core `1.18.0` are available from npm. React `1.12.1` includes Issue #107 data-synchronization behavior; Core `1.17.0` includes Issue #100 chip auto-scroll, and Core `1.18.0` includes Issue #104 custom-arrow hover styling. See the [React 1.12.1 release record](../../docs/releases/REACT-1.12.1-RELEASE.md) and [web 1.17.0 release record](../../docs/releases/WEB-1.17.0-RELEASE.md).
6
+
7
+ > **Unpublished React 1.12.2 candidate:** Issue #112 preserves React custom option and group-header renderer roots while Core retains cumulative acknowledged pages across controlled rerenders. The candidate was locally checked with Core 1.18.0; Core 1.19.0 compatibility has not been verified. See [renderer lifecycle details](../../docs/architecture/ISSUE-112-REACT-RENDERER-CACHE-LIFECYCLE.md) and the [combined release record](../../docs/releases/WEB-1.19.0-RELEASE.md).
6
8
 
7
9
  > Large-list status: the public `virtualized` prop enables legacy chunked rendering for large flat lists; it does not window rows to the viewport, and all results may eventually be mounted. True viewport virtualization remains guarded by a private test seam and is not a supported production mode. The shared core passed its scoped Phase 4 automated browser matrix in Chromium, Firefox, and WebKit; this does not certify every React integration, minimum browser versions, or WCAG conformance. Manual assistive-technology assessment remains pending. See the [current limitation record](../../docs/KNOWN-LIMITATIONS.md#viewport-virtualization-status).
8
10
 
@@ -53,6 +55,31 @@ The current local Phase 2F-D candidate integrates the core acknowledged-loading
53
55
 
54
56
  Acknowledged loading is opt-in through per-instance `config.dataLoading`; there is no global acknowledged-loading default. If the config is omitted, the adapter keeps the legacy protocol and existing callback behavior. The host owns fetch, cancellation, and retry policy; the core owns request identity, stale-completion rejection, canonical acceptance, and subsequent DOM projection.
55
57
 
58
+ ### Minimum remote-search length — Issue #109
59
+
60
+ Configure the Core coordinator through the existing `config` prop. React does not filter or suppress callbacks itself; short queries never become Core search requests, so they do not invoke `onSearch` or enter search busy state.
61
+
62
+ ```tsx
63
+ <Select
64
+ searchable
65
+ infiniteScroll
66
+ pageSize={6}
67
+ config={{
68
+ dataLoading: {
69
+ protocol: 'acknowledged',
70
+ searchMode: 'remote',
71
+ paginationMode: 'page',
72
+ fetchLimit: 6,
73
+ minSearchCharacters: 3,
74
+ },
75
+ }}
76
+ onSearch={handleSearch}
77
+ onLoadMore={handleLoadMore}
78
+ />
79
+ ```
80
+
81
+ The default `0` retains the existing request behavior. `3` counts three Unicode code points after trimming surrounding whitespace; it does not count grapheme clusters. When the query is shorter, Core restores the unfiltered item and pagination snapshot and continues to route browse pagination through `onLoadMore`. Crossing the threshold starts a search at its first page. Deleting back below threshold or calling the imperative `clearSearch()` cancels eligible search work and restores browsing state; canceled late responses cannot replace it. Runtime threshold updates use the same transitions. See the [Core contract and qualification record](../../docs/architecture/ISSUE-109-MIN-SEARCH-CHARACTERS.md).
82
+
56
83
  ### Remote cursor search with cancellation and failures
57
84
 
58
85
  This illustrative component handles remote search and load-more requests through one host function. It sends the exact query (including an empty string), passes page/cursor position and fetch limit to the server, echoes request identity on completion, aborts cancelled requests, and reports failures without an automatic retry.
@@ -176,6 +203,14 @@ export function RemoteSelect() {
176
203
 
177
204
  The coordinator rejects stale responses by request ID and query generation; the host should still abort cancelled network work to save resources. An accepted response does not mean projection is finished: observe `onDataProjection` for the projection result. A failed request remains failed until a new explicit request is made; the sample deliberately does not retry automatically.
178
205
 
206
+ ### React item synchronization and acknowledged pagination
207
+
208
+ The adapter treats React props as the source snapshot and the Core data coordinator as the owner of accepted acknowledged responses. Rerendering with a newly allocated array of equivalent plain-object records does not call `setItems()` and cannot reset pages accepted by Core. Meaningful changes to an item's enumerable fields, nested plain-object metadata, array metadata, or group structure synchronize as source updates; an empty array is also an intentional update.
209
+
210
+ Use immutable plain-object item records. Functions and non-plain metadata values such as `Date`, `Map`, and class instances compare by identity, so memoize them if they are part of item metadata. Enumerable symbol keys and accessor identity are included in comparison. When data is semantically unchanged, React cannot infer that the application intends to restart pagination; initiate a new acknowledged search/generation for that intent instead of relying on a render or a fresh array.
211
+
212
+ The adapter applies configuration, source data, and controlled selection through separate lifecycle paths. Fresh equivalent configuration objects and inline React `removeButtonIcon` nodes do not reapply Core configuration. Actual selection, layout, styling, disabled-state, and data-loading configuration changes remain active. See the [React data synchronization ownership record](../../docs/architecture/REACT-DATA-SYNC-OWNERSHIP-107.md).
213
+
179
214
  ### Other useful scenarios
180
215
 
181
216
  - **Terminal empty remote search (#92):** When the host completes the matching acknowledged request with `status: 'exhausted'`, `items: []`, and `hasMore: false`, Core displays the query-specific no-results message after successful projection. React consumers do not need a manual rerender, popup toggle, or `setItems([])` workaround. Wait for `onDataProjection` with `status: 'complete'` before relying on the projected DOM; `completeDataRequest()` returning `accepted` reports response acceptance, not DOM settlement. An empty page with `status: 'empty'` and `hasMore: true` is nonterminal. This guidance does not include the separate React #85 fix.
@@ -219,9 +254,9 @@ Use `contentMode: 'replace'` when accessible `loadingContent` should be the only
219
254
 
220
255
  `minDisplayTime` is a presentation policy for the busy bucket, not a request delay. Request acceptance, pagination state, and `aria-busy` update as soon as the request completes. The dedicated `Searching...` view remains unchanged and is not replaced by these props.
221
256
 
222
- ### Latest-chip auto-scroll (React 1.12.0 candidate; Issue #100)
257
+ ### Latest-chip auto-scroll (React 1.12.0; Issue #100)
223
258
 
224
- In horizontal multi-select mode, `multiSelectDisplay.scrollToLatestChip` reveals a newly selected chip. It is opt-in and respects reduced-motion preferences. This behavior requires the pending Core `1.17.0` release; the adapter versions listed in the [web release checklist](../../docs/releases/WEB-1.17.0-RELEASE.md) are not yet on npm.
259
+ In horizontal multi-select mode, `multiSelectDisplay.scrollToLatestChip` reveals a newly selected chip. It is opt-in and respects reduced-motion preferences. It is available with Core `1.17.0`.
225
260
 
226
261
  ```tsx
227
262
  <Select
@@ -236,7 +271,7 @@ In horizontal multi-select mode, `multiSelectDisplay.scrollToLatestChip` reveals
236
271
  />
237
272
  ```
238
273
 
239
- ### Custom empty-state renderer (React 1.12.0 candidate; Issue #93)
274
+ ### Custom empty-state renderer (React 1.12.0; Issue #93)
240
275
 
241
276
  `emptyStateRenderer` receives Core's readonly `{ query, reason }` context only while a terminal empty state is active. React renders its result in Core's native `empty-state` slot; omit the prop to keep the built-in fallback. `onEmptyStateChange` receives the new context and receives `null` when the empty state clears. The imperative handle also exposes `getEmptyStateContext()`.
242
277
 
@@ -1881,11 +1916,11 @@ When rendering custom option content, set `classMap.active` to the class names u
1881
1916
 
1882
1917
  The option's `data-sm-state`, `aria-selected`, and classes reflect independent active/selected semantics. The fix is in Core, not in React's renderer. See [Issue #82](https://github.com/navidrezadoost/Smilodon/issues/82) and the [Core rendering guide](../core/README.md#active-state-on-custom-option-roots).
1883
1918
 
1884
- ### Acknowledged pagination on React rerenders — Issue #85 (unreleased)
1919
+ ### Acknowledged data synchronization on React rerenders — Issue #107
1885
1920
 
1886
- The reported local fix for [Issue #85](https://github.com/navidrezadoost/Smilodon/issues/85) is qualified **but not yet pushed, merged, or published**. In acknowledged loading, React's `items` prop can supply the initial page while Core accepts cumulative pages using `completeDataRequest()`. Equivalent or newly allocated `config`, `multiSelectDisplay`, and `disabledOptionBehavior` objects must not force Core to revert its accepted cumulative snapshot to the initial `items`.
1921
+ In acknowledged loading, Core owns the cumulative accepted result pages, while React owns the source records and configuration passed by the application. React `1.12.1` compares incoming source/configuration values with the last values it successfully synchronized. Equivalent newly allocated arrays and plain configuration objects do not reset accepted pages during an incidental rerender; changed item fields, grouping, and an explicit empty source still synchronize.
1887
1922
 
1888
- The pending fix moves `items`/`groupedItems` synchronization into one identity-guarded effect, independent of presentation configuration, and applies uncontrolled `defaultValue` after item registration. New `items` or `groupedItems` identities still represent deliberate updates; `setItems()` alone is not an acknowledged coordinator reset. Keep input references stable where the input is unchanged, complete requests with their exact request IDs and generations, and consult the final release notes before expecting this fix in published packages.
1923
+ Controlled selection remains synchronized separately. Core's acknowledged request protocol and imperative `setItems()` behavior are unchanged. Functions and non-plain metadata values compare by identity; keep them stable when they have not changed. Consumers should replace records immutably when changing their contents. See [Issue #107](https://github.com/navidrezadoost/Smilodon/issues/107), the [implementation and qualification record](../../docs/architecture/REACT-DATA-SYNC-OWNERSHIP-107.md), and the [React 1.12.1 release record](../../docs/releases/REACT-1.12.1-RELEASE.md).
1889
1924
 
1890
1925
  ## Styling
1891
1926
 
package/dist/index.cjs CHANGED
@@ -32,7 +32,8 @@ const DEFAULT_DATA_LOADING_CONFIG = {
32
32
  protocol: "legacy",
33
33
  searchMode: "local",
34
34
  paginationMode: "page",
35
- firstPage: 1
35
+ firstPage: 1,
36
+ minSearchCharacters: 0
36
37
  };
37
38
  function isPlainRecord(value) {
38
39
  if (value === null || typeof value !== "object" || Array.isArray(value)) {
@@ -41,6 +42,64 @@ function isPlainRecord(value) {
41
42
  const prototype = Object.getPrototypeOf(value);
42
43
  return prototype === Object.prototype || prototype === null;
43
44
  }
45
+ function areSemanticallyEqual(left, right, seen = /* @__PURE__ */ new WeakMap()) {
46
+ var _a;
47
+ if (Object.is(left, right)) return true;
48
+ if (left === null || right === null || typeof left !== "object" || typeof right !== "object") {
49
+ return false;
50
+ }
51
+ const leftArray = Array.isArray(left);
52
+ const rightArray = Array.isArray(right);
53
+ if (leftArray !== rightArray) return false;
54
+ if (!leftArray && (!isPlainRecord(left) || !isPlainRecord(right))) return false;
55
+ if (leftArray && !Array.isArray(right)) return false;
56
+ if (leftArray && rightArray && left.length !== right.length) return false;
57
+ const leftPrototype = Object.getPrototypeOf(left);
58
+ const rightPrototype = Object.getPrototypeOf(right);
59
+ if (leftPrototype !== rightPrototype && !(isPlainRecord(left) && isPlainRecord(right))) return false;
60
+ const prior = (_a = seen.get(left)) == null ? void 0 : _a.get(right);
61
+ if (prior !== void 0) return prior;
62
+ let rightPairs = seen.get(left);
63
+ if (!rightPairs) {
64
+ rightPairs = /* @__PURE__ */ new WeakMap();
65
+ seen.set(left, rightPairs);
66
+ }
67
+ rightPairs.set(right, true);
68
+ const enumerableKeys = (value) => Reflect.ownKeys(value).filter((key) => {
69
+ var _a2;
70
+ return (_a2 = Object.getOwnPropertyDescriptor(value, key)) == null ? void 0 : _a2.enumerable;
71
+ });
72
+ const leftKeys = enumerableKeys(left);
73
+ const rightKeys = enumerableKeys(right);
74
+ const rightKeySet = new Set(rightKeys);
75
+ if (leftKeys.length !== rightKeys.length) {
76
+ rightPairs.set(right, false);
77
+ return false;
78
+ }
79
+ for (const key of leftKeys) {
80
+ if (!rightKeySet.has(key)) {
81
+ rightPairs.set(right, false);
82
+ return false;
83
+ }
84
+ const leftDescriptor = Object.getOwnPropertyDescriptor(left, key);
85
+ const rightDescriptor = Object.getOwnPropertyDescriptor(right, key);
86
+ if ("value" in leftDescriptor !== "value" in rightDescriptor) {
87
+ rightPairs.set(right, false);
88
+ return false;
89
+ }
90
+ if ("value" in leftDescriptor) {
91
+ if (!areSemanticallyEqual(leftDescriptor.value, rightDescriptor.value, seen)) {
92
+ rightPairs.set(right, false);
93
+ return false;
94
+ }
95
+ } else if (leftDescriptor.get !== rightDescriptor.get || leftDescriptor.set !== rightDescriptor.set) {
96
+ rightPairs.set(right, false);
97
+ return false;
98
+ }
99
+ }
100
+ return true;
101
+ }
102
+ const EMPTY_ITEMS = [];
44
103
  function isBusyToken(value) {
45
104
  return value === true || value === "true";
46
105
  }
@@ -52,7 +111,7 @@ function composeBusyToken(consumerValue, externalBusy) {
52
111
  const Select = React.forwardRef((props, ref) => {
53
112
  var _a, _b, _c;
54
113
  const {
55
- items = [],
114
+ items = EMPTY_ITEMS,
56
115
  groupedItems,
57
116
  value,
58
117
  defaultValue,
@@ -219,6 +278,13 @@ const Select = React.forwardRef((props, ref) => {
219
278
  }
220
279
  Promise.resolve().then(() => root.unmount());
221
280
  }, []);
281
+ const reconcileRendererCache = React.useCallback((cache, renderedOptions) => {
282
+ for (const [index, entry] of cache) {
283
+ if (renderedOptions.contains(entry.container)) continue;
284
+ if (cache.get(index) === entry) cache.delete(index);
285
+ scheduleRootUnmount(entry.root);
286
+ }
287
+ }, [scheduleRootUnmount]);
222
288
  const customRendererRef = React.useRef(customRenderer ?? renderItem);
223
289
  const optionRendererRef = React.useRef(optionRenderer);
224
290
  const groupHeaderRendererRef = React.useRef(groupHeaderRenderer);
@@ -278,24 +344,6 @@ const Select = React.forwardRef((props, ref) => {
278
344
  groupHeaderRendererCache.current.clear();
279
345
  };
280
346
  }, [scheduleRootUnmount]);
281
- React.useEffect(() => {
282
- const totalItems = groupedItems ? groupedItems.reduce((count, group) => count + group.options.length, 0) : items.length;
283
- reactRendererCache.current.forEach((entry, index) => {
284
- if (index >= totalItems) {
285
- scheduleRootUnmount(entry.root);
286
- reactRendererCache.current.delete(index);
287
- }
288
- });
289
- }, [items, groupedItems, scheduleRootUnmount]);
290
- React.useEffect(() => {
291
- const totalGroups = (groupedItems == null ? void 0 : groupedItems.length) ?? 0;
292
- groupHeaderRendererCache.current.forEach((entry, index) => {
293
- if (index >= totalGroups) {
294
- scheduleRootUnmount(entry.root);
295
- groupHeaderRendererCache.current.delete(index);
296
- }
297
- });
298
- }, [groupedItems, scheduleRootUnmount]);
299
347
  React.useEffect(() => {
300
348
  if (groupHeaderRenderer) return;
301
349
  groupHeaderRendererCache.current.forEach(
@@ -317,6 +365,37 @@ const Select = React.forwardRef((props, ref) => {
317
365
  const dataLoadingConfigured = (coreConfig == null ? void 0 : coreConfig.dataLoading) !== void 0;
318
366
  const coreFacadeRequired = acknowledgedRequested || dataLoadingConfigured;
319
367
  const isElementUsable = isElementReady && (!acknowledgedRequested || isAcknowledgedQualified) && (!coreFacadeRequired || isCoreModuleLoaded) && !isUnusable;
368
+ React.useEffect(() => {
369
+ var _a2;
370
+ if (!isElementReady) return;
371
+ const shadow = (_a2 = elementRef.current) == null ? void 0 : _a2.shadowRoot;
372
+ const renderedOptions = shadow == null ? void 0 : shadow.querySelector(".options-container");
373
+ if (!renderedOptions) return;
374
+ let disposed = false;
375
+ let reconciliationQueued = false;
376
+ const reconcile = () => {
377
+ reconciliationQueued = false;
378
+ if (disposed) return;
379
+ reconcileRendererCache(reactRendererCache.current, renderedOptions);
380
+ reconcileRendererCache(groupHeaderRendererCache.current, renderedOptions);
381
+ };
382
+ const queueReconciliation = () => {
383
+ if (reconciliationQueued || disposed) return;
384
+ reconciliationQueued = true;
385
+ if (typeof queueMicrotask === "function") {
386
+ queueMicrotask(reconcile);
387
+ } else {
388
+ Promise.resolve().then(reconcile);
389
+ }
390
+ };
391
+ const observer = new MutationObserver(queueReconciliation);
392
+ observer.observe(renderedOptions, { childList: true });
393
+ queueReconciliation();
394
+ return () => {
395
+ disposed = true;
396
+ observer.disconnect();
397
+ };
398
+ }, [isElementReady, reconcileRendererCache]);
320
399
  const markUnusable = React.useCallback(
321
400
  (message) => {
322
401
  if (unusableRef.current) return;
@@ -639,156 +718,108 @@ const Select = React.forwardRef((props, ref) => {
639
718
  return (_a2 = activeListenersRef.current) == null ? void 0 : _a2.dispose();
640
719
  };
641
720
  }, []);
642
- React.useEffect(() => {
643
- var _a2;
644
- const element = elementRef.current;
645
- if (!element || !isElementUsable) return;
646
- if (!element.setItems) {
647
- console.warn("Enhanced select element not fully initialized yet");
648
- return;
649
- }
650
- if (groupedItems) {
651
- element.setGroupedItems(groupedItems);
652
- } else if (items.length > 0) {
653
- element.setItems(items);
654
- }
655
- const config = {
656
- searchable,
657
- placeholder,
658
- virtualize: virtualized,
659
- estimatedItemHeight,
660
- enabled: !disabled,
661
- dropdownPlacement: {
662
- mode: resolvedDropdownPlacement
663
- },
664
- selection: {
665
- ...selectionConfig,
666
- mode: multiple ? "multi" : "single",
667
- maxSelections,
668
- removeButtonIcon: typeof removeButtonIcon === "string" ? removeButtonIcon : void 0,
669
- disabledOptionBehavior,
670
- showSelectedIndicator,
671
- toggleOnTriggerClick
672
- },
673
- direction,
674
- multiSelectDisplay,
675
- infiniteScroll: {
676
- enabled: infiniteScroll,
677
- pageSize
678
- },
679
- scrollToSelected: {
680
- enabled: true,
681
- ...scrollToSelected
682
- },
683
- creatable,
684
- styles: stylesConfig,
685
- clearControl: {
686
- enabled: clearable,
687
- clearSelection: clearSelectionOnClear,
688
- clearSearch: clearSearchOnClear,
689
- ariaLabel: clearAriaLabel,
690
- icon: clearIcon
691
- },
692
- tracking: {
693
- enabled: trackingEnabled,
694
- events: trackEvents,
695
- styling: trackStyling,
696
- limitations: trackLimitations,
697
- emitDiagnostics,
698
- maxEntries: trackingMaxEntries
699
- },
700
- limitations: {
701
- policies: limitationPolicies,
702
- autoMitigateRuntimeModeSwitch
703
- }
704
- };
705
- applyInstanceConfig(element, config);
706
- if (coreConfig) {
707
- applyInstanceConfig(element, coreConfig);
708
- }
709
- if (!isControlled && !hasAppliedInitialValueRef.current && internalValue !== void 0) {
710
- const values = Array.isArray(internalValue) ? internalValue : [internalValue];
711
- const currentValues = ((_a2 = element.getSelectedValues) == null ? void 0 : _a2.call(element)) || [];
712
- if (!areValuesEqual(values, currentValues)) {
713
- element.setSelectedValues(values);
714
- }
715
- hasAppliedInitialValueRef.current = true;
716
- }
717
- if (error) {
718
- element.setError(errorMessage || "Invalid selection");
719
- } else {
720
- element.clearError();
721
- }
722
- if (required) {
723
- element.setRequired(true);
724
- }
725
- }, [
726
- isElementUsable,
727
- items,
728
- groupedItems,
721
+ const componentConfig = {
729
722
  searchable,
730
723
  placeholder,
731
- virtualized,
724
+ virtualize: virtualized,
732
725
  estimatedItemHeight,
733
- disabled,
734
- multiple,
735
- maxSelections,
736
- selectionConfig,
726
+ enabled: !disabled,
727
+ dropdownPlacement: { mode: resolvedDropdownPlacement },
728
+ selection: {
729
+ ...selectionConfig,
730
+ mode: multiple ? "multi" : "single",
731
+ maxSelections,
732
+ removeButtonIcon: typeof removeButtonIcon === "string" ? removeButtonIcon : void 0,
733
+ disabledOptionBehavior,
734
+ showSelectedIndicator,
735
+ toggleOnTriggerClick
736
+ },
737
+ direction,
737
738
  multiSelectDisplay,
738
- scrollToSelected,
739
- stylesConfig,
740
- coreConfig,
741
- removeButtonIcon,
742
- disabledOptionBehavior,
743
- showSelectedIndicator,
744
- toggleOnTriggerClick,
745
- infiniteScroll,
746
- pageSize,
739
+ infiniteScroll: { enabled: infiniteScroll, pageSize },
740
+ scrollToSelected: { enabled: true, ...scrollToSelected },
747
741
  creatable,
748
- clearable,
749
- clearSelectionOnClear,
750
- clearSearchOnClear,
751
- clearAriaLabel,
752
- clearIcon,
753
- trackingEnabled,
754
- trackEvents,
755
- trackStyling,
756
- trackLimitations,
757
- emitDiagnostics,
758
- trackingMaxEntries,
759
- limitationPolicies,
760
- autoMitigateRuntimeModeSwitch,
761
- direction,
762
- resolvedDropdownPlacement,
763
- error,
764
- errorMessage,
765
- required,
766
- internalValue,
767
- isControlled,
768
- areValuesEqual,
769
- applyInstanceConfig
770
- ]);
742
+ styles: stylesConfig,
743
+ clearControl: {
744
+ enabled: clearable,
745
+ clearSelection: clearSelectionOnClear,
746
+ clearSearch: clearSearchOnClear,
747
+ ariaLabel: clearAriaLabel,
748
+ icon: clearIcon
749
+ },
750
+ tracking: {
751
+ enabled: trackingEnabled,
752
+ events: trackEvents,
753
+ styling: trackStyling,
754
+ limitations: trackLimitations,
755
+ emitDiagnostics,
756
+ maxEntries: trackingMaxEntries
757
+ },
758
+ limitations: { policies: limitationPolicies, autoMitigateRuntimeModeSwitch }
759
+ };
760
+ const configCandidate = { component: componentConfig, core: coreConfig };
761
+ const appliedConfigRef = React.useRef({ hasComponent: false, component: null, hasCore: false, core: void 0 });
762
+ React.useEffect(() => {
763
+ const element = elementRef.current;
764
+ if (!element || !isElementUsable || !element.updateConfig) return;
765
+ const previous = appliedConfigRef.current;
766
+ const componentChanged = !previous.hasComponent || !areSemanticallyEqual(previous.component, configCandidate.component);
767
+ const coreChanged = !previous.hasCore || !areSemanticallyEqual(previous.core, configCandidate.core);
768
+ if (!componentChanged && !coreChanged) return;
769
+ if (componentChanged) {
770
+ applyInstanceConfig(element, configCandidate.component);
771
+ if (configCandidate.core) applyInstanceConfig(element, configCandidate.core);
772
+ } else if (coreChanged) {
773
+ if (configCandidate.core) {
774
+ applyInstanceConfig(element, configCandidate.core);
775
+ } else {
776
+ applyInstanceConfig(element, configCandidate.component);
777
+ }
778
+ }
779
+ appliedConfigRef.current = {
780
+ hasComponent: true,
781
+ component: configCandidate.component,
782
+ hasCore: true,
783
+ core: configCandidate.core
784
+ };
785
+ });
786
+ const sourceCandidate = groupedItems !== void 0 ? { kind: "grouped", data: groupedItems } : { kind: "items", data: items };
787
+ const synchronizedSourceRef = React.useRef(null);
771
788
  React.useEffect(() => {
789
+ var _a2;
772
790
  const element = elementRef.current;
773
791
  if (!element || !isElementUsable || !element.setItems) return;
774
- if (groupedItems) {
775
- element.setGroupedItems(groupedItems);
776
- } else if (items && items.length && items[0] && items[0].group !== void 0) {
777
- const map = /* @__PURE__ */ new Map();
778
- items.forEach((it) => {
779
- const g = it.group ?? "Ungrouped";
780
- if (!map.has(g)) map.set(g, []);
781
- map.get(g).push(it);
782
- });
783
- const groups = Array.from(map.entries()).map(([label, options]) => ({
784
- label,
785
- options
786
- }));
787
- element.setGroupedItems(groups);
792
+ if (areSemanticallyEqual(synchronizedSourceRef.current, sourceCandidate)) return;
793
+ if (sourceCandidate.kind === "grouped") {
794
+ element.setGroupedItems(sourceCandidate.data);
788
795
  } else {
789
- element.setItems(items);
796
+ const sourceItems = sourceCandidate.data;
797
+ if (sourceItems.length > 0 && ((_a2 = sourceItems[0]) == null ? void 0 : _a2.group) !== void 0) {
798
+ const groups = /* @__PURE__ */ new Map();
799
+ sourceItems.forEach((item) => {
800
+ const label = item.group ?? "Ungrouped";
801
+ if (!groups.has(label)) groups.set(label, []);
802
+ groups.get(label).push(item);
803
+ });
804
+ element.setGroupedItems(
805
+ Array.from(groups, ([label, options]) => ({ label, options }))
806
+ );
807
+ } else {
808
+ element.setItems(sourceItems);
809
+ }
790
810
  }
791
- }, [items, groupedItems, isElementUsable]);
811
+ synchronizedSourceRef.current = sourceCandidate;
812
+ });
813
+ React.useEffect(() => {
814
+ var _a2;
815
+ const element = elementRef.current;
816
+ if (!element || !isElementUsable || isControlled || hasAppliedInitialValueRef.current) return;
817
+ if (internalValue === void 0) return;
818
+ const values = Array.isArray(internalValue) ? internalValue : [internalValue];
819
+ const currentValues = ((_a2 = element.getSelectedValues) == null ? void 0 : _a2.call(element)) || [];
820
+ if (!areValuesEqual(values, currentValues)) element.setSelectedValues(values);
821
+ hasAppliedInitialValueRef.current = true;
822
+ }, [isElementUsable, isControlled, internalValue, areValuesEqual]);
792
823
  React.useEffect(() => {
793
824
  var _a2;
794
825
  const element = elementRef.current;
@@ -802,99 +833,6 @@ const Select = React.forwardRef((props, ref) => {
802
833
  }
803
834
  }
804
835
  }, [value, isControlled, isElementUsable, areValuesEqual]);
805
- React.useEffect(() => {
806
- const element = elementRef.current;
807
- if (!element || !isElementUsable || !element.updateConfig) return;
808
- const config = {
809
- searchable,
810
- placeholder,
811
- virtualize: virtualized,
812
- estimatedItemHeight,
813
- enabled: !disabled,
814
- dropdownPlacement: {
815
- mode: resolvedDropdownPlacement
816
- },
817
- selection: {
818
- ...selectionConfig,
819
- mode: multiple ? "multi" : "single",
820
- maxSelections,
821
- removeButtonIcon: typeof removeButtonIcon === "string" ? removeButtonIcon : void 0,
822
- disabledOptionBehavior,
823
- showSelectedIndicator,
824
- toggleOnTriggerClick
825
- },
826
- direction,
827
- multiSelectDisplay,
828
- infiniteScroll: {
829
- enabled: infiniteScroll,
830
- pageSize
831
- },
832
- scrollToSelected: {
833
- enabled: true,
834
- ...scrollToSelected
835
- },
836
- styles: stylesConfig,
837
- clearControl: {
838
- enabled: clearable,
839
- clearSelection: clearSelectionOnClear,
840
- clearSearch: clearSearchOnClear,
841
- ariaLabel: clearAriaLabel,
842
- icon: clearIcon
843
- },
844
- tracking: {
845
- enabled: trackingEnabled,
846
- events: trackEvents,
847
- styling: trackStyling,
848
- limitations: trackLimitations,
849
- emitDiagnostics,
850
- maxEntries: trackingMaxEntries
851
- },
852
- limitations: {
853
- policies: limitationPolicies,
854
- autoMitigateRuntimeModeSwitch
855
- }
856
- };
857
- applyInstanceConfig(element, config);
858
- if (coreConfig) {
859
- applyInstanceConfig(element, coreConfig);
860
- }
861
- }, [
862
- searchable,
863
- placeholder,
864
- virtualized,
865
- estimatedItemHeight,
866
- disabled,
867
- multiple,
868
- maxSelections,
869
- selectionConfig,
870
- multiSelectDisplay,
871
- scrollToSelected,
872
- stylesConfig,
873
- coreConfig,
874
- removeButtonIcon,
875
- disabledOptionBehavior,
876
- showSelectedIndicator,
877
- toggleOnTriggerClick,
878
- infiniteScroll,
879
- pageSize,
880
- clearable,
881
- clearSelectionOnClear,
882
- clearSearchOnClear,
883
- clearAriaLabel,
884
- clearIcon,
885
- trackingEnabled,
886
- trackEvents,
887
- trackStyling,
888
- trackLimitations,
889
- emitDiagnostics,
890
- trackingMaxEntries,
891
- limitationPolicies,
892
- autoMitigateRuntimeModeSwitch,
893
- direction,
894
- resolvedDropdownPlacement,
895
- isElementUsable,
896
- applyInstanceConfig
897
- ]);
898
836
  React.useEffect(() => {
899
837
  const element = elementRef.current;
900
838
  const shadow = element == null ? void 0 : element.shadowRoot;
@@ -978,11 +916,6 @@ const Select = React.forwardRef((props, ref) => {
978
916
  isElementUsable,
979
917
  acceptedProtocol,
980
918
  acknowledgedRequested,
981
- coreConfig,
982
- items,
983
- groupedItems,
984
- value,
985
- defaultValue,
986
919
  loading,
987
920
  consumerAriaBusy,
988
921
  syncHostBusy,