@nocopypaste/vue-grid 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/AGENTS.md +28 -25
  2. package/CHANGELOG.md +20 -0
  3. package/README.md +84 -25
  4. package/agent/api.json +18 -2
  5. package/agent/api.md +4 -2
  6. package/agent/grid-config.schema.json +6 -0
  7. package/dist/agent/api.js +16 -2
  8. package/dist/agent/requirements.js +1 -0
  9. package/dist/agent/requirements.js.map +1 -1
  10. package/dist/components/VGrid.vue_vue_type_script_setup_true_lang.js +406 -370
  11. package/dist/components/VGrid.vue_vue_type_script_setup_true_lang.js.map +1 -1
  12. package/dist/components/VGridGroupCells.vue_vue_type_script_setup_true_lang.js +3 -3
  13. package/dist/components/VGridGroupCells.vue_vue_type_script_setup_true_lang.js.map +1 -1
  14. package/dist/composables/useDataSource.js +21 -19
  15. package/dist/composables/useDataSource.js.map +1 -1
  16. package/dist/composables/useGridExport.js +1 -1
  17. package/dist/composables/useGridExport.js.map +1 -1
  18. package/dist/composables/useRowGrouping.js +103 -74
  19. package/dist/composables/useRowGrouping.js.map +1 -1
  20. package/dist/composables/useServerGroups.js +106 -0
  21. package/dist/composables/useServerGroups.js.map +1 -0
  22. package/dist/core/grouping.js +41 -24
  23. package/dist/core/grouping.js.map +1 -1
  24. package/dist/features/index.js +12 -10
  25. package/dist/features/index.js.map +1 -1
  26. package/dist/features/serverGrouping.js +9 -0
  27. package/dist/features/serverGrouping.js.map +1 -0
  28. package/dist/index.js +7 -6
  29. package/dist/internal/features.js.map +1 -1
  30. package/dist/types/agent/requirements.d.ts +1 -1
  31. package/dist/types/components/VGrid.vue.d.ts +11 -2
  32. package/dist/types/composables/useDataSource.d.ts +33 -2
  33. package/dist/types/composables/useGridExport.d.ts +2 -0
  34. package/dist/types/composables/useRowGrouping.d.ts +12 -1
  35. package/dist/types/composables/useServerGroups.d.ts +37 -0
  36. package/dist/types/core/grouping.d.ts +26 -0
  37. package/dist/types/features/index.d.ts +2 -1
  38. package/dist/types/features/serverGrouping.d.ts +9 -0
  39. package/dist/types/index.d.ts +1 -1
  40. package/dist/types/internal/features.d.ts +2 -1
  41. package/dist/types/types.d.ts +5 -1
  42. package/llms-full.txt +116 -52
  43. package/llms.txt +1 -1
  44. package/package.json +1 -1
