@rowsncolumns/spreadsheet 10.19.1 → 10.19.3

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 (31) hide show
  1. package/dist/cjs/api/fill-series.d.ts +30 -8
  2. package/dist/cjs/api/fill-series.d.ts.map +1 -1
  3. package/dist/cjs/api/fill-series.js +136 -24
  4. package/dist/cjs/atoms/frozen-area-sent.atom.d.ts +13 -2
  5. package/dist/cjs/atoms/frozen-area-sent.atom.d.ts.map +1 -1
  6. package/dist/cjs/atoms/frozen-area-sent.atom.js +21 -2
  7. package/dist/cjs/components/canvas-grid/index.d.ts.map +1 -1
  8. package/dist/cjs/components/canvas-grid/index.js +148 -67
  9. package/dist/cjs/components/fill-series-dialog/index.d.ts +3 -3
  10. package/dist/cjs/components/fill-series-dialog/index.d.ts.map +1 -1
  11. package/dist/cjs/components/fill-series-dialog/index.js +15 -10
  12. package/dist/cjs/hooks/use-editable.d.ts +8 -1
  13. package/dist/cjs/hooks/use-editable.d.ts.map +1 -1
  14. package/dist/cjs/hooks/use-editable.js +12 -10
  15. package/dist/cjs/release-date.js +1 -1
  16. package/dist/esm/api/fill-series.d.ts +30 -8
  17. package/dist/esm/api/fill-series.d.ts.map +1 -1
  18. package/dist/esm/api/fill-series.js +133 -23
  19. package/dist/esm/atoms/frozen-area-sent.atom.d.ts +13 -2
  20. package/dist/esm/atoms/frozen-area-sent.atom.d.ts.map +1 -1
  21. package/dist/esm/atoms/frozen-area-sent.atom.js +24 -2
  22. package/dist/esm/components/canvas-grid/index.d.ts.map +1 -1
  23. package/dist/esm/components/canvas-grid/index.js +112 -36
  24. package/dist/esm/components/fill-series-dialog/index.d.ts +3 -3
  25. package/dist/esm/components/fill-series-dialog/index.d.ts.map +1 -1
  26. package/dist/esm/components/fill-series-dialog/index.js +15 -10
  27. package/dist/esm/hooks/use-editable.d.ts +8 -1
  28. package/dist/esm/hooks/use-editable.d.ts.map +1 -1
  29. package/dist/esm/hooks/use-editable.js +7 -5
  30. package/dist/esm/release-date.js +1 -1
  31. package/package.json +1 -1
@@ -27,20 +27,36 @@ export declare const seedRangeForSeriesSpec: (target: GridRange, spec: FillSerie
27
27
  /**
28
28
  * How many series values fit before `stop` is passed, starting from the seed's
29
29
  * last value. `undefined` when the spec has no usable stop (no stop, zero step,
30
- * a step that walks away from the stop, …) — the caller then fills the target
31
- * 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.
32
34
  */
33
- 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;
34
38
  export type FillRangeForSeriesSpecArgs = {
35
39
  /** The range the user selected (seed + cells to fill). */
36
40
  target: GridRange;
37
41
  /** From {@link seedRangeForSeriesSpec}. */
38
42
  seed: GridRange;
39
43
  spec: FillSeriesSpec;
40
- /** 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
+ */
41
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
+ */
42
56
  rowCount: number;
43
57
  columnCount: number;
58
+ /** The workbook counts dates in the 1904 system (a Date series' stop is one of its serials). */
59
+ date1904?: boolean;
44
60
  };
45
61
  /**
46
62
  * The range a Series-dialog fill covers (seed + cells to fill). A selection
@@ -48,9 +64,15 @@ export type FillRangeForSeriesSpecArgs = {
48
64
  * is nothing beyond the seed and no stop): the engines apply the `stop` value
49
65
  * per fill line — every column (Series in Columns) / row (Rows) ends at the
50
66
  * last value within its own stop and the remaining selected cells stay
51
- * untouched, exactly as Excel leaves them. Only a seed-only selection is
52
- * extended along the axis by the number of values that stay within the stop —
53
- * 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.
54
76
  */
55
- 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;
56
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;AAGpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAkC/C;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,oBAAoB,GAC/B,MAAM,MAAM,EACZ,UAAS;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAO,KACpD,MAAM,GAAG,SA8CX,CAAC;AAEF;;;;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,CAAC;IAChB,IAAI,EAAE,cAAc,CAAC;IACrB,oEAAoE;IACpE,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IACxE,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,sBAAsB,GAAI,8DAOpC,0BAA0B,KAAG,SAAS,GAAG,SAwB3C,CAAC"}
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;AAGpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAkC/C;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,oBAAoB,GAC/B,MAAM,MAAM,EACZ,UAAS;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAO,KACpD,MAAM,GAAG,SA8CX,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,GACjC,QAAQ,SAAS,EACjB,MAAM,cAAc,KACnB,SAGyD,CAAC;AAyF7D;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,GAC5B,MAAM,MAAM,EACZ,MAAM,cAAc,EACpB,UAAS;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAO,KACnC,MAAM,GAAG,SA0CX,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG;IACvC,0DAA0D;IAC1D,MAAM,EAAE,SAAS,CAAC;IAClB,2CAA2C;IAC3C,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,EAAE,cAAc,CAAC;IACrB;;;;;OAKG;IACH,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IACxE;;;;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"}
@@ -106,16 +106,99 @@ var seedRangeForSeriesSpec = function (target, spec) {
106
106
  ? tslib_1.__assign(tslib_1.__assign({}, target), { endRowIndex: target.startRowIndex }) : tslib_1.__assign(tslib_1.__assign({}, target), { endColumnIndex: target.startColumnIndex });
107
107
  };
108
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
+ };
109
185
  /**
110
186
  * How many series values fit before `stop` is passed, starting from the seed's
111
187
  * last value. `undefined` when the spec has no usable stop (no stop, zero step,
112
- * a step that walks away from the stop, …) — the caller then fills the target
113
- * 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.
114
192
  */
