@rowsncolumns/spreadsheet 10.18.0 → 10.19.2

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 (65) hide show
  1. package/dist/cjs/api/fill-series.d.ts +48 -8
  2. package/dist/cjs/api/fill-series.d.ts.map +1 -1
  3. package/dist/cjs/api/fill-series.js +231 -25
  4. package/dist/cjs/atoms/cell-input-context.atom.d.ts.map +1 -1
  5. package/dist/cjs/atoms/fill-series-dialog.atom.d.ts +6 -0
  6. package/dist/cjs/atoms/fill-series-dialog.atom.d.ts.map +1 -1
  7. package/dist/cjs/atoms/frozen-area-sent.atom.d.ts +53 -0
  8. package/dist/cjs/atoms/frozen-area-sent.atom.d.ts.map +1 -0
  9. package/dist/cjs/atoms/frozen-area-sent.atom.js +48 -0
  10. package/dist/cjs/atoms/index.d.ts +2 -0
  11. package/dist/cjs/atoms/index.d.ts.map +1 -1
  12. package/dist/cjs/atoms/index.js +2 -0
  13. package/dist/cjs/atoms/undo-redo-sent.atom.d.ts +25 -0
  14. package/dist/cjs/atoms/undo-redo-sent.atom.d.ts.map +1 -0
  15. package/dist/cjs/atoms/undo-redo-sent.atom.js +23 -0
  16. package/dist/cjs/components/canvas-grid/frozen-start.d.ts +25 -10
  17. package/dist/cjs/components/canvas-grid/frozen-start.d.ts.map +1 -1
  18. package/dist/cjs/components/canvas-grid/frozen-start.js +25 -18
  19. package/dist/cjs/components/canvas-grid/index.d.ts.map +1 -1
  20. package/dist/cjs/components/canvas-grid/index.js +181 -33
  21. package/dist/cjs/components/canvas-grid/typings.d.ts +15 -0
  22. package/dist/cjs/components/canvas-grid/typings.d.ts.map +1 -1
  23. package/dist/cjs/components/fill-series-dialog/index.d.ts +13 -4
  24. package/dist/cjs/components/fill-series-dialog/index.d.ts.map +1 -1
  25. package/dist/cjs/components/fill-series-dialog/index.js +29 -14
  26. package/dist/cjs/hooks/use-selection-interceptors.d.ts.map +1 -1
  27. package/dist/cjs/hooks/use-selection-interceptors.js +9 -0
  28. package/dist/cjs/hooks/use-selection.d.ts +8 -1
  29. package/dist/cjs/hooks/use-selection.d.ts.map +1 -1
  30. package/dist/cjs/hooks/use-selection.js +39 -9
  31. package/dist/cjs/release-date.js +1 -1
  32. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  33. package/dist/esm/api/fill-series.d.ts +48 -8
  34. package/dist/esm/api/fill-series.d.ts.map +1 -1
  35. package/dist/esm/api/fill-series.js +222 -23
  36. package/dist/esm/atoms/cell-input-context.atom.d.ts.map +1 -1
  37. package/dist/esm/atoms/fill-series-dialog.atom.d.ts +6 -0
  38. package/dist/esm/atoms/fill-series-dialog.atom.d.ts.map +1 -1
  39. package/dist/esm/atoms/frozen-area-sent.atom.d.ts +53 -0
  40. package/dist/esm/atoms/frozen-area-sent.atom.d.ts.map +1 -0
  41. package/dist/esm/atoms/frozen-area-sent.atom.js +43 -0
  42. package/dist/esm/atoms/index.d.ts +2 -0
  43. package/dist/esm/atoms/index.d.ts.map +1 -1
  44. package/dist/esm/atoms/index.js +2 -0
  45. package/dist/esm/atoms/undo-redo-sent.atom.d.ts +25 -0
  46. package/dist/esm/atoms/undo-redo-sent.atom.d.ts.map +1 -0
  47. package/dist/esm/atoms/undo-redo-sent.atom.js +18 -0
  48. package/dist/esm/components/canvas-grid/frozen-start.d.ts +25 -10
  49. package/dist/esm/components/canvas-grid/frozen-start.d.ts.map +1 -1
  50. package/dist/esm/components/canvas-grid/frozen-start.js +25 -18
  51. package/dist/esm/components/canvas-grid/index.d.ts.map +1 -1
  52. package/dist/esm/components/canvas-grid/index.js +176 -31
  53. package/dist/esm/components/canvas-grid/typings.d.ts +15 -0
  54. package/dist/esm/components/canvas-grid/typings.d.ts.map +1 -1
  55. package/dist/esm/components/fill-series-dialog/index.d.ts +13 -4
  56. package/dist/esm/components/fill-series-dialog/index.d.ts.map +1 -1
  57. package/dist/esm/components/fill-series-dialog/index.js +29 -14
  58. package/dist/esm/hooks/use-selection-interceptors.d.ts.map +1 -1
  59. package/dist/esm/hooks/use-selection-interceptors.js +10 -1
  60. package/dist/esm/hooks/use-selection.d.ts +8 -1
  61. package/dist/esm/hooks/use-selection.d.ts.map +1 -1
  62. package/dist/esm/hooks/use-selection.js +35 -5
  63. package/dist/esm/release-date.js +1 -1
  64. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  65. package/package.json +2 -1
@@ -1,5 +1,23 @@
1
1
  import type { GridRange } from "@rowsncolumns/grid";
2
2
  import type { FillSeriesSpec } from "../types";
