@envisiongroup/porygon 1.0.0-rc.2 → 1.0.0-rc.4

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.
Files changed (24) hide show
  1. package/dist/index.js +23 -20
  2. package/dist/react-components/fields/EFWDatePicker/EFWDatePicker.js +28 -28
  3. package/dist/react-components/fields/EFWTagPicker/EFWTagPicker.js +44 -44
  4. package/dist/react-components/tables/EFWTable/EFWTable.d.ts +1 -1
  5. package/dist/react-components/tables/EFWTable/EFWTable.js +405 -344
  6. package/dist/react-components/tables/EFWTable/EFWTable.types.d.ts +59 -3
  7. package/dist/react-components/tables/EFWTable/components/EFWTableCell/EFWTableCell.js +14 -13
  8. package/dist/react-components/tables/EFWTable/components/EFWTableOverlay/EFWTableOverlay.d.ts +15 -0
  9. package/dist/react-components/tables/EFWTable/components/EFWTableOverlay/EFWTableOverlay.js +253 -0
  10. package/dist/react-components/tables/EFWTable/components/EFWTableOverlay/EFWTableOverlay.types.d.ts +102 -0
  11. package/dist/react-components/tables/EFWTable/components/EFWTableOverlay/index.d.ts +2 -0
  12. package/dist/react-components/tables/EFWTable/components/EFWTableOverlay/index.js +5 -0
  13. package/dist/react-components/tables/EFWTable/hooks/useTableController/useTableController.js +78 -64
  14. package/dist/react-components/tables/EFWTable/index.d.ts +2 -0
  15. package/dist/react-components/tables/EFWTable/index.js +7 -4
  16. package/dist/react-components/tables/EFWTable/utils/cache.js +19 -19
  17. package/package.json +1 -1
  18. package/dist/react-components/tables/EFWTable/components/EFWTableEmpty/EFWTableEmpty.d.ts +0 -3
  19. package/dist/react-components/tables/EFWTable/components/EFWTableEmpty/EFWTableEmpty.js +0 -66
  20. package/dist/react-components/tables/EFWTable/components/EFWTableEmpty/EFWTableEmpty.types.d.ts +0 -16
  21. package/dist/react-components/tables/EFWTable/components/EFWTableEmpty/index.d.ts +0 -2
  22. package/dist/react-components/tables/EFWTable/components/EFWTableEmpty/index.js +0 -4
  23. package/dist/react-components/tables/EFWTable/hooks/useTableController/useTableController copy.d.ts +0 -4
  24. package/dist/react-components/tables/EFWTable/hooks/useTableController/useTableController copy.js +0 -178
