@gustavo-valsechi/client 1.4.118 → 1.4.119
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/types/select/index.js +1 -9
- package/dist/components/types/form/types/select/index.mjs +2 -10
- package/dist/components/types/form/types/select/options/index.js +1 -1
- package/dist/components/types/form/types/select/options/index.mjs +1 -1
- package/dist/contexts/target/index.js +9 -4
- package/dist/contexts/target/index.mjs +9 -4
- package/dist/interfaces/contexts/tooltip/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -50,7 +50,7 @@ function InputSelect(props) {
|
|
|
50
50
|
const register = (props.register || ((name) => ({})))(props.name || "");
|
|
51
51
|
const inputValue = (_a = props.watch) == null ? void 0 : _a.call(props, props.name);
|
|
52
52
|
const value = ((_b = import_lodash.default.find(props.options, (option) => Object.keys(option)[0] === inputValue)) == null ? void 0 : _b[inputValue || ""]) || "";
|
|
53
|
-
|
|
53
|
+
(0, import_react.useEffect)(() => {
|
|
54
54
|
var _a2;
|
|
55
55
|
if (!(inputRef == null ? void 0 : inputRef.current) || !(containerRef == null ? void 0 : containerRef.current)) return;
|
|
56
56
|
target.add({
|
|
@@ -67,9 +67,6 @@ function InputSelect(props) {
|
|
|
67
67
|
});
|
|
68
68
|
return () => target.remove(inputRef);
|
|
69
69
|
}, [containerRef, inputRef]);
|
|
70
|
-
(0, import_react.useEffect)(() => {
|
|
71
|
-
addOptionsTarget();
|
|
72
|
-
}, [addOptionsTarget]);
|
|
73
70
|
const onBlur = (event) => {
|
|
74
71
|
setFocus(false);
|
|
75
72
|
setFilter("");
|
|
@@ -79,10 +76,6 @@ function InputSelect(props) {
|
|
|
79
76
|
setFocus(true);
|
|
80
77
|
if (register.onFocus) register.onFocus(event);
|
|
81
78
|
};
|
|
82
|
-
const onClick = (event) => {
|
|
83
|
-
if (register.onClick) register.onClick(event);
|
|
84
|
-
addOptionsTarget();
|
|
85
|
-
};
|
|
86
79
|
const onChange = (event) => {
|
|
87
80
|
const value2 = event.target.value || "";
|
|
88
81
|
event.target.value = props.mask ? props.mask(value2) : value2;
|
|
@@ -114,7 +107,6 @@ function InputSelect(props) {
|
|
|
114
107
|
onChange,
|
|
115
108
|
onFocus,
|
|
116
109
|
onBlur,
|
|
117
|
-
onClick,
|
|
118
110
|
value: focus ? filter : "",
|
|
119
111
|
placeholder: import_lodash.default.isString(value) ? value : (value == null ? void 0 : value.textContent) || ""
|
|
120
112
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useState, useRef, useEffect
|
|
3
|
+
import { useState, useRef, useEffect } from "react";
|
|
4
4
|
import { Container } from "./styles";
|
|
5
5
|
import { InputLabel } from "../label";
|
|
6
6
|
import { InputError } from "../error";
|
|
@@ -17,7 +17,7 @@ function InputSelect(props) {
|
|
|
17
17
|
const register = (props.register || ((name) => ({})))(props.name || "");
|
|
18
18
|
const inputValue = (_a = props.watch) == null ? void 0 : _a.call(props, props.name);
|
|
19
19
|
const value = ((_b = _.find(props.options, (option) => Object.keys(option)[0] === inputValue)) == null ? void 0 : _b[inputValue || ""]) || "";
|
|
20
|
-
|
|
20
|
+
useEffect(() => {
|
|
21
21
|
var _a2;
|
|
22
22
|
if (!(inputRef == null ? void 0 : inputRef.current) || !(containerRef == null ? void 0 : containerRef.current)) return;
|
|
23
23
|
target.add({
|
|
@@ -34,9 +34,6 @@ function InputSelect(props) {
|
|
|
34
34
|
});
|
|
35
35
|
return () => target.remove(inputRef);
|
|
36
36
|
}, [containerRef, inputRef]);
|
|
37
|
-
useEffect(() => {
|
|
38
|
-
addOptionsTarget();
|
|
39
|
-
}, [addOptionsTarget]);
|
|
40
37
|
const onBlur = (event) => {
|
|
41
38
|
setFocus(false);
|
|
42
39
|
setFilter("");
|
|
@@ -46,10 +43,6 @@ function InputSelect(props) {
|
|
|
46
43
|
setFocus(true);
|
|
47
44
|
if (register.onFocus) register.onFocus(event);
|
|
48
45
|
};
|
|
49
|
-
const onClick = (event) => {
|
|
50
|
-
if (register.onClick) register.onClick(event);
|
|
51
|
-
addOptionsTarget();
|
|
52
|
-
};
|
|
53
46
|
const onChange = (event) => {
|
|
54
47
|
const value2 = event.target.value || "";
|
|
55
48
|
event.target.value = props.mask ? props.mask(value2) : value2;
|
|
@@ -81,7 +74,6 @@ function InputSelect(props) {
|
|
|
81
74
|
onChange,
|
|
82
75
|
onFocus,
|
|
83
76
|
onBlur,
|
|
84
|
-
onClick,
|
|
85
77
|
value: focus ? filter : "",
|
|
86
78
|
placeholder: _.isString(value) ? value : (value == null ? void 0 : value.textContent) || ""
|
|
87
79
|
}
|
|
@@ -44,7 +44,7 @@ function InputSelectOption(props) {
|
|
|
44
44
|
(0, import_react.useEffect)(() => {
|
|
45
45
|
var _a;
|
|
46
46
|
(_a = props.setValue) == null ? void 0 : _a.call(props, props.name, value);
|
|
47
|
-
target.
|
|
47
|
+
target.close(props.inputRef);
|
|
48
48
|
}, [value, props.inputRef]);
|
|
49
49
|
(0, import_react.useEffect)(() => {
|
|
50
50
|
const optionsElement = document.getElementById("input-options");
|
|
@@ -11,7 +11,7 @@ function InputSelectOption(props) {
|
|
|
11
11
|
useEffect(() => {
|
|
12
12
|
var _a;
|
|
13
13
|
(_a = props.setValue) == null ? void 0 : _a.call(props, props.name, value);
|
|
14
|
-
target.
|
|
14
|
+
target.close(props.inputRef);
|
|
15
15
|
}, [value, props.inputRef]);
|
|
16
16
|
useEffect(() => {
|
|
17
17
|
const optionsElement = document.getElementById("input-options");
|
|
@@ -150,18 +150,23 @@ const TargetProviderContainer = ({ children }) => {
|
|
|
150
150
|
};
|
|
151
151
|
const remove = (ref) => {
|
|
152
152
|
const index = import_lodash.default.findIndex(memory, (data) => data.ref.current === ref.current);
|
|
153
|
-
console.log(import_lodash.default.find(memory, (data) => data.ref.current === ref.current));
|
|
154
153
|
insideMemory.splice(import_lodash.default.findIndex(insideMemory, (i) => i === index), 1);
|
|
155
|
-
memory.
|
|
156
|
-
console.log("memory", memory);
|
|
154
|
+
memory.splice(index, 1);
|
|
157
155
|
setTargets(memory);
|
|
158
156
|
};
|
|
157
|
+
const closeTarget = (ref) => {
|
|
158
|
+
const index = import_lodash.default.findIndex(memory, (data) => data.ref.current === ref.current);
|
|
159
|
+
const targetElement = import_lodash.default.find(containerRef.current, (data, i) => i === index);
|
|
160
|
+
if (!targetElement) return;
|
|
161
|
+
close(targetElement, index);
|
|
162
|
+
};
|
|
159
163
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
160
164
|
TargetContext.Provider,
|
|
161
165
|
{
|
|
162
166
|
value: {
|
|
163
167
|
add,
|
|
164
|
-
remove
|
|
168
|
+
remove,
|
|
169
|
+
close: closeTarget
|
|
165
170
|
},
|
|
166
171
|
children: [
|
|
167
172
|
import_lodash.default.map(
|
|
@@ -116,18 +116,23 @@ const TargetProviderContainer = ({ children }) => {
|
|
|
116
116
|
};
|
|
117
117
|
const remove = (ref) => {
|
|
118
118
|
const index = _.findIndex(memory, (data) => data.ref.current === ref.current);
|
|
119
|
-
console.log(_.find(memory, (data) => data.ref.current === ref.current));
|
|
120
119
|
insideMemory.splice(_.findIndex(insideMemory, (i) => i === index), 1);
|
|
121
|
-
memory.
|
|
122
|
-
console.log("memory", memory);
|
|
120
|
+
memory.splice(index, 1);
|
|
123
121
|
setTargets(memory);
|
|
124
122
|
};
|
|
123
|
+
const closeTarget = (ref) => {
|
|
124
|
+
const index = _.findIndex(memory, (data) => data.ref.current === ref.current);
|
|
125
|
+
const targetElement = _.find(containerRef.current, (data, i) => i === index);
|
|
126
|
+
if (!targetElement) return;
|
|
127
|
+
close(targetElement, index);
|
|
128
|
+
};
|
|
125
129
|
return /* @__PURE__ */ jsxs(
|
|
126
130
|
TargetContext.Provider,
|
|
127
131
|
{
|
|
128
132
|
value: {
|
|
129
133
|
add,
|
|
130
|
-
remove
|
|
134
|
+
remove,
|
|
135
|
+
close: closeTarget
|
|
131
136
|
},
|
|
132
137
|
children: [
|
|
133
138
|
_.map(
|