@@ -0,0 +1,106 @@
1
+ import { groupedLevels as e, isRowGroup as t, pathKey as n, serverGroups as r } from "../core/grouping.js";
2
+ import { computed as i, shallowReactive as a, toRaw as o, watch as s } from "vue";
3
+ // src/composables/useServerGroups.ts
4
+ var c = (e, t) => e === t || e.startsWith(`${t}\u001e`);
5
+ function l(l) {
6
+ let u = a(/* @__PURE__ */ new Map()), d = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new WeakMap();
7
+ s(l.top, () => {
8
+ for (let e of d.values()) e.abort();
9
+ d.clear(), u.clear();
10
+ });
11
+ let p = (e) => {
12
+ let t = l.top();
13
+ return t && e[0] ? r(t, e[0]) : void 0;
14
+ };
15
+ function m(n, i) {
16
+ d.get(n.key)?.abort();
17
+ let a = new AbortController();
18
+ d.set(n.key, a), u.set(n.key, { status: "loading" });
19
+ let s = i[n.level + 1];
20
+ Promise.resolve().then(() => l.load(n.path, a.signal)).then((i) => {
21
+ if (d.get(n.key) !== a) return;
22
+ d.delete(n.key);
23
+ let c = s && i?.groups ? r(i.groups, s, n) : i?.rows ?? [];
24
+ for (let e of c) t(e) || f.set(o(e), n.key);
25
+ e.add(c), u.set(n.key, {
26
+ status: "loaded",
27
+ rows: c
28
+ });
29
+ }, (e) => {
30
+ d.get(n.key) !== a || a.signal.aborted || (d.delete(n.key), u.set(n.key, {
31
+ status: "error",
32
+ error: e
33
+ }), l.onError(e));
34
+ });
35
+ }
36
+ let h = (e) => {
37
+ let t = u.get(e.key);
38
+ return t?.status === "loaded" ? t.rows : void 0;
39
+ }, g = (e) => u.get(e.key);
40
+ function _(e, t) {
41
+ e.count > 0 && !u.has(e.key) && m(e, t);
42
+ }
43
+ let v = () => void u.size, y = i(() => new Set(l.selectedGroups.value.map((e) => n(e))));
44
+ function b(e) {
45
+ if (e) {
46
+ for (let t of y.value) if (c(e, t)) return t;
47
+ }
48
+ }
49
+ let x = (e) => t(e) ? !!b(e.key) && !y.value.has(e.key) : !!b(f.get(o(e)));
50
+ function S(e, n) {
51
+ for (let [r, i] of u) if (c(r, e.key) && i.status === "loaded") for (let e of i.rows) t(e) || n(e);
52
+ }
53
+ function C(e) {
54
+ if (b(e.key)) return "all";
55
+ for (let t of y.value) if (c(t, e.key)) return "some";
56
+ let t = new Set(l.selected.value), n = !1;
57
+ return S(e, (e) => {
58
+ t.has(l.getKey(e)) && (n = !0);
59
+ }), n ? "some" : "none";
60
+ }
61
+ function w(e) {
62
+ let t = C(e) !== "all", r = l.selectedGroups.value.filter((t) => !c(n(t), e.key));
63
+ if (l.selectedGroups.value = t ? [...r, e.path] : r, t && l.selected.value.length) {
64
+ let t = /* @__PURE__ */ new Set();
65
+ S(e, (e) => t.add(l.getKey(e))), l.selected.value = l.selected.value.filter((e) => !t.has(e));
66
+ }
67
+ }
68
+ function T(e) {
69
+ let t = 0;
70
+ return y.value.size && e((e) => {
71
+ y.value.has(e.key) && (t += e.count);
72
+ }), t;
73
+ }
74
+ function E(e) {
75
+ if (!e.length) return "none";
76
+ let t = e.filter((e) => y.value.has(e.key)).length;
77
+ return t === e.length ? "all" : t || l.selectedGroups.value.length || l.selected.value.length ? "some" : "none";
78
+ }
79
+ function D(e) {
80
+ l.selectedGroups.value = E(e) === "all" ? [] : e.map((e) => e.path), l.selected.value = [];
81
+ }
82
+ function O(e) {
83
+ let n = [], r = (e) => {
84
+ for (let i of h(e) ?? []) t(i) ? r(i) : n.push(i);
85
+ };
86
+ return r(e), n;
87
+ }
88
+ return {
89
+ groups: p,
90
+ children: h,
91
+ state: g,
92
+ ensure: _,
93
+ retry: m,
94
+ track: v,
95
+ locked: x,
96
+ checkState: C,
97
+ toggle: w,
98
+ selectedCount: T,
99
+ allState: E,
100
+ toggleAll: D,
101
+ rowsIn: O
102
+ };
103
+ }
104
+ export { l as useServerGroups };
105
+
106
+ //# sourceMappingURL=useServerGroups.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useServerGroups.js","names":["within","key","of","useServerGroups","cache","shallowReactive","requests","rowGroup","opts","c","groups","top","by","serverGroups","load","group","controller","next","rows","result","row","isRowGroup","toRaw","groupedLevels","error","children","entry","state","ensure","track","selectedKeys","computed","pathKey","p","selecting","k","locked","loadedRows","r","visit","checkState","picked","some","toggle","checked","paths","inside","selectedCount","n","each","g","allState","toggleAll","rowsIn","out","add"],"sources":["../../src/composables/useServerGroups.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any -- rows are an opaque, type-erased T inside the grid internals. */\nimport { computed, shallowReactive, toRaw, watch, type Ref } from 'vue'\nimport { groupedLevels, isRowGroup, pathKey, serverGroups, type RowGroup } from '../core/grouping'\nimport type { ColumnDef, RowKey } from '../types'\nimport type { DataSourceResult, GroupPath, ServerGroup } from './useDataSource'\nimport type { SubRowEntry } from './useSubRows'\n\nexport interface ServerGroupsOptions<T> {\n /** The top-level groups the data source returned for a grouped query; undefined: it sent rows. */\n top: () => readonly ServerGroup[] | undefined\n /** A group's contents: its sub-groups or (at the last level) its rows. */\n load: (path: GroupPath, signal: AbortSignal) => Promise<DataSourceResult<T>>\n /** Groups selected by query (`v-model:selected-groups`). */\n selectedGroups: Ref<GroupPath[]>\n selected: Ref<RowKey[]>\n getKey: (row: T) => RowKey\n onError: (error: unknown) => void\n}\n\n/** `key` is the group `of` or inside it. */\nconst within = (key: string, of: string) => key === of || key.startsWith(`${of}\\u001e`)\n\n/**\n * The server grouping feature: groups from the data source, each one's contents loaded when it\n * expands (cached, with loading / error states), and groups selected by query, without their rows.\n * The row grouping feature calls in here for groups that came from the server.\n */\nexport function useServerGroups<T>(opts: ServerGroupsOptions<T>) {\n const cache = shallowReactive(new Map<string, SubRowEntry>())\n const requests = new Map<string, AbortController>()\n /** Loaded rows → the key of the group they were loaded in. */\n const rowGroup = new WeakMap<object, string>()\n // A new answer to the top-level query (sort, filters, page, grouping): load contents again.\n watch(opts.top, () => {\n for (const c of requests.values()) c.abort()\n requests.clear()\n cache.clear()\n })\n\n /** The top-level groups, as group rows (undefined: the server sent rows). */\n const groups = (by: readonly ColumnDef<T>[]) => {\n const top = opts.top()\n return top && by[0] ? serverGroups(top, by[0]) : undefined\n }\n\n function load(group: RowGroup<T>, by: readonly ColumnDef<T>[]) {\n requests.get(group.key)?.abort()\n const controller = new AbortController()\n requests.set(group.key, controller)\n cache.set(group.key, { status: 'loading' })\n const next = by[group.level + 1]\n Promise.resolve()\n .then(() => opts.load(group.path as GroupPath, controller.signal))\n .then(\n (result) => {\n if (requests.get(group.key) !== controller) return\n requests.delete(group.key)\n const rows: unknown[] =\n next && result?.groups\n ? serverGroups(result.groups, next, group)\n : ((result?.rows ?? []) as unknown[])\n for (const row of rows)\n if (!isRowGroup(row)) rowGroup.set(toRaw(row as object), group.key)\n groupedLevels.add(rows) // already filtered and sorted by the server\n cache.set(group.key, { status: 'loaded', rows })\n },\n (error: unknown) => {\n if (requests.get(group.key) !== controller || controller.signal.aborted) return\n requests.delete(group.key)\n cache.set(group.key, { status: 'error', error })\n opts.onError(error)\n },\n )\n }\n const children = (group: RowGroup<T>): T[] | undefined => {\n const entry = cache.get(group.key)\n return entry?.status === 'loaded' ? (entry.rows as T[]) : undefined\n }\n const state = (group: RowGroup<T>) => cache.get(group.key)\n function ensure(group: RowGroup<T>, by: readonly ColumnDef<T>[]) {\n if (group.count > 0 && !cache.has(group.key)) load(group, by)\n }\n /** Re-reads the cache (any level loaded or failed): for computeds over the tree. */\n const track = () => void cache.size\n\n // ── Selection by query ──────────────────────────────────────────────────────────────────\n const selectedKeys = computed(() => new Set(opts.selectedGroups.value.map((p) => pathKey(p))))\n /** The selected group a group (by key) is, or is inside. */\n function selecting(key: string | undefined): string | undefined {\n if (!key) return undefined\n for (const k of selectedKeys.value) if (within(key, k)) return k\n return undefined\n }\n /** Inside a selected group: ticked and locked, untick the group to change it. */\n const locked = (row: any) =>\n isRowGroup(row)\n ? !!selecting(row.key) && !selectedKeys.value.has(row.key)\n : !!selecting(rowGroup.get(toRaw(row as object)))\n /** Loaded rows inside a group (its sub-groups' included). */\n function loadedRows(group: RowGroup<T>, visit: (row: T) => void) {\n for (const [key, entry] of cache)\n if (within(key, group.key) && entry.status === 'loaded')\n for (const r of entry.rows) if (!isRowGroup(r)) visit(r as T)\n }\n function checkState(group: RowGroup<T>): 'all' | 'some' | 'none' {\n if (selecting(group.key)) return 'all'\n for (const k of selectedKeys.value) if (within(k, group.key)) return 'some'\n const picked = new Set(opts.selected.value)\n let some = false\n loadedRows(group, (r) => {\n if (picked.has(opts.getKey(r))) some = true\n })\n return some ? 'some' : 'none'\n }\n /** Ticks or unticks a group, by its path; what it holds counts through it from then on. */\n function toggle(group: RowGroup<T>) {\n const checked = checkState(group) !== 'all'\n const paths = opts.selectedGroups.value.filter((p) => !within(pathKey(p), group.key))\n opts.selectedGroups.value = checked ? [...paths, group.path as GroupPath] : paths\n if (checked && opts.selected.value.length) {\n const inside = new Set<RowKey>()\n loadedRows(group, (r) => inside.add(opts.getKey(r)))\n opts.selected.value = opts.selected.value.filter((k) => !inside.has(k))\n }\n }\n /** Rows of the selected groups (they aren't loaded: the server's counts). */\n function selectedCount(each: (visit: (g: RowGroup<T>) => void) => void) {\n let n = 0\n if (selectedKeys.value.size)\n each((g) => {\n if (selectedKeys.value.has(g.key)) n += g.count\n })\n return n\n }\n /** The header checkbox: every top-level group, or none. */\n function allState(top: readonly RowGroup<T>[]): 'all' | 'some' | 'none' {\n if (!top.length) return 'none'\n const n = top.filter((g) => selectedKeys.value.has(g.key)).length\n if (n === top.length) return 'all'\n return n || opts.selectedGroups.value.length || opts.selected.value.length ? 'some' : 'none'\n }\n function toggleAll(top: readonly RowGroup<T>[]) {\n opts.selectedGroups.value = allState(top) === 'all' ? [] : top.map((g) => g.path as GroupPath)\n opts.selected.value = []\n }\n /** A group's loaded rows (export, print). */\n function rowsIn(group: RowGroup<T>): T[] {\n const out: T[] = []\n const add = (g: RowGroup<T>) => {\n for (const r of children(g) ?? []) {\n if (isRowGroup(r)) add(r as RowGroup<T>)\n else out.push(r)\n }\n }\n add(group)\n return out\n }\n\n return {\n groups,\n children,\n state,\n ensure,\n retry: load,\n track,\n locked,\n checkState,\n toggle,\n selectedCount,\n allState,\n toggleAll,\n rowsIn,\n }\n}\n\nexport type ServerGroups<T> = ReturnType<typeof useServerGroups<T>>\n"],"mappings":";;;AAoBA,IAAMA,KAAU,GAAa,MAAeC,MAAQC,KAAMD,EAAI,WAAW,GAAGC,EAAG,OAAO;AAOtF,SAAgBC,EAAmB,GAA8B;CAC/D,IAAMC,IAAQC,kBAAgB,IAAI,IAAyB,CAAC,GACtDC,oBAAW,IAAI,IAA6B,GAE5CC,oBAAW,IAAI,QAAwB;CAE7C,EAAMC,EAAK,WAAW;EACpB,KAAK,IAAMC,KAAKH,EAAS,OAAO,GAAG,EAAE,MAAM;EAE3C,AADAA,EAAS,MAAM,GACfF,EAAM,MAAM;CACd,CAAC;CAGD,IAAMM,KAAU,MAAgC;EAC9C,IAAMC,IAAMH,EAAK,IAAI;EACrB,OAAOG,KAAOC,EAAG,KAAKC,EAAaF,GAAKC,EAAG,EAAE,IAAI,KAAA;CACnD;CAEA,SAASE,EAAK,GAAoB,GAA6B;EAC7D,EAAS,IAAIC,EAAM,GAAG,CAAC,EAAE,MAAM;EAC/B,IAAMC,IAAa,IAAI,gBAAgB;EAEvC,AADAV,EAAS,IAAIS,EAAM,KAAKC,CAAU,GAClCZ,EAAM,IAAIW,EAAM,KAAK,EAAE,QAAQ,UAAU,CAAC;EAC1C,IAAME,IAAOL,EAAGG,EAAM,QAAQ;EAC9B,QAAQ,QAAQ,CAAC,CACd,WAAWP,EAAK,KAAKO,EAAM,MAAmBC,EAAW,MAAM,CAAC,CAAC,CACjE,MAC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X,CAAC,CAAC;EACxE;CACF;CAEA,SAASY,EAAc,GAAiD;EACtE,IAAIC,IAAI;EAKR,OAJIlB,EAAa,MAAM,QACrBmB,GAAM,MAAM;GACV,AAAInB,EAAa,MAAM,IAAIoB,EAAE,GAAG,MAAG,KAAKA,EAAE;EAC5C,CAAC,GACIF;CACT;CAEA,SAASG,EAAS,GAAsD;EACtE,IAAI,CAACxC,EAAI,QAAQ,OAAO;EACxB,IAAMqC,IAAIrC,EAAI,QAAQ,MAAMmB,EAAa,MAAM,IAAIoB,EAAE,GAAG,CAAC,CAAC,CAAC;EAE3D,OADIF,MAAMrC,EAAI,SAAe,QACtBqC,KAAKxC,EAAK,eAAe,MAAM,UAAUA,EAAK,SAAS,MAAM,SAAS,SAAS;CACxF;CACA,SAAS4C,EAAU,GAA6B;EAE9C,AADA,EAAK,eAAe,QAAQD,EAASxC,CAAG,MAAM,QAAQ,CAAC,IAAIA,EAAI,KAAK,MAAMuC,EAAE,IAAiB,GAC7F,EAAK,SAAS,QAAQ,CAAC;CACzB;CAEA,SAASG,EAAO,GAAyB;EACvC,IAAMC,IAAW,CAAC,GACZC,KAAO,MAAmB;GAC9B,KAAK,IAAMjB,KAAKb,EAASyB,CAAC,KAAK,CAAC,GAC9B,AAAI7B,EAAWiB,CAAC,IAAGiB,EAAIjB,CAAgB,IAClCgB,EAAI,KAAKhB,CAAC;EAEnB;EAEA,OADAiB,EAAIxC,CAAK,GACFuC;CACT;CAEA,OAAO;EACL;EACA;EACA;EACA;EACA,OAAOxC;EACP;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
@@ -22,45 +22,62 @@ function l(e) {
22
22
  return `${typeof e == "number" || typeof e == "bigint" ? "n" : "s"}${String(e)}`;
23
23
  }
