@eintrek/erp-theme 1.0.0 → 1.0.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/dist/components/ui/{button.d.ts → Buttons.d.ts} +2 -1
- package/dist/components/ui/{button.stories.d.ts → Buttons.stories.d.ts} +1 -1
- package/dist/components/ui/{card.stories.d.ts → Cards.stories.d.ts} +1 -1
- package/dist/components/ui/Form.d.ts +1 -1
- package/dist/components/ui/Form.stories.d.ts +1 -1
- package/dist/components/ui/Input.d.ts +1 -1
- package/dist/components/ui/Input.stories.d.ts +1 -1
- package/dist/components/ui/InputDropdown.d.ts +1 -1
- package/dist/components/ui/InputDropdown.stories.d.ts +1 -1
- package/dist/components/ui/Label.d.ts +1 -1
- package/dist/components/ui/Label.stories.d.ts +1 -1
- package/dist/components/ui/Modal.d.ts +1 -1
- package/dist/components/ui/Modal.stories.d.ts +1 -1
- package/dist/components/ui/table/Table.d.ts +4 -3
- package/dist/index.css +1 -1
- package/dist/index.d.ts +7 -8
- package/dist/index.esm.css +1 -0
- package/dist/index.esm.js +11249 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +202 -217
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
- package/dist/components/ui/badge/Badge.d.ts +0 -6
- package/dist/components/ui/button/Button.d.ts +0 -7
- package/dist/components/ui/tabs/Tabs.d.ts +0 -11
- /package/dist/components/ui/{card.d.ts → Cards.d.ts} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,23 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime$1 = require('react/jsx-runtime');
|
|
4
|
+
var React__default = require('react');
|
|
5
|
+
var reactSlot = require('@radix-ui/react-slot');
|
|
6
|
+
var classVarianceAuthority = require('class-variance-authority');
|
|
7
|
+
var LucideIcons = require('lucide-react');
|
|
8
|
+
var clsx = require('clsx');
|
|
9
|
+
var tailwindMerge = require('tailwind-merge');
|
|
10
|
+
|
|
11
|
+
function _interopNamespaceDefault(e) {
|
|
12
|
+
var n = Object.create(null);
|
|
13
|
+
if (e) {
|
|
14
|
+
Object.keys(e).forEach(function (k) {
|
|
15
|
+
if (k !== 'default') {
|
|
16
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
17
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () { return e[k]; }
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
n.default = e;
|
|
25
|
+
return Object.freeze(n);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
var React__default__namespace = /*#__PURE__*/_interopNamespaceDefault(React__default);
|
|
29
|
+
var LucideIcons__namespace = /*#__PURE__*/_interopNamespaceDefault(LucideIcons);
|
|
10
30
|
|
|
11
31
|
function cn(...inputs) {
|
|
12
|
-
return twMerge(clsx(inputs));
|
|
32
|
+
return tailwindMerge.twMerge(clsx.clsx(inputs));
|
|
13
33
|
}
|
|
14
34
|
|
|
15
|
-
const buttonVariants = cva("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1
|
|
35
|
+
const buttonVariants = classVarianceAuthority.cva("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 ring-gray-400 disabled:pointer-events-none disabled:opacity-50", {
|
|
16
36
|
variants: {
|
|
17
37
|
variant: {
|
|
18
38
|
default: "shadow hover:opacity-90",
|
|
19
39
|
destructive: "shadow-sm hover:opacity-90",
|
|
20
|
-
outline: "border border-
|
|
40
|
+
outline: "border border-gray-300 bg-white shadow-sm hover:bg-accent hover:text-accent-foreground",
|
|
21
41
|
secondary: "shadow-sm hover:opacity-80",
|
|
22
42
|
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
23
43
|
link: "underline-offset-4 hover:underline",
|
|
@@ -37,53 +57,53 @@ const buttonVariants = cva("inline-flex items-center justify-center whitespace-n
|
|
|
37
57
|
const DynamicIcon$1 = ({ name, size = 16, className }) => {
|
|
38
58
|
if (!name)
|
|
39
59
|
return null;
|
|
40
|
-
const IconComponent =
|
|
60
|
+
const IconComponent = LucideIcons__namespace[name];
|
|
41
61
|
if (!IconComponent)
|
|
42
62
|
return null;
|
|
43
|
-
return jsx(IconComponent, { size: size, className: className });
|
|
63
|
+
return jsxRuntime$1.jsx(IconComponent, { size: size, className: className });
|
|
44
64
|
};
|
|
45
65
|
const isLucideIcon$1 = (name) => {
|
|
46
66
|
if (!name)
|
|
47
67
|
return false;
|
|
48
|
-
return Boolean(
|
|
68
|
+
return Boolean(LucideIcons__namespace[name]);
|
|
49
69
|
};
|
|
50
|
-
const Button =
|
|
51
|
-
const Comp = asChild ? Slot : "button";
|
|
52
|
-
return (jsxs(Comp, { className: cn(buttonVariants({ variant, size, className })), ref: ref, ...props, children: [prefix && (isLucideIcon$1(prefix)
|
|
53
|
-
? jsx(DynamicIcon$1, { name: prefix, className: children ? 'mr-2' : '' })
|
|
54
|
-
: jsx("span", { className: children ? 'mr-2' : '', children: prefix })), children, suffix && (isLucideIcon$1(suffix)
|
|
55
|
-
? jsx(DynamicIcon$1, { name: suffix, className: children ? 'ml-2' : '' })
|
|
56
|
-
: jsx("span", { className: children ? 'ml-2' : '', children: suffix }))] }));
|
|
70
|
+
const Button = React__default__namespace.forwardRef(({ className, variant, size, asChild = false, children, prefix, suffix, ...props }, ref) => {
|
|
71
|
+
const Comp = asChild ? reactSlot.Slot : "button";
|
|
72
|
+
return (jsxRuntime$1.jsxs(Comp, { className: cn(buttonVariants({ variant, size, className })), ref: ref, ...props, children: [prefix && (isLucideIcon$1(prefix)
|
|
73
|
+
? jsxRuntime$1.jsx(DynamicIcon$1, { name: prefix, className: children ? 'mr-2' : '' })
|
|
74
|
+
: jsxRuntime$1.jsx("span", { className: children ? 'mr-2' : '', children: prefix })), children, suffix && (isLucideIcon$1(suffix)
|
|
75
|
+
? jsxRuntime$1.jsx(DynamicIcon$1, { name: suffix, className: children ? 'ml-2' : '' })
|
|
76
|
+
: jsxRuntime$1.jsx("span", { className: children ? 'ml-2' : '', children: suffix }))] }));
|
|
57
77
|
});
|
|
58
78
|
Button.displayName = "Button";
|
|
59
79
|
|
|
60
80
|
const Label = ({ label, required = false, className = '' }) => {
|
|
61
|
-
return (jsxs("label", { className: `block text-sm font-medium text-gray-700 mb-1 ${className}`, children: [label, required && jsx("span", { className: "text-red-500", children: "*" })] }));
|
|
81
|
+
return (jsxRuntime$1.jsxs("label", { className: `block text-sm font-medium text-gray-700 mb-1 ${className}`, children: [label, required && jsxRuntime$1.jsx("span", { className: "text-red-500", children: "*" })] }));
|
|
62
82
|
};
|
|
63
83
|
|
|
64
84
|
// DynamicIcon component
|
|
65
85
|
const DynamicIcon = ({ name, size = 18 }) => {
|
|
66
86
|
if (!name)
|
|
67
87
|
return null;
|
|
68
|
-
const IconComponent =
|
|
88
|
+
const IconComponent = LucideIcons__namespace[name];
|
|
69
89
|
if (!IconComponent)
|
|
70
90
|
return null;
|
|
71
|
-
return jsx(IconComponent, { size: size });
|
|
91
|
+
return jsxRuntime$1.jsx(IconComponent, { size: size });
|
|
72
92
|
};
|
|
73
93
|
const isLucideIcon = (name) => {
|
|
74
94
|
if (!name)
|
|
75
95
|
return false;
|
|
76
|
-
return Boolean(
|
|
96
|
+
return Boolean(LucideIcons__namespace[name]);
|
|
77
97
|
};
|
|
78
98
|
const Input$1 = ({ label, type = 'text', value, onChange, placeholder = '', required = false, error, name, icon, suffix, disabled, inputClassName = '', }) => {
|
|
79
99
|
const hasSuffix = !!suffix;
|
|
80
100
|
const stateClass = disabled ? 'opacity-50 cursor-not-allowed' : '';
|
|
81
|
-
return (jsxs("div", { className: "mb-4", children: [jsx(Label, { label: label, required: required }), jsxs("div", { className: "relative", children: [icon && (jsx("span", { className: "absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none text-gray-400", children: jsx(DynamicIcon, { name: icon, size: 18 }) })), hasSuffix && (jsx("span", { className: "absolute inset-y-0 right-0 flex items-center pr-3 pointer-events-none text-gray-400", children: isLucideIcon(suffix) ? jsx(DynamicIcon, { name: suffix, size: 18 }) : jsx("span", { className: "text-sm", children: suffix }) })), jsx("input", { id: name, name: name, type: type, value: value, onChange: onChange, placeholder: placeholder, required: required, disabled: disabled, className: `w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-primary ${icon ? 'pl-10' : ''} ${hasSuffix ? 'pr-10' : ''} ${error ? 'border-red-500' : 'border-gray-300'} ${stateClass} ${inputClassName}` })] }), error && jsx("p", { className: "text-xs text-red-500 mt-1", children: error })] }));
|
|
101
|
+
return (jsxRuntime$1.jsxs("div", { className: "mb-4", children: [jsxRuntime$1.jsx(Label, { label: label, required: required }), jsxRuntime$1.jsxs("div", { className: "relative", children: [icon && (jsxRuntime$1.jsx("span", { className: "absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none text-gray-400", children: jsxRuntime$1.jsx(DynamicIcon, { name: icon, size: 18 }) })), hasSuffix && (jsxRuntime$1.jsx("span", { className: "absolute inset-y-0 right-0 flex items-center pr-3 pointer-events-none text-gray-400", children: isLucideIcon(suffix) ? jsxRuntime$1.jsx(DynamicIcon, { name: suffix, size: 18 }) : jsxRuntime$1.jsx("span", { className: "text-sm", children: suffix }) })), jsxRuntime$1.jsx("input", { id: name, name: name, type: type, value: value, onChange: onChange, placeholder: placeholder, required: required, disabled: disabled, className: `w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-primary ${icon ? 'pl-10' : ''} ${hasSuffix ? 'pr-10' : ''} ${error ? 'border-red-500' : 'border-gray-300'} ${stateClass} ${inputClassName}` })] }), error && jsxRuntime$1.jsx("p", { className: "text-xs text-red-500 mt-1", children: error })] }));
|
|
82
102
|
};
|
|
83
103
|
|
|
84
104
|
const InputDropdown = ({ label, options, value, onChange, placeholder = '', required = false, error, name, disabled, inputClassName = '', }) => {
|
|
85
105
|
const stateClass = disabled ? 'opacity-50 cursor-not-allowed' : '';
|
|
86
|
-
return (jsxs("div", { className: "mb-4", children: [jsx(Label, { label: label, required: required }), jsxs("select", { id: name, name: name, value: value, onChange: onChange, required: required, disabled: disabled, className: `w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-primary ${error ? 'border-red-500' : 'border-gray-300'} ${stateClass} ${inputClassName}`, children: [placeholder && jsx("option", { value: "", disabled: true, className: "text-gray-400", children: placeholder }), options.map(opt => (jsx("option", { value: opt.value, children: opt.label }, opt.value)))] }), error && jsx("p", { className: "text-xs text-red-500 mt-1", children: error })] }));
|
|
106
|
+
return (jsxRuntime$1.jsxs("div", { className: "mb-4", children: [jsxRuntime$1.jsx(Label, { label: label, required: required }), jsxRuntime$1.jsxs("select", { id: name, name: name, value: value, onChange: onChange, required: required, disabled: disabled, className: `w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-primary ${error ? 'border-red-500' : 'border-gray-300'} ${stateClass} ${inputClassName}`, children: [placeholder && jsxRuntime$1.jsx("option", { value: "", disabled: true, className: "text-gray-400", children: placeholder }), options.map(opt => (jsxRuntime$1.jsx("option", { value: opt.value, children: opt.label }, opt.value)))] }), error && jsxRuntime$1.jsx("p", { className: "text-xs text-red-500 mt-1", children: error })] }));
|
|
87
107
|
};
|
|
88
108
|
|
|
89
109
|
var isCheckBoxInput = (element) => element.type === 'checkbox';
|
|
@@ -214,7 +234,7 @@ const INPUT_VALIDATION_RULES = {
|
|
|
214
234
|
validate: 'validate',
|
|
215
235
|
};
|
|
216
236
|
|
|
217
|
-
const HookFormContext =
|
|
237
|
+
const HookFormContext = React__default.createContext(null);
|
|
218
238
|
HookFormContext.displayName = 'HookFormContext';
|
|
219
239
|
|
|
220
240
|
var getProxyFormState = (formState, control, localProxyFormState, isRoot = true) => {
|
|
@@ -235,7 +255,7 @@ var getProxyFormState = (formState, control, localProxyFormState, isRoot = true)
|
|
|
235
255
|
return result;
|
|
236
256
|
};
|
|
237
257
|
|
|
238
|
-
const useIsomorphicLayoutEffect = typeof window !== 'undefined' ?
|
|
258
|
+
const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? React__default__namespace.useLayoutEffect : React__default__namespace.useEffect;
|
|
239
259
|
|
|
240
260
|
var isString = (value) => typeof value === 'string';
|
|
241
261
|
|
|
@@ -1936,9 +1956,9 @@ function createFormControl(props = {}) {
|
|
|
1936
1956
|
* ```
|
|
1937
1957
|
*/
|
|
1938
1958
|
function useForm(props = {}) {
|
|
1939
|
-
const _formControl =
|
|
1940
|
-
const _values =
|
|
1941
|
-
const [formState, updateFormState] =
|
|
1959
|
+
const _formControl = React__default.useRef(undefined);
|
|
1960
|
+
const _values = React__default.useRef(undefined);
|
|
1961
|
+
const [formState, updateFormState] = React__default.useState({
|
|
1942
1962
|
isDirty: false,
|
|
1943
1963
|
isValidating: false,
|
|
1944
1964
|
isLoading: isFunction$1(props.defaultValues),
|
|
@@ -1990,8 +2010,8 @@ function useForm(props = {}) {
|
|
|
1990
2010
|
control._formState.isReady = true;
|
|
1991
2011
|
return sub;
|
|
1992
2012
|
}, [control]);
|
|
1993
|
-
|
|
1994
|
-
|
|
2013
|
+
React__default.useEffect(() => control._disableForm(props.disabled), [control, props.disabled]);
|
|
2014
|
+
React__default.useEffect(() => {
|
|
1995
2015
|
if (props.mode) {
|
|
1996
2016
|
control._options.mode = props.mode;
|
|
1997
2017
|
}
|
|
@@ -1999,19 +2019,19 @@ function useForm(props = {}) {
|
|
|
1999
2019
|
control._options.reValidateMode = props.reValidateMode;
|
|
2000
2020
|
}
|
|
2001
2021
|
}, [control, props.mode, props.reValidateMode]);
|
|
2002
|
-
|
|
2022
|
+
React__default.useEffect(() => {
|
|
2003
2023
|
if (props.errors) {
|
|
2004
2024
|
control._setErrors(props.errors);
|
|
2005
2025
|
control._focusError();
|
|
2006
2026
|
}
|
|
2007
2027
|
}, [control, props.errors]);
|
|
2008
|
-
|
|
2028
|
+
React__default.useEffect(() => {
|
|
2009
2029
|
props.shouldUnregister &&
|
|
2010
2030
|
control._subjects.state.next({
|
|
2011
2031
|
values: control._getWatch(),
|
|
2012
2032
|
});
|
|
2013
2033
|
}, [control, props.shouldUnregister]);
|
|
2014
|
-
|
|
2034
|
+
React__default.useEffect(() => {
|
|
2015
2035
|
if (control._proxyFormState.isDirty) {
|
|
2016
2036
|
const isDirty = control._getDirty();
|
|
2017
2037
|
if (isDirty !== formState.isDirty) {
|
|
@@ -2021,7 +2041,7 @@ function useForm(props = {}) {
|
|
|
2021
2041
|
}
|
|
2022
2042
|
}
|
|
2023
2043
|
}, [control, formState.isDirty]);
|
|
2024
|
-
|
|
2044
|
+
React__default.useEffect(() => {
|
|
2025
2045
|
if (props.values && !deepEqual(props.values, _values.current)) {
|
|
2026
2046
|
control._reset(props.values, control._options.resetOptions);
|
|
2027
2047
|
_values.current = props.values;
|
|
@@ -2031,7 +2051,7 @@ function useForm(props = {}) {
|
|
|
2031
2051
|
control._resetDefaultValues();
|
|
2032
2052
|
}
|
|
2033
2053
|
}, [control, props.values]);
|
|
2034
|
-
|
|
2054
|
+
React__default.useEffect(() => {
|
|
2035
2055
|
if (!control._state.mount) {
|
|
2036
2056
|
control._setValid();
|
|
2037
2057
|
control._state.mount = true;
|
|
@@ -2048,7 +2068,7 @@ function useForm(props = {}) {
|
|
|
2048
2068
|
|
|
2049
2069
|
const Form = ({ onSubmit, children, defaultValues = {}, formRef }) => {
|
|
2050
2070
|
const { control, handleSubmit, formState: { errors } } = useForm({ defaultValues });
|
|
2051
|
-
return (jsx("form", { ref: formRef, onSubmit: handleSubmit(onSubmit), children: children({ control, errors, handleSubmit }) }));
|
|
2071
|
+
return (jsxRuntime$1.jsx("form", { ref: formRef, onSubmit: handleSubmit(onSubmit), children: children({ control, errors, handleSubmit }) }));
|
|
2052
2072
|
};
|
|
2053
2073
|
|
|
2054
2074
|
const sizeClassMap = {
|
|
@@ -2060,20 +2080,20 @@ const sizeClassMap = {
|
|
|
2060
2080
|
const Modal = ({ open, onClose, children, actions, header, footer, size = 'md' }) => {
|
|
2061
2081
|
if (!open)
|
|
2062
2082
|
return null;
|
|
2063
|
-
return (jsxs("div", { className: "fixed inset-0 z-50 flex items-center justify-center", children: [jsx("div", { className: "fixed inset-0 bg-black bg-opacity-40 transition-opacity", onClick: onClose }), jsxs("div", { className: `relative bg-white shadow-lg w-full mx-4 z-10 animate-fade-in ${sizeClassMap[size]}${size === 'full' ? '' : ' rounded-lg'}`, children: [header && jsx("div", { className: "px-6 py-4 border-b", children: header }), jsx("div", { className: "px-6 py-4", children: children }), actions && jsx("div", { className: "px-6 py-3 border-t flex justify-end gap-2", children: actions }), footer && jsx("div", { className: "px-6 py-3 border-t", children: footer }), jsx("button", { className: "absolute top-2 right-2 text-gray-400 hover:text-gray-600 focus:outline-none", onClick: onClose, "aria-label": "Close", children: jsx(X, { size: 20 }) })] })] }));
|
|
2083
|
+
return (jsxRuntime$1.jsxs("div", { className: "fixed inset-0 z-50 flex items-center justify-center", children: [jsxRuntime$1.jsx("div", { className: "fixed inset-0 bg-black bg-opacity-40 transition-opacity", onClick: onClose }), jsxRuntime$1.jsxs("div", { className: `relative bg-white shadow-lg w-full mx-4 z-10 animate-fade-in ${sizeClassMap[size]}${size === 'full' ? '' : ' rounded-lg'}`, children: [header && jsxRuntime$1.jsx("div", { className: "px-6 py-4 border-b", children: header }), jsxRuntime$1.jsx("div", { className: "px-6 py-4", children: children }), actions && jsxRuntime$1.jsx("div", { className: "px-6 py-3 border-t flex justify-end gap-2", children: actions }), footer && jsxRuntime$1.jsx("div", { className: "px-6 py-3 border-t", children: footer }), jsxRuntime$1.jsx("button", { className: "absolute top-2 right-2 text-gray-400 hover:text-gray-600 focus:outline-none", onClick: onClose, "aria-label": "Close", children: jsxRuntime$1.jsx(LucideIcons.X, { size: 20 }) })] })] }));
|
|
2064
2084
|
};
|
|
2065
2085
|
|
|
2066
|
-
const Card =
|
|
2086
|
+
const Card = React__default__namespace.forwardRef(({ className, ...props }, ref) => (jsxRuntime$1.jsx("div", { ref: ref, className: cn("rounded-xl border bg-card text-card-foreground shadow", className), ...props })));
|
|
2067
2087
|
Card.displayName = "Card";
|
|
2068
|
-
const CardHeader =
|
|
2088
|
+
const CardHeader = React__default__namespace.forwardRef(({ className, ...props }, ref) => (jsxRuntime$1.jsx("div", { ref: ref, className: cn("flex flex-col space-y-1.5 p-6", className), ...props })));
|
|
2069
2089
|
CardHeader.displayName = "CardHeader";
|
|
2070
|
-
const CardTitle =
|
|
2090
|
+
const CardTitle = React__default__namespace.forwardRef(({ className, ...props }, ref) => (jsxRuntime$1.jsx("h3", { ref: ref, className: cn("font-semibold leading-none tracking-tight", className), ...props })));
|
|
2071
2091
|
CardTitle.displayName = "CardTitle";
|
|
2072
|
-
const CardDescription =
|
|
2092
|
+
const CardDescription = React__default__namespace.forwardRef(({ className, ...props }, ref) => (jsxRuntime$1.jsx("p", { ref: ref, className: cn("text-sm text-gray-500", className), ...props })));
|
|
2073
2093
|
CardDescription.displayName = "CardDescription";
|
|
2074
|
-
const CardContent =
|
|
2094
|
+
const CardContent = React__default__namespace.forwardRef(({ className, ...props }, ref) => (jsxRuntime$1.jsx("div", { ref: ref, className: cn("p-6 pt-0", className), ...props })));
|
|
2075
2095
|
CardContent.displayName = "CardContent";
|
|
2076
|
-
const CardFooter =
|
|
2096
|
+
const CardFooter = React__default__namespace.forwardRef(({ className, ...props }, ref) => (jsxRuntime$1.jsx("div", { ref: ref, className: cn("flex items-center p-6 pt-0", className), ...props })));
|
|
2077
2097
|
CardFooter.displayName = "CardFooter";
|
|
2078
2098
|
|
|
2079
2099
|
/**
|
|
@@ -5367,7 +5387,7 @@ function getSortedRowModel() {
|
|
|
5367
5387
|
* If rendering headers, cells, or footers with custom markup, use flexRender instead of `cell.getValue()` or `cell.renderValue()`.
|
|
5368
5388
|
*/
|
|
5369
5389
|
function flexRender(Comp, props) {
|
|
5370
|
-
return !Comp ? null : isReactComponent(Comp) ? /*#__PURE__*/
|
|
5390
|
+
return !Comp ? null : isReactComponent(Comp) ? /*#__PURE__*/React__default__namespace.createElement(Comp, props) : Comp;
|
|
5371
5391
|
}
|
|
5372
5392
|
function isReactComponent(component) {
|
|
5373
5393
|
return isClassComponent(component) || typeof component === 'function' || isExoticComponent(component);
|
|
@@ -5393,12 +5413,12 @@ function useReactTable(options) {
|
|
|
5393
5413
|
};
|
|
5394
5414
|
|
|
5395
5415
|
// Create a new table and store it in state
|
|
5396
|
-
const [tableRef] =
|
|
5416
|
+
const [tableRef] = React__default__namespace.useState(() => ({
|
|
5397
5417
|
current: createTable(resolvedOptions)
|
|
5398
5418
|
}));
|
|
5399
5419
|
|
|
5400
5420
|
// By default, manage table state here using the table's initial state
|
|
5401
|
-
const [state, setState] =
|
|
5421
|
+
const [state, setState] = React__default__namespace.useState(() => tableRef.current.initialState);
|
|
5402
5422
|
|
|
5403
5423
|
// Compose the default state above with any user state. This will allow the user
|
|
5404
5424
|
// to only control a subset of the state if desired.
|
|
@@ -5420,9 +5440,9 @@ function useReactTable(options) {
|
|
|
5420
5440
|
}
|
|
5421
5441
|
|
|
5422
5442
|
const TableBody = ({ table, onRowClick }) => {
|
|
5423
|
-
return (jsx("div", { className: "flex-1 overflow-auto", children: jsxs("table", { className: "w-full border-collapse", children: [jsx("thead", { className: "bg-gray-50", children: table.getHeaderGroups().map(headerGroup => (jsx("tr", { children: headerGroup.headers.map(header => (jsx("th", { className: "px-4 py-2 text-left text-sm font-medium text-gray-500 border-b", children: header.isPlaceholder
|
|
5443
|
+
return (jsxRuntime$1.jsx("div", { className: "flex-1 overflow-auto", children: jsxRuntime$1.jsxs("table", { className: "w-full border-collapse", children: [jsxRuntime$1.jsx("thead", { className: "bg-gray-50", children: table.getHeaderGroups().map(headerGroup => (jsxRuntime$1.jsx("tr", { children: headerGroup.headers.map(header => (jsxRuntime$1.jsx("th", { className: "px-4 py-2 text-left text-sm font-medium text-gray-500 border-b", children: header.isPlaceholder
|
|
5424
5444
|
? null
|
|
5425
|
-
: flexRender(header.column.columnDef.header, header.getContext()) }, header.id))) }, headerGroup.id))) }), jsx("tbody", { children: table.getRowModel().rows.map(row => (jsx("tr", { onClick: () => onRowClick?.(row), className: `border-b hover:bg-gray-50 ${onRowClick ? 'cursor-pointer' : ''}`, children: row.getVisibleCells().map(cell => (jsx("td", { className: "px-4 py-2 text-sm", children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id))) }, row.id))) })] }) }));
|
|
5445
|
+
: flexRender(header.column.columnDef.header, header.getContext()) }, header.id))) }, headerGroup.id))) }), jsxRuntime$1.jsx("tbody", { children: table.getRowModel().rows.map(row => (jsxRuntime$1.jsx("tr", { onClick: () => onRowClick?.(row), className: `border-b hover:bg-gray-50 ${onRowClick ? 'cursor-pointer' : ''}`, children: row.getVisibleCells().map(cell => (jsxRuntime$1.jsx("td", { className: "px-4 py-2 text-sm", children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id))) }, row.id))) })] }) }));
|
|
5426
5446
|
};
|
|
5427
5447
|
|
|
5428
5448
|
function getDefaultExportFromCjs$1 (x) {
|
|
@@ -6107,7 +6127,7 @@ function requireReactJsxRuntime_development () {
|
|
|
6107
6127
|
"\n\nCheck the top-level render call using <" + parentType + ">."));
|
|
6108
6128
|
return info;
|
|
6109
6129
|
}
|
|
6110
|
-
var React =
|
|
6130
|
+
var React = React__default,
|
|
6111
6131
|
REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
|
|
6112
6132
|
REACT_PORTAL_TYPE = Symbol.for("react.portal"),
|
|
6113
6133
|
REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
|
|
@@ -6426,7 +6446,7 @@ const BUTTON_COLOR = {
|
|
|
6426
6446
|
}
|
|
6427
6447
|
};
|
|
6428
6448
|
|
|
6429
|
-
const DatepickerContext = createContext({
|
|
6449
|
+
const DatepickerContext = React__default.createContext({
|
|
6430
6450
|
arrowContainer: null,
|
|
6431
6451
|
asSingle: false,
|
|
6432
6452
|
calendarContainer: null,
|
|
@@ -7155,9 +7175,9 @@ const DoubleChevronRightIcon = (props) => {
|
|
|
7155
7175
|
const RoundedButton = (props) => {
|
|
7156
7176
|
const { children, onClick, disabled, roundedFull = false, padding = "py-[0.55rem]", active = false } = props;
|
|
7157
7177
|
// Contexts
|
|
7158
|
-
const { primaryColor } = useContext(DatepickerContext);
|
|
7178
|
+
const { primaryColor } = React__default.useContext(DatepickerContext);
|
|
7159
7179
|
// Functions
|
|
7160
|
-
const getClassName = useCallback(() => {
|
|
7180
|
+
const getClassName = React__default.useCallback(() => {
|
|
7161
7181
|
const darkClass = "dark:text-white/70 dark:hover:bg-white/10 dark:focus:bg-white/10";
|
|
7162
7182
|
const activeClass = active ? "font-semibold bg-gray-50 dark:bg-white/5" : "";
|
|
7163
7183
|
const defaultClass = !roundedFull
|
|
@@ -7191,14 +7211,14 @@ const Days = (props) => {
|
|
|
7191
7211
|
// Props
|
|
7192
7212
|
const { days, onClickPreviousDays, onClickDay, onClickNextDays } = props;
|
|
7193
7213
|
// Contexts
|
|
7194
|
-
const { primaryColor, period, changePeriod, dayHover, changeDayHover, minDate, maxDate, disabledDates } = useContext(DatepickerContext);
|
|
7214
|
+
const { primaryColor, period, changePeriod, dayHover, changeDayHover, minDate, maxDate, disabledDates } = React__default.useContext(DatepickerContext);
|
|
7195
7215
|
// Functions
|
|
7196
|
-
const currentDateClass = useCallback((day) => {
|
|
7216
|
+
const currentDateClass = React__default.useCallback((day) => {
|
|
7197
7217
|
if (isCurrentDay(day))
|
|
7198
7218
|
return TEXT_COLOR["500"][primaryColor];
|
|
7199
7219
|
return "";
|
|
7200
7220
|
}, [primaryColor]);
|
|
7201
|
-
const activeDateData = useCallback((day) => {
|
|
7221
|
+
const activeDateData = React__default.useCallback((day) => {
|
|
7202
7222
|
let className = "";
|
|
7203
7223
|
const dayIsSameStart = period.start && dateIsSame(day, period.start, "date");
|
|
7204
7224
|
const dayIsSameEnd = period.end && dateIsSame(day, period.end, "date");
|
|
@@ -7217,7 +7237,7 @@ const Days = (props) => {
|
|
|
7217
7237
|
className: className
|
|
7218
7238
|
};
|
|
7219
7239
|
}, [dayHover, period.end, period.start, primaryColor]);
|
|
7220
|
-
const hoverClassByDay = useCallback((day) => {
|
|
7240
|
+
const hoverClassByDay = React__default.useCallback((day) => {
|
|
7221
7241
|
let className = currentDateClass(day);
|
|
7222
7242
|
if (period.start && period.end) {
|
|
7223
7243
|
if (dateIsBetween(day, period.start, period.end, "day", { start: true, end: false })) {
|
|
@@ -7241,17 +7261,17 @@ const Days = (props) => {
|
|
|
7241
7261
|
}
|
|
7242
7262
|
return className;
|
|
7243
7263
|
}, [currentDateClass, dayHover, period.end, period.start, primaryColor]);
|
|
7244
|
-
const isDateTooEarly = useCallback((day) => {
|
|
7264
|
+
const isDateTooEarly = React__default.useCallback((day) => {
|
|
7245
7265
|
if (!minDate)
|
|
7246
7266
|
return false;
|
|
7247
7267
|
return dateIsBefore(day, minDate, "date");
|
|
7248
7268
|
}, [minDate]);
|
|
7249
|
-
const isDateTooLate = useCallback((day) => {
|
|
7269
|
+
const isDateTooLate = React__default.useCallback((day) => {
|
|
7250
7270
|
if (!maxDate)
|
|
7251
7271
|
return false;
|
|
7252
7272
|
return dateIsAfter(day, maxDate, "date");
|
|
7253
7273
|
}, [maxDate]);
|
|
7254
|
-
const isDateDisabled = useCallback((day) => {
|
|
7274
|
+
const isDateDisabled = React__default.useCallback((day) => {
|
|
7255
7275
|
if (isDateTooEarly(day) || isDateTooLate(day)) {
|
|
7256
7276
|
return true;
|
|
7257
7277
|
}
|
|
@@ -7271,7 +7291,7 @@ const Days = (props) => {
|
|
|
7271
7291
|
});
|
|
7272
7292
|
return matchingCount > 0;
|
|
7273
7293
|
}, [isDateTooEarly, isDateTooLate, disabledDates]);
|
|
7274
|
-
const buttonClass = useCallback((day, type) => {
|
|
7294
|
+
const buttonClass = React__default.useCallback((day, type) => {
|
|
7275
7295
|
const baseClass = "flex items-center justify-center w-12 h-12 lg:w-10 lg:h-10";
|
|
7276
7296
|
if (type === "current") {
|
|
7277
7297
|
return classNames(baseClass, !activeDateData(day).active
|
|
@@ -7280,7 +7300,7 @@ const Days = (props) => {
|
|
|
7280
7300
|
}
|
|
7281
7301
|
return classNames(baseClass, isDateDisabled(day) && "line-through", "text-gray-400");
|
|
7282
7302
|
}, [activeDateData, hoverClassByDay, isDateDisabled]);
|
|
7283
|
-
const checkIfHoverPeriodContainsDisabledPeriod = useCallback((hoverPeriod) => {
|
|
7303
|
+
const checkIfHoverPeriodContainsDisabledPeriod = React__default.useCallback((hoverPeriod) => {
|
|
7284
7304
|
if (!Array.isArray(disabledDates)) {
|
|
7285
7305
|
return false;
|
|
7286
7306
|
}
|
|
@@ -7292,7 +7312,7 @@ const Days = (props) => {
|
|
|
7292
7312
|
}
|
|
7293
7313
|
return false;
|
|
7294
7314
|
}, [disabledDates]);
|
|
7295
|
-
const hoverDay = useCallback((day) => {
|
|
7315
|
+
const hoverDay = React__default.useCallback((day) => {
|
|
7296
7316
|
if (period.start && !period.end) {
|
|
7297
7317
|
const hoverPeriod = { ...period, end: day };
|
|
7298
7318
|
if (dateIsBefore(day, period.start, "date")) {
|
|
@@ -7326,7 +7346,7 @@ const Days = (props) => {
|
|
|
7326
7346
|
}
|
|
7327
7347
|
}
|
|
7328
7348
|
}, [changeDayHover, changePeriod, checkIfHoverPeriodContainsDisabledPeriod, period]);
|
|
7329
|
-
const handleClickDay = useCallback((day, type) => {
|
|
7349
|
+
const handleClickDay = React__default.useCallback((day, type) => {
|
|
7330
7350
|
function continueClick() {
|
|
7331
7351
|
if (type === "previous") {
|
|
7332
7352
|
onClickPreviousDays(day);
|
|
@@ -7373,8 +7393,8 @@ const Days = (props) => {
|
|
|
7373
7393
|
|
|
7374
7394
|
const Months = (props) => {
|
|
7375
7395
|
const { currentMonth, clickMonth } = props;
|
|
7376
|
-
const { i18n } = useContext(DatepickerContext);
|
|
7377
|
-
useEffect(() => {
|
|
7396
|
+
const { i18n } = React__default.useContext(DatepickerContext);
|
|
7397
|
+
React__default.useEffect(() => {
|
|
7378
7398
|
loadLanguageModule(i18n);
|
|
7379
7399
|
}, [i18n]);
|
|
7380
7400
|
return (jsxRuntimeExports.jsx("div", { className: "w-full grid grid-cols-2 gap-2 mt-2", children: MONTHS.map(item => (jsxRuntimeExports.jsx(RoundedButton, { padding: "py-3", onClick: () => {
|
|
@@ -7383,11 +7403,11 @@ const Months = (props) => {
|
|
|
7383
7403
|
};
|
|
7384
7404
|
|
|
7385
7405
|
const Week = () => {
|
|
7386
|
-
const { i18n, startWeekOn } = useContext(DatepickerContext);
|
|
7387
|
-
useEffect(() => {
|
|
7406
|
+
const { i18n, startWeekOn } = React__default.useContext(DatepickerContext);
|
|
7407
|
+
React__default.useEffect(() => {
|
|
7388
7408
|
loadLanguageModule(i18n);
|
|
7389
7409
|
}, [i18n]);
|
|
7390
|
-
const startDateModifier = useMemo(() => {
|
|
7410
|
+
const startDateModifier = React__default.useMemo(() => {
|
|
7391
7411
|
if (startWeekOn) {
|
|
7392
7412
|
switch (startWeekOn) {
|
|
7393
7413
|
case "mon":
|
|
@@ -7415,8 +7435,8 @@ const Week = () => {
|
|
|
7415
7435
|
|
|
7416
7436
|
const Years = (props) => {
|
|
7417
7437
|
const { year, currentYear, minYear, maxYear, clickYear } = props;
|
|
7418
|
-
const { dateLooking } = useContext(DatepickerContext);
|
|
7419
|
-
const date = useMemo(() => {
|
|
7438
|
+
const { dateLooking } = React__default.useContext(DatepickerContext);
|
|
7439
|
+
const date = React__default.useMemo(() => {
|
|
7420
7440
|
let start;
|
|
7421
7441
|
let end;
|
|
7422
7442
|
switch (dateLooking) {
|
|
@@ -7450,34 +7470,34 @@ const Calendar = (props) => {
|
|
|
7450
7470
|
// Props
|
|
7451
7471
|
const { date, minDate, maxDate, onClickPrevious, onClickNext, changeMonth, changeYear } = props;
|
|
7452
7472
|
// Contexts
|
|
7453
|
-
const { period, changePeriod, changeDayHover, showFooter, changeDatepickerValue, hideDatepicker, asSingle, i18n, startWeekOn, input } = useContext(DatepickerContext);
|
|
7473
|
+
const { period, changePeriod, changeDayHover, showFooter, changeDatepickerValue, hideDatepicker, asSingle, i18n, startWeekOn, input } = React__default.useContext(DatepickerContext);
|
|
7454
7474
|
loadLanguageModule(i18n);
|
|
7455
7475
|
// States
|
|
7456
|
-
const [showMonths, setShowMonths] = useState(false);
|
|
7457
|
-
const [showYears, setShowYears] = useState(false);
|
|
7458
|
-
const [year, setYear] = useState(date.getFullYear());
|
|
7476
|
+
const [showMonths, setShowMonths] = React__default.useState(false);
|
|
7477
|
+
const [showYears, setShowYears] = React__default.useState(false);
|
|
7478
|
+
const [year, setYear] = React__default.useState(date.getFullYear());
|
|
7459
7479
|
// Functions
|
|
7460
|
-
const hideMonths = useCallback(() => {
|
|
7480
|
+
const hideMonths = React__default.useCallback(() => {
|
|
7461
7481
|
if (showMonths)
|
|
7462
7482
|
setShowMonths(false);
|
|
7463
7483
|
}, [showMonths]);
|
|
7464
|
-
const hideYears = useCallback(() => {
|
|
7484
|
+
const hideYears = React__default.useCallback(() => {
|
|
7465
7485
|
if (showYears)
|
|
7466
7486
|
setShowYears(false);
|
|
7467
7487
|
}, [showYears]);
|
|
7468
|
-
const clickMonth = useCallback((month) => {
|
|
7488
|
+
const clickMonth = React__default.useCallback((month) => {
|
|
7469
7489
|
setTimeout(() => {
|
|
7470
7490
|
changeMonth(month);
|
|
7471
7491
|
setShowMonths(!showMonths);
|
|
7472
7492
|
}, 250);
|
|
7473
7493
|
}, [changeMonth, showMonths]);
|
|
7474
|
-
const clickYear = useCallback((year) => {
|
|
7494
|
+
const clickYear = React__default.useCallback((year) => {
|
|
7475
7495
|
setTimeout(() => {
|
|
7476
7496
|
changeYear(year);
|
|
7477
7497
|
setShowYears(!showYears);
|
|
7478
7498
|
}, 250);
|
|
7479
7499
|
}, [changeYear, showYears]);
|
|
7480
|
-
const clickDay = useCallback((day, after) => {
|
|
7500
|
+
const clickDay = React__default.useCallback((day, after) => {
|
|
7481
7501
|
let newStart;
|
|
7482
7502
|
let newEnd = null;
|
|
7483
7503
|
function chosePeriod(start, end) {
|
|
@@ -7549,22 +7569,22 @@ const Calendar = (props) => {
|
|
|
7549
7569
|
showFooter,
|
|
7550
7570
|
input
|
|
7551
7571
|
]);
|
|
7552
|
-
const clickPreviousDays = useCallback((day) => {
|
|
7572
|
+
const clickPreviousDays = React__default.useCallback((day) => {
|
|
7553
7573
|
clickDay(day, () => {
|
|
7554
7574
|
onClickPrevious();
|
|
7555
7575
|
});
|
|
7556
7576
|
}, [clickDay, onClickPrevious]);
|
|
7557
|
-
const clickNextDays = useCallback((day) => {
|
|
7577
|
+
const clickNextDays = React__default.useCallback((day) => {
|
|
7558
7578
|
clickDay(day, () => {
|
|
7559
7579
|
onClickNext();
|
|
7560
7580
|
});
|
|
7561
7581
|
}, [clickDay, onClickNext]);
|
|
7562
7582
|
// UseEffects & UseLayoutEffect
|
|
7563
|
-
useEffect(() => {
|
|
7583
|
+
React__default.useEffect(() => {
|
|
7564
7584
|
setYear(date.getFullYear());
|
|
7565
7585
|
}, [date]);
|
|
7566
7586
|
// Variables
|
|
7567
|
-
const calendarData = useMemo(() => {
|
|
7587
|
+
const calendarData = React__default.useMemo(() => {
|
|
7568
7588
|
const firstDateCurrentMonth = firstDayOfMonth(date);
|
|
7569
7589
|
const lastDateCurrentMonth = endDayOfMonth(date);
|
|
7570
7590
|
const startWeekOnIndex = weekDayStringToIndex(startWeekOn || START_WEEK);
|
|
@@ -7582,7 +7602,7 @@ const Calendar = (props) => {
|
|
|
7582
7602
|
next: next
|
|
7583
7603
|
};
|
|
7584
7604
|
}, [date, startWeekOn]);
|
|
7585
|
-
const years = useMemo(() => {
|
|
7605
|
+
const years = React__default.useMemo(() => {
|
|
7586
7606
|
return {
|
|
7587
7607
|
min: minDate && dateIsValid(minDate) ? minDate.getFullYear() : null,
|
|
7588
7608
|
max: maxDate && dateIsValid(maxDate) ? maxDate.getFullYear() : null
|
|
@@ -7604,13 +7624,13 @@ const Calendar = (props) => {
|
|
|
7604
7624
|
const PrimaryButton = (props) => {
|
|
7605
7625
|
const { children, onClick, disabled = false } = props;
|
|
7606
7626
|
// Contexts
|
|
7607
|
-
const { primaryColor } = useContext(DatepickerContext);
|
|
7627
|
+
const { primaryColor } = React__default.useContext(DatepickerContext);
|
|
7608
7628
|
const bgColor = BG_COLOR["500"][primaryColor];
|
|
7609
7629
|
const borderColor = BORDER_COLOR["500"][primaryColor];
|
|
7610
7630
|
const bgColorHover = BG_COLOR.hover[primaryColor];
|
|
7611
7631
|
const ringColor = RING_COLOR.focus[primaryColor];
|
|
7612
7632
|
// Functions
|
|
7613
|
-
const getClassName = useCallback(() => {
|
|
7633
|
+
const getClassName = React__default.useCallback(() => {
|
|
7614
7634
|
return `w-full transition-all duration-300 ${bgColor} ${borderColor} text-white font-medium border px-4 py-2 text-sm rounded-md focus:ring-2 focus:ring-offset-2 ${bgColorHover} ${ringColor} ${disabled ? " cursor-no-drop" : ""}`;
|
|
7615
7635
|
}, [bgColor, bgColorHover, borderColor, disabled, ringColor]);
|
|
7616
7636
|
return (jsxRuntimeExports.jsx("button", { type: "button", className: getClassName(), onClick: onClick, disabled: disabled, children: children }));
|
|
@@ -7619,9 +7639,9 @@ const PrimaryButton = (props) => {
|
|
|
7619
7639
|
const SecondaryButton = (props) => {
|
|
7620
7640
|
const { children, onClick, disabled = false } = props;
|
|
7621
7641
|
// Contexts
|
|
7622
|
-
const { primaryColor } = useContext(DatepickerContext);
|
|
7642
|
+
const { primaryColor } = React__default.useContext(DatepickerContext);
|
|
7623
7643
|
// Functions
|
|
7624
|
-
const getClassName = useCallback(() => {
|
|
7644
|
+
const getClassName = React__default.useCallback(() => {
|
|
7625
7645
|
const ringColor = RING_COLOR.focus[primaryColor];
|
|
7626
7646
|
return `w-full transition-all duration-300 bg-white dark:text-gray-700 font-medium border border-gray-300 px-4 py-2 text-sm rounded-md focus:ring-2 focus:ring-offset-2 hover:bg-gray-50 ${ringColor}`;
|
|
7627
7647
|
}, [primaryColor]);
|
|
@@ -7630,9 +7650,9 @@ const SecondaryButton = (props) => {
|
|
|
7630
7650
|
|
|
7631
7651
|
const Footer = () => {
|
|
7632
7652
|
// Contexts
|
|
7633
|
-
const { hideDatepicker, period, changeDatepickerValue, configs, classNames, input } = useContext(DatepickerContext);
|
|
7653
|
+
const { hideDatepicker, period, changeDatepickerValue, configs, classNames, input } = React__default.useContext(DatepickerContext);
|
|
7634
7654
|
// Functions
|
|
7635
|
-
const getClassName = useCallback(() => {
|
|
7655
|
+
const getClassName = React__default.useCallback(() => {
|
|
7636
7656
|
if (typeof classNames !== "undefined" && typeof classNames?.footer === "function") {
|
|
7637
7657
|
return classNames.footer();
|
|
7638
7658
|
}
|
|
@@ -7667,12 +7687,12 @@ const ToggleButton = (e) => {
|
|
|
7667
7687
|
|
|
7668
7688
|
const Input = () => {
|
|
7669
7689
|
// Context
|
|
7670
|
-
const { primaryColor, period, dayHover, changeDayHover, calendarContainer, arrowContainer, inputText, changeInputText, hideDatepicker, changeDatepickerValue, asSingle, placeholder, separator, disabled, inputClassName, toggleClassName, toggleIcon, readOnly, displayFormat, inputId, inputName, classNames, popoverDirection, required, input, setInput } = useContext(DatepickerContext);
|
|
7690
|
+
const { primaryColor, period, dayHover, changeDayHover, calendarContainer, arrowContainer, inputText, changeInputText, hideDatepicker, changeDatepickerValue, asSingle, placeholder, separator, disabled, inputClassName, toggleClassName, toggleIcon, readOnly, displayFormat, inputId, inputName, classNames, popoverDirection, required, input, setInput } = React__default.useContext(DatepickerContext);
|
|
7671
7691
|
// UseRefs
|
|
7672
|
-
const buttonRef = useRef(null);
|
|
7673
|
-
const inputRef = useRef(null);
|
|
7692
|
+
const buttonRef = React__default.useRef(null);
|
|
7693
|
+
const inputRef = React__default.useRef(null);
|
|
7674
7694
|
// Functions
|
|
7675
|
-
const getClassName = useCallback(() => {
|
|
7695
|
+
const getClassName = React__default.useCallback(() => {
|
|
7676
7696
|
const input = inputRef.current;
|
|
7677
7697
|
if (input && typeof classNames !== "undefined" && typeof classNames?.input === "function") {
|
|
7678
7698
|
return classNames.input(input);
|
|
@@ -7686,7 +7706,7 @@ const Input = () => {
|
|
|
7686
7706
|
? inputClassName
|
|
7687
7707
|
: defaultInputClassName;
|
|
7688
7708
|
}, [inputRef, classNames, primaryColor, inputClassName]);
|
|
7689
|
-
const handleInputChange = useCallback((e) => {
|
|
7709
|
+
const handleInputChange = React__default.useCallback((e) => {
|
|
7690
7710
|
const inputValue = e.target.value;
|
|
7691
7711
|
const dates = [];
|
|
7692
7712
|
if (asSingle) {
|
|
@@ -7728,7 +7748,7 @@ const Input = () => {
|
|
|
7728
7748
|
}
|
|
7729
7749
|
changeInputText(e.target.value);
|
|
7730
7750
|
}, [asSingle, separator, changeDatepickerValue, changeDayHover, changeInputText]);
|
|
7731
|
-
const handleInputKeyDown = useCallback((e) => {
|
|
7751
|
+
const handleInputKeyDown = React__default.useCallback((e) => {
|
|
7732
7752
|
if (e.key === "Enter") {
|
|
7733
7753
|
const input = inputRef.current;
|
|
7734
7754
|
if (input) {
|
|
@@ -7737,10 +7757,10 @@ const Input = () => {
|
|
|
7737
7757
|
hideDatepicker();
|
|
7738
7758
|
}
|
|
7739
7759
|
}, [hideDatepicker]);
|
|
7740
|
-
const renderToggleIcon = useCallback((isEmpty) => {
|
|
7760
|
+
const renderToggleIcon = React__default.useCallback((isEmpty) => {
|
|
7741
7761
|
return typeof toggleIcon === "undefined" ? (jsxRuntimeExports.jsx(ToggleButton, { isEmpty: isEmpty })) : (toggleIcon(isEmpty));
|
|
7742
7762
|
}, [toggleIcon]);
|
|
7743
|
-
const getToggleClassName = useCallback(() => {
|
|
7763
|
+
const getToggleClassName = React__default.useCallback(() => {
|
|
7744
7764
|
const button = buttonRef.current;
|
|
7745
7765
|
if (button &&
|
|
7746
7766
|
typeof classNames !== "undefined" &&
|
|
@@ -7755,12 +7775,12 @@ const Input = () => {
|
|
|
7755
7775
|
: defaultToggleClassName;
|
|
7756
7776
|
}, [toggleClassName, buttonRef, classNames]);
|
|
7757
7777
|
// UseEffects && UseLayoutEffect
|
|
7758
|
-
useEffect(() => {
|
|
7778
|
+
React__default.useEffect(() => {
|
|
7759
7779
|
if (!input && inputRef?.current) {
|
|
7760
7780
|
setInput(inputRef.current);
|
|
7761
7781
|
}
|
|
7762
7782
|
}, [input, inputRef, setInput]);
|
|
7763
|
-
useEffect(() => {
|
|
7783
|
+
React__default.useEffect(() => {
|
|
7764
7784
|
const button = buttonRef?.current;
|
|
7765
7785
|
function focusInput(e) {
|
|
7766
7786
|
e.stopPropagation();
|
|
@@ -7799,7 +7819,7 @@ const Input = () => {
|
|
|
7799
7819
|
period.start,
|
|
7800
7820
|
inputRef
|
|
7801
7821
|
]);
|
|
7802
|
-
useEffect(() => {
|
|
7822
|
+
React__default.useEffect(() => {
|
|
7803
7823
|
const div = calendarContainer?.current;
|
|
7804
7824
|
const input = inputRef.current;
|
|
7805
7825
|
const arrow = arrowContainer?.current;
|
|
@@ -7895,15 +7915,15 @@ const DEFAULT_SHORTCUTS = {
|
|
|
7895
7915
|
}
|
|
7896
7916
|
};
|
|
7897
7917
|
|
|
7898
|
-
const ItemTemplate = memo
|
|
7899
|
-
const { primaryColor, period, changePeriod, updateFirstDate, dayHover, changeDayHover, hideDatepicker, changeDatepickerValue, input } = useContext(DatepickerContext);
|
|
7918
|
+
const ItemTemplate = React__default.memo((props) => {
|
|
7919
|
+
const { primaryColor, period, changePeriod, updateFirstDate, dayHover, changeDayHover, hideDatepicker, changeDatepickerValue, input } = React__default.useContext(DatepickerContext);
|
|
7900
7920
|
// Functions
|
|
7901
|
-
const getClassName = useCallback(() => {
|
|
7921
|
+
const getClassName = React__default.useCallback(() => {
|
|
7902
7922
|
const textColor = TEXT_COLOR["600"][primaryColor];
|
|
7903
7923
|
const textColorHover = TEXT_COLOR.hover[primaryColor];
|
|
7904
7924
|
return `whitespace-nowrap w-1/2 md:w-1/3 lg:w-auto transition-all duration-300 hover:bg-gray-100 dark:hover:bg-white/10 p-2 rounded cursor-pointer ${textColor} ${textColorHover}`;
|
|
7905
7925
|
}, [primaryColor]);
|
|
7906
|
-
const chosePeriod = useCallback((item) => {
|
|
7926
|
+
const chosePeriod = React__default.useCallback((item) => {
|
|
7907
7927
|
if (dayHover) {
|
|
7908
7928
|
changeDayHover(null);
|
|
7909
7929
|
}
|
|
@@ -7942,11 +7962,11 @@ const ItemTemplate = memo$1((props) => {
|
|
|
7942
7962
|
ItemTemplate.displayName = "ItemTemplate";
|
|
7943
7963
|
const Shortcuts = () => {
|
|
7944
7964
|
// Contexts
|
|
7945
|
-
const { configs } = useContext(DatepickerContext);
|
|
7946
|
-
const callPastFunction = useCallback((data, numberValue) => {
|
|
7965
|
+
const { configs } = React__default.useContext(DatepickerContext);
|
|
7966
|
+
const callPastFunction = React__default.useCallback((data, numberValue) => {
|
|
7947
7967
|
return typeof data === "function" ? data(numberValue) : null;
|
|
7948
7968
|
}, []);
|
|
7949
|
-
const shortcutOptions = useMemo(() => {
|
|
7969
|
+
const shortcutOptions = React__default.useMemo(() => {
|
|
7950
7970
|
if (!configs?.shortcuts) {
|
|
7951
7971
|
return Object.entries(DEFAULT_SHORTCUTS);
|
|
7952
7972
|
}
|
|
@@ -7976,7 +7996,7 @@ const Shortcuts = () => {
|
|
|
7976
7996
|
return [];
|
|
7977
7997
|
});
|
|
7978
7998
|
}, [configs]);
|
|
7979
|
-
const printItemText = useCallback((item) => {
|
|
7999
|
+
const printItemText = React__default.useCallback((item) => {
|
|
7980
8000
|
return item?.text ?? null;
|
|
7981
8001
|
}, []);
|
|
7982
8002
|
return shortcutOptions?.length ? (jsxRuntimeExports.jsx("div", { className: "md:border-b mb-3 lg:mb-0 lg:border-r lg:border-b-0 border-gray-300 dark:border-gray-700 pr-1", children: jsxRuntimeExports.jsx("ul", { className: "w-full tracking-wide flex flex-wrap lg:flex-col pb-1 lg:pb-0", children: shortcutOptions.map(([key, item], index) => Array.isArray(item) ? (item.map((item, index) => (jsxRuntimeExports.jsx(ItemTemplate, { item: item, children: jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: key === "past" &&
|
|
@@ -7992,7 +8012,7 @@ const Shortcuts = () => {
|
|
|
7992
8012
|
};
|
|
7993
8013
|
|
|
7994
8014
|
function useOnClickOutside(ref, handler) {
|
|
7995
|
-
useEffect(() => {
|
|
8015
|
+
React__default.useEffect(() => {
|
|
7996
8016
|
const listener = (event) => {
|
|
7997
8017
|
if (!ref || ref.contains(event.target)) {
|
|
7998
8018
|
return;
|
|
@@ -8008,14 +8028,14 @@ function useOnClickOutside(ref, handler) {
|
|
|
8008
8028
|
}, [ref, handler]);
|
|
8009
8029
|
}
|
|
8010
8030
|
|
|
8011
|
-
const Arrow = forwardRef((props, ref) => {
|
|
8031
|
+
const Arrow = React__default.forwardRef((props, ref) => {
|
|
8012
8032
|
return (jsxRuntimeExports.jsx("div", { ...props, ref: ref, className: "absolute z-20 h-4 w-4 rotate-45 mt-0.5 ml-[1.2rem] border-l border-t border-gray-300 bg-white dark:bg-slate-800 dark:border-slate-600" }));
|
|
8013
8033
|
});
|
|
8014
8034
|
Arrow.displayName = "Arrow";
|
|
8015
8035
|
|
|
8016
8036
|
const VerticalDash = () => {
|
|
8017
8037
|
// Contexts
|
|
8018
|
-
const { primaryColor } = useContext(DatepickerContext);
|
|
8038
|
+
const { primaryColor } = React__default.useContext(DatepickerContext);
|
|
8019
8039
|
const bgColor = BG_COLOR["500"][primaryColor];
|
|
8020
8040
|
return jsxRuntimeExports.jsx("div", { className: `h-7 w-1 rounded-full hidden md:block ${bgColor || "bg-blue-500"}` });
|
|
8021
8041
|
};
|
|
@@ -8024,19 +8044,19 @@ const Datepicker = (props) => {
|
|
|
8024
8044
|
// Props
|
|
8025
8045
|
const { asSingle = false, classNames = undefined, configs = undefined, containerClassName = null, dateLooking = DEFAULT_DATE_LOOKING, disabledDates = null, disabled = false, displayFormat = DATE_FORMAT, i18n = LANGUAGE, inputClassName = null, inputId, inputName, minDate = undefined, maxDate = undefined, onChange, placeholder = null, popupClassName = null, popoverDirection = undefined, primaryColor = DEFAULT_COLOR, separator = DEFAULT_SEPARATOR, showFooter = false, showShortcuts = false, startFrom = null, startWeekOn = START_WEEK, readOnly = false, required = false, toggleClassName = null, toggleIcon = undefined, useRange = true, value = null } = props;
|
|
8026
8046
|
// Refs
|
|
8027
|
-
const containerRef = useRef(null);
|
|
8028
|
-
const calendarContainerRef = useRef(null);
|
|
8029
|
-
const arrowRef = useRef(null);
|
|
8047
|
+
const containerRef = React__default.useRef(null);
|
|
8048
|
+
const calendarContainerRef = React__default.useRef(null);
|
|
8049
|
+
const arrowRef = React__default.useRef(null);
|
|
8030
8050
|
// States
|
|
8031
|
-
const [firstDate, setFirstDate] = useState(startFrom && dateIsValid(startFrom) ? startFrom : new Date());
|
|
8032
|
-
const [secondDate, setSecondDate] = useState(nextMonthBy(firstDate));
|
|
8033
|
-
const [period, setPeriod] = useState({
|
|
8051
|
+
const [firstDate, setFirstDate] = React__default.useState(startFrom && dateIsValid(startFrom) ? startFrom : new Date());
|
|
8052
|
+
const [secondDate, setSecondDate] = React__default.useState(nextMonthBy(firstDate));
|
|
8053
|
+
const [period, setPeriod] = React__default.useState({
|
|
8034
8054
|
start: null,
|
|
8035
8055
|
end: null
|
|
8036
8056
|
});
|
|
8037
|
-
const [dayHover, setDayHover] = useState(null);
|
|
8038
|
-
const [inputText, setInputText] = useState("");
|
|
8039
|
-
const [input, setInput] = useState(null);
|
|
8057
|
+
const [dayHover, setDayHover] = React__default.useState(null);
|
|
8058
|
+
const [inputText, setInputText] = React__default.useState("");
|
|
8059
|
+
const [input, setInput] = React__default.useState(null);
|
|
8040
8060
|
// Custom Hooks use
|
|
8041
8061
|
useOnClickOutside(containerRef.current, () => {
|
|
8042
8062
|
const container = containerRef.current;
|
|
@@ -8045,7 +8065,7 @@ const Datepicker = (props) => {
|
|
|
8045
8065
|
}
|
|
8046
8066
|
});
|
|
8047
8067
|
// Functions
|
|
8048
|
-
const hideDatepicker = useCallback(() => {
|
|
8068
|
+
const hideDatepicker = React__default.useCallback(() => {
|
|
8049
8069
|
const div = calendarContainerRef.current;
|
|
8050
8070
|
const arrow = arrowRef.current;
|
|
8051
8071
|
if (arrow && div && div.classList.contains("block")) {
|
|
@@ -8068,48 +8088,48 @@ const Datepicker = (props) => {
|
|
|
8068
8088
|
}
|
|
8069
8089
|
}, []);
|
|
8070
8090
|
/* Start First */
|
|
8071
|
-
const firstGotoDate = useCallback((date) => {
|
|
8091
|
+
const firstGotoDate = React__default.useCallback((date) => {
|
|
8072
8092
|
if (dateIsSameOrAfter(date, secondDate, "date")) {
|
|
8073
8093
|
setSecondDate(nextMonthBy(date));
|
|
8074
8094
|
}
|
|
8075
8095
|
setFirstDate(date);
|
|
8076
8096
|
}, [secondDate]);
|
|
8077
|
-
const previousMonthFirst = useCallback(() => {
|
|
8097
|
+
const previousMonthFirst = React__default.useCallback(() => {
|
|
8078
8098
|
setFirstDate(previousMonthBy(firstDate));
|
|
8079
8099
|
}, [firstDate]);
|
|
8080
|
-
const nextMonthFirst = useCallback(() => {
|
|
8100
|
+
const nextMonthFirst = React__default.useCallback(() => {
|
|
8081
8101
|
firstGotoDate(nextMonthBy(firstDate));
|
|
8082
8102
|
}, [firstDate, firstGotoDate]);
|
|
8083
|
-
const changeFirstMonth = useCallback((month) => {
|
|
8103
|
+
const changeFirstMonth = React__default.useCallback((month) => {
|
|
8084
8104
|
firstGotoDate(dateUpdateMonth(firstDate, month - 1));
|
|
8085
8105
|
}, [firstDate, firstGotoDate]);
|
|
8086
|
-
const changeFirstYear = useCallback((year) => {
|
|
8106
|
+
const changeFirstYear = React__default.useCallback((year) => {
|
|
8087
8107
|
firstGotoDate(dateUpdateYear(firstDate, year));
|
|
8088
8108
|
}, [firstDate, firstGotoDate]);
|
|
8089
8109
|
/* End First */
|
|
8090
8110
|
/* Start Second */
|
|
8091
|
-
const secondGotoDate = useCallback((date) => {
|
|
8111
|
+
const secondGotoDate = React__default.useCallback((date) => {
|
|
8092
8112
|
dateIsSameOrBefore(date, firstDate, "date");
|
|
8093
8113
|
if (dateIsSameOrBefore(date, firstDate, "date")) {
|
|
8094
8114
|
setFirstDate(previousMonthBy(date));
|
|
8095
8115
|
}
|
|
8096
8116
|
setSecondDate(date);
|
|
8097
8117
|
}, [firstDate]);
|
|
8098
|
-
const previousMonthSecond = useCallback(() => {
|
|
8118
|
+
const previousMonthSecond = React__default.useCallback(() => {
|
|
8099
8119
|
secondGotoDate(previousMonthBy(secondDate));
|
|
8100
8120
|
}, [secondDate, secondGotoDate]);
|
|
8101
|
-
const nextMonthSecond = useCallback(() => {
|
|
8121
|
+
const nextMonthSecond = React__default.useCallback(() => {
|
|
8102
8122
|
setSecondDate(nextMonthBy(secondDate));
|
|
8103
8123
|
}, [secondDate]);
|
|
8104
|
-
const changeSecondMonth = useCallback((month) => {
|
|
8124
|
+
const changeSecondMonth = React__default.useCallback((month) => {
|
|
8105
8125
|
secondGotoDate(dateUpdateMonth(secondDate, month - 1));
|
|
8106
8126
|
}, [secondDate, secondGotoDate]);
|
|
8107
|
-
const changeSecondYear = useCallback((year) => {
|
|
8127
|
+
const changeSecondYear = React__default.useCallback((year) => {
|
|
8108
8128
|
secondGotoDate(dateUpdateYear(secondDate, year));
|
|
8109
8129
|
}, [secondDate, secondGotoDate]);
|
|
8110
8130
|
/* End Second */
|
|
8111
8131
|
// UseEffects & UseLayoutEffect
|
|
8112
|
-
useEffect(() => {
|
|
8132
|
+
React__default.useEffect(() => {
|
|
8113
8133
|
const container = containerRef.current;
|
|
8114
8134
|
const calendarContainer = calendarContainerRef.current;
|
|
8115
8135
|
const arrow = arrowRef.current;
|
|
@@ -8124,7 +8144,7 @@ const Datepicker = (props) => {
|
|
|
8124
8144
|
}
|
|
8125
8145
|
}
|
|
8126
8146
|
}, []);
|
|
8127
|
-
useEffect(() => {
|
|
8147
|
+
React__default.useEffect(() => {
|
|
8128
8148
|
if (value && value.startDate && value.endDate) {
|
|
8129
8149
|
if (dateIsSameOrBefore(value.startDate, value.endDate, "date")) {
|
|
8130
8150
|
setPeriod({
|
|
@@ -8144,7 +8164,7 @@ const Datepicker = (props) => {
|
|
|
8144
8164
|
setInputText("");
|
|
8145
8165
|
}
|
|
8146
8166
|
}, [asSingle, value, displayFormat, separator, i18n]);
|
|
8147
|
-
useEffect(() => {
|
|
8167
|
+
React__default.useEffect(() => {
|
|
8148
8168
|
if (startFrom && dateIsValid(startFrom)) {
|
|
8149
8169
|
const startDate = value?.startDate;
|
|
8150
8170
|
const endDate = value?.endDate;
|
|
@@ -8168,13 +8188,13 @@ const Datepicker = (props) => {
|
|
|
8168
8188
|
}
|
|
8169
8189
|
}, [asSingle, startFrom, value]);
|
|
8170
8190
|
// Variables
|
|
8171
|
-
const safePrimaryColor = useMemo(() => {
|
|
8191
|
+
const safePrimaryColor = React__default.useMemo(() => {
|
|
8172
8192
|
if (COLORS.includes(primaryColor)) {
|
|
8173
8193
|
return primaryColor;
|
|
8174
8194
|
}
|
|
8175
8195
|
return DEFAULT_COLOR;
|
|
8176
8196
|
}, [primaryColor]);
|
|
8177
|
-
const contextValues = useMemo(() => {
|
|
8197
|
+
const contextValues = React__default.useMemo(() => {
|
|
8178
8198
|
if (minDate && !dateIsValid(minDate)) {
|
|
8179
8199
|
/* eslint-disable */
|
|
8180
8200
|
console.error(`minDate (${minDate}) is invalid date`);
|
|
@@ -8265,7 +8285,7 @@ const Datepicker = (props) => {
|
|
|
8265
8285
|
value,
|
|
8266
8286
|
firstGotoDate
|
|
8267
8287
|
]);
|
|
8268
|
-
const containerClassNameOverload = useMemo(() => {
|
|
8288
|
+
const containerClassNameOverload = React__default.useMemo(() => {
|
|
8269
8289
|
const defaultContainerClassName = "relative w-full text-gray-700";
|
|
8270
8290
|
return typeof containerClassName === "function"
|
|
8271
8291
|
? containerClassName(defaultContainerClassName)
|
|
@@ -8273,7 +8293,7 @@ const Datepicker = (props) => {
|
|
|
8273
8293
|
? containerClassName
|
|
8274
8294
|
: defaultContainerClassName;
|
|
8275
8295
|
}, [containerClassName]);
|
|
8276
|
-
const popupClassNameOverload = useMemo(() => {
|
|
8296
|
+
const popupClassNameOverload = React__default.useMemo(() => {
|
|
8277
8297
|
const defaultPopupClassName = "transition-all ease-out duration-300 absolute z-10 mt-[1px] text-sm lg:text-xs 2xl:text-sm translate-y-4 opacity-0 hidden";
|
|
8278
8298
|
return typeof popupClassName === "function"
|
|
8279
8299
|
? popupClassName(defaultPopupClassName)
|
|
@@ -11123,7 +11143,7 @@ const TableFilter = ({ globalFilter, setGlobalFilter, showFilterPanel, setShowFi
|
|
|
11123
11143
|
if (!table) {
|
|
11124
11144
|
return null; // Return null if table is undefined
|
|
11125
11145
|
}
|
|
11126
|
-
const [localFilters, setLocalFilters] = useState({});
|
|
11146
|
+
const [localFilters, setLocalFilters] = React__default.useState({});
|
|
11127
11147
|
const handleLocalChange = (id, value) => {
|
|
11128
11148
|
setLocalFilters((prev) => ({ ...prev, [id]: value }));
|
|
11129
11149
|
};
|
|
@@ -11135,41 +11155,41 @@ const TableFilter = ({ globalFilter, setGlobalFilter, showFilterPanel, setShowFi
|
|
|
11135
11155
|
});
|
|
11136
11156
|
setShowFilterPanel(false);
|
|
11137
11157
|
};
|
|
11138
|
-
return (jsx("div", { className: "flex flex-col", children: jsxs("div", { className: "flex justify-between", children: [jsx("div", { className: "flex-1 gap-2 relative items-center", children: jsx("div", { className: "relative mt-4", children: jsx(Input$1, { label: "", type: "text", value: typeof globalFilter === 'string' ? globalFilter : '', onChange: e => setGlobalFilter(e.target.value), placeholder: "Search...", icon: "Search", inputClassName: "text-sm h-9" }) }) }), jsxs("div", { className: "flex gap-2 relative items-center", children: [jsxs("div", { className: "relative", children: [jsx(Button, { variant: "default", size: "sm", onClick: () => setShowFilterPanel(!showFilterPanel), className: "text-gray-400 text-sm font-normal h-9 border border-gray-300 ml-2", suffix: "Filter", children: "\u0E01\u0E23\u0E2D\u0E07\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25" }), showFilterPanel && (jsxs("div", { className: "absolute right-0 mt-2 w-64 bg-white border rounded shadow-lg z-50 p-4", children: [jsx("div", { className: "flex flex-col space-y-2", children: table.getAllColumns()
|
|
11158
|
+
return (jsxRuntime$1.jsx("div", { className: "flex flex-col", children: jsxRuntime$1.jsxs("div", { className: "flex justify-between", children: [jsxRuntime$1.jsx("div", { className: "flex-1 gap-2 relative items-center", children: jsxRuntime$1.jsx("div", { className: "relative mt-4", children: jsxRuntime$1.jsx(Input$1, { label: "", type: "text", value: typeof globalFilter === 'string' ? globalFilter : '', onChange: e => setGlobalFilter(e.target.value), placeholder: "Search...", icon: "Search", inputClassName: "text-sm h-9" }) }) }), jsxRuntime$1.jsxs("div", { className: "flex gap-2 relative items-center", children: [jsxRuntime$1.jsxs("div", { className: "relative", children: [jsxRuntime$1.jsx(Button, { variant: "default", size: "sm", onClick: () => setShowFilterPanel(!showFilterPanel), className: "text-gray-400 text-sm font-normal h-9 border border-gray-300 ml-2", suffix: "Filter", children: "\u0E01\u0E23\u0E2D\u0E07\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25" }), showFilterPanel && (jsxRuntime$1.jsxs("div", { className: "absolute right-0 mt-2 w-64 bg-white border rounded shadow-lg z-50 p-4", children: [jsxRuntime$1.jsx("div", { className: "flex flex-col space-y-2", children: table.getAllColumns()
|
|
11139
11159
|
.filter((column) => column.getCanFilter())
|
|
11140
|
-
.map((column) => (jsxs("div", { className: "flex flex-col", children: [jsx("label", { htmlFor: `filter-${column.id}`, className: "text-xs mb-1", children: typeof column.columnDef.header === 'string' ? column.columnDef.header : column.id }), jsx("input", { id: `filter-${column.id}`, type: "text", value: localFilters[column.id] || '', onChange: e => handleLocalChange(column.id, e.target.value), className: "border rounded px-2 py-1 w-full", placeholder: `กรอง${typeof column.columnDef.header === 'string' ? ' ' + column.columnDef.header : ''}` })] }, column.id))) }), jsxs("div", { className: "flex justify-end mt-2 gap-2", children: [jsx(Button, { variant: "outline", size: "sm", onClick: () => setShowFilterPanel(false), className: "text-gray-600 border-gray-300 hover:bg-gray-100", children: "\u0E1B\u0E34\u0E14" }), jsx(Button, { variant: "default", size: "sm", onClick: handleApply, className: "bg-blue-600 text-white hover:bg-blue-700 border-blue-600", children: "Apply" })] })] }))] }), enableDateFilter && (jsx("div", { className: "min-w-[220px] h-9 flex items-center", children: jsx(Datepicker, { value: dateRange, onChange: setDateRange, inputClassName: "w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-primary text-sm h-9", placeholder: "\u0E01\u0E23\u0E2D\u0E07\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E15\u0E32\u0E21\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48" }) }))] })] }) }));
|
|
11160
|
+
.map((column) => (jsxRuntime$1.jsxs("div", { className: "flex flex-col", children: [jsxRuntime$1.jsx("label", { htmlFor: `filter-${column.id}`, className: "text-xs mb-1", children: typeof column.columnDef.header === 'string' ? column.columnDef.header : column.id }), jsxRuntime$1.jsx("input", { id: `filter-${column.id}`, type: "text", value: localFilters[column.id] || '', onChange: e => handleLocalChange(column.id, e.target.value), className: "border rounded px-2 py-1 w-full", placeholder: `กรอง${typeof column.columnDef.header === 'string' ? ' ' + column.columnDef.header : ''}` })] }, column.id))) }), jsxRuntime$1.jsxs("div", { className: "flex justify-end mt-2 gap-2", children: [jsxRuntime$1.jsx(Button, { variant: "outline", size: "sm", onClick: () => setShowFilterPanel(false), className: "text-gray-600 border-gray-300 hover:bg-gray-100", children: "\u0E1B\u0E34\u0E14" }), jsxRuntime$1.jsx(Button, { variant: "default", size: "sm", onClick: handleApply, className: "bg-blue-600 text-white hover:bg-blue-700 border-blue-600", children: "Apply" })] })] }))] }), enableDateFilter && (jsxRuntime$1.jsx("div", { className: "min-w-[220px] h-9 flex items-center", children: jsxRuntime$1.jsx(Datepicker, { value: dateRange, onChange: setDateRange, inputClassName: "w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-primary text-sm h-9", placeholder: "\u0E01\u0E23\u0E2D\u0E07\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E15\u0E32\u0E21\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48" }) }))] })] }) }));
|
|
11141
11161
|
};
|
|
11142
11162
|
|
|
11143
11163
|
function TablePagination({ pageIndex, pageCount, pageSize, pageSizeOptions, onPageChange, onPageSizeChange, className, }) {
|
|
11144
11164
|
const options = pageSizeOptions ?? [10, 20, 50, 100];
|
|
11145
|
-
const [jumpPage, setJumpPage] = useState(pageIndex + 1);
|
|
11146
|
-
|
|
11165
|
+
const [jumpPage, setJumpPage] = React__default.useState(pageIndex + 1);
|
|
11166
|
+
React__default.useEffect(() => {
|
|
11147
11167
|
setJumpPage(pageIndex + 1);
|
|
11148
11168
|
}, [pageIndex]);
|
|
11149
|
-
return (jsxs("div", { className: `flex flex-wrap items-center gap-4 py-2 ${className ?? ''}`, children: [jsxs("label", { className: "flex items-center gap-2 text-sm", children: ["Show", jsx("select", { value: pageSize, onChange: e => onPageSizeChange(Number(e.target.value)), className: "border px-2 py-1 rounded text-sm", children: options.map(size => (jsx("option", { value: size, children: size }, size))) }), "per page"] }), jsxs("div", { className: "flex items-center gap-1", children: [jsx("button", { className: "p-1 rounded border disabled:opacity-50", onClick: () => onPageChange(0), disabled: pageIndex === 0, "aria-label": "First page", children: "\u00AB" }), jsx("button", { className: "p-1 rounded border disabled:opacity-50", onClick: () => onPageChange(pageIndex - 1), disabled: pageIndex === 0, "aria-label": "Previous page", children: "<" }), jsxs("span", { className: "text-sm px-2", children: ["Page ", pageIndex + 1, " of ", pageCount] }), jsx("button", { className: "p-1 rounded border disabled:opacity-50", onClick: () => onPageChange(pageIndex + 1), disabled: pageIndex >= pageCount - 1, "aria-label": "Next page", children: ">" }), jsx("button", { className: "p-1 rounded border disabled:opacity-50", onClick: () => onPageChange(pageCount - 1), disabled: pageIndex >= pageCount - 1, "aria-label": "Last page", children: "\u00BB" })] }), jsxs("form", { className: "flex items-center gap-2 text-sm", onSubmit: e => {
|
|
11169
|
+
return (jsxRuntime$1.jsxs("div", { className: `flex flex-wrap items-center gap-4 py-2 ${className ?? ''}`, children: [jsxRuntime$1.jsxs("label", { className: "flex items-center gap-2 text-sm", children: ["Show", jsxRuntime$1.jsx("select", { value: pageSize, onChange: e => onPageSizeChange(Number(e.target.value)), className: "border px-2 py-1 rounded text-sm", children: options.map(size => (jsxRuntime$1.jsx("option", { value: size, children: size }, size))) }), "per page"] }), jsxRuntime$1.jsxs("div", { className: "flex items-center gap-1", children: [jsxRuntime$1.jsx("button", { className: "p-1 rounded border disabled:opacity-50", onClick: () => onPageChange(0), disabled: pageIndex === 0, "aria-label": "First page", children: "\u00AB" }), jsxRuntime$1.jsx("button", { className: "p-1 rounded border disabled:opacity-50", onClick: () => onPageChange(pageIndex - 1), disabled: pageIndex === 0, "aria-label": "Previous page", children: "<" }), jsxRuntime$1.jsxs("span", { className: "text-sm px-2", children: ["Page ", pageIndex + 1, " of ", pageCount] }), jsxRuntime$1.jsx("button", { className: "p-1 rounded border disabled:opacity-50", onClick: () => onPageChange(pageIndex + 1), disabled: pageIndex >= pageCount - 1, "aria-label": "Next page", children: ">" }), jsxRuntime$1.jsx("button", { className: "p-1 rounded border disabled:opacity-50", onClick: () => onPageChange(pageCount - 1), disabled: pageIndex >= pageCount - 1, "aria-label": "Last page", children: "\u00BB" })] }), jsxRuntime$1.jsxs("form", { className: "flex items-center gap-2 text-sm", onSubmit: e => {
|
|
11150
11170
|
e.preventDefault();
|
|
11151
11171
|
if (jumpPage > 0 && jumpPage <= pageCount) {
|
|
11152
11172
|
onPageChange(jumpPage - 1);
|
|
11153
11173
|
}
|
|
11154
|
-
}, children: [jsxs("label", { children: ["Go to", jsx("input", { type: "number", min: 1, max: pageCount, value: jumpPage, onChange: e => setJumpPage(Number(e.target.value)), className: "w-16 border px-2 py-1 rounded ml-1" })] }), jsx("button", { type: "submit", className: "px-2 py-1 border rounded text-sm", children: "Go" })] })] }));
|
|
11174
|
+
}, children: [jsxRuntime$1.jsxs("label", { children: ["Go to", jsxRuntime$1.jsx("input", { type: "number", min: 1, max: pageCount, value: jumpPage, onChange: e => setJumpPage(Number(e.target.value)), className: "w-16 border px-2 py-1 rounded ml-1" })] }), jsxRuntime$1.jsx("button", { type: "submit", className: "px-2 py-1 border rounded text-sm", children: "Go" })] })] }));
|
|
11155
11175
|
}
|
|
11156
11176
|
|
|
11157
|
-
|
|
11177
|
+
const Table = ({ data, columns, className = '', height = '100%', enableRowSelection = false, enableMultiRowSelection = false, enableSorting = true, enableFiltering = true, enablePagination = true, enableDateFilter = false, dateColumn = '', onRowClick, onSelectionChange, onSortingChange, onFilteringChange, onDateFilterChange, headerLeftSection, headerRightSection, }) => {
|
|
11158
11178
|
// State management
|
|
11159
|
-
const [rowSelection, setRowSelection] = useState({});
|
|
11160
|
-
const [sorting, setSorting] = useState([]);
|
|
11161
|
-
const [columnFilters, setColumnFilters] = useState([]);
|
|
11162
|
-
const [globalFilter, setGlobalFilter] = useState('');
|
|
11163
|
-
const [columnVisibility, setColumnVisibility] = useState({});
|
|
11164
|
-
const [showFilterPanel, setShowFilterPanel] = useState(true);
|
|
11165
|
-
const [dateRange, setDateRange] = useState({
|
|
11179
|
+
const [rowSelection, setRowSelection] = React__default.useState({});
|
|
11180
|
+
const [sorting, setSorting] = React__default.useState([]);
|
|
11181
|
+
const [columnFilters, setColumnFilters] = React__default.useState([]);
|
|
11182
|
+
const [globalFilter, setGlobalFilter] = React__default.useState('');
|
|
11183
|
+
const [columnVisibility, setColumnVisibility] = React__default.useState({});
|
|
11184
|
+
const [showFilterPanel, setShowFilterPanel] = React__default.useState(true);
|
|
11185
|
+
const [dateRange, setDateRange] = React__default.useState({
|
|
11166
11186
|
startDate: null,
|
|
11167
11187
|
endDate: null,
|
|
11168
11188
|
});
|
|
11169
|
-
const [isDatePickerOpen, setIsDatePickerOpen] = useState(false);
|
|
11170
|
-
const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: 10 });
|
|
11189
|
+
const [isDatePickerOpen, setIsDatePickerOpen] = React__default.useState(false);
|
|
11190
|
+
const [pagination, setPagination] = React__default.useState({ pageIndex: 0, pageSize: 10 });
|
|
11171
11191
|
// Filter data based on date range
|
|
11172
|
-
const filteredData = useMemo(() => {
|
|
11192
|
+
const filteredData = React__default.useMemo(() => {
|
|
11173
11193
|
if (!data)
|
|
11174
11194
|
return [];
|
|
11175
11195
|
if (!enableDateFilter || (!dateRange?.startDate && !dateRange?.endDate)) {
|
|
@@ -11217,23 +11237,23 @@ function Table({ data, columns, className = '', height = '100%', enableRowSelect
|
|
|
11217
11237
|
pageCount: Math.ceil(filteredData.length / pagination.pageSize),
|
|
11218
11238
|
});
|
|
11219
11239
|
// Effects
|
|
11220
|
-
useEffect(() => {
|
|
11240
|
+
React__default.useEffect(() => {
|
|
11221
11241
|
if (onSelectionChange) {
|
|
11222
11242
|
const selectedRows = table.getSelectedRowModel().rows;
|
|
11223
11243
|
onSelectionChange(selectedRows);
|
|
11224
11244
|
}
|
|
11225
11245
|
}, [rowSelection, onSelectionChange, table]);
|
|
11226
|
-
useEffect(() => {
|
|
11246
|
+
React__default.useEffect(() => {
|
|
11227
11247
|
if (onSortingChange) {
|
|
11228
11248
|
onSortingChange(sorting);
|
|
11229
11249
|
}
|
|
11230
11250
|
}, [sorting, onSortingChange]);
|
|
11231
|
-
useEffect(() => {
|
|
11251
|
+
React__default.useEffect(() => {
|
|
11232
11252
|
if (onFilteringChange) {
|
|
11233
11253
|
onFilteringChange(columnFilters);
|
|
11234
11254
|
}
|
|
11235
11255
|
}, [columnFilters, onFilteringChange]);
|
|
11236
|
-
useEffect(() => {
|
|
11256
|
+
React__default.useEffect(() => {
|
|
11237
11257
|
if (onDateFilterChange) {
|
|
11238
11258
|
onDateFilterChange(dateRange);
|
|
11239
11259
|
}
|
|
@@ -11242,56 +11262,21 @@ function Table({ data, columns, className = '', height = '100%', enableRowSelect
|
|
|
11242
11262
|
const pageCount = table.getPageCount();
|
|
11243
11263
|
const pageIndex = table.getState().pagination.pageIndex;
|
|
11244
11264
|
const pageSize = table.getState().pagination.pageSize;
|
|
11245
|
-
return (jsxs("div", { className: `flex flex-col w-full ${className}`, style: { height, minWidth: '900px', minHeight: '300px' }, children: [jsxs("div", { className: "flex items-center justify-between px-4 py-2 border-b", children: [jsx("div", { children: headerLeftSection }), jsx("div", { children: headerRightSection })] }), enableFiltering && (jsx(TableFilter, { globalFilter: globalFilter, setGlobalFilter: setGlobalFilter, showFilterPanel: showFilterPanel, setShowFilterPanel: setShowFilterPanel, enableDateFilter: enableDateFilter, dateRange: dateRange, setDateRange: setDateRange, isDatePickerOpen: isDatePickerOpen, setIsDatePickerOpen: setIsDatePickerOpen, table: table })), jsx(TableBody, { table: table, onRowClick: onRowClick }), enablePagination && (jsx(TablePagination, { pageIndex: pageIndex, pageCount: pageCount, pageSize: pageSize, onPageChange: table.setPageIndex, onPageSizeChange: table.setPageSize }))] }));
|
|
11246
|
-
}
|
|
11247
|
-
|
|
11248
|
-
const mockAccountingData = [
|
|
11249
|
-
{
|
|
11250
|
-
id: 1,
|
|
11251
|
-
date: '2024-06-01',
|
|
11252
|
-
description: 'Opening Balance',
|
|
11253
|
-
debit: 0,
|
|
11254
|
-
credit: 0,
|
|
11255
|
-
balance: 10000,
|
|
11256
|
-
created_at: '2024-06-01T09:00:00Z',
|
|
11257
|
-
},
|
|
11258
|
-
{
|
|
11259
|
-
id: 2,
|
|
11260
|
-
date: '2024-06-02',
|
|
11261
|
-
description: 'Invoice Payment',
|
|
11262
|
-
debit: 2000,
|
|
11263
|
-
credit: 0,
|
|
11264
|
-
balance: 12000,
|
|
11265
|
-
created_at: '2024-06-02T10:30:00Z',
|
|
11266
|
-
},
|
|
11267
|
-
{
|
|
11268
|
-
id: 3,
|
|
11269
|
-
date: '2024-06-03',
|
|
11270
|
-
description: 'Office Supplies',
|
|
11271
|
-
debit: 0,
|
|
11272
|
-
credit: 300,
|
|
11273
|
-
balance: 11700,
|
|
11274
|
-
created_at: '2024-06-03T14:15:00Z',
|
|
11275
|
-
},
|
|
11276
|
-
{
|
|
11277
|
-
id: 4,
|
|
11278
|
-
date: '2024-06-04',
|
|
11279
|
-
description: 'Client Refund',
|
|
11280
|
-
debit: 0,
|
|
11281
|
-
credit: 500,
|
|
11282
|
-
balance: 11200,
|
|
11283
|
-
created_at: '2024-06-04T11:45:00Z',
|
|
11284
|
-
},
|
|
11285
|
-
{
|
|
11286
|
-
id: 5,
|
|
11287
|
-
date: '2024-06-05',
|
|
11288
|
-
description: 'Service Revenue',
|
|
11289
|
-
debit: 1500,
|
|
11290
|
-
credit: 0,
|
|
11291
|
-
balance: 12700,
|
|
11292
|
-
created_at: '2024-06-05T16:00:00Z',
|
|
11293
|
-
},
|
|
11294
|
-
];
|
|
11265
|
+
return (jsxRuntime$1.jsxs("div", { className: `flex flex-col w-full ${className}`, style: { height, minWidth: '900px', minHeight: '300px' }, children: [jsxRuntime$1.jsxs("div", { className: "flex items-center justify-between px-4 py-2 border-b", children: [jsxRuntime$1.jsx("div", { children: headerLeftSection }), jsxRuntime$1.jsx("div", { children: headerRightSection })] }), enableFiltering && (jsxRuntime$1.jsx(TableFilter, { globalFilter: globalFilter, setGlobalFilter: setGlobalFilter, showFilterPanel: showFilterPanel, setShowFilterPanel: setShowFilterPanel, enableDateFilter: enableDateFilter, dateRange: dateRange, setDateRange: setDateRange, isDatePickerOpen: isDatePickerOpen, setIsDatePickerOpen: setIsDatePickerOpen, table: table })), jsxRuntime$1.jsx(TableBody, { table: table, onRowClick: onRowClick }), enablePagination && (jsxRuntime$1.jsx(TablePagination, { pageIndex: pageIndex, pageCount: pageCount, pageSize: pageSize, onPageChange: table.setPageIndex, onPageSizeChange: table.setPageSize }))] }));
|
|
11266
|
+
};
|
|
11295
11267
|
|
|
11296
|
-
|
|
11268
|
+
exports.Button = Button;
|
|
11269
|
+
exports.Card = Card;
|
|
11270
|
+
exports.CardContent = CardContent;
|
|
11271
|
+
exports.CardDescription = CardDescription;
|
|
11272
|
+
exports.CardFooter = CardFooter;
|
|
11273
|
+
exports.CardHeader = CardHeader;
|
|
11274
|
+
exports.CardTitle = CardTitle;
|
|
11275
|
+
exports.Form = Form;
|
|
11276
|
+
exports.Input = Input$1;
|
|
11277
|
+
exports.InputDropdown = InputDropdown;
|
|
11278
|
+
exports.Label = Label;
|
|
11279
|
+
exports.Modal = Modal;
|
|
11280
|
+
exports.Table = Table;
|
|
11281
|
+
exports.cn = cn;
|
|
11297
11282
|
//# sourceMappingURL=index.js.map
|