@rytass/bpm-core-react 0.13.5 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +97 -0
- package/dist/chunks/FormBuilderView-6bCbIkz6.cjs +3 -0
- package/dist/chunks/FormBuilderView-6bCbIkz6.cjs.map +1 -0
- package/dist/chunks/{FormBuilderView-BYLN6W-P.js → FormBuilderView-CLg-JYmu.js} +495 -452
- package/dist/chunks/FormBuilderView-CLg-JYmu.js.map +1 -0
- package/dist/chunks/FormRendererView-DU9LLrOF.js +999 -0
- package/dist/chunks/FormRendererView-DU9LLrOF.js.map +1 -0
- package/dist/chunks/FormRendererView-gctFIqwC.cjs +4 -0
- package/dist/chunks/FormRendererView-gctFIqwC.cjs.map +1 -0
- package/dist/chunks/{compose-6P64PO1i.js → compose-BtQPBd1Q.js} +6 -5
- package/dist/chunks/compose-BtQPBd1Q.js.map +1 -0
- package/dist/chunks/compose-DZhTQOt4.cjs +2 -0
- package/dist/chunks/compose-DZhTQOt4.cjs.map +1 -0
- package/dist/chunks/{designer-C3s2kSna.js → designer-CrbBRPUU.js} +1382 -1199
- package/dist/chunks/designer-CrbBRPUU.js.map +1 -0
- package/dist/chunks/designer-D3_lWmfa.cjs +65 -0
- package/dist/chunks/designer-D3_lWmfa.cjs.map +1 -0
- package/dist/chunks/detail-CVXb5Vy8.cjs +2 -0
- package/dist/chunks/detail-CVXb5Vy8.cjs.map +1 -0
- package/dist/chunks/{detail-pYEIk-jW.js → detail-_c21WQla.js} +862 -815
- package/dist/chunks/detail-_c21WQla.js.map +1 -0
- package/dist/chunks/routes-config-C1j_vFKo.cjs.map +1 -1
- package/dist/chunks/routes-config-yZbESPlw.js.map +1 -1
- package/dist/chunks/task-node-label-BF6UllxP.cjs +2 -0
- package/dist/chunks/task-node-label-BF6UllxP.cjs.map +1 -0
- package/dist/chunks/task-node-label-CWZgOBj0.js +9 -0
- package/dist/chunks/task-node-label-CWZgOBj0.js.map +1 -0
- package/dist/lib/member-profile-resolution.d.ts +48 -0
- package/dist/lib/routes-config.d.ts +1 -1
- package/dist/lib/task-node-label.d.ts +10 -0
- package/dist/pages/instances/detail/index.cjs +1 -1
- package/dist/pages/instances/detail/index.js +1 -1
- package/dist/pages/templates/compose/index.cjs +1 -1
- package/dist/pages/templates/compose/index.js +1 -1
- package/dist/pages/templates/designer/index.cjs +1 -1
- package/dist/pages/templates/designer/index.js +1 -1
- package/dist/views/forms/builder/index.cjs +1 -1
- package/dist/views/forms/builder/index.js +1 -1
- package/dist/views/forms/renderer/form-field-link.d.ts +16 -0
- package/dist/views/forms/renderer/index.cjs +1 -1
- package/dist/views/forms/renderer/index.js +2 -2
- package/dist/views/forms/renderer/member-field-options.d.ts +39 -0
- package/dist/views/forms/renderer/member-field.d.ts +21 -0
- package/dist/views/inbox/index.cjs +1 -1
- package/dist/views/inbox/index.cjs.map +1 -1
- package/dist/views/inbox/index.js +100 -97
- package/dist/views/inbox/index.js.map +1 -1
- package/dist/views/instances/detail/index.cjs +1 -1
- package/dist/views/instances/detail/index.js +1 -1
- package/dist/views/instances/detail/sections/container-helpers.d.ts +3 -2
- package/dist/views/instances/detail/sections/shared.d.ts +5 -0
- package/dist/views/instances/detail/submitted-by.d.ts +23 -0
- package/dist/views/instances/new/index.cjs +1 -1
- package/dist/views/instances/new/index.js +1 -1
- package/dist/views/sent/SentView.d.ts +1 -1
- package/dist/views/sent/index.cjs +1 -1
- package/dist/views/sent/index.cjs.map +1 -1
- package/dist/views/sent/index.js +2 -2
- package/dist/views/sent/index.js.map +1 -1
- package/dist/views/templates/compose/index.cjs +1 -1
- package/dist/views/templates/compose/index.js +1 -1
- package/dist/views/templates/designer/decision-policy-options.d.ts +8 -0
- package/dist/views/templates/designer/designer-version-labels.d.ts +12 -0
- package/dist/views/templates/designer/dry-run-assignee-label.d.ts +28 -0
- package/dist/views/templates/designer/dry-run-sample-data.d.ts +9 -0
- package/dist/views/templates/designer/dynamic-form-resolver-options.d.ts +35 -0
- package/dist/views/templates/designer/index.cjs +1 -1
- package/dist/views/templates/designer/index.js +1 -1
- package/dist/views/templates/designer/position-level-options.d.ts +17 -0
- package/package.json +3 -3
- package/dist/chunks/FormBuilderView-BYLN6W-P.js.map +0 -1
- package/dist/chunks/FormBuilderView-VmdPVbg7.cjs +0 -3
- package/dist/chunks/FormBuilderView-VmdPVbg7.cjs.map +0 -1
- package/dist/chunks/FormRendererView-Bs8lTb4k.cjs +0 -2
- package/dist/chunks/FormRendererView-Bs8lTb4k.cjs.map +0 -1
- package/dist/chunks/FormRendererView-UPowZZgw.js +0 -798
- package/dist/chunks/FormRendererView-UPowZZgw.js.map +0 -1
- package/dist/chunks/compose-6P64PO1i.js.map +0 -1
- package/dist/chunks/compose-BnSRL4ml.cjs +0 -2
- package/dist/chunks/compose-BnSRL4ml.cjs.map +0 -1
- package/dist/chunks/designer-C3s2kSna.js.map +0 -1
- package/dist/chunks/designer-_g58R6rQ.cjs +0 -65
- package/dist/chunks/designer-_g58R6rQ.cjs.map +0 -1
- package/dist/chunks/detail-Db-UOELp.cjs +0 -2
- package/dist/chunks/detail-Db-UOELp.cjs.map +0 -1
- package/dist/chunks/detail-pYEIk-jW.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,100 @@
|
|
|
1
|
+
## 0.15.0 (2026-10-13)
|
|
2
|
+
|
|
3
|
+
### ⚠️ Breaking Changes
|
|
4
|
+
|
|
5
|
+
- **workflow-engine / organization:** the engine now reads "today" in the organization time zone (`organizationTimeZone`, default `Asia/Taipei`) instead of UTC. For a membership or manager rule whose `effectiveFrom` / `effectiveTo` is today, approver resolution applies or retires it from local midnight — up to eight hours earlier than before in UTC+8. A host whose organization dates are kept in UTC sets `organizationTimeZone: 'UTC'` before upgrading. Running instances keep their tasks. ([d6e43f3](https://github.com/Rytass/BPMCore/commit/d6e43f3); this note was missing from the generated changelog because the footer sits on a `docs:` commit)
|
|
6
|
+
- **template:** publishing now refuses a `DYNAMIC_FORM` resolver whose member field can be left empty — the field must be `required`, not `hidden`, and have no `visibleWhen`. Drafts still save; versions already published are not re-validated. ([b3a3950](https://github.com/Rytass/BPMCore/commit/b3a3950))
|
|
7
|
+
|
|
8
|
+
### 🗄️ Upgrade
|
|
9
|
+
|
|
10
|
+
- New migrations add nullable columns and indexes only; no data is dropped. Hosts run with `migrationsRun: false`, so **run the migrations before deploying 0.15.0**.
|
|
11
|
+
|
|
12
|
+
### 🚀 Features
|
|
13
|
+
|
|
14
|
+
- **forms:** add store-only hidden fields and link display for text fields ([ae38a92](https://github.com/Rytass/BPMCore/commit/ae38a92))
|
|
15
|
+
- **inbox:** show node names instead of node ids in task lists ([e9e8f46](https://github.com/Rytass/BPMCore/commit/e9e8f46))
|
|
16
|
+
- **designer:** show who submitted on the applicant's behalf in the instance detail ([4bcb291](https://github.com/Rytass/BPMCore/commit/4bcb291))
|
|
17
|
+
- **designer:** pick approvers from a member field and show readable dry-run assignees ([bc9592e](https://github.com/Rytass/BPMCore/commit/bc9592e))
|
|
18
|
+
- **forms:** add a member field type ([0fca8d4](https://github.com/Rytass/BPMCore/commit/0fca8d4))
|
|
19
|
+
|
|
20
|
+
### 🩹 Fixes
|
|
21
|
+
|
|
22
|
+
- **template-designer:** name a member-field dry-run assignee by its field label ([465fcc3](https://github.com/Rytass/BPMCore/commit/465fcc3))
|
|
23
|
+
- **template-designer:** sample a dry-run member field with a placeholder, not the initiator ([b567e41](https://github.com/Rytass/BPMCore/commit/b567e41))
|
|
24
|
+
- **template:** refuse a DYNAMIC_FORM resolver on a member field that can be left empty ([b3a3950](https://github.com/Rytass/BPMCore/commit/b3a3950))
|
|
25
|
+
- **organization:** default organizationTimeZone to Asia/Taipei ([cc6b908](https://github.com/Rytass/BPMCore/commit/cc6b908))
|
|
26
|
+
- **forms:** keep the new-tab cue out of copied link text ([4fcd8e8](https://github.com/Rytass/BPMCore/commit/4fcd8e8))
|
|
27
|
+
- **forms:** harden hidden fields and link display after review ([9ce1f82](https://github.com/Rytass/BPMCore/commit/9ce1f82))
|
|
28
|
+
- **designer:** say the sent list includes cases submitted on someone's behalf ([bfd928f](https://github.com/Rytass/BPMCore/commit/bfd928f))
|
|
29
|
+
- **workflow-engine:** index the submitter column that the sent list now matches ([557f458](https://github.com/Rytass/BPMCore/commit/557f458))
|
|
30
|
+
- **workflow-engine:** leave out the refusals of seats the initiator exclusion removes ([959912e](https://github.com/Rytass/BPMCore/commit/959912e))
|
|
31
|
+
- **workflow-engine:** harden business key lookup and count its length in characters ([844ce82](https://github.com/Rytass/BPMCore/commit/844ce82))
|
|
32
|
+
- **designer:** keep capped-out member ids eligible in the form renderer ([b8b4d4b](https://github.com/Rytass/BPMCore/commit/b8b4d4b))
|
|
33
|
+
- **designer:** stop re-requesting unresolvable members and warn on optional member fields ([8d6afa5](https://github.com/Rytass/BPMCore/commit/8d6afa5))
|
|
34
|
+
- **forms:** keep member ids out of case titles and check member references on publish ([2b3c9c0](https://github.com/Rytass/BPMCore/commit/2b3c9c0))
|
|
35
|
+
|
|
36
|
+
### 🔥 Performance
|
|
37
|
+
|
|
38
|
+
- **notification:** name the submitter at submit instead of inside the approval transaction ([da64763](https://github.com/Rytass/BPMCore/commit/da64763))
|
|
39
|
+
|
|
40
|
+
### ❤️ Thank You
|
|
41
|
+
|
|
42
|
+
- Chia Yu Pai @fantasywind
|
|
43
|
+
- Claude Opus 5.5
|
|
44
|
+
- Kai-Chieh Yang
|
|
45
|
+
|
|
46
|
+
## 0.14.0 (2026-10-12)
|
|
47
|
+
|
|
48
|
+
### 🚀 Features
|
|
49
|
+
|
|
50
|
+
- **workflow-engine:** sign manager chains in order and keep the initiator out of re-delegation ([6eaf1e6](https://github.com/Rytass/BPMCore/commit/6eaf1e6))
|
|
51
|
+
- **designer:** offer SEQUENTIAL again and show signing order in task views ([ed38d04](https://github.com/Rytass/BPMCore/commit/ed38d04))
|
|
52
|
+
- ⚠️ **workflow-engine:** make SEQUENTIAL sign one candidate at a time ([70e9cde](https://github.com/Rytass/BPMCore/commit/70e9cde))
|
|
53
|
+
- **designer:** configure initiator exclusion on user task nodes ([b7b51cd](https://github.com/Rytass/BPMCore/commit/b7b51cd))
|
|
54
|
+
- **workflow-engine:** let a user task exclude the initiator from its approvers ([a4c6e51](https://github.com/Rytass/BPMCore/commit/a4c6e51))
|
|
55
|
+
- **designer:** configure the ORG_MANAGER_CHAIN resolver in the template designer ([ab64fe4](https://github.com/Rytass/BPMCore/commit/ab64fe4))
|
|
56
|
+
- **workflow-engine:** add ORG_MANAGER_CHAIN resolver that walks up to a position level ([001af84](https://github.com/Rytass/BPMCore/commit/001af84))
|
|
57
|
+
|
|
58
|
+
### 🩹 Fixes
|
|
59
|
+
|
|
60
|
+
- **workflow-engine:** reopen a rejected pre-approval for its requester on sequential tasks ([2cf8004](https://github.com/Rytass/BPMCore/commit/2cf8004))
|
|
61
|
+
- **designer:** show the signing order and turn hand-offs in the instance timeline ([7ade44a](https://github.com/Rytass/BPMCore/commit/7ade44a))
|
|
62
|
+
- **workflow-engine:** re-delegate on activation, anchor the SLA warning and give consumers a turn signal ([f50c781](https://github.com/Rytass/BPMCore/commit/f50c781))
|
|
63
|
+
- **workflow-engine:** filter the initiator before dedupe and keep exclusion nodes completable ([5a6570a](https://github.com/Rytass/BPMCore/commit/5a6570a))
|
|
64
|
+
- **designer:** explain the chain policy switch and keep the chain fallback in the toolset ([743df14](https://github.com/Rytass/BPMCore/commit/743df14))
|
|
65
|
+
- **workflow-engine:** let ORG_MANAGER_CHAIN climb past unit heads under org-unit rules ([5baa2e6](https://github.com/Rytass/BPMCore/commit/5baa2e6))
|
|
66
|
+
- **workflow-engine:** scope the transfer re-point to pre-approvals on the origin node ([70d99d7](https://github.com/Rytass/BPMCore/commit/70d99d7))
|
|
67
|
+
|
|
68
|
+
### ⚠️ Breaking Changes
|
|
69
|
+
|
|
70
|
+
- **workflow-engine:** make SEQUENTIAL sign one candidate at a time ([70e9cde](https://github.com/Rytass/BPMCore/commit/70e9cde))
|
|
71
|
+
the SEQUENTIAL decision policy used to behave exactly like
|
|
72
|
+
PARALLEL_ALL (every candidate got the task at once). It now means what its
|
|
73
|
+
name says: candidates sign one after another, in the order the approver
|
|
74
|
+
resolver returned them.
|
|
75
|
+
- task_candidates gains a nullable `sequence` column (migration
|
|
76
|
+
0000000025000-task-candidate-sequence) and a WAITING status for candidates
|
|
77
|
+
whose turn has not come. Only the first candidate is PENDING, assigned and
|
|
78
|
+
notified; an approval activates the next one (fresh SLA window, a
|
|
79
|
+
TASK_CANDIDATE_ACTIVATED activity log, a new assignment notification).
|
|
80
|
+
- A WAITING candidate who tries to decide gets a ConflictException.
|
|
81
|
+
- Reject, return and instance cancellation close the WAITING candidates too.
|
|
82
|
+
- Transferring (including SLA escalation) keeps the SEQUENTIAL policy and
|
|
83
|
+
carries the remaining WAITING candidates to the replacement task.
|
|
84
|
+
- TASK_CREATED lists only the active candidate in candidateMemberIds and adds
|
|
85
|
+
sequentialCandidateMemberIds with the full order.
|
|
86
|
+
- Candidates are read ordered by sequence, unordered ones last.
|
|
87
|
+
SEQUENTIAL tasks created before this change keep their old behaviour: their
|
|
88
|
+
candidates are all PENDING with a NULL sequence and nothing is backfilled.
|
|
89
|
+
PARALLEL_*, QUORUM, ad-hoc tasks and dry run are unchanged.
|
|
90
|
+
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
|
91
|
+
Claude-Session: https://claude.ai/code/session_01C3u1QC5Uo4tZvyTaJE6Gap
|
|
92
|
+
|
|
93
|
+
### ❤️ Thank You
|
|
94
|
+
|
|
95
|
+
- Claude Opus 5.5
|
|
96
|
+
- Kai-Chieh Yang
|
|
97
|
+
|
|
1
98
|
## 0.13.5 (2026-10-12)
|
|
2
99
|
|
|
3
100
|
### 🩹 Fixes
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use client";const e=require("./rolldown-runtime-BocRIvOZ.cjs"),t=require("./bpm-form-field-Bc6k4ZEO.cjs"),n=require("./FormRendererView-gctFIqwC.cjs");let r=require("react"),i=require("@mezzanine-ui/react"),a=require("react/jsx-runtime"),o=require("@mezzanine-ui/core/form"),s=require("@mezzanine-ui/icons"),c=require("@rytass/bpm-core-client/form"),l=require("@rytass/bpm-core-shared/form"),u=require("@hello-pangea/dnd"),d=require("next/dynamic");d=e.t(d,1);let f=require("@codemirror/lang-json"),p=require("@codemirror/view");var m={alignItems:`center`,border:`1px solid var(--mzn-color-border-neutral)`,borderRadius:4,color:`var(--mzn-color-text-neutral)`,display:`flex`,minHeight:160,padding:12,width:`100%`},h=[(0,f.json)(),p.EditorView.lineWrapping,p.EditorView.theme({"&":{border:`1px solid var(--mzn-color-border-neutral)`,borderRadius:`4px`,fontSize:`13px`,width:`100%`},"&.cm-focused":{outline:`1px solid var(--mzn-color-border-primary)`},".cm-content":{fontFamily:`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace`,minHeight:`100%`},".cm-editor":{width:`100%`},".cm-gutters":{borderRight:`1px solid var(--mzn-color-border-neutral)`},".cm-scroller":{fontFamily:`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace`}})],g=(0,d.default)(()=>import(`@uiw/react-codemirror`),{loading:()=>(0,a.jsx)(`div`,{style:m,children:`載入 JSON 編輯器`}),ssr:!1});function ee({disabled:e=!1,height:t,name:n,onChange:r,placeholder:i,value:o}){return(0,a.jsx)(g,{"aria-label":n,basicSetup:{autocompletion:!0,bracketMatching:!0,closeBrackets:!0,defaultKeymap:!0,foldGutter:!0,highlightActiveLine:!0,highlightSelectionMatches:!0,lineNumbers:!0,syntaxHighlighting:!0},editable:!e,extensions:[...h],height:t,indentWithTab:!1,onChange:r,placeholder:i,readOnly:e,theme:`light`,value:o,width:`100%`})}var _=[{description:`單行文字、姓名、編號`,icon:s.AlignLeftIcon,label:`文字`,type:`text`},{description:`多行補充內容`,icon:s.FileIcon,label:`長文字`,type:`textarea`},{description:`金額、數量、分數`,icon:s.CurrencyDollarIcon,label:`數字`,type:`number`},{description:`金額與費用`,icon:s.CurrencyDollarIcon,label:`金額`,type:`money`},{description:`日期或到期日`,icon:s.CalendarIcon,label:`日期`,type:`date`},{description:`日期與時間`,icon:s.CalendarIcon,label:`日期時間`,type:`datetime`},{description:`是 / 否狀態`,icon:s.CheckedIcon,label:`開關`,type:`boolean`},{description:`固定選項擇一`,icon:s.ListIcon,label:`下拉選單`,type:`select`},{description:`可搜尋的固定選項`,icon:s.ListIcon,label:`自動完成`,type:`autocomplete`},{description:`固定選項單選`,icon:s.DotGridIcon,label:`單選`,type:`radio`},{description:`固定選項複選`,icon:s.CheckedOutlineIcon,label:`複選`,type:`checkbox`},{description:`附件或佐證資料`,icon:s.FileAttachmentIcon,label:`附件`,type:`file_upload`},{description:`從成員名單挑選一或多位人員`,icon:s.UserIcon,label:`人員選擇`,type:`member`},{description:`多列多欄明細`,icon:s.DotGridIcon,label:`表格`,type:`table`}],v=_.filter(e=>(0,l.isTableColumnFieldType)(e.type)).map(e=>({id:e.type,name:e.label})),te={alignItems:`start`,display:`flex`,flexWrap:`wrap`,gap:16},ne={flex:`0.55 1 300px`,minWidth:0},re={flex:`1.45 1 720px`,minWidth:620,paddingBottom:260},ie=240,ae={BOOLEAN:`開關`,NUMBER:`數字`,STRING:`文字或選單`,STRING_ARRAY:`多選`},oe=/^schema\.fields\[(\d+)\](?:\.columns\[(\d+)\])?\.dataSource\.bindings missing required parameter: (.+)$/u,se=/^schema\.fields\[(\d+)\](?:\.columns\[(\d+)\])?\.dataSource\.bindings unknown parameter: (.+)$/u,y={display:`grid`,gap:12},ce={display:`flex`,flexWrap:`wrap`,gap:6},le={flex:`0 0 auto`,whiteSpace:`nowrap`},ue={display:`grid`,gap:8},de={alignItems:`center`,cursor:`grab`,display:`flex`,gap:12,touchAction:`none`},fe={display:`grid`,flex:`1 1 auto`,gap:2,minWidth:0},pe={alignItems:`center`,display:`flex`,flex:`0 0 auto`,gap:4},me={alignItems:`center`,display:`flex`,gap:6},he={cursor:`pointer`,userSelect:`none`},ge={filter:`drop-shadow(0 8px 18px rgba(0, 0, 0, 0.12))`},_e={backgroundColor:`color-mix(in srgb, var(--mzn-color-primary) 8%, var(--mzn-color-bg-surface))`,boxShadow:`inset 0 0 0 1px var(--mzn-color-border-primary)`},ve={alignItems:`center`,border:`1px dashed var(--mzn-color-border-neutral)`,borderRadius:6,display:`grid`,gap:12,minHeight:240,padding:32,textAlign:`center`},ye={display:`flex`,gap:8,justifyContent:`center`},be={display:`grid`,gap:14},xe={display:`grid`,columnGap:16,gridTemplateColumns:`repeat(auto-fit, minmax(280px, 360px))`,justifyContent:`start`,maxWidth:736,rowGap:8},Se={gridColumn:`1 / -1`},Ce={alignItems:`center`,display:`flex`,gap:8,gridColumn:`1 / -1`,justifyContent:`flex-end`},b={gridColumn:`1 / -1`},we={alignItems:`start`,display:`block`,width:`100%`},Te={...we,gridColumn:`1 / -1`},Ee={minWidth:0,width:`100%`},De={minWidth:`100%`,width:`100%`},Oe={display:`grid`,gap:14},ke={alignItems:`start`,display:`block`,width:`100%`},Ae={minWidth:0,width:`100%`},je={gridColumn:`2 / -1`},Me={display:`grid`,gap:10,width:`100%`},Ne={display:`grid`,gap:8,gridTemplateColumns:`repeat(auto-fit, minmax(160px, 1fr))`},Pe={display:`inline-flex`},Fe={display:`grid`,gap:16},Ie={display:`grid`,gap:8},Le={display:`flex`,justifyContent:`flex-end`},Re={color:`var(--mzn-color-text-error)`,fontSize:`0.72em`,lineHeight:0,marginLeft:2,verticalAlign:`super`},ze={display:`grid`,gap:10,gridColumn:`1 / -1`},Be={display:`grid`,gap:2},Ve={display:`grid`,gap:8},He={display:`flex`,justifyContent:`flex-start`},Ue={display:`flex`,flexWrap:`wrap`,gap:4},We={backgroundColor:`var(--mzn-color-bg-surface-secondary)`,borderRadius:6,display:`grid`,gap:4,padding:10},Ge={...xe,gridTemplateColumns:`minmax(280px, 520px)`,padding:`4px 0 8px`},Ke={display:`grid`,gap:8,gridColumn:`1 / -1`},qe={alignItems:`center`,display:`flex`,gap:12,justifyContent:`space-between`},Je={alignItems:`baseline`,display:`flex`,gap:2},Ye={display:`grid`,gap:4};function Xe(e){e&&(e.style.width=`100%`)}var Ze={fields:[],schemaVersion:1},Qe={layout:[],schemaVersion:1},x=`__STATIC_OPTIONS__`,S=`__CONSTANT__`,C=`__ROW_FIELD__:`,w=`__UNBOUND__`,$e=[{id:x,name:`靜態選項`}],et=[{id:`single`,name:`單選`},{id:`multiple`,name:`複選`}],tt=[{id:`unset`,name:`不預設`},{id:`true`,name:`是`},{id:`false`,name:`否`}],nt=[{id:`true`,name:`是`},{id:`false`,name:`否`}],rt=[{label:`顯示`,name:`fieldVisibleWhen`,supportingText:`符合條件時才顯示這個欄位。`,target:`visibleWhen`},{label:`必填`,name:`fieldRequiredWhen`,supportingText:`符合條件時才要求填寫這個欄位。`,target:`requiredWhen`},{label:`唯讀`,name:`fieldReadonlyWhen`,supportingText:`符合條件時不允許修改這個欄位。`,target:`readonlyWhen`}];function T({onChange:e,value:d}){let f=d?.schema??Ze,p=d?.uiSchema??Qe,[m,h]=(0,r.useState)(f),[g,T]=(0,r.useState)(p),[ct,D]=(0,r.useState)(A(f)),[pt,j]=(0,r.useState)(A(p)),[St,Ct]=(0,r.useState)({}),[wt,N]=(0,r.useState)(null),[P,Tt]=(0,r.useState)(`design`),[F,I]=(0,r.useState)(null),[L,Et]=(0,r.useState)([]),[R,Dt]=(0,r.useState)(null),[Ot,kt]=(0,r.useState)(`loading`),[z,B]=(0,r.useState)(null),[At,jt]=(0,r.useState)(!1),[V,H]=(0,r.useState)(null),[Mt,U]=(0,r.useState)(null);(0,r.useEffect)(()=>{let e=!0;return(0,c.listFormDataSources)().then(t=>{e&&(Et(t),Dt(null),kt(`ready`))}).catch(t=>{e&&(Et([]),Dt(`目前無法載入 DataSource Catalog,請稍後重試。`),kt(`unavailable`))}),()=>{e=!1}},[]),(0,r.useEffect)(()=>{m.fields.some(e=>e.fieldKey===F)||I(m.fields[0]?.fieldKey??null)},[m.fields,F]),(0,r.useEffect)(()=>{Ct(e=>(0,c.buildFormRendererValues)(m.fields,e))},[m.fields]),(0,r.useEffect)(()=>{P!==`advanced`&&(D(A(m)),j(A(g)))},[P,m,g]);let W=(0,r.useMemo)(()=>m.fields.find(e=>e.fieldKey===F)??m.fields[0]??null,[m.fields,F]);(0,r.useEffect)(()=>{e?.({schema:m,uiSchema:g})},[m,g]);function G(e){let t=m.fields.length+1,n=(0,c.createFieldDefinition)(e,t);h({...m,fields:[...m.fields,n]}),T({...g,layout:[...g.layout,{fieldKey:n.fieldKey,width:e===`textarea`||e===`file_upload`||e===`table`?`FULL`:`HALF`}]}),I(n.fieldKey),Tt(`design`),N(null)}function Nt(e){let t=e;t===`advanced`&&P!==`advanced`&&(D(A(m)),j(A(g))),Tt(t)}function Pt(e){let t=m.fields.flatMap(t=>(0,l.isTableFieldDefinition)(t)?t.columns.flatMap(n=>(0,l.isFormDataSourceFieldDefinition)(n)&&(0,c.readFormDataSourceFieldDependencyKeys)(n).includes(e)?[`${t.fieldKey}.${n.fieldKey}`]:[]):(0,l.isFormDataSourceFieldDefinition)(t)&&(0,c.readFormDataSourceFieldDependencyKeys)(t).includes(e)?[t.fieldKey]:[]);if(t.length>0){H({affectedFieldKeys:t,fieldKey:e,kind:`remove-field`});return}Ft(e)}function Ft(e){let t=m.fields.filter(t=>t.fieldKey!==e);h({...m,fields:t}),T({...g,layout:g.layout.filter(t=>t.fieldKey!==e)}),I(F===e?t[0]?.fieldKey??null:F),N(null),B(null)}function It(e){let t=e.destination;t&&e.source.index!==t.index&&(h(n=>({...n,fields:M(n.fields,e.source.index,t.index)})),T(n=>({...n,layout:M(n.layout,e.source.index,t.index)})),N(null))}function K(e){q(t=>({...t,...e}))}function q(e){if(!W)return;let t=W.fieldKey,n=e(W),r=n.fieldKey,i={...m,fields:m.fields.map(e=>e.fieldKey===t?n:e)},a=t===r?i:(0,c.renameFormDataSourceFieldBindings)(i,t,r);h(a),T({...g,layout:g.layout.map(e=>e.fieldKey===t?{...e,fieldKey:r}:e)}),I(r),N(null),B(null)}function Lt(e){q(()=>e)}function J(e,t){h(n=>({...n,fields:n.fields.map(n=>n.fieldKey===e&&(0,l.isTableFieldDefinition)(n)?t(n):n)})),N(null),B(null)}function Y(e,t,n){let r=e.columns[t]?.fieldKey;J(e.fieldKey,e=>{let i={...e,columns:e.columns.map((e,r)=>r===t?n:e)};return typeof r==`string`&&r!==n.fieldKey?(0,c.renameFormTableColumnBindings)(i,r,n.fieldKey):i})}function Rt(e){let t=(0,c.createTableColumnDefinition)(e.columns,`text`);J(e.fieldKey,e=>({...e,columns:[...e.columns,t]})),U(e.columns.length)}function zt(e,t){J(e,e=>({...e,columns:e.columns.filter((e,n)=>n!==t)})),U(e=>e===null||e<t?e:e===t?null:e-1)}function Bt(e,t,n){J(e.fieldKey,e=>({...e,columns:M(e.columns,t,n)})),U(e=>e===null?e:e===t?n:e>t&&e<=n?e-1:e<t&&e>=n?e+1:e)}function Vt(e,t,n){if(e.type!==`select`&&e.type!==`autocomplete`||(0,l.readFormFieldSelectionMode)(e)===t)return;let r=e.defaultValue,i=t===`multiple`?typeof r==`string`?[r]:r:Array.isArray(r)?r[0]:r;n(e,{...e,defaultValue:i,mode:t},`選擇模式變更可能轉換或捨棄既有預設值。`)}function Ht(e,t,n=`此變更會替換目前選項來源;既有 options、dynamic reference 或 bindings 可能失效。`){JSON.stringify(e)!==JSON.stringify(t)&&H({fieldKey:e.fieldKey,impact:n,kind:`replace-field`,nextField:t})}function Ut(e,t,n){if(!t)return;if(t===x){if(!(0,l.isFormDataSourceFieldDefinition)(e))return;let{dataSource:t,defaultValue:r,...i}=e;n({...i,options:[]});return}let r=L.find(e=>E(e)===t);if(!r)return;if((0,l.isFormDataSourceFieldDefinition)(e)){let t=new Set(r.parameters.map(e=>e.key)),i=e.dataSource.bindings.filter(e=>t.has(e.parameter));n({...e,dataSource:{bindings:i,key:r.key,version:r.version}});return}let{options:i,defaultValue:a,...o}=e;n({...o,dataSource:{bindings:[],key:r.key,version:r.version}})}function Wt(){V&&(Gt(V),H(null))}function Gt(e){if(e.kind===`remove-field`){Ft(e.fieldKey);return}if(e.kind===`remove-column`){zt(e.fieldKey,e.columnIndex);return}if(e.kind===`replace-column`){J(e.fieldKey,t=>({...t,columns:t.columns.map(t=>t.fieldKey===e.columnKey?e.nextColumn:t)})),U(e.columnIndex);return}h({...m,fields:m.fields.map(t=>t.fieldKey===e.fieldKey?e.nextField:t)}),N(null),B(null)}async function Kt(){jt(!0);try{let e=await(0,c.lintFormSchema)(m,g);B(e.errors.map(qt))}catch{B([`目前無法完成 DataSource schema 驗證。`])}finally{jt(!1)}}function qt(e){let t=oe.exec(e);if(t?.[1]&&t[3])return`${Jt(t[1],t[2])}尚未指定必要參數「${Yt(t[1],t[2],t[3])}」的來源`;let n=se.exec(e);return n?.[1]&&n[3]?`${Jt(n[1],n[2])}綁定了來源沒有的參數「${n[3]}」`:(0,c.readFormSchemaLintMessage)(e)}function Jt(e,t){let n=m.fields[Number(e)];if(!n)return``;let r=n.label||n.fieldKey,i=Xt(n,t);return i?`「${r}」表格的「${i.label||i.fieldKey}」欄`:`「${r}」欄位`}function Yt(e,t,n){let r=m.fields[Number(e)];if(!r)return n;let i=Xt(r,t)??r,a=(0,l.isFormDataSourceFieldDefinition)(i)?i.dataSource:null;return(a?L.find(e=>e.key===a.key&&e.version===a.version):void 0)?.parameters.find(e=>e.key===n)?.label||n}function Xt(e,t){return typeof t==`string`&&(0,l.isTableFieldDefinition)(e)?e.columns[Number(t)]:void 0}function Zt(e){Ct(e)}function Qt(e,t){h(n=>({...n,fields:n.fields.map(n=>n.fieldKey===e?{...n,required:t}:n)})),N(null)}function $t(e){D(e);try{h(JSON.parse(e)),N(null)}catch{N(`Form Schema JSON 格式不正確`)}}function en(e){j(e);try{T(JSON.parse(e)),N(null)}catch{N(`UI Schema JSON 格式不正確`)}}return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(i.SectionGroup,{children:(0,a.jsx)(i.Section,{children:(0,a.jsxs)(`div`,{style:Fe,children:[(0,a.jsxs)(i.Tab,{activeKey:P,onChange:Nt,size:`sub`,children:[(0,a.jsx)(i.TabItem,{children:`設計`},`design`),(0,a.jsx)(i.TabItem,{children:`預覽`},`preview`),(0,a.jsx)(i.TabItem,{children:`進階`},`advanced`)]}),P===`design`?tn():null,P===`preview`?Vn():null,P===`advanced`?Hn():null]})})})}),V?(0,a.jsx)(i.Modal,{cancelText:`返回`,confirmText:`確認變更`,modalType:`standard`,onCancel:()=>H(null),onClose:()=>H(null),onConfirm:Wt,open:!0,showModalFooter:!0,showModalHeader:!0,title:dt(V),children:V.kind===`remove-field`?(0,a.jsxs)(`div`,{style:Ie,children:[(0,a.jsx)(i.Typography,{variant:`body`,children:`此欄位仍被下列 DataSource binding 使用;移除後請重新設定這些欄位。`}),(0,a.jsx)(i.Typography,{color:`text-warning`,variant:`body`,children:V.affectedFieldKeys.join(`、`)})]}):V.kind===`remove-column`?(0,a.jsxs)(i.Typography,{variant:`body`,children:[`移除欄「`,V.columnKey,`」後,既有案件仍保留原本的表單版本,但新版本的這一欄資料將不再被填寫。`]}):(0,a.jsx)(i.Typography,{variant:`body`,children:V.impact})}):null]});function tn(){return(0,a.jsxs)(`div`,{style:y,children:[(0,a.jsxs)(`div`,{style:ue,children:[(0,a.jsx)(i.Typography,{component:`h2`,variant:`label-primary`,children:`新增欄位`}),(0,a.jsx)(`div`,{style:ce,children:_.map(e=>(0,a.jsx)(i.Button,{icon:e.icon,iconType:`leading`,onClick:()=>G(e.type),size:`sub`,style:le,type:`button`,variant:`base-secondary`,children:e.label},e.type))})]}),(0,a.jsxs)(`div`,{style:te,children:[(0,a.jsxs)(`div`,{style:{...y,...ne},children:[(0,a.jsx)(i.Typography,{component:`h2`,variant:`label-primary`,children:`表單畫布`}),m.fields.length>0?(0,a.jsx)(u.DragDropContext,{onDragEnd:It,children:(0,a.jsx)(u.Droppable,{droppableId:`form-builder-fields`,children:e=>(0,a.jsxs)(`div`,{...e.droppableProps,ref:e.innerRef,style:y,children:[m.fields.map((e,t)=>(0,a.jsx)(u.Draggable,{draggableId:e.fieldKey,index:t,children:(t,n)=>zn(e,t,n.isDragging)},e.fieldKey)),e.placeholder]})})}):(0,a.jsxs)(`div`,{style:ve,children:[(0,a.jsxs)(`div`,{style:y,children:[(0,a.jsx)(i.Typography,{component:`h3`,variant:`h3`,children:`尚未建立欄位`}),(0,a.jsx)(i.Typography,{color:`text-neutral`,variant:`body`,children:`從上方新增第一個欄位,或直接建立常用文字欄位開始設計。`})]}),(0,a.jsxs)(`div`,{style:ye,children:[(0,a.jsx)(i.Button,{onClick:()=>G(`text`),variant:`base-primary`,children:`新增文字欄位`}),(0,a.jsx)(i.Button,{onClick:()=>G(`textarea`),variant:`base-secondary`,children:`新增長文字`})]})]})]}),(0,a.jsxs)(`div`,{style:{...y,...re},children:[(0,a.jsx)(i.Typography,{component:`h2`,variant:`label-primary`,children:`欄位設定`}),W?nn(W):(0,a.jsx)(i.Typography,{color:`text-neutral`,variant:`body`,children:`請先新增或選取欄位。`})]})]})]})}function nn(e){return(0,a.jsxs)(`div`,{style:be,children:[rn(e),(0,l.isTableFieldDefinition)(e)?cn(e):null,an(e)]})}function rn(e){return(0,a.jsxs)(`div`,{style:xe,children:[(0,a.jsx)(`div`,{style:Ce,children:(0,a.jsx)(i.Badge,{size:`main`,text:it(e.type),variant:`text-info`})}),$(`標題`,`fieldLabel`,(0,a.jsx)(i.Input,{onChange:e=>K({label:e.target.value}),placeholder:`例如:申請金額`,value:e.label,variant:`base`})),$(`欄位 Key`,`fieldKey`,(0,a.jsx)(i.Input,{onChange:e=>K({fieldKey:e.target.value}),placeholder:`例如:amount`,value:e.fieldKey,variant:`base`})),(0,l.isTableFieldDefinition)(e)?null:$(`提示文字`,`fieldPlaceholder`,(0,a.jsx)(i.Input,{onChange:e=>K({placeholder:e.target.value||void 0}),placeholder:`例如:請輸入申請金額`,value:e.placeholder??``,variant:`base`})),on(e,Lt,Ht),O(e)?$(`以連結顯示`,`fieldDisplayAsLink`,(0,a.jsx)(i.Toggle,{checked:e.displayAs===`link`,onChange:e=>q(t=>e.target.checked?O(t)?{...t,displayAs:`link`}:t:ht(t,`displayAs`))})):null,$(`只存不顯示(系統整合用)`,`fieldHidden`,(0,a.jsx)(i.Toggle,{checked:e.hidden===!0,onChange:e=>q(t=>e.target.checked?{...t,hidden:!0,required:!1}:ht(t,`hidden`))})),e.hidden===!0?(0,a.jsx)(i.Typography,{color:`text-neutral`,style:b,variant:`body`,children:`填寫、唯讀與重送畫面都不會顯示這個欄位,值仍會存下來; 透過 API 仍然讀得到這個值,不是權限控管。`}):null]})}function an(e){return(0,a.jsx)(i.Accordion,{defaultExpanded:gt(e),size:`sub`,title:`進階設定`,children:(0,a.jsxs)(`div`,{style:xe,children:[(0,a.jsx)(i.Typography,{component:`h3`,style:Se,variant:`label-primary`,children:`條件規則`}),(0,a.jsx)(i.Typography,{color:`text-neutral`,style:b,variant:`body`,children:`只有需要根據其他欄位改變顯示、必填或唯讀狀態時才需要設定。`}),Nn(e)]})})}function on(e,t,n,r){return O(e)?pn(e,t):(0,c.isNumberFieldDefinition)(e)?mn(e,t):(0,c.isDateFieldDefinition)(e)?hn(e,t):(0,l.isFormOptionFieldDefinition)(e)?gn(e,t,n,r):e.type===`boolean`?An(e,t):e.type===`file_upload`?Mn(e,t):(0,l.isMemberFieldDefinition)(e)?jn(e,t):(0,l.isTableFieldDefinition)(e)?sn(e):null}function sn(e){let t=(0,c.readFormTableRowBounds)(e);return(0,a.jsxs)(a.Fragment,{children:[$(`最少列數`,`fieldMinRows`,Q(e.minRows,t=>J(e.fieldKey,e=>({...e,minRows:t})),`例如:1`,{max:t.maxRows,min:0})),$(`最多列數`,`fieldMaxRows`,Q(e.maxRows,t=>J(e.fieldKey,e=>({...e,maxRows:t})),`未設定即為 ${l.FORM_TABLE_MAX_ROWS}`,{max:l.FORM_TABLE_MAX_ROWS,min:Math.max(t.minRows,1)})),$(`新增列按鈕文字`,`fieldAddRowLabel`,(0,a.jsx)(i.Input,{onChange:t=>J(e.fieldKey,e=>({...e,addRowLabel:t.target.value||void 0})),placeholder:`預設為「新增一列」`,value:e.addRowLabel??``,variant:`base`}))]})}function cn(e){return(0,a.jsxs)(`div`,{style:Ke,children:[(0,a.jsxs)(`div`,{style:qe,children:[(0,a.jsxs)(i.Typography,{component:`h3`,variant:`label-primary`,children:[`欄(`,e.columns.length,`)`]}),(0,a.jsx)(i.Button,{icon:s.PlusIcon,iconType:`leading`,onClick:()=>Rt(e),size:`sub`,type:`button`,variant:`base-secondary`,children:`新增欄`})]}),ln(e)]})}function ln(e){let t=e.columns.map((t,n)=>({fieldKey:t.fieldKey,index:n,key:`${e.fieldKey}-column-${n}`,label:t.label,type:t.type})),n=[{key:`label`,render:t=>(0,a.jsx)(i.Input,{fullWidth:!0,onChange:n=>Y(e,t.index,{...X(e,t.index),label:n.target.value}),placeholder:`例如:數量`,size:`sub`,value:t.label,variant:`base`}),title:`標題`},{key:`type`,render:t=>(0,a.jsx)(i.Select,{fullWidth:!0,clearable:!1,menuMaxHeight:ie,onChange:n=>dn(e,t.index,n?.id),options:[...v],size:`sub`,value:(0,c.readSelectOption)(v,t.type)}),title:`型別`},{key:`required`,render:t=>(0,a.jsx)(i.Toggle,{checked:X(e,t.index).required===!0,inputProps:{"aria-label":`${t.label||t.fieldKey} 必填`},onChange:n=>Y(e,t.index,{...X(e,t.index),required:n.target.checked}),size:`sub`}),title:`必填`}],r={render:t=>[{disabled:()=>e.columns.length<=1,icon:s.TrashIcon,iconType:`leading`,name:`移除此欄`,onClick:()=>H({columnIndex:t.index,columnKey:t.fieldKey,fieldKey:e.fieldKey,kind:`remove-column`}),variant:`destructive-ghost`}],width:104},o=Mt===null?void 0:t[Mt]?.key;return(0,a.jsx)(i.Table,{actions:r,columns:n,dataSource:t,draggable:{enabled:!0,onDragEnd:(t,n)=>Bt(e,n.fromIndex,n.toIndex)},expandable:{expandedRowKeys:o?[o]:[],expandedRowRender:t=>un(e,t.index),onExpand:(e,t)=>U(e?t.index:null)},fullWidth:!0,rowHeightPreset:`roomy`,showHeader:!0,size:`sub`})}function un(e,t){let n=e.columns[t];return n?(0,a.jsxs)(`div`,{style:Ge,children:[$(`欄位 Key`,`columnFieldKey`,(0,a.jsx)(i.Input,{onChange:r=>Y(e,t,{...n,fieldKey:r.target.value}),placeholder:`例如:qty`,value:n.fieldKey,variant:`base`})),$(`提示文字`,`columnPlaceholder`,(0,a.jsx)(i.Input,{onChange:r=>Y(e,t,{...n,placeholder:r.target.value||void 0}),placeholder:`例如:請輸入數量`,value:n.placeholder??``,variant:`base`})),on(n,n=>{(0,l.isTableColumnFieldType)(n.type)&&Y(e,t,n)},(n,r)=>{(0,l.isTableColumnFieldType)(r.type)&&Y(e,t,r)},e.columns)]}):null}function dn(e,t,n){let r=e.columns[t],i=v.find(e=>e.id===n)?.id;if(!r||!i||r.type===i)return;let a=mt(r,i),o=ft(r);if(o.length===0){Y(e,t,a),U(t);return}H({columnIndex:t,columnKey:r.fieldKey,fieldKey:e.fieldKey,impact:`「${r.label||r.fieldKey}」改為${fn(i)}後,這一欄的${o.join(`、`)}會被捨棄。`,kind:`replace-column`,nextColumn:a})}function fn(e){return v.find(t=>t.id===e)?.name??e}function X(e,t){let n=e.columns[t];if(!n)throw Error(`Table ${e.fieldKey} has no column at index ${t}.`);return n}function pn(e,t){return(0,a.jsxs)(a.Fragment,{children:[$(`預設值`,`fieldDefaultValue`,e.type===`textarea`?In({name:`fieldDefaultValue`,onChange:n=>t({...e,defaultValue:n||void 0}),placeholder:`輸入此欄位的預設文字`,rows:3,value:k(e.defaultValue)}):(0,a.jsx)(i.Input,{onChange:n=>t({...e,defaultValue:n.target.value||void 0}),placeholder:`輸入此欄位的預設文字`,value:k(e.defaultValue),variant:`base`})),$(`最小長度`,`fieldMinLength`,Q(e.minLength,n=>t({...e,minLength:n}),`例如:2`,{min:0})),$(`最大長度`,`fieldMaxLength`,Q(e.maxLength,n=>t({...e,maxLength:n}),`例如:100`,{min:1}))]})}function mn(e,t){return(0,a.jsxs)(a.Fragment,{children:[$(`預設值`,`fieldDefaultValue`,Q(typeof e.defaultValue==`number`?e.defaultValue:void 0,n=>t({...e,defaultValue:n}),e.type===`money`?`例如:1000`:`輸入預設數值`,{max:e.maximum,min:e.minimum})),$(`最小值`,`fieldMinimum`,Q(e.minimum,n=>t({...e,minimum:n}),`例如:0`)),$(`最大值`,`fieldMaximum`,Q(e.maximum,n=>t({...e,maximum:n}),`例如:999999`))]})}function hn(e,t){return $(`預設值`,`fieldDefaultValue`,Ln(e,k(e.defaultValue),n=>t({...e,defaultValue:n})))}function gn(e,t,n,r){let o=(0,c.readCompatibleFormDataSourceDescriptors)(e.type,L),s={commit:e=>t(e),rowColumns:r},u=(0,l.isFormDataSourceFieldDefinition)(e)?E(e.dataSource):x,d=(0,l.isFormDataSourceFieldDefinition)(e)?L.find(t=>t.key===e.dataSource.key&&t.version===e.dataSource.version):null,f=d?o.some(e=>e.key===d.key&&e.version===d.version):!1,p=[...$e,...o.map(ot),...(0,l.isFormDataSourceFieldDefinition)(e)&&!f?[{id:u,name:`${e.dataSource.key} v${e.dataSource.version}(目前不可用或不支援)`}]:[]],m=(0,l.readFormFieldSelectionMode)(e);return(0,a.jsxs)(a.Fragment,{children:[e.type===`select`||e.type===`autocomplete`?$(`選擇模式`,`fieldSelectionMode`,(0,a.jsx)(i.Select,{clearable:!1,onChange:t=>{(t?.id===`single`||t?.id===`multiple`)&&Vt(e,t.id,n)},options:[...et],value:(0,c.readSelectOption)(et,m)})):$(`選擇模式`,`fieldSelectionMode`,(0,a.jsx)(i.Typography,{color:`text-neutral`,variant:`body`,children:m===`multiple`?`固定複選`:`固定單選`})),$(`選項來源`,`fieldOptionSource`,(0,a.jsx)(i.Select,{clearable:!1,disabled:Ot===`loading`&&!(0,l.isFormDataSourceFieldDefinition)(e),onChange:n=>Ut(e,n?.id,t),options:p,placeholder:`選擇選項來源`,value:(0,c.readSelectOption)(p,u)})),(0,l.isFormDataSourceFieldDefinition)(e)?_n(e,o,s):kn(e,t)]})}function _n(e,t,n){let r=L.find(t=>t.key===e.dataSource.key&&t.version===e.dataSource.version),o=r&&!(0,c.isFormDataSourceDescriptorCompatible)(r,e.type);return(0,a.jsxs)(`div`,{style:ze,children:[Ot===`loading`?(0,a.jsx)(i.Typography,{color:`text-neutral`,variant:`body`,children:`正在載入可用的選項來源…`}):null,R?(0,a.jsx)(i.Typography,{color:`text-error`,variant:`body`,children:R}):null,r?null:(0,a.jsx)(i.Typography,{color:`text-warning`,variant:`body`,children:`找不到目前設定的來源版本。設定會保留,但這張表單在來源恢復前無法發布。`}),o?(0,a.jsx)(i.Typography,{color:`text-error`,variant:`body`,children:`這個來源不支援目前的控制項,請改選其他來源。`}):null,r?vn(r):null,r&&r.parameters.length>0?yn(e,r,n):null,t.length===0&&!R?(0,a.jsx)(i.Typography,{color:`text-warning`,variant:`body`,children:`沒有支援目前控制項的已註冊來源。`}):null,(0,a.jsx)(`div`,{style:He,children:(0,a.jsx)(i.Button,{disabled:At,loading:At,onClick:()=>void Kt(),size:`sub`,type:`button`,variant:`base-secondary`,children:`檢查全部動態選項設定`})}),z?(0,a.jsx)(`div`,{style:Be,children:z.length>0?z.map(e=>(0,a.jsx)(i.Typography,{color:`text-error`,variant:`caption`,children:e},e)):(0,a.jsx)(i.Typography,{color:`text-success`,variant:`caption`,children:`這張表單的動態選項設定都可以使用。`})}):null]})}function vn(e){return(0,a.jsxs)(`div`,{style:We,children:[e.description?(0,a.jsx)(i.Typography,{variant:`body`,children:e.description}):null,(0,a.jsx)(`div`,{style:Ue,children:at(e).map(e=>(0,a.jsx)(i.Tag,{label:e,readOnly:!0,size:`minor`},e))}),(0,a.jsxs)(i.Typography,{color:`text-neutral`,variant:`caption`,children:[`來源代號:`,e.key,` · v`,e.version]})]})}function yn(e,t,n){let r=t.parameters.map((e,t)=>({key:e.key,index:t,parameter:e}));return(0,a.jsxs)(`div`,{style:Ve,children:[(0,a.jsx)(i.Typography,{color:`text-neutral`,variant:`label-secondary`,children:`這個來源需要的條件`}),(0,a.jsx)(i.Table,{columns:[{key:`parameter`,render:e=>(0,a.jsxs)(`div`,{style:Je,children:[(0,a.jsx)(i.Typography,{variant:`input`,children:e.parameter.label??e.parameter.key}),e.parameter.required?(0,a.jsx)(i.Typography,{color:`text-error`,variant:`input`,children:`*`}):null]}),title:`條件`,width:100},{key:`binding`,width:268,render:t=>xn(e,t.parameter,n),title:`值從哪裡來`},{key:`constant`,width:140,render:t=>(0,c.readFormDataSourceBindingValueKind)((0,c.readFormDataSourceBinding)(e,t.parameter.key))===`CONSTANT`?Tn(e,t.parameter.key,t.parameter.type,(0,c.readFormDataSourceBinding)(e,t.parameter.key),n):(0,a.jsx)(i.Typography,{color:`text-neutral`,variant:`caption`,children:`—`}),title:`固定值`},{key:`meaning`,render:t=>(0,a.jsx)(i.Typography,{color:`text-neutral`,variant:`caption`,children:Cn((0,c.readFormDataSourceBinding)(e,t.parameter.key),t.parameter,n,bn(e,t.parameter,n))}),title:`填寫時的行為`}],dataSource:r,fullWidth:!0,showHeader:!0,size:`sub`})]})}function bn(e,t,n){return(0,c.readCompatibleFormDataSourceBindingFields)(t.type,m.fields,e.fieldKey).length+(n.rowColumns?(0,c.readCompatibleFormTableColumnBindingFields)(t.type,n.rowColumns,e.fieldKey).length:0)}function xn(e,t,n){let r=st((0,c.readFormDataSourceBinding)(e,t.key)),o=n.rowColumns?(0,c.readCompatibleFormTableColumnBindingFields)(t.type,n.rowColumns,e.fieldKey).map(e=>({id:`${C}${e.id}`,name:`同列:${e.name}`})):[],s=[...t.required?[]:[{id:w,name:`未綁定`}],...o,...(0,c.readCompatibleFormDataSourceBindingFields)(t.type,m.fields,e.fieldKey),...t.type===`STRING_ARRAY`?[]:[{id:S,name:`固定常數`}]];return(0,a.jsx)(`div`,{"data-data-source-parameter":t.key,style:Ye,children:(0,a.jsx)(i.Select,{clearable:!1,fullWidth:!0,inputProps:{"aria-label":`${t.label??t.key} 的值來源`,title:(0,c.readSelectOption)(s,r)?.name??``},onChange:r=>Dn(e,t.key,t.type,r?.id,n),options:s,placeholder:`選擇欄位或常數`,size:`sub`,value:(0,c.readSelectOption)(s,r)})})}function Sn(e){return ae[e]}function Cn(e,t,n,r){let i=(0,c.readFormDataSourceBindingValueKind)(e);return i===`CONSTANT`?`固定值,不隨填寫變動`:i===`FIELD`?`隨欄位「${wn(e,n)}」變動`:i===`ROW_FIELD`?`隨同列「${wn(e,n)}」變動`:t.required?r>0?`尚未設定,選項無法載入`:`沒有相容的${Sn(t.type)}欄位,請改用固定值`:`未設定,不做這層篩選`}function wn(e,t){let n=e?.from;if(n?.kind===`FIELD`){let e=m.fields.find(e=>e.fieldKey===n.fieldKey);return e?e.label||e.fieldKey:``}if(n?.kind===`ROW_FIELD`){let e=t.rowColumns?.find(e=>e.fieldKey===n.columnKey);return e?e.label||e.fieldKey:``}return``}function Tn(e,t,n,r,i){return(0,a.jsx)(`div`,{"data-data-source-constant":t,children:En(e,t,n,r,i)})}function En(e,t,n,r,o){let s=(0,c.readFormDataSourceBindingValue)(e,t);if(n===`BOOLEAN`){let n=[{id:`true`,name:`是`},{id:`false`,name:`否`}];return(0,a.jsx)(i.Select,{clearable:!1,fullWidth:!0,onChange:n=>On(e,t,n?.id===`true`,o),options:n,size:`sub`,value:(0,c.readSelectOption)(n,s===!0?`true`:`false`)})}return n===`STRING_ARRAY`?(0,a.jsx)(i.Typography,{color:`text-warning`,variant:`caption`,children:`這個條件要收多個值,請綁定一個複選欄位;不接受固定值。`}):(0,a.jsx)(i.Input,{onChange:r=>On(e,t,n===`NUMBER`?(0,c.parseOptionalNumberInput)(r.target.value)??0:r.target.value,o),placeholder:n===`NUMBER`?`輸入數字`:`輸入固定值`,value:lt(r,n),variant:`base`})}function Dn(e,t,n,r,i){i.commit((0,c.upsertFormDataSourceFieldBinding)(e,t,ut(t,n,r)))}function On(e,t,n,r){r.commit((0,c.upsertFormDataSourceFieldBinding)(e,t,{from:{kind:`CONSTANT`,value:n},parameter:t}))}function kn(e,t){let n=(0,l.readFormFieldSelectionMode)(e),r=Array.isArray(e.defaultValue)?e.defaultValue:[],o=e.options.map(c.readFieldOptionAsSelectOption),s=o.filter(e=>r.includes(e.id));return(0,a.jsxs)(a.Fragment,{children:[$(`預設值`,`fieldDefaultValue`,n===`multiple`?(0,a.jsx)(i.Select,{clearable:!0,mode:`multiple`,onChange:n=>t({...e,defaultValue:n.length?n.map(e=>e.id):void 0}),options:o,placeholder:`選擇一或多個預設選項`,value:s}):(0,a.jsx)(i.Select,{clearable:!0,onChange:n=>t({...e,defaultValue:n?.id||void 0}),options:o,placeholder:`選擇預設選項`,value:typeof e.defaultValue==`string`?(0,c.readSelectOption)(o,e.defaultValue):null})),$(`選項`,`fieldOptions`,Rn(e,t),!0)]})}function An(e,t){let n=typeof e.defaultValue==`boolean`?String(e.defaultValue):`unset`;return $(`預設值`,`fieldDefaultValue`,(0,a.jsx)(i.Select,{clearable:!1,onChange:n=>t({...e,defaultValue:n?.id===`true`||n?.id!==`false`&&void 0}),options:[...tt],placeholder:`選擇預設狀態`,value:(0,c.readSelectOption)(tt,n)}))}function jn(e,t){return $(`可複選`,`fieldMemberMultiple`,(0,a.jsx)(i.Toggle,{checked:e.multiple===!0,label:e.multiple===!0?`可選多位`:`只能選一位`,onChange:n=>t({...e,defaultValue:void 0,multiple:n.target.checked||void 0}),size:`sub`}))}function Mn(e,t){return(0,a.jsxs)(a.Fragment,{children:[$(`檔案數`,`fieldMaxFiles`,Q(e.maxFiles,n=>t({...e,maxFiles:n}),`例如:1`,{min:1})),$(`MIME`,`fieldAcceptedMimeTypes`,In({name:`fieldAcceptedMimeTypes`,onChange:n=>t({...e,acceptedMimeTypes:vt(n)}),placeholder:`每行一個 MIME type,例如:application/pdf`,rows:3,value:yt(e.acceptedMimeTypes)}),!1)]})}function Nn(e){let t=m.fields.filter(t=>t.fieldKey!==e.fieldKey&&!(0,l.isMemberFieldDefinition)(t));return t.length?(0,a.jsx)(a.Fragment,{children:rt.map(n=>Pn(e,n,t))}):(0,a.jsx)(i.Typography,{color:`text-neutral`,style:b,variant:`body`,children:`目前沒有其他欄位可作為條件來源。新增更多欄位後即可設定條件規則。`})}function Pn(e,t,n){let r=e[t.target],o=r?(0,c.parseConditionRule)(r):null,s=n.find(e=>e.fieldKey===o?.fieldKey),l=s??n[0],u=n.map(_t),d=(0,c.readConditionOperatorOptions)(l),f=o&&d.some(e=>e.id===o.operator)?o.operator:(0,c.readDefaultConditionOperator)(l),p=o?.value??(0,c.readDefaultConditionValue)(l),m=!!r,h=m&&(!o||!s);return $(t.label,t.name,(0,a.jsxs)(`div`,{style:Me,children:[(0,a.jsx)(i.Toggle,{checked:m,label:m?`已啟用`:`不啟用`,onChange:e=>Z(t.target,e.target.checked?(0,c.buildConditionExpression)(l,(0,c.readDefaultConditionOperator)(l),(0,c.readDefaultConditionValue)(l)):void 0),size:`sub`,supportingText:t.supportingText}),m?h?(0,a.jsx)(i.Typography,{color:`text-warning`,variant:`body`,children:`這個規則不是目前 UI 支援的格式。重新選擇條件後會取代既有規則。`}):(0,a.jsxs)(`div`,{style:Ne,children:[(0,a.jsx)(i.Select,{clearable:!1,onChange:e=>{let r=n.find(t=>t.fieldKey===e?.id)??l;Z(t.target,(0,c.buildConditionExpression)(r,(0,c.readDefaultConditionOperator)(r),(0,c.readDefaultConditionValue)(r)))},options:u,placeholder:`選擇欄位`,value:(0,c.readSelectOption)(u,l.fieldKey)}),(0,a.jsx)(i.Select,{clearable:!1,onChange:e=>Z(t.target,(0,c.buildConditionExpression)(l,(0,c.readConditionOperatorOption)(e?.id)??f,p)),options:[...d],placeholder:`判斷方式`,value:(0,c.readSelectOption)(d,f)}),Fn(l,p,e=>Z(t.target,(0,c.buildConditionExpression)(l,f,e)))]}):null]}),!0)}function Z(e,t){K({[e]:t})}function Fn(e,t,n){if(e.type===`boolean`)return(0,a.jsx)(i.Select,{clearable:!1,onChange:e=>n(e?.id??`true`),options:[...nt],placeholder:`比較值`,value:(0,c.readSelectOption)(nt,t===`false`?`false`:`true`)});if((0,c.isSelectFieldDefinition)(e)){let r=e.options.map(c.readFieldOptionAsSelectOption);return(0,a.jsx)(i.Select,{clearable:!1,onChange:e=>n(e?.id??r[0]?.id??``),options:r,placeholder:`比較值`,value:(0,c.readSelectOption)(r,t)})}return(0,c.isNumberFieldDefinition)(e)?Q((0,c.parseOptionalNumberInput)(t),e=>n(String(e??0)),`比較值`):(0,c.isDateFieldDefinition)(e)?Ln(e,t,e=>n(e??``)):(0,a.jsx)(i.Input,{onChange:e=>n(e.target.value),placeholder:`比較值`,value:t,variant:`base`})}function In({name:e,onChange:t,placeholder:n,rows:r,value:o}){return(0,a.jsx)(i.Textarea,{"aria-label":e,onChange:e=>t(e.target.value),placeholder:n,ref:Xe,resize:`vertical`,rows:r,style:De,value:o})}function Q(e,t,n,r={}){return(0,a.jsx)(i.Input,{max:r.max,min:r.min,onChange:e=>t((0,c.clampOptionalNumber)((0,c.parseOptionalNumberInput)(e.target.value),r)),placeholder:n,showSpinner:!0,step:r.step??1,value:typeof e==`number`?String(e):``,variant:`measure`})}function Ln(e,t,n){return e.type===`datetime`?(0,a.jsx)(i.DateTimePicker,{formatDate:`YYYY-MM-DD`,formatTime:`HH:mm`,hideSecond:!0,onChange:e=>n((0,c.formatDateTimePickerValue)(e)),placeholderLeft:`選擇日期`,placeholderRight:`選擇時間`,value:(0,c.readDatePickerValue)(t)}):(0,a.jsx)(i.DatePicker,{format:`YYYY-MM-DD`,onChange:e=>n((0,c.formatDatePickerValue)(e)),placeholder:`選擇日期`,value:(0,c.readDatePickerValue)(t)})}function Rn(e,t){let n=e.options.map((t,n)=>({index:n,key:`${e.fieldKey}-${n}`,label:t.label,value:t.value}));return(0,a.jsxs)(`div`,{style:Ie,children:[(0,a.jsx)(i.Table,{actions:{render:n=>[{disabled:()=>e.options.length<=1,icon:s.TrashIcon,iconType:`icon-only`,name:`移除選項`,onClick:()=>t({...e,options:e.options.filter((e,t)=>t!==n.index)}),variant:`destructive-ghost`}],width:56},columns:[{key:`label`,render:n=>(0,a.jsx)(i.Input,{onChange:r=>t({...e,options:bt(e.options,n.index,{label:r.target.value})}),placeholder:`例如:主管`,size:`sub`,value:n.label,variant:`base`}),title:`Label`},{key:`value`,render:n=>(0,a.jsx)(i.Input,{onChange:r=>t({...e,options:bt(e.options,n.index,{value:r.target.value})}),placeholder:`例如:manager`,size:`sub`,value:n.value,variant:`base`}),title:`Value`}],dataSource:n,showHeader:!0,size:`sub`}),(0,a.jsx)(`div`,{style:Le,children:(0,a.jsx)(i.Button,{icon:s.PlusIcon,iconType:`leading`,onClick:()=>t({...e,options:[...e.options,xt(e.options)]}),variant:`base-secondary`,children:`新增選項`})})]})}function zn(e,t,n){return(0,a.jsx)(`div`,{...t.draggableProps,"data-form-builder-field-key":e.fieldKey,ref:t.innerRef,style:{...he,...n?ge:null,...t.draggableProps.style},children:(0,a.jsx)(i.BaseCard,{style:e.fieldKey===W?.fieldKey?_e:void 0,children:Bn(e,t,n)})})}function $(e,n,r,i=!1){return(0,a.jsx)(`div`,{style:i?Te:we,children:(0,a.jsx)(`div`,{style:Ee,children:(0,a.jsx)(t.t,{label:e,layout:i?o.FormFieldLayout.VERTICAL:o.FormFieldLayout.STRETCH,name:n,children:r})})})}function Bn(e,t,n){return(0,a.jsxs)(`div`,{...t.dragHandleProps??{},"aria-label":`選取或拖曳排序欄位`,onClick:()=>I(e.fieldKey),style:de,title:`點擊選取,拖曳排序`,children:[(0,a.jsx)(`span`,{"aria-label":`拖曳排序`,role:`img`,style:Pe,title:`拖曳排序`,children:(0,a.jsx)(i.Icon,{icon:s.DotDragVerticalIcon,size:20})}),(0,a.jsxs)(`div`,{style:fe,children:[(0,a.jsxs)(i.Typography,{component:`span`,ellipsis:!0,variant:`label-primary`,children:[e.label,e.required?(0,a.jsx)(`sup`,{"aria-label":`必填`,style:Re,children:`*`}):null]}),(0,a.jsxs)(i.Typography,{color:`text-neutral`,component:`span`,ellipsis:!0,variant:`caption`,children:[it(e.type),` ·`,e.required?` 必填`:` 選填`,` ·`,e.fieldKey,e.hidden?` · 只存不顯示`:null]})]}),(0,a.jsxs)(`div`,{onClick:e=>e.stopPropagation(),style:pe,children:[(0,a.jsx)(`div`,{style:me,children:(0,a.jsx)(i.Toggle,{checked:!!e.required,disabled:n||e.hidden===!0,label:`必填`,onChange:t=>Qt(e.fieldKey,t.target.checked)})}),(0,a.jsx)(i.Button,{disabled:n,icon:s.TrashIcon,iconType:`icon-only`,onClick:()=>Pt(e.fieldKey),variant:`destructive-ghost`,children:`移除欄位`})]})]})}function Vn(){return(0,a.jsxs)(`div`,{style:y,children:[(0,a.jsx)(i.Typography,{component:`h2`,variant:`h3`,children:`填寫預覽`}),(0,a.jsx)(n.t,{dataSourceContext:{kind:`preview`},onChange:Zt,schema:m,uiSchema:g,value:St})]})}function Hn(){return(0,a.jsxs)(`div`,{style:y,children:[(0,a.jsx)(i.Typography,{component:`h2`,variant:`h3`,children:`Schema`}),(0,a.jsxs)(`div`,{style:Oe,children:[Un(`Form Schema`,`schemaJson`,(0,a.jsx)(ee,{height:`360px`,name:`schemaJson`,onChange:$t,placeholder:`輸入 Form Schema JSON`,value:ct})),Un(`UI Schema`,`uiSchemaJson`,(0,a.jsx)(ee,{height:`240px`,name:`uiSchemaJson`,onChange:en,placeholder:`輸入 UI Schema JSON`,value:pt})),wt?(0,a.jsx)(i.Typography,{color:`text-error`,style:je,variant:`body`,children:wt}):null]})]})}function Un(e,n,r){return(0,a.jsx)(`div`,{style:ke,children:(0,a.jsx)(`div`,{style:Ae,children:(0,a.jsx)(t.t,{label:e,name:n,children:r})})})}}function it(e){return _.find(t=>t.type===e)?.label??e}function E(e){return`${e.key}@${e.version}`}function at(e){return[e.supportsSearch?`可輸入關鍵字搜尋${e.minimumSearchLength>1?`(至少 ${e.minimumSearchLength} 字)`:``}`:`不支援搜尋`,e.paginationMode===`CURSOR`?`捲動載入更多(每次 ${e.pageSize} 筆)`:`一次載入完整清單(最多 ${e.maximumResultCount} 筆)`,e.revalidationPolicy===`ALWAYS`?`退回重送時一律重新確認`:`值與條件未變時沿用上次結果`]}function ot(e){return{id:E(e),name:e.label}}function st(e){return e?e.from.kind===`FIELD`?e.from.fieldKey:e.from.kind===`ROW_FIELD`?`${C}${e.from.columnKey}`:S:w}function ct(e){switch(e){case`BOOLEAN`:return!1;case`NUMBER`:return 0;case`STRING_ARRAY`:return``;case`STRING`:return``;default:return``}}function lt(e,t){let n=e?.from.kind===`CONSTANT`?e.from.value:``;return t===`NUMBER`?typeof n==`number`?String(n):``:typeof n==`string`?n:``}function ut(e,t,n){return!n||n===w?null:n===S?{from:{kind:`CONSTANT`,value:ct(t)},parameter:e}:n.startsWith(C)?{from:{columnKey:n.slice(14),kind:`ROW_FIELD`},parameter:e}:{from:{fieldKey:n,kind:`FIELD`},parameter:e}}function dt(e){return e.kind===`remove-field`?`確認移除 dependency 欄位`:e.kind===`remove-column`?`確認移除表格欄`:e.kind===`replace-column`?`確認變更欄型別`:`確認變更選擇模式`}var D=[{label:`選項 A`,value:`option_a`},{label:`選項 B`,value:`option_b`}];function ft(e){let t=[];return e.defaultValue!==void 0&&t.push(`預設值`),e.type===`text`&&(typeof e.minLength==`number`||typeof e.maxLength==`number`)&&t.push(`長度限制`),(e.type===`number`||e.type===`money`)&&(typeof e.minimum==`number`||typeof e.maximum==`number`)&&t.push(`數值範圍`),(0,l.isFormDataSourceFieldDefinition)(e)?t.push(`選項來源設定`):(0,l.isFormStaticOptionFieldDefinition)(e)&&!pt(e.options)&&t.push(`${e.options.length} 個選項`),(e.type===`select`||e.type===`autocomplete`)&&e.mode===`multiple`&&t.push(`選擇模式`),t}function pt(e){return e.length===D.length&&e.every((e,t)=>e.label===D[t]?.label&&e.value===D[t]?.value)}function mt(e,t){let n={fieldKey:e.fieldKey,label:e.label,required:e.required,...e.description?{description:e.description}:{},...e.placeholder?{placeholder:e.placeholder}:{}};return t===`select`||t===`autocomplete`?{...n,mode:`single`,options:[...D],type:t}:{...n,type:t}}function ht(e,t){return Object.fromEntries(Object.entries(e).filter(([e])=>e!==t))}function gt(e){return!!(e.visibleWhen||e.requiredWhen||e.readonlyWhen)}function _t(e){return{id:e.fieldKey,name:e.label}}function O(e){return e.type===`text`||e.type===`textarea`}function k(e){return typeof e==`string`?e:``}function vt(e){let t=e.split(/[\n,]/u).map(e=>e.trim()).filter(Boolean);return t.length?t:void 0}function yt(e){return e?.join(`
|
|
2
|
+
`)??``}function A(e){return JSON.stringify(e,null,2)}function bt(e,t,n){return e.map((e,r)=>r===t?{...e,...n}:e)}function xt(e){let t=e.length+1;return{label:`選項 ${t}`,value:j(e,t)}}function j(e,t){let n=`option_${t}`;return e.some(e=>e.value===n)?j(e,t+1):n}function M(e,t,n){let r=e[t];if(!r||t===n)return[...e];let i=e.filter((e,n)=>n!==t);return[...i.slice(0,n),r,...i.slice(n)]}Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return T}});
|
|
3
|
+
//# sourceMappingURL=FormBuilderView-6bCbIkz6.cjs.map
|