@khanhminh/design-system 1.13.0 → 1.14.0
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 +26 -131
- package/dist/index.d.ts +0 -1
- package/dist/index.js +27 -124
- package/package.json +5 -2
package/dist/index.cjs
CHANGED
|
@@ -1,11 +1,34 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var React = require('react');
|
|
4
|
-
var classVarianceAuthority = require('class-variance-authority');
|
|
5
|
-
var radixUi = require('radix-ui');
|
|
6
4
|
var clsx = require('clsx');
|
|
7
5
|
var tailwindMerge = require('tailwind-merge');
|
|
8
|
-
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A simple boolean toggle hook.
|
|
9
|
+
*
|
|
10
|
+
* @param initial initial value (defaults to false)
|
|
11
|
+
* @returns an object with the current state and helpers to toggle / set on / set off
|
|
12
|
+
*/
|
|
13
|
+
function useToggle(initial = false) {
|
|
14
|
+
const [state, setState] = React.useState(initial);
|
|
15
|
+
const toggle = React.useCallback(() => setState((s) => !s), []);
|
|
16
|
+
const setOn = React.useCallback(() => setState(true), []);
|
|
17
|
+
const setOff = React.useCallback(() => setState(false), []);
|
|
18
|
+
return { state, toggle, setOn, setOff };
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function cn(...inputs) {
|
|
22
|
+
return tailwindMerge.twMerge(clsx.clsx(inputs));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const applyTheme = (theme) => {
|
|
26
|
+
const root = window.document.documentElement;
|
|
27
|
+
const systemDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
|
28
|
+
const resolvedTheme = theme === 'system' ? (systemDark ? 'dark' : 'light') : theme;
|
|
29
|
+
root.classList.remove('light', 'dark');
|
|
30
|
+
root.classList.add(resolvedTheme);
|
|
31
|
+
};
|
|
9
32
|
|
|
10
33
|
var jsxRuntime = {exports: {}};
|
|
11
34
|
|
|
@@ -421,126 +444,6 @@ if (process.env.NODE_ENV === 'production') {
|
|
|
421
444
|
|
|
422
445
|
var jsxRuntimeExports = jsxRuntime.exports;
|
|
423
446
|
|
|
424
|
-
function cn(...inputs) {
|
|
425
|
-
return tailwindMerge.twMerge(clsx.clsx(inputs));
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
const buttonVariants = classVarianceAuthority.cva("inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", {
|
|
429
|
-
variants: {
|
|
430
|
-
variant: {
|
|
431
|
-
default: 'bg-primary text-primary-foreground hover:bg-primary/90',
|
|
432
|
-
destructive: 'bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40',
|
|
433
|
-
outline: 'border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50',
|
|
434
|
-
secondary: 'bg-secondary text-secondary-foreground hover:bg-secondary/80',
|
|
435
|
-
ghost: 'hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50',
|
|
436
|
-
link: 'text-primary underline-offset-4 hover:underline',
|
|
437
|
-
},
|
|
438
|
-
size: {
|
|
439
|
-
default: 'h-9 px-4 py-2 has-[>svg]:px-3',
|
|
440
|
-
xs: "h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3",
|
|
441
|
-
sm: 'h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5',
|
|
442
|
-
lg: 'h-10 rounded-md px-6 has-[>svg]:px-4',
|
|
443
|
-
icon: 'size-9',
|
|
444
|
-
'icon-xs': "size-6 rounded-md [&_svg:not([class*='size-'])]:size-3",
|
|
445
|
-
'icon-sm': 'size-8',
|
|
446
|
-
'icon-lg': 'size-10',
|
|
447
|
-
},
|
|
448
|
-
},
|
|
449
|
-
defaultVariants: {
|
|
450
|
-
variant: 'default',
|
|
451
|
-
size: 'default',
|
|
452
|
-
},
|
|
453
|
-
});
|
|
454
|
-
function Button$1({ className, variant = 'default', size = 'default', asChild = false, ...props }) {
|
|
455
|
-
const Comp = asChild ? radixUi.Slot.Root : 'button';
|
|
456
|
-
return (jsxRuntimeExports.jsx(Comp, { className: cn(buttonVariants({ variant, size, className })), "data-size": size, "data-slot": "button", "data-variant": variant, ...props }));
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
const Button = (props) => {
|
|
460
|
-
return jsxRuntimeExports.jsx(Button$1, { ...props });
|
|
461
|
-
};
|
|
462
|
-
|
|
463
|
-
function Input$1({ className, type, ...props }) {
|
|
464
|
-
return (jsxRuntimeExports.jsx("input", { className: cn('border-input selection:bg-primary selection:text-primary-foreground file:text-foreground placeholder:text-muted-foreground dark:bg-input/30 h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm', 'focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]', 'aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40', className), "data-slot": "input", type: type, ...props }));
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
const Input = (props) => {
|
|
468
|
-
return jsxRuntimeExports.jsx(Input$1, { ...props });
|
|
469
|
-
};
|
|
470
|
-
|
|
471
|
-
function Spinner$1({ className, ...props }) {
|
|
472
|
-
return jsxRuntimeExports.jsx(lucideReact.Loader2Icon, { "aria-label": "Loading", className: cn('size-4 animate-spin', className), role: "status", ...props });
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
const Spinner = (props) => {
|
|
476
|
-
return jsxRuntimeExports.jsx(Spinner$1, { ...props });
|
|
477
|
-
};
|
|
478
|
-
|
|
479
|
-
function Checkbox$1({ className, ...props }) {
|
|
480
|
-
return (jsxRuntimeExports.jsx(radixUi.Checkbox.Root, { className: cn('peer border-input focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:bg-input/30 dark:aria-invalid:ring-destructive/40 dark:data-[state=checked]:bg-primary size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50', className), "data-slot": "checkbox", ...props, children: jsxRuntimeExports.jsx(radixUi.Checkbox.Indicator, { className: "grid place-content-center text-current transition-none", "data-slot": "checkbox-indicator", children: jsxRuntimeExports.jsx(lucideReact.CheckIcon, { className: "size-3.5" }) }) }));
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
const Checkbox = (props) => {
|
|
484
|
-
return jsxRuntimeExports.jsx(Checkbox$1, { ...props });
|
|
485
|
-
};
|
|
486
|
-
|
|
487
|
-
function Label$1({ className, ...props }) {
|
|
488
|
-
return (jsxRuntimeExports.jsx(radixUi.Label.Root, { className: cn('flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50', className), "data-slot": "label", ...props }));
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
const Label = (props) => {
|
|
492
|
-
return jsxRuntimeExports.jsx(Label$1, { ...props });
|
|
493
|
-
};
|
|
494
|
-
|
|
495
|
-
function Separator$1({ className, orientation = 'horizontal', decorative = true, ...props }) {
|
|
496
|
-
return (jsxRuntimeExports.jsx(radixUi.Separator.Root, { className: cn('bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px', className), "data-slot": "separator", decorative: decorative, orientation: orientation, ...props }));
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
const Separator = (props) => {
|
|
500
|
-
return jsxRuntimeExports.jsx(Separator$1, { ...props });
|
|
501
|
-
};
|
|
502
|
-
|
|
503
|
-
function Switch$1({ className, size = 'default', ...props }) {
|
|
504
|
-
return (jsxRuntimeExports.jsx(radixUi.Switch.Root, { className: cn('peer group/switch focus-visible:border-ring focus-visible:ring-ring/50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input dark:data-[state=unchecked]:bg-input/80 inline-flex shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-[1.15rem] data-[size=default]:w-8 data-[size=sm]:h-3.5 data-[size=sm]:w-6', className), "data-size": size, "data-slot": "switch", ...props, children: jsxRuntimeExports.jsx(radixUi.Switch.Thumb, { className: cn('bg-background dark:data-[state=checked]:bg-primary-foreground dark:data-[state=unchecked]:bg-foreground pointer-events-none block rounded-full ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0'), "data-slot": "switch-thumb" }) }));
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
const Switch = ({ id, label, ...props }) => {
|
|
508
|
-
return (jsxRuntimeExports.jsxs("div", { className: "flex items-center space-x-2", children: [jsxRuntimeExports.jsx(Switch$1, { "data-slot": "switch", id: id, ...props }), jsxRuntimeExports.jsx(Label, { "data-slot": "label", htmlFor: id, children: label })] }));
|
|
509
|
-
};
|
|
510
|
-
|
|
511
|
-
function ScrollArea$1({ className, children, ...props }) {
|
|
512
|
-
return (jsxRuntimeExports.jsxs(radixUi.ScrollArea.Root, { className: cn('relative', className), "data-slot": "scroll-area", ...props, children: [jsxRuntimeExports.jsx(radixUi.ScrollArea.Viewport, { className: "focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1", "data-slot": "scroll-area-viewport", children: children }), jsxRuntimeExports.jsx(ScrollBar, {}), jsxRuntimeExports.jsx(radixUi.ScrollArea.Corner, {})] }));
|
|
513
|
-
}
|
|
514
|
-
function ScrollBar({ className, orientation = 'vertical', ...props }) {
|
|
515
|
-
return (jsxRuntimeExports.jsx(radixUi.ScrollArea.ScrollAreaScrollbar, { className: cn('flex touch-none p-px transition-colors select-none', orientation === 'vertical' && 'h-full w-2.5 border-l border-l-transparent', orientation === 'horizontal' && 'h-2.5 flex-col border-t border-t-transparent', className), "data-slot": "scroll-area-scrollbar", orientation: orientation, ...props, children: jsxRuntimeExports.jsx(radixUi.ScrollArea.ScrollAreaThumb, { className: "bg-border relative flex-1 rounded-full", "data-slot": "scroll-area-thumb" }) }));
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
const ScrollArea = ({ children, orientation = 'horizontal', className, ...props }) => {
|
|
519
|
-
return (jsxRuntimeExports.jsxs(ScrollArea$1, { className: className, "data-slot": "scroll-area", ...props, children: [jsxRuntimeExports.jsx("div", { "data-slot": "scroll-area-viewport", children: children }), jsxRuntimeExports.jsx("div", { "data-slot": "scroll-area-scrollbar", children: jsxRuntimeExports.jsx(ScrollBar, { orientation: orientation }) })] }));
|
|
520
|
-
};
|
|
521
|
-
|
|
522
|
-
/**
|
|
523
|
-
* A simple boolean toggle hook.
|
|
524
|
-
*
|
|
525
|
-
* @param initial initial value (defaults to false)
|
|
526
|
-
* @returns an object with the current state and helpers to toggle / set on / set off
|
|
527
|
-
*/
|
|
528
|
-
function useToggle(initial = false) {
|
|
529
|
-
const [state, setState] = React.useState(initial);
|
|
530
|
-
const toggle = React.useCallback(() => setState((s) => !s), []);
|
|
531
|
-
const setOn = React.useCallback(() => setState(true), []);
|
|
532
|
-
const setOff = React.useCallback(() => setState(false), []);
|
|
533
|
-
return { state, toggle, setOn, setOff };
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
const applyTheme = (theme) => {
|
|
537
|
-
const root = window.document.documentElement;
|
|
538
|
-
const systemDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
|
539
|
-
const resolvedTheme = theme === 'system' ? (systemDark ? 'dark' : 'light') : theme;
|
|
540
|
-
root.classList.remove('light', 'dark');
|
|
541
|
-
root.classList.add(resolvedTheme);
|
|
542
|
-
};
|
|
543
|
-
|
|
544
447
|
const createStoreImpl = (createState) => {
|
|
545
448
|
let state;
|
|
546
449
|
const listeners = /* @__PURE__ */ new Set();
|
|
@@ -606,14 +509,6 @@ function ThemeProvider({ children }) {
|
|
|
606
509
|
return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: children });
|
|
607
510
|
}
|
|
608
511
|
|
|
609
|
-
exports.Button = Button;
|
|
610
|
-
exports.Checkbox = Checkbox;
|
|
611
|
-
exports.Input = Input;
|
|
612
|
-
exports.Label = Label;
|
|
613
|
-
exports.ScrollArea = ScrollArea;
|
|
614
|
-
exports.Separator = Separator;
|
|
615
|
-
exports.Spinner = Spinner;
|
|
616
|
-
exports.Switch = Switch;
|
|
617
512
|
exports.ThemeProvider = ThemeProvider;
|
|
618
513
|
exports.applyTheme = applyTheme;
|
|
619
514
|
exports.cn = cn;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,9 +1,32 @@
|
|
|
1
1
|
import React, { useState, useCallback, useEffect } from 'react';
|
|
2
|
-
import { cva } from 'class-variance-authority';
|
|
3
|
-
import { Slot, Checkbox as Checkbox$2, Label as Label$2, Separator as Separator$2, Switch as Switch$2, ScrollArea as ScrollArea$2 } from 'radix-ui';
|
|
4
2
|
import { clsx } from 'clsx';
|
|
5
3
|
import { twMerge } from 'tailwind-merge';
|
|
6
|
-
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A simple boolean toggle hook.
|
|
7
|
+
*
|
|
8
|
+
* @param initial initial value (defaults to false)
|
|
9
|
+
* @returns an object with the current state and helpers to toggle / set on / set off
|
|
10
|
+
*/
|
|
11
|
+
function useToggle(initial = false) {
|
|
12
|
+
const [state, setState] = useState(initial);
|
|
13
|
+
const toggle = useCallback(() => setState((s) => !s), []);
|
|
14
|
+
const setOn = useCallback(() => setState(true), []);
|
|
15
|
+
const setOff = useCallback(() => setState(false), []);
|
|
16
|
+
return { state, toggle, setOn, setOff };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function cn(...inputs) {
|
|
20
|
+
return twMerge(clsx(inputs));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const applyTheme = (theme) => {
|
|
24
|
+
const root = window.document.documentElement;
|
|
25
|
+
const systemDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
|
26
|
+
const resolvedTheme = theme === 'system' ? (systemDark ? 'dark' : 'light') : theme;
|
|
27
|
+
root.classList.remove('light', 'dark');
|
|
28
|
+
root.classList.add(resolvedTheme);
|
|
29
|
+
};
|
|
7
30
|
|
|
8
31
|
var jsxRuntime = {exports: {}};
|
|
9
32
|
|
|
@@ -419,126 +442,6 @@ if (process.env.NODE_ENV === 'production') {
|
|
|
419
442
|
|
|
420
443
|
var jsxRuntimeExports = jsxRuntime.exports;
|
|
421
444
|
|
|
422
|
-
function cn(...inputs) {
|
|
423
|
-
return twMerge(clsx(inputs));
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
const buttonVariants = cva("inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", {
|
|
427
|
-
variants: {
|
|
428
|
-
variant: {
|
|
429
|
-
default: 'bg-primary text-primary-foreground hover:bg-primary/90',
|
|
430
|
-
destructive: 'bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40',
|
|
431
|
-
outline: 'border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50',
|
|
432
|
-
secondary: 'bg-secondary text-secondary-foreground hover:bg-secondary/80',
|
|
433
|
-
ghost: 'hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50',
|
|
434
|
-
link: 'text-primary underline-offset-4 hover:underline',
|
|
435
|
-
},
|
|
436
|
-
size: {
|
|
437
|
-
default: 'h-9 px-4 py-2 has-[>svg]:px-3',
|
|
438
|
-
xs: "h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3",
|
|
439
|
-
sm: 'h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5',
|
|
440
|
-
lg: 'h-10 rounded-md px-6 has-[>svg]:px-4',
|
|
441
|
-
icon: 'size-9',
|
|
442
|
-
'icon-xs': "size-6 rounded-md [&_svg:not([class*='size-'])]:size-3",
|
|
443
|
-
'icon-sm': 'size-8',
|
|
444
|
-
'icon-lg': 'size-10',
|
|
445
|
-
},
|
|
446
|
-
},
|
|
447
|
-
defaultVariants: {
|
|
448
|
-
variant: 'default',
|
|
449
|
-
size: 'default',
|
|
450
|
-
},
|
|
451
|
-
});
|
|
452
|
-
function Button$1({ className, variant = 'default', size = 'default', asChild = false, ...props }) {
|
|
453
|
-
const Comp = asChild ? Slot.Root : 'button';
|
|
454
|
-
return (jsxRuntimeExports.jsx(Comp, { className: cn(buttonVariants({ variant, size, className })), "data-size": size, "data-slot": "button", "data-variant": variant, ...props }));
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
const Button = (props) => {
|
|
458
|
-
return jsxRuntimeExports.jsx(Button$1, { ...props });
|
|
459
|
-
};
|
|
460
|
-
|
|
461
|
-
function Input$1({ className, type, ...props }) {
|
|
462
|
-
return (jsxRuntimeExports.jsx("input", { className: cn('border-input selection:bg-primary selection:text-primary-foreground file:text-foreground placeholder:text-muted-foreground dark:bg-input/30 h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm', 'focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]', 'aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40', className), "data-slot": "input", type: type, ...props }));
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
const Input = (props) => {
|
|
466
|
-
return jsxRuntimeExports.jsx(Input$1, { ...props });
|
|
467
|
-
};
|
|
468
|
-
|
|
469
|
-
function Spinner$1({ className, ...props }) {
|
|
470
|
-
return jsxRuntimeExports.jsx(Loader2Icon, { "aria-label": "Loading", className: cn('size-4 animate-spin', className), role: "status", ...props });
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
const Spinner = (props) => {
|
|
474
|
-
return jsxRuntimeExports.jsx(Spinner$1, { ...props });
|
|
475
|
-
};
|
|
476
|
-
|
|
477
|
-
function Checkbox$1({ className, ...props }) {
|
|
478
|
-
return (jsxRuntimeExports.jsx(Checkbox$2.Root, { className: cn('peer border-input focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:bg-input/30 dark:aria-invalid:ring-destructive/40 dark:data-[state=checked]:bg-primary size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50', className), "data-slot": "checkbox", ...props, children: jsxRuntimeExports.jsx(Checkbox$2.Indicator, { className: "grid place-content-center text-current transition-none", "data-slot": "checkbox-indicator", children: jsxRuntimeExports.jsx(CheckIcon, { className: "size-3.5" }) }) }));
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
const Checkbox = (props) => {
|
|
482
|
-
return jsxRuntimeExports.jsx(Checkbox$1, { ...props });
|
|
483
|
-
};
|
|
484
|
-
|
|
485
|
-
function Label$1({ className, ...props }) {
|
|
486
|
-
return (jsxRuntimeExports.jsx(Label$2.Root, { className: cn('flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50', className), "data-slot": "label", ...props }));
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
const Label = (props) => {
|
|
490
|
-
return jsxRuntimeExports.jsx(Label$1, { ...props });
|
|
491
|
-
};
|
|
492
|
-
|
|
493
|
-
function Separator$1({ className, orientation = 'horizontal', decorative = true, ...props }) {
|
|
494
|
-
return (jsxRuntimeExports.jsx(Separator$2.Root, { className: cn('bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px', className), "data-slot": "separator", decorative: decorative, orientation: orientation, ...props }));
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
const Separator = (props) => {
|
|
498
|
-
return jsxRuntimeExports.jsx(Separator$1, { ...props });
|
|
499
|
-
};
|
|
500
|
-
|
|
501
|
-
function Switch$1({ className, size = 'default', ...props }) {
|
|
502
|
-
return (jsxRuntimeExports.jsx(Switch$2.Root, { className: cn('peer group/switch focus-visible:border-ring focus-visible:ring-ring/50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input dark:data-[state=unchecked]:bg-input/80 inline-flex shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-[1.15rem] data-[size=default]:w-8 data-[size=sm]:h-3.5 data-[size=sm]:w-6', className), "data-size": size, "data-slot": "switch", ...props, children: jsxRuntimeExports.jsx(Switch$2.Thumb, { className: cn('bg-background dark:data-[state=checked]:bg-primary-foreground dark:data-[state=unchecked]:bg-foreground pointer-events-none block rounded-full ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0'), "data-slot": "switch-thumb" }) }));
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
const Switch = ({ id, label, ...props }) => {
|
|
506
|
-
return (jsxRuntimeExports.jsxs("div", { className: "flex items-center space-x-2", children: [jsxRuntimeExports.jsx(Switch$1, { "data-slot": "switch", id: id, ...props }), jsxRuntimeExports.jsx(Label, { "data-slot": "label", htmlFor: id, children: label })] }));
|
|
507
|
-
};
|
|
508
|
-
|
|
509
|
-
function ScrollArea$1({ className, children, ...props }) {
|
|
510
|
-
return (jsxRuntimeExports.jsxs(ScrollArea$2.Root, { className: cn('relative', className), "data-slot": "scroll-area", ...props, children: [jsxRuntimeExports.jsx(ScrollArea$2.Viewport, { className: "focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1", "data-slot": "scroll-area-viewport", children: children }), jsxRuntimeExports.jsx(ScrollBar, {}), jsxRuntimeExports.jsx(ScrollArea$2.Corner, {})] }));
|
|
511
|
-
}
|
|
512
|
-
function ScrollBar({ className, orientation = 'vertical', ...props }) {
|
|
513
|
-
return (jsxRuntimeExports.jsx(ScrollArea$2.ScrollAreaScrollbar, { className: cn('flex touch-none p-px transition-colors select-none', orientation === 'vertical' && 'h-full w-2.5 border-l border-l-transparent', orientation === 'horizontal' && 'h-2.5 flex-col border-t border-t-transparent', className), "data-slot": "scroll-area-scrollbar", orientation: orientation, ...props, children: jsxRuntimeExports.jsx(ScrollArea$2.ScrollAreaThumb, { className: "bg-border relative flex-1 rounded-full", "data-slot": "scroll-area-thumb" }) }));
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
const ScrollArea = ({ children, orientation = 'horizontal', className, ...props }) => {
|
|
517
|
-
return (jsxRuntimeExports.jsxs(ScrollArea$1, { className: className, "data-slot": "scroll-area", ...props, children: [jsxRuntimeExports.jsx("div", { "data-slot": "scroll-area-viewport", children: children }), jsxRuntimeExports.jsx("div", { "data-slot": "scroll-area-scrollbar", children: jsxRuntimeExports.jsx(ScrollBar, { orientation: orientation }) })] }));
|
|
518
|
-
};
|
|
519
|
-
|
|
520
|
-
/**
|
|
521
|
-
* A simple boolean toggle hook.
|
|
522
|
-
*
|
|
523
|
-
* @param initial initial value (defaults to false)
|
|
524
|
-
* @returns an object with the current state and helpers to toggle / set on / set off
|
|
525
|
-
*/
|
|
526
|
-
function useToggle(initial = false) {
|
|
527
|
-
const [state, setState] = useState(initial);
|
|
528
|
-
const toggle = useCallback(() => setState((s) => !s), []);
|
|
529
|
-
const setOn = useCallback(() => setState(true), []);
|
|
530
|
-
const setOff = useCallback(() => setState(false), []);
|
|
531
|
-
return { state, toggle, setOn, setOff };
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
const applyTheme = (theme) => {
|
|
535
|
-
const root = window.document.documentElement;
|
|
536
|
-
const systemDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
|
537
|
-
const resolvedTheme = theme === 'system' ? (systemDark ? 'dark' : 'light') : theme;
|
|
538
|
-
root.classList.remove('light', 'dark');
|
|
539
|
-
root.classList.add(resolvedTheme);
|
|
540
|
-
};
|
|
541
|
-
|
|
542
445
|
const createStoreImpl = (createState) => {
|
|
543
446
|
let state;
|
|
544
447
|
const listeners = /* @__PURE__ */ new Set();
|
|
@@ -604,4 +507,4 @@ function ThemeProvider({ children }) {
|
|
|
604
507
|
return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: children });
|
|
605
508
|
}
|
|
606
509
|
|
|
607
|
-
export {
|
|
510
|
+
export { ThemeProvider, applyTheme, cn, useThemeStore, useToggle };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@khanhminh/design-system",
|
|
3
3
|
"description": "A reusable React component library built with TypeScript, Tailwind CSS, and Radix UI",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.14.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
7
7
|
"main": "dist/index.cjs",
|
|
@@ -11,7 +11,10 @@
|
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
13
13
|
"import": "./dist/index.js",
|
|
14
|
-
"require": "./dist/index.cjs"
|
|
14
|
+
"require": "./dist/index.cjs"
|
|
15
|
+
},
|
|
16
|
+
"./components": {
|
|
17
|
+
"import": "./dist/index.js",
|
|
15
18
|
"types": "./dist/index.d.ts"
|
|
16
19
|
},
|
|
17
20
|
"./package.json": "./package.json",
|