@leankylin-sheet/react 5.2.61 → 5.2.63

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.
@@ -5,7 +5,7 @@ export declare function generateAPIs(context: Context, setContext: (recipe: (ctx
5
5
  setVariable: (name: string, value: string | number) => void;
6
6
  scrollToHighlightCell: (r: number, c: number, selected: number) => void;
7
7
  getRefs: () => RefValues;
8
- setCellOptions: (cellOptions: Context["cellOptions"]) => void;
8
+ setCellOptions: (cellOptions: Context["cellOptions"], sheetId?: string) => void;
9
9
  applyOp: (ops: Op[]) => void;
10
10
  createFilter: () => void;
11
11
  createFilterOptions: (range: any, sheetId: string, filterObj: any, saveData: boolean) => void;
@@ -13,7 +13,7 @@ declare const Workbook: React.ForwardRefExoticComponent<Settings & AdditionalPro
13
13
  setVariable: (name: string, value: string | number) => void;
14
14
  scrollToHighlightCell: (r: number, c: number, selected: number) => void;
15
15
  getRefs: () => RefValues;
16
- setCellOptions: (cellOptions: import("@leankylin-sheet/core").CellOptions) => void;
16
+ setCellOptions: (cellOptions: import("@leankylin-sheet/core").CellOptions, sheetId?: string | undefined) => void;
17
17
  applyOp: (ops: Op[]) => void;
18
18
  createFilter: () => void;
19
19
  createFilterOptions: (range: any, sheetId: string, filterObj: any, saveData: boolean) => void;
package/dist/index.esm.js CHANGED
@@ -53,6 +53,307 @@ function _objectSpread2(e) {
53
53
  }
54
54
  return e;
55
55
  }
56
+ function _regeneratorRuntime() {
57
+ _regeneratorRuntime = function () {
58
+ return e;
59
+ };
60
+ var t,
61
+ e = {},
62
+ r = Object.prototype,
63
+ n = r.hasOwnProperty,
64
+ o = Object.defineProperty || function (t, e, r) {
65
+ t[e] = r.value;
66
+ },
67
+ i = "function" == typeof Symbol ? Symbol : {},
68
+ a = i.iterator || "@@iterator",
69
+ c = i.asyncIterator || "@@asyncIterator",
70
+ u = i.toStringTag || "@@toStringTag";
71
+ function define(t, e, r) {
72
+ return Object.defineProperty(t, e, {
73
+ value: r,
74
+ enumerable: !0,
75
+ configurable: !0,
76
+ writable: !0
77
+ }), t[e];
78
+ }
79
+ try {
80
+ define({}, "");
81
+ } catch (t) {
82
+ define = function (t, e, r) {
83
+ return t[e] = r;
84
+ };
85
+ }
86
+ function wrap(t, e, r, n) {
87
+ var i = e && e.prototype instanceof Generator ? e : Generator,
88
+ a = Object.create(i.prototype),
89
+ c = new Context(n || []);
90
+ return o(a, "_invoke", {
91
+ value: makeInvokeMethod(t, r, c)
92
+ }), a;
93
+ }
94
+ function tryCatch(t, e, r) {
95
+ try {
96
+ return {
97
+ type: "normal",
98
+ arg: t.call(e, r)
99
+ };
100
+ } catch (t) {
101
+ return {
102
+ type: "throw",
103
+ arg: t
104
+ };
105
+ }
106
+ }
107
+ e.wrap = wrap;
108
+ var h = "suspendedStart",
109
+ l = "suspendedYield",
110
+ f = "executing",
111
+ s = "completed",
112
+ y = {};
113
+ function Generator() {}
114
+ function GeneratorFunction() {}
115
+ function GeneratorFunctionPrototype() {}
116
+ var p = {};
117
+ define(p, a, function () {
118
+ return this;
119
+ });
120
+ var d = Object.getPrototypeOf,
121
+ v = d && d(d(values([])));
122
+ v && v !== r && n.call(v, a) && (p = v);
123
+ var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
124
+ function defineIteratorMethods(t) {
125
+ ["next", "throw", "return"].forEach(function (e) {
126
+ define(t, e, function (t) {
127
+ return this._invoke(e, t);
128
+ });
129
+ });
130
+ }
131
+ function AsyncIterator(t, e) {
132
+ function invoke(r, o, i, a) {
133
+ var c = tryCatch(t[r], t, o);
134
+ if ("throw" !== c.type) {
135
+ var u = c.arg,
136
+ h = u.value;
137
+ return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
138
+ invoke("next", t, i, a);
139
+ }, function (t) {
140
+ invoke("throw", t, i, a);
141
+ }) : e.resolve(h).then(function (t) {
142
+ u.value = t, i(u);
143
+ }, function (t) {
144
+ return invoke("throw", t, i, a);
145
+ });
146
+ }
147
+ a(c.arg);
148
+ }
149
+ var r;
150
+ o(this, "_invoke", {
151
+ value: function (t, n) {
152
+ function callInvokeWithMethodAndArg() {
153
+ return new e(function (e, r) {
154
+ invoke(t, n, e, r);
155
+ });
156
+ }
157
+ return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
158
+ }
159
+ });
160
+ }
161
+ function makeInvokeMethod(e, r, n) {
162
+ var o = h;
163
+ return function (i, a) {
164
+ if (o === f) throw Error("Generator is already running");
165
+ if (o === s) {
166
+ if ("throw" === i) throw a;
167
+ return {
168
+ value: t,
169
+ done: !0
170
+ };
171
+ }
172
+ for (n.method = i, n.arg = a;;) {
173
+ var c = n.delegate;
174
+ if (c) {
175
+ var u = maybeInvokeDelegate(c, n);
176
+ if (u) {
177
+ if (u === y) continue;
178
+ return u;
179
+ }
180
+ }
181
+ if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
182
+ if (o === h) throw o = s, n.arg;
183
+ n.dispatchException(n.arg);
184
+ } else "return" === n.method && n.abrupt("return", n.arg);
185
+ o = f;
186
+ var p = tryCatch(e, r, n);
187
+ if ("normal" === p.type) {
188
+ if (o = n.done ? s : l, p.arg === y) continue;
189
+ return {
190
+ value: p.arg,
191
+ done: n.done
192
+ };
193
+ }
194
+ "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
195
+ }
196
+ };
197
+ }
198
+ function maybeInvokeDelegate(e, r) {
199
+ var n = r.method,
200
+ o = e.iterator[n];
201
+ if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
202
+ var i = tryCatch(o, e.iterator, r.arg);
203
+ if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
204
+ var a = i.arg;
205
+ return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
206
+ }
207
+ function pushTryEntry(t) {
208
+ var e = {
209
+ tryLoc: t[0]
210
+ };
211
+ 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
212
+ }
213
+ function resetTryEntry(t) {
214
+ var e = t.completion || {};
215
+ e.type = "normal", delete e.arg, t.completion = e;
216
+ }
217
+ function Context(t) {
218
+ this.tryEntries = [{
219
+ tryLoc: "root"
220
+ }], t.forEach(pushTryEntry, this), this.reset(!0);
221
+ }
222
+ function values(e) {
223
+ if (e || "" === e) {
224
+ var r = e[a];
225
+ if (r) return r.call(e);
226
+ if ("function" == typeof e.next) return e;
227
+ if (!isNaN(e.length)) {
228
+ var o = -1,
229
+ i = function next() {
230
+ for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
231
+ return next.value = t, next.done = !0, next;
232
+ };
233
+ return i.next = i;
234
+ }
235
+ }
236
+ throw new TypeError(typeof e + " is not iterable");
237
+ }
238
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
239
+ value: GeneratorFunctionPrototype,
240
+ configurable: !0
241
+ }), o(GeneratorFunctionPrototype, "constructor", {
242
+ value: GeneratorFunction,
243
+ configurable: !0
244
+ }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
245
+ var e = "function" == typeof t && t.constructor;
246
+ return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
247
+ }, e.mark = function (t) {
248
+ return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
249
+ }, e.awrap = function (t) {
250
+ return {
251
+ __await: t
252
+ };
253
+ }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
254
+ return this;
255
+ }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
256
+ void 0 === i && (i = Promise);
257
+ var a = new AsyncIterator(wrap(t, r, n, o), i);
258
+ return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
259
+ return t.done ? t.value : a.next();
260
+ });
261
+ }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
262
+ return this;
263
+ }), define(g, "toString", function () {
264
+ return "[object Generator]";
265
+ }), e.keys = function (t) {
266
+ var e = Object(t),
267
+ r = [];
268
+ for (var n in e) r.push(n);
269
+ return r.reverse(), function next() {
270
+ for (; r.length;) {
271
+ var t = r.pop();
272
+ if (t in e) return next.value = t, next.done = !1, next;
273
+ }
274
+ return next.done = !0, next;
275
+ };
276
+ }, e.values = values, Context.prototype = {
277
+ constructor: Context,
278
+ reset: function (e) {
279
+ if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
280
+ },
281
+ stop: function () {
282
+ this.done = !0;
283
+ var t = this.tryEntries[0].completion;
284
+ if ("throw" === t.type) throw t.arg;
285
+ return this.rval;
286
+ },
287
+ dispatchException: function (e) {
288
+ if (this.done) throw e;
289
+ var r = this;
290
+ function handle(n, o) {
291
+ return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
292
+ }
293
+ for (var o = this.tryEntries.length - 1; o >= 0; --o) {
294
+ var i = this.tryEntries[o],
295
+ a = i.completion;
296
+ if ("root" === i.tryLoc) return handle("end");
297
+ if (i.tryLoc <= this.prev) {
298
+ var c = n.call(i, "catchLoc"),
299
+ u = n.call(i, "finallyLoc");
300
+ if (c && u) {
301
+ if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
302
+ if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
303
+ } else if (c) {
304
+ if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
305
+ } else {
306
+ if (!u) throw Error("try statement without catch or finally");
307
+ if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
308
+ }
309
+ }
310
+ }
311
+ },
312
+ abrupt: function (t, e) {
313
+ for (var r = this.tryEntries.length - 1; r >= 0; --r) {
314
+ var o = this.tryEntries[r];
315
+ if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
316
+ var i = o;
317
+ break;
318
+ }
319
+ }
320
+ i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
321
+ var a = i ? i.completion : {};
322
+ return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
323
+ },
324
+ complete: function (t, e) {
325
+ if ("throw" === t.type) throw t.arg;
326
+ return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
327
+ },
328
+ finish: function (t) {
329
+ for (var e = this.tryEntries.length - 1; e >= 0; --e) {
330
+ var r = this.tryEntries[e];
331
+ if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
332
+ }
333
+ },
334
+ catch: function (t) {
335
+ for (var e = this.tryEntries.length - 1; e >= 0; --e) {
336
+ var r = this.tryEntries[e];
337
+ if (r.tryLoc === t) {
338
+ var n = r.completion;
339
+ if ("throw" === n.type) {
340
+ var o = n.arg;
341
+ resetTryEntry(r);
342
+ }
343
+ return o;
344
+ }
345
+ }
346
+ throw Error("illegal catch attempt");
347
+ },
348
+ delegateYield: function (e, r, n) {
349
+ return this.delegate = {
350
+ iterator: values(e),
351
+ resultName: r,
352
+ nextLoc: n
353
+ }, "next" === this.method && (this.arg = t), y;
354
+ }
355
+ }, e;
356
+ }
56
357
  function _toPrimitive(t, r) {
57
358
  if ("object" != typeof t || !t) return t;
58
359
  var e = t[Symbol.toPrimitive];
@@ -67,6 +368,36 @@ function _toPropertyKey(t) {
67
368
  var i = _toPrimitive(t, "string");
68
369
  return "symbol" == typeof i ? i : i + "";
69
370
  }
371
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
372
+ try {
373
+ var info = gen[key](arg);
374
+ var value = info.value;
375
+ } catch (error) {
376
+ reject(error);
377
+ return;
378
+ }
379
+ if (info.done) {
380
+ resolve(value);
381
+ } else {
382
+ Promise.resolve(value).then(_next, _throw);
383
+ }
384
+ }
385
+ function _asyncToGenerator(fn) {
386
+ return function () {
387
+ var self = this,
388
+ args = arguments;
389
+ return new Promise(function (resolve, reject) {
390
+ var gen = fn.apply(self, args);
391
+ function _next(value) {
392
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
393
+ }
394
+ function _throw(err) {
395
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
396
+ }
397
+ _next(undefined);
398
+ });
399
+ };
400
+ }
70
401
  function _defineProperty(obj, key, value) {
71
402
  key = _toPropertyKey(key);
72
403
  if (key in obj) {
@@ -10289,16 +10620,49 @@ var SheetTabContextMenu = function SheetTabContextMenu() {
10289
10620
  return _.isUndefined(singleSheet.hide) || singleSheet.hide !== 1;
10290
10621
  });
10291
10622
  if (context.luckysheetfile.length > 1 && shownSheets.length > 1) {
10292
- showAlert("".concat(sheetconfig.confirmDelete, "\"").concat(sheet.name, "\"\uFF1F"), "yesno", function () {
10293
- setContext(function (ctx) {
10294
- deleteSheet(ctx, sheet.id);
10295
- }, {
10296
- deleteSheetOp: {
10297
- id: sheet.id
10623
+ showAlert("".concat(sheetconfig.confirmDelete, "\"").concat(sheet.name, "\"\uFF1F"), "yesno", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
10624
+ var onDeleteSheetCheck, isAllowed;
10625
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
10626
+ while (1) switch (_context.prev = _context.next) {
10627
+ case 0:
10628
+ onDeleteSheetCheck = settings.onDeleteSheetCheck;
10629
+ if (!onDeleteSheetCheck) {
10630
+ _context.next = 14;
10631
+ break;
10632
+ }
10633
+ _context.prev = 2;
10634
+ _context.next = 5;
10635
+ return onDeleteSheetCheck(sheet.id, sheet);
10636
+ case 5:
10637
+ isAllowed = _context.sent;
10638
+ _context.next = 12;
10639
+ break;
10640
+ case 8:
10641
+ _context.prev = 8;
10642
+ _context.t0 = _context["catch"](2);
10643
+ console.error(_context.t0);
10644
+ isAllowed = false;
10645
+ case 12:
10646
+ if (isAllowed) {
10647
+ _context.next = 14;
10648
+ break;
10649
+ }
10650
+ return _context.abrupt("return");
10651
+ case 14:
10652
+ setContext(function (ctx) {
10653
+ deleteSheet(ctx, sheet.id);
10654
+ }, {
10655
+ deleteSheetOp: {
10656
+ id: sheet.id
10657
+ }
10658
+ });
10659
+ hideAlert();
10660
+ case 16:
10661
+ case "end":
10662
+ return _context.stop();
10298
10663
  }
10299
- });
10300
- hideAlert();
10301
- }, undefined, {
10664
+ }, _callee, null, [[2, 8]]);
10665
+ })), undefined, {
10302
10666
  confirmText: sheetconfig.delete,
10303
10667
  danger: true
10304
10668
  });
@@ -10430,11 +10794,15 @@ function generateAPIs(context, setContext, handleUndo, handleRedo, settings, cel
10430
10794
  getRefs: function getRefs() {
10431
10795
  return refs;
10432
10796
  },
10433
- setCellOptions: function setCellOptions(cellOptions) {
10797
+ setCellOptions: function setCellOptions(cellOptions, sheetId) {
10434
10798
  return setContext(function (ctx) {
10435
- ctx.cellOptions = cellOptions;
10436
- var index = getSheetIndex(ctx, context.currentSheetId);
10799
+ var targetSheetId = sheetId !== null && sheetId !== void 0 ? sheetId : ctx.currentSheetId;
10800
+ var index = getSheetIndex(ctx, targetSheetId);
10801
+ if (index == null) return;
10437
10802
  ctx.luckysheetfile[index].cellOptions = cellOptions;
10803
+ if (targetSheetId === ctx.currentSheetId) {
10804
+ ctx.cellOptions = cellOptions;
10805
+ }
10438
10806
  });
10439
10807
  },
10440
10808
  applyOp: function applyOp(ops) {