@gustavo-valsechi/client 1.4.117 → 1.4.118
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.
|
@@ -50,18 +50,9 @@ 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
|
-
const
|
|
54
|
-
setFocus(false);
|
|
55
|
-
setFilter("");
|
|
56
|
-
if (register.onBlur) register.onBlur(event);
|
|
57
|
-
};
|
|
58
|
-
const onFocus = (event) => {
|
|
59
|
-
setFocus(true);
|
|
60
|
-
if (register.onFocus) register.onFocus(event);
|
|
61
|
-
};
|
|
62
|
-
const onClick = (event) => {
|
|
53
|
+
const addOptionsTarget = (0, import_react.useCallback)(() => {
|
|
63
54
|
var _a2;
|
|
64
|
-
if (
|
|
55
|
+
if (!(inputRef == null ? void 0 : inputRef.current) || !(containerRef == null ? void 0 : containerRef.current)) return;
|
|
65
56
|
target.add({
|
|
66
57
|
ref: inputRef,
|
|
67
58
|
component: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -74,6 +65,23 @@ function InputSelect(props) {
|
|
|
74
65
|
}
|
|
75
66
|
)
|
|
76
67
|
});
|
|
68
|
+
return () => target.remove(inputRef);
|
|
69
|
+
}, [containerRef, inputRef]);
|
|
70
|
+
(0, import_react.useEffect)(() => {
|
|
71
|
+
addOptionsTarget();
|
|
72
|
+
}, [addOptionsTarget]);
|
|
73
|
+
const onBlur = (event) => {
|
|
74
|
+
setFocus(false);
|
|
75
|
+
setFilter("");
|
|
76
|
+
if (register.onBlur) register.onBlur(event);
|
|
77
|
+
};
|
|
78
|
+
const onFocus = (event) => {
|
|
79
|
+
setFocus(true);
|
|
80
|
+
if (register.onFocus) register.onFocus(event);
|
|
81
|
+
};
|
|
82
|
+
const onClick = (event) => {
|
|
83
|
+
if (register.onClick) register.onClick(event);
|
|
84
|
+
addOptionsTarget();
|
|
77
85
|
};
|
|
78
86
|
const onChange = (event) => {
|
|
79
87
|
const value2 = event.target.value || "";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useState, useRef } from "react";
|
|
3
|
+
import { useState, useRef, useEffect, useCallback } from "react";
|
|
4
4
|
import { Container } from "./styles";
|
|
5
5
|
import { InputLabel } from "../label";
|
|
6
6
|
import { InputError } from "../error";
|
|
@@ -17,18 +17,9 @@ 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
|
-
const
|
|
21
|
-
setFocus(false);
|
|
22
|
-
setFilter("");
|
|
23
|
-
if (register.onBlur) register.onBlur(event);
|
|
24
|
-
};
|
|
25
|
-
const onFocus = (event) => {
|
|
26
|
-
setFocus(true);
|
|
27
|
-
if (register.onFocus) register.onFocus(event);
|
|
28
|
-
};
|
|
29
|
-
const onClick = (event) => {
|
|
20
|
+
const addOptionsTarget = useCallback(() => {
|
|
30
21
|
var _a2;
|
|
31
|
-
if (
|
|
22
|
+
if (!(inputRef == null ? void 0 : inputRef.current) || !(containerRef == null ? void 0 : containerRef.current)) return;
|
|
32
23
|
target.add({
|
|
33
24
|
ref: inputRef,
|
|
34
25
|
component: /* @__PURE__ */ jsx(
|
|
@@ -41,6 +32,23 @@ function InputSelect(props) {
|
|
|
41
32
|
}
|
|
42
33
|
)
|
|
43
34
|
});
|
|
35
|
+
return () => target.remove(inputRef);
|
|
36
|
+
}, [containerRef, inputRef]);
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
addOptionsTarget();
|
|
39
|
+
}, [addOptionsTarget]);
|
|
40
|
+
const onBlur = (event) => {
|
|
41
|
+
setFocus(false);
|
|
42
|
+
setFilter("");
|
|
43
|
+
if (register.onBlur) register.onBlur(event);
|
|
44
|
+
};
|
|
45
|
+
const onFocus = (event) => {
|
|
46
|
+
setFocus(true);
|
|
47
|
+
if (register.onFocus) register.onFocus(event);
|
|
48
|
+
};
|
|
49
|
+
const onClick = (event) => {
|
|
50
|
+
if (register.onClick) register.onClick(event);
|
|
51
|
+
addOptionsTarget();
|
|
44
52
|
};
|
|
45
53
|
const onChange = (event) => {
|
|
46
54
|
const value2 = event.target.value || "";
|
|
@@ -150,8 +150,10 @@ 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));
|
|
153
154
|
insideMemory.splice(import_lodash.default.findIndex(insideMemory, (i) => i === index), 1);
|
|
154
155
|
memory.slice(index, 1);
|
|
156
|
+
console.log("memory", memory);
|
|
155
157
|
setTargets(memory);
|
|
156
158
|
};
|
|
157
159
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
@@ -116,8 +116,10 @@ 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));
|
|
119
120
|
insideMemory.splice(_.findIndex(insideMemory, (i) => i === index), 1);
|
|
120
121
|
memory.slice(index, 1);
|
|
122
|
+
console.log("memory", memory);
|
|
121
123
|
setTargets(memory);
|
|
122
124
|
};
|
|
123
125
|
return /* @__PURE__ */ jsxs(
|