@gustavo-valsechi/client 1.4.94 → 1.4.96
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,7 +41,7 @@ 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 || "");
|
|
@@ -73,10 +73,10 @@ function InputSelect(props) {
|
|
|
73
73
|
"input",
|
|
74
74
|
{
|
|
75
75
|
...import_lodash.default.omit(props, ["className", "register", "mask", "setValue"]),
|
|
76
|
-
ref: inputRef,
|
|
77
76
|
type: "text",
|
|
78
77
|
maxLength: props.maxLength || 255,
|
|
79
78
|
...register,
|
|
79
|
+
ref: inputRef,
|
|
80
80
|
onChange,
|
|
81
81
|
onFocus,
|
|
82
82
|
onBlur
|
|
@@ -8,7 +8,7 @@ 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 || "");
|
|
@@ -40,10 +40,10 @@ function InputSelect(props) {
|
|
|
40
40
|
"input",
|
|
41
41
|
{
|
|
42
42
|
..._.omit(props, ["className", "register", "mask", "setValue"]),
|
|
43
|
-
ref: inputRef,
|
|
44
43
|
type: "text",
|
|
45
44
|
maxLength: props.maxLength || 255,
|
|
46
45
|
...register,
|
|
46
|
+
ref: inputRef,
|
|
47
47
|
onChange,
|
|
48
48
|
onFocus,
|
|
49
49
|
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,20 @@ 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;
|
|
103
|
+
console.log(target);
|
|
107
104
|
console.log(element);
|
|
108
105
|
if (!(element == null ? void 0 : element.addEventListener)) return;
|
|
109
106
|
element.addEventListener("click", () => {
|
|
110
107
|
const targetElement = import_lodash.default.find(containerRef.current, (data, i) => i === index);
|
|
111
108
|
if (!targetElement) return;
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
console.log("target focus", elementFocusable(target, index) === document.activeElement);
|
|
115
|
-
if (elementFocusable(target, index) === document.activeElement) {
|
|
109
|
+
const focusable = elementFocusable(target, index);
|
|
110
|
+
if (focusable === document.activeElement) {
|
|
116
111
|
close(targetElement);
|
|
117
112
|
return;
|
|
118
113
|
}
|
|
119
114
|
const coords = getCoords(element);
|
|
120
115
|
open(targetElement, coords);
|
|
121
|
-
|
|
116
|
+
focusable.focus();
|
|
122
117
|
});
|
|
123
118
|
element.addEventListener("resize", () => {
|
|
124
119
|
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,20 @@ 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;
|
|
69
|
+
console.log(target);
|
|
73
70
|
console.log(element);
|
|
74
71
|
if (!(element == null ? void 0 : element.addEventListener)) return;
|
|
75
72
|
element.addEventListener("click", () => {
|
|
76
73
|
const targetElement = _.find(containerRef.current, (data, i) => i === index);
|
|
77
74
|
if (!targetElement) return;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
console.log("target focus", elementFocusable(target, index) === document.activeElement);
|
|
81
|
-
if (elementFocusable(target, index) === document.activeElement) {
|
|
75
|
+
const focusable = elementFocusable(target, index);
|
|
76
|
+
if (focusable === document.activeElement) {
|
|
82
77
|
close(targetElement);
|
|
83
78
|
return;
|
|
84
79
|
}
|
|
85
80
|
const coords = getCoords(element);
|
|
86
81
|
open(targetElement, coords);
|
|
87
|
-
|
|
82
|
+
focusable.focus();
|
|
88
83
|
});
|
|
89
84
|
element.addEventListener("resize", () => {
|
|
90
85
|
_.forEach(containerRef.current, (elementRef) => close(elementRef));
|