@g4rcez/components 2.0.21 → 2.0.23
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/step.d.ts +11 -2
- package/dist/components/display/step.d.ts.map +1 -1
- package/dist/components/display/step.js +90 -47
- 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/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 +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +1 -0
- package/dist/components/table/pagination.js +1 -1
- package/dist/index.css +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6068 -5940
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +53 -53
- 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
|
};
|
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
import React, { PropsWithChildren } from "react";
|
|
2
|
+
import { Label } from "../../types";
|
|
3
|
+
type StepContextValue = {
|
|
4
|
+
currentStep: number;
|
|
5
|
+
previousStep: number;
|
|
6
|
+
progressBarDuration: number;
|
|
7
|
+
};
|
|
2
8
|
type StepStatus = "active" | "inactive" | "complete" | "error";
|
|
3
9
|
export type StepProps = React.ComponentProps<"button"> & {
|
|
4
10
|
step: number;
|
|
11
|
+
title?: Label;
|
|
5
12
|
currentStep: number;
|
|
6
13
|
status?: StepStatus;
|
|
14
|
+
titleClassName?: string;
|
|
7
15
|
};
|
|
8
|
-
export declare const
|
|
16
|
+
export declare const useStepContext: () => StepContextValue | null;
|
|
17
|
+
export declare const Step: ({ step, currentStep, status, title, titleClassName, ...props }: StepProps) => import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export declare const Steps: (props: PropsWithChildren<{
|
|
9
19
|
steps: number;
|
|
10
20
|
currentStep: number;
|
|
11
21
|
}>) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
-
export declare const Step: (props: StepProps) => import("react/jsx-runtime").JSX.Element;
|
|
13
22
|
export {};
|
|
14
23
|
//# 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,
|
|
1
|
+
{"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../../../src/components/display/step.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAA2C,iBAAiB,EAA2C,MAAM,OAAO,CAAC;AAEnI,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAMpC,KAAK,gBAAgB,GAAG;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,mBAAmB,EAAE,MAAM,CAAA;CAAE,CAAC;AA+BnG,KAAK,UAAU,GAAG,QAAQ,GAAG,UAAU,GAAG,UAAU,GAAG,OAAO,CAAC;AAE/D,MAAM,MAAM,SAAS,GAAG,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,GAAG;IACvD,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAoCF,eAAO,MAAM,cAAc,+BAAgC,CAAC;AAE5D,eAAO,MAAM,IAAI,GAAI,gEAAgE,SAAS,4CAmF7F,CAAC;AAEF,eAAO,MAAM,KAAK,GAAI,OAAO,iBAAiB,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC,4CA2CrF,CAAC"}
|
|
@@ -1,78 +1,121 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { motion,
|
|
4
|
-
import { useEffect } from "react";
|
|
3
|
+
import { motion, useAnimate } from "motion/react";
|
|
4
|
+
import { createContext, Fragment, useContext, useEffect, useRef, useState } from "react";
|
|
5
5
|
import { useColorParser } from "../../hooks/use-color-parser";
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
ease: "easeOut",
|
|
11
|
-
};
|
|
6
|
+
const PROGRESS_BAR_DURATION = 0.3;
|
|
7
|
+
const transition = { duration: PROGRESS_BAR_DURATION, type: "tween", ease: "easeInOut" };
|
|
8
|
+
const StepContext = createContext(null);
|
|
9
|
+
const iconTransitions = { delay: 0.2, duration: 0.3, type: "tween", ease: "easeOut" };
|
|
12
10
|
const states = {
|
|
13
11
|
initial: { pathLength: 0, opacity: 0 },
|
|
14
12
|
animate: { pathLength: 1, opacity: 1 },
|
|
15
13
|
};
|
|
16
14
|
const ErrorIcon = (props) => (_jsxs("svg", { ...props, viewBox: "0 0 24 24", fill: "currentColor", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [_jsx(motion.path, { className: "currentColor", initial: states.initial, animate: states.animate, transition: iconTransitions, d: "M18 6 6 18" }), _jsx(motion.path, { className: "currentColor", initial: states.initial, animate: states.animate, transition: iconTransitions, d: "m6 6 12 12" })] }));
|
|
17
15
|
const CheckIcon = (props) => (_jsx("svg", { ...props, fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", strokeWidth: 3, children: _jsx(motion.path, { d: "M5 13l4 4L19 7", strokeLinecap: "round", strokeLinejoin: "round", animate: states.animate, initial: states.initial, transition: iconTransitions }) }));
|
|
18
|
-
const variants = {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
const variants = {
|
|
17
|
+
complete: { scale: 1.25 },
|
|
18
|
+
active: {
|
|
19
|
+
scale: 1,
|
|
20
|
+
transition: { delay: 0, duration: 0.3 }
|
|
21
|
+
}
|
|
24
22
|
};
|
|
25
|
-
const
|
|
26
|
-
|
|
23
|
+
const transitions = { duration: 0.6, delay: 0.2, type: "tween", ease: "circOut", };
|
|
24
|
+
const getCurrentStatus = (step, currentStep, status) => {
|
|
25
|
+
if (status === "error")
|
|
27
26
|
return "error";
|
|
28
|
-
if (
|
|
27
|
+
if (currentStep === step)
|
|
29
28
|
return "active";
|
|
30
|
-
if (
|
|
29
|
+
if (currentStep < step)
|
|
31
30
|
return "inactive";
|
|
32
31
|
return "complete";
|
|
33
32
|
};
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
const calculateStepDelay = (step, currentStep, previousStep, duration) => {
|
|
34
|
+
if (currentStep === previousStep)
|
|
35
|
+
return 0;
|
|
36
|
+
const isForward = currentStep > previousStep;
|
|
37
|
+
if (isForward) {
|
|
38
|
+
if (step <= previousStep || step > currentStep)
|
|
39
|
+
return 0;
|
|
40
|
+
return ((step - previousStep) / (currentStep - previousStep)) * duration;
|
|
41
|
+
}
|
|
42
|
+
if (step <= currentStep || step > previousStep)
|
|
43
|
+
return 0;
|
|
44
|
+
return ((previousStep - step) / (previousStep - currentStep)) * duration;
|
|
45
|
+
};
|
|
46
|
+
export const useStepContext = () => useContext(StepContext);
|
|
47
|
+
export const Step = ({ step, currentStep, status, title, titleClassName, ...props }) => {
|
|
48
|
+
const parser = useColorParser();
|
|
49
|
+
const context = useStepContext();
|
|
50
|
+
const [visualCurrentStep, setVisualCurrentStep] = useState(currentStep);
|
|
36
51
|
useEffect(() => {
|
|
37
|
-
if (
|
|
52
|
+
if (!context) {
|
|
53
|
+
setVisualCurrentStep(currentStep);
|
|
38
54
|
return;
|
|
39
|
-
const container = ref.current;
|
|
40
|
-
const first = container.querySelectorAll('[data-step]')[0];
|
|
41
|
-
const step = container.querySelector(`[data-step="${props.currentStep}"]`);
|
|
42
|
-
if (first && step) {
|
|
43
|
-
const diff = step.getBoundingClientRect().left - first.getBoundingClientRect().left;
|
|
44
|
-
animate("div[data-name='progress']", { width: `${Math.max(0, diff)}px` }, {
|
|
45
|
-
type: "spring",
|
|
46
|
-
duration: 0.5,
|
|
47
|
-
delay: stagger(0.075),
|
|
48
|
-
});
|
|
49
55
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
const delay = calculateStepDelay(step, context.currentStep, context.previousStep, context.progressBarDuration);
|
|
57
|
+
if (delay === 0) {
|
|
58
|
+
setVisualCurrentStep(currentStep);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const timer = setTimeout(() => {
|
|
62
|
+
setVisualCurrentStep(currentStep);
|
|
63
|
+
}, delay * 1000);
|
|
64
|
+
return () => clearTimeout(timer);
|
|
65
|
+
}, [currentStep, context, step]);
|
|
66
|
+
const innerStatus = getCurrentStatus(step, visualCurrentStep, status);
|
|
67
|
+
return (_jsxs(motion.button, { ...props, type: "button", "data-step": step, animate: innerStatus, className: "relative w-auto text-center flex items-center justify-center", children: [_jsx(motion.div, { variants: variants, transition: transitions, className: `absolute inset-0 rounded-full text-center ${innerStatus === "error" ? "bg-danger" : ""}` }), _jsx(motion.div, { initial: false, animate: innerStatus, transition: transition, className: "flex relative justify-center items-center w-10 h-10 font-semibold rounded-full", variants: {
|
|
57
68
|
error: {
|
|
58
|
-
backgroundColor: parser("var(--danger-DEFAULT)"),
|
|
59
|
-
borderColor: parser("var(--danger-hover)"),
|
|
60
69
|
color: parser("var(--danger-foreground)"),
|
|
70
|
+
borderColor: parser("var(--danger-hover)"),
|
|
71
|
+
backgroundColor: parser("var(--danger-DEFAULT)"),
|
|
61
72
|
},
|
|
62
73
|
inactive: {
|
|
63
|
-
|
|
64
|
-
borderColor: parser("var(--card-border)"),
|
|
74
|
+
transition,
|
|
65
75
|
color: parser("var(--disabled)"),
|
|
76
|
+
borderColor: parser("var(--card-border)"),
|
|
77
|
+
backgroundColor: parser("var(--background)"),
|
|
66
78
|
},
|
|
67
79
|
active: {
|
|
68
|
-
|
|
69
|
-
borderColor: parser("var(--primary-DEFAULT)"),
|
|
80
|
+
transition,
|
|
70
81
|
color: parser("var(--primary-foreground)"),
|
|
82
|
+
borderColor: parser("var(--primary-DEFAULT)"),
|
|
83
|
+
backgroundColor: parser("var(--primary-DEFAULT)"),
|
|
71
84
|
},
|
|
72
85
|
complete: {
|
|
73
|
-
|
|
74
|
-
borderColor: parser("var(--success-DEFAULT)"),
|
|
86
|
+
transition,
|
|
75
87
|
color: parser("var(--success-foreground)"),
|
|
88
|
+
borderColor: parser("var(--success-DEFAULT)"),
|
|
89
|
+
backgroundColor: parser("var(--success-DEFAULT)"),
|
|
76
90
|
},
|
|
77
|
-
},
|
|
91
|
+
}, children: _jsx("div", { className: "flex justify-center items-center", children: innerStatus === "complete" ? (_jsx(CheckIcon, { className: "size-6 text-primary-foreground" })) : innerStatus === "error" ? (_jsx(ErrorIcon, { className: "size-6 text-danger-foreground" })) : (_jsx(Fragment, { children: _jsx("span", { children: step }) })) }) }), title && innerStatus === "active" ? _jsx("span", { className: `h-full flex items-center px-4 ${titleClassName}`, children: title }) : null] }));
|
|
92
|
+
};
|
|
93
|
+
export const Steps = (props) => {
|
|
94
|
+
const [ref, animate] = useAnimate();
|
|
95
|
+
const previousStepRef = useRef(props.currentStep);
|
|
96
|
+
const [previousStep, setPreviousStep] = useState(props.currentStep);
|
|
97
|
+
useEffect(() => {
|
|
98
|
+
if (props.currentStep === 0)
|
|
99
|
+
return;
|
|
100
|
+
const container = ref.current;
|
|
101
|
+
const first = container.querySelectorAll('[data-step]')[0];
|
|
102
|
+
const step = container.querySelector(`[data-step="${props.currentStep}"]`);
|
|
103
|
+
if (first && step) {
|
|
104
|
+
const diff = step.getBoundingClientRect().left - first.getBoundingClientRect().left;
|
|
105
|
+
animate("div[data-name='progress']", { width: `${Math.max(0, diff)}px` }, transition);
|
|
106
|
+
}
|
|
107
|
+
}, [props.currentStep]);
|
|
108
|
+
useEffect(() => {
|
|
109
|
+
previousStepRef.current = previousStep;
|
|
110
|
+
const timer = setTimeout(() => {
|
|
111
|
+
setPreviousStep(props.currentStep);
|
|
112
|
+
}, PROGRESS_BAR_DURATION * 1000);
|
|
113
|
+
return () => clearTimeout(timer);
|
|
114
|
+
}, [props.currentStep]);
|
|
115
|
+
const contextValue = {
|
|
116
|
+
currentStep: props.currentStep,
|
|
117
|
+
previousStep: previousStepRef.current,
|
|
118
|
+
progressBarDuration: PROGRESS_BAR_DURATION,
|
|
119
|
+
};
|
|
120
|
+
return (_jsx(StepContext.Provider, { value: contextValue, children: _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 bg-success" }), props.children] }) }));
|
|
78
121
|
};
|
|
@@ -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);
|
|
@@ -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
|
});
|
|
@@ -9,6 +9,7 @@ export * from "./table/index";
|
|
|
9
9
|
export * from "./display/card";
|
|
10
10
|
export * from "./display/list";
|
|
11
11
|
export * from "./display/tabs";
|
|
12
|
+
export * from "./display/step";
|
|
12
13
|
export * from "./display/alert";
|
|
13
14
|
export * from "./display/empty";
|
|
14
15
|
export * from "./display/stats";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"A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Ae,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/components/index.js
CHANGED
|
@@ -9,6 +9,7 @@ export * from "./table/index";
|
|
|
9
9
|
export * from "./display/card";
|
|
10
10
|
export * from "./display/list";
|
|
11
11
|
export * from "./display/tabs";
|
|
12
|
+
export * from "./display/step";
|
|
12
13
|
export * from "./display/alert";
|
|
13
14
|
export * from "./display/empty";
|
|
14
15
|
export * from "./display/stats";
|
|
@@ -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)
|