@sreedev/my3dui 0.2.1 → 0.2.2
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 +68 -59
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +69 -60
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1657,56 +1657,73 @@ function Tabs3D({
|
|
|
1657
1657
|
var import_react18 = require("react");
|
|
1658
1658
|
var import_framer_motion8 = require("framer-motion");
|
|
1659
1659
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1660
|
+
var Toggle3D = (0, import_react18.forwardRef)(
|
|
1661
|
+
({
|
|
1662
|
+
checked: controlledChecked,
|
|
1663
|
+
defaultChecked = false,
|
|
1664
|
+
onChange,
|
|
1665
|
+
disabled = false,
|
|
1666
|
+
variant = "pill",
|
|
1667
|
+
label
|
|
1668
|
+
}, ref) => {
|
|
1669
|
+
const [internalChecked, setInternalChecked] = (0, import_react18.useState)(defaultChecked);
|
|
1670
|
+
const isControlled = controlledChecked !== void 0;
|
|
1671
|
+
const isChecked = isControlled ? controlledChecked : internalChecked;
|
|
1672
|
+
const handleToggle = () => {
|
|
1673
|
+
if (disabled) return;
|
|
1674
|
+
const newChecked = !isChecked;
|
|
1675
|
+
if (!isControlled) {
|
|
1676
|
+
setInternalChecked(newChecked);
|
|
1677
|
+
}
|
|
1678
|
+
onChange?.(newChecked);
|
|
1679
|
+
};
|
|
1680
|
+
const getVariantStyles = () => {
|
|
1681
|
+
switch (variant) {
|
|
1682
|
+
case "neon":
|
|
1683
|
+
return isChecked ? "bg-black border border-cyan-400 shadow-[0_0_15px_rgba(34,211,238,0.4)]" : "bg-black border border-slate-700";
|
|
1684
|
+
case "glass":
|
|
1685
|
+
return "bg-white/20 backdrop-blur-md border border-white/30";
|
|
1686
|
+
case "pill":
|
|
1687
|
+
default:
|
|
1688
|
+
return isChecked ? "bg-primary" : "bg-muted";
|
|
1689
|
+
}
|
|
1690
|
+
};
|
|
1691
|
+
const toggleWidth = 56;
|
|
1692
|
+
const knobSize = 24;
|
|
1693
|
+
const padding = 4;
|
|
1694
|
+
const travel = toggleWidth - knobSize - padding * 2;
|
|
1695
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex items-center gap-3", children: [
|
|
1696
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1697
|
+
"button",
|
|
1698
|
+
{
|
|
1699
|
+
ref,
|
|
1700
|
+
type: "button",
|
|
1701
|
+
role: "switch",
|
|
1702
|
+
"aria-checked": isChecked,
|
|
1703
|
+
"aria-disabled": disabled,
|
|
1704
|
+
disabled,
|
|
1705
|
+
onClick: handleToggle,
|
|
1706
|
+
onKeyDown: (e) => {
|
|
1707
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
1708
|
+
e.preventDefault();
|
|
1709
|
+
handleToggle();
|
|
1710
|
+
}
|
|
1711
|
+
},
|
|
1712
|
+
className: cn(
|
|
1713
|
+
"relative h-8 w-14 rounded-full transition-colors",
|
|
1714
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
1715
|
+
disabled && "opacity-50 cursor-not-allowed",
|
|
1716
|
+
getVariantStyles()
|
|
1717
|
+
),
|
|
1718
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1702
1719
|
import_framer_motion8.motion.div,
|
|
1703
1720
|
{
|
|
1704
1721
|
className: cn(
|
|
1705
|
-
"absolute top-1 left-1 h-6 w-6 rounded-full shadow-md
|
|
1722
|
+
"absolute top-1 left-1 h-6 w-6 rounded-full shadow-md",
|
|
1706
1723
|
variant === "neon" && isChecked ? "bg-cyan-400 shadow-[0_0_10px_#22d3ee]" : "bg-white"
|
|
1707
1724
|
),
|
|
1708
1725
|
animate: {
|
|
1709
|
-
x: isChecked ?
|
|
1726
|
+
x: isChecked ? travel : 0,
|
|
1710
1727
|
scale: disabled ? 0.9 : 1
|
|
1711
1728
|
},
|
|
1712
1729
|
transition: {
|
|
@@ -1715,22 +1732,14 @@ function Toggle3D({
|
|
|
1715
1732
|
damping: 30
|
|
1716
1733
|
}
|
|
1717
1734
|
}
|
|
1718
|
-
),
|
|
1719
|
-
variant !== "neon" && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1720
|
-
"div",
|
|
1721
|
-
{
|
|
1722
|
-
className: cn(
|
|
1723
|
-
"absolute inset-0 rounded-full border-b-[3px] border-black/5 pointer-events-none",
|
|
1724
|
-
isChecked ? "border-black/10" : "border-black/5"
|
|
1725
|
-
)
|
|
1726
|
-
}
|
|
1727
1735
|
)
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1736
|
+
}
|
|
1737
|
+
),
|
|
1738
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "text-sm font-medium", children: label })
|
|
1739
|
+
] });
|
|
1740
|
+
}
|
|
1741
|
+
);
|
|
1742
|
+
Toggle3D.displayName = "Toggle3D";
|
|
1734
1743
|
|
|
1735
1744
|
// src/components/ui/modal3d.tsx
|
|
1736
1745
|
var DialogPrimitive = __toESM(require("@radix-ui/react-dialog"), 1);
|