@rytass/bpm-core-react 0.8.0 → 0.9.1

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.
Files changed (154) hide show
  1. package/CHANGELOG.md +93 -0
  2. package/README.md +18 -2
  3. package/dist/chunks/FormBuilderView-BPLwAJGv.cjs +3 -0
  4. package/dist/chunks/FormBuilderView-BPLwAJGv.cjs.map +1 -0
  5. package/dist/chunks/FormBuilderView-Do9-MIAe.js +1477 -0
  6. package/dist/chunks/FormBuilderView-Do9-MIAe.js.map +1 -0
  7. package/dist/chunks/FormRendererView-C5POZbWz.js +492 -0
  8. package/dist/chunks/FormRendererView-C5POZbWz.js.map +1 -0
  9. package/dist/chunks/FormRendererView-DNtNodNl.cjs +2 -0
  10. package/dist/chunks/FormRendererView-DNtNodNl.cjs.map +1 -0
  11. package/dist/chunks/{approval-instance-list-page-YZcGGDD8.js → approval-instance-list-page-BjX2kaoF.js} +56 -54
  12. package/dist/chunks/approval-instance-list-page-BjX2kaoF.js.map +1 -0
  13. package/dist/chunks/approval-instance-list-page-C408vxE2.cjs +2 -0
  14. package/dist/chunks/approval-instance-list-page-C408vxE2.cjs.map +1 -0
  15. package/dist/chunks/{categories-DBPoSrsi.js → categories-DGlxuC6X.js} +5 -5
  16. package/dist/chunks/{categories-DBPoSrsi.js.map → categories-DGlxuC6X.js.map} +1 -1
  17. package/dist/chunks/{categories-B6QZKZRt.cjs → categories-DUfldZ_9.cjs} +2 -2
  18. package/dist/chunks/{categories-B6QZKZRt.cjs.map → categories-DUfldZ_9.cjs.map} +1 -1
  19. package/dist/chunks/compose-CULMDsLS.cjs +2 -0
  20. package/dist/chunks/compose-CULMDsLS.cjs.map +1 -0
  21. package/dist/chunks/{compose-CQHDT7vh.js → compose-DJBlA5PD.js} +60 -58
  22. package/dist/chunks/compose-DJBlA5PD.js.map +1 -0
  23. package/dist/chunks/{delegations-DDEk-WI6.cjs → delegations-CGj-tZNO.cjs} +2 -2
  24. package/dist/chunks/{delegations-DDEk-WI6.cjs.map → delegations-CGj-tZNO.cjs.map} +1 -1
  25. package/dist/chunks/{delegations-iVnRi3QE.js → delegations-DLEEFBlH.js} +231 -231
  26. package/dist/chunks/{delegations-iVnRi3QE.js.map → delegations-DLEEFBlH.js.map} +1 -1
  27. package/dist/chunks/{delegations-ZNtodFaD.js → delegations-DqMpI_Nk.js} +168 -167
  28. package/dist/chunks/delegations-DqMpI_Nk.js.map +1 -0
  29. package/dist/chunks/delegations-kbMOSEif.cjs +2 -0
  30. package/dist/chunks/delegations-kbMOSEif.cjs.map +1 -0
  31. package/dist/chunks/{designer-CUbVXEtS.js → designer-BszXJ5RO.js} +1227 -990
  32. package/dist/chunks/designer-BszXJ5RO.js.map +1 -0
  33. package/dist/chunks/designer-CmqAU92b.cjs +65 -0
  34. package/dist/chunks/designer-CmqAU92b.cjs.map +1 -0
  35. package/dist/chunks/detail-CDexqBoU.cjs +2 -0
  36. package/dist/chunks/detail-CDexqBoU.cjs.map +1 -0
  37. package/dist/chunks/{detail-Cts5_gVp.js → detail-DAak2OXS.js} +704 -622
  38. package/dist/chunks/detail-DAak2OXS.js.map +1 -0
  39. package/dist/chunks/notifications--hwl-DR0.cjs +2 -0
  40. package/dist/chunks/{notifications-BKs4--96.cjs.map → notifications--hwl-DR0.cjs.map} +1 -1
  41. package/dist/chunks/{notifications-CSulztkU.js → notifications-DJ5wzCye.js} +7 -7
  42. package/dist/chunks/{notifications-CSulztkU.js.map → notifications-DJ5wzCye.js.map} +1 -1
  43. package/dist/chunks/{orgs-CrNxqlwp.js → orgs-DytLvZ_X.js} +243 -241
  44. package/dist/chunks/{orgs-CrNxqlwp.js.map → orgs-DytLvZ_X.js.map} +1 -1
  45. package/dist/chunks/orgs-Ni22buHs.cjs +2 -0
  46. package/dist/chunks/orgs-Ni22buHs.cjs.map +1 -0
  47. package/dist/chunks/providers-DEqcuXw9.js +506 -0
  48. package/dist/chunks/providers-DEqcuXw9.js.map +1 -0
  49. package/dist/chunks/providers-D_zTbkQH.cjs +2 -0
  50. package/dist/chunks/providers-D_zTbkQH.cjs.map +1 -0
  51. package/dist/chunks/{users-qghSMtLn.cjs → users-0HqlM_VQ.cjs} +2 -2
  52. package/dist/chunks/{users-qghSMtLn.cjs.map → users-0HqlM_VQ.cjs.map} +1 -1
  53. package/dist/chunks/{users-CUY139DF.js → users-FWrb3ehW.js} +5 -5
  54. package/dist/chunks/{users-CUY139DF.js.map → users-FWrb3ehW.js.map} +1 -1
  55. package/dist/components/notification-drawer.d.ts +4 -3
  56. package/dist/index.cjs +1 -1
  57. package/dist/index.cjs.map +1 -1
  58. package/dist/index.js +21 -428
  59. package/dist/index.js.map +1 -1
  60. package/dist/next/index.cjs +1 -1
  61. package/dist/next/index.cjs.map +1 -1
  62. package/dist/next/index.js +16 -15
  63. package/dist/next/index.js.map +1 -1
  64. package/dist/pages/admin/delegations/index.cjs +1 -1
  65. package/dist/pages/admin/delegations/index.js +1 -1
  66. package/dist/pages/admin/orgs/index.cjs +1 -1
  67. package/dist/pages/admin/orgs/index.js +1 -1
  68. package/dist/pages/admin/users/index.cjs +1 -1
  69. package/dist/pages/admin/users/index.js +1 -1
  70. package/dist/pages/delegations/index.cjs +1 -1
  71. package/dist/pages/delegations/index.js +1 -1
  72. package/dist/pages/instances/detail/index.cjs +1 -1
  73. package/dist/pages/instances/detail/index.js +1 -1
  74. package/dist/pages/settings/notifications/index.cjs +1 -1
  75. package/dist/pages/settings/notifications/index.js +1 -1
  76. package/dist/pages/templates/categories/index.cjs +1 -1
  77. package/dist/pages/templates/categories/index.js +1 -1
  78. package/dist/pages/templates/compose/index.cjs +1 -1
  79. package/dist/pages/templates/compose/index.js +1 -1
  80. package/dist/pages/templates/designer/index.cjs +1 -1
  81. package/dist/pages/templates/designer/index.js +1 -1
  82. package/dist/views/admin/delegations/index.cjs +1 -1
  83. package/dist/views/admin/delegations/index.js +1 -1
  84. package/dist/views/admin/index.cjs +1 -1
  85. package/dist/views/admin/index.js +3 -3
  86. package/dist/views/admin/orgs/index.cjs +1 -1
  87. package/dist/views/admin/orgs/index.js +1 -1
  88. package/dist/views/admin/users/index.cjs +1 -1
  89. package/dist/views/admin/users/index.js +1 -1
  90. package/dist/views/cc/index.cjs +1 -1
  91. package/dist/views/cc/index.js +1 -1
  92. package/dist/views/delegations/index.cjs +1 -1
  93. package/dist/views/delegations/index.js +1 -1
  94. package/dist/views/forms/builder/index.cjs +1 -1
  95. package/dist/views/forms/builder/index.js +1 -1
  96. package/dist/views/forms/renderer/FormRendererView.d.ts +7 -2
  97. package/dist/views/forms/renderer/form-data-source-field.d.ts +34 -0
  98. package/dist/views/forms/renderer/index.cjs +1 -1
  99. package/dist/views/forms/renderer/index.d.ts +1 -0
  100. package/dist/views/forms/renderer/index.js +2 -2
  101. package/dist/views/instances/detail/index.cjs +1 -1
  102. package/dist/views/instances/detail/index.js +1 -1
  103. package/dist/views/instances/detail/sections/InstanceFormSection.d.ts +4 -1
  104. package/dist/views/instances/detail/sections/InstanceTasksSection.d.ts +5 -1
  105. package/dist/views/instances/new/index.cjs +1 -1
  106. package/dist/views/instances/new/index.cjs.map +1 -1
  107. package/dist/views/instances/new/index.js +105 -86
  108. package/dist/views/instances/new/index.js.map +1 -1
  109. package/dist/views/search/index.cjs +1 -1
  110. package/dist/views/search/index.js +1 -1
  111. package/dist/views/sent/index.cjs +1 -1
  112. package/dist/views/sent/index.js +1 -1
  113. package/dist/views/settings/index.cjs +1 -1
  114. package/dist/views/settings/index.js +1 -1
  115. package/dist/views/settings/notifications/index.cjs +1 -1
  116. package/dist/views/settings/notifications/index.js +1 -1
  117. package/dist/views/templates/categories/index.cjs +1 -1
  118. package/dist/views/templates/categories/index.js +1 -1
  119. package/dist/views/templates/compose/TemplateComposeWizardView.d.ts +3 -2
  120. package/dist/views/templates/compose/index.cjs +1 -1
  121. package/dist/views/templates/compose/index.js +1 -1
  122. package/dist/views/templates/designer/index.cjs +1 -1
  123. package/dist/views/templates/designer/index.js +1 -1
  124. package/dist/views/templates/index.cjs +1 -1
  125. package/dist/views/templates/index.cjs.map +1 -1
  126. package/dist/views/templates/index.js +153 -112
  127. package/dist/views/templates/index.js.map +1 -1
  128. package/package.json +56 -11
  129. package/dist/chunks/FormBuilderView-B_KGPjlp.cjs +0 -3
  130. package/dist/chunks/FormBuilderView-B_KGPjlp.cjs.map +0 -1
  131. package/dist/chunks/FormBuilderView-D8DrQOXD.js +0 -1090
  132. package/dist/chunks/FormBuilderView-D8DrQOXD.js.map +0 -1
  133. package/dist/chunks/FormRendererView-BwVsH2eX.cjs +0 -2
  134. package/dist/chunks/FormRendererView-BwVsH2eX.cjs.map +0 -1
  135. package/dist/chunks/FormRendererView-DrHsuSVo.js +0 -220
  136. package/dist/chunks/FormRendererView-DrHsuSVo.js.map +0 -1
  137. package/dist/chunks/approval-instance-list-page-BMUKxzcz.cjs +0 -2
  138. package/dist/chunks/approval-instance-list-page-BMUKxzcz.cjs.map +0 -1
  139. package/dist/chunks/approval-instance-list-page-YZcGGDD8.js.map +0 -1
  140. package/dist/chunks/compose-CQHDT7vh.js.map +0 -1
  141. package/dist/chunks/compose-Ds_cAefe.cjs +0 -2
  142. package/dist/chunks/compose-Ds_cAefe.cjs.map +0 -1
  143. package/dist/chunks/delegations-C2wLWsDQ.cjs +0 -2
  144. package/dist/chunks/delegations-C2wLWsDQ.cjs.map +0 -1
  145. package/dist/chunks/delegations-ZNtodFaD.js.map +0 -1
  146. package/dist/chunks/designer-CQ9hxSdD.cjs +0 -65
  147. package/dist/chunks/designer-CQ9hxSdD.cjs.map +0 -1
  148. package/dist/chunks/designer-CUbVXEtS.js.map +0 -1
  149. package/dist/chunks/detail-B-Q4W-iw.cjs +0 -2
  150. package/dist/chunks/detail-B-Q4W-iw.cjs.map +0 -1
  151. package/dist/chunks/detail-Cts5_gVp.js.map +0 -1
  152. package/dist/chunks/notifications-BKs4--96.cjs +0 -2
  153. package/dist/chunks/orgs-iNJ0QEcK.cjs +0 -2
  154. package/dist/chunks/orgs-iNJ0QEcK.cjs.map +0 -1
