antd-import-export 0.0.0-stage → 1.0.0
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.
- package/LICENSE +21 -0
- package/README.md +181 -2
- package/README_EN.md +129 -0
- package/dist/components/BatchExportButton.d.ts +10 -0
- package/dist/components/ExcelExportButton.d.ts +15 -0
- package/dist/components/ExcelImportButton.d.ts +11 -0
- package/dist/components/ExportTaskModal.d.ts +7 -0
- package/dist/components/ImportCheckContent.d.ts +10 -0
- package/dist/components/ImportPreviewModal.d.ts +19 -0
- package/dist/core/excel/importEditor.d.ts +7 -0
- package/dist/core/excel/importRow.d.ts +14 -0
- package/dist/core/excel/parseSheet.d.ts +18 -0
- package/dist/core/excel/runtime.d.ts +11 -0
- package/dist/core/excel/worker-url.js +8 -0
- package/dist/core/excel/worker.d.ts +12 -0
- package/dist/core/excel/worker.mjs +119 -0
- package/dist/core/excel/worksheet.d.ts +13 -0
- package/dist/core/httpError.d.ts +6 -0
- package/dist/core/limits.d.ts +5 -0
- package/dist/core/schema/index.d.ts +88 -0
- package/dist/core/schema/multiValue.d.ts +4 -0
- package/dist/core/schema/validate.d.ts +21 -0
- package/dist/core/taskManager.d.ts +123 -0
- package/dist/core/types.d.ts +16 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.mjs +1598 -0
- package/dist/react/useDebouncedValue.d.ts +2 -0
- package/dist/react/useTaskDetail.d.ts +2 -0
- package/dist/react/useThrottledValue.d.ts +2 -0
- package/dist/worksheet-BEUkpIL-.js +467 -0
- package/package.json +99 -4
|
@@ -0,0 +1,467 @@
|
|
|
1
|
+
import e from "dayjs";
|
|
2
|
+
import t from "decimal.js";
|
|
3
|
+
// \0rolldown/runtime.js
|
|
4
|
+
var n = Object.create, r = Object.defineProperty, i = Object.getOwnPropertyDescriptor, a = Object.getOwnPropertyNames, o = Object.getPrototypeOf, s = Object.prototype.hasOwnProperty, c = (e, t) => () => (t || (e((t = { exports: {} }).exports, t, t.exports), e = null), t.exports), l = (e, t, n, o) => {
|
|
5
|
+
if (t && typeof t == "object" || typeof t == "function") for (var c = a(t), l = 0, u = c.length, d; l < u; l++) d = c[l], !s.call(e, d) && d !== n && r(e, d, {
|
|
6
|
+
get: ((e) => t[e]).bind(null, d),
|
|
7
|
+
enumerable: !(o = i(t, d)) || o.enumerable
|
|
8
|
+
});
|
|
9
|
+
return e;
|
|
10
|
+
}, u = (e, t, i) => (i = e == null ? {} : n(o(e)), l(t || !e || !e.__esModule || !s.call(e, "default") ? r(i, "default", {
|
|
11
|
+
value: e,
|
|
12
|
+
enumerable: !0
|
|
13
|
+
}) : i, e)), d = ";", f = /[;;]/;
|
|
14
|
+
function p(e) {
|
|
15
|
+
return e.map((e) => String(e)).join(";");
|
|
16
|
+
}
|
|
17
|
+
function m(e) {
|
|
18
|
+
return e.split(f).map((e) => e.trim()).filter(Boolean);
|
|
19
|
+
}
|
|
20
|
+
// src/core/schema/validate.ts
|
|
21
|
+
var h = /* @__PURE__ */ u((/* @__PURE__ */ c(((e, t, n) => {
|
|
22
|
+
(function(n, r) {
|
|
23
|
+
typeof e == "object" && t !== void 0 ? t.exports = r() : typeof define == "function" && define.amd ? define(r) : (n = typeof globalThis < "u" ? globalThis : n || self).dayjs_plugin_customParseFormat = r();
|
|
24
|
+
})(n, (function() {
|
|
25
|
+
var e = {
|
|
26
|
+
LTS: "h:mm:ss A",
|
|
27
|
+
LT: "h:mm A",
|
|
28
|
+
L: "MM/DD/YYYY",
|
|
29
|
+
LL: "MMMM D, YYYY",
|
|
30
|
+
LLL: "MMMM D, YYYY h:mm A",
|
|
31
|
+
LLLL: "dddd, MMMM D, YYYY h:mm A"
|
|
32
|
+
}, t = /(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|Q|YYYY|YY?|ww?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g, n = /\d/, r = /\d\d/, i = /\d\d?/, a = /\d*[^-_:/,()\s\d]+/, o = {}, s = function(e) {
|
|
33
|
+
return (e = +e) + (e > 68 ? 1900 : 2e3);
|
|
34
|
+
}, c = function(e) {
|
|
35
|
+
return function(t) {
|
|
36
|
+
this[e] = +t;
|
|
37
|
+
};
|
|
38
|
+
}, l = [/[+-]\d\d:?(\d\d)?|Z/, function(e) {
|
|
39
|
+
(this.zone ||= {}).offset = function(e) {
|
|
40
|
+
if (!e || e === "Z") return 0;
|
|
41
|
+
var t = e.match(/([+-]|\d\d)/g), n = 60 * t[1] + (+t[2] || 0);
|
|
42
|
+
return n === 0 ? 0 : t[0] === "+" ? -n : n;
|
|
43
|
+
}(e);
|
|
44
|
+
}], u = function(e) {
|
|
45
|
+
var t = o[e];
|
|
46
|
+
return t && (t.indexOf ? t : t.s.concat(t.f));
|
|
47
|
+
}, d = function(e, t) {
|
|
48
|
+
var n, r = o.meridiem;
|
|
49
|
+
if (r) {
|
|
50
|
+
for (var i = 1; i <= 24; i += 1) if (e.indexOf(r(i, 0, t)) > -1) {
|
|
51
|
+
n = i > 12;
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
} else n = e === (t ? "pm" : "PM");
|
|
55
|
+
return n;
|
|
56
|
+
}, f = {
|
|
57
|
+
A: [a, function(e) {
|
|
58
|
+
this.afternoon = d(e, !1);
|
|
59
|
+
}],
|
|
60
|
+
a: [a, function(e) {
|
|
61
|
+
this.afternoon = d(e, !0);
|
|
62
|
+
}],
|
|
63
|
+
Q: [n, function(e) {
|
|
64
|
+
this.month = 3 * (e - 1) + 1;
|
|
65
|
+
}],
|
|
66
|
+
S: [n, function(e) {
|
|
67
|
+
this.milliseconds = 100 * e;
|
|
68
|
+
}],
|
|
69
|
+
SS: [r, function(e) {
|
|
70
|
+
this.milliseconds = 10 * e;
|
|
71
|
+
}],
|
|
72
|
+
SSS: [/\d{3}/, function(e) {
|
|
73
|
+
this.milliseconds = +e;
|
|
74
|
+
}],
|
|
75
|
+
s: [i, c("seconds")],
|
|
76
|
+
ss: [i, c("seconds")],
|
|
77
|
+
m: [i, c("minutes")],
|
|
78
|
+
mm: [i, c("minutes")],
|
|
79
|
+
H: [i, c("hours")],
|
|
80
|
+
h: [i, c("hours")],
|
|
81
|
+
HH: [i, c("hours")],
|
|
82
|
+
hh: [i, c("hours")],
|
|
83
|
+
D: [i, c("day")],
|
|
84
|
+
DD: [r, c("day")],
|
|
85
|
+
Do: [a, function(e) {
|
|
86
|
+
var t = o.ordinal, n = e.match(/\d+/);
|
|
87
|
+
if (this.day = n[0], t) for (var r = 1; r <= 31; r += 1) t(r).replace(/\[|\]/g, "") === e && (this.day = r);
|
|
88
|
+
}],
|
|
89
|
+
w: [i, c("week")],
|
|
90
|
+
ww: [r, c("week")],
|
|
91
|
+
M: [i, c("month")],
|
|
92
|
+
MM: [r, c("month")],
|
|
93
|
+
MMM: [a, function(e) {
|
|
94
|
+
var t = u("months"), n = (u("monthsShort") || t.map((function(e) {
|
|
95
|
+
return e.slice(0, 3);
|
|
96
|
+
}))).indexOf(e) + 1;
|
|
97
|
+
if (n < 1) throw Error();
|
|
98
|
+
this.month = n % 12 || n;
|
|
99
|
+
}],
|
|
100
|
+
MMMM: [a, function(e) {
|
|
101
|
+
var t = u("months").indexOf(e) + 1;
|
|
102
|
+
if (t < 1) throw Error();
|
|
103
|
+
this.month = t % 12 || t;
|
|
104
|
+
}],
|
|
105
|
+
Y: [/[+-]?\d+/, c("year")],
|
|
106
|
+
YY: [r, function(e) {
|
|
107
|
+
this.year = s(e);
|
|
108
|
+
}],
|
|
109
|
+
YYYY: [/\d{4}/, c("year")],
|
|
110
|
+
Z: l,
|
|
111
|
+
ZZ: l
|
|
112
|
+
};
|
|
113
|
+
function p(n) {
|
|
114
|
+
for (var r = n, i = o && o.formats, a = (n = r.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g, (function(t, n, r) {
|
|
115
|
+
var a = r && r.toUpperCase();
|
|
116
|
+
return n || i[r] || e[r] || i[a].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g, (function(e, t, n) {
|
|
117
|
+
return t || n.slice(1);
|
|
118
|
+
}));
|
|
119
|
+
}))).match(t), s = a.length, c = 0; c < s; c += 1) {
|
|
120
|
+
var l = a[c], u = f[l], d = u && u[0], p = u && u[1];
|
|
121
|
+
a[c] = p ? {
|
|
122
|
+
regex: d,
|
|
123
|
+
parser: p
|
|
124
|
+
} : l.replace(/^\[|\]$/g, "");
|
|
125
|
+
}
|
|
126
|
+
return function(e) {
|
|
127
|
+
for (var t = {}, n = 0, r = 0; n < s; n += 1) {
|
|
128
|
+
var i = a[n];
|
|
129
|
+
if (typeof i == "string") r += i.length;
|
|
130
|
+
else {
|
|
131
|
+
var o = i.regex, c = i.parser, l = e.slice(r), u = o.exec(l)[0];
|
|
132
|
+
c.call(t, u), e = e.replace(u, "");
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return function(e) {
|
|
136
|
+
var t = e.afternoon;
|
|
137
|
+
if (t !== void 0) {
|
|
138
|
+
var n = e.hours;
|
|
139
|
+
t ? n < 12 && (e.hours += 12) : n === 12 && (e.hours = 0), delete e.afternoon;
|
|
140
|
+
}
|
|
141
|
+
}(t), t;
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
return function(e, t, n) {
|
|
145
|
+
n.p.customParseFormat = !0, e && e.parseTwoDigitYear && (s = e.parseTwoDigitYear);
|
|
146
|
+
var r = t.prototype, i = r.parse;
|
|
147
|
+
r.parse = function(e) {
|
|
148
|
+
var t = e.date, r = e.utc, a = e.args;
|
|
149
|
+
this.$u = r;
|
|
150
|
+
var s = a[1];
|
|
151
|
+
if (typeof s == "string") {
|
|
152
|
+
var c = !0 === a[2], l = !0 === a[3], u = c || l, d = a[2];
|
|
153
|
+
l && (d = a[2]), o = this.$locale(), !c && d && (o = n.Ls[d]), this.$d = function(e, t, n, r) {
|
|
154
|
+
try {
|
|
155
|
+
if (["x", "X"].indexOf(t) > -1) return /* @__PURE__ */ new Date((t === "X" ? 1e3 : 1) * e);
|
|
156
|
+
var i = p(t)(e), a = i.year, o = i.month, s = i.day, c = i.hours, l = i.minutes, u = i.seconds, d = i.milliseconds, f = i.zone, m = i.week, h = /* @__PURE__ */ new Date(), g = s || (a || o ? 1 : h.getDate()), _ = a || h.getFullYear(), v = 0;
|
|
157
|
+
a && !o || (v = o > 0 ? o - 1 : h.getMonth());
|
|
158
|
+
var y, b = c || 0, x = l || 0, S = u || 0, C = d || 0;
|
|
159
|
+
return f ? new Date(Date.UTC(_, v, g, b, x, S, C + 60 * f.offset * 1e3)) : n ? new Date(Date.UTC(_, v, g, b, x, S, C)) : (y = new Date(_, v, g, b, x, S, C), m && (y = r(y).week(m).toDate()), y);
|
|
160
|
+
} catch {
|
|
161
|
+
return /* @__PURE__ */ new Date("");
|
|
162
|
+
}
|
|
163
|
+
}(t, s, r, n), this.init(), d && !0 !== d && (this.$L = this.locale(d).$L), u && t != this.format(s) && (this.$d = /* @__PURE__ */ new Date("")), o = {};
|
|
164
|
+
} else if (s instanceof Array) for (var f = s.length, m = 1; m <= f; m += 1) {
|
|
165
|
+
a[1] = s[m - 1];
|
|
166
|
+
var h = n.apply(this, a);
|
|
167
|
+
if (h.isValid()) {
|
|
168
|
+
this.$d = h.$d, this.$L = h.$L, this.init();
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
m === f && (this.$d = /* @__PURE__ */ new Date(""));
|
|
172
|
+
}
|
|
173
|
+
else i.call(this, e);
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
}));
|
|
177
|
+
})))(), 1);
|
|
178
|
+
e.extend(h.default);
|
|
179
|
+
function g(e, t) {
|
|
180
|
+
return e.length > t.property.max_length ? {
|
|
181
|
+
validateSuccess: !1,
|
|
182
|
+
validateMessage: `长度不能超过 ${t.property.max_length}`
|
|
183
|
+
} : {
|
|
184
|
+
validateSuccess: !0,
|
|
185
|
+
validateValue: e
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
function _(e, n) {
|
|
189
|
+
let r = Number(e);
|
|
190
|
+
if (!Number.isFinite(r)) return {
|
|
191
|
+
validateSuccess: !1,
|
|
192
|
+
validateMessage: "不是有效数字"
|
|
193
|
+
};
|
|
194
|
+
let i = n.property.precision, a;
|
|
195
|
+
try {
|
|
196
|
+
a = new t(e);
|
|
197
|
+
} catch {
|
|
198
|
+
return {
|
|
199
|
+
validateSuccess: !1,
|
|
200
|
+
validateMessage: "不是有效数字"
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
if (a.decimalPlaces() > i) return {
|
|
204
|
+
validateSuccess: !1,
|
|
205
|
+
validateMessage: `精度不能超过 ${i} 位小数`
|
|
206
|
+
};
|
|
207
|
+
let o = n.property.max_digits;
|
|
208
|
+
if (o !== void 0) {
|
|
209
|
+
let e = a.abs().trunc().toFixed(0).replace(/^0+/, "").length, t = o - i;
|
|
210
|
+
if (e > t) return {
|
|
211
|
+
validateSuccess: !1,
|
|
212
|
+
validateMessage: `整数部分不能超过 ${t} 位`
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
return n.property.min_value !== void 0 && r < n.property.min_value ? {
|
|
216
|
+
validateSuccess: !1,
|
|
217
|
+
validateMessage: `不能小于 ${n.property.min_value}`
|
|
218
|
+
} : n.property.max_value !== void 0 && r > n.property.max_value ? {
|
|
219
|
+
validateSuccess: !1,
|
|
220
|
+
validateMessage: `不能大于 ${n.property.max_value}`
|
|
221
|
+
} : {
|
|
222
|
+
validateSuccess: !0,
|
|
223
|
+
validateValue: r
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
function v(e, t) {
|
|
227
|
+
return e === t.property.true_label ? {
|
|
228
|
+
validateSuccess: !0,
|
|
229
|
+
validateValue: !0
|
|
230
|
+
} : e === t.property.false_label ? {
|
|
231
|
+
validateSuccess: !0,
|
|
232
|
+
validateValue: !1
|
|
233
|
+
} : {
|
|
234
|
+
validateSuccess: !1,
|
|
235
|
+
validateMessage: `内容必须是 ${t.property.true_label}|${t.property.false_label}`
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
function y(t) {
|
|
239
|
+
let n = e(t, "YYYY-MM-DD", !0);
|
|
240
|
+
return n.isValid() ? {
|
|
241
|
+
validateSuccess: !0,
|
|
242
|
+
validateValue: n.format("YYYY-MM-DD")
|
|
243
|
+
} : {
|
|
244
|
+
validateSuccess: !1,
|
|
245
|
+
validateMessage: "不是有效的日期格式 YYYY-MM-DD"
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
function b(e) {
|
|
249
|
+
let t = /^([01]?[0-9]|2[0-3]):([0-5][0-9])$/.exec(e);
|
|
250
|
+
return t ? {
|
|
251
|
+
validateSuccess: !0,
|
|
252
|
+
validateValue: `${t[1].padStart(2, "0")}:${t[2]}`
|
|
253
|
+
} : {
|
|
254
|
+
validateSuccess: !1,
|
|
255
|
+
validateMessage: "不是有效的日期格式 HH:mm"
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
function x(t) {
|
|
259
|
+
let n = e(t, "YYYY-MM-DD HH:mm", !0);
|
|
260
|
+
return n.isValid() ? {
|
|
261
|
+
validateSuccess: !0,
|
|
262
|
+
validateValue: n.format("YYYY-MM-DD HH:mm")
|
|
263
|
+
} : {
|
|
264
|
+
validateSuccess: !1,
|
|
265
|
+
validateMessage: "不是有效的日期时间格式 YYYY-MM-DD HH:mm"
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
function S(e, t) {
|
|
269
|
+
let n = m(e);
|
|
270
|
+
if (n.length > t.property.list_max_length) return {
|
|
271
|
+
validateSuccess: !1,
|
|
272
|
+
validateMessage: `列表长度不能超过 ${t.property.list_max_length}`
|
|
273
|
+
};
|
|
274
|
+
for (let e of n) if (e.length > t.property.text_max_length) return {
|
|
275
|
+
validateSuccess: !1,
|
|
276
|
+
validateMessage: `单项文本长度不能超过 ${t.property.text_max_length}`
|
|
277
|
+
};
|
|
278
|
+
return {
|
|
279
|
+
validateSuccess: !0,
|
|
280
|
+
validateValue: n
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
function C(e, t) {
|
|
284
|
+
return e in t.property.option_map ? {
|
|
285
|
+
validateSuccess: !0,
|
|
286
|
+
validateValue: t.property.option_map[e]
|
|
287
|
+
} : {
|
|
288
|
+
validateSuccess: !1,
|
|
289
|
+
validateMessage: `内容必须是 ${Object.keys(t.property.option_map).join("|")}`
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
function w(e, t) {
|
|
293
|
+
let n = m(e), r = t.property.option_map, i = [];
|
|
294
|
+
for (let e of n) {
|
|
295
|
+
if (!(e in r)) return {
|
|
296
|
+
validateSuccess: !1,
|
|
297
|
+
validateMessage: `内容必须是 ${Object.keys(r).join("|")}`
|
|
298
|
+
};
|
|
299
|
+
i.push(r[e]);
|
|
300
|
+
}
|
|
301
|
+
return {
|
|
302
|
+
validateSuccess: !0,
|
|
303
|
+
validateValue: i
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
function T(e, t) {
|
|
307
|
+
if (e === null) return t.property.required ? {
|
|
308
|
+
validateSuccess: !1,
|
|
309
|
+
validateMessage: "不能为空"
|
|
310
|
+
} : {
|
|
311
|
+
validateSuccess: !0,
|
|
312
|
+
validateValue: t.property.default_value
|
|
313
|
+
};
|
|
314
|
+
if (t.type === "text") return g(e, t);
|
|
315
|
+
if (t.type === "number") return _(e, t);
|
|
316
|
+
if (t.type === "boolean") return v(e, t);
|
|
317
|
+
if (t.type === "date") return y(e);
|
|
318
|
+
if (t.type === "time") return b(e);
|
|
319
|
+
if (t.type === "datetime") return x(e);
|
|
320
|
+
if (t.type === "list") return S(e, t);
|
|
321
|
+
if (t.type === "single_choice") return C(e, t);
|
|
322
|
+
if (t.type === "multiple_choice") return w(e, t);
|
|
323
|
+
throw Error("未知的字段类型");
|
|
324
|
+
}
|
|
325
|
+
// src/core/limits.ts
|
|
326
|
+
var E = 2e4, D = 2e4, O = 20971520;
|
|
327
|
+
// src/core/excel/importEditor.ts
|
|
328
|
+
function k(e, t) {
|
|
329
|
+
if (t != null) {
|
|
330
|
+
if (e.type !== "single_choice" && e.type !== "multiple_choice") return String(t);
|
|
331
|
+
for (let [n, r] of Object.entries(e.property.option_map)) if (r === t) return n;
|
|
332
|
+
return String(t);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
function A(e, t) {
|
|
336
|
+
return e.type === "boolean" ? t === !0 ? e.property.true_label : t === !1 ? e.property.false_label : void 0 : e.type === "single_choice" ? k(e, t) : e.type === "multiple_choice" ? Array.isArray(t) ? t.map((t) => k(e, t)).filter(Boolean) : [] : e.type === "list" ? Array.isArray(t) ? p(t) : "" : e.type === "number" ? typeof t == "number" ? t : void 0 : t == null ? "" : String(t);
|
|
337
|
+
}
|
|
338
|
+
function j(e, t) {
|
|
339
|
+
return t === null ? e.type === "multiple_choice" ? [] : "" : e.type === "multiple_choice" ? m(t) : t;
|
|
340
|
+
}
|
|
341
|
+
function M(e, t) {
|
|
342
|
+
return t == null ? "" : e.type === "boolean" || e.type === "single_choice" ? String(t) : (e.type === "multiple_choice" || e.type === "list") && Array.isArray(t) ? p(t) : String(t);
|
|
343
|
+
}
|
|
344
|
+
// src/core/excel/worksheet.ts
|
|
345
|
+
function N(t, n) {
|
|
346
|
+
let r = n[t.key];
|
|
347
|
+
if (r == null || r === "") return null;
|
|
348
|
+
switch (t.type) {
|
|
349
|
+
case "datetime": return e(r).format("YYYY-MM-DD HH:mm");
|
|
350
|
+
case "boolean": return r ? t.property.true_label : t.property.false_label;
|
|
351
|
+
case "single_choice": {
|
|
352
|
+
let e = t.property.option_map;
|
|
353
|
+
return Object.keys(e).find((t) => e[t] === r) ?? String(r);
|
|
354
|
+
}
|
|
355
|
+
case "multiple_choice": {
|
|
356
|
+
let e = t.property.option_map;
|
|
357
|
+
return p((Array.isArray(r) ? r : [r]).map((t) => Object.keys(e).find((n) => e[n] === t) ?? String(t)));
|
|
358
|
+
}
|
|
359
|
+
case "list": {
|
|
360
|
+
let e = Array.isArray(r) ? r : [r], n = t.property.item_key;
|
|
361
|
+
return p(e.map((e) => String(n && typeof e == "object" && e ? e[n] ?? "" : e)));
|
|
362
|
+
}
|
|
363
|
+
default: return r;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
function P(e, t) {
|
|
367
|
+
t.forEach((t, n) => {
|
|
368
|
+
t.type === "text" && (e.getColumn(n + 1).numFmt = "@");
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
function F(e, t, n) {
|
|
372
|
+
let r = n.map((e) => e.importable === !1 ? `${e.title}\n(仅导出)` : e.title), i = e.addRow(r);
|
|
373
|
+
i.height = 20 + (Math.max(...r.map((e) => e.split("\n").length)) - 1) * 15, i.eachCell({ includeEmpty: !0 }, (e) => {
|
|
374
|
+
e.font = {
|
|
375
|
+
bold: !0,
|
|
376
|
+
size: 14,
|
|
377
|
+
color: { argb: "FFFFFFFF" }
|
|
378
|
+
}, e.fill = {
|
|
379
|
+
type: "pattern",
|
|
380
|
+
pattern: "solid",
|
|
381
|
+
fgColor: { argb: "FF4472C4" }
|
|
382
|
+
}, e.alignment = {
|
|
383
|
+
vertical: "middle",
|
|
384
|
+
wrapText: !0
|
|
385
|
+
};
|
|
386
|
+
}), t.forEach((t) => {
|
|
387
|
+
e.addRow(n.map((e) => N(e, t))).eachCell({ includeEmpty: !0 }, (e) => {
|
|
388
|
+
e.alignment = {
|
|
389
|
+
...e.alignment,
|
|
390
|
+
wrapText: !0,
|
|
391
|
+
vertical: "top"
|
|
392
|
+
};
|
|
393
|
+
});
|
|
394
|
+
}), P(e, n), R(e);
|
|
395
|
+
}
|
|
396
|
+
function I(e) {
|
|
397
|
+
let t = [e.property.required ? "必填" : "可选"];
|
|
398
|
+
switch (e.type) {
|
|
399
|
+
case "text":
|
|
400
|
+
t.push(`最长 ${e.property.max_length} 个字符`);
|
|
401
|
+
break;
|
|
402
|
+
case "number":
|
|
403
|
+
t.push(`最多 ${e.property.precision} 位小数`), e.property.max_digits !== void 0 && t.push(`整数最多 ${e.property.max_digits - e.property.precision} 位`), e.property.min_value !== void 0 && t.push(`最小 ${e.property.min_value}`), e.property.max_value !== void 0 && t.push(`最大 ${e.property.max_value}`);
|
|
404
|
+
break;
|
|
405
|
+
case "boolean":
|
|
406
|
+
t.push(`填 ${e.property.true_label} 或 ${e.property.false_label}`);
|
|
407
|
+
break;
|
|
408
|
+
case "date":
|
|
409
|
+
t.push("格式 YYYY-MM-DD");
|
|
410
|
+
break;
|
|
411
|
+
case "time":
|
|
412
|
+
t.push("格式 HH:mm");
|
|
413
|
+
break;
|
|
414
|
+
case "datetime":
|
|
415
|
+
t.push("格式 YYYY-MM-DD HH:mm");
|
|
416
|
+
break;
|
|
417
|
+
case "list":
|
|
418
|
+
t.push(`多个值用分号分隔(中英文均可), 最多 ${e.property.list_max_length} 个`);
|
|
419
|
+
break;
|
|
420
|
+
case "single_choice":
|
|
421
|
+
t.push(`填其一: ${Object.keys(e.property.option_map).join(" / ")}`);
|
|
422
|
+
break;
|
|
423
|
+
case "multiple_choice": t.push(`可多选, 分号分隔(中英文均可): ${Object.keys(e.property.option_map).join(" / ")}`);
|
|
424
|
+
}
|
|
425
|
+
e.key.endsWith("_name") ? t.push("填对应记录的名称") : e.key.endsWith("_number") && t.push("填对应记录的编号");
|
|
426
|
+
let n = N(e, { [e.key]: e.property.default_value });
|
|
427
|
+
return t.push(`默认值: ${n == null || n === "" ? "空" : n}`), t.join("\n");
|
|
428
|
+
}
|
|
429
|
+
function L(e, t) {
|
|
430
|
+
let n = t.map((e) => `${e.title}\n\n${I(e)}`), r = e.addRow(n);
|
|
431
|
+
r.height = 20 + (Math.max(...n.map((e) => e.split("\n").length)) - 1) * 15, r.eachCell({ includeEmpty: !0 }, (e) => {
|
|
432
|
+
e.font = {
|
|
433
|
+
bold: !0,
|
|
434
|
+
size: 14,
|
|
435
|
+
color: { argb: "FFFFFFFF" }
|
|
436
|
+
}, e.fill = {
|
|
437
|
+
type: "pattern",
|
|
438
|
+
pattern: "solid",
|
|
439
|
+
fgColor: { argb: "FF4472C4" }
|
|
440
|
+
}, e.alignment = {
|
|
441
|
+
vertical: "top",
|
|
442
|
+
wrapText: !0
|
|
443
|
+
};
|
|
444
|
+
}), P(e, t), R(e);
|
|
445
|
+
}
|
|
446
|
+
function R(e, t = 20, n = 60) {
|
|
447
|
+
let r = [];
|
|
448
|
+
e.eachRow({ includeEmpty: !1 }, (e) => {
|
|
449
|
+
e.eachCell({ includeEmpty: !1 }, (e, t) => {
|
|
450
|
+
let n = t - 1, i = e.text, a = e.font?.size || 11, o = .8 + a / 11 * .4, s = i.split("\n"), c = 0;
|
|
451
|
+
for (let e of s) {
|
|
452
|
+
let t = 0;
|
|
453
|
+
for (let n of e) {
|
|
454
|
+
let e = n.charCodeAt(0);
|
|
455
|
+
t += e > 255 || e >= 65280 && e <= 65519 ? 2 : 1;
|
|
456
|
+
}
|
|
457
|
+
c = Math.max(c, t);
|
|
458
|
+
}
|
|
459
|
+
let l = c * 7 * (a / 11) * o;
|
|
460
|
+
(!r[n] || l > r[n]) && (r[n] = l);
|
|
461
|
+
});
|
|
462
|
+
}), r.forEach((r, i) => {
|
|
463
|
+
let a = r / 7;
|
|
464
|
+
e.getColumn(i + 1).width = Math.min(Math.max(a, t), n);
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
export { m as S, C as _, A as a, d as b, O as c, y as d, x as f, _ as g, w as h, M as i, E as l, S as m, F as n, j as o, T as p, L as r, D as s, R as t, v as u, g as v, p as x, b as y };
|
package/package.json
CHANGED
|
@@ -1,6 +1,101 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "antd-import-export",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"description": "Schema-driven Excel import and export for Ant Design: template generation, client-side validation, batched submission, row-level error feedback and cursor-based export",
|
|
6
|
+
"main": "./dist/index.mjs",
|
|
7
|
+
"module": "./dist/index.mjs",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.mjs"
|
|
13
|
+
},
|
|
14
|
+
"./worker": {
|
|
15
|
+
"import": "./dist/core/excel/worker.mjs"
|
|
16
|
+
},
|
|
17
|
+
"./package.json": "./package.json"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"README.md",
|
|
22
|
+
"README_EN.md",
|
|
23
|
+
"LICENSE"
|
|
24
|
+
],
|
|
25
|
+
"sideEffects": false,
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "rm -rf dist && npx vite build && npx tsc -p tsconfig.json && mkdir -p dist/core/excel && cp src/core/excel/worker-url.js dist/core/excel/worker-url.js",
|
|
28
|
+
"dev": "npx vite build --watch",
|
|
29
|
+
"preview": "npm run build && npx vite --config vite.config.preview.ts",
|
|
30
|
+
"build:preview": "npm run build && npx vite build --config vite.config.preview.ts",
|
|
31
|
+
"prepublishOnly": "npm run build",
|
|
32
|
+
"lint": "eslint . --report-unused-disable-directives --max-warnings 0",
|
|
33
|
+
"lint:fix": "eslint . --fix",
|
|
34
|
+
"format": "prettier --write \"src/**/*.{ts,tsx}\" \"preview/**/*.{ts,tsx}\"",
|
|
35
|
+
"typecheck": "tsc --noEmit",
|
|
36
|
+
"test": "vitest run",
|
|
37
|
+
"typecheck:preview": "tsc -p tsconfig.preview.json",
|
|
38
|
+
"verify": "npm run lint && npm run test && npm run build && npm run typecheck:preview"
|
|
39
|
+
},
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"@ant-design/icons": ">=5.0.0",
|
|
42
|
+
"antd": ">=6.0.0",
|
|
43
|
+
"react": ">=18.2.0",
|
|
44
|
+
"react-dom": ">=18.2.0"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"dayjs": "^1.11.13",
|
|
48
|
+
"decimal.js": "^10.6.0",
|
|
49
|
+
"comlink": "^4.4.2",
|
|
50
|
+
"exceljs": "^4.4.0",
|
|
51
|
+
"file-saver": "^2.0.5"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@eslint/js": "^9.39.4",
|
|
55
|
+
"@types/file-saver": "^2.0.7",
|
|
56
|
+
"@types/node": "^25.9.1",
|
|
57
|
+
"@types/react": "^19.2.14",
|
|
58
|
+
"@types/react-dom": "^19.2.3",
|
|
59
|
+
"@typescript-eslint/eslint-plugin": "^8.60.0",
|
|
60
|
+
"@typescript-eslint/parser": "^8.60.0",
|
|
61
|
+
"@vitejs/plugin-react": "^6.0.1",
|
|
62
|
+
"antd": "^6.3.4",
|
|
63
|
+
"eslint": "^9.39.4",
|
|
64
|
+
"eslint-config-prettier": "^10.1.8",
|
|
65
|
+
"eslint-plugin-react": "^7.37.5",
|
|
66
|
+
"eslint-plugin-react-hooks": "^7.1.1",
|
|
67
|
+
"eslint-plugin-react-refresh": "^0.5.2",
|
|
68
|
+
"globals": "^17.6.0",
|
|
69
|
+
"prettier": "^3.8.3",
|
|
70
|
+
"react": "^19.2.6",
|
|
71
|
+
"react-dom": "^19.2.6",
|
|
72
|
+
"typescript": "~6.0.2",
|
|
73
|
+
"typescript-eslint": "^8.60.0",
|
|
74
|
+
"vite": "^8.0.12",
|
|
75
|
+
"vitest": "^5.1.1"
|
|
76
|
+
},
|
|
77
|
+
"keywords": [
|
|
78
|
+
"react",
|
|
79
|
+
"antd",
|
|
80
|
+
"ant-design",
|
|
81
|
+
"excel",
|
|
82
|
+
"xlsx",
|
|
83
|
+
"exceljs",
|
|
84
|
+
"import",
|
|
85
|
+
"export",
|
|
86
|
+
"template",
|
|
87
|
+
"validation",
|
|
88
|
+
"batch",
|
|
89
|
+
"typescript"
|
|
90
|
+
],
|
|
91
|
+
"author": "Czw96",
|
|
92
|
+
"license": "MIT",
|
|
93
|
+
"repository": {
|
|
94
|
+
"type": "git",
|
|
95
|
+
"url": "git+https://github.com/Czw96/antd-import-export.git"
|
|
96
|
+
},
|
|
97
|
+
"bugs": {
|
|
98
|
+
"url": "https://github.com/Czw96/antd-import-export/issues"
|
|
99
|
+
},
|
|
100
|
+
"homepage": "https://github.com/Czw96/antd-import-export#readme"
|
|
101
|
+
}
|