@ishibashi0112/spreadsheet-grid-core 0.48.0 → 0.50.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 (119) hide show
  1. package/dist/controllers/autoHeightMeasurer.cjs +1 -1
  2. package/dist/controllers/autoHeightMeasurer.js +4 -2
  3. package/dist/controllers/clipboardController.cjs +1 -1
  4. package/dist/controllers/clipboardController.d.ts +2 -1
  5. package/dist/controllers/clipboardController.js +67 -61
  6. package/dist/controllers/columnAutosizeRunner.cjs +1 -1
  7. package/dist/controllers/columnAutosizeRunner.d.ts +3 -0
  8. package/dist/controllers/columnAutosizeRunner.js +40 -24
  9. package/dist/controllers/columnHeaderDragController.cjs +1 -1
  10. package/dist/controllers/columnHeaderDragController.js +5 -2
  11. package/dist/controllers/dateRolloverStore.cjs +1 -0
  12. package/dist/controllers/dateRolloverStore.d.ts +13 -0
  13. package/dist/controllers/dateRolloverStore.js +41 -0
  14. package/dist/controllers/editController.cjs +1 -1
  15. package/dist/controllers/editController.js +2 -2
  16. package/dist/controllers/fillHandleController.cjs +1 -0
  17. package/dist/controllers/fillHandleController.d.ts +87 -0
  18. package/dist/controllers/fillHandleController.js +346 -0
  19. package/dist/controllers/filterPopoverController.cjs +1 -1
  20. package/dist/controllers/filterPopoverController.js +55 -46
  21. package/dist/controllers/globalFilteredOrder.cjs +1 -1
  22. package/dist/controllers/globalFilteredOrder.js +5 -5
  23. package/dist/controllers/historyController.cjs +1 -1
  24. package/dist/controllers/historyController.d.ts +1 -0
  25. package/dist/controllers/historyController.js +8 -5
  26. package/dist/controllers/keyboardController.cjs +1 -1
  27. package/dist/controllers/keyboardController.js +2 -2
  28. package/dist/controllers/pointerInteractionsController.cjs +1 -1
  29. package/dist/controllers/pointerInteractionsController.d.ts +2 -0
  30. package/dist/controllers/pointerInteractionsController.js +136 -132
  31. package/dist/controllers/rowDragController.cjs +1 -1
  32. package/dist/controllers/rowDragController.d.ts +1 -0
  33. package/dist/controllers/rowDragController.js +104 -97
  34. package/dist/controllers/scrollSyncController.cjs +1 -1
  35. package/dist/controllers/scrollSyncController.d.ts +1 -0
  36. package/dist/controllers/scrollSyncController.js +32 -21
  37. package/dist/controllers/selectOptionsCollector.cjs +1 -1
  38. package/dist/controllers/selectOptionsCollector.js +5 -5
  39. package/dist/controllers/selectionAggregatesRunner.cjs +1 -0
  40. package/dist/controllers/selectionAggregatesRunner.d.ts +27 -0
  41. package/dist/controllers/selectionAggregatesRunner.js +65 -0
  42. package/dist/controllers/serverSideRowModel.cjs +1 -1
  43. package/dist/controllers/serverSideRowModel.js +75 -69
  44. package/dist/controllers/tooltipController.cjs +1 -1
  45. package/dist/controllers/tooltipController.js +44 -43
  46. package/dist/controllers/viewportSyncController.cjs +1 -1
  47. package/dist/controllers/viewportSyncController.d.ts +3 -2
  48. package/dist/controllers/viewportSyncController.js +6 -4
  49. package/dist/engine/columnCommands.cjs +1 -1
  50. package/dist/engine/columnCommands.js +1 -1
  51. package/dist/engine/columnLayout.cjs +1 -1
  52. package/dist/engine/columnLayout.js +1 -1
  53. package/dist/engine/createGridEngine.cjs +1 -1
  54. package/dist/engine/createGridEngine.d.ts +4 -0
  55. package/dist/engine/createGridEngine.js +58 -54
  56. package/dist/engine/gridApi.cjs +1 -1
  57. package/dist/engine/gridApi.d.ts +6 -0
  58. package/dist/engine/gridApi.js +130 -119
  59. package/dist/engine/rowPipeline.cjs +1 -1
  60. package/dist/engine/rowPipeline.d.ts +2 -0
  61. package/dist/engine/rowPipeline.js +67 -35
  62. package/dist/logic/aggregation.cjs +1 -1
  63. package/dist/logic/aggregation.d.ts +1 -0
  64. package/dist/logic/aggregation.js +16 -7
  65. package/dist/logic/autoScrollGeometry.cjs +1 -1
  66. package/dist/logic/autoScrollGeometry.d.ts +1 -0
  67. package/dist/logic/autoScrollGeometry.js +3 -3
  68. package/dist/logic/clearCells.cjs +1 -1
  69. package/dist/logic/clearCells.d.ts +1 -1
  70. package/dist/logic/clearCells.js +7 -7
  71. package/dist/logic/columnAutosize.cjs +1 -1
  72. package/dist/logic/columnAutosize.d.ts +6 -0
  73. package/dist/logic/columnAutosize.js +60 -39
  74. package/dist/logic/columnFlex.cjs +1 -1
  75. package/dist/logic/columnFlex.js +20 -22
  76. package/dist/logic/exportCsv.cjs +2 -2
  77. package/dist/logic/exportCsv.d.ts +5 -1
  78. package/dist/logic/exportCsv.js +16 -15
  79. package/dist/logic/exportData.cjs +1 -1
  80. package/dist/logic/exportData.d.ts +2 -1
  81. package/dist/logic/exportData.js +27 -21
  82. package/dist/logic/fillHandle.cjs +1 -0
  83. package/dist/logic/fillHandle.d.ts +69 -0
  84. package/dist/logic/fillHandle.js +254 -0
  85. package/dist/logic/fillSeries.cjs +1 -0
  86. package/dist/logic/fillSeries.d.ts +11 -0
  87. package/dist/logic/fillSeries.js +239 -0
  88. package/dist/logic/filtering.cjs +1 -1
  89. package/dist/logic/filtering.d.ts +2 -0
  90. package/dist/logic/filtering.js +50 -37
  91. package/dist/logic/gridState.cjs +1 -1
  92. package/dist/logic/gridState.d.ts +1 -0
  93. package/dist/logic/gridState.js +2 -2
  94. package/dist/logic/imeInput.cjs +1 -1
  95. package/dist/logic/imeInput.js +2 -2
  96. package/dist/logic/labelRows.cjs +1 -1
  97. package/dist/logic/labelRows.js +1 -1
  98. package/dist/logic/selectOptions.cjs +1 -1
  99. package/dist/logic/selectOptions.js +1 -1
  100. package/dist/logic/selectionAggregates.cjs +1 -0
  101. package/dist/logic/selectionAggregates.d.ts +25 -0
  102. package/dist/logic/selectionAggregates.js +74 -0
  103. package/dist/logic/sorting.cjs +1 -1
  104. package/dist/logic/sorting.d.ts +18 -0
  105. package/dist/logic/sorting.js +133 -64
  106. package/dist/logic/totalRow.cjs +1 -0
  107. package/dist/logic/totalRow.d.ts +25 -0
  108. package/dist/logic/totalRow.js +90 -0
  109. package/dist/model/gridReducer.cjs +1 -1
  110. package/dist/model/gridReducer.js +73 -68
  111. package/dist/model/gridTypes.core.d.ts +204 -17
  112. package/dist/model/gridTypes.unbound.d.ts +4 -0
  113. package/dist/utils/clipboard.cjs +1 -1
  114. package/dist/utils/clipboard.d.ts +1 -1
  115. package/dist/utils/clipboard.js +9 -9
  116. package/dist/utils/permissions.cjs +1 -1
  117. package/dist/utils/permissions.d.ts +6 -2
  118. package/dist/utils/permissions.js +8 -2
  119. package/package.json +1 -1
@@ -1,29 +1,61 @@
1
1
  import { getCellValue as e } from "../utils/permissions.js";
