@envisiongroup/porygon 1.0.0-rc.21 → 1.0.0-rc.23

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.
@@ -1,21 +1,21 @@
1
- import { jsx as L, jsxs as He } from "react/jsx-runtime";
2
- import * as Rn from "react";
3
- import { useRef as S, useState as be, useCallback as d, useEffect as X, useLayoutEffect as Yt, useMemo as te } from "react";
4
- import { useReactTable as yn, getSortedRowModel as En, getFilteredRowModel as zn, getCoreRowModel as Tn } from "@tanstack/react-table";
5
- import { makeStyles as Mn, tokens as se, mergeClasses as Nn, Card as _n, Checkbox as en, Spinner as Wn } from "@fluentui/react-components";
6
- import { useTableSelection as kn } from "./hooks/useTableSelection/useTableSelection.js";
7
- import { renderCellContent as Ln } from "./utils/index.js";
8
- import { useDefaultAddButton as Fn } from "./hooks/useDefaultAddButton/useDefaultAddButton.js";
9
- import { useDefaultUpdateButton as An } from "./hooks/useDefaultUpdateButton/useDefaultUpdateButton.js";
10
- import { useDefaultDeleteButton as Bn } from "./hooks/useDefaultDeleteButton/useDefaultDeleteButton.js";
11
- import { useStableColumnRenderers as Dn } from "./hooks/useStableColumnRenderers/useStableColumnRenderers.js";
12
- import { generateId as Gt } from "./utils/general.js";
13
- import { addRowId as Ee, ensureItemRowId as Kt } from "./utils/typeHelpers.js";
14
- import { EFWTableCommandBar as Hn } from "./components/EFWTableCommandBar/EFWTableCommandBar.js";
15
- import { EFWTableOverlay as Xt } from "./components/EFWTableOverlay/EFWTableOverlay.js";
16
- import { EFWTableHeader as On } from "./components/EFWTableHeader/EFWTableHeader.js";
17
- import { EFWTableBody as Pn } from "./components/EFWTableBody/EFWTableBody.js";
18
- const ze = {}, jn = /* @__PURE__ */ new Set(), Jt = [], Te = [], W = 120, ce = 120, Me = 2500, Ce = 45, lr = 45, Vt = 500;
1
+ import { jsx as L, jsxs as Oe } from "react/jsx-runtime";
2
+ import * as yn from "react";
3
+ import { useRef as S, useState as be, useCallback as d, useEffect as X, useLayoutEffect as Gt, useMemo as te } from "react";
4
+ import { useReactTable as En, getSortedRowModel as zn, getFilteredRowModel as Tn, getCoreRowModel as Mn } from "@tanstack/react-table";
5
+ import { makeStyles as Nn, tokens as se, mergeClasses as _n, Card as Wn, Checkbox as tn, Spinner as kn } from "@fluentui/react-components";
6
+ import { useTableSelection as Ln } from "./hooks/useTableSelection/useTableSelection.js";
7
+ import { renderCellContent as Fn } from "./utils/index.js";
8
+ import { useDefaultAddButton as An } from "./hooks/useDefaultAddButton/useDefaultAddButton.js";
9
+ import { useDefaultUpdateButton as Bn } from "./hooks/useDefaultUpdateButton/useDefaultUpdateButton.js";
10
+ import { useDefaultDeleteButton as Dn } from "./hooks/useDefaultDeleteButton/useDefaultDeleteButton.js";
11
+ import { useStableColumnRenderers as Hn } from "./hooks/useStableColumnRenderers/useStableColumnRenderers.js";
12
+ import { generateId as Kt } from "./utils/general.js";
13
+ import { addRowId as Ee, ensureItemRowId as Xt } from "./utils/typeHelpers.js";
14
+ import { EFWTableCommandBar as On } from "./components/EFWTableCommandBar/EFWTableCommandBar.js";
15
+ import { EFWTableOverlay as Jt } from "./components/EFWTableOverlay/EFWTableOverlay.js";
16
+ import { EFWTableHeader as Pn } from "./components/EFWTableHeader/EFWTableHeader.js";
17
+ import { EFWTableBody as jn } from "./components/EFWTableBody/EFWTableBody.js";
18
+ const ze = {}, qn = /* @__PURE__ */ new Set(), Vt = [], Te = [], Me = (b) => b, W = 120, ce = 120, Ne = 2500, Ce = 45, ar = 45, Zt = 500;
19
19
  function ne(b, E, z) {
20
20
  return E.length === 0 ? b : z === "start" ? [...E, ...b] : [...b, ...E];
21
21
  }
@@ -26,21 +26,21 @@ function re(b, E, z) {
26
26
  item: F
27
27
  }));
28
28
  }
