tor-univer-sheet 1.1.6 → 1.1.8

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,40 +1,40 @@
1
- import h from "dayjs";
2
- import { CellValueType as C } from "@univerjs/presets";
3
- import B from "decimal.js";
4
- const ct = (t, r) => {
5
- for (const n of r)
6
- t[n] = null;
7
- }, _ = () => {
1
+ import l from "dayjs";
2
+ import { CellValueType as R } from "@univerjs/presets";
3
+ import z from "decimal.js";
4
+ const ft = (t, r) => {
5
+ for (const o of r)
6
+ t[o] = null;
7
+ }, K = () => {
8
8
  if (typeof crypto == "object") {
9
9
  if (typeof crypto.randomUUID == "function")
10
10
  return crypto.randomUUID();
11
11
  if (typeof crypto.getRandomValues == "function" && typeof Uint8Array == "function") {
12
- const n = (e) => {
12
+ const o = (e) => {
13
13
  const c = Number(e);
14
14
  return (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16);
15
15
  };
16
- return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, n);
16
+ return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, o);
17
17
  }
18
18
  }
19
19
  let t = (/* @__PURE__ */ new Date()).getTime(), r = typeof performance < "u" && performance.now && performance.now() * 1e3 || 0;
20
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (n) => {
20
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (o) => {
21
21
  let e = Math.random() * 16;
22
- return t > 0 ? (e = (t + e) % 16 | 0, t = Math.floor(t / 16)) : (e = (r + e) % 16 | 0, r = Math.floor(r / 16)), (n === "x" ? e : e & 3 | 8).toString(16);
22
+ return t > 0 ? (e = (t + e) % 16 | 0, t = Math.floor(t / 16)) : (e = (r + e) % 16 | 0, r = Math.floor(r / 16)), (o === "x" ? e : e & 3 | 8).toString(16);
23
23
  });
24
24
  };