2
- import { sortOrder as t } from "../logic/sorting.js";
3
- import { buildGroupTree as n, flattenGroupTree as r, groupIndexOfOrderValue as i, groupRowKey as a, isGroupOrderValue as o } from "../logic/grouping.js";
4
- import { isIdentityOrder as s, isRowDragOperable as c } from "../logic/rowReorder.js";
5
- import { buildLabelDisplay as l, createLabelFreeOrder as u, createLabelRowModel as d, isSameOrder as f, resolveLabelRowLayout as p } from "../logic/labelRows.js";
6
- import { coerceNumberFilterCellValue as m, columnFilterUsesNumericKey as h, createSourceOrder as g, filterOrderByColumns as _ } from "../logic/filtering.js";
7
- import { createMemo as v } from "./memo.js";
8
- import { buildServerSideQuery as y, serializeServerSideQuery as b } from "../logic/serverSideQuery.js";
2
+ import { decorateSortKeys as t, diffSortKeys as n, repositionSortedPositions as r, sortPositionsByKeys as i, undecorateSortedPositions as a } from "../logic/sorting.js";
3
+ import { buildGroupTree as o, flattenGroupTree as s, groupIndexOfOrderValue as c, groupRowKey as l, isGroupOrderValue as u } from "../logic/grouping.js";
4
+ import { isIdentityOrder as d, isRowDragOperable as f } from "../logic/rowReorder.js";
5
+ import { buildLabelDisplay as p, createLabelFreeOrder as m, createLabelRowModel as h, isSameOrder as g, resolveLabelRowLayout as _ } from "../logic/labelRows.js";
6
+ import { coerceNumberFilterCellValue as v, columnFilterUsesNumericKey as y, createSourceOrder as b, filterOrderByColumns as x } from "../logic/filtering.js";
7
+ import { createMemo as S } from "./memo.js";
8
+ import { buildServerSideQuery as C, serializeServerSideQuery as w } from "../logic/serverSideQuery.js";
9
9
  //#region src/engine/rowPipeline.ts