3
+ /**
4
+ * The Series dialog's Stop value as the serial the spec carries, read the way a cell entry is read,
5
+ * for a host that does not parse it itself (`CanvasGrid`'s `parseCellEntryNumber`, which the rnc
6
+ * engine's hook answers with the cell-entry inference). `undefined` when the text is empty or would
7
+ * not be a number in a cell (text, a boolean).
8
+ * - A day / month without a year (`3/4`, `15/1`) follows the locale's order (3 April and 15 January
9
+ * in en-GB, 4 March in en-US), in the current year, as a cell entry does. Where the decimal mark is a
10
+ * comma, `1.5` is such a date too (1 May in de-DE).
11
+ * - A plain number is taken as it is (`45306`, `-2.5`, `1e3`; `1.5` where the decimal mark is `.`).
12
+ * - A date with a year, a date and time, or a time, in the locale (`15/1/2024` in en-GB,
13
+ * `15.1.2024` in de-DE, `Jan 15, 2024`, `2024-01-15`, `1/15/2024 12:00`, `10:30`). A date counts
14
+ * in the workbook's date system (1462 lower in a 1904 workbook); a time part is kept.
15
+ * - A number the locale writes otherwise: `2,5` in de-DE, `50%` (0.5), `1,000` (1000) and `$5` in en-US.
16
+ */
17
+ export declare const parseSeriesStopValue: (text: string, options?: {
18
+ locale?: string;
19
+ date1904?: boolean;
20
+ }) => number | undefined;
3
21
  /**
4
22
  * The seed line of a Series-dialog fill: Excel treats the target range's first
5
23
  * row (Series in Columns — filling down) or first column (Series in Rows —
@@ -9,20 +27,36 @@ export declare const seedRangeForSeriesSpec: (target: GridRange, spec: FillSerie
9
27
  /**
10
28
  * How many series values fit before `stop` is passed, starting from the seed's
11
29
  * last value. `undefined` when the spec has no usable stop (no stop, zero step,
12
- * a step that walks away from the stop, …) — the caller then fills the target
13
- * as selected.
30
+ * a trend, AutoFill, a Growth that shrinks toward zero and never reaches a stop
31
+ * on the other side, …): a seed-only selection is then not filled at all. A Date
32
+ * series counts on the calendar: a 1904 workbook's serials (`date1904`) are
33
+ * moved onto the 1900 system first, as the engine does with the seed and stop.
14
34
  */
15
- export declare const seriesCountToStop: (last: number, spec: FillSeriesSpec) => number | undefined;
35
+ export declare const seriesCountToStop: (last: number, spec: FillSeriesSpec, options?: {
36
+ date1904?: boolean;
37
+ }) => number | undefined;
16
38
  export type FillRangeForSeriesSpecArgs = {
17
39
  /** The range the user selected (seed + cells to fill). */
18
40
  target: GridRange;
19
41
  /** From {@link seedRangeForSeriesSpec}. */
20
42
  seed: GridRange;
21
43
  spec: FillSeriesSpec;
22
- /** Numeric value of a seed cell (`undefined` when not a number). */
44
+ /**
45
+ * The value a seed cell starts the series from, or `undefined` when the engine would not run its
46
+ * line as this series (not a number, a formula, or, for a Date series, not a date). A seed-only
47
+ * selection with any such line fills nothing: the engine would fill that line with its regular
48
+ * generator over the whole range, ignoring the stop.
49
+ */
23
50
  getSeedValue(rowIndex: number, columnIndex: number): number | undefined;
51
+ /**
52
+ * Bounds of the fill: the last row index is `rowCount - 1` and the last column index
53
+ * `columnCount - 1`. A host whose rows / columns start at index 1 passes its sheet's last index
54
+ * + 1 (CanvasGrid passes the sheet maximum, 1,048,576 rows × 16,384 columns, not its drawn extent).
55
+ */
24
56
  rowCount: number;
25
57
  columnCount: number;
58
+ /** The workbook counts dates in the 1904 system (a Date series' stop is one of its serials). */
59
+ date1904?: boolean;
26
60
  };
27
61
  /**
28
62
  * The range a Series-dialog fill covers (seed + cells to fill). A selection
@@ -30,9 +64,15 @@ export type FillRangeForSeriesSpecArgs = {
30
64
  * is nothing beyond the seed and no stop): the engines apply the `stop` value
31
65
  * per fill line — every column (Series in Columns) / row (Rows) ends at the
32
66
  * last value within its own stop and the remaining selected cells stay
33
- * untouched, exactly as Excel leaves them. Only a seed-only selection is
34
- * extended along the axis by the number of values that stay within the stop —
35
- * Excel fills down/right from a single line until the value would pass it.
67
+ * untouched, exactly as Excel leaves them. A seed-only selection (one cell, or
68
+ * one line across the axis) is extended along the axis to the LONGEST of its
69
+ * lines' series — Excel runs every line from its own seed until its next value
70
+ * would pass the stop (A1:C1 = 8, 1, 5, Columns, Stop 10 fills A to 10, B to 10
71
+ * and C to 10: rows 2–3, 2–10 and 2–6) — and the engine's stop ends each
72
+ * shorter line inside that range. When any line is one the engine will not run
73
+ * as the series (`getSeedValue` answers `undefined`: text, empty, a formula, a
74
+ * plain number under Date), nothing is filled: the engine would copy or clear
75
+ * that line down the whole range.
36
76
  */
37
- export declare const fillRangeForSeriesSpec: ({ target, seed, spec, getSeedValue, rowCount, columnCount, }: FillRangeForSeriesSpecArgs) => GridRange | undefined;
77
+ export declare const fillRangeForSeriesSpec: ({ target, seed, spec, getSeedValue, rowCount, columnCount, date1904, }: FillRangeForSeriesSpecArgs) => GridRange | undefined;
38
78
  //# sourceMappingURL=fill-series.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fill-series.d.ts","sourceRoot":"","sources":["../../../api/fill-series.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,GACjC,QAAQ,SAAS,EACjB,MAAM,cAAc,KACnB,SAGyD,CAAC;AAE7D;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAC5B,MAAM,MAAM,EACZ,MAAM,cAAc,KACnB,MAAM,GAAG,SAuBX,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG;IACvC,0DAA0D;IAC1D,MAAM,EAAE,SAAS,CAAC;IAClB,2CAA2C;IAC3C,IAAI,EAAE,SAAS,CAA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;;;;OAIG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,gGAAgG;IAChG,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,sBAAsB,GAAI,wEAQpC,0BAA0B,KAAG,SAAS,GAAG,SAgC3C,CAAC"}
