@smilodon/react 1.12.2 → 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -5
- package/dist/index.cjs +51 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +52 -11
- package/dist/index.js.map +1 -1
- package/dist/types/Select.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,9 +2,7 @@
|
|
|
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
|
-
> **Published package versions:** React `1.
|
|
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).
|
|
5
|
+
> **Published package versions (verified 2026-11-28):** React `1.13.0` and Core `1.21.0` are current. React Native remains unqualified for Android/iOS runtime. The next candidate is React `1.14.0` paired with Core `1.22.0`; it has not been published. See the [candidate release record](../../docs/releases/WEB-1.22.0-RELEASE.md).
|
|
8
6
|
|
|
9
7
|
> 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).
|
|
10
8
|
|
|
@@ -51,7 +49,7 @@ In focused JSX examples, `items`, `groups`, `bigItems`, and similar values are c
|
|
|
51
49
|
|
|
52
50
|
## Acknowledged data loading (Phase 2F-D development candidate)
|
|
53
51
|
|
|
54
|
-
The
|
|
52
|
+
The Core and React acknowledged-loading APIs are published in Core `1.19.0` and React `1.12.2` and later. This documents the released Core/React contract; it does not claim equivalent Vue, Svelte, Solid, Vanilla, or React Native adapter APIs, or full browser/accessibility qualification. See the [Core and React release record](../../docs/releases/WEB-1.19.0-RELEASE.md).
|
|
55
53
|
|
|
56
54
|
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.
|
|
57
55
|
|
|
@@ -205,6 +203,8 @@ The coordinator rejects stale responses by request ID and query generation; the
|
|
|
205
203
|
|
|
206
204
|
### React item synchronization and acknowledged pagination
|
|
207
205
|
|
|
206
|
+
React `1.12.2` also preserves custom option and group-header renderer roots when Core retains cumulative accepted pages across acknowledged requests and equivalent controlled rerenders. This avoids dropping custom React content when new pages or controlled selection changes update the adapter. See the [renderer lifecycle design record](../../docs/architecture/ISSUE-112-REACT-RENDERER-CACHE-LIFECYCLE.md) and [release qualification](../../docs/releases/WEB-1.19.0-RELEASE.md).
|
|
207
|
+
|
|
208
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
209
|
|
|
210
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.
|
|
@@ -271,6 +271,23 @@ In horizontal multi-select mode, `multiSelectDisplay.scrollToLatestChip` reveals
|
|
|
271
271
|
/>
|
|
272
272
|
```
|
|
273
273
|
|
|
274
|
+
### Selected-option order and open positioning
|
|
275
|
+
|
|
276
|
+
React accepts Core's `selectedOptions` and `scrollToSelected` settings in the `config` prop. Nested partial updates are supported; for example, updating only `selectedOptions.placement` preserves the other Core settings. The open dropdown keeps its current ordering snapshot until it closes and opens again. See the [projection and adapter qualification record](../../docs/architecture/SELECTED-OPTIONS-PROJECTION.md) for browser coverage and limitations.
|
|
277
|
+
|
|
278
|
+
These options are available in `@smilodon/react@1.13.0` with Core `1.20.0`. React Native is excluded from this release; its native runtime is not qualified.
|
|
279
|
+
|
|
280
|
+
```tsx
|
|
281
|
+
<Select
|
|
282
|
+
items={items}
|
|
283
|
+
value={value}
|
|
284
|
+
config={{
|
|
285
|
+
selectedOptions: { placement: 'selected-first' },
|
|
286
|
+
scrollToSelected: { onOpen: 'align', block: 'center' },
|
|
287
|
+
}}
|
|
288
|
+
/>
|
|
289
|
+
```
|
|
290
|
+
|
|
274
291
|
### Custom empty-state renderer (React 1.12.0; Issue #93)
|
|
275
292
|
|
|
276
293
|
`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()`.
|
|
@@ -1660,12 +1677,25 @@ import TrashIcon from '@/generated/icons/Trash.icon';
|
|
|
1660
1677
|
The React node is displayed inside Core's existing remove buttons in selected
|
|
1661
1678
|
chips and selected dropdown options. Remove behavior, accessibility labels, and
|
|
1662
1679
|
`chip-remove` / `chip-remove-icon` parts remain Core-owned. Strings still
|
|
1663
|
-
render as the legacy text or inline SVG markup.
|
|
1680
|
+
render as the legacy text or inline SVG markup. If the prop is omitted, Core's
|
|
1681
|
+
`configureSelect()` remove-icon default remains active; removing an instance
|
|
1682
|
+
string override restores the configured fallback. The prop supports React nodes,
|
|
1664
1683
|
**not** a component function passed directly: use `<TrashIcon />`, not
|
|
1665
1684
|
`TrashIcon`. When `config.selection.removeButtonIcon` is explicitly
|
|
1666
1685
|
supplied, that Core string configuration takes precedence. React nodes are
|
|
1667
1686
|
supported by the React adapter only, not Core or other framework adapters.
|
|
1668
1687
|
|
|
1688
|
+
For React-node icons, Core owns the button, icon target, and fallback subtree;
|
|
1689
|
+
React owns only the isolated portal root inside that target. Updating selected
|
|
1690
|
+
chips or recreating a selected dropdown option therefore cannot clear React's
|
|
1691
|
+
portal children. Switching to a string or the default icon releases the portal
|
|
1692
|
+
and restores Core's fallback. This ownership contract requires a Core build
|
|
1693
|
+
that exposes isolated React icon portal roots. Older Core builds are not a
|
|
1694
|
+
supported pairing for React-node icons: the adapter reports the missing
|
|
1695
|
+
capability and does not portal into Core-owned DOM. The release candidate pairs
|
|
1696
|
+
React `1.14.0` with Core `1.22.0` and declares `@smilodon/core: ^1.22.0`.
|
|
1697
|
+
String and markup icons remain Core-owned.
|
|
1698
|
+
|
|
1669
1699
|
To style the icon separately from the round remove button, use the host `style` prop with these tokens:
|
|
1670
1700
|
|
|
1671
1701
|
- `--select-badge-remove-icon-size`
|
package/dist/index.cjs
CHANGED
|
@@ -358,9 +358,21 @@ const Select = React.forwardRef((props, ref) => {
|
|
|
358
358
|
reactRendererCache.current.clear();
|
|
359
359
|
}, [!!optionRenderer, !!(customRenderer ?? renderItem), scheduleRootUnmount]);
|
|
360
360
|
const [isElementReady, setIsElementReady] = React.useState(false);
|
|
361
|
+
const [globalRemoveButtonIcon, setGlobalRemoveButtonIcon] = React.useState();
|
|
361
362
|
const [emptyStateContext, setEmptyStateContext] = React.useState(null);
|
|
362
363
|
const [removeIconTargets, setRemoveIconTargets] = React.useState([]);
|
|
363
|
-
const
|
|
364
|
+
const removeIconPortalKeysRef = React.useRef(/* @__PURE__ */ new WeakMap());
|
|
365
|
+
const removeIconPortalKeySequenceRef = React.useRef(0);
|
|
366
|
+
const warnedUnsupportedRemoveIconCoreRef = React.useRef(false);
|
|
367
|
+
const getRemoveIconPortalKey = (target) => {
|
|
368
|
+
let key = removeIconPortalKeysRef.current.get(target);
|
|
369
|
+
if (!key) {
|
|
370
|
+
key = `remove-icon-${removeIconPortalKeySequenceRef.current++}`;
|
|
371
|
+
removeIconPortalKeysRef.current.set(target, key);
|
|
372
|
+
}
|
|
373
|
+
return key;
|
|
374
|
+
};
|
|
375
|
+
const shouldPortalRemoveIcon = multiple && removeButtonIcon != null && typeof removeButtonIcon !== "string" && typeof removeButtonIcon !== "boolean" && (selectionConfig == null ? void 0 : selectionConfig.removeButtonIcon) === void 0 && ((_a = coreConfig == null ? void 0 : coreConfig.selection) == null ? void 0 : _a.removeButtonIcon) === void 0;
|
|
364
376
|
const acknowledgedRequested = acceptedProtocol === "acknowledged" || ((_b = coreConfig == null ? void 0 : coreConfig.dataLoading) == null ? void 0 : _b.protocol) === "acknowledged";
|
|
365
377
|
const dataLoadingConfigured = (coreConfig == null ? void 0 : coreConfig.dataLoading) !== void 0;
|
|
366
378
|
const coreFacadeRequired = acknowledgedRequested || dataLoadingConfigured;
|
|
@@ -674,6 +686,7 @@ const Select = React.forwardRef((props, ref) => {
|
|
|
674
686
|
import("@smilodon/core").then((module2) => {
|
|
675
687
|
if (!active) return;
|
|
676
688
|
coreModuleRef.current = module2;
|
|
689
|
+
setGlobalRemoveButtonIcon(module2.selectConfig.getConfig().selection.removeButtonIcon);
|
|
677
690
|
setIsCoreModuleLoaded(true);
|
|
678
691
|
const currentConstructor = customElements.get("enhanced-select");
|
|
679
692
|
if (!currentConstructor) {
|
|
@@ -729,15 +742,20 @@ const Select = React.forwardRef((props, ref) => {
|
|
|
729
742
|
...selectionConfig,
|
|
730
743
|
mode: multiple ? "multi" : "single",
|
|
731
744
|
maxSelections,
|
|
732
|
-
|
|
745
|
+
// Preserve the configured global fallback and restore it after a local
|
|
746
|
+
// string prop is removed. Core ignores undefined config entries, so
|
|
747
|
+
// forwarding undefined would leave the previous instance override in place.
|
|
748
|
+
removeButtonIcon: typeof removeButtonIcon === "string" ? removeButtonIcon : (selectionConfig == null ? void 0 : selectionConfig.removeButtonIcon) ?? globalRemoveButtonIcon,
|
|
733
749
|
disabledOptionBehavior,
|
|
734
750
|
showSelectedIndicator,
|
|
735
751
|
toggleOnTriggerClick
|
|
736
752
|
},
|
|
737
753
|
direction,
|
|
738
754
|
multiSelectDisplay,
|
|
755
|
+
...scrollToSelected !== void 0 ? {
|
|
756
|
+
scrollToSelected: { enabled: true, ...scrollToSelected }
|
|
757
|
+
} : {},
|
|
739
758
|
infiniteScroll: { enabled: infiniteScroll, pageSize },
|
|
740
|
-
scrollToSelected: { enabled: true, ...scrollToSelected },
|
|
741
759
|
creatable,
|
|
742
760
|
styles: stylesConfig,
|
|
743
761
|
clearControl: {
|
|
@@ -840,11 +858,22 @@ const Select = React.forwardRef((props, ref) => {
|
|
|
840
858
|
setRemoveIconTargets((previous) => previous.length ? [] : previous);
|
|
841
859
|
return;
|
|
842
860
|
}
|
|
861
|
+
if (element.getAttribute("data-smilodon-react-icon-portals") !== "isolated-v1") {
|
|
862
|
+
if (!warnedUnsupportedRemoveIconCoreRef.current) {
|
|
863
|
+
warnedUnsupportedRemoveIconCoreRef.current = true;
|
|
864
|
+
console.error(
|
|
865
|
+
"[Smilodon React] React-node removeButtonIcon requires a Core version that provides isolated React icon portal roots. Upgrade @smilodon/core to the compatible release; the adapter will not portal into Core-owned icon DOM."
|
|
866
|
+
);
|
|
867
|
+
}
|
|
868
|
+
setRemoveIconTargets((previous) => previous.length ? [] : previous);
|
|
869
|
+
return;
|
|
870
|
+
}
|
|
843
871
|
const observed = /* @__PURE__ */ new Set();
|
|
844
872
|
let currentTargets = [];
|
|
845
873
|
let disposed = false;
|
|
846
|
-
const observer = new MutationObserver(() => refresh
|
|
874
|
+
const observer = new MutationObserver(() => reactDom.flushSync(refresh));
|
|
847
875
|
const refresh = () => {
|
|
876
|
+
var _a2, _b2;
|
|
848
877
|
if (disposed) return;
|
|
849
878
|
const optionRoots = Array.from(shadow.querySelectorAll("select-option")).map((option) => option.shadowRoot).filter((root) => root !== null);
|
|
850
879
|
const roots = [shadow, ...optionRoots];
|
|
@@ -857,22 +886,34 @@ const Select = React.forwardRef((props, ref) => {
|
|
|
857
886
|
}
|
|
858
887
|
}
|
|
859
888
|
const targets = [
|
|
860
|
-
...Array.from(shadow.querySelectorAll(
|
|
889
|
+
...Array.from(shadow.querySelectorAll("[data-smilodon-react-icon-root]")),
|
|
861
890
|
...optionRoots.flatMap(
|
|
862
|
-
(root) => Array.from(root.querySelectorAll(
|
|
891
|
+
(root) => Array.from(root.querySelectorAll("[data-smilodon-react-icon-root]"))
|
|
863
892
|
)
|
|
864
893
|
];
|
|
865
|
-
|
|
894
|
+
const targetSet = new Set(targets);
|
|
895
|
+
for (const previous of currentTargets) {
|
|
896
|
+
if (!targetSet.has(previous) && ((_a2 = previous.parentElement) == null ? void 0 : _a2.getAttribute("data-smilodon-icon-owner")) === "react") {
|
|
897
|
+
previous.parentElement.removeAttribute("data-smilodon-icon-owner");
|
|
898
|
+
}
|
|
899
|
+
}
|
|
866
900
|
for (const target of targets) {
|
|
867
|
-
|
|
901
|
+
(_b2 = target.parentElement) == null ? void 0 : _b2.setAttribute("data-smilodon-icon-owner", "react");
|
|
868
902
|
}
|
|
903
|
+
if (targets.length === currentTargets.length && targets.every((target, index) => target === currentTargets[index])) return;
|
|
869
904
|
currentTargets = targets;
|
|
870
905
|
setRemoveIconTargets(targets);
|
|
871
906
|
};
|
|
872
907
|
refresh();
|
|
873
908
|
return () => {
|
|
909
|
+
var _a2;
|
|
874
910
|
disposed = true;
|
|
875
911
|
observer.disconnect();
|
|
912
|
+
for (const target of currentTargets) {
|
|
913
|
+
if (((_a2 = target.parentElement) == null ? void 0 : _a2.getAttribute("data-smilodon-icon-owner")) === "react") {
|
|
914
|
+
target.parentElement.removeAttribute("data-smilodon-icon-owner");
|
|
915
|
+
}
|
|
916
|
+
}
|
|
876
917
|
};
|
|
877
918
|
}, [isElementUsable, shouldPortalRemoveIcon]);
|
|
878
919
|
React.useEffect(() => {
|
|
@@ -1120,10 +1161,10 @@ const Select = React.forwardRef((props, ref) => {
|
|
|
1120
1161
|
renderedEmptyState
|
|
1121
1162
|
) : null,
|
|
1122
1163
|
shouldPortalRemoveIcon ? removeIconTargets.map(
|
|
1123
|
-
(target
|
|
1164
|
+
(target) => reactDom.createPortal(
|
|
1124
1165
|
React.createElement("span", { "aria-hidden": "true" }, removeButtonIcon),
|
|
1125
1166
|
target,
|
|
1126
|
-
|
|
1167
|
+
getRemoveIconPortalKey(target)
|
|
1127
1168
|
)
|
|
1128
1169
|
) : null
|
|
1129
1170
|
);
|