@gridsheet/react-core 3.0.5 → 3.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,1103 +0,0 @@
1
- import { useRef as V, useEffect as O, useState as K } from "react";
2
- import { x2c as ne, y2r as se, a2p as N, Autofill as ie, areaToZone as L, zoneToArea as z, areaDiff as j, restrictZone as U, matrixShape as ce, superposeArea as oe, p2a as re, operations as G, DEFAULT_HEIGHT as F, DEFAULT_WIDTH as k, smartScroll as $, createBook as de } from "@gridsheet/core";
3
- const p = (c) => {
4
- const e = { ...c };
5
- return e.selectingZone != null && e.selectingZone.endY === -1 && e.selectingZone.endX === -1 && delete e.selectingZone, e;
6
- }, W = (c, e) => {
7
- const { choosing: s, selectingZone: t } = c;
8
- let { y: n, x: i } = s, { startY: o, startX: d, endY: r, endX: u } = t;
9
- const [l, a] = [e.numRows, e.numCols];
10
- return n > l && (n = l), i > a && (i = a), o > l && (o = l), r > l && (r = l), d > a && (d = a), u > a && (u = a), {
11
- choosing: { y: n, x: i },
12
- selectingZone: { startY: o, startX: d, endY: r, endX: u }
13
- };
14
- }, _ = "gs-flash-overlay--active", le = 600, D = (c) => {
15
- c && (c.classList.remove(_), c.offsetWidth, c.classList.add(_), setTimeout(() => c.classList.remove(_), le));
16
- }, J = (c, e, s) => ({
17
- ...c,
18
- sheetReactive: { current: e },
19
- callback: (t) => {
20
- s == null || s(t), D(c.flashRef.current);
21
- }
22
- }), M = (c, e) => {
23
- const { searchQuery: s, searchCaseSensitive: t, searchRegex: n, searchRange: i } = e;
24
- let { choosing: o } = e;
25
- if (!s)
26
- return { matchingCells: [] };
27
- const d = [];
28
- let r;
29
- if (n)
30
- try {
31
- const x = t ? "" : "i", w = new RegExp(s, x);
32
- r = (g) => w.test(g);
33
- } catch {
34
- const w = t ? s : s.toLowerCase();
35
- r = (g) => (t ? g : g.toLowerCase()).indexOf(w) !== -1;
36
- }
37
- else {
38
- const x = t ? s : s.toLowerCase();
39
- r = (w) => (t ? w : w.toLowerCase()).indexOf(x) !== -1;
40
- }
41
- let u = 1, l = c.bottom, a = 1, f = c.right;
42
- i && (u = i.startY, l = i.endY, a = i.startX, f = i.endX);
43
- for (let x = u; x <= l; x++)
44
- for (let w = a; w <= f; w++) {
45
- const g = c.getSerializedValue({ point: { y: x, x: w } });
46
- r(g) && d.push(`${ne(w)}${se(x)}`);
47
- }
48
- const m = d.length === e.matchingCells.length ? e.matchingCellIndex : 0;
49
- if (d.length > 0) {
50
- const x = d[m];
51
- o = N(x);
52
- }
53
- return { matchingCells: d, searchQuery: s, matchingCellIndex: m, choosing: o };
54
- }, Zt = (c) => {
55
- const { sheetId: e, sheetReactive: s } = c, t = s.current;
56
- return !t || e === t.registry.editingSheetId ? !1 : !!t.registry.editingAddress;
57
- }, E = { startY: -1, startX: -1, endY: -1, endX: -1 }, ee = {}, Xt = (c, e) => {
58
- var d, r;
59
- const s = ee[e.type];
60
- if (s == null)
61
- return c;
62
- const t = (d = c.sheetReactive.current) == null ? void 0 : d.registry;
63
- if ((r = t == null ? void 0 : t._strictModeCache) != null && r.has(e)) {
64
- const u = t._strictModeCache.get(e);
65
- return t._strictModeCache.delete(e), u;
66
- }
67
- const { callback: n, ...i } = s.reduce(c, e.value);
68
- n == null || n(i);
69
- const o = { ...c, ...i };
70
- return t && (t._strictModeCache || (t._strictModeCache = /* @__PURE__ */ new Map()), t._strictModeCache.set(e, o), queueMicrotask(() => {
71
- var u;
72
- (u = t._strictModeCache) == null || u.delete(e);
73
- })), o;
74
- }, B = class B {
75
- constructor() {
76
- this.actionId = 1;
77
- }
78
- reduce(e, s) {
79
- return e;
80
- }
81
- call(e) {
82
- return {
83
- type: this.actionId,
84
- value: e
85
- };
86
- }
87
- bind() {
88
- return this.actionId = B.head++, ee[this.actionId] = this, this.call.bind(this);
89
- }
90
- };
91
- B.head = 1;
92
- let h = B;
93
- class ae extends h {
94
- reduce(e, s) {
95
- const t = s, { sheetReactive: n } = e;
96
- return n.current == null ? e : {
97
- ...e,
98
- ...M(n.current, { ...e, searchQuery: t }),
99
- searchQuery: t
100
- };
101
- }
102
- }
103
- const Mt = new ae().bind();
104
- class ue extends h {
105
- reduce(e, s) {
106
- const t = s, { sheetReactive: n } = e;
107
- return n.current == null ? e : {
108
- ...e,
109
- ...M(n.current, { ...e, searchCaseSensitive: t }),
110
- searchCaseSensitive: t
111
- };
112
- }
113
- }
114
- const Et = new ue().bind();
115
- class he extends h {
116
- reduce(e, s) {
117
- const t = s, { sheetReactive: n } = e;
118
- return n.current == null ? e : {
119
- ...e,
120
- ...M(n.current, { ...e, searchRegex: t }),
121
- searchRegex: t
122
- };
123
- }
124
- }
125
- const Tt = new he().bind();
126
- class fe extends h {
127
- reduce(e, s) {
128
- const t = s, { sheetReactive: n } = e;
129
- return n.current == null ? e : {
130
- ...e,
131
- ...M(n.current, { ...e, searchRange: t }),
132
- searchRange: t
133
- };
134
- }
135
- }
136
- const Ht = new fe().bind();
137
- class ge extends h {
138
- reduce(e, s) {
139
- return {
140
- ...e,
141
- editingAddress: s
142
- };
143
- }
144
- }
145
- const Ft = new ge().bind();
146
- class Re extends h {
147
- reduce(e, s) {
148
- return {
149
- ...e,
150
- autofillDraggingTo: s
151
- };
152
- }
153
- }
154
- const kt = new Re().bind();
155
- class we extends h {
156
- reduce(e, s) {
157
- const t = new ie(e, s), n = t.applied, i = L(t.wholeArea);
158
- return {
159
- ...e,
160
- sheetReactive: { current: n },
161
- ...M(n, e),
162
- ...W(e, n),
163
- selectingZone: i,
164
- leftHeaderSelecting: !1,
165
- topHeaderSelecting: !1,
166
- autofillDraggingTo: null
167
- };
168
- }
169
- }
170
- const Lt = new we().bind();
171
- class Se extends h {
172
- reduce(e, s) {
173
- return {
174
- ...e,
175
- contextMenuPosition: s
176
- };
177
- }
178
- }
179
- const Dt = new Se().bind();
180
- class xe extends h {
181
- reduce(e, s) {
182
- return {
183
- ...e,
184
- resizingPositionY: s
185
- };
186
- }
187
- }
188
- const Pt = new xe().bind();
189
- class ye extends h {
190
- reduce(e, s) {
191
- return {
192
- ...e,
193
- resizingPositionX: s
194
- };
195
- }
196
- }
197
- const zt = new ye().bind();
198
- class pe extends h {
199
- reduce(e, s) {
200
- return {
201
- ...e,
202
- entering: s
203
- };
204
- }
205
- }
206
- const Bt = new pe().bind();
207
- class me extends h {
208
- reduce(e, s) {
209
- return {
210
- ...e,
211
- sheetReactive: { current: s },
212
- ...M(s, e),
213
- ...W(e, s)
214
- };
215
- }
216
- }
217
- const ve = new me().bind();
218
- class be extends h {
219
- reduce(e, s) {
220
- return {
221
- ...e,
222
- editorRect: s
223
- };
224
- }
225
- }
226
- const Wt = new be().bind();
227
- class Ae extends h {
228
- reduce(e, s) {
229
- return {
230
- ...e,
231
- dragging: s
232
- };
233
- }
234
- }
235
- const Ut = new Ae().bind();
236
- class Ce extends h {
237
- reduce(e, s) {
238
- return {
239
- ...e,
240
- editingAddress: ""
241
- };
242
- }
243
- }
244
- const Ie = new Ce().bind();
245
- class Ye extends h {
246
- reduce(e, s) {
247
- const { sheetReactive: t } = e, n = t.current;
248
- return n ? {
249
- ...e,
250
- callback: ({ sheetReactive: i }) => {
251
- n.registry.transmit({
252
- copyingSheetId: n.id,
253
- copyingZone: s,
254
- cutting: !1
255
- });
256
- }
257
- } : e;
258
- }
259
- }
260
- const Ze = new Ye().bind();
261
- class Xe extends h {
262
- reduce(e, s) {
263
- const { sheetReactive: t } = e, n = t.current;
264
- return n ? {
265
- ...e,
266
- callback: ({ sheetReactive: i }) => {
267
- n.registry.transmit({
268
- copyingSheetId: n.id,
269
- copyingZone: s,
270
- cutting: !0
271
- });
272
- }
273
- } : e;
274
- }
275
- }
276
- const Me = new Xe().bind();
277
- class Ee extends h {
278
- reduce(e, s) {
279
- const { choosing: t, selectingZone: n, sheetReactive: i } = e, o = i.current;
280
- if (!o)
281
- return e;
282
- const { registry: d } = o, { copyingSheetId: r, copyingZone: u, cutting: l } = d, a = o.getSheetBySheetId(r);
283
- let f = z(n);
284
- const m = z(u), { matrix: x, onlyValue: w } = s;
285
- if (l) {
286
- if (!a)
287
- return e;
288
- const Y = m, { rows: C, cols: v } = j(m), R = f.top !== -1 ? {
289
- top: f.top,
290
- left: f.left,
291
- bottom: f.top + C,
292
- right: f.left + v
293
- } : {
294
- top: t.y,
295
- left: t.x,
296
- bottom: t.y + C,
297
- right: t.x + v
298
- }, y = U(L(R)), X = o.move({
299
- srcSheet: a,
300
- src: Y,
301
- dst: R,
302
- operator: "USER",
303
- undoReflection: p({
304
- sheetId: a.id,
305
- selectingZone: y,
306
- choosing: t,
307
- transmit: { copyingSheetId: a.id, copyingZone: u, cutting: !0 }
308
- }),
309
- redoReflection: p({
310
- sheetId: a.id,
311
- choosing: t,
312
- transmit: { copyingSheetId: a.id, copyingZone: E }
313
- })
314
- });
315
- return {
316
- ...e,
317
- ...M(X, e),
318
- sheetReactive: { current: X },
319
- selectingZone: y,
320
- inputting: X.getSerializedValue({ point: t, resolution: "RAW" }),
321
- callback: ({ sheetReactive: H }) => {
322
- d.transmit({
323
- cutting: !1,
324
- copyingZone: E
325
- });
326
- }
327
- };
328
- }
329
- let g, { y: S, x: Z } = t;
330
- if (m.top === -1) {
331
- const { rows: Y, cols: C } = ce({ matrix: x, base: -1 });
332
- f = {
333
- top: S,
334
- left: Z,
335
- bottom: S + Y,
336
- right: Z + C
337
- };
338
- const v = U(L(f));
339
- g = o.writeRawCellMatrix({
340
- point: { y: S, x: Z },
341
- matrix: x,
342
- onlyValue: w,
343
- undoReflection: p({
344
- sheetId: o.id,
345
- selectingZone: v,
346
- choosing: t
347
- }),
348
- redoReflection: p({
349
- sheetId: o.id,
350
- selectingZone: v,
351
- choosing: t
352
- })
353
- });
354
- } else {
355
- if (a == null)
356
- return e;
357
- let { rows: Y, cols: C } = j(m);
358
- if (f.top !== -1) {
359
- S = f.top, Z = f.left;
360
- const v = oe(f, m);
361
- Y = v.rows, C = v.cols;
362
- }
363
- f = { top: S, left: Z, bottom: S + Y, right: Z + C }, g = o.copy({
364
- srcSheet: a,
365
- src: m,
366
- dst: f,
367
- onlyValue: w,
368
- operator: "USER",
369
- undoReflection: p({
370
- sheetId: a.id,
371
- transmit: { copyingZone: u },
372
- choosing: t,
373
- selectingZone: n
374
- }),
375
- redoReflection: p({
376
- sheetId: a.id,
377
- transmit: { copyingSheetId: a.id, copyingZone: E },
378
- choosing: t,
379
- selectingZone: L(f)
380
- })
381
- });
382
- }
383
- const I = U(L(f));
384
- return I.endX = Math.min(I.endX, g.numCols), I.endY = Math.min(I.endY, g.numRows), {
385
- ...e,
386
- sheetReactive: { current: g },
387
- selectingZone: I,
388
- inputting: g.getSerializedValue({ point: t, resolution: "RAW" }),
389
- ...M(g, e),
390
- callback: ({ sheetReactive: Y }) => {
391
- d.transmit({
392
- copyingZone: E
393
- });
394
- }
395
- };
396
- }
397
- }
398
- const Te = new Ee().bind();
399
- class He extends h {
400
- reduce(e, s) {
401
- const { sheetReactive: t } = e;
402
- return {
403
- ...e,
404
- editingAddress: "",
405
- leftHeaderSelecting: !1,
406
- topHeaderSelecting: !1,
407
- callback: ({ sheetReactive: n }) => {
408
- n.current.registry.transmit({
409
- copyingZone: E,
410
- cutting: !1
411
- });
412
- }
413
- };
414
- }
415
- }
416
- const Fe = new He().bind();
417
- class ke extends h {
418
- reduce(e, s) {
419
- return {
420
- ...e,
421
- choosing: s,
422
- entering: !0
423
- };
424
- }
425
- }
426
- const Le = new ke().bind();
427
- class De extends h {
428
- reduce(e, s) {
429
- return {
430
- ...e,
431
- selectingZone: s,
432
- leftHeaderSelecting: !1,
433
- topHeaderSelecting: !1
434
- };
435
- }
436
- }
437
- const Pe = new De().bind();
438
- class ze extends h {
439
- reduce(e, s) {
440
- const { range: t, numCols: n } = s, { start: i, end: o } = t, d = e.sheetReactive.current, r = {
441
- startY: i,
442
- startX: 1,
443
- endY: o,
444
- endX: n
445
- };
446
- let u = i;
447
- if (d) {
448
- for (let l = i; l <= o; l++)
449
- if (!d.isRowFiltered(l)) {
450
- u = l;
451
- break;
452
- }
453
- }
454
- return {
455
- ...e,
456
- selectingZone: r,
457
- choosing: { y: u, x: 1 },
458
- leftHeaderSelecting: !0,
459
- topHeaderSelecting: !1
460
- };
461
- }
462
- }
463
- const Be = new ze().bind();
464
- class We extends h {
465
- reduce(e, s) {
466
- const { range: t, numRows: n } = s, { start: i, end: o } = t, d = e.sheetReactive.current, r = {
467
- startY: 1,
468
- startX: i,
469
- endY: n,
470
- endX: o
471
- };
472
- let u = 1;
473
- if (d) {
474
- for (let l = 1; l <= n; l++)
475
- if (!d.isRowFiltered(l)) {
476
- u = l;
477
- break;
478
- }
479
- }
480
- return {
481
- ...e,
482
- selectingZone: r,
483
- choosing: { y: u, x: i },
484
- leftHeaderSelecting: !1,
485
- topHeaderSelecting: !0
486
- };
487
- }
488
- }
489
- const Ue = new We().bind();
490
- class _e extends h {
491
- reduce(e, s) {
492
- const { startY: t, startX: n } = e.selectingZone, i = {
493
- startY: t,
494
- startX: n,
495
- endY: s.y,
496
- endX: s.x
497
- };
498
- return t === s.y && n === s.x && (i.endY = -1, i.endX = -1), { ...e, selectingZone: i };
499
- }
500
- }
501
- const Oe = new _e().bind();
502
- class qe extends h {
503
- reduce(e, s) {
504
- const { matchingCells: t } = e;
505
- let { matchingCellIndex: n, choosing: i } = e;
506
- if (n += s, n >= t.length ? n = 0 : n < 0 && (n = t.length - 1), t.length > 0) {
507
- const o = t[n];
508
- i = N(o);
509
- }
510
- return { ...e, matchingCells: t, matchingCellIndex: n, choosing: i };
511
- }
512
- }
513
- const Qe = new qe().bind();
514
- class Ve extends h {
515
- reduce(e, s) {
516
- let { value: t, point: n } = s;
517
- const { choosing: i, selectingZone: o, sheetReactive: d } = e;
518
- n == null && (n = i);
519
- const r = d.current;
520
- if (!r)
521
- return e;
522
- const u = r.write({
523
- point: n,
524
- value: t,
525
- operator: "USER",
526
- undoReflection: p({
527
- sheetId: r.id,
528
- selectingZone: o,
529
- choosing: n
530
- }),
531
- redoReflection: p({
532
- sheetId: r.id,
533
- selectingZone: o,
534
- choosing: n
535
- })
536
- });
537
- return {
538
- ...e,
539
- ...M(u, e),
540
- sheetReactive: { current: u },
541
- callback: ({ sheetReactive: l }) => {
542
- r.registry.transmit({
543
- copyingZone: E
544
- });
545
- }
546
- };
547
- }
548
- }
549
- const je = new Ve().bind();
550
- class Ge extends h {
551
- reduce(e, s) {
552
- var x;
553
- const { choosing: t, selectingZone: n, sheetReactive: i } = e, o = i.current;
554
- if (!o)
555
- return e;
556
- let d = z(n);
557
- if (d.top === -1) {
558
- const { y: w, x: g } = t;
559
- d = { top: w, left: g, bottom: w, right: g };
560
- }
561
- const { top: r, left: u, bottom: l, right: a } = d, f = {};
562
- let m = 0;
563
- for (let w = r; w <= l; w++)
564
- if (!o.isRowFiltered(w))
565
- for (let g = u; g <= a; g++) {
566
- const S = o.getCell({ y: w, x: g }, { resolution: "SYSTEM" }), Z = re({ y: w, x: g });
567
- G.hasOperation(S == null ? void 0 : S.prevention, G.Write) || ((x = o.getSystem({ y: w, x: g })) == null ? void 0 : x.spilledFrom) == null && (S == null ? void 0 : S.value) != null && (f[Z] = { value: void 0 }, m++);
568
- }
569
- return m === 0 ? e : (o.update({
570
- diff: f,
571
- partial: !0,
572
- operator: "USER",
573
- undoReflection: p({
574
- sheetId: o.id,
575
- selectingZone: n,
576
- choosing: t
577
- }),
578
- redoReflection: p({
579
- sheetId: o.id,
580
- selectingZone: n,
581
- choosing: t
582
- })
583
- }), {
584
- ...e,
585
- ...M(o, e),
586
- sheetReactive: { current: o }
587
- });
588
- }
589
- }
590
- const Ke = new Ge().bind();
591
- class Ne extends h {
592
- reduce(e, s) {
593
- const { sheetReactive: t } = e, n = t.current;
594
- if (!n)
595
- return e;
596
- const { history: i, callback: o } = n.undo();
597
- if (i == null)
598
- return e;
599
- if (i.dstSheetId !== n.id) {
600
- const { dispatch: d, store: r } = n.registry.contextsBySheetId[i.dstSheetId];
601
- return d(
602
- te({
603
- ...r,
604
- ...i.undoReflection,
605
- sheetReactive: { current: r.sheetReactive.current }
606
- })
607
- ), D(r.flashRef.current), i.srcSheetId === n.id ? J(e, n, o) : e;
608
- }
609
- return {
610
- ...e,
611
- ...W(e, n),
612
- ...i.undoReflection,
613
- ...M(n, e),
614
- sheetReactive: { current: n },
615
- callback: (d) => {
616
- o == null || o(d), D(e.flashRef.current);
617
- }
618
- };
619
- }
620
- }
621
- const $e = new Ne().bind();
622
- class Je extends h {
623
- reduce(e, s) {
624
- const { sheetReactive: t } = e, n = t.current;
625
- if (n == null)
626
- return e;
627
- const { history: i, newSheet: o, callback: d } = n.redo();
628
- if (i == null)
629
- return e;
630
- if (i.dstSheetId !== n.id) {
631
- const { dispatch: r, store: u } = n.registry.contextsBySheetId[i.dstSheetId];
632
- return r(
633
- te({
634
- ...u,
635
- ...i.redoReflection,
636
- sheetReactive: { current: u.sheetReactive.current }
637
- })
638
- ), D(u.flashRef.current), i.srcSheetId === n.id ? J(e, n, d) : e;
639
- }
640
- return {
641
- ...e,
642
- ...W(e, n),
643
- ...i.redoReflection,
644
- ...M(n, e),
645
- sheetReactive: { current: n },
646
- callback: (r) => {
647
- d == null || d(r), D(e.flashRef.current);
648
- }
649
- };
650
- }
651
- }
652
- const et = new Je().bind();
653
- class tt extends h {
654
- reduce(e, s) {
655
- var R, y, X, H;
656
- const { shiftKey: t, deltaY: n, deltaX: i, numRows: o, numCols: d } = s, { choosing: r, sheetReactive: u, tabularRef: l } = e, a = u.current;
657
- if (a == null)
658
- return e;
659
- let { selectingZone: f } = e;
660
- const { y: m, x } = r;
661
- if (t) {
662
- const [b, P] = [
663
- f.endY === -1 ? m : f.endY,
664
- f.endX === -1 ? x : f.endX
665
- ], [T, A] = [b + n, P + i];
666
- return T < 1 || o < T || A < 1 || d < A ? e : (f = m === T && x === A ? { startY: -1, startX: -1, endY: -1, endX: -1 } : { startY: m, startX: x, endY: T, endX: A }, {
667
- ...e,
668
- selectingZone: f
669
- });
670
- }
671
- const [w, g] = [m + n, x + i];
672
- if (w < 1 || o < w || g < 1 || d < g)
673
- return e;
674
- let S = w;
675
- if (a.isRowFiltered(S)) {
676
- const b = n >= 0 ? 1 : -1;
677
- for (; S >= 1 && S <= o && a.isRowFiltered(S); )
678
- S += b;
679
- if (S < 1 || S > o)
680
- return e;
681
- }
682
- let { y: Z, x: I, height: Y, width: C } = e.editorRect;
683
- if (n > 0)
684
- for (let b = m; b < S; b++)
685
- Z += ((R = a.getCell({ y: b, x: 0 }, { resolution: "SYSTEM" })) == null ? void 0 : R.height) || F;
686
- else if (n < 0)
687
- for (let b = m - 1; b >= S; b--)
688
- Z -= ((y = a.getCell({ y: b, x: 0 }, { resolution: "SYSTEM" })) == null ? void 0 : y.height) || F;
689
- if (i > 0)
690
- for (let b = x; b < g; b++)
691
- I += ((X = a.getCell({ y: 0, x: b }, { resolution: "SYSTEM" })) == null ? void 0 : X.width) || k;
692
- else if (i < 0)
693
- for (let b = x - 1; b >= g; b--)
694
- I -= ((H = a.getCell({ y: 0, x: b }, { resolution: "SYSTEM" })) == null ? void 0 : H.width) || k;
695
- const v = a.getCell({ y: S, x: g }, { resolution: "SYSTEM" });
696
- return Y = (v == null ? void 0 : v.height) || F, C = (v == null ? void 0 : v.width) || k, $(a, l.current, { y: S, x: g }), {
697
- ...e,
698
- selectingZone: { startY: -1, startX: -1, endY: -1, endX: -1 },
699
- choosing: { y: S, x: g },
700
- editorRect: { y: Z, x: I, height: Y, width: C }
701
- };
702
- }
703
- }
704
- const nt = new tt().bind();
705
- class st extends h {
706
- reduce(e, s) {
707
- var H, b, P, T;
708
- const { numRows: t, numCols: n } = s;
709
- let { deltaY: i, deltaX: o } = s;
710
- const { choosing: d, selectingZone: r, sheetReactive: u, tabularRef: l } = e, a = u.current;
711
- if (a == null)
712
- return e;
713
- let { y: f, x: m, height: x, width: w } = e.editorRect;
714
- const { y: g, x: S } = d, Z = z(r), { top: I, left: Y, bottom: C, right: v } = Z;
715
- let [R, y] = [g + i, S + o];
716
- if (R < I && I !== -1 && (i = C - R, R = C, y > Y ? (y--, o--) : (o = v - y, y = v)), R > C && C !== -1 && (i = I - R, R = I, y < v ? (y++, o++) : (o = Y - y, y = Y)), y < Y && Y !== -1 && (o = v - y, y = v, R > I ? (R--, i--) : (i = C - R, R = C)), y > v && v !== -1 && (o = Y - y, y = Y, R < C ? (R++, i++) : (i = I - R, R = I)), R < 1 || t < R || y < 1 || n < y)
717
- return e;
718
- if (a.isRowFiltered(R)) {
719
- const A = i >= 0 ? 1 : -1, q = I !== -1 ? I : 1, Q = C !== -1 ? C : t;
720
- for (; R >= q && R <= Q && a.isRowFiltered(R); )
721
- R += A;
722
- if (R < q || R > Q || a.isRowFiltered(R))
723
- return e;
724
- }
725
- if (i > 0)
726
- for (let A = g; A < R; A++)
727
- f += ((H = a.getCell({ y: A, x: 0 }, { resolution: "SYSTEM" })) == null ? void 0 : H.height) || F;
728
- else if (i < 0)
729
- for (let A = g - 1; A >= R; A--)
730
- f -= ((b = a.getCell({ y: A, x: 0 }, { resolution: "SYSTEM" })) == null ? void 0 : b.height) || F;
731
- if (o > 0)
732
- for (let A = S; A < y; A++)
733
- m += ((P = a.getCell({ y: 0, x: A }, { resolution: "SYSTEM" })) == null ? void 0 : P.width) || k;
734
- else if (o < 0)
735
- for (let A = S - 1; A >= y; A--)
736
- m -= ((T = a.getCell({ y: 0, x: A }, { resolution: "SYSTEM" })) == null ? void 0 : T.width) || k;
737
- const X = a.getCell({ y: R, x: y }, { resolution: "SYSTEM" });
738
- return x = (X == null ? void 0 : X.height) || F, w = (X == null ? void 0 : X.width) || k, $(a, l.current, { y: R, x: y }), {
739
- ...e,
740
- choosing: { y: R, x: y },
741
- editorRect: { y: f, x: m, height: x, width: w }
742
- };
743
- }
744
- }
745
- const it = new st().bind();
746
- class ct extends h {
747
- reduce(e, s) {
748
- return {
749
- ...e,
750
- inputting: s
751
- };
752
- }
753
- }
754
- const _t = new ct().bind();
755
- class ot extends h {
756
- reduce(e, s) {
757
- const { numRows: t, y: n, operator: i } = s, { sheetReactive: o, selectingZone: d, choosing: r } = e, u = o.current;
758
- return u == null ? e : (u.insertRows({
759
- y: n,
760
- numRows: t,
761
- baseY: n,
762
- operator: i,
763
- undoReflection: p({
764
- sheetId: u.id,
765
- selectingZone: d,
766
- choosing: r
767
- }),
768
- redoReflection: p({
769
- sheetId: u.id,
770
- selectingZone: d,
771
- choosing: r
772
- })
773
- }), {
774
- ...e,
775
- sheetReactive: { current: u }
776
- });
777
- }
778
- }
779
- const rt = new ot().bind();
780
- class dt extends h {
781
- reduce(e, s) {
782
- const { numRows: t, y: n, operator: i } = s, { sheetReactive: o, selectingZone: d, choosing: r, editorRef: u } = e, l = o.current;
783
- if (l == null)
784
- return e;
785
- const a = {
786
- ...d,
787
- startY: d.startY + t,
788
- endY: d.endY + t
789
- }, f = { ...r, y: r.y + t };
790
- return l.insertRows({
791
- y: n + 1,
792
- numRows: t,
793
- baseY: n,
794
- operator: i,
795
- undoReflection: p({
796
- sheetId: l.id,
797
- selectingZone: d,
798
- choosing: r
799
- }),
800
- redoReflection: p({
801
- sheetId: l.id,
802
- selectingZone: a,
803
- choosing: f
804
- })
805
- }), {
806
- ...e,
807
- selectingZone: a,
808
- choosing: f,
809
- sheetReactive: { current: l }
810
- };
811
- }
812
- }
813
- const lt = new dt().bind();
814
- class at extends h {
815
- reduce(e, s) {
816
- const { numCols: t, x: n, operator: i } = s, { sheetReactive: o, selectingZone: d, choosing: r, editorRef: u } = e, l = o.current;
817
- return l == null ? e : (l.insertCols({
818
- x: n,
819
- numCols: t,
820
- baseX: n,
821
- operator: i,
822
- undoReflection: p({
823
- sheetId: l.id,
824
- selectingZone: d,
825
- choosing: r
826
- }),
827
- redoReflection: p({
828
- sheetId: l.id,
829
- selectingZone: d,
830
- choosing: r
831
- })
832
- }), {
833
- ...e,
834
- sheetReactive: { current: l }
835
- });
836
- }
837
- }
838
- const ut = new at().bind();
839
- class ht extends h {
840
- reduce(e, s) {
841
- const { numCols: t, x: n, operator: i } = s, { sheetReactive: o, selectingZone: d, choosing: r } = e, u = o.current;
842
- if (u == null)
843
- return e;
844
- const l = {
845
- ...d,
846
- startX: d.startX + t,
847
- endX: d.endX + t
848
- }, a = { ...r, x: r.x + t };
849
- return d.startX += t, d.endX += t, u.insertCols({
850
- x: n + 1,
851
- numCols: t,
852
- baseX: n,
853
- operator: i,
854
- undoReflection: p({
855
- sheetId: u.id,
856
- selectingZone: d,
857
- choosing: r
858
- }),
859
- redoReflection: p({
860
- sheetId: u.id,
861
- selectingZone: l,
862
- choosing: a
863
- })
864
- }), {
865
- ...e,
866
- selectingZone: l,
867
- choosing: a,
868
- sheetReactive: { current: u }
869
- };
870
- }
871
- }
872
- const ft = new ht().bind();
873
- class gt extends h {
874
- reduce(e, s) {
875
- const { numRows: t, y: n, operator: i } = s, { sheetReactive: o, selectingZone: d, choosing: r, editorRef: u } = e, l = o.current;
876
- return l == null ? e : (l.removeRows({
877
- y: n,
878
- numRows: t,
879
- operator: i,
880
- undoReflection: p({
881
- sheetId: l.id,
882
- selectingZone: d,
883
- choosing: r,
884
- sheetHeight: e.sheetHeight
885
- }),
886
- redoReflection: p({
887
- sheetId: l.id,
888
- selectingZone: d,
889
- choosing: r
890
- })
891
- }), {
892
- ...e,
893
- sheetReactive: { current: l }
894
- });
895
- }
896
- }
897
- const Rt = new gt().bind();
898
- class wt extends h {
899
- reduce(e, s) {
900
- const { numCols: t, x: n, operator: i } = s, { sheetReactive: o, selectingZone: d, choosing: r, editorRef: u } = e, l = o.current;
901
- return l == null ? e : (l.removeCols({
902
- x: n,
903
- numCols: t,
904
- operator: i,
905
- undoReflection: p({
906
- sheetId: l.id,
907
- selectingZone: d,
908
- choosing: r,
909
- sheetWidth: e.sheetWidth
910
- }),
911
- redoReflection: p({
912
- sheetId: l.id,
913
- selectingZone: d,
914
- choosing: r
915
- })
916
- }), {
917
- ...e,
918
- sheetReactive: { current: l }
919
- });
920
- }
921
- }
922
- const St = new wt().bind();
923
- class xt extends h {
924
- reduce(e, s) {
925
- const { x: t, direction: n } = s, { sheetReactive: i, selectingZone: o, choosing: d } = e, r = i.current;
926
- if (r == null)
927
- return e;
928
- r.sortRows({ x: t, direction: n });
929
- const u = p({ sheetId: r.id, selectingZone: o, choosing: d });
930
- return r.registry.lastHistory && (r.registry.lastHistory.undoReflection = u, r.registry.lastHistory.redoReflection = u), {
931
- ...e,
932
- sheetReactive: { current: r }
933
- };
934
- }
935
- }
936
- const yt = new xt().bind();
937
- class pt extends h {
938
- reduce(e, s) {
939
- const { x: t, filter: n } = s, { sheetReactive: i, selectingZone: o, choosing: d } = e, r = i.current;
940
- if (r == null)
941
- return e;
942
- r.filterRows({ x: t, filter: n });
943
- const u = p({ sheetId: r.id, selectingZone: o, choosing: d });
944
- r.registry.lastHistory && (r.registry.lastHistory.undoReflection = u, r.registry.lastHistory.redoReflection = u);
945
- let l = d;
946
- if (r.isRowFiltered(d.y)) {
947
- for (let a = 1; a <= r.numRows; a++)
948
- if (!r.isRowFiltered(a)) {
949
- l = { y: a, x: d.x };
950
- break;
951
- }
952
- }
953
- return {
954
- ...e,
955
- choosing: l,
956
- selectingZone: l !== d ? E : o,
957
- sheetReactive: { current: r },
958
- callback: ({ sheetReactive: a }) => {
959
- const f = a.current;
960
- f && f.registry.transmit({
961
- cutting: !1,
962
- copyingZone: E
963
- });
964
- }
965
- };
966
- }
967
- }
968
- const mt = new pt().bind();
969
- class vt extends h {
970
- reduce(e, s) {
971
- return {
972
- ...e,
973
- columnMenuState: s
974
- };
975
- }
976
- }
977
- const Ot = new vt().bind();
978
- class bt extends h {
979
- reduce(e, s) {
980
- return {
981
- ...e,
982
- rowMenuState: s
983
- };
984
- }
985
- }
986
- const qt = new bt().bind();
987
- class At extends h {
988
- reduce(e, s) {
989
- return {
990
- ...e,
991
- editorHovering: s
992
- };
993
- }
994
- }
995
- const Qt = new At().bind();
996
- class Ct extends h {
997
- reduce(e, s) {
998
- return {
999
- ...e,
1000
- ...s
1001
- };
1002
- }
1003
- }
1004
- const te = new Ct().bind(), Vt = {
1005
- blur: Ie,
1006
- copy: Ze,
1007
- cut: Me,
1008
- paste: Te,
1009
- escape: Fe,
1010
- choose: Le,
1011
- select: Pe,
1012
- selectRows: Be,
1013
- selectCols: Ue,
1014
- drag: Oe,
1015
- search: Qe,
1016
- write: je,
1017
- clear: Ke,
1018
- undo: $e,
1019
- redo: et,
1020
- arrow: nt,
1021
- walk: it,
1022
- insertRowsAbove: rt,
1023
- insertRowsBelow: lt,
1024
- insertColsLeft: ut,
1025
- insertColsRight: ft,
1026
- removeRows: Rt,
1027
- removeCols: St,
1028
- sortRows: yt,
1029
- filterRows: mt
1030
- }, jt = () => {
1031
- const [c, e] = K(!1);
1032
- return O(() => {
1033
- e(!0);
1034
- }, []), c && typeof window < "u" ? { window, document } : { window: null, document: null };
1035
- }, Gt = (c, e = 100) => {
1036
- const s = V(c), t = V();
1037
- return O(() => {
1038
- s.current = c;
1039
- }, [c]), (...n) => {
1040
- window.clearTimeout(t.current), t.current = window.setTimeout(() => {
1041
- s.current(...n);
1042
- }, e);
1043
- };
1044
- }, Kt = (c = {}) => {
1045
- const [e, s] = K(() => de(c)), { registry: t } = e;
1046
- return t.updateSheet = ve, t.transmit = (n) => {
1047
- Object.assign(t, n), t.ready && requestAnimationFrame(() => s({ registry: t }));
1048
- }, O(() => {
1049
- Object.assign(t, c);
1050
- }, [c]), e;
1051
- };
1052
- export {
1053
- ut as A,
1054
- lt as B,
1055
- rt as C,
1056
- Dt as D,
1057
- Ot as E,
1058
- qt as F,
1059
- Zt as G,
1060
- Wt as H,
1061
- Le as I,
1062
- Oe as J,
1063
- Ut as K,
1064
- Lt as L,
1065
- kt as M,
1066
- Ue as N,
1067
- Gt as O,
1068
- Be as P,
1069
- Qe as Q,
1070
- Et as R,
1071
- Tt as S,
1072
- Ht as T,
1073
- Kt as U,
1074
- Xt as V,
1075
- Vt as W,
1076
- _t as a,
1077
- ve as b,
1078
- $e as c,
1079
- Me as d,
1080
- Mt as e,
1081
- Bt as f,
1082
- Ze as g,
1083
- Pe as h,
1084
- nt as i,
1085
- Fe as j,
1086
- Ke as k,
1087
- it as l,
1088
- Qt as m,
1089
- te as n,
1090
- Pt as o,
1091
- Te as p,
1092
- zt as q,
1093
- et as r,
1094
- Ft as s,
1095
- mt as t,
1096
- jt as u,
1097
- yt as v,
1098
- je as w,
1099
- St as x,
1100
- Rt as y,
1101
- ft as z
1102
- };
1103
- //# sourceMappingURL=hooks-Y7BI_RNj.mjs.map