@gustavo-valsechi/client 1.4.112 → 1.4.114

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.
@@ -49,9 +49,7 @@ function InputSelect(props) {
49
49
  const [filter, setFilter] = (0, import_react.useState)("");
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
- console.log("inputValue", inputValue);
53
52
  const value = ((_b = import_lodash.default.find(props.options, (option) => Object.keys(option)[0] === inputValue)) == null ? void 0 : _b[inputValue || ""]) || "";
54
- console.log("valueContent", value);
55
53
  (0, import_react.useEffect)(() => {
56
54
  var _a2;
57
55
  if (!(inputRef == null ? void 0 : inputRef.current) || !(containerRef == null ? void 0 : containerRef.current)) return;
@@ -83,6 +81,9 @@ function InputSelect(props) {
83
81
  event.target.value = props.mask ? props.mask(value2) : value2;
84
82
  setFilter(value2);
85
83
  if (props.onFilter) props.onFilter(value2);
84
+ const optionsElement = document.getElementById("input-options");
85
+ if (!optionsElement) return;
86
+ optionsElement.setAttribute("value", value2);
86
87
  };
87
88
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_styles.Container, { className: props.className, error: props.error, children: [
88
89
  !!props.label && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_label.InputLabel, { children: [
@@ -16,9 +16,7 @@ function InputSelect(props) {
16
16
  const [filter, setFilter] = useState("");
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
- console.log("inputValue", inputValue);
20
19
  const value = ((_b = _.find(props.options, (option) => Object.keys(option)[0] === inputValue)) == null ? void 0 : _b[inputValue || ""]) || "";
21
- console.log("valueContent", value);
22
20
  useEffect(() => {
23
21
  var _a2;
24
22
  if (!(inputRef == null ? void 0 : inputRef.current) || !(containerRef == null ? void 0 : containerRef.current)) return;
@@ -50,6 +48,9 @@ function InputSelect(props) {
50
48
  event.target.value = props.mask ? props.mask(value2) : value2;
51
49
  setFilter(value2);
52
50
  if (props.onFilter) props.onFilter(value2);
51
+ const optionsElement = document.getElementById("input-options");
52
+ if (!optionsElement) return;
53
+ optionsElement.setAttribute("value", value2);
53
54
  };
54
55
  return /* @__PURE__ */ jsxs(Container, { className: props.className, error: props.error, children: [
55
56
  !!props.label && /* @__PURE__ */ jsxs(InputLabel, { children: [
@@ -43,7 +43,7 @@ function InputSelectOption(props) {
43
43
  var _a, _b;
44
44
  (_a = props.setValue) == null ? void 0 : _a.call(props, props.name, value);
45
45
  if (!value || !((_b = props.inputRef) == null ? void 0 : _b.current)) return;
46
- props.inputRef.current.click();
46
+ props.inputRef.current.blur();
47
47
  }, [value, props.inputRef]);
48
48
  (0, import_react.useEffect)(() => {
49
49
  const filter = props.value || "";
@@ -57,7 +57,7 @@ function InputSelectOption(props) {
57
57
  });
58
58
  setOptions(filtredOptions);
59
59
  }, [props.value]);
60
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.Container, { width: props.width, children: import_lodash.default.map(
60
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.Container, { id: "input-options", width: props.width, children: import_lodash.default.map(
61
61
  options,
62
62
  (data, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
63
63
  "div",
@@ -10,7 +10,7 @@ function InputSelectOption(props) {
10
10
  var _a, _b;
11
11
  (_a = props.setValue) == null ? void 0 : _a.call(props, props.name, value);
12
12
  if (!value || !((_b = props.inputRef) == null ? void 0 : _b.current)) return;
13
- props.inputRef.current.click();
13
+ props.inputRef.current.blur();
14
14
  }, [value, props.inputRef]);
15
15
  useEffect(() => {
16
16
  const filter = props.value || "";
@@ -24,7 +24,7 @@ function InputSelectOption(props) {
24
24
  });
25
25
  setOptions(filtredOptions);
26
26
  }, [props.value]);
27
- return /* @__PURE__ */ jsx(Container, { width: props.width, children: _.map(
27
+ return /* @__PURE__ */ jsx(Container, { id: "input-options", width: props.width, children: _.map(
28
28
  options,
29
29
  (data, index) => /* @__PURE__ */ jsx(
30
30
  "div",
@@ -121,21 +121,16 @@ const TargetProviderContainer = ({ children }) => {
121
121
  import_lodash.default.forEach(containerRef.current, (elementRef) => close(elementRef, index));
122
122
  });
123
123
  focusable.addEventListener("blur", () => {
124
+ console.log("onBlur", insideMemory);
124
125
  if (import_lodash.default.some(insideMemory, (i) => i === index)) return;
125
126
  close(containerRef.current[index], index);
126
127
  });
127
- focusable.addEventListener("change", (e) => {
128
- var _a2;
129
- if (!targetElement) return;
130
- e.preventDefault();
131
- targetElement.setAttribute("value", ((_a2 = e.target) == null ? void 0 : _a2.value) || "");
132
- });
133
128
  });
134
129
  }, [targets, inputRef, containerRef]);
135
130
  const getCoords = (target) => {
136
131
  const rect = target.getBoundingClientRect();
137
132
  const targetTop = rect.top + window.scrollY;
138
- const targetLeft = rect.left + window.scrollX;
133
+ const targetLeft = rect.left + window.scrollX + 1;
139
134
  const coords = {
140
135
  top: targetTop + (target.offsetHeight + 5),
141
136
  left: targetLeft
@@ -87,21 +87,16 @@ const TargetProviderContainer = ({ children }) => {
87
87
  _.forEach(containerRef.current, (elementRef) => close(elementRef, index));
88
88
  });
89
89
  focusable.addEventListener("blur", () => {
90
+ console.log("onBlur", insideMemory);
90
91
  if (_.some(insideMemory, (i) => i === index)) return;
91
92
  close(containerRef.current[index], index);
92
93
  });
93
- focusable.addEventListener("change", (e) => {
94
- var _a2;
95
- if (!targetElement) return;
96
- e.preventDefault();
97
- targetElement.setAttribute("value", ((_a2 = e.target) == null ? void 0 : _a2.value) || "");
98
- });
99
94
  });
100
95
  }, [targets, inputRef, containerRef]);
101
96
  const getCoords = (target) => {
102
97
  const rect = target.getBoundingClientRect();
103
98
  const targetTop = rect.top + window.scrollY;
104
- const targetLeft = rect.left + window.scrollX;
99
+ const targetLeft = rect.left + window.scrollX + 1;
105
100
  const coords = {
106
101
  top: targetTop + (target.offsetHeight + 5),
107
102
  left: targetLeft
@@ -4,7 +4,7 @@ export interface ITargetProvider extends IBaseProvider {
4
4
  }
5
5
  export interface ITargetConfig {
6
6
  ref: React.RefObject<any>;
7
- component: React.ReactNode;
7
+ component: React.ReactElement;
8
8
  }
9
9
  export interface ITargetConfigCoords {
10
10
  top: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gustavo-valsechi/client",
3
- "version": "1.4.112",
3
+ "version": "1.4.114",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",