@g4rcez/components 2.0.20 → 2.0.22
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/components/display/card.js +2 -2
- package/dist/components/display/notifications.d.ts +1 -1
- package/dist/components/display/step.d.ts +2 -2
- package/dist/components/display/step.d.ts.map +1 -1
- package/dist/components/display/step.js +10 -10
- package/dist/components/display/tabs.d.ts +2 -1
- package/dist/components/display/tabs.d.ts.map +1 -1
- package/dist/components/display/tabs.js +2 -2
- package/dist/components/floating/menu.d.ts +2 -2
- package/dist/components/floating/modal.d.ts +2 -2
- package/dist/components/floating/modal.js +2 -2
- package/dist/components/floating/tooltip.js +1 -1
- package/dist/components/form/autocomplete.js +5 -3
- package/dist/components/form/date-picker.d.ts +1 -0
- package/dist/components/form/date-picker.d.ts.map +1 -1
- package/dist/components/form/date-picker.js +3 -2
- package/dist/components/index.d.ts +28 -26
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +28 -26
- package/dist/components/table/pagination.js +1 -1
- package/dist/hooks/use-form.js +2 -2
- package/dist/hooks/use-preferences.d.ts +2 -0
- package/dist/hooks/use-preferences.d.ts.map +1 -0
- package/dist/hooks/use-preferences.js +23 -0
- package/dist/index.css +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +25221 -25110
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +65 -65
- package/dist/index.umd.js.map +1 -1
- package/dist/preset/src/styles/dark.js +1 -1
- package/dist/styles/dark.js +1 -1
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@ import { Is } from "sidekicker";
|
|
|
4
4
|
import { css } from "../../lib/dom";
|
|
5
5
|
import { Polymorph } from "../core/polymorph";
|
|
6
6
|
import { Skeleton } from "./skeleton";
|
|
7
|
-
export const Card = ({ title, loading, children, as, header = null, container = "", titleClassName = "", ...props }) => (_jsxs(Polymorph, { ...props, as: as || "div", "data-component": "card", className: css("flex shadow-shadow-card flex-col gap-4 rounded-card border border-card-border bg-card-background w-full py-4
|
|
7
|
+
export const Card = ({ title, loading, children, as, header = null, container = "", titleClassName = "", ...props }) => (_jsxs(Polymorph, { ...props, as: as || "div", "data-component": "card", className: css("flex shadow-shadow-card flex-col gap-4 rounded-card border border-card-border bg-card-background w-full py-4", container), children: [title ? (_jsx("header", { "data-component": "card-title", className: css("mb-2 w-full border-b border-card-border px-6 pb-4 text-xl font-medium", titleClassName), children: title })) : (header), _jsx("div", { "data-component": "card-body", className: css("min-w-full px-6", props.className), children: loading ? (_jsxs("div", { className: "flex flex-col gap-4", children: [_jsx(Skeleton, { className: "w-full" }), _jsx(Skeleton, { className: "w-8/12" }), _jsx(Skeleton, { className: "w-10/12" }), _jsx(Skeleton, { className: "w-1/2" })] })) : children })] }));
|
|
8
8
|
Card.Title = ({ as, titleTag, navTag, children, ...props }) => {
|
|
9
9
|
const Component = (as || "div");
|
|
10
10
|
const Title = (titleTag || "h2");
|
|
@@ -14,5 +14,5 @@ Card.Title = ({ as, titleTag, navTag, children, ...props }) => {
|
|
|
14
14
|
export const StatsCard = (props) => {
|
|
15
15
|
const interactive = props.interactive ?? true;
|
|
16
16
|
const Icon = props.Icon ?? InfoIcon;
|
|
17
|
-
return (_jsx(Card, { ...props, title: null, loading: undefined, container: "px-0 py-0", className: "flex gap-4 items-center px-0
|
|
17
|
+
return (_jsx(Card, { ...props, title: null, loading: undefined, container: "px-0 py-0", className: "flex gap-4 items-center px-0", children: _jsxs("div", { className: `flex w-full items-center gap-4 rounded-card px-0 lg:px-0 ${interactive ? "transition-colors duration-300 ease-linear hover:bg-primary-hover/10" : ""}`, children: [_jsx("div", { className: css("flex aspect-square h-[stretch] w-20 items-center justify-center rounded-l-card bg-primary p-4 text-primary-foreground", props.mark), children: _jsx(Icon, { size: 48 }) }), _jsxs("div", { className: "flex flex-col gap-2 justify-center py-2", children: [_jsx("p", { className: "text-lg", children: props.title }), props.loading ? _jsx(Skeleton, { className: "h-10" }) : _jsx("p", { className: "text-4xl font-bold tracking-wide", children: props.value })] })] }) }));
|
|
18
18
|
};
|
|
@@ -2,7 +2,7 @@ import { type VariantProps } from "class-variance-authority";
|
|
|
2
2
|
import { type PropsWithChildren } from "react";
|
|
3
3
|
import { Label } from "../../types";
|
|
4
4
|
declare const variants: (props?: ({
|
|
5
|
-
theme?: "
|
|
5
|
+
theme?: "info" | "warn" | "muted" | "danger" | "success" | "secondary" | "default" | null | undefined;
|
|
6
6
|
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
7
7
|
type NotificationOptions = Partial<{
|
|
8
8
|
title: Label;
|
|
@@ -5,10 +5,10 @@ export type StepProps = React.ComponentProps<"button"> & {
|
|
|
5
5
|
currentStep: number;
|
|
6
6
|
status?: StepStatus;
|
|
7
7
|
};
|
|
8
|
-
export declare const
|
|
8
|
+
export declare const Steps: (props: PropsWithChildren<{
|
|
9
9
|
steps: number;
|
|
10
10
|
currentStep: number;
|
|
11
11
|
}>) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
-
export declare const Step: (props: StepProps) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export declare const Step: ({ step, currentStep, status, ...props }: StepProps) => import("react/jsx-runtime").JSX.Element;
|
|
13
13
|
export {};
|
|
14
14
|
//# sourceMappingURL=step.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../../../src/components/display/step.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAkB,iBAAiB,EAAa,MAAM,OAAO,CAAC;AAmC5E,KAAK,UAAU,GAAG,QAAQ,GAAG,UAAU,GAAG,UAAU,GAAG,OAAO,CAAC;AAE/D,MAAM,MAAM,SAAS,GAAG,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,UAAU,CAAA;CAAE,CAAC;AAkBpH,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../../../src/components/display/step.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAkB,iBAAiB,EAAa,MAAM,OAAO,CAAC;AAmC5E,KAAK,UAAU,GAAG,QAAQ,GAAG,UAAU,GAAG,UAAU,GAAG,OAAO,CAAC;AAE/D,MAAM,MAAM,SAAS,GAAG,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,UAAU,CAAA;CAAE,CAAC;AAkBpH,eAAO,MAAM,KAAK,GAAI,OAAO,iBAAiB,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC,4CA6BrF,CAAC;AAEF,eAAO,MAAM,IAAI,GAAI,yCAAyC,SAAS,4CAkDtE,CAAC"}
|
|
@@ -22,16 +22,16 @@ const transitions = {
|
|
|
22
22
|
type: "tween",
|
|
23
23
|
ease: "circOut",
|
|
24
24
|
};
|
|
25
|
-
const getCurrentStatus = (
|
|
26
|
-
if (
|
|
25
|
+
const getCurrentStatus = (step, currentStep, status) => {
|
|
26
|
+
if (status === "error")
|
|
27
27
|
return "error";
|
|
28
|
-
if (
|
|
28
|
+
if (currentStep === step)
|
|
29
29
|
return "active";
|
|
30
|
-
if (
|
|
30
|
+
if (currentStep < step)
|
|
31
31
|
return "inactive";
|
|
32
32
|
return "complete";
|
|
33
33
|
};
|
|
34
|
-
export const
|
|
34
|
+
export const Steps = (props) => {
|
|
35
35
|
const [ref, animate] = useAnimate();
|
|
36
36
|
useEffect(() => {
|
|
37
37
|
if (props.currentStep === 0)
|
|
@@ -48,12 +48,12 @@ export const StepsContainer = (props) => {
|
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
50
|
}, [props.currentStep]);
|
|
51
|
-
return (_jsxs("div", { className: "relative
|
|
51
|
+
return (_jsxs("div", { className: "flex relative justify-between", ref: ref, children: [_jsx("div", { className: "absolute top-1/2 h-1 w-[calc(100%)] bg-card-border" }), _jsx("div", { "data-name": "progress", className: "absolute top-1/2 w-0 h-1 transition-all duration-300 ease-out bg-success" }), props.children] }));
|
|
52
52
|
};
|
|
53
|
-
export const Step = (props) => {
|
|
53
|
+
export const Step = ({ step, currentStep, status, ...props }) => {
|
|
54
54
|
const parser = useColorParser();
|
|
55
|
-
const
|
|
56
|
-
return (_jsxs(motion.button, { ...props, type: "button", "data-step":
|
|
55
|
+
const innerStatus = getCurrentStatus(step, currentStep, status);
|
|
56
|
+
return (_jsxs(motion.button, { ...props, type: "button", "data-step": step, animate: innerStatus, className: "block relative w-auto", children: [_jsx(motion.div, { variants: variants, transition: transitions, className: `absolute inset-0 rounded-full ${innerStatus === "error" ? "bg-danger" : ""}` }), _jsx(motion.div, { initial: false, transition: { duration: 0.2 }, className: "flex relative justify-center items-center w-10 h-10 font-semibold rounded-full", variants: {
|
|
57
57
|
error: {
|
|
58
58
|
backgroundColor: parser("var(--danger-DEFAULT)"),
|
|
59
59
|
borderColor: parser("var(--danger-hover)"),
|
|
@@ -74,5 +74,5 @@ export const Step = (props) => {
|
|
|
74
74
|
borderColor: parser("var(--success-DEFAULT)"),
|
|
75
75
|
color: parser("var(--success-foreground)"),
|
|
76
76
|
},
|
|
77
|
-
},
|
|
77
|
+
}, children: _jsx("div", { className: "flex justify-center items-center", children: innerStatus === "complete" ? (_jsx(CheckIcon, { className: "w-6 h-6 text-primary-foreground" })) : innerStatus === "error" ? (_jsx(ErrorIcon, { className: "w-6 h-6 text-danger-foreground" })) : (_jsx("span", { children: step })) }) })] }));
|
|
78
78
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { PropsWithChildren } from "react";
|
|
2
2
|
import { Label } from "../../types";
|
|
3
|
-
|
|
3
|
+
import { CardProps } from "./card";
|
|
4
|
+
export type TabsProps = Omit<CardProps<"div">, "onChange"> & {
|
|
4
5
|
active: string;
|
|
5
6
|
container?: string;
|
|
6
7
|
className?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tabs.d.ts","sourceRoot":"","sources":["../../../src/components/display/tabs.tsx"],"names":[],"mappings":"AACA,OAAc,EAA2B,iBAAiB,EAAiC,MAAM,OAAO,CAAC;AAMzG,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"tabs.d.ts","sourceRoot":"","sources":["../../../src/components/display/tabs.tsx"],"names":[],"mappings":"AACA,OAAc,EAA2B,iBAAiB,EAAiC,MAAM,OAAO,CAAC;AAMzG,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,OAAO,EAAQ,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEzC,MAAM,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC,GAAG;IACzD,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC,CAAC;AAiCF,eAAO,MAAM,IAAI,GAAI,OAAO,iBAAiB,CAAC,SAAS,CAAC,4CAsFvD,CAAC;AAIF,KAAK,cAAc,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAEzD,MAAM,MAAM,QAAQ,GAAG,cAAc,GACjC,CACM;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,SAAS,CAAA;CAAE,GACpC;IACE,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;CAC9B,CACJ,CAAC;AAEN,eAAO,MAAM,GAAG,GAAI,OAAO,iBAAiB,CAAC,QAAQ,CAAC,4CAGrD,CAAC"}
|
|
@@ -73,10 +73,10 @@ export const Tabs = (props) => {
|
|
|
73
73
|
setActive(result);
|
|
74
74
|
}
|
|
75
75
|
};
|
|
76
|
-
return (_jsx(Context.Provider, { value: active, children: _jsx(Card, { className: props.className, container: css("pt-0 max-w-full w-full min-w-0", props.container), header: _jsxs("header", { className: "relative mb-2
|
|
76
|
+
return (_jsx(Context.Provider, { value: active, children: _jsx(Card, { className: props.className, container: css("pt-0 max-w-full w-full min-w-0", props.container), header: _jsxs("header", { className: "overflow-x-auto relative mb-2", children: [_jsx("div", { className: "absolute bottom-0 w-full h-[1px] bg-card-border" }), _jsx("nav", { className: "min-w-0", children: _jsx("ul", { onKeyDown: onKeyDown, ref: ref, className: "flex overflow-x-auto flex-1 justify-start w-0 min-w-full", children: items.map((x) => {
|
|
77
77
|
const inner = x.props;
|
|
78
78
|
const current = active === inner.id;
|
|
79
|
-
return (_jsx("li", { "data-id": inner.id, "data-active": current, "aria-disabled": inner.disabled, className: css("relative w-fit border-b border-transparent transition-all", current ? "border-primary font-medium text-primary" : "", inner.disabled ? "aria-disabled:text-disabled" : ""), children: _jsx(Polymorph, { as: "button", type: "button", "data-id": inner.id, "aria-current": "page", disabled: inner.disabled, onClick: inner.disabled ? undefined : onClick, className: "block w-full whitespace-nowrap
|
|
79
|
+
return (_jsx("li", { "data-id": inner.id, "data-active": current, "aria-disabled": inner.disabled, className: css("relative w-fit border-b border-transparent transition-all", current ? "border-primary font-medium text-primary" : "", inner.disabled ? "aria-disabled:text-disabled" : ""), children: _jsx(Polymorph, { as: "button", type: "button", "data-id": inner.id, "aria-current": "page", disabled: inner.disabled, onClick: inner.disabled ? undefined : onClick, className: "block py-4 px-10 w-full whitespace-nowrap disabled:cursor-not-allowed", children: inner.title }) }, `tab-header-${inner.id}`));
|
|
80
80
|
}) }) })] }), children: props.children }) }));
|
|
81
81
|
};
|
|
82
82
|
const useTabs = () => useContext(Context);
|
|
@@ -22,7 +22,7 @@ type MenuItemProps = {
|
|
|
22
22
|
Right?: React.FC<LucideProps>;
|
|
23
23
|
};
|
|
24
24
|
export declare const MenuItem: React.ForwardRefExoticComponent<Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, keyof MenuItemProps> & MenuItemProps & React.RefAttributes<HTMLButtonElement>>;
|
|
25
|
-
export declare const Menu: React.ForwardRefExoticComponent<(Omit<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "label" | "children" | "
|
|
25
|
+
export declare const Menu: React.ForwardRefExoticComponent<(Omit<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "label" | "children" | "hover" | "open" | "asChild" | "restoreFocus" | "nested" | "isParent" | "floatingClassName" | "FloatingComponent"> & Partial<{
|
|
26
26
|
hover: boolean;
|
|
27
27
|
open?: boolean;
|
|
28
28
|
nested: boolean;
|
|
@@ -34,7 +34,7 @@ export declare const Menu: React.ForwardRefExoticComponent<(Omit<Omit<React.Deta
|
|
|
34
34
|
FloatingComponent: React.ElementType;
|
|
35
35
|
} & {
|
|
36
36
|
label: string;
|
|
37
|
-
}>, "ref"> | Omit<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "label" | "children" | "
|
|
37
|
+
}>, "ref"> | Omit<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "label" | "children" | "hover" | "open" | "asChild" | "restoreFocus" | "nested" | "isParent" | "floatingClassName" | "FloatingComponent"> & Partial<{
|
|
38
38
|
hover: boolean;
|
|
39
39
|
open?: boolean;
|
|
40
40
|
nested: boolean;
|
|
@@ -35,7 +35,7 @@ type ModalRef = {
|
|
|
35
35
|
context: any;
|
|
36
36
|
floating: HTMLElement | null;
|
|
37
37
|
};
|
|
38
|
-
export declare const Modal: React.ForwardRefExoticComponent<(Omit<Omit<HTMLMotionProps<"div">, "footer" | "title" | "className" | "role" | "onChange" | "
|
|
38
|
+
export declare const Modal: React.ForwardRefExoticComponent<(Omit<Omit<HTMLMotionProps<"div">, "footer" | "title" | "className" | "role" | "onChange" | "position" | "open" | "resizer" | "type" | "asChild" | "layoutId" | "trigger" | "animated" | "closable" | "forceType" | "bodyClassName" | "overlayClassName" | "overlayClickClose" | "interactions" | "ariaTitle"> & {
|
|
39
39
|
title: Label;
|
|
40
40
|
ariaTitle?: string;
|
|
41
41
|
} & {
|
|
@@ -60,7 +60,7 @@ export declare const Modal: React.ForwardRefExoticComponent<(Omit<Omit<HTMLMotio
|
|
|
60
60
|
trigger: Label | React.FC<any>;
|
|
61
61
|
}> & {
|
|
62
62
|
children?: React.ReactNode | undefined;
|
|
63
|
-
}, "ref"> | Omit<Omit<HTMLMotionProps<"div">, "footer" | "title" | "className" | "role" | "onChange" | "
|
|
63
|
+
}, "ref"> | Omit<Omit<HTMLMotionProps<"div">, "footer" | "title" | "className" | "role" | "onChange" | "position" | "open" | "resizer" | "type" | "asChild" | "layoutId" | "trigger" | "animated" | "closable" | "forceType" | "bodyClassName" | "overlayClassName" | "overlayClickClose" | "interactions" | "ariaTitle"> & {
|
|
64
64
|
ariaTitle: string;
|
|
65
65
|
title?: Label;
|
|
66
66
|
} & {
|
|
@@ -97,11 +97,11 @@ export const Modal = forwardRef(({ open, title, footer, asChild, trigger, childr
|
|
|
97
97
|
const headingId = useId();
|
|
98
98
|
const descriptionId = useId();
|
|
99
99
|
const isDesktop = useMediaQuery("(min-width: 64rem)");
|
|
100
|
-
const useResizer = _type !== "dialog";
|
|
101
100
|
const position = fetchPosition(isDesktop, forceType, _type, propsPosition);
|
|
102
101
|
const func = isDesktop ? animations[_type] : forceType ? animations[_type] : animations.sheet;
|
|
103
102
|
const animation = typeof func === "function" ? func(position) : func;
|
|
104
103
|
const type = isDesktop ? _type : forceType ? _type : "sheet";
|
|
104
|
+
const useResizer = type !== "dialog";
|
|
105
105
|
const floating = useFloating({ open, onOpenChange: onChange });
|
|
106
106
|
const click = useClick(floating.context, {});
|
|
107
107
|
const role = useRole(floating.context, { role: roleName });
|
|
@@ -175,7 +175,7 @@ export const Modal = forwardRef(({ open, title, footer, asChild, trigger, childr
|
|
|
175
175
|
"aria-modal": open,
|
|
176
176
|
ref: mergeRefs(floating.refs.setFloating, removeScrollRef),
|
|
177
177
|
className: css(variants({ position, type }), className, "isolate overscroll-contain"),
|
|
178
|
-
}), exit: "exit", layout: true, animate: "enter", initial: "initial", layoutId: layoutId, variants: animation, "data-component": "modal", style: type === "drawer" ? { width: floatingSize } : { height: floatingSize }, children: [useResizer && resizer ? (_jsx(Draggable, { onChange: onChange, value: floatingSize, sheet: type === "sheet", position: position, parent: floating.refs.floating })) : null, title ? (_jsx(motion.header, { ...draggableMotionProps, className: "relative w-full isolate", children: title ? (_jsx("h2", { id: headingId, className: "block px-8 pb-2 text-3xl font-medium leading-relaxed border-b select-text border-floating-border", children: title })) : null })) : null, _jsx(motion.section, { ref: innerContent, "data-component": "modal-body", dragConstraints: dragConstraints, drag: isDesktop ? "y"
|
|
178
|
+
}), exit: "exit", layout: true, animate: "enter", initial: "initial", layoutId: layoutId, variants: animation, "data-component": "modal", style: type === "drawer" ? { width: floatingSize } : { height: floatingSize }, children: [useResizer && resizer ? (_jsx(Draggable, { onChange: onChange, value: floatingSize, sheet: type === "sheet", position: position, parent: floating.refs.floating })) : null, title ? (_jsx(motion.header, { ...draggableMotionProps, className: "relative w-full isolate", children: title ? (_jsx("h2", { id: headingId, className: "block px-8 pb-2 text-3xl font-medium leading-relaxed border-b select-text border-floating-border", children: title })) : null })) : null, _jsx(motion.section, { ref: innerContent, "data-component": "modal-body", dragConstraints: dragConstraints, drag: isDesktop ? undefined : "y", onDrag: type === "sheet" ? (isDesktop ? undefined : onDragBody) : undefined, className: css("flex-1 select-text overflow-y-auto px-8 py-1", bodyClassName), onTouchEnd: () => {
|
|
179
179
|
scroll.set(undefined);
|
|
180
180
|
scrollInitial.set(undefined);
|
|
181
181
|
}, onTouchStart: e => {
|
|
@@ -51,5 +51,5 @@ export const Tooltip = forwardRef(function Tooltip({ as, open, title, children,
|
|
|
51
51
|
return setInnerOpen(false);
|
|
52
52
|
return setInnerOpen(open);
|
|
53
53
|
}, [open]);
|
|
54
|
-
return (_jsxs(Fragment, { children: [_jsx(Component, { ...getReferenceProps(props), ref: mergeRefs(refs.setReference, outerRef), children: title }), innerOpen && (_jsx(FloatingPortal, { children: _jsxs(Polymorph, { ...getFloatingProps(), ref: refs.setFloating, style: floatingStyles, className: "
|
|
54
|
+
return (_jsxs(Fragment, { children: [_jsx(Component, { ...getReferenceProps(props), ref: mergeRefs(refs.setReference, outerRef), children: title }), innerOpen && (_jsx(FloatingPortal, { children: _jsxs(Polymorph, { ...getFloatingProps(), ref: refs.setFloating, style: floatingStyles, className: "p-3 rounded-lg border isolate z-tooltip border-tooltip-border bg-tooltip-background text-tooltip-foreground shadow-shadow-floating", children: [_jsx(FloatingArrow, { ref: arrowRef, context: context, strokeWidth: 0.1, className: "fill-tooltip-background stroke-tooltip-border" }), children] }) }))] }));
|
|
55
55
|
});
|
|
@@ -28,7 +28,7 @@ const Item = forwardRef(function VirtualItem({ item, context, ...props }, ref) {
|
|
|
28
28
|
return _jsx(motion.li, { ...props, ref: ref, className: "first:rounded-t-lg last:rounded-t-lg" });
|
|
29
29
|
});
|
|
30
30
|
const components = { List, Item };
|
|
31
|
-
const MIN_SIZE =
|
|
31
|
+
const MIN_SIZE = 40;
|
|
32
32
|
export const Autocomplete = forwardRef(({ left, error, right, loading, options, container, rightLabel, interactive, emptyMessage, optionalText, labelClassName, feedback = null, hideLeft = false, required = false, dynamicOption = false, ...props }, externalRef) => {
|
|
33
33
|
const scroller = useRef(null);
|
|
34
34
|
const fieldset = useRef(null);
|
|
@@ -217,7 +217,7 @@ export const Autocomplete = forwardRef(({ left, error, right, loading, options,
|
|
|
217
217
|
},
|
|
218
218
|
}), "data-value": value, "data-error": !!error, "data-name": id, "data-target": id, required: required, value: open ? shadow : options.length === 0 ? "" : label || value, "aria-autocomplete": "list", autoComplete: "off", className: css("input placeholder-input-mask group h-input-height w-full flex-1", "rounded-md bg-transparent px-input-x py-input-y text-foreground", "outline-none transition-colors focus:ring-2 focus:ring-inset focus:ring-primary", "group-error:text-danger group-error:placeholder-input-mask-error", "text-base group-focus-within:border-primary group-hover:border-primary", props.className) }), _jsx("input", { id: id, name: id, type: "hidden", "data-origin": id, ref: externalRef, required: required, defaultValue: props.value || value || undefined }), _jsx(FloatingPortal, { preserveTabOrder: true, children: open ? (_jsx(FloatingFocusManager, { modal: true, guards: true, returnFocus: false, context: context, initialFocus: -1, visuallyHiddenDismiss: true, children: _jsxs(motion.div, { ...getFloatingProps({
|
|
219
219
|
ref: mergeRefs(removeScrollRef, refs.setFloating),
|
|
220
|
-
style: { ...transitions.styles, left: x, top: y ?? 0, position: strategy },
|
|
220
|
+
style: { ...transitions.styles, left: x, top: y ?? 0, position: strategy, height: "auto" },
|
|
221
221
|
}), initial: false, "data-floating": "true", animate: { height: isEmpty ? "auto" : h }, className: "isolate z-floating m-0 max-h-80 origin-[top_center] list-none overscroll-contain rounded-b-lg rounded-t-lg border border-floating-border bg-floating-background p-0 text-foreground shadow-floating ease-in-out", onAnimationComplete: () => {
|
|
222
222
|
if (!open)
|
|
223
223
|
return setH(0);
|
|
@@ -225,7 +225,9 @@ export const Autocomplete = forwardRef(({ left, error, right, loading, options,
|
|
|
225
225
|
const li = ul.querySelectorAll("li").item(0);
|
|
226
226
|
const sum = (li ? li.getBoundingClientRect().height : MIN_SIZE) * displayList.length;
|
|
227
227
|
return flushSync(() => setH(sum + 10));
|
|
228
|
-
}, children: [isEmpty ? (_jsx("div", { role: "option", className: "w-full border-b border-tooltip-border", children: _jsx("span", { className: "flex w-full justify-between p-2 text-left text-disabled", children: emptyMessage || translation.autocompleteEmpty }) })) : null, _jsx(Virtuoso, { overscan: 40, ref: virtuoso, hidden: isEmpty, data: displayList,
|
|
228
|
+
}, children: [isEmpty ? (_jsx("div", { role: "option", className: "w-full border-b border-tooltip-border", children: _jsx("span", { className: "flex w-full justify-between p-2 text-left text-disabled", children: emptyMessage || translation.autocompleteEmpty }) })) : null, _jsx(Virtuoso, { overscan: 40, ref: virtuoso, hidden: isEmpty, data: displayList,
|
|
229
|
+
// style={{ height: h - 10 }}
|
|
230
|
+
defaultItemHeight: MIN_SIZE, components: components, scrollerRef: (e) => void (scroller.current = e), className: "max-h-full overscroll-contain rounded-lg border-floating bg-floating-background p-0 text-foreground", itemContent: (i, option) => {
|
|
229
231
|
const Label = option.Render ?? Frag;
|
|
230
232
|
const active = value === option.value || value === option.label;
|
|
231
233
|
const selected = index === i;
|
|
@@ -3,6 +3,7 @@ import { Override } from "../../types";
|
|
|
3
3
|
import { CalendarProps } from "../display/calendar";
|
|
4
4
|
import { InputProps } from "./input";
|
|
5
5
|
export type DatePickerProps = Omit<Override<InputProps, CalendarProps & {
|
|
6
|
+
floating?: boolean;
|
|
6
7
|
clickToClose?: boolean;
|
|
7
8
|
}>, "currency">;
|
|
8
9
|
export declare const DatePicker: React.ForwardRefExoticComponent<Omit<DatePickerProps, "ref"> & React.RefAttributes<HTMLInputElement>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-picker.d.ts","sourceRoot":"","sources":["../../../src/components/form/date-picker.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAoE,MAAM,OAAO,CAAC;AAIzF,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAY,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAE9D,OAAO,EAAS,UAAU,EAAE,MAAM,SAAS,CAAC;AAE5C,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,aAAa,GAAG;IACpE,YAAY,CAAC,EAAE,OAAO,CAAA;CACzB,CAAC,EAAE,UAAU,CAAC,CAAA;AAkDf,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"date-picker.d.ts","sourceRoot":"","sources":["../../../src/components/form/date-picker.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAoE,MAAM,OAAO,CAAC;AAIzF,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAY,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAE9D,OAAO,EAAS,UAAU,EAAE,MAAM,SAAS,CAAC;AAE5C,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,aAAa,GAAG;IACpE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,OAAO,CAAA;CACzB,CAAC,EAAE,UAAU,CAAC,CAAA;AAkDf,eAAO,MAAM,UAAU,uGAiItB,CAAC"}
|
|
@@ -49,7 +49,7 @@ const formatParts = (datetimeFormat, date) => {
|
|
|
49
49
|
};
|
|
50
50
|
const DATE_TIME_FORMAT = { day: "numeric", month: "numeric", year: "numeric", hour: "numeric", minute: "numeric" };
|
|
51
51
|
const DATE_FORMAT = { day: "numeric", month: "numeric", year: "numeric" };
|
|
52
|
-
export const DatePicker = forwardRef(({ date, locale: inputLocal, disabledDate, onChange, markToday, clickToClose, type, ...props }, externalRef) => {
|
|
52
|
+
export const DatePicker = forwardRef(({ date, locale: inputLocal, disabledDate, onChange, markToday, clickToClose, floating = true, type, ...props }, externalRef) => {
|
|
53
53
|
const locale = useLocale(inputLocal);
|
|
54
54
|
const labelId = useId();
|
|
55
55
|
const translation = useTranslations();
|
|
@@ -99,5 +99,6 @@ export const DatePicker = forwardRef(({ date, locale: inputLocal, disabledDate,
|
|
|
99
99
|
};
|
|
100
100
|
const validDate = isValid(innerDate);
|
|
101
101
|
const htmlValue = validDate ? innerDate.toISOString() : undefined;
|
|
102
|
-
|
|
102
|
+
const CalendarComponent = _jsx(Calendar, { ...props, type: type, locale: locale, changeOnlyOnClick: true, markToday: markToday, onChange: onChangeDate, disabledDate: disabledDate, date: validDate ? innerDate : undefined });
|
|
103
|
+
return (_jsxs(Fragment, { children: [_jsx(Input, { ...props, mask: mask, value: value, id: undefined, name: undefined, "data-value": htmlValue, formNoValidate: !open, "data-target": props.name, "data-component": "date-picker", onChange: onChangeDateInput, required: props.required ?? true, error: open ? undefined : props.error, placeholder: props.placeholder || translation.datepickerPlaceholder(placeholder), right: floating ? _jsxs(Fragment, { children: [_jsx("input", { "data-origin": props.name, defaultValue: htmlValue, form: props.form, hidden: true, id: props.name, name: props.name, ref: externalRef, type: "date" }), _jsx(Dropdown, { open: open, onChange: setOpen, buttonProps: { "aria-describedby": labelId }, trigger: _jsxs("span", { "aria-labelledby": labelId, children: [_jsx("span", { id: labelId, className: "sr-only", children: translation.datePickerCalendarButtonLabel }), _jsx(CalendarIcon, {})] }), children: CalendarComponent })] }) : null }), CalendarComponent] }));
|
|
103
104
|
});
|
|
@@ -1,41 +1,43 @@
|
|
|
1
|
-
export * from "./core/button";
|
|
2
|
-
export * from "./core/polymorph";
|
|
3
|
-
export * from "./core/render-on-view";
|
|
4
1
|
export * from "./core/tag";
|
|
5
|
-
export * from "./
|
|
6
|
-
export * from "./
|
|
7
|
-
export * from "./
|
|
2
|
+
export * from "./form/form";
|
|
3
|
+
export * from "./form/input";
|
|
4
|
+
export * from "./core/button";
|
|
5
|
+
export * from "./form/select";
|
|
6
|
+
export * from "./form/slider";
|
|
7
|
+
export * from "./form/switch";
|
|
8
|
+
export * from "./table/index";
|
|
8
9
|
export * from "./display/card";
|
|
10
|
+
export * from "./display/list";
|
|
11
|
+
export * from "./display/tabs";
|
|
12
|
+
export * from "./display/step";
|
|
13
|
+
export * from "./display/alert";
|
|
9
14
|
export * from "./display/empty";
|
|
10
|
-
export * from "./display/notifications";
|
|
11
|
-
export * from "./display/progress";
|
|
12
15
|
export * from "./display/stats";
|
|
13
|
-
export * from "./display/tabs";
|
|
14
|
-
export * from "./display/timeline";
|
|
15
|
-
export * from "./display/list";
|
|
16
|
-
export * from "./floating/command-palette";
|
|
17
|
-
export * from "./floating/dropdown";
|
|
18
|
-
export * from "./floating/expand";
|
|
19
16
|
export * from "./floating/menu";
|
|
17
|
+
export * from "./form/checkbox";
|
|
18
|
+
export * from "./form/radiobox";
|
|
19
|
+
export * from "./form/textarea";
|
|
20
|
+
export * from "./core/polymorph";
|
|
20
21
|
export * from "./floating/modal";
|
|
22
|
+
export * from "./form/task-list";
|
|
23
|
+
export * from "./core/typography";
|
|
24
|
+
export * from "./display/spinner";
|
|
25
|
+
export * from "./floating/expand";
|
|
26
|
+
export * from "./display/calendar";
|
|
27
|
+
export * from "./display/progress";
|
|
28
|
+
export * from "./display/timeline";
|
|
21
29
|
export * from "./floating/toolbar";
|
|
22
30
|
export * from "./floating/tooltip";
|
|
23
|
-
export * from "./form/autocomplete";
|
|
24
|
-
export * from "./form/checkbox";
|
|
25
31
|
export * from "./form/date-picker";
|
|
26
32
|
export * from "./form/file-upload";
|
|
27
|
-
export * from "./form/form";
|
|
28
|
-
export * from "./form/input";
|
|
29
33
|
export * from "./form/input-field";
|
|
34
|
+
export * from "./floating/dropdown";
|
|
35
|
+
export * from "./form/autocomplete";
|
|
30
36
|
export * from "./form/multi-select";
|
|
31
|
-
export * from "./form/radiobox";
|
|
32
|
-
export * from "./form/select";
|
|
33
|
-
export * from "./form/slider";
|
|
34
|
-
export * from "./form/switch";
|
|
35
|
-
export * from "./form/task-list";
|
|
36
|
-
export * from "./form/textarea";
|
|
37
37
|
export * from "./form/transfer-list";
|
|
38
|
-
export * from "./
|
|
39
|
-
export
|
|
38
|
+
export * from "./core/render-on-view";
|
|
39
|
+
export * from "./display/notifications";
|
|
40
|
+
export * from "./floating/command-palette";
|
|
40
41
|
export { formReset } from "./form/formReset";
|
|
42
|
+
export { createColumns, createOptionCols, type ColType, useTablePreferences, type TablePagination } from "./table/table-lib";
|
|
41
43
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,KAAK,OAAO,EAAE,mBAAmB,EAAE,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/components/index.js
CHANGED
|
@@ -1,40 +1,42 @@
|
|
|
1
|
-
export * from "./core/button";
|
|
2
|
-
export * from "./core/polymorph";
|
|
3
|
-
export * from "./core/render-on-view";
|
|
4
1
|
export * from "./core/tag";
|
|
5
|
-
export * from "./
|
|
6
|
-
export * from "./
|
|
7
|
-
export * from "./
|
|
2
|
+
export * from "./form/form";
|
|
3
|
+
export * from "./form/input";
|
|
4
|
+
export * from "./core/button";
|
|
5
|
+
export * from "./form/select";
|
|
6
|
+
export * from "./form/slider";
|
|
7
|
+
export * from "./form/switch";
|
|
8
|
+
export * from "./table/index";
|
|
8
9
|
export * from "./display/card";
|
|
10
|
+
export * from "./display/list";
|
|
11
|
+
export * from "./display/tabs";
|
|
12
|
+
export * from "./display/step";
|
|
13
|
+
export * from "./display/alert";
|
|
9
14
|
export * from "./display/empty";
|
|
10
|
-
export * from "./display/notifications";
|
|
11
|
-
export * from "./display/progress";
|
|
12
15
|
export * from "./display/stats";
|
|
13
|
-
export * from "./display/tabs";
|
|
14
|
-
export * from "./display/timeline";
|
|
15
|
-
export * from "./display/list";
|
|
16
|
-
export * from "./floating/command-palette";
|
|
17
|
-
export * from "./floating/dropdown";
|
|
18
|
-
export * from "./floating/expand";
|
|
19
16
|
export * from "./floating/menu";
|
|
17
|
+
export * from "./form/checkbox";
|
|
18
|
+
export * from "./form/radiobox";
|
|
19
|
+
export * from "./form/textarea";
|
|
20
|
+
export * from "./core/polymorph";
|
|
20
21
|
export * from "./floating/modal";
|
|
22
|
+
export * from "./form/task-list";
|
|
23
|
+
export * from "./core/typography";
|
|
24
|
+
export * from "./display/spinner";
|
|
25
|
+
export * from "./floating/expand";
|
|
26
|
+
export * from "./display/calendar";
|
|
27
|
+
export * from "./display/progress";
|
|
28
|
+
export * from "./display/timeline";
|
|
21
29
|
export * from "./floating/toolbar";
|
|
22
30
|
export * from "./floating/tooltip";
|
|
23
|
-
export * from "./form/autocomplete";
|
|
24
|
-
export * from "./form/checkbox";
|
|
25
31
|
export * from "./form/date-picker";
|
|
26
32
|
export * from "./form/file-upload";
|
|
27
|
-
export * from "./form/form";
|
|
28
|
-
export * from "./form/input";
|
|
29
33
|
export * from "./form/input-field";
|
|
34
|
+
export * from "./floating/dropdown";
|
|
35
|
+
export * from "./form/autocomplete";
|
|
30
36
|
export * from "./form/multi-select";
|
|
31
|
-
export * from "./form/radiobox";
|
|
32
|
-
export * from "./form/select";
|
|
33
|
-
export * from "./form/slider";
|
|
34
|
-
export * from "./form/switch";
|
|
35
|
-
export * from "./form/task-list";
|
|
36
|
-
export * from "./form/textarea";
|
|
37
37
|
export * from "./form/transfer-list";
|
|
38
|
-
export * from "./
|
|
39
|
-
export
|
|
38
|
+
export * from "./core/render-on-view";
|
|
39
|
+
export * from "./display/notifications";
|
|
40
|
+
export * from "./floating/command-palette";
|
|
40
41
|
export { formReset } from "./form/formReset";
|
|
42
|
+
export { createColumns, createOptionCols, useTablePreferences } from "./table/table-lib";
|
|
@@ -32,7 +32,7 @@ export const Pagination = (pagination) => {
|
|
|
32
32
|
const translation = useTranslations();
|
|
33
33
|
const pageNavigation = useMemo(() => createPaginationItems(pagination.current, pagination.pages), [pagination.current, pagination.pages]);
|
|
34
34
|
const hasNext = pagination.current < pagination.pages;
|
|
35
|
-
return (_jsxs("footer", { className: "flex flex-wrap items-center justify-center gap-4
|
|
35
|
+
return (_jsxs("footer", { className: "flex flex-wrap items-center justify-center gap-4 p-3 border-t-muted text-sm lg:flex-nowrap lg:justify-between", children: [_jsx("p", { children: _jsx(translation.tablePaginationFooter, { ...pagination, sizes: pagination.sizes, select: pagination.onChangeSize && Array.isArray(pagination.sizes) ? (_jsxs(Fragment, { children: [_jsx("label", { htmlFor: id, children: translation.tablePaginationSelectLabel }), _jsx("select", { id: id, value: pagination.size, className: "cursor-pointer bg-transparent", onChange: (e) => {
|
|
36
36
|
pagination.onChangeSize?.(Number(e.target.value));
|
|
37
37
|
}, children: pagination.sizes.map((value) => (_jsx("option", { value: value, children: value }, `pagination-opt-${value}`))) }), " "] })) : null }) }), _jsx("nav", { children: _jsxs("ul", { className: "flex items-center gap-2", children: [pagination.current > 1 ? (_jsx("li", { children: _jsx(Polymorph, { as: pagination.asLink || "button", href: "previous", className: "", children: translation.tablePaginationPrevious }) })) : null, pageNavigation.map((x) => {
|
|
38
38
|
if (x === null)
|
package/dist/hooks/use-form.js
CHANGED
|
@@ -17,7 +17,7 @@ const isValidJSON = (value) => {
|
|
|
17
17
|
try {
|
|
18
18
|
value = JSON.stringify(value);
|
|
19
19
|
}
|
|
20
|
-
catch
|
|
20
|
+
catch {
|
|
21
21
|
return false;
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -25,7 +25,7 @@ const isValidJSON = (value) => {
|
|
|
25
25
|
JSON.parse(value);
|
|
26
26
|
return true;
|
|
27
27
|
}
|
|
28
|
-
catch
|
|
28
|
+
catch {
|
|
29
29
|
return false;
|
|
30
30
|
}
|
|
31
31
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-preferences.d.ts","sourceRoot":"","sources":["../../src/hooks/use-preferences.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,MAAM,EAAE,CAAC,EAChD,KAAK,CAAC,EACN,cAAc,CAAC,2BASJ,UAAU,6DAAiB,CAAC,CAAC,CAAC,cAc1C,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useCallback, useState } from "react";
|
|
2
|
+
import { Is } from "sidekicker";
|
|
3
|
+
import { LocalStorage } from "storage-manager-js";
|
|
4
|
+
export const usePreferences = (key, defaultValue) => {
|
|
5
|
+
const [state, setState] = useState(() => {
|
|
6
|
+
const saved = LocalStorage.get(key);
|
|
7
|
+
if (saved)
|
|
8
|
+
return saved;
|
|
9
|
+
return defaultValue;
|
|
10
|
+
});
|
|
11
|
+
const setCallback = useCallback((params) => {
|
|
12
|
+
if (Is.function(params)) {
|
|
13
|
+
return setState((prev) => {
|
|
14
|
+
const result = params(prev);
|
|
15
|
+
LocalStorage.set(key, result);
|
|
16
|
+
return result;
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
LocalStorage.set(key, params);
|
|
20
|
+
return params;
|
|
21
|
+
}, [key]);
|
|
22
|
+
return [state, setCallback];
|
|
23
|
+
};
|