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