@rytass/bpm-core-react 0.11.0 → 0.12.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 (51) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/dist/chunks/FormBuilderView-CLFlfDGe.cjs +3 -0
  3. package/dist/chunks/FormBuilderView-CLFlfDGe.cjs.map +1 -0
  4. package/dist/chunks/FormBuilderView-D4xIuPYB.js +1960 -0
  5. package/dist/chunks/FormBuilderView-D4xIuPYB.js.map +1 -0
  6. package/dist/chunks/FormRendererView-BxGT16z0.cjs +2 -0
  7. package/dist/chunks/FormRendererView-BxGT16z0.cjs.map +1 -0
  8. package/dist/chunks/FormRendererView-DUceSOXe.js +798 -0
  9. package/dist/chunks/FormRendererView-DUceSOXe.js.map +1 -0
  10. package/dist/chunks/{compose-CUOe5Ia9.js → compose-Bb-REfoB.js} +4 -4
  11. package/dist/chunks/{compose-CUOe5Ia9.js.map → compose-Bb-REfoB.js.map} +1 -1
  12. package/dist/chunks/{compose-CyRkXdeu.cjs → compose-DzRYZcqe.cjs} +2 -2
  13. package/dist/chunks/{compose-CyRkXdeu.cjs.map → compose-DzRYZcqe.cjs.map} +1 -1
  14. package/dist/chunks/{designer-Cb3WAC46.js → designer-C6oIO9Kq.js} +2 -2
  15. package/dist/chunks/{designer-Cb3WAC46.js.map → designer-C6oIO9Kq.js.map} +1 -1
  16. package/dist/chunks/{designer-zLliyrHu.cjs → designer-gFUdImeZ.cjs} +2 -2
  17. package/dist/chunks/{designer-zLliyrHu.cjs.map → designer-gFUdImeZ.cjs.map} +1 -1
  18. package/dist/chunks/{detail-Cmw-aQcu.js → detail-BgKgMvYx.js} +391 -390
  19. package/dist/chunks/{detail-Cmw-aQcu.js.map → detail-BgKgMvYx.js.map} +1 -1
  20. package/dist/chunks/{detail-Bp2Nv0cs.cjs → detail-Dnz5aaI-.cjs} +2 -2
  21. package/dist/chunks/{detail-Bp2Nv0cs.cjs.map → detail-Dnz5aaI-.cjs.map} +1 -1
  22. package/dist/pages/instances/detail/index.cjs +1 -1
  23. package/dist/pages/instances/detail/index.js +1 -1
  24. package/dist/pages/templates/compose/index.cjs +1 -1
  25. package/dist/pages/templates/compose/index.js +1 -1
  26. package/dist/pages/templates/designer/index.cjs +1 -1
  27. package/dist/pages/templates/designer/index.js +1 -1
  28. package/dist/views/forms/builder/index.cjs +1 -1
  29. package/dist/views/forms/builder/index.js +1 -1
  30. package/dist/views/forms/renderer/form-data-source-field.d.ts +16 -0
  31. package/dist/views/forms/renderer/index.cjs +1 -1
  32. package/dist/views/forms/renderer/index.js +1 -1
  33. package/dist/views/instances/detail/index.cjs +1 -1
  34. package/dist/views/instances/detail/index.js +1 -1
  35. package/dist/views/instances/new/index.cjs +1 -1
  36. package/dist/views/instances/new/index.cjs.map +1 -1
  37. package/dist/views/instances/new/index.js +48 -48
  38. package/dist/views/instances/new/index.js.map +1 -1
  39. package/dist/views/templates/compose/index.cjs +1 -1
  40. package/dist/views/templates/compose/index.js +1 -1
  41. package/dist/views/templates/designer/index.cjs +1 -1
  42. package/dist/views/templates/designer/index.js +1 -1
  43. package/package.json +3 -3
  44. package/dist/chunks/FormBuilderView-CAqjOYAP.cjs +0 -3
  45. package/dist/chunks/FormBuilderView-CAqjOYAP.cjs.map +0 -1
  46. package/dist/chunks/FormBuilderView-TzSezeqC.js +0 -1479
  47. package/dist/chunks/FormBuilderView-TzSezeqC.js.map +0 -1
  48. package/dist/chunks/FormRendererView-BurlEDUu.js +0 -580
  49. package/dist/chunks/FormRendererView-BurlEDUu.js.map +0 -1
  50. package/dist/chunks/FormRendererView-Dde1s3I0.cjs +0 -2
  51. package/dist/chunks/FormRendererView-Dde1s3I0.cjs.map +0 -1
