@gustavo-valsechi/client 1.4.93 → 1.4.94
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.
|
@@ -46,9 +46,10 @@ function InputSelect(props) {
|
|
|
46
46
|
const [focus, setFocus] = (0, import_react.useState)(false);
|
|
47
47
|
const register = (props.register || ((name) => ({})))(props.name || "");
|
|
48
48
|
(0, import_react.useEffect)(() => {
|
|
49
|
+
if (!(inputRef == null ? void 0 : inputRef.current)) return;
|
|
49
50
|
target.add({ ref: inputRef, component: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_options.default, { ...props, inputRef, register }) });
|
|
50
51
|
return () => target.remove(inputRef);
|
|
51
|
-
}, []);
|
|
52
|
+
}, [inputRef]);
|
|
52
53
|
const onBlur = (event) => {
|
|
53
54
|
setFocus(false);
|
|
54
55
|
if (register.onBlur) register.onBlur(event);
|
|
@@ -13,9 +13,10 @@ function InputSelect(props) {
|
|
|
13
13
|
const [focus, setFocus] = useState(false);
|
|
14
14
|
const register = (props.register || ((name) => ({})))(props.name || "");
|
|
15
15
|
useEffect(() => {
|
|
16
|
+
if (!(inputRef == null ? void 0 : inputRef.current)) return;
|
|
16
17
|
target.add({ ref: inputRef, component: /* @__PURE__ */ jsx(InputSelectOption, { ...props, inputRef, register }) });
|
|
17
18
|
return () => target.remove(inputRef);
|
|
18
|
-
}, []);
|
|
19
|
+
}, [inputRef]);
|
|
19
20
|
const onBlur = (event) => {
|
|
20
21
|
setFocus(false);
|
|
21
22
|
if (register.onBlur) register.onBlur(event);
|
|
@@ -105,7 +105,24 @@ const TargetProviderContainer = ({ children }) => {
|
|
|
105
105
|
var _a;
|
|
106
106
|
const element = (_a = target.ref) == null ? void 0 : _a.current;
|
|
107
107
|
console.log(element);
|
|
108
|
-
if (!element) return;
|
|
108
|
+
if (!(element == null ? void 0 : element.addEventListener)) return;
|
|
109
|
+
element.addEventListener("click", () => {
|
|
110
|
+
const targetElement = import_lodash.default.find(containerRef.current, (data, i) => i === index);
|
|
111
|
+
if (!targetElement) return;
|
|
112
|
+
console.log("document.activeElement", document.activeElement);
|
|
113
|
+
console.log("elementFocusable", elementFocusable(target, index));
|
|
114
|
+
console.log("target focus", elementFocusable(target, index) === document.activeElement);
|
|
115
|
+
if (elementFocusable(target, index) === document.activeElement) {
|
|
116
|
+
close(targetElement);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const coords = getCoords(element);
|
|
120
|
+
open(targetElement, coords);
|
|
121
|
+
elementFocusable(target, index).focus();
|
|
122
|
+
});
|
|
123
|
+
element.addEventListener("resize", () => {
|
|
124
|
+
import_lodash.default.forEach(containerRef.current, (elementRef) => close(elementRef));
|
|
125
|
+
});
|
|
109
126
|
});
|
|
110
127
|
}, [targets, inputRef, containerRef]);
|
|
111
128
|
const getCoords = (target) => {
|
|
@@ -71,7 +71,24 @@ const TargetProviderContainer = ({ children }) => {
|
|
|
71
71
|
var _a;
|
|
72
72
|
const element = (_a = target.ref) == null ? void 0 : _a.current;
|
|
73
73
|
console.log(element);
|
|
74
|
-
if (!element) return;
|
|
74
|
+
if (!(element == null ? void 0 : element.addEventListener)) return;
|
|
75
|
+
element.addEventListener("click", () => {
|
|
76
|
+
const targetElement = _.find(containerRef.current, (data, i) => i === index);
|
|
77
|
+
if (!targetElement) return;
|
|
78
|
+
console.log("document.activeElement", document.activeElement);
|
|
79
|
+
console.log("elementFocusable", elementFocusable(target, index));
|
|
80
|
+
console.log("target focus", elementFocusable(target, index) === document.activeElement);
|
|
81
|
+
if (elementFocusable(target, index) === document.activeElement) {
|
|
82
|
+
close(targetElement);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const coords = getCoords(element);
|
|
86
|
+
open(targetElement, coords);
|
|
87
|
+
elementFocusable(target, index).focus();
|
|
88
|
+
});
|
|
89
|
+
element.addEventListener("resize", () => {
|
|
90
|
+
_.forEach(containerRef.current, (elementRef) => close(elementRef));
|
|
91
|
+
});
|
|
75
92
|
});
|
|
76
93
|
}, [targets, inputRef, containerRef]);
|
|
77
94
|
const getCoords = (target) => {
|