25
- function ft(t) {
25
+ function mt(t) {
26
26
  return {
27
27
  ...t?.workbookData,
28
- id: t?.id || _(),
28
+ id: t?.id || K(),
29
29
  name: t?.name || "未命名",
30
30
  appVersion: t?.appVersion || "1.0.0"
31
31
  };
32
32
  }
33
- const K = Object.prototype.toString, J = (t, r) => K.call(t) === `[object ${r}]`, L = (t) => typeof t < "u", Q = (t) => !L(t), W = (t) => t !== null && J(t, "Object"), G = (t) => t == null || typeof t > "u" ? !0 : q(t) || et(t) ? t.length === 0 : t instanceof Map || t instanceof Set ? t.size === 0 : W(t) ? Object.keys(t).length === 0 : !1, X = (t) => t === null, tt = (t) => Q(t) || X(t), et = (t) => J(t, "String"), q = (t) => t && Array.isArray(t);
34
- class rt {
33
+ const L = Object.prototype.toString, Z = (t, r) => L.call(t) === `[object ${r}]`, Q = (t) => typeof t < "u", W = (t) => !Q(t), X = (t) => t !== null && Z(t, "Object"), $ = (t) => t == null || typeof t > "u" ? !0 : q(t) || rt(t) ? t.length === 0 : t instanceof Map || t instanceof Set ? t.size === 0 : X(t) ? Object.keys(t).length === 0 : !1, tt = (t) => t === null, et = (t) => W(t) || tt(t), rt = (t) => Z(t, "String"), q = (t) => t && Array.isArray(t);
34
+ class ot {
35
35
  value;
36
36
  constructor(r) {
37
- this.value = new B(r);
37
+ this.value = new z(r);
38
38
  }
39
39
  /**
40
40
  * 加法运算
@@ -67,10 +67,10 @@ class rt {
67
67
  * @throws 当除数为0时抛出错误
68
68
  */
69
69
  divide(r) {
70
- const n = new B(r);
71
- if (n.isZero())
70
+ const o = new z(r);
71
+ if (o.isZero())
72
72
  throw new Error("除数是0");
73
- return this.value = this.value.div(n), this;
73
+ return this.value = this.value.div(o), this;
74
74
  }
75
75
  /**
76
76
  * 保留小数位数
@@ -78,8 +78,8 @@ class rt {
78
78
  * @param rounding 舍入模式,默认为四舍五入
79
79
  * @returns DecimalChain 实例,支持链式调用
80
80
  */
81
- toFixed(r, n) {
82
- return this.value = new B(this.value.toFixed(r, n)), this;
81
+ toFixed(r, o) {
82
+ return this.value = new z(this.value.toFixed(r, o)), this;
83
83
  }
84
84
  /**
85
85
  * 返回当前值
@@ -103,296 +103,298 @@ class rt {
103
103
  return this.value.toNumber();
104
104
  }
105
105
  }
106
- function I(t = 0) {
107
- return new rt(t);
106
+ function U(t = 0) {
107
+ return new ot(t);
108
108
  }
109
- var nt = /* @__PURE__ */ ((t) => (t.无 = "no", t.年 = "year", t.月 = "month", t.周 = "week", t.天 = "day", t.班组 = "shift", t.小时 = "hour", t.半小时 = "half_hour", t))(nt || {}), ot = /* @__PURE__ */ ((t) => (t.view = "view", t.edit = "edit", t))(ot || {});
110
- async function mt(t, r) {
109
+ var nt = /* @__PURE__ */ ((t) => (t.无 = "no", t.年 = "year", t.月 = "month", t.周 = "week", t.天 = "day", t.班组 = "shift", t.小时 = "hour", t.半小时 = "half_hour", t))(nt || {}), st = /* @__PURE__ */ ((t) => (t.view = "view", t.edit = "edit", t))(st || {});
110
+ async function lt(t, r) {
111
111
  if (!r) return Promise.reject("日期不能为空");
112
112
  switch (t) {
113
113
  case "year":
114
114
  if (q(r))
115
115
  return Promise.resolve(r);
116
- const n = h(r);
117
- if (!n.isValid())
116
+ const o = l(r);
117
+ if (!o.isValid())
118
118
  return Promise.reject("无效的日期格式");
119
- const e = n.year(), c = `${e}-01`, o = `${e}-12`;
120
- return Promise.resolve([c, o]);
119
+ const e = o.year(), c = `${e}-01`, n = `${e}-12`;
120
+ return Promise.resolve([c, n]);
121
121
  case "month":
122
122
  if (q(r))
123
123
  return Promise.resolve(r);
124
- const i = h(r);
124
+ const i = l(r);
125
125
  if (!i.isValid())
126
126
  return Promise.reject("无效的日期格式");
127
- const x = i.startOf("month").format("YYYY-MM-DD"), s = i.endOf("month").format("YYYY-MM-DD");
128
- return Promise.resolve([x, s]);
127
+ const N = i.startOf("month").format("YYYY-MM-DD"), s = i.endOf("month").format("YYYY-MM-DD");
128
+ return Promise.resolve([N, s]);
129
129
  case "day":
130
130
  if (q(r))
131
131
  return Promise.resolve(r);
132
- const w = h(r);
132
+ const w = l(r);
133
133
  if (!w.isValid())
134
134
  return Promise.reject("无效的日期格式");
135
- const l = w.startOf("day").format("YYYY-MM-DD HH:mm:ss"), H = w.endOf("day").format("YYYY-MM-DD HH:mm:ss");
136
- return Promise.resolve([l, H]);
135
+ const d = w.startOf("day").format("YYYY-MM-DD HH:mm:ss"), H = w.endOf("day").format("YYYY-MM-DD HH:mm:ss");
136
+ return Promise.resolve([d, H]);
137
137
  default:
138
138
  return Promise.reject("不支持的周期类型");
139
139
  }
140
140
  }
141
- function S(t, r, n) {
142
- if (!n) return 0;
141
+ function S(t, r, o) {
142
+ if (!o) return 0;
143
143
  const e = {
144
144
  year: "YYYY",
145
145
  month: "YYYY-MM",
146
146
  day: "YYYY-MM-DD",
147
147
  hour: "HH:mm:ss"
148
- }[n];
149
- return ["day", "hour"].includes(n) ? h(r, e).diff(h(t, e), n) + 1 : h(r, e).diff(h(t, e), n);
148
+ }[o];
149
+ return ["day", "hour"].includes(o) ? l(r, e).diff(l(t, e), o) + 1 : l(r, e).diff(l(t, e), o);
150
150
  }
151
- function $(t, r, n) {
152
- if (!n)
151
+ function F(t, r, o) {
152
+ if (!o)
153
153
  throw new Error("日期类型不能为空");
154
154
  const e = {
155
155
  year: "YYYY",
156
156
  month: "YYYY-MM",
157
157
  day: "YYYY-MM-DD",
158
158
  hour: "HH:mm:ss"
159
- }[n];
160
- return h(t).subtract(r, n).format(e);
159
+ }[o];
160
+ return l(t).subtract(r, o).format(e);
161
161
  }
162
- function N(t, r, n, e) {
163
- const c = "YYYY-MM-DD HH:mm:ss", o = U(t, r, n, e), i = h(o);
162
+ function p(t, r, o, e) {
163
+ const c = "YYYY-MM-DD HH:mm:ss", n = A(t, r, o, e), i = l(n);
164
164
  if (r === "month") {
165
165
  const s = i.month();
166
166
  return s === 0 ? [i.startOf("month").format(c), i.date(25).endOf("day").format(c)] : s === 11 ? [i.subtract(1, "month").date(26).startOf("day").format(c), i.endOf("month").format(c)] : [i.subtract(1, "month").date(26).startOf("day").format(c), i.date(25).endOf("day").format(c)];
167
167
  }
168
- const x = { year: "year", day: "day", hour: "hour" };
169
- return [i.startOf(x[r]).format(c), i.endOf(x[r]).format(c)];
168
+ const N = { year: "year", day: "day", hour: "hour" };
169
+ return [i.startOf(N[r]).format(c), i.endOf(N[r]).format(c)];
170
170
  }
171
- function U(t, r, n, e) {
171
+ function A(t, r, o, e) {
172
172
  const c = {
173
173
  year: "YYYY",
174
174
  month: "YYYY-MM",
175
175
  day: "YYYY-MM-DD",
176
176
  hour: "YYYY-MM-DD HH:mm:ss"
177
177
  }[r];
178
- return h(t, c).add(n * e, r).format(c);
178
+ return l(t, c).add(o * e, r).format(c);
179
179
  }
180
- function M(t, r, n) {
181
- return t[r] || (t[r] = {}), t[r][n] || (t[r][n] = {}), t[r][n];
180
+ function g(t, r, o) {
181
+ return t[r] || (t[r] = {}), t[r][o] || (t[r][o] = {}), t[r][o];
182
182
  }
183
- async function lt(t) {
183
+ async function dt(t) {
184
184
  if (!t)
185
185
  throw new Error("cellData is required");
186
- const r = Object.entries(t).reduce((n, e) => {
187
- const [c, o] = e;
188
- for (const [i, x] of Object.entries(o)) {
189
- const { custom: s, v: w, t: l, s: H } = x;
186
+ const r = Object.entries(t).reduce((o, e) => {
187
+ const [c, n] = e;
188
+ for (const [i, N] of Object.entries(n)) {
189
+ const { custom: s, v: w, t: d, s: H } = N;
190
190
  if (!s) continue;
191
- const { cellType: d } = s;
192
- if (d === "indicator") {
193
- const P = M(n, c, i);
191
+ const { cellType: m } = s, j = $(s?.writeBack) ? !0 : s.writeBack;
192
+ if (m === "indicator" && j) {
193
+ const P = g(o, c, i);
194
194
  P.custom = {
195
195
  ...s,
196
- required: G(s?.required) ? !1 : s?.required,
197
- defaultShift: G(s?.defaultShift) ? !1 : s?.defaultShift,
198
- forwardPush: G(s?.forwardPush) ? !1 : s?.forwardPush,
199
- forwardPushTimes: G(s?.useDefaultEndDate) ? 0 : s?.forwardPushTimes,
200
- useDefaultEndDate: G(s?.useDefaultEndDate) ? !1 : s?.useDefaultEndDate
201
- }, P.s = H, P.t = l, P.v = w;
196
+ required: $(s?.required) ? !1 : s?.required,
197
+ defaultShift: $(s?.defaultShift) ? !1 : s?.defaultShift,
198
+ forwardPush: $(s?.forwardPush) ? !1 : s?.forwardPush,
199
+ forwardPushTimes: $(s?.useDefaultEndDate) ? 0 : s?.forwardPushTimes,
200
+ useDefaultEndDate: $(s?.useDefaultEndDate) ? !1 : s?.useDefaultEndDate,
201
+ writeBack: j
202
+ }, P.s = H, P.t = d, P.v = w;
202
203
  }
203
204
  }
204
- return n;
205
+ return o;
205
206
  }, {});
206
- return !r || G(r) ? Promise.reject(new Error("No data found")) : Promise.resolve(r);
207
+ return !r || $(r) ? Promise.reject(new Error("No data found")) : Promise.resolve(r);
207
208
  }
208
209
  function E(t, r) {
209
- return t.replace(/\$\{([^}]+)\}/g, (n, e) => {
210
+ return t.replace(/\$\{([^}]+)\}/g, (o, e) => {
210
211
  try {
211
- const c = Object.keys(r), o = Object.values(r);
212
- return new Function(...c, `return ${e};`)(...o);
212
+ const c = Object.keys(r), n = Object.values(r);
213
+ return new Function(...c, `return ${e};`)(...n);
213
214
  } catch (c) {
214
- return console.error(`表达式执行失败: ${e}`, c), n;
215
+ return console.error(`表达式执行失败: ${e}`, c), o;
215
216
  }
216
217
  });
217
218
  }
218
- function st({
219
+ function at({
219
220
  acc: t,
220
221
  params: r,
221
- initRowNum: n,
222
+ initRowNum: o,
222
223
  initColNum: e,
223
224
  cellData: c
224
225
  }) {
225
- const { rangeData: o, currentDay: i, extraArgs: x } = r;
226
- x?.teamData;
227
- const { cycleType: s, timeIncrement: w, forwardPush: l, forwardPushTimes: H, copyType: d, copyInterval: P, defaultShift: V, templateStr: T, useDefaultEndDate: k } = c.custom;
228
- let g = 0;
226
+ const { rangeData: n, currentDay: i, extraArgs: N } = r;
227
+ N?.teamData;
228
+ const { cycleType: s, timeIncrement: w, forwardPush: d, forwardPushTimes: H, copyType: m, copyInterval: j, defaultShift: P, templateStr: v, useDefaultEndDate: B } = c.custom;
229
+ let b = 0;
229
230
  switch (s) {
230
231
  case "day": {
231
232
  let a = "";
232
- if (l && (a = $(
233
- o[0],
233
+ if (d && (a = F(
234
+ n[0],
234
235
  H,
235
236
  "day"
236
237
  /* day */
237
- )), !d) {
238
+ )), !m) {
238
239
  let u = "";
239
- l ? u = a : u = o[0];
240
- const y = M(t, n, e);
241
- y.v = T ? E(T, { businessDate: u, dayjs: h }) : h(u).format("YYYY-MM-DD"), y.t = C.STRING;
240
+ d ? u = a : u = n[0];
241
+ const Y = g(t, o, e);
242
+ Y.v = v ? E(v, { businessDate: u, dayjs: l }) : l(u).format("YYYY-MM-DD"), Y.t = R.STRING;
242
243
  break;
243
244
  }
244
- l ? g = S(
245
+ d ? b = S(
245
246
  a,
246
- o[0],
247
+ n[0],
247
248
  "day"
248
249
  /* day */
249
- ) : g = S(
250
- o[0],
251
- o[1],
250
+ ) : b = S(
251
+ n[0],
252
+ n[1],
252
253
  "day"
253
254
  /* day */
254
255
  );
255
- for (let u = 0; u <= Math.abs(g === 0 ? 1 : g); u++) {
256
- const y = u * (P + 1);
257
- let p = "";
258
- l ? p = U(a, "day", u, w) : p = U(o[0], "day", u, w);
259
- const Y = d === "right" ? n : n + y, D = d === "right" ? e + y : e, f = M(t, Y, D);
260
- f.v = T ? E(T, { businessDate: p, dayjs: h }) : h(p).format("YYYY-MM-DD"), f.t = C.STRING;
256
+ for (let u = 0; u <= Math.abs(b === 0 ? 1 : b); u++) {
257
+ const Y = u * (j + 1);
258
+ let O = "";
259
+ d ? O = A(a, "day", u, w) : O = A(n[0], "day", u, w);
260
+ const x = m === "right" ? o : o + Y, M = m === "right" ? e + Y : e, D = g(t, x, M);
261
+ D.v = v ? E(v, { businessDate: O, dayjs: l }) : l(O).format("YYYY-MM-DD"), D.t = R.STRING;
261
262
  }
262
263
  break;
263
264
  }
264
265
  case "month": {
265
- if (!d) {
266
- const [a, u] = N(o[1], "month", 0, 1), y = M(t, n, e);
267
- y.v = h(u).format("YYYY-MM"), y.t = C.STRING;
266
+ if (!m) {
267
+ const [a, u] = p(n[1], "month", 0, 1), Y = g(t, o, e);
268
+ Y.v = l(u).format("YYYY-MM"), Y.t = R.STRING;
268
269
  break;
269
270
  }
270
- g = S(
271
- o[0],
272
- o[1],
271
+ b = S(
272
+ n[0],
273
+ n[1],
273
274
  "month"
274
275
  /* month */
275
276
  );
276
- for (let a = 0; a <= Math.abs(g === 0 ? 1 : g); a++) {
277
- const u = a * (P + 1), y = d === "right" ? n : n + u, p = d === "right" ? e + u : e, Y = M(t, y, p);
278
- Y.v = U(o[0], "month", a, w), Y.t = C.STRING;
277
+ for (let a = 0; a <= Math.abs(b === 0 ? 1 : b); a++) {
278
+ const u = a * (j + 1), Y = m === "right" ? o : o + u, O = m === "right" ? e + u : e, x = g(t, Y, O);
279
+ x.v = A(n[0], "month", a, w), x.t = R.STRING;
279
280
  }
280
281
  break;
281
282
  }
282
283
  case "year": {
283
284
  let a = "";
284
- if (l && (a = $(
285
- o[0],
285
+ if (d && (a = F(
286
+ n[0],
286
287
  H || 0,
287
288
  "year"
288
289
  /* year */
289
- )), !d) {
290
- const u = l ? a : o[0], [y, p] = N(u, "year", 0, 1), Y = M(t, n, e), [, D] = N(o[1], "month", 0, 1);
291
- Y.v = T ? E(T, {
292
- startTime: y,
293
- endTime: p,
294
- rangeData: o,
295
- dayjs: h
296
- }) : u, Y.t = C.STRING;
290
+ )), !m) {
291
+ const u = d ? a : n[0], [Y, O] = p(u, "year", 0, 1), x = g(t, o, e), [, M] = p(n[1], "month", 0, 1);
292
+ x.v = v ? E(v, {
293
+ startTime: Y,
294
+ endTime: O,
295
+ rangeData: n,
296
+ dayjs: l
297
+ }) : u, x.t = R.STRING;
297
298
  break;
298
299
  }
299
- l ? g = S(
300
+ d ? b = S(
300
301
  a,
301
- o[0],
302
+ n[0],
302
303
  "year"
303
304
  /* year */
304
- ) : g = S(
305
- o[0],
306
- o[1],
305
+ ) : b = S(
306
+ n[0],
307
+ n[1],
307
308
  "year"
308
309
  /* year */
309
310
  );
310
- for (let u = 0; u <= Math.abs(g === 0 ? 1 : g); u++) {
311
- const y = u * (P + 1), p = d === "right" ? n : n + y, Y = d === "right" ? e + y : e, [D, f] = N(o[0], "year", u, w), m = M(t, p, Y), b = U(o[0], "year", u, w);
312
- m.v = T ? E(T, {
313
- startTime: D,
314
- endTime: f,
315
- rangeData: o,
316
- dayjs: h
317
- }) : b, m.t = C.STRING;
311
+ for (let u = 0; u <= Math.abs(b === 0 ? 1 : b); u++) {
312
+ const Y = u * (j + 1), O = m === "right" ? o : o + Y, x = m === "right" ? e + Y : e, [M, D] = p(n[0], "year", u, w), f = g(t, O, x), h = A(n[0], "year", u, w);
313
+ f.v = v ? E(v, {
314
+ startTime: M,
315
+ endTime: D,
316
+ rangeData: n,
317
+ dayjs: l
318
+ }) : h, f.t = R.STRING;
318
319
  }
319
320
  break;
320
321
  }
321
322
  case "hour": {
322
- if (!d) {
323
- const a = M(t, n, e);
324
- if (a.t = C.STRING, V) {
325
- a.v = h(o[0]).add(1, "hour").format("YYYY-MM-DD HH:mm:ss");
323
+ if (!m) {
324
+ const a = g(t, o, e);
325
+ if (a.t = R.STRING, P) {
326
+ a.v = l(n[0]).add(1, "hour").format("YYYY-MM-DD HH:mm:ss");
326
327
  break;
327
328
  }
328
- a.v = h(i).add(1, "hour").format("YYYY-MM-DD HH:mm:ss");
329
+ a.v = l(i).add(1, "hour").format("YYYY-MM-DD HH:mm:ss");
329
330
  break;
330
331
  }
331
- g = S(
332
- o[0],
333
- o[1],
332
+ b = S(
333
+ n[0],
334
+ n[1],
334
335
  "hour"
335
336
  /* hour */
336
337
  );
337
- for (let a = 0; a < Math.abs(g === 0 ? 1 : g); a++) {
338
- const u = a * (P + 1), y = d === "right" ? n : n + u, p = d === "right" ? e + u : e, Y = M(t, y, p);
339
- if (Y.t = C.STRING, V) {
340
- const D = h(o[0]).add(1, "hour").format("YYYY-MM-DD HH:mm:ss");
341
- Y.v = U(D, "hour", a, w);
338
+ for (let a = 0; a < Math.abs(b === 0 ? 1 : b); a++) {
339
+ const u = a * (j + 1), Y = m === "right" ? o : o + u, O = m === "right" ? e + u : e, x = g(t, Y, O);
340
+ if (x.t = R.STRING, P) {
341
+ const M = l(n[0]).add(1, "hour").format("YYYY-MM-DD HH:mm:ss");
342
+ x.v = A(M, "hour", a, w);
342
343
  continue;
343
344
  }
344
- Y.v = U(h(i).add(1, "hour").format("YYYY-MM-DD HH:mm:ss"), "hour", a, w);
345
+ x.v = A(l(i).add(1, "hour").format("YYYY-MM-DD HH:mm:ss"), "hour", a, w);
345
346
  }
346
347
  }
347
348
  }
348
349
  }
349
- async function dt(t, r) {
350
+ async function ht(t, r) {
350
351
  if (!t)
351
352
  return Promise.reject("没有可用的单元格数据");
352
- const { extraArgs: n, rangeData: e } = r;
353
+ const { extraArgs: o, rangeData: e } = r;
353
354
  if (!e.length)
354
355
  return Promise.reject("处理时间范围失败, rangeData不能为空");
355
- n?.teamData;
356
- const c = r?.currentDay || h().format("YYYY-MM-DD"), o = Object.entries(t).reduce((i, x) => {
357
- const [s, w] = x;
358
- for (const [l, H] of Object.entries(w)) {
359
- const { custom: d } = H;
360
- if (!d) continue;
361
- const { cellType: P, cycleType: V, timeIncrement: T, forwardPush: k, forwardPushTimes: g, copyType: a, copyInterval: u, defaultShift: y, useDefaultEndDate: p } = d;
362
- if (P === "time") {
363
- st({ acc: i, params: r, initRowNum: Number(s), initColNum: Number(l), cellData: H });
356
+ o?.teamData;
357
+ const c = r?.currentDay || l().format("YYYY-MM-DD"), n = Object.entries(t).reduce((i, N) => {
358
+ const [s, w] = N;
359
+ for (const [d, H] of Object.entries(w)) {
360
+ const { custom: m } = H;
361
+ if (!m) continue;
362
+ const { cellType: j, cycleType: P, timeIncrement: v, forwardPush: B, forwardPushTimes: b, copyType: a, copyInterval: u, defaultShift: Y, useDefaultStartDate: O, useDefaultEndDate: x } = m;
363
+ if (j === "time") {
364
+ at({ acc: i, params: r, initRowNum: Number(s), initColNum: Number(d), cellData: H });
364
365
  continue;
365
366
  }
366
- const Y = {
367
- cycleType: V,
368
- indicatorName: d.indicatorName,
369
- indicatorCode: d.indicatorCode,
370
- indicatorId: d.indicatorId,
371
- indicatorDimensionName: d.indicatorDimensionName,
372
- indicatorDimensionConfig: d.indicatorDimensionConfig,
373
- required: tt(d?.required) ?? !1,
374
- cellType: d.cellType,
375
- defaultShift: d?.defaultShift || !1
367
+ const M = {
368
+ cycleType: P,
369
+ indicatorName: m.indicatorName,
370
+ indicatorCode: m.indicatorCode,
371
+ indicatorId: m.indicatorId,
372
+ indicatorDimensionName: m.indicatorDimensionName,
373
+ indicatorDimensionConfig: m.indicatorDimensionConfig,
374
+ required: et(m?.required) ?? !1,
375
+ cellType: m.cellType,
376
+ defaultShift: m?.defaultShift || !1,
377
+ writeBack: $(m?.writeBack) ? !0 : m.writeBack
376
378
  };
377
379
  let D = 0;
378
- switch (V) {
380
+ switch (P) {
379
381
  case "day": {
380
382
  let f = "";
381
- if (k && (f = $(
383
+ if (B && (f = F(
382
384
  e[0],
383
- g || 0,
385
+ b || 0,
384
386
  "day"
385
387
  /* day */
386
388
  )), !a) {
387
- const m = k ? f : e[0], [b, v] = N(m, "day", 0, 1), O = M(i, s, l);
388
- O.custom = {
389
- ...Y,
390
- startTime: b,
391
- endTime: v
389
+ const h = B ? f : e[0], [T, y] = p(h, "day", 0, 1), k = g(i, s, d);
390
+ k.custom = {
391
+ ...M,
392
+ startTime: T,
393
+ endTime: y
392
394
  };
393
395
  break;
394
396
  }
395
- k ? D = S(
397
+ B ? D = S(
396
398
  f,
397
399
  e[0],
398
400
  "day"
@@ -403,23 +405,23 @@ async function dt(t, r) {
403
405
  "day"
404
406
  /* day */
405
407
  );
406
- for (let m = 0; m < Math.abs(D === 0 ? 1 : D); m++) {
407
- const b = m * (u + 1), v = k ? f : e[0], [O, j] = N(v, "day", m, T), R = a === "right" ? s : I(s).add(b).toNumber(), A = a === "right" ? I(l).add(b).toNumber() : l, F = M(i, R, A);
408
- F.custom = {
409
- ...Y,
410
- startTime: O,
411
- endTime: j
408
+ for (let h = 0; h < Math.abs(D === 0 ? 1 : D); h++) {
409
+ const T = h * (u + 1), y = B ? f : e[0], [k, C] = p(y, "day", h, v), I = a === "right" ? s : U(s).add(T).toNumber(), G = a === "right" ? U(d).add(T).toNumber() : d, V = g(i, I, G);
410
+ V.custom = {
411
+ ...M,
412
+ startTime: k,
413
+ endTime: C
412
414
  };
413
415
  }
414
416
  break;
415
417
  }
416
418
  case "month": {
417
419
  if (!a) {
418
- const [f, m] = N(e[1], "month", 0, 1), b = M(i, s, l);
419
- b.custom = {
420
- ...Y,
420
+ const [f, h] = p(e[1], "month", 0, 1), T = g(i, s, d);
421
+ T.custom = {
422
+ ...M,
421
423
  startTime: f,
422
- endTime: m
424
+ endTime: h
423
425
  };
424
426
  break;
425
427
  }
@@ -430,32 +432,37 @@ async function dt(t, r) {
430
432
  /* month */
431
433
  );
432
434
  for (let f = 0; f <= Math.abs(D === 0 ? 1 : D); f++) {
433
- const m = f * (u + 1), b = a === "right" ? s : I(s).add(m).toNumber(), v = a === "right" ? I(l).add(m).toNumber() : l, [O, j] = N(e[0], "month", f, T), R = M(i, b, v);
434
- R.custom = {
435
- ...Y,
436
- startTime: O,
437
- endTime: j
435
+ const h = f * (u + 1), T = a === "right" ? s : U(s).add(h).toNumber(), y = a === "right" ? U(d).add(h).toNumber() : d, [k, C] = p(e[0], "month", f, v), I = g(i, T, y);
436
+ I.custom = {
437
+ ...M,
438
+ startTime: k,
439
+ endTime: C
438
440
  };
439
441
  }
440
442
  break;
441
443
  }
442
444
  case "year": {
443
- let f = "";
444
- if (k && (f = $(
445
- e[0],
446
- g || 0,
447
- "year"
448
- /* year */
449
- )), !a) {
450
- const m = k ? f : e[0], [b, v] = N(m, "year", 0, 1), O = M(i, s, l), [, j] = N(e[1], "month", 0, 1);
451
- O.custom = {
452
- ...Y,
453
- startTime: b,
454
- endTime: p ? j : v
445
+ let f = "", h = "", T = "";
446
+ if (B) {
447
+ f = F(
448
+ e[0],
449
+ b || 0,
450
+ "year"
451
+ /* year */
452
+ );
453
+ const y = l(e[1]).format("MM");
454
+ h = l(`${f}-${y + 1}`).format("YYYY-MM"), T = l(`${f}-${y + 2}`).format("YYYY-MM");
455
+ }
456
+ if (!a) {
457
+ const y = B ? f : e[0], [k, C] = p(y, "year", 0, 1), I = g(i, s, d), [, G] = p(h, "month", 0, 1), [V] = p(T, "month", 0, 1);
458
+ I.custom = {
459
+ ...M,
460
+ startTime: O ? V : k,
461
+ endTime: x ? G : C
455
462
  };
456
463
  break;
457
464
  }
458
- k ? D = S(
465
+ B ? D = S(
459
466
  f,
460
467
  e[0],
461
468
  "year"
@@ -466,23 +473,23 @@ async function dt(t, r) {
466
473
  "year"
467
474
  /* year */
468
475
  );
469
- for (let m = 0; m < Math.abs(D === 0 ? 1 : D); m++) {
470
- const b = m * (u + 1), v = a === "right" ? s : I(s).add(b).toNumber(), O = a === "right" ? I(l).add(b).toNumber() : l, [j, R] = N(e[0], "year", m, T), A = M(i, v, O);
471
- A.custom = {
472
- ...Y,
473
- startTime: j,
474
- endTime: R
476
+ for (let y = 0; y < Math.abs(D === 0 ? 1 : D); y++) {
477
+ const k = y * (u + 1), C = a === "right" ? s : U(s).add(k).toNumber(), I = a === "right" ? U(d).add(k).toNumber() : d, [G, V] = p(e[0], "year", y, v), J = g(i, C, I);
478
+ J.custom = {
479
+ ...M,
480
+ startTime: G,
481
+ endTime: V
475
482
  };
476
483
  }
477
484
  break;
478
485
  }
479
486
  case "hour": {
480
487
  if (!a) {
481
- const f = y ? e[0] : e[0] ?? c, [m, b] = N(f, "hour", 1, 1), v = M(i, s, l);
482
- v.custom = {
483
- ...Y,
484
- startTime: m,
485
- endTime: b
488
+ const f = Y ? e[0] : e[0] ?? c, [h, T] = p(f, "hour", 1, 1), y = g(i, s, d);
489
+ y.custom = {
490
+ ...M,
491
+ startTime: h,
492
+ endTime: T
486
493
  };
487
494
  break;
488
495
  }
@@ -493,21 +500,21 @@ async function dt(t, r) {
493
500
  /* hour */
494
501
  );
495
502
  for (let f = 0; f < Math.abs(D === 0 ? 1 : D); f++) {
496
- const m = f * (u + 1), b = a === "right" ? s : I(s).add(m).toNumber(), v = a === "right" ? I(l).add(m).toNumber() : l, O = M(i, b, v);
497
- if (y) {
498
- const F = h(e[0]).add(1, "hour").format("YYYY-MM-DD HH:mm:ss"), [z, Z] = N(F, "hour", f, T);
499
- O.custom = {
500
- ...Y,
501
- startTime: z,
502
- endTime: Z
503
+ const h = f * (u + 1), T = a === "right" ? s : U(s).add(h).toNumber(), y = a === "right" ? U(d).add(h).toNumber() : d, k = g(i, T, y);
504
+ if (Y) {
505
+ const V = l(e[0]).add(1, "hour").format("YYYY-MM-DD HH:mm:ss"), [J, _] = p(V, "hour", f, v);
506
+ k.custom = {
507
+ ...M,
508
+ startTime: J,
509
+ endTime: _
503
510
  };
504
511
  continue;
505
512
  }
506
- const j = h(c).add(1, "hour").format("YYYY-MM-DD HH:mm:ss"), [R, A] = N(j, "hour", f, T);
507
- O.custom = {
508
- ...Y,
509
- startTime: R,
510
- endTime: A
513
+ const C = l(c).add(1, "hour").format("YYYY-MM-DD HH:mm:ss"), [I, G] = p(C, "hour", f, v);
514
+ k.custom = {
515
+ ...M,
516
+ startTime: I,
517
+ endTime: G
511
518
  };
512
519
  }
513
520
  break;
@@ -516,44 +523,44 @@ async function dt(t, r) {
516
523
  }
517
524
  return i;
518
525
  }, {});
519
- return Promise.resolve(o);
526
+ return Promise.resolve(n);
520
527
  }
521
- function ht(t) {
522
- return Object.entries(t).reduce((n, [e, c]) => {
523
- const o = Math.max(...Object.keys(c).map(Number));
524
- return o > n ? n = Number(o) : n = Number(n) || 0, n;
528
+ function Yt(t) {
529
+ return Object.entries(t).reduce((o, [e, c]) => {
530
+ const n = Math.max(...Object.keys(c).map(Number));
531
+ return n > o ? o = Number(n) : o = Number(o) || 0, o;
525
532
  }, 0);
526
533
  }
527
- function Yt(t, r) {
528
- const n = JSON.parse(JSON.stringify(t || {}));
534
+ function Dt(t, r) {
535
+ const o = JSON.parse(JSON.stringify(t || {}));
529
536
  for (const [e, c] of Object.entries(r)) {
530
- n[e] || (n[e] = {});
531
- for (const [o, i] of Object.entries(c)) {
532
- const x = i, s = n[e]?.[o];
533
- s ? n[e][o] = {
537
+ o[e] || (o[e] = {});
538
+ for (const [n, i] of Object.entries(c)) {
539
+ const N = i, s = o[e]?.[n];
540
+ s ? o[e][n] = {
534
541
  ...s,
535
- ...x,
542
+ ...N,
536
543
  custom: {
537
544
  ...s.custom,
538
- ...x.custom || {}
545
+ ...N.custom
539
546
  }
540
- } : n[e][o] = x;
547
+ } : o[e][n] = N;
541
548
  }
542
549
  }
543
- return n;
550
+ return o;
544
551
  }
545
- const Dt = "./style.css";
552
+ const yt = "./style.css";
546
553
  export {
547
554
  nt as CycleTypeEnum,
548
- ot as ModeEnum,
549
- I as decimal,
550
- lt as filterIndicatorsCell,
551
- dt as generateIndicatorsCells,
552
- _ as generateUUID,
553
- ht as getNumColumns,
554
- ct as handleClearInput,
555
- mt as initDateRange,
556
- Yt as mergeCellData,
557
- Dt as stylePath,
558
- ft as useData
555
+ st as ModeEnum,
556
+ U as decimal,
557
+ dt as filterIndicatorsCell,
558
+ ht as generateIndicatorsCells,
559
+ K as generateUUID,
560
+ Yt as getNumColumns,
561
+ ft as handleClearInput,
562
+ lt as initDateRange,
563
+ Dt as mergeCellData,
564
+ yt as stylePath,
565
+ mt as useData
559
566
  };
@@ -1 +1 @@
1
- (function(y,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("dayjs"),require("@univerjs/presets"),require("decimal.js")):typeof define=="function"&&define.amd?define(["exports","dayjs","@univerjs/presets","decimal.js"],f):(y=typeof globalThis<"u"?globalThis:y||self,f(y.TorUniverSheet={},y.dayjs,y.presets,y.Decimal))})(this,(function(y,f,V,B){"use strict";const L=(e,r)=>{for(const n of r)e[n]=null},z=()=>{if(typeof crypto=="object"){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();if(typeof crypto.getRandomValues=="function"&&typeof Uint8Array=="function"){const n=t=>{const c=Number(t);return(c^crypto.getRandomValues(new Uint8Array(1))[0]&15>>c/4).toString(16)};return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,n)}}let e=new Date().getTime(),r=typeof performance<"u"&&performance.now&&performance.now()*1e3||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,n=>{let t=Math.random()*16;return e>0?(t=(e+t)%16|0,e=Math.floor(e/16)):(t=(r+t)%16|0,r=Math.floor(r/16)),(n==="x"?t:t&3|8).toString(16)})};function Q(e){return{...e?.workbookData,id:e?.id||z(),name:e?.name||"未命名",appVersion:e?.appVersion||"1.0.0"}}const W=Object.prototype.toString,Z=(e,r)=>W.call(e)===`[object ${r}]`,X=e=>typeof e<"u",ee=e=>!X(e),te=e=>e!==null&&Z(e,"Object"),q=e=>e==null||typeof e>"u"?!0:A(e)||oe(e)?e.length===0:e instanceof Map||e instanceof Set?e.size===0:te(e)?Object.keys(e).length===0:!1,re=e=>e===null,ne=e=>ee(e)||re(e),oe=e=>Z(e,"String"),A=e=>e&&Array.isArray(e);class se{value;constructor(r){this.value=new B(r)}add(r){return this.value=this.value.add(r||0),this}subtract(r){return this.value=this.value.sub(r||0),this}multiply(r){return this.value=this.value.mul(r||0),this}divide(r){const n=new B(r);if(n.isZero())throw new Error("除数是0");return this.value=this.value.div(n),this}toFixed(r,n){return this.value=new B(this.value.toFixed(r,n)),this}valueOf(){return this.value}toString(){return this.value.toString()}toNumber(){return this.value.toNumber()}}function H(e=0){return new se(e)}var _=(e=>(e.无="no",e.年="year",e.月="month",e.周="week",e.天="day",e.班组="shift",e.小时="hour",e.半小时="half_hour",e))(_||{}),K=(e=>(e.view="view",e.edit="edit",e))(K||{});async function ae(e,r){if(!r)return Promise.reject("日期不能为空");switch(e){case"year":if(A(r))return Promise.resolve(r);const n=f(r);if(!n.isValid())return Promise.reject("无效的日期格式");const t=n.year(),c=`${t}-01`,o=`${t}-12`;return Promise.resolve([c,o]);case"month":if(A(r))return Promise.resolve(r);const i=f(r);if(!i.isValid())return Promise.reject("无效的日期格式");const N=i.startOf("month").format("YYYY-MM-DD"),s=i.endOf("month").format("YYYY-MM-DD");return Promise.resolve([N,s]);case"day":if(A(r))return Promise.resolve(r);const w=f(r);if(!w.isValid())return Promise.reject("无效的日期格式");const d=w.startOf("day").format("YYYY-MM-DD HH:mm:ss"),k=w.endOf("day").format("YYYY-MM-DD HH:mm:ss");return Promise.resolve([d,k]);default:return Promise.reject("不支持的周期类型")}}function O(e,r,n){if(!n)return 0;const t={year:"YYYY",month:"YYYY-MM",day:"YYYY-MM-DD",hour:"HH:mm:ss"}[n];return["day","hour"].includes(n)?f(r,t).diff(f(e,t),n)+1:f(r,t).diff(f(e,t),n)}function $(e,r,n){if(!n)throw new Error("日期类型不能为空");const t={year:"YYYY",month:"YYYY-MM",day:"YYYY-MM-DD",hour:"HH:mm:ss"}[n];return f(e).subtract(r,n).format(t)}function v(e,r,n,t){const c="YYYY-MM-DD HH:mm:ss",o=R(e,r,n,t),i=f(o);if(r==="month"){const s=i.month();return s===0?[i.startOf("month").format(c),i.date(25).endOf("day").format(c)]:s===11?[i.subtract(1,"month").date(26).startOf("day").format(c),i.endOf("month").format(c)]:[i.subtract(1,"month").date(26).startOf("day").format(c),i.date(25).endOf("day").format(c)]}const N={year:"year",day:"day",hour:"hour"};return[i.startOf(N[r]).format(c),i.endOf(N[r]).format(c)]}function R(e,r,n,t){const c={year:"YYYY",month:"YYYY-MM",day:"YYYY-MM-DD",hour:"YYYY-MM-DD HH:mm:ss"}[r];return f(e,c).add(n*t,r).format(c)}function M(e,r,n){return e[r]||(e[r]={}),e[r][n]||(e[r][n]={}),e[r][n]}async function ie(e){if(!e)throw new Error("cellData is required");const r=Object.entries(e).reduce((n,t)=>{const[c,o]=t;for(const[i,N]of Object.entries(o)){const{custom:s,v:w,t:d,s:k}=N;if(!s)continue;const{cellType:h}=s;if(h==="indicator"){const P=M(n,c,i);P.custom={...s,required:q(s?.required)?!1:s?.required,defaultShift:q(s?.defaultShift)?!1:s?.defaultShift,forwardPush:q(s?.forwardPush)?!1:s?.forwardPush,forwardPushTimes:q(s?.useDefaultEndDate)?0:s?.forwardPushTimes,useDefaultEndDate:q(s?.useDefaultEndDate)?!1:s?.useDefaultEndDate},P.s=k,P.t=d,P.v=w}}return n},{});return!r||q(r)?Promise.reject(new Error("No data found")):Promise.resolve(r)}function F(e,r){return e.replace(/\$\{([^}]+)\}/g,(n,t)=>{try{const c=Object.keys(r),o=Object.values(r);return new Function(...c,`return ${t};`)(...o)}catch(c){return console.error(`表达式执行失败: ${t}`,c),n}})}function ue({acc:e,params:r,initRowNum:n,initColNum:t,cellData:c}){const{rangeData:o,currentDay:i,extraArgs:N}=r;N?.teamData;const{cycleType:s,timeIncrement:w,forwardPush:d,forwardPushTimes:k,copyType:h,copyInterval:P,defaultShift:E,templateStr:C,useDefaultEndDate:U}=c.custom;let T=0;switch(s){case"day":{let a="";if(d&&(a=$(o[0],k,"day")),!h){let u="";d?u=a:u=o[0];const b=M(e,n,t);b.v=C?F(C,{businessDate:u,dayjs:f}):f(u).format("YYYY-MM-DD"),b.t=V.CellValueType.STRING;break}d?T=O(a,o[0],"day"):T=O(o[0],o[1],"day");for(let u=0;u<=Math.abs(T===0?1:T);u++){const b=u*(P+1);let p="";d?p=R(a,"day",u,w):p=R(o[0],"day",u,w);const Y=h==="right"?n:n+b,D=h==="right"?t+b:t,l=M(e,Y,D);l.v=C?F(C,{businessDate:p,dayjs:f}):f(p).format("YYYY-MM-DD"),l.t=V.CellValueType.STRING}break}case"month":{if(!h){const[a,u]=v(o[1],"month",0,1),b=M(e,n,t);b.v=f(u).format("YYYY-MM"),b.t=V.CellValueType.STRING;break}T=O(o[0],o[1],"month");for(let a=0;a<=Math.abs(T===0?1:T);a++){const u=a*(P+1),b=h==="right"?n:n+u,p=h==="right"?t+u:t,Y=M(e,b,p);Y.v=R(o[0],"month",a,w),Y.t=V.CellValueType.STRING}break}case"year":{let a="";if(d&&(a=$(o[0],k||0,"year")),!h){const u=d?a:o[0],[b,p]=v(u,"year",0,1),Y=M(e,n,t),[,D]=v(o[1],"month",0,1);Y.v=C?F(C,{startTime:b,endTime:p,rangeData:o,dayjs:f}):u,Y.t=V.CellValueType.STRING;break}d?T=O(a,o[0],"year"):T=O(o[0],o[1],"year");for(let u=0;u<=Math.abs(T===0?1:T);u++){const b=u*(P+1),p=h==="right"?n:n+b,Y=h==="right"?t+b:t,[D,l]=v(o[0],"year",u,w),m=M(e,p,Y),g=R(o[0],"year",u,w);m.v=C?F(C,{startTime:D,endTime:l,rangeData:o,dayjs:f}):g,m.t=V.CellValueType.STRING}break}case"hour":{if(!h){const a=M(e,n,t);if(a.t=V.CellValueType.STRING,E){a.v=f(o[0]).add(1,"hour").format("YYYY-MM-DD HH:mm:ss");break}a.v=f(i).add(1,"hour").format("YYYY-MM-DD HH:mm:ss");break}T=O(o[0],o[1],"hour");for(let a=0;a<Math.abs(T===0?1:T);a++){const u=a*(P+1),b=h==="right"?n:n+u,p=h==="right"?t+u:t,Y=M(e,b,p);if(Y.t=V.CellValueType.STRING,E){const D=f(o[0]).add(1,"hour").format("YYYY-MM-DD HH:mm:ss");Y.v=R(D,"hour",a,w);continue}Y.v=R(f(i).add(1,"hour").format("YYYY-MM-DD HH:mm:ss"),"hour",a,w)}}}}async function ce(e,r){if(!e)return Promise.reject("没有可用的单元格数据");const{extraArgs:n,rangeData:t}=r;if(!t.length)return Promise.reject("处理时间范围失败, rangeData不能为空");n?.teamData;const c=r?.currentDay||f().format("YYYY-MM-DD"),o=Object.entries(e).reduce((i,N)=>{const[s,w]=N;for(const[d,k]of Object.entries(w)){const{custom:h}=k;if(!h)continue;const{cellType:P,cycleType:E,timeIncrement:C,forwardPush:U,forwardPushTimes:T,copyType:a,copyInterval:u,defaultShift:b,useDefaultEndDate:p}=h;if(P==="time"){ue({acc:i,params:r,initRowNum:Number(s),initColNum:Number(d),cellData:k});continue}const Y={cycleType:E,indicatorName:h.indicatorName,indicatorCode:h.indicatorCode,indicatorId:h.indicatorId,indicatorDimensionName:h.indicatorDimensionName,indicatorDimensionConfig:h.indicatorDimensionConfig,required:ne(h?.required)??!1,cellType:h.cellType,defaultShift:h?.defaultShift||!1};let D=0;switch(E){case"day":{let l="";if(U&&(l=$(t[0],T||0,"day")),!a){const m=U?l:t[0],[g,x]=v(m,"day",0,1),S=M(i,s,d);S.custom={...Y,startTime:g,endTime:x};break}U?D=O(l,t[0],"day"):D=O(t[0],t[1],"day");for(let m=0;m<Math.abs(D===0?1:D);m++){const g=m*(u+1),x=U?l:t[0],[S,I]=v(x,"day",m,C),j=a==="right"?s:H(s).add(g).toNumber(),G=a==="right"?H(d).add(g).toNumber():d,J=M(i,j,G);J.custom={...Y,startTime:S,endTime:I}}break}case"month":{if(!a){const[l,m]=v(t[1],"month",0,1),g=M(i,s,d);g.custom={...Y,startTime:l,endTime:m};break}D=O(t[0],t[1],"month");for(let l=0;l<=Math.abs(D===0?1:D);l++){const m=l*(u+1),g=a==="right"?s:H(s).add(m).toNumber(),x=a==="right"?H(d).add(m).toNumber():d,[S,I]=v(t[0],"month",l,C),j=M(i,g,x);j.custom={...Y,startTime:S,endTime:I}}break}case"year":{let l="";if(U&&(l=$(t[0],T||0,"year")),!a){const m=U?l:t[0],[g,x]=v(m,"year",0,1),S=M(i,s,d),[,I]=v(t[1],"month",0,1);S.custom={...Y,startTime:g,endTime:p?I:x};break}U?D=O(l,t[0],"year"):D=O(t[0],t[1],"year");for(let m=0;m<Math.abs(D===0?1:D);m++){const g=m*(u+1),x=a==="right"?s:H(s).add(g).toNumber(),S=a==="right"?H(d).add(g).toNumber():d,[I,j]=v(t[0],"year",m,C),G=M(i,x,S);G.custom={...Y,startTime:I,endTime:j}}break}case"hour":{if(!a){const l=b?t[0]:t[0]??c,[m,g]=v(l,"hour",1,1),x=M(i,s,d);x.custom={...Y,startTime:m,endTime:g};break}D=O(t[0],t[1],"hour");for(let l=0;l<Math.abs(D===0?1:D);l++){const m=l*(u+1),g=a==="right"?s:H(s).add(m).toNumber(),x=a==="right"?H(d).add(m).toNumber():d,S=M(i,g,x);if(b){const J=f(t[0]).add(1,"hour").format("YYYY-MM-DD HH:mm:ss"),[de,he]=v(J,"hour",l,C);S.custom={...Y,startTime:de,endTime:he};continue}const I=f(c).add(1,"hour").format("YYYY-MM-DD HH:mm:ss"),[j,G]=v(I,"hour",l,C);S.custom={...Y,startTime:j,endTime:G}}break}}}return i},{});return Promise.resolve(o)}function fe(e){return Object.entries(e).reduce((n,[t,c])=>{const o=Math.max(...Object.keys(c).map(Number));return o>n?n=Number(o):n=Number(n)||0,n},0)}function le(e,r){const n=JSON.parse(JSON.stringify(e||{}));for(const[t,c]of Object.entries(r)){n[t]||(n[t]={});for(const[o,i]of Object.entries(c)){const N=i,s=n[t]?.[o];s?n[t][o]={...s,...N,custom:{...s.custom,...N.custom||{}}}:n[t][o]=N}}return n}const me="./style.css";y.CycleTypeEnum=_,y.ModeEnum=K,y.decimal=H,y.filterIndicatorsCell=ie,y.generateIndicatorsCells=ce,y.generateUUID=z,y.getNumColumns=fe,y.handleClearInput=L,y.initDateRange=ae,y.mergeCellData=le,y.stylePath=me,y.useData=Q,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(Y,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("dayjs"),require("@univerjs/presets"),require("decimal.js")):typeof define=="function"&&define.amd?define(["exports","dayjs","@univerjs/presets","decimal.js"],c):(Y=typeof globalThis<"u"?globalThis:Y||self,c(Y.TorUniverSheet={},Y.dayjs,Y.presets,Y.Decimal))})(this,(function(Y,c,R,z){"use strict";const W=(e,r)=>{for(const n of r)e[n]=null},_=()=>{if(typeof crypto=="object"){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();if(typeof crypto.getRandomValues=="function"&&typeof Uint8Array=="function"){const n=t=>{const f=Number(t);return(f^crypto.getRandomValues(new Uint8Array(1))[0]&15>>f/4).toString(16)};return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,n)}}let e=new Date().getTime(),r=typeof performance<"u"&&performance.now&&performance.now()*1e3||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,n=>{let t=Math.random()*16;return e>0?(t=(e+t)%16|0,e=Math.floor(e/16)):(t=(r+t)%16|0,r=Math.floor(r/16)),(n==="x"?t:t&3|8).toString(16)})};function X(e){return{...e?.workbookData,id:e?.id||_(),name:e?.name||"未命名",appVersion:e?.appVersion||"1.0.0"}}const ee=Object.prototype.toString,K=(e,r)=>ee.call(e)===`[object ${r}]`,te=e=>typeof e<"u",re=e=>!te(e),ne=e=>e!==null&&K(e,"Object"),$=e=>e==null||typeof e>"u"?!0:A(e)||ae(e)?e.length===0:e instanceof Map||e instanceof Set?e.size===0:ne(e)?Object.keys(e).length===0:!1,oe=e=>e===null,se=e=>re(e)||oe(e),ae=e=>K(e,"String"),A=e=>e&&Array.isArray(e);class ie{value;constructor(r){this.value=new z(r)}add(r){return this.value=this.value.add(r||0),this}subtract(r){return this.value=this.value.sub(r||0),this}multiply(r){return this.value=this.value.mul(r||0),this}divide(r){const n=new z(r);if(n.isZero())throw new Error("除数是0");return this.value=this.value.div(n),this}toFixed(r,n){return this.value=new z(this.value.toFixed(r,n)),this}valueOf(){return this.value}toString(){return this.value.toString()}toNumber(){return this.value.toNumber()}}function H(e=0){return new ie(e)}var L=(e=>(e.无="no",e.年="year",e.月="month",e.周="week",e.天="day",e.班组="shift",e.小时="hour",e.半小时="half_hour",e))(L||{}),Q=(e=>(e.view="view",e.edit="edit",e))(Q||{});async function ue(e,r){if(!r)return Promise.reject("日期不能为空");switch(e){case"year":if(A(r))return Promise.resolve(r);const n=c(r);if(!n.isValid())return Promise.reject("无效的日期格式");const t=n.year(),f=`${t}-01`,o=`${t}-12`;return Promise.resolve([f,o]);case"month":if(A(r))return Promise.resolve(r);const i=c(r);if(!i.isValid())return Promise.reject("无效的日期格式");const C=i.startOf("month").format("YYYY-MM-DD"),s=i.endOf("month").format("YYYY-MM-DD");return Promise.resolve([C,s]);case"day":if(A(r))return Promise.resolve(r);const v=c(r);if(!v.isValid())return Promise.reject("无效的日期格式");const d=v.startOf("day").format("YYYY-MM-DD HH:mm:ss"),I=v.endOf("day").format("YYYY-MM-DD HH:mm:ss");return Promise.resolve([d,I]);default:return Promise.reject("不支持的周期类型")}}function k(e,r,n){if(!n)return 0;const t={year:"YYYY",month:"YYYY-MM",day:"YYYY-MM-DD",hour:"HH:mm:ss"}[n];return["day","hour"].includes(n)?c(r,t).diff(c(e,t),n)+1:c(r,t).diff(c(e,t),n)}function F(e,r,n){if(!n)throw new Error("日期类型不能为空");const t={year:"YYYY",month:"YYYY-MM",day:"YYYY-MM-DD",hour:"HH:mm:ss"}[n];return c(e).subtract(r,n).format(t)}function T(e,r,n,t){const f="YYYY-MM-DD HH:mm:ss",o=E(e,r,n,t),i=c(o);if(r==="month"){const s=i.month();return s===0?[i.startOf("month").format(f),i.date(25).endOf("day").format(f)]:s===11?[i.subtract(1,"month").date(26).startOf("day").format(f),i.endOf("month").format(f)]:[i.subtract(1,"month").date(26).startOf("day").format(f),i.date(25).endOf("day").format(f)]}const C={year:"year",day:"day",hour:"hour"};return[i.startOf(C[r]).format(f),i.endOf(C[r]).format(f)]}function E(e,r,n,t){const f={year:"YYYY",month:"YYYY-MM",day:"YYYY-MM-DD",hour:"YYYY-MM-DD HH:mm:ss"}[r];return c(e,f).add(n*t,r).format(f)}function y(e,r,n){return e[r]||(e[r]={}),e[r][n]||(e[r][n]={}),e[r][n]}async function ce(e){if(!e)throw new Error("cellData is required");const r=Object.entries(e).reduce((n,t)=>{const[f,o]=t;for(const[i,C]of Object.entries(o)){const{custom:s,v,t:d,s:I}=C;if(!s)continue;const{cellType:m}=s,V=$(s?.writeBack)?!0:s.writeBack;if(m==="indicator"&&V){const P=y(n,f,i);P.custom={...s,required:$(s?.required)?!1:s?.required,defaultShift:$(s?.defaultShift)?!1:s?.defaultShift,forwardPush:$(s?.forwardPush)?!1:s?.forwardPush,forwardPushTimes:$(s?.useDefaultEndDate)?0:s?.forwardPushTimes,useDefaultEndDate:$(s?.useDefaultEndDate)?!1:s?.useDefaultEndDate,writeBack:V},P.s=I,P.t=d,P.v=v}}return n},{});return!r||$(r)?Promise.reject(new Error("No data found")):Promise.resolve(r)}function J(e,r){return e.replace(/\$\{([^}]+)\}/g,(n,t)=>{try{const f=Object.keys(r),o=Object.values(r);return new Function(...f,`return ${t};`)(...o)}catch(f){return console.error(`表达式执行失败: ${t}`,f),n}})}function fe({acc:e,params:r,initRowNum:n,initColNum:t,cellData:f}){const{rangeData:o,currentDay:i,extraArgs:C}=r;C?.teamData;const{cycleType:s,timeIncrement:v,forwardPush:d,forwardPushTimes:I,copyType:m,copyInterval:V,defaultShift:P,templateStr:p,useDefaultEndDate:q}=f.custom;let M=0;switch(s){case"day":{let a="";if(d&&(a=F(o[0],I,"day")),!m){let u="";d?u=a:u=o[0];const D=y(e,n,t);D.v=p?J(p,{businessDate:u,dayjs:c}):c(u).format("YYYY-MM-DD"),D.t=R.CellValueType.STRING;break}d?M=k(a,o[0],"day"):M=k(o[0],o[1],"day");for(let u=0;u<=Math.abs(M===0?1:M);u++){const D=u*(V+1);let O="";d?O=E(a,"day",u,v):O=E(o[0],"day",u,v);const N=m==="right"?n:n+D,w=m==="right"?t+D:t,b=y(e,N,w);b.v=p?J(p,{businessDate:O,dayjs:c}):c(O).format("YYYY-MM-DD"),b.t=R.CellValueType.STRING}break}case"month":{if(!m){const[a,u]=T(o[1],"month",0,1),D=y(e,n,t);D.v=c(u).format("YYYY-MM"),D.t=R.CellValueType.STRING;break}M=k(o[0],o[1],"month");for(let a=0;a<=Math.abs(M===0?1:M);a++){const u=a*(V+1),D=m==="right"?n:n+u,O=m==="right"?t+u:t,N=y(e,D,O);N.v=E(o[0],"month",a,v),N.t=R.CellValueType.STRING}break}case"year":{let a="";if(d&&(a=F(o[0],I||0,"year")),!m){const u=d?a:o[0],[D,O]=T(u,"year",0,1),N=y(e,n,t),[,w]=T(o[1],"month",0,1);N.v=p?J(p,{startTime:D,endTime:O,rangeData:o,dayjs:c}):u,N.t=R.CellValueType.STRING;break}d?M=k(a,o[0],"year"):M=k(o[0],o[1],"year");for(let u=0;u<=Math.abs(M===0?1:M);u++){const D=u*(V+1),O=m==="right"?n:n+D,N=m==="right"?t+D:t,[w,b]=T(o[0],"year",u,v),l=y(e,O,N),h=E(o[0],"year",u,v);l.v=p?J(p,{startTime:w,endTime:b,rangeData:o,dayjs:c}):h,l.t=R.CellValueType.STRING}break}case"hour":{if(!m){const a=y(e,n,t);if(a.t=R.CellValueType.STRING,P){a.v=c(o[0]).add(1,"hour").format("YYYY-MM-DD HH:mm:ss");break}a.v=c(i).add(1,"hour").format("YYYY-MM-DD HH:mm:ss");break}M=k(o[0],o[1],"hour");for(let a=0;a<Math.abs(M===0?1:M);a++){const u=a*(V+1),D=m==="right"?n:n+u,O=m==="right"?t+u:t,N=y(e,D,O);if(N.t=R.CellValueType.STRING,P){const w=c(o[0]).add(1,"hour").format("YYYY-MM-DD HH:mm:ss");N.v=E(w,"hour",a,v);continue}N.v=E(c(i).add(1,"hour").format("YYYY-MM-DD HH:mm:ss"),"hour",a,v)}}}}async function le(e,r){if(!e)return Promise.reject("没有可用的单元格数据");const{extraArgs:n,rangeData:t}=r;if(!t.length)return Promise.reject("处理时间范围失败, rangeData不能为空");n?.teamData;const f=r?.currentDay||c().format("YYYY-MM-DD"),o=Object.entries(e).reduce((i,C)=>{const[s,v]=C;for(const[d,I]of Object.entries(v)){const{custom:m}=I;if(!m)continue;const{cellType:V,cycleType:P,timeIncrement:p,forwardPush:q,forwardPushTimes:M,copyType:a,copyInterval:u,defaultShift:D,useDefaultStartDate:O,useDefaultEndDate:N}=m;if(V==="time"){fe({acc:i,params:r,initRowNum:Number(s),initColNum:Number(d),cellData:I});continue}const w={cycleType:P,indicatorName:m.indicatorName,indicatorCode:m.indicatorCode,indicatorId:m.indicatorId,indicatorDimensionName:m.indicatorDimensionName,indicatorDimensionConfig:m.indicatorDimensionConfig,required:se(m?.required)??!1,cellType:m.cellType,defaultShift:m?.defaultShift||!1,writeBack:$(m?.writeBack)?!0:m.writeBack};let b=0;switch(P){case"day":{let l="";if(q&&(l=F(t[0],M||0,"day")),!a){const h=q?l:t[0],[x,g]=T(h,"day",0,1),S=y(i,s,d);S.custom={...w,startTime:x,endTime:g};break}q?b=k(l,t[0],"day"):b=k(t[0],t[1],"day");for(let h=0;h<Math.abs(b===0?1:b);h++){const x=h*(u+1),g=q?l:t[0],[S,U]=T(g,"day",h,p),B=a==="right"?s:H(s).add(x).toNumber(),G=a==="right"?H(d).add(x).toNumber():d,j=y(i,B,G);j.custom={...w,startTime:S,endTime:U}}break}case"month":{if(!a){const[l,h]=T(t[1],"month",0,1),x=y(i,s,d);x.custom={...w,startTime:l,endTime:h};break}b=k(t[0],t[1],"month");for(let l=0;l<=Math.abs(b===0?1:b);l++){const h=l*(u+1),x=a==="right"?s:H(s).add(h).toNumber(),g=a==="right"?H(d).add(h).toNumber():d,[S,U]=T(t[0],"month",l,p),B=y(i,x,g);B.custom={...w,startTime:S,endTime:U}}break}case"year":{let l="",h="",x="";if(q){l=F(t[0],M||0,"year");const g=c(t[1]).format("MM");h=c(`${l}-${g+1}`).format("YYYY-MM"),x=c(`${l}-${g+2}`).format("YYYY-MM")}if(!a){const g=q?l:t[0],[S,U]=T(g,"year",0,1),B=y(i,s,d),[,G]=T(h,"month",0,1),[j]=T(x,"month",0,1);B.custom={...w,startTime:O?j:S,endTime:N?G:U};break}q?b=k(l,t[0],"year"):b=k(t[0],t[1],"year");for(let g=0;g<Math.abs(b===0?1:b);g++){const S=g*(u+1),U=a==="right"?s:H(s).add(S).toNumber(),B=a==="right"?H(d).add(S).toNumber():d,[G,j]=T(t[0],"year",g,p),Z=y(i,U,B);Z.custom={...w,startTime:G,endTime:j}}break}case"hour":{if(!a){const l=D?t[0]:t[0]??f,[h,x]=T(l,"hour",1,1),g=y(i,s,d);g.custom={...w,startTime:h,endTime:x};break}b=k(t[0],t[1],"hour");for(let l=0;l<Math.abs(b===0?1:b);l++){const h=l*(u+1),x=a==="right"?s:H(s).add(h).toNumber(),g=a==="right"?H(d).add(h).toNumber():d,S=y(i,x,g);if(D){const j=c(t[0]).add(1,"hour").format("YYYY-MM-DD HH:mm:ss"),[Z,Ye]=T(j,"hour",l,p);S.custom={...w,startTime:Z,endTime:Ye};continue}const U=c(f).add(1,"hour").format("YYYY-MM-DD HH:mm:ss"),[B,G]=T(U,"hour",l,p);S.custom={...w,startTime:B,endTime:G}}break}}}return i},{});return Promise.resolve(o)}function me(e){return Object.entries(e).reduce((n,[t,f])=>{const o=Math.max(...Object.keys(f).map(Number));return o>n?n=Number(o):n=Number(n)||0,n},0)}function de(e,r){const n=JSON.parse(JSON.stringify(e||{}));for(const[t,f]of Object.entries(r)){n[t]||(n[t]={});for(const[o,i]of Object.entries(f)){const C=i,s=n[t]?.[o];s?n[t][o]={...s,...C,custom:{...s.custom,...C.custom}}:n[t][o]=C}}return n}const he="./style.css";Y.CycleTypeEnum=L,Y.ModeEnum=Q,Y.decimal=H,Y.filterIndicatorsCell=ce,Y.generateIndicatorsCells=le,Y.generateUUID=_,Y.getNumColumns=me,Y.handleClearInput=W,Y.initDateRange=ue,Y.mergeCellData=de,Y.stylePath=he,Y.useData=X,Object.defineProperty(Y,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tor-univer-sheet",
3
- "version": "1.1.6",
3
+ "version": "1.1.8",
4
4
  "style": "./dist/style.css",
5
5
  "description": "基于 Univer 的 Vue3 电子表格组件",
6
6
  "author": "tortormore",
@@ -42,6 +42,7 @@
42
42
  "@univerjs/preset-sheets-advanced": "^0.18.0",
43
43
  "@univerjs/preset-sheets-core": "^0.18.0",
44
44
  "@univerjs/preset-sheets-drawing": "^0.18.0",
45
+ "@univerjs/preset-sheets-hyper-link": "^0.20.1",
45
46
  "@univerjs/preset-sheets-note": "^0.18.0",
46
47
  "@univerjs/presets": "^0.18.0",
47
48
  "@univerjs/ui": "^0.18.0",