@nexus-cross/design-system 1.0.3-beta.1
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/cursor-rules/nexus-project-setup.mdc +188 -0
- package/cursor-rules/nexus-ui-api.mdc +698 -0
- package/cursor-rules/nexus-ui-components.mdc +104 -0
- package/dist/accordion.d.mts +28 -0
- package/dist/accordion.d.ts +28 -0
- package/dist/accordion.js +28 -0
- package/dist/accordion.mjs +3 -0
- package/dist/avatar.d.mts +17 -0
- package/dist/avatar.d.ts +17 -0
- package/dist/avatar.js +16 -0
- package/dist/avatar.mjs +3 -0
- package/dist/button.d.mts +15 -0
- package/dist/button.d.ts +15 -0
- package/dist/button.js +16 -0
- package/dist/button.mjs +3 -0
- package/dist/carousel.d.mts +36 -0
- package/dist/carousel.d.ts +36 -0
- package/dist/carousel.js +32 -0
- package/dist/carousel.mjs +3 -0
- package/dist/checkbox.d.mts +21 -0
- package/dist/checkbox.d.ts +21 -0
- package/dist/checkbox.js +20 -0
- package/dist/checkbox.mjs +3 -0
- package/dist/chip.d.mts +16 -0
- package/dist/chip.d.ts +16 -0
- package/dist/chip.js +16 -0
- package/dist/chip.mjs +3 -0
- package/dist/chunks/chunk-22ULI3BF.js +21 -0
- package/dist/chunks/chunk-2JTPRBHZ.mjs +36 -0
- package/dist/chunks/chunk-377KBJQG.js +74 -0
- package/dist/chunks/chunk-3CHRUKSJ.mjs +120 -0
- package/dist/chunks/chunk-4ITJA3IS.mjs +83 -0
- package/dist/chunks/chunk-4J3GCZ7W.mjs +102 -0
- package/dist/chunks/chunk-53A2SL62.js +218 -0
- package/dist/chunks/chunk-54IA2P2Z.mjs +40 -0
- package/dist/chunks/chunk-5I2VRWWU.js +172 -0
- package/dist/chunks/chunk-5TBXVD56.js +88 -0
- package/dist/chunks/chunk-6DZVNFVY.js +82 -0
- package/dist/chunks/chunk-6FHK6CBR.js +117 -0
- package/dist/chunks/chunk-6H7V2I3X.mjs +270 -0
- package/dist/chunks/chunk-6MRM5K2N.js +106 -0
- package/dist/chunks/chunk-6NTASYZO.js +132 -0
- package/dist/chunks/chunk-76CY4STF.js +165 -0
- package/dist/chunks/chunk-76K6KXCT.js +100 -0
- package/dist/chunks/chunk-7MT3QYE6.js +92 -0
- package/dist/chunks/chunk-7OEK2KX3.mjs +81 -0
- package/dist/chunks/chunk-AKIBUO5A.mjs +83 -0
- package/dist/chunks/chunk-AOVU67NI.mjs +139 -0
- package/dist/chunks/chunk-AOXXE5UQ.mjs +14 -0
- package/dist/chunks/chunk-AWBGWBFS.js +135 -0
- package/dist/chunks/chunk-AZ2URLDD.js +39 -0
- package/dist/chunks/chunk-BEA727LO.mjs +108 -0
- package/dist/chunks/chunk-C3E7CSKG.mjs +115 -0
- package/dist/chunks/chunk-C6H2UNOX.js +83 -0
- package/dist/chunks/chunk-CVYXRSXT.mjs +8 -0
- package/dist/chunks/chunk-EIOP4DOE.mjs +292 -0
- package/dist/chunks/chunk-FA2OPP3U.mjs +140 -0
- package/dist/chunks/chunk-FHPHDK3O.mjs +89 -0
- package/dist/chunks/chunk-FKHW7QYG.js +725 -0
- package/dist/chunks/chunk-FKZI2HTI.js +104 -0
- package/dist/chunks/chunk-G4XJG7XI.js +66 -0
- package/dist/chunks/chunk-GMIGQ5VP.mjs +86 -0
- package/dist/chunks/chunk-GSLIY6WW.js +109 -0
- package/dist/chunks/chunk-HHXDOKXY.js +108 -0
- package/dist/chunks/chunk-HUPAHDJ7.js +273 -0
- package/dist/chunks/chunk-I252NERB.mjs +21 -0
- package/dist/chunks/chunk-I7YJB2F5.js +143 -0
- package/dist/chunks/chunk-IB5UCYQY.mjs +66 -0
- package/dist/chunks/chunk-IJG7J2VU.mjs +148 -0
- package/dist/chunks/chunk-INP2AH3B.js +27 -0
- package/dist/chunks/chunk-IUNNTSD2.mjs +195 -0
- package/dist/chunks/chunk-JNMCYWGY.js +10 -0
- package/dist/chunks/chunk-JZ3PWHKS.mjs +51 -0
- package/dist/chunks/chunk-KWPIEHD2.mjs +78 -0
- package/dist/chunks/chunk-LBKBCI2K.mjs +44 -0
- package/dist/chunks/chunk-LVTD2UQN.mjs +48 -0
- package/dist/chunks/chunk-MPKRXMCJ.js +93 -0
- package/dist/chunks/chunk-NCQDOPBR.mjs +86 -0
- package/dist/chunks/chunk-NHDGKOAM.js +104 -0
- package/dist/chunks/chunk-OTGS6BDQ.mjs +25 -0
- package/dist/chunks/chunk-Q2TMXHPK.js +178 -0
- package/dist/chunks/chunk-Q7GQVAYY.js +88 -0
- package/dist/chunks/chunk-Q7H6LCNN.js +169 -0
- package/dist/chunks/chunk-QJNQCLMV.js +25 -0
- package/dist/chunks/chunk-QK6NCII4.js +36 -0
- package/dist/chunks/chunk-RLP3U52D.mjs +153 -0
- package/dist/chunks/chunk-T2IY2TSR.js +43 -0
- package/dist/chunks/chunk-TLTEUIBY.js +112 -0
- package/dist/chunks/chunk-TPBKQ3WC.js +303 -0
- package/dist/chunks/chunk-TR5JBBEA.mjs +116 -0
- package/dist/chunks/chunk-TWHDXCKR.js +61 -0
- package/dist/chunks/chunk-U56AGSLE.mjs +106 -0
- package/dist/chunks/chunk-U6KOUYWX.mjs +66 -0
- package/dist/chunks/chunk-U76LT5GE.js +70 -0
- package/dist/chunks/chunk-UDQXLI5Y.mjs +81 -0
- package/dist/chunks/chunk-UH667FUK.mjs +712 -0
- package/dist/chunks/chunk-UR6JOKVB.mjs +65 -0
- package/dist/chunks/chunk-VH5FF6DZ.mjs +38 -0
- package/dist/chunks/chunk-WJ2OVQD3.mjs +105 -0
- package/dist/chunks/chunk-WNFJ4NJN.mjs +55 -0
- package/dist/chunks/chunk-WSWD5ZUJ.js +106 -0
- package/dist/chunks/chunk-XALPBGSC.mjs +23 -0
- package/dist/chunks/chunk-XEHFB62A.js +82 -0
- package/dist/chunks/chunk-YEGPB7A7.js +83 -0
- package/dist/chunks/chunk-YEWKPWK3.mjs +80 -0
- package/dist/chunks/chunk-Z7OKV6NW.mjs +59 -0
- package/dist/chunks/chunk-ZCMKIB5U.js +140 -0
- package/dist/client-only.d.mts +13 -0
- package/dist/client-only.d.ts +13 -0
- package/dist/client-only.js +11 -0
- package/dist/client-only.mjs +2 -0
- package/dist/countdown.d.mts +27 -0
- package/dist/countdown.d.ts +27 -0
- package/dist/countdown.js +16 -0
- package/dist/countdown.mjs +3 -0
- package/dist/counter.d.mts +15 -0
- package/dist/counter.d.ts +15 -0
- package/dist/counter.js +11 -0
- package/dist/counter.mjs +2 -0
- package/dist/divider.d.mts +14 -0
- package/dist/divider.d.ts +14 -0
- package/dist/divider.js +16 -0
- package/dist/divider.mjs +3 -0
- package/dist/drawer.d.mts +42 -0
- package/dist/drawer.d.ts +42 -0
- package/dist/drawer.js +44 -0
- package/dist/drawer.mjs +3 -0
- package/dist/ellipsis.d.mts +16 -0
- package/dist/ellipsis.d.ts +16 -0
- package/dist/ellipsis.js +12 -0
- package/dist/ellipsis.mjs +3 -0
- package/dist/error-boundary.d.mts +20 -0
- package/dist/error-boundary.d.ts +20 -0
- package/dist/error-boundary.js +11 -0
- package/dist/error-boundary.mjs +2 -0
- package/dist/hooks/useCheckDevice.d.mts +47 -0
- package/dist/hooks/useCheckDevice.d.ts +47 -0
- package/dist/hooks/useCheckDevice.js +8 -0
- package/dist/hooks/useCheckDevice.mjs +2 -0
- package/dist/hooks/useClickOutside.d.mts +12 -0
- package/dist/hooks/useClickOutside.d.ts +12 -0
- package/dist/hooks/useClickOutside.js +8 -0
- package/dist/hooks/useClickOutside.mjs +2 -0
- package/dist/hooks/useDraggableBottomSheet.d.mts +24 -0
- package/dist/hooks/useDraggableBottomSheet.d.ts +24 -0
- package/dist/hooks/useDraggableBottomSheet.js +11 -0
- package/dist/hooks/useDraggableBottomSheet.mjs +2 -0
- package/dist/hooks/useDraggableWindow.d.mts +21 -0
- package/dist/hooks/useDraggableWindow.d.ts +21 -0
- package/dist/hooks/useDraggableWindow.js +11 -0
- package/dist/hooks/useDraggableWindow.mjs +2 -0
- package/dist/hooks/useInView.d.mts +14 -0
- package/dist/hooks/useInView.d.ts +14 -0
- package/dist/hooks/useInView.js +17 -0
- package/dist/hooks/useInView.mjs +2 -0
- package/dist/hooks/useModal.d.mts +2 -0
- package/dist/hooks/useModal.d.ts +2 -0
- package/dist/hooks/useModal.js +11 -0
- package/dist/hooks/useModal.mjs +2 -0
- package/dist/index.d.mts +74 -0
- package/dist/index.d.ts +74 -0
- package/dist/index.js +633 -0
- package/dist/index.mjs +227 -0
- package/dist/infinite-scroll.d.mts +26 -0
- package/dist/infinite-scroll.d.ts +26 -0
- package/dist/infinite-scroll.js +12 -0
- package/dist/infinite-scroll.mjs +3 -0
- package/dist/marquee.d.mts +12 -0
- package/dist/marquee.d.ts +12 -0
- package/dist/marquee.js +12 -0
- package/dist/marquee.mjs +3 -0
- package/dist/modal/index.d.mts +87 -0
- package/dist/modal/index.d.ts +87 -0
- package/dist/modal/index.js +54 -0
- package/dist/modal/index.mjs +9 -0
- package/dist/number-input.d.mts +21 -0
- package/dist/number-input.d.ts +21 -0
- package/dist/number-input.js +16 -0
- package/dist/number-input.mjs +3 -0
- package/dist/pagination.d.mts +21 -0
- package/dist/pagination.d.ts +21 -0
- package/dist/pagination.js +20 -0
- package/dist/pagination.mjs +3 -0
- package/dist/popover.d.mts +25 -0
- package/dist/popover.d.ts +25 -0
- package/dist/popover.js +32 -0
- package/dist/popover.mjs +3 -0
- package/dist/radio-group.d.mts +29 -0
- package/dist/radio-group.d.ts +29 -0
- package/dist/radio-group.js +24 -0
- package/dist/radio-group.mjs +3 -0
- package/dist/select.d.mts +31 -0
- package/dist/select.d.ts +31 -0
- package/dist/select.js +24 -0
- package/dist/select.mjs +3 -0
- package/dist/spinner.d.mts +9 -0
- package/dist/spinner.d.ts +9 -0
- package/dist/spinner.js +12 -0
- package/dist/spinner.mjs +3 -0
- package/dist/styles.css +2 -0
- package/dist/styles.d.mts +3 -0
- package/dist/styles.d.ts +3 -0
- package/dist/styles.js +19 -0
- package/dist/styles.mjs +17 -0
- package/dist/switch.d.mts +15 -0
- package/dist/switch.d.ts +15 -0
- package/dist/switch.js +16 -0
- package/dist/switch.mjs +3 -0
- package/dist/tab.d.mts +36 -0
- package/dist/tab.d.ts +36 -0
- package/dist/tab.js +20 -0
- package/dist/tab.mjs +3 -0
- package/dist/table.d.mts +80 -0
- package/dist/table.d.ts +80 -0
- package/dist/table.js +32 -0
- package/dist/table.mjs +3 -0
- package/dist/text-area.d.mts +15 -0
- package/dist/text-area.d.ts +15 -0
- package/dist/text-area.js +16 -0
- package/dist/text-area.mjs +3 -0
- package/dist/text-input.d.mts +17 -0
- package/dist/text-input.d.ts +17 -0
- package/dist/text-input.js +16 -0
- package/dist/text-input.mjs +3 -0
- package/dist/theme-provider.d.mts +25 -0
- package/dist/theme-provider.d.ts +25 -0
- package/dist/theme-provider.js +15 -0
- package/dist/theme-provider.mjs +2 -0
- package/dist/toast.d.mts +42 -0
- package/dist/toast.d.ts +42 -0
- package/dist/toast.js +20 -0
- package/dist/toast.mjs +3 -0
- package/dist/tooltip.d.mts +24 -0
- package/dist/tooltip.d.ts +24 -0
- package/dist/tooltip.js +20 -0
- package/dist/tooltip.mjs +3 -0
- package/dist/typography.d.mts +19 -0
- package/dist/typography.d.ts +19 -0
- package/dist/typography.js +102 -0
- package/dist/typography.mjs +79 -0
- package/dist/useModal-BsGIcP8t.d.mts +128 -0
- package/dist/useModal-BsGIcP8t.d.ts +128 -0
- package/dist/utils/cn.d.mts +15 -0
- package/dist/utils/cn.d.ts +15 -0
- package/dist/utils/cn.js +11 -0
- package/dist/utils/cn.mjs +2 -0
- package/dist/utils/scroll.d.mts +4 -0
- package/dist/utils/scroll.d.ts +4 -0
- package/dist/utils/scroll.js +15 -0
- package/dist/utils/scroll.mjs +2 -0
- package/dist/virtual-scroll.d.mts +34 -0
- package/dist/virtual-scroll.d.ts +34 -0
- package/dist/virtual-scroll.js +16 -0
- package/dist/virtual-scroll.mjs +3 -0
- package/package.json +271 -0
- package/scripts/setup-cursor-rules.cjs +92 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { cn } from './chunk-XALPBGSC.mjs';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { cva } from 'class-variance-authority';
|
|
4
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
var textAreaVariants = cva(
|
|
7
|
+
[
|
|
8
|
+
"nx:w-full nx:rounded-md nx:border nx:bg-surface-default nx:px-3 nx:py-2 nx:text-sm nx:text-text-primary",
|
|
9
|
+
"nx:transition-colors nx:duration-200 nx:resize-none",
|
|
10
|
+
"nx:placeholder:text-text-tertiary",
|
|
11
|
+
"nx:disabled:cursor-not-allowed nx:disabled:opacity-50"
|
|
12
|
+
],
|
|
13
|
+
{
|
|
14
|
+
variants: {
|
|
15
|
+
state: {
|
|
16
|
+
default: "nx:border-border-default nx:focus:border-text-primary",
|
|
17
|
+
error: "nx:border-status-negative nx:focus:border-status-negative"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
defaultVariants: { state: "default" }
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
var TextArea = React.forwardRef(
|
|
24
|
+
({ className, error, showCount, maxLength, onValueChange, onChange, ...props }, ref) => {
|
|
25
|
+
const state = error ? "error" : "default";
|
|
26
|
+
const [count, setCount] = React.useState(0);
|
|
27
|
+
const handleChange = React.useCallback(
|
|
28
|
+
(e) => {
|
|
29
|
+
setCount(e.target.value.length);
|
|
30
|
+
onValueChange?.(e.target.value);
|
|
31
|
+
onChange?.(e);
|
|
32
|
+
},
|
|
33
|
+
[onValueChange, onChange]
|
|
34
|
+
);
|
|
35
|
+
return /* @__PURE__ */ jsxs("div", { className: "nx:flex nx:flex-col", children: [
|
|
36
|
+
/* @__PURE__ */ jsx(
|
|
37
|
+
"textarea",
|
|
38
|
+
{
|
|
39
|
+
ref,
|
|
40
|
+
className: cn(textAreaVariants({ state }), className),
|
|
41
|
+
maxLength,
|
|
42
|
+
"aria-invalid": error || void 0,
|
|
43
|
+
onChange: handleChange,
|
|
44
|
+
...props
|
|
45
|
+
}
|
|
46
|
+
),
|
|
47
|
+
showCount && maxLength && /* @__PURE__ */ jsxs(
|
|
48
|
+
"p",
|
|
49
|
+
{
|
|
50
|
+
className: "nx:mt-1 nx:text-right nx:text-xs nx:text-text-tertiary",
|
|
51
|
+
"aria-live": "polite",
|
|
52
|
+
"aria-atomic": "true",
|
|
53
|
+
children: [
|
|
54
|
+
/* @__PURE__ */ jsx("span", { className: "nx:text-text-primary nx:font-medium", children: count.toLocaleString() }),
|
|
55
|
+
"/",
|
|
56
|
+
maxLength.toLocaleString()
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
)
|
|
60
|
+
] });
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
TextArea.displayName = "TextArea";
|
|
64
|
+
|
|
65
|
+
export { TextArea, textAreaVariants };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { cn } from './chunk-XALPBGSC.mjs';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { cva } from 'class-variance-authority';
|
|
4
|
+
import { jsx } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
var dividerVariants = cva("nx:shrink-0 nx:border-border-default", {
|
|
7
|
+
variants: {
|
|
8
|
+
orientation: {
|
|
9
|
+
horizontal: "nx:w-full nx:border-t",
|
|
10
|
+
vertical: "nx:self-stretch nx:border-l"
|
|
11
|
+
},
|
|
12
|
+
variant: {
|
|
13
|
+
solid: "nx:border-solid",
|
|
14
|
+
dashed: "nx:border-dashed",
|
|
15
|
+
dotted: "nx:border-dotted"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
defaultVariants: {
|
|
19
|
+
orientation: "horizontal",
|
|
20
|
+
variant: "solid"
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
var Divider = React.forwardRef(
|
|
24
|
+
({ className, orientation, variant, color, style, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
25
|
+
"div",
|
|
26
|
+
{
|
|
27
|
+
ref,
|
|
28
|
+
role: "separator",
|
|
29
|
+
"aria-orientation": orientation ?? "horizontal",
|
|
30
|
+
className: cn(dividerVariants({ orientation, variant }), className),
|
|
31
|
+
style: { ...style, ...color ? { borderColor: color } : {} },
|
|
32
|
+
...props
|
|
33
|
+
}
|
|
34
|
+
)
|
|
35
|
+
);
|
|
36
|
+
Divider.displayName = "Divider";
|
|
37
|
+
|
|
38
|
+
export { Divider, dividerVariants };
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { cn } from './chunk-XALPBGSC.mjs';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { Drawer as Drawer$1 } from 'vaul';
|
|
4
|
+
import { cva } from 'class-variance-authority';
|
|
5
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
var DrawerDirectionCtx = React.createContext("bottom");
|
|
8
|
+
var drawerOverlayVariants = cva("nx:fixed nx:inset-0 nx:z-50 nx:bg-static-black/60", {
|
|
9
|
+
variants: {
|
|
10
|
+
blur: {
|
|
11
|
+
none: "",
|
|
12
|
+
sm: "nx:backdrop-blur-sm",
|
|
13
|
+
md: "nx:backdrop-blur-md"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
defaultVariants: { blur: "none" }
|
|
17
|
+
});
|
|
18
|
+
var drawerContentVariants = cva(
|
|
19
|
+
"nx:fixed nx:z-50 nx:flex nx:flex-col nx:bg-surface-default",
|
|
20
|
+
{
|
|
21
|
+
variants: {
|
|
22
|
+
direction: {
|
|
23
|
+
bottom: "nx:inset-x-0 nx:bottom-0 nx:mt-24 nx:rounded-t-2xl nx:border-t nx:border-border-default",
|
|
24
|
+
top: "nx:inset-x-0 nx:top-0 nx:mb-24 nx:rounded-b-2xl nx:border-b nx:border-border-default",
|
|
25
|
+
left: "nx:inset-y-0 nx:left-0 nx:mr-24 nx:w-[85vw] nx:max-w-sm nx:rounded-r-2xl nx:border-r nx:border-border-default",
|
|
26
|
+
right: "nx:inset-y-0 nx:right-0 nx:ml-24 nx:w-[85vw] nx:max-w-sm nx:rounded-l-2xl nx:border-l nx:border-border-default"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
defaultVariants: { direction: "bottom" }
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
var DrawerRoot = ({ direction = "bottom", ...props }) => /* @__PURE__ */ jsx(DrawerDirectionCtx.Provider, { value: direction, children: /* @__PURE__ */ jsx(Drawer$1.Root, { shouldScaleBackground: false, direction, ...props }) });
|
|
33
|
+
var DrawerTrigger = (props) => /* @__PURE__ */ jsx(Drawer$1.Trigger, { ...props });
|
|
34
|
+
DrawerTrigger.displayName = "DrawerTrigger";
|
|
35
|
+
var DrawerContent = React.forwardRef(
|
|
36
|
+
({
|
|
37
|
+
className,
|
|
38
|
+
children,
|
|
39
|
+
direction: directionProp,
|
|
40
|
+
showHandle = true,
|
|
41
|
+
blur,
|
|
42
|
+
overlayClassName,
|
|
43
|
+
...props
|
|
44
|
+
}, ref) => {
|
|
45
|
+
const ctxDirection = React.useContext(DrawerDirectionCtx);
|
|
46
|
+
const direction = directionProp ?? ctxDirection;
|
|
47
|
+
return /* @__PURE__ */ jsxs(Drawer$1.Portal, { children: [
|
|
48
|
+
/* @__PURE__ */ jsx(
|
|
49
|
+
Drawer$1.Overlay,
|
|
50
|
+
{
|
|
51
|
+
className: cn(drawerOverlayVariants({ blur }), overlayClassName)
|
|
52
|
+
}
|
|
53
|
+
),
|
|
54
|
+
/* @__PURE__ */ jsxs(
|
|
55
|
+
Drawer$1.Content,
|
|
56
|
+
{
|
|
57
|
+
ref,
|
|
58
|
+
className: cn(drawerContentVariants({ direction }), className),
|
|
59
|
+
...props,
|
|
60
|
+
children: [
|
|
61
|
+
showHandle && (direction === "bottom" || direction === "top") && /* @__PURE__ */ jsx(
|
|
62
|
+
"div",
|
|
63
|
+
{
|
|
64
|
+
className: cn(
|
|
65
|
+
"nx:flex nx:justify-center",
|
|
66
|
+
direction === "bottom" ? "nx:pt-4" : "nx:pb-4"
|
|
67
|
+
),
|
|
68
|
+
children: /* @__PURE__ */ jsx("div", { className: "nx:bg-border-strong nx:h-1.5 nx:w-12 nx:rounded-full" })
|
|
69
|
+
}
|
|
70
|
+
),
|
|
71
|
+
children
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
)
|
|
75
|
+
] });
|
|
76
|
+
}
|
|
77
|
+
);
|
|
78
|
+
DrawerContent.displayName = "DrawerContent";
|
|
79
|
+
var DrawerClose = (props) => /* @__PURE__ */ jsx(Drawer$1.Close, { ...props });
|
|
80
|
+
DrawerClose.displayName = "DrawerClose";
|
|
81
|
+
var DrawerTitle = ({ className, ...props }) => /* @__PURE__ */ jsx(
|
|
82
|
+
Drawer$1.Title,
|
|
83
|
+
{
|
|
84
|
+
className: cn("nx:text-lg nx:font-semibold nx:text-text-primary", className),
|
|
85
|
+
...props
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
DrawerTitle.displayName = "DrawerTitle";
|
|
89
|
+
var DrawerDescription = ({ className, ...props }) => /* @__PURE__ */ jsx(
|
|
90
|
+
Drawer$1.Description,
|
|
91
|
+
{
|
|
92
|
+
className: cn("nx:text-sm nx:text-text-secondary", className),
|
|
93
|
+
...props
|
|
94
|
+
}
|
|
95
|
+
);
|
|
96
|
+
DrawerDescription.displayName = "DrawerDescription";
|
|
97
|
+
var Drawer = Object.assign(DrawerRoot, {
|
|
98
|
+
Trigger: DrawerTrigger,
|
|
99
|
+
Content: DrawerContent,
|
|
100
|
+
Close: DrawerClose,
|
|
101
|
+
Title: DrawerTitle,
|
|
102
|
+
Description: DrawerDescription
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
export { Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerRoot, DrawerTitle, DrawerTrigger, drawerContentVariants, drawerOverlayVariants };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { cn } from './chunk-XALPBGSC.mjs';
|
|
2
|
+
import * as PopoverPrimitive from '@radix-ui/react-popover';
|
|
3
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
var popoverContentClasses = [
|
|
6
|
+
"nx:z-50 nx:rounded-lg nx:border nx:p-4 nx:shadow-lg nx:outline-none",
|
|
7
|
+
"nx:bg-surface-default nx:border-border-default nx:text-text-primary",
|
|
8
|
+
"nx:data-[state=open]:animate-in nx:data-[state=closed]:animate-out",
|
|
9
|
+
"nx:data-[state=closed]:fade-out-0 nx:data-[state=open]:fade-in-0",
|
|
10
|
+
"nx:data-[state=closed]:zoom-out-95 nx:data-[state=open]:zoom-in-95",
|
|
11
|
+
"nx:data-[side=bottom]:slide-in-from-top-2 nx:data-[side=left]:slide-in-from-right-2",
|
|
12
|
+
"nx:data-[side=right]:slide-in-from-left-2 nx:data-[side=top]:slide-in-from-bottom-2"
|
|
13
|
+
].join(" ");
|
|
14
|
+
var Popover = ({
|
|
15
|
+
children,
|
|
16
|
+
trigger,
|
|
17
|
+
align = "center",
|
|
18
|
+
side = "bottom",
|
|
19
|
+
sideOffset = 4,
|
|
20
|
+
alignOffset,
|
|
21
|
+
open,
|
|
22
|
+
onOpenChange,
|
|
23
|
+
className = "",
|
|
24
|
+
arrowClassName,
|
|
25
|
+
onClickTrigger
|
|
26
|
+
}) => {
|
|
27
|
+
return /* @__PURE__ */ jsxs(PopoverPrimitive.Root, { open, onOpenChange, children: [
|
|
28
|
+
/* @__PURE__ */ jsx(PopoverPrimitive.Trigger, { asChild: true, onClick: onClickTrigger, children: trigger }),
|
|
29
|
+
/* @__PURE__ */ jsx(PopoverPrimitive.Portal, { children: /* @__PURE__ */ jsxs(
|
|
30
|
+
PopoverPrimitive.Content,
|
|
31
|
+
{
|
|
32
|
+
align,
|
|
33
|
+
alignOffset,
|
|
34
|
+
side,
|
|
35
|
+
sideOffset,
|
|
36
|
+
className: cn(popoverContentClasses, className),
|
|
37
|
+
children: [
|
|
38
|
+
children,
|
|
39
|
+
/* @__PURE__ */ jsx(
|
|
40
|
+
PopoverPrimitive.Arrow,
|
|
41
|
+
{
|
|
42
|
+
className: cn("nx:fill-surface-default", arrowClassName)
|
|
43
|
+
}
|
|
44
|
+
)
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
) })
|
|
48
|
+
] });
|
|
49
|
+
};
|
|
50
|
+
var PopoverTrigger = PopoverPrimitive.Trigger;
|
|
51
|
+
var PopoverContent = PopoverPrimitive.Content;
|
|
52
|
+
var PopoverArrow = PopoverPrimitive.Arrow;
|
|
53
|
+
var PopoverClose = PopoverPrimitive.Close;
|
|
54
|
+
|
|
55
|
+
export { Popover, PopoverArrow, PopoverClose, PopoverContent, PopoverTrigger, popoverContentClasses };
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkQJNQCLMV_js = require('./chunk-QJNQCLMV.js');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var reactSlot = require('@radix-ui/react-slot');
|
|
6
|
+
var classVarianceAuthority = require('class-variance-authority');
|
|
7
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
8
|
+
|
|
9
|
+
function _interopNamespace(e) {
|
|
10
|
+
if (e && e.__esModule) return e;
|
|
11
|
+
var n = Object.create(null);
|
|
12
|
+
if (e) {
|
|
13
|
+
Object.keys(e).forEach(function (k) {
|
|
14
|
+
if (k !== 'default') {
|
|
15
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
16
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return e[k]; }
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
n.default = e;
|
|
24
|
+
return Object.freeze(n);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
28
|
+
|
|
29
|
+
var chipVariants = classVarianceAuthority.cva(
|
|
30
|
+
[
|
|
31
|
+
"nx:inline-flex nx:items-center nx:gap-1.5 nx:whitespace-nowrap nx:font-medium nx:transition-colors",
|
|
32
|
+
"nx:select-none nx:rounded-full nx:border",
|
|
33
|
+
"nx:aria-disabled:opacity-50 nx:aria-disabled:pointer-events-none"
|
|
34
|
+
],
|
|
35
|
+
{
|
|
36
|
+
variants: {
|
|
37
|
+
variant: {
|
|
38
|
+
default: "nx:border-border-default nx:bg-surface-default nx:text-text-primary",
|
|
39
|
+
filled: "nx:border-transparent nx:bg-surface-hover nx:text-text-primary",
|
|
40
|
+
outline: "nx:border-border-default nx:bg-transparent nx:text-text-primary",
|
|
41
|
+
accent: "nx:border-transparent nx:bg-accent-primary/10 nx:text-accent-primary"
|
|
42
|
+
},
|
|
43
|
+
size: {
|
|
44
|
+
sm: "nx:h-6 nx:px-2 nx:text-xs",
|
|
45
|
+
md: "nx:h-7 nx:px-2.5 nx:text-xs",
|
|
46
|
+
lg: "nx:h-8 nx:px-3 nx:text-sm"
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
defaultVariants: {
|
|
50
|
+
variant: "default",
|
|
51
|
+
size: "md"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
);
|
|
55
|
+
var CloseIcon = ({ className }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
56
|
+
"svg",
|
|
57
|
+
{
|
|
58
|
+
className,
|
|
59
|
+
viewBox: "0 0 16 16",
|
|
60
|
+
fill: "none",
|
|
61
|
+
stroke: "currentColor",
|
|
62
|
+
strokeWidth: "2",
|
|
63
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M4 4l8 8M12 4l-8 8", strokeLinecap: "round" })
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
var Chip = React__namespace.forwardRef(
|
|
67
|
+
({
|
|
68
|
+
className,
|
|
69
|
+
variant,
|
|
70
|
+
size,
|
|
71
|
+
asChild = false,
|
|
72
|
+
disabled,
|
|
73
|
+
children,
|
|
74
|
+
onClose,
|
|
75
|
+
...props
|
|
76
|
+
}, ref) => {
|
|
77
|
+
const Comp = asChild ? reactSlot.Slot : "div";
|
|
78
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
79
|
+
Comp,
|
|
80
|
+
{
|
|
81
|
+
ref,
|
|
82
|
+
className: chunkQJNQCLMV_js.cn(chipVariants({ variant, size }), className),
|
|
83
|
+
"aria-disabled": disabled || void 0,
|
|
84
|
+
...props,
|
|
85
|
+
children: [
|
|
86
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children }),
|
|
87
|
+
onClose && /* @__PURE__ */ jsxRuntime.jsx(
|
|
88
|
+
"button",
|
|
89
|
+
{
|
|
90
|
+
type: "button",
|
|
91
|
+
className: "nx:inline-flex nx:shrink-0 nx:items-center nx:justify-center nx:rounded-full nx:p-0.5 nx:opacity-60 nx:hover:opacity-100 nx:transition-opacity",
|
|
92
|
+
onClick: disabled ? void 0 : onClose,
|
|
93
|
+
disabled,
|
|
94
|
+
"aria-label": "Remove",
|
|
95
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(CloseIcon, { className: "nx:size-3" })
|
|
96
|
+
}
|
|
97
|
+
)
|
|
98
|
+
]
|
|
99
|
+
}
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
);
|
|
103
|
+
Chip.displayName = "Chip";
|
|
104
|
+
|
|
105
|
+
exports.Chip = Chip;
|
|
106
|
+
exports.chipVariants = chipVariants;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { clsx } from 'clsx';
|
|
2
|
+
import { extendTailwindMerge } from 'tailwind-merge';
|
|
3
|
+
|
|
4
|
+
// src/utils/cn.ts
|
|
5
|
+
var PREFIX = "nx:";
|
|
6
|
+
var twMerge = extendTailwindMerge({ prefix: "nx" });
|
|
7
|
+
function cn(...inputs) {
|
|
8
|
+
const flat = clsx(inputs);
|
|
9
|
+
const tokens = flat.split(/\s+/).filter(Boolean);
|
|
10
|
+
const nxTokens = [];
|
|
11
|
+
const plainTokens = [];
|
|
12
|
+
for (const t of tokens) {
|
|
13
|
+
(t.startsWith(PREFIX) ? nxTokens : plainTokens).push(t);
|
|
14
|
+
}
|
|
15
|
+
if (plainTokens.length === 0) return twMerge(flat);
|
|
16
|
+
if (nxTokens.length === 0) return flat;
|
|
17
|
+
const prefixed = plainTokens.map((t) => `${PREFIX}${t}`);
|
|
18
|
+
const prefixedSet = new Set(prefixed);
|
|
19
|
+
const merged = twMerge([...nxTokens, ...prefixed].join(" "));
|
|
20
|
+
return merged.split(/\s+/).filter(Boolean).map((cls) => prefixedSet.has(cls) ? cls.slice(PREFIX.length) : cls).join(" ");
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { cn };
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('react');
|
|
4
|
+
|
|
5
|
+
// src/hooks/useCheckDevice.ts
|
|
6
|
+
function getMatchMedia(query) {
|
|
7
|
+
if (typeof window === "undefined") return false;
|
|
8
|
+
return window.matchMedia(query).matches;
|
|
9
|
+
}
|
|
10
|
+
var DEFAULT_BREAKPOINTS = {
|
|
11
|
+
mobile: 0,
|
|
12
|
+
tablet: 768,
|
|
13
|
+
desktop: 1280
|
|
14
|
+
};
|
|
15
|
+
function buildQueries(bp) {
|
|
16
|
+
const sorted = Object.entries(bp).sort(([, a], [, b]) => a - b);
|
|
17
|
+
const queries = {};
|
|
18
|
+
sorted.forEach(([name, minWidth], i) => {
|
|
19
|
+
const next = sorted[i + 1];
|
|
20
|
+
if (minWidth === 0 && next) {
|
|
21
|
+
queries[name] = `(max-width: ${next[1] - 1}px)`;
|
|
22
|
+
} else if (!next) {
|
|
23
|
+
queries[name] = `(min-width: ${minWidth}px)`;
|
|
24
|
+
} else {
|
|
25
|
+
queries[name] = `(min-width: ${minWidth}px) and (max-width: ${next[1] - 1}px)`;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
return queries;
|
|
29
|
+
}
|
|
30
|
+
function isLegacy(bp) {
|
|
31
|
+
if (!bp || typeof bp !== "object") return false;
|
|
32
|
+
return Object.values(bp).some((v) => typeof v === "string");
|
|
33
|
+
}
|
|
34
|
+
function toLegacyQueries(bp) {
|
|
35
|
+
return {
|
|
36
|
+
isDesktop: bp?.isDesktop ?? "(min-width: 1280px)",
|
|
37
|
+
isTablet: bp?.isTablet ?? "screen and (min-width: 768px) and (max-width: 1279px)",
|
|
38
|
+
isMobile: bp?.isMobile ?? "(max-width: 767px)"
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function useCheckDevice(breakPoints) {
|
|
42
|
+
const serialized = breakPoints ? JSON.stringify(breakPoints) : "";
|
|
43
|
+
const queries = react.useMemo(() => {
|
|
44
|
+
if (!breakPoints) return buildQueries(DEFAULT_BREAKPOINTS);
|
|
45
|
+
if (isLegacy(breakPoints)) return toLegacyQueries(breakPoints);
|
|
46
|
+
return buildQueries(breakPoints);
|
|
47
|
+
}, [serialized]);
|
|
48
|
+
const [result, setResult] = react.useState(() => {
|
|
49
|
+
const init = {};
|
|
50
|
+
for (const [key, query] of Object.entries(queries)) {
|
|
51
|
+
init[key] = getMatchMedia(query);
|
|
52
|
+
}
|
|
53
|
+
return init;
|
|
54
|
+
});
|
|
55
|
+
react.useEffect(() => {
|
|
56
|
+
if (typeof window === "undefined") return;
|
|
57
|
+
const mqls = Object.entries(queries).map(([key, query]) => ({
|
|
58
|
+
key,
|
|
59
|
+
mql: window.matchMedia(query)
|
|
60
|
+
}));
|
|
61
|
+
const update = () => {
|
|
62
|
+
setResult((prev) => {
|
|
63
|
+
const next = {};
|
|
64
|
+
let changed = false;
|
|
65
|
+
for (const { key, mql } of mqls) {
|
|
66
|
+
next[key] = mql.matches;
|
|
67
|
+
if (next[key] !== prev[key]) changed = true;
|
|
68
|
+
}
|
|
69
|
+
return changed ? next : prev;
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
for (const { mql } of mqls) mql.addEventListener("change", update);
|
|
73
|
+
update();
|
|
74
|
+
return () => {
|
|
75
|
+
for (const { mql } of mqls) mql.removeEventListener("change", update);
|
|
76
|
+
};
|
|
77
|
+
}, [queries]);
|
|
78
|
+
return result;
|
|
79
|
+
}
|
|
80
|
+
var useCheckDevice_default = useCheckDevice;
|
|
81
|
+
|
|
82
|
+
exports.useCheckDevice_default = useCheckDevice_default;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkQJNQCLMV_js = require('./chunk-QJNQCLMV.js');
|
|
4
|
+
var react = require('react');
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
|
|
7
|
+
var DefaultSpinner = () => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "nx:flex nx:items-center nx:justify-center nx:py-4", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "nx:h-6 nx:w-6 nx:animate-spin nx:rounded-full nx:border-2 nx:border-border-default nx:border-t-accent-primary" }) });
|
|
8
|
+
var InfiniteScroll = ({
|
|
9
|
+
className = "",
|
|
10
|
+
tag = "div",
|
|
11
|
+
list,
|
|
12
|
+
scrollTarget = null,
|
|
13
|
+
rootMargin = 100,
|
|
14
|
+
loading,
|
|
15
|
+
loadingElement = /* @__PURE__ */ jsxRuntime.jsx(DefaultSpinner, {}),
|
|
16
|
+
children,
|
|
17
|
+
handleLoadMore,
|
|
18
|
+
...props
|
|
19
|
+
}) => {
|
|
20
|
+
const target = react.useRef(null);
|
|
21
|
+
const listRef = react.useRef(list);
|
|
22
|
+
const totalCountRef = react.useRef("totalCount" in props ? props.totalCount : void 0);
|
|
23
|
+
const hasMoreRef = react.useRef("hasMore" in props ? props.hasMore : void 0);
|
|
24
|
+
const loadingRef = react.useRef(loading);
|
|
25
|
+
const prevCount = react.useRef(-1);
|
|
26
|
+
const [count, setCount] = react.useState(0);
|
|
27
|
+
const io = react.useMemo(() => {
|
|
28
|
+
if (typeof window === "undefined") return null;
|
|
29
|
+
return new IntersectionObserver(
|
|
30
|
+
(entries, observer) => {
|
|
31
|
+
if (!target.current) return;
|
|
32
|
+
if (entries[0].intersectionRatio > 0.2) {
|
|
33
|
+
if (!loadingRef.current) {
|
|
34
|
+
setCount((v) => v + 1);
|
|
35
|
+
observer.disconnect();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
root: !scrollTarget ? null : "current" in scrollTarget ? scrollTarget.current : scrollTarget,
|
|
41
|
+
rootMargin: `${rootMargin}px 0px`,
|
|
42
|
+
threshold: [0.1, 0.2, 0.5, 0.8, 0.9, 1]
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
}, [rootMargin, scrollTarget]);
|
|
46
|
+
const hasNext = react.useCallback(() => {
|
|
47
|
+
if (!listRef.current || loadingRef.current) return false;
|
|
48
|
+
if (typeof totalCountRef.current !== "undefined") {
|
|
49
|
+
return totalCountRef.current > listRef.current.length;
|
|
50
|
+
}
|
|
51
|
+
return !!hasMoreRef.current;
|
|
52
|
+
}, []);
|
|
53
|
+
react.useEffect(() => {
|
|
54
|
+
if (count > 0 && prevCount.current < count && (listRef.current ?? []).length && hasNext()) {
|
|
55
|
+
prevCount.current = count;
|
|
56
|
+
handleLoadMore();
|
|
57
|
+
}
|
|
58
|
+
}, [count, hasNext, handleLoadMore]);
|
|
59
|
+
react.useEffect(() => {
|
|
60
|
+
const observeEl = target.current;
|
|
61
|
+
if (observeEl && io) io.observe(observeEl);
|
|
62
|
+
return () => {
|
|
63
|
+
if (observeEl && io) io.unobserve(observeEl);
|
|
64
|
+
};
|
|
65
|
+
}, [list, io]);
|
|
66
|
+
react.useEffect(() => {
|
|
67
|
+
if ("totalCount" in props) {
|
|
68
|
+
totalCountRef.current = props.totalCount;
|
|
69
|
+
} else {
|
|
70
|
+
hasMoreRef.current = props.hasMore;
|
|
71
|
+
}
|
|
72
|
+
listRef.current = [...list || []];
|
|
73
|
+
}, [list, props]);
|
|
74
|
+
react.useEffect(() => {
|
|
75
|
+
loadingRef.current = loading;
|
|
76
|
+
}, [loading]);
|
|
77
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunkQJNQCLMV_js.cn("nx:relative", className), children: [
|
|
78
|
+
react.createElement(tag, null, children),
|
|
79
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { ref: target, className: "nx:relative nx:h-px nx:w-full", children: loading && (list ?? []).length > 0 && loadingElement })
|
|
80
|
+
] });
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
exports.InfiniteScroll = InfiniteScroll;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { useMemo, useState, useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
// src/hooks/useCheckDevice.ts
|
|
4
|
+
function getMatchMedia(query) {
|
|
5
|
+
if (typeof window === "undefined") return false;
|
|
6
|
+
return window.matchMedia(query).matches;
|
|
7
|
+
}
|
|
8
|
+
var DEFAULT_BREAKPOINTS = {
|
|
9
|
+
mobile: 0,
|
|
10
|
+
tablet: 768,
|
|
11
|
+
desktop: 1280
|
|
12
|
+
};
|
|
13
|
+
function buildQueries(bp) {
|
|
14
|
+
const sorted = Object.entries(bp).sort(([, a], [, b]) => a - b);
|
|
15
|
+
const queries = {};
|
|
16
|
+
sorted.forEach(([name, minWidth], i) => {
|
|
17
|
+
const next = sorted[i + 1];
|
|
18
|
+
if (minWidth === 0 && next) {
|
|
19
|
+
queries[name] = `(max-width: ${next[1] - 1}px)`;
|
|
20
|
+
} else if (!next) {
|
|
21
|
+
queries[name] = `(min-width: ${minWidth}px)`;
|
|
22
|
+
} else {
|
|
23
|
+
queries[name] = `(min-width: ${minWidth}px) and (max-width: ${next[1] - 1}px)`;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
return queries;
|
|
27
|
+
}
|
|
28
|
+
function isLegacy(bp) {
|
|
29
|
+
if (!bp || typeof bp !== "object") return false;
|
|
30
|
+
return Object.values(bp).some((v) => typeof v === "string");
|
|
31
|
+
}
|
|
32
|
+
function toLegacyQueries(bp) {
|
|
33
|
+
return {
|
|
34
|
+
isDesktop: bp?.isDesktop ?? "(min-width: 1280px)",
|
|
35
|
+
isTablet: bp?.isTablet ?? "screen and (min-width: 768px) and (max-width: 1279px)",
|
|
36
|
+
isMobile: bp?.isMobile ?? "(max-width: 767px)"
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function useCheckDevice(breakPoints) {
|
|
40
|
+
const serialized = breakPoints ? JSON.stringify(breakPoints) : "";
|
|
41
|
+
const queries = useMemo(() => {
|
|
42
|
+
if (!breakPoints) return buildQueries(DEFAULT_BREAKPOINTS);
|
|
43
|
+
if (isLegacy(breakPoints)) return toLegacyQueries(breakPoints);
|
|
44
|
+
return buildQueries(breakPoints);
|
|
45
|
+
}, [serialized]);
|
|
46
|
+
const [result, setResult] = useState(() => {
|
|
47
|
+
const init = {};
|
|
48
|
+
for (const [key, query] of Object.entries(queries)) {
|
|
49
|
+
init[key] = getMatchMedia(query);
|
|
50
|
+
}
|
|
51
|
+
return init;
|
|
52
|
+
});
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
if (typeof window === "undefined") return;
|
|
55
|
+
const mqls = Object.entries(queries).map(([key, query]) => ({
|
|
56
|
+
key,
|
|
57
|
+
mql: window.matchMedia(query)
|
|
58
|
+
}));
|
|
59
|
+
const update = () => {
|
|
60
|
+
setResult((prev) => {
|
|
61
|
+
const next = {};
|
|
62
|
+
let changed = false;
|
|
63
|
+
for (const { key, mql } of mqls) {
|
|
64
|
+
next[key] = mql.matches;
|
|
65
|
+
if (next[key] !== prev[key]) changed = true;
|
|
66
|
+
}
|
|
67
|
+
return changed ? next : prev;
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
for (const { mql } of mqls) mql.addEventListener("change", update);
|
|
71
|
+
update();
|
|
72
|
+
return () => {
|
|
73
|
+
for (const { mql } of mqls) mql.removeEventListener("change", update);
|
|
74
|
+
};
|
|
75
|
+
}, [queries]);
|
|
76
|
+
return result;
|
|
77
|
+
}
|
|
78
|
+
var useCheckDevice_default = useCheckDevice;
|
|
79
|
+
|
|
80
|
+
export { useCheckDevice_default };
|