@geovi/the-datagrid 0.0.12 → 0.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/README.md +195 -40
  2. package/dist/base.css +1 -1
  3. package/dist/components.js +23 -23
  4. package/dist/grid/ReactDataGrid.d.ts.map +1 -1
  5. package/dist/grid/hooks/useGridColumnApi.d.ts +0 -5
  6. package/dist/grid/hooks/useGridColumnApi.d.ts.map +1 -1
  7. package/dist/grid/hooks/useGridToolbarBridge.d.ts +28 -0
  8. package/dist/grid/hooks/useGridToolbarBridge.d.ts.map +1 -0
  9. package/dist/grid/internalProps.d.ts +12 -5
  10. package/dist/grid/internalProps.d.ts.map +1 -1
  11. package/dist/index.cjs +9 -9
  12. package/dist/index.css +1 -1
  13. package/dist/index.js +6061 -5994
  14. package/dist/optional-target.d.ts +1 -1
  15. package/dist/optional-target.d.ts.map +1 -1
  16. package/dist/providers/index.d.ts +2 -2
  17. package/dist/providers/index.d.ts.map +1 -1
  18. package/dist/search/RDGSearchTarget.d.ts.map +1 -1
  19. package/dist/search.js +70 -70
  20. package/dist/style/theme/amber-dark/index.css +1 -1
  21. package/dist/style/theme/amber-light/index.css +1 -1
  22. package/dist/style/theme/blue-dark/index.css +1 -1
  23. package/dist/style/theme/blue-light/index.css +1 -1
  24. package/dist/style/theme/default-dark/index.css +1 -1
  25. package/dist/style/theme/default-light/index.css +1 -1
  26. package/dist/style/theme/green-dark/index.css +1 -1
  27. package/dist/style/theme/green-light/index.css +1 -1
  28. package/dist/style/theme/pink-dark/index.css +1 -1
  29. package/dist/style/theme/pink-light/index.css +1 -1
  30. package/dist/toolbar/RDGToolbar.d.ts +88 -0
  31. package/dist/toolbar/RDGToolbar.d.ts.map +1 -0
  32. package/dist/toolbar/RDGToolbarProvider.d.ts +6 -0
  33. package/dist/toolbar/RDGToolbarProvider.d.ts.map +1 -0
  34. package/dist/toolbar/RDGToolbarTarget.d.ts +7 -0
  35. package/dist/toolbar/RDGToolbarTarget.d.ts.map +1 -0
  36. package/dist/toolbar/controller.d.ts +29 -0
  37. package/dist/toolbar/controller.d.ts.map +1 -0
  38. package/dist/toolbar/export.d.ts +70 -0
  39. package/dist/toolbar/export.d.ts.map +1 -0
  40. package/dist/toolbar/icons.d.ts +22 -0
  41. package/dist/toolbar/icons.d.ts.map +1 -0
  42. package/dist/toolbar/index.d.ts +8 -0
  43. package/dist/toolbar/index.d.ts.map +1 -0
  44. package/dist/toolbar/runtime.d.ts.map +1 -0
  45. package/dist/toolbar/store.d.ts +20 -0
  46. package/dist/toolbar/store.d.ts.map +1 -0
  47. package/dist/toolbar/xlsx.d.ts +35 -0
  48. package/dist/toolbar/xlsx.d.ts.map +1 -0
  49. package/dist/toolbar.css +1 -0
  50. package/dist/toolbar.js +797 -0
  51. package/dist/types.d.ts +18 -0
  52. package/dist/types.d.ts.map +1 -1
  53. package/package.json +29 -11
  54. package/dist/column-visibility/RDGColumnVisibilityProvider.d.ts +0 -6
  55. package/dist/column-visibility/RDGColumnVisibilityProvider.d.ts.map +0 -1
  56. package/dist/column-visibility/RDGColumnVisibilityTarget.d.ts +0 -7
  57. package/dist/column-visibility/RDGColumnVisibilityTarget.d.ts.map +0 -1
  58. package/dist/column-visibility/RDGColumnVisibilityToolbar.d.ts +0 -9
  59. package/dist/column-visibility/RDGColumnVisibilityToolbar.d.ts.map +0 -1
  60. package/dist/column-visibility/controller.d.ts +0 -13
  61. package/dist/column-visibility/controller.d.ts.map +0 -1
  62. package/dist/column-visibility/index.d.ts +0 -7
  63. package/dist/column-visibility/index.d.ts.map +0 -1
  64. package/dist/column-visibility/runtime.d.ts.map +0 -1
  65. package/dist/column-visibility/store.d.ts +0 -20
  66. package/dist/column-visibility/store.d.ts.map +0 -1
  67. package/dist/column-visibility.css +0 -1
  68. package/dist/column-visibility.js +0 -426
  69. /package/dist/{column-visibility → toolbar}/runtime.d.ts +0 -0
