@sreedev/my3dui 0.2.1 → 0.2.3
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 +3 -1
package/dist/index.d.cts
CHANGED
|
@@ -287,7 +287,7 @@ interface Toggle3DProps {
|
|
|
287
287
|
variant?: "glass" | "neon" | "pill";
|
|
288
288
|
label?: string;
|
|
289
289
|
}
|
|
290
|
-
declare
|
|
290
|
+
declare const Toggle3D: React__default.ForwardRefExoticComponent<Toggle3DProps & React__default.RefAttributes<HTMLButtonElement>>;
|
|
291
291
|
|
|
292
292
|
interface Modal3DProps {
|
|
293
293
|
open?: boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -287,7 +287,7 @@ interface Toggle3DProps {
|
|
|
287
287
|
variant?: "glass" | "neon" | "pill";
|
|
288
288
|
label?: string;
|
|
289
289
|
}
|
|
290
|
-
declare
|
|
290
|
+
declare const Toggle3D: React__default.ForwardRefExoticComponent<Toggle3DProps & React__default.RefAttributes<HTMLButtonElement>>;
|
|
291
291
|
|
|
292
292
|
interface Modal3DProps {
|
|
293
293
|
open?: boolean;
|
package/dist/index.js
CHANGED
|
@@ -1326,59 +1326,76 @@ function Tabs3D({
|
|
|
1326
1326
|
}
|
|
1327
1327
|
|
|
1328
1328
|
// src/components/ui/toggle3d.tsx
|
|
1329
|
-
import { useState as useState7 } from "react";
|
|
1329
|
+
import { useState as useState7, forwardRef as forwardRef2 } from "react";
|
|
1330
1330
|
import { motion as motion8 } from "framer-motion";
|
|
1331
1331
|
import { jsx as jsx20, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1332
|
+
var Toggle3D = forwardRef2(
|
|
1333
|
+
({
|
|
1334
|
+
checked: controlledChecked,
|
|
1335
|
+
defaultChecked = false,
|
|
1336
|
+
onChange,
|
|
1337
|
+
disabled = false,
|
|
1338
|
+
variant = "pill",
|
|
1339
|
+
label
|
|
1340
|
+
}, ref) => {
|
|
1341
|
+
const [internalChecked, setInternalChecked] = useState7(defaultChecked);
|
|
1342
|
+
const isControlled = controlledChecked !== void 0;
|
|
1343
|
+
const isChecked = isControlled ? controlledChecked : internalChecked;
|
|
1344
|
+
const handleToggle = () => {
|
|
1345
|
+
if (disabled) return;
|
|
1346
|
+
const newChecked = !isChecked;
|
|
1347
|
+
if (!isControlled) {
|
|
1348
|
+
setInternalChecked(newChecked);
|
|
1349
|
+
}
|
|
1350
|
+
onChange?.(newChecked);
|
|
1351
|
+
};
|
|
1352
|
+
const getVariantStyles = () => {
|
|
1353
|
+
switch (variant) {
|
|
1354
|
+
case "neon":
|
|
1355
|
+
return isChecked ? "bg-black border border-cyan-400 shadow-[0_0_15px_rgba(34,211,238,0.4)]" : "bg-black border border-slate-700";
|
|
1356
|
+
case "glass":
|
|
1357
|
+
return "bg-white/20 backdrop-blur-md border border-white/30";
|
|
1358
|
+
case "pill":
|
|
1359
|
+
default:
|
|
1360
|
+
return isChecked ? "bg-primary" : "bg-muted";
|
|
1361
|
+
}
|
|
1362
|
+
};
|
|
1363
|
+
const toggleWidth = 56;
|
|
1364
|
+
const knobSize = 24;
|
|
1365
|
+
const padding = 4;
|
|
1366
|
+
const travel = toggleWidth - knobSize - padding * 2;
|
|
1367
|
+
return /* @__PURE__ */ jsxs10("div", { className: "flex items-center gap-3", children: [
|
|
1368
|
+
/* @__PURE__ */ jsx20(
|
|
1369
|
+
"button",
|
|
1370
|
+
{
|
|
1371
|
+
ref,
|
|
1372
|
+
type: "button",
|
|
1373
|
+
role: "switch",
|
|
1374
|
+
"aria-checked": isChecked,
|
|
1375
|
+
"aria-disabled": disabled,
|
|
1376
|
+
disabled,
|
|
1377
|
+
onClick: handleToggle,
|
|
1378
|
+
onKeyDown: (e) => {
|
|
1379
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
1380
|
+
e.preventDefault();
|
|
1381
|
+
handleToggle();
|
|
1382
|
+
}
|
|
1383
|
+
},
|
|
1384
|
+
className: cn(
|
|
1385
|
+
"relative h-8 w-14 rounded-full transition-colors",
|
|
1386
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
1387
|
+
disabled && "opacity-50 cursor-not-allowed",
|
|
1388
|
+
getVariantStyles()
|
|
1389
|
+
),
|
|
1390
|
+
children: /* @__PURE__ */ jsx20(
|
|
1374
1391
|
motion8.div,
|
|
1375
1392
|
{
|
|
1376
1393
|
className: cn(
|
|
1377
|
-
"absolute top-1 left-1 h-6 w-6 rounded-full shadow-md
|
|
1394
|
+
"absolute top-1 left-1 h-6 w-6 rounded-full shadow-md",
|
|
1378
1395
|
variant === "neon" && isChecked ? "bg-cyan-400 shadow-[0_0_10px_#22d3ee]" : "bg-white"
|
|
1379
1396
|
),
|
|
1380
1397
|
animate: {
|
|
1381
|
-
x: isChecked ?
|
|
1398
|
+
x: isChecked ? travel : 0,
|
|
1382
1399
|
scale: disabled ? 0.9 : 1
|
|
1383
1400
|
},
|
|
1384
1401
|
transition: {
|
|
@@ -1387,22 +1404,14 @@ function Toggle3D({
|
|
|
1387
1404
|
damping: 30
|
|
1388
1405
|
}
|
|
1389
1406
|
}
|
|
1390
|
-
),
|
|
1391
|
-
variant !== "neon" && /* @__PURE__ */ jsx20(
|
|
1392
|
-
"div",
|
|
1393
|
-
{
|
|
1394
|
-
className: cn(
|
|
1395
|
-
"absolute inset-0 rounded-full border-b-[3px] border-black/5 pointer-events-none",
|
|
1396
|
-
isChecked ? "border-black/10" : "border-black/5"
|
|
1397
|
-
)
|
|
1398
|
-
}
|
|
1399
1407
|
)
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1408
|
+
}
|
|
1409
|
+
),
|
|
1410
|
+
label && /* @__PURE__ */ jsx20("span", { className: "text-sm font-medium", children: label })
|
|
1411
|
+
] });
|
|
1412
|
+
}
|
|
1413
|
+
);
|
|
1414
|
+
Toggle3D.displayName = "Toggle3D";
|
|
1406
1415
|
|
|
1407
1416
|
// src/components/ui/modal3d.tsx
|
|
1408
1417
|
import * as DialogPrimitive from "@radix-ui/react-dialog";
|