@rytass/bpm-core-react 0.13.5 → 0.15.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/CHANGELOG.md +97 -0
- package/dist/chunks/FormBuilderView-6bCbIkz6.cjs +3 -0
- package/dist/chunks/FormBuilderView-6bCbIkz6.cjs.map +1 -0
- package/dist/chunks/{FormBuilderView-BYLN6W-P.js → FormBuilderView-CLg-JYmu.js} +495 -452
- package/dist/chunks/FormBuilderView-CLg-JYmu.js.map +1 -0
- package/dist/chunks/FormRendererView-DU9LLrOF.js +999 -0
- package/dist/chunks/FormRendererView-DU9LLrOF.js.map +1 -0
- package/dist/chunks/FormRendererView-gctFIqwC.cjs +4 -0
- package/dist/chunks/FormRendererView-gctFIqwC.cjs.map +1 -0
- package/dist/chunks/{compose-6P64PO1i.js → compose-BtQPBd1Q.js} +6 -5
- package/dist/chunks/compose-BtQPBd1Q.js.map +1 -0
- package/dist/chunks/compose-DZhTQOt4.cjs +2 -0
- package/dist/chunks/compose-DZhTQOt4.cjs.map +1 -0
- package/dist/chunks/{designer-C3s2kSna.js → designer-CrbBRPUU.js} +1382 -1199
- package/dist/chunks/designer-CrbBRPUU.js.map +1 -0
- package/dist/chunks/designer-D3_lWmfa.cjs +65 -0
- package/dist/chunks/designer-D3_lWmfa.cjs.map +1 -0
- package/dist/chunks/detail-CVXb5Vy8.cjs +2 -0
- package/dist/chunks/detail-CVXb5Vy8.cjs.map +1 -0
- package/dist/chunks/{detail-pYEIk-jW.js → detail-_c21WQla.js} +862 -815
- package/dist/chunks/detail-_c21WQla.js.map +1 -0
- package/dist/chunks/routes-config-C1j_vFKo.cjs.map +1 -1
- package/dist/chunks/routes-config-yZbESPlw.js.map +1 -1
- package/dist/chunks/task-node-label-BF6UllxP.cjs +2 -0
- package/dist/chunks/task-node-label-BF6UllxP.cjs.map +1 -0
- package/dist/chunks/task-node-label-CWZgOBj0.js +9 -0
- package/dist/chunks/task-node-label-CWZgOBj0.js.map +1 -0
- package/dist/lib/member-profile-resolution.d.ts +48 -0
- package/dist/lib/routes-config.d.ts +1 -1
- package/dist/lib/task-node-label.d.ts +10 -0
- package/dist/pages/instances/detail/index.cjs +1 -1
- package/dist/pages/instances/detail/index.js +1 -1
- package/dist/pages/templates/compose/index.cjs +1 -1
- package/dist/pages/templates/compose/index.js +1 -1
- package/dist/pages/templates/designer/index.cjs +1 -1
- package/dist/pages/templates/designer/index.js +1 -1
- package/dist/views/forms/builder/index.cjs +1 -1
- package/dist/views/forms/builder/index.js +1 -1
- package/dist/views/forms/renderer/form-field-link.d.ts +16 -0
- package/dist/views/forms/renderer/index.cjs +1 -1
- package/dist/views/forms/renderer/index.js +2 -2
- package/dist/views/forms/renderer/member-field-options.d.ts +39 -0
- package/dist/views/forms/renderer/member-field.d.ts +21 -0
- package/dist/views/inbox/index.cjs +1 -1
- package/dist/views/inbox/index.cjs.map +1 -1
- package/dist/views/inbox/index.js +100 -97
- package/dist/views/inbox/index.js.map +1 -1
- package/dist/views/instances/detail/index.cjs +1 -1
- package/dist/views/instances/detail/index.js +1 -1
- package/dist/views/instances/detail/sections/container-helpers.d.ts +3 -2
- package/dist/views/instances/detail/sections/shared.d.ts +5 -0
- package/dist/views/instances/detail/submitted-by.d.ts +23 -0
- package/dist/views/instances/new/index.cjs +1 -1
- package/dist/views/instances/new/index.js +1 -1
- package/dist/views/sent/SentView.d.ts +1 -1
- package/dist/views/sent/index.cjs +1 -1
- package/dist/views/sent/index.cjs.map +1 -1
- package/dist/views/sent/index.js +2 -2
- package/dist/views/sent/index.js.map +1 -1
- package/dist/views/templates/compose/index.cjs +1 -1
- package/dist/views/templates/compose/index.js +1 -1
- package/dist/views/templates/designer/decision-policy-options.d.ts +8 -0
- package/dist/views/templates/designer/designer-version-labels.d.ts +12 -0
- package/dist/views/templates/designer/dry-run-assignee-label.d.ts +28 -0
- package/dist/views/templates/designer/dry-run-sample-data.d.ts +9 -0
- package/dist/views/templates/designer/dynamic-form-resolver-options.d.ts +35 -0
- package/dist/views/templates/designer/index.cjs +1 -1
- package/dist/views/templates/designer/index.js +1 -1
- package/dist/views/templates/designer/position-level-options.d.ts +17 -0
- package/package.json +3 -3
- package/dist/chunks/FormBuilderView-BYLN6W-P.js.map +0 -1
- package/dist/chunks/FormBuilderView-VmdPVbg7.cjs +0 -3
- package/dist/chunks/FormBuilderView-VmdPVbg7.cjs.map +0 -1
- package/dist/chunks/FormRendererView-Bs8lTb4k.cjs +0 -2
- package/dist/chunks/FormRendererView-Bs8lTb4k.cjs.map +0 -1
- package/dist/chunks/FormRendererView-UPowZZgw.js +0 -798
- package/dist/chunks/FormRendererView-UPowZZgw.js.map +0 -1
- package/dist/chunks/compose-6P64PO1i.js.map +0 -1
- package/dist/chunks/compose-BnSRL4ml.cjs +0 -2
- package/dist/chunks/compose-BnSRL4ml.cjs.map +0 -1
- package/dist/chunks/designer-C3s2kSna.js.map +0 -1
- package/dist/chunks/designer-_g58R6rQ.cjs +0 -65
- package/dist/chunks/designer-_g58R6rQ.cjs.map +0 -1
- package/dist/chunks/detail-Db-UOELp.cjs +0 -2
- package/dist/chunks/detail-Db-UOELp.cjs.map +0 -1
- package/dist/chunks/detail-pYEIk-jW.js.map +0 -1
|
@@ -0,0 +1,999 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { t as e } from "./bpm-form-field-Cao0rMol.js";
|
|
3
|
+
import { useCallback as t, useEffect as n, useMemo as r, useRef as i, useState as a } from "react";
|
|
4
|
+
import { AutoComplete as o, Button as s, CheckboxGroup as c, DatePicker as l, DateTimePicker as u, Input as d, RadioGroup as f, Select as p, Table as m, Textarea as h, Toggle as g, Typography as _, Upload as v } from "@mezzanine-ui/react";
|
|
5
|
+
import { resolveMembers as y, searchMembers as b } from "@rytass/bpm-core-client";
|
|
6
|
+
import { jsx as x, jsxs as S } from "react/jsx-runtime";
|
|
7
|
+
import { PlusIcon as C, TrashIcon as w } from "@mezzanine-ui/icons";
|
|
8
|
+
import { buildFormRendererValues as T, clampOptionalNumber as E, createFormTableRow as ee, formatDatePickerValue as te, formatDateTimePickerValue as D, isFormRendererFieldReadonly as O, isFormRendererFieldRequired as k, mergeFormDataSourceOptions as A, parseOptionalNumberInput as j, previewFormFieldOptions as ne, previewResolveFormFieldOptions as re, readDatePickerValue as M, readFieldOptionAsSelectOption as N, readFormDataSourceErrorCode as ie, readFormDataSourceErrorMessage as ae, readFormDataSourceSelectedValues as oe, readFormDataSourceValueSignature as P, readFormFieldOptions as se, readFormTableCellPath as F, readFormTableRowBounds as ce, readFormTableRows as I, readMissingFormDataSourceDependencies as le, readMissingFormDataSourceOptionValues as L, readSelectOption as ue, readSelectedFormDataSourceOptions as R, readVisibleFormRendererFields as de, resolveFormFieldOptions as fe } from "@rytass/bpm-core-client/form";
|
|
9
|
+
import { isFormDataSourceFieldDefinition as z, isFormStaticOptionFieldDefinition as pe, isFormTableCellValue as me, isTableFieldDefinition as B, readFormFieldSelectionMode as he, readFormMemberIds as V } from "@rytass/bpm-core-shared/form";
|
|
10
|
+
//#region src/views/forms/renderer/form-data-source-field.ts
|
|
11
|
+
var ge = {
|
|
12
|
+
canRetry: !1,
|
|
13
|
+
error: null,
|
|
14
|
+
hasValue: !1,
|
|
15
|
+
hasNextPage: !1,
|
|
16
|
+
invalidValues: [],
|
|
17
|
+
onReachBottom: () => void 0,
|
|
18
|
+
onSearch: () => void 0,
|
|
19
|
+
options: [],
|
|
20
|
+
retry: () => void 0,
|
|
21
|
+
status: "IDLE"
|
|
22
|
+
}, H = [], _e = 10, ve = ["FORM_DATA_SOURCE_SEARCH_NOT_SUPPORTED", "FORM_DATA_SOURCE_SEARCH_TOO_SHORT"];
|
|
23
|
+
function U(e) {
|
|
24
|
+
let o = z(e.field) ? e.field : null, s = e.fieldPath ?? o?.fieldKey ?? "", c = o ? e.optionSnapshots?.[e.snapshotKey ?? o.fieldKey] : void 0, l = o ? JSON.stringify({
|
|
25
|
+
dataSource: o.dataSource,
|
|
26
|
+
fieldKey: o.fieldKey,
|
|
27
|
+
type: o.type
|
|
28
|
+
}) : "", u = JSON.stringify(c ?? null), d = r(() => c?.options ?? [], [u]), f = JSON.stringify(e.formData), p = JSON.stringify(e.initialFormData ?? {}), m = JSON.stringify(e.schema), h = JSON.stringify(e.uiSchema), g = e.context?.kind, _ = e.context?.kind === "runtime" ? e.context.instanceId : void 0, v = e.context?.kind === "runtime" ? e.context.templateId : void 0, y = JSON.stringify(e.row?.values ?? null), b = JSON.stringify(e.row?.initialValues ?? null), x = o ? e.row ? e.row.values[o.fieldKey] : e.formData[o.fieldKey] : void 0, S = P(x), C = r(() => oe(x), [S]), w = C.length > 0, T = o ? JSON.stringify({
|
|
29
|
+
bindings: o.dataSource.bindings.map((t) => t.from.kind === "FIELD" ? {
|
|
30
|
+
fieldKey: t.from.fieldKey,
|
|
31
|
+
value: e.formData[t.from.fieldKey]
|
|
32
|
+
} : t.from.kind === "CONSTANT" ? { value: t.from.value } : {
|
|
33
|
+
columnKey: t.from.columnKey,
|
|
34
|
+
value: e.row?.values[t.from.columnKey]
|
|
35
|
+
}),
|
|
36
|
+
value: e.initialFormData !== void 0 || e.initialValue !== void 0 ? x : void 0
|
|
37
|
+
}) : "", E = r(() => {
|
|
38
|
+
if (g === "preview") return { kind: "preview" };
|
|
39
|
+
if (g === "runtime" && !e.readonly) return {
|
|
40
|
+
instanceId: _,
|
|
41
|
+
kind: "runtime",
|
|
42
|
+
templateId: v
|
|
43
|
+
};
|
|
44
|
+
}, [
|
|
45
|
+
_,
|
|
46
|
+
g,
|
|
47
|
+
v,
|
|
48
|
+
e.readonly
|
|
49
|
+
]), ee = o ? (e.initialFormData !== void 0 || e.initialValue !== void 0) && P(e.initialValue) !== S : !1, te = o ? e.initialFormData !== void 0 && o.dataSource.bindings.some((t) => t.from.kind === "FIELD" ? P(e.initialFormData?.[t.from.fieldKey]) !== P(e.formData[t.from.fieldKey]) : t.from.kind === "ROW_FIELD" && e.row?.initialValues ? P(e.row.initialValues[t.from.columnKey]) !== P(e.row.values[t.from.columnKey]) : !1) : !1, D = !(!c && !w || !ee && !te), O = !!(o && E && D && w), k = be({
|
|
50
|
+
hasSnapshot: !!c,
|
|
51
|
+
hasValue: w,
|
|
52
|
+
isStale: D,
|
|
53
|
+
readonly: e.readonly
|
|
54
|
+
}), j = !!(o && E && o.type !== "autocomplete"), M = xe(D, j && o !== null && le(o, e.formData, e.row?.values).length > 0), [N, F] = a([]), [ce, I] = a(""), [L, ue] = a(null), [de, pe] = a(null), [me, B] = a(() => o ? j ? M : k : "IDLE"), [he, V] = a(null), H = i(0), U = i(0), W = i(0), G = i(null), K = i(null), J = i({
|
|
55
|
+
cursor: null,
|
|
56
|
+
searchText: ""
|
|
57
|
+
}), Y = r(() => we(e.formData), [f]), X = r(() => e.row ? we(e.row.values) : void 0, [y]), Te = r(() => A(d, N), [N, d]), Z = de && de.signature === T ? de : null, Ee = O && !Z, De = ye({
|
|
58
|
+
options: Te,
|
|
59
|
+
resolution: Z,
|
|
60
|
+
resolvePending: Ee,
|
|
61
|
+
value: x
|
|
62
|
+
}), Q = t((t, n) => {
|
|
63
|
+
if (!o || !E) return;
|
|
64
|
+
let r = U.current + 1;
|
|
65
|
+
U.current = r, J.current = {
|
|
66
|
+
cursor: n,
|
|
67
|
+
searchText: t
|
|
68
|
+
}, G.current?.abort();
|
|
69
|
+
let i = new AbortController();
|
|
70
|
+
G.current = i, B(M), V(null), (E.kind === "preview" ? ne({
|
|
71
|
+
cursor: n,
|
|
72
|
+
fieldKey: s,
|
|
73
|
+
formData: Y,
|
|
74
|
+
rowValues: X,
|
|
75
|
+
schema: e.schema,
|
|
76
|
+
searchText: t,
|
|
77
|
+
signal: i.signal,
|
|
78
|
+
uiSchema: e.uiSchema
|
|
79
|
+
}) : se({
|
|
80
|
+
cursor: n,
|
|
81
|
+
fieldKey: s,
|
|
82
|
+
formData: Y,
|
|
83
|
+
instanceId: E.instanceId ?? null,
|
|
84
|
+
rowValues: X,
|
|
85
|
+
searchText: t,
|
|
86
|
+
signal: i.signal,
|
|
87
|
+
templateId: E.templateId ?? null
|
|
88
|
+
})).then((e) => {
|
|
89
|
+
q(i, U, r) || (F((t) => {
|
|
90
|
+
let r = R(x, t);
|
|
91
|
+
return A(r, n ? t : [], e.options);
|
|
92
|
+
}), ue(e.nextCursor), V(null), H.current = n ? H.current + e.options.length : e.options.length, e.nextCursor && e.options.length > 0 && H.current < _e && $.current(t, e.nextCursor), B(e.waitingForFieldKeys.length ? "WAITING_FOR_DEPENDENCIES" : "VALID"));
|
|
93
|
+
}).catch((e) => {
|
|
94
|
+
if (q(i, U, r)) return;
|
|
95
|
+
let t = ae(e) ?? "選項來源暫時無法使用。", n = ie(e);
|
|
96
|
+
V(t), B(Se(!!(n && ve.includes(n)), w));
|
|
97
|
+
});
|
|
98
|
+
}, [
|
|
99
|
+
S,
|
|
100
|
+
l,
|
|
101
|
+
E,
|
|
102
|
+
w,
|
|
103
|
+
M,
|
|
104
|
+
s,
|
|
105
|
+
Y,
|
|
106
|
+
X,
|
|
107
|
+
m,
|
|
108
|
+
h
|
|
109
|
+
]), $ = i(Q);
|
|
110
|
+
$.current = Q;
|
|
111
|
+
let Oe = t(() => {
|
|
112
|
+
if (!o || !E || C.length === 0) return;
|
|
113
|
+
let t = T, n = W.current + 1;
|
|
114
|
+
W.current = n, K.current?.abort();
|
|
115
|
+
let r = new AbortController();
|
|
116
|
+
K.current = r, V(null), (E.kind === "preview" ? re({
|
|
117
|
+
fieldKey: s,
|
|
118
|
+
formData: Y,
|
|
119
|
+
rowValues: X,
|
|
120
|
+
schema: e.schema,
|
|
121
|
+
signal: r.signal,
|
|
122
|
+
uiSchema: e.uiSchema,
|
|
123
|
+
values: C
|
|
124
|
+
}) : fe({
|
|
125
|
+
fieldKey: s,
|
|
126
|
+
formData: Y,
|
|
127
|
+
instanceId: E.instanceId ?? null,
|
|
128
|
+
rowValues: X,
|
|
129
|
+
signal: r.signal,
|
|
130
|
+
templateId: E.templateId ?? null,
|
|
131
|
+
values: C
|
|
132
|
+
})).then((e) => {
|
|
133
|
+
if (!q(r, W, n)) {
|
|
134
|
+
if (e.waitingForFieldKeys.length) {
|
|
135
|
+
B("WAITING_FOR_DEPENDENCIES");
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
F((t) => A(t, e.options)), pe({
|
|
139
|
+
signature: t,
|
|
140
|
+
unresolvedValues: e.unresolvedValues
|
|
141
|
+
}), B("VALID");
|
|
142
|
+
}
|
|
143
|
+
}).catch((e) => {
|
|
144
|
+
q(r, W, n) || (B("UNAVAILABLE"), V(ae(e) ?? "選項來源暫時無法使用。"));
|
|
145
|
+
});
|
|
146
|
+
}, [
|
|
147
|
+
T,
|
|
148
|
+
l,
|
|
149
|
+
E,
|
|
150
|
+
s,
|
|
151
|
+
Y,
|
|
152
|
+
X,
|
|
153
|
+
m,
|
|
154
|
+
C,
|
|
155
|
+
h
|
|
156
|
+
]), ke = i(Oe);
|
|
157
|
+
ke.current = Oe, n(() => {
|
|
158
|
+
if (U.current += 1, G.current?.abort(), F((e) => R(x, e)), ue((e) => e === null ? e : null), I((e) => e && ""), V((e) => e && null), !o) {
|
|
159
|
+
B("IDLE");
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
if (!j) {
|
|
163
|
+
B(k);
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
$.current("", null);
|
|
167
|
+
}, [
|
|
168
|
+
j,
|
|
169
|
+
l,
|
|
170
|
+
E,
|
|
171
|
+
T,
|
|
172
|
+
p,
|
|
173
|
+
b,
|
|
174
|
+
e.readonly,
|
|
175
|
+
M,
|
|
176
|
+
k,
|
|
177
|
+
u
|
|
178
|
+
]), n(() => {
|
|
179
|
+
O && ke.current();
|
|
180
|
+
}, [
|
|
181
|
+
T,
|
|
182
|
+
E,
|
|
183
|
+
O
|
|
184
|
+
]), n(() => () => {
|
|
185
|
+
G.current?.abort(), K.current?.abort();
|
|
186
|
+
}, []);
|
|
187
|
+
let Ae = t((e) => {
|
|
188
|
+
I(e), F((e) => R(x, e)), ue(null), Q(e, null);
|
|
189
|
+
}, [Q]), je = t(() => {
|
|
190
|
+
L && Q(ce, L);
|
|
191
|
+
}, [
|
|
192
|
+
Q,
|
|
193
|
+
L,
|
|
194
|
+
ce
|
|
195
|
+
]), Me = t(() => {
|
|
196
|
+
E && (Q(J.current.searchText, J.current.cursor), O && ke.current());
|
|
197
|
+
}, [
|
|
198
|
+
E,
|
|
199
|
+
Q,
|
|
200
|
+
O
|
|
201
|
+
]);
|
|
202
|
+
return o ? {
|
|
203
|
+
canRetry: !!E,
|
|
204
|
+
error: he,
|
|
205
|
+
hasValue: w,
|
|
206
|
+
hasNextPage: !!L,
|
|
207
|
+
invalidValues: De,
|
|
208
|
+
onReachBottom: je,
|
|
209
|
+
onSearch: Ae,
|
|
210
|
+
options: Te,
|
|
211
|
+
retry: Me,
|
|
212
|
+
status: Ce({
|
|
213
|
+
invalidValues: De,
|
|
214
|
+
resolvePending: Ee,
|
|
215
|
+
status: me
|
|
216
|
+
})
|
|
217
|
+
} : ge;
|
|
218
|
+
}
|
|
219
|
+
function W(e) {
|
|
220
|
+
switch (e.status) {
|
|
221
|
+
case "WAITING_FOR_DEPENDENCIES": return "請先填寫相依欄位。";
|
|
222
|
+
case "STALE": return "選項需要重新載入或驗證。";
|
|
223
|
+
case "INVALID": return e.invalidValues.length ? `無法辨識選項:${e.invalidValues.join("、")}` : "目前選項已失效,請重新選擇。";
|
|
224
|
+
case "UNAVAILABLE": return e.error ?? "選項來源暫時無法使用。";
|
|
225
|
+
case "VALID": return e.error ?? (e.options.length ? null : "目前沒有可用選項。");
|
|
226
|
+
default: return e.error;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
function G(e) {
|
|
230
|
+
return e.hasValue && e.status !== "VALID";
|
|
231
|
+
}
|
|
232
|
+
function K(e) {
|
|
233
|
+
let t = e.filter(G);
|
|
234
|
+
return t.length === 0 ? null : t.every((e) => e.status === "LOADING" || e.status === "STALE") ? "選項驗證中,請稍候再送出。" : "請先完成動態選項驗證。";
|
|
235
|
+
}
|
|
236
|
+
function ye(e) {
|
|
237
|
+
return e.resolution ? e.resolution.unresolvedValues : e.resolvePending ? H : L(e.value, e.options);
|
|
238
|
+
}
|
|
239
|
+
function be(e) {
|
|
240
|
+
return e.isStale ? "STALE" : e.hasSnapshot ? "VALID" : e.readonly && e.hasValue ? "UNAVAILABLE" : "IDLE";
|
|
241
|
+
}
|
|
242
|
+
function xe(e, t) {
|
|
243
|
+
return t ? "WAITING_FOR_DEPENDENCIES" : e ? "STALE" : "LOADING";
|
|
244
|
+
}
|
|
245
|
+
function Se(e, t) {
|
|
246
|
+
return e ? t ? "VALID" : "IDLE" : "UNAVAILABLE";
|
|
247
|
+
}
|
|
248
|
+
function Ce(e) {
|
|
249
|
+
return e.status === "LOADING" || e.status === "UNAVAILABLE" || e.status === "WAITING_FOR_DEPENDENCIES" ? e.status : e.invalidValues.length ? "INVALID" : e.resolvePending ? "STALE" : e.status;
|
|
250
|
+
}
|
|
251
|
+
function q(e, t, n) {
|
|
252
|
+
return e.signal.aborted || t.current !== n;
|
|
253
|
+
}
|
|
254
|
+
function we(e) {
|
|
255
|
+
return Object.entries(e).reduce((e, [t, n]) => n === void 0 ? e : {
|
|
256
|
+
...e,
|
|
257
|
+
[t]: n
|
|
258
|
+
}, {});
|
|
259
|
+
}
|
|
260
|
+
//#endregion
|
|
261
|
+
//#region src/views/forms/renderer/form-field-link.ts
|
|
262
|
+
var J = /\s/u;
|
|
263
|
+
function Y(e) {
|
|
264
|
+
return [...e].some((e) => {
|
|
265
|
+
let t = e.codePointAt(0) ?? 0;
|
|
266
|
+
return t <= 32 || t >= 127 && t <= 160 || J.test(e);
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
var X = /^https?:\/\//iu;
|
|
270
|
+
function Te(e) {
|
|
271
|
+
return typeof e != "string" || !e || e.includes("\\") || Y(e) ? null : e.startsWith("/") ? !e.startsWith("//") && Ee(e) ? {
|
|
272
|
+
external: !1,
|
|
273
|
+
href: e
|
|
274
|
+
} : null : X.test(e) && De(e) ? {
|
|
275
|
+
external: !0,
|
|
276
|
+
href: e
|
|
277
|
+
} : null;
|
|
278
|
+
}
|
|
279
|
+
var Z = "http://placeholder.invalid";
|
|
280
|
+
function Ee(e) {
|
|
281
|
+
try {
|
|
282
|
+
let t = new URL(e, Z);
|
|
283
|
+
return t.origin === Z && !t.pathname.startsWith("//");
|
|
284
|
+
} catch {
|
|
285
|
+
return !1;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
function De(e) {
|
|
289
|
+
try {
|
|
290
|
+
let t = new URL(e);
|
|
291
|
+
return (t.protocol === "http:" || t.protocol === "https:") && !!t.hostname && !t.username && !t.password;
|
|
292
|
+
} catch {
|
|
293
|
+
return !1;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
async function Q(e, t, n = {}) {
|
|
297
|
+
let r = n.maxPerIdRequests ?? 20, i = Math.max(1, n.concurrency ?? 4);
|
|
298
|
+
try {
|
|
299
|
+
return {
|
|
300
|
+
failedIds: [],
|
|
301
|
+
profiles: await t(e),
|
|
302
|
+
skippedIds: []
|
|
303
|
+
};
|
|
304
|
+
} catch {
|
|
305
|
+
if (e.length <= 1) return {
|
|
306
|
+
failedIds: e,
|
|
307
|
+
profiles: [],
|
|
308
|
+
skippedIds: []
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
let a = e.slice(0, r), o = await Oe(a, i, (e) => t([e]));
|
|
312
|
+
return {
|
|
313
|
+
failedIds: a.filter((e, t) => o[t].status === "rejected"),
|
|
314
|
+
profiles: o.flatMap((e) => e.status === "fulfilled" ? e.value : []),
|
|
315
|
+
skippedIds: e.slice(r)
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
function $(e, t) {
|
|
319
|
+
return e.filter((e) => !t.has(e));
|
|
320
|
+
}
|
|
321
|
+
async function Oe(e, t, n) {
|
|
322
|
+
let r = [], i = 0;
|
|
323
|
+
async function a() {
|
|
324
|
+
for (; i < e.length;) {
|
|
325
|
+
let t = i;
|
|
326
|
+
i += 1, r[t] = await n(e[t]).then((e) => ({
|
|
327
|
+
status: "fulfilled",
|
|
328
|
+
value: e
|
|
329
|
+
}), (e) => ({
|
|
330
|
+
reason: e,
|
|
331
|
+
status: "rejected"
|
|
332
|
+
}));
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
return await Promise.all(Array.from({ length: Math.min(t, e.length) }, a)), r;
|
|
336
|
+
}
|
|
337
|
+
//#endregion
|
|
338
|
+
//#region src/views/forms/renderer/member-field-options.ts
|
|
339
|
+
var ke = "未知會員";
|
|
340
|
+
function Ae(e) {
|
|
341
|
+
return {
|
|
342
|
+
id: e.memberId,
|
|
343
|
+
name: e.email ? `${e.name} (${e.email})` : e.name
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
function je(e) {
|
|
347
|
+
return {
|
|
348
|
+
id: e,
|
|
349
|
+
name: ke,
|
|
350
|
+
unresolved: !0
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
function Me(e, t) {
|
|
354
|
+
let n = new Map(t.filter((e) => !e.unresolved).map((e) => [e.id, e])), r = new Set(e.map((e) => e.id)), i = t.filter((e, n) => !r.has(e.id) && t.findIndex((t) => t.id === e.id) === n), a = e.map((e) => (e.unresolved ? n.get(e.id) : void 0) ?? e);
|
|
355
|
+
return i.length > 0 || a.some((t, n) => t !== e[n]) ? [...a, ...i] : e;
|
|
356
|
+
}
|
|
357
|
+
function Ne(e, t) {
|
|
358
|
+
let n = new Set(t.filter((e) => !e.unresolved).map((e) => e.id));
|
|
359
|
+
return V(e).filter((e) => !n.has(e));
|
|
360
|
+
}
|
|
361
|
+
function Pe(e, t) {
|
|
362
|
+
return V(e).map((e) => t.find((t) => t.id === e) ?? je(e));
|
|
363
|
+
}
|
|
364
|
+
function Fe(e, t) {
|
|
365
|
+
if (e.length !== 0) return t ? e.map((e) => e.id) : e[0]?.id;
|
|
366
|
+
}
|
|
367
|
+
//#endregion
|
|
368
|
+
//#region src/views/forms/renderer/member-field.tsx
|
|
369
|
+
function Ie({ multiple: e, name: t, onChange: r, placeholder: s, readonly: c, size: l, value: u }) {
|
|
370
|
+
let [d, f] = a([]), [p, m] = a([]), [h, g] = a(!1), _ = i(0), v = i(/* @__PURE__ */ new Set()), S = Ne(u, d).join("\n");
|
|
371
|
+
n(() => {
|
|
372
|
+
let e = $(S ? S.split("\n") : [], v.current), t = !1;
|
|
373
|
+
return e.length === 0 ? () => void 0 : (Q(e, y).then(({ profiles: n, skippedIds: r }) => {
|
|
374
|
+
if (t) return;
|
|
375
|
+
let i = n.map(Ae), a = e.filter((e) => !i.some((t) => t.id === e)).map(je);
|
|
376
|
+
a.filter((e) => !r.includes(e.id)).forEach((e) => v.current.add(e.id)), f((e) => Me(e, [...i, ...a]));
|
|
377
|
+
}), () => {
|
|
378
|
+
t = !0;
|
|
379
|
+
});
|
|
380
|
+
}, [S]);
|
|
381
|
+
async function C(e) {
|
|
382
|
+
let t = _.current + 1;
|
|
383
|
+
_.current = t, g(!0);
|
|
384
|
+
try {
|
|
385
|
+
let n = (await b(e)).map(Ae);
|
|
386
|
+
_.current === t && (m(n), f((e) => Me(e, n)));
|
|
387
|
+
} catch {
|
|
388
|
+
_.current === t && m([]);
|
|
389
|
+
} finally {
|
|
390
|
+
_.current === t && g(!1);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
let w = Pe(u, d), T = [...Me(w, p)], E = {
|
|
394
|
+
asyncData: !0,
|
|
395
|
+
clearSearchText: !0,
|
|
396
|
+
disabled: c,
|
|
397
|
+
disabledOptionsFilter: !0,
|
|
398
|
+
emptyText: "沒有符合的成員",
|
|
399
|
+
globalPortal: !0,
|
|
400
|
+
inputProps: {
|
|
401
|
+
autoCapitalize: "none",
|
|
402
|
+
autoCorrect: "off",
|
|
403
|
+
name: t,
|
|
404
|
+
spellCheck: !1
|
|
405
|
+
},
|
|
406
|
+
loading: h,
|
|
407
|
+
loadingText: "搜尋成員中...",
|
|
408
|
+
onSearch: C,
|
|
409
|
+
onVisibilityChange: (e) => {
|
|
410
|
+
e && (m([]), C(""));
|
|
411
|
+
},
|
|
412
|
+
options: T,
|
|
413
|
+
placeholder: s ?? "搜尋姓名或信箱",
|
|
414
|
+
readOnly: c,
|
|
415
|
+
searchDebounceTime: 300,
|
|
416
|
+
size: l
|
|
417
|
+
};
|
|
418
|
+
return e ? /* @__PURE__ */ x(o, {
|
|
419
|
+
...E,
|
|
420
|
+
mode: "multiple",
|
|
421
|
+
onChange: (e) => r(Fe(e, !0)),
|
|
422
|
+
value: [...w]
|
|
423
|
+
}) : /* @__PURE__ */ x(o, {
|
|
424
|
+
...E,
|
|
425
|
+
mode: "single",
|
|
426
|
+
onChange: (e) => r(Fe(e ? [e] : [], !1)),
|
|
427
|
+
value: w[0] ?? null
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
//#endregion
|
|
431
|
+
//#region src/views/forms/renderer/FormRendererView.tsx
|
|
432
|
+
var Le = {
|
|
433
|
+
alignItems: "start",
|
|
434
|
+
display: "grid",
|
|
435
|
+
gap: 12,
|
|
436
|
+
gridTemplateColumns: "repeat(12, minmax(0, 1fr))"
|
|
437
|
+
}, Re = { gridColumn: "1 / -1" }, ze = {
|
|
438
|
+
alignItems: "start",
|
|
439
|
+
display: "grid",
|
|
440
|
+
gap: 8,
|
|
441
|
+
minWidth: 0
|
|
442
|
+
}, Be = {
|
|
443
|
+
minWidth: "100%",
|
|
444
|
+
width: "100%"
|
|
445
|
+
};
|
|
446
|
+
function Ve(e) {
|
|
447
|
+
e && (e.style.width = "100%");
|
|
448
|
+
}
|
|
449
|
+
function He({ dataSourceContext: e, dataSourceInitialValues: t, emptyText: o = "尚未建立欄位。", errors: s = {}, maxWidth: c, onChange: l, onDataSourceStateChange: u, onUploadAttachment: d, optionSnapshots: f, readonly: p = !1, schema: m, singleColumn: h = !1, uiSchema: g, value: v }) {
|
|
450
|
+
let [y, b] = a(() => T(m.fields, v ?? {})), S = r(() => T(m.fields, v ?? y), [
|
|
451
|
+
y,
|
|
452
|
+
m.fields,
|
|
453
|
+
v
|
|
454
|
+
]), C = i(S), w = r(() => de(m, g, S), [
|
|
455
|
+
m,
|
|
456
|
+
g,
|
|
457
|
+
S
|
|
458
|
+
]);
|
|
459
|
+
n(() => {
|
|
460
|
+
C.current = S;
|
|
461
|
+
}, [S]), n(() => {
|
|
462
|
+
b((e) => T(m.fields, v ?? e));
|
|
463
|
+
}, [m.fields, v]);
|
|
464
|
+
function E(e, t) {
|
|
465
|
+
let n = {
|
|
466
|
+
...C.current,
|
|
467
|
+
[e]: t
|
|
468
|
+
};
|
|
469
|
+
C.current = n, v || b(n), l?.(n);
|
|
470
|
+
}
|
|
471
|
+
return w.length ? /* @__PURE__ */ x("div", {
|
|
472
|
+
style: {
|
|
473
|
+
...Le,
|
|
474
|
+
...h ? { width: "100%" } : {}
|
|
475
|
+
},
|
|
476
|
+
children: w.map((n) => /* @__PURE__ */ x(Ue, {
|
|
477
|
+
dataSourceContext: e,
|
|
478
|
+
dataSourceInitialValues: t,
|
|
479
|
+
field: n,
|
|
480
|
+
error: s[n.fieldKey] ?? null,
|
|
481
|
+
errors: s,
|
|
482
|
+
fields: m.fields,
|
|
483
|
+
onChange: E,
|
|
484
|
+
onDataSourceStateChange: u,
|
|
485
|
+
onUploadAttachment: d,
|
|
486
|
+
optionSnapshots: f,
|
|
487
|
+
readonly: p,
|
|
488
|
+
schema: m,
|
|
489
|
+
style: {
|
|
490
|
+
...ze,
|
|
491
|
+
gridColumn: `span ${h ? 12 : lt(n, g)}`,
|
|
492
|
+
...h && !B(n) ? { maxWidth: c } : {}
|
|
493
|
+
},
|
|
494
|
+
value: S[n.fieldKey],
|
|
495
|
+
values: S,
|
|
496
|
+
uiSchema: g
|
|
497
|
+
}, n.fieldKey))
|
|
498
|
+
}) : /* @__PURE__ */ x("div", {
|
|
499
|
+
style: Le,
|
|
500
|
+
children: /* @__PURE__ */ x(_, {
|
|
501
|
+
color: "text-neutral",
|
|
502
|
+
style: Re,
|
|
503
|
+
variant: "body",
|
|
504
|
+
children: m.fields.length > 0 ? "目前條件下沒有可填寫欄位。" : o
|
|
505
|
+
})
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
function Ue({ dataSourceContext: t, dataSourceInitialValues: r, error: i, errors: a, field: o, fields: c, onChange: l, onDataSourceStateChange: u, onUploadAttachment: d, optionSnapshots: f, readonly: p, schema: m, style: h, value: g, values: v, uiSchema: y }) {
|
|
509
|
+
let b = k(o, c, v), C = p || O(o, c, v), w = U({
|
|
510
|
+
context: t,
|
|
511
|
+
field: o,
|
|
512
|
+
formData: v,
|
|
513
|
+
initialFormData: r,
|
|
514
|
+
initialValue: r?.[o.fieldKey],
|
|
515
|
+
optionSnapshots: f,
|
|
516
|
+
readonly: C,
|
|
517
|
+
schema: m,
|
|
518
|
+
uiSchema: y
|
|
519
|
+
}), T = W(w), E = JSON.stringify({
|
|
520
|
+
hasValue: w.hasValue,
|
|
521
|
+
invalidValues: w.invalidValues,
|
|
522
|
+
status: w.status
|
|
523
|
+
});
|
|
524
|
+
return n(() => {
|
|
525
|
+
z(o) && u?.(o.fieldKey, {
|
|
526
|
+
hasValue: w.hasValue,
|
|
527
|
+
invalidValues: w.invalidValues,
|
|
528
|
+
status: w.status
|
|
529
|
+
});
|
|
530
|
+
}, [
|
|
531
|
+
E,
|
|
532
|
+
o.fieldKey,
|
|
533
|
+
u
|
|
534
|
+
]), /* @__PURE__ */ S("div", {
|
|
535
|
+
"data-form-field-key": o.fieldKey,
|
|
536
|
+
style: h,
|
|
537
|
+
children: [
|
|
538
|
+
/* @__PURE__ */ x(e, {
|
|
539
|
+
label: o.label,
|
|
540
|
+
name: o.fieldKey,
|
|
541
|
+
required: b,
|
|
542
|
+
children: B(o) ? /* @__PURE__ */ x(et, {
|
|
543
|
+
dataSourceContext: t,
|
|
544
|
+
dataSourceInitialValues: r,
|
|
545
|
+
errors: a,
|
|
546
|
+
field: o,
|
|
547
|
+
onChange: l,
|
|
548
|
+
onDataSourceStateChange: u,
|
|
549
|
+
optionSnapshots: f,
|
|
550
|
+
readonly: C,
|
|
551
|
+
schema: m,
|
|
552
|
+
uiSchema: y,
|
|
553
|
+
value: g,
|
|
554
|
+
values: v
|
|
555
|
+
}) : ot(o, g, C, l, d, t, w)
|
|
556
|
+
}),
|
|
557
|
+
i ? /* @__PURE__ */ x(_, {
|
|
558
|
+
color: "text-error",
|
|
559
|
+
variant: "caption",
|
|
560
|
+
children: i
|
|
561
|
+
}) : null,
|
|
562
|
+
T ? /* @__PURE__ */ S("div", {
|
|
563
|
+
style: qe,
|
|
564
|
+
children: [/* @__PURE__ */ x(_, {
|
|
565
|
+
color: w.status === "INVALID" || w.status === "UNAVAILABLE" ? "text-error" : "text-neutral",
|
|
566
|
+
variant: "caption",
|
|
567
|
+
children: T
|
|
568
|
+
}), w.status === "UNAVAILABLE" && w.canRetry ? /* @__PURE__ */ x(s, {
|
|
569
|
+
onClick: w.retry,
|
|
570
|
+
size: "sub",
|
|
571
|
+
type: "button",
|
|
572
|
+
variant: "base-ghost",
|
|
573
|
+
children: "重試"
|
|
574
|
+
}) : null]
|
|
575
|
+
}) : null
|
|
576
|
+
]
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
var We = "(另開新分頁)", Ge = "另開新分頁", Ke = {
|
|
580
|
+
color: "inherit",
|
|
581
|
+
textDecoration: "underline",
|
|
582
|
+
wordBreak: "break-all"
|
|
583
|
+
}, qe = {
|
|
584
|
+
alignItems: "center",
|
|
585
|
+
display: "flex",
|
|
586
|
+
gap: 8
|
|
587
|
+
}, Je = {
|
|
588
|
+
display: "grid",
|
|
589
|
+
gap: 8,
|
|
590
|
+
minWidth: 0,
|
|
591
|
+
width: "100%"
|
|
592
|
+
}, Ye = {
|
|
593
|
+
display: "flex",
|
|
594
|
+
justifyContent: "flex-start"
|
|
595
|
+
}, Xe = {
|
|
596
|
+
maxWidth: "100%",
|
|
597
|
+
overflowX: "auto"
|
|
598
|
+
}, Ze = 160, Qe = 56, $e = {
|
|
599
|
+
display: "grid",
|
|
600
|
+
gap: 4,
|
|
601
|
+
minWidth: 0
|
|
602
|
+
};
|
|
603
|
+
function et({ dataSourceContext: e, dataSourceInitialValues: t, errors: r, field: o, onChange: c, onDataSourceStateChange: l, optionSnapshots: u, readonly: d, schema: f, uiSchema: p, value: h, values: g }) {
|
|
604
|
+
let _ = I(h), v = ce(o), y = i(0), [b, T] = a(() => _.map(() => rt(y)));
|
|
605
|
+
n(() => {
|
|
606
|
+
b.length !== _.length && T(_.map(() => rt(y)));
|
|
607
|
+
}, [b.length, _.length]);
|
|
608
|
+
function E(e) {
|
|
609
|
+
c(o.fieldKey, e);
|
|
610
|
+
}
|
|
611
|
+
function te() {
|
|
612
|
+
T([...b, rt(y)]), E([..._, ee(o.columns)]);
|
|
613
|
+
}
|
|
614
|
+
function D(e) {
|
|
615
|
+
T(b.filter((t, n) => n !== e)), E(_.filter((t, n) => n !== e));
|
|
616
|
+
}
|
|
617
|
+
function O(e, t, n) {
|
|
618
|
+
E(_.map((r, i) => i === e ? it(r, t, n) : r));
|
|
619
|
+
}
|
|
620
|
+
let k = _.map((e, t) => ({
|
|
621
|
+
...e,
|
|
622
|
+
index: t,
|
|
623
|
+
key: b[t] ?? `row-${t}`
|
|
624
|
+
})), A = o.columns.map((n) => ({
|
|
625
|
+
key: n.fieldKey,
|
|
626
|
+
render: (i) => /* @__PURE__ */ x(tt, {
|
|
627
|
+
column: n,
|
|
628
|
+
dataSourceContext: e,
|
|
629
|
+
error: r[F(o.fieldKey, i.index, n.fieldKey)] ?? null,
|
|
630
|
+
fieldPath: `${o.fieldKey}.${n.fieldKey}`,
|
|
631
|
+
formData: g,
|
|
632
|
+
initialFormData: t,
|
|
633
|
+
initialRowValues: nt(t?.[o.fieldKey], i.index),
|
|
634
|
+
onChange: (e) => O(i.index, n.fieldKey, e),
|
|
635
|
+
onDataSourceStateChange: l,
|
|
636
|
+
optionSnapshots: u,
|
|
637
|
+
path: F(o.fieldKey, i.index, n.fieldKey),
|
|
638
|
+
readonly: d,
|
|
639
|
+
rowValues: _[i.index] ?? {},
|
|
640
|
+
schema: f,
|
|
641
|
+
uiSchema: p
|
|
642
|
+
}, `${b[i.index] ?? i.index}-${n.fieldKey}`),
|
|
643
|
+
title: n.label || n.fieldKey
|
|
644
|
+
})), j = d ? void 0 : {
|
|
645
|
+
render: (e) => [{
|
|
646
|
+
disabled: () => _.length <= v.minRows,
|
|
647
|
+
icon: w,
|
|
648
|
+
iconType: "icon-only",
|
|
649
|
+
name: "刪除此列",
|
|
650
|
+
onClick: () => D(e.index),
|
|
651
|
+
variant: "destructive-ghost"
|
|
652
|
+
}],
|
|
653
|
+
width: 56
|
|
654
|
+
};
|
|
655
|
+
return /* @__PURE__ */ S("div", {
|
|
656
|
+
style: Je,
|
|
657
|
+
children: [/* @__PURE__ */ x("div", {
|
|
658
|
+
style: Xe,
|
|
659
|
+
children: /* @__PURE__ */ x("div", {
|
|
660
|
+
style: { minWidth: o.columns.length * Ze + (j ? Qe : 0) },
|
|
661
|
+
children: /* @__PURE__ */ x(m, {
|
|
662
|
+
...j ? { actions: j } : {},
|
|
663
|
+
columns: A,
|
|
664
|
+
dataSource: [...k],
|
|
665
|
+
rowHeightPreset: "roomy",
|
|
666
|
+
showHeader: !0,
|
|
667
|
+
size: "sub"
|
|
668
|
+
})
|
|
669
|
+
})
|
|
670
|
+
}), d ? null : /* @__PURE__ */ x("div", {
|
|
671
|
+
style: Ye,
|
|
672
|
+
children: /* @__PURE__ */ x(s, {
|
|
673
|
+
disabled: _.length >= v.maxRows,
|
|
674
|
+
icon: C,
|
|
675
|
+
iconType: "leading",
|
|
676
|
+
onClick: te,
|
|
677
|
+
size: "sub",
|
|
678
|
+
type: "button",
|
|
679
|
+
variant: "base-secondary",
|
|
680
|
+
children: o.addRowLabel || "新增一列"
|
|
681
|
+
})
|
|
682
|
+
})]
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
function tt({ column: e, dataSourceContext: t, error: r, fieldPath: i, formData: a, initialFormData: o, initialRowValues: c, onChange: l, onDataSourceStateChange: u, optionSnapshots: d, path: f, readonly: p, rowValues: m, schema: h, uiSchema: g }) {
|
|
686
|
+
let v = at(m, e.fieldKey), y = U({
|
|
687
|
+
context: t,
|
|
688
|
+
field: e,
|
|
689
|
+
fieldPath: i,
|
|
690
|
+
formData: a,
|
|
691
|
+
initialFormData: o,
|
|
692
|
+
initialValue: c ? at(c, e.fieldKey) : void 0,
|
|
693
|
+
optionSnapshots: d,
|
|
694
|
+
readonly: p,
|
|
695
|
+
row: {
|
|
696
|
+
initialValues: c,
|
|
697
|
+
values: m
|
|
698
|
+
},
|
|
699
|
+
schema: h,
|
|
700
|
+
snapshotKey: f,
|
|
701
|
+
uiSchema: g
|
|
702
|
+
}), b = W(y), C = JSON.stringify({
|
|
703
|
+
hasValue: y.hasValue,
|
|
704
|
+
invalidValues: y.invalidValues,
|
|
705
|
+
status: y.status
|
|
706
|
+
});
|
|
707
|
+
return n(() => {
|
|
708
|
+
if (z(e)) return u?.(f, {
|
|
709
|
+
hasValue: y.hasValue,
|
|
710
|
+
invalidValues: y.invalidValues,
|
|
711
|
+
status: y.status
|
|
712
|
+
}), () => {
|
|
713
|
+
u?.(f, {
|
|
714
|
+
hasValue: !1,
|
|
715
|
+
invalidValues: [],
|
|
716
|
+
status: "IDLE"
|
|
717
|
+
});
|
|
718
|
+
};
|
|
719
|
+
}, [
|
|
720
|
+
u,
|
|
721
|
+
f,
|
|
722
|
+
C
|
|
723
|
+
]), /* @__PURE__ */ S("div", {
|
|
724
|
+
"data-form-field-key": f,
|
|
725
|
+
style: $e,
|
|
726
|
+
children: [
|
|
727
|
+
ot(e, v, p, (e, t) => l(t), void 0, t, y, "sub"),
|
|
728
|
+
r ? /* @__PURE__ */ x(_, {
|
|
729
|
+
color: "text-error",
|
|
730
|
+
variant: "caption",
|
|
731
|
+
children: r
|
|
732
|
+
}) : null,
|
|
733
|
+
b ? /* @__PURE__ */ S("div", {
|
|
734
|
+
style: qe,
|
|
735
|
+
children: [/* @__PURE__ */ x(_, {
|
|
736
|
+
color: y.status === "INVALID" || y.status === "UNAVAILABLE" ? "text-error" : "text-neutral",
|
|
737
|
+
variant: "caption",
|
|
738
|
+
children: b
|
|
739
|
+
}), y.status === "UNAVAILABLE" && y.canRetry ? /* @__PURE__ */ x(s, {
|
|
740
|
+
onClick: y.retry,
|
|
741
|
+
size: "sub",
|
|
742
|
+
type: "button",
|
|
743
|
+
variant: "base-ghost",
|
|
744
|
+
children: "重試"
|
|
745
|
+
}) : null]
|
|
746
|
+
}) : null
|
|
747
|
+
]
|
|
748
|
+
});
|
|
749
|
+
}
|
|
750
|
+
function nt(e, t) {
|
|
751
|
+
return I(e)[t];
|
|
752
|
+
}
|
|
753
|
+
function rt(e) {
|
|
754
|
+
return e.current += 1, `table-row-${e.current}`;
|
|
755
|
+
}
|
|
756
|
+
function it(e, t, n) {
|
|
757
|
+
return n === void 0 || !me(n) ? Object.fromEntries(Object.entries(e).filter(([e]) => e !== t)) : {
|
|
758
|
+
...e,
|
|
759
|
+
[t]: n
|
|
760
|
+
};
|
|
761
|
+
}
|
|
762
|
+
function at(e, t) {
|
|
763
|
+
if (e && Object.prototype.hasOwnProperty.call(e, t)) return e[t];
|
|
764
|
+
}
|
|
765
|
+
function ot(e, t, n, r, i, a, o, s = "main") {
|
|
766
|
+
return z(e) ? ct(e, t, n, r, a, o, s) : st(e, t, n, r, i, s);
|
|
767
|
+
}
|
|
768
|
+
function st(e, t, n, r, i, a = "main") {
|
|
769
|
+
let o = n && (e.type === "text" || e.type === "textarea") && e.displayAs === "link" ? Te(t) : null;
|
|
770
|
+
if (o) return /* @__PURE__ */ x(_, {
|
|
771
|
+
color: "text-brand",
|
|
772
|
+
component: "span",
|
|
773
|
+
variant: "body",
|
|
774
|
+
children: /* @__PURE__ */ x("a", {
|
|
775
|
+
href: o.href,
|
|
776
|
+
style: Ke,
|
|
777
|
+
...o.external ? {
|
|
778
|
+
"aria-label": `${o.href}${We}`,
|
|
779
|
+
rel: "noopener noreferrer",
|
|
780
|
+
target: "_blank",
|
|
781
|
+
title: Ge
|
|
782
|
+
} : {},
|
|
783
|
+
children: o.href
|
|
784
|
+
})
|
|
785
|
+
});
|
|
786
|
+
if (e.type === "textarea") return /* @__PURE__ */ x(h, {
|
|
787
|
+
onChange: (t) => r(e.fieldKey, t.target.value),
|
|
788
|
+
placeholder: e.placeholder ?? "請輸入多行文字",
|
|
789
|
+
readOnly: n,
|
|
790
|
+
ref: Ve,
|
|
791
|
+
rows: 3,
|
|
792
|
+
style: Be,
|
|
793
|
+
value: ut(t)
|
|
794
|
+
});
|
|
795
|
+
if (e.type === "boolean") return /* @__PURE__ */ x(g, {
|
|
796
|
+
checked: t === !0,
|
|
797
|
+
disabled: n,
|
|
798
|
+
label: "啟用",
|
|
799
|
+
onChange: (t) => r(e.fieldKey, t.target.checked),
|
|
800
|
+
size: a
|
|
801
|
+
});
|
|
802
|
+
if (pe(e) && e.type === "checkbox") {
|
|
803
|
+
let i = e.options.map(N);
|
|
804
|
+
return /* @__PURE__ */ x(p, {
|
|
805
|
+
mode: "multiple",
|
|
806
|
+
onChange: (t) => r(e.fieldKey, t?.length ? t.map((e) => e.id) : void 0),
|
|
807
|
+
options: i,
|
|
808
|
+
placeholder: e.placeholder ?? "請選擇一或多個選項",
|
|
809
|
+
readOnly: n,
|
|
810
|
+
size: a,
|
|
811
|
+
value: i.filter((e) => dt(t).includes(e.id))
|
|
812
|
+
});
|
|
813
|
+
}
|
|
814
|
+
if (pe(e)) {
|
|
815
|
+
let i = e.options.map(N);
|
|
816
|
+
return /* @__PURE__ */ x(p, {
|
|
817
|
+
onChange: (t) => r(e.fieldKey, t?.id ?? void 0),
|
|
818
|
+
options: i,
|
|
819
|
+
placeholder: e.placeholder ?? "請選擇",
|
|
820
|
+
readOnly: n,
|
|
821
|
+
size: a,
|
|
822
|
+
value: ue(i, ut(t))
|
|
823
|
+
});
|
|
824
|
+
}
|
|
825
|
+
return e.type === "member" ? /* @__PURE__ */ x(Ie, {
|
|
826
|
+
multiple: e.multiple === !0,
|
|
827
|
+
name: e.fieldKey,
|
|
828
|
+
onChange: (t) => r(e.fieldKey, t),
|
|
829
|
+
placeholder: e.placeholder,
|
|
830
|
+
readonly: n,
|
|
831
|
+
size: a,
|
|
832
|
+
value: t
|
|
833
|
+
}) : e.type === "file_upload" ? /* @__PURE__ */ x(v, {
|
|
834
|
+
accept: e.acceptedMimeTypes?.join(","),
|
|
835
|
+
disabled: n,
|
|
836
|
+
maxFiles: e.maxFiles,
|
|
837
|
+
mode: "button-list",
|
|
838
|
+
...(e.maxFiles ?? 1) > 1 ? { multiple: !0 } : {},
|
|
839
|
+
onChange: (t) => r(e.fieldKey, t.length ? t.map((e) => e.id) : void 0),
|
|
840
|
+
onUpload: async (t) => Promise.all(t.map(async (t) => ({
|
|
841
|
+
file: t,
|
|
842
|
+
id: (i ? await i(e, t) : { id: `${t.name}-${t.lastModified}` }).id,
|
|
843
|
+
progress: 100,
|
|
844
|
+
status: "done"
|
|
845
|
+
}))),
|
|
846
|
+
size: "sub"
|
|
847
|
+
}) : e.type === "date" ? /* @__PURE__ */ x(l, {
|
|
848
|
+
format: "YYYY-MM-DD",
|
|
849
|
+
fullWidth: !0,
|
|
850
|
+
onChange: (t) => r(e.fieldKey, te(t)),
|
|
851
|
+
placeholder: e.placeholder ?? pt(e.type),
|
|
852
|
+
readOnly: n,
|
|
853
|
+
value: M(t)
|
|
854
|
+
}) : e.type === "datetime" ? /* @__PURE__ */ x(u, {
|
|
855
|
+
formatDate: "YYYY-MM-DD",
|
|
856
|
+
formatTime: "HH:mm",
|
|
857
|
+
fullWidth: !0,
|
|
858
|
+
hideSecond: !0,
|
|
859
|
+
onChange: (t) => r(e.fieldKey, D(t)),
|
|
860
|
+
placeholderLeft: "選擇日期",
|
|
861
|
+
placeholderRight: "選擇時間",
|
|
862
|
+
readOnly: n,
|
|
863
|
+
value: M(t)
|
|
864
|
+
}) : e.type === "number" || e.type === "money" ? /* @__PURE__ */ x(d, {
|
|
865
|
+
fullWidth: !0,
|
|
866
|
+
max: e.maximum,
|
|
867
|
+
min: e.minimum,
|
|
868
|
+
size: a,
|
|
869
|
+
onChange: (t) => r(e.fieldKey, E(j(t.target.value), {
|
|
870
|
+
max: e.maximum,
|
|
871
|
+
min: e.minimum
|
|
872
|
+
})),
|
|
873
|
+
placeholder: e.placeholder ?? pt(e.type),
|
|
874
|
+
...n ? { readonly: !0 } : {},
|
|
875
|
+
showSpinner: !0,
|
|
876
|
+
value: ft(t),
|
|
877
|
+
variant: "measure"
|
|
878
|
+
}) : /* @__PURE__ */ x(d, {
|
|
879
|
+
fullWidth: !0,
|
|
880
|
+
onChange: (t) => r(e.fieldKey, t.target.value),
|
|
881
|
+
placeholder: e.placeholder ?? pt(e.type),
|
|
882
|
+
...n ? { readonly: !0 } : {},
|
|
883
|
+
size: a,
|
|
884
|
+
value: ut(t),
|
|
885
|
+
variant: "base"
|
|
886
|
+
});
|
|
887
|
+
}
|
|
888
|
+
function ct(e, t, n, r, i, a, s = "main") {
|
|
889
|
+
let l = a.options.map(N), u = R(t, a.options).map(N), d = a.status === "LOADING", m = a.status === "WAITING_FOR_DEPENDENCIES", h = !!i && !n, g = n || m, _ = n;
|
|
890
|
+
return e.type === "autocomplete" ? he(e) === "multiple" ? /* @__PURE__ */ x(o, {
|
|
891
|
+
asyncData: h,
|
|
892
|
+
clearSearchText: !0,
|
|
893
|
+
disabled: _,
|
|
894
|
+
disabledOptionsFilter: h,
|
|
895
|
+
globalPortal: !0,
|
|
896
|
+
loading: d,
|
|
897
|
+
mode: "multiple",
|
|
898
|
+
onChange: (t) => r(e.fieldKey, t.length ? t.map((e) => e.id) : void 0),
|
|
899
|
+
onReachBottom: a.hasNextPage ? a.onReachBottom : void 0,
|
|
900
|
+
onSearch: h ? a.onSearch : void 0,
|
|
901
|
+
options: l,
|
|
902
|
+
placeholder: e.placeholder ?? "請輸入或選擇",
|
|
903
|
+
readOnly: n,
|
|
904
|
+
searchDebounceTime: 300,
|
|
905
|
+
size: s,
|
|
906
|
+
value: u
|
|
907
|
+
}) : /* @__PURE__ */ x(o, {
|
|
908
|
+
asyncData: h,
|
|
909
|
+
clearSearchText: !0,
|
|
910
|
+
disabled: _,
|
|
911
|
+
disabledOptionsFilter: h,
|
|
912
|
+
globalPortal: !0,
|
|
913
|
+
loading: d,
|
|
914
|
+
mode: "single",
|
|
915
|
+
onChange: (t) => r(e.fieldKey, t?.id ?? void 0),
|
|
916
|
+
onReachBottom: a.hasNextPage ? a.onReachBottom : void 0,
|
|
917
|
+
onSearch: h ? a.onSearch : void 0,
|
|
918
|
+
options: l,
|
|
919
|
+
placeholder: e.placeholder ?? "請輸入或選擇",
|
|
920
|
+
readOnly: n,
|
|
921
|
+
searchDebounceTime: 300,
|
|
922
|
+
size: s,
|
|
923
|
+
value: u[0] ?? null
|
|
924
|
+
}) : e.type === "radio" ? /* @__PURE__ */ x(f, {
|
|
925
|
+
disabled: g,
|
|
926
|
+
name: e.fieldKey,
|
|
927
|
+
onChange: (t) => r(e.fieldKey, t.target.value || void 0),
|
|
928
|
+
options: l,
|
|
929
|
+
value: ut(t)
|
|
930
|
+
}) : e.type === "checkbox" ? /* @__PURE__ */ x(c, {
|
|
931
|
+
disabled: g,
|
|
932
|
+
name: e.fieldKey,
|
|
933
|
+
onChange: (t) => r(e.fieldKey, t.target.values.length ? t.target.values : void 0),
|
|
934
|
+
options: l.map((e) => ({
|
|
935
|
+
label: e.name,
|
|
936
|
+
value: e.id
|
|
937
|
+
})),
|
|
938
|
+
value: [...dt(t)]
|
|
939
|
+
}) : he(e) === "multiple" ? /* @__PURE__ */ x(p, {
|
|
940
|
+
disabled: g,
|
|
941
|
+
loading: d,
|
|
942
|
+
mode: "multiple",
|
|
943
|
+
onChange: (t) => r(e.fieldKey, t.length ? t.map((e) => e.id) : void 0),
|
|
944
|
+
onReachBottom: a.hasNextPage ? a.onReachBottom : void 0,
|
|
945
|
+
options: l,
|
|
946
|
+
placeholder: e.placeholder ?? "請選擇一或多個選項",
|
|
947
|
+
readOnly: n,
|
|
948
|
+
size: s,
|
|
949
|
+
value: u
|
|
950
|
+
}) : /* @__PURE__ */ x(p, {
|
|
951
|
+
disabled: g,
|
|
952
|
+
loading: d,
|
|
953
|
+
onChange: (t) => r(e.fieldKey, t?.id ?? void 0),
|
|
954
|
+
onReachBottom: a.hasNextPage ? a.onReachBottom : void 0,
|
|
955
|
+
options: l,
|
|
956
|
+
placeholder: e.placeholder ?? "請選擇",
|
|
957
|
+
readOnly: n,
|
|
958
|
+
size: s,
|
|
959
|
+
value: u[0] ?? null
|
|
960
|
+
});
|
|
961
|
+
}
|
|
962
|
+
function lt(e, t) {
|
|
963
|
+
return {
|
|
964
|
+
FULL: 12,
|
|
965
|
+
HALF: 6,
|
|
966
|
+
THIRD: 4
|
|
967
|
+
}[t.layout.find((t) => t.fieldKey === e.fieldKey)?.width ?? "FULL"];
|
|
968
|
+
}
|
|
969
|
+
function ut(e) {
|
|
970
|
+
return typeof e == "string" ? e : "";
|
|
971
|
+
}
|
|
972
|
+
function dt(e) {
|
|
973
|
+
return Array.isArray(e) && e.every((e) => typeof e == "string") ? e : [];
|
|
974
|
+
}
|
|
975
|
+
function ft(e) {
|
|
976
|
+
return typeof e == "number" ? String(e) : "";
|
|
977
|
+
}
|
|
978
|
+
function pt(e) {
|
|
979
|
+
return {
|
|
980
|
+
boolean: "",
|
|
981
|
+
autocomplete: "請輸入或選擇",
|
|
982
|
+
checkbox: "請選擇一或多個選項",
|
|
983
|
+
date: "請選擇日期",
|
|
984
|
+
datetime: "請選擇日期與時間",
|
|
985
|
+
file_upload: "請上傳附件",
|
|
986
|
+
member: "搜尋姓名或信箱",
|
|
987
|
+
money: "請輸入金額",
|
|
988
|
+
number: "請輸入數字",
|
|
989
|
+
radio: "請選擇一個選項",
|
|
990
|
+
select: "請選擇一個選項",
|
|
991
|
+
table: "",
|
|
992
|
+
text: "請輸入文字",
|
|
993
|
+
textarea: "請輸入多行文字"
|
|
994
|
+
}[e];
|
|
995
|
+
}
|
|
996
|
+
//#endregion
|
|
997
|
+
export { W as a, G as i, $ as n, K as o, Q as r, U as s, He as t };
|
|
998
|
+
|
|
999
|
+
//# sourceMappingURL=FormRendererView-DU9LLrOF.js.map
|