@idds/react 1.5.12 → 1.5.15
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
|
@@ -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(() => {
|
|
@@ -10479,62 +10477,17 @@ function Toggle({
|
|
|
10479
10477
|
const checked = isControlled ? controlledChecked : internalChecked;
|
|
10480
10478
|
const handleChange = useCallback(
|
|
10481
10479
|
(event) => {
|
|
10482
|
-
console.log("handleChange called", {
|
|
10483
|
-
disabled,
|
|
10484
|
-
checked: event.target.checked,
|
|
10485
|
-
isControlled
|
|
10486
|
-
});
|
|
10487
10480
|
if (disabled) return;
|
|
10488
10481
|
const newChecked = event.target.checked;
|
|
10489
10482
|
if (!isControlled) {
|
|
10490
10483
|
setInternalChecked(newChecked);
|
|
10491
10484
|
}
|
|
10492
10485
|
if (onChange) {
|
|
10493
|
-
console.log("Calling onChange from handleChange with", newChecked);
|
|
10494
10486
|
onChange(newChecked);
|
|
10495
10487
|
}
|
|
10496
10488
|
},
|
|
10497
10489
|
[disabled, onChange, isControlled]
|
|
10498
10490
|
);
|
|
10499
|
-
const handleKeyDown = useCallback(
|
|
10500
|
-
(event) => {
|
|
10501
|
-
if (disabled) return;
|
|
10502
|
-
if (event.key === "Enter" || event.key === " ") {
|
|
10503
|
-
event.preventDefault();
|
|
10504
|
-
const newChecked = !checked;
|
|
10505
|
-
if (!isControlled) {
|
|
10506
|
-
setInternalChecked(newChecked);
|
|
10507
|
-
}
|
|
10508
|
-
if (onChange) {
|
|
10509
|
-
onChange(newChecked);
|
|
10510
|
-
}
|
|
10511
|
-
}
|
|
10512
|
-
},
|
|
10513
|
-
[disabled, checked, onChange, isControlled]
|
|
10514
|
-
);
|
|
10515
|
-
const handleClick = useCallback(
|
|
10516
|
-
(event) => {
|
|
10517
|
-
console.log("handleClick called", { disabled, checked, isControlled });
|
|
10518
|
-
if (disabled) return;
|
|
10519
|
-
if (event.target.tagName === "INPUT") {
|
|
10520
|
-
return;
|
|
10521
|
-
}
|
|
10522
|
-
event.preventDefault();
|
|
10523
|
-
event.stopPropagation();
|
|
10524
|
-
const newChecked = !checked;
|
|
10525
|
-
console.log("Toggle changing from", checked, "to", newChecked);
|
|
10526
|
-
if (!isControlled) {
|
|
10527
|
-
setInternalChecked(newChecked);
|
|
10528
|
-
}
|
|
10529
|
-
if (onChange) {
|
|
10530
|
-
console.log("Calling onChange with", newChecked);
|
|
10531
|
-
onChange(newChecked);
|
|
10532
|
-
} else {
|
|
10533
|
-
console.log("onChange is not provided");
|
|
10534
|
-
}
|
|
10535
|
-
},
|
|
10536
|
-
[disabled, checked, onChange, isControlled]
|
|
10537
|
-
);
|
|
10538
10491
|
const toggleClasses = clsx(
|
|
10539
10492
|
"ina-toggle",
|
|
10540
10493
|
`ina-toggle--size-${size}`,
|
|
@@ -10561,46 +10514,32 @@ function Toggle({
|
|
|
10561
10514
|
}
|
|
10562
10515
|
);
|
|
10563
10516
|
const trackStyle = checked && color && !disabled ? { backgroundColor: color, borderColor: color } : {};
|
|
10564
|
-
return /* @__PURE__ */ jsxs(
|
|
10565
|
-
|
|
10566
|
-
|
|
10567
|
-
|
|
10568
|
-
|
|
10569
|
-
|
|
10570
|
-
|
|
10571
|
-
|
|
10572
|
-
|
|
10573
|
-
|
|
10574
|
-
|
|
10575
|
-
|
|
10576
|
-
|
|
10577
|
-
|
|
10578
|
-
|
|
10579
|
-
|
|
10580
|
-
|
|
10581
|
-
|
|
10582
|
-
|
|
10583
|
-
|
|
10584
|
-
|
|
10585
|
-
|
|
10586
|
-
|
|
10587
|
-
|
|
10588
|
-
|
|
10589
|
-
|
|
10590
|
-
readOnly: true
|
|
10591
|
-
}
|
|
10592
|
-
),
|
|
10593
|
-
/* @__PURE__ */ jsx(
|
|
10594
|
-
"div",
|
|
10595
|
-
{
|
|
10596
|
-
className: trackClasses,
|
|
10597
|
-
style: { pointerEvents: "none", ...trackStyle },
|
|
10598
|
-
children: /* @__PURE__ */ jsx("div", { className: thumbClasses })
|
|
10599
|
-
}
|
|
10600
|
-
)
|
|
10601
|
-
]
|
|
10602
|
-
}
|
|
10603
|
-
);
|
|
10517
|
+
return /* @__PURE__ */ jsxs("div", { className: toggleClasses, children: [
|
|
10518
|
+
/* @__PURE__ */ jsx(
|
|
10519
|
+
"input",
|
|
10520
|
+
{
|
|
10521
|
+
...rest,
|
|
10522
|
+
type: "checkbox",
|
|
10523
|
+
id,
|
|
10524
|
+
name,
|
|
10525
|
+
value,
|
|
10526
|
+
checked,
|
|
10527
|
+
disabled,
|
|
10528
|
+
onChange: handleChange,
|
|
10529
|
+
"aria-label": ariaLabel,
|
|
10530
|
+
"aria-describedby": ariaDescribedBy,
|
|
10531
|
+
className: "ina-toggle__input"
|
|
10532
|
+
}
|
|
10533
|
+
),
|
|
10534
|
+
/* @__PURE__ */ jsx(
|
|
10535
|
+
"div",
|
|
10536
|
+
{
|
|
10537
|
+
className: trackClasses,
|
|
10538
|
+
style: { pointerEvents: "none", ...trackStyle },
|
|
10539
|
+
children: /* @__PURE__ */ jsx("div", { className: thumbClasses })
|
|
10540
|
+
}
|
|
10541
|
+
)
|
|
10542
|
+
] });
|
|
10604
10543
|
}
|
|
10605
10544
|
function TabHorizontal({
|
|
10606
10545
|
items,
|