lkd-web-kit 0.4.0 → 0.4.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/components/InfinityLoader/index.cjs +3 -3
- package/dist/components/SelectInfinity/index.cjs +118 -74
- package/dist/components/SelectInfinity/index.js +119 -75
- package/dist/contexts/NavigationHistoryContext/index.cjs +5 -5
- package/dist/contexts/PageDataContext/index.cjs +3 -3
- package/dist/dist/components/InfinityLoader/index.cjs +46 -0
- package/dist/dist/components/InfinityLoader/index.js +42 -0
- package/dist/dist/form/utils/zodValidator.cjs +15 -0
- package/dist/dist/form/utils/zodValidator.js +11 -0
- package/dist/dist/hocs/withForm.cjs +51 -0
- package/dist/dist/hocs/withForm.js +47 -0
- package/dist/form/FormButtonSubmit.cjs +3 -2
- package/dist/form/FormButtonSubmit.js +3 -2
- package/dist/form/base/FormSelectInfinity.cjs +15 -9
- package/dist/form/base/FormSelectInfinity.js +16 -10
- package/dist/hocs/withModalManager.cjs +3 -3
- package/dist/hooks/useOnScrollProgress.cjs +2 -2
- package/dist/index.cjs +5 -2
- package/dist/index.d.ts +48 -25
- package/dist/index.js +3 -2
- package/dist/node_modules/@tanstack/react-virtual/dist/esm/index.cjs +71 -0
- package/dist/node_modules/@tanstack/react-virtual/dist/esm/index.js +42 -0
- package/dist/node_modules/@tanstack/virtual-core/dist/esm/index.cjs +744 -0
- package/dist/node_modules/@tanstack/virtual-core/dist/esm/index.js +730 -0
- package/dist/node_modules/@tanstack/virtual-core/dist/esm/utils.cjs +71 -0
- package/dist/node_modules/@tanstack/virtual-core/dist/esm/utils.js +64 -0
- package/dist/utils/virtual-styles.cjs +30 -0
- package/dist/utils/virtual-styles.js +25 -0
- package/package.json +4 -1
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
5
5
|
const jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
const core = require('@mantine/core');
|
|
7
7
|
const hooks = require('@mantine/hooks');
|
|
8
|
-
const
|
|
8
|
+
const React = require('react');
|
|
9
9
|
|
|
10
10
|
const InfinityLoader = ({
|
|
11
11
|
root,
|
|
@@ -19,10 +19,10 @@ const InfinityLoader = ({
|
|
|
19
19
|
root: root?.current,
|
|
20
20
|
rootMargin
|
|
21
21
|
});
|
|
22
|
-
|
|
22
|
+
React.useEffect(() => {
|
|
23
23
|
if (entry?.isIntersecting && infinity.hasNextPage) infinity.fetchNextPage();
|
|
24
24
|
}, [entry?.isIntersecting]);
|
|
25
|
-
|
|
25
|
+
React.useEffect(() => {
|
|
26
26
|
if (!entry?.isIntersecting) return;
|
|
27
27
|
const el = root?.current ?? document.documentElement;
|
|
28
28
|
const hasScroll = el?.scrollHeight > el?.clientHeight;
|
|
@@ -4,45 +4,74 @@
|
|
|
4
4
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
5
5
|
|
|
6
6
|
const jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
const React = require('react');
|
|
7
8
|
const core = require('@mantine/core');
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
9
|
+
const hooks = require('@mantine/hooks');
|
|
10
|
+
const index = require('../../node_modules/@tanstack/react-virtual/dist/esm/index.cjs');
|
|
11
|
+
const virtualStyles = require('../../utils/virtual-styles.cjs');
|
|
12
|
+
const index$1 = require('../../dist/components/InfinityLoader/index.cjs');
|
|
11
13
|
|
|
12
|
-
function
|
|
14
|
+
function InfinitySelect({
|
|
13
15
|
value,
|
|
14
|
-
onChange,
|
|
15
|
-
data = [],
|
|
16
16
|
searchValue,
|
|
17
|
+
defaultSearchValue,
|
|
18
|
+
nothingFoundMessage,
|
|
19
|
+
infinity,
|
|
20
|
+
defaultValue,
|
|
21
|
+
onChange,
|
|
17
22
|
onSearchChange,
|
|
18
23
|
renderOption,
|
|
19
24
|
onOptionSubmit,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
25
|
+
getOptionLabel,
|
|
26
|
+
getOptionValue,
|
|
27
|
+
onSelectedOptionChange,
|
|
28
|
+
selectedOption,
|
|
29
|
+
comboboxProps,
|
|
23
30
|
...props
|
|
24
31
|
}) {
|
|
25
|
-
const combobox = core.useCombobox(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
const combobox = core.useCombobox();
|
|
33
|
+
const [_selectedOption, handleSelectedOption] = hooks.useUncontrolled({
|
|
34
|
+
defaultValue: null,
|
|
35
|
+
value: selectedOption,
|
|
36
|
+
onChange: onSelectedOptionChange
|
|
37
|
+
});
|
|
38
|
+
const [_value, handleValue] = hooks.useUncontrolled({
|
|
39
|
+
defaultValue,
|
|
40
|
+
value,
|
|
41
|
+
onChange
|
|
42
|
+
});
|
|
43
|
+
const [_search, handleSearch] = hooks.useUncontrolled({
|
|
44
|
+
defaultValue: defaultSearchValue,
|
|
45
|
+
value: searchValue,
|
|
46
|
+
onChange: onSearchChange
|
|
47
|
+
});
|
|
48
|
+
const [searchHasChanged, setSearchHasChanged] = React.useState(false);
|
|
49
|
+
const data = infinity.data?.pages.flatMap((page) => page.data) ?? [];
|
|
50
|
+
const _reset = () => {
|
|
51
|
+
handleSearch("");
|
|
52
|
+
handleValue(null);
|
|
53
|
+
handleSelectedOption(null);
|
|
54
|
+
};
|
|
55
|
+
const setSearchAndValue = (option) => {
|
|
56
|
+
if (option === null) _reset();
|
|
57
|
+
else {
|
|
58
|
+
handleSearch(getOptionLabel(option));
|
|
59
|
+
handleValue(getOptionValue(option));
|
|
33
60
|
}
|
|
61
|
+
};
|
|
62
|
+
React.useEffect(() => {
|
|
63
|
+
setSearchAndValue(_selectedOption);
|
|
64
|
+
}, [_selectedOption]);
|
|
65
|
+
const virtualizer = index.useVirtualizer({
|
|
66
|
+
count: data.length,
|
|
67
|
+
estimateSize: () => 40,
|
|
68
|
+
overscan: 7,
|
|
69
|
+
getScrollElement: () => scrollRef.current
|
|
34
70
|
});
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
children: renderOption ? renderOption({ option: i }) : i.label
|
|
40
|
-
},
|
|
41
|
-
i.value
|
|
42
|
-
));
|
|
43
|
-
const selectedOption = data.find((i) => i.value === value);
|
|
44
|
-
const scrollRef = react.useRef(null);
|
|
45
|
-
useFetchNextPageOnScroll.useFetchNextPageOnScroll({ infinity, scrollRef });
|
|
71
|
+
const openDropdown = () => {
|
|
72
|
+
if (searchHasChanged || _search === "" || !_value) combobox.openDropdown();
|
|
73
|
+
};
|
|
74
|
+
const scrollRef = React.useRef(null);
|
|
46
75
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
47
76
|
core.Combobox,
|
|
48
77
|
{
|
|
@@ -53,66 +82,81 @@ function SelectInfinity({
|
|
|
53
82
|
}
|
|
54
83
|
},
|
|
55
84
|
onOptionSubmit: (val) => {
|
|
56
|
-
|
|
57
|
-
|
|
85
|
+
const selectedOption2 = data.find((i) => getOptionValue(i) === val);
|
|
86
|
+
if (selectedOption2) {
|
|
87
|
+
setSearchAndValue(selectedOption2);
|
|
88
|
+
handleSelectedOption(selectedOption2);
|
|
89
|
+
onOptionSubmit?.(val, selectedOption2);
|
|
90
|
+
}
|
|
58
91
|
combobox.closeDropdown();
|
|
59
92
|
},
|
|
93
|
+
...comboboxProps,
|
|
60
94
|
children: [
|
|
61
95
|
/* @__PURE__ */ jsxRuntime.jsx(core.Combobox.Target, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
62
96
|
core.InputBase,
|
|
63
97
|
{
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
98
|
+
rightSection: props.readOnly ? null : value ? /* @__PURE__ */ jsxRuntime.jsx(core.Input.ClearButton, { onClick: _reset }) : /* @__PURE__ */ jsxRuntime.jsx(core.Combobox.Chevron, {}),
|
|
99
|
+
rightSectionPointerEvents: value ? void 0 : "none",
|
|
100
|
+
onClick: openDropdown,
|
|
101
|
+
onFocus: openDropdown,
|
|
102
|
+
value: _search,
|
|
103
|
+
onChange: (event) => {
|
|
104
|
+
if (event.currentTarget.value) combobox.openDropdown();
|
|
105
|
+
else combobox.closeDropdown();
|
|
106
|
+
setSearchHasChanged(true);
|
|
107
|
+
handleSearch(event.currentTarget.value);
|
|
108
|
+
},
|
|
70
109
|
...props,
|
|
71
|
-
|
|
110
|
+
variant: props.readOnly ? "filled" : "default",
|
|
111
|
+
onBlur: (e) => {
|
|
112
|
+
if (_selectedOption) setSearchAndValue(_selectedOption);
|
|
113
|
+
combobox.closeDropdown();
|
|
114
|
+
props.onBlur?.(e);
|
|
115
|
+
setSearchHasChanged(false);
|
|
116
|
+
}
|
|
72
117
|
}
|
|
73
118
|
) }),
|
|
74
|
-
/* @__PURE__ */ jsxRuntime.
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
mah: 200,
|
|
87
|
-
type: "scroll",
|
|
88
|
-
viewportRef: scrollRef,
|
|
89
|
-
children: [
|
|
90
|
-
options.length > 0 ? options : !infinity.isFetching ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
91
|
-
core.Combobox.Empty,
|
|
92
|
-
{
|
|
93
|
-
onClick: () => combobox.closeDropdown(),
|
|
94
|
-
className: "min-h-6",
|
|
95
|
-
children: nothingFoundMessage ?? "Sin resultados"
|
|
96
|
-
}
|
|
97
|
-
) : null,
|
|
98
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
99
|
-
index.InfinityLoader,
|
|
119
|
+
/* @__PURE__ */ jsxRuntime.jsx(core.Combobox.Dropdown, { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
120
|
+
core.Combobox.Options,
|
|
121
|
+
{
|
|
122
|
+
mah: 200,
|
|
123
|
+
className: "overflow-y-auto",
|
|
124
|
+
ref: scrollRef,
|
|
125
|
+
children: [
|
|
126
|
+
data.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { ...virtualStyles.getVirtualContainerProps(virtualizer), children: virtualizer.getVirtualItems().map((virtualItem) => {
|
|
127
|
+
const option = data[virtualItem.index];
|
|
128
|
+
const virtualItemProps = virtualStyles.getVirtualItemProps(virtualItem, virtualizer);
|
|
129
|
+
return /* @__PURE__ */ React.createElement(
|
|
130
|
+
core.Combobox.Option,
|
|
100
131
|
{
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
132
|
+
value: getOptionValue(option),
|
|
133
|
+
...virtualItemProps,
|
|
134
|
+
key: virtualItemProps.key,
|
|
135
|
+
style: {
|
|
136
|
+
...virtualItemProps.style,
|
|
137
|
+
fontWeight: 400
|
|
106
138
|
}
|
|
139
|
+
},
|
|
140
|
+
renderOption ? renderOption({ option }) : getOptionLabel(option)
|
|
141
|
+
);
|
|
142
|
+
}) }) : !infinity.isFetching ? /* @__PURE__ */ jsxRuntime.jsx(core.Combobox.Empty, { className: "min-h-6", children: nothingFoundMessage ? typeof nothingFoundMessage === "function" ? nothingFoundMessage({ combobox }) : nothingFoundMessage : "No hay resultados" }) : null,
|
|
143
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
144
|
+
index$1.InfinityLoader,
|
|
145
|
+
{
|
|
146
|
+
root: scrollRef,
|
|
147
|
+
infinity,
|
|
148
|
+
loaderProps: {
|
|
149
|
+
size: "sm",
|
|
150
|
+
className: "mt-1 mb-2"
|
|
107
151
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
152
|
+
}
|
|
153
|
+
)
|
|
154
|
+
]
|
|
155
|
+
}
|
|
156
|
+
) })
|
|
113
157
|
]
|
|
114
158
|
}
|
|
115
159
|
);
|
|
116
160
|
}
|
|
117
161
|
|
|
118
|
-
exports.
|
|
162
|
+
exports.InfinitySelect = InfinitySelect;
|
|
@@ -1,44 +1,73 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useState, useEffect, useRef, createElement } from 'react';
|
|
4
|
+
import { useCombobox, Combobox, InputBase, Input } from '@mantine/core';
|
|
5
|
+
import { useUncontrolled } from '@mantine/hooks';
|
|
6
|
+
import { useVirtualizer } from '../../node_modules/@tanstack/react-virtual/dist/esm/index.js';
|
|
7
|
+
import { getVirtualContainerProps, getVirtualItemProps } from '../../utils/virtual-styles.js';
|
|
8
|
+
import { InfinityLoader } from '../../dist/components/InfinityLoader/index.js';
|
|
7
9
|
|
|
8
|
-
function
|
|
10
|
+
function InfinitySelect({
|
|
9
11
|
value,
|
|
10
|
-
onChange,
|
|
11
|
-
data = [],
|
|
12
12
|
searchValue,
|
|
13
|
+
defaultSearchValue,
|
|
14
|
+
nothingFoundMessage,
|
|
15
|
+
infinity,
|
|
16
|
+
defaultValue,
|
|
17
|
+
onChange,
|
|
13
18
|
onSearchChange,
|
|
14
19
|
renderOption,
|
|
15
20
|
onOptionSubmit,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
21
|
+
getOptionLabel,
|
|
22
|
+
getOptionValue,
|
|
23
|
+
onSelectedOptionChange,
|
|
24
|
+
selectedOption,
|
|
25
|
+
comboboxProps,
|
|
19
26
|
...props
|
|
20
27
|
}) {
|
|
21
|
-
const combobox = useCombobox(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
const combobox = useCombobox();
|
|
29
|
+
const [_selectedOption, handleSelectedOption] = useUncontrolled({
|
|
30
|
+
defaultValue: null,
|
|
31
|
+
value: selectedOption,
|
|
32
|
+
onChange: onSelectedOptionChange
|
|
33
|
+
});
|
|
34
|
+
const [_value, handleValue] = useUncontrolled({
|
|
35
|
+
defaultValue,
|
|
36
|
+
value,
|
|
37
|
+
onChange
|
|
38
|
+
});
|
|
39
|
+
const [_search, handleSearch] = useUncontrolled({
|
|
40
|
+
defaultValue: defaultSearchValue,
|
|
41
|
+
value: searchValue,
|
|
42
|
+
onChange: onSearchChange
|
|
43
|
+
});
|
|
44
|
+
const [searchHasChanged, setSearchHasChanged] = useState(false);
|
|
45
|
+
const data = infinity.data?.pages.flatMap((page) => page.data) ?? [];
|
|
46
|
+
const _reset = () => {
|
|
47
|
+
handleSearch("");
|
|
48
|
+
handleValue(null);
|
|
49
|
+
handleSelectedOption(null);
|
|
50
|
+
};
|
|
51
|
+
const setSearchAndValue = (option) => {
|
|
52
|
+
if (option === null) _reset();
|
|
53
|
+
else {
|
|
54
|
+
handleSearch(getOptionLabel(option));
|
|
55
|
+
handleValue(getOptionValue(option));
|
|
29
56
|
}
|
|
57
|
+
};
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
setSearchAndValue(_selectedOption);
|
|
60
|
+
}, [_selectedOption]);
|
|
61
|
+
const virtualizer = useVirtualizer({
|
|
62
|
+
count: data.length,
|
|
63
|
+
estimateSize: () => 40,
|
|
64
|
+
overscan: 7,
|
|
65
|
+
getScrollElement: () => scrollRef.current
|
|
30
66
|
});
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
value: i.value,
|
|
35
|
-
children: renderOption ? renderOption({ option: i }) : i.label
|
|
36
|
-
},
|
|
37
|
-
i.value
|
|
38
|
-
));
|
|
39
|
-
const selectedOption = data.find((i) => i.value === value);
|
|
67
|
+
const openDropdown = () => {
|
|
68
|
+
if (searchHasChanged || _search === "" || !_value) combobox.openDropdown();
|
|
69
|
+
};
|
|
40
70
|
const scrollRef = useRef(null);
|
|
41
|
-
useFetchNextPageOnScroll({ infinity, scrollRef });
|
|
42
71
|
return /* @__PURE__ */ jsxs(
|
|
43
72
|
Combobox,
|
|
44
73
|
{
|
|
@@ -49,66 +78,81 @@ function SelectInfinity({
|
|
|
49
78
|
}
|
|
50
79
|
},
|
|
51
80
|
onOptionSubmit: (val) => {
|
|
52
|
-
|
|
53
|
-
|
|
81
|
+
const selectedOption2 = data.find((i) => getOptionValue(i) === val);
|
|
82
|
+
if (selectedOption2) {
|
|
83
|
+
setSearchAndValue(selectedOption2);
|
|
84
|
+
handleSelectedOption(selectedOption2);
|
|
85
|
+
onOptionSubmit?.(val, selectedOption2);
|
|
86
|
+
}
|
|
54
87
|
combobox.closeDropdown();
|
|
55
88
|
},
|
|
89
|
+
...comboboxProps,
|
|
56
90
|
children: [
|
|
57
91
|
/* @__PURE__ */ jsx(Combobox.Target, { children: /* @__PURE__ */ jsx(
|
|
58
92
|
InputBase,
|
|
59
93
|
{
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
94
|
+
rightSection: props.readOnly ? null : value ? /* @__PURE__ */ jsx(Input.ClearButton, { onClick: _reset }) : /* @__PURE__ */ jsx(Combobox.Chevron, {}),
|
|
95
|
+
rightSectionPointerEvents: value ? void 0 : "none",
|
|
96
|
+
onClick: openDropdown,
|
|
97
|
+
onFocus: openDropdown,
|
|
98
|
+
value: _search,
|
|
99
|
+
onChange: (event) => {
|
|
100
|
+
if (event.currentTarget.value) combobox.openDropdown();
|
|
101
|
+
else combobox.closeDropdown();
|
|
102
|
+
setSearchHasChanged(true);
|
|
103
|
+
handleSearch(event.currentTarget.value);
|
|
104
|
+
},
|
|
66
105
|
...props,
|
|
67
|
-
|
|
106
|
+
variant: props.readOnly ? "filled" : "default",
|
|
107
|
+
onBlur: (e) => {
|
|
108
|
+
if (_selectedOption) setSearchAndValue(_selectedOption);
|
|
109
|
+
combobox.closeDropdown();
|
|
110
|
+
props.onBlur?.(e);
|
|
111
|
+
setSearchHasChanged(false);
|
|
112
|
+
}
|
|
68
113
|
}
|
|
69
114
|
) }),
|
|
70
|
-
/* @__PURE__ */
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
mah: 200,
|
|
83
|
-
type: "scroll",
|
|
84
|
-
viewportRef: scrollRef,
|
|
85
|
-
children: [
|
|
86
|
-
options.length > 0 ? options : !infinity.isFetching ? /* @__PURE__ */ jsx(
|
|
87
|
-
Combobox.Empty,
|
|
88
|
-
{
|
|
89
|
-
onClick: () => combobox.closeDropdown(),
|
|
90
|
-
className: "min-h-6",
|
|
91
|
-
children: nothingFoundMessage ?? "Sin resultados"
|
|
92
|
-
}
|
|
93
|
-
) : null,
|
|
94
|
-
/* @__PURE__ */ jsx(
|
|
95
|
-
InfinityLoader,
|
|
115
|
+
/* @__PURE__ */ jsx(Combobox.Dropdown, { children: /* @__PURE__ */ jsxs(
|
|
116
|
+
Combobox.Options,
|
|
117
|
+
{
|
|
118
|
+
mah: 200,
|
|
119
|
+
className: "overflow-y-auto",
|
|
120
|
+
ref: scrollRef,
|
|
121
|
+
children: [
|
|
122
|
+
data.length > 0 ? /* @__PURE__ */ jsx("div", { ...getVirtualContainerProps(virtualizer), children: virtualizer.getVirtualItems().map((virtualItem) => {
|
|
123
|
+
const option = data[virtualItem.index];
|
|
124
|
+
const virtualItemProps = getVirtualItemProps(virtualItem, virtualizer);
|
|
125
|
+
return /* @__PURE__ */ createElement(
|
|
126
|
+
Combobox.Option,
|
|
96
127
|
{
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
128
|
+
value: getOptionValue(option),
|
|
129
|
+
...virtualItemProps,
|
|
130
|
+
key: virtualItemProps.key,
|
|
131
|
+
style: {
|
|
132
|
+
...virtualItemProps.style,
|
|
133
|
+
fontWeight: 400
|
|
102
134
|
}
|
|
135
|
+
},
|
|
136
|
+
renderOption ? renderOption({ option }) : getOptionLabel(option)
|
|
137
|
+
);
|
|
138
|
+
}) }) : !infinity.isFetching ? /* @__PURE__ */ jsx(Combobox.Empty, { className: "min-h-6", children: nothingFoundMessage ? typeof nothingFoundMessage === "function" ? nothingFoundMessage({ combobox }) : nothingFoundMessage : "No hay resultados" }) : null,
|
|
139
|
+
/* @__PURE__ */ jsx(
|
|
140
|
+
InfinityLoader,
|
|
141
|
+
{
|
|
142
|
+
root: scrollRef,
|
|
143
|
+
infinity,
|
|
144
|
+
loaderProps: {
|
|
145
|
+
size: "sm",
|
|
146
|
+
className: "mt-1 mb-2"
|
|
103
147
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
148
|
+
}
|
|
149
|
+
)
|
|
150
|
+
]
|
|
151
|
+
}
|
|
152
|
+
) })
|
|
109
153
|
]
|
|
110
154
|
}
|
|
111
155
|
);
|
|
112
156
|
}
|
|
113
157
|
|
|
114
|
-
export {
|
|
158
|
+
export { InfinitySelect };
|
|
@@ -5,14 +5,14 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
5
5
|
|
|
6
6
|
const jsxRuntime = require('react/jsx-runtime');
|
|
7
7
|
const navigation = require('next/navigation');
|
|
8
|
-
const
|
|
8
|
+
const React = require('react');
|
|
9
9
|
|
|
10
|
-
const NavigationHistoryContext =
|
|
10
|
+
const NavigationHistoryContext = React.createContext(null);
|
|
11
11
|
function NavigationHistoryProvider({ children }) {
|
|
12
12
|
const pathname = navigation.usePathname();
|
|
13
13
|
const searchParams = navigation.useSearchParams();
|
|
14
|
-
const [history, setHistory] =
|
|
15
|
-
|
|
14
|
+
const [history, setHistory] = React.useState([]);
|
|
15
|
+
React.useEffect(() => {
|
|
16
16
|
const fullPath = searchParams?.size ? `${pathname}?${searchParams.toString()}` : pathname;
|
|
17
17
|
if (fullPath) {
|
|
18
18
|
setHistory((prev) => {
|
|
@@ -27,7 +27,7 @@ function NavigationHistoryProvider({ children }) {
|
|
|
27
27
|
}
|
|
28
28
|
const QP_BACK_URL_NAME = "backUrl";
|
|
29
29
|
function useNavigationHistory() {
|
|
30
|
-
const context =
|
|
30
|
+
const context = React.useContext(NavigationHistoryContext);
|
|
31
31
|
const router = navigation.useRouter();
|
|
32
32
|
if (!context) {
|
|
33
33
|
throw new Error("useNavigationHistory debe usarse dentro de un NavigationHistoryProvider");
|
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
5
5
|
|
|
6
6
|
const jsxRuntime = require('react/jsx-runtime');
|
|
7
|
-
const
|
|
7
|
+
const React = require('react');
|
|
8
8
|
|
|
9
|
-
const PageData =
|
|
9
|
+
const PageData = React.createContext(void 0);
|
|
10
10
|
const PageDataProvider = ({
|
|
11
11
|
value,
|
|
12
12
|
children
|
|
13
13
|
}) => /* @__PURE__ */ jsxRuntime.jsx(PageData.Provider, { value, children });
|
|
14
14
|
const usePageData = () => {
|
|
15
|
-
const data =
|
|
15
|
+
const data = React.useContext(PageData);
|
|
16
16
|
if (data === void 0) throw new Error("Out of context: usePageData");
|
|
17
17
|
return data;
|
|
18
18
|
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
const core = require('@mantine/core');
|
|
7
|
+
const hooks = require('@mantine/hooks');
|
|
8
|
+
const React = require('react');
|
|
9
|
+
|
|
10
|
+
const InfinityLoader = ({
|
|
11
|
+
root,
|
|
12
|
+
infinity,
|
|
13
|
+
rootMargin = "0px 0px 0px 0px",
|
|
14
|
+
endMessage = "No hay más resultados",
|
|
15
|
+
loaderProps,
|
|
16
|
+
...props
|
|
17
|
+
}) => {
|
|
18
|
+
const { entry, ref } = hooks.useIntersection({
|
|
19
|
+
root: root?.current,
|
|
20
|
+
rootMargin
|
|
21
|
+
});
|
|
22
|
+
React.useEffect(() => {
|
|
23
|
+
if (entry?.isIntersecting && infinity.hasNextPage) infinity.fetchNextPage();
|
|
24
|
+
}, [entry?.isIntersecting]);
|
|
25
|
+
React.useEffect(() => {
|
|
26
|
+
if (!entry?.isIntersecting) return;
|
|
27
|
+
const el = root?.current ?? document.documentElement;
|
|
28
|
+
const hasScroll = el?.scrollHeight > el?.clientHeight;
|
|
29
|
+
if (!hasScroll) infinity.fetchNextPage();
|
|
30
|
+
}, [entry?.isIntersecting, infinity.data?.pages.length]);
|
|
31
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
32
|
+
core.Center,
|
|
33
|
+
{
|
|
34
|
+
ref,
|
|
35
|
+
...props,
|
|
36
|
+
style: {
|
|
37
|
+
minHeight: "1rem",
|
|
38
|
+
fontSize: "14px",
|
|
39
|
+
...props.style
|
|
40
|
+
},
|
|
41
|
+
children: infinity.isLoading || infinity.isFetchingNextPage ? /* @__PURE__ */ jsxRuntime.jsx(core.Loader, { ...loaderProps }) : infinity.data && infinity.data.pages.length > 1 && !infinity.hasNextPage ? endMessage : null
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
exports.InfinityLoader = InfinityLoader;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { Center, Loader } from '@mantine/core';
|
|
3
|
+
import { useIntersection } from '@mantine/hooks';
|
|
4
|
+
import { useEffect } from 'react';
|
|
5
|
+
|
|
6
|
+
const InfinityLoader = ({
|
|
7
|
+
root,
|
|
8
|
+
infinity,
|
|
9
|
+
rootMargin = "0px 0px 0px 0px",
|
|
10
|
+
endMessage = "No hay más resultados",
|
|
11
|
+
loaderProps,
|
|
12
|
+
...props
|
|
13
|
+
}) => {
|
|
14
|
+
const { entry, ref } = useIntersection({
|
|
15
|
+
root: root?.current,
|
|
16
|
+
rootMargin
|
|
17
|
+
});
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
if (entry?.isIntersecting && infinity.hasNextPage) infinity.fetchNextPage();
|
|
20
|
+
}, [entry?.isIntersecting]);
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (!entry?.isIntersecting) return;
|
|
23
|
+
const el = root?.current ?? document.documentElement;
|
|
24
|
+
const hasScroll = el?.scrollHeight > el?.clientHeight;
|
|
25
|
+
if (!hasScroll) infinity.fetchNextPage();
|
|
26
|
+
}, [entry?.isIntersecting, infinity.data?.pages.length]);
|
|
27
|
+
return /* @__PURE__ */ jsx(
|
|
28
|
+
Center,
|
|
29
|
+
{
|
|
30
|
+
ref,
|
|
31
|
+
...props,
|
|
32
|
+
style: {
|
|
33
|
+
minHeight: "1rem",
|
|
34
|
+
fontSize: "14px",
|
|
35
|
+
...props.style
|
|
36
|
+
},
|
|
37
|
+
children: infinity.isLoading || infinity.isFetchingNextPage ? /* @__PURE__ */ jsx(Loader, { ...loaderProps }) : infinity.data && infinity.data.pages.length > 1 && !infinity.hasNextPage ? endMessage : null
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export { InfinityLoader };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const zodValidator = (schema) => {
|
|
6
|
+
return (values) => {
|
|
7
|
+
const result = schema.safeParse(values);
|
|
8
|
+
if (result.success) return;
|
|
9
|
+
const { error } = result;
|
|
10
|
+
const firstError = error.issues[0];
|
|
11
|
+
return firstError?.message;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
exports.zodValidator = zodValidator;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const zodValidator = (schema) => {
|
|
2
|
+
return (values) => {
|
|
3
|
+
const result = schema.safeParse(values);
|
|
4
|
+
if (result.success) return;
|
|
5
|
+
const { error } = result;
|
|
6
|
+
const firstError = error.issues[0];
|
|
7
|
+
return firstError?.message;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { zodValidator };
|