@idds/react 1.5.14 → 1.5.18
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/dist/index.cjs.js +1 -1
- package/dist/index.css +1 -1
- package/dist/index.es.js +6 -8
- package/dist/index.umd.js +1 -1
- package/dist/types/components/Accordion.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.es.js
CHANGED
|
@@ -669,21 +669,19 @@ function Accordion(props) {
|
|
|
669
669
|
const [itemIndex, setItemIndex] = useState(-1);
|
|
670
670
|
const defaultOpenRef = useRef(defaultOpen);
|
|
671
671
|
defaultOpenRef.current = defaultOpen;
|
|
672
|
+
const { registerItem, unregisterItem } = accordionGroup || {};
|
|
672
673
|
useEffect(() => {
|
|
673
|
-
if (
|
|
674
|
-
const index =
|
|
675
|
-
itemIdRef.current,
|
|
676
|
-
defaultOpenRef.current
|
|
677
|
-
);
|
|
674
|
+
if (registerItem) {
|
|
675
|
+
const index = registerItem(itemIdRef.current, defaultOpenRef.current);
|
|
678
676
|
setItemIndex(index);
|
|
679
677
|
}
|
|
680
678
|
return () => {
|
|
681
|
-
if (
|
|
682
|
-
|
|
679
|
+
if (unregisterItem) {
|
|
680
|
+
unregisterItem(itemIdRef.current);
|
|
683
681
|
setItemIndex(-1);
|
|
684
682
|
}
|
|
685
683
|
};
|
|
686
|
-
}, [
|
|
684
|
+
}, [registerItem, unregisterItem]);
|
|
687
685
|
const isInGroup = accordionGroup !== null;
|
|
688
686
|
const isControlled = open !== void 0 || isInGroup;
|
|
689
687
|
const isOpen = useMemo(() => {
|