@gears-frontx/ui-kit 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"export-service.d.ts","sourceRoot":"","sources":["../../../../../../../src/components/data-grid/plugins/actions-menu/menu-items/export-menu-items/export-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAShE,OAAO,KAAK,EAGV,qBAAqB,EACtB,MAAM,gBAAgB,CAAC;AAIxB,wBAAgB,mBAAmB,CACjC,IAAI,SAAS,YAAY,GAAG,YAAY,KACrC,qBAAqB,CAAC,IAAI,CAAC,CAgQ/B;AAUD,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,GAAG,SAAS,EAC7C,SAAS,EAAE,MAAM,GAChB,MAAM,CAWR"}
1
+ {"version":3,"file":"export-service.d.ts","sourceRoot":"","sources":["../../../../../../../src/components/data-grid/plugins/actions-menu/menu-items/export-menu-items/export-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAShE,OAAO,KAAK,EAGV,qBAAqB,EACtB,MAAM,gBAAgB,CAAC;AAIxB,wBAAgB,mBAAmB,CACjC,IAAI,SAAS,YAAY,GAAG,YAAY,KACrC,qBAAqB,CAAC,IAAI,CAAC,CA0Q/B;AAUD,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,GAAG,SAAS,EAC7C,SAAS,EAAE,MAAM,GAChB,MAAM,CAWR"}
@@ -1 +1 @@
1
- {"version":3,"file":"drag-drop-plugin.d.ts","sourceRoot":"","sources":["../../../../../src/components/data-grid/plugins/drag-drop/drag-drop-plugin.tsx"],"names":[],"mappings":";AAYA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0B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AAS,YAAY,GAAG,YAAY,EACpF,MAAM,EAAE,2BAA2B,CAAC,KAAK,CAAC,+DA8D3C;AAED,2CAA2C;AAC3C,wBAAgB,iBAAiB,CAAC,KAAK,SAAS,YAAY,EAAE,EAC5D,YAAY,EACZ,YAAY,EACZ,MAAM,EACN,cAAc,EACd,gBAAgB,GACjB,EAAE;IACD,YAAY,EAAE,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC,CAAC;IACzD,YAAY,EAAE,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;IAC9D,MAAM,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,GAAG,IAAI,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpE,cAAc,EAAE,CAAC,EAAE,EAAE,cAAc,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IAC7D,gBAAgB,EAAE,CAAC,EAAE,EAAE,cAAc,KAAK,IAAI,CAAC;CAChD,QAwBA"}
@@ -1,43 +1,43 @@
1
1
  "use client";
2
- import { create as T } from "zustand";
3
- import { u as L, c as j, a as A } from "../chunks/plugins-helpers.js";
4
- import { jsxs as M, jsx as w } from "react/jsx-runtime";
5
- import { EllipsisIcon as B, ArrowDownToLineIcon as N } from "lucide-react";
6
- import { m as y } from "../chunks/messages.js";
7
- import { u as $ } from "../chunks/data-grid-portal-container-context.js";
8
- import { DropdownMenu as F, DropdownMenuTrigger as G, DropdownMenuContent as J, DropdownMenuItem as O } from "../dropdown-menu.js";
9
- import { Button as W } from "../button.js";
10
- import { useState as H } from "react";
11
- import { a as U } from "../chunks/table-helpers.js";
12
- import { u as Q } from "../chunks/table-context.js";
13
- import { i as z } from "../chunks/is-record.js";
14
- function Z() {
15
- const a = L().getPlugin("actionsMenu").useMenuItems(), i = $();
16
- return /* @__PURE__ */ M(F, { children: [
17
- /* @__PURE__ */ w(
18
- G,
2
+ import { create as A } from "zustand";
3
+ import { u as B, c as N, a as $ } from "../chunks/plugins-helpers.js";
4
+ import { jsxs as P, jsx as y } from "react/jsx-runtime";
5
+ import { EllipsisIcon as F, ArrowDownToLineIcon as G } from "lucide-react";
6
+ import { m as b } from "../chunks/messages.js";
7
+ import { u as J } from "../chunks/data-grid-portal-container-context.js";
8
+ import { DropdownMenu as O, DropdownMenuTrigger as W, DropdownMenuContent as H, DropdownMenuItem as U } from "../dropdown-menu.js";
9
+ import { Button as z } from "../button.js";
10
+ import { useState as Q } from "react";
11
+ import { a as Z } from "../chunks/table-helpers.js";
12
+ import { u as q } from "../chunks/table-context.js";
13
+ import { i as K } from "../chunks/is-record.js";
14
+ function X() {
15
+ const a = B().getPlugin("actionsMenu").useMenuItems(), i = J();
16
+ return /* @__PURE__ */ P(O, { children: [
17
+ /* @__PURE__ */ y(
18
+ W,
19
19
  {
20
- render: /* @__PURE__ */ w(
21
- W,
20
+ render: /* @__PURE__ */ y(
21
+ z,
22
22
  {
23
23
  variant: "ghost",
24
24
  size: "sm",
25
- icon: /* @__PURE__ */ w(B, {}),
26
- "aria-label": y.actionsMenu.actions
25
+ icon: /* @__PURE__ */ y(F, {}),
26
+ "aria-label": b.actionsMenu.actions
27
27
  }
28
28
  )
29
29
  }
30
30
  ),
31
- /* @__PURE__ */ w(J, { side: "bottom", align: "end", container: i, children: a.map((u) => /* @__PURE__ */ w(u.component, { params: u.params }, u.id)) })
31
+ /* @__PURE__ */ y(H, { side: "bottom", align: "end", container: i, children: a.map((u) => /* @__PURE__ */ y(u.component, { params: u.params }, u.id)) })
32
32
  ] });
33
33
  }
34
- const xe = j("actionsMenu", (e) => {
35
- const o = T(() => ({
34
+ const ye = N("actionsMenu", (e) => {
35
+ const o = A(() => ({
36
36
  menuItems: []
37
37
  }));
38
38
  return e.registerSlot("top-end", {
39
39
  id: "actionsMenu",
40
- component: Z,
40
+ component: X,
41
41
  order: 100
42
42
  }), {
43
43
  registerMenuItem: u,
@@ -56,12 +56,12 @@ const xe = j("actionsMenu", (e) => {
56
56
  g.sort((t, n) => t.order - n.order), o.setState({ menuItems: g });
57
57
  }
58
58
  });
59
- function R(e, o) {
59
+ function k(e, o) {
60
60
  const a = o.key ? e[o.key] : e[o.id];
61
61
  let i;
62
62
  return o.formatter ? i = o.formatter(a) : i = String(a ?? ""), { raw: a, formatted: i };
63
63
  }
64
- function C({
64
+ function T({
65
65
  item: e,
66
66
  column: o,
67
67
  cellValue: a,
@@ -78,45 +78,45 @@ function C({
78
78
  u
79
79
  ) : a.formatted;
80
80
  }
81
- const q = (e) => {
81
+ const Y = (e) => {
82
82
  const { data: o, columns: a, options: i, gridContext: u } = e, f = i.delimiter || ",", p = i.includeHeaders ?? !0, g = [];
83
83
  if (p) {
84
- const t = a.map((n) => v(n.label, f)).join(f);
84
+ const t = a.map((n) => D(n.label, f)).join(f);
85
85
  g.push(t);
86
86
  }
87
87
  for (const t of o) {
88
88
  const n = [];
89
89
  for (const s of a) {
90
- const c = R(t, s), l = C({
90
+ const c = k(t, s), l = T({
91
91
  item: t,
92
92
  column: s,
93
93
  cellValue: c,
94
94
  transformCellText: i.transformCellText,
95
95
  gridContext: u
96
96
  });
97
- n.push(v(l, f));
97
+ n.push(D(l, f));
98
98
  }
99
99
  g.push(n.join(f));
100
100
  }
101
101
  return Promise.resolve(g.join(`
102
102
  `));
103
- }, S = /^[=+\-@\t\r]/;
104
- function v(e, o) {
103
+ }, E = /^[=+\-@\t\r]/;
104
+ function D(e, o) {
105
105
  const a = String(e ?? "");
106
106
  if (a.includes(o) || a.includes(`
107
- `) || a.includes('"') || S.test(a)) {
107
+ `) || a.includes('"') || E.test(a)) {
108
108
  const u = a.replace(/"/g, '""');
109
- return `"${S.test(a) ? " " : ""}${u}"`;
109
+ return `"${E.test(a) ? " " : ""}${u}"`;
110
110
  }
111
111
  return a;
112
112
  }
113
- const K = async (e) => {
113
+ const _ = async (e) => {
114
114
  const { data: o, columns: a, options: i, gridContext: u } = e;
115
115
  if (!i.loadExcelJs)
116
116
  throw new Error(
117
117
  "Exporting to Excel needs `loadExcelJs`, a function that loads the exceljs package: the grid does not import it itself."
118
118
  );
119
- const f = Y(await i.loadExcelJs()), p = new f.Workbook(), g = p.addWorksheet(i.sheetName), t = i.includeHeaders ?? !0;
119
+ const f = ee(await i.loadExcelJs()), p = new f.Workbook(), g = p.addWorksheet(i.sheetName), t = i.includeHeaders ?? !0;
120
120
  let n = 1;
121
121
  if (t) {
122
122
  const c = g.getRow(n);
@@ -128,14 +128,14 @@ const K = async (e) => {
128
128
  for (const c of o) {
129
129
  const l = g.getRow(n);
130
130
  for (const [r, d] of a.entries()) {
131
- const m = R(c, d), x = C({
131
+ const m = k(c, d), h = T({
132
132
  item: c,
133
133
  column: d,
134
134
  cellValue: m,
135
135
  transformCellText: i.transformCellText,
136
136
  gridContext: u
137
- }), h = l.getCell(r + 1);
138
- h.value = _(m.raw, x);
137
+ }), x = l.getCell(r + 1);
138
+ x.value = te(m.raw, h);
139
139
  }
140
140
  n++;
141
141
  }
@@ -144,16 +144,16 @@ const K = async (e) => {
144
144
  type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
145
145
  });
146
146
  };
147
- function X(e) {
147
+ function V(e) {
148
148
  return "default" in e && !!e.default;
149
149
  }
150
- function Y(e) {
151
- const o = X(e) ? e.default : e;
150
+ function ee(e) {
151
+ const o = V(e) ? e.default : e;
152
152
  if (typeof o.Workbook != "function")
153
153
  throw new Error("`loadExcelJs` has to resolve to the exceljs package, which exports `Workbook`.");
154
154
  return o;
155
155
  }
156
- function _(e, o) {
156
+ function te(e, o) {
157
157
  if (o !== String(e ?? ""))
158
158
  return o;
159
159
  if (e == null)
@@ -172,7 +172,7 @@ function _(e, o) {
172
172
  }
173
173
  return String(e);
174
174
  }
175
- function V() {
175
+ function oe() {
176
176
  return {
177
177
  exportToCSV: e,
178
178
  exportToExcel: o,
@@ -182,16 +182,16 @@ function V() {
182
182
  async function e(t, n, s, c) {
183
183
  const l = { ...s, format: "csv" };
184
184
  try {
185
- const r = await q({
185
+ const r = await Y({
186
186
  data: t,
187
187
  columns: n,
188
188
  options: l,
189
189
  gridContext: c
190
- }), d = E(s.filename, "csv");
190
+ }), d = R(s.filename, "csv");
191
191
  a(r, d, "text/csv");
192
192
  } catch (r) {
193
193
  if (s.onError)
194
- s.onError(I(r));
194
+ s.onError(M(r));
195
195
  else
196
196
  throw r;
197
197
  }
@@ -199,12 +199,12 @@ function V() {
199
199
  async function o(t, n, s, c) {
200
200
  const l = { ...s, format: "xlsx" };
201
201
  try {
202
- const r = await K({
202
+ const r = await _({
203
203
  data: t,
204
204
  columns: n,
205
205
  options: l,
206
206
  gridContext: c
207
- }), d = E(s.filename, "xlsx");
207
+ }), d = R(s.filename, "xlsx");
208
208
  a(
209
209
  r,
210
210
  d,
@@ -212,7 +212,7 @@ function V() {
212
212
  );
213
213
  } catch (r) {
214
214
  if (s.onError)
215
- s.onError(I(r));
215
+ s.onError(M(r));
216
216
  else
217
217
  throw r;
218
218
  }
@@ -231,7 +231,7 @@ function V() {
231
231
  }
232
232
  async function f(t, n, s) {
233
233
  const c = { page: s.getPage(), limit: s.getLimit() }, l = [], r = /* @__PURE__ */ new Set();
234
- let d = 1, m = !0;
234
+ let d = 1, m = !0, h = /* @__PURE__ */ new Set();
235
235
  for (; m; ) {
236
236
  const x = t.triggerLoad({
237
237
  loadContext: {
@@ -241,23 +241,23 @@ function V() {
241
241
  store: !1
242
242
  });
243
243
  if (await x.promise, x.processResult) {
244
- const h = x.processResult.results;
245
- if (h.length === 0)
244
+ const v = x.processResult.results;
245
+ if (v.length === 0)
246
246
  m = !1;
247
247
  else {
248
- const k = h.map((b, P) => ({
249
- id: t.getItemId(b),
250
- item: b,
251
- index: P,
252
- section: ee()
253
- }));
254
- await p(
248
+ const I = v.map((w, j) => ({
249
+ id: t.getItemId(w),
250
+ item: w,
251
+ index: j,
252
+ section: ne()
253
+ })), S = new Set(I.map((w) => w.id)), L = S.size === h.size && [...S].every((w) => h.has(w));
254
+ h = S, await p(
255
255
  t,
256
- k,
256
+ I,
257
257
  l,
258
258
  r,
259
259
  n
260
- ), d++, h.length < c.limit && (m = !1);
260
+ ), d++, (L || v.length < c.limit) && (m = !1);
261
261
  }
262
262
  } else
263
263
  m = !1;
@@ -272,10 +272,10 @@ function V() {
272
272
  t.getSectionsByParentId(r.id).length || await t.triggerLoad({
273
273
  loadContext: { tree: { parentId: r.id } }
274
274
  }).promise;
275
- const x = t.getRecordsByParentId(r.id);
276
- x.length > 0 && await p(
275
+ const h = t.getRecordsByParentId(r.id);
276
+ h.length > 0 && await p(
277
277
  t,
278
- x,
278
+ h,
279
279
  s,
280
280
  c,
281
281
  l
@@ -302,48 +302,48 @@ function V() {
302
302
  return c;
303
303
  }
304
304
  }
305
- function ee() {
305
+ function ne() {
306
306
  return { id: "", visible: !0, loadContext: {}, parentId: null, records: [] };
307
307
  }
308
- function I(e) {
308
+ function M(e) {
309
309
  return e instanceof Error ? e : new Error(String(e));
310
310
  }
311
- function E(e, o) {
311
+ function R(e, o) {
312
312
  return typeof e == "function" ? e() : typeof e == "string" ? e.endsWith(`.${o}`) ? e : `${e}.${o}` : `${(/* @__PURE__ */ new Date()).toISOString().slice(0, 19).replace(/:/g, "-")}.${o}`;
313
313
  }
314
- function te(e) {
314
+ function re(e) {
315
315
  return e === "csv" || e === "xlsx";
316
316
  }
317
- function oe(e) {
318
- return z(e);
317
+ function se(e) {
318
+ return K(e);
319
319
  }
320
- function ne(e) {
321
- if (!(!e || !te(e.type)))
320
+ function ae(e) {
321
+ if (!(!e || !re(e.type)))
322
322
  return {
323
323
  type: e.type,
324
- exportConfig: oe(e.exportConfig) ? e.exportConfig : void 0
324
+ exportConfig: se(e.exportConfig) ? e.exportConfig : void 0
325
325
  };
326
326
  }
327
- function D({ params: e }) {
328
- const o = ne(e), a = A(), i = Q(), [u, f] = H(!1), p = i.useVisibleColumns(), g = (o == null ? void 0 : o.type) === "csv" ? "CSV" : "Excel";
327
+ function C({ params: e }) {
328
+ const o = ae(e), a = $(), i = q(), [u, f] = Q(!1), p = i.useVisibleColumns(), g = (o == null ? void 0 : o.type) === "csv" ? "CSV" : "Excel";
329
329
  async function t() {
330
330
  if (!(u || !o)) {
331
331
  f(!0);
332
332
  try {
333
- const n = V(), s = await n.getAllData(a), c = p.map((m) => {
334
- const x = U(m.label);
333
+ const n = oe(), s = await n.getAllData(a), c = p.map((m) => {
334
+ const h = Z(m.label);
335
335
  return {
336
336
  id: m.id,
337
- label: x,
337
+ label: h,
338
338
  key: m.key,
339
339
  formatter: m.formatter
340
340
  };
341
341
  }), r = {
342
342
  ...{
343
343
  format: o.type,
344
- filename: y.exportMenuItem.defaultFilename,
344
+ filename: b.exportMenuItem.defaultFilename,
345
345
  includeHeaders: !0,
346
- ...o.type === "xlsx" ? { sheetName: y.exportMenuItem.defaultSheetName } : {}
346
+ ...o.type === "xlsx" ? { sheetName: b.exportMenuItem.defaultSheetName } : {}
347
347
  },
348
348
  ...o.exportConfig
349
349
  };
@@ -355,20 +355,20 @@ function D({ params: e }) {
355
355
  }
356
356
  }
357
357
  }
358
- return /* @__PURE__ */ M(O, { disabled: u, onClick: t, children: [
359
- /* @__PURE__ */ w(N, {}),
360
- y.exportMenuItem.exportAs(g)
358
+ return /* @__PURE__ */ P(U, { disabled: u, onClick: t, children: [
359
+ /* @__PURE__ */ y(G, {}),
360
+ b.exportMenuItem.exportAs(g)
361
361
  ] });
362
362
  }
363
- function he(e) {
363
+ function be(e) {
364
364
  const o = {
365
- component: D,
365
+ component: C,
366
366
  params: { type: "csv", exportConfig: e }
367
367
  };
368
- return e != null && e.loadExcelJs ? [{ component: D, params: { type: "xlsx", exportConfig: e } }, o] : [o];
368
+ return e != null && e.loadExcelJs ? [{ component: C, params: { type: "xlsx", exportConfig: e } }, o] : [o];
369
369
  }
370
370
  export {
371
- xe as DataGridActionsMenuPlugin,
372
- he as exportMenuItems
371
+ ye as DataGridActionsMenuPlugin,
372
+ be as exportMenuItems
373
373
  };
374
374
  //# sourceMappingURL=actions-menu.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"actions-menu.js","sources":["../../src/components/data-grid/plugins/actions-menu/components/data-grid-actions-menu.tsx","../../src/components/data-grid/plugins/actions-menu/actions-menu-plugin.tsx","../../src/components/data-grid/plugins/actions-menu/menu-items/export-menu-items/export-cells.ts","../../src/components/data-grid/plugins/actions-menu/menu-items/export-menu-items/formatters/csv-formatter.ts","../../src/components/data-grid/plugins/actions-menu/menu-items/export-menu-items/formatters/excel-formatter.ts","../../src/components/data-grid/plugins/actions-menu/menu-items/export-menu-items/export-service.ts","../../src/components/data-grid/plugins/actions-menu/menu-items/export-menu-items/data-grid-export-menu-item.tsx","../../src/components/data-grid/plugins/actions-menu/menu-items/export-menu-items/export-menu-items.ts"],"sourcesContent":["import { EllipsisIcon } from 'lucide-react';\n\nimport { Button } from '../../../../button/public.js';\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuTrigger,\n} from '../../../../dropdown-menu/public.js';\nimport { messages } from '../../../messages';\nimport { useDataGrid } from '../../../services/core/data-grid-context';\nimport { useDataGridPortalContainer } from '../../../services/core/data-grid-portal-container-context';\nimport type { DataGridActionsMenuPluginApi } from '../actions-menu-types';\n\nexport function DataGridActionsMenu() {\n const grid = useDataGrid();\n const actionsMenu = grid.getPlugin<DataGridActionsMenuPluginApi>('actionsMenu')!;\n const menuItems = actionsMenu.useMenuItems();\n const portalContainer = useDataGridPortalContainer();\n\n return (\n <DropdownMenu>\n <DropdownMenuTrigger\n render={\n <Button\n variant=\"ghost\"\n size=\"sm\"\n icon={<EllipsisIcon />}\n aria-label={messages.actionsMenu.actions}\n />\n }\n />\n <DropdownMenuContent side=\"bottom\" align=\"end\" container={portalContainer}>\n {menuItems.map((menuItem) => (\n <menuItem.component key={menuItem.id} params={menuItem.params} />\n ))}\n </DropdownMenuContent>\n </DropdownMenu>\n );\n}\n","// Load-bearing: a plugin is rendered as a child of <DataGrid>, so a Server Component can import\n// and render it, and the component it returns calls hooks. This directive puts the banner on the\n// plugin's own entry chunk (dist/data-grid/<plugin>.js). client-boundaries.test.ts only scans a\n// component's top-level files, so scripts/verify-consumer.sh is what checks the built banner of\n// every plugin entry.\n'use client';\n\nimport { create } from 'zustand';\nimport type { DataGridItem } from '../../data-grid-types';\nimport { createDataGridPlugin } from '../../services/plugins/plugins-helpers';\nimport type {\n DataGridActionsMenuItem,\n DataGridActionsMenuItemOption,\n DataGridActionsMenuPluginApi,\n DataGridActionsMenuPluginProps,\n} from './actions-menu-types';\nimport { DataGridActionsMenu } from './components/data-grid-actions-menu';\n\ninterface ActionsMenuStore {\n menuItems: DataGridActionsMenuItem[];\n}\n\nexport const DataGridActionsMenuPlugin = createDataGridPlugin<\n DataGridItem,\n 'actionsMenu',\n DataGridActionsMenuPluginProps,\n DataGridActionsMenuPluginApi\n>('actionsMenu', (context) => {\n const useStore = create<ActionsMenuStore>(() => ({\n menuItems: [],\n }));\n\n context.registerSlot('top-end', {\n id: 'actionsMenu',\n component: DataGridActionsMenu,\n order: 100,\n });\n\n const useMenuItems = () => useStore((s) => s.menuItems);\n\n const api: DataGridActionsMenuPluginApi = {\n registerMenuItem,\n useMenuItems,\n onPropsChange,\n };\n\n return api;\n\n function registerMenuItem(options: DataGridActionsMenuItemOption) {\n const id = Math.random().toString();\n const currentItems = useStore.getState().menuItems;\n const order = options.order ?? (currentItems.length + 1) * 10;\n const newMenuItem = { id, ...options, order };\n const updatedItems = [...currentItems, newMenuItem].sort((a, b) => a.order - b.order);\n useStore.setState({ menuItems: updatedItems });\n }\n\n function onPropsChange(props: DataGridActionsMenuPluginProps) {\n const items: DataGridActionsMenuItem[] = props.menuItems.map((options, index) => {\n const id = Math.random().toString();\n const order = options.order ?? (index + 1) * 10;\n return { id, ...options, order } satisfies DataGridActionsMenuItem;\n });\n items.sort((a, b) => a.order - b.order);\n useStore.setState({ menuItems: items });\n }\n});\n","import type { DataGridItem } from '../../../../data-grid-types';\nimport type { DataGridPluginContext } from '../../../../services/plugins/plugins-types';\nimport type { DataGridExportColumn, DataGridExportOptions } from './export-types';\n\n// What a formatter does to one cell, apart from the service that uses the formatters: the service\n// imports them, so they cannot import it back.\n\nexport function getCellValue<Item extends DataGridItem = DataGridItem>(\n item: Item,\n column: DataGridExportColumn,\n): { raw: unknown; formatted: string } {\n const rawValue = column.key ? item[column.key] : item[column.id];\n\n let formattedValue: string;\n if (column.formatter) {\n formattedValue = column.formatter(rawValue);\n } else {\n formattedValue = String(rawValue ?? '');\n }\n\n return { raw: rawValue, formatted: formattedValue };\n}\n\nexport function applyCellTextTransformation<Item extends DataGridItem = DataGridItem>({\n item,\n column,\n cellValue,\n transformCellText,\n gridContext,\n}: {\n item: Item;\n column: DataGridExportColumn;\n cellValue: { raw: unknown; formatted: string };\n transformCellText: DataGridExportOptions<Item>['transformCellText'];\n gridContext: DataGridPluginContext<Item>;\n}): string {\n const transformer = transformCellText?.[column.id];\n\n if (!transformer) {\n return cellValue.formatted;\n }\n\n return transformer(\n {\n value: cellValue.raw,\n formattedValue: cellValue.formatted,\n row: item,\n },\n gridContext,\n );\n}\n","import type { DataGridItem } from '../../../../../data-grid-types';\nimport { applyCellTextTransformation, getCellValue } from '../export-cells';\nimport type { DataGridExportFormatter, DataGridExportFormatterParams } from '../export-types';\n\nexport const csvFormatter: DataGridExportFormatter = <Item extends DataGridItem>(\n exportContext: DataGridExportFormatterParams<Item>,\n): Promise<string> => {\n const { data, columns, options, gridContext } = exportContext;\n const delimiter = options.delimiter || ',';\n const includeHeaders = options.includeHeaders ?? true;\n const rows: string[] = [];\n\n if (includeHeaders) {\n const headerRow = columns\n .map((column) => escapeCsvValue(column.label, delimiter))\n .join(delimiter);\n rows.push(headerRow);\n }\n\n for (const item of data) {\n const row: string[] = [];\n\n for (const column of columns) {\n const cellValue = getCellValue(item, column);\n\n const transformedValue = applyCellTextTransformation({\n item,\n column,\n cellValue,\n transformCellText: options.transformCellText,\n gridContext,\n });\n\n row.push(escapeCsvValue(transformedValue, delimiter));\n }\n\n rows.push(row.join(delimiter));\n }\n\n return Promise.resolve(rows.join('\\n'));\n};\n\nconst csvInjectionChars = /^[=+\\-@\\t\\r]/;\n\nfunction escapeCsvValue(value: string, delimiter: string): string {\n const stringValue = String(value ?? '');\n\n const needsQuoting =\n stringValue.includes(delimiter) ||\n stringValue.includes('\\n') ||\n stringValue.includes('\"') ||\n csvInjectionChars.test(stringValue);\n\n if (needsQuoting) {\n const escaped = stringValue.replace(/\"/g, '\"\"');\n // Prefix with tab to prevent CSV injection (CWE-1236) when value starts with a formula character\n const prefix = csvInjectionChars.test(stringValue) ? '\\t' : '';\n return `\"${prefix}${escaped}\"`;\n }\n\n return stringValue;\n}\n","import type { DataGridItem } from '../../../../../data-grid-types';\nimport { applyCellTextTransformation, getCellValue } from '../export-cells';\nimport type {\n DataGridExcelJsApi,\n DataGridExcelJsModule,\n DataGridExportFormatter,\n DataGridExportFormatterParams,\n} from '../export-types';\n\nexport const excelFormatter: DataGridExportFormatter = async <Item extends DataGridItem>(\n exportContext: DataGridExportFormatterParams<Item>,\n): Promise<Blob> => {\n const { data, columns, options, gridContext } = exportContext;\n\n if (!options.loadExcelJs) {\n throw new Error(\n 'Exporting to Excel needs `loadExcelJs`, a function that loads the exceljs package: the grid does not import it itself.',\n );\n }\n const excelJs = resolveExcelJs(await options.loadExcelJs());\n\n const workbook = new excelJs.Workbook();\n const worksheet = workbook.addWorksheet(options.sheetName);\n\n const includeHeaders = options.includeHeaders ?? true;\n let currentRow = 1;\n\n if (includeHeaders) {\n const headerRow = worksheet.getRow(currentRow);\n\n columns.forEach((column, index) => {\n const cell = headerRow.getCell(index + 1);\n cell.value = column.label;\n });\n\n currentRow++;\n }\n\n for (const item of data) {\n const row = worksheet.getRow(currentRow);\n\n for (const [columnIndex, column] of columns.entries()) {\n const cellValue = getCellValue(item, column);\n\n const transformedValue = applyCellTextTransformation({\n item,\n column,\n cellValue,\n transformCellText: options.transformCellText,\n gridContext,\n });\n\n const cell = row.getCell(columnIndex + 1);\n\n cell.value = processExcelValue(cellValue.raw, transformedValue);\n }\n\n currentRow++;\n }\n\n const buffer = await workbook.xlsx.writeBuffer();\n return new Blob([buffer], {\n type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',\n });\n};\n\nfunction hasDefault(module: DataGridExcelJsModule): module is { default: DataGridExcelJsApi } {\n return 'default' in module && !!module.default;\n}\n\n// A CommonJS package imported dynamically arrives as the module itself under one bundler and as\n// `{ default: module }` under another, so the loader's result is read either way.\nfunction resolveExcelJs(module: DataGridExcelJsModule): DataGridExcelJsApi {\n const api = hasDefault(module) ? module.default : module;\n if (typeof api.Workbook !== 'function') {\n throw new Error('`loadExcelJs` has to resolve to the exceljs package, which exports `Workbook`.');\n }\n return api;\n}\n\nexport function processExcelValue(\n rawValue: unknown,\n transformedValue: string,\n): string | number | boolean | Date {\n if (transformedValue !== String(rawValue ?? '')) {\n return transformedValue;\n }\n\n if (rawValue === null || rawValue === undefined) {\n return '';\n }\n\n if (typeof rawValue === 'number') {\n return rawValue;\n }\n\n if (typeof rawValue === 'boolean') {\n return rawValue;\n }\n\n if (rawValue instanceof Date) {\n return rawValue;\n }\n\n if (typeof rawValue === 'string') {\n const dateRegex = /^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(Z|[+-]\\d{2}:\\d{2})?)?$/;\n if (dateRegex.test(rawValue)) {\n const date = new Date(rawValue);\n if (!isNaN(date.getTime())) {\n return date;\n }\n }\n\n const trimmed = rawValue.trim();\n if (\n trimmed !== '' &&\n !isNaN(Number(trimmed)) &&\n !/[eE]/.test(trimmed) &&\n !(trimmed.length > 1 && trimmed.startsWith('0') && trimmed[1] !== '.')\n ) {\n return Number(trimmed);\n }\n }\n\n return String(rawValue);\n}\n","import type { DataGridItem } from '../../../../data-grid-types';\nimport type { DataGridPluginContext } from '../../../../services/plugins/plugins-types';\nimport type {\n DataGridItemId,\n DataGridRecord,\n DataGridSection,\n} from '../../../../services/storage/storage-types';\nimport type { PaginationPluginApi } from '../../../pagination/pagination-plugin';\nimport type { DataGridTableTreePluginApi } from '../../../table-tree/table-tree-types';\nimport type {\n DataGridExportColumn,\n DataGridExportOptions,\n DataGridExportService,\n} from './export-types';\nimport { csvFormatter } from './formatters/csv-formatter';\nimport { excelFormatter } from './formatters/excel-formatter';\n\nexport function createExportService<\n Item extends DataGridItem = DataGridItem,\n>(): DataGridExportService<Item> {\n return {\n exportToCSV,\n exportToExcel,\n downloadFile,\n getAllData,\n };\n\n async function exportToCSV(\n data: Item[],\n columns: DataGridExportColumn[],\n options: DataGridExportOptions<Item>,\n gridContext: DataGridPluginContext<Item>,\n ): Promise<void> {\n const csvOptions = { ...options, format: 'csv' as const };\n try {\n const csvContent = await csvFormatter<Item>({\n data,\n columns,\n options: csvOptions,\n gridContext,\n });\n\n const filename = generateFilename(options.filename, 'csv');\n downloadFile(csvContent, filename, 'text/csv');\n } catch (error) {\n if (options.onError) {\n options.onError(toError(error));\n } else {\n throw error;\n }\n }\n }\n\n async function exportToExcel(\n data: Item[],\n columns: DataGridExportColumn[],\n options: DataGridExportOptions<Item>,\n gridContext: DataGridPluginContext<Item>,\n ): Promise<void> {\n const excelOptions = { ...options, format: 'xlsx' as const };\n try {\n const excelBlob = await excelFormatter<Item>({\n data,\n columns,\n options: excelOptions,\n gridContext,\n });\n\n const filename = generateFilename(options.filename, 'xlsx');\n downloadFile(\n excelBlob,\n filename,\n 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',\n );\n } catch (error) {\n if (options.onError) {\n options.onError(toError(error));\n } else {\n throw error;\n }\n }\n }\n\n function downloadFile(content: string | Blob, filename: string, mimeType: string): void {\n const blob = content instanceof Blob ? content : new Blob([content], { type: mimeType });\n const url = URL.createObjectURL(blob);\n\n const link = document.createElement('a');\n link.href = url;\n link.download = filename;\n link.style.display = 'none';\n\n document.body.appendChild(link);\n link.click();\n document.body.removeChild(link);\n\n URL.revokeObjectURL(url);\n }\n\n async function getAllData(gridContext: DataGridPluginContext<Item>): Promise<Item[]> {\n // The export reads the pagination and the tree plugin by name: with neither registered, what\n // is on screen is everything there is.\n const paginationPlugin = gridContext.getPlugin<PaginationPluginApi>('pagination');\n const treePlugin = gridContext.getPlugin<DataGridTableTreePluginApi<Item>>('tableTree');\n\n if (treePlugin && paginationPlugin) {\n return await getAllTreeDataWithPagination(gridContext, treePlugin, paginationPlugin);\n } else if (treePlugin) {\n return await getAllTreeData(gridContext, treePlugin);\n } else if (paginationPlugin) {\n return await getAllDataPageByPage(gridContext, paginationPlugin);\n }\n\n const records = gridContext.useStore.getState().visibleRecords;\n return records.map((record) => record.item);\n }\n\n async function getAllTreeData(\n gridContext: DataGridPluginContext<Item>,\n treePlugin: DataGridTableTreePluginApi<Item>,\n ): Promise<Item[]> {\n const allData: Item[] = [];\n const visitedIds = new Set<DataGridItemId>();\n const records = gridContext.useStore.getState().visibleRecords;\n\n await collectTreeDataFromRecords(gridContext, records, allData, visitedIds, treePlugin);\n return allData;\n }\n\n async function getAllTreeDataWithPagination(\n gridContext: DataGridPluginContext<Item>,\n treePlugin: DataGridTableTreePluginApi<Item>,\n paginationPlugin: PaginationPluginApi,\n ): Promise<Item[]> {\n const originalState = { page: paginationPlugin.getPage(), limit: paginationPlugin.getLimit() };\n const allData: Item[] = [];\n const visitedIds = new Set<DataGridItemId>();\n let currentPage = 1;\n let hasMorePages = true;\n\n while (hasMorePages) {\n const loadInstance = gridContext.triggerLoad({\n loadContext: {\n pagination: { ...originalState, page: currentPage },\n tree: { parentId: null },\n },\n store: false,\n });\n\n await loadInstance.promise;\n\n if (loadInstance.processResult) {\n const pageData = loadInstance.processResult.results;\n\n if (pageData.length === 0) {\n hasMorePages = false;\n } else {\n // A page is not stored, so it has no records of the grid's own; the tree is walked\n // over records made for it.\n const pageRecords = pageData.map((item, index) => ({\n id: gridContext.getItemId(item),\n item,\n index,\n section: rootSection<Item>(),\n }));\n\n await collectTreeDataFromRecords(\n gridContext,\n pageRecords,\n allData,\n visitedIds,\n treePlugin,\n );\n\n currentPage++;\n\n if (pageData.length < originalState.limit) {\n hasMorePages = false;\n }\n }\n } else {\n hasMorePages = false;\n }\n }\n\n return allData;\n }\n\n async function collectTreeDataFromRecords(\n gridContext: DataGridPluginContext<Item>,\n records: DataGridRecord<Item>[],\n allData: Item[],\n visitedIds: Set<DataGridItemId>,\n treePlugin: DataGridTableTreePluginApi<Item>,\n ): Promise<void> {\n for (const record of records) {\n if (visitedIds.has(record.id)) {\n continue;\n }\n\n visitedIds.add(record.id);\n allData.push(record.item);\n\n const expandable = treePlugin.isExpandable(record);\n if (expandable) {\n // Load children if not already loaded\n const loadedSections = gridContext.getSectionsByParentId(record.id);\n if (!loadedSections.length) {\n const loadInstance = gridContext.triggerLoad({\n loadContext: { tree: { parentId: record.id } },\n });\n await loadInstance.promise;\n }\n\n const childRecords = gridContext.getRecordsByParentId(record.id);\n if (childRecords.length > 0) {\n await collectTreeDataFromRecords(\n gridContext,\n childRecords,\n allData,\n visitedIds,\n treePlugin,\n );\n }\n }\n }\n }\n\n async function getAllDataPageByPage(\n gridContext: DataGridPluginContext<Item>,\n paginationPlugin: PaginationPluginApi,\n ): Promise<Item[]> {\n const originalState = { page: paginationPlugin.getPage(), limit: paginationPlugin.getLimit() };\n\n const allData: Item[] = [];\n let currentPage = 1;\n let hasMorePages = true;\n\n while (hasMorePages) {\n const loadInstance = gridContext.triggerLoad({\n loadContext: {\n pagination: { ...originalState, page: currentPage },\n },\n store: false,\n });\n\n await loadInstance.promise;\n\n if (loadInstance.processResult) {\n const pageData = loadInstance.processResult.results;\n\n if (pageData.length === 0) {\n hasMorePages = false;\n } else {\n allData.push(...pageData);\n currentPage++;\n\n if (pageData.length < originalState.limit) {\n hasMorePages = false;\n }\n\n if (\n loadInstance.processResult.total &&\n allData.length >= loadInstance.processResult.total\n ) {\n hasMorePages = false;\n }\n }\n } else {\n hasMorePages = false;\n }\n }\n\n return allData;\n }\n}\n\nfunction rootSection<Item extends DataGridItem>(): DataGridSection<Item> {\n return { id: '', visible: true, loadContext: {}, parentId: null, records: [] };\n}\n\nfunction toError(error: unknown): Error {\n return error instanceof Error ? error : new Error(String(error));\n}\n\nexport function generateFilename(\n filename: string | (() => string) | undefined,\n extension: string,\n): string {\n if (typeof filename === 'function') {\n return filename();\n }\n\n if (typeof filename === 'string') {\n return filename.endsWith(`.${extension}`) ? filename : `${filename}.${extension}`;\n }\n\n const timestamp = new Date().toISOString().slice(0, 19).replace(/:/g, '-');\n return `${timestamp}.${extension}`;\n}\n","import { ArrowDownToLineIcon } from 'lucide-react';\nimport { useState } from 'react';\nimport { DropdownMenuItem } from '../../../../../dropdown-menu/public.js';\nimport { messages } from '../../../../messages';\nimport { useDataGridPluginContext } from '../../../../services/core/data-grid-context';\nimport { resolveLabel } from '../../../../services/table/table-helpers';\nimport { useTableService } from '../../../../services/table/table-context';\nimport { isRecord } from '../../../../utils/is-record';\nimport { createExportService } from './export-service';\nimport type {\n DataGridExportColumn,\n DataGridExportFormat,\n DataGridExportOptions,\n} from './export-types';\n\ninterface DataGridExportMenuItemParams {\n type: DataGridExportFormat;\n exportConfig?: Partial<DataGridExportOptions>;\n}\n\nexport interface DataGridExportMenuItemProps {\n params?: Record<string, unknown>;\n}\n\n// The menu hands every item `params` as a plain record, so the item reads its own back with these.\n// `exportConfig` is only known to be an object here: `exportMenuItems` is what typed it.\nfunction isExportFormat(value: unknown): value is DataGridExportFormat {\n return value === 'csv' || value === 'xlsx';\n}\n\nfunction isExportConfig(value: unknown): value is Partial<DataGridExportOptions> {\n return isRecord(value);\n}\n\nfunction readParams(params: Record<string, unknown> | undefined): DataGridExportMenuItemParams | undefined {\n if (!params || !isExportFormat(params.type)) return undefined;\n\n return {\n type: params.type,\n exportConfig: isExportConfig(params.exportConfig) ? params.exportConfig : undefined,\n };\n}\n\nexport function DataGridExportMenuItem({ params: rawParams }: DataGridExportMenuItemProps) {\n const params = readParams(rawParams);\n const pluginContext = useDataGridPluginContext();\n // useTableService is needed for useVisibleColumns which isn't exposed in the public API\n const tableService = useTableService();\n const [isExporting, setIsExporting] = useState(false);\n\n const visibleColumns = tableService.useVisibleColumns();\n const exportType = params?.type === 'csv' ? 'CSV' : 'Excel';\n\n async function handleSelect() {\n if (isExporting || !params) return;\n\n setIsExporting(true);\n\n try {\n const exportService = createExportService();\n\n const allData = await exportService.getAllData(pluginContext);\n\n const columns: DataGridExportColumn[] = visibleColumns.map((column) => {\n const label = resolveLabel(column.label);\n return {\n id: column.id,\n label,\n key: column.key,\n formatter: column.formatter,\n };\n });\n\n const defaultOptions: DataGridExportOptions = {\n format: params.type,\n filename: messages.exportMenuItem.defaultFilename,\n includeHeaders: true,\n ...(params.type === 'xlsx' ? { sheetName: messages.exportMenuItem.defaultSheetName } : {}),\n };\n\n const options: DataGridExportOptions = {\n ...defaultOptions,\n ...params.exportConfig,\n };\n\n const method =\n params.type === 'csv' ? exportService.exportToCSV : exportService.exportToExcel;\n\n await method(allData, columns, options, pluginContext);\n } catch (error) {\n console.error('Export failed:', error);\n } finally {\n setIsExporting(false);\n }\n }\n\n return (\n <DropdownMenuItem disabled={isExporting} onClick={handleSelect}>\n <ArrowDownToLineIcon />\n {messages.exportMenuItem.exportAs(exportType)}\n </DropdownMenuItem>\n );\n}\n","// `.js` on each relative import: they land verbatim in the shipped declaration file, where\n// `moduleResolution: \"nodenext\"` rejects an extensionless one and the type behind it goes untyped.\nimport type { DataGridItem } from '../../../../data-grid-types.js';\nimport type { DataGridActionsMenuItemOption } from '../../actions-menu-types.js';\nimport { DataGridExportMenuItem } from './data-grid-export-menu-item';\nimport type { DataGridExportOptions } from './export-types.js';\n\n/**\n * The items that export the grid's rows: Excel, when `loadExcelJs` is given, and CSV. Both read the\n * whole data set, not just the page on screen.\n */\nexport function exportMenuItems<Item extends DataGridItem = DataGridItem>(\n config?: Partial<DataGridExportOptions<Item>>,\n): DataGridActionsMenuItemOption[] {\n const csv: DataGridActionsMenuItemOption = {\n component: DataGridExportMenuItem,\n params: { type: 'csv', exportConfig: config },\n };\n\n // exceljs is the consumer's to load, so an Excel item with no way to load it would only fail.\n if (!config?.loadExcelJs) return [csv];\n\n return [{ component: DataGridExportMenuItem, params: { type: 'xlsx', exportConfig: config } }, csv];\n}\n"],"names":["DataGridActionsMenu","menuItems","useDataGrid","portalContainer","useDataGridPortalContainer","DropdownMenu","jsx","DropdownMenuTrigger","Button","EllipsisIcon","messages","DropdownMenuContent","menuItem","DataGridActionsMenuPlugin","createDataGridPlugin","context","useStore","create","registerMenuItem","s","onPropsChange","options","id","currentItems","order","newMenuItem","updatedItems","a","b","props","items","index","getCellValue","item","column","rawValue","formattedValue","applyCellTextTransformation","cellValue","transformCellText","gridContext","transformer","csvFormatter","exportContext","data","columns","delimiter","includeHeaders","rows","headerRow","escapeCsvValue","row","transformedValue","csvInjectionChars","value","stringValue","escaped","excelFormatter","excelJs","resolveExcelJs","workbook","worksheet","currentRow","cell","columnIndex","processExcelValue","buffer","hasDefault","module","api","date","trimmed","createExportService","exportToCSV","exportToExcel","downloadFile","getAllData","csvOptions","csvContent","filename","generateFilename","error","toError","excelOptions","excelBlob","content","mimeType","blob","url","link","paginationPlugin","treePlugin","getAllTreeDataWithPagination","getAllTreeData","getAllDataPageByPage","record","allData","visitedIds","records","collectTreeDataFromRecords","originalState","currentPage","hasMorePages","loadInstance","pageData","pageRecords","rootSection","childRecords","extension","isExportFormat","isExportConfig","isRecord","readParams","params","DataGridExportMenuItem","rawParams","pluginContext","useDataGridPluginContext","tableService","useTableService","isExporting","setIsExporting","useState","visibleColumns","exportType","handleSelect","exportService","label","resolveLabel","jsxs","DropdownMenuItem","ArrowDownToLineIcon","exportMenuItems","config","csv"],"mappings":";;;;;;;;;;;;;AAaO,SAASA,IAAsB;AAGpC,QAAMC,IAFOC,EAAA,EACY,UAAwC,aAAa,EAChD,aAAA,GACxBC,IAAkBC,EAAA;AAExB,2BACGC,GAAA,EACC,UAAA;AAAA,IAAA,gBAAAC;AAAA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YACf,UAAUvG,EAAS,eAAe;AAAA,YAClC,gBAAgB;AAAA,YAChB,GAAIuG,EAAO,SAAS,SAAS,EAAE,WAAWvG,EAAS,eAAe,qBAAqB,CAAA;AAAA,UAAC;AAAA,UAKxF,GAAGuG,EAAO;AAAA,QAAA;AAMZ,eAFEA,EAAO,SAAS,QAAQa,EAAc,cAAcA,EAAc,eAEvD9B,GAASnD,GAASxB,GAAS+F,CAAa;AAAA,MACvD,SAASnC,GAAO;AACd,gBAAQ,MAAM,kBAAkBA,CAAK;AAAA,MACvC,UAAA;AACE,QAAAwC,EAAe,EAAK;AAAA,MACtB;AAAA;AAAA,EACF;AAEA,SACE,gBAAAQ,EAACC,GAAA,EAAiB,UAAUV,GAAa,SAASK,GAChD,UAAA;AAAA,IAAA,gBAAAvH,EAAC6H,GAAA,EAAoB;AAAA,IACpBzH,EAAS,eAAe,SAASkH,CAAU;AAAA,EAAA,GAC9C;AAEJ;AC3FO,SAASQ,GACdC,GACiC;AACjC,QAAMC,IAAqC;AAAA,IACzC,WAAWpB;AAAA,IACX,QAAQ,EAAE,MAAM,OAAO,cAAcmB,EAAA;AAAA,EAAO;AAI9C,SAAKA,KAAA,QAAAA,EAAQ,cAEN,CAAC,EAAE,WAAWnB,GAAwB,QAAQ,EAAE,MAAM,QAAQ,cAAcmB,EAAA,EAAO,GAAKC,CAAG,IAFjE,CAACA,CAAG;AAGvC;"}
1
+ {"version":3,"file":"actions-menu.js","sources":["../../src/components/data-grid/plugins/actions-menu/components/data-grid-actions-menu.tsx","../../src/components/data-grid/plugins/actions-menu/actions-menu-plugin.tsx","../../src/components/data-grid/plugins/actions-menu/menu-items/export-menu-items/export-cells.ts","../../src/components/data-grid/plugins/actions-menu/menu-items/export-menu-items/formatters/csv-formatter.ts","../../src/components/data-grid/plugins/actions-menu/menu-items/export-menu-items/formatters/excel-formatter.ts","../../src/components/data-grid/plugins/actions-menu/menu-items/export-menu-items/export-service.ts","../../src/components/data-grid/plugins/actions-menu/menu-items/export-menu-items/data-grid-export-menu-item.tsx","../../src/components/data-grid/plugins/actions-menu/menu-items/export-menu-items/export-menu-items.ts"],"sourcesContent":["import { EllipsisIcon } from 'lucide-react';\n\nimport { Button } from '../../../../button/public.js';\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuTrigger,\n} from '../../../../dropdown-menu/public.js';\nimport { messages } from '../../../messages';\nimport { useDataGrid } from '../../../services/core/data-grid-context';\nimport { useDataGridPortalContainer } from '../../../services/core/data-grid-portal-container-context';\nimport type { DataGridActionsMenuPluginApi } from '../actions-menu-types';\n\nexport function DataGridActionsMenu() {\n const grid = useDataGrid();\n const actionsMenu = grid.getPlugin<DataGridActionsMenuPluginApi>('actionsMenu')!;\n const menuItems = actionsMenu.useMenuItems();\n const portalContainer = useDataGridPortalContainer();\n\n return (\n <DropdownMenu>\n <DropdownMenuTrigger\n render={\n <Button\n variant=\"ghost\"\n size=\"sm\"\n icon={<EllipsisIcon />}\n aria-label={messages.actionsMenu.actions}\n />\n }\n />\n <DropdownMenuContent side=\"bottom\" align=\"end\" container={portalContainer}>\n {menuItems.map((menuItem) => (\n <menuItem.component key={menuItem.id} params={menuItem.params} />\n ))}\n </DropdownMenuContent>\n </DropdownMenu>\n );\n}\n","// Load-bearing: a plugin is rendered as a child of <DataGrid>, so a Server Component can import\n// and render it, and the component it returns calls hooks. This directive puts the banner on the\n// plugin's own entry chunk (dist/data-grid/<plugin>.js). client-boundaries.test.ts only scans a\n// component's top-level files, so scripts/verify-consumer.sh is what checks the built banner of\n// every plugin entry.\n'use client';\n\nimport { create } from 'zustand';\nimport type { DataGridItem } from '../../data-grid-types';\nimport { createDataGridPlugin } from '../../services/plugins/plugins-helpers';\nimport type {\n DataGridActionsMenuItem,\n DataGridActionsMenuItemOption,\n DataGridActionsMenuPluginApi,\n DataGridActionsMenuPluginProps,\n} from './actions-menu-types';\nimport { DataGridActionsMenu } from './components/data-grid-actions-menu';\n\ninterface ActionsMenuStore {\n menuItems: DataGridActionsMenuItem[];\n}\n\nexport const DataGridActionsMenuPlugin = createDataGridPlugin<\n DataGridItem,\n 'actionsMenu',\n DataGridActionsMenuPluginProps,\n DataGridActionsMenuPluginApi\n>('actionsMenu', (context) => {\n const useStore = create<ActionsMenuStore>(() => ({\n menuItems: [],\n }));\n\n context.registerSlot('top-end', {\n id: 'actionsMenu',\n component: DataGridActionsMenu,\n order: 100,\n });\n\n const useMenuItems = () => useStore((s) => s.menuItems);\n\n const api: DataGridActionsMenuPluginApi = {\n registerMenuItem,\n useMenuItems,\n onPropsChange,\n };\n\n return api;\n\n function registerMenuItem(options: DataGridActionsMenuItemOption) {\n const id = Math.random().toString();\n const currentItems = useStore.getState().menuItems;\n const order = options.order ?? (currentItems.length + 1) * 10;\n const newMenuItem = { id, ...options, order };\n const updatedItems = [...currentItems, newMenuItem].sort((a, b) => a.order - b.order);\n useStore.setState({ menuItems: updatedItems });\n }\n\n function onPropsChange(props: DataGridActionsMenuPluginProps) {\n const items: DataGridActionsMenuItem[] = props.menuItems.map((options, index) => {\n const id = Math.random().toString();\n const order = options.order ?? (index + 1) * 10;\n return { id, ...options, order } satisfies DataGridActionsMenuItem;\n });\n items.sort((a, b) => a.order - b.order);\n useStore.setState({ menuItems: items });\n }\n});\n","import type { DataGridItem } from '../../../../data-grid-types';\nimport type { DataGridPluginContext } from '../../../../services/plugins/plugins-types';\nimport type { DataGridExportColumn, DataGridExportOptions } from './export-types';\n\n// What a formatter does to one cell, apart from the service that uses the formatters: the service\n// imports them, so they cannot import it back.\n\nexport function getCellValue<Item extends DataGridItem = DataGridItem>(\n item: Item,\n column: DataGridExportColumn,\n): { raw: unknown; formatted: string } {\n const rawValue = column.key ? item[column.key] : item[column.id];\n\n let formattedValue: string;\n if (column.formatter) {\n formattedValue = column.formatter(rawValue);\n } else {\n formattedValue = String(rawValue ?? '');\n }\n\n return { raw: rawValue, formatted: formattedValue };\n}\n\nexport function applyCellTextTransformation<Item extends DataGridItem = DataGridItem>({\n item,\n column,\n cellValue,\n transformCellText,\n gridContext,\n}: {\n item: Item;\n column: DataGridExportColumn;\n cellValue: { raw: unknown; formatted: string };\n transformCellText: DataGridExportOptions<Item>['transformCellText'];\n gridContext: DataGridPluginContext<Item>;\n}): string {\n const transformer = transformCellText?.[column.id];\n\n if (!transformer) {\n return cellValue.formatted;\n }\n\n return transformer(\n {\n value: cellValue.raw,\n formattedValue: cellValue.formatted,\n row: item,\n },\n gridContext,\n );\n}\n","import type { DataGridItem } from '../../../../../data-grid-types';\nimport { applyCellTextTransformation, getCellValue } from '../export-cells';\nimport type { DataGridExportFormatter, DataGridExportFormatterParams } from '../export-types';\n\nexport const csvFormatter: DataGridExportFormatter = <Item extends DataGridItem>(\n exportContext: DataGridExportFormatterParams<Item>,\n): Promise<string> => {\n const { data, columns, options, gridContext } = exportContext;\n const delimiter = options.delimiter || ',';\n const includeHeaders = options.includeHeaders ?? true;\n const rows: string[] = [];\n\n if (includeHeaders) {\n const headerRow = columns\n .map((column) => escapeCsvValue(column.label, delimiter))\n .join(delimiter);\n rows.push(headerRow);\n }\n\n for (const item of data) {\n const row: string[] = [];\n\n for (const column of columns) {\n const cellValue = getCellValue(item, column);\n\n const transformedValue = applyCellTextTransformation({\n item,\n column,\n cellValue,\n transformCellText: options.transformCellText,\n gridContext,\n });\n\n row.push(escapeCsvValue(transformedValue, delimiter));\n }\n\n rows.push(row.join(delimiter));\n }\n\n return Promise.resolve(rows.join('\\n'));\n};\n\nconst csvInjectionChars = /^[=+\\-@\\t\\r]/;\n\nfunction escapeCsvValue(value: string, delimiter: string): string {\n const stringValue = String(value ?? '');\n\n const needsQuoting =\n stringValue.includes(delimiter) ||\n stringValue.includes('\\n') ||\n stringValue.includes('\"') ||\n csvInjectionChars.test(stringValue);\n\n if (needsQuoting) {\n const escaped = stringValue.replace(/\"/g, '\"\"');\n // Prefix with tab to prevent CSV injection (CWE-1236) when value starts with a formula character\n const prefix = csvInjectionChars.test(stringValue) ? '\\t' : '';\n return `\"${prefix}${escaped}\"`;\n }\n\n return stringValue;\n}\n","import type { DataGridItem } from '../../../../../data-grid-types';\nimport { applyCellTextTransformation, getCellValue } from '../export-cells';\nimport type {\n DataGridExcelJsApi,\n DataGridExcelJsModule,\n DataGridExportFormatter,\n DataGridExportFormatterParams,\n} from '../export-types';\n\nexport const excelFormatter: DataGridExportFormatter = async <Item extends DataGridItem>(\n exportContext: DataGridExportFormatterParams<Item>,\n): Promise<Blob> => {\n const { data, columns, options, gridContext } = exportContext;\n\n if (!options.loadExcelJs) {\n throw new Error(\n 'Exporting to Excel needs `loadExcelJs`, a function that loads the exceljs package: the grid does not import it itself.',\n );\n }\n const excelJs = resolveExcelJs(await options.loadExcelJs());\n\n const workbook = new excelJs.Workbook();\n const worksheet = workbook.addWorksheet(options.sheetName);\n\n const includeHeaders = options.includeHeaders ?? true;\n let currentRow = 1;\n\n if (includeHeaders) {\n const headerRow = worksheet.getRow(currentRow);\n\n columns.forEach((column, index) => {\n const cell = headerRow.getCell(index + 1);\n cell.value = column.label;\n });\n\n currentRow++;\n }\n\n for (const item of data) {\n const row = worksheet.getRow(currentRow);\n\n for (const [columnIndex, column] of columns.entries()) {\n const cellValue = getCellValue(item, column);\n\n const transformedValue = applyCellTextTransformation({\n item,\n column,\n cellValue,\n transformCellText: options.transformCellText,\n gridContext,\n });\n\n const cell = row.getCell(columnIndex + 1);\n\n cell.value = processExcelValue(cellValue.raw, transformedValue);\n }\n\n currentRow++;\n }\n\n const buffer = await workbook.xlsx.writeBuffer();\n return new Blob([buffer], {\n type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',\n });\n};\n\nfunction hasDefault(module: DataGridExcelJsModule): module is { default: DataGridExcelJsApi } {\n return 'default' in module && !!module.default;\n}\n\n// A CommonJS package imported dynamically arrives as the module itself under one bundler and as\n// `{ default: module }` under another, so the loader's result is read either way.\nfunction resolveExcelJs(module: DataGridExcelJsModule): DataGridExcelJsApi {\n const api = hasDefault(module) ? module.default : module;\n if (typeof api.Workbook !== 'function') {\n throw new Error('`loadExcelJs` has to resolve to the exceljs package, which exports `Workbook`.');\n }\n return api;\n}\n\nexport function processExcelValue(\n rawValue: unknown,\n transformedValue: string,\n): string | number | boolean | Date {\n if (transformedValue !== String(rawValue ?? '')) {\n return transformedValue;\n }\n\n if (rawValue === null || rawValue === undefined) {\n return '';\n }\n\n if (typeof rawValue === 'number') {\n return rawValue;\n }\n\n if (typeof rawValue === 'boolean') {\n return rawValue;\n }\n\n if (rawValue instanceof Date) {\n return rawValue;\n }\n\n if (typeof rawValue === 'string') {\n const dateRegex = /^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(Z|[+-]\\d{2}:\\d{2})?)?$/;\n if (dateRegex.test(rawValue)) {\n const date = new Date(rawValue);\n if (!isNaN(date.getTime())) {\n return date;\n }\n }\n\n const trimmed = rawValue.trim();\n if (\n trimmed !== '' &&\n !isNaN(Number(trimmed)) &&\n !/[eE]/.test(trimmed) &&\n !(trimmed.length > 1 && trimmed.startsWith('0') && trimmed[1] !== '.')\n ) {\n return Number(trimmed);\n }\n }\n\n return String(rawValue);\n}\n","import type { DataGridItem } from '../../../../data-grid-types';\nimport type { DataGridPluginContext } from '../../../../services/plugins/plugins-types';\nimport type {\n DataGridItemId,\n DataGridRecord,\n DataGridSection,\n} from '../../../../services/storage/storage-types';\nimport type { PaginationPluginApi } from '../../../pagination/pagination-plugin';\nimport type { DataGridTableTreePluginApi } from '../../../table-tree/table-tree-types';\nimport type {\n DataGridExportColumn,\n DataGridExportOptions,\n DataGridExportService,\n} from './export-types';\nimport { csvFormatter } from './formatters/csv-formatter';\nimport { excelFormatter } from './formatters/excel-formatter';\n\nexport function createExportService<\n Item extends DataGridItem = DataGridItem,\n>(): DataGridExportService<Item> {\n return {\n exportToCSV,\n exportToExcel,\n downloadFile,\n getAllData,\n };\n\n async function exportToCSV(\n data: Item[],\n columns: DataGridExportColumn[],\n options: DataGridExportOptions<Item>,\n gridContext: DataGridPluginContext<Item>,\n ): Promise<void> {\n const csvOptions = { ...options, format: 'csv' as const };\n try {\n const csvContent = await csvFormatter<Item>({\n data,\n columns,\n options: csvOptions,\n gridContext,\n });\n\n const filename = generateFilename(options.filename, 'csv');\n downloadFile(csvContent, filename, 'text/csv');\n } catch (error) {\n if (options.onError) {\n options.onError(toError(error));\n } else {\n throw error;\n }\n }\n }\n\n async function exportToExcel(\n data: Item[],\n columns: DataGridExportColumn[],\n options: DataGridExportOptions<Item>,\n gridContext: DataGridPluginContext<Item>,\n ): Promise<void> {\n const excelOptions = { ...options, format: 'xlsx' as const };\n try {\n const excelBlob = await excelFormatter<Item>({\n data,\n columns,\n options: excelOptions,\n gridContext,\n });\n\n const filename = generateFilename(options.filename, 'xlsx');\n downloadFile(\n excelBlob,\n filename,\n 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',\n );\n } catch (error) {\n if (options.onError) {\n options.onError(toError(error));\n } else {\n throw error;\n }\n }\n }\n\n function downloadFile(content: string | Blob, filename: string, mimeType: string): void {\n const blob = content instanceof Blob ? content : new Blob([content], { type: mimeType });\n const url = URL.createObjectURL(blob);\n\n const link = document.createElement('a');\n link.href = url;\n link.download = filename;\n link.style.display = 'none';\n\n document.body.appendChild(link);\n link.click();\n document.body.removeChild(link);\n\n URL.revokeObjectURL(url);\n }\n\n async function getAllData(gridContext: DataGridPluginContext<Item>): Promise<Item[]> {\n // The export reads the pagination and the tree plugin by name: with neither registered, what\n // is on screen is everything there is.\n const paginationPlugin = gridContext.getPlugin<PaginationPluginApi>('pagination');\n const treePlugin = gridContext.getPlugin<DataGridTableTreePluginApi<Item>>('tableTree');\n\n if (treePlugin && paginationPlugin) {\n return await getAllTreeDataWithPagination(gridContext, treePlugin, paginationPlugin);\n } else if (treePlugin) {\n return await getAllTreeData(gridContext, treePlugin);\n } else if (paginationPlugin) {\n return await getAllDataPageByPage(gridContext, paginationPlugin);\n }\n\n const records = gridContext.useStore.getState().visibleRecords;\n return records.map((record) => record.item);\n }\n\n async function getAllTreeData(\n gridContext: DataGridPluginContext<Item>,\n treePlugin: DataGridTableTreePluginApi<Item>,\n ): Promise<Item[]> {\n const allData: Item[] = [];\n const visitedIds = new Set<DataGridItemId>();\n const records = gridContext.useStore.getState().visibleRecords;\n\n await collectTreeDataFromRecords(gridContext, records, allData, visitedIds, treePlugin);\n return allData;\n }\n\n async function getAllTreeDataWithPagination(\n gridContext: DataGridPluginContext<Item>,\n treePlugin: DataGridTableTreePluginApi<Item>,\n paginationPlugin: PaginationPluginApi,\n ): Promise<Item[]> {\n const originalState = { page: paginationPlugin.getPage(), limit: paginationPlugin.getLimit() };\n const allData: Item[] = [];\n const visitedIds = new Set<DataGridItemId>();\n let currentPage = 1;\n let hasMorePages = true;\n // A page here is never empty, so the empty set stands for \"no previous page\".\n let previousPageIds = new Set<DataGridItemId>();\n\n while (hasMorePages) {\n const loadInstance = gridContext.triggerLoad({\n loadContext: {\n pagination: { ...originalState, page: currentPage },\n tree: { parentId: null },\n },\n store: false,\n });\n\n await loadInstance.promise;\n\n if (loadInstance.processResult) {\n const pageData = loadInstance.processResult.results;\n\n if (pageData.length === 0) {\n hasMorePages = false;\n } else {\n // A page is not stored, so it has no records of the grid's own; the tree is walked\n // over records made for it.\n const pageRecords = pageData.map((item, index) => ({\n id: gridContext.getItemId(item),\n item,\n index,\n section: rootSection<Item>(),\n }));\n\n // A load that ignores the page returns the same rows again, maybe reordered; stop\n // there, not never.\n const pageIds = new Set(pageRecords.map((record) => record.id));\n const repeatsPreviousPage =\n pageIds.size === previousPageIds.size &&\n [...pageIds].every((id) => previousPageIds.has(id));\n previousPageIds = pageIds;\n\n await collectTreeDataFromRecords(\n gridContext,\n pageRecords,\n allData,\n visitedIds,\n treePlugin,\n );\n\n currentPage++;\n\n if (repeatsPreviousPage || pageData.length < originalState.limit) {\n hasMorePages = false;\n }\n }\n } else {\n hasMorePages = false;\n }\n }\n\n return allData;\n }\n\n async function collectTreeDataFromRecords(\n gridContext: DataGridPluginContext<Item>,\n records: DataGridRecord<Item>[],\n allData: Item[],\n visitedIds: Set<DataGridItemId>,\n treePlugin: DataGridTableTreePluginApi<Item>,\n ): Promise<void> {\n for (const record of records) {\n if (visitedIds.has(record.id)) {\n continue;\n }\n\n visitedIds.add(record.id);\n allData.push(record.item);\n\n const expandable = treePlugin.isExpandable(record);\n if (expandable) {\n // Load children if not already loaded\n const loadedSections = gridContext.getSectionsByParentId(record.id);\n if (!loadedSections.length) {\n const loadInstance = gridContext.triggerLoad({\n loadContext: { tree: { parentId: record.id } },\n });\n await loadInstance.promise;\n }\n\n const childRecords = gridContext.getRecordsByParentId(record.id);\n if (childRecords.length > 0) {\n await collectTreeDataFromRecords(\n gridContext,\n childRecords,\n allData,\n visitedIds,\n treePlugin,\n );\n }\n }\n }\n }\n\n async function getAllDataPageByPage(\n gridContext: DataGridPluginContext<Item>,\n paginationPlugin: PaginationPluginApi,\n ): Promise<Item[]> {\n const originalState = { page: paginationPlugin.getPage(), limit: paginationPlugin.getLimit() };\n\n const allData: Item[] = [];\n let currentPage = 1;\n let hasMorePages = true;\n\n while (hasMorePages) {\n const loadInstance = gridContext.triggerLoad({\n loadContext: {\n pagination: { ...originalState, page: currentPage },\n },\n store: false,\n });\n\n await loadInstance.promise;\n\n if (loadInstance.processResult) {\n const pageData = loadInstance.processResult.results;\n\n if (pageData.length === 0) {\n hasMorePages = false;\n } else {\n allData.push(...pageData);\n currentPage++;\n\n if (pageData.length < originalState.limit) {\n hasMorePages = false;\n }\n\n if (\n loadInstance.processResult.total &&\n allData.length >= loadInstance.processResult.total\n ) {\n hasMorePages = false;\n }\n }\n } else {\n hasMorePages = false;\n }\n }\n\n return allData;\n }\n}\n\nfunction rootSection<Item extends DataGridItem>(): DataGridSection<Item> {\n return { id: '', visible: true, loadContext: {}, parentId: null, records: [] };\n}\n\nfunction toError(error: unknown): Error {\n return error instanceof Error ? error : new Error(String(error));\n}\n\nexport function generateFilename(\n filename: string | (() => string) | undefined,\n extension: string,\n): string {\n if (typeof filename === 'function') {\n return filename();\n }\n\n if (typeof filename === 'string') {\n return filename.endsWith(`.${extension}`) ? filename : `${filename}.${extension}`;\n }\n\n const timestamp = new Date().toISOString().slice(0, 19).replace(/:/g, '-');\n return `${timestamp}.${extension}`;\n}\n","import { ArrowDownToLineIcon } from 'lucide-react';\nimport { useState } from 'react';\nimport { DropdownMenuItem } from '../../../../../dropdown-menu/public.js';\nimport { messages } from '../../../../messages';\nimport { useDataGridPluginContext } from '../../../../services/core/data-grid-context';\nimport { resolveLabel } from '../../../../services/table/table-helpers';\nimport { useTableService } from '../../../../services/table/table-context';\nimport { isRecord } from '../../../../utils/is-record';\nimport { createExportService } from './export-service';\nimport type {\n DataGridExportColumn,\n DataGridExportFormat,\n DataGridExportOptions,\n} from './export-types';\n\ninterface DataGridExportMenuItemParams {\n type: DataGridExportFormat;\n exportConfig?: Partial<DataGridExportOptions>;\n}\n\nexport interface DataGridExportMenuItemProps {\n params?: Record<string, unknown>;\n}\n\n// The menu hands every item `params` as a plain record, so the item reads its own back with these.\n// `exportConfig` is only known to be an object here: `exportMenuItems` is what typed it.\nfunction isExportFormat(value: unknown): value is DataGridExportFormat {\n return value === 'csv' || value === 'xlsx';\n}\n\nfunction isExportConfig(value: unknown): value is Partial<DataGridExportOptions> {\n return isRecord(value);\n}\n\nfunction readParams(params: Record<string, unknown> | undefined): DataGridExportMenuItemParams | undefined {\n if (!params || !isExportFormat(params.type)) return undefined;\n\n return {\n type: params.type,\n exportConfig: isExportConfig(params.exportConfig) ? params.exportConfig : undefined,\n };\n}\n\nexport function DataGridExportMenuItem({ params: rawParams }: DataGridExportMenuItemProps) {\n const params = readParams(rawParams);\n const pluginContext = useDataGridPluginContext();\n // useTableService is needed for useVisibleColumns which isn't exposed in the public API\n const tableService = useTableService();\n const [isExporting, setIsExporting] = useState(false);\n\n const visibleColumns = tableService.useVisibleColumns();\n const exportType = params?.type === 'csv' ? 'CSV' : 'Excel';\n\n async function handleSelect() {\n if (isExporting || !params) return;\n\n setIsExporting(true);\n\n try {\n const exportService = createExportService();\n\n const allData = await exportService.getAllData(pluginContext);\n\n const columns: DataGridExportColumn[] = visibleColumns.map((column) => {\n const label = resolveLabel(column.label);\n return {\n id: column.id,\n label,\n key: column.key,\n formatter: column.formatter,\n };\n });\n\n const defaultOptions: DataGridExportOptions = {\n format: params.type,\n filename: messages.exportMenuItem.defaultFilename,\n includeHeaders: true,\n ...(params.type === 'xlsx' ? { sheetName: messages.exportMenuItem.defaultSheetName } : {}),\n };\n\n const options: DataGridExportOptions = {\n ...defaultOptions,\n ...params.exportConfig,\n };\n\n const method =\n params.type === 'csv' ? exportService.exportToCSV : exportService.exportToExcel;\n\n await method(allData, columns, options, pluginContext);\n } catch (error) {\n console.error('Export failed:', error);\n } finally {\n setIsExporting(false);\n }\n }\n\n return (\n <DropdownMenuItem disabled={isExporting} onClick={handleSelect}>\n <ArrowDownToLineIcon />\n {messages.exportMenuItem.exportAs(exportType)}\n </DropdownMenuItem>\n );\n}\n","// `.js` on each relative import: they land verbatim in the shipped declaration file, where\n// `moduleResolution: \"nodenext\"` rejects an extensionless one and the type behind it goes untyped.\nimport type { DataGridItem } from '../../../../data-grid-types.js';\nimport type { DataGridActionsMenuItemOption } from '../../actions-menu-types.js';\nimport { DataGridExportMenuItem } from './data-grid-export-menu-item';\nimport type { DataGridExportOptions } from './export-types.js';\n\n/**\n * The items that export the grid's rows: Excel, when `loadExcelJs` is given, and CSV. Both read the\n * whole data set, not just the page on screen.\n */\nexport function exportMenuItems<Item extends DataGridItem = DataGridItem>(\n config?: Partial<DataGridExportOptions<Item>>,\n): DataGridActionsMenuItemOption[] {\n const csv: DataGridActionsMenuItemOption = {\n component: DataGridExportMenuItem,\n params: { type: 'csv', exportConfig: config },\n };\n\n // exceljs is the consumer's to load, so an Excel item with no way to load it would only fail.\n if (!config?.loadExcelJs) return [csv];\n\n return [{ component: DataGridExportMenuItem, params: { type: 'xlsx', exportConfig: config } }, csv];\n}\n"],"names":["DataGridActionsMenu","menuItems","useDataGrid","portalContainer","useDataGridPortalContainer","DropdownMenu","jsx","DropdownMenuTrigger","Button","EllipsisIcon","messages","DropdownMenuContent","menuItem","DataGridActionsMenuPlugin","createDataGridPlugin","context","useStore","create","registerMenuItem","s","onPropsChange","options","id","currentItems","order","newMenuItem","updatedItems","a","b","props","items","index","getCellValue","item","column","rawValue","formattedValue","applyCellTextTransformation","cellValue","transformCellText","gridContext","transformer","csvFormatter","exportContext","data","columns","delimiter","includeHeaders","rows","headerRow","escapeCsvValue","row","transformedValue","csvInjectionChars","value","stringValue","escaped","excelFormatter","excelJs","resolveExcelJs","workbook","worksheet","currentRow","cell","columnIndex","processExcelValue","buffer","hasDefault","module","api","date","trimmed","createExportService","exportToCSV","exportToExcel","downloadFile","getAllData","csvOptions","csvContent","filename","generateFilename","error","toError","excelOptions","excelBlob","content","mimeType","blob","url","link","paginationPlugin","treePlugin","getAllTreeDataWithPagination","getAllTreeData","getAllDataPageByPage","record","allData","visitedIds","records","collectTreeDataFromRecords","originalState","currentPage","hasMorePages","previousPageIds","loadInstance","pageData","pageRecords","rootSection","pageIds","repeatsPreviousPage","childRecords","extension","isExportFormat","isExportConfig","isRecord","readParams","params","DataGridExportMenuItem","rawParams","pluginContext","useDataGridPluginContext","tableService","useTableService","isExporting","setIsExporting","useState","visibleColumns","exportType","handleSelect","exportService","label","resolveLabel","jsxs","DropdownMenuItem","ArrowDownToLineIcon","exportMenuItems","config","csv"],"mappings":";;;;;;;;;;;;;AAaO,SAASA,IAAsB;AAGpC,QAAMC,IAFOC,EAAA,EACY,UAAwC,aAAa,EAChD,aAAA,GACxBC,IAAkBC,EAAA;AAExB,2BACGC,GAAA,EACC,UAAA;AAAA,IAAA,gBAAAC;AAAA,MAACC;AAAA,MAAA;AAAA,QACC,QACE,gBAAAD;AAAA,UAACE;AAAA,UAAA;AAAA,YACC,SAAQ;AAAA,YACR,MAAK;AAAA,YACL,wBAAOC,GAAA,EAAa;AAAA,YACpB,cAAYC,EAAS,YAAY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,CAAC,GASKb,IAAiC;AAAA,UACrC,GAR4C;AAAA,YAC5C,QAAQ+F,EAAO;AAAA,YACf,UAAU1G,EAAS,eAAe;AAAA,YAClC,gBAAgB;AAAA,YAChB,GAAI0G,EAAO,SAAS,SAAS,EAAE,WAAW1G,EAAS,eAAe,qBAAqB,CAAA;AAAA,UAAC;AAAA,UAKxF,GAAG0G,EAAO;AAAA,QAAA;AAMZ,eAFEA,EAAO,SAAS,QAAQa,EAAc,cAAcA,EAAc,eAEvDjC,GAASnD,GAASxB,GAASkG,CAAa;AAAA,MACvD,SAAStC,GAAO;AACd,gBAAQ,MAAM,kBAAkBA,CAAK;AAAA,MACvC,UAAA;AACE,QAAA2C,EAAe,EAAK;AAAA,MACtB;AAAA;AAAA,EACF;AAEA,SACE,gBAAAQ,EAACC,GAAA,EAAiB,UAAUV,GAAa,SAASK,GAChD,UAAA;AAAA,IAAA,gBAAA1H,EAACgI,GAAA,EAAoB;AAAA,IACpB5H,EAAS,eAAe,SAASqH,CAAU;AAAA,EAAA,GAC9C;AAEJ;AC3FO,SAASQ,GACdC,GACiC;AACjC,QAAMC,IAAqC;AAAA,IACzC,WAAWpB;AAAA,IACX,QAAQ,EAAE,MAAM,OAAO,cAAcmB,EAAA;AAAA,EAAO;AAI9C,SAAKA,KAAA,QAAAA,EAAQ,cAEN,CAAC,EAAE,WAAWnB,GAAwB,QAAQ,EAAE,MAAM,QAAQ,cAAcmB,EAAA,EAAO,GAAKC,CAAG,IAFjE,CAACA,CAAG;AAGvC;"}
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { create as I } from "zustand";
3
- import { u as L, b as P, c as q } from "../chunks/plugins-helpers.js";
3
+ import { u as q, b as h, c as L } from "../chunks/plugins-helpers.js";
4
4
  import { jsx as D, jsxs as y } from "react/jsx-runtime";
5
5
  import { cx as C } from "class-variance-authority";
6
6
  import { GripVerticalIcon as B } from "lucide-react";
@@ -8,18 +8,18 @@ import { m as H } from "../chunks/messages.js";
8
8
  import { I as N } from "../chunks/ignore-row-click.js";
9
9
  import { u as O, D as j } from "../chunks/data-grid-record-context.js";
10
10
  import { Spinner as F } from "../spinner.js";
11
- import { combine as h } from "@atlaskit/pragmatic-drag-and-drop/dist/esm/entry-point/combine.js";
12
- import { dropTargetForElements as E, monitorForElements as V, draggable as A } from "@atlaskit/pragmatic-drag-and-drop/dist/esm/entry-point/element/adapter.js";
13
- import { extractClosestEdge as K, attachClosestEdge as M } from "@atlaskit/pragmatic-drag-and-drop-hitbox/dist/esm/closest-edge.js";
14
- import { useRef as S, useEffect as G, useState as U } from "react";
11
+ import { combine as P } from "@atlaskit/pragmatic-drag-and-drop/dist/esm/entry-point/combine.js";
12
+ import { dropTargetForElements as E, monitorForElements as M, draggable as V } from "@atlaskit/pragmatic-drag-and-drop/dist/esm/entry-point/element/adapter.js";
13
+ import { extractClosestEdge as k, attachClosestEdge as A } from "@atlaskit/pragmatic-drag-and-drop-hitbox/dist/esm/closest-edge.js";
14
+ import { useRef as S, useEffect as G, useState as K } from "react";
15
15
  import { i as T } from "../chunks/is-record.js";
16
- import { pointerOutsideOfPreview as $ } from "@atlaskit/pragmatic-drag-and-drop/dist/esm/entry-point/element/pointer-outside-of-preview.js";
17
- import { setCustomNativeDragPreview as k } from "@atlaskit/pragmatic-drag-and-drop/dist/esm/entry-point/element/set-custom-native-drag-preview.js";
16
+ import { pointerOutsideOfPreview as U } from "@atlaskit/pragmatic-drag-and-drop/dist/esm/entry-point/element/pointer-outside-of-preview.js";
17
+ import { setCustomNativeDragPreview as $ } from "@atlaskit/pragmatic-drag-and-drop/dist/esm/entry-point/element/set-custom-native-drag-preview.js";
18
18
  import { flushSync as z, createPortal as J } from "react-dom";
19
19
  import { D as b, r as Q, a as W } from "../chunks/resolve-body-cell-props.js";
20
20
  import { u as X } from "../chunks/use-latest.js";
21
21
  import { TableRow as Y } from "../table.js";
22
- import '../chunks/drag-drop.BASVe3_O.css';const Z = "_dragHandler_mre9q_12", rr = "_dragHandlerLoading_mre9q_26", tr = "_dragRow_mre9q_38", or = "_dragRowDragging_mre9q_38", er = "_dragRowDropping_mre9q_60", nr = "_dragRowDropIndicatorTop_mre9q_66", ar = "_dragRowDropIndicatorBottom_mre9q_70", dr = "_dragPreview_mre9q_79", ir = "_content_mre9q_98", gr = "_contentDragging_mre9q_111", sr = "_contentRootDropping_mre9q_122", c = {
22
+ import '../chunks/drag-drop.BASVe3_O.css';const Z = "_dragHandler_mre9q_12", rr = "_dragHandlerLoading_mre9q_26", tr = "_dragRow_mre9q_38", or = "_dragRowDragging_mre9q_38", er = "_dragRowDropping_mre9q_60", nr = "_dragRowDropIndicatorTop_mre9q_66", ar = "_dragRowDropIndicatorBottom_mre9q_70", dr = "_dragPreview_mre9q_79", ir = "_content_mre9q_98", gr = "_contentDragging_mre9q_111", sr = "_contentRootDropping_mre9q_122", p = {
23
23
  dragHandler: Z,
24
24
  dragHandlerLoading: rr,
25
25
  dragRow: tr,
@@ -33,11 +33,11 @@ import '../chunks/drag-drop.BASVe3_O.css';const Z = "_dragHandler_mre9q_12", rr
33
33
  contentRootDropping: sr
34
34
  };
35
35
  function cr() {
36
- const r = L(), t = O(), { useDropLoadingStore: n } = r.getPlugin("dragDrop"), o = n((i) => !!i.loading[t.id]);
36
+ const r = q(), t = O(), { useDropLoadingStore: a } = r.getPlugin("dragDrop"), o = a((i) => !!i.loading[t.id]);
37
37
  return /* @__PURE__ */ D(
38
38
  "div",
39
39
  {
40
- className: C(c.dragHandler, o && c.dragHandlerLoading),
40
+ className: C(p.dragHandler, o && p.dragHandlerLoading),
41
41
  [N]: "",
42
42
  "data-drag-handle": "",
43
43
  "aria-label": H.dragDrop.dragHandle,
@@ -55,35 +55,35 @@ function v(r) {
55
55
  return lr(r.record) ? r.record : void 0;
56
56
  }
57
57
  function mr({ children: r }) {
58
- const t = S(null), n = P(), { useDragDropStore: o, handleDrop: i } = n.plugins.getPlugin("dragDrop"), p = o((a) => a.isDragging), l = o((a) => a.isRootDropTarget);
58
+ const t = S(null), a = h(), { useDragDropStore: o, handleDrop: i } = a.plugins.getPlugin("dragDrop"), l = o((n) => n.isDragging), s = o((n) => n.isRootDropTarget);
59
59
  return G(() => {
60
60
  if (t.current)
61
- return h(
61
+ return P(
62
62
  E({
63
63
  element: t.current,
64
64
  getData: () => ({ type: "data-grid-root" })
65
65
  }),
66
- V({
66
+ M({
67
67
  // A page can hold several grids with this plugin, and another grid's rows are drag
68
68
  // sources too: only a drag that began in this plugin instance is this one's to track.
69
- canMonitor: ({ source: a }) => a.data.pluginStore === o,
70
- onDragStart: ({ source: a }) => {
71
- const g = v(a.data);
69
+ canMonitor: ({ source: n }) => n.data.pluginStore === o,
70
+ onDragStart: ({ source: n }) => {
71
+ const g = v(n.data);
72
72
  g && o.setState({ isDragging: !0, draggedRecordId: g.id });
73
73
  },
74
- onDropTargetChange: ({ location: a }) => {
75
- const g = a.current.dropTargets, e = g.find((w) => w.data.type === "data-grid-row"), s = g.find((w) => w.data.type === "data-grid-root"), m = e ? K(e.data) : null, f = e ? v(e.data) : void 0;
74
+ onDropTargetChange: ({ location: n }) => {
75
+ const g = n.current.dropTargets, e = g.find((w) => w.data.type === "data-grid-row"), c = g.find((w) => w.data.type === "data-grid-root"), m = e ? k(e.data) : null, f = e ? v(e.data) : void 0;
76
76
  o.setState({
77
77
  dropTargetRecordId: f == null ? void 0 : f.id,
78
78
  dropEdge: m === "top" || m === "bottom" ? m : void 0,
79
- isRootDropTarget: !e && !!s
79
+ isRootDropTarget: !e && !!c
80
80
  });
81
81
  },
82
- onDrop: ({ source: a, location: g }) => {
83
- const e = g.current.dropTargets, s = v(a.data);
84
- if (e.length > 0 && s) {
82
+ onDrop: ({ source: n, location: g }) => {
83
+ const e = g.current.dropTargets, c = v(n.data);
84
+ if (e.length > 0 && c) {
85
85
  const m = e.find((f) => f.data.type === "data-grid-row");
86
- i(s, m ? v(m.data) : void 0);
86
+ i(c, m ? v(m.data) : void 0);
87
87
  }
88
88
  o.setState({
89
89
  isDragging: !1,
@@ -100,80 +100,80 @@ function mr({ children: r }) {
100
100
  {
101
101
  ref: t,
102
102
  className: C(
103
- c.content,
104
- p && c.contentDragging,
105
- p && l && c.contentRootDropping
103
+ p.content,
104
+ l && p.contentDragging,
105
+ l && s && p.contentRootDropping
106
106
  ),
107
107
  children: r
108
108
  }
109
109
  );
110
110
  }
111
111
  function ur(r, t) {
112
- const n = document.createElement("table"), o = r.closest("table");
113
- n.className = [o == null ? void 0 : o.className, t].filter(Boolean).join(" "), n.style.width = `${r.getBoundingClientRect().width}px`;
112
+ const a = document.createElement("table"), o = r.closest("table");
113
+ a.className = [o == null ? void 0 : o.className, t].filter(Boolean).join(" "), a.style.width = `${r.getBoundingClientRect().width}px`;
114
114
  const i = document.createElement("tbody");
115
- return i.appendChild(r.cloneNode(!0)), n.appendChild(i), n;
115
+ return i.appendChild(r.cloneNode(!0)), a.appendChild(i), a;
116
116
  }
117
117
  function Dr({
118
118
  record: r
119
119
  }) {
120
- const t = S(null), n = X(r), [o, i] = U(null), p = P(), l = p.table, a = l.useVisibleColumns(), g = l.useTableLayout(), { useDragDropStore: e, renderDragPreview: s } = p.plugins.getPlugin("dragDrop"), m = e((d) => d.draggedRecordId === r.id), f = e((d) => d.dropTargetRecordId === r.id), w = e(
120
+ const t = S(null), a = X(r), [o, i] = K(null), l = h(), s = l.table, n = s.useVisibleColumns(), g = s.useTableLayout(), { useDragDropStore: e, renderDragPreview: c } = l.plugins.getPlugin("dragDrop"), m = e((d) => d.draggedRecordId === r.id), f = e((d) => d.dropTargetRecordId === r.id), w = e(
121
121
  (d) => d.dropTargetRecordId === r.id ? d.dropEdge : void 0
122
- ), x = l.useComponent("body-cell-content");
122
+ ), x = s.useComponent("body-cell-content");
123
123
  return G(() => {
124
124
  if (!t.current) return;
125
125
  const d = t.current.querySelector("[data-drag-handle]");
126
- return h(
127
- A({
126
+ return P(
127
+ V({
128
128
  element: t.current,
129
129
  dragHandle: d ?? void 0,
130
130
  getInitialData: () => ({
131
131
  type: "data-grid-row",
132
132
  pluginStore: e,
133
- recordId: n.current.id,
134
- record: n.current
133
+ recordId: a.current.id,
134
+ record: a.current
135
135
  }),
136
136
  onGenerateDragPreview: ({ nativeSetDragImage: u }) => {
137
- k({
137
+ $({
138
138
  nativeSetDragImage: u,
139
- getOffset: $({ x: "8px", y: "8px" }),
139
+ getOffset: U({ x: "8px", y: "8px" }),
140
140
  render: ({ container: R }) => {
141
- if (s)
141
+ if (c)
142
142
  return z(() => i(R)), () => i(null);
143
143
  const _ = t.current;
144
- _ && R.appendChild(ur(_, c.dragPreview));
144
+ _ && R.appendChild(ur(_, p.dragPreview));
145
145
  }
146
146
  });
147
147
  }
148
148
  }),
149
149
  E({
150
150
  element: t.current,
151
- canDrop: ({ source: u }) => u.data.pluginStore === e && u.data.recordId !== n.current.id,
152
- getData: ({ input: u, element: R }) => M(
151
+ canDrop: ({ source: u }) => u.data.pluginStore === e && u.data.recordId !== a.current.id,
152
+ getData: ({ input: u, element: R }) => A(
153
153
  {
154
154
  type: "data-grid-row",
155
- recordId: n.current.id,
156
- record: n.current
155
+ recordId: a.current.id,
156
+ record: a.current
157
157
  },
158
158
  { input: u, element: R, allowedEdges: ["top", "bottom"] }
159
159
  )
160
160
  })
161
161
  );
162
- }, [r.id, e, s, n]), /* @__PURE__ */ y(j, { value: r, children: [
162
+ }, [r.id, e, c, a]), /* @__PURE__ */ y(j, { value: r, children: [
163
163
  /* @__PURE__ */ y(
164
164
  Y,
165
165
  {
166
166
  ref: t,
167
167
  className: C(
168
- c.dragRow,
169
- m && c.dragRowDragging,
170
- f && c.dragRowDropping,
171
- w === "top" && c.dragRowDropIndicatorTop,
172
- w === "bottom" && c.dragRowDropIndicatorBottom
168
+ p.dragRow,
169
+ m && p.dragRowDragging,
170
+ f && p.dragRowDropping,
171
+ w === "top" && p.dragRowDropIndicatorTop,
172
+ w === "bottom" && p.dragRowDropIndicatorBottom
173
173
  ),
174
174
  children: [
175
175
  /* @__PURE__ */ D(b, { position: "start" }),
176
- a.map((d) => {
176
+ n.map((d) => {
177
177
  var _;
178
178
  const u = (_ = d.getClassName) == null ? void 0 : _.call(d, r.item), R = Q(d, r.item, g);
179
179
  return /* @__PURE__ */ D(
@@ -191,14 +191,14 @@ function Dr({
191
191
  ]
192
192
  }
193
193
  ),
194
- o && s ? J(s(r.item), o) : null
194
+ o && c ? J(c(r.item), o) : null
195
195
  ] });
196
196
  }
197
197
  function Or(r) {
198
- return q(
198
+ return L(
199
199
  "dragDrop",
200
200
  (t) => {
201
- const n = I(() => ({
201
+ const a = I(() => ({
202
202
  isDragging: !1,
203
203
  draggedRecordId: void 0,
204
204
  dropTargetRecordId: void 0,
@@ -215,28 +215,28 @@ function Or(r) {
215
215
  width: "37px"
216
216
  }), t.registerComponent("row", Dr), {
217
217
  renderDragPreview: r.renderDragPreview,
218
- useDragDropStore: n,
218
+ useDragDropStore: a,
219
219
  useDropLoadingStore: o,
220
220
  setDropLoading: i,
221
- clearDropLoading: p,
222
- handleDrop: l
221
+ clearDropLoading: l,
222
+ handleDrop: s
223
223
  };
224
- function i(a, g) {
225
- o.setState((e) => ({ loading: { ...e.loading, [a]: g } }));
224
+ function i(n, g) {
225
+ o.setState((e) => ({ loading: { ...e.loading, [n]: g } }));
226
226
  }
227
- function p(a) {
227
+ function l(n) {
228
228
  o.setState((g) => {
229
229
  const e = { ...g.loading };
230
- return delete e[a], { loading: e };
230
+ return delete e[n], { loading: e };
231
231
  });
232
232
  }
233
- function l(a, g) {
233
+ function s(n, g) {
234
234
  fr({
235
- sourceRecord: a,
235
+ sourceRecord: n,
236
236
  targetRecord: g,
237
- onDrop: (e, s) => r.onDrop({ ...t, item: e, target: s }),
237
+ onDrop: (e, c) => r.onDrop({ ...t, item: e, target: c }),
238
238
  setDropLoading: i,
239
- clearDropLoading: p
239
+ clearDropLoading: l
240
240
  });
241
241
  }
242
242
  }
@@ -245,12 +245,21 @@ function Or(r) {
245
245
  function fr({
246
246
  sourceRecord: r,
247
247
  targetRecord: t,
248
- onDrop: n,
248
+ onDrop: a,
249
249
  setDropLoading: o,
250
250
  clearDropLoading: i
251
251
  }) {
252
- const p = (t == null ? void 0 : t.item) ?? null, l = n(r.item, p);
253
- l instanceof Promise && (o(r.id, !0), l.catch(() => {
252
+ const l = (t == null ? void 0 : t.item) ?? null;
253
+ let s;
254
+ try {
255
+ s = a(r.item, l);
256
+ } catch (n) {
257
+ queueMicrotask(() => {
258
+ throw n;
259
+ });
260
+ return;
261
+ }
262
+ s instanceof Promise && (o(r.id, !0), s.catch(() => {
254
263
  }).finally(() => {
255
264
  i(r.id);
256
265
  }));
@@ -1 +1 @@
1
- {"version":3,"file":"drag-drop.js","sources":["../../src/components/data-grid/plugins/drag-drop/components/data-grid-drag-drop-body-cell.tsx","../../src/components/data-grid/plugins/drag-drop/drag-data.ts","../../src/components/data-grid/plugins/drag-drop/components/data-grid-drag-drop-content.tsx","../../src/components/data-grid/plugins/drag-drop/drag-preview.ts","../../src/components/data-grid/plugins/drag-drop/components/data-grid-drag-drop-row.tsx","../../src/components/data-grid/plugins/drag-drop/drag-drop-plugin.tsx"],"sourcesContent":["import { cx } from 'class-variance-authority';\nimport { GripVerticalIcon } from 'lucide-react';\nimport { Spinner } from '../../../../spinner/public.js';\nimport { messages } from '../../../messages';\nimport { useDataGrid } from '../../../services/core/data-grid-context';\nimport { IGNORE_CLICK_ATTRIBUTE } from '../../../services/table/ignore-row-click';\nimport { useDataGridRecord } from '../../../services/table/data-grid-record-context';\nimport type { DataGridDragDropPluginApi } from '../drag-drop-types';\nimport styles from './data-grid-drag-drop.module.css';\n\nexport function DataGridDragDropBodyCell() {\n const grid = useDataGrid();\n const record = useDataGridRecord();\n\n const { useDropLoadingStore } = grid.getPlugin<DataGridDragDropPluginApi>('dragDrop')!;\n\n const isLoading = useDropLoadingStore((s) => !!s.loading[record.id]);\n\n return (\n <div\n className={cx(styles.dragHandler, isLoading && styles.dragHandlerLoading)}\n {...{ [IGNORE_CLICK_ATTRIBUTE]: '' }}\n data-drag-handle=\"\"\n aria-label={messages.dragDrop.dragHandle}\n >\n {isLoading ? <Spinner /> : <GripVerticalIcon />}\n </div>\n );\n}\n","import type { DataGridItemId, DataGridRecord } from '../../services/storage/storage-types';\nimport { isRecord } from '../../utils/is-record';\n\n// What a row puts in the drag data (`getInitialData`) and a drop target reads back is typed\n// `unknown` by the drag library, so each read goes through one of these guards instead of a cast.\n\nfunction isDataGridItemId(value: unknown): value is DataGridItemId {\n return typeof value === 'string' || typeof value === 'number';\n}\n\nfunction isDataGridRecord(value: unknown): value is DataGridRecord {\n return isRecord(value) && isDataGridItemId(value.id) && isRecord(value.item);\n}\n\n/** The record a dragged row or a row used as a drop target carries, or nothing for any other data. */\nexport function readRecord(data: Record<string | symbol, unknown>): DataGridRecord | undefined {\n return isDataGridRecord(data.record) ? data.record : undefined;\n}\n","import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';\nimport {\n dropTargetForElements,\n monitorForElements,\n} from '@atlaskit/pragmatic-drag-and-drop/element/adapter';\nimport { extractClosestEdge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge';\nimport { cx } from 'class-variance-authority';\nimport type { ReactNode } from 'react';\nimport { useEffect, useRef } from 'react';\nimport { useDataGridContext } from '../../../services/core/data-grid-context';\nimport { readRecord } from '../drag-data';\nimport type { DataGridDragDropPluginApi } from '../drag-drop-types';\nimport styles from './data-grid-drag-drop.module.css';\n\ninterface DataGridDragDropContentProps {\n children?: ReactNode;\n}\n\nexport function DataGridDragDropContent({ children }: DataGridDragDropContentProps) {\n const contentRef = useRef<HTMLDivElement>(null);\n\n const context = useDataGridContext();\n const { useDragDropStore, handleDrop } =\n context.plugins.getPlugin<DataGridDragDropPluginApi>('dragDrop')!;\n\n const isDragging = useDragDropStore((s) => s.isDragging);\n const isRootDropTarget = useDragDropStore((s) => s.isRootDropTarget);\n\n useEffect(() => {\n if (!contentRef.current) return;\n\n return combine(\n dropTargetForElements({\n element: contentRef.current,\n getData: () => ({ type: 'data-grid-root' }),\n }),\n monitorForElements({\n // A page can hold several grids with this plugin, and another grid's rows are drag\n // sources too: only a drag that began in this plugin instance is this one's to track.\n canMonitor: ({ source }) => source.data.pluginStore === useDragDropStore,\n onDragStart: ({ source }) => {\n const record = readRecord(source.data);\n if (!record) return;\n\n useDragDropStore.setState({ isDragging: true, draggedRecordId: record.id });\n },\n onDropTargetChange: ({ location }) => {\n const targets = location.current.dropTargets;\n const rowTarget = targets.find((t) => t.data.type === 'data-grid-row');\n const rootTarget = targets.find((t) => t.data.type === 'data-grid-root');\n const dropEdge = rowTarget ? extractClosestEdge(rowTarget.data) : null;\n const targetRecord = rowTarget ? readRecord(rowTarget.data) : undefined;\n\n useDragDropStore.setState({\n dropTargetRecordId: targetRecord?.id,\n dropEdge: dropEdge === 'top' || dropEdge === 'bottom' ? dropEdge : undefined,\n isRootDropTarget: !rowTarget && !!rootTarget,\n });\n },\n onDrop: ({ source, location }) => {\n const targets = location.current.dropTargets;\n const sourceRecord = readRecord(source.data);\n\n if (targets.length > 0 && sourceRecord) {\n const rowTarget = targets.find((t) => t.data.type === 'data-grid-row');\n handleDrop(sourceRecord, rowTarget ? readRecord(rowTarget.data) : undefined);\n }\n\n useDragDropStore.setState({\n isDragging: false,\n draggedRecordId: undefined,\n dropTargetRecordId: undefined,\n dropEdge: undefined,\n isRootDropTarget: false,\n });\n },\n }),\n );\n }, [useDragDropStore, handleDrop]);\n\n return (\n <div\n ref={contentRef}\n className={cx(\n styles.content,\n isDragging && styles.contentDragging,\n isDragging && isRootDropTarget && styles.contentRootDropping,\n )}\n >\n {children}\n </div>\n );\n}\n","export function buildClonedRowPreview(row: HTMLElement, className: string): HTMLTableElement {\n const table = document.createElement('table');\n const sourceTable = row.closest('table');\n table.className = [sourceTable?.className, className].filter(Boolean).join(' ');\n table.style.width = `${row.getBoundingClientRect().width}px`;\n\n const tbody = document.createElement('tbody');\n tbody.appendChild(row.cloneNode(true));\n table.appendChild(tbody);\n\n return table;\n}\n","import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';\nimport {\n draggable,\n dropTargetForElements,\n} from '@atlaskit/pragmatic-drag-and-drop/element/adapter';\nimport { pointerOutsideOfPreview } from '@atlaskit/pragmatic-drag-and-drop/element/pointer-outside-of-preview';\nimport { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview';\nimport { attachClosestEdge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge';\nimport { cx } from 'class-variance-authority';\nimport { useEffect, useRef, useState } from 'react';\nimport { createPortal, flushSync } from 'react-dom';\nimport { TableRow } from '../../../../table/public.js';\nimport type { DataGridItem } from '../../../data-grid-types';\nimport { useDataGridContext } from '../../../services/core/data-grid-context';\nimport type { DataGridRecord } from '../../../services/storage/storage-types';\nimport { DataGridCell } from '../../../services/table/components/data-grid-cell';\nimport { DataGridExtraBodyColumns } from '../../../services/table/components/data-grid-extra-body-columns';\nimport { DataGridRecordProvider } from '../../../services/table/data-grid-record-context';\nimport { resolveBodyCellProps } from '../../../services/table/resolve-body-cell-props';\nimport type { DataGridTableColumn } from '../../../services/table/table-types';\nimport { useLatest } from '../../../utils/use-latest';\nimport type { DataGridDragDropPluginApi } from '../drag-drop-types';\nimport { buildClonedRowPreview } from '../drag-preview';\nimport styles from './data-grid-drag-drop.module.css';\n\ninterface DataGridDragDropRowProps<TItem extends DataGridItem> {\n record: DataGridRecord<TItem>;\n}\n\nexport function DataGridDragDropRow<TItem extends DataGridItem>({\n record,\n}: DataGridDragDropRowProps<TItem>) {\n const rowRef = useRef<HTMLTableRowElement>(null);\n // The drag and drop callbacks are registered once per record id and read the record when the\n // event fires, so a refreshed record is what they see.\n const recordRef = useLatest(record);\n\n const [previewContainer, setPreviewContainer] = useState<HTMLElement | null>(null);\n\n const context = useDataGridContext<TItem>();\n const tableService = context.table;\n const columns = tableService.useVisibleColumns();\n const tableLayout = tableService.useTableLayout();\n\n const { useDragDropStore, renderDragPreview } =\n context.plugins.getPlugin<DataGridDragDropPluginApi<TItem>>('dragDrop')!;\n\n const isDragging = useDragDropStore((s) => s.draggedRecordId === record.id);\n const isDropping = useDragDropStore((s) => s.dropTargetRecordId === record.id);\n const dropEdge = useDragDropStore((s) =>\n s.dropTargetRecordId === record.id ? s.dropEdge : undefined,\n );\n\n const BodyCellContent = tableService.useComponent<{\n column: DataGridTableColumn<TItem>;\n item: TItem;\n }>('body-cell-content');\n\n useEffect(() => {\n if (!rowRef.current) return;\n\n const handleEl = rowRef.current.querySelector<HTMLElement>('[data-drag-handle]');\n\n return combine(\n draggable({\n element: rowRef.current,\n dragHandle: handleEl ?? undefined,\n getInitialData: () => ({\n type: 'data-grid-row',\n pluginStore: useDragDropStore,\n recordId: recordRef.current.id,\n record: recordRef.current,\n }),\n onGenerateDragPreview: ({ nativeSetDragImage }) => {\n setCustomNativeDragPreview({\n nativeSetDragImage,\n getOffset: pointerOutsideOfPreview({ x: '8px', y: '8px' }),\n render: ({ container }) => {\n if (renderDragPreview) {\n // Render the consumer's preview inside the live React tree (so it\n // keeps context); flushSync commits the portal before the browser\n // snapshots the preview image.\n flushSync(() => setPreviewContainer(container));\n return () => setPreviewContainer(null);\n }\n const row = rowRef.current;\n if (!row) return undefined;\n container.appendChild(buildClonedRowPreview(row, styles.dragPreview));\n return undefined;\n },\n });\n },\n }),\n dropTargetForElements({\n element: rowRef.current,\n canDrop: ({ source }) =>\n source.data.pluginStore === useDragDropStore &&\n source.data.recordId !== recordRef.current.id,\n getData: ({ input, element }) =>\n attachClosestEdge(\n {\n type: 'data-grid-row',\n recordId: recordRef.current.id,\n record: recordRef.current,\n },\n { input, element, allowedEdges: ['top', 'bottom'] },\n ),\n }),\n );\n }, [record.id, useDragDropStore, renderDragPreview, recordRef]);\n\n return (\n <DataGridRecordProvider value={record}>\n <TableRow\n ref={rowRef}\n className={cx(\n styles.dragRow,\n isDragging && styles.dragRowDragging,\n isDropping && styles.dragRowDropping,\n dropEdge === 'top' && styles.dragRowDropIndicatorTop,\n dropEdge === 'bottom' && styles.dragRowDropIndicatorBottom,\n )}\n >\n <DataGridExtraBodyColumns position=\"start\" />\n {columns.map((col) => {\n const dynamicClassName = col.getClassName?.(record.item);\n const bodyCellProps = resolveBodyCellProps(col, record.item, tableLayout);\n\n return (\n <DataGridCell<TItem>\n key={col.id}\n columnId={col.id}\n className={dynamicClassName}\n {...bodyCellProps}\n >\n <BodyCellContent column={col} item={record.item} />\n </DataGridCell>\n );\n })}\n <DataGridExtraBodyColumns position=\"end\" />\n </TableRow>\n {previewContainer && renderDragPreview\n ? createPortal(renderDragPreview(record.item), previewContainer)\n : null}\n </DataGridRecordProvider>\n );\n}\n","// Load-bearing: a plugin is rendered as a child of <DataGrid>, so a Server Component can import\n// and render it, and the component it returns calls hooks. This directive puts the banner on the\n// plugin's own entry chunk (dist/data-grid/<plugin>.js). client-boundaries.test.ts only scans a\n// component's top-level files, so scripts/verify-consumer.sh is what checks the built banner of\n// every plugin entry.\n'use client';\n\nimport { create } from 'zustand';\n// The `.js` on the type imports below is for the shipped declaration file: this file's\n// `createDataGridDragDropPlugin(config: DataGridDragDropPluginProps)` is a signature a consumer\n// types a callback by, and `moduleResolution: \"nodenext\"` rejects an extensionless relative\n// specifier in it, which turns the parameter into an untyped one.\nimport type { DataGridItem } from '../../data-grid-types.js';\nimport { createDataGridPlugin } from '../../services/plugins/plugins-helpers';\nimport type { DataGridItemId, DataGridRecord } from '../../services/storage/storage-types.js';\nimport { DataGridDragDropBodyCell } from './components/data-grid-drag-drop-body-cell';\nimport { DataGridDragDropContent } from './components/data-grid-drag-drop-content';\nimport { DataGridDragDropRow } from './components/data-grid-drag-drop-row';\nimport type {\n DataGridDragDropPluginApi,\n DataGridDragDropPluginProps,\n DataGridDragDropState,\n DataGridDropLoadingState,\n} from './drag-drop-types.js';\n\n/**\n * Creates a drag-and-drop plugin component for reordering a DataGrid's rows. It is a factory\n * because the callbacks are the plugin's own configuration, not props of the component it\n * returns: create it once, outside render, and render the result as a child of the grid.\n */\nexport function createDataGridDragDropPlugin<TItem extends DataGridItem = DataGridItem>(\n config: DataGridDragDropPluginProps<TItem>,\n) {\n return createDataGridPlugin<TItem, 'dragDrop', Record<string, never>, DataGridDragDropPluginApi<TItem>>(\n 'dragDrop',\n (context) => {\n const useDragDropStore = create<DataGridDragDropState>(() => ({\n isDragging: false,\n draggedRecordId: undefined,\n dropTargetRecordId: undefined,\n dropEdge: undefined,\n isRootDropTarget: false,\n }));\n\n const useDropLoadingStore = create<DataGridDropLoadingState>(() => ({\n loading: {},\n }));\n\n context.registerComponent('content', DataGridDragDropContent);\n context.registerExtraColumn({\n id: 'drag-drop',\n body: DataGridDragDropBodyCell,\n position: 'start',\n order: 0,\n width: '37px',\n });\n context.registerComponent('row', DataGridDragDropRow);\n\n return {\n renderDragPreview: config.renderDragPreview,\n useDragDropStore,\n useDropLoadingStore,\n setDropLoading,\n clearDropLoading,\n handleDrop,\n };\n\n function setDropLoading(id: DataGridItemId, value: boolean) {\n useDropLoadingStore.setState((state) => ({ loading: { ...state.loading, [id]: value } }));\n }\n\n function clearDropLoading(id: DataGridItemId) {\n useDropLoadingStore.setState((state) => {\n const next = { ...state.loading };\n delete next[id];\n return { loading: next };\n });\n }\n\n function handleDrop(\n sourceRecord: DataGridRecord<TItem>,\n targetRecord: DataGridRecord<TItem> | undefined,\n ) {\n executeHandleDrop({\n sourceRecord,\n targetRecord,\n onDrop: (item, target) => config.onDrop({ ...context, item, target }),\n setDropLoading,\n clearDropLoading,\n });\n }\n },\n );\n}\n\n/** @internal Extracted for testability. */\nexport function executeHandleDrop<TItem extends DataGridItem>({\n sourceRecord,\n targetRecord,\n onDrop,\n setDropLoading,\n clearDropLoading,\n}: {\n sourceRecord: Pick<DataGridRecord<TItem>, 'id' | 'item'>;\n targetRecord: Pick<DataGridRecord<TItem>, 'item'> | undefined;\n onDrop: (item: TItem, target: TItem | null) => void | Promise<void>;\n setDropLoading: (id: DataGridItemId, value: boolean) => void;\n clearDropLoading: (id: DataGridItemId) => void;\n}) {\n const target = targetRecord?.item ?? null;\n const drop = onDrop(sourceRecord.item, target);\n\n if (drop instanceof Promise) {\n setDropLoading(sourceRecord.id, true);\n drop\n .catch(() => {\n // Swallow rejection — cleanup happens in finally\n })\n .finally(() => {\n clearDropLoading(sourceRecord.id);\n });\n }\n}\n"],"names":["DataGridDragDropBodyCell","grid","useDataGrid","record","useDataGridRecord","useDropLoadingStore","isLoading","s","jsx","cx","styles","IGNORE_CLICK_ATTRIBUTE","messages","Spinner","GripVerticalIcon","isDataGridItemId","value","isDataGridRecord","isRecord","readRecord","data","DataGridDragDropContent","children","contentRef","useRef","context","useDataGridContext","useDragDropStore","handleDrop","isDragging","isRootDropTarget","useEffect","combine","dropTargetForElements","monitorForElements","source","location","targets","rowTarget","t","rootTarget","dropEdge","extractClosestEdge","targetRecord","sourceRecord","buildClonedRowPreview","row","className","table","sourceTable","tbody","DataGridDragDropRow","rowRef","recordRef","useLatest","previewContainer","setPreviewContainer","useState","tableService","columns","tableLayout","renderDragPreview","isDropping","BodyCellContent","handleEl","draggable","nativeSetDragImage","setCustomNativeDragPreview","pointerOutsideOfPreview","container","flushSync","input","element","attachClosestEdge","jsxs","DataGridRecordProvider","TableRow","DataGridExtraBodyColumns","col","dynamicClassName","_a","bodyCellProps","resolveBodyCellProps","DataGridCell","createPortal","createDataGridDragDropPlugin","config","createDataGridPlugin","create","setDropLoading","clearDropLoading","id","state","next","executeHandleDrop","item","target","onDrop","drop"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUO,SAASA,KAA2B;AACzC,QAAMC,IAAOC,EAAA,GACPC,IAASC,EAAA,GAET,EAAE,qBAAAC,EAAA,IAAwBJ,EAAK,UAAqC,UAAU,GAE9EK,IAAYD,EAAoB,CAACE,MAAM,CAAC,CAACA,EAAE,QAAQJ,EAAO,EAAE,CAAC;AAEnE,SACE,gBAAAK;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAWC,EAAGC,EAAO,aAAaJ,KAAa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sD,EACG,MAAM,MAAM;AAAA,EAEb,CAAC,EACA,QAAQ,MAAM;AACb,IAAAR,EAAiB9C,EAAa,EAAE;AAAA,EAClC,CAAC;AAEP;"}
1
+ {"version":3,"file":"drag-drop.js","sources":["../../src/components/data-grid/plugins/drag-drop/components/data-grid-drag-drop-body-cell.tsx","../../src/components/data-grid/plugins/drag-drop/drag-data.ts","../../src/components/data-grid/plugins/drag-drop/components/data-grid-drag-drop-content.tsx","../../src/components/data-grid/plugins/drag-drop/drag-preview.ts","../../src/components/data-grid/plugins/drag-drop/components/data-grid-drag-drop-row.tsx","../../src/components/data-grid/plugins/drag-drop/drag-drop-plugin.tsx"],"sourcesContent":["import { cx } from 'class-variance-authority';\nimport { GripVerticalIcon } from 'lucide-react';\nimport { Spinner } from '../../../../spinner/public.js';\nimport { messages } from '../../../messages';\nimport { useDataGrid } from '../../../services/core/data-grid-context';\nimport { IGNORE_CLICK_ATTRIBUTE } from '../../../services/table/ignore-row-click';\nimport { useDataGridRecord } from '../../../services/table/data-grid-record-context';\nimport type { DataGridDragDropPluginApi } from '../drag-drop-types';\nimport styles from './data-grid-drag-drop.module.css';\n\nexport function DataGridDragDropBodyCell() {\n const grid = useDataGrid();\n const record = useDataGridRecord();\n\n const { useDropLoadingStore } = grid.getPlugin<DataGridDragDropPluginApi>('dragDrop')!;\n\n const isLoading = useDropLoadingStore((s) => !!s.loading[record.id]);\n\n return (\n <div\n className={cx(styles.dragHandler, isLoading && styles.dragHandlerLoading)}\n {...{ [IGNORE_CLICK_ATTRIBUTE]: '' }}\n data-drag-handle=\"\"\n aria-label={messages.dragDrop.dragHandle}\n >\n {isLoading ? <Spinner /> : <GripVerticalIcon />}\n </div>\n );\n}\n","import type { DataGridItemId, DataGridRecord } from '../../services/storage/storage-types';\nimport { isRecord } from '../../utils/is-record';\n\n// What a row puts in the drag data (`getInitialData`) and a drop target reads back is typed\n// `unknown` by the drag library, so each read goes through one of these guards instead of a cast.\n\nfunction isDataGridItemId(value: unknown): value is DataGridItemId {\n return typeof value === 'string' || typeof value === 'number';\n}\n\nfunction isDataGridRecord(value: unknown): value is DataGridRecord {\n return isRecord(value) && isDataGridItemId(value.id) && isRecord(value.item);\n}\n\n/** The record a dragged row or a row used as a drop target carries, or nothing for any other data. */\nexport function readRecord(data: Record<string | symbol, unknown>): DataGridRecord | undefined {\n return isDataGridRecord(data.record) ? data.record : undefined;\n}\n","import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';\nimport {\n dropTargetForElements,\n monitorForElements,\n} from '@atlaskit/pragmatic-drag-and-drop/element/adapter';\nimport { extractClosestEdge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge';\nimport { cx } from 'class-variance-authority';\nimport type { ReactNode } from 'react';\nimport { useEffect, useRef } from 'react';\nimport { useDataGridContext } from '../../../services/core/data-grid-context';\nimport { readRecord } from '../drag-data';\nimport type { DataGridDragDropPluginApi } from '../drag-drop-types';\nimport styles from './data-grid-drag-drop.module.css';\n\ninterface DataGridDragDropContentProps {\n children?: ReactNode;\n}\n\nexport function DataGridDragDropContent({ children }: DataGridDragDropContentProps) {\n const contentRef = useRef<HTMLDivElement>(null);\n\n const context = useDataGridContext();\n const { useDragDropStore, handleDrop } =\n context.plugins.getPlugin<DataGridDragDropPluginApi>('dragDrop')!;\n\n const isDragging = useDragDropStore((s) => s.isDragging);\n const isRootDropTarget = useDragDropStore((s) => s.isRootDropTarget);\n\n useEffect(() => {\n if (!contentRef.current) return;\n\n return combine(\n dropTargetForElements({\n element: contentRef.current,\n getData: () => ({ type: 'data-grid-root' }),\n }),\n monitorForElements({\n // A page can hold several grids with this plugin, and another grid's rows are drag\n // sources too: only a drag that began in this plugin instance is this one's to track.\n canMonitor: ({ source }) => source.data.pluginStore === useDragDropStore,\n onDragStart: ({ source }) => {\n const record = readRecord(source.data);\n if (!record) return;\n\n useDragDropStore.setState({ isDragging: true, draggedRecordId: record.id });\n },\n onDropTargetChange: ({ location }) => {\n const targets = location.current.dropTargets;\n const rowTarget = targets.find((t) => t.data.type === 'data-grid-row');\n const rootTarget = targets.find((t) => t.data.type === 'data-grid-root');\n const dropEdge = rowTarget ? extractClosestEdge(rowTarget.data) : null;\n const targetRecord = rowTarget ? readRecord(rowTarget.data) : undefined;\n\n useDragDropStore.setState({\n dropTargetRecordId: targetRecord?.id,\n dropEdge: dropEdge === 'top' || dropEdge === 'bottom' ? dropEdge : undefined,\n isRootDropTarget: !rowTarget && !!rootTarget,\n });\n },\n onDrop: ({ source, location }) => {\n const targets = location.current.dropTargets;\n const sourceRecord = readRecord(source.data);\n\n if (targets.length > 0 && sourceRecord) {\n const rowTarget = targets.find((t) => t.data.type === 'data-grid-row');\n handleDrop(sourceRecord, rowTarget ? readRecord(rowTarget.data) : undefined);\n }\n\n useDragDropStore.setState({\n isDragging: false,\n draggedRecordId: undefined,\n dropTargetRecordId: undefined,\n dropEdge: undefined,\n isRootDropTarget: false,\n });\n },\n }),\n );\n }, [useDragDropStore, handleDrop]);\n\n return (\n <div\n ref={contentRef}\n className={cx(\n styles.content,\n isDragging && styles.contentDragging,\n isDragging && isRootDropTarget && styles.contentRootDropping,\n )}\n >\n {children}\n </div>\n );\n}\n","export function buildClonedRowPreview(row: HTMLElement, className: string): HTMLTableElement {\n const table = document.createElement('table');\n const sourceTable = row.closest('table');\n table.className = [sourceTable?.className, className].filter(Boolean).join(' ');\n table.style.width = `${row.getBoundingClientRect().width}px`;\n\n const tbody = document.createElement('tbody');\n tbody.appendChild(row.cloneNode(true));\n table.appendChild(tbody);\n\n return table;\n}\n","import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';\nimport {\n draggable,\n dropTargetForElements,\n} from '@atlaskit/pragmatic-drag-and-drop/element/adapter';\nimport { pointerOutsideOfPreview } from '@atlaskit/pragmatic-drag-and-drop/element/pointer-outside-of-preview';\nimport { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview';\nimport { attachClosestEdge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge';\nimport { cx } from 'class-variance-authority';\nimport { useEffect, useRef, useState } from 'react';\nimport { createPortal, flushSync } from 'react-dom';\nimport { TableRow } from '../../../../table/public.js';\nimport type { DataGridItem } from '../../../data-grid-types';\nimport { useDataGridContext } from '../../../services/core/data-grid-context';\nimport type { DataGridRecord } from '../../../services/storage/storage-types';\nimport { DataGridCell } from '../../../services/table/components/data-grid-cell';\nimport { DataGridExtraBodyColumns } from '../../../services/table/components/data-grid-extra-body-columns';\nimport { DataGridRecordProvider } from '../../../services/table/data-grid-record-context';\nimport { resolveBodyCellProps } from '../../../services/table/resolve-body-cell-props';\nimport type { DataGridTableColumn } from '../../../services/table/table-types';\nimport { useLatest } from '../../../utils/use-latest';\nimport type { DataGridDragDropPluginApi } from '../drag-drop-types';\nimport { buildClonedRowPreview } from '../drag-preview';\nimport styles from './data-grid-drag-drop.module.css';\n\ninterface DataGridDragDropRowProps<TItem extends DataGridItem> {\n record: DataGridRecord<TItem>;\n}\n\nexport function DataGridDragDropRow<TItem extends DataGridItem>({\n record,\n}: DataGridDragDropRowProps<TItem>) {\n const rowRef = useRef<HTMLTableRowElement>(null);\n // The drag and drop callbacks are registered once per record id and read the record when the\n // event fires, so a refreshed record is what they see.\n const recordRef = useLatest(record);\n\n const [previewContainer, setPreviewContainer] = useState<HTMLElement | null>(null);\n\n const context = useDataGridContext<TItem>();\n const tableService = context.table;\n const columns = tableService.useVisibleColumns();\n const tableLayout = tableService.useTableLayout();\n\n const { useDragDropStore, renderDragPreview } =\n context.plugins.getPlugin<DataGridDragDropPluginApi<TItem>>('dragDrop')!;\n\n const isDragging = useDragDropStore((s) => s.draggedRecordId === record.id);\n const isDropping = useDragDropStore((s) => s.dropTargetRecordId === record.id);\n const dropEdge = useDragDropStore((s) =>\n s.dropTargetRecordId === record.id ? s.dropEdge : undefined,\n );\n\n const BodyCellContent = tableService.useComponent<{\n column: DataGridTableColumn<TItem>;\n item: TItem;\n }>('body-cell-content');\n\n useEffect(() => {\n if (!rowRef.current) return;\n\n const handleEl = rowRef.current.querySelector<HTMLElement>('[data-drag-handle]');\n\n return combine(\n draggable({\n element: rowRef.current,\n dragHandle: handleEl ?? undefined,\n getInitialData: () => ({\n type: 'data-grid-row',\n pluginStore: useDragDropStore,\n recordId: recordRef.current.id,\n record: recordRef.current,\n }),\n onGenerateDragPreview: ({ nativeSetDragImage }) => {\n setCustomNativeDragPreview({\n nativeSetDragImage,\n getOffset: pointerOutsideOfPreview({ x: '8px', y: '8px' }),\n render: ({ container }) => {\n if (renderDragPreview) {\n // Render the consumer's preview inside the live React tree (so it\n // keeps context); flushSync commits the portal before the browser\n // snapshots the preview image.\n flushSync(() => setPreviewContainer(container));\n return () => setPreviewContainer(null);\n }\n const row = rowRef.current;\n if (!row) return undefined;\n container.appendChild(buildClonedRowPreview(row, styles.dragPreview));\n return undefined;\n },\n });\n },\n }),\n dropTargetForElements({\n element: rowRef.current,\n canDrop: ({ source }) =>\n source.data.pluginStore === useDragDropStore &&\n source.data.recordId !== recordRef.current.id,\n getData: ({ input, element }) =>\n attachClosestEdge(\n {\n type: 'data-grid-row',\n recordId: recordRef.current.id,\n record: recordRef.current,\n },\n { input, element, allowedEdges: ['top', 'bottom'] },\n ),\n }),\n );\n }, [record.id, useDragDropStore, renderDragPreview, recordRef]);\n\n return (\n <DataGridRecordProvider value={record}>\n <TableRow\n ref={rowRef}\n className={cx(\n styles.dragRow,\n isDragging && styles.dragRowDragging,\n isDropping && styles.dragRowDropping,\n dropEdge === 'top' && styles.dragRowDropIndicatorTop,\n dropEdge === 'bottom' && styles.dragRowDropIndicatorBottom,\n )}\n >\n <DataGridExtraBodyColumns position=\"start\" />\n {columns.map((col) => {\n const dynamicClassName = col.getClassName?.(record.item);\n const bodyCellProps = resolveBodyCellProps(col, record.item, tableLayout);\n\n return (\n <DataGridCell<TItem>\n key={col.id}\n columnId={col.id}\n className={dynamicClassName}\n {...bodyCellProps}\n >\n <BodyCellContent column={col} item={record.item} />\n </DataGridCell>\n );\n })}\n <DataGridExtraBodyColumns position=\"end\" />\n </TableRow>\n {previewContainer && renderDragPreview\n ? createPortal(renderDragPreview(record.item), previewContainer)\n : null}\n </DataGridRecordProvider>\n );\n}\n","// Load-bearing: a plugin is rendered as a child of <DataGrid>, so a Server Component can import\n// and render it, and the component it returns calls hooks. This directive puts the banner on the\n// plugin's own entry chunk (dist/data-grid/<plugin>.js). client-boundaries.test.ts only scans a\n// component's top-level files, so scripts/verify-consumer.sh is what checks the built banner of\n// every plugin entry.\n'use client';\n\nimport { create } from 'zustand';\n// The `.js` on the type imports below is for the shipped declaration file: this file's\n// `createDataGridDragDropPlugin(config: DataGridDragDropPluginProps)` is a signature a consumer\n// types a callback by, and `moduleResolution: \"nodenext\"` rejects an extensionless relative\n// specifier in it, which turns the parameter into an untyped one.\nimport type { DataGridItem } from '../../data-grid-types.js';\nimport { createDataGridPlugin } from '../../services/plugins/plugins-helpers';\nimport type { DataGridItemId, DataGridRecord } from '../../services/storage/storage-types.js';\nimport { DataGridDragDropBodyCell } from './components/data-grid-drag-drop-body-cell';\nimport { DataGridDragDropContent } from './components/data-grid-drag-drop-content';\nimport { DataGridDragDropRow } from './components/data-grid-drag-drop-row';\nimport type {\n DataGridDragDropPluginApi,\n DataGridDragDropPluginProps,\n DataGridDragDropState,\n DataGridDropLoadingState,\n} from './drag-drop-types.js';\n\n/**\n * Creates a drag-and-drop plugin component for reordering a DataGrid's rows. It is a factory\n * because the callbacks are the plugin's own configuration, not props of the component it\n * returns: create it once, outside render, and render the result as a child of the grid.\n */\nexport function createDataGridDragDropPlugin<TItem extends DataGridItem = DataGridItem>(\n config: DataGridDragDropPluginProps<TItem>,\n) {\n return createDataGridPlugin<TItem, 'dragDrop', Record<string, never>, DataGridDragDropPluginApi<TItem>>(\n 'dragDrop',\n (context) => {\n const useDragDropStore = create<DataGridDragDropState>(() => ({\n isDragging: false,\n draggedRecordId: undefined,\n dropTargetRecordId: undefined,\n dropEdge: undefined,\n isRootDropTarget: false,\n }));\n\n const useDropLoadingStore = create<DataGridDropLoadingState>(() => ({\n loading: {},\n }));\n\n context.registerComponent('content', DataGridDragDropContent);\n context.registerExtraColumn({\n id: 'drag-drop',\n body: DataGridDragDropBodyCell,\n position: 'start',\n order: 0,\n width: '37px',\n });\n context.registerComponent('row', DataGridDragDropRow);\n\n return {\n renderDragPreview: config.renderDragPreview,\n useDragDropStore,\n useDropLoadingStore,\n setDropLoading,\n clearDropLoading,\n handleDrop,\n };\n\n function setDropLoading(id: DataGridItemId, value: boolean) {\n useDropLoadingStore.setState((state) => ({ loading: { ...state.loading, [id]: value } }));\n }\n\n function clearDropLoading(id: DataGridItemId) {\n useDropLoadingStore.setState((state) => {\n const next = { ...state.loading };\n delete next[id];\n return { loading: next };\n });\n }\n\n function handleDrop(\n sourceRecord: DataGridRecord<TItem>,\n targetRecord: DataGridRecord<TItem> | undefined,\n ) {\n executeHandleDrop({\n sourceRecord,\n targetRecord,\n onDrop: (item, target) => config.onDrop({ ...context, item, target }),\n setDropLoading,\n clearDropLoading,\n });\n }\n },\n );\n}\n\n/** @internal Extracted for testability. */\nexport function executeHandleDrop<TItem extends DataGridItem>({\n sourceRecord,\n targetRecord,\n onDrop,\n setDropLoading,\n clearDropLoading,\n}: {\n sourceRecord: Pick<DataGridRecord<TItem>, 'id' | 'item'>;\n targetRecord: Pick<DataGridRecord<TItem>, 'item'> | undefined;\n onDrop: (item: TItem, target: TItem | null) => void | Promise<void>;\n setDropLoading: (id: DataGridItemId, value: boolean) => void;\n clearDropLoading: (id: DataGridItemId) => void;\n}) {\n const target = targetRecord?.item ?? null;\n let drop: void | Promise<void>;\n try {\n drop = onDrop(sourceRecord.item, target);\n } catch (error) {\n // Thrown out of the library's drop handler, it would leave the library mid-drag, so no\n // later drag starts; it is reported on its own instead.\n queueMicrotask(() => {\n throw error;\n });\n return;\n }\n\n if (drop instanceof Promise) {\n setDropLoading(sourceRecord.id, true);\n drop\n .catch(() => {\n // Swallow rejection — cleanup happens in finally\n })\n .finally(() => {\n clearDropLoading(sourceRecord.id);\n });\n }\n}\n"],"names":["DataGridDragDropBodyCell","grid","useDataGrid","record","useDataGridRecord","useDropLoadingStore","isLoading","s","jsx","cx","styles","IGNORE_CLICK_ATTRIBUTE","messages","Spinner","GripVerticalIcon","isDataGridItemId","value","isDataGridRecord","isRecord","readRecord","data","DataGridDragDropContent","children","contentRef","useRef","context","useDataGridContext","useDragDropStore","handleDrop","isDragging","isRootDropTarget","useEffect","combine","dropTargetForElements","monitorForElements","source","location","targets","rowTarget","t","rootTarget","dropEdge","extractClosestEdge","targetRecord","sourceRecord","buildClonedRowPreview","row","className","table","sourceTable","tbody","DataGridDragDropRow","rowRef","recordRef","useLatest","previewContainer","setPreviewContainer","useState","tableService","columns","tableLayout","renderDragPreview","isDropping","BodyCellContent","handleEl","draggable","nativeSetDragImage","setCustomNativeDragPreview","pointerOutsideOfPreview","container","flushSync","input","element","attachClosestEdge","jsxs","DataGridRecordProvider","TableRow","DataGridExtraBodyColumns","col","dynamicClassName","_a","bodyCellProps","resolveBodyCellProps","DataGridCell","createPortal","createDataGridDragDropPlugin","config","createDataGridPlugin","create","setDropLoading","clearDropLoading","id","state","next","executeHandleDrop","item","target","onDrop","drop","error"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUO,SAASA,KAA2B;AACzC,QAAMC,IAAOC,EAAA,GACPC,IAASC,EAAA,GAET,EAAE,qBAAAC,EAAA,IAAwBJ,EAAK,UAAqC,UAAU,GAE9EK,IAAYD,EAAoB,CAACE,MAAM,CAAC,CAACA,EAAE,QAAQJ,EAAO,EAAE,CAAC;AAEnE,SACE,gBAAAK;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAWC,EAAGC,EAAO,aAAaJ,KAAaI,EAAO,kBAAkB;AAAA,MAClE,CAACC,CAAsB,GAAG;AAAA,MAChC,oBAAiB;AAAA,MACjB,cAAYC,EAAS,SAAS;AAAA,MAE7B,UAAAN,IAAY,gBAAAE,E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AAAA,EAEb,CAAC,EACA,QAAQ,MAAM;AACb,IAAAR,EAAiB9C,EAAa,EAAE;AAAA,EAClC,CAAC;AAEP;"}
@@ -136,7 +136,7 @@ const ie = V("tableTree", (t) => {
136
136
  }
137
137
  function C(e) {
138
138
  const { parentId: n } = e;
139
- if (!n)
139
+ if (n === null)
140
140
  return 0;
141
141
  const s = t.getRecord(n);
142
142
  return 1 + (s ? C(s.section) : 0);
@@ -1 +1 @@
1
- {"version":3,"file":"table-tree.js","sources":["../../src/components/data-grid/plugins/table-tree/components/data-grid-table-tree-expand.tsx","../../src/components/data-grid/plugins/table-tree/components/data-grid-table-tree-body-cell-content.tsx","../../src/components/data-grid/plugins/table-tree/components/data-grid-table-tree-row.tsx","../../src/components/data-grid/plugins/table-tree/table-tree-helpers.ts","../../src/components/data-grid/plugins/table-tree/table-tree-plugin.tsx"],"sourcesContent":["import { ChevronDownIcon } from 'lucide-react';\nimport { Button } from '../../../../button/public.js';\nimport type { DataGridItem } from '../../../data-grid-types';\nimport { useDataGrid } from '../../../services/core/data-grid-context';\nimport { IGNORE_CLICK_ATTRIBUTE } from '../../../services/table/ignore-row-click';\nimport { useDataGridRecord } from '../../../services/table/data-grid-record-context';\nimport type { DataGridTableTreePluginApi } from '../table-tree-types';\nimport styles from './data-grid-table-tree.module.css';\n\nexport function DataGridTableTreeExpand<TItem extends DataGridItem>() {\n const grid = useDataGrid<TItem>();\n const record = useDataGridRecord<TItem>();\n const treePlugin = grid.getPlugin<DataGridTableTreePluginApi<TItem>>('tableTree')!;\n const isExpanded = treePlugin.useIsExpanded(record.id);\n\n const iconClassName = isExpanded\n ? styles.expandIcon\n : `${styles.expandIcon} ${styles.expandIconCollapsed}`;\n\n return (\n <div className={styles.expand} {...{ [IGNORE_CLICK_ATTRIBUTE]: '' }}>\n <Button\n variant=\"ghost\"\n size=\"sm\"\n className={styles.toggle}\n icon={<ChevronDownIcon className={iconClassName} />}\n onClick={() => treePlugin.toggle(record.id)}\n />\n </div>\n );\n}\n","import type { DataGridItem } from '../../../data-grid-types';\nimport { useDataGrid } from '../../../services/core/data-grid-context';\nimport { DataGridBodyCellContent } from '../../../services/table/components/data-grid-body-cell-content';\nimport { useDataGridRecord } from '../../../services/table/data-grid-record-context';\nimport { useTableService } from '../../../services/table/table-context';\nimport type { DataGridTableColumn } from '../../../services/table/table-types';\nimport type { DataGridTableTreePluginApi } from '../table-tree-types';\nimport { DataGridTableTreeExpand } from './data-grid-table-tree-expand';\nimport styles from './data-grid-table-tree.module.css';\n\ninterface DataGridTableTreeBodyCellContentProps<TItem extends DataGridItem> {\n column: DataGridTableColumn<TItem>;\n item: TItem;\n}\n\nexport function DataGridTableTreeBodyCellContent<TItem extends DataGridItem>({\n column,\n item,\n}: DataGridTableTreeBodyCellContentProps<TItem>) {\n const grid = useDataGrid<TItem>();\n const record = useDataGridRecord<TItem>();\n const tableService = useTableService<TItem>();\n const treePlugin = grid.getPlugin<DataGridTableTreePluginApi<TItem>>('tableTree')!;\n const visibleColumns = tableService.useVisibleColumns();\n const isFirstColumn = visibleColumns[0]?.id === column.id;\n const isExpandable = treePlugin.useIsExpandable(record);\n const level = treePlugin.useLevel(record.section);\n\n if ((isExpandable || level > 0) && isFirstColumn) {\n return (\n <div className={styles.treeCellContent}>\n {level > 0 && (\n <div\n className={styles.indentSpacer}\n style={{ inlineSize: `calc(var(--_data-grid-table-tree-indent) * ${level})` }}\n />\n )}\n {isExpandable && <DataGridTableTreeExpand />}\n <div className={styles.label}>\n <DataGridBodyCellContent column={column} item={item} />\n </div>\n </div>\n );\n }\n\n return <DataGridBodyCellContent column={column} item={item} />;\n}\n","import type { KeyboardEvent } from 'react';\nimport { TableRow } from '../../../../table/public.js';\nimport type { DataGridItem } from '../../../data-grid-types';\nimport { useDataGridContext } from '../../../services/core/data-grid-context';\nimport type { DataGridRecord } from '../../../services/storage/storage-types';\nimport { DataGridCell } from '../../../services/table/components/data-grid-cell';\nimport { DataGridExtraBodyColumns } from '../../../services/table/components/data-grid-extra-body-columns';\nimport { DataGridTableRecords } from '../../../services/table/components/data-grid-table-records';\nimport { DataGridRecordProvider } from '../../../services/table/data-grid-record-context';\nimport { resolveBodyCellProps } from '../../../services/table/resolve-body-cell-props';\nimport type { DataGridTableColumn } from '../../../services/table/table-types';\nimport type { DataGridRowClickPluginApi } from '../../row-click/row-click-plugin';\nimport { getClickListener } from '../../row-click/row-click-utils';\nimport type { DataGridTableTreePluginApi } from '../table-tree-types';\nimport styles from './data-grid-table-tree.module.css';\n\ninterface DataGridTableTreeRowProps<TItem extends DataGridItem> {\n record: DataGridRecord<TItem>;\n}\n\nexport function DataGridTableTreeRow<TItem extends DataGridItem>({\n record,\n}: DataGridTableTreeRowProps<TItem>) {\n const context = useDataGridContext<TItem>();\n const tableService = context.table;\n const columns = tableService.useVisibleColumns();\n const tableLayout = tableService.useTableLayout();\n const treePlugin = context.plugins.getPlugin<DataGridTableTreePluginApi<TItem>>('tableTree')!;\n const rowClickApi = context.plugins.getPlugin<DataGridRowClickPluginApi<TItem>>('rowClick');\n const isExpanded = treePlugin.useIsExpanded(record.id);\n const childRecords = context.storage.getRecordsByParentId(record.id);\n\n const BodyCellContent = tableService.useComponent<{\n column: DataGridTableColumn<TItem>;\n item: TItem;\n }>('body-cell-content');\n\n // This row replaces the row-click plugin's, so it has to do what that row does when the plugin\n // is registered.\n const hasRowClick = !!rowClickApi;\n const onClick = hasRowClick ? getClickListener(record.item, () => rowClickApi?.click) : undefined;\n const onDblClick = hasRowClick\n ? getClickListener(record.item, () => rowClickApi?.dblclick)\n : undefined;\n const onKeyDown = hasRowClick\n ? (event: KeyboardEvent) => {\n if (event.key === 'Enter') {\n onClick?.(event);\n }\n }\n : undefined;\n\n return (\n <DataGridRecordProvider value={record}>\n <TableRow\n className={hasRowClick ? styles.clickableRow : undefined}\n tabIndex={hasRowClick ? 0 : undefined}\n onClick={onClick}\n onDoubleClick={onDblClick}\n onKeyDown={onKeyDown}\n >\n <DataGridExtraBodyColumns position=\"start\" />\n {columns.map((col) => {\n const dynamicClassName = col.getClassName?.(record.item);\n const bodyCellProps = resolveBodyCellProps(col, record.item, tableLayout);\n\n return (\n <DataGridCell<TItem>\n key={col.id}\n columnId={col.id}\n className={dynamicClassName}\n {...bodyCellProps}\n >\n <BodyCellContent column={col} item={record.item} />\n </DataGridCell>\n );\n })}\n <DataGridExtraBodyColumns position=\"end\" />\n </TableRow>\n {isExpanded && childRecords.length > 0 && (\n <DataGridTableRecords<TItem> records={childRecords} />\n )}\n </DataGridRecordProvider>\n );\n}\n","import type { DataGridItem } from '../../data-grid-types';\nimport { getItemKeyValue } from '../../services/storage/storage-helpers';\nimport type { DataGridDataKey, DataGridParentId } from '../../services/storage/storage-types';\n\nexport function createTreeDataFromFlattenedArray<TItem extends DataGridItem = DataGridItem>(\n items: TItem[],\n parentKey: DataGridDataKey<TItem>,\n): Map<DataGridParentId, TItem[]> {\n const results = new Map<DataGridParentId, TItem[]>();\n\n for (const item of items) {\n const parentId = getItemKeyValue(item, parentKey) ?? null;\n const group = results.get(parentId);\n if (group) {\n group.push(item);\n } else {\n results.set(parentId, [item]);\n }\n }\n\n return results;\n}\n","// Load-bearing: a plugin is rendered as a child of <DataGrid>, so a Server Component can import\n// and render it, and the component it returns calls hooks. This directive puts the banner on the\n// plugin's own entry chunk (dist/data-grid/<plugin>.js). client-boundaries.test.ts only scans a\n// component's top-level files, so scripts/verify-consumer.sh is what checks the built banner of\n// every plugin entry.\n'use client';\n\nimport type { ReactNode } from 'react';\nimport { create } from 'zustand';\n// `.js` on each relative type import: they land verbatim in the shipped declaration file, where\n// `moduleResolution: \"nodenext\"` rejects an extensionless one and every type from it goes untyped\n// (the `expandable` callback's `item` among them).\nimport type { DataGridItem } from '../../data-grid-types.js';\nimport type { LoadInstance } from '../../services/load/load-types.js';\nimport { createDataGridPlugin } from '../../services/plugins/plugins-helpers';\nimport type {\n DataGridItemId,\n DataGridRecord,\n DataGridSection,\n} from '../../services/storage/storage-types.js';\nimport { DataGridTableTreeBodyCellContent } from './components/data-grid-table-tree-body-cell-content';\nimport { DataGridTableTreeRow } from './components/data-grid-table-tree-row';\nimport { createTreeDataFromFlattenedArray } from './table-tree-helpers';\nimport type {\n DataGridTableTreePluginApi,\n DataGridTableTreePluginConfig,\n TableTreeConfigStore,\n TableTreePersistentState,\n TableTreeStore,\n} from './table-tree-types.js';\n\n// Ids from every visited page accumulate in the stored list (a row that is not\n// on screen cannot be collapsed), and rows deleted server-side never come back\n// to be collapsed either — so the list is bounded, dropping the oldest first.\nconst maxPersistedExpandedIds = 200;\n\nconst DataGridTableTreePluginRaw = createDataGridPlugin<\n DataGridItem,\n 'tableTree',\n DataGridTableTreePluginConfig,\n DataGridTableTreePluginApi\n>('tableTree', (context) => {\n const useTreeStore = create<TableTreeStore>(() => ({\n expandedIds: new Set(),\n }));\n\n const useConfigStore = create<TableTreeConfigStore>(() => ({\n parentKey: undefined,\n expandable: undefined,\n }));\n\n const resetIds = new Set<DataGridItemId>();\n // One-shot work queue, not observable state: ids restored from storage whose\n // children still need a lazy load. A restored id alone cannot tell whether the\n // row exists or is expandable, so the load waits until its record arrives.\n const restoredIds = new Set<DataGridItemId>();\n // Expand state is stored next to the page, filters and order, under whichever\n // backend the grid was configured with — except the URL: the list grows to the\n // persistence cap and keeps ids of rows deleted server-side, and every copied\n // URL would seed all of that into whichever grid opens the link.\n const persistentState = context.registerPersistentState<TableTreePersistentState>('tree', {\n schema: { expanded: 'object' },\n router: false,\n });\n\n context.hook('load:prepare', onBeforeLoad);\n context.hook('load:context', ({ loadContext }) => ({\n tree: { parentId: loadContext.tree?.parentId ?? null },\n }));\n context.hook('load:store', onLoadStore);\n context.registerComponent('row', DataGridTableTreeRow);\n context.registerComponent('body-cell-content', DataGridTableTreeBodyCellContent);\n\n return {\n useIsExpandable,\n useIsExpanded,\n useLevel: getLevel,\n toggle,\n isExpandable,\n onPropsChange,\n };\n\n function onPropsChange(props: DataGridTableTreePluginConfig) {\n useConfigStore.setState({\n parentKey: props.parentKey,\n expandable: props.expandable,\n });\n }\n\n function useIsExpandable(record: DataGridRecord): boolean {\n const expandable = useConfigStore((s) => s.expandable);\n const parentKey = useConfigStore((s) => s.parentKey);\n\n if (expandable) {\n return expandable(record.item);\n }\n\n if (parentKey) {\n return !!context.getSectionsByParentId(record.id).length;\n }\n\n return false;\n }\n\n function useIsExpanded(itemId: DataGridItemId): boolean {\n return useTreeStore((s) => s.expandedIds.has(itemId));\n }\n\n function getLevel(section: DataGridSection<DataGridItem>): number {\n const { parentId } = section;\n\n if (!parentId) {\n return 0;\n }\n\n const parentRecord = context.getRecord(parentId);\n return 1 + (parentRecord ? getLevel(parentRecord.section) : 0);\n }\n\n function toggle(itemId: DataGridItemId) {\n const state = useTreeStore.getState();\n const isCurrentlyExpanded = state.expandedIds.has(itemId);\n\n const newExpandedIds = new Set(state.expandedIds);\n if (isCurrentlyExpanded) {\n newExpandedIds.delete(itemId);\n } else {\n newExpandedIds.add(itemId);\n }\n useTreeStore.setState({ expandedIds: newExpandedIds });\n syncPersistent();\n\n if (!isCurrentlyExpanded) {\n triggerLoadChildren(itemId);\n }\n }\n\n // --- Private helpers ---\n\n function seedFromPersistent() {\n // Storage is user-editable, so the value is narrowed to the id type\n // instead of being trusted as-is, and capped the same way the write side\n // caps it — the plugin itself never stores more, so an oversized list is\n // external. The slice keeps the tail: storage order is oldest-first.\n const stored = persistentState.value?.expanded;\n const expanded = Array.isArray(stored)\n ? stored\n .filter((id): id is DataGridItemId => typeof id === 'string' || typeof id === 'number')\n .slice(-maxPersistedExpandedIds)\n : [];\n if (!expanded.length) {\n return;\n }\n\n const { parentKey } = useConfigStore.getState();\n const expandedIds = new Set(useTreeStore.getState().expandedIds);\n\n for (const id of expanded) {\n expandedIds.add(id);\n if (!parentKey) {\n restoredIds.add(id);\n }\n }\n\n useTreeStore.setState({ expandedIds });\n }\n\n function syncPersistent() {\n // Writes the whole object rather than a delta, because the accessor stores\n // whatever it is given: a partial write would drop the ids it omits. The\n // empty list is written too, so a fully collapsed hierarchy is stored as\n // such instead of as an absent entry. Set iterates in insertion order —\n // seeded ids first, fresh toggles last — so the slice drops the oldest.\n const expanded = [...useTreeStore.getState().expandedIds].slice(-maxPersistedExpandedIds);\n persistentState.setValue({ expanded });\n }\n\n // Drains the restored ids against sections that have just been stored,\n // starting a children load only for rows that actually arrived.\n function loadRestoredChildren(sections: DataGridSection<DataGridItem>[]) {\n if (!restoredIds.size) {\n return;\n }\n\n const { expandedIds } = useTreeStore.getState();\n\n for (const section of sections) {\n for (const record of section.records) {\n if (!restoredIds.delete(record.id) || !expandedIds.has(record.id)) {\n continue;\n }\n\n if (isExpandable(record)) {\n triggerLoadChildren(record.id);\n } else {\n // The row arrived and cannot be expanded, so the stored id is dropped\n // instead of leaving the row marked expanded with nothing under it.\n toggle(record.id);\n }\n }\n }\n }\n\n function triggerLoadChildren(parentId: DataGridItemId) {\n const loadInstance = findLoadInstance(parentId);\n if (loadInstance) {\n return;\n }\n\n const loadedSections = context.getSectionsByParentId(parentId);\n if (!loadedSections.length) {\n context.triggerLoad({ loadContext: { tree: { parentId } } });\n }\n }\n\n function findLoadInstance(parentId: DataGridItemId) {\n return context\n .getLoadInstances()\n .find((instance) => instance.loadContext.tree?.parentId === parentId);\n }\n\n function onBeforeLoad() {\n resetIds.clear();\n\n for (const section of context.getSections()) {\n for (const record of section.records) {\n if (useTreeStore.getState().expandedIds.has(record.id)) {\n resetIds.add(record.id);\n }\n }\n }\n }\n\n function onLoadStore(instance: LoadInstance<DataGridItem>) {\n const { parentKey } = useConfigStore.getState();\n const pageChanged = isPageChanged(instance.loadContext.pagination?.page);\n\n if (instance.refresh || pageChanged) {\n context.clearSections();\n }\n if (pageChanged) {\n // Two cases reach this branch, and the reseed serves both.\n //\n // A real page change: the in-memory expansion belongs to the page being\n // left, so it is reset, but the stored ids are kept and re-applied. A row\n // expanded on page 1 is expanded again when the user comes back to it, and\n // ids belonging to other pages sit in the set harmlessly, because children\n // load only for records that arrived and pass isExpandable.\n //\n // The very first load, where isPageChanged() is also true because no root\n // section exists yet: here the reset would erase the state just restored\n // from storage, so it has to be seeded again.\n useTreeStore.setState({ expandedIds: new Set() });\n seedFromPersistent();\n }\n\n const newSections: DataGridSection<DataGridItem>[] = [];\n\n if (parentKey) {\n const results = createTreeDataFromFlattenedArray(instance.processResult!.results, parentKey);\n\n for (const [parentId, items] of results) {\n const newSection = context.createSection(\n { loadContext: instance.loadContext, parentId },\n items,\n );\n newSections.push(newSection);\n }\n } else {\n const newSection = context.createSection(\n { loadContext: instance.loadContext, parentId: instance.loadContext.tree!.parentId },\n instance.processResult!.results,\n );\n newSections.push(newSection);\n }\n\n if (resetIds.size) {\n const { expandedIds } = useTreeStore.getState();\n const toLoadRecords = newSections.flatMap((section) => {\n return section.records.filter(\n (record) => resetIds.has(record.id) && isExpandable(record) && expandedIds.has(record.id),\n );\n });\n\n if (toLoadRecords.length) {\n for (const record of toLoadRecords) {\n resetIds.delete(record.id);\n triggerLoadChildren(record.id);\n }\n } else {\n resetIds.clear();\n }\n }\n\n loadRestoredChildren(newSections);\n\n return true;\n }\n\n function isPageChanged(newPage?: number) {\n const sections = context.getSectionsByParentId(null);\n return sections.length === 0\n ? true\n : (newPage ?? 1) !== (sections[0].loadContext.pagination?.page ?? 1);\n }\n\n function isExpandable(record: DataGridRecord): boolean {\n const { expandable, parentKey } = useConfigStore.getState();\n\n if (expandable) {\n return expandable(record.item);\n }\n\n if (parentKey) {\n return !!context.getSectionsByParentId(record.id).length;\n }\n\n return false;\n }\n});\n\n// The plugin is built for the base item type; the cast hands the consumer a generic component, so\n// `<DataGridTableTreePlugin<Category> parentKey=\"parent_id\" />` types `parentKey` and `expandable`\n// against the consumer's item.\nexport const DataGridTableTreePlugin = DataGridTableTreePluginRaw as <\n TItem extends DataGridItem = DataGridItem,\n>(\n props: DataGridTableTreePluginConfig<TItem>,\n) => ReactNode;\n"],"names":["DataGridTableTreeExpand","grid","useDataGrid","record","useDataGridRecord","treePlugin","iconClassName","styles","jsx","IGNORE_CLICK_ATTRIBUTE","Button","ChevronDownIcon","DataGridTableTreeBodyCellContent","column","item","tableService","useTableService","isFirstColumn","_a","isExpandable","level","jsxs","DataGridBodyCellContent","DataGridTableTreeRow","context","useDataGridContext","columns","tableLayout","rowClickApi","isExpanded","childRecords","BodyCellContent","hasRowClick","onClick","getClickListener","onDblClick","onKeyDown","event","DataGridRecordProvider","TableRow","DataGridExtraBodyColumns","col","dynamicClassName","bodyCellProps","resolveBodyCellProps","DataGridCell","DataGridTableRecords","createTreeDataFromFlattenedArray","items","parentKey","results","parentId","getItemKeyValue","group","DataGridTableTreePluginRaw","createDataGridPlugin","useTreeStore","create","useConfigStore","resetIds","restoredIds","persistentState","onBeforeLoad","loadContext","onLoadStore","useIsExpandable","useIsExpanded","getLevel","toggle","onPropsChange","props","expandable","s","itemId","section","parentRecord","state","isCurrentlyExpanded","newExpandedIds","syncPersistent","triggerLoadChildren","seedFromPersistent","stored","expanded","id","expandedIds","loadRestoredChildren","sections","findLoadInstance","instance","pageChanged","isPageChanged","newSections","newSection","toLoadRecords","newPage","DataGridTableTreePlugin"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AASO,SAASA,KAAsD;AACpE,QAAMC,IAAOC,EAAA,GACPC,IAASC,EAAA,GACTC,IAAaJ,EAAK,UAA6C,WAAW,GAG1EK,IAFaD,EAAW,cAAcF,EAAO,EAAE,IAGjDI,EAAO,aACP,GAAGA,EAAO,UAAU,IAAIA,EAAO,mBAAmB;AAEtD,SACE,gBAAAC,EAAC,OAAA,EAAI,WAAWD,EAAO,QAAc,CAACE,CAAsB,GAAG,IAC7D,UAAA,gBAAAD;AAAA,IAACE;AAAA,IAAA;AAAA,MACC,SAAQ;AAAA,MACR,MAAK;AAAA,MACL,WAAWH,EAAO;AAAA,MAClB,MAAM,gBAAAC,EAACG,GAAA,EAAgB,WAAWL,EAAA,CAAe;AAAA,MACjD,SAAS,MAAMD,EAAW,OAAOF,EAAO,EAAE;AAAA,IAAA;AAAA,E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AAG/B,QAAAwD,EAAS,MAAA;AAAA,IAEb;AAEA,WAAA2B,EAAqBM,CAAW,GAEzB;AAAA,EACT;AAEA,WAASD,EAAcI,GAAkB;;AACvC,UAAMR,IAAW/D,EAAQ,sBAAsB,IAAI;AACnD,WAAO+D,EAAS,WAAW,IACvB,MACCQ,KAAW,UAAQ7E,IAAAqE,EAAS,CAAC,EAAE,YAAY,eAAxB,gBAAArE,EAAoC,SAAQ;AAAA,EACtE;AAEA,WAASC,EAAahB,GAAiC;AACrD,UAAM,EAAE,YAAAoE,GAAY,WAAAtB,MAAcS,EAAe,SAAA;AAEjD,WAAIa,IACKA,EAAWpE,EAAO,IAAI,IAG3B8C,IACK,CAAC,CAACzB,EAAQ,sBAAsBrB,EAAO,EAAE,EAAE,SAG7C;AAAA,EACT;AACF,CAAC,GAKY6F,KAA0B1C;"}
1
+ {"version":3,"file":"table-tree.js","sources":["../../src/components/data-grid/plugins/table-tree/components/data-grid-table-tree-expand.tsx","../../src/components/data-grid/plugins/table-tree/components/data-grid-table-tree-body-cell-content.tsx","../../src/components/data-grid/plugins/table-tree/components/data-grid-table-tree-row.tsx","../../src/components/data-grid/plugins/table-tree/table-tree-helpers.ts","../../src/components/data-grid/plugins/table-tree/table-tree-plugin.tsx"],"sourcesContent":["import { ChevronDownIcon } from 'lucide-react';\nimport { Button } from '../../../../button/public.js';\nimport type { DataGridItem } from '../../../data-grid-types';\nimport { useDataGrid } from '../../../services/core/data-grid-context';\nimport { IGNORE_CLICK_ATTRIBUTE } from '../../../services/table/ignore-row-click';\nimport { useDataGridRecord } from '../../../services/table/data-grid-record-context';\nimport type { DataGridTableTreePluginApi } from '../table-tree-types';\nimport styles from './data-grid-table-tree.module.css';\n\nexport function DataGridTableTreeExpand<TItem extends DataGridItem>() {\n const grid = useDataGrid<TItem>();\n const record = useDataGridRecord<TItem>();\n const treePlugin = grid.getPlugin<DataGridTableTreePluginApi<TItem>>('tableTree')!;\n const isExpanded = treePlugin.useIsExpanded(record.id);\n\n const iconClassName = isExpanded\n ? styles.expandIcon\n : `${styles.expandIcon} ${styles.expandIconCollapsed}`;\n\n return (\n <div className={styles.expand} {...{ [IGNORE_CLICK_ATTRIBUTE]: '' }}>\n <Button\n variant=\"ghost\"\n size=\"sm\"\n className={styles.toggle}\n icon={<ChevronDownIcon className={iconClassName} />}\n onClick={() => treePlugin.toggle(record.id)}\n />\n </div>\n );\n}\n","import type { DataGridItem } from '../../../data-grid-types';\nimport { useDataGrid } from '../../../services/core/data-grid-context';\nimport { DataGridBodyCellContent } from '../../../services/table/components/data-grid-body-cell-content';\nimport { useDataGridRecord } from '../../../services/table/data-grid-record-context';\nimport { useTableService } from '../../../services/table/table-context';\nimport type { DataGridTableColumn } from '../../../services/table/table-types';\nimport type { DataGridTableTreePluginApi } from '../table-tree-types';\nimport { DataGridTableTreeExpand } from './data-grid-table-tree-expand';\nimport styles from './data-grid-table-tree.module.css';\n\ninterface DataGridTableTreeBodyCellContentProps<TItem extends DataGridItem> {\n column: DataGridTableColumn<TItem>;\n item: TItem;\n}\n\nexport function DataGridTableTreeBodyCellContent<TItem extends DataGridItem>({\n column,\n item,\n}: DataGridTableTreeBodyCellContentProps<TItem>) {\n const grid = useDataGrid<TItem>();\n const record = useDataGridRecord<TItem>();\n const tableService = useTableService<TItem>();\n const treePlugin = grid.getPlugin<DataGridTableTreePluginApi<TItem>>('tableTree')!;\n const visibleColumns = tableService.useVisibleColumns();\n const isFirstColumn = visibleColumns[0]?.id === column.id;\n const isExpandable = treePlugin.useIsExpandable(record);\n const level = treePlugin.useLevel(record.section);\n\n if ((isExpandable || level > 0) && isFirstColumn) {\n return (\n <div className={styles.treeCellContent}>\n {level > 0 && (\n <div\n className={styles.indentSpacer}\n style={{ inlineSize: `calc(var(--_data-grid-table-tree-indent) * ${level})` }}\n />\n )}\n {isExpandable && <DataGridTableTreeExpand />}\n <div className={styles.label}>\n <DataGridBodyCellContent column={column} item={item} />\n </div>\n </div>\n );\n }\n\n return <DataGridBodyCellContent column={column} item={item} />;\n}\n","import type { KeyboardEvent } from 'react';\nimport { TableRow } from '../../../../table/public.js';\nimport type { DataGridItem } from '../../../data-grid-types';\nimport { useDataGridContext } from '../../../services/core/data-grid-context';\nimport type { DataGridRecord } from '../../../services/storage/storage-types';\nimport { DataGridCell } from '../../../services/table/components/data-grid-cell';\nimport { DataGridExtraBodyColumns } from '../../../services/table/components/data-grid-extra-body-columns';\nimport { DataGridTableRecords } from '../../../services/table/components/data-grid-table-records';\nimport { DataGridRecordProvider } from '../../../services/table/data-grid-record-context';\nimport { resolveBodyCellProps } from '../../../services/table/resolve-body-cell-props';\nimport type { DataGridTableColumn } from '../../../services/table/table-types';\nimport type { DataGridRowClickPluginApi } from '../../row-click/row-click-plugin';\nimport { getClickListener } from '../../row-click/row-click-utils';\nimport type { DataGridTableTreePluginApi } from '../table-tree-types';\nimport styles from './data-grid-table-tree.module.css';\n\ninterface DataGridTableTreeRowProps<TItem extends DataGridItem> {\n record: DataGridRecord<TItem>;\n}\n\nexport function DataGridTableTreeRow<TItem extends DataGridItem>({\n record,\n}: DataGridTableTreeRowProps<TItem>) {\n const context = useDataGridContext<TItem>();\n const tableService = context.table;\n const columns = tableService.useVisibleColumns();\n const tableLayout = tableService.useTableLayout();\n const treePlugin = context.plugins.getPlugin<DataGridTableTreePluginApi<TItem>>('tableTree')!;\n const rowClickApi = context.plugins.getPlugin<DataGridRowClickPluginApi<TItem>>('rowClick');\n const isExpanded = treePlugin.useIsExpanded(record.id);\n const childRecords = context.storage.getRecordsByParentId(record.id);\n\n const BodyCellContent = tableService.useComponent<{\n column: DataGridTableColumn<TItem>;\n item: TItem;\n }>('body-cell-content');\n\n // This row replaces the row-click plugin's, so it has to do what that row does when the plugin\n // is registered.\n const hasRowClick = !!rowClickApi;\n const onClick = hasRowClick ? getClickListener(record.item, () => rowClickApi?.click) : undefined;\n const onDblClick = hasRowClick\n ? getClickListener(record.item, () => rowClickApi?.dblclick)\n : undefined;\n const onKeyDown = hasRowClick\n ? (event: KeyboardEvent) => {\n if (event.key === 'Enter') {\n onClick?.(event);\n }\n }\n : undefined;\n\n return (\n <DataGridRecordProvider value={record}>\n <TableRow\n className={hasRowClick ? styles.clickableRow : undefined}\n tabIndex={hasRowClick ? 0 : undefined}\n onClick={onClick}\n onDoubleClick={onDblClick}\n onKeyDown={onKeyDown}\n >\n <DataGridExtraBodyColumns position=\"start\" />\n {columns.map((col) => {\n const dynamicClassName = col.getClassName?.(record.item);\n const bodyCellProps = resolveBodyCellProps(col, record.item, tableLayout);\n\n return (\n <DataGridCell<TItem>\n key={col.id}\n columnId={col.id}\n className={dynamicClassName}\n {...bodyCellProps}\n >\n <BodyCellContent column={col} item={record.item} />\n </DataGridCell>\n );\n })}\n <DataGridExtraBodyColumns position=\"end\" />\n </TableRow>\n {isExpanded && childRecords.length > 0 && (\n <DataGridTableRecords<TItem> records={childRecords} />\n )}\n </DataGridRecordProvider>\n );\n}\n","import type { DataGridItem } from '../../data-grid-types';\nimport { getItemKeyValue } from '../../services/storage/storage-helpers';\nimport type { DataGridDataKey, DataGridParentId } from '../../services/storage/storage-types';\n\nexport function createTreeDataFromFlattenedArray<TItem extends DataGridItem = DataGridItem>(\n items: TItem[],\n parentKey: DataGridDataKey<TItem>,\n): Map<DataGridParentId, TItem[]> {\n const results = new Map<DataGridParentId, TItem[]>();\n\n for (const item of items) {\n const parentId = getItemKeyValue(item, parentKey) ?? null;\n const group = results.get(parentId);\n if (group) {\n group.push(item);\n } else {\n results.set(parentId, [item]);\n }\n }\n\n return results;\n}\n","// Load-bearing: a plugin is rendered as a child of <DataGrid>, so a Server Component can import\n// and render it, and the component it returns calls hooks. This directive puts the banner on the\n// plugin's own entry chunk (dist/data-grid/<plugin>.js). client-boundaries.test.ts only scans a\n// component's top-level files, so scripts/verify-consumer.sh is what checks the built banner of\n// every plugin entry.\n'use client';\n\nimport type { ReactNode } from 'react';\nimport { create } from 'zustand';\n// `.js` on each relative type import: they land verbatim in the shipped declaration file, where\n// `moduleResolution: \"nodenext\"` rejects an extensionless one and every type from it goes untyped\n// (the `expandable` callback's `item` among them).\nimport type { DataGridItem } from '../../data-grid-types.js';\nimport type { LoadInstance } from '../../services/load/load-types.js';\nimport { createDataGridPlugin } from '../../services/plugins/plugins-helpers';\nimport type {\n DataGridItemId,\n DataGridRecord,\n DataGridSection,\n} from '../../services/storage/storage-types.js';\nimport { DataGridTableTreeBodyCellContent } from './components/data-grid-table-tree-body-cell-content';\nimport { DataGridTableTreeRow } from './components/data-grid-table-tree-row';\nimport { createTreeDataFromFlattenedArray } from './table-tree-helpers';\nimport type {\n DataGridTableTreePluginApi,\n DataGridTableTreePluginConfig,\n TableTreeConfigStore,\n TableTreePersistentState,\n TableTreeStore,\n} from './table-tree-types.js';\n\n// Ids from every visited page accumulate in the stored list (a row that is not\n// on screen cannot be collapsed), and rows deleted server-side never come back\n// to be collapsed either — so the list is bounded, dropping the oldest first.\nconst maxPersistedExpandedIds = 200;\n\nconst DataGridTableTreePluginRaw = createDataGridPlugin<\n DataGridItem,\n 'tableTree',\n DataGridTableTreePluginConfig,\n DataGridTableTreePluginApi\n>('tableTree', (context) => {\n const useTreeStore = create<TableTreeStore>(() => ({\n expandedIds: new Set(),\n }));\n\n const useConfigStore = create<TableTreeConfigStore>(() => ({\n parentKey: undefined,\n expandable: undefined,\n }));\n\n const resetIds = new Set<DataGridItemId>();\n // One-shot work queue, not observable state: ids restored from storage whose\n // children still need a lazy load. A restored id alone cannot tell whether the\n // row exists or is expandable, so the load waits until its record arrives.\n const restoredIds = new Set<DataGridItemId>();\n // Expand state is stored next to the page, filters and order, under whichever\n // backend the grid was configured with — except the URL: the list grows to the\n // persistence cap and keeps ids of rows deleted server-side, and every copied\n // URL would seed all of that into whichever grid opens the link.\n const persistentState = context.registerPersistentState<TableTreePersistentState>('tree', {\n schema: { expanded: 'object' },\n router: false,\n });\n\n context.hook('load:prepare', onBeforeLoad);\n context.hook('load:context', ({ loadContext }) => ({\n tree: { parentId: loadContext.tree?.parentId ?? null },\n }));\n context.hook('load:store', onLoadStore);\n context.registerComponent('row', DataGridTableTreeRow);\n context.registerComponent('body-cell-content', DataGridTableTreeBodyCellContent);\n\n return {\n useIsExpandable,\n useIsExpanded,\n useLevel: getLevel,\n toggle,\n isExpandable,\n onPropsChange,\n };\n\n function onPropsChange(props: DataGridTableTreePluginConfig) {\n useConfigStore.setState({\n parentKey: props.parentKey,\n expandable: props.expandable,\n });\n }\n\n function useIsExpandable(record: DataGridRecord): boolean {\n const expandable = useConfigStore((s) => s.expandable);\n const parentKey = useConfigStore((s) => s.parentKey);\n\n if (expandable) {\n return expandable(record.item);\n }\n\n if (parentKey) {\n return !!context.getSectionsByParentId(record.id).length;\n }\n\n return false;\n }\n\n function useIsExpanded(itemId: DataGridItemId): boolean {\n return useTreeStore((s) => s.expandedIds.has(itemId));\n }\n\n function getLevel(section: DataGridSection<DataGridItem>): number {\n const { parentId } = section;\n\n if (parentId === null) {\n return 0;\n }\n\n const parentRecord = context.getRecord(parentId);\n return 1 + (parentRecord ? getLevel(parentRecord.section) : 0);\n }\n\n function toggle(itemId: DataGridItemId) {\n const state = useTreeStore.getState();\n const isCurrentlyExpanded = state.expandedIds.has(itemId);\n\n const newExpandedIds = new Set(state.expandedIds);\n if (isCurrentlyExpanded) {\n newExpandedIds.delete(itemId);\n } else {\n newExpandedIds.add(itemId);\n }\n useTreeStore.setState({ expandedIds: newExpandedIds });\n syncPersistent();\n\n if (!isCurrentlyExpanded) {\n triggerLoadChildren(itemId);\n }\n }\n\n // --- Private helpers ---\n\n function seedFromPersistent() {\n // Storage is user-editable, so the value is narrowed to the id type\n // instead of being trusted as-is, and capped the same way the write side\n // caps it — the plugin itself never stores more, so an oversized list is\n // external. The slice keeps the tail: storage order is oldest-first.\n const stored = persistentState.value?.expanded;\n const expanded = Array.isArray(stored)\n ? stored\n .filter((id): id is DataGridItemId => typeof id === 'string' || typeof id === 'number')\n .slice(-maxPersistedExpandedIds)\n : [];\n if (!expanded.length) {\n return;\n }\n\n const { parentKey } = useConfigStore.getState();\n const expandedIds = new Set(useTreeStore.getState().expandedIds);\n\n for (const id of expanded) {\n expandedIds.add(id);\n if (!parentKey) {\n restoredIds.add(id);\n }\n }\n\n useTreeStore.setState({ expandedIds });\n }\n\n function syncPersistent() {\n // Writes the whole object rather than a delta, because the accessor stores\n // whatever it is given: a partial write would drop the ids it omits. The\n // empty list is written too, so a fully collapsed hierarchy is stored as\n // such instead of as an absent entry. Set iterates in insertion order —\n // seeded ids first, fresh toggles last — so the slice drops the oldest.\n const expanded = [...useTreeStore.getState().expandedIds].slice(-maxPersistedExpandedIds);\n persistentState.setValue({ expanded });\n }\n\n // Drains the restored ids against sections that have just been stored,\n // starting a children load only for rows that actually arrived.\n function loadRestoredChildren(sections: DataGridSection<DataGridItem>[]) {\n if (!restoredIds.size) {\n return;\n }\n\n const { expandedIds } = useTreeStore.getState();\n\n for (const section of sections) {\n for (const record of section.records) {\n if (!restoredIds.delete(record.id) || !expandedIds.has(record.id)) {\n continue;\n }\n\n if (isExpandable(record)) {\n triggerLoadChildren(record.id);\n } else {\n // The row arrived and cannot be expanded, so the stored id is dropped\n // instead of leaving the row marked expanded with nothing under it.\n toggle(record.id);\n }\n }\n }\n }\n\n function triggerLoadChildren(parentId: DataGridItemId) {\n const loadInstance = findLoadInstance(parentId);\n if (loadInstance) {\n return;\n }\n\n const loadedSections = context.getSectionsByParentId(parentId);\n if (!loadedSections.length) {\n context.triggerLoad({ loadContext: { tree: { parentId } } });\n }\n }\n\n function findLoadInstance(parentId: DataGridItemId) {\n return context\n .getLoadInstances()\n .find((instance) => instance.loadContext.tree?.parentId === parentId);\n }\n\n function onBeforeLoad() {\n resetIds.clear();\n\n for (const section of context.getSections()) {\n for (const record of section.records) {\n if (useTreeStore.getState().expandedIds.has(record.id)) {\n resetIds.add(record.id);\n }\n }\n }\n }\n\n function onLoadStore(instance: LoadInstance<DataGridItem>) {\n const { parentKey } = useConfigStore.getState();\n const pageChanged = isPageChanged(instance.loadContext.pagination?.page);\n\n if (instance.refresh || pageChanged) {\n context.clearSections();\n }\n if (pageChanged) {\n // Two cases reach this branch, and the reseed serves both.\n //\n // A real page change: the in-memory expansion belongs to the page being\n // left, so it is reset, but the stored ids are kept and re-applied. A row\n // expanded on page 1 is expanded again when the user comes back to it, and\n // ids belonging to other pages sit in the set harmlessly, because children\n // load only for records that arrived and pass isExpandable.\n //\n // The very first load, where isPageChanged() is also true because no root\n // section exists yet: here the reset would erase the state just restored\n // from storage, so it has to be seeded again.\n useTreeStore.setState({ expandedIds: new Set() });\n seedFromPersistent();\n }\n\n const newSections: DataGridSection<DataGridItem>[] = [];\n\n if (parentKey) {\n const results = createTreeDataFromFlattenedArray(instance.processResult!.results, parentKey);\n\n for (const [parentId, items] of results) {\n const newSection = context.createSection(\n { loadContext: instance.loadContext, parentId },\n items,\n );\n newSections.push(newSection);\n }\n } else {\n const newSection = context.createSection(\n { loadContext: instance.loadContext, parentId: instance.loadContext.tree!.parentId },\n instance.processResult!.results,\n );\n newSections.push(newSection);\n }\n\n if (resetIds.size) {\n const { expandedIds } = useTreeStore.getState();\n const toLoadRecords = newSections.flatMap((section) => {\n return section.records.filter(\n (record) => resetIds.has(record.id) && isExpandable(record) && expandedIds.has(record.id),\n );\n });\n\n if (toLoadRecords.length) {\n for (const record of toLoadRecords) {\n resetIds.delete(record.id);\n triggerLoadChildren(record.id);\n }\n } else {\n resetIds.clear();\n }\n }\n\n loadRestoredChildren(newSections);\n\n return true;\n }\n\n function isPageChanged(newPage?: number) {\n const sections = context.getSectionsByParentId(null);\n return sections.length === 0\n ? true\n : (newPage ?? 1) !== (sections[0].loadContext.pagination?.page ?? 1);\n }\n\n function isExpandable(record: DataGridRecord): boolean {\n const { expandable, parentKey } = useConfigStore.getState();\n\n if (expandable) {\n return expandable(record.item);\n }\n\n if (parentKey) {\n return !!context.getSectionsByParentId(record.id).length;\n }\n\n return false;\n }\n});\n\n// The plugin is built for the base item type; the cast hands the consumer a generic component, so\n// `<DataGridTableTreePlugin<Category> parentKey=\"parent_id\" />` types `parentKey` and `expandable`\n// against the consumer's item.\nexport const DataGridTableTreePlugin = DataGridTableTreePluginRaw as <\n TItem extends DataGridItem = DataGridItem,\n>(\n props: DataGridTableTreePluginConfig<TItem>,\n) => ReactNode;\n"],"names":["DataGridTableTreeExpand","grid","useDataGrid","record","useDataGridRecord","treePlugin","iconClassName","styles","jsx","IGNORE_CLICK_ATTRIBUTE","Button","ChevronDownIcon","DataGridTableTreeBodyCellContent","column","item","tableService","useTableService","isFirstColumn","_a","isExpandable","level","jsxs","DataGridBodyCellContent","DataGridTableTreeRow","context","useDataGridContext","columns","tableLayout","rowClickApi","isExpanded","childRecords","BodyCellContent","hasRowClick","onClick","getClickListener","onDblClick","onKeyDown","event","DataGridRecordProvider","TableRow","DataGridExtraBodyColumns","col","dynamicClassName","bodyCellProps","resolveBodyCellProps","DataGridCell","DataGridTableRecords","createTreeDataFromFlattenedArray","items","parentKey","results","parentId","getItemKeyValue","group","DataGridTableTreePluginRaw","createDataGridPlugin","useTreeStore","create","useConfigStore","resetIds","restoredIds","persistentState","onBeforeLoad","loadContext","onLoadStore","useIsExpandable","useIsExpanded","getLevel","toggle","onPropsChange","props","expandable","s","itemId","section","parentRecord","state","isCurrentlyExpanded","newExpandedIds","syncPersistent","triggerLoadChildren","seedFromPersistent","stored","expanded","id","expandedIds","loadRestoredChildren","sections","findLoadInstance","instance","pageChanged","isPageChanged","newSections","newSection","toLoadRecords","newPage","DataGridTableTreePlugin"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AASO,SAASA,KAAsD;AACpE,QAAMC,IAAOC,EAAA,GACPC,IAASC,EAAA,GACTC,IAAaJ,EAAK,UAA6C,WAAW,GAG1EK,IAFaD,EAAW,cAAcF,EAAO,EAAE,IAGjDI,EAAO,aACP,GAAGA,EAAO,UAAU,IAAIA,EAAO,mBAAmB;AAEtD,SACE,gBAAAC,EAAC,OAAA,EAAI,WAAWD,EAAO,QAAc,CAACE,CAA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AAAA,QACrB,CAACvE,MAAWwD,EAAS,IAAIxD,EAAO,EAAE,KAAKgB,EAAahB,CAAM,KAAKkF,EAAY,IAAIlF,EAAO,EAAE;AAAA,MAAA,CAE3F;AAED,UAAI2F,EAAc;AAChB,mBAAW3F,KAAU2F;AACnB,UAAAnC,EAAS,OAAOxD,EAAO,EAAE,GACzB6E,EAAoB7E,EAAO,EAAE;AAAA;AAG/B,QAAAwD,EAAS,MAAA;AAAA,IAEb;AAEA,WAAA2B,EAAqBM,CAAW,GAEzB;AAAA,EACT;AAEA,WAASD,EAAcI,GAAkB;;AACvC,UAAMR,IAAW/D,EAAQ,sBAAsB,IAAI;AACnD,WAAO+D,EAAS,WAAW,IACvB,MACCQ,KAAW,UAAQ7E,IAAAqE,EAAS,CAAC,EAAE,YAAY,eAAxB,gBAAArE,EAAoC,SAAQ;AAAA,EACtE;AAEA,WAASC,EAAahB,GAAiC;AACrD,UAAM,EAAE,YAAAoE,GAAY,WAAAtB,MAAcS,EAAe,SAAA;AAEjD,WAAIa,IACKA,EAAWpE,EAAO,IAAI,IAG3B8C,IACK,CAAC,CAACzB,EAAQ,sBAAsBrB,EAAO,EAAE,EAAE,SAG7C;AAAA,EACT;AACF,CAAC,GAKY6F,KAA0B1C;"}
@@ -826,7 +826,7 @@ need nothing installed either.
826
826
 
827
827
  | Option | Type | Default |
828
828
  |--------|------|---------|
829
- | `filename` | `string \| () => string` | `Report`; the extension is added when it is missing |
829
+ | `filename` | `string \| () => string` | `Report`; a string gets the extension when it is missing, a function's result is used as is |
830
830
  | `includeHeaders` | `boolean` | `true` |
831
831
  | `delimiter` | `string` | `,` (CSV) |
832
832
  | `sheetName` | `string` | `Sheet` (Excel) |
@@ -1107,7 +1107,8 @@ whole grid. A drop outside the grid does nothing.
1107
1107
 
1108
1108
  When `onDrop` returns a promise, the handle of the dragged row shows a spinner until it settles.
1109
1109
  A rejection is swallowed and the spinner stops: handle errors inside `onDrop`. A callback that
1110
- returns anything else is done at once.
1110
+ returns anything else is done at once. One that throws has its error reported as uncaught, on
1111
+ its own, and the next drag works as usual.
1111
1112
 
1112
1113
  The handle, which fills its cell, is marked `data-grid-row-ignore-click`; the rest of the cell
1113
1114
  around it is not, since there is none. Only this entry loads the drag
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gears-frontx/ui-kit",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "Standard React component base for FrontX templates - Base UI behavior, CSS Modules styling on semantic tokens, CVA variants",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",