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