@@ -1,580 +0,0 @@
1
- "use client";
2
- import { t as e } from "./bpm-form-field-Cao0rMol.js";
3
- import { useCallback as t, useEffect as n, useMemo as r, useRef as i, useState as a } from "react";
4
- import { AutoComplete as o, Button as s, CheckboxGroup as c, DatePicker as l, DateTimePicker as u, Input as d, RadioGroup as f, Select as p, Textarea as m, Toggle as h, Typography as g, Upload as _ } from "@mezzanine-ui/react";
5
- import { jsx as v, jsxs as y } from "react/jsx-runtime";
6
- import { buildFormRendererValues as b, clampOptionalNumber as x, formatDatePickerValue as S, formatDateTimePickerValue as C, isFormRendererFieldReadonly as w, isFormRendererFieldRequired as T, mergeFormDataSourceOptions as E, parseOptionalNumberInput as D, previewFormFieldOptions as ee, previewResolveFormFieldOptions as te, readDatePickerValue as O, readFieldOptionAsSelectOption as k, readFormDataSourceErrorCode as ne, readFormDataSourceErrorMessage as re, readFormDataSourceSelectedValues as ie, readFormDataSourceValueSignature as A, readFormFieldOptions as ae, readMissingFormDataSourceDependencies as oe, readMissingFormDataSourceOptionValues as j, readSelectOption as M, readSelectedFormDataSourceOptions as N, readVisibleFormRendererFields as se, resolveFormFieldOptions as ce } from "@rytass/bpm-core-client/form";
7
- import { isFormDataSourceFieldDefinition as le, isFormStaticOptionFieldDefinition as P, readFormFieldSelectionMode as F } from "@rytass/bpm-core-shared/form";
8
- //#region src/views/forms/renderer/form-data-source-field.ts
9
- var ue = {
10
- canRetry: !1,
11
- error: null,
12
- hasValue: !1,
13
- hasNextPage: !1,
14
- invalidValues: [],
15
- onReachBottom: () => void 0,
16
- onSearch: () => void 0,
17
- options: [],
18
- retry: () => void 0,
19
- status: "IDLE"
20
- }, de = [], fe = 10, pe = ["FORM_DATA_SOURCE_SEARCH_NOT_SUPPORTED", "FORM_DATA_SOURCE_SEARCH_TOO_SHORT"];
21
- function I(e) {
22
- let o = le(e.field) ? e.field : null, s = o ? e.optionSnapshots?.[o.fieldKey] : void 0, c = o ? JSON.stringify({
23
- dataSource: o.dataSource,
24
- fieldKey: o.fieldKey,
25
- type: o.type
26
- }) : "", l = JSON.stringify(s ?? null), u = r(() => s?.options ?? [], [l]), d = JSON.stringify(e.formData), f = JSON.stringify(e.initialFormData ?? {}), p = JSON.stringify(e.schema), m = JSON.stringify(e.uiSchema), h = e.context?.kind, g = e.context?.kind === "runtime" ? e.context.instanceId : void 0, _ = e.context?.kind === "runtime" ? e.context.templateId : void 0, v = o ? e.formData[o.fieldKey] : void 0, y = A(v), b = r(() => ie(v), [y]), x = b.length > 0, S = o ? JSON.stringify({
27
- bindings: o.dataSource.bindings.map((t) => t.from.kind === "FIELD" ? {
28
- fieldKey: t.from.fieldKey,
29
- value: e.formData[t.from.fieldKey]
30
- } : { value: t.from.value }),
31
- value: e.initialFormData !== void 0 || e.initialValue !== void 0 ? e.formData[o.fieldKey] : void 0
32
- }) : "", C = r(() => {
33
- if (h === "preview") return { kind: "preview" };
34
- if (h === "runtime" && !e.readonly) return {
35
- instanceId: g,
36
- kind: "runtime",
37
- templateId: _
38
- };
39
- }, [
40
- g,
41
- h,
42
- _,
43
- e.readonly
44
- ]), w = o ? (e.initialFormData !== void 0 || e.initialValue !== void 0) && A(e.initialValue) !== y : !1, T = o ? e.initialFormData !== void 0 && o.dataSource.bindings.some((t) => t.from.kind === "FIELD" && A(e.initialFormData?.[t.from.fieldKey]) !== A(e.formData[t.from.fieldKey])) : !1, D = !!((s || x) && (w || T)), O = !!(o && C && D && x), k = ge({
45
- hasSnapshot: !!s,
46
- hasValue: x,
47
- isStale: D,
48
- readonly: e.readonly
49
- }), j = !!(o && C && o.type !== "autocomplete"), M = _e(D, j && o !== null && oe(o, e.formData).length > 0), [se, P] = a([]), [F, de] = a(""), [I, L] = a(null), [R, me] = a(null), [B, V] = a(() => o ? j ? M : k : "IDLE"), [be, H] = a(null), U = i(0), W = i(0), G = i(0), K = i(null), q = i(null), J = i({
50
- cursor: null,
51
- searchText: ""
52
- }), Y = r(() => Object.entries(e.formData).reduce((e, [t, n]) => n === void 0 ? e : {
53
- ...e,
54
- [t]: n
55
- }, {}), [d]), X = r(() => E(u, se), [se, u]), Z = R && R.signature === S ? R : null, xe = O && !Z, Q = he({
56
- options: X,
57
- resolution: Z,
58
- resolvePending: xe,
59
- value: v
60
- }), $ = t((t, n) => {
61
- if (!o || !C) return;
62
- let r = W.current + 1;
63
- W.current = r, J.current = {
64
- cursor: n,
65
- searchText: t
66
- }, K.current?.abort();
67
- let i = new AbortController();
68
- K.current = i, V(M), H(null), (C.kind === "preview" ? ee({
69
- cursor: n,
70
- fieldKey: o.fieldKey,
71
- formData: Y,
72
- schema: e.schema,
73
- searchText: t,
74
- signal: i.signal,
75
- uiSchema: e.uiSchema
76
- }) : ae({
77
- cursor: n,
78
- fieldKey: o.fieldKey,
79
- formData: Y,
80
- instanceId: C.instanceId ?? null,
81
- searchText: t,
82
- signal: i.signal,
83
- templateId: C.templateId ?? null
84
- })).then((a) => {
85
- z(i, W, r) || (P((t) => {
86
- let r = N(o ? e.formData[o.fieldKey] : void 0, t);
87
- return E(r, n ? t : [], a.options);
88
- }), L(a.nextCursor), H(null), U.current = n ? U.current + a.options.length : a.options.length, a.nextCursor && a.options.length > 0 && U.current < fe && Se.current(t, a.nextCursor), V(a.waitingForFieldKeys.length ? "WAITING_FOR_DEPENDENCIES" : "VALID"));
89
- }).catch((e) => {
90
- if (z(i, W, r)) return;
91
- let t = re(e) ?? "選項來源暫時無法使用。", n = ne(e);
92
- H(t), V(ve(!!(n && pe.includes(n)), x));
93
- });
94
- }, [
95
- c,
96
- C,
97
- x,
98
- M,
99
- Y,
100
- p,
101
- m
102
- ]), Se = i($);
103
- Se.current = $;
104
- let Ce = t(() => {
105
- if (!o || !C || b.length === 0) return;
106
- let t = S, n = G.current + 1;
107
- G.current = n, q.current?.abort();
108
- let r = new AbortController();
109
- q.current = r, H(null), (C.kind === "preview" ? te({
110
- fieldKey: o.fieldKey,
111
- formData: Y,
112
- schema: e.schema,
113
- signal: r.signal,
114
- uiSchema: e.uiSchema,
115
- values: b
116
- }) : ce({
117
- fieldKey: o.fieldKey,
118
- formData: Y,
119
- instanceId: C.instanceId ?? null,
120
- signal: r.signal,
121
- templateId: C.templateId ?? null,
122
- values: b
123
- })).then((e) => {
124
- if (!z(r, G, n)) {
125
- if (e.waitingForFieldKeys.length) {
126
- V("WAITING_FOR_DEPENDENCIES");
127
- return;
128
- }
129
- P((t) => E(t, e.options)), me({
130
- signature: t,
131
- unresolvedValues: e.unresolvedValues
132
- }), V("VALID");
133
- }
134
- }).catch((e) => {
135
- z(r, G, n) || (V("UNAVAILABLE"), H(re(e) ?? "選項來源暫時無法使用。"));
136
- });
137
- }, [
138
- S,
139
- c,
140
- C,
141
- Y,
142
- p,
143
- b,
144
- m
145
- ]), we = i(Ce);
146
- we.current = Ce, n(() => {
147
- if (W.current += 1, K.current?.abort(), P((e) => N(v, e)), L((e) => e === null ? e : null), de((e) => e && ""), H((e) => e && null), !o) {
148
- V("IDLE");
149
- return;
150
- }
151
- if (!j) {
152
- V(k);
153
- return;
154
- }
155
- Se.current("", null);
156
- }, [
157
- j,
158
- c,
159
- C,
160
- S,
161
- f,
162
- e.readonly,
163
- M,
164
- k,
165
- l
166
- ]), n(() => {
167
- O && we.current();
168
- }, [
169
- S,
170
- C,
171
- O
172
- ]), n(() => () => {
173
- K.current?.abort(), q.current?.abort();
174
- }, []);
175
- let Te = t((e) => {
176
- de(e), P((e) => N(v, e)), L(null), $(e, null);
177
- }, [$]), Ee = t(() => {
178
- I && $(F, I);
179
- }, [
180
- $,
181
- I,
182
- F
183
- ]), De = t(() => {
184
- C && ($(J.current.searchText, J.current.cursor), O && we.current());
185
- }, [
186
- C,
187
- $,
188
- O
189
- ]);
190
- return o ? {
191
- canRetry: !!C,
192
- error: be,
193
- hasValue: x,
194
- hasNextPage: !!I,
195
- invalidValues: Q,
196
- onReachBottom: Ee,
197
- onSearch: Te,
198
- options: X,
199
- retry: De,
200
- status: ye({
201
- invalidValues: Q,
202
- resolvePending: xe,
203
- status: B
204
- })
205
- } : ue;
206
- }
207
- function L(e) {
208
- switch (e.status) {
209
- case "WAITING_FOR_DEPENDENCIES": return "請先填寫相依欄位。";
210
- case "STALE": return "選項需要重新載入或驗證。";
211
- case "INVALID": return e.invalidValues.length ? `無法辨識選項:${e.invalidValues.join("、")}` : "目前選項已失效,請重新選擇。";
212
- case "UNAVAILABLE": return e.error ?? "選項來源暫時無法使用。";
213
- case "VALID": return e.error ?? (e.options.length ? null : "目前沒有可用選項。");
214
- default: return e.error;
215
- }
216
- }
217
- function R(e) {
218
- return e.hasValue && e.status !== "VALID";
219
- }
220
- function me(e) {
221
- let t = e.filter(R);
222
- return t.length === 0 ? null : t.every((e) => e.status === "LOADING" || e.status === "STALE") ? "選項驗證中,請稍候再送出。" : "請先完成動態選項驗證。";
223
- }
224
- function he(e) {
225
- return e.resolution ? e.resolution.unresolvedValues : e.resolvePending ? de : j(e.value, e.options);
226
- }
227
- function ge(e) {
228
- return e.isStale ? "STALE" : e.hasSnapshot ? "VALID" : e.readonly && e.hasValue ? "UNAVAILABLE" : "IDLE";
229
- }
230
- function _e(e, t) {
231
- return t ? "WAITING_FOR_DEPENDENCIES" : e ? "STALE" : "LOADING";
232
- }
233
- function ve(e, t) {
234
- return e ? t ? "VALID" : "IDLE" : "UNAVAILABLE";
235
- }
236
- function ye(e) {
237
- return e.status === "LOADING" || e.status === "UNAVAILABLE" || e.status === "WAITING_FOR_DEPENDENCIES" ? e.status : e.invalidValues.length ? "INVALID" : e.resolvePending ? "STALE" : e.status;
238
- }
239
- function z(e, t, n) {
240
- return e.signal.aborted || t.current !== n;
241
- }
242
- //#endregion
243
- //#region src/views/forms/renderer/FormRendererView.tsx
244
- var B = {
245
- alignItems: "start",
246
- display: "grid",
247
- gap: 12,
248
- gridTemplateColumns: "repeat(12, minmax(0, 1fr))"
249
- }, V = { gridColumn: "1 / -1" }, be = {
250
- alignItems: "start",
251
- display: "grid",
252
- gap: 8,
253
- minWidth: 0
254
- }, H = {
255
- minWidth: "100%",
256
- width: "100%"
257
- };
258
- function U(e) {
259
- e && (e.style.width = "100%");
260
- }
261
- function W({ dataSourceContext: e, dataSourceInitialValues: t, emptyText: o = "尚未建立欄位。", errors: s = {}, maxWidth: c, onChange: l, onDataSourceStateChange: u, onUploadAttachment: d, optionSnapshots: f, readonly: p = !1, schema: m, singleColumn: h = !1, uiSchema: _, value: y }) {
262
- let [x, S] = a(() => b(m.fields, y ?? {})), C = r(() => b(m.fields, y ?? x), [
263
- x,
264
- m.fields,
265
- y
266
- ]), w = i(C), T = r(() => se(m, _, C), [
267
- m,
268
- _,
269
- C
270
- ]);
271
- n(() => {
272
- w.current = C;
273
- }, [C]), n(() => {
274
- S((e) => b(m.fields, y ?? e));
275
- }, [m.fields, y]);
276
- function E(e, t) {
277
- let n = {
278
- ...w.current,
279
- [e]: t
280
- };
281
- w.current = n, y || S(n), l?.(n);
282
- }
283
- return T.length ? /* @__PURE__ */ v("div", {
284
- style: {
285
- ...B,
286
- ...h ? {
287
- maxWidth: c,
288
- width: "100%"
289
- } : {}
290
- },
291
- children: T.map((n) => /* @__PURE__ */ v(G, {
292
- dataSourceContext: e,
293
- dataSourceInitialValues: t,
294
- field: n,
295
- error: s[n.fieldKey] ?? null,
296
- fields: m.fields,
297
- onChange: E,
298
- onDataSourceStateChange: u,
299
- onUploadAttachment: d,
300
- optionSnapshots: f,
301
- readonly: p,
302
- schema: m,
303
- style: {
304
- ...be,
305
- gridColumn: `span ${h ? 12 : Y(n, _)}`
306
- },
307
- value: C[n.fieldKey],
308
- values: C,
309
- uiSchema: _
310
- }, n.fieldKey))
311
- }) : /* @__PURE__ */ v("div", {
312
- style: B,
313
- children: /* @__PURE__ */ v(g, {
314
- color: "text-neutral",
315
- style: V,
316
- variant: "body",
317
- children: m.fields.length > 0 ? "目前條件下沒有可填寫欄位。" : o
318
- })
319
- });
320
- }
321
- function G({ dataSourceContext: t, dataSourceInitialValues: r, error: i, field: a, fields: o, onChange: c, onDataSourceStateChange: l, onUploadAttachment: u, optionSnapshots: d, readonly: f, schema: p, style: m, value: h, values: _, uiSchema: b }) {
322
- let x = T(a, o, _), S = f || w(a, o, _), C = I({
323
- context: t,
324
- field: a,
325
- formData: _,
326
- initialFormData: r,
327
- initialValue: r?.[a.fieldKey],
328
- optionSnapshots: d,
329
- readonly: S,
330
- schema: p,
331
- uiSchema: b
332
- }), E = L(C), D = JSON.stringify({
333
- hasValue: C.hasValue,
334
- invalidValues: C.invalidValues,
335
- status: C.status
336
- });
337
- return n(() => {
338
- le(a) && l?.(a.fieldKey, {
339
- hasValue: C.hasValue,
340
- invalidValues: C.invalidValues,
341
- status: C.status
342
- });
343
- }, [
344
- D,
345
- a.fieldKey,
346
- l
347
- ]), /* @__PURE__ */ y("div", {
348
- "data-form-field-key": a.fieldKey,
349
- style: m,
350
- children: [
351
- /* @__PURE__ */ v(e, {
352
- label: a.label,
353
- name: a.fieldKey,
354
- required: x,
355
- children: q(a, h, S, c, u, t, C)
356
- }),
357
- i ? /* @__PURE__ */ v(g, {
358
- color: "text-error",
359
- variant: "caption",
360
- children: i
361
- }) : null,
362
- E ? /* @__PURE__ */ y("div", {
363
- style: K,
364
- children: [/* @__PURE__ */ v(g, {
365
- color: C.status === "INVALID" || C.status === "UNAVAILABLE" ? "text-error" : "text-neutral",
366
- variant: "caption",
367
- children: E
368
- }), C.status === "UNAVAILABLE" && C.canRetry ? /* @__PURE__ */ v(s, {
369
- onClick: C.retry,
370
- size: "sub",
371
- type: "button",
372
- variant: "base-ghost",
373
- children: "重試"
374
- }) : null]
375
- }) : null
376
- ]
377
- });
378
- }
379
- var K = {
380
- alignItems: "center",
381
- display: "flex",
382
- gap: 8
383
- };
384
- function q(e, t, n, r, i, a, o) {
385
- if (e.type === "textarea") return /* @__PURE__ */ v(m, {
386
- onChange: (t) => r(e.fieldKey, t.target.value),
387
- placeholder: e.placeholder ?? "請輸入多行文字",
388
- readOnly: n,
389
- ref: U,
390
- rows: 3,
391
- style: H,
392
- value: X(t)
393
- });
394
- if (e.type === "boolean") return /* @__PURE__ */ v(h, {
395
- checked: t === !0,
396
- disabled: n,
397
- label: "啟用",
398
- onChange: (t) => r(e.fieldKey, t.target.checked)
399
- });
400
- if (le(e)) return J(e, t, n, r, a, o);
401
- if (P(e) && e.type === "checkbox") {
402
- let i = e.options.map(k);
403
- return /* @__PURE__ */ v(p, {
404
- mode: "multiple",
405
- onChange: (t) => r(e.fieldKey, t?.length ? t.map((e) => e.id) : void 0),
406
- options: i,
407
- placeholder: e.placeholder ?? "請選擇一或多個選項",
408
- readOnly: n,
409
- value: i.filter((e) => Z(t).includes(e.id))
410
- });
411
- }
412
- if (P(e)) {
413
- let i = e.options.map(k);
414
- return /* @__PURE__ */ v(p, {
415
- onChange: (t) => r(e.fieldKey, t?.id ?? void 0),
416
- options: i,
417
- placeholder: e.placeholder ?? "請選擇",
418
- readOnly: n,
419
- value: M(i, X(t))
420
- });
421
- }
422
- return e.type === "file_upload" ? /* @__PURE__ */ v(_, {
423
- accept: e.acceptedMimeTypes?.join(","),
424
- disabled: n,
425
- maxFiles: e.maxFiles,
426
- mode: "button-list",
427
- ...(e.maxFiles ?? 1) > 1 ? { multiple: !0 } : {},
428
- onChange: (t) => r(e.fieldKey, t.length ? t.map((e) => e.id) : void 0),
429
- onUpload: async (t) => Promise.all(t.map(async (t) => ({
430
- file: t,
431
- id: (i ? await i(e, t) : { id: `${t.name}-${t.lastModified}` }).id,
432
- progress: 100,
433
- status: "done"
434
- }))),
435
- size: "sub"
436
- }) : e.type === "date" ? /* @__PURE__ */ v(l, {
437
- format: "YYYY-MM-DD",
438
- fullWidth: !0,
439
- onChange: (t) => r(e.fieldKey, S(t)),
440
- placeholder: e.placeholder ?? Q(e.type),
441
- readOnly: n,
442
- value: O(t)
443
- }) : e.type === "datetime" ? /* @__PURE__ */ v(u, {
444
- formatDate: "YYYY-MM-DD",
445
- formatTime: "HH:mm",
446
- fullWidth: !0,
447
- hideSecond: !0,
448
- onChange: (t) => r(e.fieldKey, C(t)),
449
- placeholderLeft: "選擇日期",
450
- placeholderRight: "選擇時間",
451
- readOnly: n,
452
- value: O(t)
453
- }) : e.type === "number" || e.type === "money" ? /* @__PURE__ */ v(d, {
454
- fullWidth: !0,
455
- max: e.maximum,
456
- min: e.minimum,
457
- onChange: (t) => r(e.fieldKey, x(D(t.target.value), {
458
- max: e.maximum,
459
- min: e.minimum
460
- })),
461
- placeholder: e.placeholder ?? Q(e.type),
462
- ...n ? { readonly: !0 } : {},
463
- showSpinner: !0,
464
- value: xe(t),
465
- variant: "measure"
466
- }) : /* @__PURE__ */ v(d, {
467
- fullWidth: !0,
468
- onChange: (t) => r(e.fieldKey, t.target.value),
469
- placeholder: e.placeholder ?? Q(e.type),
470
- ...n ? { readonly: !0 } : {},
471
- value: X(t),
472
- variant: "base"
473
- });
474
- }
475
- function J(e, t, n, r, i, a) {
476
- let s = a.options.map(k), l = N(t, a.options).map(k), u = a.status === "LOADING", d = a.status === "WAITING_FOR_DEPENDENCIES", m = !!i && !n, h = n || d, g = n;
477
- return e.type === "autocomplete" ? F(e) === "multiple" ? /* @__PURE__ */ v(o, {
478
- asyncData: m,
479
- clearSearchText: !0,
480
- disabled: g,
481
- disabledOptionsFilter: m,
482
- globalPortal: !0,
483
- loading: u,
484
- mode: "multiple",
485
- onChange: (t) => r(e.fieldKey, t.length ? t.map((e) => e.id) : void 0),
486
- onReachBottom: a.hasNextPage ? a.onReachBottom : void 0,
487
- onSearch: m ? a.onSearch : void 0,
488
- options: s,
489
- placeholder: e.placeholder ?? "請輸入或選擇",
490
- readOnly: n,
491
- searchDebounceTime: 300,
492
- value: l
493
- }) : /* @__PURE__ */ v(o, {
494
- asyncData: m,
495
- clearSearchText: !0,
496
- disabled: g,
497
- disabledOptionsFilter: m,
498
- globalPortal: !0,
499
- loading: u,
500
- mode: "single",
501
- onChange: (t) => r(e.fieldKey, t?.id ?? void 0),
502
- onReachBottom: a.hasNextPage ? a.onReachBottom : void 0,
503
- onSearch: m ? a.onSearch : void 0,
504
- options: s,
505
- placeholder: e.placeholder ?? "請輸入或選擇",
506
- readOnly: n,
507
- searchDebounceTime: 300,
508
- value: l[0] ?? null
509
- }) : e.type === "radio" ? /* @__PURE__ */ v(f, {
510
- disabled: h,
511
- name: e.fieldKey,
512
- onChange: (t) => r(e.fieldKey, t.target.value || void 0),
513
- options: s,
514
- value: X(t)
515
- }) : e.type === "checkbox" ? /* @__PURE__ */ v(c, {
516
- disabled: h,
517
- name: e.fieldKey,
518
- onChange: (t) => r(e.fieldKey, t.target.values.length ? t.target.values : void 0),
519
- options: s.map((e) => ({
520
- label: e.name,
521
- value: e.id
522
- })),
523
- value: [...Z(t)]
524
- }) : F(e) === "multiple" ? /* @__PURE__ */ v(p, {
525
- disabled: h,
526
- loading: u,
527
- mode: "multiple",
528
- onChange: (t) => r(e.fieldKey, t.length ? t.map((e) => e.id) : void 0),
529
- onReachBottom: a.hasNextPage ? a.onReachBottom : void 0,
530
- options: s,
531
- placeholder: e.placeholder ?? "請選擇一或多個選項",
532
- readOnly: n,
533
- value: l
534
- }) : /* @__PURE__ */ v(p, {
535
- disabled: h,
536
- loading: u,
537
- onChange: (t) => r(e.fieldKey, t?.id ?? void 0),
538
- onReachBottom: a.hasNextPage ? a.onReachBottom : void 0,
539
- options: s,
540
- placeholder: e.placeholder ?? "請選擇",
541
- readOnly: n,
542
- value: l[0] ?? null
543
- });
544
- }
545
- function Y(e, t) {
546
- return {
547
- FULL: 12,
548
- HALF: 6,
549
- THIRD: 4
550
- }[t.layout.find((t) => t.fieldKey === e.fieldKey)?.width ?? "FULL"];
551
- }
552
- function X(e) {
553
- return typeof e == "string" ? e : "";
554
- }
555
- function Z(e) {
556
- return Array.isArray(e) ? e : [];
557
- }
558
- function xe(e) {
559
- return typeof e == "number" ? String(e) : "";
560
- }
561
- function Q(e) {
562
- return {
563
- boolean: "",
564
- autocomplete: "請輸入或選擇",
565
- checkbox: "請選擇一或多個選項",
566
- date: "請選擇日期",
567
- datetime: "請選擇日期與時間",
568
- file_upload: "請上傳附件",
569
- money: "請輸入金額",
570
- number: "請輸入數字",
571
- radio: "請選擇一個選項",
572
- select: "請選擇一個選項",
573
- text: "請輸入文字",
574
- textarea: "請輸入多行文字"
575
- }[e];
576
- }
577
- //#endregion
578
- export { I as a, me as i, R as n, L as r, W as t };
579
-
580
- //# sourceMappingURL=FormRendererView-BurlEDUu.js.map