10
- var x = {}, S = {}, C = [], w = "\0", T = () => {
11
- let T = v((e) => g(e)), E = v((e, t) => t ? p(e, t) : null), D = v((e, t) => u(e, t)), O = v((e, t) => {
10
+ var T = {}, E = {}, D = [], O = "\0", k = 1024, A = () => {
11
+ let A = S((e) => b(e)), j = S((e, t) => t ? _(e, t) : null), M = S((e, t) => m(e, t)), N = S((e, t) => {
12
12
  let n = [];
13
- for (let r of e) h(t[r.key]) && n.push(r.key);
14
- return n.join(w);
15
- }), k = v((t, n, r) => {
13
+ for (let r of e) y(t[r.key]) && n.push(r.key);
14
+ return n.join(O);
15
+ }), P = S((t, n, r) => {
16
16
  let i = /* @__PURE__ */ new Map();
17
17
  if (r.length === 0) return i;
18
- let a = new Set(r.split(w)), o = t.length;
18
+ let a = new Set(r.split(O)), o = t.length;
19
19
  for (let r of n) {
20
20
  if (!a.has(r.key)) continue;
21
21
  let n = new Float64Array(o);
22
- for (let i = 0; i < o; i += 1) n[i] = m(e(t[i], r));
22
+ for (let i = 0; i < o; i += 1) n[i] = v(e(t[i], r));
23
23
  i.set(r.key, n);
24
24
  }
25
25
  return i;
26
- }), A = v((e, t, n, r, i) => _(e, t, n, r, i)), j = v((e, n, r, i) => t(e, n, r, i)), M = v((e, t, n) => e && s(t, n)), N = v((e, t, n) => e && f(t, n)), P = v((e, t, r, i, a) => e ? n(t, r, i, a) : null), F = v((e, t) => e ? r(e, t) : null), I = v((e, t, n, r, i, a, o) => e && o ? l({
26
+ }), F = null, I = (e, t, n, r, i, a) => {
27
+ let o = F;
28
+ if (o !== null && o.rows === e && o.globalFilteredOrder === t && o.columns === n && o.columnFilters === r && o.numericKeys === i && o.relativeDateKey === a) return o.result;
29
+ let s = x(e, t, n, r, i);
30
+ return o !== null && s !== o.result && g(s, o.result) && (s = o.result), F = {
31
+ rows: e,
32
+ globalFilteredOrder: t,
33
+ columns: n,
34
+ columnFilters: r,
35
+ numericKeys: i,
36
+ relativeDateKey: a,
37
+ result: s
38
+ }, s;
39
+ }, L = null, R = (e, o, s, c) => {
40
+ let l = L;
41
+ if (l !== null && l.rows === e && l.input === o && l.columns === s && l.sort === c) return l.result;
42
+ let u = t(e, o, s, c);
43
+ if (u === null) return L = null, o;
44
+ let d = null, f = null;
45
+ if (l !== null && l.input === o) {
46
+ let e = n(l.keys, u, k);
47
+ e !== null && e.length === 0 ? (d = l.positions, f = l.result) : e !== null && (d = r(l.positions, e, u, o));
48
+ }
49
+ return d === null && (d = i(u, o)), f === null && (f = a(o, d)), L = {
50
+ rows: e,
51
+ input: o,
52
+ columns: s,
53
+ sort: c,
54
+ keys: u,
55
+ positions: d,
56
+ result: f
57
+ }, f;
58
+ }, z = S((e, t, n) => e && d(t, n)), B = S((e, t, n) => e && g(t, n)), V = S((e, t, n, r, i) => e ? o(t, n, r, i) : null), H = S((e, t) => e ? s(e, t) : null), U = S((e, t, n, r, i, a, o) => e && o ? p({
27
59
  rows: t,
28
60
  order: n,
29
61
  layout: e,
@@ -31,8 +63,8 @@ var x = {}, S = {}, C = [], w = "\0", T = () => {
31
63
  keepEmptySections: i,
32
64
  sortActive: a,
33
65
  getLabel: o
34
- }) : null), L = v((e, t, n, r, s) => {
35
- if (t) return d(t, r, s);
66
+ }) : null), W = S((e, t, n, r, i) => {
67
+ if (t) return h(t, r, i);
36
68
  if (e) {
37
69
  let { displayOrder: t, groups: n } = e;
38
70
  return {
@@ -43,12 +75,12 @@ var x = {}, S = {}, C = [], w = "\0", T = () => {
43
75
  return n >= 0 ? n : void 0;
44
76
  },
45
77
  getRowKey: (e) => {
46
- let c = t[e];
47
- return o(c) ? a(n[i(c)]) : s(r[c], c);
78
+ let a = t[e];
79
+ return u(a) ? l(n[c(a)]) : i(r[a], a);
48
80
  },
49
81
  getGroupRow: (e) => {
50
82
  let r = t[e];
51
- return o(r) ? n[i(r)] : void 0;
83
+ return u(r) ? n[c(r)] : void 0;
52
84
  }
53
85
  };
54
86
  }
@@ -56,41 +88,41 @@ var x = {}, S = {}, C = [], w = "\0", T = () => {
56
88
  getRowCount: () => n.length,
57
89
  getRow: (e) => r[n[e]],
58
90
  getSourceIndex: (e) => n[e],
59
- getRowKey: (e) => s(r[n[e]], n[e])
91
+ getRowKey: (e) => i(r[n[e]], n[e])
60
92
  };
61
- }), R = v((e, t, n, r, i, a, o) => e ? y({
93
+ }), G = S((e, t, n, r, i, a, o) => e ? C({
62
94
  globalText: t ? n : "",
63
- columnFilters: r ? i : S,
64
- sort: a ? o : C
65
- }) : x), z = v((e, t) => e ? b(t) : ""), B = v((e, t) => ({
95
+ columnFilters: r ? i : E,
96
+ sort: a ? o : D
97
+ }) : T), K = S((e, t, n) => e ? n === "" ? w(t) : `${w(t)}${O}${n}` : ""), q = S((e, t) => ({
66
98
  query: e,
67
99
  queryKey: t
68
100
  }));
69
101
  return {
70
- resolveLabelRowLayout: (e, t) => E(e, t),
71
- resolveBaseOrder: (e, t) => t ? D(t, e) : T(e),
102
+ resolveLabelRowLayout: (e, t) => j(e, t),
103
+ resolveBaseOrder: (e, t) => t ? M(t, e) : A(e),
72
104
  resolveOrder: (e) => {
73
- let { rows: t, filterSortColumns: n, globalFilteredOrder: r, rowDragAvailable: i, labelLayout: a } = e, o = e.manualFiltering ? S : e.columnFilters, s = e.manualSorting ? C : e.sort, l = O(n, o), u = k(t, n, l), d = A(t, r, n, o, u), f = j(t, d, n, s), p = a ? N(i, f, D(a, t.length)) : M(i, f, t.length);
105
+ let { rows: t, filterSortColumns: n, globalFilteredOrder: r, rowDragAvailable: i, labelLayout: a } = e, o = e.manualFiltering ? E : e.columnFilters, s = e.manualSorting ? D : e.sort, c = N(n, o), l = P(t, n, c), u = I(t, r, n, o, l, e.relativeDateKey ?? ""), d = R(t, u, n, s), p = a ? B(i, d, M(a, t.length)) : z(i, d, t.length);
74
106
  return {
75
- order: f,
107
+ order: d,
76
108
  orderIsIdentity: p,
77
- rowDragOperable: c(i, p)
109
+ rowDragOperable: f(i, p)
78
110
  };
79
111
  },
80
112
  resolveClientSideRowModel: (e) => {
81
- let { rows: t, order: n, rowGroupingActive: r, groupColumns: i, aggColumns: a, collapsedGroupKeys: o, rowKeyGetter: s, labelLayout: c, labelSortMode: l = "section", keepEmptySections: u = !1, sortActive: d = !1, getLabel: f } = e, p = P(r, t, n, i, a), m = F(p, o), h = I(r ? null : c ?? null, t, n, l, u, d, f);
113
+ let { rows: t, order: n, rowGroupingActive: r, groupColumns: i, aggColumns: a, collapsedGroupKeys: o, rowKeyGetter: s, labelLayout: c, labelSortMode: l = "section", keepEmptySections: u = !1, sortActive: d = !1, getLabel: f } = e, p = V(r, t, n, i, a), m = H(p, o), h = U(r ? null : c ?? null, t, n, l, u, d, f);
82
114
  return {
83
115
  groupTree: p,
84
116
  groupedDisplay: m,
85
117
  labelDisplay: h,
86
- rowModel: L(m, h, n, t, s)
118
+ rowModel: W(m, h, n, t, s)
87
119
  };
88
120
  },
89
121
  resolveServerSideQuery: (e) => {
90
- let { isServerSide: t, globalFilterEnabled: n, globalText: r, columnFilterEnabled: i, columnFilters: a, sortingEnabled: o, sort: s } = e, c = R(t, n, r, i, a, o, s);
91
- return B(c, z(t, c));
122
+ let { isServerSide: t, globalFilterEnabled: n, globalText: r, columnFilterEnabled: i, columnFilters: a, sortingEnabled: o, sort: s } = e, c = G(t, n, r, i, a, o, s);
123
+ return q(c, K(t, c, e.relativeDateKey ?? ""));
92
124
  }
93
125
  };
94
126
  };
95
127
  //#endregion
96
- export { T as createRowPipelineResolver };
128
+ export { A as createRowPipelineResolver };
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=[`sum`,`min`,`max`,`avg`,`count`],t=t=>typeof t==`string`&&e.includes(t),n=()=>({count:0,numericCount:0,sum:0,min:1/0,max:-1/0}),r=(e,t)=>{if(e.count+=1,t==null||t===``)return;let n=Number(t);Number.isFinite(n)&&(e.numericCount+=1,e.sum+=n,n<e.min&&(e.min=n),n>e.max&&(e.max=n))},i=(e,t)=>{switch(e){case`count`:return t.count;case`sum`:return t.numericCount>0?t.sum:void 0;case`avg`:return t.numericCount>0?t.sum/t.numericCount:void 0;case`min`:return t.numericCount>0?t.min:void 0;case`max`:return t.numericCount>0?t.max:void 0}};exports.BUILTIN_AGG_FUNC_NAMES=e,exports.accumulateBuiltinAgg=r,exports.createBuiltinAggAccumulator=n,exports.finalizeBuiltinAgg=i,exports.isBuiltinAggFuncName=t;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=[`sum`,`min`,`max`,`avg`,`count`],t=t=>typeof t==`string`&&e.includes(t),n=e=>{let t;if(typeof e==`number`)t=e;else if(typeof e==`string`){if(e.trim()===``)return;t=Number(e)}else if(typeof e==`bigint`)t=Number(e);else return;return Number.isFinite(t)?t:void 0},r=()=>({count:0,numericCount:0,sum:0,min:1/0,max:-1/0}),i=(e,t)=>{e.count+=1;let r=n(t);r!==void 0&&(e.numericCount+=1,e.sum+=r,r<e.min&&(e.min=r),r>e.max&&(e.max=r))},a=(e,t)=>{switch(e){case`count`:return t.count;case`sum`:return t.numericCount>0?t.sum:void 0;case`avg`:return t.numericCount>0?t.sum/t.numericCount:void 0;case`min`:return t.numericCount>0?t.min:void 0;case`max`:return t.numericCount>0?t.max:void 0}};exports.BUILTIN_AGG_FUNC_NAMES=e,exports.accumulateBuiltinAgg=i,exports.createBuiltinAggAccumulator=r,exports.finalizeBuiltinAgg=a,exports.isBuiltinAggFuncName=t,exports.toAggregatableNumber=n;
@@ -1,6 +1,7 @@
1
1
  import type { GridAggFuncName } from '../model/gridTypes.unbound.js';
2
2
  export declare const BUILTIN_AGG_FUNC_NAMES: readonly GridAggFuncName[];
3
3
  export declare const isBuiltinAggFuncName: (value: unknown) => value is GridAggFuncName;
4
+ export declare const toAggregatableNumber: (value: unknown) => number | undefined;
4
5
  export type BuiltinAggAccumulator = {
5
6
  count: number;
6
7
  numericCount: number;
@@ -5,17 +5,26 @@ var e = [
5
5
  "max",
6
6
  "avg",
7
7
  "count"
8
- ], t = (t) => typeof t == "string" && e.includes(t), n = () => ({
8
+ ], t = (t) => typeof t == "string" && e.includes(t), n = (e) => {
9
+ let t;
10
+ if (typeof e == "number") t = e;
11
+ else if (typeof e == "string") {
12
+ if (e.trim() === "") return;
13
+ t = Number(e);
14
+ } else if (typeof e == "bigint") t = Number(e);
15
+ else return;
16
+ return Number.isFinite(t) ? t : void 0;
17
+ }, r = () => ({
9
18
  count: 0,
10
19
  numericCount: 0,
11
20
  sum: 0,
12
21
  min: Infinity,
13
22
  max: -Infinity
14
- }), r = (e, t) => {
15
- if (e.count += 1, t == null || t === "") return;
16
- let n = Number(t);
17
- Number.isFinite(n) && (e.numericCount += 1, e.sum += n, n < e.min && (e.min = n), n > e.max && (e.max = n));
18
- }, i = (e, t) => {
23
+ }), i = (e, t) => {
24
+ e.count += 1;
25
+ let r = n(t);
26
+ r !== void 0 && (e.numericCount += 1, e.sum += r, r < e.min && (e.min = r), r > e.max && (e.max = r));
27
+ }, a = (e, t) => {
19
28
  switch (e) {
20
29
  case "count": return t.count;
21
30
  case "sum": return t.numericCount > 0 ? t.sum : void 0;
@@ -25,4 +34,4 @@ var e = [
25
34
  }
26
35
  };
27
36
  //#endregion
28
- export { e as BUILTIN_AGG_FUNC_NAMES, r as accumulateBuiltinAgg, n as createBuiltinAggAccumulator, i as finalizeBuiltinAgg, t as isBuiltinAggFuncName };
37
+ export { e as BUILTIN_AGG_FUNC_NAMES, i as accumulateBuiltinAgg, r as createBuiltinAggAccumulator, a as finalizeBuiltinAgg, t as isBuiltinAggFuncName, n as toAggregatableNumber };
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=24,t=18,n=6,r=({rectLeft:e,rectTop:t,clientLeft:n,clientTop:r,clientWidth:i,clientHeight:a})=>{let o=e+n,s=t+r;return{left:o,top:s,right:o+i,bottom:s+a}},i=(e,t,n,r)=>e<t+r?-1:+(e>n-r),a=(e,t,n,r)=>{if(t===0)return e;let i=Math.max(r,0),a=e+t*n;return a<0?0:a>i?i:a},o=(e,t,n)=>{let r=t.x-e.x,i=t.y-e.y;return r*r+i*i>=n*n};exports.AUTO_SCROLL_ACTIVATION_DISTANCE=n,exports.AUTO_SCROLL_EDGE_THRESHOLD=e,exports.AUTO_SCROLL_STEP=t,exports.computeNextScrollPosition=a,exports.hasPointerLeftActivationRadius=o,exports.resolveAutoScrollAxisDirection=i,exports.resolveScrollContentBox=r;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=24,t=18,n=6,r=({rectLeft:e,rectTop:t,clientLeft:n,clientTop:r,clientWidth:i,clientHeight:a})=>{let o=e+n,s=t+r;return{left:o,top:s,right:o+i,bottom:s+a}},i=(e,t,n)=>n>0?Math.min(e,t-n-1):e,a=(e,t,n,r)=>e<t+r?-1:+(e>n-r),o=(e,t,n,r)=>{if(t===0)return e;let i=Math.max(r,0),a=e+t*n;return a<0?0:a>i?i:a},s=(e,t,n)=>{let r=t.x-e.x,i=t.y-e.y;return r*r+i*i>=n*n};exports.AUTO_SCROLL_ACTIVATION_DISTANCE=n,exports.AUTO_SCROLL_EDGE_THRESHOLD=e,exports.AUTO_SCROLL_STEP=t,exports.clampClientYAboveFooter=i,exports.computeNextScrollPosition=o,exports.hasPointerLeftActivationRadius=s,exports.resolveAutoScrollAxisDirection=a,exports.resolveScrollContentBox=r;
@@ -16,6 +16,7 @@ export declare const resolveScrollContentBox: ({ rectLeft, rectTop, clientLeft,
16
16
  clientWidth: number;
17
17
  clientHeight: number;
18
18
  }) => AutoScrollContentBox;
19
+ export declare const clampClientYAboveFooter: (clientY: number, contentBottom: number, footerHeight: number) => number;
19
20
  export declare const resolveAutoScrollAxisDirection: (pointer: number, start: number, end: number, edgeThreshold: number) => AutoScrollAxisDirection;
20
21
  export declare const computeNextScrollPosition: (current: number, direction: AutoScrollAxisDirection, step: number, max: number) => number;
21
22
  export declare const hasPointerLeftActivationRadius: (origin: {
@@ -7,13 +7,13 @@ var e = 24, t = 18, n = 6, r = ({ rectLeft: e, rectTop: t, clientLeft: n, client
7
7
  right: o + i,
8
8
  bottom: s + a
9
9
  };
10
- }, i = (e, t, n, r) => e < t + r ? -1 : +(e > n - r), a = (e, t, n, r) => {
10
+ }, i = (e, t, n) => n > 0 ? Math.min(e, t - n - 1) : e, a = (e, t, n, r) => e < t + r ? -1 : +(e > n - r), o = (e, t, n, r) => {
11
11
  if (t === 0) return e;
12
12
  let i = Math.max(r, 0), a = e + t * n;
13
13
  return a < 0 ? 0 : a > i ? i : a;
14
- }, o = (e, t, n) => {
14
+ }, s = (e, t, n) => {
15
15
  let r = t.x - e.x, i = t.y - e.y;
16
16
  return r * r + i * i >= n * n;
17
17
  };
18
18
  //#endregion
19
- export { n as AUTO_SCROLL_ACTIVATION_DISTANCE, e as AUTO_SCROLL_EDGE_THRESHOLD, t as AUTO_SCROLL_STEP, a as computeNextScrollPosition, o as hasPointerLeftActivationRadius, i as resolveAutoScrollAxisDirection, r as resolveScrollContentBox };
19
+ export { n as AUTO_SCROLL_ACTIVATION_DISTANCE, e as AUTO_SCROLL_EDGE_THRESHOLD, t as AUTO_SCROLL_STEP, i as clampClientYAboveFooter, o as computeNextScrollPosition, s as hasPointerLeftActivationRadius, a as resolveAutoScrollAxisDirection, r as resolveScrollContentBox };
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../utils/permissions.cjs"),t=require("./geometry.cjs"),n=require("../model/gridSelectors.cjs"),r=require("./editorValues.cjs"),i=require("./validation.cjs");var a=(e,r,i,a)=>{if(i===0||a===0)return null;let o=i-1,s=a-1;if(e?.type===`cell`){let r=n.normalizeCellRange(e.range);return{startRow:t.clamp(r.start.row,0,o),endRow:t.clamp(r.end.row,0,o),startCol:t.clamp(r.start.col,0,s),endCol:t.clamp(r.end.col,0,s)}}if(e?.type===`row`){let r=n.normalizeRowRange(e.startRow,e.endRow);return{startRow:t.clamp(r.startRow,0,o),endRow:t.clamp(r.endRow,0,o),startCol:0,endCol:s}}if(e?.type===`col`){let r=n.normalizeColumnRange(e.startCol,e.endCol);return{startRow:0,endRow:o,startCol:t.clamp(r.startCol,0,s),endCol:t.clamp(r.endCol,0,s)}}return r?r.row>o||r.col>s?null:{startRow:r.row,endRow:r.row,startCol:r.col,endCol:r.col}:null},o=({rows:t,resolveSourceIndex:n,columns:o,selection:s,activeCell:c,viewRowCount:l,canWriteCell:u})=>{let d=a(s,c,l,o.length);if(!d)return{nextRows:t,changed:!1};let f=[...t],p=!1;for(let t=d.startRow;t<=d.endRow;t+=1){let a=n(t);if(a===void 0)continue;let s=f[a];if(!s)continue;let c=s,l=!1;for(let t=d.startCol;t<=d.endCol;t+=1){let n=o[t];if(!n||!u(a,t,s,n))continue;let d=r.resolveCellParser(n)(``,s);Object.is(e.getCellValue(c,n),d)||i.decideCellWrite(n,s,d).action!==`reject`&&(c=e.setCellValue(c,n,d),l=!0)}l&&(f[a]=c,p=!0)}return p?{nextRows:f,changed:p}:{nextRows:t,changed:!1}},s=({getRow:t,columns:n,selection:o,activeCell:s,viewRowCount:c,canWriteCell:l})=>{let u=a(o,s,c,n.length);if(!u)return[];let d=[];for(let a=u.startRow;a<=u.endRow;a+=1){let o=t(a);if(o)for(let t=u.startCol;t<=u.endCol;t+=1){let s=n[t];if(!s||!l(a,t,o,s))continue;let c=r.resolveCellParser(s)(``,o);Object.is(e.getCellValue(o,s),c)||i.decideCellWrite(s,o,c).action!==`reject`&&d.push({viewIndex:a,column:s,value:c})}}return d};exports.buildClearCellEdits=s,exports.clearCellsInSelection=o,exports.resolveClearTarget=a;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../utils/permissions.cjs"),t=require("./geometry.cjs"),n=require("../model/gridSelectors.cjs"),r=require("./editorValues.cjs"),i=require("./validation.cjs");var a=(e,r,i,a)=>{if(i===0||a===0)return null;let o=i-1,s=a-1;if(e?.type===`cell`){let r=n.normalizeCellRange(e.range);return{startRow:t.clamp(r.start.row,0,o),endRow:t.clamp(r.end.row,0,o),startCol:t.clamp(r.start.col,0,s),endCol:t.clamp(r.end.col,0,s)}}if(e?.type===`row`){let r=n.normalizeRowRange(e.startRow,e.endRow);return{startRow:t.clamp(r.startRow,0,o),endRow:t.clamp(r.endRow,0,o),startCol:0,endCol:s}}if(e?.type===`col`){let r=n.normalizeColumnRange(e.startCol,e.endCol);return{startRow:0,endRow:o,startCol:t.clamp(r.startCol,0,s),endCol:t.clamp(r.endCol,0,s)}}return r?r.row>o||r.col>s?null:{startRow:r.row,endRow:r.row,startCol:r.col,endCol:r.col}:null},o=({rows:t,resolveSourceIndex:n,columns:o,selection:s,activeCell:c,viewRowCount:l,canWriteCell:u})=>{let d=a(s,c,l,o.length);if(!d)return{nextRows:t,changed:!1};let f=[...t],p=!1;for(let t=d.startRow;t<=d.endRow;t+=1){let a=n(t);if(a===void 0)continue;let s=f[a];if(!s)continue;let c=s,l=!1;for(let n=d.startCol;n<=d.endCol;n+=1){let d=o[n];if(!d||!u(a,n,s,d,t))continue;let f=r.resolveCellParser(d)(``,s),p=e.getCellValue(c,d);Object.is(p,f)||p==null&&f==null||i.decideCellWrite(d,s,f).action!==`reject`&&(c=e.setCellValue(c,d,f),l=!0)}l&&(f[a]=c,p=!0)}return p?{nextRows:f,changed:p}:{nextRows:t,changed:!1}},s=({getRow:t,columns:n,selection:o,activeCell:s,viewRowCount:c,canWriteCell:l})=>{let u=a(o,s,c,n.length);if(!u)return[];let d=[];for(let a=u.startRow;a<=u.endRow;a+=1){let o=t(a);if(o)for(let t=u.startCol;t<=u.endCol;t+=1){let s=n[t];if(!s||!l(a,t,o,s))continue;let c=r.resolveCellParser(s)(``,o),u=e.getCellValue(o,s);Object.is(u,c)||u==null&&c==null||i.decideCellWrite(s,o,c).action!==`reject`&&d.push({viewIndex:a,column:s,value:c})}}return d};exports.buildClearCellEdits=s,exports.clearCellsInSelection=o,exports.resolveClearTarget=a;
@@ -14,7 +14,7 @@ type ClearCellsArgs<T extends object> = {
14
14
  selection: GridSelection;
15
15
  activeCell: CellCoord | null;
16
16
  viewRowCount: number;
17
- canWriteCell: (originalRowIndex: number, colIndex: number, row: T, column: GridColumn<T>) => boolean;
17
+ canWriteCell: (originalRowIndex: number, colIndex: number, row: T, column: GridColumn<T>, viewIndex: number) => boolean;
18
18
  };
19
19
  export declare const clearCellsInSelection: <T extends object>({ rows, resolveSourceIndex, columns, selection, activeCell, viewRowCount, canWriteCell, }: ClearCellsArgs<T>) => {
20
20
  nextRows: T[];
@@ -53,11 +53,11 @@ var c = (e, t, o, s) => {
53
53
  let c = p[a];
54
54
  if (!c) continue;
55
55
  let l = c, u = !1;
56
- for (let n = f.startCol; n <= f.endCol; n += 1) {
57
- let r = i[n];
58
- if (!r || !d(a, n, c, r)) continue;
59
- let f = o(r)("", c);
60
- Object.is(e(l, r), f) || s(r, c, f).action !== "reject" && (l = t(l, r, f), u = !0);
56
+ for (let r = f.startCol; r <= f.endCol; r += 1) {
57
+ let f = i[r];
58
+ if (!f || !d(a, r, c, f, n)) continue;
59
+ let p = o(f)("", c), m = e(l, f);
60
+ Object.is(m, p) || m == null && p == null || s(f, c, p).action !== "reject" && (l = t(l, f, p), u = !0);
61
61
  }
62
62
  u && (p[a] = l, m = !0);
63
63
  }
@@ -77,8 +77,8 @@ var c = (e, t, o, s) => {
77
77
  if (i) for (let t = u.startCol; t <= u.endCol; t += 1) {
78
78
  let a = n[t];
79
79
  if (!a || !l(r, t, i, a)) continue;
80
- let c = o(a)("", i);
81
- Object.is(e(i, a), c) || s(a, i, c).action !== "reject" && d.push({
80
+ let c = o(a)("", i), u = e(i, a);
81
+ Object.is(u, c) || u == null && c == null || s(a, i, c).action !== "reject" && d.push({
82
82
  viewIndex: r,
83
83
  column: a,
84
84
  value: c
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../utils/permissions.cjs");var t=21,n=4,r=41,i=13,a=600,o=60,s=16,c=null,l=()=>c||(typeof document>`u`?null:(c=document.createElement(`canvas`).getContext(`2d`),c)),u=`system-ui, sans-serif`,d=e=>{let t=u,n=13,r=`400`;if(e&&typeof window<`u`){let i=window.getComputedStyle(e);i.fontFamily&&(t=i.fontFamily);let a=Number.parseFloat(i.fontSize);Number.isFinite(a)&&a>0&&(n=a),i.fontWeight&&(r=i.fontWeight)}return{cellFont:`${r} ${n}px ${t}`,headerFont:`${a} ${i}px ${t}`}},f=(e,t,n)=>Math.min(Math.max(e,t),n),p=e=>e>=4352&&e<=4447||e>=11904&&e<=12350||e>=12353&&e<=13311||e>=13312&&e<=19903||e>=19968&&e<=40959||e>=40960&&e<=42191||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65072&&e<=65103||e>=65280&&e<=65376||e>=65504&&e<=65510||e>=127744&&e<=129791||e>=131072&&e<=262141,m=e=>{let t=0;for(let n of e){let e=n.codePointAt(0)??0;t+=p(e)?2:1}return t},h=(t,n)=>{let r=e.getCellValue(t,n);return n.valueFormatter?n.valueFormatter({value:r,row:t,column:n}):String(r??``)},g=e=>{if(!e||typeof document>`u`)return null;let t=document.createElement(`div`);return t.setAttribute(`aria-hidden`,`true`),t.style.cssText=`position:absolute;top:-99999px;left:-99999px;visibility:hidden;pointer-events:none;width:auto;height:auto;contain:layout style;`,e.appendChild(t),t},_=e=>{let t=document.createElement(`div`);return t.className=`ssg-body-cell`,t.style.cssText=`display:inline-block;position:static;top:auto;left:auto;width:auto;height:auto;white-space:nowrap;overflow:visible;`,t.textContent=e,t},v=e=>e.suppressAutoSize===!0||e.autoHeight===!0;function y(i){let a=i.map(()=>[]),c=i.map(()=>[]),u=i.map(()=>1/0),p=i.map(()=>0);return{collect:t=>{for(let n=0;n<i.length;n+=1){if(v(i[n]))continue;let r=i[n].estimateCellWidth;if(r){let e=r(t,i[n]);e>p[n]&&(p[n]=e);continue}let o=String(e.getCellValue(t,i[n])??``);if(o===``)continue;let l=a[n],d=c[n];if(l.length===s&&2*o.length<=u[n])continue;let f=m(o);if(l.length<s){if(l.push(t),d.push(f),l.length===s){let e=d[0];for(let t=1;t<s;t+=1)d[t]<e&&(e=d[t]);u[n]=e}continue}if(f<=u[n])continue;let h=0;for(let e=1;e<s;e+=1)d[e]<d[h]&&(h=e);l[h]=t,d[h]=f;let g=d[0];for(let e=1;e<s;e+=1)d[e]<g&&(g=d[e]);u[n]=g}},finalize:({gridRoot:e,currentWidths:s})=>{let c=l();if(!c||i.length===0)return{};let{cellFont:u,headerFont:m}=d(e),y={},b=g(e);try{let e=null;if(b){let t=[];for(let e=0;e<i.length;e+=1){if(v(i[e])){t.push([]);continue}if(i[e].estimateCellWidth){t.push([]);continue}let n=a[e],r=[];for(let t=0;t<n.length;t+=1){let a=h(n[t],i[e]);if(a===``)continue;let o=_(a);b.appendChild(o),r.push(o)}t.push(r)}e=t.map(e=>{let t=0;for(let n=0;n<e.length;n+=1){let r=e[n].offsetWidth;r>t&&(t=r)}return t})}for(let l=0;l<i.length;l+=1){let d=i[l];if(v(d))continue;c.font=m;let g=d.title||d.key,_=c.measureText(g).width+n+r,b;if(d.estimateCellWidth)b=p[l]>0?p[l]+t:0;else if(e)b=e[l];else{c.font=u;let e=0,r=a[l];for(let t=0;t<r.length;t+=1){let n=h(r[t],d);if(n===``)continue;let i=c.measureText(n).width;i>e&&(e=i)}b=e>0?e+n+t:0}let x=Math.ceil(f(Math.max(_,b),d.minWidth??o,d.maxWidth??1/0));s[d.key]!==x&&(y[d.key]=x)}}finally{b&&b.parentNode&&b.parentNode.removeChild(b)}return y}}}function b(){return l()!==null}function x({columns:e,getRow:t,viewRowCount:n,gridRoot:r,currentWidths:i}){if(e.length===0||l()===null)return{};let a=y(e);for(let e=0;e<n;e+=1){let n=t(e);n&&a.collect(n)}return a.finalize({gridRoot:r,currentWidths:i})}exports.canMeasureAutosize=b,exports.computeAutosizedColumnWidths=x,exports.createColumnWidthAccumulator=y;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../utils/permissions.cjs");var t=21,n=4,r=41,i=13,a=600,o=60,s=16,c=null,l=()=>c||(typeof document>`u`?null:(c=document.createElement(`canvas`).getContext(`2d`),c)),u=`system-ui, sans-serif`,d=e=>{let t=u,n=13,r=`400`;if(e&&typeof window<`u`){let i=window.getComputedStyle(e);i.fontFamily&&(t=i.fontFamily);let a=Number.parseFloat(i.fontSize);Number.isFinite(a)&&a>0&&(n=a),i.fontWeight&&(r=i.fontWeight)}return{cellFont:`${r} ${n}px ${t}`,headerFont:`${a} ${i}px ${t}`}},f=(e,t,n)=>Math.min(Math.max(e,t),n),p=e=>e>=4352&&e<=4447||e>=11904&&e<=12350||e>=12353&&e<=13311||e>=13312&&e<=19903||e>=19968&&e<=40959||e>=40960&&e<=42191||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65072&&e<=65103||e>=65280&&e<=65376||e>=65504&&e<=65510||e>=127744&&e<=129791||e>=131072&&e<=262141,m=e=>{let t=0;for(let n of e){let e=n.codePointAt(0)??0;t+=p(e)?2:1}return t},h=(t,n)=>{let r=e.getCellValue(t,n);return n.valueFormatter?n.valueFormatter({value:r,row:t,column:n}):String(r??``)},g=e=>{if(!e||typeof document>`u`)return null;let t=document.createElement(`div`);return t.setAttribute(`aria-hidden`,`true`),t.style.cssText=`position:absolute;top:-99999px;left:-99999px;visibility:hidden;pointer-events:none;width:auto;height:auto;contain:layout style;`,e.appendChild(t),t},_=e=>{let t=document.createElement(`div`);return t.className=`ssg-body-cell`,t.style.cssText=`display:inline-block;position:static;top:auto;left:auto;width:auto;height:auto;white-space:nowrap;overflow:visible;`,t.textContent=e,t},v=e=>{let t=_(``);t.className=`ssg-body-cell ssg-total-cell`;let n=document.createElement(`span`);if(n.className=`ssg-total-value`,e.caption!==void 0&&e.caption!==``){let t=document.createElement(`span`);t.className=`ssg-total-caption`,t.textContent=e.caption,n.appendChild(t)}return n.appendChild(document.createTextNode(e.text)),t.appendChild(n),t},y=e=>e.suppressAutoSize===!0||e.autoHeight===!0;function b(i){let a=i.map(()=>[]),c=i.map(()=>[]),u=i.map(()=>1/0),p=i.map(()=>0);return{collect:t=>{for(let n=0;n<i.length;n+=1){if(y(i[n]))continue;let r=i[n].estimateCellWidth;if(r){let e=r(t,i[n]);e>p[n]&&(p[n]=e);continue}let o=String(e.getCellValue(t,i[n])??``);if(o===``)continue;let l=a[n],d=c[n];if(l.length===s&&2*o.length<=u[n])continue;let f=m(o);if(l.length<s){if(l.push(t),d.push(f),l.length===s){let e=d[0];for(let t=1;t<s;t+=1)d[t]<e&&(e=d[t]);u[n]=e}continue}if(f<=u[n])continue;let h=0;for(let e=1;e<s;e+=1)d[e]<d[h]&&(h=e);l[h]=t,d[h]=f;let g=d[0];for(let e=1;e<s;e+=1)d[e]<g&&(g=d[e]);u[n]=g}},finalize:({gridRoot:e,currentWidths:s,totalRowTexts:c})=>{let u=l();if(!u||i.length===0)return{};let{cellFont:m,headerFont:b}=d(e),x={},S=g(e);try{let e=null,l=null;if(S){let t=i.map(e=>{let t=c?.get(e.key);if(y(e)||t===void 0||t.text===``)return null;let n=v(t);return S.appendChild(n),n}),n=[];for(let e=0;e<i.length;e+=1){if(y(i[e])){n.push([]);continue}if(i[e].estimateCellWidth){n.push([]);continue}let t=a[e],r=[];for(let n=0;n<t.length;n+=1){let a=h(t[n],i[e]);if(a===``)continue;let o=_(a);S.appendChild(o),r.push(o)}n.push(r)}l=t.map(e=>e?e.offsetWidth:0),e=n.map(e=>{let t=0;for(let n=0;n<e.length;n+=1){let r=e[n].offsetWidth;r>t&&(t=r)}return t})}for(let d=0;d<i.length;d+=1){let g=i[d];if(y(g))continue;u.font=b;let _=g.title||g.key,v=u.measureText(_).width+n+r,S;if(g.estimateCellWidth)S=p[d]>0?p[d]+t:0;else if(e)S=e[d];else{u.font=m;let e=0,r=a[d];for(let t=0;t<r.length;t+=1){let n=h(r[t],g);if(n===``)continue;let i=u.measureText(n).width;i>e&&(e=i)}S=e>0?e+n+t:0}let C=0,w=c?.get(g.key);if(l)C=l[d];else if(w!==void 0&&w.text!==``){u.font=m;let e=w.caption?`${w.caption} ${w.text}`:w.text;C=u.measureText(e).width+n+t}let T=Math.ceil(f(Math.max(v,S,C),g.minWidth??o,g.maxWidth??1/0));s[g.key]!==T&&(x[g.key]=T)}}finally{S&&S.parentNode&&S.parentNode.removeChild(S)}return x}}}function x(){return l()!==null}function S({columns:e,getRow:t,viewRowCount:n,gridRoot:r,currentWidths:i}){if(e.length===0||l()===null)return{};let a=b(e);for(let e=0;e<n;e+=1){let n=t(e);n&&a.collect(n)}return a.finalize({gridRoot:r,currentWidths:i})}exports.canMeasureAutosize=x,exports.computeAutosizedColumnWidths=S,exports.createColumnWidthAccumulator=b;
@@ -1,4 +1,9 @@
1
1
  import type { GridColumn } from '../model/gridTypes.unbound.js';
2
+ export type AutosizeTotalRowText = {
3
+ text: string;
4
+ caption?: string;
5
+ };
6
+ export type AutosizeTotalRowTexts = ReadonlyMap<string, AutosizeTotalRowText>;
2
7
  export type ColumnAutosizeParams<T> = {
3
8
  columns: GridColumn<T>[];
4
9
  getRow: (viewIndex: number) => T;
@@ -11,6 +16,7 @@ export type ColumnWidthAccumulator<T> = {
11
16
  finalize: (params: {
12
17
  gridRoot: HTMLElement | null;
13
18
  currentWidths: Record<string, number>;
19
+ totalRowTexts?: AutosizeTotalRowTexts;
14
20
  }) => Record<string, number>;
15
21
  };
16
22
  export declare function createColumnWidthAccumulator<T>(columns: GridColumn<T>[]): ColumnWidthAccumulator<T>;
@@ -33,13 +33,22 @@ var t = 21, n = 4, r = 41, i = 13, a = 600, o = 60, s = 16, c = null, l = () =>
33
33
  }, _ = (e) => {
34
34
  let t = document.createElement("div");
35
35
  return t.className = "ssg-body-cell", t.style.cssText = "display:inline-block;position:static;top:auto;left:auto;width:auto;height:auto;white-space:nowrap;overflow:visible;", t.textContent = e, t;
36
- }, v = (e) => e.suppressAutoSize === !0 || e.autoHeight === !0;
37
- function y(i) {
36
+ }, v = (e) => {
37
+ let t = _("");
38
+ t.className = "ssg-body-cell ssg-total-cell";
39
+ let n = document.createElement("span");
40
+ if (n.className = "ssg-total-value", e.caption !== void 0 && e.caption !== "") {
41
+ let t = document.createElement("span");
42
+ t.className = "ssg-total-caption", t.textContent = e.caption, n.appendChild(t);
43
+ }
44
+ return n.appendChild(document.createTextNode(e.text)), t.appendChild(n), t;
45
+ }, y = (e) => e.suppressAutoSize === !0 || e.autoHeight === !0;
46
+ function b(i) {
38
47
  let a = i.map(() => []), c = i.map(() => []), u = i.map(() => Infinity), p = i.map(() => 0);
39
48
  return {
40
49
  collect: (t) => {
41
50
  for (let n = 0; n < i.length; n += 1) {
42
- if (v(i[n])) continue;
51
+ if (y(i[n])) continue;
43
52
  let r = i[n].estimateCellWidth;
44
53
  if (r) {
45
54
  let e = r(t, i[n]);
@@ -68,33 +77,38 @@ function y(i) {
68
77
  u[n] = g;
69
78
  }
70
79
  },
71
- finalize: ({ gridRoot: e, currentWidths: s }) => {
72
- let c = l();
73
- if (!c || i.length === 0) return {};
74
- let { cellFont: u, headerFont: m } = d(e), y = {}, b = g(e);
80
+ finalize: ({ gridRoot: e, currentWidths: s, totalRowTexts: c }) => {
81
+ let u = l();
82
+ if (!u || i.length === 0) return {};
83
+ let { cellFont: m, headerFont: b } = d(e), x = {}, S = g(e);
75
84
  try {
76
- let e = null;
77
- if (b) {
78
- let t = [];
85
+ let e = null, l = null;
86
+ if (S) {
87
+ let t = i.map((e) => {
88
+ let t = c?.get(e.key);
89
+ if (y(e) || t === void 0 || t.text === "") return null;
90
+ let n = v(t);
91
+ return S.appendChild(n), n;
92
+ }), n = [];
79
93
  for (let e = 0; e < i.length; e += 1) {
80
- if (v(i[e])) {
81
- t.push([]);
94
+ if (y(i[e])) {
95
+ n.push([]);
82
96
  continue;
83
97
  }
84
98
  if (i[e].estimateCellWidth) {
85
- t.push([]);
99
+ n.push([]);
86
100
  continue;
87
101
  }
88
- let n = a[e], r = [];
89
- for (let t = 0; t < n.length; t += 1) {
90
- let a = h(n[t], i[e]);
102
+ let t = a[e], r = [];
103
+ for (let n = 0; n < t.length; n += 1) {
104
+ let a = h(t[n], i[e]);
91
105
  if (a === "") continue;
92
106
  let o = _(a);
93
- b.appendChild(o), r.push(o);
107
+ S.appendChild(o), r.push(o);
94
108
  }
95
- t.push(r);
109
+ n.push(r);
96
110
  }
97
- e = t.map((e) => {
111
+ l = t.map((e) => e ? e.offsetWidth : 0), e = n.map((e) => {
98
112
  let t = 0;
99
113
  for (let n = 0; n < e.length; n += 1) {
100
114
  let r = e[n].offsetWidth;
@@ -103,40 +117,47 @@ function y(i) {
103
117
  return t;
104
118
  });
105
119
  }
106
- for (let l = 0; l < i.length; l += 1) {
107
- let d = i[l];
108
- if (v(d)) continue;
109
- c.font = m;
110
- let g = d.title || d.key, _ = c.measureText(g).width + n + r, b;
111
- if (d.estimateCellWidth) b = p[l] > 0 ? p[l] + t : 0;
112
- else if (e) b = e[l];
120
+ for (let d = 0; d < i.length; d += 1) {
121
+ let g = i[d];
122
+ if (y(g)) continue;
123
+ u.font = b;
124
+ let _ = g.title || g.key, v = u.measureText(_).width + n + r, S;
125
+ if (g.estimateCellWidth) S = p[d] > 0 ? p[d] + t : 0;
126
+ else if (e) S = e[d];
113
127
  else {
114
- c.font = u;
115
- let e = 0, r = a[l];
128
+ u.font = m;
129
+ let e = 0, r = a[d];
116
130
  for (let t = 0; t < r.length; t += 1) {
117
- let n = h(r[t], d);
131
+ let n = h(r[t], g);
118
132
  if (n === "") continue;
119
- let i = c.measureText(n).width;
133
+ let i = u.measureText(n).width;
120
134
  i > e && (e = i);
121
135
  }
122
- b = e > 0 ? e + n + t : 0;
136
+ S = e > 0 ? e + n + t : 0;
137
+ }
138
+ let C = 0, w = c?.get(g.key);
139
+ if (l) C = l[d];
140
+ else if (w !== void 0 && w.text !== "") {
141
+ u.font = m;
142
+ let e = w.caption ? `${w.caption} ${w.text}` : w.text;
143
+ C = u.measureText(e).width + n + t;
123
144
  }
124
- let x = Math.ceil(f(Math.max(_, b), d.minWidth ?? o, d.maxWidth ?? Infinity));
125
- s[d.key] !== x && (y[d.key] = x);
145
+ let T = Math.ceil(f(Math.max(v, S, C), g.minWidth ?? o, g.maxWidth ?? Infinity));
146
+ s[g.key] !== T && (x[g.key] = T);
126
147
  }
127
148
  } finally {
128
- b && b.parentNode && b.parentNode.removeChild(b);
149
+ S && S.parentNode && S.parentNode.removeChild(S);
129
150
  }
130
- return y;
151
+ return x;
131
152
  }
132
153
  };
133
154
  }
134
- function b() {
155
+ function x() {
135
156
  return l() !== null;
136
157
  }
137
- function x({ columns: e, getRow: t, viewRowCount: n, gridRoot: r, currentWidths: i }) {
158
+ function S({ columns: e, getRow: t, viewRowCount: n, gridRoot: r, currentWidths: i }) {
138
159
  if (e.length === 0 || l() === null) return {};
139
- let a = y(e);
160
+ let a = b(e);
140
161
  for (let e = 0; e < n; e += 1) {
141
162
  let n = t(e);
142
163
  n && a.collect(n);
@@ -147,4 +168,4 @@ function x({ columns: e, getRow: t, viewRowCount: n, gridRoot: r, currentWidths:
147
168
  });
148
169
  }
149
170
  //#endregion
150
- export { b as canMeasureAutosize, x as computeAutosizedColumnWidths, y as createColumnWidthAccumulator };
171
+ export { x as canMeasureAutosize, S as computeAutosizedColumnWidths, b as createColumnWidthAccumulator };
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./geometry.cjs");var t=50,n=t=>t.flex!=null&&t.flex>0&&e.getColumnPane(t)===`center`,r=(e,t)=>{let n=new Map,r=e,i=t;for(;;){let e=r.reduce((e,t)=>e+t.flex,0);if(r.length===0||e<=0)break;let t=null;for(let a of r){let r=i*a.flex/e;if(r<a.min){n.set(a.key,a.min),i-=a.min,t=a.key;break}if(r>a.max){n.set(a.key,a.max),i-=a.max,t=a.key;break}}if(t!==null){r=r.filter(e=>e.key!==t);continue}let a=0;r.forEach((t,o)=>{if(o===r.length-1)n.set(t.key,i-a);else{let r=i*t.flex/e;n.set(t.key,r),a+=r}});break}return n},i=(t,n,i)=>{let a=[],o=0;for(let r of t){let t=n[r.key];if(t!=null){o+=t;continue}let i=r.flex;if(i!=null&&i>0&&e.getColumnPane(r)===`center`){a.push({key:r.key,flex:i,min:r.minWidth??50,max:r.maxWidth??1/0});continue}o+=r.width}if(a.length===0)return{};let s=i-o;return Object.fromEntries(r(a,s))};exports.DEFAULT_FLEX_MIN_WIDTH=t,exports.computeCenterFlexWidths=i,exports.isFlexingColumn=n;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./geometry.cjs");var t=50,n=t=>t.flex!=null&&t.flex>0&&e.getColumnPane(t)===`center`,r=1e-6,i=(e,t)=>{let n=new Map,i=e,a=t;for(;;){let e=i.reduce((e,t)=>e+t.flex,0);if(i.length===0||e<=0)break;let t=null;for(let r of i){let i=a*r.flex/e;if(i<r.min){n.set(r.key,r.min),a-=r.min,t=r.key;break}if(i>r.max){n.set(r.key,r.max),a-=r.max,t=r.key;break}}if(t!==null){i=i.filter(e=>e.key!==t);continue}let o=0,s=0;i.forEach((t,c)=>{o+=t.flex;let l=c===i.length-1?a:a*o/e,u=Math.floor(l+r);n.set(t.key,u-s),s=u});break}return n},a=(t,n,r)=>{let a=[],o=0;for(let r of t){let t=n[r.key];if(t!=null){o+=t;continue}let i=r.flex;if(i!=null&&i>0&&e.getColumnPane(r)===`center`){a.push({key:r.key,flex:i,min:r.minWidth??50,max:r.maxWidth??1/0});continue}o+=r.width}if(a.length===0)return{};let s=r-o;return Object.fromEntries(i(a,s))};exports.DEFAULT_FLEX_MIN_WIDTH=t,exports.computeCenterFlexWidths=a,exports.isFlexingColumn=n;
@@ -1,38 +1,36 @@
1
1
  import { getColumnPane as e } from "./geometry.js";
2
2
  //#region src/logic/columnFlex.ts
3
- var t = 50, n = (t) => t.flex != null && t.flex > 0 && e(t) === "center", r = (e, t) => {
4
- let n = /* @__PURE__ */ new Map(), r = e, i = t;
3
+ var t = 50, n = (t) => t.flex != null && t.flex > 0 && e(t) === "center", r = 1e-6, i = (e, t) => {
4
+ let n = /* @__PURE__ */ new Map(), i = e, a = t;
5
5
  for (;;) {
6
- let e = r.reduce((e, t) => e + t.flex, 0);
7
- if (r.length === 0 || e <= 0) break;
6
+ let e = i.reduce((e, t) => e + t.flex, 0);
7
+ if (i.length === 0 || e <= 0) break;
8
8
  let t = null;
9
- for (let a of r) {
10
- let r = i * a.flex / e;
11
- if (r < a.min) {
12
- n.set(a.key, a.min), i -= a.min, t = a.key;
9
+ for (let r of i) {
10
+ let i = a * r.flex / e;
11
+ if (i < r.min) {
12
+ n.set(r.key, r.min), a -= r.min, t = r.key;
13
13
  break;
14
14
  }
15
- if (r > a.max) {
16
- n.set(a.key, a.max), i -= a.max, t = a.key;
15
+ if (i > r.max) {
16
+ n.set(r.key, r.max), a -= r.max, t = r.key;
17
17
  break;
18
18
  }
19
19
  }
20
20
  if (t !== null) {
21
- r = r.filter((e) => e.key !== t);
21
+ i = i.filter((e) => e.key !== t);
22
22
  continue;
23
23
  }
24
- let a = 0;
25
- r.forEach((t, o) => {
26
- if (o === r.length - 1) n.set(t.key, i - a);
27
- else {
28
- let r = i * t.flex / e;
29
- n.set(t.key, r), a += r;
30
- }
24
+ let o = 0, s = 0;
25
+ i.forEach((t, c) => {
26
+ o += t.flex;
27
+ let l = c === i.length - 1 ? a : a * o / e, u = Math.floor(l + r);
28
+ n.set(t.key, u - s), s = u;
31
29
  });
32
30
  break;
33
31
  }
34
32
  return n;
35
- }, i = (t, n, i) => {
33
+ }, a = (t, n, r) => {
36
34
  let a = [], o = 0;
37
35
  for (let r of t) {
38
36
  let t = n[r.key];
@@ -53,8 +51,8 @@ var t = 50, n = (t) => t.flex != null && t.flex > 0 && e(t) === "center", r = (e
53
51
  o += r.width;
54
52
  }
55
53
  if (a.length === 0) return {};
56
- let s = i - o;
57
- return Object.fromEntries(r(a, s));
54
+ let s = r - o;
55
+ return Object.fromEntries(i(a, s));
58
56
  };
59
57
  //#endregion
60
- export { t as DEFAULT_FLEX_MIN_WIDTH, i as computeCenterFlexWidths, n as isFlexingColumn };
58
+ export { t as DEFAULT_FLEX_MIN_WIDTH, a as computeCenterFlexWidths, n as isFlexingColumn };
@@ -1,3 +1,3 @@
1
1
  Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../utils/permissions.cjs");var t=(e,t)=>e.includes(t)||e.includes(`"`)||e.includes(`
2
- `)||e.includes(`\r`)?`"${e.replace(/"/g,`""`)}"`:e,n=(t,n)=>{let r=e.getCellValue(t,n);return n.formatClipboardValue?n.formatClipboardValue(r,t):String(r??``)},r=e=>e==null?``:String(e),i=({getRow:e,startRow:i,endRow:a,columns:o,delimiter:s=`,`,includeHeaders:c=!0,bom:l=!1,isRowIncluded:u,getLabelLine:d})=>{let f=[];c&&f.push(o.map(e=>t(e.title??e.key,s)).join(s));for(let c=i;c<a;c+=1){let i=e(c);if(!i){let e=d?.(c);e&&f.push(o.map((n,i)=>t(r(e[i]),s)).join(s));continue}if(u&&!u(i,c))continue;let a=o.map(e=>t(n(i,e),s));f.push(a.join(s))}let p=f.join(`\r
3
- `);return l?`\uFEFF${p}`:p};exports.labelExportCellText=r,exports.serializeRowsToCsv=i;
2
+ `)||e.includes(`\r`)?`"${e.replace(/"/g,`""`)}"`:e,n=/^[=+\-@\t\r]/,r=/^[+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?$/i,i=e=>n.test(e)&&!r.test(e)?`'${e}`:e,a=(t,n)=>{let r=e.getCellValue(t,n);return n.formatClipboardValue?n.formatClipboardValue(r,t):String(r??``)},o=e=>e==null?``:String(e),s=e=>e==null?``:String(e),c=({getRow:e,startRow:n,endRow:r,columns:c,delimiter:l=`,`,includeHeaders:u=!0,bom:d=!1,escapeFormulas:f=!1,isRowIncluded:p,getLabelLine:m,totalLine:h})=>{let g=[],_=e=>t(f?i(e):e,l);u&&g.push(c.map(e=>t(e.title||e.key,l)).join(l));for(let t=n;t<r;t+=1){let n=e(t);if(!n){let e=m?.(t);e&&g.push(c.map((t,n)=>_(o(e[n]))).join(l));continue}if(p&&!p(n,t))continue;let r=c.map(e=>_(a(n,e)));g.push(r.join(l))}h&&g.push(c.map((e,t)=>_(s(h[t]))).join(l));let v=g.join(`\r
3
+ `);return d?`\uFEFF${v}`:v};exports.escapeCsvFormula=i,exports.labelExportCellText=o,exports.serializeRowsToCsv=c,exports.totalExportCellText=s;
@@ -1,4 +1,5 @@
1
1
  import type { GridColumn } from '../model/gridTypes.unbound.js';
2
+ export declare const escapeCsvFormula: (value: string) => string;
2
3
  export type SerializeRowsToCsvParams<T> = {
3
4
  getRow: (viewIndex: number) => T;
4
5
  startRow: number;
@@ -7,9 +8,12 @@ export type SerializeRowsToCsvParams<T> = {
7
8
  delimiter?: string;
8
9
  includeHeaders?: boolean;
9
10
  bom?: boolean;
11
+ escapeFormulas?: boolean;
10
12
  isRowIncluded?: (row: T, rowIndex: number) => boolean;
11
13
  getLabelLine?: (rowIndex: number) => LabelExportLine | undefined;
14
+ totalLine?: ReadonlyArray<unknown>;
12
15
  };
13
16
  export type LabelExportLine = ReadonlyArray<string | number | null | undefined>;
14
17
  export declare const labelExportCellText: (value: string | number | null | undefined) => string;
15
- export declare const serializeRowsToCsv: <T>({ getRow, startRow, endRow, columns, delimiter, includeHeaders, bom, isRowIncluded, getLabelLine, }: SerializeRowsToCsvParams<T>) => string;
18
+ export declare const totalExportCellText: (value: unknown) => string;
19
+ export declare const serializeRowsToCsv: <T>({ getRow, startRow, endRow, columns, delimiter, includeHeaders, bom, escapeFormulas, isRowIncluded, getLabelLine, totalLine, }: SerializeRowsToCsvParams<T>) => string;