@gustavo-valsechi/client 1.4.99 → 1.4.100

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.
@@ -101,24 +101,28 @@ const TargetProviderContainer = ({ children }) => {
101
101
  var _a;
102
102
  const element = (_a = target.ref) == null ? void 0 : _a.current;
103
103
  if (!(element == null ? void 0 : element.addEventListener)) return;
104
+ const focusable = elementFocusable(target, index);
104
105
  element.addEventListener("click", () => {
105
106
  const targetElement = import_lodash.default.find(containerRef.current, (data, i) => i === index);
106
107
  if (!targetElement) return;
107
108
  const styles = window.getComputedStyle(targetElement);
108
- console.log(styles);
109
109
  if (styles.opacity === "1") {
110
110
  close(targetElement);
111
111
  return;
112
112
  }
113
113
  const coords = getCoords(element);
114
114
  open(targetElement, coords);
115
- elementFocusable(target, index).focus();
115
+ focusable.focus();
116
116
  });
117
117
  element.addEventListener("resize", () => {
118
118
  import_lodash.default.forEach(containerRef.current, (elementRef) => close(elementRef));
119
119
  });
120
+ focusable.addEventListener("blur", () => {
121
+ if (inside) return;
122
+ close(containerRef.current[index]);
123
+ });
120
124
  });
121
- }, [targets, inputRef, containerRef]);
125
+ }, [targets, inputRef, containerRef, inside]);
122
126
  const getCoords = (target) => {
123
127
  const rect = target.getBoundingClientRect();
124
128
  const targetTop = rect.top + window.scrollY;
@@ -174,11 +178,7 @@ const TargetProviderContainer = ({ children }) => {
174
178
  "input",
175
179
  {
176
180
  style: { zIndex: "-1", position: "fixed", opacity: "0" },
177
- ref: (element) => inputRef.current[index] = element,
178
- onBlur: () => {
179
- if (inside) return;
180
- close(containerRef.current[index]);
181
- }
181
+ ref: (element) => inputRef.current[index] = element
182
182
  }
183
183
  )
184
184
  ] }, index)
@@ -67,24 +67,28 @@ const TargetProviderContainer = ({ children }) => {
67
67
  var _a;
68
68
  const element = (_a = target.ref) == null ? void 0 : _a.current;
69
69
  if (!(element == null ? void 0 : element.addEventListener)) return;
70
+ const focusable = elementFocusable(target, index);
70
71
  element.addEventListener("click", () => {
71
72
  const targetElement = _.find(containerRef.current, (data, i) => i === index);
72
73
  if (!targetElement) return;
73
74
  const styles = window.getComputedStyle(targetElement);
74
- console.log(styles);
75
75
  if (styles.opacity === "1") {
76
76
  close(targetElement);
77
77
  return;
78
78
  }
79
79
  const coords = getCoords(element);
80
80
  open(targetElement, coords);
81
- elementFocusable(target, index).focus();
81
+ focusable.focus();
82
82
  });
83
83
  element.addEventListener("resize", () => {
84
84
  _.forEach(containerRef.current, (elementRef) => close(elementRef));
85
85
  });
86
+ focusable.addEventListener("blur", () => {
87
+ if (inside) return;
88
+ close(containerRef.current[index]);
89
+ });
86
90
  });
87
- }, [targets, inputRef, containerRef]);
91
+ }, [targets, inputRef, containerRef, inside]);
88
92
  const getCoords = (target) => {
89
93
  const rect = target.getBoundingClientRect();
90
94
  const targetTop = rect.top + window.scrollY;
@@ -140,11 +144,7 @@ const TargetProviderContainer = ({ children }) => {
140
144
  "input",
141
145
  {
142
146
  style: { zIndex: "-1", position: "fixed", opacity: "0" },
143
- ref: (element) => inputRef.current[index] = element,
144
- onBlur: () => {
145
- if (inside) return;
146
- close(containerRef.current[index]);
147
- }
147
+ ref: (element) => inputRef.current[index] = element
148
148
  }
149
149
  )
150
150
  ] }, index)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gustavo-valsechi/client",
3
- "version": "1.4.99",
3
+ "version": "1.4.100",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",