@rytass/bpm-core-react 0.10.0 → 0.11.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 +15 -0
- package/dist/chunks/FormBuilderView-CAqjOYAP.cjs +3 -0
- package/dist/chunks/{FormBuilderView-D6baVqBY.cjs.map → FormBuilderView-CAqjOYAP.cjs.map} +1 -1
- package/dist/chunks/{FormBuilderView-QtREqV4j.js → FormBuilderView-TzSezeqC.js} +18 -16
- package/dist/chunks/{FormBuilderView-QtREqV4j.js.map → FormBuilderView-TzSezeqC.js.map} +1 -1
- package/dist/chunks/{FormRendererView-D8QHLvd0.js → FormRendererView-BurlEDUu.js} +44 -41
- package/dist/chunks/{FormRendererView-D8QHLvd0.js.map → FormRendererView-BurlEDUu.js.map} +1 -1
- package/dist/chunks/FormRendererView-Dde1s3I0.cjs +2 -0
- package/dist/chunks/{FormRendererView-Cw9LiidV.cjs.map → FormRendererView-Dde1s3I0.cjs.map} +1 -1
- package/dist/chunks/admin-pickers-Btvij1at.cjs.map +1 -1
- package/dist/chunks/admin-pickers-DLlG_1du.js.map +1 -1
- package/dist/chunks/approval-instance-list-page-BjX2kaoF.js.map +1 -1
- package/dist/chunks/approval-instance-list-page-CWiQvnfE.cjs +2 -0
- package/dist/chunks/{approval-instance-list-page-C408vxE2.cjs.map → approval-instance-list-page-CWiQvnfE.cjs.map} +1 -1
- package/dist/chunks/auth-provider-4BeCw7cI.cjs.map +1 -1
- package/dist/chunks/auth-provider-B5oPmvk2.js.map +1 -1
- package/dist/chunks/bpm-form-field-Bc6k4ZEO.cjs.map +1 -1
- package/dist/chunks/categories-DGlxuC6X.js.map +1 -1
- package/dist/chunks/categories-Yid05WAX.cjs +2 -0
- package/dist/chunks/{categories-DUfldZ_9.cjs.map → categories-Yid05WAX.cjs.map} +1 -1
- package/dist/chunks/{compose-D-OS-Ngs.js → compose-CUOe5Ia9.js} +4 -4
- package/dist/chunks/{compose-D-OS-Ngs.js.map → compose-CUOe5Ia9.js.map} +1 -1
- package/dist/chunks/compose-CyRkXdeu.cjs +2 -0
- package/dist/chunks/{compose-CODnd9-2.cjs.map → compose-CyRkXdeu.cjs.map} +1 -1
- package/dist/chunks/dashboard-page-CH87L5nx.cjs +2 -0
- package/dist/chunks/{dashboard-page-DwHQY6Ki.cjs.map → dashboard-page-CH87L5nx.cjs.map} +1 -1
- package/dist/chunks/dashboard-page-DJ9vOPga.js.map +1 -1
- package/dist/chunks/{delegations-DLEEFBlH.js → delegations-0MbJ7CWj.js} +3 -2
- package/dist/chunks/{delegations-DLEEFBlH.js.map → delegations-0MbJ7CWj.js.map} +1 -1
- package/dist/chunks/delegations-Bc9psOZ3.cjs +2 -0
- package/dist/chunks/{delegations-CGj-tZNO.cjs.map → delegations-Bc9psOZ3.cjs.map} +1 -1
- package/dist/chunks/{delegations-DqMpI_Nk.js → delegations-DyMGIDpp.js} +3 -2
- package/dist/chunks/{delegations-DqMpI_Nk.js.map → delegations-DyMGIDpp.js.map} +1 -1
- package/dist/chunks/delegations-vpLtus9g.cjs +2 -0
- package/dist/chunks/{delegations-kbMOSEif.cjs.map → delegations-vpLtus9g.cjs.map} +1 -1
- package/dist/chunks/{designer-DDSxwtjV.js → designer-Cb3WAC46.js} +39 -30
- package/dist/chunks/{designer-DDSxwtjV.js.map → designer-Cb3WAC46.js.map} +1 -1
- package/dist/chunks/designer-zLliyrHu.cjs +65 -0
- package/dist/chunks/{designer-Cdn10NNl.cjs.map → designer-zLliyrHu.cjs.map} +1 -1
- package/dist/chunks/detail-Bp2Nv0cs.cjs +2 -0
- package/dist/chunks/{detail-CtVu5NTi.cjs.map → detail-Bp2Nv0cs.cjs.map} +1 -1
- package/dist/chunks/{detail-DAPz2qyn.js → detail-Cmw-aQcu.js} +4 -4
- package/dist/chunks/{detail-DAPz2qyn.js.map → detail-Cmw-aQcu.js.map} +1 -1
- package/dist/chunks/format-date-time-CB-LxzqT.js.map +1 -1
- package/dist/chunks/format-date-time-D-cx5M8z.cjs +2 -0
- package/dist/chunks/{format-date-time-XxBzF0F5.cjs.map → format-date-time-D-cx5M8z.cjs.map} +1 -1
- package/dist/chunks/login-9bCXyjbX.cjs.map +1 -1
- package/dist/chunks/login-BKxpLibd.js.map +1 -1
- package/dist/chunks/notifications-Bc4mgSds.cjs +2 -0
- package/dist/chunks/{notifications--hwl-DR0.cjs.map → notifications-Bc4mgSds.cjs.map} +1 -1
- package/dist/chunks/notifications-DJ5wzCye.js.map +1 -1
- package/dist/chunks/{orgs-DytLvZ_X.js → orgs-B930facb.js} +11 -10
- package/dist/chunks/{orgs-DytLvZ_X.js.map → orgs-B930facb.js.map} +1 -1
- package/dist/chunks/orgs-BefGgeyc.cjs +2 -0
- package/dist/chunks/{orgs-Ni22buHs.cjs.map → orgs-BefGgeyc.cjs.map} +1 -1
- package/dist/chunks/providers-BsEn3ikK.cjs +2 -0
- package/dist/chunks/{providers-D_zTbkQH.cjs.map → providers-BsEn3ikK.cjs.map} +1 -1
- package/dist/chunks/{providers-DEqcuXw9.js → providers-DjLh4oLY.js} +3 -3
- package/dist/chunks/{providers-DEqcuXw9.js.map → providers-DjLh4oLY.js.map} +1 -1
- package/dist/chunks/{chunk-CMqjfN_6.cjs → rolldown-runtime-BocRIvOZ.cjs} +1 -1
- package/dist/chunks/router-adapter--gYs13E8.cjs.map +1 -1
- package/dist/chunks/routes-config-fDVHmvXi.cjs.map +1 -1
- package/dist/chunks/users-C9LA-Rd7.cjs +2 -0
- package/dist/chunks/{users-0HqlM_VQ.cjs.map → users-C9LA-Rd7.cjs.map} +1 -1
- package/dist/chunks/users-FWrb3ehW.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/next/index.cjs +1 -1
- package/dist/next/index.cjs.map +1 -1
- package/dist/next/index.js +9 -9
- package/dist/next/index.js.map +1 -1
- package/dist/next/workflow-chat-route.cjs +1 -1
- package/dist/next/workflow-chat-route.cjs.map +1 -1
- package/dist/next/workflow-chat-route.js +2 -1
- package/dist/next/workflow-chat-route.js.map +1 -1
- package/dist/pages/admin/delegations/index.cjs +1 -1
- package/dist/pages/admin/delegations/index.cjs.map +1 -1
- package/dist/pages/admin/delegations/index.js +1 -1
- package/dist/pages/admin/orgs/index.cjs +1 -1
- package/dist/pages/admin/orgs/index.cjs.map +1 -1
- package/dist/pages/admin/orgs/index.js +1 -1
- package/dist/pages/admin/users/index.cjs +1 -1
- package/dist/pages/admin/users/index.cjs.map +1 -1
- package/dist/pages/cc/index.cjs.map +1 -1
- package/dist/pages/dashboard/index.cjs.map +1 -1
- package/dist/pages/delegations/index.cjs +1 -1
- package/dist/pages/delegations/index.cjs.map +1 -1
- package/dist/pages/delegations/index.js +1 -1
- package/dist/pages/inbox/index.cjs.map +1 -1
- package/dist/pages/instances/detail/index.cjs +1 -1
- package/dist/pages/instances/detail/index.cjs.map +1 -1
- package/dist/pages/instances/detail/index.js +1 -1
- package/dist/pages/instances/new/index.cjs.map +1 -1
- package/dist/pages/login/index.cjs.map +1 -1
- package/dist/pages/root/index.cjs.map +1 -1
- package/dist/pages/search/index.cjs.map +1 -1
- package/dist/pages/sent/index.cjs.map +1 -1
- package/dist/pages/settings/notifications/index.cjs +1 -1
- package/dist/pages/settings/notifications/index.cjs.map +1 -1
- package/dist/pages/templates/categories/index.cjs +1 -1
- package/dist/pages/templates/categories/index.cjs.map +1 -1
- package/dist/pages/templates/compose/index.cjs +1 -1
- package/dist/pages/templates/compose/index.cjs.map +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.cjs.map +1 -1
- package/dist/pages/templates/designer/index.js +1 -1
- package/dist/pages/templates/index.cjs.map +1 -1
- package/dist/pages/templates/versions/index.cjs.map +1 -1
- package/dist/views/admin/delegations/index.cjs +1 -1
- package/dist/views/admin/delegations/index.js +1 -1
- package/dist/views/admin/index.cjs +1 -1
- package/dist/views/admin/index.js +2 -2
- package/dist/views/admin/orgs/index.cjs +1 -1
- package/dist/views/admin/orgs/index.js +1 -1
- package/dist/views/admin/users/index.cjs +1 -1
- package/dist/views/cc/index.cjs +1 -1
- package/dist/views/cc/index.cjs.map +1 -1
- package/dist/views/dashboard/index.cjs +1 -1
- package/dist/views/dashboard/index.cjs.map +1 -1
- package/dist/views/delegations/index.cjs +1 -1
- package/dist/views/delegations/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/index.cjs +1 -1
- package/dist/views/forms/renderer/index.js +1 -1
- package/dist/views/inbox/index.cjs +1 -1
- package/dist/views/inbox/index.cjs.map +1 -1
- 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/new/index.cjs +1 -1
- package/dist/views/instances/new/index.cjs.map +1 -1
- package/dist/views/instances/new/index.js +1 -1
- package/dist/views/instances/new/index.js.map +1 -1
- package/dist/views/search/index.cjs +1 -1
- package/dist/views/search/index.cjs.map +1 -1
- package/dist/views/sent/index.cjs +1 -1
- package/dist/views/sent/index.cjs.map +1 -1
- package/dist/views/settings/index.cjs +1 -1
- package/dist/views/settings/notifications/index.cjs +1 -1
- package/dist/views/templates/categories/index.cjs +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/index.cjs +1 -1
- package/dist/views/templates/designer/index.js +1 -1
- package/dist/views/templates/index.cjs +1 -1
- package/dist/views/templates/index.cjs.map +1 -1
- package/dist/views/templates/index.js.map +1 -1
- package/dist/views/templates/versions/index.cjs +1 -1
- package/dist/views/templates/versions/index.cjs.map +1 -1
- package/dist/views/templates/versions/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/chunks/FormBuilderView-D6baVqBY.cjs +0 -3
- package/dist/chunks/FormRendererView-Cw9LiidV.cjs +0 -2
- package/dist/chunks/approval-instance-list-page-C408vxE2.cjs +0 -2
- package/dist/chunks/categories-DUfldZ_9.cjs +0 -2
- package/dist/chunks/compose-CODnd9-2.cjs +0 -2
- package/dist/chunks/dashboard-page-DwHQY6Ki.cjs +0 -2
- package/dist/chunks/delegations-CGj-tZNO.cjs +0 -2
- package/dist/chunks/delegations-kbMOSEif.cjs +0 -2
- package/dist/chunks/designer-Cdn10NNl.cjs +0 -65
- package/dist/chunks/detail-CtVu5NTi.cjs +0 -2
- package/dist/chunks/format-date-time-XxBzF0F5.cjs +0 -2
- package/dist/chunks/notifications--hwl-DR0.cjs +0 -2
- package/dist/chunks/orgs-Ni22buHs.cjs +0 -2
- package/dist/chunks/providers-D_zTbkQH.cjs +0 -2
- package/dist/chunks/users-0HqlM_VQ.cjs +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
## 0.11.0 (2026-08-18)
|
|
2
|
+
|
|
3
|
+
### 🚀 Features
|
|
4
|
+
|
|
5
|
+
- **notification:** bound delivery dispatch with a timeout ([d8115f0](https://github.com/Rytass/BPMCore/commit/d8115f0))
|
|
6
|
+
|
|
7
|
+
### 🩹 Fixes
|
|
8
|
+
|
|
9
|
+
- **notification:** move nodemailer to ^9.0.1 ([e094738](https://github.com/Rytass/BPMCore/commit/e094738))
|
|
10
|
+
|
|
11
|
+
### ❤️ Thank You
|
|
12
|
+
|
|
13
|
+
- Chia Yu Pai @fantasywind
|
|
14
|
+
- Claude Opus 5
|
|
15
|
+
|
|
1
16
|
## 0.10.0 (2026-08-18)
|
|
2
17
|
|
|
3
18
|
### 🚀 Features
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use client";const e=require("./rolldown-runtime-BocRIvOZ.cjs"),t=require("./bpm-form-field-Bc6k4ZEO.cjs"),n=require("./FormRendererView-Dde1s3I0.cjs");let r=require("react"),i=require("@mezzanine-ui/react"),a=require("react/jsx-runtime"),o=require("@mezzanine-ui/icons"),s=require("@rytass/bpm-core-client/form"),c=require("@rytass/bpm-core-shared/form"),l=require("@hello-pangea/dnd"),u=require("next/dynamic");u=e.t(u,1);let d=require("@codemirror/lang-json"),f=require("@codemirror/view");var p={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%`},m=[(0,d.json)(),f.EditorView.lineWrapping,f.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`}})],h=(0,u.default)(()=>import(`@uiw/react-codemirror`),{loading:()=>(0,a.jsx)(`div`,{style:p,children:`載入 JSON 編輯器`}),ssr:!1});function ee({disabled:e=!1,height:t,name:n,onChange:r,placeholder:i,value:o}){return(0,a.jsx)(h,{"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:[...m],height:t,indentWithTab:!1,onChange:r,placeholder:i,readOnly:e,theme:`light`,value:o,width:`100%`})}var g=[{description:`單行文字、姓名、編號`,icon:o.AlignLeftIcon,label:`文字`,type:`text`},{description:`多行補充內容`,icon:o.FileIcon,label:`長文字`,type:`textarea`},{description:`金額、數量、分數`,icon:o.CurrencyDollarIcon,label:`數字`,type:`number`},{description:`金額與費用`,icon:o.CurrencyDollarIcon,label:`金額`,type:`money`},{description:`日期或到期日`,icon:o.CalendarIcon,label:`日期`,type:`date`},{description:`日期與時間`,icon:o.CalendarIcon,label:`日期時間`,type:`datetime`},{description:`是 / 否狀態`,icon:o.CheckedIcon,label:`開關`,type:`boolean`},{description:`固定選項擇一`,icon:o.ListIcon,label:`下拉選單`,type:`select`},{description:`可搜尋的固定選項`,icon:o.ListIcon,label:`自動完成`,type:`autocomplete`},{description:`固定選項單選`,icon:o.DotGridIcon,label:`單選`,type:`radio`},{description:`固定選項複選`,icon:o.CheckedOutlineIcon,label:`複選`,type:`checkbox`},{description:`附件或佐證資料`,icon:o.FileAttachmentIcon,label:`附件`,type:`file_upload`}],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},_={display:`grid`,gap:12},ie={display:`flex`,flexWrap:`wrap`,gap:6},ae={flex:`0 0 auto`,whiteSpace:`nowrap`},oe={display:`grid`,gap:8},se={alignItems:`center`,cursor:`grab`,display:`flex`,gap:12,touchAction:`none`},ce={display:`grid`,flex:`1 1 auto`,gap:2,minWidth:0},le={alignItems:`center`,display:`flex`,flex:`0 0 auto`,gap:4},ue={alignItems:`center`,display:`flex`,gap:6},de={cursor:`pointer`,userSelect:`none`},fe={filter:`drop-shadow(0 8px 18px rgba(0, 0, 0, 0.12))`},pe={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)`},me={alignItems:`center`,border:`1px dashed var(--mzn-color-border-neutral)`,borderRadius:6,display:`grid`,gap:12,minHeight:240,padding:32,textAlign:`center`},he={display:`flex`,gap:8,justifyContent:`center`},ge={display:`grid`,gap:14},_e={display:`grid`,columnGap:16,gridTemplateColumns:`repeat(auto-fit, minmax(280px, 1fr))`,rowGap:8},ve={gridColumn:`1 / -1`},ye={alignItems:`center`,display:`flex`,gap:8,gridColumn:`1 / -1`,justifyContent:`flex-end`},be={gridColumn:`1 / -1`},xe={alignItems:`start`,display:`block`,width:`100%`},Se={...xe,gridColumn:`1 / -1`},Ce={minWidth:0,width:`100%`},we={minWidth:`100%`,width:`100%`},Te={display:`grid`,gap:14},Ee={alignItems:`start`,display:`block`,width:`100%`},De={minWidth:0,width:`100%`},Oe={gridColumn:`2 / -1`},ke={display:`grid`,gap:10,width:`100%`},Ae={display:`grid`,gap:8,gridTemplateColumns:`repeat(auto-fit, minmax(160px, 1fr))`},je={display:`inline-flex`},Me={display:`grid`,gap:16},v={display:`grid`,gap:8},y={display:`flex`,justifyContent:`flex-end`},Ne={color:`var(--mzn-color-text-error)`,fontSize:`0.72em`,lineHeight:0,marginLeft:2,verticalAlign:`super`},Pe={display:`grid`,gap:10,gridColumn:`1 / -1`},Fe={backgroundColor:`var(--mzn-color-bg-surface-secondary)`,borderRadius:6,display:`grid`,gap:4,padding:10},Ie={display:`grid`,gap:8,gridTemplateColumns:`minmax(180px, 0.7fr) minmax(220px, 1.3fr)`};function Le(e){e&&(e.style.width=`100%`)}var Re={fields:[],schemaVersion:1},ze={layout:[],schemaVersion:1},b=`__STATIC_OPTIONS__`,x=`__CONSTANT__`,S=`__UNBOUND__`,Be=[{id:b,name:`靜態選項`}],C=[{id:`single`,name:`單選`},{id:`multiple`,name:`複選`}],Ve=[{id:`unset`,name:`不預設`},{id:`true`,name:`是`},{id:`false`,name:`否`}],He=[{id:`true`,name:`是`},{id:`false`,name:`否`}],Ue=[{label:`顯示`,name:`fieldVisibleWhen`,supportingText:`符合條件時才顯示這個欄位。`,target:`visibleWhen`},{label:`必填`,name:`fieldRequiredWhen`,supportingText:`符合條件時才要求填寫這個欄位。`,target:`requiredWhen`},{label:`唯讀`,name:`fieldReadonlyWhen`,supportingText:`符合條件時不允許修改這個欄位。`,target:`readonlyWhen`}];function w({onChange:e,value:u}){let d=u?.schema??Re,f=u?.uiSchema??ze,[p,m]=(0,r.useState)(d),[h,w]=(0,r.useState)(f),[O,k]=(0,r.useState)(D(d)),[rt,A]=(0,r.useState)(D(f)),[it,at]=(0,r.useState)({}),[ot,j]=(0,r.useState)(null),[M,N]=(0,r.useState)(`design`),[P,F]=(0,r.useState)(null),[I,st]=(0,r.useState)([]),[L,ct]=(0,r.useState)(null),[lt,ut]=(0,r.useState)(`loading`),[R,z]=(0,r.useState)(null),[dt,ft]=(0,r.useState)(!1),[B,V]=(0,r.useState)(null);(0,r.useEffect)(()=>{let e=!0;return(0,s.listFormDataSources)().then(t=>{e&&(st(t),ct(null),ut(`ready`))}).catch(t=>{e&&(st([]),ct(`目前無法載入 DataSource Catalog,請稍後重試。`),ut(`unavailable`))}),()=>{e=!1}},[]),(0,r.useEffect)(()=>{p.fields.some(e=>e.fieldKey===P)||F(p.fields[0]?.fieldKey??null)},[p.fields,P]),(0,r.useEffect)(()=>{at(e=>(0,s.buildFormRendererValues)(p.fields,e))},[p.fields]),(0,r.useEffect)(()=>{M!==`advanced`&&(k(D(p)),A(D(h)))},[M,p,h]);let H=(0,r.useMemo)(()=>p.fields.find(e=>e.fieldKey===P)??p.fields[0]??null,[p.fields,P]);(0,r.useEffect)(()=>{e?.({schema:p,uiSchema:h})},[p,h]);function U(e){let t=p.fields.length+1,n=(0,s.createFieldDefinition)(e,t);m({...p,fields:[...p.fields,n]}),w({...h,layout:[...h.layout,{fieldKey:n.fieldKey,width:e===`textarea`||e===`file_upload`?`FULL`:`HALF`}]}),F(n.fieldKey),N(`design`),j(null)}function pt(e){let t=e;t===`advanced`&&M!==`advanced`&&(k(D(p)),A(D(h))),N(t)}function mt(e){let t=p.fields.flatMap(t=>(0,c.isFormDataSourceFieldDefinition)(t)&&(0,s.readFormDataSourceFieldDependencyKeys)(t).includes(e)?[t.fieldKey]:[]);if(t.length>0){V({affectedFieldKeys:t,fieldKey:e,kind:`remove-field`});return}ht(e)}function ht(e){let t=p.fields.filter(t=>t.fieldKey!==e);m({...p,fields:t}),w({...h,layout:h.layout.filter(t=>t.fieldKey!==e)}),F(P===e?t[0]?.fieldKey??null:P),j(null),z(null)}function gt(e){let t=e.destination;t&&e.source.index!==t.index&&(m(n=>({...n,fields:nt(n.fields,e.source.index,t.index)})),w(n=>({...n,layout:nt(n.layout,e.source.index,t.index)})),j(null))}function W(e){G(t=>({...t,...e}))}function G(e){if(!H)return;let t=H.fieldKey,n=e(H),r=n.fieldKey,i={...p,fields:p.fields.map(e=>e.fieldKey===t?n:e)},a=t===r?i:(0,s.renameFormDataSourceFieldBindings)(i,t,r);m(a),w({...h,layout:h.layout.map(e=>e.fieldKey===t?{...e,fieldKey:r}:e)}),F(r),j(null),z(null)}function K(e){G(t=>Ze(t)?{...t,...e}:t)}function q(e){G(t=>(0,s.isNumberFieldDefinition)(t)?{...t,...e}:t)}function _t(e){G(t=>(0,s.isDateFieldDefinition)(t)?{...t,...e}:t)}function J(e){G(t=>(0,s.isSelectFieldDefinition)(t)?{...t,...e}:t)}function vt(e){if(!H||H.type!==`select`&&H.type!==`autocomplete`||(0,c.readFormFieldSelectionMode)(H)===e)return;let t=H.defaultValue,n=e===`multiple`?typeof t==`string`?[t]:t:Array.isArray(t)?t[0]:t;Y(H,{...H,defaultValue:n,mode:e},`選擇模式變更可能轉換或捨棄既有預設值。`)}function Y(e,t,n=`此變更會替換目前選項來源;既有 options、dynamic reference 或 bindings 可能失效。`){JSON.stringify(e)!==JSON.stringify(t)&&V({fieldKey:e.fieldKey,impact:n,kind:`replace-field`,nextField:t})}function yt(e,t){if(!t)return;if(t===b){if(!(0,c.isFormDataSourceFieldDefinition)(e))return;let{dataSource:t,defaultValue:n,...r}=e;Y(e,{...r,options:[]});return}let n=I.find(e=>T(e)===t);if(!n)return;if((0,c.isFormDataSourceFieldDefinition)(e)){let t=new Set(n.parameters.map(e=>e.key)),r=e.dataSource.bindings.filter(e=>t.has(e.parameter));Y(e,{...e,dataSource:{bindings:r,key:n.key,version:n.version}});return}let{options:r,defaultValue:i,...a}=e;Y(e,{...a,dataSource:{bindings:[],key:n.key,version:n.version}})}function bt(){B&&(B.kind===`remove-field`?ht(B.fieldKey):(m({...p,fields:p.fields.map(e=>e.fieldKey===B.fieldKey?B.nextField:e)}),j(null),z(null)),V(null))}async function xt(){ft(!0);try{let e=await(0,s.lintFormSchema)(p,h);z(e.errors.map(s.readFormSchemaLintMessage))}catch{z([`目前無法完成 DataSource schema 驗證。`])}finally{ft(!1)}}function St(e){G(t=>t.type===`boolean`?{...t,...e}:t)}function Ct(e){G(t=>t.type===`file_upload`?{...t,...e}:t)}function wt(e){at(e)}function Tt(e,t){m(n=>({...n,fields:n.fields.map(n=>n.fieldKey===e?{...n,required:t}:n)})),j(null)}function Et(e){k(e);try{m(JSON.parse(e)),j(null)}catch{j(`Form Schema JSON 格式不正確`)}}function Dt(e){A(e);try{w(JSON.parse(e)),j(null)}catch{j(`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:Me,children:[(0,a.jsxs)(i.Tab,{activeKey:M,onChange:pt,size:`sub`,children:[(0,a.jsx)(i.TabItem,{children:`設計`},`design`),(0,a.jsx)(i.TabItem,{children:`預覽`},`preview`),(0,a.jsx)(i.TabItem,{children:`進階`},`advanced`)]}),M===`design`?Ot():null,M===`preview`?en():null,M===`advanced`?tn():null]})})})}),B?(0,a.jsx)(i.Modal,{cancelText:`返回`,confirmText:`確認變更`,modalType:`standard`,onCancel:()=>V(null),onClose:()=>V(null),onConfirm:bt,open:!0,showModalFooter:!0,showModalHeader:!0,title:B.kind===`remove-field`?`確認移除 dependency 欄位`:`確認替換選項來源`,children:B.kind===`remove-field`?(0,a.jsxs)(`div`,{style:v,children:[(0,a.jsx)(i.Typography,{variant:`body`,children:`此欄位仍被下列 DataSource binding 使用;移除後請重新設定這些欄位。`}),(0,a.jsx)(i.Typography,{color:`text-warning`,variant:`body`,children:B.affectedFieldKeys.join(`、`)})]}):(0,a.jsxs)(i.Typography,{variant:`body`,children:[B.impact,`確認後才會寫入 schema。`]})}):null]});function Ot(){return(0,a.jsxs)(`div`,{style:_,children:[(0,a.jsxs)(`div`,{style:oe,children:[(0,a.jsx)(i.Typography,{component:`h2`,variant:`label-primary`,children:`新增欄位`}),(0,a.jsx)(`div`,{style:ie,children:g.map(e=>(0,a.jsx)(i.Button,{icon:e.icon,iconType:`leading`,onClick:()=>U(e.type),size:`sub`,style:ae,type:`button`,variant:`base-secondary`,children:e.label},e.type))})]}),(0,a.jsxs)(`div`,{style:te,children:[(0,a.jsxs)(`div`,{style:{..._,...ne},children:[(0,a.jsx)(i.Typography,{component:`h2`,variant:`label-primary`,children:`表單畫布`}),p.fields.length>0?(0,a.jsx)(l.DragDropContext,{onDragEnd:gt,children:(0,a.jsx)(l.Droppable,{droppableId:`form-builder-fields`,children:e=>(0,a.jsxs)(`div`,{...e.droppableProps,ref:e.innerRef,style:_,children:[p.fields.map((e,t)=>(0,a.jsx)(l.Draggable,{draggableId:e.fieldKey,index:t,children:(t,n)=>Qt(e,t,n.isDragging)},e.fieldKey)),e.placeholder]})})}):(0,a.jsxs)(`div`,{style:me,children:[(0,a.jsxs)(`div`,{style:_,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:he,children:[(0,a.jsx)(i.Button,{onClick:()=>U(`text`),variant:`base-primary`,children:`新增文字欄位`}),(0,a.jsx)(i.Button,{onClick:()=>U(`textarea`),variant:`base-secondary`,children:`新增長文字`})]})]})]}),(0,a.jsxs)(`div`,{style:{..._,...re},children:[(0,a.jsx)(i.Typography,{component:`h2`,variant:`label-primary`,children:`欄位設定`}),H?kt(H):(0,a.jsx)(i.Typography,{color:`text-neutral`,variant:`body`,children:`請先新增或選取欄位。`})]})]})]})}function kt(e){return(0,a.jsxs)(`div`,{style:ge,children:[At(e),jt(e)]})}function At(e){return(0,a.jsxs)(`div`,{style:_e,children:[(0,a.jsx)(`div`,{style:ye,children:(0,a.jsx)(i.Badge,{size:`main`,text:We(e.type),variant:`text-info`})}),Q(`標題`,`fieldLabel`,(0,a.jsx)(i.Input,{onChange:e=>W({label:e.target.value}),placeholder:`例如:申請金額`,value:e.label,variant:`base`})),Q(`欄位 Key`,`fieldKey`,(0,a.jsx)(i.Input,{onChange:e=>W({fieldKey:e.target.value}),placeholder:`例如:amount`,value:e.fieldKey,variant:`base`})),Q(`提示文字`,`fieldPlaceholder`,(0,a.jsx)(i.Input,{onChange:e=>W({placeholder:e.target.value||void 0}),placeholder:`例如:請輸入申請金額`,value:e.placeholder??``,variant:`base`})),Mt(e)]})}function jt(e){return(0,a.jsx)(i.Accordion,{defaultExpanded:Ye(e),size:`sub`,title:`進階設定`,children:(0,a.jsxs)(`div`,{style:_e,children:[(0,a.jsx)(i.Typography,{component:`h3`,style:ve,variant:`label-primary`,children:`條件規則`}),(0,a.jsx)(i.Typography,{color:`text-neutral`,style:be,variant:`body`,children:`只有需要根據其他欄位改變顯示、必填或唯讀狀態時才需要設定。`}),Kt(e)]})})}function Mt(e){return Ze(e)?Nt(e):(0,s.isNumberFieldDefinition)(e)?Pt(e):(0,s.isDateFieldDefinition)(e)?Ft(e):(0,c.isFormOptionFieldDefinition)(e)?It(e):e.type===`boolean`?Wt(e):Gt(e)}function Nt(e){return(0,a.jsxs)(a.Fragment,{children:[Q(`預設值`,`fieldDefaultValue`,e.type===`textarea`?Yt({name:`fieldDefaultValue`,onChange:e=>K({defaultValue:e||void 0}),placeholder:`輸入此欄位的預設文字`,rows:3,value:E(e.defaultValue)}):(0,a.jsx)(i.Input,{onChange:e=>K({defaultValue:e.target.value||void 0}),placeholder:`輸入此欄位的預設文字`,value:E(e.defaultValue),variant:`base`})),Q(`最小長度`,`fieldMinLength`,Z(e.minLength,e=>K({minLength:e}),`例如:2`,{min:0})),Q(`最大長度`,`fieldMaxLength`,Z(e.maxLength,e=>K({maxLength:e}),`例如:100`,{min:1}))]})}function Pt(e){return(0,a.jsxs)(a.Fragment,{children:[Q(`預設值`,`fieldDefaultValue`,Z(typeof e.defaultValue==`number`?e.defaultValue:void 0,e=>q({defaultValue:e}),e.type===`money`?`例如:1000`:`輸入預設數值`,{max:e.maximum,min:e.minimum})),Q(`最小值`,`fieldMinimum`,Z(e.minimum,e=>q({minimum:e}),`例如:0`)),Q(`最大值`,`fieldMaximum`,Z(e.maximum,e=>q({maximum:e}),`例如:999999`))]})}function Ft(e){return Q(`預設值`,`fieldDefaultValue`,Xt(e,E(e.defaultValue),e=>_t({defaultValue:e})))}function It(e){let t=(0,s.readCompatibleFormDataSourceDescriptors)(e.type,I),n=(0,c.isFormDataSourceFieldDefinition)(e)?T(e.dataSource):b,r=(0,c.isFormDataSourceFieldDefinition)(e)?I.find(t=>t.key===e.dataSource.key&&t.version===e.dataSource.version):null,o=r?t.some(e=>e.key===r.key&&e.version===r.version):!1,l=[...Be,...t.map(Ge),...(0,c.isFormDataSourceFieldDefinition)(e)&&!o?[{id:n,name:`${e.dataSource.key} v${e.dataSource.version}(目前不可用或不支援)`}]:[]],u=(0,c.readFormFieldSelectionMode)(e);return(0,a.jsxs)(a.Fragment,{children:[e.type===`select`||e.type===`autocomplete`?Q(`選擇模式`,`fieldSelectionMode`,(0,a.jsx)(i.Select,{clearable:!1,onChange:e=>{(e?.id===`single`||e?.id===`multiple`)&&vt(e.id)},options:[...C],value:(0,s.readSelectOption)(C,u)})):Q(`選擇模式`,`fieldSelectionMode`,(0,a.jsx)(i.Typography,{color:`text-neutral`,variant:`body`,children:u===`multiple`?`固定複選`:`固定單選`})),Q(`選項來源`,`fieldOptionSource`,(0,a.jsx)(i.Select,{clearable:!1,disabled:lt===`loading`&&!(0,c.isFormDataSourceFieldDefinition)(e),onChange:t=>yt(e,t?.id),options:l,placeholder:`選擇選項來源`,value:(0,s.readSelectOption)(l,n)})),(0,c.isFormDataSourceFieldDefinition)(e)?Lt(e,t):Ut(e)]})}function Lt(e,t){let n=I.find(t=>t.key===e.dataSource.key&&t.version===e.dataSource.version),r=n&&!(0,s.isFormDataSourceDescriptorCompatible)(n,e.type);return(0,a.jsxs)(`div`,{style:Pe,children:[lt===`loading`?(0,a.jsx)(i.Typography,{color:`text-neutral`,variant:`body`,children:`正在載入可用的 DataSource Catalog…`}):null,L?(0,a.jsx)(i.Typography,{color:`text-error`,variant:`body`,children:L}):null,n?null:(0,a.jsx)(i.Typography,{color:`text-warning`,variant:`body`,children:`目前來源版本未出現在 Catalog;會保留原設定,但在環境 lint 通過前不可發布。`}),r?(0,a.jsx)(i.Typography,{color:`text-error`,variant:`body`,children:`目前來源不支援此控制項或超出 bounded list 限制,請選擇其他版本。`}):null,n?Rt(n):null,n?n.parameters.map(t=>zt(e,t)):null,t.length===0&&!L?(0,a.jsx)(i.Typography,{color:`text-warning`,variant:`body`,children:`沒有符合目前控制項能力的已註冊來源。`}):null,(0,a.jsx)(`div`,{style:y,children:(0,a.jsx)(i.Button,{disabled:dt,onClick:()=>void xt(),size:`sub`,type:`button`,variant:`base-secondary`,children:dt?`驗證中…`:`驗證 DataSource 設定`})}),R?(0,a.jsx)(i.Typography,{color:R.length>0?`text-error`:`text-success`,variant:`caption`,children:R.length>0?R.join(`;`):`DataSource schema 與目前環境均通過驗證。`}):null]})}function Rt(e){return(0,a.jsxs)(`div`,{style:Fe,children:[(0,a.jsxs)(i.Typography,{variant:`label-primary`,children:[e.label,` · v`,e.version]}),e.description?(0,a.jsx)(i.Typography,{color:`text-neutral`,variant:`caption`,children:e.description}):null,(0,a.jsxs)(i.Typography,{color:`text-neutral`,variant:`caption`,children:[`支援:`,e.supportedControls.join(`、`),`;`,e.supportsSearch?`支援搜尋`:`不支援搜尋`,`;`,e.paginationMode===`CURSOR`?`支援分頁`:`完整清單`,`; policy:`,e.revalidationPolicy]})]})}function zt(e,n){let r=(0,s.readFormDataSourceBinding)(e,n.key),o=Ke(r),c=(0,s.readCompatibleFormDataSourceBindingFields)(n.type,p.fields,e.fieldKey),l=[...n.required?[]:[{id:S,name:`未綁定`}],...c,...n.type===`STRING_ARRAY`?[]:[{id:x,name:`固定常數`}]];return(0,a.jsxs)(`div`,{style:Ie,children:[(0,a.jsx)(t.t,{label:`${n.label??n.key}${n.required?`(必填)`:`(選填)`}`,name:`dataSourceParameter_${n.key}`,children:(0,a.jsx)(i.Select,{clearable:!1,onChange:t=>Vt(e,n.key,n.type,t?.id),options:l,placeholder:`選擇欄位或常數`,value:(0,s.readSelectOption)(l,o)})}),(0,s.readFormDataSourceBindingValueKind)(r)===`CONSTANT`?Bt(e,n.key,n.type,r):(0,s.readFormDataSourceBindingValueKind)(r)===`FIELD`?(0,a.jsxs)(i.Typography,{color:`text-neutral`,variant:`caption`,children:[`使用表單欄位「`,r?.from.kind===`FIELD`?r.from.fieldKey:``,`」的目前值。`]}):(0,a.jsx)(i.Typography,{color:`text-neutral`,variant:`caption`,children:n.required?c.length>0?`請選擇相容的表單欄位或固定常數。`:`目前沒有型別相容的表單欄位,請先建立 dependency。`:`此參數可不綁定。`})]},n.key)}function Bt(e,t,n,r){let o=(0,s.readFormDataSourceBindingValue)(e,t);if(n===`BOOLEAN`){let e=[{id:`true`,name:`是`},{id:`false`,name:`否`}];return(0,a.jsx)(i.Select,{clearable:!1,onChange:e=>Ht(t,e?.id===`true`),options:e,value:(0,s.readSelectOption)(e,o===!0?`true`:`false`)})}return n===`STRING_ARRAY`?(0,a.jsx)(i.Typography,{color:`text-warning`,variant:`caption`,children:`STRING_ARRAY 參數請綁定複選欄位;目前不接受固定常數。`}):(0,a.jsx)(i.Input,{onChange:e=>Ht(t,n===`NUMBER`?(0,s.parseOptionalNumberInput)(e.target.value)??0:e.target.value),placeholder:n===`NUMBER`?`輸入數字`:`輸入固定值`,value:Je(r,n),variant:`base`})}function Vt(e,t,n,r){if(!r||r===S){G(e=>(0,c.isFormDataSourceFieldDefinition)(e)?(0,s.upsertFormDataSourceFieldBinding)(e,t,null):e);return}if(r===x){G(e=>(0,c.isFormDataSourceFieldDefinition)(e)?(0,s.upsertFormDataSourceFieldBinding)(e,t,{from:{kind:`CONSTANT`,value:qe(n)},parameter:t}):e);return}G(e=>(0,c.isFormDataSourceFieldDefinition)(e)?(0,s.upsertFormDataSourceFieldBinding)(e,t,{from:{fieldKey:r,kind:`FIELD`},parameter:t}):e)}function Ht(e,t){G(n=>(0,c.isFormDataSourceFieldDefinition)(n)?(0,s.upsertFormDataSourceFieldBinding)(n,e,{from:{kind:`CONSTANT`,value:t},parameter:e}):n)}function Ut(e){let t=(0,c.readFormFieldSelectionMode)(e),n=Array.isArray(e.defaultValue)?e.defaultValue:[],r=e.options.map(s.readFieldOptionAsSelectOption),o=r.filter(e=>n.includes(e.id));return(0,a.jsxs)(a.Fragment,{children:[Q(`預設值`,`fieldDefaultValue`,t===`multiple`?(0,a.jsx)(i.Select,{clearable:!0,mode:`multiple`,onChange:e=>J({defaultValue:e.length?e.map(e=>e.id):void 0}),options:r,placeholder:`選擇一或多個預設選項`,value:o}):(0,a.jsx)(i.Select,{clearable:!0,onChange:e=>J({defaultValue:e?.id||void 0}),options:r,placeholder:`選擇預設選項`,value:typeof e.defaultValue==`string`?(0,s.readSelectOption)(r,e.defaultValue):null})),Q(`選項`,`fieldOptions`,Zt(e),!0)]})}function Wt(e){let t=typeof e.defaultValue==`boolean`?String(e.defaultValue):`unset`;return Q(`預設值`,`fieldDefaultValue`,(0,a.jsx)(i.Select,{clearable:!1,onChange:e=>St({defaultValue:e?.id===`true`||e?.id!==`false`&&void 0}),options:[...Ve],placeholder:`選擇預設狀態`,value:(0,s.readSelectOption)(Ve,t)}))}function Gt(e){return(0,a.jsxs)(a.Fragment,{children:[Q(`檔案數`,`fieldMaxFiles`,Z(e.maxFiles,e=>Ct({maxFiles:e}),`例如:1`,{min:1})),Q(`MIME`,`fieldAcceptedMimeTypes`,Yt({name:`fieldAcceptedMimeTypes`,onChange:e=>Ct({acceptedMimeTypes:Qe(e)}),placeholder:`每行一個 MIME type,例如:application/pdf`,rows:3,value:$e(e.acceptedMimeTypes)}),!1)]})}function Kt(e){let t=p.fields.filter(t=>t.fieldKey!==e.fieldKey);return t.length?(0,a.jsx)(a.Fragment,{children:Ue.map(n=>qt(e,n,t))}):(0,a.jsx)(i.Typography,{color:`text-neutral`,style:be,variant:`body`,children:`目前沒有其他欄位可作為條件來源。新增更多欄位後即可設定條件規則。`})}function qt(e,t,n){let r=e[t.target],o=r?(0,s.parseConditionRule)(r):null,c=n.find(e=>e.fieldKey===o?.fieldKey),l=c??n[0],u=n.map(Xe),d=(0,s.readConditionOperatorOptions)(l),f=o&&d.some(e=>e.id===o.operator)?o.operator:(0,s.readDefaultConditionOperator)(l),p=o?.value??(0,s.readDefaultConditionValue)(l),m=!!r,h=m&&(!o||!c);return Q(t.label,t.name,(0,a.jsxs)(`div`,{style:ke,children:[(0,a.jsx)(i.Toggle,{checked:m,label:m?`已啟用`:`不啟用`,onChange:e=>X(t.target,e.target.checked?(0,s.buildConditionExpression)(l,(0,s.readDefaultConditionOperator)(l),(0,s.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:Ae,children:[(0,a.jsx)(i.Select,{clearable:!1,onChange:e=>{let r=n.find(t=>t.fieldKey===e?.id)??l;X(t.target,(0,s.buildConditionExpression)(r,(0,s.readDefaultConditionOperator)(r),(0,s.readDefaultConditionValue)(r)))},options:u,placeholder:`選擇欄位`,value:(0,s.readSelectOption)(u,l.fieldKey)}),(0,a.jsx)(i.Select,{clearable:!1,onChange:e=>X(t.target,(0,s.buildConditionExpression)(l,(0,s.readConditionOperatorOption)(e?.id)??f,p)),options:[...d],placeholder:`判斷方式`,value:(0,s.readSelectOption)(d,f)}),Jt(l,p,e=>X(t.target,(0,s.buildConditionExpression)(l,f,e)))]}):null]}),!0)}function X(e,t){W({[e]:t})}function Jt(e,t,n){if(e.type===`boolean`)return(0,a.jsx)(i.Select,{clearable:!1,onChange:e=>n(e?.id??`true`),options:[...He],placeholder:`比較值`,value:(0,s.readSelectOption)(He,t===`false`?`false`:`true`)});if((0,s.isSelectFieldDefinition)(e)){let r=e.options.map(s.readFieldOptionAsSelectOption);return(0,a.jsx)(i.Select,{clearable:!1,onChange:e=>n(e?.id??r[0]?.id??``),options:r,placeholder:`比較值`,value:(0,s.readSelectOption)(r,t)})}return(0,s.isNumberFieldDefinition)(e)?Z((0,s.parseOptionalNumberInput)(t),e=>n(String(e??0)),`比較值`):(0,s.isDateFieldDefinition)(e)?Xt(e,t,e=>n(e??``)):(0,a.jsx)(i.Input,{onChange:e=>n(e.target.value),placeholder:`比較值`,value:t,variant:`base`})}function Yt({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:Le,resize:`vertical`,rows:r,style:we,value:o})}function Z(e,t,n,r={}){return(0,a.jsx)(i.Input,{max:r.max,min:r.min,onChange:e=>t((0,s.clampOptionalNumber)((0,s.parseOptionalNumberInput)(e.target.value),r)),placeholder:n,showSpinner:!0,step:r.step??1,value:typeof e==`number`?String(e):``,variant:`measure`})}function Xt(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,s.formatDateTimePickerValue)(e)),placeholderLeft:`選擇日期`,placeholderRight:`選擇時間`,value:(0,s.readDatePickerValue)(t)}):(0,a.jsx)(i.DatePicker,{format:`YYYY-MM-DD`,onChange:e=>n((0,s.formatDatePickerValue)(e)),placeholder:`選擇日期`,value:(0,s.readDatePickerValue)(t)})}function Zt(e){let t=e.options.map((t,n)=>({index:n,key:`${e.fieldKey}-${n}`,label:t.label,value:t.value}));return(0,a.jsxs)(`div`,{style:v,children:[(0,a.jsx)(i.Table,{actions:{render:t=>[{disabled:()=>e.options.length<=1,icon:o.TrashIcon,iconType:`icon-only`,name:`移除選項`,onClick:()=>J({options:e.options.filter((e,n)=>n!==t.index)}),variant:`destructive-ghost`}],width:56},columns:[{key:`label`,render:t=>(0,a.jsx)(i.Input,{onChange:n=>J({options:et(e.options,t.index,{label:n.target.value})}),placeholder:`例如:主管`,size:`sub`,value:t.label,variant:`base`}),title:`Label`},{key:`value`,render:t=>(0,a.jsx)(i.Input,{onChange:n=>J({options:et(e.options,t.index,{value:n.target.value})}),placeholder:`例如:manager`,size:`sub`,value:t.value,variant:`base`}),title:`Value`}],dataSource:t,showHeader:!0,size:`sub`}),(0,a.jsx)(`div`,{style:y,children:(0,a.jsx)(i.Button,{icon:o.PlusIcon,iconType:`leading`,onClick:()=>J({options:[...e.options,tt(e.options)]}),variant:`base-secondary`,children:`新增選項`})})]})}function Qt(e,t,n){return(0,a.jsx)(`div`,{...t.draggableProps,"data-form-builder-field-key":e.fieldKey,ref:t.innerRef,style:{...de,...n?fe:null,...t.draggableProps.style},children:(0,a.jsx)(i.BaseCard,{style:e.fieldKey===H?.fieldKey?pe:void 0,children:$t(e,t,n)})})}function Q(e,n,r,i=!1){return(0,a.jsx)(`div`,{style:i?Se:xe,children:(0,a.jsx)(`div`,{style:Ce,children:(0,a.jsx)(t.t,{label:e,name:n,children:r})})})}function $t(e,t,n){return(0,a.jsxs)(`div`,{...t.dragHandleProps??{},"aria-label":`選取或拖曳排序欄位`,onClick:()=>F(e.fieldKey),style:se,title:`點擊選取,拖曳排序`,children:[(0,a.jsx)(`span`,{"aria-label":`拖曳排序`,role:`img`,style:je,title:`拖曳排序`,children:(0,a.jsx)(i.Icon,{icon:o.DotDragVerticalIcon,size:20})}),(0,a.jsxs)(`div`,{style:ce,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:Ne,children:`*`}):null]}),(0,a.jsxs)(i.Typography,{color:`text-neutral`,component:`span`,ellipsis:!0,variant:`caption`,children:[We(e.type),` ·`,e.required?` 必填`:` 選填`,` ·`,e.fieldKey]})]}),(0,a.jsxs)(`div`,{onClick:e=>e.stopPropagation(),style:le,children:[(0,a.jsx)(`div`,{style:ue,children:(0,a.jsx)(i.Toggle,{checked:!!e.required,disabled:n,label:`必填`,onChange:t=>Tt(e.fieldKey,t.target.checked)})}),(0,a.jsx)(i.Button,{disabled:n,icon:o.TrashIcon,iconType:`icon-only`,onClick:()=>mt(e.fieldKey),variant:`destructive-ghost`,children:`移除欄位`})]})]})}function en(){return(0,a.jsxs)(`div`,{style:_,children:[(0,a.jsx)(i.Typography,{component:`h2`,variant:`h3`,children:`填寫預覽`}),(0,a.jsx)(n.t,{dataSourceContext:{kind:`preview`},onChange:wt,schema:p,uiSchema:h,value:it})]})}function tn(){return(0,a.jsxs)(`div`,{style:_,children:[(0,a.jsx)(i.Typography,{component:`h2`,variant:`h3`,children:`Schema`}),(0,a.jsxs)(`div`,{style:Te,children:[$(`Form Schema`,`schemaJson`,(0,a.jsx)(ee,{height:`360px`,name:`schemaJson`,onChange:Et,placeholder:`輸入 Form Schema JSON`,value:O})),$(`UI Schema`,`uiSchemaJson`,(0,a.jsx)(ee,{height:`240px`,name:`uiSchemaJson`,onChange:Dt,placeholder:`輸入 UI Schema JSON`,value:rt})),ot?(0,a.jsx)(i.Typography,{color:`text-error`,style:Oe,variant:`body`,children:ot}):null]})]})}function $(e,n,r){return(0,a.jsx)(`div`,{style:Ee,children:(0,a.jsx)(`div`,{style:De,children:(0,a.jsx)(t.t,{label:e,name:n,children:r})})})}}function We(e){return g.find(t=>t.type===e)?.label??e}function T(e){return`${e.key}@${e.version}`}function Ge(e){return{id:T(e),name:`${e.label} · ${e.key} v${e.version}`}}function Ke(e){return e?e.from.kind===`FIELD`?e.from.fieldKey:x:S}function qe(e){switch(e){case`BOOLEAN`:return!1;case`NUMBER`:return 0;case`STRING_ARRAY`:return``;case`STRING`:return``;default:return``}}function Je(e,t){let n=e?.from.kind===`CONSTANT`?e.from.value:``;return t===`NUMBER`?typeof n==`number`?String(n):``:typeof n==`string`?n:``}function Ye(e){return!!(e.visibleWhen||e.requiredWhen||e.readonlyWhen)}function Xe(e){return{id:e.fieldKey,name:e.label}}function Ze(e){return e.type===`text`||e.type===`textarea`}function E(e){return typeof e==`string`?e:``}function Qe(e){let t=e.split(/[\n,]/u).map(e=>e.trim()).filter(Boolean);return t.length?t:void 0}function $e(e){return e?.join(`
|
|
2
|
+
`)??``}function D(e){return JSON.stringify(e,null,2)}function et(e,t,n){return e.map((e,r)=>r===t?{...e,...n}:e)}function tt(e){let t=e.length+1;return{label:`選項 ${t}`,value:O(e,t)}}function O(e,t){let n=`option_${t}`;return e.some(e=>e.value===n)?O(e,t+1):n}function nt(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 w}});
|
|
3
|
+
//# sourceMappingURL=FormBuilderView-CAqjOYAP.cjs.map
|