29
- const qn = ({
29
+ const Un = ({
30
30
  table: b
31
31
  }) => /* @__PURE__ */ L(
32
- en,
32
+ tn,
33
33
  {
34
34
  shape: "circular",
35
35
  checked: b.getIsAllRowsSelected(),
36
36
  onChange: b.getToggleAllRowsSelectedHandler(),
37
37
  "data-checkbox": "true"
38
38
  }
39
- ), Un = ({
39
+ ), $n = ({
40
40
  row: b,
41
41
  toggleMultiple: E
42
42
  }) => /* @__PURE__ */ L(
43
- en,
43
+ tn,
44
44
  {
45
45
  shape: "circular",
46
46
  checked: b.getIsSelected(),
@@ -50,7 +50,7 @@ const qn = ({
50
50
  onClick: (z) => z.stopPropagation(),
51
51
  "data-checkbox": "true"
52
52
  }
53
- ), $n = Mn({
53
+ ), Yn = Nn({
54
54
  "efw-table": {},
55
55
  /* Transición suave para el box-shadow en las celdas y cabeceras fijas */
56
56
  "efw-table-scroll-container": {
@@ -95,7 +95,7 @@ const qn = ({
95
95
  }
96
96
  }
97
97
  });
98
- function Zt(b, E, z, a) {
98
+ function Qt(b, E, z, a) {
99
99
  let F = 0, A = 0;
100
100
  const T = [];
101
101
  if (E.forEach((C) => {
@@ -112,7 +112,7 @@ function Zt(b, E, z, a) {
112
112
  j === T.length - 1 ? y = v - oe : y = Math.round(D * J), y = Math.max(R, y), V[C.id] = y, oe += y;
113
113
  }), V;
114
114
  }
115
- function Qt(b, E, z, a, F) {
115
+ function en(b, E, z, a, F) {
116
116
  const A = b - F;
117
117
  if (Math.abs(A) < 1) return null;
118
118
  const T = E.filter((y) => y.id && y.id !== "select");
@@ -120,7 +120,7 @@ function Qt(b, E, z, a, F) {
120
120
  const B = T[T.length - 1], v = B.id, V = z.find((y) => y.internalName === v)?.typeAsString === "Note" ? W * 2 : W, C = (a[v] || (typeof B.size == "number" ? B.size : V)) + A, j = B.minSize || ce, D = Math.max(j, C), R = a[v];
121
121
  return R !== void 0 && Math.abs(R - D) < 1 ? null : { [v]: D };
122
122
  }
123
- const ar = ({
123
+ const ur = ({
124
124
  appearance: b = "outline",
125
125
  style: E = {},
126
126
  className: z = "",
@@ -132,7 +132,7 @@ const ar = ({
132
132
  // tableStyle = 'row',
133
133
  enableSelection: v = !0,
134
134
  enableCommandBar: J = !0,
135
- defaultSelectedItems: V = jn,
135
+ defaultSelectedItems: V = qn,
136
136
  onSelectionChange: oe,
137
137
  onRowClick: C,
138
138
  onRowDoubleClick: j,
@@ -140,67 +140,67 @@ const ar = ({
140
140
  columnSizing: R = ze,
141
141
  useVirtualization: y = !1,
142
142
  autoSizeColumns: ie = !1,
143
- tableRef: tn,
144
- onItemsChange: Oe,
145
- onScroll: Pe,
146
- onScrollEnd: je,
147
- scrollEndThreshold: qe = Vt,
143
+ tableRef: nn,
144
+ onItemsChange: Pe,
145
+ onScroll: je,
146
+ onScrollEnd: qe,
147
+ scrollEndThreshold: Ue = Zt,
148
148
  loadingMore: le = !1,
149
- addButtonConfig: nn = ze,
150
- updateButtonConfig: rn = ze,
151
- deleteButtonConfig: sn = ze,
152
- alwaysButtons: Ue = Te,
153
- noSelectionButtons: cn = Te,
154
- singleSelectionButtons: on = Te,
155
- multiSelectionButtons: $e = Te,
156
- beforeAddItems: Ye,
157
- beforeUpdateItems: Ge,
158
- beforeDeleteItems: Ke,
159
- columnRenderers: ln,
160
- useDefaultRendererAsFallback: Xe = !0,
149
+ addButtonConfig: rn = ze,
150
+ updateButtonConfig: sn = ze,
151
+ deleteButtonConfig: cn = ze,
152
+ alwaysButtons: $e = Te,
153
+ noSelectionButtons: on = Te,
154
+ singleSelectionButtons: ln = Te,
155
+ multiSelectionButtons: Ye = Te,
156
+ beforeAddItems: Ge,
157
+ beforeUpdateItems: Ke,
158
+ beforeDeleteItems: Xe,
159
+ columnRenderers: an,
160
+ useDefaultRendererAsFallback: Je = !0,
161
161
  // Overlay state props
162
- overlayState: Je,
163
- defaultOverlayState: an,
162
+ overlayState: Ve,
163
+ defaultOverlayState: un,
164
164
  onOverlayStateChange: H,
165
165
  overlayCustomization: ae,
166
- overlayHeight: Ne = 200
166
+ overlayHeight: _e = 200
167
167
  }) => {
168
- const Ve = Dn(ln);
168
+ const Ze = Hn(an);
169
169
  y && T === void 0 && console.warn(
170
170
  '[EFWTable] La prop "height" es requerida cuando "useVirtualization" está habilitado. La virtualización necesita una altura fija para calcular las filas visibles.'
171
171
  );
172
- const ue = T !== void 0 ? J ? T - 40 : T : void 0, Ze = $n(), un = Nn(z, Ze["efw-table"]), O = S(!1), de = S(null), fe = S(null), _e = F !== void 0, k = Je !== void 0, [dn, me] = be(
173
- () => an || { state: "none" }
174
- ), ve = k ? Je : dn, [fn, mn] = be(() => (A || Jt).map((t) => ({
172
+ const ue = T !== void 0 ? J ? T - 40 : T : void 0, Qe = Yn(), dn = _n(z, Qe["efw-table"]), O = S(!1), de = S(null), fe = S(null), We = F !== void 0, k = Ve !== void 0, [fn, me] = be(
173
+ () => un || { state: "none" }
174
+ ), ve = k ? Ve : fn, [mn, hn] = be(() => (A || Vt).map((t) => ({
175
175
  ...t,
176
- _rowId: t._rowId || Gt()
177
- }))), Y = _e ? F || Jt : fn, [M, Z] = be(() => {
176
+ _rowId: t._rowId || Kt()
177
+ }))), Y = We ? F || Vt : mn, [M, Z] = be(() => {
178
178
  const e = {};
179
179
  return a.forEach((t) => {
180
180
  const n = R[t.internalName];
181
181
  if (n?.width) {
182
- const r = n.minWidth ?? ce, o = n.maxWidth ?? Me;
182
+ const r = n.minWidth ?? ce, o = n.maxWidth ?? Ne;
183
183
  e[t.internalName] = Math.min(Math.max(n.width ?? 0, r), o);
184
184
  }
185
185
  }), e;
186
- }), Qe = S(R), [q, et] = be(0), {
186
+ }), et = S(R), [q, tt] = be(0), {
187
187
  rowSelection: Q,
188
- setRowSelection: tt,
188
+ setRowSelection: nt,
189
189
  // selectedIndexes,
190
- deselectAll: nt,
191
- selectSingle: rt,
192
- toggleMultiple: st,
190
+ deselectAll: rt,
191
+ selectSingle: st,
192
+ toggleMultiple: ct,
193
193
  // selectMultiple,
194
- getSelectedItems: ct,
195
- getSelectedRows: ot
196
- } = kn({
194
+ getSelectedItems: ot,
195
+ getSelectedRows: it
196
+ } = Ln({
197
197
  initialSelection: V,
198
198
  onSelectionChange: oe,
199
199
  enableSelection: v
200
- }), G = S(null), ee = S(null), [We, hn] = be(null), pn = d((e) => {
201
- G.current = e, hn(e);
200
+ }), G = S(null), ee = S(null), [ke, pn] = be(null), gn = d((e) => {
201
+ G.current = e, pn(e);
202
202
  }, []), U = d(() => {
203
- if (Le.current && !he.current) {
203
+ if (Fe.current && !he.current) {
204
204
  ee.current = null;
205
205
  return;
206
206
  }
@@ -213,32 +213,32 @@ const ar = ({
213
213
  top: e.scrollTop,
214
214
  left: e.scrollLeft
215
215
  };
216
- }, []), ke = d((e, t) => {
216
+ }, []), Le = d((e, t) => {
217
217
  e.scrollTop !== t.top && (e.scrollTop = t.top), e.scrollLeft !== t.left && (e.scrollLeft = t.left);
218
- }, []), I = S(Y), Re = S(/* @__PURE__ */ new Map()), Le = S(_e);
219
- Le.current = _e;
220
- const he = S(Oe);
221
- he.current = Oe;
222
- const pe = S(Ye);
223
- pe.current = Ye;
224
- const ge = S(Ge);
225
- ge.current = Ge;
226
- const Se = S(Ke);
227
- Se.current = Ke;
228
- const K = S(null), it = S(le);
229
- it.current = le;
230
- const lt = S(Pe);
231
- lt.current = Pe;
232
- const Fe = S(je);
233
- Fe.current = je;
218
+ }, []), I = S(Y), Re = S(/* @__PURE__ */ new Map()), Fe = S(We);
219
+ Fe.current = We;
220
+ const he = S(Pe);
221
+ he.current = Pe;
222
+ const pe = S(Ge);
223
+ pe.current = Ge;
224
+ const ge = S(Ke);
225
+ ge.current = Ke;
226
+ const Se = S(Xe);
227
+ Se.current = Xe;
228
+ const K = S(null), lt = S(le);
229
+ lt.current = le;
230
+ const at = S(je);
231
+ at.current = je;
234
232
  const Ae = S(qe);
235
- Ae.current = qe, X(() => {
233
+ Ae.current = qe;
234
+ const Be = S(Ue);
235
+ Be.current = Ue, X(() => {
236
236
  I.current = Y;
237
237
  const e = /* @__PURE__ */ new Map();
238
238
  Y.forEach((t, n) => {
239
239
  t._rowId && e.set(String(t._rowId), n);
240
240
  }), Re.current = e;
241
- }, [Y]), Yt(() => {
241
+ }, [Y]), Gt(() => {
242
242
  const e = ee.current;
243
243
  if (!e)
244
244
  return;
@@ -246,20 +246,20 @@ const ar = ({
246
246
  const t = G.current;
247
247
  if (!t)
248
248
  return;
249
- ke(t, e);
249
+ Le(t, e);
250
250
  const n = requestAnimationFrame(() => {
251
251
  const r = G.current;
252
- r && ke(r, e);
252
+ r && Le(r, e);
253
253
  });
254
254
  return () => {
255
255
  cancelAnimationFrame(n);
256
256
  };
257
- }, [Y, ke]);
258
- const Be = S(/* @__PURE__ */ new Set()), we = S(!1), at = S(0), ut = S(0), dt = S(!1);
257
+ }, [Y, Le]);
258
+ const De = S(/* @__PURE__ */ new Set()), we = S(!1), ut = S(0), dt = S(0), ft = S(!1);
259
259
  X(() => {
260
- le || (G.current?.scrollHeight ?? 0) > ut.current && (we.current = !1);
260
+ le || (G.current?.scrollHeight ?? 0) > dt.current && (we.current = !1);
261
261
  }, [le]);
262
- const ft = te(() => {
262
+ const mt = te(() => {
263
263
  const e = [], t = {};
264
264
  let n = 0;
265
265
  return v && (e.push("select"), t.select = n, n += Ce), a.forEach((r) => {
@@ -274,8 +274,8 @@ const ar = ({
274
274
  const e = [];
275
275
  return v && e.push({
276
276
  id: "select",
277
- header: ({ table: t }) => /* @__PURE__ */ L(qn, { table: t }),
278
- cell: ({ row: t }) => /* @__PURE__ */ L(Un, { row: t, toggleMultiple: st }),
277
+ header: ({ table: t }) => /* @__PURE__ */ L(Un, { table: t }),
278
+ cell: ({ row: t }) => /* @__PURE__ */ L($n, { row: t, toggleMultiple: ct }),
279
279
  size: Ce,
280
280
  minSize: Ce,
281
281
  maxSize: Ce,
@@ -284,18 +284,18 @@ const ar = ({
284
284
  const n = R[t.internalName] || {};
285
285
  if (n.hidden)
286
286
  return;
287
- const r = t.typeAsString === "Note" ? W * 2 : W, o = n.width || r, c = n.minWidth || ce, s = n.maxWidth || Me;
287
+ const r = t.typeAsString === "Note" ? W * 2 : W, o = n.width || r, c = n.minWidth || ce, s = n.maxWidth || Ne;
288
288
  e.push({
289
289
  id: t.internalName,
290
290
  accessorKey: t.internalName,
291
291
  header: t.title || t.internalName,
292
- cell: ({ row: l }) => Ln(
292
+ cell: ({ row: l }) => Fn(
293
293
  t,
294
294
  l.original[t.internalName],
295
295
  l.original,
296
296
  l.index,
297
- Ve,
298
- Xe
297
+ Ze,
298
+ Je
299
299
  ),
300
300
  size: Math.min(Math.max(o, c), s),
301
301
  minSize: c,
@@ -308,12 +308,12 @@ const ar = ({
308
308
  v,
309
309
  D,
310
310
  R,
311
- Ve,
312
- Xe,
313
- st
311
+ Ze,
312
+ Je,
313
+ ct
314
314
  ]);
315
315
  X(() => {
316
- const e = Qe.current;
316
+ const e = et.current;
317
317
  Z((t) => {
318
318
  let n = !1;
319
319
  const r = { ...t }, o = new Set(a.map((c) => c.internalName));
@@ -322,42 +322,42 @@ const ar = ({
322
322
  }), a.forEach((c) => {
323
323
  const s = c.internalName, l = R[s], g = e[s];
324
324
  if (l?.width !== void 0) {
325
- const u = l.minWidth ?? ce, m = l.maxWidth ?? Me, i = Math.min(Math.max(l.width, u), m);
325
+ const u = l.minWidth ?? ce, m = l.maxWidth ?? Ne, i = Math.min(Math.max(l.width, u), m);
326
326
  r[s] !== i && (r[s] = i, n = !0);
327
327
  } else g?.width !== void 0 && r[s] !== void 0 && (delete r[s], n = !0);
328
328
  }), n ? r : t;
329
- }), Qe.current = R;
329
+ }), et.current = R;
330
330
  }, [R, a]);
331
331
  const Ie = te(() => N.reduce((e, t) => {
332
332
  const r = a.find((c) => c.internalName === t.id)?.typeAsString === "Note" ? W * 2 : W, o = M[t.id] || (typeof t.size == "number" ? t.size : r);
333
333
  return e + o;
334
- }, 0), [N, M, a]), gn = te(
334
+ }, 0), [N, M, a]), Sn = te(
335
335
  () => Math.max(Ie, q || 0, 300),
336
336
  [Ie, q]
337
- ), mt = yn({
337
+ ), ht = En({
338
338
  data: Y,
339
339
  columns: N,
340
340
  state: {
341
341
  rowSelection: Q,
342
342
  columnSizing: M
343
343
  },
344
- onRowSelectionChange: tt,
344
+ onRowSelectionChange: nt,
345
345
  onColumnSizingChange: (e) => {
346
346
  Z((t) => {
347
347
  const n = typeof e == "function" ? e(t) : e, r = {};
348
348
  return Object.keys(n).forEach((o) => {
349
349
  const c = N.find((s) => s.id === o);
350
350
  if (c) {
351
- const s = c.minSize || ce, l = c.maxSize || Me;
351
+ const s = c.minSize || ce, l = c.maxSize || Ne;
352
352
  O.current ? r[o] = Math.max(n[o], s) : r[o] = Math.min(Math.max(n[o], s), l);
353
353
  }
354
354
  }), { ...t, ...r };
355
355
  });
356
356
  },
357
357
  //getRowId: row => row.id as string,
358
- getCoreRowModel: Tn(),
359
- getFilteredRowModel: zn(),
360
- getSortedRowModel: En(),
358
+ getCoreRowModel: Mn(),
359
+ getFilteredRowModel: Tn(),
360
+ getSortedRowModel: zn(),
361
361
  columnResizeMode: "onChange",
362
362
  enableRowSelection: !0,
363
363
  enableMultiRowSelection: v
@@ -369,13 +369,13 @@ const ar = ({
369
369
  const n = parseInt(t), r = I.current[n];
370
370
  r?._rowId && e.add(r._rowId);
371
371
  }
372
- }), Be.current = e;
372
+ }), De.current = e;
373
373
  }, [Q]);
374
- const Sn = d((e) => {
375
- if (lt.current?.(e), !Fe.current || it.current)
374
+ const wn = d((e) => {
375
+ if (at.current?.(e), !Ae.current || lt.current)
376
376
  return;
377
- const t = e.currentTarget, n = Number.isFinite(Ae.current) ? Math.max(0, Ae.current) : Vt, { scrollTop: r, scrollHeight: o, clientHeight: c } = t, l = o - r - c <= n, g = at.current;
378
- if (at.current = o, o > g && !l) {
377
+ const t = e.currentTarget, n = Number.isFinite(Be.current) ? Math.max(0, Be.current) : Zt, { scrollTop: r, scrollHeight: o, clientHeight: c } = t, l = o - r - c <= n, g = ut.current;
378
+ if (ut.current = o, o > g && !l) {
379
379
  we.current = !1;
380
380
  return;
381
381
  }
@@ -383,8 +383,8 @@ const ar = ({
383
383
  we.current = !1;
384
384
  return;
385
385
  }
386
- we.current || (we.current = !0, ut.current = o, Fe.current());
387
- }, []), ht = (e) => {
386
+ we.current || (we.current = !0, dt.current = o, Ae.current());
387
+ }, []), pt = (e) => {
388
388
  const t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set();
389
389
  return Object.keys(Q).forEach((o) => {
390
390
  if (!Q[o])
@@ -398,7 +398,7 @@ const ar = ({
398
398
  selectedIndexes: r,
399
399
  sourceLength: e.length
400
400
  };
401
- }, pt = (e, t) => {
401
+ }, gt = (e, t) => {
402
402
  if (!t.hasSelection)
403
403
  return;
404
404
  const n = t.sourceLength !== e.length, r = {};
@@ -407,30 +407,30 @@ const ar = ({
407
407
  return;
408
408
  const s = o._rowId ? t.selectedIds.has(o._rowId) : !1, l = t.selectedRefs.has(o), g = !o._rowId && !n && t.selectedIndexes.has(c);
409
409
  (s || l || g) && (r[c.toString()] = !0);
410
- }), tt(r);
410
+ }), nt(r);
411
411
  }, p = d((e) => {
412
- if (Le.current) {
412
+ if (Fe.current) {
413
413
  if (!he.current)
414
- return ee.current = null, dt.current || (console.warn("[EFWTable] Modo controlled detectado sin onItemsChange. Las operaciones CRUD locales no se aplicarán."), dt.current = !0), !1;
414
+ return ee.current = null, ft.current || (console.warn("[EFWTable] Modo controlled detectado sin onItemsChange. Las operaciones CRUD locales no se aplicarán."), ft.current = !0), !1;
415
415
  const t = I.current, n = typeof e == "function" ? e(t) : e;
416
416
  I.current = n;
417
- const r = ht(t);
418
- return Be.current = r.selectedIds, pt(n, r), he.current(n), !0;
417
+ const r = pt(t);
418
+ return De.current = r.selectedIds, gt(n, r), he.current(n), !0;
419
419
  }
420
- return mn((t) => {
420
+ return hn((t) => {
421
421
  const n = typeof e == "function" ? e(t) : e;
422
422
  I.current = n;
423
- const r = ht(t);
424
- return Be.current = r.selectedIds, pt(n, r), he.current?.(n), n;
423
+ const r = pt(t);
424
+ return De.current = r.selectedIds, gt(n, r), he.current?.(n), n;
425
425
  }), !0;
426
- }, []), gt = d(() => a, [a]), St = d(async (e, t = "end") => {
426
+ }, []), St = d(() => a, [a]), wt = d(async (e, t = "end") => {
427
427
  try {
428
428
  if (pe.current) {
429
429
  const n = Ee(e), r = await pe.current([n], K.current);
430
430
  if (r) {
431
431
  if (r.successful.length > 0) {
432
432
  const s = I.current.length, l = r.successful.map(
433
- (u) => Kt(u.item)
433
+ (u) => Xt(u.item)
434
434
  );
435
435
  return U(), p((u) => ne(u, l, t)) ? {
436
436
  ...r,
@@ -457,7 +457,7 @@ const ar = ({
457
457
  failed: [{ index: -1, item: e, error: String(n) }]
458
458
  };
459
459
  }
460
- }, [p, U]), wt = d(async (e, t = "end") => {
460
+ }, [p, U]), It = d(async (e, t = "end") => {
461
461
  if (e.length === 0)
462
462
  return {
463
463
  successful: [],
@@ -469,7 +469,7 @@ const ar = ({
469
469
  if (r) {
470
470
  if (r.successful.length > 0) {
471
471
  const s = I.current.length, l = r.successful.map(
472
- (u) => Kt(u.item)
472
+ (u) => Xt(u.item)
473
473
  );
474
474
  return U(), p((u) => ne(u, l, t)) ? {
475
475
  ...r,
@@ -500,7 +500,7 @@ const ar = ({
500
500
  }))
501
501
  };
502
502
  }
503
- }, [p, U]), It = d(async (e, t) => {
503
+ }, [p, U]), xt = d(async (e, t) => {
504
504
  const n = I.current;
505
505
  if (e < 0 || e >= n.length)
506
506
  return {
@@ -514,7 +514,7 @@ const ar = ({
514
514
  const l = c.successful.filter(
515
515
  ({ index: i }) => i >= 0 && i < n.length
516
516
  ).map(({ index: i, item: h }) => {
517
- const x = bt(
517
+ const x = Ct(
518
518
  n,
519
519
  i,
520
520
  h,
@@ -551,7 +551,7 @@ const ar = ({
551
551
  failed: [{ index: e, item: t, error: String(r) }]
552
552
  };
553
553
  }
554
- }, [p]), xt = d(async (e) => {
554
+ }, [p]), bt = d(async (e) => {
555
555
  if (!e.length) return { successful: [], failed: [] };
556
556
  const t = I.current, n = (s) => s >= 0 && s < t.length, r = e.filter(({ index: s }) => !n(s)).map(({ index: s, item: l }) => ({ index: s, item: l, error: "Invalid index" })), o = e.filter(({ index: s }) => n(s)), c = /* @__PURE__ */ new Map();
557
557
  o.forEach(({ index: s, item: l }) => {
@@ -562,7 +562,7 @@ const ar = ({
562
562
  const u = await ge.current(e, K.current);
563
563
  if (u) {
564
564
  const i = u.successful.filter(({ index: w }) => n(w)).map(({ index: w, item: f }) => {
565
- const _ = bt(
565
+ const _ = Ct(
566
566
  t,
567
567
  w,
568
568
  f,
@@ -572,8 +572,8 @@ const ar = ({
572
572
  }).filter((w) => w !== null);
573
573
  if (i.length && !p((f) => {
574
574
  const _ = [...f];
575
- return i.forEach(({ index: P, item: $t }) => {
576
- _[P] = $t;
575
+ return i.forEach(({ index: P, item: Yt }) => {
576
+ _[P] = Yt;
577
577
  }), _;
578
578
  }))
579
579
  return { successful: [], failed: i.map(({ index: f, item: _ }) => ({ index: f, item: _, error: "Controlled mode without onItemsChange" })) };
@@ -602,7 +602,7 @@ const ar = ({
602
602
  }))
603
603
  };
604
604
  }
605
- }, [p]), bt = (e, t, n, r) => {
605
+ }, [p]), Ct = (e, t, n, r) => {
606
606
  const o = e[t];
607
607
  if (!o)
608
608
  return null;
@@ -612,14 +612,14 @@ const ar = ({
612
612
  ...c,
613
613
  _rowId: c._rowId ?? o._rowId
614
614
  } : o;
615
- }, Ct = (e, t, n) => {
615
+ }, vt = (e, t, n) => {
616
616
  const r = e[t];
617
617
  return r ? n ? {
618
618
  ...r,
619
619
  ...n,
620
620
  _rowId: n._rowId ?? r._rowId
621
621
  } : r : null;
622
- }, vt = d(async (e) => {
622
+ }, Rt = d(async (e) => {
623
623
  const t = I.current;
624
624
  if (e < 0 || e >= t.length)
625
625
  return {
@@ -633,7 +633,7 @@ const ar = ({
633
633
  const l = c.successful.filter(
634
634
  ({ index: i }) => i >= 0 && i < t.length
635
635
  ).map(({ index: i, item: h }) => {
636
- const x = Ct(t, i, h);
636
+ const x = vt(t, i, h);
637
637
  return x ? { index: i, item: x } : null;
638
638
  }).filter((i) => i !== null);
639
639
  if (l.length && !p((h) => h.filter((x, $) => $ !== e)))
@@ -656,7 +656,7 @@ const ar = ({
656
656
  failed: [{ index: e, error: String(n) }]
657
657
  };
658
658
  }
659
- }, [p]), Rt = d(async (e) => {
659
+ }, [p]), yt = d(async (e) => {
660
660
  if (!e.length) return { successful: [], failed: [] };
661
661
  const t = I.current, n = Array.from(new Set(e)), { validIndexes: r, invalidFailures: o } = n.reduce(
662
662
  (l, g) => (g >= 0 && g < t.length ? l.validIndexes.push(g) : l.invalidFailures.push({ index: g, error: "Invalid index" }), l),
@@ -667,12 +667,12 @@ const ar = ({
667
667
  const m = await Se.current(c, K.current);
668
668
  if (m) {
669
669
  const i = m.successful.filter(({ index: f }) => s.has(f)), h = i.map(({ index: f, item: _ }) => {
670
- const P = Ct(t, f, _);
670
+ const P = vt(t, f, _);
671
671
  return P ? { index: f, item: P } : null;
672
672
  }).filter((f) => f !== null);
673
673
  if (i.length) {
674
674
  const f = new Set(h.map((P) => P.index));
675
- if (!p((P) => P.filter(($t, vn) => !f.has(vn))))
675
+ if (!p((P) => P.filter((Yt, Rn) => !f.has(Rn))))
676
676
  return { successful: [], failed: h.map(({ index: P }) => ({ index: P, error: "Controlled mode without onItemsChange" })) };
677
677
  }
678
678
  const x = new Set(m.failed.map((f) => f.index)), $ = [...m.failed];
@@ -696,23 +696,23 @@ const ar = ({
696
696
  failed: n.map((g) => ({ index: g, error: String(l) }))
697
697
  };
698
698
  }
699
- }, [p]), yt = d((e) => {
699
+ }, [p]), Et = d((e) => {
700
700
  const t = Re.current.get(String(e));
701
701
  return t !== void 0 ? I.current[t] : void 0;
702
- }, []), Et = d((e) => I.current[e], []), zt = d((e) => {
702
+ }, []), zt = d((e) => I.current[e], []), Tt = d((e) => {
703
703
  p(
704
- e.map((t) => ({ ...t, _rowId: t._rowId ?? Gt() }))
704
+ e.map((t) => ({ ...t, _rowId: t._rowId ?? Kt() }))
705
705
  );
706
- }, [p]), Tt = d(() => {
706
+ }, [p]), Mt = d(() => {
707
707
  p([]);
708
- }, [p]), Mt = d((e) => Re.current.get(String(e)) ?? -1, []), Nt = d((e) => Re.current.has(String(e)), []), _t = d(() => I.current.length, []), Wt = d(() => [...I.current], []), kt = d(() => ct(I.current), [ct]), Lt = d(() => ot(I.current), [ot]), Ft = d((e, t) => {
708
+ }, [p]), Nt = d((e) => Re.current.get(String(e)) ?? -1, []), _t = d((e) => Re.current.has(String(e)), []), Wt = d(() => I.current.length, []), kt = d(() => [...I.current], []), Lt = d(() => ot(I.current), [ot]), Ft = d(() => it(I.current), [it]), At = d((e, t) => {
709
709
  const n = e ? {
710
710
  state: "loading",
711
711
  message: t?.title,
712
712
  description: t?.description
713
713
  } : { state: "none" };
714
714
  k || me(n), H?.(n);
715
- }, [k, H]), At = d((e, t) => {
715
+ }, [k, H]), Bt = d((e, t) => {
716
716
  const n = e ? {
717
717
  state: "error",
718
718
  message: t?.title,
@@ -720,14 +720,14 @@ const ar = ({
720
720
  onRetry: t?.onRetry
721
721
  } : { state: "none" };
722
722
  k || me(n), H?.(n);
723
- }, [k, H]), Bt = d((e, t) => {
723
+ }, [k, H]), Dt = d((e, t) => {
724
724
  const n = e ? {
725
725
  state: "partial-loading",
726
726
  message: t?.title,
727
727
  description: t?.description
728
728
  } : { state: "none" };
729
729
  k || me(n), H?.(n);
730
- }, [k, H]), Dt = d((e, t) => {
730
+ }, [k, H]), Ht = d((e, t) => {
731
731
  const n = e ? {
732
732
  state: "empty",
733
733
  message: t?.title,
@@ -735,99 +735,99 @@ const ar = ({
735
735
  imageUrl: t?.imageUrl
736
736
  } : { state: "none" };
737
737
  k || me(n), H?.(n);
738
- }, [k, H]), Ht = d(() => {
738
+ }, [k, H]), Ot = d(() => {
739
739
  const e = { state: "none" };
740
740
  k || me(e), H?.(e);
741
- }, [k, H]), Ot = d(() => ve.state, [ve.state]), xe = te(() => ({
742
- getFields: gt,
743
- addItem: St,
744
- addItems: wt,
745
- updateItem: It,
746
- updateItems: xt,
747
- deleteItem: vt,
748
- deleteItems: Rt,
749
- getItem: yt,
750
- getItemByIndex: Et,
751
- getItems: Wt,
752
- getItemsCount: _t,
753
- itemExists: Nt,
754
- getItemIndex: Mt,
755
- replaceAllItems: zt,
756
- clearItems: Tt,
757
- deselectAllRows: nt,
758
- getSelectedItems: kt,
759
- getSelectedRows: Lt,
741
+ }, [k, H]), Pt = d(() => ve.state, [ve.state]), xe = te(() => ({
742
+ getFields: St,
743
+ addItem: wt,
744
+ addItems: It,
745
+ updateItem: xt,
746
+ updateItems: bt,
747
+ deleteItem: Rt,
748
+ deleteItems: yt,
749
+ getItem: Et,
750
+ getItemByIndex: zt,
751
+ getItems: kt,
752
+ getItemsCount: Wt,
753
+ itemExists: _t,
754
+ getItemIndex: Nt,
755
+ replaceAllItems: Tt,
756
+ clearItems: Mt,
757
+ deselectAllRows: rt,
758
+ getSelectedItems: Lt,
759
+ getSelectedRows: Ft,
760
760
  // Overlay methods
761
- setLoading: Ft,
762
- setError: At,
763
- setPartialLoading: Bt,
764
- setEmpty: Dt,
765
- clearOverlay: Ht,
766
- getOverlayState: Ot
761
+ setLoading: At,
762
+ setError: Bt,
763
+ setPartialLoading: Dt,
764
+ setEmpty: Ht,
765
+ clearOverlay: Ot,
766
+ getOverlayState: Pt
767
767
  }), [
768
- St,
769
768
  wt,
770
- Tt,
771
- Ht,
772
- vt,
769
+ It,
770
+ Mt,
771
+ Ot,
773
772
  Rt,
774
- nt,
775
- a,
776
- gt,
777
773
  yt,
774
+ rt,
775
+ a,
776
+ St,
778
777
  Et,
779
- Mt,
780
- Wt,
781
- _t,
782
- Ot,
778
+ zt,
779
+ Nt,
783
780
  kt,
781
+ Wt,
782
+ Pt,
784
783
  Lt,
785
- Nt,
786
- zt,
787
- Dt,
788
- At,
789
784
  Ft,
785
+ _t,
786
+ Tt,
787
+ Ht,
790
788
  Bt,
791
- It,
792
- xt
789
+ At,
790
+ Dt,
791
+ xt,
792
+ bt
793
793
  ]);
794
- K.current = xe, Rn.useImperativeHandle(tn, () => xe, [xe]);
795
- const wn = d((e, t) => {
796
- t?.target && t.target.closest('[data-checkbox="true"]') || (v && rt(e.index), C && C(e.original, e.index));
797
- }, [v, C, rt]), In = d((e, t) => {
794
+ K.current = xe, yn.useImperativeHandle(nn, () => xe, [xe]);
795
+ const In = d((e, t) => {
796
+ t?.target && t.target.closest('[data-checkbox="true"]') || (v && st(e.index), C && C(e.original, e.index));
797
+ }, [v, C, st]), xn = d((e, t) => {
798
798
  t?.target && t.target.closest('[data-checkbox="true"]') || j && j(e.original, e.index);
799
- }, [j]), Pt = te(() => N.map((e) => {
799
+ }, [j]), jt = te(() => N.map((e) => {
800
800
  const n = a.find((o) => o.internalName === e.id)?.typeAsString === "Note" ? W * 2 : W, r = M[e.id] || (typeof e.size == "number" ? e.size : n);
801
801
  return e.id === "select" ? `${Ce}px` : `${r}px`;
802
- }).join(" "), [N, M, a]), jt = S(!1);
803
- Yt(() => {
804
- if (jt.current) return;
802
+ }).join(" "), [N, M, a]), qt = S(!1);
803
+ Gt(() => {
804
+ if (qt.current) return;
805
805
  const e = G.current;
806
806
  if (!e) return;
807
807
  const t = e.clientWidth;
808
808
  if (!(t <= 0))
809
- if (jt.current = !0, et(t), ie) {
810
- const n = Zt(t, N, a, M);
809
+ if (qt.current = !0, tt(t), ie) {
810
+ const n = Qt(t, N, a, M);
811
811
  n && (O.current = !0, Z(n), requestAnimationFrame(() => {
812
812
  O.current = !1;
813
813
  }));
814
814
  } else {
815
- const n = Qt(t, N, a, M, Ie);
815
+ const n = en(t, N, a, M, Ie);
816
816
  n && (O.current = !0, Z((r) => ({ ...r, ...n })), requestAnimationFrame(() => {
817
817
  O.current = !1;
818
818
  }));
819
819
  }
820
820
  }), X(() => {
821
- if (!We) return;
821
+ if (!ke) return;
822
822
  const e = new ResizeObserver((t) => {
823
823
  for (const n of t)
824
- et(n.contentRect.width);
824
+ tt(n.contentRect.width);
825
825
  });
826
- return e.observe(We), () => e.disconnect();
827
- }, [We]), X(() => {
826
+ return e.observe(ke), () => e.disconnect();
827
+ }, [ke]), X(() => {
828
828
  if (!(!ie || q <= 0) && !O.current)
829
829
  return de.current && clearTimeout(de.current), de.current = setTimeout(() => {
830
- const e = Zt(q, N, a, M);
830
+ const e = Qt(q, N, a, M);
831
831
  e && (O.current = !0, Z(e), requestAnimationFrame(() => {
832
832
  O.current = !1;
833
833
  }));
@@ -837,7 +837,7 @@ const ar = ({
837
837
  }, [ie, q, N, a]), X(() => {
838
838
  if (!(ie || q <= 0))
839
839
  return fe.current && clearTimeout(fe.current), fe.current = setTimeout(() => {
840
- const e = Qt(q, N, a, M, Ie);
840
+ const e = en(q, N, a, M, Ie);
841
841
  e && (O.current = !0, Z((t) => ({ ...t, ...e })), requestAnimationFrame(() => {
842
842
  O.current = !1;
843
843
  }));
@@ -845,15 +845,15 @@ const ar = ({
845
845
  fe.current && clearTimeout(fe.current);
846
846
  };
847
847
  }, [ie, q, Ie, N, a]);
848
- const qt = Fn(nn), Ut = An(rn), ye = Bn(sn), xn = qt ? [qt, ...Ue] : Ue, De = [];
849
- Ut && De.push(Ut), ye && De.push(ye);
850
- const bn = [...De, ...on], Cn = ye ? [ye, ...$e] : $e;
851
- return /* @__PURE__ */ He(
852
- _n,
848
+ const Ut = An(rn), $t = Bn(sn), ye = Dn(cn), bn = Ut ? [Ut, ...$e] : $e, He = [];
849
+ $t && He.push($t), ye && He.push(ye);
850
+ const Cn = [...He, ...ln], vn = ye ? [ye, ...Ye] : Ye;
851
+ return /* @__PURE__ */ Oe(
852
+ Wn,
853
853
  {
854
854
  size: "small",
855
855
  appearance: b,
856
- className: un,
856
+ className: dn,
857
857
  style: {
858
858
  backgroundColor: se.colorNeutralBackground1,
859
859
  maxWidth: "100%",
@@ -864,13 +864,13 @@ const ar = ({
864
864
  },
865
865
  children: [
866
866
  J && /* @__PURE__ */ L(
867
- Hn,
867
+ On,
868
868
  {
869
869
  tableMethods: xe,
870
- alwaysButtons: xn,
871
- noSelectionButtons: cn,
872
- singleSelectionButtons: bn,
873
- multiSelectionButtons: Cn,
870
+ alwaysButtons: Me(bn),
871
+ noSelectionButtons: Me(on),
872
+ singleSelectionButtons: Me(Cn),
873
+ multiSelectionButtons: Me(vn),
874
874
  selectedRows: xe.getSelectedRows()
875
875
  }
876
876
  ),
@@ -880,12 +880,12 @@ const ar = ({
880
880
  message: ae?.empty?.title,
881
881
  description: ae?.empty?.description,
882
882
  imageUrl: ae?.empty?.imageUrl
883
- } : { state: "none" }, t = /* @__PURE__ */ He(
883
+ } : { state: "none" }, t = /* @__PURE__ */ Oe(
884
884
  "div",
885
885
  {
886
- ref: pn,
887
- onScroll: Sn,
888
- className: Ze["efw-table-scroll-container"],
886
+ ref: gn,
887
+ onScroll: wn,
888
+ className: Qe["efw-table-scroll-container"],
889
889
  style: {
890
890
  ...ue !== void 0 && {
891
891
  maxHeight: ue
@@ -897,39 +897,39 @@ const ar = ({
897
897
  position: "relative"
898
898
  },
899
899
  children: [
900
- /* @__PURE__ */ He(
900
+ /* @__PURE__ */ Oe(
901
901
  "div",
902
902
  {
903
903
  className: "table-container",
904
904
  style: {
905
905
  minWidth: "100%",
906
- width: gn
906
+ width: Sn
907
907
  },
908
908
  children: [
909
909
  /* @__PURE__ */ L(
910
- On,
910
+ Pn,
911
911
  {
912
- table: mt,
913
- gridTemplateColumns: Pt,
912
+ table: ht,
913
+ gridTemplateColumns: jt,
914
914
  columnSizing: M,
915
- stickyColumnsInfo: ft,
915
+ stickyColumnsInfo: mt,
916
916
  resizableColumns: D
917
917
  }
918
918
  ),
919
919
  /* @__PURE__ */ L(
920
- Pn,
920
+ jn,
921
921
  {
922
- table: mt,
922
+ table: ht,
923
923
  fields: a,
924
924
  tableContainerRef: G,
925
925
  useVirtualization: y,
926
926
  enableSelection: v,
927
927
  itemSize: B,
928
- gridTemplateColumns: Pt,
928
+ gridTemplateColumns: jt,
929
929
  columnSizing: M,
930
- stickyColumnsInfo: ft,
931
- onRowClick: wn,
932
- onRowDoubleClick: In
930
+ stickyColumnsInfo: mt,
931
+ onRowClick: In,
932
+ onRowDoubleClick: xn
933
933
  }
934
934
  )
935
935
  ]
@@ -955,25 +955,25 @@ const ar = ({
955
955
  },
956
956
  "aria-live": "polite",
957
957
  "aria-label": "Cargando más elementos",
958
- children: /* @__PURE__ */ L(Wn, { size: "tiny", label: "Cargando más..." })
958
+ children: /* @__PURE__ */ L(kn, { size: "tiny", label: "Cargando más..." })
959
959
  }
960
960
  )
961
961
  ]
962
962
  }
963
963
  );
964
964
  return e.state === "partial-loading" ? /* @__PURE__ */ L(
965
- Xt,
965
+ Jt,
966
966
  {
967
967
  config: e,
968
968
  customization: ae,
969
- height: ue !== void 0 ? Math.max(Ne, ue) : Ne,
969
+ height: ue !== void 0 ? Math.max(_e, ue) : _e,
970
970
  children: t
971
971
  }
972
972
  ) : e.state !== "none" ? /* @__PURE__ */ L(
973
- Xt,
973
+ Jt,
974
974
  {
975
975
  config: e,
976
- height: Ne,
976
+ height: _e,
977
977
  customization: ae
978
978
  }
979
979
  ) : t;
@@ -984,9 +984,9 @@ const ar = ({
984
984
  };
985
985
  export {
986
986
  W as COLS_DEF_WIDTH,
987
- Me as COLS_MAX_WIDTH,
987
+ Ne as COLS_MAX_WIDTH,
988
988
  ce as COLS_MIN_WIDTH,
989
- ar as EFWTable,
990
- lr as SELECTOR_CELL_HEIGHT,
989
+ ur as EFWTable,
990
+ ar as SELECTOR_CELL_HEIGHT,
991
991
  Ce as SELECTOR_CELL_WIDTH
992
992
  };
@@ -189,6 +189,7 @@ export interface EFWTableRowData extends TableRowData<EFWTableItem> {
189
189
  selected: boolean;
190
190
  appearance: "brand" | "none" | "neutral";
191
191
  }
192
+ export type EFWTableCommandBarButtonInput<T extends readonly EFWFormFieldProps[] = EFWFormFieldProps[]> = EFWTableCommandBarButton<T> | EFWTableCommandBarButton;
192
193
  export interface ReactWindowRenderFnProps extends ListChildComponentProps {
193
194
  data: EFWTableRowData[];
194
195
  fields: EFWFormFieldProps[];
@@ -254,13 +255,13 @@ export interface EFWTableProps<T extends readonly EFWFormFieldProps[] = EFWFormF
254
255
  onItemsChange?: (newItems: EFWTableItem<T>[]) => void;
255
256
  onBeforeDelete?: (selectedItems: EFWTableItem<T>[], selectedIndexes: number[]) => number[] | Promise<number[]>;
256
257
  /** Botones que se renderizan siempre, independientemente de la selección. */
257
- alwaysButtons?: EFWTableCommandBarButton<T>[];
258
+ alwaysButtons?: EFWTableCommandBarButtonInput<T>[];
258
259
  /** Botones que se renderizan solo cuando no hay filas seleccionadas. */
259
- noSelectionButtons?: EFWTableCommandBarButton<T>[];
260
+ noSelectionButtons?: EFWTableCommandBarButtonInput<T>[];
260
261
  /** Botones que se renderizan solo cuando hay exactamente una fila seleccionada. */
261
- singleSelectionButtons?: EFWTableCommandBarButton<T>[];
262
+ singleSelectionButtons?: EFWTableCommandBarButtonInput<T>[];
262
263
  /** Botones que se renderizan cuando hay más de una fila seleccionada. */
263
- multiSelectionButtons?: EFWTableCommandBarButton<T>[];
264
+ multiSelectionButtons?: EFWTableCommandBarButtonInput<T>[];
264
265
  /**
265
266
  * Callback genérico de scroll sobre el contenedor interno de la tabla.
266
267
  */
@@ -1,3 +1,7 @@
1
1
  import { EFWTableBodyProps } from './EFWTableBody.types';
2
2
 
3
- export declare const EFWTableBody: ({ tableContainerRef, useVirtualization, enableSelection, itemSize, table, gridTemplateColumns, columnSizing, stickyColumnsInfo, onRowClick, onRowDoubleClick, }: EFWTableBodyProps) => React.ReactElement;
3
+ /**
4
+ * Wrapper exportado: delega a VirtualizedTableBody o PlainTableBody
5
+ * según la prop useVirtualization. Mantiene la misma interfaz pública.
6
+ */
7
+ export declare const EFWTableBody: (props: EFWTableBodyProps) => React.ReactElement;
@@ -1,77 +1,103 @@
1
- import { jsxs as F, jsx as g } from "react/jsx-runtime";
2
- import { useEffect as f } from "react";
3
- import { useVirtualizer as R } from "@tanstack/react-virtual";
4
- import { EFWTableRow as S } from "../EFWTableRow/EFWTableRow.js";
5
- const T = (l) => {
6
- f(() => {
7
- const e = l.current;
8
- if (!e) return;
9
- let s = 0, d = !1, r = !1;
10
- const c = () => {
11
- cancelAnimationFrame(s), s = requestAnimationFrame(() => {
12
- const i = e.scrollLeft > 0, a = e.scrollTop > 0;
13
- i !== d && (e.classList.toggle("is-scrolling-x", i), d = i), a !== r && (e.classList.toggle("is-scrolling-y", a), r = a);
1
+ import { jsx as a, jsxs as E } from "react/jsx-runtime";
2
+ import { useEffect as p } from "react";
3
+ import { useVirtualizer as S } from "@tanstack/react-virtual";
4
+ import { EFWTableRow as v } from "../EFWTableRow/EFWTableRow.js";
5
+ const y = (e) => {
6
+ p(() => {
7
+ const t = e.current;
8
+ if (!t) return;
9
+ let o = 0, n = !1, c = !1;
10
+ const l = () => {
11
+ cancelAnimationFrame(o), o = requestAnimationFrame(() => {
12
+ const i = t.scrollLeft > 0, s = t.scrollTop > 0;
13
+ i !== n && (t.classList.toggle("is-scrolling-x", i), n = i), s !== c && (t.classList.toggle("is-scrolling-y", s), c = s);
14
14
  });
15
15
  };
16
- return e.addEventListener("scroll", c, { passive: !0 }), c(), () => {
17
- e.removeEventListener("scroll", c), cancelAnimationFrame(s);
16
+ return t.addEventListener("scroll", l, { passive: !0 }), l(), () => {
17
+ t.removeEventListener("scroll", l), cancelAnimationFrame(o);
18
18
  };
19
- }, [l]);
20
- }, j = ({
21
- tableContainerRef: l,
22
- useVirtualization: e,
23
- enableSelection: s = !0,
24
- itemSize: d,
25
- table: r,
19
+ }, [e]);
20
+ }, T = ({
21
+ tableContainerRef: e,
22
+ enableSelection: t = !0,
23
+ itemSize: o,
24
+ table: n,
26
25
  gridTemplateColumns: c,
27
- columnSizing: i,
28
- stickyColumnsInfo: a,
29
- onRowClick: h,
26
+ columnSizing: l,
27
+ stickyColumnsInfo: i,
28
+ onRowClick: s,
30
29
  onRowDoubleClick: w
31
30
  }) => {
32
- const m = r.getRowModel().rows.length, v = m > 0;
33
- T(v ? l : { current: null });
34
- const o = e ? R({
35
- count: m,
36
- getScrollElement: () => l.current,
37
- estimateSize: () => d,
38
- measureElement: typeof window < "u" && navigator.userAgent.indexOf("Firefox") === -1 ? (t) => t?.getBoundingClientRect().height : void 0,
31
+ const d = n.getRowModel().rows.length, g = d > 0;
32
+ y(g ? e : { current: null });
33
+ const m = S({
34
+ count: d,
35
+ getScrollElement: () => e.current,
36
+ estimateSize: () => o,
37
+ measureElement: typeof window < "u" && navigator.userAgent.indexOf("Firefox") === -1 ? (r) => r?.getBoundingClientRect().height : void 0,
39
38
  overscan: 10
40
- }) : null;
41
- f(() => {
42
- !e || !o || requestAnimationFrame(() => {
39
+ });
40
+ p(() => {
41
+ requestAnimationFrame(() => {
43
42
  try {
44
- o.measure();
45
- } catch (t) {
46
- console.warn("Error al recalcular virtualizer:", t);
43
+ m.measure();
44
+ } catch (r) {
45
+ console.warn("Error al recalcular virtualizer:", r);
47
46
  }
48
47
  });
49
- }, [m > 0, e, o]);
50
- const n = o?.getVirtualItems() || [], x = o?.getTotalSize() || 0, u = n.length > 0 ? n[0].start : 0, p = n.length > 0 ? x - n[n.length - 1].end : 0, y = e ? n.map((t) => ({
51
- virtualRow: t,
52
- row: r.getRowModel().rows[t.index]
53
- })) : r.getRowModel().rows.map((t) => ({ row: t, virtualRow: null }));
54
- return /* @__PURE__ */ F("div", { className: "table-body", style: { fontSize: "12px", lineHeight: "16px" }, children: [
55
- e && u > 0 && /* @__PURE__ */ g("div", { style: { height: u } }),
56
- y.map(({ row: t, virtualRow: E }) => /* @__PURE__ */ g(
57
- S,
48
+ }, [d > 0, m]);
49
+ const u = m.getVirtualItems(), z = m.getTotalSize(), f = u.length > 0 ? u[0].start : 0, h = u.length > 0 ? z - u[u.length - 1].end : 0, x = u.map((r) => ({
50
+ virtualRow: r,
51
+ row: n.getRowModel().rows[r.index]
52
+ }));
53
+ return /* @__PURE__ */ E("div", { className: "table-body", style: { fontSize: "12px", lineHeight: "16px" }, children: [
54
+ f > 0 && /* @__PURE__ */ a("div", { style: { height: f } }),
55
+ x.map(({ row: r, virtualRow: R }) => /* @__PURE__ */ a(
56
+ v,
58
57
  {
59
- row: t,
60
- virtualRow: E,
61
- rowVirtualizer: o,
62
- useVirtualization: e,
63
- enableSelection: s,
58
+ row: r,
59
+ virtualRow: R,
60
+ rowVirtualizer: m,
61
+ useVirtualization: !0,
62
+ enableSelection: t,
64
63
  gridTemplateColumns: c,
65
- columnSizing: i,
66
- stickyColumnsInfo: a,
67
- onRowClick: h,
64
+ columnSizing: l,
65
+ stickyColumnsInfo: i,
66
+ onRowClick: s,
68
67
  onRowDoubleClick: w
69
68
  },
70
- t.id
69
+ r.original._rowId || r.id
71
70
  )),
72
- e && p > 0 && /* @__PURE__ */ g("div", { style: { height: p } })
71
+ h > 0 && /* @__PURE__ */ a("div", { style: { height: h } })
73
72
  ] });
74
- };
73
+ }, V = ({
74
+ tableContainerRef: e,
75
+ enableSelection: t = !0,
76
+ table: o,
77
+ gridTemplateColumns: n,
78
+ columnSizing: c,
79
+ stickyColumnsInfo: l,
80
+ onRowClick: i,
81
+ onRowDoubleClick: s
82
+ }) => {
83
+ const d = o.getRowModel().rows.length > 0;
84
+ return y(d ? e : { current: null }), /* @__PURE__ */ a("div", { className: "table-body", style: { fontSize: "12px", lineHeight: "16px" }, children: o.getRowModel().rows.map((g) => /* @__PURE__ */ a(
85
+ v,
86
+ {
87
+ row: g,
88
+ virtualRow: null,
89
+ rowVirtualizer: null,
90
+ useVirtualization: !1,
91
+ enableSelection: t,
92
+ gridTemplateColumns: n,
93
+ columnSizing: c,
94
+ stickyColumnsInfo: l,
95
+ onRowClick: i,
96
+ onRowDoubleClick: s
97
+ },
98
+ g.original._rowId || g.id
99
+ )) });
100
+ }, b = (e) => e.useVirtualization ? /* @__PURE__ */ a(T, { ...e }) : /* @__PURE__ */ a(V, { ...e });
75
101
  export {
76
- j as EFWTableBody
102
+ b as EFWTableBody
77
103
  };
@@ -22,20 +22,6 @@ export interface CommandBarOnClickParams<T extends readonly EFWFormFieldProps[]
22
22
  */
23
23
  tableMethods: EFWTableMethods<T>;
24
24
  }
25
- export interface CommandBarOnClickParams<T extends readonly EFWFormFieldProps[] = EFWFormFieldProps[]> {
26
- /**
27
- * Un arreglo de filas seleccionadas de la tabla.
28
- *
29
- * @type {EFWTableRow[]}
30
- */
31
- selectedRows: EFWTableRow<EFWTableItem<T>>[];
32
- /**
33
- * Métodos disponibles para interactuar con la tabla.
34
- *
35
- * @type {EFWTableMethods}
36
- */
37
- tableMethods: EFWTableMethods<T>;
38
- }
39
25
  export type EFWTableCommandBarButton<T extends readonly EFWFormFieldProps[] = EFWFormFieldProps[]> = EFWGroupButtonConfig<CommandBarOnClickParams<T>> & {
40
26
  enabled?: boolean | ((selectedRows: EFWTableRow<EFWTableItem<T>>[], tableMethods: EFWTableMethods<T>) => boolean);
41
27
  };
@@ -1,2 +1,2 @@
1
1
  export { EFWTableCommandBar } from './EFWTableCommandBar';
2
- export type { EFWTableCommandBarProps } from './EFWTableCommandBar.types';
2
+ export type { EFWTableCommandBarProps, EFWTableCommandBarButton } from './EFWTableCommandBar.types';
@@ -1,9 +1,9 @@
1
1
  import { jsx as s } from "react/jsx-runtime";
2
- import { tokens as o } from "@fluentui/react-components";
3
- import { EFWTableCell as b } from "../EFWTableCell/EFWTableCell.js";
4
- const k = ({
2
+ import { tokens as l } from "@fluentui/react-components";
3
+ import { EFWTableCell as p } from "../EFWTableCell/EFWTableCell.js";
4
+ const o = (r, t) => r ? l.colorNeutralBackground1Selected : t ? l.colorNeutralBackground1Hover : l.colorNeutralBackground1, b = ({
5
5
  row: r,
6
- virtualRow: l,
6
+ virtualRow: t,
7
7
  rowVirtualizer: u,
8
8
  useVirtualization: c,
9
9
  enableSelection: d,
@@ -12,52 +12,48 @@ const k = ({
12
12
  stickyColumnsInfo: i,
13
13
  onRowClick: m,
14
14
  onRowDoubleClick: n
15
- }) => {
16
- const t = (e, p) => e ? o.colorNeutralBackground1Selected : p ? o.colorNeutralBackground1Hover : o.colorNeutralBackground1;
17
- return /* @__PURE__ */ s(
18
- "div",
19
- {
20
- ...c && l ? {
21
- "data-index": l.index,
22
- ref: (e) => u?.measureElement(e)
23
- } : {},
24
- className: "table-row",
25
- onClick: (e) => m(r, e),
26
- onDoubleClick: n ? (e) => n(r, e) : void 0,
27
- style: {
28
- display: "grid",
29
- gridTemplateColumns: a,
30
- cursor: d ? "pointer" : "default",
31
- borderBottom: `0.5px solid ${o.colorNeutralStroke1}`,
32
- backgroundColor: t(r.getIsSelected()),
33
- "--current-row-bg": t(r.getIsSelected())
34
- },
35
- onMouseEnter: d ? (e) => {
36
- e.currentTarget.style.setProperty(
37
- "--current-row-bg",
38
- t(r.getIsSelected(), !0)
39
- );
40
- } : void 0,
41
- onMouseLeave: d ? (e) => {
42
- e.currentTarget.style.setProperty(
43
- "--current-row-bg",
44
- t(r.getIsSelected())
45
- );
46
- } : void 0,
47
- children: r.getVisibleCells().map((e) => /* @__PURE__ */ s(
48
- b,
49
- {
50
- cell: e,
51
- columnSizing: g,
52
- stickyColumnsInfo: i,
53
- useVirtualization: c
54
- },
55
- e.id
56
- ))
15
+ }) => /* @__PURE__ */ s(
16
+ "div",
17
+ {
18
+ ...c && t ? {
19
+ "data-index": t.index,
20
+ ref: (e) => u?.measureElement(e)
21
+ } : {},
22
+ className: "table-row",
23
+ onClick: (e) => m(r, e),
24
+ onDoubleClick: n ? (e) => n(r, e) : void 0,
25
+ style: {
26
+ display: "grid",
27
+ gridTemplateColumns: a,
28
+ cursor: d ? "pointer" : "default",
29
+ borderBottom: `0.5px solid ${l.colorNeutralStroke1}`,
30
+ backgroundColor: o(r.getIsSelected()),
31
+ "--current-row-bg": o(r.getIsSelected())
57
32
  },
58
- r.id
59
- );
60
- }, x = k;
33
+ onMouseEnter: d ? (e) => {
34
+ e.currentTarget.style.setProperty(
35
+ "--current-row-bg",
36
+ o(r.getIsSelected(), !0)
37
+ );
38
+ } : void 0,
39
+ onMouseLeave: d ? (e) => {
40
+ e.currentTarget.style.setProperty(
41
+ "--current-row-bg",
42
+ o(r.getIsSelected())
43
+ );
44
+ } : void 0,
45
+ children: r.getVisibleCells().map((e) => /* @__PURE__ */ s(
46
+ p,
47
+ {
48
+ cell: e,
49
+ columnSizing: g,
50
+ stickyColumnsInfo: i,
51
+ useVirtualization: c
52
+ },
53
+ e.id
54
+ ))
55
+ }
56
+ ), v = b;
61
57
  export {
62
- x as EFWTableRow
58
+ v as EFWTableRow
63
59
  };
@@ -1,5 +1,6 @@
1
1
  export { EFWTable } from './EFWTable';
2
2
  export { useTableController } from './hooks/useTableController/useTableController';
3
3
  export { EFWTableOverlay, EFWTableEmpty } from './components/EFWTableOverlay';
4
- export type { EFWTableProps, EFWTableItem, EFWTableRef, EFWTableMethods } from './EFWTable.types';
4
+ export type { EFWTableProps, EFWTableItem, EFWTableRef, EFWTableMethods, EFWTableCommandBarButtonInput, } from './EFWTable.types';
5
+ export type { EFWTableCommandBarButton } from './components/EFWTableCommandBar';
5
6
  export type { EFWTableOverlayProps, EFWTableOverlayConfig, EFWTableOverlayState, EFWTableOverlayDisplayType, EFWTableOverlayStateConfig, EFWTableOverlayCustomization, EFWTableOverlayBaseOptions, EFWTableLoadingOptions, EFWTableErrorOptions, EFWTablePartialLoadingOptions, EFWTableEmptyOptions, EFWTableEmptyProps, } from './components/EFWTableOverlay';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@envisiongroup/porygon",
3
- "version": "1.0.0-rc.21",
3
+ "version": "1.0.0-rc.23",
4
4
  "description": "Librerias de componentes de React creados por la empresa Envision",
5
5
  "license": "CC-BY-ND-4.0",
6
6
  "main": "./dist/index.js",
@@ -62,7 +62,9 @@
62
62
  "clean": "rm -rf dist",
63
63
  "prepublishOnly": "npm run build",
64
64
  "dev": "vite build --config vite.lib.config.js --watch",
65
- "typecheck": "tsc --noEmit -p tsconfig.json",
65
+ "typecheck": "npm run typecheck:src && npm run typecheck:type-tests",
66
+ "typecheck:src": "tsc --noEmit -p tsconfig.json",
67
+ "typecheck:type-tests": "tsc --noEmit -p tsconfig.type-tests.json",
66
68
  "analyze": "vite build --config vite.lib.config.js && npx vite-bundle-visualizer",
67
69
  "verify:build": "npm run clean && npm run build",
68
70
  "verify:types": "npm run typecheck",