115
- var seriesCountToStop = function (last, spec) {
193
+ var seriesCountToStop = function (last, spec, options) {
116
194
  var _a, _b;
195
+ if (options === void 0) { options = {}; }
117
196
  var stop = spec.stop;
118
- 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)
119
202
  return undefined;
120
203
  var step = (_a = spec.step) !== null && _a !== void 0 ? _a : 1;
121
204
  if (spec.type === "linear") {
@@ -127,16 +210,29 @@ var seriesCountToStop = function (last, spec) {
127
210
  if (spec.type === "growth") {
128
211
  if (last === 0 || step <= 0 || step === 1)
129
212
  return undefined;
130
- if (Math.sign(last) !== Math.sign(stop))
131
- 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
+ }
132
218
  var n = Math.floor(Math.log(Math.abs(stop) / Math.abs(last)) / Math.log(step) + 1e-9);
133
219
  return n >= 0 ? n : 0;
134
220
  }
135
- if (spec.type === "date" && ((_b = spec.dateUnit) !== null && _b !== void 0 ? _b : "day") === "day") {
136
- 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)
137
225
  return undefined;
138
- var n = Math.floor((stop - last) / step + 1e-9);
139
- 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");
140
236
  }
141
237
  return undefined;
142
238
  };
@@ -147,26 +243,42 @@ exports.seriesCountToStop = seriesCountToStop;
147
243
  * is nothing beyond the seed and no stop): the engines apply the `stop` value
148
244
  * per fill line — every column (Series in Columns) / row (Rows) ends at the
149
245
  * last value within its own stop and the remaining selected cells stay
150
- * untouched, exactly as Excel leaves them. Only a seed-only selection is
151
- * extended along the axis by the number of values that stay within the stop —
152
- * 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.
153
255
  */
