@gustavo-valsechi/client 1.4.105 → 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 +35 -25
- package/dist/components/types/form/types/select/index.mjs +35 -25
- package/dist/components/types/form/types/select/options/index.d.ts +0 -1
- package/dist/components/types/form/types/select/options/index.js +18 -7
- package/dist/components/types/form/types/select/options/index.mjs +18 -7
- package/dist/components/types/form/types/select/options/styles.js +2 -12
- package/dist/components/types/form/types/select/options/styles.mjs +2 -12
- package/dist/components/types/form/types/select/styles.js +16 -0
- package/dist/components/types/form/types/select/styles.mjs +16 -0
- 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
|
});
|
|
@@ -77,33 +77,43 @@ function InputSelect(props) {
|
|
|
77
77
|
if (register.onFocus) register.onFocus(event);
|
|
78
78
|
};
|
|
79
79
|
const onChange = (event) => {
|
|
80
|
-
const
|
|
81
|
-
event.target.value = props.mask ? props.mask(
|
|
82
|
-
setFilter(
|
|
83
|
-
if (props.onFilter) props.onFilter(
|
|
80
|
+
const value2 = event.target.value || "";
|
|
81
|
+
event.target.value = props.mask ? props.mask(value2) : value2;
|
|
82
|
+
setFilter(value2);
|
|
83
|
+
if (props.onFilter) props.onFilter(value2);
|
|
84
84
|
};
|
|
85
85
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_styles.Container, { className: props.className, error: props.error, children: [
|
|
86
86
|
!!props.label && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_label.InputLabel, { children: [
|
|
87
87
|
props.label,
|
|
88
88
|
props.required ? "*" : ""
|
|
89
89
|
] }),
|
|
90
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
90
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
91
|
+
"div",
|
|
92
|
+
{
|
|
93
|
+
ref: containerRef,
|
|
94
|
+
className: "input-content",
|
|
95
|
+
onClick: () => inputRef.current.click(),
|
|
96
|
+
children: [
|
|
97
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
98
|
+
"input",
|
|
99
|
+
{
|
|
100
|
+
...import_lodash.default.omit(props, ["className", "register", "mask", "setValue"]),
|
|
101
|
+
...register,
|
|
102
|
+
ref: inputRef,
|
|
103
|
+
type: "text",
|
|
104
|
+
maxLength: props.maxLength || 255,
|
|
105
|
+
onChange,
|
|
106
|
+
onFocus,
|
|
107
|
+
onBlur,
|
|
108
|
+
value: focus ? filter : "",
|
|
109
|
+
placeholder: import_lodash.default.isString(value) ? value : (value == null ? void 0 : value.textContent) || ""
|
|
110
|
+
}
|
|
111
|
+
),
|
|
112
|
+
!focus && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "input-label-value", children: value }),
|
|
113
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "input-icon", children: focus ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("i", { "aria-hidden": true, className: "fa-solid fa-chevron-up" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("i", { "aria-hidden": true, className: "fa-solid fa-chevron-down" }) })
|
|
114
|
+
]
|
|
115
|
+
}
|
|
116
|
+
),
|
|
107
117
|
!!props.error && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_error.InputError, { children: props.error })
|
|
108
118
|
] });
|
|
109
119
|
}
|
|
@@ -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
|
});
|
|
@@ -44,33 +44,43 @@ function InputSelect(props) {
|
|
|
44
44
|
if (register.onFocus) register.onFocus(event);
|
|
45
45
|
};
|
|
46
46
|
const onChange = (event) => {
|
|
47
|
-
const
|
|
48
|
-
event.target.value = props.mask ? props.mask(
|
|
49
|
-
setFilter(
|
|
50
|
-
if (props.onFilter) props.onFilter(
|
|
47
|
+
const value2 = event.target.value || "";
|
|
48
|
+
event.target.value = props.mask ? props.mask(value2) : value2;
|
|
49
|
+
setFilter(value2);
|
|
50
|
+
if (props.onFilter) props.onFilter(value2);
|
|
51
51
|
};
|
|
52
52
|
return /* @__PURE__ */ jsxs(Container, { className: props.className, error: props.error, children: [
|
|
53
53
|
!!props.label && /* @__PURE__ */ jsxs(InputLabel, { children: [
|
|
54
54
|
props.label,
|
|
55
55
|
props.required ? "*" : ""
|
|
56
56
|
] }),
|
|
57
|
-
/* @__PURE__ */ jsxs(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
57
|
+
/* @__PURE__ */ jsxs(
|
|
58
|
+
"div",
|
|
59
|
+
{
|
|
60
|
+
ref: containerRef,
|
|
61
|
+
className: "input-content",
|
|
62
|
+
onClick: () => inputRef.current.click(),
|
|
63
|
+
children: [
|
|
64
|
+
/* @__PURE__ */ jsx(
|
|
65
|
+
"input",
|
|
66
|
+
{
|
|
67
|
+
..._.omit(props, ["className", "register", "mask", "setValue"]),
|
|
68
|
+
...register,
|
|
69
|
+
ref: inputRef,
|
|
70
|
+
type: "text",
|
|
71
|
+
maxLength: props.maxLength || 255,
|
|
72
|
+
onChange,
|
|
73
|
+
onFocus,
|
|
74
|
+
onBlur,
|
|
75
|
+
value: focus ? filter : "",
|
|
76
|
+
placeholder: _.isString(value) ? value : (value == null ? void 0 : value.textContent) || ""
|
|
77
|
+
}
|
|
78
|
+
),
|
|
79
|
+
!focus && /* @__PURE__ */ jsx("div", { className: "input-label-value", children: value }),
|
|
80
|
+
/* @__PURE__ */ jsx("div", { className: "input-icon", children: focus ? /* @__PURE__ */ jsx("i", { "aria-hidden": true, className: "fa-solid fa-chevron-up" }) : /* @__PURE__ */ jsx("i", { "aria-hidden": true, className: "fa-solid fa-chevron-down" }) })
|
|
81
|
+
]
|
|
82
|
+
}
|
|
83
|
+
),
|
|
74
84
|
!!props.error && /* @__PURE__ */ jsx(InputError, { children: props.error })
|
|
75
85
|
] });
|
|
76
86
|
}
|
|
@@ -41,24 +41,35 @@ 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
|
-
var _a
|
|
50
|
-
(_a = props.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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);
|
|
63
|
+
});
|
|
64
|
+
}, [props.inputRef]);
|
|
54
65
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.Container, { width: props.width, children: import_lodash.default.map(
|
|
55
|
-
|
|
66
|
+
options,
|
|
56
67
|
(data, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
57
68
|
"div",
|
|
58
69
|
{
|
|
59
70
|
className: "input-option",
|
|
60
71
|
onClick: () => set(Object.keys(data)[index]),
|
|
61
|
-
children:
|
|
72
|
+
children: Object.values(data)[index] || ""
|
|
62
73
|
},
|
|
63
74
|
index
|
|
64
75
|
)
|
|
@@ -8,24 +8,35 @@ 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
|
-
var _a
|
|
17
|
-
(_a = props.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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);
|
|
30
|
+
});
|
|
31
|
+
}, [props.inputRef]);
|
|
21
32
|
return /* @__PURE__ */ jsx(Container, { width: props.width, children: _.map(
|
|
22
|
-
|
|
33
|
+
options,
|
|
23
34
|
(data, index) => /* @__PURE__ */ jsx(
|
|
24
35
|
"div",
|
|
25
36
|
{
|
|
26
37
|
className: "input-option",
|
|
27
38
|
onClick: () => set(Object.keys(data)[index]),
|
|
28
|
-
children:
|
|
39
|
+
children: Object.values(data)[index] || ""
|
|
29
40
|
},
|
|
30
41
|
index
|
|
31
42
|
)
|
|
@@ -44,24 +44,14 @@ const Container = import_styled_components.default.div`
|
|
|
44
44
|
overflow-y: scroll;
|
|
45
45
|
|
|
46
46
|
.input-option {
|
|
47
|
-
padding: .5rem
|
|
47
|
+
padding: .5rem 1rem;
|
|
48
48
|
border-radius: 5px;
|
|
49
49
|
cursor: pointer;
|
|
50
|
-
|
|
51
|
-
position: relative;
|
|
50
|
+
max-height: 36px;
|
|
52
51
|
|
|
53
52
|
&:hover {
|
|
54
53
|
background-color: ${({ theme }) => theme.t05};
|
|
55
54
|
}
|
|
56
|
-
|
|
57
|
-
.input-option-elipse {
|
|
58
|
-
position: absolute;
|
|
59
|
-
left: 0;
|
|
60
|
-
right: 0;
|
|
61
|
-
white-space: nowrap;
|
|
62
|
-
overflow: hidden;
|
|
63
|
-
text-overflow: ellipsis;
|
|
64
|
-
}
|
|
65
55
|
}
|
|
66
56
|
`;
|
|
67
57
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -11,24 +11,14 @@ const Container = styled.div`
|
|
|
11
11
|
overflow-y: scroll;
|
|
12
12
|
|
|
13
13
|
.input-option {
|
|
14
|
-
padding: .5rem
|
|
14
|
+
padding: .5rem 1rem;
|
|
15
15
|
border-radius: 5px;
|
|
16
16
|
cursor: pointer;
|
|
17
|
-
|
|
18
|
-
position: relative;
|
|
17
|
+
max-height: 36px;
|
|
19
18
|
|
|
20
19
|
&:hover {
|
|
21
20
|
background-color: ${({ theme }) => theme.t05};
|
|
22
21
|
}
|
|
23
|
-
|
|
24
|
-
.input-option-elipse {
|
|
25
|
-
position: absolute;
|
|
26
|
-
left: 0;
|
|
27
|
-
right: 0;
|
|
28
|
-
white-space: nowrap;
|
|
29
|
-
overflow: hidden;
|
|
30
|
-
text-overflow: ellipsis;
|
|
31
|
-
}
|
|
32
22
|
}
|
|
33
23
|
`;
|
|
34
24
|
export {
|
|
@@ -45,6 +45,7 @@ const Container = import_styled_components.default.div`
|
|
|
45
45
|
overflow: hidden;
|
|
46
46
|
padding-right: ${({ password }) => password ? ".6rem" : "0rem"};
|
|
47
47
|
background-color: ${({ theme }) => theme.primary};
|
|
48
|
+
position: relative;
|
|
48
49
|
|
|
49
50
|
input {
|
|
50
51
|
border: 0;
|
|
@@ -54,6 +55,8 @@ const Container = import_styled_components.default.div`
|
|
|
54
55
|
background-color: ${({ theme }) => theme.primary};
|
|
55
56
|
color: ${({ theme }) => theme.t6};
|
|
56
57
|
cursor: pointer;
|
|
58
|
+
position: relative;
|
|
59
|
+
z-index: 0;
|
|
57
60
|
|
|
58
61
|
&:focus {
|
|
59
62
|
cursor: text;
|
|
@@ -69,6 +72,19 @@ const Container = import_styled_components.default.div`
|
|
|
69
72
|
outline: none;
|
|
70
73
|
}
|
|
71
74
|
}
|
|
75
|
+
|
|
76
|
+
.input-label-value {
|
|
77
|
+
position: absolute;
|
|
78
|
+
top: 0;
|
|
79
|
+
left: 0;
|
|
80
|
+
height: 100%;
|
|
81
|
+
width: 100%;
|
|
82
|
+
cursor: pointer;
|
|
83
|
+
z-index: 1;
|
|
84
|
+
padding: 0 1rem;
|
|
85
|
+
display: flex;
|
|
86
|
+
align-items: center;
|
|
87
|
+
}
|
|
72
88
|
|
|
73
89
|
.input-icon {
|
|
74
90
|
color: ${({ theme }) => theme.t3};
|
|
@@ -12,6 +12,7 @@ const Container = styled.div`
|
|
|
12
12
|
overflow: hidden;
|
|
13
13
|
padding-right: ${({ password }) => password ? ".6rem" : "0rem"};
|
|
14
14
|
background-color: ${({ theme }) => theme.primary};
|
|
15
|
+
position: relative;
|
|
15
16
|
|
|
16
17
|
input {
|
|
17
18
|
border: 0;
|
|
@@ -21,6 +22,8 @@ const Container = styled.div`
|
|
|
21
22
|
background-color: ${({ theme }) => theme.primary};
|
|
22
23
|
color: ${({ theme }) => theme.t6};
|
|
23
24
|
cursor: pointer;
|
|
25
|
+
position: relative;
|
|
26
|
+
z-index: 0;
|
|
24
27
|
|
|
25
28
|
&:focus {
|
|
26
29
|
cursor: text;
|
|
@@ -36,6 +39,19 @@ const Container = styled.div`
|
|
|
36
39
|
outline: none;
|
|
37
40
|
}
|
|
38
41
|
}
|
|
42
|
+
|
|
43
|
+
.input-label-value {
|
|
44
|
+
position: absolute;
|
|
45
|
+
top: 0;
|
|
46
|
+
left: 0;
|
|
47
|
+
height: 100%;
|
|
48
|
+
width: 100%;
|
|
49
|
+
cursor: pointer;
|
|
50
|
+
z-index: 1;
|
|
51
|
+
padding: 0 1rem;
|
|
52
|
+
display: flex;
|
|
53
|
+
align-items: center;
|
|
54
|
+
}
|
|
39
55
|
|
|
40
56
|
.input-icon {
|
|
41
57
|
color: ${({ theme }) => theme.t3};
|