@lindle/linoardo 1.0.17 → 1.0.19
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/button.cjs +10 -2
- package/dist/button.cjs.map +1 -1
- package/dist/button.d.cts +1 -0
- package/dist/button.d.ts +1 -0
- package/dist/button.js +1 -1
- package/dist/card.cjs +87 -0
- package/dist/card.cjs.map +1 -0
- package/dist/card.d.cts +34 -0
- package/dist/card.d.ts +34 -0
- package/dist/card.js +3 -0
- package/dist/card.js.map +1 -0
- package/dist/chunk-AOHXZ7OM.js +126 -0
- package/dist/chunk-AOHXZ7OM.js.map +1 -0
- package/dist/chunk-N65GNKRG.js +143 -0
- package/dist/chunk-N65GNKRG.js.map +1 -0
- package/dist/{chunk-TTDFAKOL.js → chunk-PYG5SDNO.js} +2 -2
- package/dist/{chunk-TTDFAKOL.js.map → chunk-PYG5SDNO.js.map} +1 -1
- package/dist/{chunk-3EGIRBQ3.js → chunk-QGQ66FJD.js} +69 -14
- package/dist/chunk-QGQ66FJD.js.map +1 -0
- package/dist/{chunk-7LLAWEDF.js → chunk-SZU6OYLS.js} +12 -4
- package/dist/chunk-SZU6OYLS.js.map +1 -0
- package/dist/chunk-V4BVJOSC.js +85 -0
- package/dist/chunk-V4BVJOSC.js.map +1 -0
- package/dist/index.cjs +409 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +6 -3
- package/dist/input.cjs.map +1 -1
- package/dist/input.js +1 -1
- package/dist/menu.cjs +67 -12
- package/dist/menu.cjs.map +1 -1
- package/dist/menu.js +1 -1
- package/dist/slider.cjs +128 -0
- package/dist/slider.cjs.map +1 -0
- package/dist/slider.d.cts +42 -0
- package/dist/slider.d.ts +42 -0
- package/dist/slider.js +3 -0
- package/dist/slider.js.map +1 -0
- package/dist/styles.css +349 -38
- package/dist/switch.cjs +145 -0
- package/dist/switch.cjs.map +1 -0
- package/dist/switch.d.cts +16 -0
- package/dist/switch.d.ts +16 -0
- package/dist/switch.js +3 -0
- package/dist/switch.js.map +1 -0
- package/package.json +17 -4
- package/dist/chunk-3EGIRBQ3.js.map +0 -1
- package/dist/chunk-7LLAWEDF.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -151,6 +151,13 @@ var sizeClasses = {
|
|
|
151
151
|
large: "px-6 py-3 text-lg",
|
|
152
152
|
"x-large": "px-7 py-3.5 text-xl"
|
|
153
153
|
};
|
|
154
|
+
var iconOnlySizeClasses = {
|
|
155
|
+
"x-small": "p-2 text-xs aspect-square",
|
|
156
|
+
small: "p-2.5 text-sm aspect-square",
|
|
157
|
+
medium: "p-3 text-base aspect-square",
|
|
158
|
+
large: "p-3.5 text-lg aspect-square",
|
|
159
|
+
"x-large": "p-4 text-xl aspect-square"
|
|
160
|
+
};
|
|
154
161
|
var Button = React3__namespace.forwardRef(
|
|
155
162
|
({
|
|
156
163
|
variant = "solid",
|
|
@@ -160,6 +167,7 @@ var Button = React3__namespace.forwardRef(
|
|
|
160
167
|
loading = false,
|
|
161
168
|
loadingText,
|
|
162
169
|
icon,
|
|
170
|
+
iconOnly = false,
|
|
163
171
|
className,
|
|
164
172
|
children,
|
|
165
173
|
disabled,
|
|
@@ -167,14 +175,14 @@ var Button = React3__namespace.forwardRef(
|
|
|
167
175
|
...rest
|
|
168
176
|
}, ref) => {
|
|
169
177
|
const variantClass = resolveVariantClass(variant, color);
|
|
170
|
-
const sizeClass = sizeClasses[size] ?? sizeClasses.medium;
|
|
178
|
+
const sizeClass = iconOnly ? iconOnlySizeClasses[size] ?? iconOnlySizeClasses.medium : sizeClasses[size] ?? sizeClasses.medium;
|
|
171
179
|
const blockClass = block ? "w-full" : null;
|
|
172
180
|
const isDisabled = disabled || loading;
|
|
173
181
|
const cursor = onClick && !isDisabled ? "cursor-pointer" : "cursor-default";
|
|
174
182
|
const resolvedIconClass = resolveIconClassName(icon);
|
|
175
183
|
const shouldRenderIcon = Boolean(resolvedIconClass && !loading);
|
|
176
184
|
const isLoadingTextProvided = loadingText !== void 0 && loadingText !== null;
|
|
177
|
-
const content = loading && isLoadingTextProvided ? loadingText : children;
|
|
185
|
+
const content = iconOnly ? null : loading && isLoadingTextProvided ? loadingText : children;
|
|
178
186
|
const hasDecorators = (loading || shouldRenderIcon) && Boolean(content);
|
|
179
187
|
const gapClass = hasDecorators ? "gap-2" : void 0;
|
|
180
188
|
const loadingIconClass = loading ? tailwindMerge.twMerge("mdi mdi-loading mdi-spin", "leading-none") : void 0;
|
|
@@ -663,20 +671,39 @@ var Menu = React3__namespace.forwardRef((props, ref) => {
|
|
|
663
671
|
className,
|
|
664
672
|
...rest
|
|
665
673
|
} = props;
|
|
674
|
+
const { onMouseEnter, onMouseLeave, onFocus, onBlur, ...restProps } = rest;
|
|
666
675
|
const hasContent = children !== void 0 && children !== null;
|
|
667
|
-
const
|
|
668
|
-
const
|
|
669
|
-
const
|
|
676
|
+
const isControlled = typeof open === "boolean";
|
|
677
|
+
const [uncontrolledOpen, setUncontrolledOpen] = React3__namespace.useState(false);
|
|
678
|
+
const closeTimer = React3__namespace.useRef(null);
|
|
679
|
+
const visible = isControlled ? Boolean(open) : uncontrolledOpen;
|
|
680
|
+
const shouldRenderContent = hasContent && (keepMounted || visible || !isControlled && (openOnHover || openOnFocus));
|
|
670
681
|
const verticalPlacement = placement.startsWith("top") ? "top" : "bottom";
|
|
671
|
-
const
|
|
672
|
-
if (
|
|
673
|
-
|
|
682
|
+
const clearCloseTimer = () => {
|
|
683
|
+
if (closeTimer.current !== null) {
|
|
684
|
+
window.clearTimeout(closeTimer.current);
|
|
685
|
+
closeTimer.current = null;
|
|
674
686
|
}
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
687
|
+
};
|
|
688
|
+
const openMenu = () => {
|
|
689
|
+
clearCloseTimer();
|
|
690
|
+
if (!isControlled) {
|
|
691
|
+
setUncontrolledOpen(true);
|
|
692
|
+
}
|
|
693
|
+
};
|
|
694
|
+
const scheduleClose = () => {
|
|
695
|
+
clearCloseTimer();
|
|
696
|
+
if (!isControlled) {
|
|
697
|
+
closeTimer.current = window.setTimeout(() => {
|
|
698
|
+
setUncontrolledOpen(false);
|
|
699
|
+
closeTimer.current = null;
|
|
700
|
+
}, 120);
|
|
701
|
+
}
|
|
702
|
+
};
|
|
703
|
+
React3__namespace.useEffect(() => {
|
|
704
|
+
return () => clearCloseTimer();
|
|
705
|
+
}, []);
|
|
706
|
+
const visibilityClasses = visible ? "pointer-events-auto opacity-100 scale-100" : "pointer-events-none opacity-0 scale-95";
|
|
680
707
|
const {
|
|
681
708
|
className: contentExtraClassName,
|
|
682
709
|
style: contentStyle,
|
|
@@ -690,10 +717,34 @@ var Menu = React3__namespace.forwardRef((props, ref) => {
|
|
|
690
717
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
691
718
|
"div",
|
|
692
719
|
{
|
|
693
|
-
...
|
|
720
|
+
...restProps,
|
|
694
721
|
ref,
|
|
695
722
|
className: tailwindMerge.twMerge("relative inline-flex min-w-0 group/menu", className),
|
|
696
723
|
"data-open": visible || void 0,
|
|
724
|
+
onMouseEnter: (event) => {
|
|
725
|
+
if (openOnHover) {
|
|
726
|
+
openMenu();
|
|
727
|
+
}
|
|
728
|
+
onMouseEnter?.(event);
|
|
729
|
+
},
|
|
730
|
+
onMouseLeave: (event) => {
|
|
731
|
+
if (openOnHover) {
|
|
732
|
+
scheduleClose();
|
|
733
|
+
}
|
|
734
|
+
onMouseLeave?.(event);
|
|
735
|
+
},
|
|
736
|
+
onFocus: (event) => {
|
|
737
|
+
if (openOnFocus) {
|
|
738
|
+
openMenu();
|
|
739
|
+
}
|
|
740
|
+
onFocus?.(event);
|
|
741
|
+
},
|
|
742
|
+
onBlur: (event) => {
|
|
743
|
+
if (openOnFocus) {
|
|
744
|
+
scheduleClose();
|
|
745
|
+
}
|
|
746
|
+
onBlur?.(event);
|
|
747
|
+
},
|
|
697
748
|
children: [
|
|
698
749
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "inline-flex w-full min-w-0", children: activator }),
|
|
699
750
|
shouldRenderContent ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -713,6 +764,18 @@ var Menu = React3__namespace.forwardRef((props, ref) => {
|
|
|
713
764
|
role: contentRole ?? "menu",
|
|
714
765
|
tabIndex: contentTabIndex ?? -1,
|
|
715
766
|
style: contentStyle,
|
|
767
|
+
onMouseEnter: (event) => {
|
|
768
|
+
if (openOnHover) {
|
|
769
|
+
openMenu();
|
|
770
|
+
}
|
|
771
|
+
restContentProps?.onMouseEnter?.(event);
|
|
772
|
+
},
|
|
773
|
+
onMouseLeave: (event) => {
|
|
774
|
+
if (openOnHover) {
|
|
775
|
+
scheduleClose();
|
|
776
|
+
}
|
|
777
|
+
restContentProps?.onMouseLeave?.(event);
|
|
778
|
+
},
|
|
716
779
|
children
|
|
717
780
|
}
|
|
718
781
|
) : null
|
|
@@ -1260,6 +1323,82 @@ var ToolTip = React3__namespace.forwardRef((props, forwardedRef) => {
|
|
|
1260
1323
|
});
|
|
1261
1324
|
ToolTip.displayName = "ToolTip";
|
|
1262
1325
|
var ToolTip_default = ToolTip;
|
|
1326
|
+
var paddingClasses = {
|
|
1327
|
+
none: "p-0",
|
|
1328
|
+
sm: "p-3",
|
|
1329
|
+
md: "p-4",
|
|
1330
|
+
lg: "p-6"
|
|
1331
|
+
};
|
|
1332
|
+
var cardBase = "card-base relative w-full overflow-hidden bg-white text-gray-900 transition-colors";
|
|
1333
|
+
var variantClasses = {
|
|
1334
|
+
solid: "rounded-2xl border border-gray-200 bg-white shadow-lg shadow-gray-200/55",
|
|
1335
|
+
outline: "rounded-2xl border border-gray-300 bg-white shadow-none",
|
|
1336
|
+
text: "rounded-2xl border border-transparent bg-transparent shadow-none",
|
|
1337
|
+
ghost: "rounded-2xl border border-transparent bg-gray-50 shadow-none",
|
|
1338
|
+
filled: "rounded-2xl border border-gray-200 bg-gray-50 shadow-sm",
|
|
1339
|
+
underlined: "rounded-2xl border border-transparent border-b border-b-gray-200 shadow-none",
|
|
1340
|
+
rounded: "rounded-3xl border border-gray-200 bg-white shadow-md",
|
|
1341
|
+
sharp: "rounded-none border border-gray-200 bg-white shadow-md"
|
|
1342
|
+
};
|
|
1343
|
+
var CardRoot = React3.forwardRef(function Card({ className, children, variant = "solid", padding = "md", interactive = false, ...rest }, ref) {
|
|
1344
|
+
const variantClass = variantClasses[variant] ?? variantClasses.solid;
|
|
1345
|
+
const paddingClass = paddingClasses[padding] ?? paddingClasses.md;
|
|
1346
|
+
const interactiveClass = interactive ? "transition-all duration-200 hover:-translate-y-0.5 hover:shadow-xl focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 focus-visible:ring-offset-2" : void 0;
|
|
1347
|
+
const tabIndexValue = interactive && rest.tabIndex === void 0 ? 0 : rest.tabIndex;
|
|
1348
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1349
|
+
"div",
|
|
1350
|
+
{
|
|
1351
|
+
...rest,
|
|
1352
|
+
ref,
|
|
1353
|
+
tabIndex: tabIndexValue,
|
|
1354
|
+
className: tailwindMerge.twMerge(cardBase, variantClass, paddingClass, interactiveClass, className),
|
|
1355
|
+
children
|
|
1356
|
+
}
|
|
1357
|
+
);
|
|
1358
|
+
});
|
|
1359
|
+
var CardHeader = ({ className, ...rest }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1360
|
+
"div",
|
|
1361
|
+
{
|
|
1362
|
+
...rest,
|
|
1363
|
+
className: tailwindMerge.twMerge("card-header mb-2 flex flex-col gap-1 border-b border-gray-100 pb-3", className)
|
|
1364
|
+
}
|
|
1365
|
+
);
|
|
1366
|
+
var CardBody = ({ className, ...rest }) => /* @__PURE__ */ jsxRuntime.jsx("div", { ...rest, className: tailwindMerge.twMerge("card-body flex flex-col gap-3", className) });
|
|
1367
|
+
var CardFooter = ({ className, ...rest }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1368
|
+
"div",
|
|
1369
|
+
{
|
|
1370
|
+
...rest,
|
|
1371
|
+
className: tailwindMerge.twMerge("card-footer mt-3 flex flex-wrap items-center gap-3 border-t border-gray-100 pt-3", className)
|
|
1372
|
+
}
|
|
1373
|
+
);
|
|
1374
|
+
var CardTitle = ({ className, ...rest }) => /* @__PURE__ */ jsxRuntime.jsx("h3", { ...rest, className: tailwindMerge.twMerge("card-title text-lg font-semibold text-gray-900", className) });
|
|
1375
|
+
var CardSubtitle = ({ className, ...rest }) => /* @__PURE__ */ jsxRuntime.jsx("p", { ...rest, className: tailwindMerge.twMerge("card-subtitle text-sm font-medium text-gray-600", className) });
|
|
1376
|
+
var CardText = ({ className, ...rest }) => /* @__PURE__ */ jsxRuntime.jsx("p", { ...rest, className: tailwindMerge.twMerge("card-text text-sm text-gray-700", className) });
|
|
1377
|
+
var CardMedia = ({ className, rounded = false, ...rest }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1378
|
+
"img",
|
|
1379
|
+
{
|
|
1380
|
+
...rest,
|
|
1381
|
+
className: tailwindMerge.twMerge(
|
|
1382
|
+
"card-media w-full object-cover",
|
|
1383
|
+
rounded ? "rounded-xl" : "rounded-none",
|
|
1384
|
+
rest.height || rest.style ? "block" : "block max-h-60",
|
|
1385
|
+
className
|
|
1386
|
+
),
|
|
1387
|
+
loading: rest.loading ?? "lazy"
|
|
1388
|
+
}
|
|
1389
|
+
);
|
|
1390
|
+
var CardActions = ({ className, ...rest }) => /* @__PURE__ */ jsxRuntime.jsx("div", { ...rest, className: tailwindMerge.twMerge("card-actions flex flex-wrap gap-2", className) });
|
|
1391
|
+
var Card2 = Object.assign(CardRoot, {
|
|
1392
|
+
Header: CardHeader,
|
|
1393
|
+
Body: CardBody,
|
|
1394
|
+
Footer: CardFooter,
|
|
1395
|
+
Title: CardTitle,
|
|
1396
|
+
Subtitle: CardSubtitle,
|
|
1397
|
+
Text: CardText,
|
|
1398
|
+
Media: CardMedia,
|
|
1399
|
+
Actions: CardActions
|
|
1400
|
+
});
|
|
1401
|
+
var Card_default = Card2;
|
|
1263
1402
|
|
|
1264
1403
|
// src/Form/Input/states.input.ts
|
|
1265
1404
|
var resolveIconClassName3 = (icon) => {
|
|
@@ -1309,7 +1448,7 @@ var Input = ({
|
|
|
1309
1448
|
...props
|
|
1310
1449
|
}) => {
|
|
1311
1450
|
const classBase = "input-base px-3 py-2 focus-visible:outline-none focus-visible:ring-primary transition-colors duration-200 disabled:opacity-50 disabled:cursor-not-allowed w-full";
|
|
1312
|
-
const
|
|
1451
|
+
const variantClasses2 = {
|
|
1313
1452
|
solid: "rounded border border-gray-400 bg-white shadow-sm focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-primary/30",
|
|
1314
1453
|
sharp: "rounded-none border border-gray-400 bg-white shadow-sm focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-primary/30",
|
|
1315
1454
|
outline: "rounded border border-gray-300 bg-transparent focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-primary/30",
|
|
@@ -1330,7 +1469,7 @@ var Input = ({
|
|
|
1330
1469
|
warn: "text-amber-600",
|
|
1331
1470
|
success: "text-emerald-600"
|
|
1332
1471
|
};
|
|
1333
|
-
const variantClass =
|
|
1472
|
+
const variantClass = variantClasses2[variant] ?? variantClasses2.outline;
|
|
1334
1473
|
const toneClass = status ? statusClasses[status.tone] : void 0;
|
|
1335
1474
|
const prependIconClass = resolveIconClassName3(icon);
|
|
1336
1475
|
const prependPadding = prependIconClass ? "pl-10" : void 0;
|
|
@@ -1351,8 +1490,260 @@ var Input = ({
|
|
|
1351
1490
|
] });
|
|
1352
1491
|
};
|
|
1353
1492
|
var Input_default = Input;
|
|
1493
|
+
var paletteValues = {
|
|
1494
|
+
primary: { fill: "var(--color-primary, #6366f1)", ring: "rgba(99, 102, 241, 0.28)", thumbBorder: "#6366f1" },
|
|
1495
|
+
neutral: { fill: "#4b5563", ring: "rgba(75, 85, 99, 0.28)", thumbBorder: "#4b5563" },
|
|
1496
|
+
info: { fill: "#0284c7", ring: "rgba(2, 132, 199, 0.28)", thumbBorder: "#0284c7" },
|
|
1497
|
+
success: { fill: "#059669", ring: "rgba(5, 150, 105, 0.24)", thumbBorder: "#059669" },
|
|
1498
|
+
warning: { fill: "#d97706", ring: "rgba(217, 119, 6, 0.24)", thumbBorder: "#d97706" },
|
|
1499
|
+
danger: { fill: "#dc2626", ring: "rgba(220, 38, 38, 0.24)", thumbBorder: "#dc2626" },
|
|
1500
|
+
surface: { fill: "#0f172a", ring: "rgba(15, 23, 42, 0.22)", thumbBorder: "#0f172a" },
|
|
1501
|
+
bw: { fill: "#000000", ring: "rgba(0, 0, 0, 0.26)", thumbBorder: "#000000" }
|
|
1502
|
+
};
|
|
1503
|
+
var sizeTokens = {
|
|
1504
|
+
small: { trackHeight: "0.375rem", thumbSize: "1.1rem", trackClass: "h-1.5", valueClass: "text-xs" },
|
|
1505
|
+
medium: { trackHeight: "0.5rem", thumbSize: "1.25rem", trackClass: "h-2", valueClass: "text-sm" },
|
|
1506
|
+
large: { trackHeight: "0.6rem", thumbSize: "1.4rem", trackClass: "h-[0.65rem]", valueClass: "text-base" }
|
|
1507
|
+
};
|
|
1508
|
+
var clamp = (value, min, max) => Math.min(Math.max(value, min), max);
|
|
1509
|
+
var toNumber = (value, fallback) => {
|
|
1510
|
+
if (typeof value === "number" && Number.isFinite(value)) {
|
|
1511
|
+
return value;
|
|
1512
|
+
}
|
|
1513
|
+
const parsed = Number(value);
|
|
1514
|
+
return Number.isFinite(parsed) ? parsed : fallback;
|
|
1515
|
+
};
|
|
1516
|
+
var Slider = ({
|
|
1517
|
+
color = "primary",
|
|
1518
|
+
size = "medium",
|
|
1519
|
+
label,
|
|
1520
|
+
hint,
|
|
1521
|
+
showValue = true,
|
|
1522
|
+
valueLabel,
|
|
1523
|
+
wrapperClassName,
|
|
1524
|
+
className,
|
|
1525
|
+
trackColor,
|
|
1526
|
+
onChange,
|
|
1527
|
+
disabled,
|
|
1528
|
+
min = 0,
|
|
1529
|
+
max = 100,
|
|
1530
|
+
step = 1,
|
|
1531
|
+
...rest
|
|
1532
|
+
}) => {
|
|
1533
|
+
const palette = paletteValues[color] ?? paletteValues.primary;
|
|
1534
|
+
const sizeToken = sizeTokens[size] ?? sizeTokens.medium;
|
|
1535
|
+
const { value, defaultValue, ...inputProps } = rest;
|
|
1536
|
+
const resolvedMin = toNumber(min, 0);
|
|
1537
|
+
const resolvedMax = toNumber(max, resolvedMin < 100 ? 100 : resolvedMin);
|
|
1538
|
+
const resolvedStep = toNumber(step, 1);
|
|
1539
|
+
const isControlled = typeof value === "number";
|
|
1540
|
+
const [internalValue, setInternalValue] = React3.useState(
|
|
1541
|
+
clamp(
|
|
1542
|
+
typeof value === "number" ? value : typeof defaultValue === "number" ? defaultValue : resolvedMin,
|
|
1543
|
+
resolvedMin,
|
|
1544
|
+
resolvedMax
|
|
1545
|
+
)
|
|
1546
|
+
);
|
|
1547
|
+
React3.useEffect(() => {
|
|
1548
|
+
if (isControlled && typeof value === "number") {
|
|
1549
|
+
setInternalValue(clamp(value, resolvedMin, resolvedMax));
|
|
1550
|
+
}
|
|
1551
|
+
}, [isControlled, value, resolvedMin, resolvedMax]);
|
|
1552
|
+
React3.useEffect(() => {
|
|
1553
|
+
if (!isControlled) {
|
|
1554
|
+
setInternalValue((prev) => clamp(prev, resolvedMin, resolvedMax));
|
|
1555
|
+
}
|
|
1556
|
+
}, [isControlled, resolvedMin, resolvedMax]);
|
|
1557
|
+
const currentValue = isControlled && typeof value === "number" ? clamp(value, resolvedMin, resolvedMax) : internalValue;
|
|
1558
|
+
const percentage = resolvedMax === resolvedMin ? 0 : (currentValue - resolvedMin) / (resolvedMax - resolvedMin) * 100;
|
|
1559
|
+
const cssVars = {
|
|
1560
|
+
"--slider-color": palette.fill,
|
|
1561
|
+
"--slider-ring-color": palette.ring,
|
|
1562
|
+
"--slider-thumb-border": palette.thumbBorder,
|
|
1563
|
+
"--slider-track-color": trackColor ?? "#e5e7eb",
|
|
1564
|
+
"--slider-track-height": sizeToken.trackHeight,
|
|
1565
|
+
"--slider-thumb-size": sizeToken.thumbSize,
|
|
1566
|
+
"--slider-percentage": `${percentage}%`
|
|
1567
|
+
};
|
|
1568
|
+
if (disabled) {
|
|
1569
|
+
cssVars["--slider-disabled-fill"] = "#d1d5db";
|
|
1570
|
+
cssVars["--slider-thumb-border"] = "#d1d5db";
|
|
1571
|
+
cssVars["--slider-track-color-disabled"] = "#e5e7eb";
|
|
1572
|
+
}
|
|
1573
|
+
const handleChange = (event) => {
|
|
1574
|
+
const nextValue = Number(event.target.value);
|
|
1575
|
+
if (!isControlled) {
|
|
1576
|
+
setInternalValue(nextValue);
|
|
1577
|
+
}
|
|
1578
|
+
onChange?.(nextValue, event);
|
|
1579
|
+
};
|
|
1580
|
+
const displayValue = valueLabel ? valueLabel(currentValue) : currentValue;
|
|
1581
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: tailwindMerge.twMerge("flex flex-col gap-2", wrapperClassName), children: [
|
|
1582
|
+
(label || showValue) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
|
|
1583
|
+
label && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-medium text-gray-900", children: label }),
|
|
1584
|
+
showValue && /* @__PURE__ */ jsxRuntime.jsx("span", { className: tailwindMerge.twMerge("tabular-nums text-gray-900", sizeToken.valueClass), children: displayValue })
|
|
1585
|
+
] }),
|
|
1586
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1587
|
+
"input",
|
|
1588
|
+
{
|
|
1589
|
+
...inputProps,
|
|
1590
|
+
type: "range",
|
|
1591
|
+
min: resolvedMin,
|
|
1592
|
+
max: resolvedMax,
|
|
1593
|
+
step: resolvedStep,
|
|
1594
|
+
value: currentValue,
|
|
1595
|
+
onChange: handleChange,
|
|
1596
|
+
disabled,
|
|
1597
|
+
className: tailwindMerge.twMerge(
|
|
1598
|
+
"slider-control focus-visible:outline-none rounded-full",
|
|
1599
|
+
sizeToken.trackClass,
|
|
1600
|
+
disabled ? "cursor-not-allowed opacity-70" : "cursor-pointer",
|
|
1601
|
+
className
|
|
1602
|
+
),
|
|
1603
|
+
style: cssVars
|
|
1604
|
+
}
|
|
1605
|
+
),
|
|
1606
|
+
hint && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-gray-600", children: hint })
|
|
1607
|
+
] });
|
|
1608
|
+
};
|
|
1609
|
+
var Slider_default = Slider;
|
|
1610
|
+
var trackSizes = {
|
|
1611
|
+
small: "w-10 h-6",
|
|
1612
|
+
medium: "w-12 h-7",
|
|
1613
|
+
large: "w-14 h-8"
|
|
1614
|
+
};
|
|
1615
|
+
var thumbSizes = {
|
|
1616
|
+
small: "w-5 h-5",
|
|
1617
|
+
medium: "w-6 h-6",
|
|
1618
|
+
large: "w-7 h-7"
|
|
1619
|
+
};
|
|
1620
|
+
var thumbTranslate = {
|
|
1621
|
+
small: "translate-x-4",
|
|
1622
|
+
medium: "translate-x-5",
|
|
1623
|
+
large: "translate-x-6"
|
|
1624
|
+
};
|
|
1625
|
+
var paletteTrackClasses = {
|
|
1626
|
+
primary: { active: "bg-primary", inactive: "bg-gray-300" },
|
|
1627
|
+
neutral: { active: "bg-gray-600", inactive: "bg-gray-300" },
|
|
1628
|
+
info: { active: "bg-sky-500", inactive: "bg-gray-300" },
|
|
1629
|
+
success: { active: "bg-emerald-500", inactive: "bg-gray-300" },
|
|
1630
|
+
warning: { active: "bg-amber-500", inactive: "bg-gray-300" },
|
|
1631
|
+
danger: { active: "bg-red-500", inactive: "bg-gray-300" },
|
|
1632
|
+
surface: { active: "bg-gray-900", inactive: "bg-gray-300" },
|
|
1633
|
+
bw: { active: "bg-black", inactive: "bg-gray-200" }
|
|
1634
|
+
};
|
|
1635
|
+
var focusRingClasses = {
|
|
1636
|
+
primary: "peer-focus-visible:ring-primary/40",
|
|
1637
|
+
neutral: "peer-focus-visible:ring-gray-400",
|
|
1638
|
+
info: "peer-focus-visible:ring-sky-400",
|
|
1639
|
+
success: "peer-focus-visible:ring-emerald-400",
|
|
1640
|
+
warning: "peer-focus-visible:ring-amber-400",
|
|
1641
|
+
danger: "peer-focus-visible:ring-red-400",
|
|
1642
|
+
surface: "peer-focus-visible:ring-gray-800/70",
|
|
1643
|
+
bw: "peer-focus-visible:ring-black/50"
|
|
1644
|
+
};
|
|
1645
|
+
var thumbActiveClasses = {
|
|
1646
|
+
primary: "border-primary shadow-[0_4px_12px_rgba(99,102,241,0.35)]",
|
|
1647
|
+
neutral: "border-gray-600 shadow-[0_4px_12px_rgba(75,85,99,0.35)]",
|
|
1648
|
+
info: "border-sky-500 shadow-[0_4px_12px_rgba(2,132,199,0.32)]",
|
|
1649
|
+
success: "border-emerald-500 shadow-[0_4px_12px_rgba(16,185,129,0.32)]",
|
|
1650
|
+
warning: "border-amber-500 shadow-[0_4px_12px_rgba(245,158,11,0.32)]",
|
|
1651
|
+
danger: "border-red-500 shadow-[0_4px_12px_rgba(239,68,68,0.32)]",
|
|
1652
|
+
surface: "border-gray-900 shadow-[0_4px_12px_rgba(15,23,42,0.32)]",
|
|
1653
|
+
bw: "border-black shadow-[0_4px_12px_rgba(0,0,0,0.32)]"
|
|
1654
|
+
};
|
|
1655
|
+
var Switch = React3.forwardRef(
|
|
1656
|
+
({
|
|
1657
|
+
color = "primary",
|
|
1658
|
+
size = "medium",
|
|
1659
|
+
label,
|
|
1660
|
+
description,
|
|
1661
|
+
wrapperClassName,
|
|
1662
|
+
className,
|
|
1663
|
+
labelClassName,
|
|
1664
|
+
disabled,
|
|
1665
|
+
onChange,
|
|
1666
|
+
checked,
|
|
1667
|
+
defaultChecked,
|
|
1668
|
+
...rest
|
|
1669
|
+
}, ref) => {
|
|
1670
|
+
const paletteTrack = paletteTrackClasses[color] ?? paletteTrackClasses.primary;
|
|
1671
|
+
const focusClass = focusRingClasses[color] ?? focusRingClasses.primary;
|
|
1672
|
+
const thumbActive = thumbActiveClasses[color] ?? thumbActiveClasses.primary;
|
|
1673
|
+
const isControlled = checked !== void 0;
|
|
1674
|
+
const [internalChecked, setInternalChecked] = React3.useState(
|
|
1675
|
+
Boolean((isControlled ? checked : defaultChecked) ?? false)
|
|
1676
|
+
);
|
|
1677
|
+
React3.useEffect(() => {
|
|
1678
|
+
if (isControlled) {
|
|
1679
|
+
setInternalChecked(Boolean(checked));
|
|
1680
|
+
}
|
|
1681
|
+
}, [checked, isControlled]);
|
|
1682
|
+
const currentChecked = isControlled ? Boolean(checked) : internalChecked;
|
|
1683
|
+
const handleChange = (event) => {
|
|
1684
|
+
if (!isControlled) {
|
|
1685
|
+
setInternalChecked(event.target.checked);
|
|
1686
|
+
}
|
|
1687
|
+
onChange?.(event);
|
|
1688
|
+
};
|
|
1689
|
+
const sizeTrackClass = trackSizes[size] ?? trackSizes.medium;
|
|
1690
|
+
const sizeThumbClass = thumbSizes[size] ?? thumbSizes.medium;
|
|
1691
|
+
const thumbShiftClass = thumbTranslate[size] ?? thumbTranslate.medium;
|
|
1692
|
+
const pointerClass = disabled ? "cursor-not-allowed opacity-60" : "cursor-pointer";
|
|
1693
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("label", { className: tailwindMerge.twMerge("flex items-center gap-3 select-none", pointerClass, wrapperClassName), children: [
|
|
1694
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "relative inline-flex items-center", children: [
|
|
1695
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1696
|
+
"input",
|
|
1697
|
+
{
|
|
1698
|
+
...rest,
|
|
1699
|
+
type: "checkbox",
|
|
1700
|
+
ref,
|
|
1701
|
+
checked: currentChecked,
|
|
1702
|
+
onChange: handleChange,
|
|
1703
|
+
disabled,
|
|
1704
|
+
className: "peer sr-only"
|
|
1705
|
+
}
|
|
1706
|
+
),
|
|
1707
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1708
|
+
"span",
|
|
1709
|
+
{
|
|
1710
|
+
className: tailwindMerge.twMerge(
|
|
1711
|
+
"block rounded-full border border-transparent transition-all duration-200",
|
|
1712
|
+
sizeTrackClass,
|
|
1713
|
+
currentChecked ? paletteTrack.active : paletteTrack.inactive,
|
|
1714
|
+
disabled && "bg-gray-200",
|
|
1715
|
+
"peer-focus-visible:ring-2 peer-focus-visible:ring-offset-2",
|
|
1716
|
+
focusClass,
|
|
1717
|
+
className
|
|
1718
|
+
),
|
|
1719
|
+
"aria-hidden": true,
|
|
1720
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1721
|
+
"span",
|
|
1722
|
+
{
|
|
1723
|
+
className: tailwindMerge.twMerge(
|
|
1724
|
+
"absolute left-0.5 top-0.5 rounded-full bg-white shadow-md border border-gray-200 transition-transform duration-200",
|
|
1725
|
+
sizeThumbClass,
|
|
1726
|
+
currentChecked && thumbShiftClass,
|
|
1727
|
+
currentChecked && thumbActive,
|
|
1728
|
+
disabled && "border-gray-300"
|
|
1729
|
+
)
|
|
1730
|
+
}
|
|
1731
|
+
)
|
|
1732
|
+
}
|
|
1733
|
+
)
|
|
1734
|
+
] }),
|
|
1735
|
+
(label || description) && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: tailwindMerge.twMerge("flex flex-col leading-tight", labelClassName), children: [
|
|
1736
|
+
label && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-medium text-gray-900", children: label }),
|
|
1737
|
+
description && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-gray-600", children: description })
|
|
1738
|
+
] })
|
|
1739
|
+
] });
|
|
1740
|
+
}
|
|
1741
|
+
);
|
|
1742
|
+
Switch.displayName = "Switch";
|
|
1743
|
+
var Switch_default = Switch;
|
|
1354
1744
|
|
|
1355
1745
|
exports.Button = Button_default;
|
|
1746
|
+
exports.Card = Card_default;
|
|
1356
1747
|
exports.Chip = Chip_default;
|
|
1357
1748
|
exports.Dialog = Dialog_default;
|
|
1358
1749
|
exports.ExpansionPanel = ExpansionPanel_default;
|
|
@@ -1361,6 +1752,8 @@ exports.Input = Input_default;
|
|
|
1361
1752
|
exports.List = List_default;
|
|
1362
1753
|
exports.ListItem = Item_default;
|
|
1363
1754
|
exports.Menu = Menu_default;
|
|
1755
|
+
exports.Slider = Slider_default;
|
|
1756
|
+
exports.Switch = Switch_default;
|
|
1364
1757
|
exports.ToolTip = ToolTip_default;
|
|
1365
1758
|
//# sourceMappingURL=index.cjs.map
|
|
1366
1759
|
//# sourceMappingURL=index.cjs.map
|