@@ -1,19 +1,19 @@
1
- import { jsx as v, jsxs as Ye } from "react/jsx-runtime";
2
- import * as xt from "react";
3
- import { useRef as B, useState as q, useCallback as R, useEffect as T, useMemo as F } from "react";
4
- import { useReactTable as wt, getSortedRowModel as yt, getFilteredRowModel as It, getCoreRowModel as zt } from "@tanstack/react-table";
5
- import { makeStyles as bt, tokens as K, mergeClasses as Et, Checkbox as $e, Card as Ct } from "@fluentui/react-components";
6
- import { useTableSelection as vt } from "./hooks/useTableSelection/useTableSelection.js";
7
- import { renderCellContent as Rt } from "./utils/index.js";
8
- import { useDefaultAddButton as Mt } from "./hooks/useDefaultAddButton/useDefaultAddButton.js";
9
- import { useDefaultUpdateButton as Nt } from "./hooks/useDefaultUpdateButton/useDefaultUpdateButton.js";
10
- import { useDefaultDeleteButton as Wt } from "./hooks/useDefaultDeleteButton/useDefaultDeleteButton.js";
11
- import { generateId as E } from "./utils/general.js";
12
- import { EFWTableCommandBar as kt } from "./components/EFWTableCommandBar/EFWTableCommandBar.js";
13
- import { EFWTableHeader as Tt } from "./components/EFWTableHeader/EFWTableHeader.js";
14
- import { EFWTableBody as _t } from "./components/EFWTableBody/EFWTableBody.js";
15
- import { EFWTableEmpty as At } from "./components/EFWTableEmpty/EFWTableEmpty.js";
16
- const G = {}, Bt = /* @__PURE__ */ new Set(), qe = [], X = [], x = 120, _ = 80, J = 2500, O = 48, Qt = 48, Ft = bt({
1
+ import { jsx as v, jsxs as et } from "react/jsx-runtime";
2
+ import * as kt from "react";
3
+ import { useRef as L, useState as D, useCallback as w, useEffect as A, useMemo as H } from "react";
4
+ import { useReactTable as Tt, getSortedRowModel as At, getFilteredRowModel as Bt, getCoreRowModel as Ft } from "@tanstack/react-table";
5
+ import { makeStyles as Ot, tokens as ee, mergeClasses as Lt, Checkbox as tt, Card as Dt } from "@fluentui/react-components";
6
+ import { useTableSelection as Ht } from "./hooks/useTableSelection/useTableSelection.js";
7
+ import { renderCellContent as jt } from "./utils/index.js";
8
+ import { useDefaultAddButton as Pt } from "./hooks/useDefaultAddButton/useDefaultAddButton.js";
9
+ import { useDefaultUpdateButton as Yt } from "./hooks/useDefaultUpdateButton/useDefaultUpdateButton.js";
10
+ import { useDefaultDeleteButton as $t } from "./hooks/useDefaultDeleteButton/useDefaultDeleteButton.js";
11
+ import { generateId as M } from "./utils/general.js";
12
+ import { EFWTableCommandBar as qt } from "./components/EFWTableCommandBar/EFWTableCommandBar.js";
13
+ import { EFWTableOverlay as nt } from "./components/EFWTableOverlay/EFWTableOverlay.js";
14
+ import { EFWTableHeader as Gt } from "./components/EFWTableHeader/EFWTableHeader.js";
15
+ import { EFWTableBody as Xt } from "./components/EFWTableBody/EFWTableBody.js";
16
+ const Z = {}, Jt = /* @__PURE__ */ new Set(), st = [], Q = [], I = 120, B = 80, U = 2500, j = 48, fn = 48, Kt = Ot({
17
17
  "efw-table": {},
18
18
  /* Transición suave para el box-shadow en las celdas y cabeceras fijas */
19
19
  "efw-table-scroll-container": {
@@ -23,7 +23,7 @@ const G = {}, Bt = /* @__PURE__ */ new Set(), qe = [], X = [], x = 120, _ = 80,
23
23
  transform: "translateZ(0)"
24
24
  },
25
25
  "& .table-header": {
26
- boxShadow: `0px 1px 0 0px ${K.colorNeutralStroke2}`
26
+ boxShadow: `0px 1px 0 0px ${ee.colorNeutralStroke2}`
27
27
  },
28
28
  "& .header-cell": {
29
29
  "&.sticky-column": {
@@ -57,90 +57,97 @@ const G = {}, Bt = /* @__PURE__ */ new Set(), qe = [], X = [], x = 120, _ = 80,
57
57
  }
58
58
  }
59
59
  }
60
- }), Ut = ({
61
- appearance: Ge = "outline",
62
- style: Xe = {},
63
- className: Je = "",
60
+ }), hn = ({
61
+ appearance: rt = "outline",
62
+ style: ct = {},
63
+ className: it = "",
64
64
  fields: f,
65
- items: te,
66
- defaultItems: Ke,
67
- height: ne = 700,
68
- itemSize: Ve = 32,
65
+ items: oe,
66
+ defaultItems: ot,
67
+ height: te = 700,
68
+ itemSize: at = 32,
69
69
  // tableStyle = 'row',
70
- enableSelection: I = !0,
71
- enableCommandBar: V = !0,
72
- defaultSelectedItems: Ze = Bt,
73
- onSelectionChange: Qe,
74
- onRowClick: Z,
75
- resizableColumns: Q = !1,
76
- columnSizing: z = G,
77
- useVirtualization: Ue = !1,
78
- autoSizeColumns: M = !1,
79
- tableRef: et,
80
- onItemsChange: se,
81
- onScroll: re,
82
- addButtonConfig: tt = G,
83
- updateButtonConfig: nt = G,
84
- deleteButtonConfig: st = G,
85
- alwaysButtons: ie = X,
86
- noSelectionButtons: rt = X,
87
- singleSelectionButtons: it = X,
88
- multiSelectionButtons: ce = X,
89
- beforeAddItems: L,
90
- beforeUpdateItems: D,
91
- beforeDeleteItems: H,
92
- columnRenderers: oe,
93
- useDefaultRendererAsFallback: ae = !0
70
+ enableSelection: b = !0,
71
+ enableCommandBar: ne = !0,
72
+ defaultSelectedItems: lt = Jt,
73
+ onSelectionChange: ut,
74
+ onRowClick: se,
75
+ resizableColumns: re = !1,
76
+ columnSizing: z = Z,
77
+ useVirtualization: dt = !1,
78
+ autoSizeColumns: W = !1,
79
+ tableRef: ft,
80
+ onItemsChange: ae,
81
+ onScroll: le,
82
+ addButtonConfig: ht = Z,
83
+ updateButtonConfig: mt = Z,
84
+ deleteButtonConfig: pt = Z,
85
+ alwaysButtons: ue = Q,
86
+ noSelectionButtons: gt = Q,
87
+ singleSelectionButtons: St = Q,
88
+ multiSelectionButtons: de = Q,
89
+ beforeAddItems: P,
90
+ beforeUpdateItems: Y,
91
+ beforeDeleteItems: $,
92
+ columnRenderers: fe,
93
+ useDefaultRendererAsFallback: he = !0,
94
+ // Overlay state props
95
+ overlayState: me,
96
+ defaultOverlayState: wt,
97
+ onOverlayStateChange: _,
98
+ overlayCustomization: F
94
99
  }) => {
95
- const le = Ft(), ct = Et(Je, le["efw-table"]), N = B(!1), ue = te !== void 0, [ot, at] = q(() => (Ke || qe).map((t) => ({
100
+ const pe = Kt(), It = Lt(it, pe["efw-table"]), C = L(!1), ge = oe !== void 0, E = me !== void 0, [xt, q] = D(
101
+ () => wt || { state: "none" }
102
+ ), G = E ? me : xt, [yt, bt] = D(() => (ot || st).map((t) => ({
96
103
  ...t,
97
- id: t.id || E()
98
- }))), b = ue ? te || qe : ot, [S, j] = q(() => {
104
+ _rowId: t._rowId || M()
105
+ }))), R = ge ? oe || st : yt, [S, X] = D(() => {
99
106
  const e = {};
100
107
  return f.forEach((t) => {
101
108
  const n = z[t.internalName];
102
109
  if (n?.width) {
103
- const s = n.minWidth ?? _, r = n.maxWidth ?? J;
110
+ const s = n.minWidth ?? B, r = n.maxWidth ?? U;
104
111
  e[t.internalName] = Math.min(Math.max(n.width ?? 0, s), r);
105
112
  }
106
113
  }), e;
107
- }), de = B(z), [C, fe] = q(0), {
108
- rowSelection: W,
109
- setRowSelection: he,
114
+ }), Se = L(z), [N, we] = D(0), {
115
+ rowSelection: k,
116
+ setRowSelection: Ie,
110
117
  // selectedIndexes,
111
- deselectAll: me,
112
- selectSingle: pe,
113
- toggleMultiple: lt,
118
+ deselectAll: xe,
119
+ selectSingle: ye,
120
+ toggleMultiple: zt,
114
121
  // selectMultiple,
115
- getSelectedItems: ge,
116
- getSelectedRows: Se
117
- } = vt({
118
- initialSelection: Ze,
119
- onSelectionChange: Qe,
120
- enableSelection: I
121
- }), xe = B(null), [P, ut] = q(null), dt = R((e) => {
122
- xe.current = e, ut(e);
123
- }, []), p = B(b);
124
- T(() => {
125
- p.current = b;
126
- }, [b]);
127
- const U = B(/* @__PURE__ */ new Set()), we = F(() => {
122
+ getSelectedItems: be,
123
+ getSelectedRows: ze
124
+ } = Ht({
125
+ initialSelection: lt,
126
+ onSelectionChange: ut,
127
+ enableSelection: b
128
+ }), Ee = L(null), [J, Et] = D(null), _t = w((e) => {
129
+ Ee.current = e, Et(e);
130
+ }, []), p = L(R);
131
+ A(() => {
132
+ p.current = R;
133
+ }, [R]);
134
+ const ce = L(/* @__PURE__ */ new Set()), _e = H(() => {
128
135
  const e = [], t = {};
129
136
  let n = 0;
130
- return I && (e.push("select"), t.select = n, n += O), f.forEach((s) => {
137
+ return b && (e.push("select"), t.select = n, n += j), f.forEach((s) => {
131
138
  const r = z[s.internalName] || {};
132
139
  if (!r.hidden && r.sticky) {
133
140
  e.push(s.internalName), t[s.internalName] = n;
134
- const i = S[s.internalName] || r.width || x;
135
- n += i;
141
+ const c = S[s.internalName] || r.width || I;
142
+ n += c;
136
143
  }
137
144
  }), { stickyColumns: e, stickyPositions: t };
138
- }, [f, I, z, S]), w = F(() => {
145
+ }, [f, b, z, S]), x = H(() => {
139
146
  const e = [];
140
- return I && e.push({
147
+ return b && e.push({
141
148
  id: "select",
142
149
  header: ({ table: t }) => /* @__PURE__ */ v(
143
- $e,
150
+ tt,
144
151
  {
145
152
  shape: "circular",
146
153
  checked: t.getIsAllRowsSelected(),
@@ -149,117 +156,117 @@ const G = {}, Bt = /* @__PURE__ */ new Set(), qe = [], X = [], x = 120, _ = 80,
149
156
  }
150
157
  ),
151
158
  cell: ({ row: t }) => /* @__PURE__ */ v(
152
- $e,
159
+ tt,
153
160
  {
154
161
  shape: "circular",
155
162
  checked: t.getIsSelected(),
156
163
  onChange: (n) => {
157
- n.stopPropagation(), lt(t.index);
164
+ n.stopPropagation(), zt(t.index);
158
165
  },
159
166
  onClick: (n) => n.stopPropagation(),
160
167
  "data-checkbox": "true"
161
168
  }
162
169
  ),
163
- size: O,
164
- minSize: O,
165
- maxSize: O,
170
+ size: j,
171
+ minSize: j,
172
+ maxSize: j,
166
173
  enableResizing: !1
167
174
  }), f.forEach((t) => {
168
175
  const n = z[t.internalName] || {};
169
176
  if (n.hidden)
170
177
  return;
171
- const s = t.typeAsString === "Note" ? x * 2 : x, r = n.width || s, i = n.minWidth || _, a = n.maxWidth || J;
178
+ const s = t.typeAsString === "Note" ? I * 2 : I, r = n.width || s, c = n.minWidth || B, a = n.maxWidth || U;
172
179
  e.push({
173
180
  id: t.internalName,
174
181
  accessorKey: t.internalName,
175
182
  header: t.title || t.internalName,
176
- cell: ({ row: c }) => Rt(
183
+ cell: ({ row: i }) => jt(
177
184
  t,
178
- c.original[t.internalName],
179
- c.original,
180
- c.index,
181
- oe,
182
- ae
185
+ i.original[t.internalName],
186
+ i.original,
187
+ i.index,
188
+ fe,
189
+ he
183
190
  ),
184
- size: Math.min(Math.max(r, i), a),
185
- minSize: i,
191
+ size: Math.min(Math.max(r, c), a),
192
+ minSize: c,
186
193
  maxSize: a,
187
- enableResizing: Q
194
+ enableResizing: re
188
195
  });
189
196
  }), e;
190
197
  }, [
191
198
  f,
192
- I,
193
- Q,
199
+ b,
200
+ re,
194
201
  z,
195
- oe,
196
- ae
202
+ fe,
203
+ he
197
204
  ]);
198
- T(() => {
199
- const e = de.current;
200
- j((t) => {
205
+ A(() => {
206
+ const e = Se.current;
207
+ X((t) => {
201
208
  let n = !1;
202
- const s = { ...t }, r = new Set(f.map((i) => i.internalName));
203
- return Object.keys(s).forEach((i) => {
204
- r.has(i) || (delete s[i], n = !0);
205
- }), f.forEach((i) => {
206
- const a = i.internalName, c = z[a], o = e[a];
207
- if (c?.width !== void 0) {
208
- const u = c.minWidth ?? _, h = c.maxWidth ?? J, d = Math.min(Math.max(c.width, u), h);
209
+ const s = { ...t }, r = new Set(f.map((c) => c.internalName));
210
+ return Object.keys(s).forEach((c) => {
211
+ r.has(c) || (delete s[c], n = !0);
212
+ }), f.forEach((c) => {
213
+ const a = c.internalName, i = z[a], o = e[a];
214
+ if (i?.width !== void 0) {
215
+ const u = i.minWidth ?? B, h = i.maxWidth ?? U, d = Math.min(Math.max(i.width, u), h);
209
216
  s[a] !== d && (s[a] = d, n = !0);
210
217
  } else o?.width !== void 0 && s[a] !== void 0 && (delete s[a], n = !0);
211
218
  }), n ? s : t;
212
- }), de.current = z;
219
+ }), Se.current = z;
213
220
  }, [z, f]);
214
- const Y = F(() => w.reduce((e, t) => {
215
- const s = f.find((i) => i.internalName === t.id)?.typeAsString === "Note" ? x * 2 : x, r = S[t.id] || (typeof t.size == "number" ? t.size : s);
221
+ const K = H(() => x.reduce((e, t) => {
222
+ const s = f.find((c) => c.internalName === t.id)?.typeAsString === "Note" ? I * 2 : I, r = S[t.id] || (typeof t.size == "number" ? t.size : s);
216
223
  return e + r;
217
- }, 0), [w, S, f]), ye = wt({
218
- data: b,
219
- columns: w,
224
+ }, 0), [x, S, f]), Re = Tt({
225
+ data: R,
226
+ columns: x,
220
227
  state: {
221
- rowSelection: W,
228
+ rowSelection: k,
222
229
  columnSizing: S
223
230
  },
224
- onRowSelectionChange: he,
231
+ onRowSelectionChange: Ie,
225
232
  onColumnSizingChange: (e) => {
226
- j((t) => {
233
+ X((t) => {
227
234
  const n = typeof e == "function" ? e(t) : e, s = {};
228
235
  return Object.keys(n).forEach((r) => {
229
- const i = w.find((a) => a.id === r);
230
- if (i) {
231
- const a = i.minSize || _, c = i.maxSize || J;
232
- N.current ? s[r] = Math.max(n[r], a) : s[r] = Math.min(Math.max(n[r], a), c);
236
+ const c = x.find((a) => a.id === r);
237
+ if (c) {
238
+ const a = c.minSize || B, i = c.maxSize || U;
239
+ C.current ? s[r] = Math.max(n[r], a) : s[r] = Math.min(Math.max(n[r], a), i);
233
240
  }
234
241
  }), { ...t, ...s };
235
242
  });
236
243
  },
237
244
  //getRowId: row => row.id as string,
238
- getCoreRowModel: zt(),
239
- getFilteredRowModel: It(),
240
- getSortedRowModel: yt(),
245
+ getCoreRowModel: Ft(),
246
+ getFilteredRowModel: Bt(),
247
+ getSortedRowModel: At(),
241
248
  columnResizeMode: "onChange",
242
249
  enableRowSelection: !0,
243
- enableMultiRowSelection: I
250
+ enableMultiRowSelection: b
244
251
  });
245
- T(() => {
252
+ A(() => {
246
253
  const e = /* @__PURE__ */ new Set();
247
- Object.keys(W).forEach((t) => {
248
- if (W[t]) {
254
+ Object.keys(k).forEach((t) => {
255
+ if (k[t]) {
249
256
  const n = parseInt(t), s = p.current[n];
250
- s?.id && e.add(s.id);
257
+ s?._rowId && e.add(s._rowId);
251
258
  }
252
- }), U.current = e;
253
- }, [W]);
254
- const ft = R((e) => {
255
- re?.(e);
256
- }, [re]), Ie = (e) => {
259
+ }), ce.current = e;
260
+ }, [k]);
261
+ const Rt = w((e) => {
262
+ le?.(e);
263
+ }, [le]), ve = (e) => {
257
264
  const t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set();
258
- return Object.keys(W).forEach((r) => {
259
- if (!W[r])
265
+ return Object.keys(k).forEach((r) => {
266
+ if (!k[r])
260
267
  return;
261
- const i = Number(r), a = e[i];
262
- a && (s.add(i), a.id && t.add(a.id), n.add(a));
268
+ const c = Number(r), a = e[c];
269
+ a && (s.add(c), a._rowId && t.add(a._rowId), n.add(a));
263
270
  }), {
264
271
  hasSelection: t.size > 0 || n.size > 0 || s.size > 0,
265
272
  selectedIds: t,
@@ -267,39 +274,39 @@ const G = {}, Bt = /* @__PURE__ */ new Set(), qe = [], X = [], x = 120, _ = 80,
267
274
  selectedIndexes: s,
268
275
  sourceLength: e.length
269
276
  };
270
- }, ze = (e, t) => {
277
+ }, Me = (e, t) => {
271
278
  if (!t.hasSelection)
272
279
  return;
273
280
  const n = t.sourceLength !== e.length, s = {};
274
- e.forEach((r, i) => {
281
+ e.forEach((r, c) => {
275
282
  if (!r)
276
283
  return;
277
- const a = r.id ? t.selectedIds.has(r.id) : !1, c = t.selectedRefs.has(r), o = !r.id && !n && t.selectedIndexes.has(i);
278
- (a || c || o) && (s[i.toString()] = !0);
279
- }), he(s);
284
+ const a = r._rowId ? t.selectedIds.has(r._rowId) : !1, i = t.selectedRefs.has(r), o = !r._rowId && !n && t.selectedIndexes.has(c);
285
+ (a || i || o) && (s[c.toString()] = !0);
286
+ }), Ie(s);
280
287
  }, g = (e) => {
281
- if (ue) {
282
- const t = b, n = typeof e == "function" ? e(t) : e;
288
+ if (ge) {
289
+ const t = R, n = typeof e == "function" ? e(t) : e;
283
290
  p.current = n;
284
- const s = Ie(t);
285
- U.current = s.selectedIds, ze(n, s), se?.(n);
291
+ const s = ve(t);
292
+ ce.current = s.selectedIds, Me(n, s), ae?.(n);
286
293
  return;
287
294
  }
288
- at((t) => {
295
+ bt((t) => {
289
296
  const n = typeof e == "function" ? e(t) : e;
290
297
  p.current = n;
291
- const s = Ie(t);
292
- return U.current = s.selectedIds, ze(n, s), se?.(n), n;
298
+ const s = ve(t);
299
+ return ce.current = s.selectedIds, Me(n, s), ae?.(n), n;
293
300
  });
294
- }, be = R(() => f, [f]), Ee = async (e) => {
301
+ }, Ne = w(() => f, [f]), We = async (e) => {
295
302
  try {
296
- if (L) {
297
- const t = { id: E(), ...e }, n = await L([t], y);
303
+ if (P) {
304
+ const t = { _rowId: M(), ...e }, n = await P([t], y);
298
305
  if (n) {
299
306
  if (n.successful.length > 0) {
300
307
  const s = n.successful.map((r) => {
301
- const i = r.item;
302
- return i.id ? i : { ...i, id: E() };
308
+ const c = r.item;
309
+ return c._rowId ? c : { ...c, _rowId: M() };
303
310
  });
304
311
  g((r) => [...s, ...r]);
305
312
  }
@@ -310,7 +317,7 @@ const G = {}, Bt = /* @__PURE__ */ new Set(), qe = [], X = [], x = 120, _ = 80,
310
317
  failed: []
311
318
  };
312
319
  } else {
313
- const t = { id: E(), ...e };
320
+ const t = { _rowId: M(), ...e };
314
321
  return g((n) => [t, ...n]), {
315
322
  successful: [{ index: 0, item: t }],
316
323
  failed: []
@@ -329,16 +336,16 @@ const G = {}, Bt = /* @__PURE__ */ new Set(), qe = [], X = [], x = 120, _ = 80,
329
336
  failed: []
330
337
  };
331
338
  try {
332
- if (L) {
339
+ if (P) {
333
340
  const t = e.map((s) => ({
334
- id: E(),
341
+ _rowId: M(),
335
342
  ...s
336
- })), n = await L(t, y);
343
+ })), n = await P(t, y);
337
344
  if (n) {
338
345
  if (n.successful.length > 0) {
339
346
  const s = n.successful.map((r) => {
340
- const i = r.item;
341
- return i.id ? i : { ...i, id: E() };
347
+ const c = r.item;
348
+ return c._rowId ? c : { ...c, _rowId: M() };
342
349
  });
343
350
  g((r) => [...s, ...r]);
344
351
  }
@@ -350,7 +357,7 @@ const G = {}, Bt = /* @__PURE__ */ new Set(), qe = [], X = [], x = 120, _ = 80,
350
357
  };
351
358
  } else {
352
359
  const t = e.map((n) => ({
353
- id: E(),
360
+ _rowId: M(),
354
361
  ...n
355
362
  }));
356
363
  return g((n) => [...t, ...n]), {
@@ -368,7 +375,7 @@ const G = {}, Bt = /* @__PURE__ */ new Set(), qe = [], X = [], x = 120, _ = 80,
368
375
  }))
369
376
  };
370
377
  }
371
- }, ve = async (e, t) => {
378
+ }, ke = async (e, t) => {
372
379
  const n = p.current;
373
380
  if (e < 0 || e >= n.length)
374
381
  return {
@@ -376,19 +383,19 @@ const G = {}, Bt = /* @__PURE__ */ new Set(), qe = [], X = [], x = 120, _ = 80,
376
383
  failed: [{ index: e, item: t, error: "Invalid index" }]
377
384
  };
378
385
  try {
379
- if (D) {
380
- const r = await D([{ index: e, item: t }], y);
386
+ if (Y) {
387
+ const r = await Y([{ index: e, item: t }], y);
381
388
  if (r)
382
- return r.successful.length && g((i) => {
383
- const a = [...i];
384
- return r.successful.forEach(({ index: c, item: o }) => a[c] = o), a;
389
+ return r.successful.length && g((c) => {
390
+ const a = [...c];
391
+ return r.successful.forEach(({ index: i, item: o }) => a[i] = o), a;
385
392
  }), r;
386
393
  }
387
394
  let s;
388
395
  return g((r) => {
389
396
  s = { ...r[e], ...t };
390
- const i = [...r];
391
- return i[e] = s, i;
397
+ const c = [...r];
398
+ return c[e] = s, c;
392
399
  }), { successful: [{ index: e, item: s }], failed: [] };
393
400
  } catch (s) {
394
401
  return {
@@ -396,44 +403,44 @@ const G = {}, Bt = /* @__PURE__ */ new Set(), qe = [], X = [], x = 120, _ = 80,
396
403
  failed: [{ index: e, item: t, error: String(s) }]
397
404
  };
398
405
  }
399
- }, Re = async (e) => {
406
+ }, Te = async (e) => {
400
407
  if (!e.length) return { successful: [], failed: [] };
401
- const t = p.current, n = (i) => i >= 0 && i < t.length, s = e.filter(({ index: i }) => !n(i)).map(({ index: i, item: a }) => ({ index: i, item: a, error: "Invalid index" })), r = e.filter(({ index: i }) => n(i));
408
+ const t = p.current, n = (c) => c >= 0 && c < t.length, s = e.filter(({ index: c }) => !n(c)).map(({ index: c, item: a }) => ({ index: c, item: a, error: "Invalid index" })), r = e.filter(({ index: c }) => n(c));
402
409
  try {
403
- if (D) {
404
- const c = await D(e, y);
405
- if (c) {
406
- const o = c.successful.filter(({ index: l }) => n(l));
410
+ if (Y) {
411
+ const i = await Y(e, y);
412
+ if (i) {
413
+ const o = i.successful.filter(({ index: l }) => n(l));
407
414
  o.length && g((l) => {
408
- const k = [...l];
409
- return o.forEach(({ index: m, item: A }) => k[m] = A), k;
415
+ const T = [...l];
416
+ return o.forEach(({ index: m, item: O }) => T[m] = O), T;
410
417
  });
411
- const u = new Set(c.failed.map((l) => l.index)), h = [...c.failed];
418
+ const u = new Set(i.failed.map((l) => l.index)), h = [...i.failed];
412
419
  return s.forEach((l) => {
413
420
  u.has(l.index) || h.push(l);
414
- }), c.successful.filter(({ index: l }) => !n(l)).map(({ index: l, item: k }) => ({ index: l, item: k, error: "Invalid index" })).forEach((l) => {
421
+ }), i.successful.filter(({ index: l }) => !n(l)).map(({ index: l, item: T }) => ({ index: l, item: T, error: "Invalid index" })).forEach((l) => {
415
422
  u.has(l.index) || h.push(l);
416
423
  }), { successful: o, failed: h };
417
424
  }
418
425
  }
419
- const i = [], a = [...s];
420
- return g((c) => {
421
- const o = [...c];
426
+ const c = [], a = [...s];
427
+ return g((i) => {
428
+ const o = [...i];
422
429
  return r.forEach(({ index: u, item: h }) => {
423
- o[u] = { ...o[u], ...h }, i.push({ index: u, item: o[u] });
430
+ o[u] = { ...o[u], ...h }, c.push({ index: u, item: o[u] });
424
431
  }), o;
425
- }), { successful: i, failed: a };
426
- } catch (i) {
432
+ }), { successful: c, failed: a };
433
+ } catch (c) {
427
434
  return {
428
435
  successful: [],
429
- failed: e.map(({ index: a, item: c }) => ({
436
+ failed: e.map(({ index: a, item: i }) => ({
430
437
  index: a,
431
- item: c,
432
- error: String(i)
438
+ item: i,
439
+ error: String(c)
433
440
  }))
434
441
  };
435
442
  }
436
- }, Me = async (e) => {
443
+ }, Ae = async (e) => {
437
444
  const t = p.current;
438
445
  if (e < 0 || e >= t.length)
439
446
  return {
@@ -441,33 +448,33 @@ const G = {}, Bt = /* @__PURE__ */ new Set(), qe = [], X = [], x = 120, _ = 80,
441
448
  failed: [{ index: e, error: "Invalid index" }]
442
449
  };
443
450
  try {
444
- if (H) {
445
- const s = b[e], r = await H([{ index: e, item: s }], y);
451
+ if ($) {
452
+ const s = R[e], r = await $([{ index: e, item: s }], y);
446
453
  if (r)
447
- return r.successful.length && g((i) => i.filter((a, c) => c !== e)), r;
454
+ return r.successful.length && g((c) => c.filter((a, i) => i !== e)), r;
448
455
  }
449
456
  let n;
450
- return g((s) => (n = s[e], s.filter((r, i) => i !== e))), { successful: [{ index: e, item: n }], failed: [] };
457
+ return g((s) => (n = s[e], s.filter((r, c) => c !== e))), { successful: [{ index: e, item: n }], failed: [] };
451
458
  } catch (n) {
452
459
  return {
453
460
  successful: [],
454
461
  failed: [{ index: e, error: String(n) }]
455
462
  };
456
463
  }
457
- }, Ne = async (e) => {
464
+ }, Be = async (e) => {
458
465
  if (!e.length) return { successful: [], failed: [] };
459
466
  const t = p.current, n = Array.from(new Set(e)), { validIndexes: s, invalidFailures: r } = n.reduce(
460
- (c, o) => (o >= 0 && o < t.length ? c.validIndexes.push(o) : c.invalidFailures.push({ index: o, error: "Invalid index" }), c),
467
+ (i, o) => (o >= 0 && o < t.length ? i.validIndexes.push(o) : i.invalidFailures.push({ index: o, error: "Invalid index" }), i),
461
468
  { validIndexes: [], invalidFailures: [] }
462
- ), i = n.map((c) => ({ index: c, item: b[c] })), a = new Set(s);
469
+ ), c = n.map((i) => ({ index: i, item: R[i] })), a = new Set(s);
463
470
  try {
464
- if (H) {
465
- const u = await H(i, y);
471
+ if ($) {
472
+ const u = await $(c, y);
466
473
  if (u) {
467
474
  const h = u.successful.filter(({ index: m }) => a.has(m));
468
475
  if (h.length) {
469
- const m = new Set(h.map((A) => A.index));
470
- g((A) => A.filter((Ot, St) => !m.has(St)));
476
+ const m = new Set(h.map((O) => O.index));
477
+ g((O) => O.filter((Vt, Ct) => !m.has(Ct)));
471
478
  }
472
479
  const d = new Set(u.failed.map((m) => m.index)), l = [...u.failed];
473
480
  return r.forEach((m) => {
@@ -477,204 +484,258 @@ const G = {}, Bt = /* @__PURE__ */ new Set(), qe = [], X = [], x = 120, _ = 80,
477
484
  }), { successful: h, failed: l };
478
485
  }
479
486
  }
480
- const c = new Set(s), o = [];
487
+ const i = new Set(s), o = [];
481
488
  return g((u) => {
482
489
  const h = [];
483
490
  return u.forEach((d, l) => {
484
- c.has(l) ? o.push({ index: l, item: d }) : h.push(d);
491
+ i.has(l) ? o.push({ index: l, item: d }) : h.push(d);
485
492
  }), h;
486
493
  }), { successful: o, failed: r };
487
- } catch (c) {
494
+ } catch (i) {
488
495
  return {
489
496
  successful: [],
490
- failed: n.map((o) => ({ index: o, error: String(c) }))
497
+ failed: n.map((o) => ({ index: o, error: String(i) }))
491
498
  };
492
499
  }
493
- }, We = R((e) => p.current.find((t) => t.id === e), []), ke = (e) => p.current[e], Te = (e) => {
500
+ }, Fe = w((e) => p.current.find((t) => t._rowId === e), []), Oe = (e) => p.current[e], Le = (e) => {
494
501
  g(
495
- e.map((t) => ({ ...t, id: t.id ?? E() }))
502
+ e.map((t) => ({ ...t, _rowId: t._rowId ?? M() }))
496
503
  );
497
- }, _e = () => {
504
+ }, De = () => {
498
505
  g([]);
499
- }, Ae = (e) => p.current.findIndex((t) => t.id === e), Be = (e) => p.current.some((t) => t.id === e), Fe = () => p.current.length, Oe = () => [...p.current], Le = R(() => ge(p.current), [ge]), De = R(() => Se(p.current), [Se]), y = F(() => ({
500
- getFields: be,
501
- addItem: Ee,
506
+ }, He = (e) => p.current.findIndex((t) => t._rowId === e), je = (e) => p.current.some((t) => t._rowId === e), Pe = () => p.current.length, Ye = () => [...p.current], $e = w(() => be(p.current), [be]), qe = w(() => ze(p.current), [ze]), Ge = w((e) => {
507
+ const t = {
508
+ state: "loading",
509
+ message: e
510
+ };
511
+ E || q(t), _?.(t);
512
+ }, [E, _]), Xe = w((e, t) => {
513
+ const n = {
514
+ state: "error",
515
+ message: e,
516
+ onRetry: t
517
+ };
518
+ E || q(n), _?.(n);
519
+ }, [E, _]), Je = w((e) => {
520
+ const t = {
521
+ state: e ? "partial-loading" : "none"
522
+ };
523
+ E || q(t), _?.(t);
524
+ }, [E, _]), Ke = w(() => {
525
+ const e = { state: "none" };
526
+ E || q(e), _?.(e);
527
+ }, [E, _]), Ve = w(() => G.state, [G.state]), y = H(() => ({
528
+ getFields: Ne,
529
+ addItem: We,
502
530
  addItems: Ce,
503
- updateItem: ve,
504
- updateItems: Re,
505
- deleteItem: Me,
506
- deleteItems: Ne,
507
- getItem: We,
508
- getItemByIndex: ke,
509
- getItems: Oe,
510
- getItemsCount: Fe,
511
- itemExists: Be,
512
- getItemIndex: Ae,
513
- replaceAllItems: Te,
514
- clearItems: _e,
515
- deselectAllRows: me,
516
- getSelectedItems: Le,
517
- getSelectedRows: De
531
+ updateItem: ke,
532
+ updateItems: Te,
533
+ deleteItem: Ae,
534
+ deleteItems: Be,
535
+ getItem: Fe,
536
+ getItemByIndex: Oe,
537
+ getItems: Ye,
538
+ getItemsCount: Pe,
539
+ itemExists: je,
540
+ getItemIndex: He,
541
+ replaceAllItems: Le,
542
+ clearItems: De,
543
+ deselectAllRows: xe,
544
+ getSelectedItems: $e,
545
+ getSelectedRows: qe,
546
+ // Overlay methods
547
+ setLoading: Ge,
548
+ setError: Xe,
549
+ setPartialLoading: Je,
550
+ clearOverlay: Ke,
551
+ getOverlayState: Ve
518
552
  }), [
519
- Ee,
520
- Ce,
521
- _e,
522
- Me,
523
- Ne,
524
- me,
525
- f,
526
- be,
527
553
  We,
528
- ke,
554
+ Ce,
555
+ De,
556
+ Ke,
529
557
  Ae,
530
- Oe,
558
+ Be,
559
+ xe,
560
+ f,
561
+ Ne,
531
562
  Fe,
563
+ Oe,
564
+ He,
565
+ Ye,
566
+ Pe,
567
+ Ve,
568
+ $e,
569
+ qe,
570
+ je,
532
571
  Le,
533
- De,
534
- Be,
535
- Te,
536
- ve,
537
- Re
572
+ Xe,
573
+ Ge,
574
+ Je,
575
+ ke,
576
+ Te
538
577
  ]);
539
- xt.useImperativeHandle(et, () => y, [y]);
540
- const ht = R((e, t) => {
541
- t?.target && t.target.closest('[data-checkbox="true"]') || (I && pe(e.index), Z && Z(e.original, e.index));
542
- }, [I, Z, pe]), He = F(() => w.map((e) => {
543
- const n = f.find((r) => r.internalName === e.id)?.typeAsString === "Note" ? x * 2 : x, s = S[e.id] || (typeof e.size == "number" ? e.size : n);
544
- return e.id === "select" ? `${O}px` : `${s}px`;
545
- }).join(" "), [w, S, f]);
546
- T(() => {
547
- if (!P) return;
578
+ kt.useImperativeHandle(ft, () => y, [y]);
579
+ const vt = w((e, t) => {
580
+ t?.target && t.target.closest('[data-checkbox="true"]') || (b && ye(e.index), se && se(e.original, e.index));
581
+ }, [b, se, ye]), Ze = H(() => x.map((e) => {
582
+ const n = f.find((r) => r.internalName === e.id)?.typeAsString === "Note" ? I * 2 : I, s = S[e.id] || (typeof e.size == "number" ? e.size : n);
583
+ return e.id === "select" ? `${j}px` : `${s}px`;
584
+ }).join(" "), [x, S, f]);
585
+ A(() => {
586
+ if (!J) return;
548
587
  const e = new ResizeObserver((t) => {
549
588
  for (const n of t)
550
- fe(n.contentRect.width);
589
+ we(n.contentRect.width);
551
590
  });
552
- return e.observe(P), fe(P.clientWidth), () => e.disconnect();
553
- }, [P]), T(() => {
554
- if (!M || C <= 0 || N.current) return;
591
+ return e.observe(J), we(J.clientWidth), () => e.disconnect();
592
+ }, [J]), A(() => {
593
+ if (!W || N <= 0 || C.current) return;
555
594
  let e = 0, t = 0;
556
595
  const n = [];
557
- if (w.forEach((o) => {
558
- const h = f.find((m) => m.internalName === o.id)?.typeAsString === "Note" ? x * 2 : x, d = S[o.id] || (typeof o.size == "number" ? o.size : h);
596
+ if (x.forEach((o) => {
597
+ const h = f.find((m) => m.internalName === o.id)?.typeAsString === "Note" ? I * 2 : I, d = S[o.id] || (typeof o.size == "number" ? o.size : h);
559
598
  !(o.id === "select") ? (t += d, n.push(o)) : e += d;
560
599
  }), n.length === 0)
561
600
  return;
562
601
  const s = e + t;
563
- if (Math.abs(s - C) < 1) return;
564
- const r = C - e, i = r / t, a = { ...S };
565
- let c = 0;
602
+ if (Math.abs(s - N) < 1) return;
603
+ const r = N - e, c = r / t, a = { ...S };
604
+ let i = 0;
566
605
  n.forEach((o, u) => {
567
- const h = S[o.id] || (typeof o.size == "number" ? o.size : x), d = o.minSize || _;
606
+ const h = S[o.id] || (typeof o.size == "number" ? o.size : I), d = o.minSize || B;
568
607
  let l;
569
- u === n.length - 1 ? l = r - c : l = Math.round(h * i), l = Math.max(d, l), a[o.id] = l, c += l;
570
- }), N.current = !0, j(a), requestAnimationFrame(() => {
571
- N.current = !1;
608
+ u === n.length - 1 ? l = r - i : l = Math.round(h * c), l = Math.max(d, l), a[o.id] = l, i += l;
609
+ }), C.current = !0, X(a), requestAnimationFrame(() => {
610
+ C.current = !1;
572
611
  });
573
- }, [M, C, w, f]), T(() => {
574
- if (M || C <= 0)
612
+ }, [W, N, x, f]), A(() => {
613
+ if (W || N <= 0)
575
614
  return;
576
- const e = C - Y;
615
+ const e = N - K;
577
616
  if (Math.abs(e) < 1)
578
617
  return;
579
- const t = w.filter((d) => d.id && d.id !== "select");
618
+ const t = x.filter((d) => d.id && d.id !== "select");
580
619
  if (t.length === 0) return;
581
- const n = t[t.length - 1], s = n.id, i = f.find((d) => d.internalName === s)?.typeAsString === "Note" ? x * 2 : x, c = (S[s] || (typeof n.size == "number" ? n.size : i)) + e, o = n.minSize || _, u = Math.max(o, c), h = S[s];
582
- Math.abs(h - u) < 1 || (N.current = !0, j((d) => ({
620
+ const n = t[t.length - 1], s = n.id, c = f.find((d) => d.internalName === s)?.typeAsString === "Note" ? I * 2 : I, i = (S[s] || (typeof n.size == "number" ? n.size : c)) + e, o = n.minSize || B, u = Math.max(o, i), h = S[s];
621
+ Math.abs(h - u) < 1 || (C.current = !0, X((d) => ({
583
622
  ...d,
584
623
  [s]: u
585
- })), N.current = !1);
586
- }, [M, C, Y, w, f]);
587
- const je = Mt(tt), Pe = Nt(nt), $ = Wt(st), mt = je ? [je, ...ie] : ie, ee = [];
588
- Pe && ee.push(Pe), $ && ee.push($);
589
- const pt = [...ee, ...it], gt = $ ? [$, ...ce] : ce;
590
- return /* @__PURE__ */ Ye(
591
- Ct,
624
+ })), C.current = !1);
625
+ }, [W, N, K, x, f]);
626
+ const Qe = Pt(ht), Ue = Yt(mt), V = $t(pt), Mt = Qe ? [Qe, ...ue] : ue, ie = [];
627
+ Ue && ie.push(Ue), V && ie.push(V);
628
+ const Nt = [...ie, ...St], Wt = V ? [V, ...de] : de;
629
+ return /* @__PURE__ */ et(
630
+ Dt,
592
631
  {
593
632
  size: "small",
594
- appearance: Ge,
595
- className: ct,
633
+ appearance: rt,
634
+ className: It,
596
635
  style: {
597
- backgroundColor: K.colorNeutralBackground1,
636
+ backgroundColor: ee.colorNeutralBackground1,
598
637
  maxWidth: "100%",
599
638
  // margin: "20px 20px",
600
639
  padding: "0px",
601
640
  gap: "0px",
602
- ...Xe
641
+ ...ct
603
642
  },
604
643
  children: [
605
- V && /* @__PURE__ */ v(
606
- kt,
644
+ ne && /* @__PURE__ */ v(
645
+ qt,
607
646
  {
608
647
  tableMethods: y,
609
- alwaysButtons: mt,
610
- noSelectionButtons: rt,
611
- singleSelectionButtons: pt,
612
- multiSelectionButtons: gt,
648
+ alwaysButtons: Mt,
649
+ noSelectionButtons: gt,
650
+ singleSelectionButtons: Nt,
651
+ multiSelectionButtons: Wt,
613
652
  selectedRows: y.getSelectedRows()
614
653
  }
615
654
  ),
616
- b.length > 0 ? /* @__PURE__ */ v(
617
- "div",
618
- {
619
- ref: dt,
620
- onScroll: ft,
621
- className: le["efw-table-scroll-container"],
622
- style: {
623
- maxHeight: V ? ne - 40 : ne,
624
- overflowY: "auto",
625
- overflowX: "auto",
626
- border: `1px solid ${K.colorNeutralStroke2}`,
627
- borderTop: V ? "none" : `1px solid ${K.colorNeutralStroke2}`,
628
- position: "relative"
629
- },
630
- children: /* @__PURE__ */ Ye(
631
- "div",
632
- {
633
- className: "table-container",
634
- style: {
635
- minWidth: M ? "100%" : Y,
636
- width: M ? "100%" : Math.max(Y, 300)
637
- },
638
- children: [
639
- /* @__PURE__ */ v(
640
- Tt,
641
- {
642
- table: ye,
643
- gridTemplateColumns: He,
644
- columnSizing: S,
645
- stickyColumnsInfo: we,
646
- resizableColumns: Q
647
- }
648
- ),
649
- /* @__PURE__ */ v(
650
- _t,
651
- {
652
- table: ye,
653
- fields: f,
654
- tableContainerRef: xe,
655
- useVirtualization: Ue,
656
- enableSelection: I,
657
- itemSize: Ve,
658
- gridTemplateColumns: He,
659
- columnSizing: S,
660
- stickyColumnsInfo: we,
661
- onRowClick: ht
662
- }
663
- )
664
- ]
665
- }
666
- )
667
- }
668
- ) : /* @__PURE__ */ v(At, { height: 250 })
655
+ (() => {
656
+ const e = G.state !== "none" ? G : R.length === 0 ? {
657
+ state: "empty",
658
+ message: F?.empty?.title,
659
+ description: F?.empty?.description,
660
+ imageUrl: F?.empty?.imageUrl
661
+ } : { state: "none" }, t = /* @__PURE__ */ v(
662
+ "div",
663
+ {
664
+ ref: _t,
665
+ onScroll: Rt,
666
+ className: pe["efw-table-scroll-container"],
667
+ style: {
668
+ maxHeight: ne ? te - 40 : te,
669
+ overflowY: "auto",
670
+ overflowX: "auto",
671
+ border: `1px solid ${ee.colorNeutralStroke2}`,
672
+ borderTop: ne ? "none" : `1px solid ${ee.colorNeutralStroke2}`,
673
+ position: "relative"
674
+ },
675
+ children: /* @__PURE__ */ et(
676
+ "div",
677
+ {
678
+ className: "table-container",
679
+ style: {
680
+ minWidth: W ? "100%" : K,
681
+ width: W ? "100%" : Math.max(K, 300)
682
+ },
683
+ children: [
684
+ /* @__PURE__ */ v(
685
+ Gt,
686
+ {
687
+ table: Re,
688
+ gridTemplateColumns: Ze,
689
+ columnSizing: S,
690
+ stickyColumnsInfo: _e,
691
+ resizableColumns: re
692
+ }
693
+ ),
694
+ /* @__PURE__ */ v(
695
+ Xt,
696
+ {
697
+ table: Re,
698
+ fields: f,
699
+ tableContainerRef: Ee,
700
+ useVirtualization: dt,
701
+ enableSelection: b,
702
+ itemSize: at,
703
+ gridTemplateColumns: Ze,
704
+ columnSizing: S,
705
+ stickyColumnsInfo: _e,
706
+ onRowClick: vt
707
+ }
708
+ )
709
+ ]
710
+ }
711
+ )
712
+ }
713
+ );
714
+ return e.state === "partial-loading" ? /* @__PURE__ */ v(
715
+ nt,
716
+ {
717
+ config: e,
718
+ customization: F,
719
+ children: t
720
+ }
721
+ ) : e.state !== "none" ? /* @__PURE__ */ v(
722
+ nt,
723
+ {
724
+ config: e,
725
+ height: te,
726
+ customization: F
727
+ }
728
+ ) : t;
729
+ })()
669
730
  ]
670
731
  }
671
732
  );
672
733
  };
673
734
  export {
674
- x as COLS_DEF_WIDTH,
675
- J as COLS_MAX_WIDTH,
676
- _ as COLS_MIN_WIDTH,
677
- Ut as EFWTable,
678
- Qt as SELECTOR_CELL_HEIGHT,
679
- O as SELECTOR_CELL_WIDTH
735
+ I as COLS_DEF_WIDTH,
736
+ U as COLS_MAX_WIDTH,
737
+ B as COLS_MIN_WIDTH,
738
+ hn as EFWTable,
739
+ fn as SELECTOR_CELL_HEIGHT,
740
+ j as SELECTOR_CELL_WIDTH
680
741
  };