@sio-group/ui-datatable 0.1.3 → 0.1.5

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @sio-group/ui-datatable
2
2
 
3
+ ## 0.1.5
4
+
5
+ ### Patch Changes
6
+
7
+ - Added inline input class
8
+
9
+ ## 0.1.4
10
+
11
+ ### Patch Changes
12
+
13
+ - Bug: Fix action cel behavior
14
+
3
15
  ## 0.1.3
4
16
 
5
17
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -205,13 +205,15 @@ var ActionCell = ({
205
205
  if (dropdownRef.current && triggerRef.current) {
206
206
  const rect = triggerRef.current.getBoundingClientRect();
207
207
  dropdownRef.current.style.left = `${rect.left}px`;
208
- dropdownRef.current.style.top = `${rect.top}px`;
208
+ dropdownRef.current.style.top = `${rect.bottom}px`;
209
209
  }
210
210
  };
211
211
  (0, import_react2.useEffect)(() => {
212
212
  if (!isOpen) return;
213
+ positionDropdown();
213
214
  const handleOutside = (e) => {
214
215
  if (dropdownRef.current?.contains(e.target)) return;
216
+ if (triggerRef.current?.contains(e.target)) return;
215
217
  setIsOpen(false);
216
218
  };
217
219
  document.addEventListener("mousedown", handleOutside, false);
@@ -248,10 +250,7 @@ var ActionCell = ({
248
250
  "aria-label": "Acties",
249
251
  "aria-expanded": isOpen,
250
252
  "aria-haspopup": "menu",
251
- onClick: () => {
252
- setIsOpen(!isOpen);
253
- positionDropdown();
254
- },
253
+ onClick: () => setIsOpen(!isOpen),
255
254
  children: renderMenuIcon ? renderMenuIcon() : "\u22EE"
256
255
  }
257
256
  ),
@@ -368,7 +367,7 @@ var InlineInputCell = ({
368
367
  document.addEventListener("keydown", handleEsc);
369
368
  return () => document.removeEventListener("keydown", handleEsc);
370
369
  }, [setShowEdit]);
371
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_jsx_runtime7.Fragment, { children: showEdit ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("form", { noValidate: true, children: [
370
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "inline-input", children: showEdit ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("form", { noValidate: true, children: [
372
371
  formField.type === "select" || formField.type === "radio" ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
373
372
  "select",
374
373
  {
package/dist/index.js CHANGED
@@ -179,13 +179,15 @@ var ActionCell = ({
179
179
  if (dropdownRef.current && triggerRef.current) {
180
180
  const rect = triggerRef.current.getBoundingClientRect();
181
181
  dropdownRef.current.style.left = `${rect.left}px`;
182
- dropdownRef.current.style.top = `${rect.top}px`;
182
+ dropdownRef.current.style.top = `${rect.bottom}px`;
183
183
  }
184
184
  };
185
185
  useEffect(() => {
186
186
  if (!isOpen) return;
187
+ positionDropdown();
187
188
  const handleOutside = (e) => {
188
189
  if (dropdownRef.current?.contains(e.target)) return;
190
+ if (triggerRef.current?.contains(e.target)) return;
189
191
  setIsOpen(false);
190
192
  };
191
193
  document.addEventListener("mousedown", handleOutside, false);
@@ -222,10 +224,7 @@ var ActionCell = ({
222
224
  "aria-label": "Acties",
223
225
  "aria-expanded": isOpen,
224
226
  "aria-haspopup": "menu",
225
- onClick: () => {
226
- setIsOpen(!isOpen);
227
- positionDropdown();
228
- },
227
+ onClick: () => setIsOpen(!isOpen),
229
228
  children: renderMenuIcon ? renderMenuIcon() : "\u22EE"
230
229
  }
231
230
  ),
@@ -342,7 +341,7 @@ var InlineInputCell = ({
342
341
  document.addEventListener("keydown", handleEsc);
343
342
  return () => document.removeEventListener("keydown", handleEsc);
344
343
  }, [setShowEdit]);
345
- return /* @__PURE__ */ jsx7(Fragment3, { children: showEdit ? /* @__PURE__ */ jsxs4("form", { noValidate: true, children: [
344
+ return /* @__PURE__ */ jsx7("div", { className: "inline-input", children: showEdit ? /* @__PURE__ */ jsxs4("form", { noValidate: true, children: [
346
345
  formField.type === "select" || formField.type === "radio" ? /* @__PURE__ */ jsx7(
347
346
  "select",
348
347
  {
@@ -163,7 +163,7 @@
163
163
  display: inline-block;
164
164
  }
165
165
  .datatable .action-dropdown__menu {
166
- position: absolute;
166
+ position: fixed;
167
167
  display: flex;
168
168
  flex-direction: column;
169
169
  background: var(--sio-datatable-bg);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sio-group/ui-datatable",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -173,7 +173,7 @@
173
173
  display: inline-block;
174
174
 
175
175
  &__menu {
176
- position: absolute;
176
+ position: fixed;
177
177
  display: flex;
178
178
  flex-direction: column;
179
179
  background: var(--sio-datatable-bg);
@@ -15,15 +15,18 @@ export const ActionCell = <T extends { id: string | number }> ({
15
15
  if (dropdownRef.current && triggerRef.current) {
16
16
  const rect: DOMRect = triggerRef.current.getBoundingClientRect();
17
17
  dropdownRef.current.style.left = `${rect.left}px`;
18
- dropdownRef.current.style.top = `${rect.top}px`;
18
+ dropdownRef.current.style.top = `${rect.bottom}px`;
19
19
  }
20
20
  }
21
21
 
22
22
  useEffect(() => {
23
23
  if (!isOpen) return;
24
24
 
25
+ positionDropdown();
26
+
25
27
  const handleOutside = (e: MouseEvent | Event) => {
26
28
  if (dropdownRef.current?.contains(e.target as Node)) return;
29
+ if (triggerRef.current?.contains(e.target as Node)) return;
27
30
  setIsOpen(false);
28
31
  }
29
32
 
@@ -65,10 +68,7 @@ export const ActionCell = <T extends { id: string | number }> ({
65
68
  aria-label="Acties"
66
69
  aria-expanded={isOpen}
67
70
  aria-haspopup="menu"
68
- onClick={() => {
69
- setIsOpen(!isOpen);
70
- positionDropdown();
71
- }}
71
+ onClick={() => setIsOpen(!isOpen)}
72
72
  >
73
73
  {renderMenuIcon ? renderMenuIcon() : '⋮'}
74
74
  </button>
@@ -42,7 +42,7 @@ export const InlineInputCell = <T extends { id: string | number }>({
42
42
  }, [setShowEdit]);
43
43
 
44
44
  return (
45
- <>
45
+ <div className="inline-input">
46
46
  {showEdit ? (
47
47
  <form noValidate>
48
48
  {formField.type === "select" || formField.type === "radio" ? (
@@ -115,6 +115,6 @@ export const InlineInputCell = <T extends { id: string | number }>({
115
115
  </Button>
116
116
  </>
117
117
  )}
118
- </>
118
+ </div>
119
119
  )
120
120
  }