react-hook-form-next-ui 1.3.30
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/README.md +50 -0
- package/dist/index.d.ts +253 -0
- package/dist/index.js +824 -0
- package/package.json +75 -0
package/README.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# React + TypeScript + Vite
|
|
2
|
+
|
|
3
|
+
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
|
4
|
+
|
|
5
|
+
Currently, two official plugins are available:
|
|
6
|
+
|
|
7
|
+
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
|
|
8
|
+
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
|
|
9
|
+
|
|
10
|
+
## Expanding the ESLint configuration
|
|
11
|
+
|
|
12
|
+
If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:
|
|
13
|
+
|
|
14
|
+
- Configure the top-level `parserOptions` property like this:
|
|
15
|
+
|
|
16
|
+
```js
|
|
17
|
+
export default tseslint.config({
|
|
18
|
+
languageOptions: {
|
|
19
|
+
// other options...
|
|
20
|
+
parserOptions: {
|
|
21
|
+
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
|
22
|
+
tsconfigRootDir: import.meta.dirname,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
})
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
- Replace `tseslint.configs.recommended` to `tseslint.configs.recommendedTypeChecked` or `tseslint.configs.strictTypeChecked`
|
|
29
|
+
- Optionally add `...tseslint.configs.stylisticTypeChecked`
|
|
30
|
+
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and update the config:
|
|
31
|
+
|
|
32
|
+
```js
|
|
33
|
+
// eslint.config.js
|
|
34
|
+
import react from 'eslint-plugin-react'
|
|
35
|
+
|
|
36
|
+
export default tseslint.config({
|
|
37
|
+
// Set the react version
|
|
38
|
+
settings: { react: { version: '18.3' } },
|
|
39
|
+
plugins: {
|
|
40
|
+
// Add the react plugin
|
|
41
|
+
react,
|
|
42
|
+
},
|
|
43
|
+
rules: {
|
|
44
|
+
// other rules...
|
|
45
|
+
// Enable its recommended rules
|
|
46
|
+
...react.configs.recommended.rules,
|
|
47
|
+
...react.configs['jsx-runtime'].rules,
|
|
48
|
+
},
|
|
49
|
+
})
|
|
50
|
+
```
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { AnyObject } from 'yup';
|
|
2
|
+
import { AutocompleteProps } from '@nextui-org/react';
|
|
3
|
+
import { ButtonProps } from '@nextui-org/react';
|
|
4
|
+
import { DatePickerProps } from '@nextui-org/react';
|
|
5
|
+
import { DateValue } from '@nextui-org/react';
|
|
6
|
+
import { default as default_2 } from 'react';
|
|
7
|
+
import { InputProps } from '@nextui-org/react';
|
|
8
|
+
import { LocaleObject } from 'yup';
|
|
9
|
+
import { MixedSchema } from 'yup';
|
|
10
|
+
import { ModalProps } from '@nextui-org/react';
|
|
11
|
+
import { RadioGroupProps } from '@nextui-org/react';
|
|
12
|
+
import { RadioProps } from '@nextui-org/react';
|
|
13
|
+
import { ReactNode } from 'react';
|
|
14
|
+
import { RegisterOptions } from 'react-hook-form';
|
|
15
|
+
import { SelectProps } from '@nextui-org/react';
|
|
16
|
+
import { TableColumnProps } from '@nextui-org/react';
|
|
17
|
+
import { TableProps } from '@nextui-org/react';
|
|
18
|
+
import { TextAreaProps } from '@nextui-org/react';
|
|
19
|
+
import { TimeInputProps } from '@nextui-org/react';
|
|
20
|
+
import { TimeInputValue } from '@nextui-org/react';
|
|
21
|
+
|
|
22
|
+
declare const array: LocaleObject['array'];
|
|
23
|
+
|
|
24
|
+
declare const boolean: LocaleObject['boolean'];
|
|
25
|
+
|
|
26
|
+
declare interface ButtonModalFooter extends Omit<ButtonProps, "onClick"> {
|
|
27
|
+
onClick: () => void | Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export declare interface ColumnsTableProps extends Omit<TableColumnProps<any>, "children"> {
|
|
31
|
+
export?: boolean;
|
|
32
|
+
dateFormat?: IdateFormats;
|
|
33
|
+
renderRow?: ({ value, row }: ReturnRowTable) => ReactNode;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
declare interface DataOptionsRHFAutocomplete {
|
|
37
|
+
key: string;
|
|
38
|
+
label: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
declare interface DataOptionsRHFSelect {
|
|
42
|
+
key: string;
|
|
43
|
+
label: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export declare const DataTable: ({ rows, columns, showFilter, loading, keyRow, buttonExcelExport, exportName, skeletonSize, selectionMode, inputSearch, showHandlePaginate, defaultSelectedKeys, onSelect, defaultPaginateNumber, cellClass, excelExport, ...props }: DataTableProps) => default_2.JSX.Element;
|
|
47
|
+
|
|
48
|
+
declare interface DataTableProps extends TableProps {
|
|
49
|
+
buttonExcelExport?: Omit<ButtonProps, "onClick">;
|
|
50
|
+
inputSearch?: InputProps;
|
|
51
|
+
excelExport?: boolean;
|
|
52
|
+
exportName?: string;
|
|
53
|
+
rows: any[];
|
|
54
|
+
columns: ColumnsTableProps[];
|
|
55
|
+
loading?: boolean;
|
|
56
|
+
showFilter?: boolean;
|
|
57
|
+
showHandlePaginate?: boolean;
|
|
58
|
+
onSelect?: (row: any) => void;
|
|
59
|
+
defaultPaginateNumber?: 5 | 10 | 15;
|
|
60
|
+
cellClass?: string;
|
|
61
|
+
skeletonSize?: number;
|
|
62
|
+
keyRow?: string;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
declare const date: LocaleObject['date'];
|
|
66
|
+
|
|
67
|
+
declare const dateMinMaxValidate: ({ minDate, maxDate }: DateMinMaxValueProps) => MixedSchema<DateValue | undefined, AnyObject, undefined, "">;
|
|
68
|
+
|
|
69
|
+
declare interface DateMinMaxValueProps {
|
|
70
|
+
minDate?: string;
|
|
71
|
+
maxDate?: string;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
declare const dualDateValidate: ({ endDate, startDate, range, type, maxEndDate, maxStartDate, minEndDate, minStartDate }: DualDateValidateProps) => {
|
|
75
|
+
startDateRule: MixedSchema<DateValue | undefined, AnyObject, undefined, "">;
|
|
76
|
+
endDateRule: MixedSchema<DateValue | undefined, AnyObject, undefined, "">;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
declare interface DualDateValidateProps {
|
|
80
|
+
startDate: string;
|
|
81
|
+
endDate: string;
|
|
82
|
+
type?: TypeRangeDateValue;
|
|
83
|
+
range?: number;
|
|
84
|
+
maxStartDate?: string;
|
|
85
|
+
minStartDate?: string;
|
|
86
|
+
maxEndDate?: string;
|
|
87
|
+
minEndDate?: string;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
declare const dualTimeValidate: ({ endTime, startTime, range, type }: DualTimeValidateProps) => {
|
|
91
|
+
startTimeRule: MixedSchema<TimeInputValue | undefined, AnyObject, undefined, "">;
|
|
92
|
+
endTimeRule: MixedSchema<TimeInputValue | undefined, AnyObject, undefined, "">;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
declare interface DualTimeValidateProps {
|
|
96
|
+
startTime: string;
|
|
97
|
+
endTime: string;
|
|
98
|
+
range?: number;
|
|
99
|
+
type?: TypeRangeTimeValue;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
declare type Icolor = "danger" | "default" | "primary" | "secondary" | "success" | "warning" | undefined;
|
|
103
|
+
|
|
104
|
+
declare type IdateFormats = "DD/MM/YYYY" | "DD/MM/YYYY HH:mm" | "DD-MM-YYYY hh:mm" | "DD-MM-YYYY HH:mm" | "DD-MM-YYYY hh:mm";
|
|
105
|
+
|
|
106
|
+
export declare const Layout: ({ children, title, color }: RHFNextUiLayoutProps) => default_2.JSX.Element;
|
|
107
|
+
|
|
108
|
+
declare const mixed: LocaleObject['mixed'];
|
|
109
|
+
|
|
110
|
+
export declare function Modal({ display, children, title, onCancel, cancelButton, acceptButton, ...props }: RHFNextUiModalProps): default_2.JSX.Element;
|
|
111
|
+
|
|
112
|
+
declare const number: LocaleObject['number'];
|
|
113
|
+
|
|
114
|
+
declare const object: LocaleObject['object'];
|
|
115
|
+
|
|
116
|
+
export declare const Panel: ({ title, color, children }: RHFNextUiPanelProps) => default_2.JSX.Element;
|
|
117
|
+
|
|
118
|
+
declare interface ReturnRowTable {
|
|
119
|
+
value: string;
|
|
120
|
+
row: any;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export declare const RHFAutocomplete: ({ onSelectionChange, defaultValue, name, data, rules, ...props }: RHFAutocompleteProps) => default_2.JSX.Element;
|
|
124
|
+
|
|
125
|
+
declare interface RHFAutocompleteProps extends Omit<AutocompleteProps, "children"> {
|
|
126
|
+
name: string;
|
|
127
|
+
rules?: RegisterOptions;
|
|
128
|
+
data: DataOptionsRHFAutocomplete[];
|
|
129
|
+
defaultValue?: string;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export declare const RHFDate: ({ name, rules, defaultValue, ...props }: RHFDateProps) => default_2.JSX.Element;
|
|
133
|
+
|
|
134
|
+
declare interface RHFDateProps extends DatePickerProps {
|
|
135
|
+
name: string;
|
|
136
|
+
rules?: RegisterOptions;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export declare const RHFDualDate: ({ startDate, endDate }: RHFDualDateProps) => default_2.JSX.Element;
|
|
140
|
+
|
|
141
|
+
declare interface RHFDualDateProps {
|
|
142
|
+
startDate: RHFNextUiDate;
|
|
143
|
+
endDate: RHFNextUiDate;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export declare const RHFDualTime: ({ startTime, endTime }: RHFDualTimeProps) => default_2.JSX.Element;
|
|
147
|
+
|
|
148
|
+
declare interface RHFDualTimeProps {
|
|
149
|
+
startTime: RHFTimeProps_2;
|
|
150
|
+
endTime: RHFTimeProps_2;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export declare const RHFInput: ({ defaultValue, rules, name, classNames, ...props }: RHFInputProps) => default_2.JSX.Element;
|
|
154
|
+
|
|
155
|
+
declare interface RHFInputProps extends InputProps {
|
|
156
|
+
name: string;
|
|
157
|
+
rules?: RegisterOptions;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
declare interface RHFNextUiDate extends DatePickerProps {
|
|
161
|
+
name: string;
|
|
162
|
+
rules?: RegisterOptions;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
declare type RHFNextUiLayoutProps = {
|
|
166
|
+
children: ReactNode;
|
|
167
|
+
title: string;
|
|
168
|
+
color?: Icolor;
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
declare interface RHFNextUiModalProps extends ModalProps {
|
|
172
|
+
display: boolean;
|
|
173
|
+
onCancel: () => void;
|
|
174
|
+
title?: string;
|
|
175
|
+
cancelButton?: Omit<ButtonModalFooter, "onClick">;
|
|
176
|
+
acceptButton?: ButtonModalFooter;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
declare interface RHFNextUiPanelProps {
|
|
180
|
+
title: string;
|
|
181
|
+
children: ReactNode;
|
|
182
|
+
color?: Icolor;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export declare const RHFRadioGroup: ({ radio, data, rules, name, defaultValue, ...props }: RHFRadioGroupProps) => default_2.JSX.Element;
|
|
186
|
+
|
|
187
|
+
declare interface RHFRadioGroupDataProps {
|
|
188
|
+
key: string;
|
|
189
|
+
label: string;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
declare interface RHFRadioGroupProps extends RadioGroupProps {
|
|
193
|
+
rules?: RegisterOptions;
|
|
194
|
+
radio?: RadioProps;
|
|
195
|
+
data: RHFRadioGroupDataProps[];
|
|
196
|
+
name: string;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export declare const RHFSelect: ({ name, data, rules, defaultOptions, ...props }: RHFSelectProps) => default_2.JSX.Element;
|
|
200
|
+
|
|
201
|
+
declare interface RHFSelectProps extends Omit<SelectProps, "children"> {
|
|
202
|
+
data: DataOptionsRHFSelect[];
|
|
203
|
+
name: string;
|
|
204
|
+
rules?: RegisterOptions;
|
|
205
|
+
defaultOptions?: string;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export declare const RHFTextArea: ({ defaultValue, rules, name, classNames, ...props }: RHFTextAreaProps) => default_2.JSX.Element;
|
|
209
|
+
|
|
210
|
+
declare interface RHFTextAreaProps extends TextAreaProps {
|
|
211
|
+
name: string;
|
|
212
|
+
rules?: RegisterOptions;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
export declare const RHFTime: ({ name, rules, defaultValue, ...props }: RHFTimeProps) => default_2.JSX.Element;
|
|
216
|
+
|
|
217
|
+
declare interface RHFTimeProps extends TimeInputProps {
|
|
218
|
+
name: string;
|
|
219
|
+
rules?: RegisterOptions;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
declare interface RHFTimeProps_2 extends TimeInputProps {
|
|
223
|
+
rules?: RegisterOptions;
|
|
224
|
+
name: string;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
declare const string: LocaleObject['string'];
|
|
228
|
+
|
|
229
|
+
declare type TypeRangeDateValue = "days" | "months" | "years";
|
|
230
|
+
|
|
231
|
+
declare type TypeRangeTimeValue = "hours" | "minutes";
|
|
232
|
+
|
|
233
|
+
export declare namespace validation {
|
|
234
|
+
export {
|
|
235
|
+
dualDateValidate,
|
|
236
|
+
dateMinMaxValidate,
|
|
237
|
+
dualTimeValidate
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export declare namespace yupEs {
|
|
242
|
+
export {
|
|
243
|
+
mixed,
|
|
244
|
+
string,
|
|
245
|
+
number,
|
|
246
|
+
date,
|
|
247
|
+
boolean,
|
|
248
|
+
object,
|
|
249
|
+
array
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
export { }
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,824 @@
|
|
|
1
|
+
import e, { useState as $, useEffect as L, useCallback as k, useMemo as w } from "react";
|
|
2
|
+
import { Table as de, TableHeader as fe, TableColumn as pe, TableBody as ge, TableRow as Ee, TableCell as be, Skeleton as Fe, Button as T, Pagination as Re, Input as he, Divider as ve, Card as Ne, CardHeader as Ye, CardBody as Ie, DatePicker as J, Select as Te, SelectItem as Ve, TimeInput as Q, Textarea as Pe, Autocomplete as He, AutocompleteItem as je, RadioGroup as Oe, Radio as _e, useDisclosure as Le, Modal as Ae, ModalContent as qe, ModalHeader as ze, ModalBody as Be, ModalFooter as Ue } from "@nextui-org/react";
|
|
3
|
+
import { parse as S, isAfter as xe, isEqual as We, diffYears as Ge, diffMonths as Ze, diffDays as Je, diffHours as Qe, diffSeconds as Xe, format as V } from "@formkit/tempo";
|
|
4
|
+
import { useFormContext as M, Controller as x, useWatch as A } from "react-hook-form";
|
|
5
|
+
import { printValue as ie, mixed as _ } from "yup";
|
|
6
|
+
const Ke = ({ size: t, columns: n }) => /* @__PURE__ */ e.createElement(de, { "aria-label": "Tabla de resultados" }, /* @__PURE__ */ e.createElement(fe, null, n.map(
|
|
7
|
+
(a) => /* @__PURE__ */ e.createElement(pe, { ...n, key: a.key }, a.title)
|
|
8
|
+
)), /* @__PURE__ */ e.createElement(ge, null, Array.from(
|
|
9
|
+
{ length: t ?? 10 },
|
|
10
|
+
(a, l) => /* @__PURE__ */ e.createElement(Ee, { key: l }, () => /* @__PURE__ */ e.createElement(be, null, /* @__PURE__ */ e.createElement(Fe, { className: "h-5 w-4/5 rounded-lg" })))
|
|
11
|
+
))), et = (t, n) => {
|
|
12
|
+
const [a, l] = $(t);
|
|
13
|
+
return L(() => {
|
|
14
|
+
const s = setTimeout(() => {
|
|
15
|
+
l(t);
|
|
16
|
+
}, n);
|
|
17
|
+
return () => {
|
|
18
|
+
clearTimeout(s);
|
|
19
|
+
};
|
|
20
|
+
}, [t, n]), a;
|
|
21
|
+
};
|
|
22
|
+
async function tt({ data: t, columns: n = [], name: a }) {
|
|
23
|
+
try {
|
|
24
|
+
const { utils: l, writeFile: s } = await import("xlsx"), c = l.json_to_sheet(t);
|
|
25
|
+
l.sheet_add_aoa(c, [n]);
|
|
26
|
+
const o = l.book_new();
|
|
27
|
+
l.book_append_sheet(o, c), s(o, `${a}.xlsx`);
|
|
28
|
+
} catch (l) {
|
|
29
|
+
console.warn("debe tener instalado la libreria xlsx", l);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const at = () => /* @__PURE__ */ e.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "currentColor", className: "size-4" }, /* @__PURE__ */ e.createElement("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M12 4.5v15m7.5-7.5h-15" })), nt = () => /* @__PURE__ */ e.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "currentColor", className: "size-4" }, /* @__PURE__ */ e.createElement("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M15 12H9m12 0a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z" })), xt = ({
|
|
33
|
+
rows: t,
|
|
34
|
+
columns: n,
|
|
35
|
+
showFilter: a = !0,
|
|
36
|
+
loading: l,
|
|
37
|
+
keyRow: s = "id",
|
|
38
|
+
buttonExcelExport: c,
|
|
39
|
+
exportName: o,
|
|
40
|
+
skeletonSize: r,
|
|
41
|
+
selectionMode: d,
|
|
42
|
+
inputSearch: f,
|
|
43
|
+
showHandlePaginate: u = !0,
|
|
44
|
+
defaultSelectedKeys: i,
|
|
45
|
+
onSelect: b,
|
|
46
|
+
defaultPaginateNumber: B = 10,
|
|
47
|
+
cellClass: U,
|
|
48
|
+
excelExport: X,
|
|
49
|
+
...H
|
|
50
|
+
}) => {
|
|
51
|
+
const [j, W] = $(""), [F, ye] = $(B), [y, R] = $(1), [C, K] = $(/* @__PURE__ */ new Set()), [N, De] = $(H.sortDescriptor ?? {}), [we, Me] = $(!1), ee = !!et(j, 500), te = k((m) => {
|
|
52
|
+
if (K(m), !b || d === "none") return;
|
|
53
|
+
let g = [];
|
|
54
|
+
return d === "single" ? g = t.find((p) => p[s] == [...m][0]) : m === "all" ? (g = t, K(new Set(t.map((p) => p[s])))) : g = t.filter((p) => [...m].includes(p[s])), b(g);
|
|
55
|
+
}, [b, t, d, s]);
|
|
56
|
+
L(() => {
|
|
57
|
+
if (!we) return Me(!0);
|
|
58
|
+
let m = /* @__PURE__ */ new Set();
|
|
59
|
+
if (i === "all")
|
|
60
|
+
m = "all";
|
|
61
|
+
else if (i && [...i].length > 0) {
|
|
62
|
+
const g = t.map((h) => h[s]), p = [...i].filter((h) => g.includes(h));
|
|
63
|
+
m = new Set(p);
|
|
64
|
+
}
|
|
65
|
+
te(m);
|
|
66
|
+
}, [i, t, s]);
|
|
67
|
+
const G = w(() => {
|
|
68
|
+
let m = [...t];
|
|
69
|
+
return ee && (m = m.filter(
|
|
70
|
+
(g) => Object.values(g).some(
|
|
71
|
+
(p, h) => {
|
|
72
|
+
const E = Object.keys(g)[h];
|
|
73
|
+
return !n.map((v) => v.key).includes(E) || p == null || !p ? !1 : p.toString().toLowerCase().includes(j.toLowerCase());
|
|
74
|
+
}
|
|
75
|
+
)
|
|
76
|
+
)), m;
|
|
77
|
+
}, [j, ee, t, n]), Y = Math.ceil(G.length / F) || 1, ae = w(() => [...G].sort((m, g) => {
|
|
78
|
+
let p = m[N.column], h = g[N.column];
|
|
79
|
+
const E = n.find((v) => v.key === N.column);
|
|
80
|
+
if (E != null && E.dateFormat)
|
|
81
|
+
try {
|
|
82
|
+
const v = S(p, E.dateFormat), O = S(h, E.dateFormat), I = xe(v, O);
|
|
83
|
+
p = I ? 1 : 0, h = I ? 0 : 1;
|
|
84
|
+
} catch (v) {
|
|
85
|
+
console.warn("You need @formkit/tempo", v);
|
|
86
|
+
}
|
|
87
|
+
if (p === h) return 0;
|
|
88
|
+
const D = p > h ? 1 : -1;
|
|
89
|
+
return N.direction === "descending" ? -D : D;
|
|
90
|
+
}), [N, G, n]), Ce = w(() => {
|
|
91
|
+
const m = (y - 1) * F, g = m + F;
|
|
92
|
+
return ae.slice(m, g);
|
|
93
|
+
}, [ae, y, F]), ne = k(() => {
|
|
94
|
+
W(""), R(1);
|
|
95
|
+
}, []), le = k(() => {
|
|
96
|
+
y < Y && R(y + 1);
|
|
97
|
+
}, [y, Y]), se = k(() => {
|
|
98
|
+
y > 1 && R(y - 1);
|
|
99
|
+
}, [y]), oe = k((m) => {
|
|
100
|
+
ye(Number(m.target.value)), R(1);
|
|
101
|
+
}, []), re = k((m) => {
|
|
102
|
+
m ? (W(m), R(1)) : W("");
|
|
103
|
+
}, []), ke = k((m, g) => {
|
|
104
|
+
const p = n.find((E) => E.key === g);
|
|
105
|
+
if (p.renderRow)
|
|
106
|
+
return /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("div", null, p.renderRow({
|
|
107
|
+
value: m[g],
|
|
108
|
+
row: m
|
|
109
|
+
})), m.subRows && m.subRows.length > 0 && /* @__PURE__ */ e.createElement("div", { "data-row-key": m[s], style: { display: "none" } }, m.subRows.map(
|
|
110
|
+
(E, D) => p.renderRow && /* @__PURE__ */ e.createElement("div", { key: D }, p.renderRow({
|
|
111
|
+
value: E[g],
|
|
112
|
+
row: E
|
|
113
|
+
}))
|
|
114
|
+
)));
|
|
115
|
+
const h = () => {
|
|
116
|
+
document.querySelectorAll(`div[data-row-key="${m[s]}"]`).forEach((D) => {
|
|
117
|
+
const v = D;
|
|
118
|
+
if (!v || !v.style) return;
|
|
119
|
+
const O = v.style.display;
|
|
120
|
+
v.style.display = O === "none" ? "block" : "none";
|
|
121
|
+
const I = document.querySelector(`span[data-icon-expand-table="${m[s]}"]`), Z = document.querySelector(`span[data-icon-collapse-table="${m[s]}"]`);
|
|
122
|
+
!I || !I.style || !Z || !Z.style || (I.style.display = O !== "none" ? "block" : "none", Z.style.display = O === "none" ? "block" : "none");
|
|
123
|
+
});
|
|
124
|
+
};
|
|
125
|
+
return /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("p", { title: m[g] }, m.subRows && m.subRows.length > 0 && n[0].key === g && /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(
|
|
126
|
+
T,
|
|
127
|
+
{
|
|
128
|
+
type: "button",
|
|
129
|
+
onClick: h,
|
|
130
|
+
size: "sm",
|
|
131
|
+
isIconOnly: !0,
|
|
132
|
+
className: "bg-transparent",
|
|
133
|
+
style: {
|
|
134
|
+
marginLeft: "-11px",
|
|
135
|
+
marginTop: "-12px",
|
|
136
|
+
marginBottom: "-6px"
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
/* @__PURE__ */ e.createElement("span", { "data-icon-expand-table": m[s], className: "text-emerald-500" }, /* @__PURE__ */ e.createElement(at, null)),
|
|
140
|
+
/* @__PURE__ */ e.createElement("span", { "data-icon-collapse-table": m[s], style: { display: "none" }, className: "text-rose-500" }, /* @__PURE__ */ e.createElement(nt, null))
|
|
141
|
+
)), m[g]), m.subRows && m.subRows.length > 0 && /* @__PURE__ */ e.createElement("div", { "data-row-key": m[s], style: { display: "none" } }, m.subRows.map((E, D) => /* @__PURE__ */ e.createElement(
|
|
142
|
+
"p",
|
|
143
|
+
{
|
|
144
|
+
title: E[g],
|
|
145
|
+
key: D,
|
|
146
|
+
className: n[0].key === g ? "ps-5" : ""
|
|
147
|
+
},
|
|
148
|
+
E[g]
|
|
149
|
+
))));
|
|
150
|
+
}, [n, s]), ce = k(() => {
|
|
151
|
+
const m = n.filter((p) => p.export).map((p) => p.key), g = t.map((p) => {
|
|
152
|
+
const h = {};
|
|
153
|
+
return Object.keys(p).forEach((E) => {
|
|
154
|
+
m.includes(E) && (h[E] = typeof p[E] == "boolean" ? p[E] ? "Activo" : "Inactivo" : p[E]);
|
|
155
|
+
}), h;
|
|
156
|
+
});
|
|
157
|
+
tt({
|
|
158
|
+
data: g,
|
|
159
|
+
name: o ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
160
|
+
columns: n.filter((p) => p.export).map((p) => {
|
|
161
|
+
var h;
|
|
162
|
+
return ((h = p.title) == null ? void 0 : h.toString()) ?? "";
|
|
163
|
+
})
|
|
164
|
+
});
|
|
165
|
+
}, [n, t, o]), $e = w(() => /* @__PURE__ */ e.createElement("div", { className: "py-2 px-2 flex justify-between items-center" }, /* @__PURE__ */ e.createElement("span", { className: "w-[30%] text-small text-default-400" }, d !== "none" && ([...C].length > 0 || C === "all") && /* @__PURE__ */ e.createElement(e.Fragment, null, C !== "all" && [...C].length, C === "all" ? "Todos los datos seleccionados" : [...C].length === 1 ? " dato seleccionado" : " datos seleccionados")), /* @__PURE__ */ e.createElement(
|
|
166
|
+
Re,
|
|
167
|
+
{
|
|
168
|
+
isCompact: !0,
|
|
169
|
+
showControls: !0,
|
|
170
|
+
showShadow: !0,
|
|
171
|
+
page: y,
|
|
172
|
+
total: Y,
|
|
173
|
+
onChange: R,
|
|
174
|
+
color: H.color
|
|
175
|
+
}
|
|
176
|
+
), /* @__PURE__ */ e.createElement("div", { className: "hidden sm:flex w-[30%] justify-end gap-2" }, /* @__PURE__ */ e.createElement(T, { isDisabled: Y === 1, size: "sm", variant: "flat", onPress: se }, "Atrás"), /* @__PURE__ */ e.createElement(T, { isDisabled: Y === 1, size: "sm", variant: "flat", onPress: le }, "Siguiente"))), [y, Y, le, se, C, d, H.color]), Se = w(() => /* @__PURE__ */ e.createElement("div", { className: "flex flex-col gap-4 relative" }, /* @__PURE__ */ e.createElement("div", { className: "flex justify-between gap-3 items-end" }, a && /* @__PURE__ */ e.createElement(
|
|
177
|
+
he,
|
|
178
|
+
{
|
|
179
|
+
...f,
|
|
180
|
+
className: (f == null ? void 0 : f.className) ?? "w-full sm:max-w-[44%]",
|
|
181
|
+
placeholder: (f == null ? void 0 : f.placeholder) ?? "Buscar...",
|
|
182
|
+
value: j,
|
|
183
|
+
onClear: () => ne(),
|
|
184
|
+
onValueChange: re,
|
|
185
|
+
isClearable: !0
|
|
186
|
+
}
|
|
187
|
+
), (X || c) && /* @__PURE__ */ e.createElement(
|
|
188
|
+
T,
|
|
189
|
+
{
|
|
190
|
+
...c,
|
|
191
|
+
type: "button",
|
|
192
|
+
onClick: () => ce()
|
|
193
|
+
},
|
|
194
|
+
(c == null ? void 0 : c.name) ?? "Descargar"
|
|
195
|
+
)), /* @__PURE__ */ e.createElement("div", { className: "flex justify-between items-center" }, /* @__PURE__ */ e.createElement("span", { className: "text-default-400 text-small" }, "Total ", t.length, " ", t.length === 1 ? "dato" : "datos"), u && /* @__PURE__ */ e.createElement("label", { className: "flex items-center text-default-400 text-small" }, "Filas por página:", /* @__PURE__ */ e.createElement(
|
|
196
|
+
"select",
|
|
197
|
+
{
|
|
198
|
+
className: "bg-transparent outline-none text-default-400 text-small",
|
|
199
|
+
onChange: oe,
|
|
200
|
+
defaultValue: F
|
|
201
|
+
},
|
|
202
|
+
/* @__PURE__ */ e.createElement("option", { value: "5" }, "5"),
|
|
203
|
+
/* @__PURE__ */ e.createElement("option", { value: "10" }, "10"),
|
|
204
|
+
/* @__PURE__ */ e.createElement("option", { value: "15" }, "15")
|
|
205
|
+
)))), [
|
|
206
|
+
j,
|
|
207
|
+
t.length,
|
|
208
|
+
ne,
|
|
209
|
+
oe,
|
|
210
|
+
X,
|
|
211
|
+
f,
|
|
212
|
+
re,
|
|
213
|
+
F,
|
|
214
|
+
a,
|
|
215
|
+
u,
|
|
216
|
+
ce,
|
|
217
|
+
c
|
|
218
|
+
]);
|
|
219
|
+
return /* @__PURE__ */ e.createElement(e.Fragment, null, l ? /* @__PURE__ */ e.createElement(Ke, { columns: n, size: r }) : /* @__PURE__ */ e.createElement(
|
|
220
|
+
de,
|
|
221
|
+
{
|
|
222
|
+
...H,
|
|
223
|
+
isHeaderSticky: !0,
|
|
224
|
+
"aria-label": H["aria-label"] ?? "Tabla de resultados",
|
|
225
|
+
bottomContent: t.length > 0 ? $e : void 0,
|
|
226
|
+
bottomContentPlacement: "outside",
|
|
227
|
+
topContentPlacement: "outside",
|
|
228
|
+
topContent: t.length > 0 ? Se : void 0,
|
|
229
|
+
sortDescriptor: N,
|
|
230
|
+
onSortChange: De,
|
|
231
|
+
selectedKeys: C,
|
|
232
|
+
onSelectionChange: te,
|
|
233
|
+
selectionMode: d
|
|
234
|
+
},
|
|
235
|
+
/* @__PURE__ */ e.createElement(fe, { columns: n }, (m) => /* @__PURE__ */ e.createElement(pe, { ...m, children: void 0, key: m.key })),
|
|
236
|
+
/* @__PURE__ */ e.createElement(ge, { emptyContent: "No hay datos.", items: Ce }, (m) => /* @__PURE__ */ e.createElement(Ee, { key: m[s] }, (g) => /* @__PURE__ */ e.createElement(be, { className: U ?? "whitespace-nowrap overflow-hidden overflow-ellipsis max-w-[150px]" }, ke(m, g))))
|
|
237
|
+
));
|
|
238
|
+
}, yt = ({ children: t, title: n, color: a = "primary" }) => /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("header", { className: `bg-${a} w-full text-center text-white py-5` }, /* @__PURE__ */ e.createElement("h1", { className: "font-bold text-lg" }, n)), /* @__PURE__ */ e.createElement(ve, null), /* @__PURE__ */ e.createElement("main", { className: "p-5 2xl:px-16 2xl:py-5 mx-auto" }, t)), Dt = ({ title: t, color: n = "primary", children: a }) => /* @__PURE__ */ e.createElement(Ne, { className: "mb-5" }, /* @__PURE__ */ e.createElement(Ye, { className: `bg-${n} px-5 text-white` }, t), /* @__PURE__ */ e.createElement(ve, null), /* @__PURE__ */ e.createElement(Ie, { className: "p-5" }, a)), wt = ({ name: t, rules: n, defaultValue: a = null, ...l }) => {
|
|
239
|
+
const { control: s } = M();
|
|
240
|
+
return /* @__PURE__ */ e.createElement(
|
|
241
|
+
x,
|
|
242
|
+
{
|
|
243
|
+
control: s,
|
|
244
|
+
name: t,
|
|
245
|
+
rules: n,
|
|
246
|
+
defaultValue: a,
|
|
247
|
+
render: ({ field: c, formState: { errors: o } }) => {
|
|
248
|
+
var r;
|
|
249
|
+
return /* @__PURE__ */ e.createElement(
|
|
250
|
+
J,
|
|
251
|
+
{
|
|
252
|
+
...l,
|
|
253
|
+
...c,
|
|
254
|
+
value: c.value,
|
|
255
|
+
errorMessage: o[t] ? (r = o[t]) == null ? void 0 : r.message : "",
|
|
256
|
+
isInvalid: !!o[t]
|
|
257
|
+
}
|
|
258
|
+
);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
);
|
|
262
|
+
}, Mt = ({ startDate: t, endDate: n }) => {
|
|
263
|
+
const { control: a, trigger: l, getValues: s, formState: c } = M(), o = w(() => t.name, [t.name]), r = w(() => n.name, [n.name]), d = A({ control: a, name: [o] }), f = A({ control: a, name: [r] });
|
|
264
|
+
return L(() => {
|
|
265
|
+
if (!c.isSubmitted) return;
|
|
266
|
+
const u = s();
|
|
267
|
+
u[o] && u[r] && (l([o]), l([r]));
|
|
268
|
+
}, [f, d, l, s, c.isSubmitted, r, o]), /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(
|
|
269
|
+
x,
|
|
270
|
+
{
|
|
271
|
+
control: a,
|
|
272
|
+
name: o,
|
|
273
|
+
rules: t.rules,
|
|
274
|
+
defaultValue: t.defaultValue ?? null,
|
|
275
|
+
render: ({ field: u, formState: { errors: i } }) => {
|
|
276
|
+
var b;
|
|
277
|
+
return /* @__PURE__ */ e.createElement(
|
|
278
|
+
J,
|
|
279
|
+
{
|
|
280
|
+
...t,
|
|
281
|
+
...u,
|
|
282
|
+
value: u.value,
|
|
283
|
+
errorMessage: i[o] ? (b = i[o]) == null ? void 0 : b.message : "",
|
|
284
|
+
isInvalid: !!i[o]
|
|
285
|
+
}
|
|
286
|
+
);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
), /* @__PURE__ */ e.createElement(
|
|
290
|
+
x,
|
|
291
|
+
{
|
|
292
|
+
control: a,
|
|
293
|
+
name: r,
|
|
294
|
+
rules: n.rules,
|
|
295
|
+
defaultValue: n.defaultValue ?? null,
|
|
296
|
+
render: ({ field: u, formState: { errors: i } }) => {
|
|
297
|
+
var b;
|
|
298
|
+
return /* @__PURE__ */ e.createElement(
|
|
299
|
+
J,
|
|
300
|
+
{
|
|
301
|
+
...n,
|
|
302
|
+
...u,
|
|
303
|
+
value: u.value,
|
|
304
|
+
errorMessage: i[r] ? (b = i[r]) == null ? void 0 : b.message : "",
|
|
305
|
+
isInvalid: !!i[r]
|
|
306
|
+
}
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
));
|
|
311
|
+
}, Ct = ({ defaultValue: t = "", rules: n, name: a, classNames: l, ...s }) => {
|
|
312
|
+
const { control: c } = M();
|
|
313
|
+
return /* @__PURE__ */ e.createElement(
|
|
314
|
+
x,
|
|
315
|
+
{
|
|
316
|
+
control: c,
|
|
317
|
+
defaultValue: t,
|
|
318
|
+
name: a,
|
|
319
|
+
rules: n,
|
|
320
|
+
render: ({ field: o, formState: { errors: r } }) => {
|
|
321
|
+
var d;
|
|
322
|
+
return /* @__PURE__ */ e.createElement(
|
|
323
|
+
he,
|
|
324
|
+
{
|
|
325
|
+
...s,
|
|
326
|
+
...o,
|
|
327
|
+
isInvalid: !!r[a],
|
|
328
|
+
errorMessage: r[a] ? (d = r[a]) == null ? void 0 : d.message : "",
|
|
329
|
+
classNames: {
|
|
330
|
+
...l,
|
|
331
|
+
input: `${(l == null ? void 0 : l.input) || ""} ${r[a] ? "placeholder:text-danger" : ""}`
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
);
|
|
338
|
+
}, kt = ({ name: t, data: n, rules: a, defaultOptions: l = "", ...s }) => {
|
|
339
|
+
const { control: c } = M();
|
|
340
|
+
return /* @__PURE__ */ e.createElement(
|
|
341
|
+
x,
|
|
342
|
+
{
|
|
343
|
+
control: c,
|
|
344
|
+
rules: a,
|
|
345
|
+
name: t,
|
|
346
|
+
defaultValue: l,
|
|
347
|
+
render: ({ field: o, formState: { errors: r } }) => {
|
|
348
|
+
var d;
|
|
349
|
+
return /* @__PURE__ */ e.createElement(
|
|
350
|
+
Te,
|
|
351
|
+
{
|
|
352
|
+
...s,
|
|
353
|
+
...o,
|
|
354
|
+
items: n,
|
|
355
|
+
selectedKeys: new Set(o.value ? o.value.split(",") : []),
|
|
356
|
+
errorMessage: r[t] ? (d = r[t]) == null ? void 0 : d.message : "",
|
|
357
|
+
isInvalid: !!r[t]
|
|
358
|
+
},
|
|
359
|
+
(f) => /* @__PURE__ */ e.createElement(Ve, { key: f.key }, f.label)
|
|
360
|
+
);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
);
|
|
364
|
+
}, $t = ({ name: t, rules: n, defaultValue: a, ...l }) => {
|
|
365
|
+
const { control: s } = M();
|
|
366
|
+
return /* @__PURE__ */ e.createElement(
|
|
367
|
+
x,
|
|
368
|
+
{
|
|
369
|
+
control: s,
|
|
370
|
+
name: t,
|
|
371
|
+
rules: n,
|
|
372
|
+
defaultValue: a ?? null,
|
|
373
|
+
render: ({ field: c, formState: { errors: o } }) => {
|
|
374
|
+
var r;
|
|
375
|
+
return /* @__PURE__ */ e.createElement(
|
|
376
|
+
Q,
|
|
377
|
+
{
|
|
378
|
+
...l,
|
|
379
|
+
...c,
|
|
380
|
+
value: c.value,
|
|
381
|
+
isInvalid: !!o[t],
|
|
382
|
+
errorMessage: o[t] ? (r = o[t]) == null ? void 0 : r.message : ""
|
|
383
|
+
}
|
|
384
|
+
);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
);
|
|
388
|
+
}, St = ({ startTime: t, endTime: n }) => {
|
|
389
|
+
const { control: a, trigger: l, getValues: s, formState: c } = M(), o = w(() => t.name, [t.name]), r = w(() => n.name, [n.name]), d = A({ control: a, name: [o] }), f = A({ control: a, name: [r] });
|
|
390
|
+
return L(() => {
|
|
391
|
+
if (!c.isSubmitted) return;
|
|
392
|
+
const u = s();
|
|
393
|
+
u[o] && u[r] && (l([o]), l([r]));
|
|
394
|
+
}, [f, d, l, s, c.isSubmitted, r, o]), /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(
|
|
395
|
+
x,
|
|
396
|
+
{
|
|
397
|
+
control: a,
|
|
398
|
+
name: o,
|
|
399
|
+
rules: t.rules,
|
|
400
|
+
defaultValue: t.defaultValue ?? null,
|
|
401
|
+
render: ({ field: u, formState: { errors: i } }) => {
|
|
402
|
+
var b;
|
|
403
|
+
return /* @__PURE__ */ e.createElement(
|
|
404
|
+
Q,
|
|
405
|
+
{
|
|
406
|
+
...t,
|
|
407
|
+
...u,
|
|
408
|
+
value: u.value,
|
|
409
|
+
isInvalid: !!i[o],
|
|
410
|
+
errorMessage: i[o] ? (b = i[o]) == null ? void 0 : b.message : ""
|
|
411
|
+
}
|
|
412
|
+
);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
), /* @__PURE__ */ e.createElement(
|
|
416
|
+
x,
|
|
417
|
+
{
|
|
418
|
+
control: a,
|
|
419
|
+
name: r,
|
|
420
|
+
rules: n.rules,
|
|
421
|
+
defaultValue: n.defaultValue ?? null,
|
|
422
|
+
render: ({ field: u, formState: { errors: i } }) => {
|
|
423
|
+
var b;
|
|
424
|
+
return /* @__PURE__ */ e.createElement(
|
|
425
|
+
Q,
|
|
426
|
+
{
|
|
427
|
+
...n,
|
|
428
|
+
...u,
|
|
429
|
+
value: u.value,
|
|
430
|
+
isInvalid: !!i[r],
|
|
431
|
+
errorMessage: i[r] ? (b = i[r]) == null ? void 0 : b.message : ""
|
|
432
|
+
}
|
|
433
|
+
);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
));
|
|
437
|
+
}, Ft = ({ defaultValue: t = "", rules: n, name: a, classNames: l, ...s }) => {
|
|
438
|
+
const { control: c } = M();
|
|
439
|
+
return /* @__PURE__ */ e.createElement(
|
|
440
|
+
x,
|
|
441
|
+
{
|
|
442
|
+
control: c,
|
|
443
|
+
defaultValue: t,
|
|
444
|
+
name: a,
|
|
445
|
+
rules: n,
|
|
446
|
+
render: ({ field: o, formState: { errors: r } }) => {
|
|
447
|
+
var d;
|
|
448
|
+
return /* @__PURE__ */ e.createElement(
|
|
449
|
+
Pe,
|
|
450
|
+
{
|
|
451
|
+
...s,
|
|
452
|
+
...o,
|
|
453
|
+
isInvalid: !!r[a],
|
|
454
|
+
errorMessage: r[a] ? (d = r[a]) == null ? void 0 : d.message : "",
|
|
455
|
+
classNames: {
|
|
456
|
+
...l,
|
|
457
|
+
input: `${(l == null ? void 0 : l.input) || ""} ${r[a] ? "placeholder:text-danger" : ""}`
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
);
|
|
464
|
+
}, Rt = ({ onSelectionChange: t, defaultValue: n, name: a, data: l, rules: s, ...c }) => {
|
|
465
|
+
const { control: o } = M(), r = (d) => {
|
|
466
|
+
t && t(d);
|
|
467
|
+
};
|
|
468
|
+
return /* @__PURE__ */ e.createElement(
|
|
469
|
+
x,
|
|
470
|
+
{
|
|
471
|
+
control: o,
|
|
472
|
+
defaultValue: n,
|
|
473
|
+
name: a,
|
|
474
|
+
rules: s,
|
|
475
|
+
render: ({ field: d, formState: { errors: f } }) => {
|
|
476
|
+
var u;
|
|
477
|
+
return /* @__PURE__ */ e.createElement(
|
|
478
|
+
He,
|
|
479
|
+
{
|
|
480
|
+
...c,
|
|
481
|
+
...d,
|
|
482
|
+
selectedKey: d.value ?? "",
|
|
483
|
+
defaultItems: l,
|
|
484
|
+
onSelectionChange: (i) => {
|
|
485
|
+
d.onChange(i), r(i);
|
|
486
|
+
},
|
|
487
|
+
isInvalid: !!f[a],
|
|
488
|
+
errorMessage: f[a] ? (u = f[a]) == null ? void 0 : u.message : "",
|
|
489
|
+
inputProps: {
|
|
490
|
+
classNames: {
|
|
491
|
+
input: f[a] ? "placeholder:text-danger" : ""
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
},
|
|
495
|
+
l.map((i) => /* @__PURE__ */ e.createElement(je, { key: i.key, value: i.key }, i.label))
|
|
496
|
+
);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
);
|
|
500
|
+
}, Nt = ({ radio: t, data: n, rules: a, name: l, defaultValue: s, ...c }) => {
|
|
501
|
+
const { control: o } = M();
|
|
502
|
+
return /* @__PURE__ */ e.createElement(
|
|
503
|
+
x,
|
|
504
|
+
{
|
|
505
|
+
control: o,
|
|
506
|
+
rules: a,
|
|
507
|
+
name: l,
|
|
508
|
+
defaultValue: s ?? "",
|
|
509
|
+
render: ({ field: r, formState: { errors: d } }) => {
|
|
510
|
+
var f;
|
|
511
|
+
return /* @__PURE__ */ e.createElement(
|
|
512
|
+
Oe,
|
|
513
|
+
{
|
|
514
|
+
...r,
|
|
515
|
+
...c,
|
|
516
|
+
isInvalid: !!d[l],
|
|
517
|
+
errorMessage: d[l] ? (f = d[l]) == null ? void 0 : f.message : ""
|
|
518
|
+
},
|
|
519
|
+
n.map((u, i) => /* @__PURE__ */ e.createElement(
|
|
520
|
+
_e,
|
|
521
|
+
{
|
|
522
|
+
...t,
|
|
523
|
+
key: i,
|
|
524
|
+
value: u.key
|
|
525
|
+
},
|
|
526
|
+
u.label
|
|
527
|
+
))
|
|
528
|
+
);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
);
|
|
532
|
+
};
|
|
533
|
+
function Yt({
|
|
534
|
+
display: t,
|
|
535
|
+
children: n,
|
|
536
|
+
title: a,
|
|
537
|
+
onCancel: l,
|
|
538
|
+
cancelButton: s,
|
|
539
|
+
acceptButton: c,
|
|
540
|
+
...o
|
|
541
|
+
}) {
|
|
542
|
+
const { isOpen: r, onOpen: d, onOpenChange: f } = Le(), [u, i] = $(!1);
|
|
543
|
+
L(() => {
|
|
544
|
+
t && d();
|
|
545
|
+
}, [t, d]);
|
|
546
|
+
const b = () => {
|
|
547
|
+
f(), l();
|
|
548
|
+
}, B = async () => {
|
|
549
|
+
c != null && c.onClick && (i(!0), await c.onClick(), i(!1));
|
|
550
|
+
};
|
|
551
|
+
return /* @__PURE__ */ e.createElement(Ae, { isOpen: r, onOpenChange: b, ...o }, /* @__PURE__ */ e.createElement(qe, null, (U) => /* @__PURE__ */ e.createElement(e.Fragment, null, a && /* @__PURE__ */ e.createElement(ze, { className: "flex flex-col gap-1" }, a), /* @__PURE__ */ e.createElement(Be, null, n), /* @__PURE__ */ e.createElement(Ue, null, s && /* @__PURE__ */ e.createElement(
|
|
552
|
+
T,
|
|
553
|
+
{
|
|
554
|
+
...s,
|
|
555
|
+
isDisabled: u,
|
|
556
|
+
onPress: () => {
|
|
557
|
+
U(), l();
|
|
558
|
+
}
|
|
559
|
+
},
|
|
560
|
+
(s == null ? void 0 : s.name) ?? "Cerrar"
|
|
561
|
+
), c && /* @__PURE__ */ e.createElement(
|
|
562
|
+
T,
|
|
563
|
+
{
|
|
564
|
+
...c,
|
|
565
|
+
isLoading: u,
|
|
566
|
+
onClick: () => B()
|
|
567
|
+
},
|
|
568
|
+
c.name ?? "Aceptar"
|
|
569
|
+
)))));
|
|
570
|
+
}
|
|
571
|
+
const lt = {
|
|
572
|
+
default: "Este valor no es válido.",
|
|
573
|
+
required: "Este campo es obligatorio",
|
|
574
|
+
defined: "Este campo debe definirse",
|
|
575
|
+
notNull: "Este campo no puede ser nulo",
|
|
576
|
+
oneOf: "Este campo debe ser uno de los siguientes valores: ${values}",
|
|
577
|
+
notOneOf: "Este campo no debe ser uno de los siguientes valores: ${values}",
|
|
578
|
+
notType: ({ type: t, value: n, originalValue: a }) => {
|
|
579
|
+
const l = a != null && a !== n;
|
|
580
|
+
let s = `Debe ser un \`${t}\` Tipo, Pero el valor final fue: \`${ie(n, !0)}\`` + (l ? ` (Eche el valor \`${ie(a, !0)}\`).` : ".");
|
|
581
|
+
return n === null && (s += '\n Si "nulo" está destinado a ser un valor vacío, asegúrese de marcar el esquema como `.nullable()`'), s;
|
|
582
|
+
}
|
|
583
|
+
}, st = {
|
|
584
|
+
length: "Debe ser exactamente ${length} caracteres",
|
|
585
|
+
min: "Debe ser al menos ${min} caracteres",
|
|
586
|
+
max: "Debe ser como máximo ${max} caracteres",
|
|
587
|
+
matches: "Este valor no es válido",
|
|
588
|
+
email: "Debe ser un correo electrónico válido",
|
|
589
|
+
url: "Debe ser una URL válida",
|
|
590
|
+
uuid: "Debe ser un UUID válido",
|
|
591
|
+
trim: "No debe tener espacios vacios",
|
|
592
|
+
lowercase: "Debe ser un texto en minúscula",
|
|
593
|
+
uppercase: "Debe ser un texto en mayúscula"
|
|
594
|
+
}, ot = {
|
|
595
|
+
min: "Debe ser mayor o igual a ${min}",
|
|
596
|
+
max: "Debe ser menor o igual a ${max}",
|
|
597
|
+
lessThan: "Debe ser menor que ${less}",
|
|
598
|
+
moreThan: "Debe ser mayor que ${more}",
|
|
599
|
+
positive: "Debe ser un número positivo",
|
|
600
|
+
negative: "Debe ser un número negativo",
|
|
601
|
+
integer: "Debe ser un entero"
|
|
602
|
+
}, rt = {
|
|
603
|
+
min: "El campo debe ser más tarde que ${min}",
|
|
604
|
+
max: "El campo debe estar antes de ${max}"
|
|
605
|
+
}, ct = {
|
|
606
|
+
isValue: "El campo debe ser ${value}"
|
|
607
|
+
}, it = {
|
|
608
|
+
noUnknown: "El campo no puede tener claves no especificadas en la forma del objeto"
|
|
609
|
+
}, mt = {
|
|
610
|
+
min: "El campo debe tener al menos ${min} elementos",
|
|
611
|
+
max: "El campo debe tener menos o igual a los elementos ${max}",
|
|
612
|
+
length: "Debe tener ${length} elementos"
|
|
613
|
+
}, It = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
614
|
+
__proto__: null,
|
|
615
|
+
array: mt,
|
|
616
|
+
boolean: ct,
|
|
617
|
+
date: rt,
|
|
618
|
+
mixed: lt,
|
|
619
|
+
number: ot,
|
|
620
|
+
object: it,
|
|
621
|
+
string: st
|
|
622
|
+
}, Symbol.toStringTag, { value: "Module" })), me = ({ value: t, context: n, name: a, range: l, rangeDate: s, type: c }) => {
|
|
623
|
+
const o = n.parent[a];
|
|
624
|
+
if (!o || !t || !l || l === 0 || !s) return !0;
|
|
625
|
+
const r = S(c == "min" ? o.toString() : t.toString()), d = S(c == "max" ? o.toString() : t.toString());
|
|
626
|
+
let f;
|
|
627
|
+
switch (s) {
|
|
628
|
+
case "days":
|
|
629
|
+
f = Je(r, d);
|
|
630
|
+
break;
|
|
631
|
+
case "months":
|
|
632
|
+
f = Ze(r, d);
|
|
633
|
+
break;
|
|
634
|
+
case "years":
|
|
635
|
+
f = Ge(r, d);
|
|
636
|
+
break;
|
|
637
|
+
default:
|
|
638
|
+
f = 0;
|
|
639
|
+
break;
|
|
640
|
+
}
|
|
641
|
+
return f < l;
|
|
642
|
+
}, q = ({ context: t, name: n, type: a, value: l }) => {
|
|
643
|
+
const s = t.parent[n];
|
|
644
|
+
if (!s || !l) return !0;
|
|
645
|
+
const c = l.compare(s);
|
|
646
|
+
return a == "max" ? c >= 0 : c <= 0;
|
|
647
|
+
}, P = ({ value: t, date: n, type: a }) => {
|
|
648
|
+
if (!t || !n) return !0;
|
|
649
|
+
let l, s;
|
|
650
|
+
try {
|
|
651
|
+
l = S(n), s = S(t.toString());
|
|
652
|
+
} catch {
|
|
653
|
+
return !1;
|
|
654
|
+
}
|
|
655
|
+
if (We(s, l)) return !0;
|
|
656
|
+
const c = xe(s, l);
|
|
657
|
+
return a === "min" ? c : !c;
|
|
658
|
+
}, ue = ({ value: t, context: n, name: a, range: l, rangeDate: s, type: c }) => {
|
|
659
|
+
const o = n.parent[a];
|
|
660
|
+
if (!o || !t || !l || l === 0 || !s) return !0;
|
|
661
|
+
const r = t.toString(), d = o.toString(), f = S(c == "max" ? d : r, "HH:mm:ss"), u = S(c == "min" ? d : r, "HH:mm:ss");
|
|
662
|
+
let i = 0;
|
|
663
|
+
return s === "hours" ? i = Qe(u, f) : i = Xe(u, f), i < l;
|
|
664
|
+
}, z = (t, n) => {
|
|
665
|
+
switch (t) {
|
|
666
|
+
case "days":
|
|
667
|
+
return n === 1 ? "El rango es de 1 dia" : `El rango es de ${n} dias`;
|
|
668
|
+
case "months":
|
|
669
|
+
return n === 1 ? "El rango es de 1 mes" : `El rango es de ${n} meses`;
|
|
670
|
+
case "years":
|
|
671
|
+
return n === 1 ? "El rango es de 1 año" : `El rango es de ${n} años`;
|
|
672
|
+
case "hours":
|
|
673
|
+
return n === 1 ? "El rango es de 1 hora" : `El rango es de ${n} horas`;
|
|
674
|
+
case "minutes":
|
|
675
|
+
return n === 1 ? "El rango es de 1 minuto" : `El rango es de ${n} minutos`;
|
|
676
|
+
default:
|
|
677
|
+
return "Custom Test";
|
|
678
|
+
}
|
|
679
|
+
}, ut = ({
|
|
680
|
+
endDate: t,
|
|
681
|
+
startDate: n,
|
|
682
|
+
range: a = 0,
|
|
683
|
+
type: l,
|
|
684
|
+
maxEndDate: s,
|
|
685
|
+
maxStartDate: c,
|
|
686
|
+
minEndDate: o,
|
|
687
|
+
minStartDate: r
|
|
688
|
+
}) => {
|
|
689
|
+
const d = _().test(
|
|
690
|
+
"Menor",
|
|
691
|
+
"Este campo debe ser menor a la fecha final",
|
|
692
|
+
(u, i) => q({ value: u, context: i, name: t, type: "min" })
|
|
693
|
+
).when([], {
|
|
694
|
+
is: a && a > 0 && l,
|
|
695
|
+
then: (u) => u.test(
|
|
696
|
+
"Rango de tiempo",
|
|
697
|
+
z(l, a),
|
|
698
|
+
(i, b) => me({
|
|
699
|
+
context: b,
|
|
700
|
+
value: i,
|
|
701
|
+
range: a,
|
|
702
|
+
name: t,
|
|
703
|
+
rangeDate: l,
|
|
704
|
+
type: "min"
|
|
705
|
+
})
|
|
706
|
+
)
|
|
707
|
+
}).when([], {
|
|
708
|
+
is: c,
|
|
709
|
+
then: (u) => u.test(
|
|
710
|
+
"Max Date",
|
|
711
|
+
`Fecha maxima ${V(c, "DD/MM/YYYY")}`,
|
|
712
|
+
(i) => P({ value: i, date: c, type: "max" })
|
|
713
|
+
)
|
|
714
|
+
}).when([], {
|
|
715
|
+
is: r,
|
|
716
|
+
then: (u) => u.test(
|
|
717
|
+
"Min Date",
|
|
718
|
+
`Fecha minima ${V(r, "DD/MM/YYYY")}`,
|
|
719
|
+
(i) => P({ value: i, date: r, type: "min" })
|
|
720
|
+
)
|
|
721
|
+
}), f = _().test(
|
|
722
|
+
"Mayor",
|
|
723
|
+
"Este campo debe ser mayor a la fecha inicial",
|
|
724
|
+
(u, i) => q({ value: u, context: i, name: n, type: "max" })
|
|
725
|
+
).when([], {
|
|
726
|
+
is: a && a > 0 && l,
|
|
727
|
+
then: (u) => u.test(
|
|
728
|
+
"Rango de tiempo",
|
|
729
|
+
z(l, a),
|
|
730
|
+
(i, b) => me({
|
|
731
|
+
context: b,
|
|
732
|
+
value: i,
|
|
733
|
+
range: a,
|
|
734
|
+
name: n,
|
|
735
|
+
rangeDate: l,
|
|
736
|
+
type: "max"
|
|
737
|
+
})
|
|
738
|
+
)
|
|
739
|
+
}).when([], {
|
|
740
|
+
is: s,
|
|
741
|
+
then: (u) => u.test(
|
|
742
|
+
"Max Date",
|
|
743
|
+
`Fecha maxima ${V(s, "DD/MM/YYYY")}`,
|
|
744
|
+
(i) => P({ value: i, date: s, type: "max" })
|
|
745
|
+
)
|
|
746
|
+
}).when([], {
|
|
747
|
+
is: o,
|
|
748
|
+
then: (u) => u.test(
|
|
749
|
+
"Min Date",
|
|
750
|
+
`Fecha minima ${V(o, "DD/MM/YYYY")}`,
|
|
751
|
+
(i) => P({ value: i, date: o, type: "min" })
|
|
752
|
+
)
|
|
753
|
+
});
|
|
754
|
+
return { startDateRule: d, endDateRule: f };
|
|
755
|
+
}, dt = ({ minDate: t, maxDate: n }) => _().test(
|
|
756
|
+
"Min Date",
|
|
757
|
+
`Fecha minima ${V(t, "DD/MM/YYYY")}`,
|
|
758
|
+
(a) => P({ value: a, date: t, type: "min" })
|
|
759
|
+
).test(
|
|
760
|
+
"Max Date",
|
|
761
|
+
`Fecha maxima ${V(n, "DD/MM/YYYY")}`,
|
|
762
|
+
(a) => P({ value: a, date: n, type: "max" })
|
|
763
|
+
), ft = ({ endTime: t, startTime: n, range: a = 0, type: l }) => {
|
|
764
|
+
const s = _().test(
|
|
765
|
+
"Menor",
|
|
766
|
+
"Este campo debe ser menor a la hora final",
|
|
767
|
+
(o, r) => q({ value: o, context: r, name: t, type: "min" })
|
|
768
|
+
).when([], {
|
|
769
|
+
is: a && a > 0 && l,
|
|
770
|
+
then: (o) => o.test(
|
|
771
|
+
"Rango de tiempo",
|
|
772
|
+
z(l, a),
|
|
773
|
+
(r, d) => ue({
|
|
774
|
+
value: r,
|
|
775
|
+
context: d,
|
|
776
|
+
name: t,
|
|
777
|
+
type: "min",
|
|
778
|
+
range: a,
|
|
779
|
+
rangeDate: l
|
|
780
|
+
})
|
|
781
|
+
)
|
|
782
|
+
}), c = _().test(
|
|
783
|
+
"Mayor",
|
|
784
|
+
"Este campo debe ser mayor a la hora inicial",
|
|
785
|
+
(o, r) => q({ value: o, context: r, name: n, type: "max" })
|
|
786
|
+
).when([], {
|
|
787
|
+
is: a && a > 0 && l,
|
|
788
|
+
then: (o) => o.test(
|
|
789
|
+
"Rango de tiempo",
|
|
790
|
+
z(l, a),
|
|
791
|
+
(r, d) => ue({
|
|
792
|
+
value: r,
|
|
793
|
+
context: d,
|
|
794
|
+
name: n,
|
|
795
|
+
type: "max",
|
|
796
|
+
range: a,
|
|
797
|
+
rangeDate: l
|
|
798
|
+
})
|
|
799
|
+
)
|
|
800
|
+
});
|
|
801
|
+
return { startTimeRule: s, endTimeRule: c };
|
|
802
|
+
}, Tt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
803
|
+
__proto__: null,
|
|
804
|
+
dateMinMaxValidate: dt,
|
|
805
|
+
dualDateValidate: ut,
|
|
806
|
+
dualTimeValidate: ft
|
|
807
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
808
|
+
export {
|
|
809
|
+
xt as DataTable,
|
|
810
|
+
yt as Layout,
|
|
811
|
+
Yt as Modal,
|
|
812
|
+
Dt as Panel,
|
|
813
|
+
Rt as RHFAutocomplete,
|
|
814
|
+
wt as RHFDate,
|
|
815
|
+
Mt as RHFDualDate,
|
|
816
|
+
St as RHFDualTime,
|
|
817
|
+
Ct as RHFInput,
|
|
818
|
+
Nt as RHFRadioGroup,
|
|
819
|
+
kt as RHFSelect,
|
|
820
|
+
Ft as RHFTextArea,
|
|
821
|
+
$t as RHFTime,
|
|
822
|
+
Tt as validation,
|
|
823
|
+
It as yupEs
|
|
824
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "react-hook-form-next-ui",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "1.3.30",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"tailwind react components",
|
|
9
|
+
"nextui",
|
|
10
|
+
"react-hook-form-next-ui",
|
|
11
|
+
"react-components",
|
|
12
|
+
"components-react",
|
|
13
|
+
"nextui-components-rhf",
|
|
14
|
+
"RHF",
|
|
15
|
+
"react-hook-form",
|
|
16
|
+
"React Hook Form"
|
|
17
|
+
],
|
|
18
|
+
"author": "Nicolas Chamorro Giron",
|
|
19
|
+
"description": "React Components with React Hook Form and NextUI",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"import": "./dist/index.js"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"dev": "vite",
|
|
31
|
+
"build": "tsc -b && vite build",
|
|
32
|
+
"lint": "eslint .",
|
|
33
|
+
"preview": "vite preview"
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"react": "^18.3.1",
|
|
37
|
+
"react-dom": "^18.3.1",
|
|
38
|
+
"react-hook-form": "^7.53.0",
|
|
39
|
+
"@nextui-org/react": "^2.4.6",
|
|
40
|
+
"@hookform/resolvers": "^3.9.0",
|
|
41
|
+
"@formkit/tempo": "^0.1.2",
|
|
42
|
+
"framer-motion": "^11.5.4",
|
|
43
|
+
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@eslint/js": "^9.9.0",
|
|
47
|
+
"@faker-js/faker": "^8.4.1",
|
|
48
|
+
"@formkit/tempo": "^0.1.2",
|
|
49
|
+
"@hookform/devtools": "^4.3.1",
|
|
50
|
+
"@hookform/resolvers": "^3.9.0",
|
|
51
|
+
"@nextui-org/react": "^2.4.6",
|
|
52
|
+
"@types/node": "^22.5.0",
|
|
53
|
+
"@types/react": "^18.3.3",
|
|
54
|
+
"@types/react-dom": "^18.3.0",
|
|
55
|
+
"@vitejs/plugin-react-swc": "^3.5.0",
|
|
56
|
+
"autoprefixer": "^10.4.20",
|
|
57
|
+
"eslint": "^9.9.0",
|
|
58
|
+
"eslint-plugin-react-hooks": "^5.1.0-rc.0",
|
|
59
|
+
"eslint-plugin-react-refresh": "^0.4.9",
|
|
60
|
+
"framer-motion": "^11.5.4",
|
|
61
|
+
"globals": "^15.9.0",
|
|
62
|
+
"postcss": "^8.4.41",
|
|
63
|
+
"react": "^18.3.1",
|
|
64
|
+
"react-dom": "^18.3.1",
|
|
65
|
+
"react-hook-form": "^7.53.0",
|
|
66
|
+
"tailwindcss": "^3.4.10",
|
|
67
|
+
"typescript": "^5.5.3",
|
|
68
|
+
"typescript-eslint": "^8.0.1",
|
|
69
|
+
"vite": "^5.4.1",
|
|
70
|
+
"vite-bundle-analyzer": "^0.10.6",
|
|
71
|
+
"vite-plugin-dts": "^4.2.1",
|
|
72
|
+
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz",
|
|
73
|
+
"yup": "^1.4.0"
|
|
74
|
+
}
|
|
75
|
+
}
|