@gustavo-valsechi/client 1.4.106 → 1.4.107
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/types/form/index.js +4 -2
- package/dist/components/types/form/index.mjs +4 -2
- package/dist/components/types/form/types/select/index.js +5 -5
- package/dist/components/types/form/types/select/index.mjs +5 -5
- package/dist/components/types/form/types/select/options/index.d.ts +0 -1
- package/dist/components/types/form/types/select/options/index.js +15 -8
- package/dist/components/types/form/types/select/options/index.mjs +15 -8
- package/dist/interfaces/components/form/select/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -60,7 +60,8 @@ function Form(props) {
|
|
|
60
60
|
handleSubmit,
|
|
61
61
|
reset,
|
|
62
62
|
formState: { errors },
|
|
63
|
-
setValue
|
|
63
|
+
setValue,
|
|
64
|
+
watch
|
|
64
65
|
} = (0, import_react_hook_form.useForm)({
|
|
65
66
|
resolver: (0, import_zod2.zodResolver)(schema),
|
|
66
67
|
defaultValues: props.defaultValues,
|
|
@@ -99,7 +100,8 @@ function Form(props) {
|
|
|
99
100
|
type: component2 ? void 0 : data.type,
|
|
100
101
|
error: (_a = errors[data.name]) == null ? void 0 : _a.message,
|
|
101
102
|
register,
|
|
102
|
-
setValue
|
|
103
|
+
setValue,
|
|
104
|
+
watch
|
|
103
105
|
}
|
|
104
106
|
);
|
|
105
107
|
};
|
|
@@ -26,7 +26,8 @@ function Form(props) {
|
|
|
26
26
|
handleSubmit,
|
|
27
27
|
reset,
|
|
28
28
|
formState: { errors },
|
|
29
|
-
setValue
|
|
29
|
+
setValue,
|
|
30
|
+
watch
|
|
30
31
|
} = useForm({
|
|
31
32
|
resolver: zodResolver(schema),
|
|
32
33
|
defaultValues: props.defaultValues,
|
|
@@ -65,7 +66,8 @@ function Form(props) {
|
|
|
65
66
|
type: component2 ? void 0 : data.type,
|
|
66
67
|
error: (_a = errors[data.name]) == null ? void 0 : _a.message,
|
|
67
68
|
register,
|
|
68
|
-
setValue
|
|
69
|
+
setValue,
|
|
70
|
+
watch
|
|
69
71
|
}
|
|
70
72
|
);
|
|
71
73
|
};
|
|
@@ -41,14 +41,15 @@ var import_contexts = require("../../../../../contexts");
|
|
|
41
41
|
var import_lodash = __toESM(require("lodash"));
|
|
42
42
|
var import_options = __toESM(require("./options"));
|
|
43
43
|
function InputSelect(props) {
|
|
44
|
-
var _a;
|
|
44
|
+
var _a, _b;
|
|
45
45
|
const containerRef = (0, import_react.useRef)(null);
|
|
46
46
|
const inputRef = (0, import_react.useRef)(null);
|
|
47
47
|
const target = (0, import_contexts.useTarget)();
|
|
48
48
|
const [focus, setFocus] = (0, import_react.useState)(false);
|
|
49
49
|
const [filter, setFilter] = (0, import_react.useState)("");
|
|
50
50
|
const register = (props.register || ((name) => ({})))(props.name || "");
|
|
51
|
-
const
|
|
51
|
+
const inputValue = (_a = props.watch) == null ? void 0 : _a.call(props, props.name);
|
|
52
|
+
const value = ((_b = import_lodash.default.find(props.options, (option) => Object.keys(option)[0] === inputValue)) == null ? void 0 : _b[inputValue || ""]) || "";
|
|
52
53
|
(0, import_react.useEffect)(() => {
|
|
53
54
|
var _a2;
|
|
54
55
|
if (!(inputRef == null ? void 0 : inputRef.current) || !(containerRef == null ? void 0 : containerRef.current)) return;
|
|
@@ -60,8 +61,7 @@ function InputSelect(props) {
|
|
|
60
61
|
...props,
|
|
61
62
|
inputRef,
|
|
62
63
|
register,
|
|
63
|
-
width: ((_a2 = containerRef == null ? void 0 : containerRef.current) == null ? void 0 : _a2.offsetWidth) || 0
|
|
64
|
-
filter
|
|
64
|
+
width: ((_a2 = containerRef == null ? void 0 : containerRef.current) == null ? void 0 : _a2.offsetWidth) || 0
|
|
65
65
|
}
|
|
66
66
|
)
|
|
67
67
|
});
|
|
@@ -105,7 +105,7 @@ function InputSelect(props) {
|
|
|
105
105
|
onChange,
|
|
106
106
|
onFocus,
|
|
107
107
|
onBlur,
|
|
108
|
-
value: filter,
|
|
108
|
+
value: focus ? filter : "",
|
|
109
109
|
placeholder: import_lodash.default.isString(value) ? value : (value == null ? void 0 : value.textContent) || ""
|
|
110
110
|
}
|
|
111
111
|
),
|
|
@@ -8,14 +8,15 @@ import { useTarget } from "../../../../../contexts";
|
|
|
8
8
|
import _ from "lodash";
|
|
9
9
|
import InputSelectOption from "./options";
|
|
10
10
|
function InputSelect(props) {
|
|
11
|
-
var _a;
|
|
11
|
+
var _a, _b;
|
|
12
12
|
const containerRef = useRef(null);
|
|
13
13
|
const inputRef = useRef(null);
|
|
14
14
|
const target = useTarget();
|
|
15
15
|
const [focus, setFocus] = useState(false);
|
|
16
16
|
const [filter, setFilter] = useState("");
|
|
17
17
|
const register = (props.register || ((name) => ({})))(props.name || "");
|
|
18
|
-
const
|
|
18
|
+
const inputValue = (_a = props.watch) == null ? void 0 : _a.call(props, props.name);
|
|
19
|
+
const value = ((_b = _.find(props.options, (option) => Object.keys(option)[0] === inputValue)) == null ? void 0 : _b[inputValue || ""]) || "";
|
|
19
20
|
useEffect(() => {
|
|
20
21
|
var _a2;
|
|
21
22
|
if (!(inputRef == null ? void 0 : inputRef.current) || !(containerRef == null ? void 0 : containerRef.current)) return;
|
|
@@ -27,8 +28,7 @@ function InputSelect(props) {
|
|
|
27
28
|
...props,
|
|
28
29
|
inputRef,
|
|
29
30
|
register,
|
|
30
|
-
width: ((_a2 = containerRef == null ? void 0 : containerRef.current) == null ? void 0 : _a2.offsetWidth) || 0
|
|
31
|
-
filter
|
|
31
|
+
width: ((_a2 = containerRef == null ? void 0 : containerRef.current) == null ? void 0 : _a2.offsetWidth) || 0
|
|
32
32
|
}
|
|
33
33
|
)
|
|
34
34
|
});
|
|
@@ -72,7 +72,7 @@ function InputSelect(props) {
|
|
|
72
72
|
onChange,
|
|
73
73
|
onFocus,
|
|
74
74
|
onBlur,
|
|
75
|
-
value: filter,
|
|
75
|
+
value: focus ? filter : "",
|
|
76
76
|
placeholder: _.isString(value) ? value : (value == null ? void 0 : value.textContent) || ""
|
|
77
77
|
}
|
|
78
78
|
),
|
|
@@ -41,20 +41,27 @@ function InputSelectOption(props) {
|
|
|
41
41
|
const [options, setOptions] = (0, import_react.useState)(props.options);
|
|
42
42
|
(0, import_react.useEffect)(() => {
|
|
43
43
|
var _a, _b;
|
|
44
|
+
console.log("value", value);
|
|
44
45
|
(_a = props.setValue) == null ? void 0 : _a.call(props, value);
|
|
45
46
|
if (!value || !((_b = props.inputRef) == null ? void 0 : _b.current)) return;
|
|
46
47
|
props.inputRef.current.click();
|
|
47
48
|
}, [value, props.inputRef]);
|
|
48
49
|
(0, import_react.useEffect)(() => {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
var _a;
|
|
51
|
+
if (!((_a = props.inputRef) == null ? void 0 : _a.current)) return;
|
|
52
|
+
props.inputRef.current.addEventListener("change", (e) => {
|
|
53
|
+
e.preventDefault();
|
|
54
|
+
const filter = e.target.value || "";
|
|
55
|
+
if (!filter) return setOptions(props.options);
|
|
56
|
+
const filtredOptions = import_lodash.default.filter(props.options, (data) => {
|
|
57
|
+
var _a2;
|
|
58
|
+
const value2 = ((_a2 = Object.values(data || {})) == null ? void 0 : _a2[0]) || "";
|
|
59
|
+
if (import_lodash.default.isString(value2)) return import_lodash.default.includes(value2, filter);
|
|
60
|
+
return import_lodash.default.includes(value2 == null ? void 0 : value2.textContent, filter);
|
|
61
|
+
});
|
|
62
|
+
setOptions(filtredOptions);
|
|
55
63
|
});
|
|
56
|
-
|
|
57
|
-
}, [props.filter]);
|
|
64
|
+
}, [props.inputRef]);
|
|
58
65
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.Container, { width: props.width, children: import_lodash.default.map(
|
|
59
66
|
options,
|
|
60
67
|
(data, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -8,20 +8,27 @@ function InputSelectOption(props) {
|
|
|
8
8
|
const [options, setOptions] = useState(props.options);
|
|
9
9
|
useEffect(() => {
|
|
10
10
|
var _a, _b;
|
|
11
|
+
console.log("value", value);
|
|
11
12
|
(_a = props.setValue) == null ? void 0 : _a.call(props, value);
|
|
12
13
|
if (!value || !((_b = props.inputRef) == null ? void 0 : _b.current)) return;
|
|
13
14
|
props.inputRef.current.click();
|
|
14
15
|
}, [value, props.inputRef]);
|
|
15
16
|
useEffect(() => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
var _a;
|
|
18
|
+
if (!((_a = props.inputRef) == null ? void 0 : _a.current)) return;
|
|
19
|
+
props.inputRef.current.addEventListener("change", (e) => {
|
|
20
|
+
e.preventDefault();
|
|
21
|
+
const filter = e.target.value || "";
|
|
22
|
+
if (!filter) return setOptions(props.options);
|
|
23
|
+
const filtredOptions = _.filter(props.options, (data) => {
|
|
24
|
+
var _a2;
|
|
25
|
+
const value2 = ((_a2 = Object.values(data || {})) == null ? void 0 : _a2[0]) || "";
|
|
26
|
+
if (_.isString(value2)) return _.includes(value2, filter);
|
|
27
|
+
return _.includes(value2 == null ? void 0 : value2.textContent, filter);
|
|
28
|
+
});
|
|
29
|
+
setOptions(filtredOptions);
|
|
22
30
|
});
|
|
23
|
-
|
|
24
|
-
}, [props.filter]);
|
|
31
|
+
}, [props.inputRef]);
|
|
25
32
|
return /* @__PURE__ */ jsx(Container, { width: props.width, children: _.map(
|
|
26
33
|
options,
|
|
27
34
|
(data, index) => /* @__PURE__ */ jsx(
|