@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
@@ -1,426 +0,0 @@
1
- "use client";
2
- import "./column-visibility.css";
3
- import * as U from "react";
4
- import Q from "./index.js";
5
- const X = U, s = X.default ?? U, B = s.Children, Z = s.Component, ee = s.Fragment, te = s.PureComponent, H = s.cloneElement, D = s.createContext, h = s.createElement, ne = s.createRef, re = s.forwardRef, R = s.isValidElement, oe = s.lazy, ie = s.memo, se = s.useCallback, K = s.useContext, ae = s.useDebugValue, ue = s.useDeferredValue, I = s.useEffect, V = s.useId, le = s.useImperativeHandle, ce = s.useInsertionEffect, de = s.useLayoutEffect, _ = s.useMemo, fe = s.useReducer, me = s.useRef, L = s.useState, pe = s.use, he = s.version, ye = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6
- __proto__: null,
7
- Children: B,
8
- Component: Z,
9
- Fragment: ee,
10
- PureComponent: te,
11
- cloneElement: H,
12
- createContext: D,
13
- createElement: h,
14
- createRef: ne,
15
- default: s,
16
- forwardRef: re,
17
- isValidElement: R,
18
- lazy: oe,
19
- memo: ie,
20
- use: pe,
21
- useCallback: se,
22
- useContext: K,
23
- useDebugValue: ae,
24
- useDeferredValue: ue,
25
- useEffect: I,
26
- useId: V,
27
- useImperativeHandle: le,
28
- useInsertionEffect: ce,
29
- useLayoutEffect: de,
30
- useMemo: _,
31
- useReducer: fe,
32
- useRef: me,
33
- useState: L,
34
- version: he
35
- }, Symbol.toStringTag, { value: "Module" })), ge = /* @__PURE__ */ Symbol.for(
36
- "@geovi/the-datagrid/column-visibility-target"
37
- );
38
- function $(e) {
39
- return typeof e != "function" && typeof e != "object" || !e ? !1 : e === Q || e[ge] === !0;
40
- }
41
- const be = /* @__PURE__ */ Symbol.for(
42
- "@geovi/the-datagrid/search-target-component"
43
- ), Y = /* @__PURE__ */ Symbol.for(
44
- "@geovi/the-datagrid/column-visibility-target-component"
45
- );
46
- function G(e, t) {
47
- return typeof e != "function" && typeof e != "object" || !e ? !1 : e[t] === !0;
48
- }
49
- function Se(e) {
50
- return G(e, be) || G(e, Y);
51
- }
52
- function ve(e, t) {
53
- let r = e;
54
- const o = /* @__PURE__ */ new Set();
55
- for (; !o.has(r); ) {
56
- if (o.add(r), t(r.type))
57
- return r;
58
- if (!Se(r.type)) return null;
59
- const n = r.props.children;
60
- if (!R(n)) return null;
61
- r = n;
62
- }
63
- return null;
64
- }
65
- function _e(e, t) {
66
- typeof e != "function" && typeof e != "object" || !e || Object.defineProperty(e, t, { value: !0 });
67
- }
68
- function Ee(e) {
69
- if (Object.prototype.hasOwnProperty.call(e, "__esModule")) return e;
70
- var t = e.default;
71
- if (typeof t == "function") {
72
- var r = function o() {
73
- var n = !1;
74
- try {
75
- n = this instanceof o;
76
- } catch {
77
- }
78
- return n ? Reflect.construct(t, arguments, this.constructor) : t.apply(this, arguments);
79
- };
80
- r.prototype = t.prototype;
81
- } else r = {};
82
- return Object.defineProperty(r, "__esModule", { value: !0 }), Object.keys(e).forEach(function(o) {
83
- var n = Object.getOwnPropertyDescriptor(e, o);
84
- Object.defineProperty(r, o, n.get ? n : {
85
- enumerable: !0,
86
- get: function() {
87
- return e[o];
88
- }
89
- });
90
- }), r;
91
- }
92
- var E = { exports: {} }, T = {};
93
- const q = /* @__PURE__ */ Ee(ye);
94
- var M;
95
- function Oe() {
96
- if (M) return T;
97
- M = 1;
98
- var e = q;
99
- function t(c, d) {
100
- return c === d && (c !== 0 || 1 / c === 1 / d) || c !== c && d !== d;
101
- }
102
- var r = typeof Object.is == "function" ? Object.is : t, o = e.useState, n = e.useEffect, u = e.useLayoutEffect, m = e.useDebugValue;
103
- function f(c, d) {
104
- var i = d(), a = o({ inst: { value: i, getSnapshot: d } }), l = a[0].inst, p = a[1];
105
- return u(
106
- function() {
107
- l.value = i, l.getSnapshot = d, y(l) && p({ inst: l });
108
- },
109
- [c, i, d]
110
- ), n(
111
- function() {
112
- return y(l) && p({ inst: l }), c(function() {
113
- y(l) && p({ inst: l });
114
- });
115
- },
116
- [c]
117
- ), m(i), i;
118
- }
119
- function y(c) {
120
- var d = c.getSnapshot;
121
- c = c.value;
122
- try {
123
- var i = d();
124
- return !r(c, i);
125
- } catch {
126
- return !0;
127
- }
128
- }
129
- function v(c, d) {
130
- return d();
131
- }
132
- var g = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? v : f;
133
- return T.useSyncExternalStore = e.useSyncExternalStore !== void 0 ? e.useSyncExternalStore : g, T;
134
- }
135
- var w = {};
136
- var N;
137
- function Ce() {
138
- return N || (N = 1, process.env.NODE_ENV !== "production" && (function() {
139
- function e(i, a) {
140
- return i === a && (i !== 0 || 1 / i === 1 / a) || i !== i && a !== a;
141
- }
142
- function t(i, a) {
143
- g || n.startTransition === void 0 || (g = !0, console.error(
144
- "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."
145
- ));
146
- var l = a();
147
- if (!c) {
148
- var p = a();
149
- u(l, p) || (console.error(
150
- "The result of getSnapshot should be cached to avoid an infinite loop"
151
- ), c = !0);
152
- }
153
- p = m({
154
- inst: { value: l, getSnapshot: a }
155
- });
156
- var b = p[0].inst, x = p[1];
157
- return y(
158
- function() {
159
- b.value = l, b.getSnapshot = a, r(b) && x({ inst: b });
160
- },
161
- [i, l, a]
162
- ), f(
163
- function() {
164
- return r(b) && x({ inst: b }), i(function() {
165
- r(b) && x({ inst: b });
166
- });
167
- },
168
- [i]
169
- ), v(l), l;
170
- }
171
- function r(i) {
172
- var a = i.getSnapshot;
173
- i = i.value;
174
- try {
175
- var l = a();
176
- return !u(i, l);
177
- } catch {
178
- return !0;
179
- }
180
- }
181
- function o(i, a) {
182
- return a();
183
- }
184
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
185
- var n = q, u = typeof Object.is == "function" ? Object.is : e, m = n.useState, f = n.useEffect, y = n.useLayoutEffect, v = n.useDebugValue, g = !1, c = !1, d = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? o : t;
186
- w.useSyncExternalStore = n.useSyncExternalStore !== void 0 ? n.useSyncExternalStore : d, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
187
- })()), w;
188
- }
189
- var A;
190
- function Re() {
191
- return A || (A = 1, process.env.NODE_ENV === "production" ? E.exports = Oe() : E.exports = Ce()), E.exports;
192
- }
193
- var xe = Re();
194
- const Te = [], we = [], Ve = {}, De = () => {
195
- }, O = {
196
- columns: Te,
197
- columnOrder: we,
198
- columnVisibilityMap: Ve,
199
- theme: "default",
200
- setColumnVisible: De
201
- };
202
- function j(e, t) {
203
- return e === t || e.length === t.length && e.every((r, o) => r === t[o]);
204
- }
205
- function Ie(e, t) {
206
- if (e === t) return !0;
207
- const r = Object.keys(e), o = Object.keys(t);
208
- return r.length === o.length && r.every(
209
- (n) => Object.prototype.hasOwnProperty.call(t, n) && e[n] === t[n]
210
- );
211
- }
212
- function Le(e, t) {
213
- return j(e.columns, t.columns) && j(e.columnOrder, t.columnOrder) && Ie(e.columnVisibilityMap, t.columnVisibilityMap) && e.theme === t.theme && e.setColumnVisible === t.setColumnVisible;
214
- }
215
- function Ge() {
216
- let e = null, t = O;
217
- const r = /* @__PURE__ */ new Set(), o = (n) => {
218
- Le(t, n) || (t = n, r.forEach((u) => u()));
219
- };
220
- return {
221
- createTargetRegistration() {
222
- const n = /* @__PURE__ */ Symbol("rdg-column-visibility-target");
223
- let u = !1, m = null;
224
- return {
225
- controller: {
226
- publish(f) {
227
- m = f, u && e === n && o(f);
228
- }
229
- },
230
- attach() {
231
- if (e !== null && e !== n)
232
- throw new Error(
233
- "RDGColumnVisibilityProvider supports one ReactDataGrid target. Use a separate provider for each grid."
234
- );
235
- return u = !0, e = n, m && o(m), () => {
236
- u && (u = !1, e === n && (e = null, o(O)));
237
- };
238
- }
239
- };
240
- },
241
- dispose() {
242
- e = null, t = O, r.clear();
243
- },
244
- getSnapshot: () => t,
245
- getServerSnapshot: () => O,
246
- subscribe(n) {
247
- return r.add(n), () => r.delete(n);
248
- }
249
- };
250
- }
251
- const W = D(null);
252
- function z() {
253
- const e = K(W);
254
- if (!e)
255
- throw new Error(
256
- "RDG column visibility components must be rendered inside RDGColumnVisibilityProvider."
257
- );
258
- return e;
259
- }
260
- function Me() {
261
- const e = z();
262
- return xe.useSyncExternalStore(
263
- e.subscribe,
264
- e.getSnapshot,
265
- e.getServerSnapshot
266
- );
267
- }
268
- function F(e) {
269
- const { children: t } = e, r = e.__rdgSearchController, o = z(), n = _(
270
- () => o.createTargetRegistration(),
271
- [o]
272
- );
273
- if (I(() => n.attach(), [n]), !R(t))
274
- throw new Error(
275
- "RDGColumnVisibilityTarget expects exactly one ReactDataGrid child."
276
- );
277
- if (!ve(t, $))
278
- throw new Error("RDGColumnVisibilityTarget expects a ReactDataGrid child.");
279
- const u = {
280
- __rdgColumnVisibilityController: n.controller
281
- };
282
- return r !== void 0 && (u.__rdgSearchController = r), H(
283
- t,
284
- u
285
- );
286
- }
287
- _e(
288
- F,
289
- Y
290
- );
291
- function He(e) {
292
- const { children: t } = e, [r] = L(Ge);
293
- I(() => () => r.dispose(), [r]);
294
- const o = _(
295
- () => B.map(
296
- t,
297
- (n) => R(n) && $(n.type) ? /* @__PURE__ */ h(F, null, n) : n
298
- ),
299
- [t]
300
- );
301
- return /* @__PURE__ */ h(W.Provider, { value: r }, o);
302
- }
303
- let P = 0;
304
- function Ne(e) {
305
- const [t] = L(() => (P += 1, `${e}-${P}`));
306
- return t;
307
- }
308
- const Ae = typeof V == "function" ? (e) => `${e}-${V()}` : Ne;
309
- function k(e = "tdg") {
310
- return Ae(e);
311
- }
312
- const S = "default";
313
- D({
314
- themeName: S,
315
- themeBase: S,
316
- portalContainer: null
317
- });
318
- function J(e) {
319
- const t = String(e ?? S).trim();
320
- return t.length > 0 ? t : S;
321
- }
322
- function je(e) {
323
- return J(e).toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/^-+|-+$/g, "") || S;
324
- }
325
- function Pe(e) {
326
- const t = je(e);
327
- return t === S ? S : t === "dark" || t.endsWith("-dark") || t.endsWith("_dark") ? "dark" : t === "light" || t.endsWith("-light") || t.endsWith("_light") ? "light" : S;
328
- }
329
- function C(e) {
330
- return String(e.id ?? e.name ?? "");
331
- }
332
- function ke(e) {
333
- return typeof e.header == "string" && e.header.trim() || typeof e.header == "number" ? e.header : C(e);
334
- }
335
- function Ue(e, t) {
336
- const r = /* @__PURE__ */ new Map();
337
- for (const n of e) {
338
- const u = C(n);
339
- u && !r.has(u) && r.set(u, n);
340
- }
341
- const o = [];
342
- for (const n of t) {
343
- const u = r.get(n);
344
- u && (o.push(u), r.delete(n));
345
- }
346
- return o.push(...r.values()), o;
347
- }
348
- function Ke(e) {
349
- const {
350
- children: t,
351
- ariaLabel: r = "Visible column toggles",
352
- title: o = "Visible columns",
353
- description: n = "Choose which columns are visible in the grid."
354
- } = e, u = k("tdg-column-visibility-title"), m = k("tdg-column-visibility-description"), f = Me(), y = J(f.theme), v = Pe(y), g = _(
355
- () => Ue(f.columns, f.columnOrder),
356
- [f.columnOrder, f.columns]
357
- ), c = _(
358
- () => g.filter((i) => i.hideable !== !1),
359
- [g]
360
- ), d = g.reduce(
361
- (i, a) => i + (f.columnVisibilityMap[C(a)] === !1 ? 0 : 1),
362
- 0
363
- );
364
- return /* @__PURE__ */ h(
365
- "div",
366
- {
367
- className: "tdg-column-visibility-root flex flex-col gap-3 rounded-xl border bg-card/60 p-3 text-foreground shadow-sm",
368
- "data-slot": "rdg-column-visibility",
369
- "data-theme": y,
370
- "data-theme-base": v,
371
- role: o != null ? "region" : void 0,
372
- "aria-labelledby": o != null ? u : void 0,
373
- "aria-describedby": n != null ? m : void 0
374
- },
375
- o != null || n != null ? /* @__PURE__ */ h("div", { className: "flex flex-col gap-1" }, o != null ? /* @__PURE__ */ h(
376
- "div",
377
- {
378
- id: u,
379
- className: "text-sm font-medium",
380
- role: "heading",
381
- "aria-level": 2
382
- },
383
- o
384
- ) : null, n != null ? /* @__PURE__ */ h("div", { id: m, className: "text-xs text-muted-foreground" }, n) : null) : null,
385
- /* @__PURE__ */ h("div", { className: "flex flex-col gap-3 xl:flex-row xl:items-start xl:justify-between" }, /* @__PURE__ */ h(
386
- "div",
387
- {
388
- className: "flex max-w-full flex-wrap gap-2",
389
- role: "group",
390
- "aria-label": r,
391
- "aria-describedby": n != null ? m : void 0,
392
- "data-slot": "rdg-column-toggle-list"
393
- },
394
- c.map((i) => {
395
- const a = C(i), l = f.columnVisibilityMap[a] !== !1, p = l && d <= 1;
396
- return /* @__PURE__ */ h(
397
- "button",
398
- {
399
- key: a,
400
- type: "button",
401
- className: "inline-flex h-8 shrink-0 items-center justify-center rounded-md border px-3 text-sm font-medium whitespace-nowrap transition-colors outline-none hover:bg-accent hover:text-accent-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:border-transparent data-[state=on]:bg-secondary data-[state=on]:text-secondary-foreground",
402
- "aria-pressed": l,
403
- disabled: p,
404
- "data-state": l ? "on" : "off",
405
- "data-slot": "rdg-column-toggle",
406
- "data-column-id": a,
407
- onClick: () => f.setColumnVisible(a, !l)
408
- },
409
- ke(i)
410
- );
411
- })
412
- ), t != null ? /* @__PURE__ */ h(
413
- "div",
414
- {
415
- className: "flex shrink-0 flex-wrap items-center gap-2",
416
- "data-slot": "rdg-column-visibility-actions"
417
- },
418
- t
419
- ) : null)
420
- );
421
- }
422
- export {
423
- He as RDGColumnVisibilityProvider,
424
- F as RDGColumnVisibilityTarget,
425
- Ke as RDGColumnVisibilityToolbar
426
- };