24
24
  function u(n, i) {
25
- let u = i.allColumns.filter((e) => e.aggregate), d = (n, f, p) => {
26
- let m = i.columns[f], h = /* @__PURE__ */ new Map();
25
+ let a = i.allColumns.filter((e) => e.aggregate), u = (n, d, p, m) => {
26
+ let h = i.columns[d], g = /* @__PURE__ */ new Map();
27
27
  for (let e of n) {
28
- let t = s(e, m), n = l(t), r = h.get(n);
29
- r ? r.rows.push(e) : h.set(n, {
28
+ let t = s(e, h), n = l(t), r = g.get(n);
29
+ r ? r.rows.push(e) : g.set(n, {
30
30
  value: t,
31
31
  rows: [e]
32
32
  });
33
33
  }
34
- let g = i.sort?.key === m.key && i.sort.dir === "desc" ? -1 : 1, _ = [...h.entries()].sort(([, e], [, n]) => {
34
+ let _ = i.sort?.key === h.key && i.sort.dir === "desc" ? -1 : 1, v = [...g.entries()].sort(([, e], [, n]) => {
35
35
  let r = c(e.value), i = c(n.value);
36
- return r || i ? r === i ? 0 : r ? 1 : -1 : t(e.value, n.value) * g;
37
- }), v = f === i.columns.length - 1;
38
- return _.map(([t, n]) => {
39
- let i = `${p}${p ? "" : a}${m.key}=${t}`, s = v ? n.rows : d(n.rows, f + 1, i);
40
- return o.add(s), {
36
+ return r || i ? r === i ? 0 : r ? 1 : -1 : t(e.value, n.value) * _;
37
+ }), y = d === i.columns.length - 1;
38
+ return v.map(([t, n]) => {
39
+ let i = f(p, h.key, t), s = [...m, {
40
+ key: h.key,
41
+ value: n.value
42
+ }], c = y ? n.rows : u(n.rows, d + 1, i, s);
43
+ return o.add(c), {
41
44
  [r]: !0,
42
45
  key: i,
43
- column: m,
46
+ column: h,
44
47
  value: n.value,
45
- level: f,
48
+ level: d,
46
49
  rows: n.rows,
47
- children: s,
48
- aggregates: u.length ? e(n.rows, u) : {}
50
+ children: c,
51
+ aggregates: a.length ? e(n.rows, a) : {},
52
+ count: n.rows.length,
53
+ path: s
49
54
  };
50
55
  });
51
56
  };
52
- return i.columns.length ? d(n, 0, "") : [];
57
+ return i.columns.length ? u(n, 0, "", []) : [];
53
58
  }
54
- function d(e, t) {
55
- for (let n of e) {
56
- if (!i(n)) return;
57
- t(n), d(n.children, t);
58
- }
59
+ function d(e) {
60
+ return e.reduce((e, t) => f(e, t.key, l(t.value)), "");
59
61
  }
60
- function f(e) {
61
- let t = [];
62
- return d(e, (e) => t.push(e.key)), t;
62
+ var f = (e, t, n) => `${e}${e ? "" : a}${t}=${n}`;
63
+ function p(e, t, n) {
64
+ return e.map((e) => ({
65
+ [r]: !0,
66
+ key: f(n?.key ?? "", t.key, l(e.value)),
67
+ column: t,
68
+ value: e.value,
69
+ level: n ? n.level + 1 : 0,
70
+ rows: [],
71
+ children: [],
72
+ aggregates: e.aggregates ?? {},
73
+ count: Number(e.count) || 0,
74
+ path: [...n?.path ?? [], {
75
+ key: t.key,
76
+ value: e.value
77
+ }],
78
+ server: !0
79
+ }));
63
80
  }
64
- export { a as GROUP_KEY_PREFIX, f as groupKeys, u as groupRows, s as groupValueOf, o as groupedLevels, i as isRowGroup, d as walkGroups };
81
+ export { a as GROUP_KEY_PREFIX, u as groupRows, s as groupValueOf, o as groupedLevels, i as isRowGroup, d as pathKey, p as serverGroups };
65
82
 
66
83
  //# sourceMappingURL=grouping.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"grouping.js","names":["GROUP","isRowGroup","row","GROUP_KEY_PREFIX","groupedLevels","groupValueOf","column","getCellValue","isBlank","v","groupId","value","groupRows","aggregated","opts","c","build","level","buckets","items","id","bucket","dir","ordered","a","b","blankA","blankB","compareValues","last","key","parentKey","children","aggregateRows","rows","walkGroups","g","groups","visit","groupKeys","keys"],"sources":["../../src/core/grouping.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any -- rows are type-erased here; ColumnDef<T> keeps the public API typed. */\nimport type { ColumnDef, RowKey, SortState } from '../types'\nimport { aggregateRows } from './aggregate'\nimport { compareValues } from './sort'\nimport { getCellValue } from './value'\n\nconst GROUP = Symbol.for('vue-grid:row-group')\n\n/**\n * A group of rows (row grouping feature): the rows that share a value in a grouped column. Shown\n * as a group row with its value, its row count and its columns' aggregates; expanding it shows\n * its sub-groups (grouped by the next column) or, at the last level, its rows.\n */\nexport interface RowGroup<T = any> {\n readonly [GROUP]: true\n /** Unique among the grid's rows and groups (the path of group values from the top). */\n readonly key: string\n /** The grouped column. */\n readonly column: ColumnDef<T>\n /** The value its rows share (`column.groupValue`, else the cell value). */\n readonly value: unknown\n /** 0 for top-level groups. */\n readonly level: number\n /** Every row in the group, sub-groups included, in display order. */\n readonly rows: readonly T[]\n /** Sub-groups, or the rows at the last level. */\n readonly children: readonly (RowGroup<T> | T)[]\n /** Aggregates of the group's rows, by column key (columns with an `aggregate`). */\n readonly aggregates: Readonly<Record<string, unknown>>\n}\n\n/** A row of the grid is a group row, not a row of the data. */\nexport function isRowGroup(row: unknown): row is RowGroup {\n return typeof row === 'object' && row !== null && GROUP in row\n}\n\n/** Prefix of group keys: keeps them apart from the app's row keys. */\nexport const GROUP_KEY_PREFIX = '\\u001fvg-group:'\n\n/** The `children` arrays of groups: already filtered and sorted, so the grid takes them as they are. */\nexport const groupedLevels = new WeakSet<object>()\n\n/** The value rows are grouped by. */\nexport function groupValueOf<T>(row: T, column: ColumnDef<T>): unknown {\n return column.groupValue ? column.groupValue(row) : getCellValue(row, column)\n}\n\nconst isBlank = (v: unknown) =>\n v === null || v === undefined || v === '' || (typeof v === 'number' && Number.isNaN(v))\n\n/** Same group ⇔ same id: dates by time, objects by content, everything else by string. */\nfunction groupId(value: unknown): string {\n if (isBlank(value)) return ''\n if (value instanceof Date) return `d${value.getTime()}`\n if (typeof value === 'object') {\n try {\n return `o${JSON.stringify(value)}`\n } catch {\n return `o${String(value)}`\n }\n }\n return `${typeof value === 'number' || typeof value === 'bigint' ? 'n' : 's'}${String(value)}`\n}\n\nexport interface GroupRowsOptions<T> {\n /** The grouped columns, outermost first. */\n columns: readonly ColumnDef<T>[]\n /** Every column: the ones with an `aggregate` get group aggregates. */\n allColumns: readonly ColumnDef<T>[]\n /** Groups of the sorted column follow its direction; other groups are ascending. */\n sort?: SortState | null\n}\n\n/**\n * Groups rows by one or more columns. The rows keep their order inside each group (pass them\n * filtered and sorted); groups are ordered by value (blank last), descending when the grid is\n * sorted descending by that column.\n */\nexport function groupRows<T>(rows: readonly T[], opts: GroupRowsOptions<T>): RowGroup<T>[] {\n const aggregated = opts.allColumns.filter((c) => c.aggregate)\n const build = (items: readonly T[], level: number, parentKey: string): RowGroup<T>[] => {\n const column = opts.columns[level]!\n const buckets = new Map<string, { value: unknown; rows: T[] }>()\n for (const row of items) {\n const value = groupValueOf(row, column)\n const id = groupId(value)\n const bucket = buckets.get(id)\n if (bucket) bucket.rows.push(row)\n else buckets.set(id, { value, rows: [row] })\n }\n const dir = opts.sort?.key === column.key && opts.sort.dir === 'desc' ? -1 : 1\n const ordered = [...buckets.entries()].sort(([, a], [, b]) => {\n const blankA = isBlank(a.value)\n const blankB = isBlank(b.value)\n if (blankA || blankB) return blankA === blankB ? 0 : blankA ? 1 : -1\n return compareValues(a.value, b.value) * dir\n })\n const last = level === opts.columns.length - 1\n return ordered.map(([id, bucket]) => {\n const key = `${parentKey}${parentKey ? '\\u001e' : GROUP_KEY_PREFIX}${column.key}=${id}`\n const children = last ? bucket.rows : build(bucket.rows, level + 1, key)\n groupedLevels.add(children)\n return {\n [GROUP]: true,\n key,\n column,\n value: bucket.value,\n level,\n rows: bucket.rows,\n children,\n aggregates: aggregated.length ? aggregateRows(bucket.rows, aggregated) : {},\n } as RowGroup<T>\n })\n }\n return opts.columns.length ? build(rows, 0, '') : []\n}\n\n/** Pre-order walk over groups and their sub-groups (not their rows). */\nexport function walkGroups<T>(\n groups: readonly (RowGroup<T> | T)[],\n visit: (group: RowGroup<T>) => void,\n) {\n for (const g of groups) {\n if (!isRowGroup(g)) return // a level holds either groups or rows\n visit(g)\n walkGroups(g.children, visit)\n }\n}\n\n/** Row keys of every group in the tree. */\nexport function groupKeys(groups: readonly RowGroup[]): RowKey[] {\n const keys: RowKey[] = []\n walkGroups(groups, (g) => keys.push(g.key))\n return keys\n}\n"],"mappings":";;;;AAMA,IAAMA,IAAQ,OAAO,IAAI,oBAAoB;AA0B7C,SAAgBC,EAAW,GAA+B;CACxD,OAAO,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C,MAAM,GAAGM,IAAI,GAAGC,OAAO;GAC5D,IAAMC,IAASlB,EAAQgB,EAAE,KAAK,GACxBG,IAASnB,EAAQiB,EAAE,KAAK;GAE9B,OADIC,KAAUC,IAAeD,MAAWC,IAAS,IAAID,IAAS,IAAI,KAC3DE,EAAcJ,EAAE,OAAOC,EAAE,KAAK,IAAIH;EAC3C,CAAC,GACKO,IAAOZ,MAAUH,EAAK,QAAQ,SAAS;EAC7C,OAAOS,EAAQ,KAAK,CAACH,GAAIC,OAAY;GACnC,IAAMS,IAAM,GAAGC,IAAYA,IAAY,MAAW5B,IAAmBG,EAAO,IAAI,GAAGc,KAC7EY,IAAWH,IAAOR,EAAO,OAAOL,EAAMK,EAAO,MAAMJ,IAAQ,GAAGa,CAAG;GAEvE,OADA1B,EAAc,IAAI4B,CAAQ,GACnB;KACJhC,IAAQ;IACT;IACA;IACA,OAAOqB,EAAO;IACd;IACA,MAAMA,EAAO;IACb;IACA,YAAYR,EAAW,SAASoB,EAAcZ,EAAO,MAAMR,CAAU,IAAI,CAAC;GAC5E;EACF,CAAC;CACH;CACA,OAAOC,EAAK,QAAQ,SAASE,EAAMkB,GAAM,GAAG,EAAE,IAAI,CAAC;AACrD;AAGA,SAAgBC,EACd,GACA,GACA;CACA,KAAK,IAAMC,KAAKC,GAAQ;EACtB,IAAI,CAACpC,EAAWmC,CAAC,GAAG;EAEpB,AADAE,EAAMF,CAAC,GACPD,EAAWC,EAAE,UAAUE,CAAK;CAC9B;AACF;AAGA,SAAgBC,EAAU,GAAuC;CAC/D,IAAMC,IAAiB,CAAC;CAExB,OADAL,EAAWE,IAAS,MAAMG,EAAK,KAAKJ,EAAE,GAAG,CAAC,GACnCI;AACT"}
1
+ {"version":3,"file":"grouping.js","names":["GROUP","isRowGroup","row","GROUP_KEY_PREFIX","groupedLevels","groupValueOf","column","getCellValue","isBlank","v","groupId","value","groupRows","aggregated","opts","c","build","level","buckets","items","id","bucket","dir","ordered","a","b","blankA","blankB","compareValues","last","key","groupKey","parentKey","path","parentPath","children","aggregateRows","rows","pathKey","p","columnKey","serverGroups","groups","parent","g"],"sources":["../../src/core/grouping.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any -- rows are type-erased here; ColumnDef<T> keeps the public API typed. */\nimport type { ColumnDef, RowKey, SortState } from '../types'\nimport { aggregateRows } from './aggregate'\nimport { compareValues } from './sort'\nimport { getCellValue } from './value'\n\nconst GROUP = Symbol.for('vue-grid:row-group')\n\n/**\n * A group of rows (row grouping feature): the rows that share a value in a grouped column. Shown\n * as a group row with its value, its row count and its columns' aggregates; expanding it shows\n * its sub-groups (grouped by the next column) or, at the last level, its rows.\n */\nexport interface RowGroup<T = any> {\n readonly [GROUP]: true\n /** Unique among the grid's rows and groups (the path of group values from the top). */\n readonly key: string\n /** The grouped column. */\n readonly column: ColumnDef<T>\n /** The value its rows share (`column.groupValue`, else the cell value). */\n readonly value: unknown\n /** 0 for top-level groups. */\n readonly level: number\n /** Every row in the group, sub-groups included, in display order. */\n readonly rows: readonly T[]\n /** Sub-groups, or the rows at the last level. */\n readonly children: readonly (RowGroup<T> | T)[]\n /** Aggregates of the group's rows, by column key (columns with an `aggregate`). */\n readonly aggregates: Readonly<Record<string, unknown>>\n /** How many rows it holds: `rows.length`, or the server's count (server data). */\n readonly count: number\n /** The grouped columns' values from the top: `[{ key: 'status', value: 'Won' }, …]`. */\n readonly path: readonly { key: string; value: unknown }[]\n /**\n * A group from the server (row grouping with server data): `rows` and `children` are empty and\n * its contents load when it expands.\n */\n readonly server?: boolean\n}\n\n/** A row of the grid is a group row, not a row of the data. */\nexport function isRowGroup(row: unknown): row is RowGroup {\n return typeof row === 'object' && row !== null && GROUP in row\n}\n\n/** Prefix of group keys: keeps them apart from the app's row keys. */\nexport const GROUP_KEY_PREFIX = '\\u001fvg-group:'\n\n/** The `children` arrays of groups: already filtered and sorted, so the grid takes them as they are. */\nexport const groupedLevels = new WeakSet<object>()\n\n/** The value rows are grouped by. */\nexport function groupValueOf<T>(row: T, column: ColumnDef<T>): unknown {\n return column.groupValue ? column.groupValue(row) : getCellValue(row, column)\n}\n\nconst isBlank = (v: unknown) =>\n v === null || v === undefined || v === '' || (typeof v === 'number' && Number.isNaN(v))\n\n/** Same group ⇔ same id: dates by time, objects by content, everything else by string. */\nfunction groupId(value: unknown): string {\n if (isBlank(value)) return ''\n if (value instanceof Date) return `d${value.getTime()}`\n if (typeof value === 'object') {\n try {\n return `o${JSON.stringify(value)}`\n } catch {\n return `o${String(value)}`\n }\n }\n return `${typeof value === 'number' || typeof value === 'bigint' ? 'n' : 's'}${String(value)}`\n}\n\nexport interface GroupRowsOptions<T> {\n /** The grouped columns, outermost first. */\n columns: readonly ColumnDef<T>[]\n /** Every column: the ones with an `aggregate` get group aggregates. */\n allColumns: readonly ColumnDef<T>[]\n /** Groups of the sorted column follow its direction; other groups are ascending. */\n sort?: SortState | null\n}\n\n/**\n * Groups rows by one or more columns. The rows keep their order inside each group (pass them\n * filtered and sorted); groups are ordered by value (blank last), descending when the grid is\n * sorted descending by that column.\n */\nexport function groupRows<T>(rows: readonly T[], opts: GroupRowsOptions<T>): RowGroup<T>[] {\n const aggregated = opts.allColumns.filter((c) => c.aggregate)\n const build = (\n items: readonly T[],\n level: number,\n parentKey: string,\n parentPath: RowGroup['path'],\n ): RowGroup<T>[] => {\n const column = opts.columns[level]!\n const buckets = new Map<string, { value: unknown; rows: T[] }>()\n for (const row of items) {\n const value = groupValueOf(row, column)\n const id = groupId(value)\n const bucket = buckets.get(id)\n if (bucket) bucket.rows.push(row)\n else buckets.set(id, { value, rows: [row] })\n }\n const dir = opts.sort?.key === column.key && opts.sort.dir === 'desc' ? -1 : 1\n const ordered = [...buckets.entries()].sort(([, a], [, b]) => {\n const blankA = isBlank(a.value)\n const blankB = isBlank(b.value)\n if (blankA || blankB) return blankA === blankB ? 0 : blankA ? 1 : -1\n return compareValues(a.value, b.value) * dir\n })\n const last = level === opts.columns.length - 1\n return ordered.map(([id, bucket]) => {\n const key = groupKey(parentKey, column.key, id)\n const path = [...parentPath, { key: column.key, value: bucket.value }]\n const children = last ? bucket.rows : build(bucket.rows, level + 1, key, path)\n groupedLevels.add(children)\n return {\n [GROUP]: true,\n key,\n column,\n value: bucket.value,\n level,\n rows: bucket.rows,\n children,\n aggregates: aggregated.length ? aggregateRows(bucket.rows, aggregated) : {},\n count: bucket.rows.length,\n path,\n } as RowGroup<T>\n })\n }\n return opts.columns.length ? build(rows, 0, '', []) : []\n}\n\n/** The key of the group at a path (`[{ key: 'status', value: 'Won' }, …]`), as its group row has it. */\nexport function pathKey(path: readonly { key: string; value: unknown }[]): string {\n return path.reduce((key, p) => groupKey(key, p.key, groupId(p.value)), '')\n}\n\n/** A group's key: its parent's, then the column and the value's id. */\nconst groupKey = (parentKey: string, columnKey: string, id: string) =>\n `${parentKey}${parentKey ? '\\u001e' : GROUP_KEY_PREFIX}${columnKey}=${id}`\n\n/**\n * Group rows for groups the server sent (row grouping with server data), at one level: their\n * contents load when they expand. `parent` is the group they are inside (none at the top).\n */\nexport function serverGroups<T>(\n groups: readonly { value: unknown; count: number; aggregates?: Record<string, unknown> }[],\n column: ColumnDef<T>,\n parent?: RowGroup<T>,\n): RowGroup<T>[] {\n return groups.map((g) => ({\n [GROUP]: true,\n key: groupKey(parent?.key ?? '', column.key, groupId(g.value)),\n column,\n value: g.value,\n level: parent ? parent.level + 1 : 0,\n rows: [],\n children: [],\n aggregates: g.aggregates ?? {},\n count: Number(g.count) || 0,\n path: [...(parent?.path ?? []), { key: column.key, value: g.value }],\n server: true,\n })) as RowGroup<T>[]\n}\n\n/** Pre-order walk over groups and their sub-groups (not their rows). */\nexport function walkGroups<T>(\n groups: readonly (RowGroup<T> | T)[],\n visit: (group: RowGroup<T>) => void,\n) {\n for (const g of groups) {\n if (!isRowGroup(g)) return // a level holds either groups or rows\n visit(g)\n walkGroups(g.children, visit)\n }\n}\n\n/** Row keys of every group in the tree. */\nexport function groupKeys(groups: readonly RowGroup[]): RowKey[]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IAAmBqC,EAAU,GAAGpB;AAMxE,SAAgBqB,EACd,GACA,GACA,GACe;CACf,OAAOC,EAAO,KAAK,OAAO;GACvB1C,IAAQ;EACT,KAAK+B,EAASY,GAAQ,OAAO,IAAIrC,EAAO,KAAKI,EAAQkC,EAAE,KAAK,CAAC;EAC7D;EACA,OAAOA,EAAE;EACT,OAAOD,IAASA,EAAO,QAAQ,IAAI;EACnC,MAAM,CAAC;EACP,UAAU,CAAC;EACX,YAAYC,EAAE,cAAc,CAAC;EAC7B,OAAO,OAAOA,EAAE,KAAK,KAAK;EAC1B,MAAM,CAAC,GAAID,GAAQ,QAAQ,CAAC,GAAI;GAAE,KAAKrC,EAAO;GAAK,OAAOsC,EAAE;EAAM,CAAC;EACnE,QAAQ;CACV,EAAE;AACJ"}
@@ -13,22 +13,23 @@ import { rowGroupingFeature as d } from "./rowGrouping.js";
13
13
  import { rowPinningFeature as f } from "./rowPinning.js";
14
14
  import { selectionFeature as p } from "./selection.js";
15
15
  import { serverDataFeature as m } from "./serverData.js";
16
- import { sortingFeature as h } from "./sorting.js";
17
- import { statusBarFeature as g } from "./statusBar.js";
18
- import { subGridsFeature as _ } from "./subGrids.js";
19
- import { virtualScrollingFeature as v } from "./virtualScrolling.js";
16
+ import { serverGroupingFeature as h } from "./serverGrouping.js";
17
+ import { sortingFeature as g } from "./sorting.js";
18
+ import { statusBarFeature as _ } from "./statusBar.js";
19
+ import { subGridsFeature as v } from "./subGrids.js";
20
+ import { virtualScrollingFeature as y } from "./virtualScrolling.js";
20
21
  // src/features/index.ts
21
- var y = [
22
- h,
22
+ var b = [
23
+ g,
23
24
  s,
24
25
  m,
25
26
  u,
26
27
  p,
27
- _,
28
+ v,
28
29
  l,
29
30
  i,
30
31
  n,
31
- v,
32
+ y,
32
33
  a,
33
34
  c,
34
35
  r,
@@ -37,8 +38,9 @@ var y = [
37
38
  e,
38
39
  d,
39
40
  o,
40
- g
41
+ _,
42
+ h
41
43
  ];
42
- export { e as aggregationFeature, y as allFeatures, t as columnGroupsFeature, n as columnPinningFeature, i as columnReorderFeature, r as columnResizingFeature, a as columnVisibilityFeature, o as exportFeature, s as filteringFeature, c as keyboardNavigationFeature, l as menusFeature, u as paginationFeature, d as rowGroupingFeature, f as rowPinningFeature, p as selectionFeature, m as serverDataFeature, h as sortingFeature, g as statusBarFeature, _ as subGridsFeature, v as virtualScrollingFeature };
44
+ export { e as aggregationFeature, b as allFeatures, t as columnGroupsFeature, n as columnPinningFeature, i as columnReorderFeature, r as columnResizingFeature, a as columnVisibilityFeature, o as exportFeature, s as filteringFeature, c as keyboardNavigationFeature, l as menusFeature, u as paginationFeature, d as rowGroupingFeature, f as rowPinningFeature, p as selectionFeature, m as serverDataFeature, h as serverGroupingFeature, g as sortingFeature, _ as statusBarFeature, v as subGridsFeature, y as virtualScrollingFeature };
43
45
 
44
46
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["allFeatures","sortingFeature","filteringFeature","serverDataFeature","paginationFeature","selectionFeature","subGridsFeature","menusFeature","columnReorderFeature","columnPinningFeature","virtualScrollingFeature","columnVisibilityFeature","keyboardNavigationFeature","columnResizingFeature","columnGroupsFeature","rowPinningFeature","aggregationFeature","rowGroupingFeature","exportFeature","statusBarFeature"],"sources":["../../src/features/index.ts"],"sourcesContent":["import type { GridFeature } from '../types'\nimport { aggregationFeature } from './aggregation'\nimport { columnGroupsFeature } from './columnGroups'\nimport { columnPinningFeature } from './columnPinning'\nimport { columnResizingFeature } from './columnResizing'\nimport { columnReorderFeature } from './columnReorder'\nimport { columnVisibilityFeature } from './columnVisibility'\nimport { exportFeature } from './export'\nimport { filteringFeature } from './filtering'\nimport { keyboardNavigationFeature } from './keyboardNavigation'\nimport { menusFeature } from './menus'\nimport { paginationFeature } from './pagination'\nimport { rowGroupingFeature } from './rowGrouping'\nimport { rowPinningFeature } from './rowPinning'\nimport { selectionFeature } from './selection'\nimport { serverDataFeature } from './serverData'\nimport { sortingFeature } from './sorting'\nimport { statusBarFeature } from './statusBar'\nimport { subGridsFeature } from './subGrids'\nimport { virtualScrollingFeature } from './virtualScrolling'\n\nexport {\n aggregationFeature,\n columnGroupsFeature,\n columnPinningFeature,\n columnReorderFeature,\n columnResizingFeature,\n columnVisibilityFeature,\n exportFeature,\n filteringFeature,\n keyboardNavigationFeature,\n menusFeature,\n paginationFeature,\n rowGroupingFeature,\n rowPinningFeature,\n selectionFeature,\n serverDataFeature,\n sortingFeature,\n statusBarFeature,\n subGridsFeature,\n virtualScrollingFeature,\n}\n\n/** Every built-in feature, for apps that want them all: `createVueGrid({ features: allFeatures })`. */\nexport const allFeatures: readonly GridFeature[] = [\n sortingFeature,\n filteringFeature,\n serverDataFeature,\n paginationFeature,\n selectionFeature,\n subGridsFeature,\n menusFeature,\n columnReorderFeature,\n columnPinningFeature,\n virtualScrollingFeature,\n columnVisibilityFeature,\n keyboardNavigationFeature,\n columnResizingFeature,\n columnGroupsFeature,\n rowPinningFeature,\n aggregationFeature,\n rowGroupingFeature,\n exportFeature,\n statusBarFeature,\n]\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA4CA,IAAaA,IAAsC;CACjDC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;AACF"}
1
+ {"version":3,"file":"index.js","names":["allFeatures","sortingFeature","filteringFeature","serverDataFeature","paginationFeature","selectionFeature","subGridsFeature","menusFeature","columnReorderFeature","columnPinningFeature","virtualScrollingFeature","columnVisibilityFeature","keyboardNavigationFeature","columnResizingFeature","columnGroupsFeature","rowPinningFeature","aggregationFeature","rowGroupingFeature","exportFeature","statusBarFeature","serverGroupingFeature"],"sources":["../../src/features/index.ts"],"sourcesContent":["import type { GridFeature } from '../types'\nimport { aggregationFeature } from './aggregation'\nimport { columnGroupsFeature } from './columnGroups'\nimport { columnPinningFeature } from './columnPinning'\nimport { columnResizingFeature } from './columnResizing'\nimport { columnReorderFeature } from './columnReorder'\nimport { columnVisibilityFeature } from './columnVisibility'\nimport { exportFeature } from './export'\nimport { filteringFeature } from './filtering'\nimport { keyboardNavigationFeature } from './keyboardNavigation'\nimport { menusFeature } from './menus'\nimport { paginationFeature } from './pagination'\nimport { rowGroupingFeature } from './rowGrouping'\nimport { rowPinningFeature } from './rowPinning'\nimport { selectionFeature } from './selection'\nimport { serverDataFeature } from './serverData'\nimport { serverGroupingFeature } from './serverGrouping'\nimport { sortingFeature } from './sorting'\nimport { statusBarFeature } from './statusBar'\nimport { subGridsFeature } from './subGrids'\nimport { virtualScrollingFeature } from './virtualScrolling'\n\nexport {\n aggregationFeature,\n columnGroupsFeature,\n columnPinningFeature,\n columnReorderFeature,\n columnResizingFeature,\n columnVisibilityFeature,\n exportFeature,\n filteringFeature,\n keyboardNavigationFeature,\n menusFeature,\n paginationFeature,\n rowGroupingFeature,\n rowPinningFeature,\n selectionFeature,\n serverDataFeature,\n serverGroupingFeature,\n sortingFeature,\n statusBarFeature,\n subGridsFeature,\n virtualScrollingFeature,\n}\n\n/** Every built-in feature, for apps that want them all: `createVueGrid({ features: allFeatures })`. */\nexport const allFeatures: readonly GridFeature[] = [\n sortingFeature,\n filteringFeature,\n serverDataFeature,\n paginationFeature,\n selectionFeature,\n subGridsFeature,\n menusFeature,\n columnReorderFeature,\n columnPinningFeature,\n virtualScrollingFeature,\n columnVisibilityFeature,\n keyboardNavigationFeature,\n columnResizingFeature,\n columnGroupsFeature,\n rowPinningFeature,\n aggregationFeature,\n rowGroupingFeature,\n exportFeature,\n statusBarFeature,\n serverGroupingFeature,\n]\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA8CA,IAAaA,IAAsC;CACjDC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;AACF"}
@@ -0,0 +1,9 @@
1
+ import { useServerGroups as e } from "../composables/useServerGroups.js";
2
+ // src/features/serverGrouping.ts
3
+ var t = {
4
+ feature: "serverGrouping",
5
+ useServerGroups: e
6
+ };
7
+ export { t as serverGroupingFeature };
8
+
9
+ //# sourceMappingURL=serverGrouping.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serverGrouping.js","names":["serverGroupingFeature"],"sources":["../../src/features/serverGrouping.ts"],"sourcesContent":["import { useServerGroups } from '../composables/useServerGroups'\nimport type { ServerGroupingFeature } from '../types'\n\n/**\n * Row grouping with server data: with `group-by` and a `data-source`, the query carries `groupBy` and\n * `groupPath`, the server answers with groups (value, count, aggregates), and each group's contents\n * load when it expands. A group's checkbox selects it by query (`v-model:selected-groups`), without\n * loading its rows. Needs the row grouping and server data features too. Without it, a grouped\n * server grid groups only the rows it has loaded.\n */\nexport const serverGroupingFeature: ServerGroupingFeature = {\n feature: 'serverGrouping',\n useServerGroups,\n}\n"],"mappings":";;AAUA,IAAaA,IAA+C;CAC1D,SAAS;CACT;AACF"}
package/dist/index.js CHANGED
@@ -65,9 +65,10 @@ import { rowGroupingFeature as Dt } from "./features/rowGrouping.js";
65
65
  import { rowPinningFeature as Ot } from "./features/rowPinning.js";
66
66
  import { selectionFeature as kt } from "./features/selection.js";
67
67
  import { serverDataFeature as At } from "./features/serverData.js";
68
- import { sortingFeature as jt } from "./features/sorting.js";
69
- import { statusBarFeature as Mt } from "./features/statusBar.js";
70
- import { subGridsFeature as Nt } from "./features/subGrids.js";
71
- import { virtualScrollingFeature as Pt } from "./features/virtualScrolling.js";
72
- import { allFeatures as Ft } from "./features/index.js";
73
- export { me as ActionButtonCell, he as ActionsMenuCell, ge as BooleanCell, Oe as ButtonGroupCell, _e as ChangeCell, ke as CheckboxCell, Ae as ChipCell, je as CodeCell, Me as CopyCell, ve as CurrencyCell, d as DATE_DEFAULT, ye as DateCell, be as DateTimeCell, Ne as DetailsCell, Pe as EditCell, D as GRID_CONFIG_KEY, xe as IconCell, Fe as IconToggleCell, Ie as ImageCell, Se as JsonCell, Ce as JsonTreeCell, we as LinkCell, Le as ListCell, Re as MultiLineCell, Te as NumberCell, ze as RadioCell, Ee as StatusCell, Be as SwitchCell, f as TIME_DEFAULT, l as TextCell, De as ToggleTextCell, e as VGrid, n as VGridColumnMenu, r as VGridMenu, t as VGridPagination, i as VGridSearch, Ve as actionButtonRenderer, He as actionsMenuRenderer, ne as activeFilterCount, K as aggregateRows, q as aggregateValues, gt as aggregationFeature, Ft as allFeatures, Ue as allRenderers, T as anchorNameFor, We as booleanRenderer, Ge as buttonGroupRenderer, Ke as changeRenderer, qe as checkboxRenderer, Je as chipRenderer, Ye as codeRenderer, _t as columnGroupsFeature, vt as columnPinningFeature, bt as columnReorderFeature, yt as columnResizingFeature, xt as columnVisibilityFeature, U as compareValues, Xe as copyRenderer, pe as createColumnHelper, A as createRendererRegistry, O as createVueGrid, Ze as currencyRenderer, Qe as dateRenderer, $e as dateTimeRenderer, j as defineCellRenderer, et as detailsRenderer, tt as editRenderer, I as effectivePin, re as emptyFilters, St as exportFeature, ie as filterTree, Ct as filteringFeature, ae as foldText, p as formatCurrency, m as formatDate, h as formatNumber, g as formatSigned, N as getByPath, P as getCellValue, J as groupRows, X as guardFormula, nt as iconRenderer, rt as iconToggleRenderer, it as imageRenderer, oe as isFilterActive, M as isRendererDefinition, Y as isRowGroup, at as jsonRenderer, ot as jsonTreeRenderer, wt as keyboardNavigationFeature, st as linkRenderer, ct as listRenderer, se as localFilterStorage, de as localStorageAdapter, a as lookup, ce as matchesFilter, Tt as menusFeature, L as moveColumn, R as moveColumnRelative, lt as multiLineRenderer, W as nextSort, z as normalizeColumnState, ut as numberRenderer, fe as pageItems, Et as paginationFeature, _ as parseJsonish, le as parseQuickFilter, te as patchRows, Z as plainText, dt as radioRenderer, v as readableTextColor, y as resolveImageSrc, o as resolveOption, F as resolveRowKey, s as resolveTone, Dt as rowGroupingFeature, Ot as rowPinningFeature, b as safeHref, c as safeTone, kt as selectionFeature, At as serverDataFeature, B as setColumnHidden, V as setColumnPinned, ue as setKey, ft as signedNumberRenderer, G as sortRows, jt as sortingFeature, Mt as statusBarFeature, pt as statusRenderer, x as stringifyJson, Nt as subGridsFeature, E as supportsAnchorPositioning, mt as switchRenderer, u as textRenderer, Q as toCsv, S as toDate, $ as toDelimited, C as toNumber, ee as toXlsx, ht as toggleTextRenderer, w as tokenizeJson, k as useGridContext, Pt as virtualScrollingFeature, H as visibleColumns };
68
+ import { serverGroupingFeature as jt } from "./features/serverGrouping.js";
69
+ import { sortingFeature as Mt } from "./features/sorting.js";
70
+ import { statusBarFeature as Nt } from "./features/statusBar.js";
71
+ import { subGridsFeature as Pt } from "./features/subGrids.js";
72
+ import { virtualScrollingFeature as Ft } from "./features/virtualScrolling.js";
73
+ import { allFeatures as It } from "./features/index.js";
74
+ export { me as ActionButtonCell, he as ActionsMenuCell, ge as BooleanCell, Oe as ButtonGroupCell, _e as ChangeCell, ke as CheckboxCell, Ae as ChipCell, je as CodeCell, Me as CopyCell, ve as CurrencyCell, d as DATE_DEFAULT, ye as DateCell, be as DateTimeCell, Ne as DetailsCell, Pe as EditCell, D as GRID_CONFIG_KEY, xe as IconCell, Fe as IconToggleCell, Ie as ImageCell, Se as JsonCell, Ce as JsonTreeCell, we as LinkCell, Le as ListCell, Re as MultiLineCell, Te as NumberCell, ze as RadioCell, Ee as StatusCell, Be as SwitchCell, f as TIME_DEFAULT, l as TextCell, De as ToggleTextCell, e as VGrid, n as VGridColumnMenu, r as VGridMenu, t as VGridPagination, i as VGridSearch, Ve as actionButtonRenderer, He as actionsMenuRenderer, ne as activeFilterCount, K as aggregateRows, q as aggregateValues, gt as aggregationFeature, It as allFeatures, Ue as allRenderers, T as anchorNameFor, We as booleanRenderer, Ge as buttonGroupRenderer, Ke as changeRenderer, qe as checkboxRenderer, Je as chipRenderer, Ye as codeRenderer, _t as columnGroupsFeature, vt as columnPinningFeature, bt as columnReorderFeature, yt as columnResizingFeature, xt as columnVisibilityFeature, U as compareValues, Xe as copyRenderer, pe as createColumnHelper, A as createRendererRegistry, O as createVueGrid, Ze as currencyRenderer, Qe as dateRenderer, $e as dateTimeRenderer, j as defineCellRenderer, et as detailsRenderer, tt as editRenderer, I as effectivePin, re as emptyFilters, St as exportFeature, ie as filterTree, Ct as filteringFeature, ae as foldText, p as formatCurrency, m as formatDate, h as formatNumber, g as formatSigned, N as getByPath, P as getCellValue, J as groupRows, X as guardFormula, nt as iconRenderer, rt as iconToggleRenderer, it as imageRenderer, oe as isFilterActive, M as isRendererDefinition, Y as isRowGroup, at as jsonRenderer, ot as jsonTreeRenderer, wt as keyboardNavigationFeature, st as linkRenderer, ct as listRenderer, se as localFilterStorage, de as localStorageAdapter, a as lookup, ce as matchesFilter, Tt as menusFeature, L as moveColumn, R as moveColumnRelative, lt as multiLineRenderer, W as nextSort, z as normalizeColumnState, ut as numberRenderer, fe as pageItems, Et as paginationFeature, _ as parseJsonish, le as parseQuickFilter, te as patchRows, Z as plainText, dt as radioRenderer, v as readableTextColor, y as resolveImageSrc, o as resolveOption, F as resolveRowKey, s as resolveTone, Dt as rowGroupingFeature, Ot as rowPinningFeature, b as safeHref, c as safeTone, kt as selectionFeature, At as serverDataFeature, jt as serverGroupingFeature, B as setColumnHidden, V as setColumnPinned, ue as setKey, ft as signedNumberRenderer, G as sortRows, Mt as sortingFeature, Nt as statusBarFeature, pt as statusRenderer, x as stringifyJson, Pt as subGridsFeature, E as supportsAnchorPositioning, mt as switchRenderer, u as textRenderer, Q as toCsv, S as toDate, $ as toDelimited, C as toNumber, ee as toXlsx, ht as toggleTextRenderer, w as tokenizeJson, k as useGridContext, Ft as virtualScrollingFeature, H as visibleColumns };
@@ -1 +1 @@
1
- {"version":3,"file":"features.js","names":["resolveFeatures","lists","set","list","f"],"sources":["../../src/internal/features.ts"],"sourcesContent":["import type {\n AggregationFeature,\n ExportFeature,\n RowGroupingFeature,\n RowPinningFeature,\n ColumnGroupsFeature,\n ColumnPinningFeature,\n ColumnResizingFeature,\n ColumnReorderFeature,\n ColumnVisibilityFeature,\n FilteringFeature,\n KeyboardNavigationFeature,\n GridFeature,\n MenusFeature,\n PaginationFeature,\n SelectionFeature,\n ServerDataFeature,\n SortingFeature,\n StatusBarFeature,\n SubGridsFeature,\n VirtualScrollingFeature,\n} from '../types'\n\n/** The features a grid has, by name. */\nexport interface FeatureSet {\n sorting?: SortingFeature\n filtering?: FilteringFeature\n serverData?: ServerDataFeature\n pagination?: PaginationFeature\n selection?: SelectionFeature\n subGrids?: SubGridsFeature\n menus?: MenusFeature\n columnReorder?: ColumnReorderFeature\n columnPinning?: ColumnPinningFeature\n virtualScrolling?: VirtualScrollingFeature\n columnVisibility?: ColumnVisibilityFeature\n keyboardNavigation?: KeyboardNavigationFeature\n columnResizing?: ColumnResizingFeature\n columnGroups?: ColumnGroupsFeature\n rowPinning?: RowPinningFeature\n aggregation?: AggregationFeature\n rowGrouping?: RowGroupingFeature\n export?: ExportFeature\n statusBar?: StatusBarFeature\n}\n\n/** Merges feature lists (app-wide, then per grid); a later entry with the same name wins. */\nexport function resolveFeatures(...lists: (readonly GridFeature[] | undefined)[]): FeatureSet {\n const set: Record<string, GridFeature> = {}\n for (const list of lists) for (const f of list ?? []) set[f.feature] = f\n return set as FeatureSet\n}\n"],"mappings":";AA+CA,SAAgBA,EAAgB,GAAGC,GAA2D;CAC5F,IAAMC,IAAmC,CAAC;CAC1C,KAAK,IAAMC,KAAQF,GAAO,KAAK,IAAMG,KAAKD,KAAQ,CAAC,GAAG,EAAIC,EAAE,WAAWA;CACvE,OAAOF;AACT"}
1
+ {"version":3,"file":"features.js","names":["resolveFeatures","lists","set","list","f"],"sources":["../../src/internal/features.ts"],"sourcesContent":["import type {\n AggregationFeature,\n ExportFeature,\n RowGroupingFeature,\n RowPinningFeature,\n ColumnGroupsFeature,\n ColumnPinningFeature,\n ColumnResizingFeature,\n ColumnReorderFeature,\n ColumnVisibilityFeature,\n FilteringFeature,\n KeyboardNavigationFeature,\n GridFeature,\n MenusFeature,\n PaginationFeature,\n SelectionFeature,\n ServerDataFeature,\n ServerGroupingFeature,\n SortingFeature,\n StatusBarFeature,\n SubGridsFeature,\n VirtualScrollingFeature,\n} from '../types'\n\n/** The features a grid has, by name. */\nexport interface FeatureSet {\n sorting?: SortingFeature\n filtering?: FilteringFeature\n serverData?: ServerDataFeature\n pagination?: PaginationFeature\n selection?: SelectionFeature\n subGrids?: SubGridsFeature\n menus?: MenusFeature\n columnReorder?: ColumnReorderFeature\n columnPinning?: ColumnPinningFeature\n virtualScrolling?: VirtualScrollingFeature\n columnVisibility?: ColumnVisibilityFeature\n keyboardNavigation?: KeyboardNavigationFeature\n columnResizing?: ColumnResizingFeature\n columnGroups?: ColumnGroupsFeature\n rowPinning?: RowPinningFeature\n aggregation?: AggregationFeature\n rowGrouping?: RowGroupingFeature\n export?: ExportFeature\n statusBar?: StatusBarFeature\n serverGrouping?: ServerGroupingFeature\n}\n\n/** Merges feature lists (app-wide, then per grid); a later entry with the same name wins. */\nexport function resolveFeatures(...lists: (readonly GridFeature[] | undefined)[]): FeatureSet {\n const set: Record<string, GridFeature> = {}\n for (const list of lists) for (const f of list ?? []) set[f.feature] = f\n return set as FeatureSet\n}\n"],"mappings":";AAiDA,SAAgBA,EAAgB,GAAGC,GAA2D;CAC5F,IAAMC,IAAmC,CAAC;CAC1C,KAAK,IAAMC,KAAQF,GAAO,KAAK,IAAMG,KAAKD,KAAQ,CAAC,GAAG,EAAIC,EAAE,WAAWA;CACvE,OAAOF;AACT"}
@@ -3,7 +3,7 @@
3
3
  * one fact about the API the types don't carry: the agent API reference (`api.json`), the JSON
4
4
  * Schema and `validateGridConfig()` all read it from here.
5
5
  */
6
- export type FeatureId = 'sorting' | 'filtering' | 'serverData' | 'pagination' | 'selection' | 'subGrids' | 'menus' | 'columnReorder' | 'columnPinning' | 'virtualScrolling' | 'columnVisibility' | 'keyboardNavigation' | 'columnResizing' | 'columnGroups' | 'rowPinning' | 'aggregation' | 'rowGrouping' | 'export' | 'statusBar';
6
+ export type FeatureId = 'sorting' | 'filtering' | 'serverData' | 'pagination' | 'selection' | 'subGrids' | 'menus' | 'columnReorder' | 'columnPinning' | 'virtualScrolling' | 'columnVisibility' | 'keyboardNavigation' | 'columnResizing' | 'columnGroups' | 'rowPinning' | 'aggregation' | 'rowGrouping' | 'export' | 'statusBar' | 'serverGrouping';
7
7
  /** Grid props (and `v-model`s) that need a feature. */
8
8
  export declare const propFeatures: Readonly<Record<string, FeatureId>>;
9
9
  /** Column options that need a feature. */
@@ -1,6 +1,6 @@
1
1
  import type { RowGroup } from '../core/grouping';
2
2
  import { type RowKeyGetter } from '../core/value';
3
- import type { DataSource, GridQuery } from '../composables/useDataSource';
3
+ import type { DataSource, GridQuery, GroupPath } from '../composables/useDataSource';
4
4
  import type { CellActionEvent, CellClickEvent, CellContext, CellRendererDefinition, ClassValue, ColumnDef, ColumnState, FlashMode, FilterState, GridFeature, FilterStateStorage, ColumnStateStorage, ContextActionEvent, CopyEvent, Density, GridPart, HeaderActionEvent, HeaderMenuContext, MenuItem, PinnedRowsState, RowKey, SortState, PaginationOptions, StatusBarOptions, StatusBarScope, GridMessages, GridParts, VGridExposed, VirtualOptions } from '../types';
5
5
  declare const _default: typeof __VLS_export;
6
6
  export default _default;
@@ -160,6 +160,12 @@ declare const __VLS_export: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_se
160
160
  * then, not on `selected`. Needs the selection feature.
161
161
  */
162
162
  selectAllMatching?: boolean;
163
+ /**
164
+ * Server data with row grouping: groups selected by query, by their paths, without loading their
165
+ * rows (a group's checkbox). Act on these with `selected` and the filters. Ends when the filters or
166
+ * the grouping change. Needs the selection and row grouping features.
167
+ */
168
+ selectedGroups?: GroupPath[];
163
169
  }) & {
164
170
  onCopy?: ((event: CopyEvent<T>) => any) | undefined;
165
171
  "onQuery-change"?: ((query: GridQuery) => any) | undefined;
@@ -183,6 +189,7 @@ declare const __VLS_export: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_se
183
189
  "onUpdate:pinnedRows"?: ((value: PinnedRowsState | null) => any) | undefined;
184
190
  "onUpdate:groupBy"?: ((value: string | readonly string[] | null) => any) | undefined;
185
191
  "onUpdate:selectAllMatching"?: ((value: boolean) => any) | undefined;
192
+ "onUpdate:selectedGroups"?: ((value: GroupPath[]) => any) | undefined;
186
193
  }> & (typeof globalThis extends {
187
194
  __VLS_PROPS_FALLBACK: infer P;
188
195
  } ? P : {});
@@ -264,6 +271,8 @@ declare const __VLS_export: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_se
264
271
  selected: readonly RowKey[];
265
272
  /** How many rows are selected: every matching row with `selectAllMatching`. */
266
273
  selectedCount: number;
274
+ /** Server data with row grouping: groups selected by query (`v-model:selected-groups`). */
275
+ selectedGroups: GroupPath[];
267
276
  /** Every row matching the query is selected (server data, "Select all N rows"). */
268
277
  selectAllMatching: boolean;
269
278
  /** Clears the selection (and "all matching"). */
@@ -273,7 +282,7 @@ declare const __VLS_export: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_se
273
282
  emit: (((evt: "copy", event: CopyEvent<T>) => void) & ((evt: "query-change", query: GridQuery) => void) & ((evt: "load-error", error: unknown) => void) & ((evt: "row-click", row: T, event: MouseEvent | KeyboardEvent) => void) & ((evt: "cell-click", event: CellClickEvent<T>) => void) & ((evt: "cell-action", event: CellActionEvent<T>) => void) & ((evt: "sub-rows-error", event: {
274
283
  row: T;
275
284
  error: unknown;
276
- }) => void) & ((evt: "context-action", event: ContextActionEvent<T>) => void) & ((evt: "header-action", event: HeaderActionEvent<T>) => void)) & (((event: "update:sort", value: SortState | null) => void) & ((event: "update:columnState", value: ColumnState | undefined) => void) & ((event: "update:expanded", value: RowKey[]) => void) & ((event: "update:selected", value: RowKey[]) => void) & ((event: "update:filters", value: FilterState | null) => void) & ((event: "update:page", value: number) => void) & ((event: "update:pageSize", value: number) => void) & ((event: "update:pinnedRows", value: PinnedRowsState | null) => void) & ((event: "update:groupBy", value: string | readonly string[] | null) => void) & ((event: "update:selectAllMatching", value: boolean) => void));
285
+ }) => void) & ((evt: "context-action", event: ContextActionEvent<T>) => void) & ((evt: "header-action", event: HeaderActionEvent<T>) => void)) & (((event: "update:sort", value: SortState | null) => void) & ((event: "update:columnState", value: ColumnState | undefined) => void) & ((event: "update:expanded", value: RowKey[]) => void) & ((event: "update:selected", value: RowKey[]) => void) & ((event: "update:filters", value: FilterState | null) => void) & ((event: "update:page", value: number) => void) & ((event: "update:pageSize", value: number) => void) & ((event: "update:pinnedRows", value: PinnedRowsState | null) => void) & ((event: "update:groupBy", value: string | readonly string[] | null) => void) & ((event: "update:selectAllMatching", value: boolean) => void) & ((event: "update:selectedGroups", value: GroupPath[]) => void));
277
286
  }>) => import("vue").VNode & {
278
287
  __ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
279
288
  };
@@ -9,11 +9,40 @@ export interface GridQuery {
9
9
  /** 1-based; with `pageSize: null` (no pagination) always 1. */
10
10
  page: number;
11
11
  pageSize: number | null;
12
+ /**
13
+ * Row grouping with server data: the grouped column keys, outermost first (absent when the grid
14
+ * isn't grouped). Return `groups` for the level `groupPath` asks for, or `rows` at the last level.
15
+ */
16
+ groupBy?: string[];
17
+ /**
18
+ * Which group's contents: `[]` for the top-level groups, `[{ key: 'status', value: 'Won' }]` for
19
+ * the groups (or, at the last level, the rows) inside the "Won" group, and so on.
20
+ */
21
+ groupPath?: GroupPath;
22
+ }
23
+ /** A group, by the values of its grouped columns from the top: `[{ key: 'status', value: 'Won' }]`. */
24
+ export type GroupPath = {
25
+ key: string;
26
+ value: unknown;
27
+ }[];
28
+ /** A group the server returns (row grouping with server data). */
29
+ export interface ServerGroup {
30
+ /** The value its rows share in the grouped column. */
31
+ value: unknown;
32
+ /** How many rows it holds (sub-groups included). */
33
+ count: number;
34
+ /** Its columns' aggregates, by column key, shown in the group row. */
35
+ aggregates?: Record<string, unknown>;
12
36
  }
13
37
  export interface DataSourceResult<T> {
14
- rows: T[];
15
- /** Total matching rows (for pagination); default `rows.length`. */
38
+ /** The rows; with `groupBy`, the rows of a last-level group (`groups` at the levels above). */
39
+ rows?: T[];
40
+ /** With `groupBy`: the groups at `groupPath`'s level, in display order. */
41
+ groups?: ServerGroup[];
42
+ /** Total matching rows (for pagination), or top-level groups when grouped; default the length. */
16
43
  total?: number;
44
+ /** When grouped: all matching rows, for the status bar (default: the groups' counts added up). */
45
+ rowTotal?: number;
17
46
  }
18
47
  /** Loads rows for a query. Honour `signal` to cancel superseded requests. */
19
48
  export type DataSource<T> = (query: GridQuery, ctx: {
@@ -31,7 +60,9 @@ export interface DataSourceOptions<T> {
31
60
  */
32
61
  export declare function useDataSource<T>(opts: DataSourceOptions<T>): {
33
62
  rows: import("vue").ShallowRef<T[], T[]>;
63
+ groups: import("vue").ShallowRef<ServerGroup[] | undefined, ServerGroup[] | undefined>;
34
64
  total: import("vue").Ref<number | undefined, number | undefined>;
65
+ rowTotal: import("vue").Ref<number | undefined, number | undefined>;
35
66
  loading: import("vue").Ref<boolean, boolean>;
36
67
  error: import("vue").ShallowRef<unknown, unknown>;
37
68
  reload: () => Promise<void>;
@@ -15,6 +15,8 @@ export interface GridExportOptions<T> {
15
15
  getKey: (row: T) => RowKey;
16
16
  /** A group row (row grouping feature): its rows are exported instead. */
17
17
  isGroup: (row: T) => boolean;
18
+ /** A group row's rows (server groups: the loaded ones). */
19
+ groupRows?: (group: T) => readonly T[];
18
20
  /**
19
21
  * Top-level rows, sorted: `filtered` (every page, pinned rows included), `all` (filters
20
22
  * ignored), or `page` (the rows in the body, groups included).
@@ -2,6 +2,7 @@ import { type Component, type Ref } from 'vue';
2
2
  import { type RowGroup } from '../core/grouping';
3
3
  import type { GridContext } from '../internal/context';
4
4
  import type { ColumnDef, RowKey, SortState } from '../types';
5
+ import type { ServerGroups } from './useServerGroups';
5
6
  import type { SubRowsSnapshot } from './useVirtualRows';
6
7
  export interface RowGroupingOptions<T> {
7
8
  /** The `group-by` model: column keys, outermost first. */
@@ -18,16 +19,20 @@ export interface RowGroupingOptions<T> {
18
19
  /** Cascading selection: a group selects its rows' descendants too, through `walk`. */
19
20
  cascade: () => boolean;
20
21
  walk: (rows: readonly T[], visit: (row: T) => void) => void;
22
+ /** Server grouping feature: groups from the data source, loaded on expand, selected by query. */
23
+ server?: ServerGroups<T>;
21
24
  }
22
25
  /**
23
26
  * The row grouping feature: groups the rows by the `group-by` columns, keeps which groups are
24
27
  * expanded (relative to `groups-expanded`, so new groups follow the default; changing the grouped
25
28
  * columns starts over), and teaches the grid's context, virtual layout and header menu about
26
- * group rows. Without the feature none of this is bundled.
29
+ * group rows. With server data whose source returns groups, the groups come from the server and
30
+ * each one's contents load when it expands. Without the feature none of this is bundled.
27
31
  */
28
32
  export declare function useRowGrouping<T>(opts: RowGroupingOptions<T>): {
29
33
  by: import("vue").ComputedRef<ColumnDef<T, import("..").RendererName>[]>;
30
34
  active: import("vue").ComputedRef<boolean>;
35
+ server: import("vue").ComputedRef<boolean>;
31
36
  groups: import("vue").ComputedRef<RowGroup<T>[]>;
32
37
  isGroup: (row: unknown) => boolean;
33
38
  isExpanded: (key: RowKey) => boolean;
@@ -47,4 +52,10 @@ export declare function useRowGrouping<T>(opts: RowGroupingOptions<T>): {
47
52
  clear: () => void;
48
53
  any: () => boolean;
49
54
  };
55
+ /** A group's rows (export, print): server groups' loaded ones. */
56
+ rowsIn: (group: RowGroup<T>) => T[];
57
+ /** Rows of the selected server groups. */
58
+ selectedGroupCount: import("vue").ComputedRef<number>;
59
+ allServerState: import("vue").ComputedRef<"some" | "none" | "all">;
60
+ toggleAllServer: () => void | undefined;
50
61
  };
@@ -0,0 +1,37 @@
1
+ import { type Ref } from 'vue';
2
+ import { type RowGroup } from '../core/grouping';
3
+ import type { ColumnDef, RowKey } from '../types';
4
+ import type { DataSourceResult, GroupPath, ServerGroup } from './useDataSource';
5
+ import type { SubRowEntry } from './useSubRows';
6
+ export interface ServerGroupsOptions<T> {
7
+ /** The top-level groups the data source returned for a grouped query; undefined: it sent rows. */
8
+ top: () => readonly ServerGroup[] | undefined;
9
+ /** A group's contents: its sub-groups or (at the last level) its rows. */
10
+ load: (path: GroupPath, signal: AbortSignal) => Promise<DataSourceResult<T>>;
11
+ /** Groups selected by query (`v-model:selected-groups`). */
12
+ selectedGroups: Ref<GroupPath[]>;
13
+ selected: Ref<RowKey[]>;
14
+ getKey: (row: T) => RowKey;
15
+ onError: (error: unknown) => void;
16
+ }
17
+ /**
18
+ * The server grouping feature: groups from the data source, each one's contents loaded when it
19
+ * expands (cached, with loading / error states), and groups selected by query, without their rows.
20
+ * The row grouping feature calls in here for groups that came from the server.
21
+ */
22
+ export declare function useServerGroups<T>(opts: ServerGroupsOptions<T>): {
23
+ groups: (by: readonly ColumnDef<T>[]) => RowGroup<T>[] | undefined;
24
+ children: (group: RowGroup<T>) => T[] | undefined;
25
+ state: (group: RowGroup<T>) => SubRowEntry | undefined;
26
+ ensure: (group: RowGroup<T>, by: readonly ColumnDef<T>[]) => void;
27
+ retry: (group: RowGroup<T>, by: readonly ColumnDef<T>[]) => void;
28
+ track: () => undefined;
29
+ locked: (row: any) => boolean;
30
+ checkState: (group: RowGroup<T>) => "all" | "some" | "none";
31
+ toggle: (group: RowGroup<T>) => void;
32
+ selectedCount: (each: (visit: (g: RowGroup<T>) => void) => void) => number;
33
+ allState: (top: readonly RowGroup<T>[]) => "all" | "some" | "none";
34
+ toggleAll: (top: readonly RowGroup<T>[]) => void;
35
+ rowsIn: (group: RowGroup<T>) => T[];
36
+ };
37
+ export type ServerGroups<T> = ReturnType<typeof useServerGroups<T>>;