@isai_dev/data_table_lib 0.1.2 → 2.0.0-alpha.3

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/dist/index.js CHANGED
@@ -1,16 +1,16 @@
1
- import { createElement as e, useId as t, useMemo as n, useState as r } from "react";
2
- import { Fragment as i, jsx as a, jsxs as o } from "react/jsx-runtime";
1
+ import { createElement as e, useEffect as t, useId as n, useMemo as r, useRef as i, useState as a } from "react";
2
+ import { Fragment as o, jsx as s, jsxs as c } from "react/jsx-runtime";
3
3
  // src/rowModel.js
4
- var s = (e) => e == null ? "" : String(e);
5
- function c(e, t, n, r) {
6
- let i = t.filter((e) => !e.hidden && e.searchable !== !1), a = String(n ?? "").trim().toLocaleLowerCase();
7
- return e.filter((e) => a && !i.some((t) => s(e[t.field]).toLocaleLowerCase().includes(a)) ? !1 : Object.entries(r ?? {}).every(([n, r]) => {
4
+ var l = (e) => e == null ? "" : String(e), u = (e, t, n) => t.type === "image" ? l((typeof t.imageAlt == "function" ? t.imageAlt(e, n) : t.imageAlt) ?? e?.alt) : l(e);
5
+ function d(e, t, n, r) {
6
+ let i = t.filter((e) => !e.hidden && e.searchable !== !1 && (e.type !== "image" || e.searchable === !0)), a = String(n ?? "").trim().toLocaleLowerCase();
7
+ return e.filter((e) => a && !i.some((t) => u(e[t.field], t, e).toLocaleLowerCase().includes(a)) ? !1 : Object.entries(r ?? {}).every(([n, r]) => {
8
8
  if (r == null || r === "") return !0;
9
9
  let i = t.find((e) => e.field === n);
10
- return i ? i.filterFn ? i.filterFn(e[n], r, e) : s(e[n]).toLocaleLowerCase().includes(s(r).toLocaleLowerCase()) : !0;
10
+ return i ? i.filterFn ? i.filterFn(e[n], r, e) : u(e[n], i, e).toLocaleLowerCase().includes(l(r).toLocaleLowerCase()) : !0;
11
11
  }));
12
12
  }
13
- function l(e, t, n) {
13
+ function f(e, t, n) {
14
14
  if (!t?.field || !t?.direction) return e;
15
15
  let r = n.find((e) => e.field === t.field);
16
16
  if (!r) return e;
@@ -22,20 +22,393 @@ function l(e, t, n) {
22
22
  row: e,
23
23
  index: t
24
24
  })).sort((e, n) => {
25
- let o = e.row[t.field], c = n.row[t.field];
26
- return o == null && c == null ? e.index - n.index : o == null ? 1 : c == null ? -1 : (r.sortFn ? r.sortFn(o, c, e.row, n.row) : typeof o == "number" && typeof c == "number" ? o - c : a.compare(s(o), s(c))) * i || e.index - n.index;
25
+ let o = e.row[t.field], s = n.row[t.field];
26
+ return o == null && s == null ? e.index - n.index : o == null ? 1 : s == null ? -1 : (r.sortFn ? r.sortFn(o, s, e.row, n.row) : typeof o == "number" && typeof s == "number" ? o - s : a.compare(u(o, r, e.row), u(s, r, n.row))) * i || e.index - n.index;
27
27
  }).map(({ row: e }) => e);
28
28
  }
29
- function u(e, t, n) {
29
+ function p(e, t, n) {
30
30
  return e.slice(t * n, (t + 1) * n);
31
31
  }
32
+ // src/ActionIcon.jsx
33
+ var m = {
34
+ view: /* @__PURE__ */ c(o, { children: [/* @__PURE__ */ s("path", { d: "M2 12s3.5-5 10-5 10 5 10 5-3.5 5-10 5S2 12 2 12Z" }), /* @__PURE__ */ s("circle", {
35
+ cx: "12",
36
+ cy: "12",
37
+ r: "2.5"
38
+ })] }),
39
+ edit: /* @__PURE__ */ c(o, { children: [/* @__PURE__ */ s("path", { d: "M12 20h9" }), /* @__PURE__ */ s("path", { d: "M16.5 3.5a2.1 2.1 0 0 1 3 3L8 18l-4 1 1-4L16.5 3.5Z" })] }),
40
+ delete: /* @__PURE__ */ s(o, { children: /* @__PURE__ */ s("path", { d: "M4 7h16M9 7V4h6v3M6 7l1 13h10l1-13M10 11v6M14 11v6" }) }),
41
+ download: /* @__PURE__ */ s(o, { children: /* @__PURE__ */ s("path", { d: "M12 3v12m-4-4 4 4 4-4M4 17v4h16v-4" }) }),
42
+ more: /* @__PURE__ */ c(o, { children: [
43
+ /* @__PURE__ */ s("circle", {
44
+ cx: "5",
45
+ cy: "12",
46
+ r: "1"
47
+ }),
48
+ /* @__PURE__ */ s("circle", {
49
+ cx: "12",
50
+ cy: "12",
51
+ r: "1"
52
+ }),
53
+ /* @__PURE__ */ s("circle", {
54
+ cx: "19",
55
+ cy: "12",
56
+ r: "1"
57
+ })
58
+ ] }),
59
+ check: /* @__PURE__ */ s("path", { d: "m4 12 5 5L20 6" }),
60
+ close: /* @__PURE__ */ s("path", { d: "M5 5 19 19M19 5 5 19" })
61
+ }, h = (e) => Object.hasOwn(m, e);
62
+ function g({ name: e }) {
63
+ return h(e) ? /* @__PURE__ */ s("svg", {
64
+ className: "dt-action-icon",
65
+ width: "18",
66
+ height: "18",
67
+ viewBox: "0 0 24 24",
68
+ fill: "none",
69
+ stroke: "currentColor",
70
+ strokeWidth: "1.8",
71
+ strokeLinecap: "round",
72
+ strokeLinejoin: "round",
73
+ "aria-hidden": "true",
74
+ focusable: "false",
75
+ children: m[e]
76
+ }) : null;
77
+ }
78
+ // src/ImageCell.jsx
79
+ function _(e, t, n) {
80
+ return {
81
+ source: typeof e == "string" ? e : e?.src,
82
+ alt: (typeof n.imageAlt == "function" ? n.imageAlt(e, t) : n.imageAlt) ?? e?.alt ?? (t?.name ? `Foto de ${t.name}` : n.headerName ?? n.field),
83
+ srcSet: typeof e == "string" ? void 0 : e?.srcSet,
84
+ sizes: typeof e == "string" ? void 0 : e?.sizes,
85
+ width: typeof e == "string" ? void 0 : e?.width,
86
+ height: typeof e == "string" ? void 0 : e?.height
87
+ };
88
+ }
89
+ function v({ value: e, row: n, column: r, view: i, onOpen: o, openLabel: c }) {
90
+ let { source: l, alt: u, srcSet: d, sizes: f, width: p, height: m } = _(e, n, r), [h, g] = a(!1);
91
+ if (t(() => g(!1), [l, d]), !l || h) return /* @__PURE__ */ s("span", {
92
+ className: `dt-image-placeholder dt-image-${i}`,
93
+ children: r.imageFallback ?? "Sin foto"
94
+ });
95
+ let v = /* @__PURE__ */ s("img", {
96
+ className: `dt-image dt-image-${i}`,
97
+ src: l,
98
+ alt: u,
99
+ srcSet: d,
100
+ sizes: d ? f ?? (i === "gallery" ? "(max-width: 640px) 100vw, 33vw" : i === "avatar" ? "42px" : i === "thumbnail" ? "64px" : "96px") : void 0,
101
+ width: p,
102
+ height: m,
103
+ loading: "lazy",
104
+ decoding: "async",
105
+ style: {
106
+ objectFit: r.imageFit ?? "cover",
107
+ objectPosition: r.imagePosition ?? "center"
108
+ },
109
+ onError: () => g(!0)
110
+ });
111
+ return o ? /* @__PURE__ */ s("button", {
112
+ type: "button",
113
+ className: "dt-image-trigger",
114
+ "aria-label": c(u),
115
+ onClick: o,
116
+ children: v
117
+ }) : v;
118
+ }
119
+ // src/ImagePreview.jsx
120
+ function y({ entry: e, previous: n, next: r, onPrevious: a, onNext: o, onClose: l, labels: u }) {
121
+ let d = i(null);
122
+ return t(() => {
123
+ e && d.current && !d.current.open && d.current.showModal?.();
124
+ }, [e]), e ? /* @__PURE__ */ c("dialog", {
125
+ ref: d,
126
+ className: "dt-image-dialog",
127
+ "aria-label": u.imagePreview,
128
+ onClose: l,
129
+ children: [
130
+ /* @__PURE__ */ c("div", {
131
+ className: "dt-image-dialog-header",
132
+ children: [/* @__PURE__ */ s("strong", { children: e.alt }), /* @__PURE__ */ s("button", {
133
+ type: "button",
134
+ className: "dt-button",
135
+ onClick: () => {
136
+ d.current?.open && d.current.close(), l();
137
+ },
138
+ "aria-label": u.imageClose,
139
+ children: "×"
140
+ })]
141
+ }),
142
+ /* @__PURE__ */ s("img", {
143
+ src: e.source,
144
+ srcSet: e.srcSet,
145
+ sizes: e.srcSet ? "(max-width: 760px) 92vw, 760px" : void 0,
146
+ width: e.width,
147
+ height: e.height,
148
+ alt: e.alt
149
+ }),
150
+ /* @__PURE__ */ c("div", {
151
+ className: "dt-image-dialog-actions",
152
+ children: [/* @__PURE__ */ s("button", {
153
+ type: "button",
154
+ className: "dt-button",
155
+ disabled: !n,
156
+ onClick: a,
157
+ children: u.imagePrevious
158
+ }), /* @__PURE__ */ s("button", {
159
+ type: "button",
160
+ className: "dt-button",
161
+ disabled: !r,
162
+ onClick: o,
163
+ children: u.imageNext
164
+ })]
165
+ })
166
+ ]
167
+ }) : null;
168
+ }
169
+ // src/ColumnControls.jsx
170
+ function ee({ columns: e, visibleFields: t, onMove: n, onToggle: r, onReset: i, orderReadOnly: a, visibilityReadOnly: o, labels: l }) {
171
+ let u = t.length;
172
+ return /* @__PURE__ */ c("details", {
173
+ className: "dt-column-controls",
174
+ children: [/* @__PURE__ */ s("summary", {
175
+ className: "dt-button",
176
+ children: l.columns
177
+ }), /* @__PURE__ */ c("div", {
178
+ className: "dt-column-panel",
179
+ children: [/* @__PURE__ */ c("div", {
180
+ className: "dt-column-panel-heading",
181
+ children: [/* @__PURE__ */ s("strong", { children: l.columns }), /* @__PURE__ */ s("button", {
182
+ type: "button",
183
+ className: "dt-column-reset",
184
+ onClick: i,
185
+ disabled: a && o,
186
+ children: l.resetColumns
187
+ })]
188
+ }), /* @__PURE__ */ s("ul", { children: e.map((i, d) => {
189
+ let f = i.headerName ?? i.field, p = t.includes(i.field), m = e[d - 1], h = e[d + 1];
190
+ return /* @__PURE__ */ c("li", { children: [/* @__PURE__ */ c("label", {
191
+ className: "dt-column-toggle",
192
+ children: [/* @__PURE__ */ s("input", {
193
+ type: "checkbox",
194
+ checked: p,
195
+ disabled: o || i.hideable === !1 || p && u <= 1,
196
+ onChange: (e) => r(i.field, e.target.checked)
197
+ }), /* @__PURE__ */ s("span", { children: f })]
198
+ }), /* @__PURE__ */ c("span", {
199
+ className: "dt-column-move",
200
+ children: [/* @__PURE__ */ s("button", {
201
+ type: "button",
202
+ className: "dt-button",
203
+ "aria-label": l.moveColumnUp(f),
204
+ title: l.moveColumnUp(f),
205
+ disabled: a || !m || i.reorderable === !1 || m.reorderable === !1,
206
+ onClick: () => n(i.field, -1),
207
+ children: "↑"
208
+ }), /* @__PURE__ */ s("button", {
209
+ type: "button",
210
+ className: "dt-button",
211
+ "aria-label": l.moveColumnDown(f),
212
+ title: l.moveColumnDown(f),
213
+ disabled: a || !h || i.reorderable === !1 || h.reorderable === !1,
214
+ onClick: () => n(i.field, 1),
215
+ children: "↓"
216
+ })]
217
+ })] }, i.field);
218
+ }) })]
219
+ })]
220
+ });
221
+ }
222
+ // src/GalleryView.jsx
223
+ function te({ caption: e, rows: t, imageColumn: n, titleField: r, descriptionField: i, getRowId: a, selectedSet: o, selectable: l, onSelect: u, actions: d, renderAction: f, onImageOpen: p, sortColumns: m, filterColumns: h, sort: g, filters: _, onSortField: y, onSortDirection: ee, onFilter: te, sortReadOnly: b, filterReadOnly: ne, onTogglePage: re, selectedPageCount: x, gallery: S, loading: ie, loadingMessage: ae, emptyMessage: oe, labels: C }) {
224
+ let w = typeof e == "string" ? e : C.gallery, se = [
225
+ "square",
226
+ "landscape",
227
+ "portrait"
228
+ ].includes(S.aspectRatio) ? S.aspectRatio : "landscape", T = S.cardSize === "compact" ? "compact" : "comfortable", ce = m.length > 0 || h.length > 0 || l;
229
+ return /* @__PURE__ */ c("section", {
230
+ className: "dt-gallery",
231
+ "aria-label": w,
232
+ "aria-busy": ie,
233
+ children: [
234
+ e && /* @__PURE__ */ s("div", {
235
+ className: "dt-gallery-heading",
236
+ children: e
237
+ }),
238
+ ce && /* @__PURE__ */ c("div", {
239
+ className: "dt-gallery-controls",
240
+ children: [
241
+ m.length > 0 && /* @__PURE__ */ c("div", {
242
+ className: "dt-gallery-sort",
243
+ children: [/* @__PURE__ */ c("label", { children: [C.gallerySort, /* @__PURE__ */ c("select", {
244
+ className: "dt-control",
245
+ value: g?.field ?? "",
246
+ disabled: b,
247
+ onChange: (e) => y(e.target.value),
248
+ children: [/* @__PURE__ */ s("option", {
249
+ value: "",
250
+ children: C.galleryNoSort
251
+ }), m.map((e) => /* @__PURE__ */ s("option", {
252
+ value: e.field,
253
+ children: e.headerName ?? e.field
254
+ }, e.field))]
255
+ })] }), /* @__PURE__ */ s("button", {
256
+ type: "button",
257
+ className: "dt-button",
258
+ disabled: !g || b,
259
+ "aria-label": g?.direction === "desc" ? C.galleryAscending : C.galleryDescending,
260
+ onClick: ee,
261
+ children: g?.direction === "desc" ? "↓" : "↑"
262
+ })]
263
+ }),
264
+ h.map((e) => /* @__PURE__ */ c("label", {
265
+ className: "dt-gallery-filter",
266
+ children: [C.filter(e.headerName ?? e.field), /* @__PURE__ */ s("input", {
267
+ className: "dt-control",
268
+ type: "search",
269
+ disabled: ne,
270
+ value: _[e.field] ?? "",
271
+ placeholder: C.filterPlaceholder,
272
+ onChange: (t) => te(e.field, t.target.value)
273
+ })]
274
+ }, e.field)),
275
+ l && /* @__PURE__ */ c("label", {
276
+ className: "dt-gallery-select-page",
277
+ children: [/* @__PURE__ */ s("input", {
278
+ type: "checkbox",
279
+ checked: t.length > 0 && x === t.length,
280
+ disabled: ie || t.length === 0,
281
+ ref: (e) => {
282
+ e && (e.indeterminate = x > 0 && x < t.length);
283
+ },
284
+ onChange: re
285
+ }), C.selectPage]
286
+ })
287
+ ]
288
+ }),
289
+ ie ? /* @__PURE__ */ s("div", {
290
+ className: "dt-message",
291
+ role: "status",
292
+ children: ae
293
+ }) : t.length === 0 ? /* @__PURE__ */ s("div", {
294
+ className: "dt-message dt-gallery-empty",
295
+ children: oe
296
+ }) : /* @__PURE__ */ s("ul", {
297
+ className: `dt-gallery-grid dt-gallery-grid-${T}`,
298
+ children: t.map((e, t) => {
299
+ let m = a(e, t), h = String(m), g = e?.[n.field], _ = e?.[r], y = i ? e?.[i] : null;
300
+ return /* @__PURE__ */ s("li", {
301
+ className: "dt-gallery-item",
302
+ children: /* @__PURE__ */ c("article", {
303
+ className: "dt-gallery-card",
304
+ "aria-label": String(_ ?? m),
305
+ children: [/* @__PURE__ */ s("div", {
306
+ className: `dt-gallery-media dt-gallery-media-${se}`,
307
+ children: /* @__PURE__ */ s(v, {
308
+ value: g,
309
+ row: e,
310
+ column: n,
311
+ view: "gallery",
312
+ openLabel: C.imageOpen,
313
+ onOpen: n.previewable || n.onImageClick ? () => p(g, e, m) : void 0
314
+ })
315
+ }), /* @__PURE__ */ c("div", {
316
+ className: "dt-gallery-content",
317
+ children: [
318
+ /* @__PURE__ */ c("div", {
319
+ className: "dt-gallery-title-row",
320
+ children: [/* @__PURE__ */ s("h3", { children: String(_ ?? m) }), l && /* @__PURE__ */ s("input", {
321
+ type: "checkbox",
322
+ checked: o.has(h),
323
+ "aria-label": C.selectRow(m),
324
+ onChange: () => u(m)
325
+ })]
326
+ }),
327
+ y != null && y !== "" && /* @__PURE__ */ s("p", { children: String(y) }),
328
+ S.renderDetails && /* @__PURE__ */ s("div", {
329
+ className: "dt-gallery-details",
330
+ children: S.renderDetails(e, t)
331
+ }),
332
+ d.length > 0 && /* @__PURE__ */ s("div", {
333
+ className: "dt-actions",
334
+ children: d.map((t, n) => f(t, e, n))
335
+ })
336
+ ]
337
+ })]
338
+ })
339
+ }, h);
340
+ })
341
+ })
342
+ ]
343
+ });
344
+ }
345
+ // src/columnState.js
346
+ function b(e, t) {
347
+ let n = t.filter((e) => !e.hidden).map((e) => e.field), r = new Set(n), i = [];
348
+ for (let t of Array.isArray(e) ? e : []) r.has(t) && !i.includes(t) && i.push(t);
349
+ for (let e of n) i.includes(e) || i.push(e);
350
+ return i;
351
+ }
352
+ function ne(e, t) {
353
+ if (!e || typeof window > "u") return {
354
+ key: e,
355
+ ...t
356
+ };
357
+ try {
358
+ let n = JSON.parse(window.localStorage.getItem(e) ?? "null");
359
+ return {
360
+ key: e,
361
+ order: Array.isArray(n?.order) ? n.order : t.order,
362
+ visibility: n?.visibility && typeof n.visibility == "object" && !Array.isArray(n.visibility) ? n.visibility : t.visibility
363
+ };
364
+ } catch {
365
+ return {
366
+ key: e,
367
+ ...t
368
+ };
369
+ }
370
+ }
371
+ function re(e, t, n) {
372
+ if (e && typeof window < "u") try {
373
+ window.localStorage.setItem(e, JSON.stringify({
374
+ order: t,
375
+ visibility: n
376
+ }));
377
+ } catch {}
378
+ }
379
+ // src/layoutState.js
380
+ var x = /* @__PURE__ */ new Set(["table", "gallery"]);
381
+ function S(e, t) {
382
+ let n = x.has(t) ? t : "table";
383
+ if (!e || typeof window > "u") return {
384
+ key: e,
385
+ layout: n
386
+ };
387
+ try {
388
+ let t = JSON.parse(window.localStorage.getItem(e) ?? "null");
389
+ return {
390
+ key: e,
391
+ layout: x.has(t?.layout) ? t.layout : n
392
+ };
393
+ } catch {
394
+ return {
395
+ key: e,
396
+ layout: n
397
+ };
398
+ }
399
+ }
400
+ function ie(e, t) {
401
+ if (e && typeof window < "u" && x.has(t)) try {
402
+ window.localStorage.setItem(e, JSON.stringify({ layout: t }));
403
+ } catch {}
404
+ }
32
405
  // src/TableBase.jsx
33
- var d = (e, t) => e?.id ?? t, ee = {
406
+ var ae = (e, t) => e?.id ?? t, oe = {
34
407
  pageIndex: 0,
35
408
  pageSize: 10
36
409
  };
37
- function f({ checked: e, mixed: t, onChange: n, label: r }) {
38
- return /* @__PURE__ */ a("input", {
410
+ function C({ checked: e, mixed: t, onChange: n, label: r }) {
411
+ return /* @__PURE__ */ s("input", {
39
412
  type: "checkbox",
40
413
  checked: e,
41
414
  "aria-checked": t ? "mixed" : e,
@@ -46,40 +419,66 @@ function f({ checked: e, mixed: t, onChange: n, label: r }) {
46
419
  }
47
420
  });
48
421
  }
49
- function p({ row: t, column: n, rowIndex: r, editable: i, saveMode: s, onEdit: c, error: l, errorId: u, disabled: d, fileVersion: ee, selectOptionLabel: f }) {
50
- let p = t?.[n.field];
51
- if (typeof n.renderCell == "function") return n.renderCell(p, t, r);
52
- if (!i) return p ?? null;
53
- let m = {
54
- name: n.field,
55
- "aria-label": n.headerName || n.field,
56
- "aria-invalid": !!l || void 0,
57
- "aria-describedby": l ? u : void 0,
58
- disabled: d,
59
- onChange: (e) => c(e, t, n)
60
- };
61
- return n.type === "button" ? /* @__PURE__ */ o("button", {
422
+ function w({ action: e, onClick: t, disabled: n }) {
423
+ let r = e.icon ?? (h(e.iconName) ? /* @__PURE__ */ s(g, { name: e.iconName }) : null), i = e.ariaLabel ?? (typeof e.label == "string" ? e.label : void 0), a = !!(r && i && (e.iconOnly || e.label == null)), o = ["primary", "danger"].includes(e.variant) ? e.variant : "default";
424
+ return /* @__PURE__ */ c("button", {
62
425
  type: "button",
63
- className: "dt-button",
64
- style: n.style,
65
- "aria-label": n.ariaLabel ?? (typeof n.label == "string" ? n.label : void 0),
66
- disabled: d,
67
- onClick: (e) => n.onClick?.(e, t),
426
+ className: `dt-button dt-action-button dt-action-${o} ${a ? "dt-icon-only" : ""} ${e.className ?? ""}`.trim(),
427
+ style: e.style,
428
+ disabled: n || e.disabled,
429
+ "aria-label": i,
430
+ title: a ? i : void 0,
431
+ onClick: t,
68
432
  children: [
69
- n.label,
70
- " ",
71
- n.icon
433
+ r && e.iconPosition !== "end" && /* @__PURE__ */ s("span", {
434
+ className: "dt-action-symbol",
435
+ children: r
436
+ }),
437
+ e.label != null && /* @__PURE__ */ s("span", {
438
+ className: a ? "dt-visually-hidden" : "dt-action-label",
439
+ children: e.label
440
+ }),
441
+ r && e.iconPosition === "end" && /* @__PURE__ */ s("span", {
442
+ className: "dt-action-symbol",
443
+ children: r
444
+ })
72
445
  ]
73
- }) : n.type === "select" ? /* @__PURE__ */ o("select", {
74
- ...m,
446
+ });
447
+ }
448
+ function se({ row: t, column: n, rowIndex: r, imageView: i, imageOpenLabel: a, onImageOpen: o, editable: l, saveMode: u, onEdit: d, error: f, errorId: p, disabled: m, fileVersion: h, selectOptionLabel: g }) {
449
+ let _ = t?.[n.field];
450
+ if (typeof n.renderCell == "function") return n.renderCell(_, t, r);
451
+ if (n.type === "image") return /* @__PURE__ */ s(v, {
452
+ value: _,
453
+ row: t,
454
+ column: n,
455
+ view: i,
456
+ openLabel: a,
457
+ onOpen: n.previewable || n.onImageClick ? () => o(_, t, n) : void 0
458
+ });
459
+ if (!l) return _ ?? null;
460
+ let y = {
461
+ name: n.field,
462
+ "aria-label": n.headerName || n.field,
463
+ "aria-invalid": !!f || void 0,
464
+ "aria-describedby": f ? p : void 0,
465
+ disabled: m,
466
+ onChange: (e) => d(e, t, n)
467
+ };
468
+ return n.type === "button" ? /* @__PURE__ */ s(w, {
469
+ action: n,
470
+ disabled: m,
471
+ onClick: (e) => n.onClick?.(e, t)
472
+ }) : n.type === "select" ? /* @__PURE__ */ c("select", {
473
+ ...y,
75
474
  className: "dt-control",
76
- value: p ?? "",
77
- disabled: d || !s && !n.onChange,
78
- children: [p == null && /* @__PURE__ */ a("option", {
475
+ value: _ ?? "",
476
+ disabled: m || !u && !n.onChange,
477
+ children: [_ == null && /* @__PURE__ */ s("option", {
79
478
  value: "",
80
479
  disabled: !0,
81
- children: n.placeholder ?? f
82
- }), (n.options ?? []).map((e) => /* @__PURE__ */ a("option", {
480
+ children: n.placeholder ?? g
481
+ }), (n.options ?? []).map((e) => /* @__PURE__ */ s("option", {
83
482
  value: e.value,
84
483
  children: e.label
85
484
  }, String(e.value)))]
@@ -89,20 +488,20 @@ function p({ row: t, column: n, rowIndex: r, editable: i, saveMode: s, onEdit: c
89
488
  "number",
90
489
  "file"
91
490
  ].includes(n.type) ? n.type === "file" ? /* @__PURE__ */ e("input", {
92
- ...m,
93
- key: ee,
491
+ ...y,
492
+ key: h,
94
493
  className: "dt-control",
95
494
  type: "file"
96
- }) : /* @__PURE__ */ a("input", {
97
- ...m,
495
+ }) : /* @__PURE__ */ s("input", {
496
+ ...y,
98
497
  className: "dt-control",
99
498
  type: n.type,
100
- value: p ?? "",
101
- readOnly: !s && !n.onChange
102
- }) : p ?? null;
499
+ value: _ ?? "",
500
+ readOnly: !u && !n.onChange
501
+ }) : _ ?? null;
103
502
  }
104
- function m({ columns: e = [], rows: s = [], actions: m = [], caption: h, editable: g = !1, legacyEditActions: te = !1, getRowId: _ = d, actionsHeader: v = "Acciones", emptyMessage: ne = "No hay datos", className: re = "", sortable: ie = !1, sort: y, onSortChange: ae, searchable: oe = !1, search: b, onSearchChange: se, searchPlaceholder: ce = "Buscar…", filters: x, onFiltersChange: le, paginationEnabled: ue = !1, pagination: S, onPaginationChange: de, manualSorting: C = !1, manualFiltering: fe = !1, manualPagination: pe = !1, rowCount: me, selectable: w = !1, selectedRowIds: T, onSelectionChange: he, loading: E = !1, error: ge, loadingMessage: _e = "Cargando…", editMode: ve = "immediate", onSave: D, onCancel: ye, previousLabel: be = "Anterior", nextLabel: xe = "Siguiente", saveLabel: Se = "Guardar", cancelLabel: Ce = "Cancelar", labels: we = {} }) {
105
- let O = {
503
+ function T({ columns: e = [], rows: i = [], actions: l = [], bulkActions: u = [], caption: m, editable: h = !1, legacyEditActions: v = !1, getRowId: x = ae, actionsHeader: T = "Acciones", emptyMessage: ce = "No hay datos", className: le = "", sortable: ue = !1, sort: de, onSortChange: fe, searchable: pe = !1, search: me, onSearchChange: he, searchPlaceholder: ge = "Buscar…", filters: E, onFiltersChange: _e, paginationEnabled: ve = !1, pagination: ye, onPaginationChange: be, manualSorting: xe = !1, manualFiltering: Se = !1, manualPagination: Ce = !1, rowCount: we, selectable: D = !1, selectedRowIds: Te, onSelectionChange: Ee, defaultImageView: De = "thumbnail", imageView: Oe, onImageViewChange: ke, allowImageViewChange: Ae = !1, allowColumnCustomization: je = !1, columnOrder: Me, defaultColumnOrder: Ne, onColumnOrderChange: Pe, columnVisibility: Fe, defaultColumnVisibility: Ie, onColumnVisibilityChange: Le, columnPreferencesKey: O, defaultLayout: Re = "table", layout: ze, onLayoutChange: Be, allowLayoutChange: Ve = !1, layoutPreferencesKey: k, gallery: A = {}, loading: j = !1, error: He, loadingMessage: Ue = "Cargando…", editMode: We = "immediate", onSave: Ge, onCancel: Ke, previousLabel: qe = "Anterior", nextLabel: Je = "Siguiente", saveLabel: Ye = "Guardar", cancelLabel: Xe = "Cancelar", labels: Ze = {} }) {
504
+ let M = {
106
505
  search: "Buscar en la tabla",
107
506
  filter: (e) => `Filtrar ${e}`,
108
507
  filterPlaceholder: "Filtrar…",
@@ -110,67 +509,148 @@ function m({ columns: e = [], rows: s = [], actions: m = [], caption: h, editabl
110
509
  selectRow: (e) => `Seleccionar fila ${e}`,
111
510
  rowsPerPage: "Filas por página",
112
511
  selectOption: "Selecciona una opción",
113
- ...we
114
- }, [Te, Ee] = r(null), [De, Oe] = r(""), [ke, Ae] = r({}), [je, Me] = r(ee), [Ne, Pe] = r([]), [k, A] = r({}), [Fe, j] = r({}), [Ie, M] = r({}), [N, P] = r({}), [Le, Re] = r({}), ze = t().replace(/:/g, ""), F = y === void 0 ? Te : y, I = b === void 0 ? De : b, L = x === void 0 ? ke : x, Be = S ?? je, R = T === void 0 ? Ne : T, z = g && ve === "save", B = e.filter((e) => !e.hidden), Ve = Array.isArray(m) ? m : [], V = Ve.length > 0 || z, He = oe || b !== void 0, H = ue || S !== void 0, Ue = B.length + +!!w + +!!V, U = n(() => {
115
- let t = fe ? s : c(s, e, I, L);
116
- return C ? t : l(t, F, e);
512
+ imageView: "Vista de fotos",
513
+ imageAvatar: "Avatares",
514
+ imageThumbnail: "Miniaturas",
515
+ imageLarge: "Grandes",
516
+ imageHidden: "Ocultar fotos",
517
+ imageOpen: (e) => `Ampliar ${e}`,
518
+ imagePreview: "Vista ampliada de la foto",
519
+ imagePrevious: "Anterior foto",
520
+ imageNext: "Siguiente foto",
521
+ imageClose: "Cerrar foto",
522
+ columns: "Columnas",
523
+ resetColumns: "Restablecer",
524
+ moveColumnUp: (e) => `Mover ${e} a la izquierda`,
525
+ moveColumnDown: (e) => `Mover ${e} a la derecha`,
526
+ layout: "Presentación",
527
+ layoutTable: "Tabla",
528
+ layoutGallery: "Galería",
529
+ gallery: "Galería de fotos",
530
+ gallerySort: "Ordenar por",
531
+ galleryNoSort: "Sin ordenar",
532
+ galleryAscending: "Orden ascendente",
533
+ galleryDescending: "Orden descendente",
534
+ selectedCount: (e) => `${e} ${e === 1 ? "seleccionado" : "seleccionados"}`,
535
+ bulkActions: "Acciones de selección",
536
+ clearSelection: "Limpiar selección",
537
+ ...Ze
538
+ }, [Qe, $e] = a(null), [et, tt] = a(""), [nt, rt] = a({}), [it, at] = a(oe), [ot, st] = a([]), [ct, lt] = a(De), [N, ut] = a(() => S(k, Re)), dt = N.key === k ? N.layout : S(k, Re).layout, P = {
539
+ order: Ne ?? e.map((e) => e.field),
540
+ visibility: Ie ?? {}
541
+ }, [ft, pt] = a(() => ne(O, P)), mt = ft.key === O ? ft : ne(O, P), [F, ht] = a(null), [gt, _t] = a({}), [vt, yt] = a({}), [bt, xt] = a({}), [St, Ct] = a({}), [wt, Tt] = a({}), Et = n().replace(/:/g, "");
542
+ t(() => {
543
+ ft.key !== O && pt(mt);
544
+ }, [O, ft.key]), t(() => {
545
+ N.key !== k && ut(S(k, Re));
546
+ }, [k, N.key]);
547
+ let I = de === void 0 ? Qe : de, Dt = me === void 0 ? et : me, L = E === void 0 ? nt : E, Ot = ye ?? it, R = Te === void 0 ? ot : Te, z = Oe ?? ct, kt = ze ?? dt, At = b(Me ?? mt.order, e), B = Fe ?? mt.visibility, V = new Map(e.map((e) => [e.field, e])), jt = At.map((e) => V.get(e)), Mt = jt.filter((e) => !e.hidden), Nt = Mt.filter((e) => B[e.field] !== !1).map((e) => e.field), H = h && We === "save", Pt = e.some((e) => e.type === "image" && !e.hidden), U = jt.filter((e) => !e.hidden && B[e.field] !== !1 && (e.type !== "image" || z !== "hidden")), Ft = e.find((e) => e.type === "image" && e.field === A.imageField) ?? e.find((e) => e.type === "image" && !e.hidden), W = !h && Ft && kt === "gallery" ? "gallery" : "table", It = A.titleField ?? U.find((e) => e.type !== "image")?.field, Lt = A.descriptionField, Rt = e.filter((e) => !e.hidden && e.type !== "image" && (ue || e.sortable) && e.sortable !== !1), zt = e.filter((e) => !e.hidden && e.type !== "image" && e.filterable), Bt = Array.isArray(l) ? l : [], Vt = Array.isArray(u) ? u : [], Ht = Bt.length > 0 || H, Ut = pe || me !== void 0, Wt = Ae && Pt, Gt = je && Mt.length > 0, Kt = !h && !!Ft && Ve, qt = Me !== void 0 && !Pe, Jt = Fe !== void 0 && !Le, Yt = ve || ye !== void 0, Xt = U.length + +!!D + +!!Ht, Zt = r(() => {
548
+ let t = e.map((e) => ({
549
+ ...e,
550
+ hidden: e.hidden || B[e.field] === !1 || e.type === "image" && z === "hidden"
551
+ })), n = Se ? i : d(i, t, Dt, L);
552
+ return xe ? n : f(n, I, e);
117
553
  }, [
118
- s,
554
+ i,
119
555
  e,
120
- I,
556
+ B,
557
+ z,
558
+ Dt,
121
559
  L,
122
- F,
123
- fe,
124
- C
125
- ]), W = pe ? me ?? s.length : U.length, G = Math.max(1, Number(Be.pageSize) || 10), We = Math.max(0, Math.ceil(W / G) - 1), K = Math.max(0, Math.min(Number(Be.pageIndex) || 0, We)), q = H && !pe ? u(U, K, G) : U, J = new Set(R.map(String)), Y = q.map((e, t) => _(e, t)), X = Y.filter((e) => J.has(String(e))).length, Z = (e) => {
560
+ I,
561
+ Se,
562
+ xe
563
+ ]), Qt = Ce ? we ?? i.length : Zt.length, G = Math.max(1, Number(Ot.pageSize) || 10), $t = Math.max(0, Math.ceil(Qt / G) - 1), K = Math.max(0, Math.min(Number(Ot.pageIndex) || 0, $t)), q = Yt && !Ce ? p(Zt, K, G) : Zt, en = F && V.get(F.field), J = en ? q.map((e, t) => ({
564
+ ..._(e?.[en.field], e, en),
565
+ rowId: x(e, t)
566
+ })).filter((e) => e.source) : [], Y = J.findIndex((e) => String(e.rowId) === String(F?.rowId)), tn = J[Y] ?? null, X = new Set(R.map(String)), Z = q.map((e, t) => x(e, t)), Q = Z.filter((e) => X.has(String(e))).length, nn = (e) => {
126
567
  let t = {
127
568
  pageIndex: Math.max(0, e.pageIndex),
128
569
  pageSize: e.pageSize
129
570
  };
130
- S === void 0 && Me(t), de?.(t);
131
- }, Q = () => {
132
- H && K !== 0 && Z({
571
+ ye === void 0 && at(t), be?.(t);
572
+ }, rn = () => {
573
+ Yt && K !== 0 && nn({
133
574
  pageIndex: 0,
134
575
  pageSize: G
135
576
  });
136
- }, Ge = (e) => {
577
+ }, an = (e) => {
578
+ de === void 0 && $e(e), fe?.(e), rn();
579
+ }, on = (e) => {
137
580
  let t = {
138
581
  field: e.field,
139
- direction: F?.field === e.field && F.direction === "asc" ? "desc" : "asc"
582
+ direction: I?.field === e.field && I.direction === "asc" ? "desc" : "asc"
140
583
  };
141
- y === void 0 && Ee(t), ae?.(t), Q();
142
- }, Ke = (e) => {
143
- b === void 0 && Oe(e), se?.(e), Q();
144
- }, qe = (e, t) => {
584
+ an(t);
585
+ }, sn = (e) => {
586
+ me === void 0 && tt(e), he?.(e), rn();
587
+ }, cn = (e, t) => {
145
588
  let n = {
146
589
  ...L,
147
590
  [e]: t
148
591
  };
149
- x === void 0 && Ae(n), le?.(n), Q();
150
- }, Je = (e) => {
151
- T === void 0 && Pe(e), he?.(e, s.filter((t, n) => e.some((e) => String(e) === String(_(t, n)))));
152
- }, Ye = () => {
153
- let e = Y.length > 0 && X === Y.length ? R.filter((e) => !Y.some((t) => String(t) === String(e))) : [...R, ...Y.filter((e) => !J.has(String(e)))];
154
- Je(e);
155
- }, Xe = (e, t, n, r) => {
156
- if (!z) {
592
+ E === void 0 && rt(n), _e?.(n), rn();
593
+ }, $ = (e) => {
594
+ Te === void 0 && st(e), Ee?.(e, i.filter((t, n) => e.some((e) => String(e) === String(x(t, n)))));
595
+ }, ln = (e) => {
596
+ Oe === void 0 && lt(e), ke?.(e);
597
+ }, un = (e) => {
598
+ ze === void 0 && ut({
599
+ key: k,
600
+ layout: e
601
+ }), Be?.(e), ie(k, e);
602
+ }, dn = (e, t, n, r) => {
603
+ n.onImageClick ? n.onImageClick(e, t) : ht({
604
+ field: n.field,
605
+ rowId: r
606
+ });
607
+ }, fn = (e) => {
608
+ Me === void 0 && pt((t) => ({
609
+ ...t,
610
+ key: O,
611
+ order: e
612
+ })), Pe?.(e), re(O, e, B);
613
+ }, pn = (e) => {
614
+ Fe === void 0 && pt((t) => ({
615
+ ...t,
616
+ key: O,
617
+ visibility: e
618
+ })), Le?.(e), re(O, At, e);
619
+ }, mn = (e, t) => {
620
+ let n = Mt.map((e) => e.field), r = n[n.indexOf(e) + t];
621
+ if (!r || V.get(e)?.reorderable === !1 || V.get(r)?.reorderable === !1) return;
622
+ let i = [...At], a = i.indexOf(e), o = i.indexOf(r);
623
+ [i[a], i[o]] = [i[o], i[a]], fn(i);
624
+ }, hn = (e, t) => {
625
+ V.get(e)?.hideable === !1 || !t && Nt.length <= 1 || pn({
626
+ ...B,
627
+ [e]: t
628
+ });
629
+ }, gn = () => {
630
+ let t = b(P.order, e);
631
+ qt || fn(t), Jt || pn(P.visibility), re(O, qt ? At : t, Jt ? B : P.visibility);
632
+ }, _n = () => {
633
+ let e = Z.length > 0 && Q === Z.length ? R.filter((e) => !Z.some((t) => String(t) === String(e))) : [...R, ...Z.filter((e) => !X.has(String(e)))];
634
+ $(e);
635
+ }, vn = (e, t, n, r) => {
636
+ if (!H) {
157
637
  n.onChange?.(e, t);
158
638
  return;
159
639
  }
160
640
  let i = n.type === "file" ? e.target.files?.[0] ?? null : e.target.value, a = String(r), o = {
161
641
  ...t,
162
- ...k[a],
642
+ ...gt[a],
163
643
  [n.field]: i
164
644
  };
165
- if (A((e) => ({
645
+ if (_t((e) => ({
166
646
  ...e,
167
647
  [a]: o
168
- })), P((e) => ({
648
+ })), Ct((e) => ({
169
649
  ...e,
170
650
  [a]: ""
171
651
  })), n.validate) {
172
652
  let e = n.validate(i, o) || "";
173
- j((t) => ({
653
+ yt((t) => ({
174
654
  ...t,
175
655
  [a]: {
176
656
  ...t[a],
@@ -178,104 +658,227 @@ function m({ columns: e = [], rows: s = [], actions: m = [], caption: h, editabl
178
658
  }
179
659
  }));
180
660
  }
181
- }, $ = (e) => {
182
- A((t) => {
661
+ }, yn = (e) => {
662
+ _t((t) => {
183
663
  let n = { ...t };
184
664
  return delete n[e], n;
185
- }), j((t) => {
665
+ }), yt((t) => {
186
666
  let n = { ...t };
187
667
  return delete n[e], n;
188
- }), P((t) => {
668
+ }), Ct((t) => {
189
669
  let n = { ...t };
190
670
  return delete n[e], n;
191
- }), Re((t) => ({
671
+ }), Tt((t) => ({
192
672
  ...t,
193
673
  [e]: (t[e] ?? 0) + 1
194
674
  }));
195
- }, Ze = async (t, n) => {
196
- let r = String(t), i = k[r];
197
- if (!i || !D) return;
675
+ }, bn = async (t, n) => {
676
+ let r = String(t), i = gt[r];
677
+ if (!i || !Ge) return;
198
678
  let a = {};
199
679
  for (let t of e) if (t.validate) {
200
680
  let e = t.validate(i[t.field], i);
201
681
  e && (a[t.field] = e);
202
682
  }
203
- if (Object.keys(a).length) j((e) => ({
683
+ if (Object.keys(a).length) yt((e) => ({
204
684
  ...e,
205
685
  [r]: a
206
686
  }));
207
687
  else {
208
- M((e) => ({
688
+ xt((e) => ({
209
689
  ...e,
210
690
  [r]: !0
211
691
  }));
212
692
  try {
213
- await D(i, n), $(r);
693
+ await Ge(i, n), yn(r);
214
694
  } catch (e) {
215
- P((t) => ({
695
+ Ct((t) => ({
216
696
  ...t,
217
697
  [r]: e?.message || "No se pudo guardar"
218
698
  }));
219
699
  } finally {
220
- M((e) => ({
700
+ xt((e) => ({
221
701
  ...e,
222
702
  [r]: !1
223
703
  }));
224
704
  }
225
705
  }
226
706
  };
227
- return /* @__PURE__ */ o("div", {
228
- className: `dt-container ${re}`.trim(),
707
+ return /* @__PURE__ */ c("div", {
708
+ className: `dt-container ${le}`.trim(),
229
709
  children: [
230
- He && /* @__PURE__ */ a("div", {
710
+ (Ut || Wt || Gt || Kt) && /* @__PURE__ */ c("div", {
231
711
  className: "dt-toolbar",
232
- children: /* @__PURE__ */ o("label", {
233
- className: "dt-search-label",
234
- children: [/* @__PURE__ */ a("span", {
235
- className: "dt-visually-hidden",
236
- children: O.search
237
- }), /* @__PURE__ */ a("input", {
238
- className: "dt-control dt-search",
239
- type: "search",
240
- value: I ?? "",
241
- placeholder: ce,
242
- onChange: (e) => Ke(e.target.value)
243
- })]
244
- })
712
+ children: [
713
+ Ut && /* @__PURE__ */ c("label", {
714
+ className: "dt-search-label",
715
+ children: [/* @__PURE__ */ s("span", {
716
+ className: "dt-visually-hidden",
717
+ children: M.search
718
+ }), /* @__PURE__ */ s("input", {
719
+ className: "dt-control dt-search",
720
+ type: "search",
721
+ value: Dt ?? "",
722
+ placeholder: ge,
723
+ onChange: (e) => sn(e.target.value)
724
+ })]
725
+ }),
726
+ Kt && /* @__PURE__ */ c("div", {
727
+ className: "dt-layout-control",
728
+ role: "group",
729
+ "aria-label": M.layout,
730
+ children: [/* @__PURE__ */ s("button", {
731
+ type: "button",
732
+ className: "dt-button",
733
+ "aria-pressed": W === "table",
734
+ disabled: ze !== void 0 && !Be,
735
+ onClick: () => un("table"),
736
+ children: M.layoutTable
737
+ }), /* @__PURE__ */ s("button", {
738
+ type: "button",
739
+ className: "dt-button",
740
+ "aria-pressed": W === "gallery",
741
+ disabled: ze !== void 0 && !Be,
742
+ onClick: () => un("gallery"),
743
+ children: M.layoutGallery
744
+ })]
745
+ }),
746
+ Wt && W === "table" && /* @__PURE__ */ c("label", {
747
+ className: "dt-image-view-label",
748
+ children: [M.imageView, /* @__PURE__ */ c("select", {
749
+ className: "dt-control",
750
+ value: z,
751
+ disabled: Oe !== void 0 && !ke,
752
+ onChange: (e) => ln(e.target.value),
753
+ children: [
754
+ /* @__PURE__ */ s("option", {
755
+ value: "avatar",
756
+ children: M.imageAvatar
757
+ }),
758
+ /* @__PURE__ */ s("option", {
759
+ value: "thumbnail",
760
+ children: M.imageThumbnail
761
+ }),
762
+ /* @__PURE__ */ s("option", {
763
+ value: "large",
764
+ children: M.imageLarge
765
+ }),
766
+ /* @__PURE__ */ s("option", {
767
+ value: "hidden",
768
+ children: M.imageHidden
769
+ })
770
+ ]
771
+ })]
772
+ }),
773
+ Gt && W === "table" && /* @__PURE__ */ s(ee, {
774
+ columns: Mt,
775
+ visibleFields: Nt,
776
+ onMove: mn,
777
+ onToggle: hn,
778
+ onReset: gn,
779
+ orderReadOnly: qt,
780
+ visibilityReadOnly: Jt,
781
+ labels: M
782
+ })
783
+ ]
245
784
  }),
246
- ge && /* @__PURE__ */ a("div", {
785
+ He && /* @__PURE__ */ s("div", {
247
786
  className: "dt-message dt-error",
248
787
  role: "alert",
249
- children: ge
788
+ children: He
250
789
  }),
251
- /* @__PURE__ */ a("div", {
790
+ D && R.length > 0 && Vt.length > 0 && /* @__PURE__ */ c("div", {
791
+ className: "dt-bulk-bar",
792
+ role: "toolbar",
793
+ "aria-label": M.bulkActions,
794
+ children: [/* @__PURE__ */ s("strong", {
795
+ "aria-live": "polite",
796
+ children: M.selectedCount(R.length)
797
+ }), /* @__PURE__ */ c("div", {
798
+ className: "dt-actions",
799
+ children: [Vt.map((e, t) => /* @__PURE__ */ s(w, {
800
+ action: e,
801
+ onClick: (t) => e.onClick?.(i.filter((e, t) => X.has(String(x(e, t)))), R, t)
802
+ }, e.id ?? t)), /* @__PURE__ */ s("button", {
803
+ type: "button",
804
+ className: "dt-button",
805
+ onClick: () => $([]),
806
+ children: M.clearSelection
807
+ })]
808
+ })]
809
+ }),
810
+ W === "gallery" && /* @__PURE__ */ s(te, {
811
+ caption: m,
812
+ rows: q,
813
+ imageColumn: Ft,
814
+ titleField: It,
815
+ descriptionField: Lt,
816
+ getRowId: x,
817
+ selectedSet: X,
818
+ selectable: D,
819
+ selectedPageCount: Q,
820
+ onTogglePage: _n,
821
+ onSelect: (e) => {
822
+ let t = String(e);
823
+ $(X.has(t) ? R.filter((e) => String(e) !== t) : [...R, e]);
824
+ },
825
+ actions: Bt,
826
+ sortColumns: Rt,
827
+ filterColumns: zt,
828
+ sort: I,
829
+ filters: L,
830
+ sortReadOnly: de !== void 0 && !fe,
831
+ filterReadOnly: E !== void 0 && !_e,
832
+ onSortField: (e) => an(e ? {
833
+ field: e,
834
+ direction: "asc"
835
+ } : null),
836
+ onSortDirection: () => {
837
+ I && an({
838
+ field: I.field,
839
+ direction: I.direction === "asc" ? "desc" : "asc"
840
+ });
841
+ },
842
+ onFilter: cn,
843
+ gallery: A,
844
+ renderAction: (e, t, n) => /* @__PURE__ */ s(w, {
845
+ action: e,
846
+ onClick: (n) => e.onClick?.(t, n)
847
+ }, e.id ?? n),
848
+ onImageOpen: (e, t, n) => dn(e, t, Ft, n),
849
+ loading: j,
850
+ loadingMessage: Ue,
851
+ emptyMessage: ce,
852
+ labels: M
853
+ }),
854
+ W === "table" && /* @__PURE__ */ s("div", {
252
855
  className: "dt-scroll",
253
- children: /* @__PURE__ */ o("table", {
856
+ children: /* @__PURE__ */ c("table", {
254
857
  className: "dt-table",
255
- "aria-busy": E,
858
+ "aria-busy": j,
256
859
  children: [
257
- h && /* @__PURE__ */ a("caption", { children: h }),
258
- /* @__PURE__ */ o("thead", { children: [/* @__PURE__ */ o("tr", { children: [
259
- w && /* @__PURE__ */ a("th", {
860
+ m && /* @__PURE__ */ s("caption", { children: m }),
861
+ /* @__PURE__ */ c("thead", { children: [/* @__PURE__ */ c("tr", { children: [
862
+ D && /* @__PURE__ */ s("th", {
260
863
  scope: "col",
261
864
  className: "dt-selection",
262
- children: /* @__PURE__ */ a(f, {
263
- checked: Y.length > 0 && X === Y.length,
264
- mixed: X > 0 && X < Y.length,
265
- onChange: Ye,
266
- label: O.selectPage
865
+ children: /* @__PURE__ */ s(C, {
866
+ checked: Z.length > 0 && Q === Z.length,
867
+ mixed: Q > 0 && Q < Z.length,
868
+ onChange: _n,
869
+ label: M.selectPage
267
870
  })
268
871
  }),
269
- B.map((e) => {
270
- let t = (ie || e.sortable) && e.sortable !== !1, n = F?.field === e.field ? F.direction : null;
271
- return /* @__PURE__ */ a("th", {
872
+ U.map((e) => {
873
+ let t = (ue || e.sortable) && e.sortable !== !1, n = I?.field === e.field ? I.direction : null;
874
+ return /* @__PURE__ */ s("th", {
272
875
  scope: "col",
273
876
  "aria-sort": n === "asc" ? "ascending" : n === "desc" ? "descending" : void 0,
274
- children: t ? /* @__PURE__ */ o("button", {
877
+ children: t ? /* @__PURE__ */ c("button", {
275
878
  type: "button",
276
879
  className: "dt-sort",
277
- onClick: () => Ge(e),
278
- children: [e.headerName ?? e.field, /* @__PURE__ */ a("span", {
880
+ onClick: () => on(e),
881
+ children: [e.headerName ?? e.field, /* @__PURE__ */ s("span", {
279
882
  "aria-hidden": "true",
280
883
  className: "dt-sort-icon",
281
884
  children: n === "asc" ? "↑" : n === "desc" ? "↓" : "↕"
@@ -283,109 +886,106 @@ function m({ columns: e = [], rows: s = [], actions: m = [], caption: h, editabl
283
886
  }) : e.headerName ?? e.field
284
887
  }, e.field);
285
888
  }),
286
- V && /* @__PURE__ */ a("th", {
889
+ Ht && /* @__PURE__ */ s("th", {
287
890
  scope: "col",
288
- children: v
891
+ children: T
289
892
  })
290
- ] }), B.some((e) => e.filterable) && /* @__PURE__ */ o("tr", {
893
+ ] }), U.some((e) => e.filterable) && /* @__PURE__ */ c("tr", {
291
894
  className: "dt-filter-row",
292
895
  children: [
293
- w && /* @__PURE__ */ a("th", { role: "presentation" }),
294
- B.map((e) => /* @__PURE__ */ a("th", {
896
+ D && /* @__PURE__ */ s("th", { role: "presentation" }),
897
+ U.map((e) => /* @__PURE__ */ s("th", {
295
898
  role: "presentation",
296
- children: e.filterable && /* @__PURE__ */ a("input", {
899
+ children: e.filterable && /* @__PURE__ */ s("input", {
297
900
  className: "dt-control",
298
901
  type: "search",
299
- "aria-label": O.filter(e.headerName ?? e.field),
902
+ "aria-label": M.filter(e.headerName ?? e.field),
300
903
  value: L[e.field] ?? "",
301
- placeholder: O.filterPlaceholder,
302
- onChange: (t) => qe(e.field, t.target.value)
904
+ placeholder: M.filterPlaceholder,
905
+ onChange: (t) => cn(e.field, t.target.value)
303
906
  })
304
907
  }, e.field)),
305
- V && /* @__PURE__ */ a("th", { role: "presentation" })
908
+ Ht && /* @__PURE__ */ s("th", { role: "presentation" })
306
909
  ]
307
910
  })] }),
308
- /* @__PURE__ */ a("tbody", { children: E ? /* @__PURE__ */ a("tr", { children: /* @__PURE__ */ a("td", {
911
+ /* @__PURE__ */ s("tbody", { children: j ? /* @__PURE__ */ s("tr", { children: /* @__PURE__ */ s("td", {
309
912
  className: "dt-empty",
310
- colSpan: Math.max(Ue, 1),
913
+ colSpan: Math.max(Xt, 1),
311
914
  role: "status",
312
- children: _e
313
- }) }) : q.length === 0 ? /* @__PURE__ */ a("tr", { children: /* @__PURE__ */ a("td", {
915
+ children: Ue
916
+ }) }) : q.length === 0 ? /* @__PURE__ */ s("tr", { children: /* @__PURE__ */ s("td", {
314
917
  className: "dt-empty",
315
- colSpan: Math.max(Ue, 1),
316
- children: ne
918
+ colSpan: Math.max(Xt, 1),
919
+ children: ce
317
920
  }) }) : q.map((e, t) => {
318
- let n = _(e, t), r = String(n), s = z ? k[r] ?? e : e, c = !!Ie[r];
319
- return /* @__PURE__ */ o("tr", {
320
- "aria-selected": w ? J.has(r) : void 0,
921
+ let n = x(e, t), r = String(n), i = H ? gt[r] ?? e : e, a = !!bt[r];
922
+ return /* @__PURE__ */ c("tr", {
923
+ "aria-selected": D ? X.has(r) : void 0,
321
924
  children: [
322
- w && /* @__PURE__ */ a("td", {
925
+ D && /* @__PURE__ */ s("td", {
323
926
  className: "dt-selection",
324
- children: /* @__PURE__ */ a("input", {
927
+ children: /* @__PURE__ */ s("input", {
325
928
  type: "checkbox",
326
- checked: J.has(r),
327
- "aria-label": O.selectRow(n),
328
- onChange: () => Je(J.has(r) ? R.filter((e) => String(e) !== r) : [...R, n])
929
+ checked: X.has(r),
930
+ "aria-label": M.selectRow(n),
931
+ onChange: () => $(X.has(r) ? R.filter((e) => String(e) !== r) : [...R, n])
329
932
  })
330
933
  }),
331
- B.map((i) => {
332
- let l = Fe[r]?.[i.field], u = `${ze}-${r}-${i.field}`;
333
- return /* @__PURE__ */ o("td", {
334
- "data-label": i.headerName ?? i.field,
335
- children: [p({
336
- row: s,
337
- column: i,
934
+ U.map((o) => {
935
+ let l = vt[r]?.[o.field], u = `${Et}-${r}-${o.field}`;
936
+ return /* @__PURE__ */ c("td", {
937
+ "data-label": o.headerName ?? o.field,
938
+ children: [se({
939
+ row: i,
940
+ column: o,
338
941
  rowIndex: t,
339
- editable: g,
340
- saveMode: z,
942
+ imageView: z,
943
+ imageOpenLabel: M.imageOpen,
944
+ onImageOpen: (e, t, r) => {
945
+ dn(e, t, r, n);
946
+ },
947
+ editable: h,
948
+ saveMode: H,
341
949
  error: l,
342
950
  errorId: u,
343
- disabled: c,
344
- fileVersion: Le[r] ?? 0,
345
- selectOptionLabel: O.selectOption,
346
- onEdit: (t) => Xe(t, e, i, n)
347
- }), l && /* @__PURE__ */ a("span", {
951
+ disabled: a,
952
+ fileVersion: wt[r] ?? 0,
953
+ selectOptionLabel: M.selectOption,
954
+ onEdit: (t) => vn(t, e, o, n)
955
+ }), l && /* @__PURE__ */ s("span", {
348
956
  className: "dt-field-error",
349
957
  id: u,
350
958
  children: l
351
959
  })]
352
- }, i.field);
960
+ }, o.field);
353
961
  }),
354
- V && /* @__PURE__ */ o("td", {
355
- "data-label": v,
356
- children: [/* @__PURE__ */ o("div", {
962
+ Ht && /* @__PURE__ */ c("td", {
963
+ "data-label": T,
964
+ children: [/* @__PURE__ */ c("div", {
357
965
  className: "dt-actions",
358
- children: [Ve.map((t, n) => /* @__PURE__ */ o("button", {
359
- type: "button",
360
- className: `dt-button ${t.className ?? ""}`.trim(),
361
- style: t.style,
362
- disabled: c || t.disabled,
363
- "aria-label": t.ariaLabel ?? (typeof t.label == "string" ? t.label : void 0),
364
- onClick: (n) => te ? t.onClick?.(n, e) : t.onClick?.(e, n),
365
- children: [
366
- t.label,
367
- " ",
368
- t.icon
369
- ]
370
- }, t.id ?? n)), z && k[r] && /* @__PURE__ */ o(i, { children: [/* @__PURE__ */ a("button", {
966
+ children: [Bt.map((t, n) => /* @__PURE__ */ s(w, {
967
+ action: t,
968
+ disabled: a,
969
+ onClick: (n) => v ? t.onClick?.(n, e) : t.onClick?.(e, n)
970
+ }, t.id ?? n)), H && gt[r] && /* @__PURE__ */ c(o, { children: [/* @__PURE__ */ c("button", {
371
971
  type: "button",
372
972
  className: "dt-button dt-primary",
373
- disabled: c || !D,
374
- onClick: () => Ze(n, e),
375
- children: c ? _e : Se
376
- }), /* @__PURE__ */ a("button", {
973
+ disabled: a || !Ge,
974
+ onClick: () => bn(n, e),
975
+ children: [/* @__PURE__ */ s(g, { name: "check" }), a ? Ue : Ye]
976
+ }), /* @__PURE__ */ c("button", {
377
977
  type: "button",
378
978
  className: "dt-button",
379
- disabled: c,
979
+ disabled: a,
380
980
  onClick: () => {
381
- $(r), ye?.(e);
981
+ yn(r), Ke?.(e);
382
982
  },
383
- children: Ce
983
+ children: [/* @__PURE__ */ s(g, { name: "close" }), Xe]
384
984
  })] })]
385
- }), N[r] && /* @__PURE__ */ a("span", {
985
+ }), St[r] && /* @__PURE__ */ s("span", {
386
986
  className: "dt-field-error",
387
987
  role: "alert",
388
- children: N[r]
988
+ children: St[r]
389
989
  })]
390
990
  })
391
991
  ]
@@ -394,24 +994,24 @@ function m({ columns: e = [], rows: s = [], actions: m = [], caption: h, editabl
394
994
  ]
395
995
  })
396
996
  }),
397
- H && /* @__PURE__ */ o("div", {
997
+ Yt && /* @__PURE__ */ c("div", {
398
998
  className: "dt-pagination",
399
- children: [/* @__PURE__ */ o("span", {
999
+ children: [/* @__PURE__ */ c("span", {
400
1000
  "aria-live": "polite",
401
1001
  children: [
402
- W === 0 ? "0" : K * G + 1,
1002
+ Qt === 0 ? "0" : K * G + 1,
403
1003
  "–",
404
- Math.min((K + 1) * G, W),
1004
+ Math.min((K + 1) * G, Qt),
405
1005
  " de ",
406
- W
1006
+ Qt
407
1007
  ]
408
- }), /* @__PURE__ */ o("div", {
1008
+ }), /* @__PURE__ */ c("div", {
409
1009
  className: "dt-page-actions",
410
1010
  children: [
411
- /* @__PURE__ */ o("label", { children: [O.rowsPerPage, /* @__PURE__ */ a("select", {
1011
+ /* @__PURE__ */ c("label", { children: [M.rowsPerPage, /* @__PURE__ */ s("select", {
412
1012
  className: "dt-control",
413
1013
  value: G,
414
- onChange: (e) => Z({
1014
+ onChange: (e) => nn({
415
1015
  pageIndex: 0,
416
1016
  pageSize: Number(e.target.value)
417
1017
  }),
@@ -425,7 +1025,7 @@ function m({ columns: e = [], rows: s = [], actions: m = [], caption: h, editabl
425
1025
  25,
426
1026
  50,
427
1027
  100
428
- ].map((e) => /* @__PURE__ */ a("option", {
1028
+ ].map((e) => /* @__PURE__ */ s("option", {
429
1029
  value: e,
430
1030
  children: e
431
1031
  }, e)) : [
@@ -434,40 +1034,55 @@ function m({ columns: e = [], rows: s = [], actions: m = [], caption: h, editabl
434
1034
  25,
435
1035
  50,
436
1036
  100
437
- ].map((e) => /* @__PURE__ */ a("option", {
1037
+ ].map((e) => /* @__PURE__ */ s("option", {
438
1038
  value: e,
439
1039
  children: e
440
1040
  }, e))
441
1041
  })] }),
442
- /* @__PURE__ */ a("button", {
1042
+ /* @__PURE__ */ s("button", {
443
1043
  type: "button",
444
1044
  className: "dt-button",
445
- disabled: K === 0 || E,
446
- onClick: () => Z({
1045
+ disabled: K === 0 || j,
1046
+ onClick: () => nn({
447
1047
  pageIndex: K - 1,
448
1048
  pageSize: G
449
1049
  }),
450
- children: be
1050
+ children: qe
451
1051
  }),
452
- /* @__PURE__ */ a("button", {
1052
+ /* @__PURE__ */ s("button", {
453
1053
  type: "button",
454
1054
  className: "dt-button",
455
- disabled: K >= We || E,
456
- onClick: () => Z({
1055
+ disabled: K >= $t || j,
1056
+ onClick: () => nn({
457
1057
  pageIndex: K + 1,
458
1058
  pageSize: G
459
1059
  }),
460
- children: xe
1060
+ children: Je
461
1061
  })
462
1062
  ]
463
1063
  })]
1064
+ }),
1065
+ /* @__PURE__ */ s(y, {
1066
+ entry: tn,
1067
+ previous: J[Y - 1],
1068
+ next: J[Y + 1],
1069
+ onPrevious: () => ht({
1070
+ ...F,
1071
+ rowId: J[Y - 1].rowId
1072
+ }),
1073
+ onNext: () => ht({
1074
+ ...F,
1075
+ rowId: J[Y + 1].rowId
1076
+ }),
1077
+ onClose: () => ht(null),
1078
+ labels: M
464
1079
  })
465
1080
  ]
466
1081
  });
467
1082
  }
468
1083
  // src/Table.jsx
469
- function h({ getColumns: e, getRows: t, getButtons: n, onCaption: r, ...i }) {
470
- return /* @__PURE__ */ a(m, {
1084
+ function ce({ getColumns: e, getRows: t, getButtons: n, onCaption: r, ...i }) {
1085
+ return /* @__PURE__ */ s(T, {
471
1086
  ...i,
472
1087
  columns: i.columns ?? e ?? [],
473
1088
  rows: i.rows ?? t ?? [],
@@ -476,8 +1091,8 @@ function h({ getColumns: e, getRows: t, getButtons: n, onCaption: r, ...i }) {
476
1091
  });
477
1092
  }
478
1093
  // src/TableEdit.jsx
479
- function g({ getColumns: e, getRows: t, getButtons: n, onCaption: r, ...i }) {
480
- return /* @__PURE__ */ a(m, {
1094
+ function le({ getColumns: e, getRows: t, getButtons: n, onCaption: r, ...i }) {
1095
+ return /* @__PURE__ */ s(T, {
481
1096
  ...i,
482
1097
  editable: !0,
483
1098
  columns: i.columns ?? e ?? [],
@@ -487,4 +1102,4 @@ function g({ getColumns: e, getRows: t, getButtons: n, onCaption: r, ...i }) {
487
1102
  caption: i.caption ?? r
488
1103
  });
489
1104
  }
490
- export { h as Table, g as TableEdit };
1105
+ export { ce as Table, le as TableEdit };