@ithinkdt/ui 4.0.0-9 → 4.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/dist/page.js ADDED
@@ -0,0 +1,642 @@
1
+ import { n as useI18n } from "./use-i18n-D-AJ8KbA.js";
2
+ import { a as DtUserRender, h as DataForm, i as DtUserDept, r as DtDeptRender, s as NRadios, x as NCheckboxes } from "./components-BXPJvdEe.js";
3
+ import { computed, createVNode, defineComponent, h, isVNode, mergeProps, nextTick, ref, shallowRef, toValue, unref } from "vue";
4
+ import { until, useClipboard } from "@vueuse/core";
5
+ import { NButton, NCheckbox, NColorPicker, NDatePicker, NDrawer, NDrawerContent, NFlex, NIcon, NInput, NInputNumber, NModal, NScrollbar, NSelect, NText, NUpload, useMessage } from "ithinkdt-ui";
6
+ import { nanoid } from "nanoid";
7
+ import { format } from "date-fns";
8
+ import { useFormItem } from "ithinkdt-ui/es/_mixins";
9
+ import { useModal } from "@ithinkdt/page";
10
+ import { isNullish } from "@ithinkdt/common";
11
+ import { useDict, useDictMap } from "@ithinkdt/common/dict";
12
+ function _isSlot(e) {
13
+ return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !isVNode(e);
14
+ }
15
+ var mapProps = (e) => Object.fromEntries(Object.entries(e || {}).map(([e, t]) => [e, unref(t)])), SimpleUpload = /* @__PURE__ */ defineComponent({
16
+ name: "SimpleUpload",
17
+ props: {
18
+ type: {
19
+ type: String,
20
+ default: "file"
21
+ },
22
+ size: {
23
+ type: String,
24
+ default: "medium"
25
+ },
26
+ multiple: {
27
+ type: Boolean,
28
+ default: !1
29
+ },
30
+ max: {
31
+ type: Number,
32
+ default: void 0
33
+ },
34
+ accept: {
35
+ type: String,
36
+ default: void 0
37
+ },
38
+ maxSize: {
39
+ type: Number,
40
+ default: void 0
41
+ },
42
+ disabled: {
43
+ type: Boolean,
44
+ default: void 0
45
+ },
46
+ fileList: {
47
+ type: Array,
48
+ default: () => []
49
+ },
50
+ onUpdateFileList: { type: [Array, Function] },
51
+ uploadFile: { type: Function }
52
+ },
53
+ setup(t, { slots: n, expose: r }) {
54
+ let { t: i } = useI18n();
55
+ SimpleUpload.t = i;
56
+ let a = useFormItem(t), o = useMessage(), c = computed(() => t.customRequest || (({ file: e, onProgress: n, onFinish: r, onError: i }) => {
57
+ t.uploadFile(e.file, (e) => n({ percent: e })).then((t) => {
58
+ e.file.fileId = t, r();
59
+ }).catch((e) => {
60
+ o.error(e.message), i(e);
61
+ });
62
+ })), l = ref();
63
+ r({ submit() {
64
+ return until(l).toBeTruthy().then((e) => e.submit());
65
+ } });
66
+ let u = (e) => {
67
+ if (e) for (let n of e) n.size > t.maxSize * 1024 && (n.status = "error");
68
+ t.onUpdateFileList?.(e), nextTick(() => a.nTriggerFormChange());
69
+ };
70
+ return () => {
71
+ let { type: e, onUpdateFileList: r, ...o } = t;
72
+ return createVNode(NUpload, mergeProps(o, {
73
+ ref: l,
74
+ customRequest: c.value,
75
+ listType: e === "image" ? "image-card" : "text",
76
+ accept: o.accept ?? e === "image" ? "image/*" : void 0,
77
+ "onUpdate:fileList": u
78
+ }), {
79
+ default: e === "image" ? void 0 : () => {
80
+ let e;
81
+ return createVNode(NButton, {
82
+ disabled: a.mergedDisabledRef.value,
83
+ size: a.mergedSizeRef.value
84
+ }, _isSlot(e = i("common.page.form.selectFileText")) ? e : { default: () => [e] });
85
+ },
86
+ ...n
87
+ });
88
+ };
89
+ }
90
+ });
91
+ function createPageFormHelper({ getUserGroups: e, getUsersByGroup: n, getDeptsByCode: i, getUsersByDept: s, getUsersByUsername: c, uploadFile: u, getFileInfos: d }) {
92
+ let f = (e) => e, p = (e) => isNullish(e) ? e : String(e), g = (e) => isNullish(e) ? e : Number(e);
93
+ return {
94
+ input: () => ({ slots: e, props: t }, { modelValue: n, "onUpdate:modelValue": r, required: i, readonly: a, ...o }) => a ? createVNode(NText, {
95
+ depth: 2,
96
+ style: "line-height: 1.25"
97
+ }, { default: () => [n ?? ""] }) : (t = mapProps(t), h(NInput, {
98
+ clearable: !0,
99
+ ...t,
100
+ ...o,
101
+ value: n,
102
+ "onUpdate:value": r
103
+ }, e)),
104
+ number: () => {
105
+ let e, t;
106
+ return ({ slots: n, props: r }, { modelValue: i, "onUpdate:modelValue": a, required: o, readonly: s, ...c }) => {
107
+ if (s) return createVNode(NText, {
108
+ depth: 2,
109
+ style: "line-height: 1.25"
110
+ }, { default: () => [i ?? ""] });
111
+ let { valueType: u = "number", ...d } = mapProps(r), f = u === "string" ? g(i) : i;
112
+ return e = a, u === "string" && !t && (t = (t, ...n) => {
113
+ e(p(t), ...n);
114
+ }), h(NInputNumber, {
115
+ clearable: !0,
116
+ ...d,
117
+ ...c,
118
+ value: f,
119
+ "onUpdate:value": u === "string" ? t : e
120
+ }, n);
121
+ };
122
+ },
123
+ select: () => {
124
+ let e, t, n, r, i;
125
+ return ({ slots: a, props: o }, { modelValue: s, "onUpdate:modelValue": c, required: u, readonly: d, ...m }) => {
126
+ let { dictType: v, options: y, valueType: b = "string", ...x } = mapProps(o), S = b === "number" ? p : f;
127
+ y ? t = y : e !== v && (e = v, !t && e && (t = useDict(e)));
128
+ let C = x.multiple ? s?.map(S) : S(s);
129
+ if (d) if (x.multiple) {
130
+ let e;
131
+ return createVNode(NText, {
132
+ depth: 2,
133
+ style: "line-height: 1.25"
134
+ }, _isSlot(e = (C?.map((e) => t?.find((t) => t[x.valueField || "value"] === e)) ?? []).map((e, t, n) => {
135
+ let r = e ? x.renderLabel ? x.renderLabel(e) ?? "" : e[x.labelField || "label"] ?? "" : C[t] ?? "";
136
+ return createVNode("span", { key: e ? e[x.valueField || "value"] : C[t] ?? "" }, [r, t < n.length - 1 ? ", " : ""]);
137
+ })) ? e : { default: () => [e] });
138
+ } else {
139
+ let e = t?.find((e) => e[x.valueField || "value"] === C);
140
+ return createVNode(NText, {
141
+ depth: 2,
142
+ style: "line-height: 1.25"
143
+ }, { default: () => [e ? x.renderLabel ? x.renderLabel(e) ?? "" : e[x.labelField || "label"] ?? "" : C ?? ""] });
144
+ }
145
+ return r = x.multiple, n = c, b === "number" && !i && (i = (e, ...t) => {
146
+ n(r ? e?.map(g) : g(e), ...t);
147
+ }), h(NSelect, {
148
+ clearable: !0,
149
+ loading: t?.loading,
150
+ ...x,
151
+ options: unref(t),
152
+ ...m,
153
+ value: C,
154
+ "onUpdate:value": b === "number" ? i : n
155
+ }, a);
156
+ };
157
+ },
158
+ checkbox: () => ({ slots: e, props: t }, { modelValue: n, "onUpdate:modelValue": r, required: i, readonly: a, ...o }) => {
159
+ if (t = mapProps(t), a) {
160
+ let r;
161
+ return r = n === (t.checkedValue ?? !0) ? e?.checked ? e.checked() : createVNode(NCheckbox, { checked: !0 }, null) : e?.unchecked ? e.unchecked() : createVNode(NCheckbox, { disabled: !0 }, null), createVNode(NText, {
162
+ depth: 2,
163
+ style: "line-height: 1.25"
164
+ }, _isSlot(r) ? r : { default: () => [r] });
165
+ }
166
+ return h(NCheckbox, {
167
+ ...t,
168
+ ...o,
169
+ checked: n,
170
+ "onUpdate:checked": r
171
+ }, e);
172
+ },
173
+ checkboxes: () => {
174
+ let e, t, n, r;
175
+ return ({ props: i }, { modelValue: a, "onUpdate:modelValue": s, required: c, readonly: u, ...d }) => {
176
+ let { dictType: m, options: _, valueType: v = "string", ...y } = mapProps(i), b = v === "number" ? p : f;
177
+ _ ? t = _ : e !== m && (e = m, !t && e && (t = useDict(e)));
178
+ let x = a?.map(b) ?? [];
179
+ if (u) {
180
+ let e;
181
+ return createVNode(NText, {
182
+ depth: 2,
183
+ style: "line-height: 2.4"
184
+ }, _isSlot(e = (x?.map((e) => t?.find((t) => t[y.valueField || "value"] === e)) ?? []).map((e, t, n) => {
185
+ let r = e ? e[y.labelField ?? "label"] ?? "" : x[t] ?? "";
186
+ return createVNode("span", { key: e ? e[y.valueField ?? "value"] : x[t] ?? "" }, [r, t < n.length - 1 ? ", " : ""]);
187
+ })) ? e : { default: () => [e] });
188
+ }
189
+ return n = s, v === "number" && !r && (r = (e, ...t) => {
190
+ n(e?.map(g), ...t);
191
+ }), h(NCheckboxes, {
192
+ ...y,
193
+ ...d,
194
+ options: t,
195
+ modelValue: x,
196
+ "onUpdate:modelValue": v === "number" ? r : n
197
+ });
198
+ };
199
+ },
200
+ radios: () => {
201
+ let e, t, n, r;
202
+ return ({ props: i }, { modelValue: o, "onUpdate:modelValue": s, required: c, readonly: u, ...d }) => {
203
+ let { dictType: m, options: _, valueType: v = "string", ...y } = mapProps(i), b = v === "number" ? p : f;
204
+ _ ? t = _ : e !== m && (e = m, !t && e && (t = useDict(e)));
205
+ let x = b(o);
206
+ if (u) {
207
+ let e = t?.find((e) => e[y.valueField ?? "value"] === x);
208
+ return createVNode(NText, {
209
+ depth: 2,
210
+ style: "line-height: 1.25"
211
+ }, { default: () => [e ? e[y.labelField ?? "label"] ?? "" : x ?? ""] });
212
+ }
213
+ return n = s, v === "number" && !r && (r = (e, ...t) => {
214
+ n(g(e), ...t);
215
+ }), h(NRadios, {
216
+ ...y,
217
+ ...d,
218
+ options: t,
219
+ modelValue: x,
220
+ "onUpdate:modelValue": v === "number" ? r : n
221
+ });
222
+ };
223
+ },
224
+ datepicker: () => ({ slots: e, props: t }, { modelValue: n, "onUpdate:modelValue": r, required: i, readonly: a, ...o }) => {
225
+ let { type: s = "date", format: c = s.startsWith("datetime") ? "yyyy-MM-dd HH:mm:ss" : "yyyy-MM-dd", ...u } = mapProps(t);
226
+ return a ? s.endsWith("range") ? createVNode(NText, {
227
+ depth: 2,
228
+ style: "line-height: 1.25"
229
+ }, { default: () => [n ? `${n[0] ? format(n[0], c) : ""} ~ ${n[1] ? format(n[1], c) : ""}` : ""] }) : createVNode(NText, {
230
+ depth: 2,
231
+ style: "line-height: 1.25"
232
+ }, { default: () => [n ? format(n, c) : ""] }) : h(NDatePicker, {
233
+ actions: null,
234
+ updateValueOnClose: !0,
235
+ clearable: !0,
236
+ ...u,
237
+ ...o,
238
+ type: s,
239
+ format: c,
240
+ value: n,
241
+ "onUpdate:value": r
242
+ }, e);
243
+ },
244
+ file: () => ({ slots: e, props: t }, { modelValue: n, "onUpdate:modelValue": r, required: i, readonly: a, ...o }) => {
245
+ if (t = mapProps(t), a) {
246
+ let e;
247
+ return console.warn("[file] 原则上此组建不应该显示在详情中"), n?.length ? createVNode(NFlex, {
248
+ gap: "8",
249
+ vertical: !0
250
+ }, _isSlot(e = n.map((e) => createVNode("a", {
251
+ key: e.id,
252
+ href: e.url,
253
+ target: "_blank",
254
+ rel: "noreferrer",
255
+ style: "max-width: 100px; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; display: inline-block"
256
+ }, [e.name]))) ? e : { default: () => [e] }) : void 0;
257
+ }
258
+ return h(SimpleUpload, {
259
+ ...t,
260
+ ...o,
261
+ defaultUpload: !1,
262
+ uploadFile: u,
263
+ fileList: n,
264
+ onUpdateFileList: r
265
+ }, e);
266
+ },
267
+ upload: () => {
268
+ let e = null, t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), r = shallowRef([]), i = 0, a = (e) => {
269
+ let t = ++i;
270
+ r.value = e.map((e) => n.get(e)).filter(Boolean);
271
+ let a = e.filter((e) => !n.has(e));
272
+ Promise.resolve(a.length > 0 ? d(a) : []).then((a) => {
273
+ if (t === i) {
274
+ r.value = e.map((e) => n.get(e) || a.find((t) => t.id === e)), n.clear();
275
+ for (let e of r.value) n.set(e.id, e);
276
+ }
277
+ });
278
+ }, o, s;
279
+ return {
280
+ renderer: ({ slots: i, props: c }, { modelValue: d, "onUpdate:modelValue": f, required: p, readonly: g, ..._ }) => {
281
+ let v = mapProps(c);
282
+ if (s = v.maxSize, o = v.ref ??= shallowRef(), e !== d && (e = d, a(d?.split(",") ?? [])), g) {
283
+ let e;
284
+ return r.value.length === 0 ? void 0 : createVNode(NFlex, {
285
+ gap: "8",
286
+ vertical: !0,
287
+ style: "padding: 6px 0"
288
+ }, _isSlot(e = r.value.map((e) => createVNode("a", {
289
+ key: e.id,
290
+ href: e.url,
291
+ target: "_blank",
292
+ rel: "noreferrer",
293
+ title: e.name,
294
+ download: e.name,
295
+ style: "max-width: 100%; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; display: inline-block"
296
+ }, [e.name]))) ? e : { default: () => [e] });
297
+ }
298
+ return h(SimpleUpload, {
299
+ ...v,
300
+ ..._,
301
+ uploadFile: u,
302
+ fileList: r.value,
303
+ onUpdateFileList: (e = []) => {
304
+ n.clear();
305
+ for (let r of e) r.file?.fileId && t.set(r.id, r.file.fileId), r.file?.fileId ? n.set(r.file.fileId, r) : n.set(r.id, r);
306
+ r.value = e, f(r.value.map((e) => t.get(e.id) || e.id).join(",") || null);
307
+ }
308
+ }, i);
309
+ },
310
+ beforeSubmit: async () => {
311
+ if (await o?.value?.submit(), await until(r).toMatch((e) => e.every((e) => !["pending", "uploading"].includes(e.status))), r.value.some((e) => e.size > s * 1024)) return SimpleUpload.t("common.page.form.validate.fileSizeExceeded", { maxSize: s });
312
+ if (r.value.some((e) => e.status === "error")) return SimpleUpload.t("common.page.form.validate.fileErrorMessage");
313
+ }
314
+ };
315
+ },
316
+ user: () => {
317
+ let a, o, u;
318
+ return ({ slots: d, props: f }, { modelValue: p, "onUpdate:modelValue": g, required: _, readonly: v, ...y }) => {
319
+ let b = mapProps(f);
320
+ return a || (a = shallowRef([]), o = shallowRef([]), u = shallowRef([]), c().then((e) => {
321
+ a.value = e;
322
+ }), e().then((e) => {
323
+ o.value = e;
324
+ }), i().then((e) => {
325
+ u.value = e;
326
+ })), v ? createVNode(DtUserRender, {
327
+ value: p,
328
+ multiple: b.multiple,
329
+ getUsersByUsername: c,
330
+ renderInfo: b.renderInfo
331
+ }, null) : h(DtUserDept, {
332
+ type: "user",
333
+ users: a.value,
334
+ depts: u.value,
335
+ groups: o.value,
336
+ getUsersByDept: s,
337
+ getUsersByGroup: n,
338
+ ...b,
339
+ ...y,
340
+ renderUserInfo: b.renderInfo,
341
+ modelValue: p,
342
+ "onUpdate:modelValue": g
343
+ }, d);
344
+ };
345
+ }
346
+ };
347
+ }
348
+ function createDescriptionHelper({ getDeptsByCode: e, getUsersByUsername: n, getFileInfos: r, previewFileUrl: a }) {
349
+ let o = (e) => (t, n, { params: r = {} }) => {
350
+ if (t != null) return format(t, r.formatter ?? e);
351
+ }, s = (e = {}) => createVNode("svg", mergeProps({
352
+ xmlns: "http://www.w3.org/2000/svg",
353
+ width: "1em",
354
+ height: "1em",
355
+ viewBox: "0 0 32 32"
356
+ }, e), [createVNode("circle", {
357
+ cx: "16",
358
+ cy: "16",
359
+ r: "8",
360
+ fill: "currentColor"
361
+ }, null)]), c = (e = {}) => createVNode("svg", mergeProps({
362
+ xmlns: "http://www.w3.org/2000/svg",
363
+ width: "1em",
364
+ height: "1em",
365
+ viewBox: "0 0 24 24"
366
+ }, e), [createVNode("path", {
367
+ fill: "currentColor",
368
+ d: "M12 9a3 3 0 0 1 3 3a3 3 0 0 1-3 3a3 3 0 0 1-3-3a3 3 0 0 1 3-3m0-4.5c5 0 9.27 3.11 11 7.5c-1.73 4.39-6 7.5-11 7.5S2.73 16.39 1 12c1.73-4.39 6-7.5 11-7.5M3.18 12a9.821 9.821 0 0 0 17.64 0a9.821 9.821 0 0 0-17.64 0"
369
+ }, null)]), l = (e) => createVNode("svg", mergeProps({
370
+ xmlns: "http://www.w3.org/2000/svg",
371
+ width: "1em",
372
+ height: "1em",
373
+ viewBox: "0 0 24 24"
374
+ }, e), [createVNode("path", {
375
+ fill: "currentColor",
376
+ d: "M19 21H8V7h11m0-2H8a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h11a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2m-3-4H4a2 2 0 0 0-2 2v14h2V3h12z"
377
+ }, null)]), u = (e) => createVNode("svg", mergeProps({
378
+ xmlns: "http://www.w3.org/2000/svg",
379
+ width: "1em",
380
+ height: "1em",
381
+ viewBox: "0 0 24 24"
382
+ }, e), [createVNode("path", {
383
+ fill: "currentColor",
384
+ d: "M20 12a8 8 0 0 1-8 8a8 8 0 0 1-8-8a8 8 0 0 1 8-8c.76 0 1.5.11 2.2.31l1.57-1.57A9.8 9.8 0 0 0 12 2A10 10 0 0 0 2 12a10 10 0 0 0 10 10a10 10 0 0 0 10-10M7.91 10.08L6.5 11.5L11 16L21 6l-1.41-1.42L11 13.17z"
385
+ }, null)]);
386
+ return {
387
+ longtext: () => {
388
+ let e = ref(), { open: t } = useModal({
389
+ type: "drawer",
390
+ resizable: !0,
391
+ content: () => createVNode("div", null, [createVNode("span", null, [e.value])]),
392
+ width: 600,
393
+ footer: null,
394
+ maskClosable: !0
395
+ }), { copy: n, copied: r } = useClipboard({ legacy: !0 }), i = (i, a, o) => {
396
+ if (!a) return t(i);
397
+ let s = () => {
398
+ o ? o(e.value) : n(e.value);
399
+ };
400
+ return t(() => createVNode("div", { style: "display: flex; align-items: center; justify-content: space-between; margin-right: 4px;" }, [toValue(i), r.value ? createVNode(NButton, {
401
+ quaternary: !0,
402
+ size: "tiny",
403
+ type: "success"
404
+ }, { icon: () => createVNode(NIcon, { size: 18 }, { default: () => [createVNode(u, null, null)] }) }) : createVNode(NButton, {
405
+ quaternary: !0,
406
+ size: "tiny",
407
+ onClick: s
408
+ }, { icon: () => createVNode(NIcon, { size: 16 }, { default: () => [createVNode(l, null, null)] }) })]));
409
+ };
410
+ return {
411
+ renderer: (t, n, { params: r = {} }, { label: a }) => createVNode("div", { style: "white-space: nowrap; overflow: hidden; display: flex; gap: 8px; align-items: center; justify-content: space-between" }, [createVNode("div", { style: "flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;" }, [t]), createVNode(NButton, {
412
+ type: "info",
413
+ text: !0,
414
+ style: "position: sticky; right: 0; z-index: 2",
415
+ onClick: r.showText ? () => r.showText(t) : () => {
416
+ e.value = r.formatText ? r.formatText(t) : t, i(r.title || a, r.copyable !== !1, r.onCopy);
417
+ }
418
+ }, { default: () => [createVNode(NIcon, { size: 18 }, { default: () => [createVNode(c, null, null)] })] })]),
419
+ default: { table: { ellipsis: !1 } }
420
+ };
421
+ },
422
+ date: () => ({
423
+ renderer: o("yyyy-MM-dd"),
424
+ default: { table: {
425
+ width: 140,
426
+ align: "center",
427
+ sortable: !0
428
+ } }
429
+ }),
430
+ datetime: () => ({
431
+ renderer: o("yyyy-MM-dd HH:mm:ss"),
432
+ default: { table: {
433
+ width: 174,
434
+ align: "center",
435
+ sortable: !0
436
+ } }
437
+ }),
438
+ dict: () => {
439
+ let e, t, n;
440
+ return (r, i, { params: a = {} }) => {
441
+ if (r == null) return;
442
+ let { dictType: o, options: c, multiple: l, statusMap: u } = mapProps(a);
443
+ if (c ? t !== c && (t = c, n = new Map(c.map((e) => [e[a.valueField || "value"], e]))) : e !== o && (e = o, !n && e && (n = useDictMap(e))), !l) {
444
+ if (r = r.toString(), u && r in u) {
445
+ let e = u[r] ?? "default";
446
+ return [
447
+ "primary",
448
+ "success",
449
+ "warning",
450
+ "danger"
451
+ ].includes(e) && (e = `var(--color-${e})`), createVNode("span", { style: "position: relative; padding-left: 1.25em" }, [createVNode(s, { style: `color: ${e}; position: absolute;left: 0; top: 1.5px` }, null), createVNode("span", null, [n.get(r)?.[a.labelField || "label"] ?? r ?? ""])]);
452
+ }
453
+ return n.get(r)?.[a.labelField || "label"] ?? r ?? "";
454
+ }
455
+ return r?.map((e) => n.get(e?.toString())?.[a.labelField || "label"] ?? e?.toString() ?? "") ?? "";
456
+ };
457
+ },
458
+ number: () => ({
459
+ renderer: (e, t, { params: n = {} }) => {
460
+ if (e != null) {
461
+ switch (n.percent && (e = Number(e) * 100), "number") {
462
+ case typeof n.fixed:
463
+ e = e.toFixed(n.fixed);
464
+ break;
465
+ case typeof n.round:
466
+ e = e.toFixed(n.round).replace(/0+$/, "");
467
+ break;
468
+ case typeof n.precision:
469
+ e = e.toPrecision(n.precision);
470
+ break;
471
+ }
472
+ return n?.separator ? Number(e).toLocaleString() : e;
473
+ }
474
+ },
475
+ default: { table: {
476
+ width: 100,
477
+ align: "right",
478
+ sortable: !0
479
+ } }
480
+ }),
481
+ email: () => (e) => createVNode("a", { href: `mailto:${e}` }, [e]),
482
+ url: () => (e) => createVNode("a", { href: e }, [e]),
483
+ color: () => (e) => createVNode(NColorPicker, {
484
+ value: e,
485
+ disabled: !0,
486
+ size: "small"
487
+ }, null),
488
+ image: () => (e, t, { params: n = {} }) => {
489
+ let r;
490
+ return e ? createVNode(NFlex, {
491
+ gap: "8",
492
+ wrap: !0
493
+ }, _isSlot(r = (Array.isArray(e) ? e : n?.multiple ? e.split(",") : [e]).map((e) => a(e)).map((e) => createVNode("img", {
494
+ key: e,
495
+ src: e,
496
+ style: "max-height: 32px; max-width: 100px; object-fit: contain"
497
+ }, null))) ? r : { default: () => [r] }) : void 0;
498
+ },
499
+ file: () => {
500
+ let e = nanoid();
501
+ return (t, n, { params: i = {} }) => {
502
+ let a;
503
+ return t ? (n.__file_urls ??= {}, n.__file_urls[e] || r(Array.isArray(t) ? t : i?.multiple ? t.split(",") : [t]).then((t) => {
504
+ n.__file_urls[e] = t;
505
+ }), createVNode(NFlex, {
506
+ gap: "8",
507
+ wrap: !0
508
+ }, _isSlot(a = (n.__file_urls[e] || []).map((e) => createVNode("a", {
509
+ key: e.id,
510
+ href: e.url,
511
+ target: "_blank",
512
+ rel: "noreferrer",
513
+ style: "max-width: 100px; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; display: inline-block"
514
+ }, [e.name]))) ? a : { default: () => [a] })) : void 0;
515
+ };
516
+ },
517
+ dept: () => (t, n, { params: r = {} }) => {
518
+ if (t) return createVNode(DtDeptRender, {
519
+ value: t,
520
+ multiple: r?.multiple,
521
+ getDeptsByCode: e
522
+ }, null);
523
+ },
524
+ user: () => {
525
+ let e = { style: "padding-block: 0" };
526
+ return {
527
+ renderer: (e, r, { params: i = {} }) => {
528
+ if (e) return createVNode(DtUserRender, {
529
+ value: e,
530
+ multiple: i?.multiple,
531
+ getUsersByUsername: n
532
+ }, null);
533
+ },
534
+ default: { table: {
535
+ width: 150,
536
+ ellipsis: !1,
537
+ align: "center",
538
+ cellProps: () => e
539
+ } }
540
+ };
541
+ }
542
+ };
543
+ }
544
+ function createFormHelper() {
545
+ return () => ({ items: e, model: t, handleSubmit: r, reset: i, validation: a, readonly: o, inModal: s, showFeedback: c, showColon: l, labelWidth: u, labelAlign: d, labelPlacement: f, showRequireMark: p, requireMarkPlacement: m }) => createVNode(DataForm, {
546
+ readonly: o,
547
+ model: t,
548
+ items: e,
549
+ validation: a,
550
+ showColon: unref(l) ?? !0,
551
+ labelWidth: unref(u),
552
+ labelAlign: unref(d),
553
+ labelPlacement: unref(f),
554
+ showRequireMark: unref(p),
555
+ requireMarkPlacement: unref(m),
556
+ showFeedback: unref(c) ?? !0,
557
+ showAction: !1,
558
+ onSubmit: r,
559
+ onReset: i,
560
+ style: s ? "padding-right: 2rem; padding-top: 1rem" : void 0
561
+ }, null);
562
+ }
563
+ function createModalHelper() {
564
+ let e = (e) => typeof e == "number" ? `${e}px` : e, t = {
565
+ maxHeight: "calc(100vh - 130px)",
566
+ display: "flex",
567
+ flexDirection: "column"
568
+ }, n = { content: !0 };
569
+ return () => ({ type: r = "dialog", visible: i, title: a, content: o, footer: s, placement: c, resizable: l, draggable: u, closeOnEsc: f, closable: p, showMask: m, maskClosable: g, width: _, height: v, style: y, onClose: x, onCancel: S, onConfirm: C, onAfterClose: w, onAfterOpen: T, confirmText: E, confirmDisabled: D, confirmLoading: O, cancelText: k, cancelDisabled: A, cancelLoading: j, nativeScrollbar: M, ...N }) => {
570
+ let P = s ? () => s : s === null ? null : () => createVNode(NFlex, {
571
+ justify: "end",
572
+ gap: "16"
573
+ }, { default: () => [k === null ? void 0 : createVNode(NButton, {
574
+ onClick: S,
575
+ disabled: A,
576
+ loading: j,
577
+ style: "min-width: 60px"
578
+ }, _isSlot(k) ? k : { default: () => [k] }), E === null ? void 0 : createVNode(NButton, {
579
+ type: "primary",
580
+ onClick: C,
581
+ disabled: D,
582
+ loading: O,
583
+ style: "min-width: 60px"
584
+ }, _isSlot(E) ? E : { default: () => [E] })] });
585
+ if (r === "dialog") {
586
+ let { style: r } = mergeProps({ style: {
587
+ width: e(_ ?? 520),
588
+ height: e(v)
589
+ } }, { style: y });
590
+ return createVNode(NModal, mergeProps({
591
+ show: i,
592
+ preset: "card",
593
+ title: () => a,
594
+ maskClosable: g ?? !1,
595
+ closeOnEsc: f,
596
+ closable: p,
597
+ onClose: x,
598
+ segmented: n,
599
+ size: "small",
600
+ onAfterEnter: T,
601
+ onAfterLeave: w,
602
+ onUpdateShow: x,
603
+ draggable: u ?? !0,
604
+ style: r,
605
+ contentStyle: t
606
+ }, N), {
607
+ default: () => createVNode(NScrollbar, {
608
+ abstract: !0,
609
+ style: "display: flex; flex-direction: column"
610
+ }, _isSlot(o) ? o : { default: () => [o] }),
611
+ action: P
612
+ });
613
+ }
614
+ let { bodyContentClass: F, bodyContentStyle: I, ...L } = N;
615
+ return createVNode(NDrawer, mergeProps({
616
+ show: i,
617
+ trapFocus: !1,
618
+ closeOnEsc: f,
619
+ showMask: m,
620
+ maskClosable: g,
621
+ resizable: l,
622
+ placement: c,
623
+ width: l ? void 0 : _ ?? 440,
624
+ defaultWidth: l ? _ ?? 440 : void 0,
625
+ height: v,
626
+ onUpdateShow: x,
627
+ onAfterEnter: T,
628
+ onAfterLeave: w,
629
+ style: y
630
+ }, L), { default: () => [createVNode(NDrawerContent, {
631
+ closable: p,
632
+ nativeScrollbar: M ?? !1,
633
+ bodyContentClass: F,
634
+ bodyContentStyle: I
635
+ }, {
636
+ default: () => o,
637
+ header: () => a,
638
+ footer: P
639
+ })] });
640
+ };
641
+ }
642
+ export { createDescriptionHelper, createFormHelper, createModalHelper, createPageFormHelper };
@@ -0,0 +1,6 @@
1
+ import { inject } from "vue";
2
+ const UI_I18N_INJECTION = "__UI_I18N__";
3
+ function useI18n() {
4
+ return inject(UI_I18N_INJECTION).value();
5
+ }
6
+ export { useI18n as n, UI_I18N_INJECTION as t };
@@ -0,0 +1,29 @@
1
+ import { useMergedClsPrefix } from "ithinkdt-ui/es/_mixins/use-config";
2
+ import _useStyle from "ithinkdt-ui/es/_mixins/use-style";
3
+ import { c, cB, cE, cM } from "ithinkdt-ui/es/_utils/cssr/index";
4
+ function useStyle(t, n, r, i) {
5
+ return r ??= useMergedClsPrefix(), _useStyle(t, n, r, i), r;
6
+ }
7
+ const fullWidth = { width: "100%" }, fullHeight = { height: "100%" }, fullWH = {
8
+ ...fullWidth,
9
+ ...fullHeight
10
+ }, flex = { display: "flex" }, flexDirCol = {
11
+ ...flex,
12
+ flexDirection: "column"
13
+ }, flexAlignCenter = {
14
+ ...flex,
15
+ alignItems: "center"
16
+ }, flexJustifyCenter = {
17
+ ...flex,
18
+ justifyContent: "center"
19
+ }, flexJustifySB = {
20
+ ...flex,
21
+ justifyContent: "space-between"
22
+ }, flexCenter = {
23
+ ...flexAlignCenter,
24
+ ...flexJustifyCenter
25
+ }, flexGap = (e) => ({
26
+ ...flex,
27
+ gap: e
28
+ });
29
+ export { flex as a, flexDirCol as c, flexJustifySB as d, fullHeight as f, useStyle as g, useMergedClsPrefix as h, cM as i, flexGap as l, fullWidth as m, cB as n, flexAlignCenter as o, fullWH as p, cE as r, flexCenter as s, c as t, flexJustifyCenter as u };
@@ -0,0 +1,2 @@
1
+ import { a as flex, c as flexDirCol, d as flexJustifySB, f as fullHeight, g as useStyle, h as useMergedClsPrefix, i as cM, l as flexGap, m as fullWidth, n as cB, o as flexAlignCenter, p as fullWH, r as cE, s as flexCenter, t as c, u as flexJustifyCenter } from "./use-style-BGq0HdRK.js";
2
+ export { c, cB, cE, cM, useStyle as default, flex, flexAlignCenter, flexCenter, flexDirCol, flexGap, flexJustifyCenter, flexJustifySB, fullHeight, fullWH, fullWidth, useMergedClsPrefix as useClsPrefix };