@@ -0,0 +1,797 @@
1
+ "use client";
2
+ import "./toolbar.css";
3
+ import * as me from "react";
4
+ import Ie from "./index.js";
5
+ const Me = me, u = Me.default ?? me, ge = u.Children, Ne = u.Component, he = u.Fragment, Ve = u.PureComponent, be = u.cloneElement, q = u.createContext, l = u.createElement, ke = u.createRef, Ge = u.forwardRef, G = u.isValidElement, je = u.lazy, Pe = u.memo, J = u.useCallback, ye = u.useContext, Ue = u.useDebugValue, Be = u.useDeferredValue, j = u.useEffect, W = u.useId, $e = u.useImperativeHandle, He = u.useInsertionEffect, Xe = u.useLayoutEffect, T = u.useMemo, We = u.useReducer, K = u.useRef, A = u.useState, Ke = u.use, ze = u.version, Ye = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6
+ __proto__: null,
7
+ Children: ge,
8
+ Component: Ne,
9
+ Fragment: he,
10
+ PureComponent: Ve,
11
+ cloneElement: be,
12
+ createContext: q,
13
+ createElement: l,
14
+ createRef: ke,
15
+ default: u,
16
+ forwardRef: Ge,
17
+ isValidElement: G,
18
+ lazy: je,
19
+ memo: Pe,
20
+ use: Ke,
21
+ useCallback: J,
22
+ useContext: ye,
23
+ useDebugValue: Ue,
24
+ useDeferredValue: Be,
25
+ useEffect: j,
26
+ useId: W,
27
+ useImperativeHandle: $e,
28
+ useInsertionEffect: He,
29
+ useLayoutEffect: Xe,
30
+ useMemo: T,
31
+ useReducer: We,
32
+ useRef: K,
33
+ useState: A,
34
+ version: ze
35
+ }, Symbol.toStringTag, { value: "Module" }));
36
+ let oe = 0;
37
+ function qe(e) {
38
+ const [t] = A(() => (oe += 1, `${e}-${oe}`));
39
+ return t;
40
+ }
41
+ const Je = typeof W == "function" ? (e) => `${e}-${W()}` : qe;
42
+ function V(e = "tdg") {
43
+ return Je(e);
44
+ }
45
+ function P(e) {
46
+ const { children: t, className: n } = e;
47
+ return /* @__PURE__ */ l(
48
+ "svg",
49
+ {
50
+ "aria-hidden": "true",
51
+ focusable: "false",
52
+ className: n,
53
+ viewBox: "0 0 24 24",
54
+ fill: "none",
55
+ stroke: "currentColor",
56
+ strokeWidth: 2,
57
+ strokeLinecap: "round",
58
+ strokeLinejoin: "round"
59
+ },
60
+ t
61
+ );
62
+ }
63
+ function se(e) {
64
+ return /* @__PURE__ */ l(P, { className: e.className }, /* @__PURE__ */ l("path", { d: "M12 3v12" }), /* @__PURE__ */ l("path", { d: "m7 10 5 5 5-5" }), /* @__PURE__ */ l("path", { d: "M4 21h16" }));
65
+ }
66
+ function Qe(e) {
67
+ return /* @__PURE__ */ l(P, { className: e.className }, /* @__PURE__ */ l("path", { d: "M3 4h18l-7 8v8l-4-2v-6z" }));
68
+ }
69
+ function Ze(e) {
70
+ return /* @__PURE__ */ l(P, { className: e.className }, /* @__PURE__ */ l("path", { d: "M3 4h18l-7 8v8l-4-2v-6z" }), /* @__PURE__ */ l("path", { d: "m16 16 5 5" }), /* @__PURE__ */ l("path", { d: "m21 16-5 5" }));
71
+ }
72
+ function et(e) {
73
+ return /* @__PURE__ */ l(P, { className: e.className }, /* @__PURE__ */ l("path", { d: "M3 12a9 9 0 1 0 3-6.7" }), /* @__PURE__ */ l("path", { d: "M3 4v5h5" }));
74
+ }
75
+ const R = "default";
76
+ q({
77
+ themeName: R,
78
+ themeBase: R,
79
+ portalContainer: null
80
+ });
81
+ function Ee(e) {
82
+ const t = String(e ?? R).trim();
83
+ return t.length > 0 ? t : R;
84
+ }
85
+ function tt(e) {
86
+ return Ee(e).toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/^-+|-+$/g, "") || R;
87
+ }
88
+ function rt(e) {
89
+ const t = tt(e);
90
+ return t === R ? R : t === "dark" || t.endsWith("-dark") || t.endsWith("_dark") ? "dark" : t === "light" || t.endsWith("-light") || t.endsWith("_light") ? "light" : R;
91
+ }
92
+ const nt = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", Se = "yyyy-mm-dd hh:mm";
93
+ class ot extends Error {
94
+ constructor(t) {
95
+ super(
96
+ 'XLSX export needs the optional "xlsx" peer dependency. Install it with `npm install xlsx`, or drop "xlsx" from the toolbar\'s exportFormats.'
97
+ ), this.name = "MissingXlsxDependencyError", this.cause = t;
98
+ }
99
+ }
100
+ class st extends Error {
101
+ constructor(t, n) {
102
+ super(
103
+ `Writing the XLSX workbook failed. If exportDateFormat is set it must be an Excel number format code the writer accepts - dot separators are rejected, so prefer "yyyy-mm-dd hh:mm" or "dd/mm/yyyy hh:mm" over "dd.mm.yyyy hh:mm". Received ${JSON.stringify(t)}. Format the value with column.exportValue instead when you need exact text.`
104
+ ), this.name = "XlsxWriteError", this.cause = n;
105
+ }
106
+ }
107
+ function at(e) {
108
+ const t = e.replace(/[[\]:*?/\\]/g, " ").trim();
109
+ return t ? t.slice(0, 31) : "Export";
110
+ }
111
+ async function lt() {
112
+ try {
113
+ return await import("xlsx");
114
+ } catch (e) {
115
+ throw new ot(e);
116
+ }
117
+ }
118
+ async function it(e, t = {}) {
119
+ const { dateFormat: n = Se, sheetName: o = "Export" } = t, r = await lt(), s = {
120
+ cellDates: !0,
121
+ dateNF: n
122
+ };
123
+ try {
124
+ const c = r.utils.aoa_to_sheet(
125
+ [e.headers, ...e.rows],
126
+ s
127
+ ), d = r.utils.book_new();
128
+ return r.utils.book_append_sheet(d, c, at(o)), r.write(d, {
129
+ bookType: "xlsx",
130
+ type: "array",
131
+ ...s
132
+ });
133
+ } catch (c) {
134
+ throw new st(n, c);
135
+ }
136
+ }
137
+ const ct = `\r
138
+ `, ut = "\uFEFF";
139
+ function z(e) {
140
+ return String(e.id ?? e.name ?? "");
141
+ }
142
+ function Q(e) {
143
+ return String(e.name ?? e.id ?? "");
144
+ }
145
+ function dt(e) {
146
+ return typeof e.header == "string" && e.header.trim() ? e.header : typeof e.header == "number" ? String(e.header) : z(e);
147
+ }
148
+ function ae(e) {
149
+ const { columns: t, columnOrder: n, columnVisibilityMap: o } = e, r = /* @__PURE__ */ new Map();
150
+ for (const c of t) {
151
+ const d = z(c);
152
+ d && !r.has(d) && r.set(d, c);
153
+ }
154
+ const s = [];
155
+ for (const c of n) {
156
+ const d = r.get(c);
157
+ d && (s.push(d), r.delete(c));
158
+ }
159
+ return s.push(...r.values()), s.filter((c) => c.exportable === !1 || !Q(c) ? !1 : c.exportWhenHidden ? !0 : o[z(c)] !== !1);
160
+ }
161
+ function ft(e, t) {
162
+ if (!(typeof e != "object" || e == null))
163
+ return e[t];
164
+ }
165
+ function pt(e, t) {
166
+ const n = ft(t, Q(e));
167
+ if (typeof e.exportValue != "function") return n;
168
+ try {
169
+ return e.exportValue({ value: n, data: t, column: e });
170
+ } catch {
171
+ return n;
172
+ }
173
+ }
174
+ function mt(e, t) {
175
+ return {
176
+ headers: e.map(dt),
177
+ fields: e.map(Q),
178
+ rows: t.map(
179
+ (n) => e.map((o) => pt(o, n))
180
+ )
181
+ };
182
+ }
183
+ function gt(e) {
184
+ return e == null ? "" : e instanceof Date ? Number.isNaN(e.getTime()) ? "" : e.toISOString() : typeof e == "object" ? JSON.stringify(e) ?? "" : String(e);
185
+ }
186
+ function le(e) {
187
+ const t = gt(e);
188
+ return /["\n\r,]/.test(t) ? `"${t.replace(/"/g, '""')}"` : t;
189
+ }
190
+ function ht(e) {
191
+ const t = [
192
+ e.headers.map(le).join(","),
193
+ ...e.rows.map((n) => n.map(le).join(","))
194
+ ];
195
+ return `${ut}${t.join(ct)}`;
196
+ }
197
+ function bt(e) {
198
+ const t = e.rows.map(
199
+ (n) => Object.fromEntries(
200
+ n.map((o, r) => [
201
+ e.fields[r],
202
+ o === void 0 ? null : o
203
+ ])
204
+ )
205
+ );
206
+ return JSON.stringify(t, null, 2);
207
+ }
208
+ const Y = {
209
+ csv: {
210
+ label: "CSV",
211
+ extension: "csv",
212
+ mimeType: "text/csv;charset=utf-8",
213
+ createContent: (e) => ht(e)
214
+ },
215
+ json: {
216
+ label: "JSON",
217
+ extension: "json",
218
+ mimeType: "application/json;charset=utf-8",
219
+ createContent: (e) => bt(e)
220
+ },
221
+ xlsx: {
222
+ label: "Excel",
223
+ extension: "xlsx",
224
+ mimeType: nt,
225
+ createContent: (e, t) => it(e, t)
226
+ }
227
+ }, yt = ["csv", "json"];
228
+ function Et(e, t, n) {
229
+ if (typeof document > "u" || typeof URL > "u") return 0;
230
+ const o = new Blob([t], { type: n }), r = URL.createObjectURL(o), s = document.createElement("a");
231
+ return s.href = r, s.download = e, s.rel = "noopener", document.body.append(s), s.click(), s.remove(), URL.revokeObjectURL(r), o.size;
232
+ }
233
+ function St(e) {
234
+ if (Object.prototype.hasOwnProperty.call(e, "__esModule")) return e;
235
+ var t = e.default;
236
+ if (typeof t == "function") {
237
+ var n = function o() {
238
+ var r = !1;
239
+ try {
240
+ r = this instanceof o;
241
+ } catch {
242
+ }
243
+ return r ? Reflect.construct(t, arguments, this.constructor) : t.apply(this, arguments);
244
+ };
245
+ n.prototype = t.prototype;
246
+ } else n = {};
247
+ return Object.defineProperty(n, "__esModule", { value: !0 }), Object.keys(e).forEach(function(o) {
248
+ var r = Object.getOwnPropertyDescriptor(e, o);
249
+ Object.defineProperty(n, o, r.get ? r : {
250
+ enumerable: !0,
251
+ get: function() {
252
+ return e[o];
253
+ }
254
+ });
255
+ }), n;
256
+ }
257
+ var I = { exports: {} }, H = {};
258
+ const xe = /* @__PURE__ */ St(Ye);
259
+ var ie;
260
+ function xt() {
261
+ if (ie) return H;
262
+ ie = 1;
263
+ var e = xe;
264
+ function t(f, h) {
265
+ return f === h && (f !== 0 || 1 / f === 1 / h) || f !== f && h !== h;
266
+ }
267
+ var n = typeof Object.is == "function" ? Object.is : t, o = e.useState, r = e.useEffect, s = e.useLayoutEffect, c = e.useDebugValue;
268
+ function d(f, h) {
269
+ var i = h(), p = o({ inst: { value: i, getSnapshot: h } }), m = p[0].inst, b = p[1];
270
+ return s(
271
+ function() {
272
+ m.value = i, m.getSnapshot = h, y(m) && b({ inst: m });
273
+ },
274
+ [f, i, h]
275
+ ), r(
276
+ function() {
277
+ return y(m) && b({ inst: m }), f(function() {
278
+ y(m) && b({ inst: m });
279
+ });
280
+ },
281
+ [f]
282
+ ), c(i), i;
283
+ }
284
+ function y(f) {
285
+ var h = f.getSnapshot;
286
+ f = f.value;
287
+ try {
288
+ var i = h();
289
+ return !n(f, i);
290
+ } catch {
291
+ return !0;
292
+ }
293
+ }
294
+ function E(f, h) {
295
+ return h();
296
+ }
297
+ var O = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? E : d;
298
+ return H.useSyncExternalStore = e.useSyncExternalStore !== void 0 ? e.useSyncExternalStore : O, H;
299
+ }
300
+ var X = {};
301
+ var ce;
302
+ function _t() {
303
+ return ce || (ce = 1, process.env.NODE_ENV !== "production" && (function() {
304
+ function e(i, p) {
305
+ return i === p && (i !== 0 || 1 / i === 1 / p) || i !== i && p !== p;
306
+ }
307
+ function t(i, p) {
308
+ O || r.startTransition === void 0 || (O = !0, console.error(
309
+ "You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."
310
+ ));
311
+ var m = p();
312
+ if (!f) {
313
+ var b = p();
314
+ s(m, b) || (console.error(
315
+ "The result of getSnapshot should be cached to avoid an infinite loop"
316
+ ), f = !0);
317
+ }
318
+ b = c({
319
+ inst: { value: m, getSnapshot: p }
320
+ });
321
+ var a = b[0].inst, S = b[1];
322
+ return y(
323
+ function() {
324
+ a.value = m, a.getSnapshot = p, n(a) && S({ inst: a });
325
+ },
326
+ [i, m, p]
327
+ ), d(
328
+ function() {
329
+ return n(a) && S({ inst: a }), i(function() {
330
+ n(a) && S({ inst: a });
331
+ });
332
+ },
333
+ [i]
334
+ ), E(m), m;
335
+ }
336
+ function n(i) {
337
+ var p = i.getSnapshot;
338
+ i = i.value;
339
+ try {
340
+ var m = p();
341
+ return !s(i, m);
342
+ } catch {
343
+ return !0;
344
+ }
345
+ }
346
+ function o(i, p) {
347
+ return p();
348
+ }
349
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
350
+ var r = xe, s = typeof Object.is == "function" ? Object.is : e, c = r.useState, d = r.useEffect, y = r.useLayoutEffect, E = r.useDebugValue, O = !1, f = !1, h = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? o : t;
351
+ X.useSyncExternalStore = r.useSyncExternalStore !== void 0 ? r.useSyncExternalStore : h, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
352
+ })()), X;
353
+ }
354
+ var ue;
355
+ function vt() {
356
+ return ue || (ue = 1, process.env.NODE_ENV === "production" ? I.exports = xt() : I.exports = _t()), I.exports;
357
+ }
358
+ var Ot = vt();
359
+ const Tt = [], Rt = [], wt = {}, Ct = [], Lt = () => {
360
+ }, Dt = () => {
361
+ }, At = () => {
362
+ }, de = () => Ct, M = {
363
+ columns: Tt,
364
+ columnOrder: Rt,
365
+ columnVisibilityMap: wt,
366
+ theme: "default",
367
+ setColumnVisible: Lt,
368
+ filteringEnabled: !1,
369
+ canToggleFiltering: !1,
370
+ setFilteringEnabled: Dt,
371
+ filtered: !1,
372
+ clearAllFilters: At,
373
+ getViewRows: de,
374
+ getAllRows: de
375
+ };
376
+ function fe(e, t) {
377
+ return e === t || e.length === t.length && e.every((n, o) => n === t[o]);
378
+ }
379
+ function Ft(e, t) {
380
+ if (e === t) return !0;
381
+ const n = Object.keys(e), o = Object.keys(t);
382
+ return n.length === o.length && n.every(
383
+ (r) => Object.prototype.hasOwnProperty.call(t, r) && e[r] === t[r]
384
+ );
385
+ }
386
+ function It(e, t) {
387
+ return fe(e.columns, t.columns) && fe(e.columnOrder, t.columnOrder) && Ft(e.columnVisibilityMap, t.columnVisibilityMap) && e.theme === t.theme && e.setColumnVisible === t.setColumnVisible && e.filteringEnabled === t.filteringEnabled && e.canToggleFiltering === t.canToggleFiltering && e.setFilteringEnabled === t.setFilteringEnabled && e.filtered === t.filtered && e.clearAllFilters === t.clearAllFilters && e.getViewRows === t.getViewRows && e.getAllRows === t.getAllRows;
388
+ }
389
+ function Mt() {
390
+ let e = null, t = M;
391
+ const n = /* @__PURE__ */ new Set(), o = (r) => {
392
+ It(t, r) || (t = r, n.forEach((s) => s()));
393
+ };
394
+ return {
395
+ createTargetRegistration() {
396
+ const r = /* @__PURE__ */ Symbol("rdg-toolbar-target");
397
+ let s = !1, c = null;
398
+ return {
399
+ controller: {
400
+ publish(d) {
401
+ c = d, s && e === r && o(d);
402
+ }
403
+ },
404
+ attach() {
405
+ if (e !== null && e !== r)
406
+ throw new Error(
407
+ "RDGToolbarProvider supports one ReactDataGrid target. Use a separate provider for each grid."
408
+ );
409
+ return s = !0, e = r, c && o(c), () => {
410
+ s && (s = !1, e === r && (e = null, o(M)));
411
+ };
412
+ }
413
+ };
414
+ },
415
+ dispose() {
416
+ e = null, t = M, n.clear();
417
+ },
418
+ getSnapshot: () => t,
419
+ getServerSnapshot: () => M,
420
+ subscribe(r) {
421
+ return n.add(r), () => n.delete(r);
422
+ }
423
+ };
424
+ }
425
+ const _e = q(
426
+ null
427
+ );
428
+ function ve() {
429
+ const e = ye(_e);
430
+ if (!e)
431
+ throw new Error(
432
+ "RDG toolbar components must be rendered inside RDGToolbarProvider."
433
+ );
434
+ return e;
435
+ }
436
+ function Nt() {
437
+ const e = ve();
438
+ return Ot.useSyncExternalStore(
439
+ e.subscribe,
440
+ e.getSnapshot,
441
+ e.getServerSnapshot
442
+ );
443
+ }
444
+ const N = {
445
+ export: "Export",
446
+ showFilters: "Show filters",
447
+ hideFilters: "Hide filters",
448
+ clearFilters: "Clear filters",
449
+ exportFormats: {},
450
+ exportSingle: {},
451
+ filteringControlledHint: "The grid owns its filter row through the enableFiltering prop."
452
+ };
453
+ function k(e) {
454
+ return String(e.id ?? e.name ?? "");
455
+ }
456
+ function Vt(e) {
457
+ return typeof e.header == "string" && e.header.trim() || typeof e.header == "number" ? e.header : k(e);
458
+ }
459
+ function kt(e, t) {
460
+ const n = /* @__PURE__ */ new Map();
461
+ for (const r of e) {
462
+ const s = k(r);
463
+ s && !n.has(s) && n.set(s, r);
464
+ }
465
+ const o = [];
466
+ for (const r of t) {
467
+ const s = n.get(r);
468
+ s && (o.push(s), n.delete(r));
469
+ }
470
+ return o.push(...n.values()), o;
471
+ }
472
+ function Wt(e) {
473
+ const {
474
+ children: t,
475
+ ariaLabel: n = "Visible column toggles",
476
+ title: o = "Visible columns",
477
+ description: r = "Choose which columns are visible in the grid.",
478
+ showColumnToggles: s = !0,
479
+ showExport: c = !1,
480
+ showFilterToggle: d = !1,
481
+ showClearFilters: y = !1,
482
+ exportScope: E = "view",
483
+ exportFormats: O = yt,
484
+ exportFileName: f = "grid-export",
485
+ exportDateFormat: h = Se,
486
+ exportSheetName: i,
487
+ onExportSuccess: p,
488
+ onExportError: m,
489
+ labels: b,
490
+ className: a
491
+ } = e, [S, x] = A(!1), L = V("tdg-toolbar-title"), D = V("tdg-toolbar-description"), g = Nt(), Z = Ee(g.theme), we = rt(Z), w = T(
492
+ () => ({
493
+ ...N,
494
+ ...b,
495
+ // A caller passing `exportFormats: undefined` out of a conditional would
496
+ // otherwise defeat the spread and leave the lookups below without a map.
497
+ exportFormats: b?.exportFormats ?? N.exportFormats,
498
+ exportSingle: b?.exportSingle ?? N.exportSingle,
499
+ filteringControlledHint: b?.filteringControlledHint ?? N.filteringControlledHint
500
+ }),
501
+ [b]
502
+ ), U = T(
503
+ () => kt(g.columns, g.columnOrder),
504
+ [g.columnOrder, g.columns]
505
+ ), Ce = T(
506
+ () => U.filter((_) => _.hideable !== !1),
507
+ [U]
508
+ ), Le = U.reduce(
509
+ (_, v) => _ + (g.columnVisibilityMap[k(v)] === !1 ? 0 : 1),
510
+ 0
511
+ ), ee = T(
512
+ () => O.filter(
513
+ (_) => Y[_] != null
514
+ ),
515
+ [O]
516
+ ), De = T(
517
+ () => c ? ae(g).length : 0,
518
+ [c, g]
519
+ ) === 0 || ee.length === 0, Ae = J(
520
+ async (_) => {
521
+ const v = Y[_];
522
+ if (!v) return;
523
+ const C = ae(g);
524
+ if (C.length === 0) return;
525
+ const B = E === "all" ? g.getAllRows() : g.getViewRows(), $ = mt(C, B), te = {
526
+ format: _,
527
+ scope: E,
528
+ rowCount: $.rows.length,
529
+ columnCount: $.headers.length
530
+ }, re = typeof f == "function" ? f(te) : f;
531
+ x(!0);
532
+ try {
533
+ const F = await v.createContent($, {
534
+ dateFormat: h,
535
+ sheetName: i ?? re
536
+ }), ne = `${re}.${v.extension}`, Fe = Et(
537
+ ne,
538
+ F,
539
+ v.mimeType
540
+ );
541
+ p?.({ ...te, fileName: ne, byteLength: Fe });
542
+ } catch (F) {
543
+ m?.(F), m || console.error(F);
544
+ } finally {
545
+ x(!1);
546
+ }
547
+ },
548
+ [
549
+ h,
550
+ f,
551
+ E,
552
+ i,
553
+ m,
554
+ p,
555
+ g
556
+ ]
557
+ );
558
+ return /* @__PURE__ */ l(
559
+ "div",
560
+ {
561
+ className: a ? `tdg-toolbar-root ${a}` : "tdg-toolbar-root",
562
+ "data-slot": "rdg-toolbar",
563
+ "data-theme": Z,
564
+ "data-theme-base": we,
565
+ role: o != null ? "region" : void 0,
566
+ "aria-labelledby": o != null ? L : void 0,
567
+ "aria-describedby": r != null ? D : void 0
568
+ },
569
+ o != null || r != null ? /* @__PURE__ */ l("div", { "data-slot": "rdg-toolbar-heading" }, o != null ? /* @__PURE__ */ l(
570
+ "div",
571
+ {
572
+ id: L,
573
+ "data-slot": "rdg-toolbar-title",
574
+ role: "heading",
575
+ "aria-level": 2
576
+ },
577
+ o
578
+ ) : null, r != null ? /* @__PURE__ */ l("div", { id: D, "data-slot": "rdg-toolbar-description" }, r) : null) : null,
579
+ /* @__PURE__ */ l("div", { "data-slot": "rdg-toolbar-body" }, s ? /* @__PURE__ */ l(
580
+ "div",
581
+ {
582
+ role: "group",
583
+ "aria-label": n,
584
+ "aria-describedby": r != null ? D : void 0,
585
+ "data-slot": "rdg-column-toggle-list"
586
+ },
587
+ Ce.map((_) => {
588
+ const v = k(_), C = g.columnVisibilityMap[v] !== !1, B = C && Le <= 1;
589
+ return /* @__PURE__ */ l(
590
+ "button",
591
+ {
592
+ key: v,
593
+ type: "button",
594
+ "aria-pressed": C,
595
+ disabled: B,
596
+ "data-state": C ? "on" : "off",
597
+ "data-slot": "rdg-column-toggle",
598
+ "data-column-id": v,
599
+ onClick: () => g.setColumnVisible(v, !C)
600
+ },
601
+ Vt(_)
602
+ );
603
+ })
604
+ ) : null, c || d || y || t != null ? /* @__PURE__ */ l("div", { "data-slot": "rdg-toolbar-actions" }, c ? /* @__PURE__ */ l(
605
+ Gt,
606
+ {
607
+ disabled: De || S,
608
+ formats: ee,
609
+ label: w.export,
610
+ formatLabels: w.exportFormats,
611
+ singleLabels: w.exportSingle,
612
+ onExport: Ae
613
+ }
614
+ ) : null, d ? /* @__PURE__ */ l(
615
+ "button",
616
+ {
617
+ type: "button",
618
+ "aria-pressed": g.filteringEnabled,
619
+ "data-state": g.filteringEnabled ? "on" : "off",
620
+ "data-slot": "rdg-toolbar-filter-toggle",
621
+ disabled: !g.canToggleFiltering,
622
+ title: g.canToggleFiltering ? void 0 : w.filteringControlledHint,
623
+ onClick: () => g.setFilteringEnabled(!g.filteringEnabled)
624
+ },
625
+ g.filteringEnabled ? /* @__PURE__ */ l(Ze, null) : /* @__PURE__ */ l(Qe, null),
626
+ g.filteringEnabled ? w.hideFilters : w.showFilters
627
+ ) : null, y ? /* @__PURE__ */ l(
628
+ "button",
629
+ {
630
+ type: "button",
631
+ "data-slot": "rdg-toolbar-clear-filters",
632
+ disabled: !g.filtered,
633
+ onClick: () => g.clearAllFilters()
634
+ },
635
+ /* @__PURE__ */ l(et, null),
636
+ w.clearFilters
637
+ ) : null, t) : null)
638
+ );
639
+ }
640
+ function Gt(e) {
641
+ const { disabled: t, formats: n, label: o, formatLabels: r, singleLabels: s, onExport: c } = e, [d, y] = A(!1), E = K(null), O = K(null), f = V("tdg-toolbar-export-menu"), h = V("tdg-toolbar-export-trigger"), i = n.length === 1 ? n[0] : null, p = (a) => r[a] ?? Y[a].label;
642
+ j(() => {
643
+ if (!d) return;
644
+ const a = (S) => {
645
+ const x = E.current;
646
+ x && !x.contains(S.target) && y(!1);
647
+ };
648
+ return document.addEventListener("pointerdown", a, !0), () => document.removeEventListener("pointerdown", a, !0);
649
+ }, [d]);
650
+ const m = J(() => {
651
+ y(!1), O.current?.focus();
652
+ }, []), b = (a, S) => {
653
+ const x = Array.from(
654
+ E.current?.querySelectorAll(
655
+ '[data-slot="rdg-toolbar-export-format"]'
656
+ ) ?? []
657
+ );
658
+ if (x.length === 0) return;
659
+ const L = x.indexOf(a), D = L < 0 ? 0 : (L + S + x.length) % x.length;
660
+ x[D]?.focus();
661
+ };
662
+ return i ? /* @__PURE__ */ l(
663
+ "button",
664
+ {
665
+ type: "button",
666
+ "data-slot": "rdg-toolbar-export",
667
+ "data-export-format": i,
668
+ disabled: t,
669
+ onClick: () => {
670
+ c(i);
671
+ }
672
+ },
673
+ /* @__PURE__ */ l(se, null),
674
+ s[i] ?? /* @__PURE__ */ l(he, null, o, " ", p(i))
675
+ ) : /* @__PURE__ */ l("div", { "data-slot": "rdg-toolbar-export-wrapper", ref: E }, /* @__PURE__ */ l(
676
+ "button",
677
+ {
678
+ type: "button",
679
+ ref: O,
680
+ id: h,
681
+ "data-slot": "rdg-toolbar-export",
682
+ "data-state": d ? "on" : "off",
683
+ "aria-haspopup": "menu",
684
+ "aria-expanded": d,
685
+ "aria-controls": d ? f : void 0,
686
+ disabled: t,
687
+ onClick: () => y((a) => !a),
688
+ onKeyDown: (a) => {
689
+ (a.key === "ArrowDown" || a.key === "ArrowUp") && (a.preventDefault(), y(!0));
690
+ }
691
+ },
692
+ /* @__PURE__ */ l(se, null),
693
+ o
694
+ ), d ? /* @__PURE__ */ l(
695
+ "div",
696
+ {
697
+ id: f,
698
+ role: "menu",
699
+ "aria-labelledby": h,
700
+ "data-slot": "rdg-toolbar-export-menu",
701
+ onKeyDown: (a) => {
702
+ if (a.key === "Escape") {
703
+ a.stopPropagation(), m();
704
+ return;
705
+ }
706
+ if (a.key === "ArrowDown") {
707
+ a.preventDefault(), b(a.target, 1);
708
+ return;
709
+ }
710
+ a.key === "ArrowUp" && (a.preventDefault(), b(a.target, -1));
711
+ }
712
+ },
713
+ n.map((a, S) => /* @__PURE__ */ l(
714
+ "button",
715
+ {
716
+ key: a,
717
+ type: "button",
718
+ role: "menuitem",
719
+ autoFocus: S === 0,
720
+ "data-slot": "rdg-toolbar-export-format",
721
+ "data-export-format": a,
722
+ onClick: () => {
723
+ m(), c(a);
724
+ }
725
+ },
726
+ p(a)
727
+ ))
728
+ ) : null);
729
+ }
730
+ const jt = /* @__PURE__ */ Symbol.for("@geovi/the-datagrid/toolbar-target");
731
+ function Oe(e) {
732
+ return typeof e != "function" && typeof e != "object" || !e ? !1 : e === Ie || e[jt] === !0;
733
+ }
734
+ const Pt = /* @__PURE__ */ Symbol.for(
735
+ "@geovi/the-datagrid/search-target-component"
736
+ ), Te = /* @__PURE__ */ Symbol.for(
737
+ "@geovi/the-datagrid/toolbar-target-component"
738
+ );
739
+ function pe(e, t) {
740
+ return typeof e != "function" && typeof e != "object" || !e ? !1 : e[t] === !0;
741
+ }
742
+ function Ut(e) {
743
+ return pe(e, Pt) || pe(e, Te);
744
+ }
745
+ function Bt(e, t) {
746
+ let n = e;
747
+ const o = /* @__PURE__ */ new Set();
748
+ for (; !o.has(n); ) {
749
+ if (o.add(n), t(n.type))
750
+ return n;
751
+ if (!Ut(n.type)) return null;
752
+ const r = n.props.children;
753
+ if (!G(r)) return null;
754
+ n = r;
755
+ }
756
+ return null;
757
+ }
758
+ function $t(e, t) {
759
+ typeof e != "function" && typeof e != "object" || !e || Object.defineProperty(e, t, { value: !0 });
760
+ }
761
+ function Re(e) {
762
+ const { children: t } = e, n = e.__rdgSearchController, o = ve(), r = T(
763
+ () => o.createTargetRegistration(),
764
+ [o]
765
+ );
766
+ if (j(() => r.attach(), [r]), !G(t))
767
+ throw new Error(
768
+ "RDGToolbarTarget expects exactly one ReactDataGrid child."
769
+ );
770
+ if (!Bt(t, Oe))
771
+ throw new Error("RDGToolbarTarget expects a ReactDataGrid child.");
772
+ const s = {
773
+ __rdgToolbarController: r.controller
774
+ };
775
+ return n !== void 0 && (s.__rdgSearchController = n), be(
776
+ t,
777
+ s
778
+ );
779
+ }
780
+ $t(Re, Te);
781
+ function Kt(e) {
782
+ const { children: t } = e, [n] = A(Mt);
783
+ j(() => () => n.dispose(), [n]);
784
+ const o = T(
785
+ () => ge.map(
786
+ t,
787
+ (r) => G(r) && Oe(r.type) ? /* @__PURE__ */ l(Re, null, r) : r
788
+ ),
789
+ [t]
790
+ );
791
+ return /* @__PURE__ */ l(_e.Provider, { value: n }, o);
792
+ }
793
+ export {
794
+ Wt as RDGToolbar,
795
+ Kt as RDGToolbarProvider,
796
+ Re as RDGToolbarTarget
797
+ };