@@ -1,7 +1,101 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fillRangeForSeriesSpec = exports.seriesCountToStop = exports.seedRangeForSeriesSpec = void 0;
3
+ exports.fillRangeForSeriesSpec = exports.seriesCountToStop = exports.seedRangeForSeriesSpec = exports.parseSeriesStopValue = void 0;
4
4
  var tslib_1 = require("tslib");
5
+ var numfmt_1 = require("numfmt");
6
+ /** Days from the 1900 date system's day zero to the 1904 system's (`DATE1904_OFFSET`). */
7
+ var DATE_1904_OFFSET = 1462;
8
+ /** A locale's day / month order and decimal mark, from `Intl` (en-US conventions on a bad tag). */
9
+ var localeEntryConventions = function (locale) {
10
+ var _a, _b;
11
+ try {
12
+ var order = new Intl.DateTimeFormat(locale, {
13
+ year: "numeric",
14
+ month: "numeric",
15
+ day: "numeric",
16
+ })
17
+ .formatToParts(new Date(2024, 11, 25))
18
+ .map(function (part) { return part.type; });
19
+ var decimal = (_b = (_a = new Intl.NumberFormat(locale)
20
+ .formatToParts(1.5)
21
+ .find(function (part) { return part.type === "decimal"; })) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : ".";
22
+ return {
23
+ monthFirst: order.indexOf("month") < order.indexOf("day"),
24
+ decimal: decimal,
25
+ };
26
+ }
27
+ catch (_c) {
28
+ return { monthFirst: true, decimal: "." };
29
+ }
30
+ };
31
+ /** Excel's serial for a calendar date (UTC arithmetic, the same in every timezone; from 1 March 1900). */
32
+ var calendarSerial = function (year, month, day) {
33
+ return (Date.UTC(year, month - 1, day) - Date.UTC(1899, 11, 30)) / 86400000;
34
+ };
35
+ /**
36
+ * The Series dialog's Stop value as the serial the spec carries, read the way a cell entry is read,
37
+ * for a host that does not parse it itself (`CanvasGrid`'s `parseCellEntryNumber`, which the rnc
38
+ * engine's hook answers with the cell-entry inference). `undefined` when the text is empty or would
39
+ * not be a number in a cell (text, a boolean).
40
+ * - A day / month without a year (`3/4`, `15/1`) follows the locale's order (3 April and 15 January
41
+ * in en-GB, 4 March in en-US), in the current year, as a cell entry does. Where the decimal mark is a
42
+ * comma, `1.5` is such a date too (1 May in de-DE).
43
+ * - A plain number is taken as it is (`45306`, `-2.5`, `1e3`; `1.5` where the decimal mark is `.`).
44
+ * - A date with a year, a date and time, or a time, in the locale (`15/1/2024` in en-GB,
45
+ * `15.1.2024` in de-DE, `Jan 15, 2024`, `2024-01-15`, `1/15/2024 12:00`, `10:30`). A date counts
46
+ * in the workbook's date system (1462 lower in a 1904 workbook); a time part is kept.
47
+ * - A number the locale writes otherwise: `2,5` in de-DE, `50%` (0.5), `1,000` (1000) and `$5` in en-US.
48
+ */
49
+ var parseSeriesStopValue = function (text, options) {
50
+ if (options === void 0) { options = {}; }
51
+ var trimmed = text.trim();
52
+ if (!trimmed)
53
+ return undefined;
54
+ var locale = options.locale;
55
+ var shift = options.date1904 ? DATE_1904_OFFSET : 0;
56
+ var _a = localeEntryConventions(locale), monthFirst = _a.monthFirst, decimal = _a.decimal;
57
+ var yearless = /^(\d{1,2})([/.-])(\d{1,2})$/.exec(trimmed);
58
+ if (yearless && (yearless[2] !== "." || decimal === ",")) {
59
+ var first = Number(yearless[1]);
60
+ var second = Number(yearless[3]);
61
+ var _b = tslib_1.__read(monthFirst ? [first, second] : [second, first], 2), month = _b[0], day = _b[1];
62
+ var year = new Date().getFullYear();
63
+ var date = new Date(Date.UTC(year, month - 1, day));
64
+ if (month >= 1 &&
65
+ month <= 12 &&
66
+ date.getUTCMonth() === month - 1 &&
67
+ date.getUTCDate() === day) {
68
+ return calendarSerial(year, month, day) - shift;
69
+ }
70
+ return undefined;
71
+ }
72
+ if (/^[+-]?\d+$/.test(trimmed) || decimal === ".") {
73
+ var number = Number(trimmed);
74
+ if (Number.isFinite(number))
75
+ return number;
76
+ }
77
+ var parseOptions = locale ? { locale: locale } : undefined;
78
+ try {
79
+ var date = (0, numfmt_1.parseDate)(trimmed, parseOptions);
80
+ if (date && typeof date.v === "number" && Number.isFinite(date.v)) {
81
+ return date.v - shift;
82
+ }
83
+ // A time alone is a fraction of a day, the same in both date systems.
84
+ var time = (0, numfmt_1.parseTime)(trimmed, parseOptions);
85
+ if (time && typeof time.v === "number" && Number.isFinite(time.v)) {
86
+ return time.v;
87
+ }
88
+ var number = (0, numfmt_1.parseNumber)(trimmed, parseOptions);
89
+ if (number && typeof number.v === "number" && Number.isFinite(number.v)) {
90
+ return number.v;
91
+ }
92
+ }
93
+ catch (_c) {
94
+ // numfmt throws on a malformed locale tag: the text is then refused.
95
+ }
96
+ return undefined;
97
+ };
98
+ exports.parseSeriesStopValue = parseSeriesStopValue;
5
99
  /**
6
100
  * The seed line of a Series-dialog fill: Excel treats the target range's first
7
101
  * row (Series in Columns — filling down) or first column (Series in Rows —
@@ -12,16 +106,99 @@ var seedRangeForSeriesSpec = function (target, spec) {
12
106
  ? tslib_1.__assign(tslib_1.__assign({}, target), { endRowIndex: target.startRowIndex }) : tslib_1.__assign(tslib_1.__assign({}, target), { endColumnIndex: target.startColumnIndex });
13
107
  };
14
108
  exports.seedRangeForSeriesSpec = seedRangeForSeriesSpec;
109
+ /**
110
+ * Days from 1970-01-01 to serial 0 of the 1900 system (1899-12-30). The calendar below is the
111
+ * engine's (`civil_from_days` / `days_from_civil`, proleptic Gregorian), in integer arithmetic so a
112
+ * Stop far outside `Date`'s range still counts.
113
+ */
114
+ var SERIAL_EPOCH_CIVIL_DAYS = -25569;
115
+ var serialToYmd = function (serial) {
116
+ var z = serial + SERIAL_EPOCH_CIVIL_DAYS + 719468;
117
+ var era = Math.floor(z / 146097);
118
+ var doe = z - era * 146097;
119
+ var yoe = Math.floor((doe - Math.floor(doe / 1460) + Math.floor(doe / 36524) - Math.floor(doe / 146096)) / 365);
120
+ var doy = doe - (365 * yoe + Math.floor(yoe / 4) - Math.floor(yoe / 100));
121
+ var mp = Math.floor((5 * doy + 2) / 153);
122
+ var day = doy - Math.floor((153 * mp + 2) / 5) + 1;
123
+ var month = mp < 10 ? mp + 3 : mp - 9;
124
+ return [yoe + era * 400 + (month <= 2 ? 1 : 0), month, day];
125
+ };
126
+ var ymdToSerial = function (year, month, day) {
127
+ var y = month <= 2 ? year - 1 : year;
128
+ var era = Math.floor(y / 400);
129
+ var yoe = y - era * 400;
130
+ var doy = Math.floor((153 * (month > 2 ? month - 3 : month + 9) + 2) / 5) + day - 1;
131
+ var doe = yoe * 365 + Math.floor(yoe / 4) - Math.floor(yoe / 100) + doy;
132
+ return era * 146097 + doe - 719468 - SERIAL_EPOCH_CIVIL_DAYS;
133
+ };
134
+ var daysInMonth = function (year, month) {
135
+ return month === 2
136
+ ? (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0
137
+ ? 29
138
+ : 28
139
+ : [4, 6, 9, 11].includes(month)
140
+ ? 30
141
+ : 31;
142
+ };
143
+ /** `serial` + `months` months, the day of month clamped to the target month's length (Jan 31 + 1 → Feb 28). */
144
+ var addMonthsClamped = function (serial, months) {
145
+ var _a = tslib_1.__read(serialToYmd(serial), 3), year = _a[0], month = _a[1], day = _a[2];
146
+ var total = year * 12 + (month - 1) + months;
147
+ var targetYear = Math.floor(total / 12);
148
+ var targetMonth = total - targetYear * 12 + 1;
149
+ return ymdToSerial(targetYear, targetMonth, Math.min(day, daysInMonth(targetYear, targetMonth)));
150
+ };
151
+ /** Weekdays (Mon–Fri) among serials up to `day`, from a fixed origin: serial 0 is a Saturday. */
152
+ var weekdaysThrough = function (day) {
153
+ var weeks = Math.floor(day / 7);
154
+ return weeks * 5 + Math.max(0, day - weeks * 7 - 1);
155
+ };
156
+ /**
157
+ * How many values a Date series in `unit`s of `step` (a whole, non-zero number) takes from the day
158
+ * `lastDay` before passing `stopDay` — the engine's calendar: each weekday step skips Saturdays and
159
+ * Sundays (from a weekend seed the first value is the Monday), and the k-th month / year value is the
160
+ * seed's day of month moved k steps and clamped to that month (1/31 → 2/28 → 3/31).
161
+ */
162
+ var dateCountToStop = function (lastDay, stopDay, step, unit) {
163
+ var ascending = step > 0;
164
+ if (ascending ? stopDay <= lastDay : stopDay >= lastDay)
165
+ return 0;
166
+ var size = Math.abs(step);
167
+ if (unit === "day")
168
+ return Math.floor(Math.abs(stopDay - lastDay) / size);
169
+ if (unit === "weekday") {
170
+ // The k-th value is the (k × step)-th weekday after the seed.
171
+ var weekdays = ascending
172
+ ? weekdaysThrough(stopDay) - weekdaysThrough(lastDay)
173
+ : weekdaysThrough(lastDay - 1) - weekdaysThrough(stopDay - 1);
174
+ return Math.floor(weekdays / size);
175
+ }
176
+ var monthsPerStep = unit === "year" ? 12 * step : step;
177
+ var _a = tslib_1.__read(serialToYmd(lastDay), 2), lastYear = _a[0], lastMonth = _a[1];
178
+ var _b = tslib_1.__read(serialToYmd(stopDay), 2), stopYear = _b[0], stopMonth = _b[1];
179
+ var months = Math.abs(stopYear * 12 + stopMonth - (lastYear * 12 + lastMonth));
180
+ var count = Math.floor(months / Math.abs(monthsPerStep));
181
+ // The value landing in the Stop's own month may still pass it by its day of month.
182
+ var value = addMonthsClamped(lastDay, monthsPerStep * count);
183
+ return count > 0 && (ascending ? value > stopDay : value < stopDay) ? count - 1 : count;
184
+ };
15
185
  /**
16
186
  * How many series values fit before `stop` is passed, starting from the seed's
17
187
  * last value. `undefined` when the spec has no usable stop (no stop, zero step,
18
- * a step that walks away from the stop, …) — the caller then fills the target
19
- * as selected.
188
+ * a trend, AutoFill, a Growth that shrinks toward zero and never reaches a stop
189
+ * on the other side, …): a seed-only selection is then not filled at all. A Date
190
+ * series counts on the calendar: a 1904 workbook's serials (`date1904`) are
191
+ * moved onto the 1900 system first, as the engine does with the seed and stop.
20
192
  */
21
- var seriesCountToStop = function (last, spec) {
193
+ var seriesCountToStop = function (last, spec, options) {
22
194
  var _a, _b;
195
+ if (options === void 0) { options = {}; }
23
196
  var stop = spec.stop;
24
- if (stop === undefined || !Number.isFinite(stop))
197
+ if (stop === undefined || !Number.isFinite(stop) || !Number.isFinite(last)) {
198
+ return undefined;
199
+ }
200
+ // Trend ignores Step and Stop (Excel greys both out).
201
+ if (spec.trend)
25
202
  return undefined;
26
203
  var step = (_a = spec.step) !== null && _a !== void 0 ? _a : 1;
27
204
  if (spec.type === "linear") {
@@ -33,16 +210,29 @@ var seriesCountToStop = function (last, spec) {
33
210
  if (spec.type === "growth") {
34
211
  if (last === 0 || step <= 0 || step === 1)
35
212
  return undefined;
36
- if (Math.sign(last) !== Math.sign(stop))
37
- return 0;
213
+ if (Math.sign(last) !== Math.sign(stop)) {
214
+ // Growing away from zero the first value is already past a stop on the other side; shrinking
215
+ // toward zero the series never reaches it, so it has no count (the engine would run on).
216
+ return step > 1 ? 0 : undefined;
217
+ }
38
218
  var n = Math.floor(Math.log(Math.abs(stop) / Math.abs(last)) / Math.log(step) + 1e-9);
39
219
  return n >= 0 ? n : 0;
40
220
  }
41
- if (spec.type === "date" && ((_b = spec.dateUnit) !== null && _b !== void 0 ? _b : "day") === "day") {
42
- if (step === 0)
221
+ if (spec.type === "date") {
222
+ // The engine steps a date series by whole units; Excel fills nothing for Step 0.
223
+ var wholeStep = Math.trunc(step);
224
+ if (wholeStep === 0)
43
225
  return undefined;
44
- var n = Math.floor((stop - last) / step + 1e-9);
45
- return n >= 0 ? n : 0;
226
+ var shift = options.date1904 ? DATE_1904_OFFSET : 0;
227
+ var lastValue = last + shift;
228
+ var stopValue = stop + shift;
229
+ var lastDay = Math.floor(lastValue);
230
+ // Every value carries the seed's time of day; a value passes the Stop when it is beyond it.
231
+ var time = lastValue - lastDay;
232
+ var stopDay = wholeStep > 0
233
+ ? Math.floor(stopValue - time + 1e-9)
234
+ : Math.ceil(stopValue - time - 1e-9);
235
+ return dateCountToStop(lastDay, stopDay, wholeStep, (_b = spec.dateUnit) !== null && _b !== void 0 ? _b : "day");
46
236
  }
47
237
  return undefined;
48
238
  };
@@ -53,26 +243,42 @@ exports.seriesCountToStop = seriesCountToStop;
53
243
  * is nothing beyond the seed and no stop): the engines apply the `stop` value
54
244
  * per fill line — every column (Series in Columns) / row (Rows) ends at the
55
245
  * last value within its own stop and the remaining selected cells stay
56
- * untouched, exactly as Excel leaves them. Only a seed-only selection is
57
- * extended along the axis by the number of values that stay within the stop —
58
- * Excel fills down/right from a single line until the value would pass it.
246
+ * untouched, exactly as Excel leaves them. A seed-only selection (one cell, or
247
+ * one line across the axis) is extended along the axis to the LONGEST of its
248
+ * lines' series — Excel runs every line from its own seed until its next value
249
+ * would pass the stop (A1:C1 = 8, 1, 5, Columns, Stop 10 fills A to 10, B to 10
250
+ * and C to 10: rows 2–3, 2–10 and 2–6) — and the engine's stop ends each
251
+ * shorter line inside that range. When any line is one the engine will not run
252
+ * as the series (`getSeedValue` answers `undefined`: text, empty, a formula, a
253
+ * plain number under Date), nothing is filled: the engine would copy or clear
254
+ * that line down the whole range.
59
255
  */
60
256
  var fillRangeForSeriesSpec = function (_a) {
61
- var _b;
62
- var target = _a.target, seed = _a.seed, spec = _a.spec, getSeedValue = _a.getSeedValue, rowCount = _a.rowCount, columnCount = _a.columnCount;
257
+ var target = _a.target, seed = _a.seed, spec = _a.spec, getSeedValue = _a.getSeedValue, rowCount = _a.rowCount, columnCount = _a.columnCount, date1904 = _a.date1904;
63
258
  var down = spec.in === "columns";
64
- // Excel reads the stop against the first seed line's last value.
65
- var last = down
66
- ? getSeedValue(seed.endRowIndex, seed.startColumnIndex)
67
- : getSeedValue(seed.startRowIndex, seed.endColumnIndex);
68
259
  var selectedBeyondSeed = down
69
260
  ? target.endRowIndex - seed.endRowIndex
70
261
  : target.endColumnIndex - seed.endColumnIndex;
71
- var extent = selectedBeyondSeed > 0
72
- ? selectedBeyondSeed
73
- : last === undefined
74
- ? 0
75
- : ((_b = (0, exports.seriesCountToStop)(last, spec)) !== null && _b !== void 0 ? _b : 0);
262
+ var extent = selectedBeyondSeed;
263
+ if (extent <= 0) {
264
+ // Every line of the seed continues from its own last value.
265
+ var _b = tslib_1.__read(down
266
+ ? [seed.startColumnIndex, seed.endColumnIndex]
267
+ : [seed.startRowIndex, seed.endRowIndex], 2), first = _b[0], end = _b[1];
268
+ for (var line = first; line <= end; line++) {
269
+ var last = down
270
+ ? getSeedValue(seed.endRowIndex, line)
271
+ : getSeedValue(line, seed.endColumnIndex);
272
+ if (last === undefined)
273
+ return undefined;
274
+ // No count to the stop (no stop, a step that never reaches it, …): the engine would run
275
+ // that line over the whole range, so nothing is filled.
276
+ var count = (0, exports.seriesCountToStop)(last, spec, { date1904: date1904 });
277
+ if (count === undefined)
278
+ return undefined;
279
+ extent = Math.max(extent, count);
280
+ }
281
+ }
76
282
  if (extent <= 0)
77
283
  return undefined;
78
284
  if (down) {
@@ -1 +1 @@
1
- {"version":3,"file":"cell-input-context.atom.d.ts","sourceRoot":"","sources":["../../../atoms/cell-input-context.atom.ts"],"names":[],"mappings":"AAoCA,eAAO,MAAM,mBAAmB;;;;oBACyq6F,CAAC;qBAAwB,CAAC;;;;;;;;;;;CADpp6F,CAAC"}
1
+ {"version":3,"file":"cell-input-context.atom.d.ts","sourceRoot":"","sources":["../../../atoms/cell-input-context.atom.ts"],"names":[],"mappings":"AAoCA,eAAO,MAAM,mBAAmB;;;;oBAC4m8F,CAAC;qBAAwB,CAAC;;;;;;;;;;;CADvl8F,CAAC"}
@@ -16,6 +16,12 @@ export type FillSeriesDialogRequest = {
16
16
  /** Pre-selected axis (a right-drag seeds it from the drag direction). */
17
17
  initialIn?: FillSeriesSpec["in"];
18
18
  onApply(spec: FillSeriesSpec): void;
19
+ /** The workbook's locale, for a date typed in Stop value. */
20
+ locale?: string;
21
+ /** The workbook's 1904 date system, for a date typed in Stop value. */
22
+ date1904?: boolean;
23
+ /** The host's cell-entry reading of Stop value (`CanvasGrid` `parseCellEntryNumber`). */
24
+ parseStop?(text: string): number | undefined;
19
25
  };
20
26
  export declare const fillSeriesDialogAtom: import("jotai").PrimitiveAtom<FillSeriesDialogRequest | null> & {
21
27
  init: FillSeriesDialogRequest | null;
@@ -1 +1 @@
1
- {"version":3,"file":"fill-series-dialog.atom.d.ts","sourceRoot":"","sources":["../../../atoms/fill-series-dialog.atom.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAIvE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C;;;;;;GAMG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,aAAa,CAAC;IAC1B,uFAAuF;IACvF,SAAS,EAAE,aAAa,CAAC,mBAAmB,CAAC,CAAC;IAC9C,yEAAyE;IACzE,SAAS,CAAC,EAAE,cAAc,CAAC,IAAI,CAAC,CAAC;IACjC,OAAO,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI,CAAC;CACrC,CAAC;AAEF,eAAO,MAAM,oBAAoB;;CAA6C,CAAC;AAE/E,eAAO,MAAM,wBAAwB,uKAAsC,CAAC;AAE5E,oEAAoE;AACpE,eAAO,MAAM,uBAAuB,kBAGtB,uBAAuB,SAGpC,CAAC"}
1
+ {"version":3,"file":"fill-series-dialog.atom.d.ts","sourceRoot":"","sources":["../../../atoms/fill-series-dialog.atom.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAIvE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C;;;;;;GAMG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,aAAa,CAAC;IAC1B,uFAAuF;IACvF,SAAS,EAAE,aAAa,CAAC,mBAAmB,CAAC,CAAC;IAC9C,yEAAyE;IACzE,SAAS,CAAC,EAAE,cAAc,CAAC,IAAI,CAAC,CAAC;IACjC,OAAO,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI,CAAC;IACpC,6DAA6D;IAC7D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,uEAAuE;IACvE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,yFAAyF;IACzF,SAAS,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CAC9C,CAAC;AAEF,eAAO,MAAM,oBAAoB;;CAA6C,CAAC;AAE/E,eAAO,MAAM,wBAAwB,uKAAsC,CAAC;AAE5E,oEAAoE;AACpE,eAAO,MAAM,uBAAuB,kBAGtB,uBAAuB,SAGpC,CAAC"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * One axis of a freeze as it is sent: how many lines, and the first of them (absent = line 1).
3
+ * `seq`: the count the axis was noted at (set by {@link useNoteFrozenAreaSent}; absent = the
4
+ * value's `seq`). The grid consumes each axis once, by this count.
5
+ */
6
+ export type FrozenAxisSent = {
7
+ count?: number;
8
+ start?: number | null;
9
+ seq?: number;
10
+ };
11
+ /**
12
+ * The last Freeze Panes / unfreeze this window itself sent, counted, with the area it asked for.
13
+ * `CanvasGrid` reads it so that only this window's own freeze or unfreeze places its view the way a
14
+ * Freeze Panes does (a frozen start, demo-app-monorepo#57258 W-5); the same change arriving from
15
+ * another window keeps the view's first line instead.
16
+ *
17
+ * Set by the engine hook wherever it sends one (`useSpreadsheetEngine`'s `onFreezeRow`,
18
+ * `onFreezeColumn`, and an `onUpdateSheet` that carries frozen counts or starts), by the legacy
19
+ * `useSpreadsheetState` freeze, and by `CanvasGrid`'s own menu, so a host whose ribbon calls those
20
+ * needs nothing more. A host that sends the command some other way calls `useNoteFrozenAreaSent()`
21
+ * right before it.
22
+ */
23
+ export declare const frozenAreaSentAtom: import("jotai").PrimitiveAtom<{
24
+ seq: number;
25
+ sheetId: number;
26
+ rows?: FrozenAxisSent;
27
+ columns?: FrozenAxisSent;
28
+ } | null> & {
29
+ init: {
30
+ seq: number;
31
+ sheetId: number;
32
+ rows?: FrozenAxisSent;
33
+ columns?: FrozenAxisSent;
34
+ } | null;
35
+ };
36
+ export declare const useFrozenAreaSentValue: () => {
37
+ seq: number;
38
+ sheetId: number;
39
+ rows?: FrozenAxisSent;
40
+ columns?: FrozenAxisSent;
41
+ } | null;
42
+ /**
43
+ * Say "the next frozen-area change on this sheet is my own freeze" (see {@link frozenAreaSentAtom}).
44
+ * Noting one axis keeps the other axis's mark on the same sheet, with the count it was noted at,
45
+ * so a host that changes both axes in one act (`onFreezeRow` then `onFreezeColumn`) marks both;
46
+ * an axis the grid has already consumed keeps its old count and is not taken again
47
+ * (rowsncolumns/spreadsheet#1769). A mark on another sheet is dropped.
48
+ */
49
+ export declare const useNoteFrozenAreaSent: () => (sheetId: number, area: {
50
+ rows?: FrozenAxisSent;
51
+ columns?: FrozenAxisSent;
52
+ }) => void;
53
+ //# sourceMappingURL=frozen-area-sent.atom.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frozen-area-sent.atom.d.ts","sourceRoot":"","sources":["../../../atoms/frozen-area-sent.atom.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAErF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,kBAAkB;SACxB,MAAM;aACF,MAAM;WACR,cAAc;cACX,cAAc;;;aAHnB,MAAM;iBACF,MAAM;eACR,cAAc;kBACX,cAAc;;CACX,CAAC;AAEhB,eAAO,MAAM,sBAAsB;SAN5B,MAAM;aACF,MAAM;WACR,cAAc;cACX,cAAc;QAGkD,CAAC;AAE7E;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,kBAGpB,MAAM,QAAQ;IAAE,IAAI,CAAC,EAAE,cAAc,CAAC;IAAC,OAAO,CAAC,EAAE,cAAc,CAAA;CAAE,SAqB9E,CAAC"}
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useNoteFrozenAreaSent = exports.useFrozenAreaSentValue = exports.frozenAreaSentAtom = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var jotai_1 = require("jotai");
6
+ var react_1 = require("react");
7
+ /**
8
+ * The last Freeze Panes / unfreeze this window itself sent, counted, with the area it asked for.
9
+ * `CanvasGrid` reads it so that only this window's own freeze or unfreeze places its view the way a
10
+ * Freeze Panes does (a frozen start, demo-app-monorepo#57258 W-5); the same change arriving from
11
+ * another window keeps the view's first line instead.
12
+ *
13
+ * Set by the engine hook wherever it sends one (`useSpreadsheetEngine`'s `onFreezeRow`,
14
+ * `onFreezeColumn`, and an `onUpdateSheet` that carries frozen counts or starts), by the legacy
15
+ * `useSpreadsheetState` freeze, and by `CanvasGrid`'s own menu, so a host whose ribbon calls those
16
+ * needs nothing more. A host that sends the command some other way calls `useNoteFrozenAreaSent()`
17
+ * right before it.
18
+ */
19
+ exports.frozenAreaSentAtom = (0, jotai_1.atom)(null);
20
+ var useFrozenAreaSentValue = function () { return (0, jotai_1.useAtomValue)(exports.frozenAreaSentAtom); };
21
+ exports.useFrozenAreaSentValue = useFrozenAreaSentValue;
22
+ /**
23
+ * Say "the next frozen-area change on this sheet is my own freeze" (see {@link frozenAreaSentAtom}).
24
+ * Noting one axis keeps the other axis's mark on the same sheet, with the count it was noted at,
25
+ * so a host that changes both axes in one act (`onFreezeRow` then `onFreezeColumn`) marks both;
26
+ * an axis the grid has already consumed keeps its old count and is not taken again
27
+ * (rowsncolumns/spreadsheet#1769). A mark on another sheet is dropped.
28
+ */
29
+ var useNoteFrozenAreaSent = function () {
30
+ var set = (0, jotai_1.useSetAtom)(exports.frozenAreaSentAtom);
31
+ return (0, react_1.useCallback)(function (sheetId, area) {
32
+ return set(function (previous) {
33
+ var _a;
34
+ var seq = ((_a = previous === null || previous === void 0 ? void 0 : previous.seq) !== null && _a !== void 0 ? _a : 0) + 1;
35
+ var kept = previous && previous.sheetId === sheetId ? previous : undefined;
36
+ var axis = function (noted, held) {
37
+ var _a;
38
+ return noted
39
+ ? tslib_1.__assign(tslib_1.__assign({}, noted), { seq: seq }) : held
40
+ ? tslib_1.__assign(tslib_1.__assign({}, held), { seq: (_a = held.seq) !== null && _a !== void 0 ? _a : kept === null || kept === void 0 ? void 0 : kept.seq }) : undefined;
41
+ };
42
+ var rows = axis(area.rows, kept === null || kept === void 0 ? void 0 : kept.rows);
43
+ var columns = axis(area.columns, kept === null || kept === void 0 ? void 0 : kept.columns);
44
+ return tslib_1.__assign(tslib_1.__assign({ seq: seq, sheetId: sheetId }, (rows ? { rows: rows } : {})), (columns ? { columns: columns } : {}));
45
+ });
46
+ }, [set]);
47
+ };
48
+ exports.useNoteFrozenAreaSent = useNoteFrozenAreaSent;
@@ -35,6 +35,8 @@ export * from "./insert-cells-dialog.atom";
35
35
  export * from "./insert-options.atom";
36
36
  export * from "./chart-actions.atom";
37
37
  export * from "./table-auto-expansion.atom";
38
+ export * from "./undo-redo-sent.atom";
39
+ export * from "./frozen-area-sent.atom";
38
40
  export * from "./flash-fill-options.atom";
39
41
  export * from "./calculated-column-fill.atom";
40
42
  export * from "./sparkline-dialog.atom";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../atoms/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iCAAiC,CAAC;AAChD,cAAc,qBAAqB,CAAC;AACpC,cAAc,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portStar(require("./insert-options.atom"), exports);
41
41
  tslib_1.__exportStar(require("./chart-actions.atom"), exports);
42
42
  tslib_1.__exportStar(require("./table-auto-expansion.atom"), exports);
43
+ tslib_1.__exportStar(require("./undo-redo-sent.atom"), exports);
44
+ tslib_1.__exportStar(require("./frozen-area-sent.atom"), exports);
43
45
  tslib_1.__exportStar(require("./flash-fill-options.atom"), exports);
44
46
  tslib_1.__exportStar(require("./calculated-column-fill.atom"), exports);
45
47
  tslib_1.__exportStar(require("./sparkline-dialog.atom"), exports);
@@ -0,0 +1,25 @@
1
+ /**
2
+ * The last undo / redo this window itself sent, counted. `CanvasGrid` reads it so that only this
3
+ * window's own undo or redo of its own Freeze Panes moves its view (a frozen start, demo-app-monorepo
4
+ * #57258 W-5); a change that arrives from another window never does.
5
+ *
6
+ * Set by the engines' undo / redo (`useSpreadsheetEngine`'s `onUndo` / `onRedo` / `undo` / `redo`) and
7
+ * by `CanvasGrid`'s own ⌘Z / ⇧⌘Z, so a host that calls those needs nothing more. A host that runs undo
8
+ * some other way (its own engine call) calls `useNoteUndoRedoSent()` right before it.
9
+ */
10
+ export declare const undoRedoSentAtom: import("jotai").PrimitiveAtom<{
11
+ kind: "undo" | "redo";
12
+ seq: number;
13
+ } | null> & {
14
+ init: {
15
+ kind: "undo" | "redo";
16
+ seq: number;
17
+ } | null;
18
+ };
19
+ export declare const useUndoRedoSentValue: () => {
20
+ kind: "undo" | "redo";
21
+ seq: number;
22
+ } | null;
23
+ /** Say "the next change is my own undo / redo" (see {@link undoRedoSentAtom}). */
24
+ export declare const useNoteUndoRedoSent: () => (kind: "undo" | "redo") => void;
25
+ //# sourceMappingURL=undo-redo-sent.atom.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"undo-redo-sent.atom.d.ts","sourceRoot":"","sources":["../../../atoms/undo-redo-sent.atom.ts"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB;UAAgB,MAAM,GAAG,MAAM;SAAO,MAAM;;;cAA5B,MAAM,GAAG,MAAM;aAAO,MAAM;;CAAgB,CAAC;AAE1F,eAAO,MAAM,oBAAoB;UAFY,MAAM,GAAG,MAAM;SAAO,MAAM;QAED,CAAC;AAEzE,kFAAkF;AAClF,eAAO,MAAM,mBAAmB,eAGrB,MAAM,GAAG,MAAM,SAGzB,CAAC"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useNoteUndoRedoSent = exports.useUndoRedoSentValue = exports.undoRedoSentAtom = void 0;
4
+ var jotai_1 = require("jotai");
5
+ var react_1 = require("react");
6
+ /**
7
+ * The last undo / redo this window itself sent, counted. `CanvasGrid` reads it so that only this
8
+ * window's own undo or redo of its own Freeze Panes moves its view (a frozen start, demo-app-monorepo
9
+ * #57258 W-5); a change that arrives from another window never does.
10
+ *
11
+ * Set by the engines' undo / redo (`useSpreadsheetEngine`'s `onUndo` / `onRedo` / `undo` / `redo`) and
12
+ * by `CanvasGrid`'s own ⌘Z / ⇧⌘Z, so a host that calls those needs nothing more. A host that runs undo
13
+ * some other way (its own engine call) calls `useNoteUndoRedoSent()` right before it.
14
+ */
15
+ exports.undoRedoSentAtom = (0, jotai_1.atom)(null);
16
+ var useUndoRedoSentValue = function () { return (0, jotai_1.useAtomValue)(exports.undoRedoSentAtom); };
17
+ exports.useUndoRedoSentValue = useUndoRedoSentValue;
18
+ /** Say "the next change is my own undo / redo" (see {@link undoRedoSentAtom}). */
19
+ var useNoteUndoRedoSent = function () {
20
+ var set = (0, jotai_1.useSetAtom)(exports.undoRedoSentAtom);
21
+ return (0, react_1.useCallback)(function (kind) { return set(function (previous) { var _a; return ({ kind: kind, seq: ((_a = previous === null || previous === void 0 ? void 0 : previous.seq) !== null && _a !== void 0 ? _a : 0) + 1 }); }); }, [set]);
22
+ };
23
+ exports.useNoteUndoRedoSent = useNoteUndoRedoSent;