154
256
  var fillRangeForSeriesSpec = function (_a) {
155
- var _b;
156
- 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;
157
258
  var down = spec.in === "columns";
158
- // Excel reads the stop against the first seed line's last value.
159
- var last = down
160
- ? getSeedValue(seed.endRowIndex, seed.startColumnIndex)
161
- : getSeedValue(seed.startRowIndex, seed.endColumnIndex);
162
259
  var selectedBeyondSeed = down
163
260
  ? target.endRowIndex - seed.endRowIndex
164
261
  : target.endColumnIndex - seed.endColumnIndex;
165
- var extent = selectedBeyondSeed > 0
166
- ? selectedBeyondSeed
167
- : last === undefined
168
- ? 0
169
- : ((_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
+ }
170
282
  if (extent <= 0)
171
283
  return undefined;
172
284
  if (down) {
@@ -1,7 +1,12 @@
1
- /** One axis of a freeze as it is sent: how many lines, and the first of them (absent = line 1). */
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
+ */
2
6
  export type FrozenAxisSent = {
3
7
  count?: number;
4
8
  start?: number | null;
9
+ seq?: number;
5
10
  };
6
11
  /**
7
12
  * The last Freeze Panes / unfreeze this window itself sent, counted, with the area it asked for.
@@ -34,7 +39,13 @@ export declare const useFrozenAreaSentValue: () => {
34
39
  rows?: FrozenAxisSent;
35
40
  columns?: FrozenAxisSent;
36
41
  } | null;
37
- /** Say "the next frozen-area change on this sheet is my own freeze" (see {@link frozenAreaSentAtom}). */
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
+ */
38
49
  export declare const useNoteFrozenAreaSent: () => (sheetId: number, area: {
39
50
  rows?: FrozenAxisSent;
40
51
  columns?: FrozenAxisSent;
@@ -1 +1 @@
1
- {"version":3,"file":"frozen-area-sent.atom.d.ts","sourceRoot":"","sources":["../../../atoms/frozen-area-sent.atom.ts"],"names":[],"mappings":"AAGA,mGAAmG;AACnG,MAAM,MAAM,cAAc,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC;AAEvE;;;;;;;;;;;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,yGAAyG;AACzG,eAAO,MAAM,qBAAqB,kBAGpB,MAAM,QAAQ;IAAE,IAAI,CAAC,EAAE,cAAc,CAAC;IAAC,OAAO,CAAC,EAAE,cAAc,CAAA;CAAE,SAI9E,CAAC"}
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"}
@@ -19,11 +19,30 @@ var react_1 = require("react");
19
19
  exports.frozenAreaSentAtom = (0, jotai_1.atom)(null);
20
20
  var useFrozenAreaSentValue = function () { return (0, jotai_1.useAtomValue)(exports.frozenAreaSentAtom); };
21
21
  exports.useFrozenAreaSentValue = useFrozenAreaSentValue;
22
- /** Say "the next frozen-area change on this sheet is my own freeze" (see {@link frozenAreaSentAtom}). */
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
+ */
23
29
  var useNoteFrozenAreaSent = function () {
24
30
  var set = (0, jotai_1.useSetAtom)(exports.frozenAreaSentAtom);
25
31
  return (0, react_1.useCallback)(function (sheetId, area) {
26
- return set(function (previous) { var _a; return (tslib_1.__assign({ seq: ((_a = previous === null || previous === void 0 ? void 0 : previous.seq) !== null && _a !== void 0 ? _a : 0) + 1, sheetId: 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
+ });
27
46
  }, [set]);
28
47
  };
29
48
  exports.useNoteFrozenAreaSent = useNoteFrozenAreaSent;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/canvas-grid/index.tsx"],"names":[],"mappings":"AAqEA,OAAO,KASN,MAAM,OAAO,CAAC;AAuRf,OAAO,KAAK,EAGV,QAAQ,EAcT,MAAM,aAAa,CAAC;AA0DrB,OAAO,KAAK,EACV,wBAAwB,EACxB,iBAAiB,EACjB,eAAe,EAEhB,MAAM,WAAW,CAAC;AAkuQnB,eAAO,MAAM,UAAU,EAA4C,CACjE,CAAC,SAAS,QAAQ,CAAC,GAAG,CAAC,EAEvB,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,GACvB,wBAAwB,GAAG;IAAE,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAA;CAAE,KAChE,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/canvas-grid/index.tsx"],"names":[],"mappings":"AAqEA,OAAO,KASN,MAAM,OAAO,CAAC;AAuRf,OAAO,KAAK,EAGV,QAAQ,EAcT,MAAM,aAAa,CAAC;AA0DrB,OAAO,KAAK,EACV,wBAAwB,EACxB,iBAAiB,EACjB,eAAe,EAEhB,MAAM,WAAW,CAAC;AAi0QnB,eAAO,MAAM,UAAU,EAA4C,CACjE,CAAC,SAAS,QAAQ,CAAC,GAAG,CAAC,EAEvB,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,GACvB,wBAAwB,GAAG;IAAE,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAA;CAAE,KAChE,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC"}