@@ -0,0 +1,1477 @@
1
+ "use client";
2
+ import { t as e } from "./bpm-form-field-Cao0rMol.js";
3
+ import { t } from "./FormRendererView-C5POZbWz.js";
4
+ import { useEffect as n, useMemo as r, useState as i } from "react";
5
+ import { Accordion as a, Badge as o, BaseCard as ee, Button as s, DatePicker as c, DateTimePicker as te, Icon as l, Input as u, Modal as ne, Section as re, SectionGroup as ie, Select as d, Tab as ae, TabItem as f, Table as oe, Textarea as se, Toggle as ce, Typography as p } from "@mezzanine-ui/react";
6
+ import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
7
+ import { AlignLeftIcon as le, CalendarIcon as _, CheckedIcon as v, CheckedOutlineIcon as ue, CurrencyDollarIcon as y, DotDragVerticalIcon as de, DotGridIcon as b, FileAttachmentIcon as x, FileIcon as S, ListIcon as fe, PlusIcon as pe, TrashIcon as me } from "@mezzanine-ui/icons";
8
+ import { buildConditionExpression as C, buildFormRendererValues as he, clampOptionalNumber as ge, createFieldDefinition as _e, formatDatePickerValue as ve, formatDateTimePickerValue as ye, isDateFieldDefinition as be, isFormDataSourceDescriptorCompatible as xe, isNumberFieldDefinition as Se, isSelectFieldDefinition as Ce, lintFormSchema as we, listFormDataSources as Te, parseConditionRule as Ee, parseOptionalNumberInput as De, readCompatibleFormDataSourceBindingFields as Oe, readCompatibleFormDataSourceDescriptors as ke, readConditionOperatorOption as Ae, readConditionOperatorOptions as je, readDatePickerValue as Me, readDefaultConditionOperator as Ne, readDefaultConditionValue as w, readFieldOptionAsSelectOption as Pe, readFormDataSourceBinding as Fe, readFormDataSourceBindingValue as Ie, readFormDataSourceBindingValueKind as Le, readFormDataSourceFieldDependencyKeys as Re, readFormSchemaLintMessage as ze, readSelectOption as T, renameFormDataSourceFieldBindings as Be, upsertFormDataSourceFieldBinding as E } from "@rytass/bpm-core-client/form";
9
+ import { isFormDataSourceFieldDefinition as D, isFormOptionFieldDefinition as Ve, readFormFieldSelectionMode as O } from "@rytass/bpm-core-shared/form";
10
+ import { DragDropContext as He, Draggable as Ue, Droppable as We } from "@hello-pangea/dnd";
11
+ import k from "next/dynamic";
12
+ import { json as Ge } from "@codemirror/lang-json";
13
+ import { EditorView as A } from "@codemirror/view";
14
+ //#region src/views/forms/builder/json-code-editor.tsx
15
+ var Ke = {
16
+ alignItems: "center",
17
+ border: "1px solid var(--mzn-color-border-neutral)",
18
+ borderRadius: 4,
19
+ color: "var(--mzn-color-text-neutral)",
20
+ display: "flex",
21
+ minHeight: 160,
22
+ padding: 12,
23
+ width: "100%"
24
+ }, j = [
25
+ Ge(),
26
+ A.lineWrapping,
27
+ A.theme({
28
+ "&": {
29
+ border: "1px solid var(--mzn-color-border-neutral)",
30
+ borderRadius: "4px",
31
+ fontSize: "13px",
32
+ width: "100%"
33
+ },
34
+ "&.cm-focused": { outline: "1px solid var(--mzn-color-border-primary)" },
35
+ ".cm-content": {
36
+ fontFamily: "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", monospace",
37
+ minHeight: "100%"
38
+ },
39
+ ".cm-editor": { width: "100%" },
40
+ ".cm-gutters": { borderRight: "1px solid var(--mzn-color-border-neutral)" },
41
+ ".cm-scroller": { fontFamily: "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", monospace" }
42
+ })
43
+ ], M = k(() => import("@uiw/react-codemirror"), {
44
+ loading: () => /* @__PURE__ */ h("div", {
45
+ style: Ke,
46
+ children: "載入 JSON 編輯器"
47
+ }),
48
+ ssr: !1
49
+ });
50
+ function qe({ disabled: e = !1, height: t, name: n, onChange: r, placeholder: i, value: a }) {
51
+ return /* @__PURE__ */ h(M, {
52
+ "aria-label": n,
53
+ basicSetup: {
54
+ autocompletion: !0,
55
+ bracketMatching: !0,
56
+ closeBrackets: !0,
57
+ defaultKeymap: !0,
58
+ foldGutter: !0,
59
+ highlightActiveLine: !0,
60
+ highlightSelectionMatches: !0,
61
+ lineNumbers: !0,
62
+ syntaxHighlighting: !0
63
+ },
64
+ editable: !e,
65
+ extensions: [...j],
66
+ height: t,
67
+ indentWithTab: !1,
68
+ onChange: r,
69
+ placeholder: i,
70
+ readOnly: e,
71
+ theme: "light",
72
+ value: a,
73
+ width: "100%"
74
+ });
75
+ }
76
+ //#endregion
77
+ //#region src/views/forms/builder/FormBuilderView.tsx
78
+ var Je = [
79
+ {
80
+ description: "單行文字、姓名、編號",
81
+ icon: le,
82
+ label: "文字",
83
+ type: "text"
84
+ },
85
+ {
86
+ description: "多行補充內容",
87
+ icon: S,
88
+ label: "長文字",
89
+ type: "textarea"
90
+ },
91
+ {
92
+ description: "金額、數量、分數",
93
+ icon: y,
94
+ label: "數字",
95
+ type: "number"
96
+ },
97
+ {
98
+ description: "金額與費用",
99
+ icon: y,
100
+ label: "金額",
101
+ type: "money"
102
+ },
103
+ {
104
+ description: "日期或到期日",
105
+ icon: _,
106
+ label: "日期",
107
+ type: "date"
108
+ },
109
+ {
110
+ description: "日期與時間",
111
+ icon: _,
112
+ label: "日期時間",
113
+ type: "datetime"
114
+ },
115
+ {
116
+ description: "是 / 否狀態",
117
+ icon: v,
118
+ label: "開關",
119
+ type: "boolean"
120
+ },
121
+ {
122
+ description: "固定選項擇一",
123
+ icon: fe,
124
+ label: "下拉選單",
125
+ type: "select"
126
+ },
127
+ {
128
+ description: "可搜尋的固定選項",
129
+ icon: fe,
130
+ label: "自動完成",
131
+ type: "autocomplete"
132
+ },
133
+ {
134
+ description: "固定選項單選",
135
+ icon: b,
136
+ label: "單選",
137
+ type: "radio"
138
+ },
139
+ {
140
+ description: "固定選項複選",
141
+ icon: ue,
142
+ label: "複選",
143
+ type: "checkbox"
144
+ },
145
+ {
146
+ description: "附件或佐證資料",
147
+ icon: x,
148
+ label: "附件",
149
+ type: "file_upload"
150
+ }
151
+ ], Ye = {
152
+ alignItems: "start",
153
+ display: "flex",
154
+ flexWrap: "wrap",
155
+ gap: 16
156
+ }, Xe = {
157
+ flex: "0.55 1 300px",
158
+ minWidth: 0
159
+ }, Ze = {
160
+ flex: "1.45 1 720px",
161
+ minWidth: 620
162
+ }, N = {
163
+ display: "grid",
164
+ gap: 12
165
+ }, Qe = {
166
+ display: "flex",
167
+ flexWrap: "wrap",
168
+ gap: 6
169
+ }, $e = {
170
+ flex: "0 0 auto",
171
+ whiteSpace: "nowrap"
172
+ }, et = {
173
+ display: "grid",
174
+ gap: 8
175
+ }, tt = {
176
+ alignItems: "center",
177
+ cursor: "grab",
178
+ display: "flex",
179
+ gap: 12,
180
+ touchAction: "none"
181
+ }, nt = {
182
+ display: "grid",
183
+ flex: "1 1 auto",
184
+ gap: 2,
185
+ minWidth: 0
186
+ }, rt = {
187
+ alignItems: "center",
188
+ display: "flex",
189
+ flex: "0 0 auto",
190
+ gap: 4
191
+ }, it = {
192
+ alignItems: "center",
193
+ display: "flex",
194
+ gap: 6
195
+ }, at = {
196
+ cursor: "pointer",
197
+ userSelect: "none"
198
+ }, ot = { filter: "drop-shadow(0 8px 18px rgba(0, 0, 0, 0.12))" }, st = {
199
+ backgroundColor: "color-mix(in srgb, var(--mzn-color-primary) 8%, var(--mzn-color-bg-surface))",
200
+ boxShadow: "inset 0 0 0 1px var(--mzn-color-border-primary)"
201
+ }, ct = {
202
+ alignItems: "center",
203
+ border: "1px dashed var(--mzn-color-border-neutral)",
204
+ borderRadius: 6,
205
+ display: "grid",
206
+ gap: 12,
207
+ minHeight: 240,
208
+ padding: 32,
209
+ textAlign: "center"
210
+ }, lt = {
211
+ display: "flex",
212
+ gap: 8,
213
+ justifyContent: "center"
214
+ }, ut = {
215
+ display: "grid",
216
+ gap: 14
217
+ }, dt = {
218
+ display: "grid",
219
+ columnGap: 16,
220
+ gridTemplateColumns: "repeat(auto-fit, minmax(280px, 1fr))",
221
+ rowGap: 8
222
+ }, ft = { gridColumn: "1 / -1" }, pt = {
223
+ alignItems: "center",
224
+ display: "flex",
225
+ gap: 8,
226
+ gridColumn: "1 / -1",
227
+ justifyContent: "flex-end"
228
+ }, mt = { gridColumn: "1 / -1" }, ht = {
229
+ alignItems: "start",
230
+ display: "block",
231
+ width: "100%"
232
+ }, gt = {
233
+ ...ht,
234
+ gridColumn: "1 / -1"
235
+ }, _t = {
236
+ minWidth: 0,
237
+ width: "100%"
238
+ }, vt = {
239
+ minWidth: "100%",
240
+ width: "100%"
241
+ }, yt = {
242
+ display: "grid",
243
+ gap: 14
244
+ }, bt = {
245
+ alignItems: "start",
246
+ display: "block",
247
+ width: "100%"
248
+ }, xt = {
249
+ minWidth: 0,
250
+ width: "100%"
251
+ }, St = { gridColumn: "2 / -1" }, Ct = {
252
+ display: "grid",
253
+ gap: 10,
254
+ width: "100%"
255
+ }, wt = {
256
+ display: "grid",
257
+ gap: 8,
258
+ gridTemplateColumns: "repeat(auto-fit, minmax(160px, 1fr))"
259
+ }, Tt = { display: "inline-flex" }, Et = {
260
+ display: "grid",
261
+ gap: 16
262
+ }, Dt = {
263
+ display: "grid",
264
+ gap: 8
265
+ }, Ot = {
266
+ display: "flex",
267
+ justifyContent: "flex-end"
268
+ }, kt = {
269
+ color: "var(--mzn-color-text-error)",
270
+ fontSize: "0.72em",
271
+ lineHeight: 0,
272
+ marginLeft: 2,
273
+ verticalAlign: "super"
274
+ }, At = {
275
+ display: "grid",
276
+ gap: 10,
277
+ gridColumn: "1 / -1"
278
+ }, jt = {
279
+ backgroundColor: "var(--mzn-color-bg-surface-secondary)",
280
+ borderRadius: 6,
281
+ display: "grid",
282
+ gap: 4,
283
+ padding: 10
284
+ }, Mt = {
285
+ display: "grid",
286
+ gap: 8,
287
+ gridTemplateColumns: "minmax(180px, 0.7fr) minmax(220px, 1.3fr)"
288
+ };
289
+ function Nt(e) {
290
+ e && (e.style.width = "100%");
291
+ }
292
+ var Pt = {
293
+ fields: [],
294
+ schemaVersion: 1
295
+ }, Ft = {
296
+ layout: [],
297
+ schemaVersion: 1
298
+ }, P = "__STATIC_OPTIONS__", It = "__CONSTANT__", Lt = "__UNBOUND__", Rt = [{
299
+ id: P,
300
+ name: "靜態選項"
301
+ }], zt = [{
302
+ id: "single",
303
+ name: "單選"
304
+ }, {
305
+ id: "multiple",
306
+ name: "複選"
307
+ }], Bt = [
308
+ {
309
+ id: "unset",
310
+ name: "不預設"
311
+ },
312
+ {
313
+ id: "true",
314
+ name: "是"
315
+ },
316
+ {
317
+ id: "false",
318
+ name: "否"
319
+ }
320
+ ], Vt = [{
321
+ id: "true",
322
+ name: "是"
323
+ }, {
324
+ id: "false",
325
+ name: "否"
326
+ }], Ht = [
327
+ {
328
+ label: "顯示",
329
+ name: "fieldVisibleWhen",
330
+ supportingText: "符合條件時才顯示這個欄位。",
331
+ target: "visibleWhen"
332
+ },
333
+ {
334
+ label: "必填",
335
+ name: "fieldRequiredWhen",
336
+ supportingText: "符合條件時才要求填寫這個欄位。",
337
+ target: "requiredWhen"
338
+ },
339
+ {
340
+ label: "唯讀",
341
+ name: "fieldReadonlyWhen",
342
+ supportingText: "符合條件時不允許修改這個欄位。",
343
+ target: "readonlyWhen"
344
+ }
345
+ ];
346
+ function F({ onChange: le, value: _ }) {
347
+ let v = _?.schema ?? Pt, ue = _?.uiSchema ?? Ft, [y, b] = i(v), [x, S] = i(ue), [fe, k] = i(I(v)), [Ge, A] = i(I(ue)), [Ke, j] = i({}), [M, F] = i(null), [L, an] = i("design"), [R, z] = i(null), [B, on] = i([]), [sn, cn] = i(null), [ln, un] = i("loading"), [V, H] = i(null), [dn, fn] = i(!1), [U, W] = i(null);
348
+ n(() => {
349
+ let e = !0;
350
+ return Te().then((t) => {
351
+ e && (on(t), cn(null), un("ready"));
352
+ }).catch((t) => {
353
+ e && (on([]), cn("目前無法載入 DataSource Catalog,請稍後重試。"), un("unavailable"));
354
+ }), () => {
355
+ e = !1;
356
+ };
357
+ }, []), n(() => {
358
+ y.fields.some((e) => e.fieldKey === R) || z(y.fields[0]?.fieldKey ?? null);
359
+ }, [y.fields, R]), n(() => {
360
+ j((e) => he(y.fields, e));
361
+ }, [y.fields]), n(() => {
362
+ L !== "advanced" && (k(I(y)), A(I(x)));
363
+ }, [
364
+ L,
365
+ y,
366
+ x
367
+ ]);
368
+ let G = r(() => y.fields.find((e) => e.fieldKey === R) ?? y.fields[0] ?? null, [y.fields, R]);
369
+ n(() => {
370
+ le?.({
371
+ schema: y,
372
+ uiSchema: x
373
+ });
374
+ }, [y, x]);
375
+ function pn(e) {
376
+ let t = _e(e, y.fields.length + 1);
377
+ b({
378
+ ...y,
379
+ fields: [...y.fields, t]
380
+ }), S({
381
+ ...x,
382
+ layout: [...x.layout, {
383
+ fieldKey: t.fieldKey,
384
+ width: e === "textarea" || e === "file_upload" ? "FULL" : "HALF"
385
+ }]
386
+ }), z(t.fieldKey), an("design"), F(null);
387
+ }
388
+ function mn(e) {
389
+ let t = e;
390
+ t === "advanced" && L !== "advanced" && (k(I(y)), A(I(x))), an(t);
391
+ }
392
+ function hn(e) {
393
+ let t = y.fields.flatMap((t) => D(t) && Re(t).includes(e) ? [t.fieldKey] : []);
394
+ if (t.length > 0) {
395
+ W({
396
+ affectedFieldKeys: t,
397
+ fieldKey: e,
398
+ kind: "remove-field"
399
+ });
400
+ return;
401
+ }
402
+ gn(e);
403
+ }
404
+ function gn(e) {
405
+ let t = y.fields.filter((t) => t.fieldKey !== e);
406
+ b({
407
+ ...y,
408
+ fields: t
409
+ }), S({
410
+ ...x,
411
+ layout: x.layout.filter((t) => t.fieldKey !== e)
412
+ }), z(R === e ? t[0]?.fieldKey ?? null : R), F(null), H(null);
413
+ }
414
+ function _n(e) {
415
+ let t = e.destination;
416
+ t && e.source.index !== t.index && (b((n) => ({
417
+ ...n,
418
+ fields: rn(n.fields, e.source.index, t.index)
419
+ })), S((n) => ({
420
+ ...n,
421
+ layout: rn(n.layout, e.source.index, t.index)
422
+ })), F(null));
423
+ }
424
+ function K(e) {
425
+ q((t) => ({
426
+ ...t,
427
+ ...e
428
+ }));
429
+ }
430
+ function q(e) {
431
+ if (!G) return;
432
+ let t = G.fieldKey, n = e(G), r = n.fieldKey, i = {
433
+ ...y,
434
+ fields: y.fields.map((e) => e.fieldKey === t ? n : e)
435
+ };
436
+ b(t === r ? i : Be(i, t, r)), S({
437
+ ...x,
438
+ layout: x.layout.map((e) => e.fieldKey === t ? {
439
+ ...e,
440
+ fieldKey: r
441
+ } : e)
442
+ }), z(r), F(null), H(null);
443
+ }
444
+ function J(e) {
445
+ q((t) => Zt(t) ? {
446
+ ...t,
447
+ ...e
448
+ } : t);
449
+ }
450
+ function vn(e) {
451
+ q((t) => Se(t) ? {
452
+ ...t,
453
+ ...e
454
+ } : t);
455
+ }
456
+ function yn(e) {
457
+ q((t) => be(t) ? {
458
+ ...t,
459
+ ...e
460
+ } : t);
461
+ }
462
+ function Y(e) {
463
+ q((t) => Ce(t) ? {
464
+ ...t,
465
+ ...e
466
+ } : t);
467
+ }
468
+ function bn(e) {
469
+ if (!G || G.type !== "select" && G.type !== "autocomplete" || O(G) === e) return;
470
+ let t = G.defaultValue, n = e === "multiple" ? typeof t == "string" ? [t] : t : Array.isArray(t) ? t[0] : t;
471
+ X(G, {
472
+ ...G,
473
+ defaultValue: n,
474
+ mode: e
475
+ }, "選擇模式變更可能轉換或捨棄既有預設值。");
476
+ }
477
+ function X(e, t, n = "此變更會替換目前選項來源;既有 options、dynamic reference 或 bindings 可能失效。") {
478
+ JSON.stringify(e) !== JSON.stringify(t) && W({
479
+ fieldKey: e.fieldKey,
480
+ impact: n,
481
+ kind: "replace-field",
482
+ nextField: t
483
+ });
484
+ }
485
+ function xn(e, t) {
486
+ if (!t) return;
487
+ if (t === P) {
488
+ if (!D(e)) return;
489
+ let { dataSource: t, defaultValue: n, ...r } = e;
490
+ X(e, {
491
+ ...r,
492
+ options: []
493
+ });
494
+ return;
495
+ }
496
+ let n = B.find((e) => Wt(e) === t);
497
+ if (!n) return;
498
+ if (D(e)) {
499
+ let t = new Set(n.parameters.map((e) => e.key)), r = e.dataSource.bindings.filter((e) => t.has(e.parameter));
500
+ X(e, {
501
+ ...e,
502
+ dataSource: {
503
+ bindings: r,
504
+ key: n.key,
505
+ version: n.version
506
+ }
507
+ });
508
+ return;
509
+ }
510
+ let { options: r, defaultValue: i, ...a } = e;
511
+ X(e, {
512
+ ...a,
513
+ dataSource: {
514
+ bindings: [],
515
+ key: n.key,
516
+ version: n.version
517
+ }
518
+ });
519
+ }
520
+ function Sn() {
521
+ U && (U.kind === "remove-field" ? gn(U.fieldKey) : (b({
522
+ ...y,
523
+ fields: y.fields.map((e) => e.fieldKey === U.fieldKey ? U.nextField : e)
524
+ }), F(null), H(null)), W(null));
525
+ }
526
+ async function Cn() {
527
+ fn(!0);
528
+ try {
529
+ H((await we(y, x)).errors.map(ze));
530
+ } catch {
531
+ H(["目前無法完成 DataSource schema 驗證。"]);
532
+ } finally {
533
+ fn(!1);
534
+ }
535
+ }
536
+ function wn(e) {
537
+ q((t) => t.type === "boolean" ? {
538
+ ...t,
539
+ ...e
540
+ } : t);
541
+ }
542
+ function Tn(e) {
543
+ q((t) => t.type === "file_upload" ? {
544
+ ...t,
545
+ ...e
546
+ } : t);
547
+ }
548
+ function En(e) {
549
+ j(e);
550
+ }
551
+ function Dn(e, t) {
552
+ b((n) => ({
553
+ ...n,
554
+ fields: n.fields.map((n) => n.fieldKey === e ? {
555
+ ...n,
556
+ required: t
557
+ } : n)
558
+ })), F(null);
559
+ }
560
+ function On(e) {
561
+ k(e);
562
+ try {
563
+ b(JSON.parse(e)), F(null);
564
+ } catch {
565
+ F("Form Schema JSON 格式不正確");
566
+ }
567
+ }
568
+ function kn(e) {
569
+ A(e);
570
+ try {
571
+ S(JSON.parse(e)), F(null);
572
+ } catch {
573
+ F("UI Schema JSON 格式不正確");
574
+ }
575
+ }
576
+ return /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ h(m, { children: /* @__PURE__ */ h(ie, { children: /* @__PURE__ */ h(re, { children: /* @__PURE__ */ g("div", {
577
+ style: Et,
578
+ children: [
579
+ /* @__PURE__ */ g(ae, {
580
+ activeKey: L,
581
+ onChange: mn,
582
+ size: "sub",
583
+ children: [
584
+ /* @__PURE__ */ h(f, { children: "設計" }, "design"),
585
+ /* @__PURE__ */ h(f, { children: "預覽" }, "preview"),
586
+ /* @__PURE__ */ h(f, { children: "進階" }, "advanced")
587
+ ]
588
+ }),
589
+ L === "design" ? An() : null,
590
+ L === "preview" ? nr() : null,
591
+ L === "advanced" ? rr() : null
592
+ ]
593
+ }) }) }) }), U ? /* @__PURE__ */ h(ne, {
594
+ cancelText: "返回",
595
+ confirmText: "確認變更",
596
+ modalType: "standard",
597
+ onCancel: () => W(null),
598
+ onClose: () => W(null),
599
+ onConfirm: Sn,
600
+ open: !0,
601
+ showModalFooter: !0,
602
+ showModalHeader: !0,
603
+ title: U.kind === "remove-field" ? "確認移除 dependency 欄位" : "確認替換選項來源",
604
+ children: U.kind === "remove-field" ? /* @__PURE__ */ g("div", {
605
+ style: Dt,
606
+ children: [/* @__PURE__ */ h(p, {
607
+ variant: "body",
608
+ children: "此欄位仍被下列 DataSource binding 使用;移除後請重新設定這些欄位。"
609
+ }), /* @__PURE__ */ h(p, {
610
+ color: "text-warning",
611
+ variant: "body",
612
+ children: U.affectedFieldKeys.join("、")
613
+ })]
614
+ }) : /* @__PURE__ */ g(p, {
615
+ variant: "body",
616
+ children: [U.impact, "確認後才會寫入 schema。"]
617
+ })
618
+ }) : null] });
619
+ function An() {
620
+ return /* @__PURE__ */ g("div", {
621
+ style: N,
622
+ children: [/* @__PURE__ */ g("div", {
623
+ style: et,
624
+ children: [/* @__PURE__ */ h(p, {
625
+ component: "h2",
626
+ variant: "label-primary",
627
+ children: "新增欄位"
628
+ }), /* @__PURE__ */ h("div", {
629
+ style: Qe,
630
+ children: Je.map((e) => /* @__PURE__ */ h(s, {
631
+ icon: e.icon,
632
+ iconType: "leading",
633
+ onClick: () => pn(e.type),
634
+ size: "sub",
635
+ style: $e,
636
+ type: "button",
637
+ variant: "base-secondary",
638
+ children: e.label
639
+ }, e.type))
640
+ })]
641
+ }), /* @__PURE__ */ g("div", {
642
+ style: Ye,
643
+ children: [/* @__PURE__ */ g("div", {
644
+ style: {
645
+ ...N,
646
+ ...Xe
647
+ },
648
+ children: [/* @__PURE__ */ h(p, {
649
+ component: "h2",
650
+ variant: "label-primary",
651
+ children: "表單畫布"
652
+ }), y.fields.length > 0 ? /* @__PURE__ */ h(He, {
653
+ onDragEnd: _n,
654
+ children: /* @__PURE__ */ h(We, {
655
+ droppableId: "form-builder-fields",
656
+ children: (e) => /* @__PURE__ */ g("div", {
657
+ ...e.droppableProps,
658
+ ref: e.innerRef,
659
+ style: N,
660
+ children: [y.fields.map((e, t) => /* @__PURE__ */ h(Ue, {
661
+ draggableId: e.fieldKey,
662
+ index: t,
663
+ children: (t, n) => er(e, t, n.isDragging)
664
+ }, e.fieldKey)), e.placeholder]
665
+ })
666
+ })
667
+ }) : /* @__PURE__ */ g("div", {
668
+ style: ct,
669
+ children: [/* @__PURE__ */ g("div", {
670
+ style: N,
671
+ children: [/* @__PURE__ */ h(p, {
672
+ component: "h3",
673
+ variant: "h3",
674
+ children: "尚未建立欄位"
675
+ }), /* @__PURE__ */ h(p, {
676
+ color: "text-neutral",
677
+ variant: "body",
678
+ children: "從上方新增第一個欄位,或直接建立常用文字欄位開始設計。"
679
+ })]
680
+ }), /* @__PURE__ */ g("div", {
681
+ style: lt,
682
+ children: [/* @__PURE__ */ h(s, {
683
+ onClick: () => pn("text"),
684
+ variant: "base-primary",
685
+ children: "新增文字欄位"
686
+ }), /* @__PURE__ */ h(s, {
687
+ onClick: () => pn("textarea"),
688
+ variant: "base-secondary",
689
+ children: "新增長文字"
690
+ })]
691
+ })]
692
+ })]
693
+ }), /* @__PURE__ */ g("div", {
694
+ style: {
695
+ ...N,
696
+ ...Ze
697
+ },
698
+ children: [/* @__PURE__ */ h(p, {
699
+ component: "h2",
700
+ variant: "label-primary",
701
+ children: "欄位設定"
702
+ }), G ? jn(G) : /* @__PURE__ */ h(p, {
703
+ color: "text-neutral",
704
+ variant: "body",
705
+ children: "請先新增或選取欄位。"
706
+ })]
707
+ })]
708
+ })]
709
+ });
710
+ }
711
+ function jn(e) {
712
+ return /* @__PURE__ */ g("div", {
713
+ style: ut,
714
+ children: [Mn(e), Nn(e)]
715
+ });
716
+ }
717
+ function Mn(e) {
718
+ return /* @__PURE__ */ g("div", {
719
+ style: dt,
720
+ children: [
721
+ /* @__PURE__ */ h("div", {
722
+ style: pt,
723
+ children: /* @__PURE__ */ h(o, {
724
+ size: "main",
725
+ text: Ut(e.type),
726
+ variant: "text-info"
727
+ })
728
+ }),
729
+ $("標題", "fieldLabel", /* @__PURE__ */ h(u, {
730
+ onChange: (e) => K({ label: e.target.value }),
731
+ placeholder: "例如:申請金額",
732
+ value: e.label,
733
+ variant: "base"
734
+ })),
735
+ $("欄位 Key", "fieldKey", /* @__PURE__ */ h(u, {
736
+ onChange: (e) => K({ fieldKey: e.target.value }),
737
+ placeholder: "例如:amount",
738
+ value: e.fieldKey,
739
+ variant: "base"
740
+ })),
741
+ $("提示文字", "fieldPlaceholder", /* @__PURE__ */ h(u, {
742
+ onChange: (e) => K({ placeholder: e.target.value || void 0 }),
743
+ placeholder: "例如:請輸入申請金額",
744
+ value: e.placeholder ?? "",
745
+ variant: "base"
746
+ })),
747
+ Pn(e)
748
+ ]
749
+ });
750
+ }
751
+ function Nn(e) {
752
+ return /* @__PURE__ */ h(a, {
753
+ defaultExpanded: Yt(e),
754
+ size: "sub",
755
+ title: "進階設定",
756
+ children: /* @__PURE__ */ g("div", {
757
+ style: dt,
758
+ children: [
759
+ /* @__PURE__ */ h(p, {
760
+ component: "h3",
761
+ style: ft,
762
+ variant: "label-primary",
763
+ children: "條件規則"
764
+ }),
765
+ /* @__PURE__ */ h(p, {
766
+ color: "text-neutral",
767
+ style: mt,
768
+ variant: "body",
769
+ children: "只有需要根據其他欄位改變顯示、必填或唯讀狀態時才需要設定。"
770
+ }),
771
+ Jn(e)
772
+ ]
773
+ })
774
+ });
775
+ }
776
+ function Pn(e) {
777
+ return Zt(e) ? Fn(e) : Se(e) ? In(e) : be(e) ? Ln(e) : Ve(e) ? Rn(e) : e.type === "boolean" ? Kn(e) : qn(e);
778
+ }
779
+ function Fn(e) {
780
+ return /* @__PURE__ */ g(m, { children: [
781
+ $("預設值", "fieldDefaultValue", e.type === "textarea" ? Zn({
782
+ name: "fieldDefaultValue",
783
+ onChange: (e) => J({ defaultValue: e || void 0 }),
784
+ placeholder: "輸入此欄位的預設文字",
785
+ rows: 3,
786
+ value: Qt(e.defaultValue)
787
+ }) : /* @__PURE__ */ h(u, {
788
+ onChange: (e) => J({ defaultValue: e.target.value || void 0 }),
789
+ placeholder: "輸入此欄位的預設文字",
790
+ value: Qt(e.defaultValue),
791
+ variant: "base"
792
+ })),
793
+ $("最小長度", "fieldMinLength", Q(e.minLength, (e) => J({ minLength: e }), "例如:2", { min: 0 })),
794
+ $("最大長度", "fieldMaxLength", Q(e.maxLength, (e) => J({ maxLength: e }), "例如:100", { min: 1 }))
795
+ ] });
796
+ }
797
+ function In(e) {
798
+ return /* @__PURE__ */ g(m, { children: [
799
+ $("預設值", "fieldDefaultValue", Q(typeof e.defaultValue == "number" ? e.defaultValue : void 0, (e) => vn({ defaultValue: e }), e.type === "money" ? "例如:1000" : "輸入預設數值", {
800
+ max: e.maximum,
801
+ min: e.minimum
802
+ })),
803
+ $("最小值", "fieldMinimum", Q(e.minimum, (e) => vn({ minimum: e }), "例如:0")),
804
+ $("最大值", "fieldMaximum", Q(e.maximum, (e) => vn({ maximum: e }), "例如:999999"))
805
+ ] });
806
+ }
807
+ function Ln(e) {
808
+ return $("預設值", "fieldDefaultValue", Qn(e, Qt(e.defaultValue), (e) => yn({ defaultValue: e })));
809
+ }
810
+ function Rn(e) {
811
+ let t = ke(e.type, B), n = D(e) ? Wt(e.dataSource) : P, r = D(e) ? B.find((t) => t.key === e.dataSource.key && t.version === e.dataSource.version) : null, i = r ? t.some((e) => e.key === r.key && e.version === r.version) : !1, a = [
812
+ ...Rt,
813
+ ...t.map(Gt),
814
+ ...D(e) && !i ? [{
815
+ id: n,
816
+ name: `${e.dataSource.key} v${e.dataSource.version}(目前不可用或不支援)`
817
+ }] : []
818
+ ], o = O(e);
819
+ return /* @__PURE__ */ g(m, { children: [
820
+ e.type === "select" || e.type === "autocomplete" ? $("選擇模式", "fieldSelectionMode", /* @__PURE__ */ h(d, {
821
+ clearable: !1,
822
+ onChange: (e) => {
823
+ (e?.id === "single" || e?.id === "multiple") && bn(e.id);
824
+ },
825
+ options: [...zt],
826
+ value: T(zt, o)
827
+ })) : $("選擇模式", "fieldSelectionMode", /* @__PURE__ */ h(p, {
828
+ color: "text-neutral",
829
+ variant: "body",
830
+ children: o === "multiple" ? "固定複選" : "固定單選"
831
+ })),
832
+ $("選項來源", "fieldOptionSource", /* @__PURE__ */ h(d, {
833
+ clearable: !1,
834
+ disabled: ln === "loading" && !D(e),
835
+ onChange: (t) => xn(e, t?.id),
836
+ options: a,
837
+ placeholder: "選擇選項來源",
838
+ value: T(a, n)
839
+ })),
840
+ D(e) ? zn(e, t) : Gn(e)
841
+ ] });
842
+ }
843
+ function zn(e, t) {
844
+ let n = B.find((t) => t.key === e.dataSource.key && t.version === e.dataSource.version), r = n && !xe(n, e.type);
845
+ return /* @__PURE__ */ g("div", {
846
+ style: At,
847
+ children: [
848
+ ln === "loading" ? /* @__PURE__ */ h(p, {
849
+ color: "text-neutral",
850
+ variant: "body",
851
+ children: "正在載入可用的 DataSource Catalog…"
852
+ }) : null,
853
+ sn ? /* @__PURE__ */ h(p, {
854
+ color: "text-error",
855
+ variant: "body",
856
+ children: sn
857
+ }) : null,
858
+ n ? null : /* @__PURE__ */ h(p, {
859
+ color: "text-warning",
860
+ variant: "body",
861
+ children: "目前來源版本未出現在 Catalog;會保留原設定,但在環境 lint 通過前不可發布。"
862
+ }),
863
+ r ? /* @__PURE__ */ h(p, {
864
+ color: "text-error",
865
+ variant: "body",
866
+ children: "目前來源不支援此控制項或超出 bounded list 限制,請選擇其他版本。"
867
+ }) : null,
868
+ n ? Bn(n) : null,
869
+ n ? n.parameters.map((t) => Vn(e, t)) : null,
870
+ t.length === 0 && !sn ? /* @__PURE__ */ h(p, {
871
+ color: "text-warning",
872
+ variant: "body",
873
+ children: "沒有符合目前控制項能力的已註冊來源。"
874
+ }) : null,
875
+ /* @__PURE__ */ h("div", {
876
+ style: Ot,
877
+ children: /* @__PURE__ */ h(s, {
878
+ disabled: dn,
879
+ onClick: () => void Cn(),
880
+ size: "sub",
881
+ type: "button",
882
+ variant: "base-secondary",
883
+ children: dn ? "驗證中…" : "驗證 DataSource 設定"
884
+ })
885
+ }),
886
+ V ? /* @__PURE__ */ h(p, {
887
+ color: V.length > 0 ? "text-error" : "text-success",
888
+ variant: "caption",
889
+ children: V.length > 0 ? V.join(";") : "DataSource schema 與目前環境均通過驗證。"
890
+ }) : null
891
+ ]
892
+ });
893
+ }
894
+ function Bn(e) {
895
+ return /* @__PURE__ */ g("div", {
896
+ style: jt,
897
+ children: [
898
+ /* @__PURE__ */ g(p, {
899
+ variant: "label-primary",
900
+ children: [
901
+ e.label,
902
+ " · v",
903
+ e.version
904
+ ]
905
+ }),
906
+ e.description ? /* @__PURE__ */ h(p, {
907
+ color: "text-neutral",
908
+ variant: "caption",
909
+ children: e.description
910
+ }) : null,
911
+ /* @__PURE__ */ g(p, {
912
+ color: "text-neutral",
913
+ variant: "caption",
914
+ children: [
915
+ "支援:",
916
+ e.supportedControls.join("、"),
917
+ ";",
918
+ e.supportsSearch ? "支援搜尋" : "不支援搜尋",
919
+ ";",
920
+ e.paginationMode === "CURSOR" ? "支援分頁" : "完整清單",
921
+ "; policy:",
922
+ e.revalidationPolicy
923
+ ]
924
+ })
925
+ ]
926
+ });
927
+ }
928
+ function Vn(t, n) {
929
+ let r = Fe(t, n.key), i = Kt(r), a = Oe(n.type, y.fields, t.fieldKey), o = [
930
+ ...n.required ? [] : [{
931
+ id: Lt,
932
+ name: "未綁定"
933
+ }],
934
+ ...a,
935
+ ...n.type === "STRING_ARRAY" ? [] : [{
936
+ id: It,
937
+ name: "固定常數"
938
+ }]
939
+ ];
940
+ return /* @__PURE__ */ g("div", {
941
+ style: Mt,
942
+ children: [/* @__PURE__ */ h(e, {
943
+ label: `${n.label ?? n.key}${n.required ? "(必填)" : "(選填)"}`,
944
+ name: `dataSourceParameter_${n.key}`,
945
+ children: /* @__PURE__ */ h(d, {
946
+ clearable: !1,
947
+ onChange: (e) => Un(t, n.key, n.type, e?.id),
948
+ options: o,
949
+ placeholder: "選擇欄位或常數",
950
+ value: T(o, i)
951
+ })
952
+ }), Le(r) === "CONSTANT" ? Hn(t, n.key, n.type, r) : Le(r) === "FIELD" ? /* @__PURE__ */ g(p, {
953
+ color: "text-neutral",
954
+ variant: "caption",
955
+ children: [
956
+ "使用表單欄位「",
957
+ r?.from.kind === "FIELD" ? r.from.fieldKey : "",
958
+ "」的目前值。"
959
+ ]
960
+ }) : /* @__PURE__ */ h(p, {
961
+ color: "text-neutral",
962
+ variant: "caption",
963
+ children: n.required ? a.length > 0 ? "請選擇相容的表單欄位或固定常數。" : "目前沒有型別相容的表單欄位,請先建立 dependency。" : "此參數可不綁定。"
964
+ })]
965
+ }, n.key);
966
+ }
967
+ function Hn(e, t, n, r) {
968
+ let i = Ie(e, t);
969
+ if (n === "BOOLEAN") {
970
+ let e = [{
971
+ id: "true",
972
+ name: "是"
973
+ }, {
974
+ id: "false",
975
+ name: "否"
976
+ }];
977
+ return /* @__PURE__ */ h(d, {
978
+ clearable: !1,
979
+ onChange: (e) => Wn(t, e?.id === "true"),
980
+ options: e,
981
+ value: T(e, i === !0 ? "true" : "false")
982
+ });
983
+ }
984
+ return n === "STRING_ARRAY" ? /* @__PURE__ */ h(p, {
985
+ color: "text-warning",
986
+ variant: "caption",
987
+ children: "STRING_ARRAY 參數請綁定複選欄位;目前不接受固定常數。"
988
+ }) : /* @__PURE__ */ h(u, {
989
+ onChange: (e) => Wn(t, n === "NUMBER" ? De(e.target.value) ?? 0 : e.target.value),
990
+ placeholder: n === "NUMBER" ? "輸入數字" : "輸入固定值",
991
+ value: Jt(r, n),
992
+ variant: "base"
993
+ });
994
+ }
995
+ function Un(e, t, n, r) {
996
+ if (!r || r === Lt) {
997
+ q((e) => D(e) ? E(e, t, null) : e);
998
+ return;
999
+ }
1000
+ if (r === It) {
1001
+ q((e) => D(e) ? E(e, t, {
1002
+ from: {
1003
+ kind: "CONSTANT",
1004
+ value: qt(n)
1005
+ },
1006
+ parameter: t
1007
+ }) : e);
1008
+ return;
1009
+ }
1010
+ q((e) => D(e) ? E(e, t, {
1011
+ from: {
1012
+ fieldKey: r,
1013
+ kind: "FIELD"
1014
+ },
1015
+ parameter: t
1016
+ }) : e);
1017
+ }
1018
+ function Wn(e, t) {
1019
+ q((n) => D(n) ? E(n, e, {
1020
+ from: {
1021
+ kind: "CONSTANT",
1022
+ value: t
1023
+ },
1024
+ parameter: e
1025
+ }) : n);
1026
+ }
1027
+ function Gn(e) {
1028
+ let t = O(e), n = Array.isArray(e.defaultValue) ? e.defaultValue : [], r = e.options.map(Pe), i = r.filter((e) => n.includes(e.id));
1029
+ return /* @__PURE__ */ g(m, { children: [$("預設值", "fieldDefaultValue", t === "multiple" ? /* @__PURE__ */ h(d, {
1030
+ clearable: !0,
1031
+ mode: "multiple",
1032
+ onChange: (e) => Y({ defaultValue: e.length ? e.map((e) => e.id) : void 0 }),
1033
+ options: r,
1034
+ placeholder: "選擇一或多個預設選項",
1035
+ value: i
1036
+ }) : /* @__PURE__ */ h(d, {
1037
+ clearable: !0,
1038
+ onChange: (e) => Y({ defaultValue: e?.id || void 0 }),
1039
+ options: r,
1040
+ placeholder: "選擇預設選項",
1041
+ value: typeof e.defaultValue == "string" ? T(r, e.defaultValue) : null
1042
+ })), $("選項", "fieldOptions", $n(e), !0)] });
1043
+ }
1044
+ function Kn(e) {
1045
+ let t = typeof e.defaultValue == "boolean" ? String(e.defaultValue) : "unset";
1046
+ return $("預設值", "fieldDefaultValue", /* @__PURE__ */ h(d, {
1047
+ clearable: !1,
1048
+ onChange: (e) => wn({ defaultValue: e?.id === "true" ? !0 : e?.id === "false" ? !1 : void 0 }),
1049
+ options: [...Bt],
1050
+ placeholder: "選擇預設狀態",
1051
+ value: T(Bt, t)
1052
+ }));
1053
+ }
1054
+ function qn(e) {
1055
+ return /* @__PURE__ */ g(m, { children: [$("檔案數", "fieldMaxFiles", Q(e.maxFiles, (e) => Tn({ maxFiles: e }), "例如:1", { min: 1 })), $("MIME", "fieldAcceptedMimeTypes", Zn({
1056
+ name: "fieldAcceptedMimeTypes",
1057
+ onChange: (e) => Tn({ acceptedMimeTypes: $t(e) }),
1058
+ placeholder: "每行一個 MIME type,例如:application/pdf",
1059
+ rows: 3,
1060
+ value: en(e.acceptedMimeTypes)
1061
+ }), !1)] });
1062
+ }
1063
+ function Jn(e) {
1064
+ let t = y.fields.filter((t) => t.fieldKey !== e.fieldKey);
1065
+ return t.length ? /* @__PURE__ */ h(m, { children: Ht.map((n) => Yn(e, n, t)) }) : /* @__PURE__ */ h(p, {
1066
+ color: "text-neutral",
1067
+ style: mt,
1068
+ variant: "body",
1069
+ children: "目前沒有其他欄位可作為條件來源。新增更多欄位後即可設定條件規則。"
1070
+ });
1071
+ }
1072
+ function Yn(e, t, n) {
1073
+ let r = e[t.target], i = r ? Ee(r) : null, a = n.find((e) => e.fieldKey === i?.fieldKey), o = a ?? n[0], ee = n.map(Xt), s = je(o), c = i && s.some((e) => e.id === i.operator) ? i.operator : Ne(o), te = i?.value ?? w(o), l = !!r, u = l && (!i || !a);
1074
+ return $(t.label, t.name, /* @__PURE__ */ g("div", {
1075
+ style: Ct,
1076
+ children: [/* @__PURE__ */ h(ce, {
1077
+ checked: l,
1078
+ label: l ? "已啟用" : "不啟用",
1079
+ onChange: (e) => Z(t.target, e.target.checked ? C(o, Ne(o), w(o)) : void 0),
1080
+ size: "sub",
1081
+ supportingText: t.supportingText
1082
+ }), l ? u ? /* @__PURE__ */ h(p, {
1083
+ color: "text-warning",
1084
+ variant: "body",
1085
+ children: "這個規則不是目前 UI 支援的格式。重新選擇條件後會取代既有規則。"
1086
+ }) : /* @__PURE__ */ g("div", {
1087
+ style: wt,
1088
+ children: [
1089
+ /* @__PURE__ */ h(d, {
1090
+ clearable: !1,
1091
+ onChange: (e) => {
1092
+ let r = n.find((t) => t.fieldKey === e?.id) ?? o;
1093
+ Z(t.target, C(r, Ne(r), w(r)));
1094
+ },
1095
+ options: ee,
1096
+ placeholder: "選擇欄位",
1097
+ value: T(ee, o.fieldKey)
1098
+ }),
1099
+ /* @__PURE__ */ h(d, {
1100
+ clearable: !1,
1101
+ onChange: (e) => Z(t.target, C(o, Ae(e?.id) ?? c, te)),
1102
+ options: [...s],
1103
+ placeholder: "判斷方式",
1104
+ value: T(s, c)
1105
+ }),
1106
+ Xn(o, te, (e) => Z(t.target, C(o, c, e)))
1107
+ ]
1108
+ }) : null]
1109
+ }), !0);
1110
+ }
1111
+ function Z(e, t) {
1112
+ K({ [e]: t });
1113
+ }
1114
+ function Xn(e, t, n) {
1115
+ if (e.type === "boolean") return /* @__PURE__ */ h(d, {
1116
+ clearable: !1,
1117
+ onChange: (e) => n(e?.id ?? "true"),
1118
+ options: [...Vt],
1119
+ placeholder: "比較值",
1120
+ value: T(Vt, t === "false" ? "false" : "true")
1121
+ });
1122
+ if (Ce(e)) {
1123
+ let r = e.options.map(Pe);
1124
+ return /* @__PURE__ */ h(d, {
1125
+ clearable: !1,
1126
+ onChange: (e) => n(e?.id ?? r[0]?.id ?? ""),
1127
+ options: r,
1128
+ placeholder: "比較值",
1129
+ value: T(r, t)
1130
+ });
1131
+ }
1132
+ return Se(e) ? Q(De(t), (e) => n(String(e ?? 0)), "比較值") : be(e) ? Qn(e, t, (e) => n(e ?? "")) : /* @__PURE__ */ h(u, {
1133
+ onChange: (e) => n(e.target.value),
1134
+ placeholder: "比較值",
1135
+ value: t,
1136
+ variant: "base"
1137
+ });
1138
+ }
1139
+ function Zn({ name: e, onChange: t, placeholder: n, rows: r, value: i }) {
1140
+ return /* @__PURE__ */ h(se, {
1141
+ "aria-label": e,
1142
+ onChange: (e) => t(e.target.value),
1143
+ placeholder: n,
1144
+ ref: Nt,
1145
+ resize: "vertical",
1146
+ rows: r,
1147
+ style: vt,
1148
+ value: i
1149
+ });
1150
+ }
1151
+ function Q(e, t, n, r = {}) {
1152
+ return /* @__PURE__ */ h(u, {
1153
+ max: r.max,
1154
+ min: r.min,
1155
+ onChange: (e) => t(ge(De(e.target.value), r)),
1156
+ placeholder: n,
1157
+ showSpinner: !0,
1158
+ step: r.step ?? 1,
1159
+ value: typeof e == "number" ? String(e) : "",
1160
+ variant: "measure"
1161
+ });
1162
+ }
1163
+ function Qn(e, t, n) {
1164
+ return e.type === "datetime" ? /* @__PURE__ */ h(te, {
1165
+ formatDate: "YYYY-MM-DD",
1166
+ formatTime: "HH:mm",
1167
+ hideSecond: !0,
1168
+ onChange: (e) => n(ye(e)),
1169
+ placeholderLeft: "選擇日期",
1170
+ placeholderRight: "選擇時間",
1171
+ value: Me(t)
1172
+ }) : /* @__PURE__ */ h(c, {
1173
+ format: "YYYY-MM-DD",
1174
+ onChange: (e) => n(ve(e)),
1175
+ placeholder: "選擇日期",
1176
+ value: Me(t)
1177
+ });
1178
+ }
1179
+ function $n(e) {
1180
+ return /* @__PURE__ */ g("div", {
1181
+ style: Dt,
1182
+ children: [/* @__PURE__ */ h(oe, {
1183
+ actions: {
1184
+ render: (t) => [{
1185
+ disabled: () => e.options.length <= 1,
1186
+ icon: me,
1187
+ iconType: "icon-only",
1188
+ name: "移除選項",
1189
+ onClick: () => Y({ options: e.options.filter((e, n) => n !== t.index) }),
1190
+ variant: "destructive-ghost"
1191
+ }],
1192
+ width: 56
1193
+ },
1194
+ columns: [{
1195
+ key: "label",
1196
+ render: (t) => /* @__PURE__ */ h(u, {
1197
+ onChange: (n) => Y({ options: tn(e.options, t.index, { label: n.target.value }) }),
1198
+ placeholder: "例如:主管",
1199
+ size: "sub",
1200
+ value: t.label,
1201
+ variant: "base"
1202
+ }),
1203
+ title: "Label"
1204
+ }, {
1205
+ key: "value",
1206
+ render: (t) => /* @__PURE__ */ h(u, {
1207
+ onChange: (n) => Y({ options: tn(e.options, t.index, { value: n.target.value }) }),
1208
+ placeholder: "例如:manager",
1209
+ size: "sub",
1210
+ value: t.value,
1211
+ variant: "base"
1212
+ }),
1213
+ title: "Value"
1214
+ }],
1215
+ dataSource: e.options.map((t, n) => ({
1216
+ index: n,
1217
+ key: `${e.fieldKey}-${n}`,
1218
+ label: t.label,
1219
+ value: t.value
1220
+ })),
1221
+ showHeader: !0,
1222
+ size: "sub"
1223
+ }), /* @__PURE__ */ h("div", {
1224
+ style: Ot,
1225
+ children: /* @__PURE__ */ h(s, {
1226
+ icon: pe,
1227
+ iconType: "leading",
1228
+ onClick: () => Y({ options: [...e.options, nn(e.options)] }),
1229
+ variant: "base-secondary",
1230
+ children: "新增選項"
1231
+ })
1232
+ })]
1233
+ });
1234
+ }
1235
+ function er(e, t, n) {
1236
+ return /* @__PURE__ */ h("div", {
1237
+ ...t.draggableProps,
1238
+ "data-form-builder-field-key": e.fieldKey,
1239
+ ref: t.innerRef,
1240
+ style: {
1241
+ ...at,
1242
+ ...n ? ot : null,
1243
+ ...t.draggableProps.style
1244
+ },
1245
+ children: /* @__PURE__ */ h(ee, {
1246
+ style: e.fieldKey === G?.fieldKey ? st : void 0,
1247
+ children: tr(e, t, n)
1248
+ })
1249
+ });
1250
+ }
1251
+ function $(t, n, r, i = !1) {
1252
+ return /* @__PURE__ */ h("div", {
1253
+ style: i ? gt : ht,
1254
+ children: /* @__PURE__ */ h("div", {
1255
+ style: _t,
1256
+ children: /* @__PURE__ */ h(e, {
1257
+ label: t,
1258
+ name: n,
1259
+ children: r
1260
+ })
1261
+ })
1262
+ });
1263
+ }
1264
+ function tr(e, t, n) {
1265
+ return /* @__PURE__ */ g("div", {
1266
+ ...t.dragHandleProps ?? {},
1267
+ "aria-label": "選取或拖曳排序欄位",
1268
+ onClick: () => z(e.fieldKey),
1269
+ style: tt,
1270
+ title: "點擊選取,拖曳排序",
1271
+ children: [
1272
+ /* @__PURE__ */ h("span", {
1273
+ "aria-label": "拖曳排序",
1274
+ role: "img",
1275
+ style: Tt,
1276
+ title: "拖曳排序",
1277
+ children: /* @__PURE__ */ h(l, {
1278
+ icon: de,
1279
+ size: 20
1280
+ })
1281
+ }),
1282
+ /* @__PURE__ */ g("div", {
1283
+ style: nt,
1284
+ children: [/* @__PURE__ */ g(p, {
1285
+ component: "span",
1286
+ ellipsis: !0,
1287
+ variant: "label-primary",
1288
+ children: [e.label, e.required ? /* @__PURE__ */ h("sup", {
1289
+ "aria-label": "必填",
1290
+ style: kt,
1291
+ children: "*"
1292
+ }) : null]
1293
+ }), /* @__PURE__ */ g(p, {
1294
+ color: "text-neutral",
1295
+ component: "span",
1296
+ ellipsis: !0,
1297
+ variant: "caption",
1298
+ children: [
1299
+ Ut(e.type),
1300
+ " ·",
1301
+ e.required ? " 必填" : " 選填",
1302
+ " ·",
1303
+ e.fieldKey
1304
+ ]
1305
+ })]
1306
+ }),
1307
+ /* @__PURE__ */ g("div", {
1308
+ onClick: (e) => e.stopPropagation(),
1309
+ style: rt,
1310
+ children: [/* @__PURE__ */ h("div", {
1311
+ style: it,
1312
+ children: /* @__PURE__ */ h(ce, {
1313
+ checked: !!e.required,
1314
+ disabled: n,
1315
+ label: "必填",
1316
+ onChange: (t) => Dn(e.fieldKey, t.target.checked)
1317
+ })
1318
+ }), /* @__PURE__ */ h(s, {
1319
+ disabled: n,
1320
+ icon: me,
1321
+ iconType: "icon-only",
1322
+ onClick: () => hn(e.fieldKey),
1323
+ variant: "destructive-ghost",
1324
+ children: "移除欄位"
1325
+ })]
1326
+ })
1327
+ ]
1328
+ });
1329
+ }
1330
+ function nr() {
1331
+ return /* @__PURE__ */ g("div", {
1332
+ style: N,
1333
+ children: [/* @__PURE__ */ h(p, {
1334
+ component: "h2",
1335
+ variant: "h3",
1336
+ children: "填寫預覽"
1337
+ }), /* @__PURE__ */ h(t, {
1338
+ dataSourceContext: { kind: "preview" },
1339
+ onChange: En,
1340
+ schema: y,
1341
+ uiSchema: x,
1342
+ value: Ke
1343
+ })]
1344
+ });
1345
+ }
1346
+ function rr() {
1347
+ return /* @__PURE__ */ g("div", {
1348
+ style: N,
1349
+ children: [/* @__PURE__ */ h(p, {
1350
+ component: "h2",
1351
+ variant: "h3",
1352
+ children: "Schema"
1353
+ }), /* @__PURE__ */ g("div", {
1354
+ style: yt,
1355
+ children: [
1356
+ ir("Form Schema", "schemaJson", /* @__PURE__ */ h(qe, {
1357
+ height: "360px",
1358
+ name: "schemaJson",
1359
+ onChange: On,
1360
+ placeholder: "輸入 Form Schema JSON",
1361
+ value: fe
1362
+ })),
1363
+ ir("UI Schema", "uiSchemaJson", /* @__PURE__ */ h(qe, {
1364
+ height: "240px",
1365
+ name: "uiSchemaJson",
1366
+ onChange: kn,
1367
+ placeholder: "輸入 UI Schema JSON",
1368
+ value: Ge
1369
+ })),
1370
+ M ? /* @__PURE__ */ h(p, {
1371
+ color: "text-error",
1372
+ style: St,
1373
+ variant: "body",
1374
+ children: M
1375
+ }) : null
1376
+ ]
1377
+ })]
1378
+ });
1379
+ }
1380
+ function ir(t, n, r) {
1381
+ return /* @__PURE__ */ h("div", {
1382
+ style: bt,
1383
+ children: /* @__PURE__ */ h("div", {
1384
+ style: xt,
1385
+ children: /* @__PURE__ */ h(e, {
1386
+ label: t,
1387
+ name: n,
1388
+ children: r
1389
+ })
1390
+ })
1391
+ });
1392
+ }
1393
+ }
1394
+ function Ut(e) {
1395
+ return Je.find((t) => t.type === e)?.label ?? e;
1396
+ }
1397
+ function Wt(e) {
1398
+ return `${e.key}@${e.version}`;
1399
+ }
1400
+ function Gt(e) {
1401
+ return {
1402
+ id: Wt(e),
1403
+ name: `${e.label} · ${e.key} v${e.version}`
1404
+ };
1405
+ }
1406
+ function Kt(e) {
1407
+ return e ? e.from.kind === "FIELD" ? e.from.fieldKey : It : Lt;
1408
+ }
1409
+ function qt(e) {
1410
+ switch (e) {
1411
+ case "BOOLEAN": return !1;
1412
+ case "NUMBER": return 0;
1413
+ case "STRING_ARRAY": return "";
1414
+ case "STRING": return "";
1415
+ default: return "";
1416
+ }
1417
+ }
1418
+ function Jt(e, t) {
1419
+ let n = e?.from.kind === "CONSTANT" ? e.from.value : "";
1420
+ return t === "NUMBER" ? typeof n == "number" ? String(n) : "" : typeof n == "string" ? n : "";
1421
+ }
1422
+ function Yt(e) {
1423
+ return !!(e.visibleWhen || e.requiredWhen || e.readonlyWhen);
1424
+ }
1425
+ function Xt(e) {
1426
+ return {
1427
+ id: e.fieldKey,
1428
+ name: e.label
1429
+ };
1430
+ }
1431
+ function Zt(e) {
1432
+ return e.type === "text" || e.type === "textarea";
1433
+ }
1434
+ function Qt(e) {
1435
+ return typeof e == "string" ? e : "";
1436
+ }
1437
+ function $t(e) {
1438
+ let t = e.split(/[\n,]/u).map((e) => e.trim()).filter(Boolean);
1439
+ return t.length ? t : void 0;
1440
+ }
1441
+ function en(e) {
1442
+ return e?.join("\n") ?? "";
1443
+ }
1444
+ function I(e) {
1445
+ return JSON.stringify(e, null, 2);
1446
+ }
1447
+ function tn(e, t, n) {
1448
+ return e.map((e, r) => r === t ? {
1449
+ ...e,
1450
+ ...n
1451
+ } : e);
1452
+ }
1453
+ function nn(e) {
1454
+ let t = e.length + 1;
1455
+ return {
1456
+ label: `選項 ${t}`,
1457
+ value: L(e, t)
1458
+ };
1459
+ }
1460
+ function L(e, t) {
1461
+ let n = `option_${t}`;
1462
+ return e.some((e) => e.value === n) ? L(e, t + 1) : n;
1463
+ }
1464
+ function rn(e, t, n) {
1465
+ let r = e[t];
1466
+ if (!r || t === n) return [...e];
1467
+ let i = e.filter((e, n) => n !== t);
1468
+ return [
1469
+ ...i.slice(0, n),
1470
+ r,
1471
+ ...i.slice(n)
1472
+ ];
1473
+ }
1474
+ //#endregion
1475
+ export { F as t };
1476
+
1477
+ //# sourceMappingURL=FormBuilderView-Do9-MIAe.js.map