@gustavo-valsechi/client 1.4.94 → 1.4.95
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.
|
@@ -41,12 +41,13 @@ 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
|
-
const inputRef = (0, import_react.useRef)(
|
|
44
|
+
const inputRef = (0, import_react.useRef)(null);
|
|
45
45
|
const target = (0, import_contexts.useTarget)();
|
|
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
49
|
if (!(inputRef == null ? void 0 : inputRef.current)) return;
|
|
50
|
+
console.log(inputRef == null ? void 0 : inputRef.current);
|
|
50
51
|
target.add({ ref: inputRef, component: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_options.default, { ...props, inputRef, register }) });
|
|
51
52
|
return () => target.remove(inputRef);
|
|
52
53
|
}, [inputRef]);
|
|
@@ -73,10 +74,10 @@ function InputSelect(props) {
|
|
|
73
74
|
"input",
|
|
74
75
|
{
|
|
75
76
|
...import_lodash.default.omit(props, ["className", "register", "mask", "setValue"]),
|
|
76
|
-
ref: inputRef,
|
|
77
77
|
type: "text",
|
|
78
78
|
maxLength: props.maxLength || 255,
|
|
79
79
|
...register,
|
|
80
|
+
ref: inputRef,
|
|
80
81
|
onChange,
|
|
81
82
|
onFocus,
|
|
82
83
|
onBlur
|
|
@@ -8,12 +8,13 @@ import { useTarget } from "../../../../../contexts";
|
|
|
8
8
|
import _ from "lodash";
|
|
9
9
|
import InputSelectOption from "./options";
|
|
10
10
|
function InputSelect(props) {
|
|
11
|
-
const inputRef = useRef(
|
|
11
|
+
const inputRef = useRef(null);
|
|
12
12
|
const target = useTarget();
|
|
13
13
|
const [focus, setFocus] = useState(false);
|
|
14
14
|
const register = (props.register || ((name) => ({})))(props.name || "");
|
|
15
15
|
useEffect(() => {
|
|
16
16
|
if (!(inputRef == null ? void 0 : inputRef.current)) return;
|
|
17
|
+
console.log(inputRef == null ? void 0 : inputRef.current);
|
|
17
18
|
target.add({ ref: inputRef, component: /* @__PURE__ */ jsx(InputSelectOption, { ...props, inputRef, register }) });
|
|
18
19
|
return () => target.remove(inputRef);
|
|
19
20
|
}, [inputRef]);
|
|
@@ -40,10 +41,10 @@ function InputSelect(props) {
|
|
|
40
41
|
"input",
|
|
41
42
|
{
|
|
42
43
|
..._.omit(props, ["className", "register", "mask", "setValue"]),
|
|
43
|
-
ref: inputRef,
|
|
44
44
|
type: "text",
|
|
45
45
|
maxLength: props.maxLength || 255,
|
|
46
46
|
...register,
|
|
47
|
+
ref: inputRef,
|
|
47
48
|
onChange,
|
|
48
49
|
onFocus,
|
|
49
50
|
onBlur
|
|
@@ -47,10 +47,6 @@ const TargetProviderContainer = ({ children }) => {
|
|
|
47
47
|
const elementFocusable = (target, index) => {
|
|
48
48
|
const focusableTags = ["input", "select", "textarea", "button"];
|
|
49
49
|
const isFocusable = import_lodash.default.some(focusableTags, (tag) => target.ref.current.tagName.toLowerCase() === tag);
|
|
50
|
-
console.log("tagName", target.ref.current.tagName.toLowerCase());
|
|
51
|
-
console.log("isFocusable", isFocusable);
|
|
52
|
-
console.log("target.ref.current", target.ref.current);
|
|
53
|
-
console.log("inputRef.current[index]", inputRef.current[index]);
|
|
54
50
|
if (isFocusable) return target.ref.current;
|
|
55
51
|
return inputRef.current[index];
|
|
56
52
|
};
|
|
@@ -104,21 +100,18 @@ const TargetProviderContainer = ({ children }) => {
|
|
|
104
100
|
import_lodash.default.forEach(targets, (target, index) => {
|
|
105
101
|
var _a;
|
|
106
102
|
const element = (_a = target.ref) == null ? void 0 : _a.current;
|
|
107
|
-
console.log(element);
|
|
108
103
|
if (!(element == null ? void 0 : element.addEventListener)) return;
|
|
109
104
|
element.addEventListener("click", () => {
|
|
110
105
|
const targetElement = import_lodash.default.find(containerRef.current, (data, i) => i === index);
|
|
111
106
|
if (!targetElement) return;
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
console.log("target focus", elementFocusable(target, index) === document.activeElement);
|
|
115
|
-
if (elementFocusable(target, index) === document.activeElement) {
|
|
107
|
+
const focusable = elementFocusable(target, index);
|
|
108
|
+
if (focusable === document.activeElement) {
|
|
116
109
|
close(targetElement);
|
|
117
110
|
return;
|
|
118
111
|
}
|
|
119
112
|
const coords = getCoords(element);
|
|
120
113
|
open(targetElement, coords);
|
|
121
|
-
|
|
114
|
+
focusable.focus();
|
|
122
115
|
});
|
|
123
116
|
element.addEventListener("resize", () => {
|
|
124
117
|
import_lodash.default.forEach(containerRef.current, (elementRef) => close(elementRef));
|
|
@@ -13,10 +13,6 @@ const TargetProviderContainer = ({ children }) => {
|
|
|
13
13
|
const elementFocusable = (target, index) => {
|
|
14
14
|
const focusableTags = ["input", "select", "textarea", "button"];
|
|
15
15
|
const isFocusable = _.some(focusableTags, (tag) => target.ref.current.tagName.toLowerCase() === tag);
|
|
16
|
-
console.log("tagName", target.ref.current.tagName.toLowerCase());
|
|
17
|
-
console.log("isFocusable", isFocusable);
|
|
18
|
-
console.log("target.ref.current", target.ref.current);
|
|
19
|
-
console.log("inputRef.current[index]", inputRef.current[index]);
|
|
20
16
|
if (isFocusable) return target.ref.current;
|
|
21
17
|
return inputRef.current[index];
|
|
22
18
|
};
|
|
@@ -70,21 +66,18 @@ const TargetProviderContainer = ({ children }) => {
|
|
|
70
66
|
_.forEach(targets, (target, index) => {
|
|
71
67
|
var _a;
|
|
72
68
|
const element = (_a = target.ref) == null ? void 0 : _a.current;
|
|
73
|
-
console.log(element);
|
|
74
69
|
if (!(element == null ? void 0 : element.addEventListener)) return;
|
|
75
70
|
element.addEventListener("click", () => {
|
|
76
71
|
const targetElement = _.find(containerRef.current, (data, i) => i === index);
|
|
77
72
|
if (!targetElement) return;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
console.log("target focus", elementFocusable(target, index) === document.activeElement);
|
|
81
|
-
if (elementFocusable(target, index) === document.activeElement) {
|
|
73
|
+
const focusable = elementFocusable(target, index);
|
|
74
|
+
if (focusable === document.activeElement) {
|
|
82
75
|
close(targetElement);
|
|
83
76
|
return;
|
|
84
77
|
}
|
|
85
78
|
const coords = getCoords(element);
|
|
86
79
|
open(targetElement, coords);
|
|
87
|
-
|
|
80
|
+
focusable.focus();
|
|
88
81
|
});
|
|
89
82
|
element.addEventListener("resize", () => {
|
|
90
83
|
_.forEach(containerRef.current, (elementRef) => close(elementRef));
|