@idds/react 1.4.3 → 1.4.4
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.es.js
CHANGED
|
@@ -535,7 +535,9 @@ function clsx() {
|
|
|
535
535
|
for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
|
|
536
536
|
return n;
|
|
537
537
|
}
|
|
538
|
-
const AccordionGroupContext = createContext(
|
|
538
|
+
const AccordionGroupContext = createContext(
|
|
539
|
+
null
|
|
540
|
+
);
|
|
539
541
|
function useAccordionGroup() {
|
|
540
542
|
const context = useContext(AccordionGroupContext);
|
|
541
543
|
return context;
|
|
@@ -557,19 +559,29 @@ function AccordionGroup(props) {
|
|
|
557
559
|
const [version, setVersion] = useState(0);
|
|
558
560
|
const openIndexesRef = useRef(openIndexes);
|
|
559
561
|
openIndexesRef.current = openIndexes;
|
|
560
|
-
const registerItem = useCallback(
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
562
|
+
const registerItem = useCallback(
|
|
563
|
+
(itemId, defaultOpen) => {
|
|
564
|
+
const index = itemsRef.current.size;
|
|
565
|
+
itemsRef.current.set(itemId, index);
|
|
566
|
+
if (defaultOpen) {
|
|
567
|
+
setOpenIndexes((prev) => {
|
|
568
|
+
if (allowMultiple) {
|
|
569
|
+
if (!prev.includes(index)) {
|
|
570
|
+
return [...prev, index];
|
|
571
|
+
}
|
|
572
|
+
return prev;
|
|
573
|
+
} else {
|
|
574
|
+
if (prev.length === 0) {
|
|
575
|
+
return [index];
|
|
576
|
+
}
|
|
577
|
+
return prev;
|
|
578
|
+
}
|
|
579
|
+
});
|
|
580
|
+
}
|
|
581
|
+
return index;
|
|
582
|
+
},
|
|
583
|
+
[allowMultiple]
|
|
584
|
+
);
|
|
573
585
|
const unregisterItem = useCallback((itemId) => {
|
|
574
586
|
const index = itemsRef.current.get(itemId);
|
|
575
587
|
if (index !== void 0) {
|
|
@@ -629,7 +641,14 @@ function AccordionGroup(props) {
|
|
|
629
641
|
version
|
|
630
642
|
// Include version untuk trigger re-render
|
|
631
643
|
}),
|
|
632
|
-
[
|
|
644
|
+
[
|
|
645
|
+
allowMultiple,
|
|
646
|
+
registerItem,
|
|
647
|
+
unregisterItem,
|
|
648
|
+
handleItemToggle,
|
|
649
|
+
isItemOpen,
|
|
650
|
+
version
|
|
651
|
+
]
|
|
633
652
|
);
|
|
634
653
|
return /* @__PURE__ */ jsx(AccordionGroupContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx("div", { className: clsx("ina-accordion-group", className), children }) });
|
|
635
654
|
}
|