@rytass/bpm-core-react 0.18.1 → 0.20.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 +52 -0
- package/dist/chunks/{FormBuilderView-vQfVc08Z.js → FormBuilderView-CFRiw04B.js} +563 -475
- package/dist/chunks/FormBuilderView-CFRiw04B.js.map +1 -0
- package/dist/chunks/FormBuilderView-CpUgbSbt.cjs +3 -0
- package/dist/chunks/FormBuilderView-CpUgbSbt.cjs.map +1 -0
- package/dist/chunks/FormRendererView-GfbVWEGa.js +1321 -0
- package/dist/chunks/FormRendererView-GfbVWEGa.js.map +1 -0
- package/dist/chunks/FormRendererView-lYSaR8CQ.cjs +6 -0
- package/dist/chunks/FormRendererView-lYSaR8CQ.cjs.map +1 -0
- package/dist/chunks/{compose-DtfX8DQ9.cjs → compose-Bb5bUVFd.cjs} +2 -2
- package/dist/chunks/{compose-DtfX8DQ9.cjs.map → compose-Bb5bUVFd.cjs.map} +1 -1
- package/dist/chunks/{compose-D9ipJpF_.js → compose-egQlRjuZ.js} +5 -4
- package/dist/chunks/{compose-D9ipJpF_.js.map → compose-egQlRjuZ.js.map} +1 -1
- package/dist/chunks/{delegations-BfhCDz5e.js → delegations-9-yvWWws.js} +3 -2
- package/dist/chunks/delegations-9-yvWWws.js.map +1 -0
- package/dist/chunks/delegations-CVmtpkRn.cjs +2 -0
- package/dist/chunks/delegations-CVmtpkRn.cjs.map +1 -0
- package/dist/chunks/delegations-CrfjsH94.cjs +2 -0
- package/dist/chunks/delegations-CrfjsH94.cjs.map +1 -0
- package/dist/chunks/{delegations-DBh5TT6G.js → delegations-CxnNvTCc.js} +3 -2
- package/dist/chunks/delegations-CxnNvTCc.js.map +1 -0
- package/dist/chunks/designer-CX9bhYJS.cjs +69 -0
- package/dist/chunks/designer-CX9bhYJS.cjs.map +1 -0
- package/dist/chunks/{designer-ubnZbP-A.js → designer-CZDlQ9Nf.js} +2341 -1584
- package/dist/chunks/designer-CZDlQ9Nf.js.map +1 -0
- package/dist/chunks/{detail-C6XKZjlF.js → detail-ByZV1XaI.js} +853 -840
- package/dist/chunks/detail-ByZV1XaI.js.map +1 -0
- package/dist/chunks/detail-ChseSF55.cjs +5 -0
- package/dist/chunks/detail-ChseSF55.cjs.map +1 -0
- package/dist/chunks/{approver-filled-form-B4zPg9kz.cjs → instance-error-message-DTARGbGo.cjs} +2 -2
- package/dist/chunks/instance-error-message-DTARGbGo.cjs.map +1 -0
- package/dist/chunks/{approver-filled-form-Bgazhbvd.js → instance-error-message-q6gy5evy.js} +44 -36
- package/dist/chunks/instance-error-message-q6gy5evy.js.map +1 -0
- package/dist/chunks/workflow-chat-prompt-B4wCFKPB.js +25 -0
- package/dist/chunks/workflow-chat-prompt-B4wCFKPB.js.map +1 -0
- package/dist/chunks/workflow-chat-prompt-B803qVdt.cjs +27 -0
- package/dist/chunks/workflow-chat-prompt-B803qVdt.cjs.map +1 -0
- package/dist/next/workflow-chat-route.cjs +8 -19
- package/dist/next/workflow-chat-route.cjs.map +1 -1
- package/dist/next/workflow-chat-route.d.cts +92 -4
- package/dist/next/workflow-chat-route.d.ts +92 -4
- package/dist/next/workflow-chat-route.js +127 -19
- package/dist/next/workflow-chat-route.js.map +1 -1
- package/dist/pages/admin/delegations/index.cjs +1 -1
- package/dist/pages/admin/delegations/index.js +1 -1
- package/dist/pages/delegations/index.cjs +1 -1
- package/dist/pages/delegations/index.js +1 -1
- 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/admin/delegations/index.cjs +1 -1
- package/dist/views/admin/delegations/index.js +1 -1
- package/dist/views/admin/index.cjs +1 -1
- package/dist/views/admin/index.js +1 -1
- package/dist/views/delegations/index.cjs +1 -1
- package/dist/views/delegations/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/FormRendererView.d.cts +25 -2
- package/dist/views/forms/renderer/FormRendererView.d.ts +25 -2
- package/dist/views/forms/renderer/file-upload-field.d.cts +84 -0
- package/dist/views/forms/renderer/file-upload-field.d.ts +84 -0
- package/dist/views/forms/renderer/form-data-source-field.d.cts +9 -1
- package/dist/views/forms/renderer/form-data-source-field.d.ts +9 -1
- package/dist/views/forms/renderer/form-value-readers.d.cts +7 -0
- package/dist/views/forms/renderer/form-value-readers.d.ts +7 -0
- package/dist/views/forms/renderer/index.cjs +1 -1
- package/dist/views/forms/renderer/index.d.cts +1 -0
- package/dist/views/forms/renderer/index.d.ts +1 -0
- package/dist/views/forms/renderer/index.js +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/InstanceFormSection.d.cts +20 -3
- package/dist/views/instances/detail/sections/InstanceFormSection.d.ts +20 -3
- package/dist/views/instances/detail/sections/shared.d.cts +1 -2
- package/dist/views/instances/detail/sections/shared.d.ts +1 -2
- package/dist/views/instances/instance-error-message.d.cts +5 -0
- package/dist/views/instances/instance-error-message.d.ts +5 -0
- package/dist/views/instances/new/index.cjs +1 -1
- package/dist/views/instances/new/index.cjs.map +1 -1
- package/dist/views/instances/new/index.js +79 -76
- package/dist/views/instances/new/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/designer-version-labels.d.cts +7 -0
- package/dist/views/templates/designer/designer-version-labels.d.ts +7 -0
- package/dist/views/templates/designer/expression/DialectUpgradeModal.d.cts +25 -0
- package/dist/views/templates/designer/expression/DialectUpgradeModal.d.ts +25 -0
- package/dist/views/templates/designer/expression/ExpressionField.d.cts +79 -0
- package/dist/views/templates/designer/expression/ExpressionField.d.ts +79 -0
- package/dist/views/templates/designer/expression/use-workflow-expression-references.d.cts +22 -0
- package/dist/views/templates/designer/expression/use-workflow-expression-references.d.ts +22 -0
- package/dist/views/templates/designer/expression/workflow-expression-edits.d.cts +58 -0
- package/dist/views/templates/designer/expression/workflow-expression-edits.d.ts +58 -0
- package/dist/views/templates/designer/expression/workflow-expression-tools.d.cts +14 -0
- package/dist/views/templates/designer/expression/workflow-expression-tools.d.ts +14 -0
- package/dist/views/templates/designer/field-access-matrix/FieldAccessMatrixDrawer.d.cts +7 -1
- package/dist/views/templates/designer/field-access-matrix/FieldAccessMatrixDrawer.d.ts +7 -1
- package/dist/views/templates/designer/index.cjs +1 -1
- package/dist/views/templates/designer/index.js +1 -1
- package/dist/views/templates/designer/notify-webhook-designer.d.cts +8 -0
- package/dist/views/templates/designer/notify-webhook-designer.d.ts +8 -0
- package/dist/views/templates/designer/use-workflow-designer-controller.d.cts +8 -2
- package/dist/views/templates/designer/use-workflow-designer-controller.d.ts +8 -2
- package/dist/views/templates/designer/workflow-chat-prompt.d.cts +18 -0
- package/dist/views/templates/designer/workflow-chat-prompt.d.ts +18 -0
- package/package.json +3 -3
- package/dist/chunks/FormBuilderView-CHaAQL5v.cjs +0 -3
- package/dist/chunks/FormBuilderView-CHaAQL5v.cjs.map +0 -1
- package/dist/chunks/FormBuilderView-vQfVc08Z.js.map +0 -1
- package/dist/chunks/FormRendererView-CTLlG13b.js +0 -1106
- package/dist/chunks/FormRendererView-CTLlG13b.js.map +0 -1
- package/dist/chunks/FormRendererView-ChmM_4Yc.cjs +0 -4
- package/dist/chunks/FormRendererView-ChmM_4Yc.cjs.map +0 -1
- package/dist/chunks/approver-filled-form-B4zPg9kz.cjs.map +0 -1
- package/dist/chunks/approver-filled-form-Bgazhbvd.js.map +0 -1
- package/dist/chunks/delegations-BfhCDz5e.js.map +0 -1
- package/dist/chunks/delegations-BmFGcuhA.cjs +0 -2
- package/dist/chunks/delegations-BmFGcuhA.cjs.map +0 -1
- package/dist/chunks/delegations-CcS0SHbf.cjs +0 -2
- package/dist/chunks/delegations-CcS0SHbf.cjs.map +0 -1
- package/dist/chunks/delegations-DBh5TT6G.js.map +0 -1
- package/dist/chunks/designer-Df79YzUn.cjs +0 -65
- package/dist/chunks/designer-Df79YzUn.cjs.map +0 -1
- package/dist/chunks/designer-ubnZbP-A.js.map +0 -1
- package/dist/chunks/detail-BBC9kqXd.cjs +0 -5
- package/dist/chunks/detail-BBC9kqXd.cjs.map +0 -1
- package/dist/chunks/detail-C6XKZjlF.js.map +0 -1
|
@@ -0,0 +1,1321 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { t as e } from "./bpm-form-field-9B-Det0u.js";
|
|
3
|
+
import { t } from "./format-member-label-C73FuP-d.js";
|
|
4
|
+
import { useCallback as n, useEffect as r, useMemo as i, useRef as a, useState as o } from "react";
|
|
5
|
+
import { AutoComplete as s, Button as c, CheckboxGroup as l, DatePicker as u, DateTimePicker as d, Input as f, RadioGroup as p, Select as m, Table as h, Textarea as g, Toggle as _, Typography as v, Upload as y } from "@mezzanine-ui/react";
|
|
6
|
+
import { resolveMembers as b, searchMembers as x } from "@rytass/bpm-core-client";
|
|
7
|
+
import { jsx as S, jsxs as C } from "react/jsx-runtime";
|
|
8
|
+
import { PlusIcon as w, TrashIcon as T } from "@mezzanine-ui/icons";
|
|
9
|
+
import { buildFormRendererValues as E, clampOptionalNumber as D, createFormTableRow as O, formatDatePickerValue as k, formatDateTimePickerValue as A, isFormRendererFieldReadonly as j, isFormRendererFieldRequired as M, mergeFormDataSourceOptions as N, parseOptionalNumberInput as ee, previewFormFieldOptions as te, previewResolveFormFieldOptions as ne, readDatePickerValue as re, readFieldOptionAsSelectOption as P, readFormDataSourceErrorCode as ie, readFormDataSourceErrorMessage as ae, readFormDataSourceSelectedValues as oe, readFormDataSourceValueSignature as F, readFormFieldOptions as se, readFormTableCellPath as ce, readFormTableRowBounds as le, readFormTableRows as I, readMissingFormDataSourceDependencies as ue, readMissingFormDataSourceOptionValues as L, readSelectOption as R, readSelectedFormDataSourceOptions as de, readVisibleFormRendererFields as z, resolveFormFieldOptions as fe } from "@rytass/bpm-core-client/form";
|
|
10
|
+
import { isFormDataSourceFieldDefinition as pe, isFormStaticOptionFieldDefinition as B, isFormTableCellValue as me, isTableFieldDefinition as he, readFormFieldSelectionMode as V, readFormMemberIds as ge } from "@rytass/bpm-core-shared/form";
|
|
11
|
+
import { resolveOrgUnitOptions as _e, searchOrgUnitOptions as H } from "@rytass/bpm-core-client/organization";
|
|
12
|
+
// src/views/forms/renderer/form-data-source-field.ts
|
|
13
|
+
var ve = {
|
|
14
|
+
canRetry: !1,
|
|
15
|
+
error: null,
|
|
16
|
+
hasValue: !1,
|
|
17
|
+
hasNextPage: !1,
|
|
18
|
+
invalidValues: [],
|
|
19
|
+
onReachBottom: () => void 0,
|
|
20
|
+
onSearch: () => void 0,
|
|
21
|
+
options: [],
|
|
22
|
+
retry: () => void 0,
|
|
23
|
+
status: "IDLE"
|
|
24
|
+
}, ye = [], be = 10, xe = 300, Se = ["FORM_DATA_SOURCE_SEARCH_NOT_SUPPORTED", "FORM_DATA_SOURCE_SEARCH_TOO_SHORT"];
|
|
25
|
+
function Ce(e, t) {
|
|
26
|
+
if (!t.row) return e;
|
|
27
|
+
let n = t.fieldPath?.indexOf(".") ?? -1;
|
|
28
|
+
return t.fieldPath && n > 0 ? t.fieldPath.slice(0, n) : null;
|
|
29
|
+
}
|
|
30
|
+
function U(e, t) {
|
|
31
|
+
return t === null ? e : Object.fromEntries(Object.entries(e).filter(([e]) => e !== t));
|
|
32
|
+
}
|
|
33
|
+
function we(e, t) {
|
|
34
|
+
let n = e.from;
|
|
35
|
+
switch (n.kind) {
|
|
36
|
+
case "FIELD": return {
|
|
37
|
+
fieldKey: n.fieldKey,
|
|
38
|
+
value: t.formData[n.fieldKey]
|
|
39
|
+
};
|
|
40
|
+
case "CONSTANT": return { value: n.value };
|
|
41
|
+
case "ROW_FIELD": return {
|
|
42
|
+
columnKey: n.columnKey,
|
|
43
|
+
value: t.rowValues?.[n.columnKey]
|
|
44
|
+
};
|
|
45
|
+
case "EXPRESSION": return {
|
|
46
|
+
expression: n.expression,
|
|
47
|
+
form: U(t.formData, t.ownFormKey),
|
|
48
|
+
row: t.rowValues ? U(t.rowValues, t.ownRowKey) : null
|
|
49
|
+
};
|
|
50
|
+
default: return Te(n);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function Te(e) {
|
|
54
|
+
return { unsupported: !0 };
|
|
55
|
+
}
|
|
56
|
+
function Ee(e) {
|
|
57
|
+
return JSON.stringify(De(e)) ?? "null";
|
|
58
|
+
}
|
|
59
|
+
function De(e) {
|
|
60
|
+
return Array.isArray(e) ? e.map(De) : typeof e == "object" && e ? Object.fromEntries(Object.entries(e).filter(([, e]) => e !== void 0).sort(([e], [t]) => e < t ? -1 : +(e > t)).map(([e, t]) => [e, De(t)])) : e;
|
|
61
|
+
}
|
|
62
|
+
function W(e) {
|
|
63
|
+
let t = pe(e.field) ? e.field : null, s = e.fieldPath ?? t?.fieldKey ?? "", c = t ? e.optionSnapshots?.[e.snapshotKey ?? t.fieldKey] : void 0, l = t ? JSON.stringify({
|
|
64
|
+
dataSource: t.dataSource,
|
|
65
|
+
fieldKey: t.fieldKey,
|
|
66
|
+
type: t.type
|
|
67
|
+
}) : "", u = JSON.stringify(c ?? null), d = i(() => 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 = t ? e.row ? e.row.values[t.fieldKey] : e.formData[t.fieldKey] : void 0, S = F(x), C = i(() => oe(x), [S]), w = C.length > 0, T = t ? JSON.stringify(t.dataSource.bindings.map((n) => we(n, {
|
|
68
|
+
formData: e.formData,
|
|
69
|
+
ownFormKey: Ce(t.fieldKey, e),
|
|
70
|
+
ownRowKey: e.row ? t.fieldKey : null,
|
|
71
|
+
rowValues: e.row?.values
|
|
72
|
+
}))) : "", D = t ? JSON.stringify(e.initialFormData !== void 0 || e.initialValue !== void 0 ? x ?? null : null) : "", O = t ? `${T}\u0000${D}` : "", k = Oe(T, t?.dataSource.bindings.some((e) => e.from.kind === "EXPRESSION") ? xe : 0), A = k !== T, j = i(() => {
|
|
73
|
+
if (g === "preview") return { kind: "preview" };
|
|
74
|
+
if (g === "runtime" && !e.readonly) return {
|
|
75
|
+
instanceId: _,
|
|
76
|
+
kind: "runtime",
|
|
77
|
+
templateId: v
|
|
78
|
+
};
|
|
79
|
+
}, [
|
|
80
|
+
_,
|
|
81
|
+
g,
|
|
82
|
+
v,
|
|
83
|
+
e.readonly
|
|
84
|
+
]), M = t ? (e.initialFormData !== void 0 || e.initialValue !== void 0) && F(e.initialValue) !== S : !1, ee = t ? e.initialFormData !== void 0 && t.dataSource.bindings.some((n) => {
|
|
85
|
+
if (n.from.kind === "FIELD") return F(e.initialFormData?.[n.from.fieldKey]) !== F(e.formData[n.from.fieldKey]);
|
|
86
|
+
if (n.from.kind === "ROW_FIELD" && e.row?.initialValues) return F(e.row.initialValues[n.from.columnKey]) !== F(e.row.values[n.from.columnKey]);
|
|
87
|
+
if (n.from.kind === "EXPRESSION") {
|
|
88
|
+
if (!j) return !1;
|
|
89
|
+
let r = {
|
|
90
|
+
ownFormKey: Ce(t.fieldKey, e),
|
|
91
|
+
ownRowKey: e.row ? t.fieldKey : null
|
|
92
|
+
};
|
|
93
|
+
return Ee(we(n, {
|
|
94
|
+
...r,
|
|
95
|
+
formData: E(e.schema.fields, e.initialFormData ?? {}),
|
|
96
|
+
rowValues: e.row?.initialValues ?? e.row?.values
|
|
97
|
+
})) !== Ee(we(n, {
|
|
98
|
+
...r,
|
|
99
|
+
formData: E(e.schema.fields, e.formData),
|
|
100
|
+
rowValues: e.row?.values
|
|
101
|
+
}));
|
|
102
|
+
}
|
|
103
|
+
return !1;
|
|
104
|
+
}) : !1, re = !!t?.dataSource.bindings.some((e) => e.from.kind === "EXPRESSION"), [P, ce] = o(() => ({
|
|
105
|
+
bindings: k,
|
|
106
|
+
value: S
|
|
107
|
+
}));
|
|
108
|
+
P.value !== S && ce({
|
|
109
|
+
bindings: k,
|
|
110
|
+
value: S
|
|
111
|
+
});
|
|
112
|
+
let le = !!(re && j && w && P.value === S && P.bindings !== k), I = !!((c || w) && (M || ee || le)), L = !!(t && j && I && w), R = Me({
|
|
113
|
+
hasSnapshot: !!c,
|
|
114
|
+
hasValue: w,
|
|
115
|
+
isStale: I,
|
|
116
|
+
readonly: e.readonly
|
|
117
|
+
}), z = !!(t && j && t.type !== "autocomplete"), B = Ne(I, z && t !== null && ue(t, e.formData, e.row?.values).length > 0), me = a(R);
|
|
118
|
+
me.current = R;
|
|
119
|
+
let [he, V] = o([]), [ge, _e] = o(""), [H, ye] = o(null), [U, Te] = o(null), [De, W] = o(() => t ? z ? B : R : "IDLE"), [ke, G] = o(null), Ae = a(0), K = a(0), q = a(0), J = a(null), Re = a(null), ze = a({
|
|
120
|
+
cursor: null,
|
|
121
|
+
searchText: ""
|
|
122
|
+
}), Y = i(() => Le(e.formData), [f]), X = i(() => e.row ? Le(e.row.values) : void 0, [y]), Be = i(() => N(d, he), [he, d]), Z = U && U.signature === O && U.valueSignature === S ? U : null, Ve = L && !Z, He = !!(le && Z && Z.unresolvedValues.length > 0), Ue = je({
|
|
123
|
+
options: Be,
|
|
124
|
+
resolution: Z,
|
|
125
|
+
resolvePending: Ve,
|
|
126
|
+
value: x
|
|
127
|
+
}), Q = n((n, r) => {
|
|
128
|
+
if (!t || !j) return;
|
|
129
|
+
let i = K.current + 1;
|
|
130
|
+
K.current = i, ze.current = {
|
|
131
|
+
cursor: r,
|
|
132
|
+
searchText: n
|
|
133
|
+
}, J.current?.abort();
|
|
134
|
+
let a = new AbortController();
|
|
135
|
+
J.current = a, W(B), G(null), (j.kind === "preview" ? te({
|
|
136
|
+
cursor: r,
|
|
137
|
+
fieldKey: s,
|
|
138
|
+
formData: Y,
|
|
139
|
+
rowValues: X,
|
|
140
|
+
schema: e.schema,
|
|
141
|
+
searchText: n,
|
|
142
|
+
signal: a.signal,
|
|
143
|
+
uiSchema: e.uiSchema
|
|
144
|
+
}) : se({
|
|
145
|
+
cursor: r,
|
|
146
|
+
fieldKey: s,
|
|
147
|
+
formData: Y,
|
|
148
|
+
instanceId: j.instanceId ?? null,
|
|
149
|
+
rowValues: X,
|
|
150
|
+
searchText: n,
|
|
151
|
+
signal: a.signal,
|
|
152
|
+
templateId: j.templateId ?? null
|
|
153
|
+
})).then((e) => {
|
|
154
|
+
Ie(a, K, i) || (V((t) => {
|
|
155
|
+
let n = de(x, t);
|
|
156
|
+
return N(n, r ? t : [], e.options);
|
|
157
|
+
}), ye(e.nextCursor), G(null), Ae.current = r ? Ae.current + e.options.length : e.options.length, e.nextCursor && e.options.length > 0 && Ae.current < be && We.current(n, e.nextCursor), W(e.waitingForFieldKeys.length ? "WAITING_FOR_DEPENDENCIES" : "VALID"));
|
|
158
|
+
}).catch((e) => {
|
|
159
|
+
if (Ie(a, K, i)) return;
|
|
160
|
+
let t = ae(e) ?? "選項來源暫時無法使用。", n = ie(e);
|
|
161
|
+
G(t), W(Pe(!!(n && Se.includes(n)), w));
|
|
162
|
+
});
|
|
163
|
+
}, [
|
|
164
|
+
S,
|
|
165
|
+
l,
|
|
166
|
+
j,
|
|
167
|
+
w,
|
|
168
|
+
B,
|
|
169
|
+
s,
|
|
170
|
+
Y,
|
|
171
|
+
X,
|
|
172
|
+
m,
|
|
173
|
+
h
|
|
174
|
+
]), We = a(Q);
|
|
175
|
+
We.current = Q;
|
|
176
|
+
let Ge = n(() => {
|
|
177
|
+
if (!t || !j || C.length === 0) return;
|
|
178
|
+
let n = O, r = S, i = q.current + 1;
|
|
179
|
+
q.current = i, Re.current?.abort();
|
|
180
|
+
let a = new AbortController();
|
|
181
|
+
Re.current = a, G(null), (j.kind === "preview" ? ne({
|
|
182
|
+
fieldKey: s,
|
|
183
|
+
formData: Y,
|
|
184
|
+
rowValues: X,
|
|
185
|
+
schema: e.schema,
|
|
186
|
+
signal: a.signal,
|
|
187
|
+
uiSchema: e.uiSchema,
|
|
188
|
+
values: C
|
|
189
|
+
}) : fe({
|
|
190
|
+
fieldKey: s,
|
|
191
|
+
formData: Y,
|
|
192
|
+
instanceId: j.instanceId ?? null,
|
|
193
|
+
rowValues: X,
|
|
194
|
+
signal: a.signal,
|
|
195
|
+
templateId: j.templateId ?? null,
|
|
196
|
+
values: C
|
|
197
|
+
})).then((e) => {
|
|
198
|
+
Ie(a, q, i) || (e.waitingForFieldKeys.length ? W("WAITING_FOR_DEPENDENCIES") : (V((t) => N(t, e.options)), Te({
|
|
199
|
+
signature: n,
|
|
200
|
+
unresolvedValues: e.unresolvedValues,
|
|
201
|
+
valueSignature: r
|
|
202
|
+
}), W("VALID")));
|
|
203
|
+
}).catch((e) => {
|
|
204
|
+
Ie(a, q, i) || (W("UNAVAILABLE"), G(ae(e) ?? "選項來源暫時無法使用。"));
|
|
205
|
+
});
|
|
206
|
+
}, [
|
|
207
|
+
S,
|
|
208
|
+
O,
|
|
209
|
+
l,
|
|
210
|
+
j,
|
|
211
|
+
s,
|
|
212
|
+
Y,
|
|
213
|
+
X,
|
|
214
|
+
m,
|
|
215
|
+
C,
|
|
216
|
+
h
|
|
217
|
+
]), Ke = a(Ge);
|
|
218
|
+
Ke.current = Ge, r(() => {
|
|
219
|
+
K.current += 1, J.current?.abort(), V((e) => de(x, e)), ye((e) => e === null ? e : null), _e((e) => e && ""), G((e) => e && null), t ? z ? We.current("", null) : W(me.current) : W("IDLE");
|
|
220
|
+
}, [
|
|
221
|
+
z,
|
|
222
|
+
l,
|
|
223
|
+
j,
|
|
224
|
+
k,
|
|
225
|
+
D,
|
|
226
|
+
p,
|
|
227
|
+
b,
|
|
228
|
+
e.readonly,
|
|
229
|
+
u
|
|
230
|
+
]), r(() => {
|
|
231
|
+
t && !z && W(R);
|
|
232
|
+
}, [
|
|
233
|
+
z,
|
|
234
|
+
l,
|
|
235
|
+
R
|
|
236
|
+
]), r(() => {
|
|
237
|
+
L && !A && Ke.current();
|
|
238
|
+
}, [
|
|
239
|
+
j,
|
|
240
|
+
L,
|
|
241
|
+
A,
|
|
242
|
+
k,
|
|
243
|
+
D
|
|
244
|
+
]), r(() => () => {
|
|
245
|
+
J.current?.abort(), Re.current?.abort();
|
|
246
|
+
}, []);
|
|
247
|
+
let qe = n((e) => {
|
|
248
|
+
_e(e), V((e) => de(x, e)), ye(null), Q(e, null);
|
|
249
|
+
}, [Q]), Je = n(() => {
|
|
250
|
+
H && Q(ge, H);
|
|
251
|
+
}, [
|
|
252
|
+
Q,
|
|
253
|
+
H,
|
|
254
|
+
ge
|
|
255
|
+
]), Ye = n(() => {
|
|
256
|
+
j && (Q(ze.current.searchText, ze.current.cursor), L && Ke.current());
|
|
257
|
+
}, [
|
|
258
|
+
j,
|
|
259
|
+
Q,
|
|
260
|
+
L
|
|
261
|
+
]);
|
|
262
|
+
return t ? {
|
|
263
|
+
canRetry: !!j,
|
|
264
|
+
error: ke,
|
|
265
|
+
hasValue: w,
|
|
266
|
+
hasNextPage: !!H,
|
|
267
|
+
invalidValues: Ue,
|
|
268
|
+
onReachBottom: Je,
|
|
269
|
+
onSearch: qe,
|
|
270
|
+
options: Be,
|
|
271
|
+
retry: Ye,
|
|
272
|
+
selectionExpired: He,
|
|
273
|
+
status: A && j && (z || w) ? z ? B : "STALE" : Fe({
|
|
274
|
+
invalidValues: Ue,
|
|
275
|
+
resolvePending: Ve,
|
|
276
|
+
status: De
|
|
277
|
+
})
|
|
278
|
+
} : ve;
|
|
279
|
+
}
|
|
280
|
+
function Oe(e, t) {
|
|
281
|
+
let [n, i] = o(e);
|
|
282
|
+
return r(() => {
|
|
283
|
+
if (t <= 0) return;
|
|
284
|
+
let n = setTimeout(() => {
|
|
285
|
+
i(e);
|
|
286
|
+
}, t);
|
|
287
|
+
return () => {
|
|
288
|
+
clearTimeout(n);
|
|
289
|
+
};
|
|
290
|
+
}, [t, e]), t > 0 ? n : e;
|
|
291
|
+
}
|
|
292
|
+
function ke(e) {
|
|
293
|
+
switch (e.status) {
|
|
294
|
+
case "WAITING_FOR_DEPENDENCIES": return "請先填寫相依欄位。";
|
|
295
|
+
case "STALE": return "選項需要重新載入或驗證。";
|
|
296
|
+
case "INVALID": return e.selectionExpired ? ae("FORM_DATA_SOURCE_VALUE_NOT_RESOLVED") : e.invalidValues.length ? `無法辨識選項:${e.invalidValues.join("、")}` : "目前選項已失效,請重新選擇。";
|
|
297
|
+
case "UNAVAILABLE": return e.error ?? "選項來源暫時無法使用。";
|
|
298
|
+
case "VALID": return e.error ?? (e.options.length ? null : "目前沒有可用選項。");
|
|
299
|
+
default: return e.error;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
function G(e) {
|
|
303
|
+
return e.hasValue && e.status !== "VALID";
|
|
304
|
+
}
|
|
305
|
+
function Ae(e) {
|
|
306
|
+
let t = e.filter(G);
|
|
307
|
+
return t.length === 0 ? null : t.some((e) => e.status === "INVALID" && e.selectionExpired === !0) ? ae("FORM_DATA_SOURCE_VALUE_NOT_RESOLVED") : t.every((e) => e.status === "LOADING" || e.status === "STALE") ? "選項驗證中,請稍候再送出。" : "請先完成動態選項驗證。";
|
|
308
|
+
}
|
|
309
|
+
function je(e) {
|
|
310
|
+
return e.resolution ? e.resolution.unresolvedValues : e.resolvePending ? ye : L(e.value, e.options);
|
|
311
|
+
}
|
|
312
|
+
function Me(e) {
|
|
313
|
+
return e.isStale ? "STALE" : e.hasSnapshot ? "VALID" : e.readonly && e.hasValue ? "UNAVAILABLE" : "IDLE";
|
|
314
|
+
}
|
|
315
|
+
function Ne(e, t) {
|
|
316
|
+
return t ? "WAITING_FOR_DEPENDENCIES" : e ? "STALE" : "LOADING";
|
|
317
|
+
}
|
|
318
|
+
function Pe(e, t) {
|
|
319
|
+
return e ? t ? "VALID" : "IDLE" : "UNAVAILABLE";
|
|
320
|
+
}
|
|
321
|
+
function Fe(e) {
|
|
322
|
+
return e.status === "LOADING" || e.status === "UNAVAILABLE" || e.status === "WAITING_FOR_DEPENDENCIES" ? e.status : e.invalidValues.length ? "INVALID" : e.resolvePending ? "STALE" : e.status;
|
|
323
|
+
}
|
|
324
|
+
function Ie(e, t, n) {
|
|
325
|
+
return e.signal.aborted || t.current !== n;
|
|
326
|
+
}
|
|
327
|
+
function Le(e) {
|
|
328
|
+
return Object.entries(e).reduce((e, [t, n]) => n === void 0 ? e : {
|
|
329
|
+
...e,
|
|
330
|
+
[t]: n
|
|
331
|
+
}, {});
|
|
332
|
+
}
|
|
333
|
+
// src/views/forms/renderer/form-value-readers.ts
|
|
334
|
+
function K(e) {
|
|
335
|
+
return Array.isArray(e) && e.every((e) => typeof e == "string") ? e : [];
|
|
336
|
+
}
|
|
337
|
+
// src/views/forms/renderer/file-upload-field.tsx
|
|
338
|
+
function q(e) {
|
|
339
|
+
return e.some((e) => e.pendingCount > 0) ? "附件仍在上傳中,請稍候再送出。" : e.some((e) => e.failedCount > 0) ? "有附件上傳失敗,請重試或移除後再送出。" : null;
|
|
340
|
+
}
|
|
341
|
+
function J() {
|
|
342
|
+
let [e, t] = o({}), r = n((e, n) => t((t) => ({
|
|
343
|
+
...t,
|
|
344
|
+
[e]: n
|
|
345
|
+
})), []);
|
|
346
|
+
return {
|
|
347
|
+
blockMessage: q(Object.values(e)),
|
|
348
|
+
onFileUploadStateChange: r
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
var Re = "無法讀取檔名的附件", ze = "此處無法上傳附件";
|
|
352
|
+
function Y({ attachments: e, field: t, onChange: s, onDownloadAttachment: c, onStateChange: l, onUploadAttachment: u, readonly: d, value: f }) {
|
|
353
|
+
let [p, m] = o([]), [h, g] = o(() => /* @__PURE__ */ new Map()), [_, v] = o([]), b = K(f), x = b.join("\n"), C = i(() => new Map((e ?? []).map((e) => [e.id, e])), [e]), w = i(() => {
|
|
354
|
+
let e = new Map(_.map((e, t) => [e, t]));
|
|
355
|
+
return [...b.map((e) => h.get(e) ?? X(e, C.get(e))), ...p].sort((t, n) => (e.get(t.id) ?? -1) - (e.get(n.id) ?? -1));
|
|
356
|
+
}, [
|
|
357
|
+
C,
|
|
358
|
+
_,
|
|
359
|
+
h,
|
|
360
|
+
p,
|
|
361
|
+
x
|
|
362
|
+
]), T = a(w), E = a(!0), D = a(M);
|
|
363
|
+
D.current = M, r(() => {
|
|
364
|
+
T.current = w;
|
|
365
|
+
}, [w]);
|
|
366
|
+
let O = n((e) => D.current(e), []), k = p.filter((e) => e.status === "loading").length, A = p.filter((e) => e.status === "error").length, j = a(l);
|
|
367
|
+
j.current = l, r(() => {
|
|
368
|
+
j.current?.({
|
|
369
|
+
failedCount: A,
|
|
370
|
+
pendingCount: k
|
|
371
|
+
});
|
|
372
|
+
}, [A, k]), r(() => (E.current = !0, () => {
|
|
373
|
+
E.current = !1, j.current?.({
|
|
374
|
+
failedCount: 0,
|
|
375
|
+
pendingCount: 0
|
|
376
|
+
});
|
|
377
|
+
}), []);
|
|
378
|
+
function M(e) {
|
|
379
|
+
if (!E.current) return;
|
|
380
|
+
let t = e.filter((e) => e.status === "done"), n = t.map((e) => e.id), r = new Set(b), i = t.filter((e) => e.file !== void 0 && !r.has(e.id));
|
|
381
|
+
T.current = e, v(e.map((e) => e.id)), m(e.filter((e) => e.status !== "done")), i.length > 0 && g((e) => new Map([...e, ...i.map((e) => [e.id, e])])), n.join("\n") !== x && s(n.length ? n : void 0);
|
|
382
|
+
}
|
|
383
|
+
async function N(e) {
|
|
384
|
+
if (!u) throw Error(ze);
|
|
385
|
+
return {
|
|
386
|
+
file: e,
|
|
387
|
+
id: (await u(t, e)).id,
|
|
388
|
+
progress: 100,
|
|
389
|
+
status: "done"
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
async function ee(e, t) {
|
|
393
|
+
let n = await N(t).catch((n) => ({
|
|
394
|
+
errorMessage: Z(n),
|
|
395
|
+
file: t,
|
|
396
|
+
id: e,
|
|
397
|
+
status: "error"
|
|
398
|
+
}));
|
|
399
|
+
D.current(T.current.map((t) => t.id === e ? n : t));
|
|
400
|
+
}
|
|
401
|
+
function te(e, t) {
|
|
402
|
+
h.has(e) ? Ve(t) : c?.(e);
|
|
403
|
+
}
|
|
404
|
+
let ne = !!u && !d, re = [...!d && !u ? [{
|
|
405
|
+
label: ze,
|
|
406
|
+
type: "info"
|
|
407
|
+
}] : [], ...p.filter((e) => e.status === "error").map((e) => ({
|
|
408
|
+
label: `${e.file?.name ?? "檔案"}:${e.errorMessage ?? "上傳失敗"},未附加。請重試或刪除。`,
|
|
409
|
+
type: "error"
|
|
410
|
+
}))];
|
|
411
|
+
return /* @__PURE__ */ S(y, {
|
|
412
|
+
accept: t.acceptedMimeTypes?.join(","),
|
|
413
|
+
disabled: !ne,
|
|
414
|
+
files: w,
|
|
415
|
+
...re.length > 0 ? { hints: re } : {},
|
|
416
|
+
maxFiles: t.maxFiles,
|
|
417
|
+
mode: "button-list",
|
|
418
|
+
...(t.maxFiles ?? 1) > 1 ? { multiple: !0 } : {},
|
|
419
|
+
onChange: O,
|
|
420
|
+
onDownload: te,
|
|
421
|
+
onReload: (e, t) => {
|
|
422
|
+
ee(e, t);
|
|
423
|
+
},
|
|
424
|
+
onUpload: async (e) => Promise.all(e.map(async (e) => N(e).catch((t) => ({
|
|
425
|
+
errorMessage: Z(t),
|
|
426
|
+
file: e,
|
|
427
|
+
id: `failed-${e.name}-${e.lastModified}-${Math.random()}`,
|
|
428
|
+
status: "error"
|
|
429
|
+
})))),
|
|
430
|
+
size: "sub"
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
function X(e, t) {
|
|
434
|
+
return t ? {
|
|
435
|
+
file: Be(t),
|
|
436
|
+
id: e,
|
|
437
|
+
progress: 100,
|
|
438
|
+
status: "done"
|
|
439
|
+
} : {
|
|
440
|
+
id: e,
|
|
441
|
+
progress: 100,
|
|
442
|
+
status: "done",
|
|
443
|
+
url: Re
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
function Be(e) {
|
|
447
|
+
let t = new File([], e.filename), n = Number(e.sizeBytes);
|
|
448
|
+
return Number.isFinite(n) && n >= 0 && Object.defineProperty(t, "size", { value: n }), t;
|
|
449
|
+
}
|
|
450
|
+
function Z(e) {
|
|
451
|
+
return e instanceof Error && e.message ? `上傳失敗:${e.message}` : "上傳失敗,請重試。";
|
|
452
|
+
}
|
|
453
|
+
function Ve(e) {
|
|
454
|
+
let t = URL.createObjectURL(e), n = document.createElement("a");
|
|
455
|
+
n.href = t, n.download = e.name, n.style.display = "none", document.body.appendChild(n), n.click(), n.remove(), setTimeout(() => URL.revokeObjectURL(t), 3e4);
|
|
456
|
+
}
|
|
457
|
+
// src/views/forms/renderer/form-field-link.ts
|
|
458
|
+
var He = /\s/u;
|
|
459
|
+
function Ue(e) {
|
|
460
|
+
return [...e].some((e) => {
|
|
461
|
+
let t = e.codePointAt(0) ?? 0;
|
|
462
|
+
return t <= 32 || t >= 127 && t <= 160 || He.test(e);
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
var Q = /^https?:\/\//iu;
|
|
466
|
+
function We(e) {
|
|
467
|
+
return typeof e != "string" || !e || e.includes("\\") || Ue(e) ? null : e.startsWith("/") ? !e.startsWith("//") && Ke(e) ? {
|
|
468
|
+
external: !1,
|
|
469
|
+
href: e
|
|
470
|
+
} : null : Q.test(e) && qe(e) ? {
|
|
471
|
+
external: !0,
|
|
472
|
+
href: e
|
|
473
|
+
} : null;
|
|
474
|
+
}
|
|
475
|
+
var Ge = "http://placeholder.invalid";
|
|
476
|
+
function Ke(e) {
|
|
477
|
+
try {
|
|
478
|
+
let t = new URL(e, Ge);
|
|
479
|
+
return t.origin === Ge && !t.pathname.startsWith("//");
|
|
480
|
+
} catch {
|
|
481
|
+
return !1;
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
function qe(e) {
|
|
485
|
+
try {
|
|
486
|
+
let t = new URL(e);
|
|
487
|
+
return (t.protocol === "http:" || t.protocol === "https:") && !!t.hostname && !t.username && !t.password;
|
|
488
|
+
} catch {
|
|
489
|
+
return !1;
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
async function Je(e, t, n = {}) {
|
|
493
|
+
let r = n.maxPerIdRequests ?? 20, i = Math.max(1, n.concurrency ?? 4);
|
|
494
|
+
try {
|
|
495
|
+
return {
|
|
496
|
+
failedIds: [],
|
|
497
|
+
profiles: await t(e),
|
|
498
|
+
skippedIds: []
|
|
499
|
+
};
|
|
500
|
+
} catch {
|
|
501
|
+
if (e.length <= 1) return {
|
|
502
|
+
failedIds: e,
|
|
503
|
+
profiles: [],
|
|
504
|
+
skippedIds: []
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
let a = e.slice(0, r), o = await Xe(a, i, (e) => t([e]));
|
|
508
|
+
return {
|
|
509
|
+
failedIds: a.filter((e, t) => o[t].status === "rejected"),
|
|
510
|
+
profiles: o.flatMap((e) => e.status === "fulfilled" ? e.value : []),
|
|
511
|
+
skippedIds: e.slice(r)
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
function Ye(e, t) {
|
|
515
|
+
return e.filter((e) => !t.has(e));
|
|
516
|
+
}
|
|
517
|
+
async function Xe(e, t, n) {
|
|
518
|
+
let r = [], i = 0;
|
|
519
|
+
async function a() {
|
|
520
|
+
for (; i < e.length;) {
|
|
521
|
+
let t = i;
|
|
522
|
+
i += 1, r[t] = await n(e[t]).then((e) => ({
|
|
523
|
+
status: "fulfilled",
|
|
524
|
+
value: e
|
|
525
|
+
}), (e) => ({
|
|
526
|
+
reason: e,
|
|
527
|
+
status: "rejected"
|
|
528
|
+
}));
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
return await Promise.all(Array.from({ length: Math.min(t, e.length) }, a)), r;
|
|
532
|
+
}
|
|
533
|
+
// src/views/forms/renderer/member-field-options.ts
|
|
534
|
+
var Ze = "未知會員";
|
|
535
|
+
function Qe(e) {
|
|
536
|
+
return {
|
|
537
|
+
id: e.memberId,
|
|
538
|
+
name: t(e.name, e.email)
|
|
539
|
+
};
|
|
540
|
+
}
|
|
541
|
+
function $e(e) {
|
|
542
|
+
return {
|
|
543
|
+
id: e,
|
|
544
|
+
name: Ze,
|
|
545
|
+
unresolved: !0
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
function et(e, t) {
|
|
549
|
+
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);
|
|
550
|
+
return i.length > 0 || a.some((t, n) => t !== e[n]) ? [...a, ...i] : e;
|
|
551
|
+
}
|
|
552
|
+
function tt(e, t) {
|
|
553
|
+
let n = new Set(t.filter((e) => !e.unresolved).map((e) => e.id));
|
|
554
|
+
return ge(e).filter((e) => !n.has(e));
|
|
555
|
+
}
|
|
556
|
+
function nt(e, t) {
|
|
557
|
+
return ge(e).map((e) => t.find((t) => t.id === e) ?? $e(e));
|
|
558
|
+
}
|
|
559
|
+
function rt(e, t) {
|
|
560
|
+
if (e.length !== 0) return t ? e.map((e) => e.id) : e[0]?.id;
|
|
561
|
+
}
|
|
562
|
+
// src/views/forms/renderer/member-field.tsx
|
|
563
|
+
function it({ multiple: e, name: t, onChange: n, placeholder: i, readonly: c, size: l, value: u }) {
|
|
564
|
+
let [d, f] = o([]), [p, m] = o([]), [h, g] = o(!1), _ = a(0), v = a(/* @__PURE__ */ new Set()), y = tt(u, d).join("\n");
|
|
565
|
+
r(() => {
|
|
566
|
+
let e = Ye(y ? y.split("\n") : [], v.current), t = !1;
|
|
567
|
+
return e.length === 0 ? () => void 0 : (Je(e, b).then(({ profiles: n, skippedIds: r }) => {
|
|
568
|
+
if (t) return;
|
|
569
|
+
let i = n.map(Qe), a = e.filter((e) => !i.some((t) => t.id === e)).map($e);
|
|
570
|
+
a.filter((e) => !r.includes(e.id)).forEach((e) => v.current.add(e.id)), f((e) => et(e, [...i, ...a]));
|
|
571
|
+
}), () => {
|
|
572
|
+
t = !0;
|
|
573
|
+
});
|
|
574
|
+
}, [y]);
|
|
575
|
+
async function C(e) {
|
|
576
|
+
let t = _.current + 1;
|
|
577
|
+
_.current = t, g(!0);
|
|
578
|
+
try {
|
|
579
|
+
let n = (await x(e)).map(Qe);
|
|
580
|
+
_.current === t && (m(n), f((e) => et(e, n)));
|
|
581
|
+
} catch {
|
|
582
|
+
_.current === t && m([]);
|
|
583
|
+
} finally {
|
|
584
|
+
_.current === t && g(!1);
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
let w = nt(u, d), T = [...et(w, p)], E = {
|
|
588
|
+
asyncData: !0,
|
|
589
|
+
clearSearchText: !0,
|
|
590
|
+
disabled: c,
|
|
591
|
+
disabledOptionsFilter: !0,
|
|
592
|
+
emptyText: "沒有符合的成員",
|
|
593
|
+
globalPortal: !0,
|
|
594
|
+
inputProps: {
|
|
595
|
+
autoCapitalize: "none",
|
|
596
|
+
autoCorrect: "off",
|
|
597
|
+
name: t,
|
|
598
|
+
spellCheck: !1
|
|
599
|
+
},
|
|
600
|
+
loading: h,
|
|
601
|
+
loadingText: "搜尋成員中...",
|
|
602
|
+
onSearch: C,
|
|
603
|
+
onVisibilityChange: (e) => {
|
|
604
|
+
e && (m([]), C(""));
|
|
605
|
+
},
|
|
606
|
+
options: T,
|
|
607
|
+
placeholder: i ?? "搜尋姓名或信箱",
|
|
608
|
+
readOnly: c,
|
|
609
|
+
searchDebounceTime: 300,
|
|
610
|
+
size: l
|
|
611
|
+
};
|
|
612
|
+
return e ? /* @__PURE__ */ S(s, {
|
|
613
|
+
...E,
|
|
614
|
+
mode: "multiple",
|
|
615
|
+
onChange: (e) => n(rt(e, !0)),
|
|
616
|
+
value: [...w]
|
|
617
|
+
}) : /* @__PURE__ */ S(s, {
|
|
618
|
+
...E,
|
|
619
|
+
mode: "single",
|
|
620
|
+
onChange: (e) => n(rt(e ? [e] : [], !1)),
|
|
621
|
+
value: w[0] ?? null
|
|
622
|
+
});
|
|
623
|
+
}
|
|
624
|
+
// src/views/forms/renderer/org-unit-field-options.ts
|
|
625
|
+
var at = "未知組織", ot = "(已刪除)";
|
|
626
|
+
function st(e) {
|
|
627
|
+
return {
|
|
628
|
+
id: e.id,
|
|
629
|
+
name: e.deleted ? `${e.name}${ot}` : e.name
|
|
630
|
+
};
|
|
631
|
+
}
|
|
632
|
+
function ct(e) {
|
|
633
|
+
return {
|
|
634
|
+
id: e,
|
|
635
|
+
name: e,
|
|
636
|
+
unresolved: !0
|
|
637
|
+
};
|
|
638
|
+
}
|
|
639
|
+
function lt(e) {
|
|
640
|
+
return {
|
|
641
|
+
id: e,
|
|
642
|
+
name: at,
|
|
643
|
+
unresolved: !0
|
|
644
|
+
};
|
|
645
|
+
}
|
|
646
|
+
function ut(e) {
|
|
647
|
+
return typeof e == "string" && e.trim() ? e : null;
|
|
648
|
+
}
|
|
649
|
+
function $(e) {
|
|
650
|
+
return e.toLowerCase();
|
|
651
|
+
}
|
|
652
|
+
function dt(e, t) {
|
|
653
|
+
return $(e) === $(t);
|
|
654
|
+
}
|
|
655
|
+
function ft(e, t) {
|
|
656
|
+
let n = ut(e);
|
|
657
|
+
return n === null ? null : t.find((e) => dt(e.id, n)) ?? ct(n);
|
|
658
|
+
}
|
|
659
|
+
function pt(e, t) {
|
|
660
|
+
let n = ut(e);
|
|
661
|
+
return n !== null && !t.some((e) => dt(e.id, n)) ? n : null;
|
|
662
|
+
}
|
|
663
|
+
function mt(e, t) {
|
|
664
|
+
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) => dt(t.id, e.id)) === n), a = e.map((e) => (e.unresolved ? n.get($(e.id)) : void 0) ?? e);
|
|
665
|
+
return i.length > 0 || a.some((t, n) => t !== e[n]) ? [...a, ...i] : e;
|
|
666
|
+
}
|
|
667
|
+
function ht(e) {
|
|
668
|
+
return e ? e.id : void 0;
|
|
669
|
+
}
|
|
670
|
+
// src/views/forms/renderer/org-unit-field.tsx
|
|
671
|
+
var gt = "搜尋組織失敗,請稍後再試。";
|
|
672
|
+
function _t({ name: e, onChange: t, placeholder: n, readonly: i, size: c, value: l }) {
|
|
673
|
+
let [u, d] = o([]), [f, p] = o([]), [m, h] = o(!1), [g, _] = o(!1), y = a(0), b = pt(l, u);
|
|
674
|
+
r(() => {
|
|
675
|
+
let e = !1;
|
|
676
|
+
return b === null ? () => void 0 : (_e([b]).then((e) => {
|
|
677
|
+
let t = e.map(st);
|
|
678
|
+
return t.some((e) => e.id.toLowerCase() === b.toLowerCase()) ? t : [...t, lt(b)];
|
|
679
|
+
}).catch(() => [lt(b)]).then((t) => {
|
|
680
|
+
e || d((e) => mt(e, t));
|
|
681
|
+
}), () => {
|
|
682
|
+
e = !0;
|
|
683
|
+
});
|
|
684
|
+
}, [b]);
|
|
685
|
+
async function x(e) {
|
|
686
|
+
let t = y.current + 1;
|
|
687
|
+
y.current = t, h(!0);
|
|
688
|
+
try {
|
|
689
|
+
let n = (await H(e)).map(st);
|
|
690
|
+
y.current === t && (p(n), _(!1), d((e) => mt(e, n)));
|
|
691
|
+
} catch {
|
|
692
|
+
y.current === t && (p([]), _(!0));
|
|
693
|
+
} finally {
|
|
694
|
+
y.current === t && h(!1);
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
let w = ft(l, u), T = [...mt(w ? [w] : [], f)];
|
|
698
|
+
return /* @__PURE__ */ C("div", { children: [/* @__PURE__ */ S(s, {
|
|
699
|
+
asyncData: !0,
|
|
700
|
+
clearSearchText: !0,
|
|
701
|
+
disabled: i,
|
|
702
|
+
disabledOptionsFilter: !0,
|
|
703
|
+
emptyText: "沒有符合的組織",
|
|
704
|
+
globalPortal: !0,
|
|
705
|
+
inputProps: {
|
|
706
|
+
autoCapitalize: "none",
|
|
707
|
+
autoCorrect: "off",
|
|
708
|
+
name: e,
|
|
709
|
+
spellCheck: !1
|
|
710
|
+
},
|
|
711
|
+
loading: m,
|
|
712
|
+
loadingText: "搜尋組織中...",
|
|
713
|
+
mode: "single",
|
|
714
|
+
onChange: (e) => t(ht(e ?? null)),
|
|
715
|
+
onSearch: x,
|
|
716
|
+
onVisibilityChange: (e) => {
|
|
717
|
+
e && (p([]), x(""));
|
|
718
|
+
},
|
|
719
|
+
options: T,
|
|
720
|
+
placeholder: n ?? "搜尋組織名稱",
|
|
721
|
+
readOnly: i,
|
|
722
|
+
searchDebounceTime: 300,
|
|
723
|
+
size: c,
|
|
724
|
+
value: w
|
|
725
|
+
}), g ? /* @__PURE__ */ S(v, {
|
|
726
|
+
color: "text-error",
|
|
727
|
+
variant: "caption",
|
|
728
|
+
children: gt
|
|
729
|
+
}) : null] });
|
|
730
|
+
}
|
|
731
|
+
// src/views/forms/renderer/FormRendererView.tsx
|
|
732
|
+
var vt = {
|
|
733
|
+
alignItems: "start",
|
|
734
|
+
display: "grid",
|
|
735
|
+
gap: 12,
|
|
736
|
+
gridTemplateColumns: "repeat(12, minmax(0, 1fr))"
|
|
737
|
+
}, yt = { gridColumn: "1 / -1" }, bt = {
|
|
738
|
+
alignItems: "start",
|
|
739
|
+
display: "grid",
|
|
740
|
+
gap: 8,
|
|
741
|
+
minWidth: 0
|
|
742
|
+
}, xt = {
|
|
743
|
+
minWidth: "100%",
|
|
744
|
+
width: "100%"
|
|
745
|
+
};
|
|
746
|
+
function St(e) {
|
|
747
|
+
e && (e.style.width = "100%");
|
|
748
|
+
}
|
|
749
|
+
function Ct({ attachments: e, dataSourceContext: t, dataSourceInitialValues: n, emptyText: s = "尚未建立欄位。", errors: c = {}, fieldAccess: l, fieldLabelMarkers: u, maxWidth: d, onChange: f, onDataSourceStateChange: p, onDownloadAttachment: m, onFileUploadStateChange: h, onUploadAttachment: g, optionSnapshots: _, readonly: y = !1, schema: b, singleColumn: x = !1, uiSchema: C, value: w }) {
|
|
750
|
+
let T = i(() => ({
|
|
751
|
+
attachments: e,
|
|
752
|
+
onDownloadAttachment: m,
|
|
753
|
+
onStateChange: h,
|
|
754
|
+
onUploadAttachment: g
|
|
755
|
+
}), [
|
|
756
|
+
e,
|
|
757
|
+
m,
|
|
758
|
+
h,
|
|
759
|
+
g
|
|
760
|
+
]), [D, O] = o(() => E(b.fields, w ?? {})), k = i(() => E(b.fields, w ?? D), [
|
|
761
|
+
D,
|
|
762
|
+
b.fields,
|
|
763
|
+
w
|
|
764
|
+
]), A = a(k), j = i(() => z(b, C, k).filter((e) => wt(l, e.fieldKey)?.visible !== !1), [
|
|
765
|
+
l,
|
|
766
|
+
b,
|
|
767
|
+
C,
|
|
768
|
+
k
|
|
769
|
+
]);
|
|
770
|
+
r(() => {
|
|
771
|
+
A.current = k;
|
|
772
|
+
}, [k]), r(() => {
|
|
773
|
+
O((e) => E(b.fields, w ?? e));
|
|
774
|
+
}, [b.fields, w]);
|
|
775
|
+
function M(e, t) {
|
|
776
|
+
let n = {
|
|
777
|
+
...A.current,
|
|
778
|
+
[e]: t
|
|
779
|
+
};
|
|
780
|
+
A.current = n, w || O(n), f?.(n);
|
|
781
|
+
}
|
|
782
|
+
return j.length ? /* @__PURE__ */ S("div", {
|
|
783
|
+
style: {
|
|
784
|
+
...vt,
|
|
785
|
+
...x ? { width: "100%" } : {}
|
|
786
|
+
},
|
|
787
|
+
children: j.map((e) => /* @__PURE__ */ S(Et, {
|
|
788
|
+
dataSourceContext: t,
|
|
789
|
+
dataSourceInitialValues: n,
|
|
790
|
+
field: e,
|
|
791
|
+
error: c[e.fieldKey] ?? null,
|
|
792
|
+
errors: c,
|
|
793
|
+
fields: b.fields,
|
|
794
|
+
labelMarker: u !== void 0 && Object.prototype.hasOwnProperty.call(u, e.fieldKey) ? u[e.fieldKey] : void 0,
|
|
795
|
+
onChange: M,
|
|
796
|
+
fileUpload: T,
|
|
797
|
+
onDataSourceStateChange: p,
|
|
798
|
+
optionSnapshots: _,
|
|
799
|
+
readonly: Tt(wt(l, e.fieldKey), y),
|
|
800
|
+
schema: b,
|
|
801
|
+
style: {
|
|
802
|
+
...bt,
|
|
803
|
+
gridColumn: `span ${x ? 12 : Kt(e, C)}`,
|
|
804
|
+
...x && !he(e) ? { maxWidth: d } : {}
|
|
805
|
+
},
|
|
806
|
+
value: k[e.fieldKey],
|
|
807
|
+
values: k,
|
|
808
|
+
uiSchema: C
|
|
809
|
+
}, e.fieldKey))
|
|
810
|
+
}) : /* @__PURE__ */ S("div", {
|
|
811
|
+
style: vt,
|
|
812
|
+
children: /* @__PURE__ */ S(v, {
|
|
813
|
+
color: "text-neutral",
|
|
814
|
+
style: yt,
|
|
815
|
+
variant: "body",
|
|
816
|
+
children: b.fields.length > 0 ? "目前條件下沒有可填寫欄位。" : s
|
|
817
|
+
})
|
|
818
|
+
});
|
|
819
|
+
}
|
|
820
|
+
function wt(e, t) {
|
|
821
|
+
return e !== void 0 && Object.prototype.hasOwnProperty.call(e, t) ? e[t] : void 0;
|
|
822
|
+
}
|
|
823
|
+
function Tt(e, t) {
|
|
824
|
+
return e === void 0 ? t : !e.editable;
|
|
825
|
+
}
|
|
826
|
+
function Et({ dataSourceContext: t, dataSourceInitialValues: n, error: i, errors: a, field: o, fields: s, fileUpload: l, labelMarker: u, onChange: d, onDataSourceStateChange: f, optionSnapshots: p, readonly: m, schema: h, style: g, value: _, values: y, uiSchema: b }) {
|
|
827
|
+
let x = M(o, s, y), w = m || j(o, s, y), T = W({
|
|
828
|
+
context: t,
|
|
829
|
+
field: o,
|
|
830
|
+
formData: y,
|
|
831
|
+
initialFormData: n,
|
|
832
|
+
initialValue: n?.[o.fieldKey],
|
|
833
|
+
optionSnapshots: p,
|
|
834
|
+
readonly: w,
|
|
835
|
+
schema: h,
|
|
836
|
+
uiSchema: b
|
|
837
|
+
}), E = ke(T), D = JSON.stringify({
|
|
838
|
+
hasValue: T.hasValue,
|
|
839
|
+
invalidValues: T.invalidValues,
|
|
840
|
+
selectionExpired: T.selectionExpired === !0,
|
|
841
|
+
status: T.status
|
|
842
|
+
});
|
|
843
|
+
return r(() => {
|
|
844
|
+
pe(o) && f?.(o.fieldKey, {
|
|
845
|
+
hasValue: T.hasValue,
|
|
846
|
+
invalidValues: T.invalidValues,
|
|
847
|
+
selectionExpired: T.selectionExpired === !0,
|
|
848
|
+
status: T.status
|
|
849
|
+
});
|
|
850
|
+
}, [
|
|
851
|
+
D,
|
|
852
|
+
o.fieldKey,
|
|
853
|
+
f
|
|
854
|
+
]), /* @__PURE__ */ C("div", {
|
|
855
|
+
"data-form-field-key": o.fieldKey,
|
|
856
|
+
style: g,
|
|
857
|
+
children: [
|
|
858
|
+
/* @__PURE__ */ S(e, {
|
|
859
|
+
label: o.label,
|
|
860
|
+
...u ? { labelOptionalMarker: u } : {},
|
|
861
|
+
name: o.fieldKey,
|
|
862
|
+
required: x,
|
|
863
|
+
children: he(o) ? /* @__PURE__ */ S(Lt, {
|
|
864
|
+
dataSourceContext: t,
|
|
865
|
+
dataSourceInitialValues: n,
|
|
866
|
+
errors: a,
|
|
867
|
+
field: o,
|
|
868
|
+
onChange: d,
|
|
869
|
+
onDataSourceStateChange: f,
|
|
870
|
+
optionSnapshots: p,
|
|
871
|
+
readonly: w,
|
|
872
|
+
schema: h,
|
|
873
|
+
uiSchema: b,
|
|
874
|
+
value: _,
|
|
875
|
+
values: y
|
|
876
|
+
}) : Ut(o, _, w, d, l, t, T)
|
|
877
|
+
}),
|
|
878
|
+
i ? /* @__PURE__ */ S(v, {
|
|
879
|
+
color: "text-error",
|
|
880
|
+
variant: "caption",
|
|
881
|
+
children: i
|
|
882
|
+
}) : null,
|
|
883
|
+
E ? /* @__PURE__ */ C("div", {
|
|
884
|
+
style: At,
|
|
885
|
+
children: [/* @__PURE__ */ S(v, {
|
|
886
|
+
color: T.status === "INVALID" || T.status === "UNAVAILABLE" ? "text-error" : "text-neutral",
|
|
887
|
+
variant: "caption",
|
|
888
|
+
children: E
|
|
889
|
+
}), T.status === "UNAVAILABLE" && T.canRetry ? /* @__PURE__ */ S(c, {
|
|
890
|
+
onClick: T.retry,
|
|
891
|
+
size: "sub",
|
|
892
|
+
type: "button",
|
|
893
|
+
variant: "base-ghost",
|
|
894
|
+
children: "重試"
|
|
895
|
+
}) : null]
|
|
896
|
+
}) : null
|
|
897
|
+
]
|
|
898
|
+
});
|
|
899
|
+
}
|
|
900
|
+
var Dt = "(另開新分頁)", Ot = "另開新分頁", kt = {
|
|
901
|
+
color: "inherit",
|
|
902
|
+
textDecoration: "underline",
|
|
903
|
+
wordBreak: "break-all"
|
|
904
|
+
}, At = {
|
|
905
|
+
alignItems: "center",
|
|
906
|
+
display: "flex",
|
|
907
|
+
gap: 8
|
|
908
|
+
}, jt = {
|
|
909
|
+
display: "grid",
|
|
910
|
+
gap: 8,
|
|
911
|
+
minWidth: 0,
|
|
912
|
+
width: "100%"
|
|
913
|
+
}, Mt = {
|
|
914
|
+
display: "flex",
|
|
915
|
+
justifyContent: "flex-start"
|
|
916
|
+
}, Nt = {
|
|
917
|
+
maxWidth: "100%",
|
|
918
|
+
overflowX: "auto"
|
|
919
|
+
}, Pt = 160, Ft = 56, It = {
|
|
920
|
+
display: "grid",
|
|
921
|
+
gap: 4,
|
|
922
|
+
minWidth: 0
|
|
923
|
+
};
|
|
924
|
+
function Lt({ dataSourceContext: e, dataSourceInitialValues: t, errors: n, field: i, onChange: s, onDataSourceStateChange: l, optionSnapshots: u, readonly: d, schema: f, uiSchema: p, value: m, values: g }) {
|
|
925
|
+
let _ = I(m), v = le(i), y = a(0), [b, x] = o(() => _.map(() => Bt(y)));
|
|
926
|
+
r(() => {
|
|
927
|
+
b.length !== _.length && x(_.map(() => Bt(y)));
|
|
928
|
+
}, [b.length, _.length]);
|
|
929
|
+
function E(e) {
|
|
930
|
+
s(i.fieldKey, e);
|
|
931
|
+
}
|
|
932
|
+
function D() {
|
|
933
|
+
x([...b, Bt(y)]), E([..._, O(i.columns)]);
|
|
934
|
+
}
|
|
935
|
+
function k(e) {
|
|
936
|
+
x(b.filter((t, n) => n !== e)), E(_.filter((t, n) => n !== e));
|
|
937
|
+
}
|
|
938
|
+
function A(e, t, n) {
|
|
939
|
+
E(_.map((r, i) => i === e ? Vt(r, t, n) : r));
|
|
940
|
+
}
|
|
941
|
+
let j = _.map((e, t) => ({
|
|
942
|
+
...e,
|
|
943
|
+
index: t,
|
|
944
|
+
key: b[t] ?? `row-${t}`
|
|
945
|
+
})), M = i.columns.map((r) => ({
|
|
946
|
+
key: r.fieldKey,
|
|
947
|
+
render: (a) => /* @__PURE__ */ S(Rt, {
|
|
948
|
+
column: r,
|
|
949
|
+
dataSourceContext: e,
|
|
950
|
+
error: n[ce(i.fieldKey, a.index, r.fieldKey)] ?? null,
|
|
951
|
+
fieldPath: `${i.fieldKey}.${r.fieldKey}`,
|
|
952
|
+
formData: g,
|
|
953
|
+
initialFormData: t,
|
|
954
|
+
initialRowValues: zt(t?.[i.fieldKey], a.index),
|
|
955
|
+
onChange: (e) => A(a.index, r.fieldKey, e),
|
|
956
|
+
onDataSourceStateChange: l,
|
|
957
|
+
optionSnapshots: u,
|
|
958
|
+
path: ce(i.fieldKey, a.index, r.fieldKey),
|
|
959
|
+
readonly: d,
|
|
960
|
+
rowValues: _[a.index] ?? {},
|
|
961
|
+
schema: f,
|
|
962
|
+
uiSchema: p
|
|
963
|
+
}, `${b[a.index] ?? a.index}-${r.fieldKey}`),
|
|
964
|
+
title: r.label || r.fieldKey
|
|
965
|
+
})), N = d ? void 0 : {
|
|
966
|
+
render: (e) => [{
|
|
967
|
+
disabled: () => _.length <= v.minRows,
|
|
968
|
+
icon: T,
|
|
969
|
+
iconType: "icon-only",
|
|
970
|
+
name: "刪除此列",
|
|
971
|
+
onClick: () => k(e.index),
|
|
972
|
+
variant: "destructive-ghost"
|
|
973
|
+
}],
|
|
974
|
+
width: 56
|
|
975
|
+
};
|
|
976
|
+
return /* @__PURE__ */ C("div", {
|
|
977
|
+
style: jt,
|
|
978
|
+
children: [/* @__PURE__ */ S("div", {
|
|
979
|
+
style: Nt,
|
|
980
|
+
children: /* @__PURE__ */ S("div", {
|
|
981
|
+
style: { minWidth: i.columns.length * Pt + (N ? Ft : 0) },
|
|
982
|
+
children: /* @__PURE__ */ S(h, {
|
|
983
|
+
...N ? { actions: N } : {},
|
|
984
|
+
columns: M,
|
|
985
|
+
dataSource: [...j],
|
|
986
|
+
rowHeightPreset: "roomy",
|
|
987
|
+
showHeader: !0,
|
|
988
|
+
size: "sub"
|
|
989
|
+
})
|
|
990
|
+
})
|
|
991
|
+
}), d ? null : /* @__PURE__ */ S("div", {
|
|
992
|
+
style: Mt,
|
|
993
|
+
children: /* @__PURE__ */ S(c, {
|
|
994
|
+
disabled: _.length >= v.maxRows,
|
|
995
|
+
icon: w,
|
|
996
|
+
iconType: "leading",
|
|
997
|
+
onClick: D,
|
|
998
|
+
size: "sub",
|
|
999
|
+
type: "button",
|
|
1000
|
+
variant: "base-secondary",
|
|
1001
|
+
children: i.addRowLabel || "新增一列"
|
|
1002
|
+
})
|
|
1003
|
+
})]
|
|
1004
|
+
});
|
|
1005
|
+
}
|
|
1006
|
+
function Rt({ column: e, dataSourceContext: t, error: n, fieldPath: i, formData: a, initialFormData: o, initialRowValues: s, onChange: l, onDataSourceStateChange: u, optionSnapshots: d, path: f, readonly: p, rowValues: m, schema: h, uiSchema: g }) {
|
|
1007
|
+
let _ = Ht(m, e.fieldKey), y = W({
|
|
1008
|
+
context: t,
|
|
1009
|
+
field: e,
|
|
1010
|
+
fieldPath: i,
|
|
1011
|
+
formData: a,
|
|
1012
|
+
initialFormData: o,
|
|
1013
|
+
initialValue: s ? Ht(s, e.fieldKey) : void 0,
|
|
1014
|
+
optionSnapshots: d,
|
|
1015
|
+
readonly: p,
|
|
1016
|
+
row: {
|
|
1017
|
+
initialValues: s,
|
|
1018
|
+
values: m
|
|
1019
|
+
},
|
|
1020
|
+
schema: h,
|
|
1021
|
+
snapshotKey: f,
|
|
1022
|
+
uiSchema: g
|
|
1023
|
+
}), b = ke(y), x = JSON.stringify({
|
|
1024
|
+
hasValue: y.hasValue,
|
|
1025
|
+
invalidValues: y.invalidValues,
|
|
1026
|
+
selectionExpired: y.selectionExpired === !0,
|
|
1027
|
+
status: y.status
|
|
1028
|
+
});
|
|
1029
|
+
return r(() => {
|
|
1030
|
+
if (pe(e)) return u?.(f, {
|
|
1031
|
+
hasValue: y.hasValue,
|
|
1032
|
+
invalidValues: y.invalidValues,
|
|
1033
|
+
selectionExpired: y.selectionExpired === !0,
|
|
1034
|
+
status: y.status
|
|
1035
|
+
}), () => {
|
|
1036
|
+
u?.(f, {
|
|
1037
|
+
hasValue: !1,
|
|
1038
|
+
invalidValues: [],
|
|
1039
|
+
status: "IDLE"
|
|
1040
|
+
});
|
|
1041
|
+
};
|
|
1042
|
+
}, [
|
|
1043
|
+
u,
|
|
1044
|
+
f,
|
|
1045
|
+
x
|
|
1046
|
+
]), /* @__PURE__ */ C("div", {
|
|
1047
|
+
"data-form-field-key": f,
|
|
1048
|
+
style: It,
|
|
1049
|
+
children: [
|
|
1050
|
+
Ut(e, _, p, (e, t) => l(t), void 0, t, y, "sub"),
|
|
1051
|
+
n ? /* @__PURE__ */ S(v, {
|
|
1052
|
+
color: "text-error",
|
|
1053
|
+
variant: "caption",
|
|
1054
|
+
children: n
|
|
1055
|
+
}) : null,
|
|
1056
|
+
b ? /* @__PURE__ */ C("div", {
|
|
1057
|
+
style: At,
|
|
1058
|
+
children: [/* @__PURE__ */ S(v, {
|
|
1059
|
+
color: y.status === "INVALID" || y.status === "UNAVAILABLE" ? "text-error" : "text-neutral",
|
|
1060
|
+
variant: "caption",
|
|
1061
|
+
children: b
|
|
1062
|
+
}), y.status === "UNAVAILABLE" && y.canRetry ? /* @__PURE__ */ S(c, {
|
|
1063
|
+
onClick: y.retry,
|
|
1064
|
+
size: "sub",
|
|
1065
|
+
type: "button",
|
|
1066
|
+
variant: "base-ghost",
|
|
1067
|
+
children: "重試"
|
|
1068
|
+
}) : null]
|
|
1069
|
+
}) : null
|
|
1070
|
+
]
|
|
1071
|
+
});
|
|
1072
|
+
}
|
|
1073
|
+
function zt(e, t) {
|
|
1074
|
+
return I(e)[t];
|
|
1075
|
+
}
|
|
1076
|
+
function Bt(e) {
|
|
1077
|
+
return e.current += 1, `table-row-${e.current}`;
|
|
1078
|
+
}
|
|
1079
|
+
function Vt(e, t, n) {
|
|
1080
|
+
return n === void 0 || !me(n) ? Object.fromEntries(Object.entries(e).filter(([e]) => e !== t)) : {
|
|
1081
|
+
...e,
|
|
1082
|
+
[t]: n
|
|
1083
|
+
};
|
|
1084
|
+
}
|
|
1085
|
+
function Ht(e, t) {
|
|
1086
|
+
if (e && Object.prototype.hasOwnProperty.call(e, t)) return e[t];
|
|
1087
|
+
}
|
|
1088
|
+
function Ut(e, t, n, r, i, a, o, s = "main") {
|
|
1089
|
+
return pe(e) ? Gt(e, t, n, r, a, o, s) : Wt(e, t, n, r, i, s);
|
|
1090
|
+
}
|
|
1091
|
+
function Wt(e, t, n, r, i, a = "main") {
|
|
1092
|
+
let o = n && (e.type === "text" || e.type === "textarea") && e.displayAs === "link" ? We(t) : null;
|
|
1093
|
+
if (o) return /* @__PURE__ */ S(v, {
|
|
1094
|
+
color: "text-brand",
|
|
1095
|
+
component: "span",
|
|
1096
|
+
variant: "body",
|
|
1097
|
+
children: /* @__PURE__ */ S("a", {
|
|
1098
|
+
href: o.href,
|
|
1099
|
+
style: kt,
|
|
1100
|
+
...o.external ? {
|
|
1101
|
+
"aria-label": `${o.href}${Dt}`,
|
|
1102
|
+
rel: "noopener noreferrer",
|
|
1103
|
+
target: "_blank",
|
|
1104
|
+
title: Ot
|
|
1105
|
+
} : {},
|
|
1106
|
+
children: o.href
|
|
1107
|
+
})
|
|
1108
|
+
});
|
|
1109
|
+
if (e.type === "textarea") return /* @__PURE__ */ S(g, {
|
|
1110
|
+
onChange: (t) => r(e.fieldKey, t.target.value),
|
|
1111
|
+
placeholder: e.placeholder ?? "請輸入多行文字",
|
|
1112
|
+
readOnly: n,
|
|
1113
|
+
ref: St,
|
|
1114
|
+
rows: 3,
|
|
1115
|
+
style: xt,
|
|
1116
|
+
value: qt(t)
|
|
1117
|
+
});
|
|
1118
|
+
if (e.type === "boolean") return /* @__PURE__ */ S(_, {
|
|
1119
|
+
checked: t === !0,
|
|
1120
|
+
disabled: n,
|
|
1121
|
+
label: "啟用",
|
|
1122
|
+
onChange: (t) => r(e.fieldKey, t.target.checked),
|
|
1123
|
+
size: a
|
|
1124
|
+
});
|
|
1125
|
+
if (B(e) && e.type === "checkbox") {
|
|
1126
|
+
let i = e.options.map(P);
|
|
1127
|
+
return /* @__PURE__ */ S(m, {
|
|
1128
|
+
mode: "multiple",
|
|
1129
|
+
onChange: (t) => r(e.fieldKey, t?.length ? t.map((e) => e.id) : void 0),
|
|
1130
|
+
options: i,
|
|
1131
|
+
placeholder: e.placeholder ?? "請選擇一或多個選項",
|
|
1132
|
+
readOnly: n,
|
|
1133
|
+
size: a,
|
|
1134
|
+
value: i.filter((e) => K(t).includes(e.id))
|
|
1135
|
+
});
|
|
1136
|
+
}
|
|
1137
|
+
if (B(e)) {
|
|
1138
|
+
let i = e.options.map(P);
|
|
1139
|
+
return /* @__PURE__ */ S(m, {
|
|
1140
|
+
onChange: (t) => r(e.fieldKey, t?.id ?? void 0),
|
|
1141
|
+
options: i,
|
|
1142
|
+
placeholder: e.placeholder ?? "請選擇",
|
|
1143
|
+
readOnly: n,
|
|
1144
|
+
size: a,
|
|
1145
|
+
value: R(i, qt(t))
|
|
1146
|
+
});
|
|
1147
|
+
}
|
|
1148
|
+
return e.type === "member" ? /* @__PURE__ */ S(it, {
|
|
1149
|
+
multiple: e.multiple === !0,
|
|
1150
|
+
name: e.fieldKey,
|
|
1151
|
+
onChange: (t) => r(e.fieldKey, t),
|
|
1152
|
+
placeholder: e.placeholder,
|
|
1153
|
+
readonly: n,
|
|
1154
|
+
size: a,
|
|
1155
|
+
value: t
|
|
1156
|
+
}) : e.type === "org_unit" ? /* @__PURE__ */ S(_t, {
|
|
1157
|
+
name: e.fieldKey,
|
|
1158
|
+
onChange: (t) => r(e.fieldKey, t),
|
|
1159
|
+
placeholder: e.placeholder ?? Yt(e.type),
|
|
1160
|
+
readonly: n,
|
|
1161
|
+
size: a,
|
|
1162
|
+
value: t
|
|
1163
|
+
}) : e.type === "file_upload" ? /* @__PURE__ */ S(Y, {
|
|
1164
|
+
attachments: i?.attachments,
|
|
1165
|
+
field: e,
|
|
1166
|
+
onChange: (t) => r(e.fieldKey, t),
|
|
1167
|
+
onDownloadAttachment: i?.onDownloadAttachment,
|
|
1168
|
+
onStateChange: (t) => i?.onStateChange?.(e.fieldKey, t),
|
|
1169
|
+
onUploadAttachment: i?.onUploadAttachment,
|
|
1170
|
+
readonly: n,
|
|
1171
|
+
value: t
|
|
1172
|
+
}) : e.type === "date" ? /* @__PURE__ */ S(u, {
|
|
1173
|
+
format: "YYYY-MM-DD",
|
|
1174
|
+
fullWidth: !0,
|
|
1175
|
+
onChange: (t) => r(e.fieldKey, k(t)),
|
|
1176
|
+
placeholder: e.placeholder ?? Yt(e.type),
|
|
1177
|
+
readOnly: n,
|
|
1178
|
+
value: re(t)
|
|
1179
|
+
}) : e.type === "datetime" ? /* @__PURE__ */ S(d, {
|
|
1180
|
+
formatDate: "YYYY-MM-DD",
|
|
1181
|
+
formatTime: "HH:mm",
|
|
1182
|
+
fullWidth: !0,
|
|
1183
|
+
hideSecond: !0,
|
|
1184
|
+
onChange: (t) => r(e.fieldKey, A(t)),
|
|
1185
|
+
placeholderLeft: "選擇日期",
|
|
1186
|
+
placeholderRight: "選擇時間",
|
|
1187
|
+
readOnly: n,
|
|
1188
|
+
value: re(t)
|
|
1189
|
+
}) : e.type === "number" || e.type === "money" ? /* @__PURE__ */ S(f, {
|
|
1190
|
+
fullWidth: !0,
|
|
1191
|
+
max: e.maximum,
|
|
1192
|
+
min: e.minimum,
|
|
1193
|
+
size: a,
|
|
1194
|
+
onChange: (t) => r(e.fieldKey, D(ee(t.target.value), {
|
|
1195
|
+
max: e.maximum,
|
|
1196
|
+
min: e.minimum
|
|
1197
|
+
})),
|
|
1198
|
+
placeholder: e.placeholder ?? Yt(e.type),
|
|
1199
|
+
...n ? { readonly: !0 } : {},
|
|
1200
|
+
showSpinner: !0,
|
|
1201
|
+
value: Jt(t),
|
|
1202
|
+
variant: "measure"
|
|
1203
|
+
}) : /* @__PURE__ */ S(f, {
|
|
1204
|
+
fullWidth: !0,
|
|
1205
|
+
onChange: (t) => r(e.fieldKey, t.target.value),
|
|
1206
|
+
placeholder: e.placeholder ?? Yt(e.type),
|
|
1207
|
+
...n ? { readonly: !0 } : {},
|
|
1208
|
+
size: a,
|
|
1209
|
+
value: qt(t),
|
|
1210
|
+
variant: "base"
|
|
1211
|
+
});
|
|
1212
|
+
}
|
|
1213
|
+
function Gt(e, t, n, r, i, a, o = "main") {
|
|
1214
|
+
let c = a.options.map(P), u = de(t, a.options).map(P), d = a.status === "LOADING", f = a.status === "WAITING_FOR_DEPENDENCIES", h = !!i && !n, g = n || f, _ = n;
|
|
1215
|
+
return e.type === "autocomplete" ? V(e) === "multiple" ? /* @__PURE__ */ S(s, {
|
|
1216
|
+
asyncData: h,
|
|
1217
|
+
clearSearchText: !0,
|
|
1218
|
+
disabled: _,
|
|
1219
|
+
disabledOptionsFilter: h,
|
|
1220
|
+
globalPortal: !0,
|
|
1221
|
+
loading: d,
|
|
1222
|
+
mode: "multiple",
|
|
1223
|
+
onChange: (t) => r(e.fieldKey, t.length ? t.map((e) => e.id) : void 0),
|
|
1224
|
+
onReachBottom: a.hasNextPage ? a.onReachBottom : void 0,
|
|
1225
|
+
onSearch: h ? a.onSearch : void 0,
|
|
1226
|
+
options: c,
|
|
1227
|
+
placeholder: e.placeholder ?? "請輸入或選擇",
|
|
1228
|
+
readOnly: n,
|
|
1229
|
+
searchDebounceTime: 300,
|
|
1230
|
+
size: o,
|
|
1231
|
+
value: u
|
|
1232
|
+
}) : /* @__PURE__ */ S(s, {
|
|
1233
|
+
asyncData: h,
|
|
1234
|
+
clearSearchText: !0,
|
|
1235
|
+
disabled: _,
|
|
1236
|
+
disabledOptionsFilter: h,
|
|
1237
|
+
globalPortal: !0,
|
|
1238
|
+
loading: d,
|
|
1239
|
+
mode: "single",
|
|
1240
|
+
onChange: (t) => r(e.fieldKey, t?.id ?? void 0),
|
|
1241
|
+
onReachBottom: a.hasNextPage ? a.onReachBottom : void 0,
|
|
1242
|
+
onSearch: h ? a.onSearch : void 0,
|
|
1243
|
+
options: c,
|
|
1244
|
+
placeholder: e.placeholder ?? "請輸入或選擇",
|
|
1245
|
+
readOnly: n,
|
|
1246
|
+
searchDebounceTime: 300,
|
|
1247
|
+
size: o,
|
|
1248
|
+
value: u[0] ?? null
|
|
1249
|
+
}) : e.type === "radio" ? /* @__PURE__ */ S(p, {
|
|
1250
|
+
disabled: g,
|
|
1251
|
+
name: e.fieldKey,
|
|
1252
|
+
onChange: (t) => r(e.fieldKey, t.target.value || void 0),
|
|
1253
|
+
options: c,
|
|
1254
|
+
value: qt(t)
|
|
1255
|
+
}) : e.type === "checkbox" ? /* @__PURE__ */ S(l, {
|
|
1256
|
+
disabled: g,
|
|
1257
|
+
name: e.fieldKey,
|
|
1258
|
+
onChange: (t) => r(e.fieldKey, t.target.values.length ? t.target.values : void 0),
|
|
1259
|
+
options: c.map((e) => ({
|
|
1260
|
+
label: e.name,
|
|
1261
|
+
value: e.id
|
|
1262
|
+
})),
|
|
1263
|
+
value: [...K(t)]
|
|
1264
|
+
}) : V(e) === "multiple" ? /* @__PURE__ */ S(m, {
|
|
1265
|
+
disabled: g,
|
|
1266
|
+
loading: d,
|
|
1267
|
+
mode: "multiple",
|
|
1268
|
+
onChange: (t) => r(e.fieldKey, t.length ? t.map((e) => e.id) : void 0),
|
|
1269
|
+
onReachBottom: a.hasNextPage ? a.onReachBottom : void 0,
|
|
1270
|
+
options: c,
|
|
1271
|
+
placeholder: e.placeholder ?? "請選擇一或多個選項",
|
|
1272
|
+
readOnly: n,
|
|
1273
|
+
size: o,
|
|
1274
|
+
value: u
|
|
1275
|
+
}) : /* @__PURE__ */ S(m, {
|
|
1276
|
+
disabled: g,
|
|
1277
|
+
loading: d,
|
|
1278
|
+
onChange: (t) => r(e.fieldKey, t?.id ?? void 0),
|
|
1279
|
+
onReachBottom: a.hasNextPage ? a.onReachBottom : void 0,
|
|
1280
|
+
options: c,
|
|
1281
|
+
placeholder: e.placeholder ?? "請選擇",
|
|
1282
|
+
readOnly: n,
|
|
1283
|
+
size: o,
|
|
1284
|
+
value: u[0] ?? null
|
|
1285
|
+
});
|
|
1286
|
+
}
|
|
1287
|
+
function Kt(e, t) {
|
|
1288
|
+
return {
|
|
1289
|
+
FULL: 12,
|
|
1290
|
+
HALF: 6,
|
|
1291
|
+
THIRD: 4
|
|
1292
|
+
}[t.layout.find((t) => t.fieldKey === e.fieldKey)?.width ?? "FULL"];
|
|
1293
|
+
}
|
|
1294
|
+
function qt(e) {
|
|
1295
|
+
return typeof e == "string" ? e : "";
|
|
1296
|
+
}
|
|
1297
|
+
function Jt(e) {
|
|
1298
|
+
return typeof e == "number" ? String(e) : "";
|
|
1299
|
+
}
|
|
1300
|
+
function Yt(e) {
|
|
1301
|
+
return {
|
|
1302
|
+
boolean: "",
|
|
1303
|
+
autocomplete: "請輸入或選擇",
|
|
1304
|
+
checkbox: "請選擇一或多個選項",
|
|
1305
|
+
date: "請選擇日期",
|
|
1306
|
+
datetime: "請選擇日期與時間",
|
|
1307
|
+
file_upload: "請上傳附件",
|
|
1308
|
+
member: "搜尋姓名或信箱",
|
|
1309
|
+
money: "請輸入金額",
|
|
1310
|
+
number: "請輸入數字",
|
|
1311
|
+
org_unit: "搜尋組織名稱",
|
|
1312
|
+
radio: "請選擇一個選項",
|
|
1313
|
+
select: "請選擇一個選項",
|
|
1314
|
+
table: "",
|
|
1315
|
+
text: "請輸入文字",
|
|
1316
|
+
textarea: "請輸入多行文字"
|
|
1317
|
+
}[e];
|
|
1318
|
+
}
|
|
1319
|
+
export { q as a, ke as c, Je as i, Ae as l, st as n, J as o, Ye as r, G as s, Ct as t, W as u };
|
|
1320
|
+
|
|
1321
|
+
//# sourceMappingURL=FormRendererView-GfbVWEGa.js.map
|