@idds/react 1.5.11 → 1.5.14
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
|
@@ -10470,69 +10470,26 @@ function Toggle({
|
|
|
10470
10470
|
"aria-describedby": ariaDescribedBy,
|
|
10471
10471
|
id,
|
|
10472
10472
|
name,
|
|
10473
|
-
value
|
|
10473
|
+
value,
|
|
10474
|
+
color,
|
|
10475
|
+
...rest
|
|
10474
10476
|
}) {
|
|
10475
10477
|
const isControlled = controlledChecked !== void 0;
|
|
10476
10478
|
const [internalChecked, setInternalChecked] = useState(defaultChecked);
|
|
10477
10479
|
const checked = isControlled ? controlledChecked : internalChecked;
|
|
10478
10480
|
const handleChange = useCallback(
|
|
10479
10481
|
(event) => {
|
|
10480
|
-
console.log("handleChange called", {
|
|
10481
|
-
disabled,
|
|
10482
|
-
checked: event.target.checked,
|
|
10483
|
-
isControlled
|
|
10484
|
-
});
|
|
10485
10482
|
if (disabled) return;
|
|
10486
10483
|
const newChecked = event.target.checked;
|
|
10487
10484
|
if (!isControlled) {
|
|
10488
10485
|
setInternalChecked(newChecked);
|
|
10489
10486
|
}
|
|
10490
10487
|
if (onChange) {
|
|
10491
|
-
console.log("Calling onChange from handleChange with", newChecked);
|
|
10492
10488
|
onChange(newChecked);
|
|
10493
10489
|
}
|
|
10494
10490
|
},
|
|
10495
10491
|
[disabled, onChange, isControlled]
|
|
10496
10492
|
);
|
|
10497
|
-
const handleKeyDown = useCallback(
|
|
10498
|
-
(event) => {
|
|
10499
|
-
if (disabled) return;
|
|
10500
|
-
if (event.key === "Enter" || event.key === " ") {
|
|
10501
|
-
event.preventDefault();
|
|
10502
|
-
const newChecked = !checked;
|
|
10503
|
-
if (!isControlled) {
|
|
10504
|
-
setInternalChecked(newChecked);
|
|
10505
|
-
}
|
|
10506
|
-
if (onChange) {
|
|
10507
|
-
onChange(newChecked);
|
|
10508
|
-
}
|
|
10509
|
-
}
|
|
10510
|
-
},
|
|
10511
|
-
[disabled, checked, onChange, isControlled]
|
|
10512
|
-
);
|
|
10513
|
-
const handleClick = useCallback(
|
|
10514
|
-
(event) => {
|
|
10515
|
-
console.log("handleClick called", { disabled, checked, isControlled });
|
|
10516
|
-
if (disabled) return;
|
|
10517
|
-
if (event.target.tagName === "INPUT") {
|
|
10518
|
-
return;
|
|
10519
|
-
}
|
|
10520
|
-
event.preventDefault();
|
|
10521
|
-
event.stopPropagation();
|
|
10522
|
-
const newChecked = !checked;
|
|
10523
|
-
console.log("Toggle changing from", checked, "to", newChecked);
|
|
10524
|
-
if (!isControlled) {
|
|
10525
|
-
setInternalChecked(newChecked);
|
|
10526
|
-
}
|
|
10527
|
-
if (onChange) {
|
|
10528
|
-
console.log("Calling onChange with", newChecked);
|
|
10529
|
-
onChange(newChecked);
|
|
10530
|
-
} else {
|
|
10531
|
-
console.log("onChange is not provided");
|
|
10532
|
-
}
|
|
10533
|
-
},
|
|
10534
|
-
[disabled, checked, onChange, isControlled]
|
|
10535
|
-
);
|
|
10536
10493
|
const toggleClasses = clsx(
|
|
10537
10494
|
"ina-toggle",
|
|
10538
10495
|
`ina-toggle--size-${size}`,
|
|
@@ -10558,38 +10515,33 @@ function Toggle({
|
|
|
10558
10515
|
"ina-toggle__thumb--disabled": disabled
|
|
10559
10516
|
}
|
|
10560
10517
|
);
|
|
10561
|
-
|
|
10562
|
-
|
|
10563
|
-
|
|
10564
|
-
|
|
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
|
-
/* @__PURE__ */ jsx("div", { className: trackClasses, style: { pointerEvents: "none" }, children: /* @__PURE__ */ jsx("div", { className: thumbClasses }) })
|
|
10590
|
-
]
|
|
10591
|
-
}
|
|
10592
|
-
);
|
|
10518
|
+
const trackStyle = checked && color && !disabled ? { backgroundColor: color, borderColor: color } : {};
|
|
10519
|
+
return /* @__PURE__ */ jsxs("div", { className: toggleClasses, children: [
|
|
10520
|
+
/* @__PURE__ */ jsx(
|
|
10521
|
+
"input",
|
|
10522
|
+
{
|
|
10523
|
+
...rest,
|
|
10524
|
+
type: "checkbox",
|
|
10525
|
+
id,
|
|
10526
|
+
name,
|
|
10527
|
+
value,
|
|
10528
|
+
checked,
|
|
10529
|
+
disabled,
|
|
10530
|
+
onChange: handleChange,
|
|
10531
|
+
"aria-label": ariaLabel,
|
|
10532
|
+
"aria-describedby": ariaDescribedBy,
|
|
10533
|
+
className: "ina-toggle__input"
|
|
10534
|
+
}
|
|
10535
|
+
),
|
|
10536
|
+
/* @__PURE__ */ jsx(
|
|
10537
|
+
"div",
|
|
10538
|
+
{
|
|
10539
|
+
className: trackClasses,
|
|
10540
|
+
style: { pointerEvents: "none", ...trackStyle },
|
|
10541
|
+
children: /* @__PURE__ */ jsx("div", { className: thumbClasses })
|
|
10542
|
+
}
|
|
10543
|
+
)
|
|
10544
|
+
] });
|
|
10593
10545
|
}
|
|
10594
10546
|
function TabHorizontal({
|
|
10595
10547
|
items,
|