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,52 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
return /* @__PURE__ */ jsx(WrappedComponent, { ...fieldProps });
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
);
|
|
47
|
-
};
|
|
48
|
-
FormField.displayName = `WithForm(${WrappedComponent.displayName})`;
|
|
49
|
-
return FormField;
|
|
1
|
+
"use client";
|
|
2
|
+
import { zodValidator } from "../form/utils/zodValidator.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { Controller } from "react-hook-form";
|
|
5
|
+
//#region src/hocs/withController.tsx
|
|
6
|
+
var withController = (WrappedComponent, getControllerProps) => {
|
|
7
|
+
const FormField = (props) => {
|
|
8
|
+
const { validate, name = "", placeholder, label, description, ...withFormRestProps } = props;
|
|
9
|
+
return /* @__PURE__ */ jsx(Controller, {
|
|
10
|
+
name,
|
|
11
|
+
defaultValue: "",
|
|
12
|
+
rules: { validate: validate && !props.disabled ? zodValidator(validate) : void 0 },
|
|
13
|
+
disabled: props.disabled,
|
|
14
|
+
...getControllerProps?.(props),
|
|
15
|
+
render: (renderProps) => {
|
|
16
|
+
const { fieldState: { error } } = renderProps;
|
|
17
|
+
return /* @__PURE__ */ jsx(WrappedComponent, {
|
|
18
|
+
...renderProps,
|
|
19
|
+
props: {
|
|
20
|
+
...props,
|
|
21
|
+
validate: void 0,
|
|
22
|
+
onValueChange: void 0
|
|
23
|
+
},
|
|
24
|
+
field: {
|
|
25
|
+
...renderProps.field,
|
|
26
|
+
onChange: (...value) => {
|
|
27
|
+
renderProps.field.onChange(...value);
|
|
28
|
+
props.onValueChange?.(...value);
|
|
29
|
+
},
|
|
30
|
+
label,
|
|
31
|
+
placeholder,
|
|
32
|
+
description,
|
|
33
|
+
error: error?.message
|
|
34
|
+
},
|
|
35
|
+
...withFormRestProps
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
FormField.displayName = `WithForm(${WrappedComponent.displayName})`;
|
|
41
|
+
return FormField;
|
|
50
42
|
};
|
|
51
|
-
|
|
43
|
+
//#endregion
|
|
52
44
|
export { withController };
|
|
@@ -1,37 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
);
|
|
32
|
-
};
|
|
33
|
-
Wrapper.displayName = `WithModalManager(${WrappedComponent.displayName})`;
|
|
34
|
-
return Wrapper;
|
|
1
|
+
"use client";
|
|
2
|
+
require("../_virtual/_rolldown/runtime.cjs");
|
|
3
|
+
let react = require("react");
|
|
4
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
5
|
+
//#region src/hocs/withModalManager.tsx
|
|
6
|
+
var withModalManager = (WrappedComponent) => {
|
|
7
|
+
const Wrapper = ({ removeModal, ...props }) => {
|
|
8
|
+
const [isOpen, setIsOpen] = (0, react.useState)(false);
|
|
9
|
+
const onClose = () => {
|
|
10
|
+
setIsOpen(false);
|
|
11
|
+
setTimeout(() => removeModal(), 200);
|
|
12
|
+
props.modalProps.onClose?.();
|
|
13
|
+
};
|
|
14
|
+
(0, react.useEffect)(() => {
|
|
15
|
+
if (props.modalProps.opened) setTimeout(() => setIsOpen(true), 0);
|
|
16
|
+
else onClose();
|
|
17
|
+
}, [props.modalProps.opened]);
|
|
18
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(WrappedComponent, {
|
|
19
|
+
...props,
|
|
20
|
+
modalProps: {
|
|
21
|
+
...props.modalProps,
|
|
22
|
+
opened: isOpen,
|
|
23
|
+
onClose
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
Wrapper.displayName = `WithModalManager(${WrappedComponent.displayName})`;
|
|
28
|
+
return Wrapper;
|
|
35
29
|
};
|
|
36
|
-
|
|
30
|
+
//#endregion
|
|
37
31
|
exports.withModalManager = withModalManager;
|
|
@@ -1,33 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
};
|
|
29
|
-
Wrapper.displayName = `WithModalManager(${WrappedComponent.displayName})`;
|
|
30
|
-
return Wrapper;
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region src/hocs/withModalManager.tsx
|
|
5
|
+
var withModalManager = (WrappedComponent) => {
|
|
6
|
+
const Wrapper = ({ removeModal, ...props }) => {
|
|
7
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
8
|
+
const onClose = () => {
|
|
9
|
+
setIsOpen(false);
|
|
10
|
+
setTimeout(() => removeModal(), 200);
|
|
11
|
+
props.modalProps.onClose?.();
|
|
12
|
+
};
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
if (props.modalProps.opened) setTimeout(() => setIsOpen(true), 0);
|
|
15
|
+
else onClose();
|
|
16
|
+
}, [props.modalProps.opened]);
|
|
17
|
+
return /* @__PURE__ */ jsx(WrappedComponent, {
|
|
18
|
+
...props,
|
|
19
|
+
modalProps: {
|
|
20
|
+
...props.modalProps,
|
|
21
|
+
opened: isOpen,
|
|
22
|
+
onClose
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
Wrapper.displayName = `WithModalManager(${WrappedComponent.displayName})`;
|
|
27
|
+
return Wrapper;
|
|
31
28
|
};
|
|
32
|
-
|
|
29
|
+
//#endregion
|
|
33
30
|
export { withModalManager };
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const useBreakpoint = (breakpoint) => {
|
|
10
|
-
const matches = hooks.useMediaQuery(`(min-width: ${breakpointsWithPx.breakpointsWithPx[breakpoint]})`);
|
|
11
|
-
return matches;
|
|
1
|
+
"use client";
|
|
2
|
+
require("../_virtual/_rolldown/runtime.cjs");
|
|
3
|
+
const require_breakpoints_with_px = require("../mantine/breakpoints-with-px.cjs");
|
|
4
|
+
let _mantine_hooks = require("@mantine/hooks");
|
|
5
|
+
//#region src/hooks/useBreakpoint.ts
|
|
6
|
+
var useBreakpoint = (breakpoint) => {
|
|
7
|
+
return (0, _mantine_hooks.useMediaQuery)(`(min-width: ${require_breakpoints_with_px.breakpointsWithPx[breakpoint]})`);
|
|
12
8
|
};
|
|
13
|
-
|
|
9
|
+
//#endregion
|
|
14
10
|
exports.useBreakpoint = useBreakpoint;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
import { breakpointsWithPx } from
|
|
3
|
-
import { useMediaQuery } from
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return matches;
|
|
1
|
+
"use client";
|
|
2
|
+
import { breakpointsWithPx } from "../mantine/breakpoints-with-px.js";
|
|
3
|
+
import { useMediaQuery } from "@mantine/hooks";
|
|
4
|
+
//#region src/hooks/useBreakpoint.ts
|
|
5
|
+
var useBreakpoint = (breakpoint) => {
|
|
6
|
+
return useMediaQuery(`(min-width: ${breakpointsWithPx[breakpoint]})`);
|
|
8
7
|
};
|
|
9
|
-
|
|
8
|
+
//#endregion
|
|
10
9
|
export { useBreakpoint };
|
|
@@ -1,23 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
})
|
|
13
|
-
useOnScrollProgress.useOnScrollProgress({
|
|
14
|
-
triggerPercentage: 0.9,
|
|
15
|
-
callback: () => {
|
|
16
|
-
if (infinity.hasNextPage) infinity.fetchNextPage();
|
|
17
|
-
},
|
|
18
|
-
scrollRef,
|
|
19
|
-
disabled
|
|
20
|
-
});
|
|
1
|
+
"use client";
|
|
2
|
+
const require_useOnScrollProgress = require("./useOnScrollProgress.cjs");
|
|
3
|
+
//#region src/hooks/useFetchNextPageOnScroll.ts
|
|
4
|
+
var useFetchNextPageOnScroll = ({ infinity, scrollRef, disabled = false }) => {
|
|
5
|
+
require_useOnScrollProgress.useOnScrollProgress({
|
|
6
|
+
triggerPercentage: .9,
|
|
7
|
+
callback: () => {
|
|
8
|
+
if (infinity.hasNextPage) infinity.fetchNextPage();
|
|
9
|
+
},
|
|
10
|
+
scrollRef,
|
|
11
|
+
disabled
|
|
12
|
+
});
|
|
21
13
|
};
|
|
22
|
-
|
|
14
|
+
//#endregion
|
|
23
15
|
exports.useFetchNextPageOnScroll = useFetchNextPageOnScroll;
|
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
import { useOnScrollProgress } from
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
},
|
|
14
|
-
scrollRef,
|
|
15
|
-
disabled
|
|
16
|
-
});
|
|
1
|
+
"use client";
|
|
2
|
+
import { useOnScrollProgress } from "./useOnScrollProgress.js";
|
|
3
|
+
//#region src/hooks/useFetchNextPageOnScroll.ts
|
|
4
|
+
var useFetchNextPageOnScroll = ({ infinity, scrollRef, disabled = false }) => {
|
|
5
|
+
useOnScrollProgress({
|
|
6
|
+
triggerPercentage: .9,
|
|
7
|
+
callback: () => {
|
|
8
|
+
if (infinity.hasNextPage) infinity.fetchNextPage();
|
|
9
|
+
},
|
|
10
|
+
scrollRef,
|
|
11
|
+
disabled
|
|
12
|
+
});
|
|
17
13
|
};
|
|
18
|
-
|
|
14
|
+
//#endregion
|
|
19
15
|
export { useFetchNextPageOnScroll };
|
|
@@ -1,39 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
return () => {
|
|
34
|
-
scrollTarget.removeEventListener("scroll", handleScroll);
|
|
35
|
-
};
|
|
36
|
-
}, [triggerPercentage, callback, scrollRef, disabled]);
|
|
1
|
+
"use client";
|
|
2
|
+
require("../_virtual/_rolldown/runtime.cjs");
|
|
3
|
+
let react = require("react");
|
|
4
|
+
//#region src/hooks/useOnScrollProgress.ts
|
|
5
|
+
var useOnScrollProgress = ({ triggerPercentage, callback, scrollRef, disabled = false }) => {
|
|
6
|
+
if (triggerPercentage < 0 || triggerPercentage > 1) throw new Error("El porcentaje debe estar entre 0 y 1");
|
|
7
|
+
(0, react.useEffect)(() => {
|
|
8
|
+
if (disabled || scrollRef && scrollRef.current === null) return;
|
|
9
|
+
let hasTriggered = false;
|
|
10
|
+
const handleScroll = () => {
|
|
11
|
+
const el = scrollRef?.current;
|
|
12
|
+
const target = el ?? document.documentElement;
|
|
13
|
+
const scrollHeight = target.scrollHeight - target.clientHeight;
|
|
14
|
+
const scrollTop = el ? target.scrollTop : window.scrollY;
|
|
15
|
+
const scrollProgress = scrollHeight > 0 ? Math.min(1, scrollTop / scrollHeight) : 0;
|
|
16
|
+
if (!hasTriggered && scrollProgress >= triggerPercentage) {
|
|
17
|
+
callback();
|
|
18
|
+
hasTriggered = true;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const scrollTarget = scrollRef?.current ?? window;
|
|
22
|
+
scrollTarget.addEventListener("scroll", handleScroll);
|
|
23
|
+
handleScroll();
|
|
24
|
+
return () => {
|
|
25
|
+
scrollTarget.removeEventListener("scroll", handleScroll);
|
|
26
|
+
};
|
|
27
|
+
}, [
|
|
28
|
+
triggerPercentage,
|
|
29
|
+
callback,
|
|
30
|
+
scrollRef,
|
|
31
|
+
disabled
|
|
32
|
+
]);
|
|
37
33
|
};
|
|
38
|
-
|
|
34
|
+
//#endregion
|
|
39
35
|
exports.useOnScrollProgress = useOnScrollProgress;
|
|
@@ -1,35 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
import { useEffect } from
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}, [triggerPercentage, callback, scrollRef, disabled]);
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
//#region src/hooks/useOnScrollProgress.ts
|
|
4
|
+
var useOnScrollProgress = ({ triggerPercentage, callback, scrollRef, disabled = false }) => {
|
|
5
|
+
if (triggerPercentage < 0 || triggerPercentage > 1) throw new Error("El porcentaje debe estar entre 0 y 1");
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
if (disabled || scrollRef && scrollRef.current === null) return;
|
|
8
|
+
let hasTriggered = false;
|
|
9
|
+
const handleScroll = () => {
|
|
10
|
+
const el = scrollRef?.current;
|
|
11
|
+
const target = el ?? document.documentElement;
|
|
12
|
+
const scrollHeight = target.scrollHeight - target.clientHeight;
|
|
13
|
+
const scrollTop = el ? target.scrollTop : window.scrollY;
|
|
14
|
+
const scrollProgress = scrollHeight > 0 ? Math.min(1, scrollTop / scrollHeight) : 0;
|
|
15
|
+
if (!hasTriggered && scrollProgress >= triggerPercentage) {
|
|
16
|
+
callback();
|
|
17
|
+
hasTriggered = true;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const scrollTarget = scrollRef?.current ?? window;
|
|
21
|
+
scrollTarget.addEventListener("scroll", handleScroll);
|
|
22
|
+
handleScroll();
|
|
23
|
+
return () => {
|
|
24
|
+
scrollTarget.removeEventListener("scroll", handleScroll);
|
|
25
|
+
};
|
|
26
|
+
}, [
|
|
27
|
+
triggerPercentage,
|
|
28
|
+
callback,
|
|
29
|
+
scrollRef,
|
|
30
|
+
disabled
|
|
31
|
+
]);
|
|
33
32
|
};
|
|
34
|
-
|
|
33
|
+
//#endregion
|
|
35
34
|
export { useOnScrollProgress };
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
require("../_virtual/_rolldown/runtime.cjs");
|
|
3
|
+
let next_navigation = require("next/navigation");
|
|
4
|
+
//#region src/hooks/useUpdateSearchParams.ts
|
|
5
|
+
var useUpdateSearchParams = () => {
|
|
6
|
+
const searchParams = (0, next_navigation.useSearchParams)();
|
|
7
|
+
const updateSearchParams = (newSearchparams) => {
|
|
8
|
+
const params = new URLSearchParams(searchParams.toString());
|
|
9
|
+
Object.entries(newSearchparams).forEach(([key, value]) => {
|
|
10
|
+
if (value === null) {
|
|
11
|
+
params.delete(key);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
params.set(key, String(value));
|
|
15
|
+
});
|
|
16
|
+
window?.history?.pushState(null, "", `?${params.toString()}`);
|
|
17
|
+
};
|
|
18
|
+
return {
|
|
19
|
+
updateSearchParams,
|
|
20
|
+
searchParams
|
|
21
|
+
};
|
|
22
22
|
};
|
|
23
|
-
|
|
23
|
+
//#endregion
|
|
24
24
|
exports.useUpdateSearchParams = useUpdateSearchParams;
|
|
@@ -1,20 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
import { useSearchParams } from
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import { useSearchParams } from "next/navigation";
|
|
3
|
+
//#region src/hooks/useUpdateSearchParams.ts
|
|
4
|
+
var useUpdateSearchParams = () => {
|
|
5
|
+
const searchParams = useSearchParams();
|
|
6
|
+
const updateSearchParams = (newSearchparams) => {
|
|
7
|
+
const params = new URLSearchParams(searchParams.toString());
|
|
8
|
+
Object.entries(newSearchparams).forEach(([key, value]) => {
|
|
9
|
+
if (value === null) {
|
|
10
|
+
params.delete(key);
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
params.set(key, String(value));
|
|
14
|
+
});
|
|
15
|
+
window?.history?.pushState(null, "", `?${params.toString()}`);
|
|
16
|
+
};
|
|
17
|
+
return {
|
|
18
|
+
updateSearchParams,
|
|
19
|
+
searchParams
|
|
20
|
+
};
|
|
18
21
|
};
|
|
19
|
-
|
|
22
|
+
//#endregion
|
|
20
23
|
export { useUpdateSearchParams };
|
|
@@ -1,21 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
if (iss.code === "too_big") return `Maximo ${iss.maximum} caracteres`;
|
|
15
|
-
if (iss.code === "invalid_format" && iss.format === "email") return `Email invalido`;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
}, []);
|
|
1
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
let react = require("react");
|
|
3
|
+
let zod = require("zod");
|
|
4
|
+
zod = require_runtime.__toESM(zod, 1);
|
|
5
|
+
//#region src/hooks/useZodConfig.ts
|
|
6
|
+
var useZodConfig = () => {
|
|
7
|
+
(0, react.useEffect)(() => {
|
|
8
|
+
zod.default.config({ customError: (iss) => {
|
|
9
|
+
if (iss.code === "too_small") return iss.minimum === 1 ? `Campo requerido` : `Minimo ${iss.minimum} caracteres`;
|
|
10
|
+
if (iss.code === "too_big") return `Maximo ${iss.maximum} caracteres`;
|
|
11
|
+
if (iss.code === "invalid_format" && iss.format === "email") return `Email invalido`;
|
|
12
|
+
} });
|
|
13
|
+
}, []);
|
|
19
14
|
};
|
|
20
|
-
|
|
15
|
+
//#endregion
|
|
21
16
|
exports.useZodConfig = useZodConfig;
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import { useEffect } from
|
|
2
|
-
import z from
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
}, []);
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
import z$1 from "zod";
|
|
3
|
+
//#region src/hooks/useZodConfig.ts
|
|
4
|
+
var useZodConfig = () => {
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
z$1.config({ customError: (iss) => {
|
|
7
|
+
if (iss.code === "too_small") return iss.minimum === 1 ? `Campo requerido` : `Minimo ${iss.minimum} caracteres`;
|
|
8
|
+
if (iss.code === "too_big") return `Maximo ${iss.maximum} caracteres`;
|
|
9
|
+
if (iss.code === "invalid_format" && iss.format === "email") return `Email invalido`;
|
|
10
|
+
} });
|
|
11
|
+
}, []);
|
|
15
12
|
};
|
|
16
|
-
|
|
13
|
+
//#endregion
|
|
17
14
|
export { useZodConfig };
|