lkd-web-kit 0.8.0 → 0.8.2
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/_virtual/_rolldown/runtime.cjs +23 -0
- package/dist/components/EmptyState/index.cjs +38 -52
- package/dist/components/EmptyState/index.js +37 -48
- package/dist/components/Icon.cjs +46 -50
- package/dist/components/Icon.js +44 -46
- package/dist/components/InfinityLoadMoreButton/index.cjs +30 -42
- package/dist/components/InfinityLoadMoreButton/index.js +28 -38
- package/dist/components/InfinitySelect/index.cjs +126 -168
- package/dist/components/InfinitySelect/index.js +125 -164
- package/dist/components/MyCheckboxGroup/index.cjs +14 -22
- package/dist/components/MyCheckboxGroup/index.js +13 -18
- package/dist/components/MyDateInput/index.cjs +12 -18
- package/dist/components/MyDateInput/index.js +11 -14
- package/dist/components/MyDatePickerInput/CalendarIcon.cjs +45 -64
- package/dist/components/MyDatePickerInput/CalendarIcon.js +43 -61
- package/dist/components/MyDatePickerInput/index.cjs +12 -18
- package/dist/components/MyDatePickerInput/index.js +11 -14
- package/dist/components/MyDateTimePicker/index.cjs +12 -18
- package/dist/components/MyDateTimePicker/index.js +11 -14
- package/dist/components/MyMonthPickerInput/index.cjs +12 -18
- package/dist/components/MyMonthPickerInput/index.js +11 -14
- package/dist/components/MyMultiSelect/index.cjs +9 -9
- package/dist/components/MyMultiSelect/index.js +8 -5
- package/dist/components/MyNotifications/index.cjs +11 -17
- package/dist/components/MyNotifications/index.js +10 -13
- package/dist/components/MyNumberInput/index.cjs +9 -15
- package/dist/components/MyNumberInput/index.js +8 -11
- package/dist/components/MyRadioGroup/index.cjs +14 -22
- package/dist/components/MyRadioGroup/index.js +13 -18
- package/dist/components/MySelect/index.cjs +9 -15
- package/dist/components/MySelect/index.js +8 -11
- package/dist/components/MyTextInput/index.cjs +9 -15
- package/dist/components/MyTextInput/index.js +8 -11
- package/dist/components/MyTextarea/index.cjs +9 -15
- package/dist/components/MyTextarea/index.js +8 -11
- package/dist/components/MyTimeInput/index.cjs +9 -15
- package/dist/components/MyTimeInput/index.js +8 -11
- package/dist/components/NavItems.cjs +28 -38
- package/dist/components/NavItems.js +26 -34
- package/dist/consts/http-status.cjs +66 -69
- package/dist/consts/http-status.js +66 -65
- package/dist/consts/revalidate.cjs +10 -13
- package/dist/consts/revalidate.js +10 -9
- package/dist/contexts/NavigationHistoryContext/hook.cjs +41 -42
- package/dist/contexts/NavigationHistoryContext/hook.js +40 -38
- package/dist/contexts/NavigationHistoryContext/index.cjs +31 -28
- package/dist/contexts/NavigationHistoryContext/index.js +30 -24
- package/dist/contexts/PageDataContext/index.cjs +15 -18
- package/dist/contexts/PageDataContext/index.js +14 -14
- package/dist/form/Form.cjs +19 -28
- package/dist/form/Form.js +18 -24
- package/dist/form/FormSubmitButton.cjs +15 -27
- package/dist/form/FormSubmitButton.js +14 -23
- package/dist/form/base/FormCheckbox.cjs +15 -23
- package/dist/form/base/FormCheckbox.js +14 -19
- package/dist/form/base/FormCheckboxGroup.cjs +10 -16
- package/dist/form/base/FormCheckboxGroup.js +9 -12
- package/dist/form/base/FormDateInput.cjs +10 -16
- package/dist/form/base/FormDateInput.js +9 -12
- package/dist/form/base/FormDatePickerInput.cjs +10 -16
- package/dist/form/base/FormDatePickerInput.js +9 -12
- package/dist/form/base/FormDateTimePicker.cjs +10 -16
- package/dist/form/base/FormDateTimePicker.js +9 -12
- package/dist/form/base/FormMonthPickerInput.cjs +10 -16
- package/dist/form/base/FormMonthPickerInput.js +9 -12
- package/dist/form/base/FormMultiSelect.cjs +10 -10
- package/dist/form/base/FormMultiSelect.js +9 -6
- package/dist/form/base/FormNumberInput.cjs +12 -12
- package/dist/form/base/FormNumberInput.js +10 -8
- package/dist/form/base/FormRadioGroup.cjs +10 -16
- package/dist/form/base/FormRadioGroup.js +9 -12
- package/dist/form/base/FormSelect.cjs +10 -16
- package/dist/form/base/FormSelect.js +9 -12
- package/dist/form/base/FormSelectInfinity.cjs +15 -21
- package/dist/form/base/FormSelectInfinity.js +14 -17
- package/dist/form/base/FormTextInput.cjs +10 -16
- package/dist/form/base/FormTextInput.js +9 -12
- package/dist/form/base/FormTextarea.cjs +10 -10
- package/dist/form/base/FormTextarea.js +9 -6
- package/dist/form/base/FormTimeInput.cjs +18 -24
- package/dist/form/base/FormTimeInput.js +17 -20
- package/dist/form/utils/nullable-but-required.cjs +14 -17
- package/dist/form/utils/nullable-but-required.js +13 -13
- package/dist/form/utils/optional-but-required.cjs +14 -17
- package/dist/form/utils/optional-but-required.js +13 -13
- package/dist/form/utils/zodValidator.cjs +9 -13
- package/dist/form/utils/zodValidator.js +9 -9
- package/dist/hocs/withController.cjs +43 -54
- package/dist/hocs/withController.js +42 -50
- package/dist/hocs/withModalManager.cjs +29 -35
- package/dist/hocs/withModalManager.js +28 -31
- package/dist/hooks/useBreakpoint.cjs +8 -12
- package/dist/hooks/useBreakpoint.js +7 -8
- package/dist/hooks/useFetchNextPageOnScroll.cjs +13 -21
- package/dist/hooks/useFetchNextPageOnScroll.js +13 -17
- package/dist/hooks/useOnScrollProgress.cjs +33 -37
- package/dist/hooks/useOnScrollProgress.js +32 -33
- package/dist/hooks/useUpdateSearchParams.cjs +22 -22
- package/dist/hooks/useUpdateSearchParams.js +21 -18
- package/dist/hooks/useZodConfig.cjs +14 -19
- package/dist/hooks/useZodConfig.js +12 -15
- package/dist/index.cjs +130 -136
- package/dist/index.d.ts +13 -13
- package/dist/index.js +62 -61
- package/dist/mantine/breakpoints-with-px.cjs +9 -12
- package/dist/mantine/breakpoints-with-px.js +9 -8
- package/dist/mantine/my-default-theme.cjs +23 -42
- package/dist/mantine/my-default-theme.js +22 -38
- package/dist/mantine/to-tailwind-colors.cjs +9 -18
- package/dist/mantine/to-tailwind-colors.js +9 -14
- package/dist/utils/array/groupBy.cjs +30 -40
- package/dist/utils/array/groupBy.js +30 -36
- package/dist/utils/array/shuffleArray.cjs +11 -17
- package/dist/utils/array/shuffleArray.js +11 -13
- package/dist/utils/formatBytes.cjs +12 -11
- package/dist/utils/formatBytes.js +12 -7
- package/dist/utils/isInfinityEmpty.cjs +3 -6
- package/dist/utils/isInfinityEmpty.js +3 -2
- package/dist/utils/ky/addBodyJsonHook.cjs +9 -14
- package/dist/utils/ky/addBodyJsonHook.js +8 -10
- package/dist/utils/ky/parseJson.cjs +6 -9
- package/dist/utils/ky/parseJson.js +6 -5
- package/dist/utils/new-route.cjs +30 -39
- package/dist/utils/new-route.js +30 -35
- package/dist/utils/query-stringify.cjs +5 -8
- package/dist/utils/query-stringify.js +5 -4
- package/dist/utils/virtual-styles.cjs +21 -26
- package/dist/utils/virtual-styles.js +21 -22
- package/package.json +20 -19
- package/dist/node_modules/@mantine/notifications/styles.css +0 -42
- package/dist/node_modules/@tanstack/react-virtual/dist/esm/index.cjs +0 -74
- package/dist/node_modules/@tanstack/react-virtual/dist/esm/index.js +0 -45
- package/dist/node_modules/@tanstack/virtual-core/dist/esm/index.cjs +0 -886
- package/dist/node_modules/@tanstack/virtual-core/dist/esm/index.js +0 -872
- package/dist/node_modules/@tanstack/virtual-core/dist/esm/utils.cjs +0 -75
- package/dist/node_modules/@tanstack/virtual-core/dist/esm/utils.js +0 -68
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
{
|
|
12
|
-
...field,
|
|
13
|
-
...props
|
|
14
|
-
}
|
|
15
|
-
));
|
|
16
|
-
|
|
1
|
+
require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_index = require("../../components/MySelect/index.cjs");
|
|
3
|
+
const require_withController = require("../../hocs/withController.cjs");
|
|
4
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
5
|
+
//#region src/form/base/FormSelect.tsx
|
|
6
|
+
var FormSelect = require_withController.withController(({ field, props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_index.MySelect, {
|
|
7
|
+
...field,
|
|
8
|
+
...props
|
|
9
|
+
}));
|
|
10
|
+
//#endregion
|
|
17
11
|
exports.FormSelect = FormSelect;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
));
|
|
12
|
-
|
|
1
|
+
import { MySelect } from "../../components/MySelect/index.js";
|
|
2
|
+
import { withController } from "../../hocs/withController.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region src/form/base/FormSelect.tsx
|
|
5
|
+
var FormSelect = withController(({ field, props }) => /* @__PURE__ */ jsx(MySelect, {
|
|
6
|
+
...field,
|
|
7
|
+
...props
|
|
8
|
+
}));
|
|
9
|
+
//#endregion
|
|
13
10
|
export { FormSelect };
|
|
@@ -1,23 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
onChange: (e) => {
|
|
16
|
-
field.onChange(e);
|
|
17
|
-
props.onChange?.(e);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
);
|
|
1
|
+
require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_index = require("../../components/InfinitySelect/index.cjs");
|
|
3
|
+
const require_withController = require("../../hocs/withController.cjs");
|
|
4
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
5
|
+
//#region src/form/base/FormSelectInfinity.tsx
|
|
6
|
+
var FormInfinitySelect = require_withController.withController(({ field, props }) => {
|
|
7
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_index.InfinitySelect, {
|
|
8
|
+
...field,
|
|
9
|
+
...props,
|
|
10
|
+
onChange: (e) => {
|
|
11
|
+
field.onChange(e);
|
|
12
|
+
props.onChange?.(e);
|
|
13
|
+
}
|
|
14
|
+
});
|
|
21
15
|
});
|
|
22
|
-
|
|
16
|
+
//#endregion
|
|
23
17
|
exports.FormInfinitySelect = FormInfinitySelect;
|
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
);
|
|
1
|
+
import { InfinitySelect } from "../../components/InfinitySelect/index.js";
|
|
2
|
+
import { withController } from "../../hocs/withController.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region src/form/base/FormSelectInfinity.tsx
|
|
5
|
+
var FormInfinitySelect = withController(({ field, props }) => {
|
|
6
|
+
return /* @__PURE__ */ jsx(InfinitySelect, {
|
|
7
|
+
...field,
|
|
8
|
+
...props,
|
|
9
|
+
onChange: (e) => {
|
|
10
|
+
field.onChange(e);
|
|
11
|
+
props.onChange?.(e);
|
|
12
|
+
}
|
|
13
|
+
});
|
|
17
14
|
});
|
|
18
|
-
|
|
15
|
+
//#endregion
|
|
19
16
|
export { FormInfinitySelect };
|
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
{
|
|
12
|
-
...field,
|
|
13
|
-
...props
|
|
14
|
-
}
|
|
15
|
-
));
|
|
16
|
-
|
|
1
|
+
require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_index = require("../../components/MyTextInput/index.cjs");
|
|
3
|
+
const require_withController = require("../../hocs/withController.cjs");
|
|
4
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
5
|
+
//#region src/form/base/FormTextInput.tsx
|
|
6
|
+
var FormTextInput = require_withController.withController(({ field, props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_index.MyTextInput, {
|
|
7
|
+
...field,
|
|
8
|
+
...props
|
|
9
|
+
}));
|
|
10
|
+
//#endregion
|
|
17
11
|
exports.FormTextInput = FormTextInput;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
));
|
|
12
|
-
|
|
1
|
+
import { MyTextInput } from "../../components/MyTextInput/index.js";
|
|
2
|
+
import { withController } from "../../hocs/withController.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region src/form/base/FormTextInput.tsx
|
|
5
|
+
var FormTextInput = withController(({ field, props }) => /* @__PURE__ */ jsx(MyTextInput, {
|
|
6
|
+
...field,
|
|
7
|
+
...props
|
|
8
|
+
}));
|
|
9
|
+
//#endregion
|
|
13
10
|
export { FormTextInput };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_index = require("../../components/MyTextarea/index.cjs");
|
|
3
|
+
const require_withController = require("../../hocs/withController.cjs");
|
|
4
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
5
|
+
//#region src/form/base/FormTextarea.tsx
|
|
6
|
+
var FormTextarea = require_withController.withController(({ field, props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_index.MyTextarea, {
|
|
7
|
+
...field,
|
|
8
|
+
...props
|
|
9
|
+
}));
|
|
10
|
+
//#endregion
|
|
11
11
|
exports.FormTextarea = FormTextarea;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { MyTextarea } from "../../components/MyTextarea/index.js";
|
|
2
|
+
import { withController } from "../../hocs/withController.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region src/form/base/FormTextarea.tsx
|
|
5
|
+
var FormTextarea = withController(({ field, props }) => /* @__PURE__ */ jsx(MyTextarea, {
|
|
6
|
+
...field,
|
|
7
|
+
...props
|
|
8
|
+
}));
|
|
9
|
+
//#endregion
|
|
7
10
|
export { FormTextarea };
|
|
@@ -1,29 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
));
|
|
16
|
-
const timeInputToNumber = (timeInput) => {
|
|
17
|
-
const [hours, minutes] = timeInput.split(":").map(Number);
|
|
18
|
-
const result = hours + minutes / 60;
|
|
19
|
-
return Number(result.toFixed(2));
|
|
1
|
+
require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_index = require("../../components/MyTimeInput/index.cjs");
|
|
3
|
+
const require_withController = require("../../hocs/withController.cjs");
|
|
4
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
5
|
+
//#region src/form/base/FormTimeInput.tsx
|
|
6
|
+
var FormTimeInput = require_withController.withController(({ field, props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_index.MyTimeInput, {
|
|
7
|
+
...field,
|
|
8
|
+
...props
|
|
9
|
+
}));
|
|
10
|
+
var timeInputToNumber = (timeInput) => {
|
|
11
|
+
const [hours, minutes] = timeInput.split(":").map(Number);
|
|
12
|
+
const result = hours + minutes / 60;
|
|
13
|
+
return Number(result.toFixed(2));
|
|
20
14
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
15
|
+
var numberToTimeInput = (number) => {
|
|
16
|
+
const hours = Math.floor(number);
|
|
17
|
+
const minutes = Math.round((number - hours) * 60);
|
|
18
|
+
return `${hours.toString().padStart(2, "0")}:${minutes.toString().padStart(2, "0")}`;
|
|
25
19
|
};
|
|
26
|
-
|
|
20
|
+
//#endregion
|
|
27
21
|
exports.FormTimeInput = FormTimeInput;
|
|
28
22
|
exports.numberToTimeInput = numberToTimeInput;
|
|
29
23
|
exports.timeInputToNumber = timeInputToNumber;
|
|
@@ -1,23 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const [hours, minutes] = timeInput.split(":").map(Number);
|
|
14
|
-
const result = hours + minutes / 60;
|
|
15
|
-
return Number(result.toFixed(2));
|
|
1
|
+
import { MyTimeInput } from "../../components/MyTimeInput/index.js";
|
|
2
|
+
import { withController } from "../../hocs/withController.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region src/form/base/FormTimeInput.tsx
|
|
5
|
+
var FormTimeInput = withController(({ field, props }) => /* @__PURE__ */ jsx(MyTimeInput, {
|
|
6
|
+
...field,
|
|
7
|
+
...props
|
|
8
|
+
}));
|
|
9
|
+
var timeInputToNumber = (timeInput) => {
|
|
10
|
+
const [hours, minutes] = timeInput.split(":").map(Number);
|
|
11
|
+
const result = hours + minutes / 60;
|
|
12
|
+
return Number(result.toFixed(2));
|
|
16
13
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
var numberToTimeInput = (number) => {
|
|
15
|
+
const hours = Math.floor(number);
|
|
16
|
+
const minutes = Math.round((number - hours) * 60);
|
|
17
|
+
return `${hours.toString().padStart(2, "0")}:${minutes.toString().padStart(2, "0")}`;
|
|
21
18
|
};
|
|
22
|
-
|
|
19
|
+
//#endregion
|
|
23
20
|
export { FormTimeInput, numberToTimeInput, timeInputToNumber };
|
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return z.z.NEVER;
|
|
15
|
-
}
|
|
16
|
-
return val;
|
|
1
|
+
require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
let zod = require("zod");
|
|
3
|
+
//#region src/form/utils/nullable-but-required.ts
|
|
4
|
+
var nullableButRequired = (schema, message = "Campo requerido") => schema.nullable().transform((val, ctx) => {
|
|
5
|
+
if (val === null) {
|
|
6
|
+
ctx.addIssue({
|
|
7
|
+
code: "custom",
|
|
8
|
+
fatal: true,
|
|
9
|
+
message
|
|
10
|
+
});
|
|
11
|
+
return zod.z.NEVER;
|
|
12
|
+
}
|
|
13
|
+
return val;
|
|
17
14
|
});
|
|
18
|
-
|
|
15
|
+
//#endregion
|
|
19
16
|
exports.nullableButRequired = nullableButRequired;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { z } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
//#region src/form/utils/nullable-but-required.ts
|
|
3
|
+
var nullableButRequired = (schema, message = "Campo requerido") => schema.nullable().transform((val, ctx) => {
|
|
4
|
+
if (val === null) {
|
|
5
|
+
ctx.addIssue({
|
|
6
|
+
code: "custom",
|
|
7
|
+
fatal: true,
|
|
8
|
+
message
|
|
9
|
+
});
|
|
10
|
+
return z.NEVER;
|
|
11
|
+
}
|
|
12
|
+
return val;
|
|
13
13
|
});
|
|
14
|
-
|
|
14
|
+
//#endregion
|
|
15
15
|
export { nullableButRequired };
|
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return z.z.NEVER;
|
|
15
|
-
}
|
|
16
|
-
return val;
|
|
1
|
+
require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
let zod = require("zod");
|
|
3
|
+
//#region src/form/utils/optional-but-required.ts
|
|
4
|
+
var optionalButRequired = (schema, message = "Campo requerido") => schema.optional().transform((val, ctx) => {
|
|
5
|
+
if (val === void 0) {
|
|
6
|
+
ctx.addIssue({
|
|
7
|
+
code: "custom",
|
|
8
|
+
fatal: true,
|
|
9
|
+
message
|
|
10
|
+
});
|
|
11
|
+
return zod.z.NEVER;
|
|
12
|
+
}
|
|
13
|
+
return val;
|
|
17
14
|
});
|
|
18
|
-
|
|
15
|
+
//#endregion
|
|
19
16
|
exports.optionalButRequired = optionalButRequired;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { z } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
//#region src/form/utils/optional-but-required.ts
|
|
3
|
+
var optionalButRequired = (schema, message = "Campo requerido") => schema.optional().transform((val, ctx) => {
|
|
4
|
+
if (val === void 0) {
|
|
5
|
+
ctx.addIssue({
|
|
6
|
+
code: "custom",
|
|
7
|
+
fatal: true,
|
|
8
|
+
message
|
|
9
|
+
});
|
|
10
|
+
return z.NEVER;
|
|
11
|
+
}
|
|
12
|
+
return val;
|
|
13
13
|
});
|
|
14
|
-
|
|
14
|
+
//#endregion
|
|
15
15
|
export { optionalButRequired };
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const { error } = result;
|
|
10
|
-
const firstError = error.issues[0];
|
|
11
|
-
return firstError?.message;
|
|
12
|
-
};
|
|
1
|
+
//#region src/form/utils/zodValidator.ts
|
|
2
|
+
var zodValidator = (schema) => {
|
|
3
|
+
return (values) => {
|
|
4
|
+
const result = schema.safeParse(values);
|
|
5
|
+
if (result.success) return;
|
|
6
|
+
const { error } = result;
|
|
7
|
+
return error.issues[0]?.message;
|
|
8
|
+
};
|
|
13
9
|
};
|
|
14
|
-
|
|
10
|
+
//#endregion
|
|
15
11
|
exports.zodValidator = zodValidator;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
//#region src/form/utils/zodValidator.ts
|
|
2
|
+
var zodValidator = (schema) => {
|
|
3
|
+
return (values) => {
|
|
4
|
+
const result = schema.safeParse(values);
|
|
5
|
+
if (result.success) return;
|
|
6
|
+
const { error } = result;
|
|
7
|
+
return error.issues[0]?.message;
|
|
8
|
+
};
|
|
9
9
|
};
|
|
10
|
-
|
|
10
|
+
//#endregion
|
|
11
11
|
export { zodValidator };
|
|
@@ -1,56 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
error: error?.message
|
|
44
|
-
},
|
|
45
|
-
...withFormRestProps
|
|
46
|
-
};
|
|
47
|
-
return /* @__PURE__ */ jsxRuntime.jsx(WrappedComponent, { ...fieldProps });
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
);
|
|
51
|
-
};
|
|
52
|
-
FormField.displayName = `WithForm(${WrappedComponent.displayName})`;
|
|
53
|
-
return FormField;
|
|
1
|
+
"use client";
|
|
2
|
+
require("../_virtual/_rolldown/runtime.cjs");
|
|
3
|
+
const require_zodValidator = require("../form/utils/zodValidator.cjs");
|
|
4
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
5
|
+
let react_hook_form = require("react-hook-form");
|
|
6
|
+
//#region src/hocs/withController.tsx
|
|
7
|
+
var withController = (WrappedComponent, getControllerProps) => {
|
|
8
|
+
const FormField = (props) => {
|
|
9
|
+
const { validate, name = "", placeholder, label, description, ...withFormRestProps } = props;
|
|
10
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_hook_form.Controller, {
|
|
11
|
+
name,
|
|
12
|
+
defaultValue: "",
|
|
13
|
+
rules: { validate: validate && !props.disabled ? require_zodValidator.zodValidator(validate) : void 0 },
|
|
14
|
+
disabled: props.disabled,
|
|
15
|
+
...getControllerProps?.(props),
|
|
16
|
+
render: (renderProps) => {
|
|
17
|
+
const { fieldState: { error } } = renderProps;
|
|
18
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(WrappedComponent, {
|
|
19
|
+
...renderProps,
|
|
20
|
+
props: {
|
|
21
|
+
...props,
|
|
22
|
+
validate: void 0,
|
|
23
|
+
onValueChange: void 0
|
|
24
|
+
},
|
|
25
|
+
field: {
|
|
26
|
+
...renderProps.field,
|
|
27
|
+
onChange: (...value) => {
|
|
28
|
+
renderProps.field.onChange(...value);
|
|
29
|
+
props.onValueChange?.(...value);
|
|
30
|
+
},
|
|
31
|
+
label,
|
|
32
|
+
placeholder,
|
|
33
|
+
description,
|
|
34
|
+
error: error?.message
|
|
35
|
+
},
|
|
36
|
+
...withFormRestProps
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
FormField.displayName = `WithForm(${WrappedComponent.displayName})`;
|
|
42
|
+
return FormField;
|
|
54
43
|
};
|
|
55
|
-
|
|
44
|
+
//#endregion
|
|
56
45
|
exports.withController = withController;
|