@gustavo-valsechi/client 1.4.106 → 1.4.108
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 +7 -5
- package/dist/components/types/form/types/select/index.mjs +7 -5
- package/dist/components/types/form/types/select/options/index.d.ts +0 -1
- package/dist/components/types/form/types/select/options/index.js +16 -8
- package/dist/components/types/form/types/select/options/index.mjs +16 -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,17 @@ 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
|
+
console.log("inputValue", inputValue);
|
|
53
|
+
const value = ((_b = import_lodash.default.find(props.options, (option) => Object.keys(option)[0] === inputValue)) == null ? void 0 : _b[inputValue || ""]) || "";
|
|
54
|
+
console.log("valueContent", value);
|
|
52
55
|
(0, import_react.useEffect)(() => {
|
|
53
56
|
var _a2;
|
|
54
57
|
if (!(inputRef == null ? void 0 : inputRef.current) || !(containerRef == null ? void 0 : containerRef.current)) return;
|
|
@@ -60,8 +63,7 @@ function InputSelect(props) {
|
|
|
60
63
|
...props,
|
|
61
64
|
inputRef,
|
|
62
65
|
register,
|
|
63
|
-
width: ((_a2 = containerRef == null ? void 0 : containerRef.current) == null ? void 0 : _a2.offsetWidth) || 0
|
|
64
|
-
filter
|
|
66
|
+
width: ((_a2 = containerRef == null ? void 0 : containerRef.current) == null ? void 0 : _a2.offsetWidth) || 0
|
|
65
67
|
}
|
|
66
68
|
)
|
|
67
69
|
});
|
|
@@ -105,7 +107,7 @@ function InputSelect(props) {
|
|
|
105
107
|
onChange,
|
|
106
108
|
onFocus,
|
|
107
109
|
onBlur,
|
|
108
|
-
value: filter,
|
|
110
|
+
value: focus ? filter : "",
|
|
109
111
|
placeholder: import_lodash.default.isString(value) ? value : (value == null ? void 0 : value.textContent) || ""
|
|
110
112
|
}
|
|
111
113
|
),
|
|
@@ -8,14 +8,17 @@ 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
|
+
console.log("inputValue", inputValue);
|
|
20
|
+
const value = ((_b = _.find(props.options, (option) => Object.keys(option)[0] === inputValue)) == null ? void 0 : _b[inputValue || ""]) || "";
|
|
21
|
+
console.log("valueContent", value);
|
|
19
22
|
useEffect(() => {
|
|
20
23
|
var _a2;
|
|
21
24
|
if (!(inputRef == null ? void 0 : inputRef.current) || !(containerRef == null ? void 0 : containerRef.current)) return;
|
|
@@ -27,8 +30,7 @@ function InputSelect(props) {
|
|
|
27
30
|
...props,
|
|
28
31
|
inputRef,
|
|
29
32
|
register,
|
|
30
|
-
width: ((_a2 = containerRef == null ? void 0 : containerRef.current) == null ? void 0 : _a2.offsetWidth) || 0
|
|
31
|
-
filter
|
|
33
|
+
width: ((_a2 = containerRef == null ? void 0 : containerRef.current) == null ? void 0 : _a2.offsetWidth) || 0
|
|
32
34
|
}
|
|
33
35
|
)
|
|
34
36
|
});
|
|
@@ -72,7 +74,7 @@ function InputSelect(props) {
|
|
|
72
74
|
onChange,
|
|
73
75
|
onFocus,
|
|
74
76
|
onBlur,
|
|
75
|
-
value: filter,
|
|
77
|
+
value: focus ? filter : "",
|
|
76
78
|
placeholder: _.isString(value) ? value : (value == null ? void 0 : value.textContent) || ""
|
|
77
79
|
}
|
|
78
80
|
),
|
|
@@ -41,20 +41,28 @@ 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
|
+
console.log("filter", filter);
|
|
56
|
+
if (!filter) return setOptions(props.options);
|
|
57
|
+
const filtredOptions = import_lodash.default.filter(props.options, (data) => {
|
|
58
|
+
var _a2;
|
|
59
|
+
const value2 = ((_a2 = Object.values(data || {})) == null ? void 0 : _a2[0]) || "";
|
|
60
|
+
if (import_lodash.default.isString(value2)) return import_lodash.default.includes(value2, filter);
|
|
61
|
+
return import_lodash.default.includes(value2 == null ? void 0 : value2.textContent, filter);
|
|
62
|
+
});
|
|
63
|
+
setOptions(filtredOptions);
|
|
55
64
|
});
|
|
56
|
-
|
|
57
|
-
}, [props.filter]);
|
|
65
|
+
}, [props.inputRef]);
|
|
58
66
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.Container, { width: props.width, children: import_lodash.default.map(
|
|
59
67
|
options,
|
|
60
68
|
(data, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -8,20 +8,28 @@ 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
|
+
console.log("filter", filter);
|
|
23
|
+
if (!filter) return setOptions(props.options);
|
|
24
|
+
const filtredOptions = _.filter(props.options, (data) => {
|
|
25
|
+
var _a2;
|
|
26
|
+
const value2 = ((_a2 = Object.values(data || {})) == null ? void 0 : _a2[0]) || "";
|
|
27
|
+
if (_.isString(value2)) return _.includes(value2, filter);
|
|
28
|
+
return _.includes(value2 == null ? void 0 : value2.textContent, filter);
|
|
29
|
+
});
|
|
30
|
+
setOptions(filtredOptions);
|
|
22
31
|
});
|
|
23
|
-
|
|
24
|
-
}, [props.filter]);
|
|
32
|
+
}, [props.inputRef]);
|
|
25
33
|
return /* @__PURE__ */ jsx(Container, { width: props.width, children: _.map(
|
|
26
34
|
options,
|
|
27
35
|
(data, index) => /* @__PURE__ */ jsx(
|