@rytass/bpm-core-react 0.21.0 → 0.21.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +46 -0
- package/dist/chunks/{FormBuilderView-WtC2iW5f.js → FormBuilderView-6KdApi-D.js} +8 -8
- package/dist/chunks/{FormBuilderView-WtC2iW5f.js.map → FormBuilderView-6KdApi-D.js.map} +1 -1
- package/dist/chunks/{FormBuilderView-DjPGrOJ2.cjs → FormBuilderView-CGKkuVFi.cjs} +3 -3
- package/dist/chunks/{FormBuilderView-DjPGrOJ2.cjs.map → FormBuilderView-CGKkuVFi.cjs.map} +1 -1
- package/dist/chunks/{approval-instance-list-page-Bth7Raya.js → approval-instance-list-page-BI5fIXc-.js} +26 -26
- package/dist/chunks/{approval-instance-list-page-Bth7Raya.js.map → approval-instance-list-page-BI5fIXc-.js.map} +1 -1
- package/dist/chunks/{approval-instance-list-page-Dcvo6TrT.cjs → approval-instance-list-page-Cv5I1YPX.cjs} +2 -2
- package/dist/chunks/{approval-instance-list-page-Dcvo6TrT.cjs.map → approval-instance-list-page-Cv5I1YPX.cjs.map} +1 -1
- package/dist/chunks/{compose-DZvIspW3.js → compose-DFuLPmOA.js} +4 -4
- package/dist/chunks/{compose-DZvIspW3.js.map → compose-DFuLPmOA.js.map} +1 -1
- package/dist/chunks/compose-DK3ocWwG.cjs +2 -0
- package/dist/chunks/compose-DK3ocWwG.cjs.map +1 -0
- package/dist/chunks/designer-CAUWEKJ4.cjs +69 -0
- package/dist/chunks/designer-CAUWEKJ4.cjs.map +1 -0
- package/dist/chunks/{designer-CWubIE69.js → designer-CCy5EbOe.js} +2189 -1608
- package/dist/chunks/designer-CCy5EbOe.js.map +1 -0
- package/dist/chunks/detail-C5KrUC7s.cjs +5 -0
- package/dist/chunks/detail-C5KrUC7s.cjs.map +1 -0
- package/dist/chunks/{detail-Bv90gvy0.js → detail-Dnc4PPWO.js} +768 -742
- package/dist/chunks/detail-Dnc4PPWO.js.map +1 -0
- package/dist/chunks/{instance-error-message-CAP1vJhX.js → instance-error-message-BEM4O_Kj.js} +6 -2
- package/dist/chunks/instance-error-message-BEM4O_Kj.js.map +1 -0
- package/dist/chunks/instance-error-message-BpCLCOjp.cjs +2 -0
- package/dist/chunks/instance-error-message-BpCLCOjp.cjs.map +1 -0
- package/dist/chunks/organization-time-zone-provider-B7CXQril.cjs +2 -0
- package/dist/chunks/organization-time-zone-provider-B7CXQril.cjs.map +1 -0
- package/dist/chunks/organization-time-zone-provider-DNL8yo4-.js +42 -0
- package/dist/chunks/organization-time-zone-provider-DNL8yo4-.js.map +1 -0
- package/dist/chunks/{providers-BbCs23sk.js → providers-CQWekD7_.js} +197 -196
- package/dist/chunks/providers-CQWekD7_.js.map +1 -0
- package/dist/chunks/providers-VUOh6i0i.cjs +2 -0
- package/dist/chunks/providers-VUOh6i0i.cjs.map +1 -0
- package/dist/components/notification-drawer-options.d.cts +18 -0
- package/dist/components/notification-drawer-options.d.ts +18 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +23 -23
- package/dist/index.js.map +1 -1
- package/dist/lib/organization-time-zone-provider.d.cts +20 -0
- package/dist/lib/organization-time-zone-provider.d.ts +20 -0
- package/dist/lib/organization-time-zone.d.cts +8 -0
- package/dist/lib/organization-time-zone.d.ts +8 -0
- package/dist/lib/providers.d.cts +10 -1
- package/dist/lib/providers.d.ts +10 -1
- package/dist/next/BPMNextProviders.d.cts +8 -1
- package/dist/next/BPMNextProviders.d.ts +8 -1
- package/dist/next/index.cjs +1 -1
- package/dist/next/index.cjs.map +1 -1
- package/dist/next/index.js +12 -11
- package/dist/next/index.js.map +1 -1
- 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/cc/index.cjs +1 -1
- package/dist/views/cc/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/instances/detail/index.cjs +1 -1
- package/dist/views/instances/detail/index.js +1 -1
- package/dist/views/instances/detail/sections/shared.d.cts +0 -1
- package/dist/views/instances/detail/sections/shared.d.ts +0 -1
- package/dist/views/instances/new/index.cjs +1 -1
- package/dist/views/instances/new/index.js +1 -1
- package/dist/views/search/index.cjs +1 -1
- package/dist/views/search/index.js +1 -1
- package/dist/views/sent/index.cjs +1 -1
- package/dist/views/sent/index.js +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/approver-resolver-model.d.cts +105 -1
- package/dist/views/templates/designer/approver-resolver-model.d.ts +105 -1
- package/dist/views/templates/designer/dynamic-form-resolver-options.d.cts +5 -0
- package/dist/views/templates/designer/dynamic-form-resolver-options.d.ts +5 -0
- package/dist/views/templates/designer/index.cjs +1 -1
- package/dist/views/templates/designer/index.js +1 -1
- package/dist/views/templates/designer/node-actor-resolver-options.d.cts +44 -1
- package/dist/views/templates/designer/node-actor-resolver-options.d.ts +44 -1
- package/dist/views/templates/designer/notify-recipient-options.d.cts +81 -0
- package/dist/views/templates/designer/notify-recipient-options.d.ts +81 -0
- package/dist/views/templates/designer/position-level-options.d.cts +3 -1
- package/dist/views/templates/designer/position-level-options.d.ts +3 -1
- package/dist/views/templates/designer/position-scope.d.cts +51 -0
- package/dist/views/templates/designer/position-scope.d.ts +51 -0
- package/package.json +3 -3
- package/dist/chunks/compose-BKUTsB2W.cjs +0 -2
- package/dist/chunks/compose-BKUTsB2W.cjs.map +0 -1
- package/dist/chunks/designer-CWubIE69.js.map +0 -1
- package/dist/chunks/designer-C_m8DmMl.cjs +0 -69
- package/dist/chunks/designer-C_m8DmMl.cjs.map +0 -1
- package/dist/chunks/detail-Bv90gvy0.js.map +0 -1
- package/dist/chunks/detail-DNzqesdI.cjs +0 -5
- package/dist/chunks/detail-DNzqesdI.cjs.map +0 -1
- package/dist/chunks/instance-error-message-BW464LRQ.cjs +0 -2
- package/dist/chunks/instance-error-message-BW464LRQ.cjs.map +0 -1
- package/dist/chunks/instance-error-message-CAP1vJhX.js.map +0 -1
- package/dist/chunks/language-provider-Bdnx3Gxl.cjs +0 -2
- package/dist/chunks/language-provider-Bdnx3Gxl.cjs.map +0 -1
- package/dist/chunks/language-provider-phkWOapf.js +0 -17
- package/dist/chunks/language-provider-phkWOapf.js.map +0 -1
- package/dist/chunks/providers-BbCs23sk.js.map +0 -1
- package/dist/chunks/providers-D_KAgOOu.cjs +0 -2
- package/dist/chunks/providers-D_KAgOOu.cjs.map +0 -1
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
let e=require("@rytass/bpm-core-shared"),t=require("@rytass/bpm-core-client/form"),n=require("@rytass/bpm-core-shared/form");function r(t,n){let r=(0,e.readApproverFilledFieldKeys)(n);return{...t,fields:t.fields.filter(e=>!r.has(e.fieldKey))}}function i(t,n){return(0,e.omitFormDataKeys)(t,(0,e.readApproverFilledFieldKeys)(n))}function a(t,n){let r=(0,e.readNodeFillableFieldKeys)(n),i=o(t,n);return{...i,fields:i.fields.filter(e=>r.has(e.fieldKey))}}function o(t,n){let r=(0,e.readNodeFillableFieldKeys)(n),i=(0,e.readNodeRequiredFieldKeys)(n);return{...t,fields:t.fields.map(e=>r.has(e.fieldKey)?{...e,required:i.has(e.fieldKey),requiredWhen:void 0}:e)}}var s=e=>e.nodes.filter(e=>e.type===`userTask`);function c(t,n){let r=n===null?new Set:(0,e.readNodeFillableFieldKeys)(n);return s(t).reduce((t,n)=>({...Object.fromEntries([...(0,e.readNodeFillableFieldKeys)(n)].map(e=>[e,r.has(e)?`本關補填`:`${n.data.label||n.id}補填`])),...t}),{})}function l(t,n){return Object.fromEntries([...(0,e.readNodeFillableFieldKeys)(n)].filter(e=>Object.prototype.hasOwnProperty.call(t,e)).map(e=>[e,t[e]??null]))}function u({draft:t,node:r,schema:i,stored:a,values:o}){let s=(0,e.readNodeFillableFieldKeys)(r),c=i.fields.filter(e=>{let t=o[e.fieldKey];return(0,n.isTableFieldDefinition)(e)&&s.has(e.fieldKey)&&!Object.prototype.hasOwnProperty.call(a,e.fieldKey)&&Array.isArray(t)&&t.length>0});return{...Object.fromEntries(c.map(e=>[e.fieldKey,o[e.fieldKey]])),...t}}function d(e){return e.includes(`form data changed; refresh and retry`)}var f=/^欄位「(.+?)」(.+)$/,p=/^「(.+?)」第 (\d+) 列(?:的「(.+?)」)?(.+)$/,m=`缺少必填欄位:`;function h(e,t,n){let r=n.settings?.label||n.settings?.fieldKey||``;switch(e){case`REQUIRED`:return n.topLevel&&r!==``?`${r}為必填欄位。`:`此欄為必填。`;case`MIN_LENGTH`:return`至少需要 ${t??0} 個字。`;case`MAX_LENGTH`:return`最多 ${t??0} 個字。`;case`MIN_ROWS`:return`至少需要 ${t??0} 列。`;case`MAX_ROWS`:return`最多 ${t??0} 列。`;case`PATTERN`:return(n.settings&&(n.settings.type===`text`||n.settings.type===`textarea`)?n.settings.patternErrorMessage?.trim():void 0)||`格式不正確。`;case`PATTERN_TIMEOUT`:return`格式檢查逾時,請縮短內容後再試,或請表單設計者簡化格式。`;default:return`此欄內容不正確。`}}function g(e){let t=/^至少需要 (\d+) 列$/.exec(e),n=/^最多 (\d+) 列$/.exec(e),r=/^至少需要 (\d+) 個字$/.exec(e),i=/^最多 (\d+) 個字$/.exec(e);return e===`為必填`?{reason:`REQUIRED`}:t?{limit:Number(t[1]),reason:`MIN_ROWS`}:n?{limit:Number(n[1]),reason:`MAX_ROWS`}:r?{limit:Number(r[1]),reason:`MIN_LENGTH`}:i?{limit:Number(i[1]),reason:`MAX_LENGTH`}:e===`格式不正確`?{reason:`PATTERN`}:e===`無法在時限內完成格式檢查`?{reason:`PATTERN_TIMEOUT`}:{reason:`TYPE`}}function _(e,t){let r=t.find(t=>e===t.fieldKey||(0,n.isTableFieldDefinition)(t)&&e.startsWith(`${t.fieldKey}[`));if(!r)return null;if(e===r.fieldKey)return{key:e,settings:r,topLevel:!0};if(!(0,n.isTableFieldDefinition)(r))return null;let i=/^\[(\d+)\](?:\.(.+))?$/u.exec(e.slice(r.fieldKey.length));if(!i)return null;let a=`${r.fieldKey}[${i[1]}]`,o=i[2];if(o===void 0)return{key:a,settings:void 0,topLevel:!1};let s=r.columns.find(e=>e.fieldKey===o);return s?{key:`${a}.${s.fieldKey}`,settings:s,topLevel:!1}:null}function v(e,t){let n=e.map(e=>{let n=_(e.path,t);return n===null?null:[n.key,h(e.reason,e.limit,n)]});return n.length===0||n.some(e=>e===null)?null:Object.fromEntries(n.filter(e=>e!==null))}function y(e,t){let r=f.exec(e);if(r){let e=t.find(e=>(e.label||e.fieldKey)===r[1]);return e?{reason:r[2],target:{key:e.fieldKey,settings:e,topLevel:!0}}:null}let i=p.exec(e);if(!i)return null;let a=t.find(e=>(0,n.isTableFieldDefinition)(e)&&(e.label||e.fieldKey)===i[1]);if(!a||!(0,n.isTableFieldDefinition)(a))return null;let o=`${a.fieldKey}[${Number(i[2])-1}]`,s=i[3];if(s===void 0)return{reason:i[4],target:{key:o,settings:void 0,topLevel:!1}};let c=a.columns.find(e=>(e.label||e.fieldKey)===s);return c?{reason:i[4],target:{key:`${o}.${c.fieldKey}`,settings:c,topLevel:!1}}:null}function b(t,n,r,i=[]){let a=n.fields.filter(t=>(0,e.readNodeFillableFieldKeys)(r).has(t.fieldKey));if(i.length>0)return v(i,a);if(t.startsWith(m)){let e=`, ${t.slice(7)}, `,n=a.filter(t=>e.includes(`, ${t.label||t.fieldKey}, `));return n.length>0?Object.fromEntries(n.map(e=>[e.fieldKey,`${e.label||e.fieldKey}為必填欄位。`])):null}let o=t.split(`;`).map(e=>y(e,a));return o.length===0||o.some(e=>e===null)?null:Object.fromEntries(o.flatMap(e=>{if(e===null)return[];let{limit:t,reason:n}=g(e.reason);return[[e.target.key,h(n,t,e.target)]]}))}var x=`未知組織`;function S(e,t){return[...new Set(e.fields.filter(n.isOrgUnitFieldDefinition).map(e=>t[e.fieldKey]).filter(e=>typeof e==`string`&&e.trim().length>0))]}function C(r,i,a,o){if((0,n.isTableFieldDefinition)(r)){let e=(0,t.readFormTableRows)(i),n=r.columns.filter(e=>e.type===`number`||e.type===`money`).map(t=>({label:t.label||t.fieldKey,total:e.reduce((e,n)=>typeof n[t.fieldKey]==`number`&&Number.isFinite(n[t.fieldKey])?e+n[t.fieldKey]:e,0)}));return[`${e.length} 列`,...e.length>0?n.map(({label:e,total:t})=>`${e}合計 ${t.toLocaleString(`zh-TW`)}`):[]].join(`,`)}if((0,e.isFormDataValueEmpty)(i))return`未填寫`;if(typeof i==`boolean`)return i?`是`:`否`;if((0,n.isOrgUnitFieldDefinition)(r))return typeof i==`string`?o.get(i)??`未知組織`:x;let s=Array.isArray(i)?i:[i],c=(0,n.isFormStaticOptionFieldDefinition)(r)?new Map(r.options.map(e=>[e.value,e.label])):r.type===`member`?a:new Map;return s.map(e=>typeof e==`string`?c.get(e)??e:String(e)).join(`、`)}function w(t,n,r,i=new Map,a=new Map){let o=(0,e.readNodeFillableFieldKeys)(n);return t.fields.filter(e=>o.has(e.fieldKey)&&Object.prototype.hasOwnProperty.call(r,e.fieldKey)).map(e=>({fieldKey:e.fieldKey,label:e.label||e.fieldKey,text:C(e,r[e.fieldKey],i,a)}))}var T=`表單中有附件無法附加到這個案件(只能附加申請人為本案上傳的檔案),請移除後重新上傳再送出。`;function E(e){let r=(0,t.readFormDataSourceErrorMessage)(e);if(r)return r;let i=e instanceof Error?e.message:null;return i?.includes(n.ATTACHMENT_NOT_BINDABLE_ERROR_CODE)?T:i??`發生未知錯誤`}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return b}});
|
|
2
|
-
//# sourceMappingURL=instance-error-message-BW464LRQ.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"instance-error-message-BW464LRQ.cjs","names":["readApproverFilledFieldKeys","omitFormDataKeys","readNodeFillableFieldKeys","readNodeRequiredFieldKeys","isTableFieldDefinition","isOrgUnitFieldDefinition","readFormTableRows","isFormDataValueEmpty","isFormStaticOptionFieldDefinition","readFormDataSourceErrorMessage","ATTACHMENT_NOT_BINDABLE_ERROR_CODE","_rytass_bpm_core_shared","_rytass_bpm_core_client_form","_rytass_bpm_core_shared_form","readApplicantFormSchema","approverFilledKeys","definition","schema","field","readApplicantSubmission","values","readFillValidationSchema","fillableKeys","node","displaySchema","readFillDisplaySchema","requiredKeys","userTaskNodes","readFillLabelMarkers","viewerKeys","viewerFillNode","fieldKey","markers","readFillPayload","readFillChanges","seededTables","seeded","stored","draft","isFillConflictMessage","message","TOP_LEVEL_REF_PATTERN","TABLE_REF_PATTERN","MISSING_FIELDS_PREFIX","readFillIssueText","name","target","reason","limit","readFillReasonFromSentence","atLeastRows","sentence","atMostRows","shortest","longest","readFillIssueTarget","fields","path","candidate","rowPath","rowKey","columnKey","column","readFillErrorsFromIssues","entries","issues","issue","entry","readFillErrorTarget","topLevel","part","tableRef","table","columnLabel","readFillServerErrors","fillableFields","formDataIssues","listed","missing","parts","UNKNOWN_FILL_ORG_UNIT_TEXT","readFillOrgUnitIds","value","readFillValueText","rows","totals","row","sum","label","total","orgUnitNames","items","optionLabels","option","memberNames","item","readFillSummary","ATTACHMENT_NOT_BINDABLE_MESSAGE","readErrorMessage","dataSourceMessage","error"],"sources":["../../src/views/instances/approver-filled-form.ts","../../src/views/instances/instance-error-message.ts"],"sourcesContent":["import {\n isFormDataValueEmpty,\n omitFormDataKeys,\n readApproverFilledFieldKeys,\n readNodeFillableFieldKeys,\n readNodeRequiredFieldKeys,\n type UserTaskNode,\n type WorkflowDefinition,\n} from '@rytass/bpm-core-shared';\nimport {\n isFormStaticOptionFieldDefinition,\n isOrgUnitFieldDefinition,\n isTableFieldDefinition,\n type FormDefinitionSchema,\n type FormFieldDefinition,\n type FormFieldValue,\n type FormDataIssue,\n type FormDataIssueReason,\n type TableColumnDefinition,\n} from '@rytass/bpm-core-shared/form';\nimport { readFormTableRows } from '@rytass/bpm-core-client/form';\nimport type { WorkflowFormData } from '@rytass/bpm-core-client/workflow';\n\n/**\n * The form as the applicant sees it: without the fields some approver fills in.\n * The server drops those keys from a submission, so rendering one would swallow\n * what the applicant types, and a `minRows` or `required` on it would block a\n * launch nobody can complete. Returns an equal schema when nothing is\n * approver-filled; never mutates its input.\n */\nexport function readApplicantFormSchema(\n schema: FormDefinitionSchema,\n definition: WorkflowDefinition,\n): FormDefinitionSchema {\n const approverFilledKeys = readApproverFilledFieldKeys(definition);\n\n return {\n ...schema,\n fields: schema.fields.filter(\n (field) => !approverFilledKeys.has(field.fieldKey),\n ),\n };\n}\n\n/** The payload the applicant may send: `values` without approver-filled keys. */\nexport function readApplicantSubmission(\n values: WorkflowFormData,\n definition: WorkflowDefinition,\n): WorkflowFormData {\n // Dropping keys cannot change a remaining value's type, which is all the\n // shared helper's `unknown` return forgets.\n return omitFormDataKeys(\n values,\n readApproverFilledFieldKeys(definition),\n ) as WorkflowFormData;\n}\n\n/**\n * The form an approver's fill is validated against: only the fields `node`\n * lets them fill in, each required exactly when the node says `REQUIRED`. A\n * required table needs at least one row, the rule `validateFormRendererValues`\n * already applies, so the result agrees with the server's fill check. Never\n * mutates its input.\n */\nexport function readFillValidationSchema(\n schema: FormDefinitionSchema,\n node: UserTaskNode,\n): FormDefinitionSchema {\n const fillableKeys = readNodeFillableFieldKeys(node);\n const displaySchema = readFillDisplaySchema(schema, node);\n\n // Derived from the display schema so the check and the asterisk read the\n // same rule.\n return {\n ...displaySchema,\n fields: displaySchema.fields.filter((field) =>\n fillableKeys.has(field.fieldKey),\n ),\n };\n}\n\n/**\n * The schema the fill node's approver sees: every field as the form defines\n * it, except that the node's fillable fields are required exactly when the\n * node says `REQUIRED`, so the asterisk matches what approving will check.\n */\nexport function readFillDisplaySchema(\n schema: FormDefinitionSchema,\n node: UserTaskNode,\n): FormDefinitionSchema {\n const fillableKeys = readNodeFillableFieldKeys(node);\n const requiredKeys = readNodeRequiredFieldKeys(node);\n\n return {\n ...schema,\n fields: schema.fields.map((field) =>\n fillableKeys.has(field.fieldKey)\n ? {\n ...field,\n required: requiredKeys.has(field.fieldKey),\n // The node alone decides; the server ignores the form's rule.\n requiredWhen: undefined,\n }\n : field,\n ),\n };\n}\n\nconst userTaskNodes = (definition: WorkflowDefinition): readonly UserTaskNode[] =>\n definition.nodes.filter(\n (node): node is UserTaskNode => node.type === 'userTask',\n );\n\n/**\n * The marker shown after each approver-filled field's label: 「本關補填」 on\n * the fields `viewerFillNode` lets the viewer fill, 「<node>補填」 on every\n * other approver-filled field (the first node in the definition that fills\n * it names it).\n */\nexport function readFillLabelMarkers(\n definition: WorkflowDefinition,\n viewerFillNode: UserTaskNode | null,\n): Readonly<Record<string, string>> {\n const viewerKeys =\n viewerFillNode === null\n ? new Set<string>()\n : readNodeFillableFieldKeys(viewerFillNode);\n\n return userTaskNodes(definition).reduce<Readonly<Record<string, string>>>(\n (markers, node) => ({\n ...Object.fromEntries(\n [...readNodeFillableFieldKeys(node)].map((fieldKey) => [\n fieldKey,\n viewerKeys.has(fieldKey)\n ? '本關補填'\n : `${node.data.label || node.id}補填`,\n ]),\n ),\n ...markers,\n }),\n {},\n );\n}\n\n/**\n * What approving sends as `fill.formData`: the keys of `values` that `node`\n * lets its approver fill, and nothing else (the server refuses any other key).\n * `values` is what the approver changed, not the rendered form — a renderer\n * default the approver never touched (a table's empty rows, a boolean's\n * `false`) is not theirs to sign, and would otherwise show up as filled in.\n */\nexport function readFillPayload(\n values: WorkflowFormData,\n node: UserTaskNode,\n): Readonly<Record<string, unknown>> {\n return Object.fromEntries(\n [...readNodeFillableFieldKeys(node)]\n .filter((fieldKey) =>\n Object.prototype.hasOwnProperty.call(values, fieldKey),\n )\n // A cleared field reads `undefined`, which JSON drops, and the server\n // would keep the old value; `null` clears it.\n .map((fieldKey) => [fieldKey, values[fieldKey] ?? null]),\n );\n}\n\n/**\n * What the approver's fill amounts to: the fields they changed (`draft`), plus\n * each fill table the page seeds with `minRows` rows that the case does not\n * store yet. The page shows those rows and validates them, so they are sent\n * too — left out, the server would refuse the approval for missing rows the\n * approver can see on screen.\n */\nexport function readFillChanges({\n draft,\n node,\n schema,\n stored,\n values,\n}: {\n readonly draft: WorkflowFormData;\n readonly node: UserTaskNode;\n readonly schema: FormDefinitionSchema;\n readonly stored: WorkflowFormData;\n readonly values: WorkflowFormData;\n}): WorkflowFormData {\n const fillableKeys = readNodeFillableFieldKeys(node);\n const seededTables = schema.fields.filter((field) => {\n const seeded = values[field.fieldKey];\n\n return (\n isTableFieldDefinition(field) &&\n fillableKeys.has(field.fieldKey) &&\n !Object.prototype.hasOwnProperty.call(stored, field.fieldKey) &&\n Array.isArray(seeded) &&\n seeded.length > 0\n );\n });\n\n return {\n ...Object.fromEntries(\n seededTables.map((field) => [field.fieldKey, values[field.fieldKey]]),\n ),\n ...draft,\n };\n}\n\n/** The server message of a fill against form data someone else changed. */\nexport function isFillConflictMessage(message: string): boolean {\n return message.includes('form data changed; refresh and retry');\n}\n\n// The server names a field by its label: `欄位「標籤」`, a table row as\n// `「表格」第 N 列` (1-based), and a cell as `「表格」第 N 列的「欄位」`.\n// Each part of a message is separated by `;`. This is the fallback for a\n// response that carries no `formDataIssues`: labels are not unique, so the\n// issues, which address each value by its path, are the primary route.\nconst TOP_LEVEL_REF_PATTERN = /^欄位「(.+?)」(.+)$/;\nconst TABLE_REF_PATTERN = /^「(.+?)」第 (\\d+) 列(?:的「(.+?)」)?(.+)$/;\nconst MISSING_FIELDS_PREFIX = '缺少必填欄位:';\n\n/** The field, or table column, a server error names, with its renderer key. */\ninterface FillErrorTarget {\n readonly key: string;\n readonly settings: FormFieldDefinition | TableColumnDefinition | undefined;\n readonly topLevel: boolean;\n}\n\n/** The sentence a refused value shows, by its reason. */\nfunction readFillIssueText(\n reason: FormDataIssueReason,\n limit: number | undefined,\n target: FillErrorTarget,\n): string {\n const name = target.settings?.label || target.settings?.fieldKey || '';\n\n switch (reason) {\n case 'REQUIRED':\n return target.topLevel && name !== ''\n ? `${name}為必填欄位。`\n : '此欄為必填。';\n case 'MIN_LENGTH':\n return `至少需要 ${limit ?? 0} 個字。`;\n case 'MAX_LENGTH':\n return `最多 ${limit ?? 0} 個字。`;\n case 'MIN_ROWS':\n return `至少需要 ${limit ?? 0} 列。`;\n case 'MAX_ROWS':\n return `最多 ${limit ?? 0} 列。`;\n case 'PATTERN': {\n const message =\n target.settings &&\n (target.settings.type === 'text' || target.settings.type === 'textarea')\n ? target.settings.patternErrorMessage?.trim()\n : undefined;\n\n return message || '格式不正確。';\n }\n // The server ran out of time on the format check; the value may be fine.\n case 'PATTERN_TIMEOUT':\n return '格式檢查逾時,請縮短內容後再試,或請表單設計者簡化格式。';\n default:\n return '此欄內容不正確。';\n }\n}\n\n/** The reason a message sentence stands for, for the message fallback. */\nfunction readFillReasonFromSentence(sentence: string): {\n readonly limit?: number;\n readonly reason: FormDataIssueReason;\n} {\n const atLeastRows = /^至少需要 (\\d+) 列$/.exec(sentence);\n const atMostRows = /^最多 (\\d+) 列$/.exec(sentence);\n const shortest = /^至少需要 (\\d+) 個字$/.exec(sentence);\n const longest = /^最多 (\\d+) 個字$/.exec(sentence);\n\n if (sentence === '為必填') {\n return { reason: 'REQUIRED' };\n }\n\n if (atLeastRows) {\n return { limit: Number(atLeastRows[1]), reason: 'MIN_ROWS' };\n }\n\n if (atMostRows) {\n return { limit: Number(atMostRows[1]), reason: 'MAX_ROWS' };\n }\n\n if (shortest) {\n return { limit: Number(shortest[1]), reason: 'MIN_LENGTH' };\n }\n\n if (longest) {\n return { limit: Number(longest[1]), reason: 'MAX_LENGTH' };\n }\n\n if (sentence === '格式不正確') {\n return { reason: 'PATTERN' };\n }\n\n if (sentence === '無法在時限內完成格式檢查') {\n return { reason: 'PATTERN_TIMEOUT' };\n }\n\n return { reason: 'TYPE' };\n}\n\n/**\n * The renderer key of the value an issue path addresses, among the fields\n * `fields` lets the approver fill. `items` is a table, `items[1]` a row,\n * `items[1].qty` a cell. `null` when the path names nothing fillable.\n */\nfunction readFillIssueTarget(\n path: string,\n fields: readonly FormFieldDefinition[],\n): FillErrorTarget | null {\n const field = fields.find(\n (candidate) =>\n path === candidate.fieldKey ||\n (isTableFieldDefinition(candidate) &&\n path.startsWith(`${candidate.fieldKey}[`)),\n );\n\n if (!field) {\n return null;\n }\n\n if (path === field.fieldKey) {\n return { key: path, settings: field, topLevel: true };\n }\n\n if (!isTableFieldDefinition(field)) {\n return null;\n }\n\n const rowPath = /^\\[(\\d+)\\](?:\\.(.+))?$/u.exec(\n path.slice(field.fieldKey.length),\n );\n\n if (!rowPath) {\n return null;\n }\n\n const rowKey = `${field.fieldKey}[${rowPath[1]}]`;\n const columnKey = rowPath[2];\n\n if (columnKey === undefined) {\n return { key: rowKey, settings: undefined, topLevel: false };\n }\n\n const column = field.columns.find(\n (candidate) => candidate.fieldKey === columnKey,\n );\n\n return column\n ? { key: `${rowKey}.${column.fieldKey}`, settings: column, topLevel: false }\n : null;\n}\n\nfunction readFillErrorsFromIssues(\n issues: readonly FormDataIssue[],\n fields: readonly FormFieldDefinition[],\n): Readonly<Record<string, string>> | null {\n const entries = issues.map((issue): readonly [string, string] | null => {\n const target = readFillIssueTarget(issue.path, fields);\n\n return target === null\n ? null\n : [target.key, readFillIssueText(issue.reason, issue.limit, target)];\n });\n\n if (entries.length === 0 || entries.some((entry) => entry === null)) {\n return null;\n }\n\n return Object.fromEntries(\n entries.filter(\n (entry): entry is readonly [string, string] => entry !== null,\n ),\n );\n}\n\nfunction readFillErrorTarget(\n part: string,\n fields: readonly FormFieldDefinition[],\n): { readonly target: FillErrorTarget; readonly reason: string } | null {\n const topLevel = TOP_LEVEL_REF_PATTERN.exec(part);\n\n if (topLevel) {\n const field = fields.find(\n (candidate) => (candidate.label || candidate.fieldKey) === topLevel[1],\n );\n\n return field\n ? {\n reason: topLevel[2],\n target: { key: field.fieldKey, settings: field, topLevel: true },\n }\n : null;\n }\n\n const tableRef = TABLE_REF_PATTERN.exec(part);\n\n if (!tableRef) {\n return null;\n }\n\n const table = fields.find(\n (candidate) =>\n isTableFieldDefinition(candidate) &&\n (candidate.label || candidate.fieldKey) === tableRef[1],\n );\n\n if (!table || !isTableFieldDefinition(table)) {\n return null;\n }\n\n const rowKey = `${table.fieldKey}[${Number(tableRef[2]) - 1}]`;\n const columnLabel = tableRef[3];\n\n if (columnLabel === undefined) {\n return {\n reason: tableRef[4],\n target: { key: rowKey, settings: undefined, topLevel: false },\n };\n }\n\n const column = table.columns.find(\n (candidate) => (candidate.label || candidate.fieldKey) === columnLabel,\n );\n\n return column\n ? {\n reason: tableRef[4],\n target: {\n key: `${rowKey}.${column.fieldKey}`,\n settings: column,\n topLevel: false,\n },\n }\n : null;\n}\n\n/**\n * Turns the server's fill validation refusal (docs/08 §8.5, error table 2)\n * into field errors keyed the way `FormRenderer` addresses them, so a check\n * the page missed still lands on the field. `formDataIssues` is the refusal's\n * structured list and wins when it is present: each issue names its value by\n * path, so two fields sharing a label stay apart. Without it, the Chinese\n * `message` is parsed. `null` when any part does not resolve to a fillable\n * field — the caller then shows the message as it is.\n */\nexport function readFillServerErrors(\n message: string,\n schema: FormDefinitionSchema,\n node: UserTaskNode,\n formDataIssues: readonly FormDataIssue[] = [],\n): Readonly<Record<string, string>> | null {\n const fillableFields = schema.fields.filter((field) =>\n readNodeFillableFieldKeys(node).has(field.fieldKey),\n );\n\n if (formDataIssues.length > 0) {\n return readFillErrorsFromIssues(formDataIssues, fillableFields);\n }\n\n if (message.startsWith(MISSING_FIELDS_PREFIX)) {\n // Labels may hold commas, so match each fillable field's label (or key)\n // against the list rather than splitting it.\n const listed = `, ${message.slice(MISSING_FIELDS_PREFIX.length)}, `;\n const missing = fillableFields.filter((field) =>\n listed.includes(`, ${field.label || field.fieldKey}, `),\n );\n\n return missing.length > 0\n ? Object.fromEntries(\n missing.map((field) => [\n field.fieldKey,\n `${field.label || field.fieldKey}為必填欄位。`,\n ]),\n )\n : null;\n }\n\n const parts = message\n .split(';')\n .map((part) => readFillErrorTarget(part, fillableFields));\n\n if (parts.length === 0 || parts.some((part) => part === null)) {\n return null;\n }\n\n return Object.fromEntries(\n parts.flatMap((part) => {\n if (part === null) {\n return [];\n }\n\n const { limit, reason } = readFillReasonFromSentence(part.reason);\n\n return [[part.target.key, readFillIssueText(reason, limit, part.target)]];\n }),\n );\n}\n\nexport interface FillSummaryItem {\n readonly fieldKey: string;\n readonly label: string;\n readonly text: string;\n}\n\nexport const UNKNOWN_FILL_ORG_UNIT_TEXT = '未知組織';\n\n/**\n * The org unit ids among `values`, once each and in form order, so the caller\n * can look up their names before building the summary.\n */\nexport function readFillOrgUnitIds(\n schema: FormDefinitionSchema,\n values: WorkflowFormData,\n): readonly string[] {\n return [\n ...new Set(\n schema.fields\n .filter(isOrgUnitFieldDefinition)\n .map((field) => values[field.fieldKey])\n .filter(\n (value): value is string =>\n typeof value === 'string' && value.trim().length > 0,\n ),\n ),\n ];\n}\n\nfunction readFillValueText(\n field: FormFieldDefinition,\n value: FormFieldValue | undefined,\n memberNames: ReadonlyMap<string, string>,\n orgUnitNames: ReadonlyMap<string, string>,\n): string {\n if (isTableFieldDefinition(field)) {\n const rows = readFormTableRows(value);\n const totals = field.columns\n .filter((column) => column.type === 'number' || column.type === 'money')\n .map((column) => ({\n label: column.label || column.fieldKey,\n total: rows.reduce(\n (sum, row) =>\n typeof row[column.fieldKey] === 'number' &&\n Number.isFinite(row[column.fieldKey])\n ? sum + (row[column.fieldKey] as number)\n : sum,\n 0,\n ),\n }));\n\n return [\n `${rows.length} 列`,\n ...(rows.length > 0\n ? totals.map(\n ({ label, total }) => `${label}合計 ${total.toLocaleString('zh-TW')}`,\n )\n : []),\n ].join(',');\n }\n\n if (isFormDataValueEmpty(value)) {\n return '未填寫';\n }\n\n if (typeof value === 'boolean') {\n return value ? '是' : '否';\n }\n\n if (isOrgUnitFieldDefinition(field)) {\n // `orgUnitNames` (`useOrgUnitNames`) maps an id still being looked up to\n // a loading text; an id the lookup did not name is 「未知組織」. Never the\n // raw id.\n return typeof value === 'string'\n ? (orgUnitNames.get(value) ?? UNKNOWN_FILL_ORG_UNIT_TEXT)\n : UNKNOWN_FILL_ORG_UNIT_TEXT;\n }\n\n const items = Array.isArray(value) ? value : [value];\n const optionLabels = isFormStaticOptionFieldDefinition(field)\n ? new Map(field.options.map((option) => [option.value, option.label]))\n : field.type === 'member'\n ? memberNames\n : new Map<string, string>();\n\n return items\n .map((item) =>\n typeof item === 'string' ? (optionLabels.get(item) ?? item) : String(item),\n )\n .join('、');\n}\n\n/**\n * One line per field `node` lets its approver fill, in form order, for the\n * approve dialog: what will be sent along with the approval. A member field\n * names each member found in `memberNames` and shows the id otherwise; an org\n * unit field names its unit from `orgUnitNames` and shows 「未知組織」 otherwise.\n */\nexport function readFillSummary(\n schema: FormDefinitionSchema,\n node: UserTaskNode,\n values: WorkflowFormData,\n memberNames: ReadonlyMap<string, string> = new Map(),\n orgUnitNames: ReadonlyMap<string, string> = new Map(),\n): readonly FillSummaryItem[] {\n const fillableKeys = readNodeFillableFieldKeys(node);\n\n return schema.fields\n .filter(\n (field) =>\n fillableKeys.has(field.fieldKey) &&\n Object.prototype.hasOwnProperty.call(values, field.fieldKey),\n )\n .map((field) => ({\n fieldKey: field.fieldKey,\n label: field.label || field.fieldKey,\n text: readFillValueText(\n field,\n values[field.fieldKey],\n memberNames,\n orgUnitNames,\n ),\n }));\n}\n","import { readFormDataSourceErrorMessage } from '@rytass/bpm-core-client/form';\nimport { ATTACHMENT_NOT_BINDABLE_ERROR_CODE } from '@rytass/bpm-core-shared/form';\n\nconst ATTACHMENT_NOT_BINDABLE_MESSAGE =\n '表單中有附件無法附加到這個案件(只能附加申請人為本案上傳的檔案),請移除後重新上傳再送出。';\n\n/**\n * The message a case page shows for a failed request: a stable server code\n * translated into words, otherwise the server's own message.\n */\nexport function readErrorMessage(error: unknown): string {\n // DataSource failures arrive as stable codes so the backend never leaks\n // upstream transport detail; translate them instead of showing the raw code.\n const dataSourceMessage = readFormDataSourceErrorMessage(error);\n\n if (dataSourceMessage) {\n return dataSourceMessage;\n }\n\n const message = error instanceof Error ? error.message : null;\n\n // Names the problem, not the attachment ids the server lists.\n if (message?.includes(ATTACHMENT_NOT_BINDABLE_ERROR_CODE)) {\n return ATTACHMENT_NOT_BINDABLE_MESSAGE;\n }\n\n return message ?? '發生未知錯誤';\n}\n"],"mappings":"A,6HA8BA,SAAgBc,EACd,EACA,EACsB,CACtB,IAAMC,GAAA,EAAqBf,EAAAA,4BAAAA,CAA4BgB,CAAU,EAEjE,MAAO,CACL,GAAGC,EACH,OAAQA,EAAO,OAAO,OACnB,GAAU,CAACF,EAAmB,IAAIG,EAAM,QAAQ,CACnD,CACF,CACF,CAGA,SAAgBC,EACd,EACA,EACkB,CAGlB,OAAA,EAAOlB,EAAAA,iBAAAA,CACLmB,GAAA,EACApB,EAAAA,4BAAAA,CAA4BgB,CAAU,CACxC,CACF,CASA,SAAgBK,EACd,EACA,EACsB,CACtB,IAAMC,GAAA,EAAepB,EAAAA,0BAAAA,CAA0BqB,CAAI,EAC7CC,EAAgBC,EAAsBR,EAAQM,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,QAAQ,IAAK,GAAW,CAAC2E,EAAO,MAAOA,EAAO,KAAK,CAAC,CAAC,EACnE3E,EAAM,OAAS,SACb4E,EACA,IAAI,IAEV,OAAOH,EACJ,IAAK,GACJ,OAAOI,GAAS,SAAYH,EAAa,IAAIG,CAAI,GAAKA,EAAQ,OAAOA,CAAI,CAC3E,CAAC,CACA,KAAK,GAAG,CACb,CAQA,SAAgBC,EACd,EACA,EACA,EACA,EAA2C,IAAI,IAC/C,EAA4C,IAAI,IACpB,CAC5B,IAAM1E,GAAA,EAAepB,EAAAA,0BAAAA,CAA0BqB,CAAI,EAEnD,OAAON,EAAO,OACX,OACE,GACCK,EAAa,IAAIJ,EAAM,QAAQ,GAC/B,OAAO,UAAU,eAAe,KAAKE,EAAQF,EAAM,QAAQ,CAC/D,CAAC,CACA,IAAK,IAAW,CACf,SAAUA,EAAM,SAChB,MAAOA,EAAM,OAASA,EAAM,SAC5B,KAAMiE,EACJjE,EACAE,EAAOF,EAAM,UACb4E,EACAJ,CACF,CACF,EAAE,CACN,CCjnBA,IAAMO,EACJ,gDAMF,SAAgBC,EAAiB,EAAwB,CAGvD,IAAMC,GAAA,EAAoB1F,EAAAA,+BAAAA,CAA+B2F,CAAK,EAE9D,GAAID,EACF,OAAOA,EAGT,IAAM3D,EAAU4D,aAAiB,MAAQA,EAAM,QAAU,KAOzD,OAJI5D,GAAS,SAAS9B,EAAAA,kCAAkC,EAC/CuF,EAGFzD,GAAW,QACpB,C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"instance-error-message-CAP1vJhX.js","names":["readApplicantFormSchema","approverFilledKeys","readApproverFilledFieldKeys","definition","schema","field","readApplicantSubmission","omitFormDataKeys","values","readFillValidationSchema","fillableKeys","readNodeFillableFieldKeys","node","displaySchema","readFillDisplaySchema","requiredKeys","readNodeRequiredFieldKeys","userTaskNodes","readFillLabelMarkers","viewerKeys","viewerFillNode","fieldKey","markers","readFillPayload","readFillChanges","seededTables","seeded","isTableFieldDefinition","stored","draft","isFillConflictMessage","message","TOP_LEVEL_REF_PATTERN","TABLE_REF_PATTERN","MISSING_FIELDS_PREFIX","readFillIssueText","name","target","reason","limit","readFillReasonFromSentence","atLeastRows","sentence","atMostRows","shortest","longest","readFillIssueTarget","fields","path","candidate","rowPath","rowKey","columnKey","column","readFillErrorsFromIssues","entries","issues","issue","entry","readFillErrorTarget","topLevel","part","tableRef","table","columnLabel","readFillServerErrors","fillableFields","formDataIssues","listed","missing","parts","UNKNOWN_FILL_ORG_UNIT_TEXT","readFillOrgUnitIds","isOrgUnitFieldDefinition","value","readFillValueText","rows","readFormTableRows","totals","row","sum","label","total","isFormDataValueEmpty","orgUnitNames","items","optionLabels","isFormStaticOptionFieldDefinition","option","memberNames","item","readFillSummary","ATTACHMENT_NOT_BINDABLE_MESSAGE","readErrorMessage","dataSourceMessage","readFormDataSourceErrorMessage","error","ATTACHMENT_NOT_BINDABLE_ERROR_CODE"],"sources":["../../src/views/instances/approver-filled-form.ts","../../src/views/instances/instance-error-message.ts"],"sourcesContent":["import {\n isFormDataValueEmpty,\n omitFormDataKeys,\n readApproverFilledFieldKeys,\n readNodeFillableFieldKeys,\n readNodeRequiredFieldKeys,\n type UserTaskNode,\n type WorkflowDefinition,\n} from '@rytass/bpm-core-shared';\nimport {\n isFormStaticOptionFieldDefinition,\n isOrgUnitFieldDefinition,\n isTableFieldDefinition,\n type FormDefinitionSchema,\n type FormFieldDefinition,\n type FormFieldValue,\n type FormDataIssue,\n type FormDataIssueReason,\n type TableColumnDefinition,\n} from '@rytass/bpm-core-shared/form';\nimport { readFormTableRows } from '@rytass/bpm-core-client/form';\nimport type { WorkflowFormData } from '@rytass/bpm-core-client/workflow';\n\n/**\n * The form as the applicant sees it: without the fields some approver fills in.\n * The server drops those keys from a submission, so rendering one would swallow\n * what the applicant types, and a `minRows` or `required` on it would block a\n * launch nobody can complete. Returns an equal schema when nothing is\n * approver-filled; never mutates its input.\n */\nexport function readApplicantFormSchema(\n schema: FormDefinitionSchema,\n definition: WorkflowDefinition,\n): FormDefinitionSchema {\n const approverFilledKeys = readApproverFilledFieldKeys(definition);\n\n return {\n ...schema,\n fields: schema.fields.filter(\n (field) => !approverFilledKeys.has(field.fieldKey),\n ),\n };\n}\n\n/** The payload the applicant may send: `values` without approver-filled keys. */\nexport function readApplicantSubmission(\n values: WorkflowFormData,\n definition: WorkflowDefinition,\n): WorkflowFormData {\n // Dropping keys cannot change a remaining value's type, which is all the\n // shared helper's `unknown` return forgets.\n return omitFormDataKeys(\n values,\n readApproverFilledFieldKeys(definition),\n ) as WorkflowFormData;\n}\n\n/**\n * The form an approver's fill is validated against: only the fields `node`\n * lets them fill in, each required exactly when the node says `REQUIRED`. A\n * required table needs at least one row, the rule `validateFormRendererValues`\n * already applies, so the result agrees with the server's fill check. Never\n * mutates its input.\n */\nexport function readFillValidationSchema(\n schema: FormDefinitionSchema,\n node: UserTaskNode,\n): FormDefinitionSchema {\n const fillableKeys = readNodeFillableFieldKeys(node);\n const displaySchema = readFillDisplaySchema(schema, node);\n\n // Derived from the display schema so the check and the asterisk read the\n // same rule.\n return {\n ...displaySchema,\n fields: displaySchema.fields.filter((field) =>\n fillableKeys.has(field.fieldKey),\n ),\n };\n}\n\n/**\n * The schema the fill node's approver sees: every field as the form defines\n * it, except that the node's fillable fields are required exactly when the\n * node says `REQUIRED`, so the asterisk matches what approving will check.\n */\nexport function readFillDisplaySchema(\n schema: FormDefinitionSchema,\n node: UserTaskNode,\n): FormDefinitionSchema {\n const fillableKeys = readNodeFillableFieldKeys(node);\n const requiredKeys = readNodeRequiredFieldKeys(node);\n\n return {\n ...schema,\n fields: schema.fields.map((field) =>\n fillableKeys.has(field.fieldKey)\n ? {\n ...field,\n required: requiredKeys.has(field.fieldKey),\n // The node alone decides; the server ignores the form's rule.\n requiredWhen: undefined,\n }\n : field,\n ),\n };\n}\n\nconst userTaskNodes = (definition: WorkflowDefinition): readonly UserTaskNode[] =>\n definition.nodes.filter(\n (node): node is UserTaskNode => node.type === 'userTask',\n );\n\n/**\n * The marker shown after each approver-filled field's label: 「本關補填」 on\n * the fields `viewerFillNode` lets the viewer fill, 「<node>補填」 on every\n * other approver-filled field (the first node in the definition that fills\n * it names it).\n */\nexport function readFillLabelMarkers(\n definition: WorkflowDefinition,\n viewerFillNode: UserTaskNode | null,\n): Readonly<Record<string, string>> {\n const viewerKeys =\n viewerFillNode === null\n ? new Set<string>()\n : readNodeFillableFieldKeys(viewerFillNode);\n\n return userTaskNodes(definition).reduce<Readonly<Record<string, string>>>(\n (markers, node) => ({\n ...Object.fromEntries(\n [...readNodeFillableFieldKeys(node)].map((fieldKey) => [\n fieldKey,\n viewerKeys.has(fieldKey)\n ? '本關補填'\n : `${node.data.label || node.id}補填`,\n ]),\n ),\n ...markers,\n }),\n {},\n );\n}\n\n/**\n * What approving sends as `fill.formData`: the keys of `values` that `node`\n * lets its approver fill, and nothing else (the server refuses any other key).\n * `values` is what the approver changed, not the rendered form — a renderer\n * default the approver never touched (a table's empty rows, a boolean's\n * `false`) is not theirs to sign, and would otherwise show up as filled in.\n */\nexport function readFillPayload(\n values: WorkflowFormData,\n node: UserTaskNode,\n): Readonly<Record<string, unknown>> {\n return Object.fromEntries(\n [...readNodeFillableFieldKeys(node)]\n .filter((fieldKey) =>\n Object.prototype.hasOwnProperty.call(values, fieldKey),\n )\n // A cleared field reads `undefined`, which JSON drops, and the server\n // would keep the old value; `null` clears it.\n .map((fieldKey) => [fieldKey, values[fieldKey] ?? null]),\n );\n}\n\n/**\n * What the approver's fill amounts to: the fields they changed (`draft`), plus\n * each fill table the page seeds with `minRows` rows that the case does not\n * store yet. The page shows those rows and validates them, so they are sent\n * too — left out, the server would refuse the approval for missing rows the\n * approver can see on screen.\n */\nexport function readFillChanges({\n draft,\n node,\n schema,\n stored,\n values,\n}: {\n readonly draft: WorkflowFormData;\n readonly node: UserTaskNode;\n readonly schema: FormDefinitionSchema;\n readonly stored: WorkflowFormData;\n readonly values: WorkflowFormData;\n}): WorkflowFormData {\n const fillableKeys = readNodeFillableFieldKeys(node);\n const seededTables = schema.fields.filter((field) => {\n const seeded = values[field.fieldKey];\n\n return (\n isTableFieldDefinition(field) &&\n fillableKeys.has(field.fieldKey) &&\n !Object.prototype.hasOwnProperty.call(stored, field.fieldKey) &&\n Array.isArray(seeded) &&\n seeded.length > 0\n );\n });\n\n return {\n ...Object.fromEntries(\n seededTables.map((field) => [field.fieldKey, values[field.fieldKey]]),\n ),\n ...draft,\n };\n}\n\n/** The server message of a fill against form data someone else changed. */\nexport function isFillConflictMessage(message: string): boolean {\n return message.includes('form data changed; refresh and retry');\n}\n\n// The server names a field by its label: `欄位「標籤」`, a table row as\n// `「表格」第 N 列` (1-based), and a cell as `「表格」第 N 列的「欄位」`.\n// Each part of a message is separated by `;`. This is the fallback for a\n// response that carries no `formDataIssues`: labels are not unique, so the\n// issues, which address each value by its path, are the primary route.\nconst TOP_LEVEL_REF_PATTERN = /^欄位「(.+?)」(.+)$/;\nconst TABLE_REF_PATTERN = /^「(.+?)」第 (\\d+) 列(?:的「(.+?)」)?(.+)$/;\nconst MISSING_FIELDS_PREFIX = '缺少必填欄位:';\n\n/** The field, or table column, a server error names, with its renderer key. */\ninterface FillErrorTarget {\n readonly key: string;\n readonly settings: FormFieldDefinition | TableColumnDefinition | undefined;\n readonly topLevel: boolean;\n}\n\n/** The sentence a refused value shows, by its reason. */\nfunction readFillIssueText(\n reason: FormDataIssueReason,\n limit: number | undefined,\n target: FillErrorTarget,\n): string {\n const name = target.settings?.label || target.settings?.fieldKey || '';\n\n switch (reason) {\n case 'REQUIRED':\n return target.topLevel && name !== ''\n ? `${name}為必填欄位。`\n : '此欄為必填。';\n case 'MIN_LENGTH':\n return `至少需要 ${limit ?? 0} 個字。`;\n case 'MAX_LENGTH':\n return `最多 ${limit ?? 0} 個字。`;\n case 'MIN_ROWS':\n return `至少需要 ${limit ?? 0} 列。`;\n case 'MAX_ROWS':\n return `最多 ${limit ?? 0} 列。`;\n case 'PATTERN': {\n const message =\n target.settings &&\n (target.settings.type === 'text' || target.settings.type === 'textarea')\n ? target.settings.patternErrorMessage?.trim()\n : undefined;\n\n return message || '格式不正確。';\n }\n // The server ran out of time on the format check; the value may be fine.\n case 'PATTERN_TIMEOUT':\n return '格式檢查逾時,請縮短內容後再試,或請表單設計者簡化格式。';\n default:\n return '此欄內容不正確。';\n }\n}\n\n/** The reason a message sentence stands for, for the message fallback. */\nfunction readFillReasonFromSentence(sentence: string): {\n readonly limit?: number;\n readonly reason: FormDataIssueReason;\n} {\n const atLeastRows = /^至少需要 (\\d+) 列$/.exec(sentence);\n const atMostRows = /^最多 (\\d+) 列$/.exec(sentence);\n const shortest = /^至少需要 (\\d+) 個字$/.exec(sentence);\n const longest = /^最多 (\\d+) 個字$/.exec(sentence);\n\n if (sentence === '為必填') {\n return { reason: 'REQUIRED' };\n }\n\n if (atLeastRows) {\n return { limit: Number(atLeastRows[1]), reason: 'MIN_ROWS' };\n }\n\n if (atMostRows) {\n return { limit: Number(atMostRows[1]), reason: 'MAX_ROWS' };\n }\n\n if (shortest) {\n return { limit: Number(shortest[1]), reason: 'MIN_LENGTH' };\n }\n\n if (longest) {\n return { limit: Number(longest[1]), reason: 'MAX_LENGTH' };\n }\n\n if (sentence === '格式不正確') {\n return { reason: 'PATTERN' };\n }\n\n if (sentence === '無法在時限內完成格式檢查') {\n return { reason: 'PATTERN_TIMEOUT' };\n }\n\n return { reason: 'TYPE' };\n}\n\n/**\n * The renderer key of the value an issue path addresses, among the fields\n * `fields` lets the approver fill. `items` is a table, `items[1]` a row,\n * `items[1].qty` a cell. `null` when the path names nothing fillable.\n */\nfunction readFillIssueTarget(\n path: string,\n fields: readonly FormFieldDefinition[],\n): FillErrorTarget | null {\n const field = fields.find(\n (candidate) =>\n path === candidate.fieldKey ||\n (isTableFieldDefinition(candidate) &&\n path.startsWith(`${candidate.fieldKey}[`)),\n );\n\n if (!field) {\n return null;\n }\n\n if (path === field.fieldKey) {\n return { key: path, settings: field, topLevel: true };\n }\n\n if (!isTableFieldDefinition(field)) {\n return null;\n }\n\n const rowPath = /^\\[(\\d+)\\](?:\\.(.+))?$/u.exec(\n path.slice(field.fieldKey.length),\n );\n\n if (!rowPath) {\n return null;\n }\n\n const rowKey = `${field.fieldKey}[${rowPath[1]}]`;\n const columnKey = rowPath[2];\n\n if (columnKey === undefined) {\n return { key: rowKey, settings: undefined, topLevel: false };\n }\n\n const column = field.columns.find(\n (candidate) => candidate.fieldKey === columnKey,\n );\n\n return column\n ? { key: `${rowKey}.${column.fieldKey}`, settings: column, topLevel: false }\n : null;\n}\n\nfunction readFillErrorsFromIssues(\n issues: readonly FormDataIssue[],\n fields: readonly FormFieldDefinition[],\n): Readonly<Record<string, string>> | null {\n const entries = issues.map((issue): readonly [string, string] | null => {\n const target = readFillIssueTarget(issue.path, fields);\n\n return target === null\n ? null\n : [target.key, readFillIssueText(issue.reason, issue.limit, target)];\n });\n\n if (entries.length === 0 || entries.some((entry) => entry === null)) {\n return null;\n }\n\n return Object.fromEntries(\n entries.filter(\n (entry): entry is readonly [string, string] => entry !== null,\n ),\n );\n}\n\nfunction readFillErrorTarget(\n part: string,\n fields: readonly FormFieldDefinition[],\n): { readonly target: FillErrorTarget; readonly reason: string } | null {\n const topLevel = TOP_LEVEL_REF_PATTERN.exec(part);\n\n if (topLevel) {\n const field = fields.find(\n (candidate) => (candidate.label || candidate.fieldKey) === topLevel[1],\n );\n\n return field\n ? {\n reason: topLevel[2],\n target: { key: field.fieldKey, settings: field, topLevel: true },\n }\n : null;\n }\n\n const tableRef = TABLE_REF_PATTERN.exec(part);\n\n if (!tableRef) {\n return null;\n }\n\n const table = fields.find(\n (candidate) =>\n isTableFieldDefinition(candidate) &&\n (candidate.label || candidate.fieldKey) === tableRef[1],\n );\n\n if (!table || !isTableFieldDefinition(table)) {\n return null;\n }\n\n const rowKey = `${table.fieldKey}[${Number(tableRef[2]) - 1}]`;\n const columnLabel = tableRef[3];\n\n if (columnLabel === undefined) {\n return {\n reason: tableRef[4],\n target: { key: rowKey, settings: undefined, topLevel: false },\n };\n }\n\n const column = table.columns.find(\n (candidate) => (candidate.label || candidate.fieldKey) === columnLabel,\n );\n\n return column\n ? {\n reason: tableRef[4],\n target: {\n key: `${rowKey}.${column.fieldKey}`,\n settings: column,\n topLevel: false,\n },\n }\n : null;\n}\n\n/**\n * Turns the server's fill validation refusal (docs/08 §8.5, error table 2)\n * into field errors keyed the way `FormRenderer` addresses them, so a check\n * the page missed still lands on the field. `formDataIssues` is the refusal's\n * structured list and wins when it is present: each issue names its value by\n * path, so two fields sharing a label stay apart. Without it, the Chinese\n * `message` is parsed. `null` when any part does not resolve to a fillable\n * field — the caller then shows the message as it is.\n */\nexport function readFillServerErrors(\n message: string,\n schema: FormDefinitionSchema,\n node: UserTaskNode,\n formDataIssues: readonly FormDataIssue[] = [],\n): Readonly<Record<string, string>> | null {\n const fillableFields = schema.fields.filter((field) =>\n readNodeFillableFieldKeys(node).has(field.fieldKey),\n );\n\n if (formDataIssues.length > 0) {\n return readFillErrorsFromIssues(formDataIssues, fillableFields);\n }\n\n if (message.startsWith(MISSING_FIELDS_PREFIX)) {\n // Labels may hold commas, so match each fillable field's label (or key)\n // against the list rather than splitting it.\n const listed = `, ${message.slice(MISSING_FIELDS_PREFIX.length)}, `;\n const missing = fillableFields.filter((field) =>\n listed.includes(`, ${field.label || field.fieldKey}, `),\n );\n\n return missing.length > 0\n ? Object.fromEntries(\n missing.map((field) => [\n field.fieldKey,\n `${field.label || field.fieldKey}為必填欄位。`,\n ]),\n )\n : null;\n }\n\n const parts = message\n .split(';')\n .map((part) => readFillErrorTarget(part, fillableFields));\n\n if (parts.length === 0 || parts.some((part) => part === null)) {\n return null;\n }\n\n return Object.fromEntries(\n parts.flatMap((part) => {\n if (part === null) {\n return [];\n }\n\n const { limit, reason } = readFillReasonFromSentence(part.reason);\n\n return [[part.target.key, readFillIssueText(reason, limit, part.target)]];\n }),\n );\n}\n\nexport interface FillSummaryItem {\n readonly fieldKey: string;\n readonly label: string;\n readonly text: string;\n}\n\nexport const UNKNOWN_FILL_ORG_UNIT_TEXT = '未知組織';\n\n/**\n * The org unit ids among `values`, once each and in form order, so the caller\n * can look up their names before building the summary.\n */\nexport function readFillOrgUnitIds(\n schema: FormDefinitionSchema,\n values: WorkflowFormData,\n): readonly string[] {\n return [\n ...new Set(\n schema.fields\n .filter(isOrgUnitFieldDefinition)\n .map((field) => values[field.fieldKey])\n .filter(\n (value): value is string =>\n typeof value === 'string' && value.trim().length > 0,\n ),\n ),\n ];\n}\n\nfunction readFillValueText(\n field: FormFieldDefinition,\n value: FormFieldValue | undefined,\n memberNames: ReadonlyMap<string, string>,\n orgUnitNames: ReadonlyMap<string, string>,\n): string {\n if (isTableFieldDefinition(field)) {\n const rows = readFormTableRows(value);\n const totals = field.columns\n .filter((column) => column.type === 'number' || column.type === 'money')\n .map((column) => ({\n label: column.label || column.fieldKey,\n total: rows.reduce(\n (sum, row) =>\n typeof row[column.fieldKey] === 'number' &&\n Number.isFinite(row[column.fieldKey])\n ? sum + (row[column.fieldKey] as number)\n : sum,\n 0,\n ),\n }));\n\n return [\n `${rows.length} 列`,\n ...(rows.length > 0\n ? totals.map(\n ({ label, total }) => `${label}合計 ${total.toLocaleString('zh-TW')}`,\n )\n : []),\n ].join(',');\n }\n\n if (isFormDataValueEmpty(value)) {\n return '未填寫';\n }\n\n if (typeof value === 'boolean') {\n return value ? '是' : '否';\n }\n\n if (isOrgUnitFieldDefinition(field)) {\n // `orgUnitNames` (`useOrgUnitNames`) maps an id still being looked up to\n // a loading text; an id the lookup did not name is 「未知組織」. Never the\n // raw id.\n return typeof value === 'string'\n ? (orgUnitNames.get(value) ?? UNKNOWN_FILL_ORG_UNIT_TEXT)\n : UNKNOWN_FILL_ORG_UNIT_TEXT;\n }\n\n const items = Array.isArray(value) ? value : [value];\n const optionLabels = isFormStaticOptionFieldDefinition(field)\n ? new Map(field.options.map((option) => [option.value, option.label]))\n : field.type === 'member'\n ? memberNames\n : new Map<string, string>();\n\n return items\n .map((item) =>\n typeof item === 'string' ? (optionLabels.get(item) ?? item) : String(item),\n )\n .join('、');\n}\n\n/**\n * One line per field `node` lets its approver fill, in form order, for the\n * approve dialog: what will be sent along with the approval. A member field\n * names each member found in `memberNames` and shows the id otherwise; an org\n * unit field names its unit from `orgUnitNames` and shows 「未知組織」 otherwise.\n */\nexport function readFillSummary(\n schema: FormDefinitionSchema,\n node: UserTaskNode,\n values: WorkflowFormData,\n memberNames: ReadonlyMap<string, string> = new Map(),\n orgUnitNames: ReadonlyMap<string, string> = new Map(),\n): readonly FillSummaryItem[] {\n const fillableKeys = readNodeFillableFieldKeys(node);\n\n return schema.fields\n .filter(\n (field) =>\n fillableKeys.has(field.fieldKey) &&\n Object.prototype.hasOwnProperty.call(values, field.fieldKey),\n )\n .map((field) => ({\n fieldKey: field.fieldKey,\n label: field.label || field.fieldKey,\n text: readFillValueText(\n field,\n values[field.fieldKey],\n memberNames,\n orgUnitNames,\n ),\n }));\n}\n","import { readFormDataSourceErrorMessage } from '@rytass/bpm-core-client/form';\nimport { ATTACHMENT_NOT_BINDABLE_ERROR_CODE } from '@rytass/bpm-core-shared/form';\n\nconst ATTACHMENT_NOT_BINDABLE_MESSAGE =\n '表單中有附件無法附加到這個案件(只能附加申請人為本案上傳的檔案),請移除後重新上傳再送出。';\n\n/**\n * The message a case page shows for a failed request: a stable server code\n * translated into words, otherwise the server's own message.\n */\nexport function readErrorMessage(error: unknown): string {\n // DataSource failures arrive as stable codes so the backend never leaks\n // upstream transport detail; translate them instead of showing the raw code.\n const dataSourceMessage = readFormDataSourceErrorMessage(error);\n\n if (dataSourceMessage) {\n return dataSourceMessage;\n }\n\n const message = error instanceof Error ? error.message : null;\n\n // Names the problem, not the attachment ids the server lists.\n if (message?.includes(ATTACHMENT_NOT_BINDABLE_ERROR_CODE)) {\n return ATTACHMENT_NOT_BINDABLE_MESSAGE;\n }\n\n return message ?? '發生未知錯誤';\n}\n"],"mappings":";;;;AA8BA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ACmF,EAAO,OAAOA,EAAO,KAAK,CAAC,CAAC,IACnEnF,EAAM,SAAS,WACboF,oBACA,IAAI,IAAoB;CAE9B,OAAOJ,EACJ,KAAK,MACJ,OAAOK,KAAS,WAAYJ,EAAa,IAAII,CAAI,KAAKA,IAAQ,OAAOA,CAAI,CAC3E,CAAC,CACA,KAAK,GAAG;AACb;AAQA,SAAgBC,EACd,GACA,GACA,GACA,oBAA2C,IAAI,IAAI,GACnD,oBAA4C,IAAI,IAAI,GACxB;CAC5B,IAAMjF,IAAeC,EAA0BC,CAAI;CAEnD,OAAOR,EAAO,OACX,QACE,MACCM,EAAa,IAAIL,EAAM,QAAQ,KAC/B,OAAO,UAAU,eAAe,KAAKG,GAAQH,EAAM,QAAQ,CAC/D,CAAC,CACA,KAAK,OAAW;EACf,UAAUA,EAAM;EAChB,OAAOA,EAAM,SAASA,EAAM;EAC5B,MAAMsE,EACJtE,GACAG,EAAOH,EAAM,WACboF,GACAL,CACF;CACF,EAAE;AACN;;ACjnBA,IAAMQ,IACJ;AAMF,SAAgBC,EAAiB,GAAwB;CAGvD,IAAMC,IAAoBC,EAA+BC,CAAK;CAE9D,IAAIF,GACF,OAAOA;CAGT,IAAM/D,IAAUiE,aAAiB,QAAQA,EAAM,UAAU;CAOzD,OAJIjE,GAAS,SAASkE,CAAkC,IAC/CL,IAGF7D,KAAW;AACpB"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";let e=require("react"),t=require("react/jsx-runtime");var n=`zh-TW`,r=[`zh-TW`,`en`],i=(0,e.createContext)(n);function a({children:e,language:n}){return(0,t.jsx)(i.Provider,{value:n,children:e})}function o(){return(0,e.useContext)(i)}Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return a}});
|
|
2
|
-
//# sourceMappingURL=language-provider-Bdnx3Gxl.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"language-provider-Bdnx3Gxl.cjs","names":["createContext","useContext","react","react_jsx_runtime","DEFAULT_BPM_LANGUAGE","BPM_LANGUAGES","BPMLanguageContext","BPMLanguageProvider","language","useBPMLanguage"],"sources":["../../src/lib/language-provider.tsx"],"sourcesContent":["'use client';\n\nimport {\n createContext,\n useContext,\n type ReactElement,\n type ReactNode,\n} from 'react';\n\n/**\n * Languages BPM views can write their messages in. This is separate from the\n * Mezzanine calendar `locale` on `<Providers>`, which only formats dates.\n */\nexport type BPMLanguage = 'en' | 'zh-TW';\n\nexport const DEFAULT_BPM_LANGUAGE: BPMLanguage = 'zh-TW';\n\nexport const BPM_LANGUAGES: readonly BPMLanguage[] = ['zh-TW', 'en'];\n\nconst BPMLanguageContext = createContext<BPMLanguage>(DEFAULT_BPM_LANGUAGE);\n\ninterface BPMLanguageProviderProps {\n readonly children: ReactNode;\n readonly language: BPMLanguage;\n}\n\n/**\n * Sets the language BPM views write their messages in. Hosts that let a user\n * choose pass that choice here as state; a change re-renders every view below.\n *\n * Outside this provider `useBPMLanguage()` answers `'zh-TW'`, so views render\n * in tests and Storybook without it.\n */\nexport function BPMLanguageProvider({\n children,\n language,\n}: BPMLanguageProviderProps): ReactElement {\n return (\n <BPMLanguageContext.Provider value={language}>\n {children}\n </BPMLanguageContext.Provider>\n );\n}\n\nexport function useBPMLanguage(): BPMLanguage {\n return useContext(BPMLanguageContext);\n}\n"],"mappings":"A,mEAeA,IAAaI,EAAoC,QAEpCC,EAAwC,CAAC,QAAS,IAAI,EAE7DC,GAAA,EAAqBN,EAAAA,cAAAA,CAA2BI,CAAoB,EAc1E,SAAgBG,EAAoB,CAClC,WACA,YACyC,CACzC,OACE,EAAAJ,EAAA,IAAA,CAACG,EAAmB,SAApB,CAA6B,MAAOE,EACjC,UAC0B,CAAA,CAEjC,CAEA,SAAgBC,GAA8B,CAC5C,OAAA,EAAOR,EAAAA,WAAAA,CAAWK,CAAkB,CACtC,C"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { createContext as e, useContext as t } from "react";
|
|
3
|
-
import { jsx as n } from "react/jsx-runtime";
|
|
4
|
-
// src/lib/language-provider.tsx
|
|
5
|
-
var r = "zh-TW", i = ["zh-TW", "en"], a = e(r);
|
|
6
|
-
function o({ children: e, language: t }) {
|
|
7
|
-
return /* @__PURE__ */ n(a.Provider, {
|
|
8
|
-
value: t,
|
|
9
|
-
children: e
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
function s() {
|
|
13
|
-
return t(a);
|
|
14
|
-
}
|
|
15
|
-
export { s as i, i as n, r, o as t };
|
|
16
|
-
|
|
17
|
-
//# sourceMappingURL=language-provider-phkWOapf.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"language-provider-phkWOapf.js","names":["DEFAULT_BPM_LANGUAGE","BPM_LANGUAGES","BPMLanguageContext","createContext","BPMLanguageProvider","language","useBPMLanguage","useContext"],"sources":["../../src/lib/language-provider.tsx"],"sourcesContent":["'use client';\n\nimport {\n createContext,\n useContext,\n type ReactElement,\n type ReactNode,\n} from 'react';\n\n/**\n * Languages BPM views can write their messages in. This is separate from the\n * Mezzanine calendar `locale` on `<Providers>`, which only formats dates.\n */\nexport type BPMLanguage = 'en' | 'zh-TW';\n\nexport const DEFAULT_BPM_LANGUAGE: BPMLanguage = 'zh-TW';\n\nexport const BPM_LANGUAGES: readonly BPMLanguage[] = ['zh-TW', 'en'];\n\nconst BPMLanguageContext = createContext<BPMLanguage>(DEFAULT_BPM_LANGUAGE);\n\ninterface BPMLanguageProviderProps {\n readonly children: ReactNode;\n readonly language: BPMLanguage;\n}\n\n/**\n * Sets the language BPM views write their messages in. Hosts that let a user\n * choose pass that choice here as state; a change re-renders every view below.\n *\n * Outside this provider `useBPMLanguage()` answers `'zh-TW'`, so views render\n * in tests and Storybook without it.\n */\nexport function BPMLanguageProvider({\n children,\n language,\n}: BPMLanguageProviderProps): ReactElement {\n return (\n <BPMLanguageContext.Provider value={language}>\n {children}\n </BPMLanguageContext.Provider>\n );\n}\n\nexport function useBPMLanguage(): BPMLanguage {\n return useContext(BPMLanguageContext);\n}\n"],"mappings":";;;;AAeA,IAAaA,IAAoC,SAEpCC,IAAwC,CAAC,SAAS,IAAI,GAE7DC,IAAqBC,EAA2BH,CAAoB;AAc1E,SAAgBI,EAAoB,EAClC,aACA,eACyC;CACzC,OACE,kBAACF,EAAmB,UAApB;EAA6B,OAAOG;EACjC;CAC0B,CAAA;AAEjC;AAEA,SAAgBC,IAA8B;CAC5C,OAAOC,EAAWL,CAAkB;AACtC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"providers-BbCs23sk.js","names":["_Fragment","Modal","Textarea","useAuth","DEFAULT_BPM_LANGUAGE","BPMLanguageProvider","useRouterAdapter","useBPMRoutes","BPMFormField","Fragment$1","Drawer","Modal$1","NotificationCenter","Textarea$1","NotificationDrawerContext","createContext","NotificationDrawerProvider","isOpen","setIsOpen","useState","open","useCallback","close","toggle","current","value","useMemo","useNotificationDrawer","useContext","NotificationUnreadContext","NotificationUnreadProvider","currentMemberId","member","unreadCount","setUnreadCount","refreshUnreadCount","next","readUnreadNotificationCount","active","useNotificationUnread","TIME_GROUP_ORDER","TIME_GROUP_LABEL","PAGE_SIZE","TOGGLE_ARCHIVED_OPTION_ID","buildNotificationOptions","canReject","readNotificationAllowReject","record","opensToFill","readNotificationHasFillableFields","RESOLVED_TITLE","resolveDisplayTitle","resolveSeverity","toSeverity","NotificationDrawer","router","routes","rows","setRows","totalCount","setTotalCount","page","setPage","loading","setLoading","bulkLoading","setBulkLoading","error","setError","notice","setNotice","filter","setFilter","includeArchived","setIncludeArchived","approveTarget","setApproveTarget","approveComment","setApproveComment","rejectTarget","setRejectTarget","rejectReason","setRejectReason","deciding","setDeciding","trimmedApproveComment","trimmedRejectReason","loadPage","result","listNotifications","nextPage","append","readErrorMessage","handleFilterChange","event","handleMarkAllRead","markAllNotificationsRead","handleLoadMore","handleMarkRead","markNotificationRead","handleArchive","label","unarchiveNotifications","archiveNotifications","handleFilterAreaSelect","option","handleOpenInstance","openApproveModal","closeApproveModal","handleApproveConfirm","target","decideTask","openRejectModal","closeRejectModal","handleRejectConfirm","handleBadgeSelect","action","isCardActivation","card","handleCardActivate","handleCardKeyDown","filteredRows","row","groupedRows","now","buckets","group","accumulator","resolveTimeGroup","items","hasMore","Fragment","openable","itemIndex","Typography","type","notificationDate","nowStartOfDay","notificationStartOfDay","yesterdayStartOfDay","payload","isRecord","Providers","CalendarLocale","CalendarConfigProviderMoment","AuthProvider","children"],"sources":["../../src/lib/notification-drawer-provider.tsx","../../src/lib/notification-unread-provider.tsx","../../src/components/notification-drawer.tsx","../../src/lib/providers.tsx"],"sourcesContent":["'use client';\n\nimport {\n createContext,\n useCallback,\n useContext,\n useMemo,\n useState,\n type ReactElement,\n type ReactNode,\n} from 'react';\n\ninterface NotificationDrawerContextValue {\n readonly close: () => void;\n readonly isOpen: boolean;\n readonly open: () => void;\n readonly toggle: () => void;\n}\n\nconst NotificationDrawerContext =\n createContext<NotificationDrawerContextValue | null>(null);\n\ninterface NotificationDrawerProviderProps {\n readonly children: ReactNode;\n}\n\n/**\n * Controls the open/closed state of the BPM notification drawer. Wraps\n * children with a context that `<NotificationDrawer />` reads to mount /\n * hide itself, and that the host navigation reads (via\n * `<BPMNotificationBellButton />` or `useNotificationDrawer().open`) to\n * open the drawer when the bell icon is clicked.\n *\n * When used outside this provider, the returned hook is a safe no-op so\n * components don't crash in test or storybook environments.\n */\nexport function NotificationDrawerProvider({\n children,\n}: NotificationDrawerProviderProps): ReactElement {\n const [isOpen, setIsOpen] = useState(false);\n\n const open = useCallback((): void => {\n setIsOpen(true);\n }, []);\n const close = useCallback((): void => {\n setIsOpen(false);\n }, []);\n const toggle = useCallback((): void => {\n setIsOpen((current) => !current);\n }, []);\n\n const value = useMemo<NotificationDrawerContextValue>(\n () => ({ close, isOpen, open, toggle }),\n [close, isOpen, open, toggle],\n );\n\n return (\n <NotificationDrawerContext.Provider value={value}>\n {children}\n </NotificationDrawerContext.Provider>\n );\n}\n\n/**\n * Read the BPM notification drawer's open state and control helpers.\n * Returns a no-op stub when used outside `<NotificationDrawerProvider>`.\n */\nexport function useNotificationDrawer(): NotificationDrawerContextValue {\n const context = useContext(NotificationDrawerContext);\n if (!context) {\n return {\n close: (): void => undefined,\n isOpen: false,\n open: (): void => undefined,\n toggle: (): void => undefined,\n };\n }\n return context;\n}\n","'use client';\n\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useState,\n type ReactElement,\n type ReactNode,\n} from 'react';\nimport { readUnreadNotificationCount } from '@rytass/bpm-core-client/workflow';\nimport { useAuth } from './auth-provider';\n\ninterface NotificationUnreadContextValue {\n readonly refreshUnreadCount: () => Promise<number>;\n readonly unreadCount: number;\n}\n\nconst NotificationUnreadContext =\n createContext<NotificationUnreadContextValue | null>(null);\n\ninterface NotificationUnreadProviderProps {\n readonly children: ReactNode;\n}\n\n/**\n * Polls BPM for the current member's unread notification count via\n * `readUnreadNotificationCount` and exposes it through context for the\n * host navigation (`<BPMNotificationBellButton />` badge or any custom\n * trigger using `useNotificationUnread().unreadCount`) and the BPM\n * `<NotificationDrawer />` (header count). Refresh is triggered on\n * mount and whenever the auth member id changes; consumers can call\n * `refreshUnreadCount()` after acknowledging a notification.\n */\nexport function NotificationUnreadProvider({\n children,\n}: NotificationUnreadProviderProps): ReactElement {\n const { member } = useAuth();\n const currentMemberId = member?.memberId ?? null;\n const [unreadCount, setUnreadCount] = useState(0);\n\n const refreshUnreadCount = useCallback(async (): Promise<number> => {\n if (!currentMemberId) {\n setUnreadCount(0);\n return 0;\n }\n const next = await readUnreadNotificationCount(currentMemberId);\n setUnreadCount(next);\n return next;\n }, [currentMemberId]);\n\n useEffect((): (() => void) => {\n let active = true;\n void (async () => {\n try {\n const next = await refreshUnreadCount();\n if (active) setUnreadCount(next);\n } catch {\n if (active) setUnreadCount(0);\n }\n })();\n return (): void => {\n active = false;\n };\n }, [refreshUnreadCount]);\n\n const value = useMemo<NotificationUnreadContextValue>(\n () => ({ refreshUnreadCount, unreadCount }),\n [refreshUnreadCount, unreadCount],\n );\n\n return (\n <NotificationUnreadContext.Provider value={value}>\n {children}\n </NotificationUnreadContext.Provider>\n );\n}\n\n/**\n * Read the current unread-notification count and a manual refresh helper.\n * Returns a zero/no-op stub when used outside\n * `<NotificationUnreadProvider>`.\n */\nexport function useNotificationUnread(): NotificationUnreadContextValue {\n const context = useContext(NotificationUnreadContext);\n if (!context) {\n return {\n refreshUnreadCount: async (): Promise<number> => 0,\n unreadCount: 0,\n };\n }\n return context;\n}\n","'use client';\n\nimport {\n Fragment,\n useCallback,\n useEffect,\n useMemo,\n useState,\n type ChangeEvent,\n type KeyboardEvent as ReactKeyboardEvent,\n type MouseEvent as ReactMouseEvent,\n type ReactElement,\n} from 'react';\nimport Drawer from '@mezzanine-ui/react/Drawer';\nimport Modal from '@mezzanine-ui/react/Modal';\nimport NotificationCenter from '@mezzanine-ui/react/NotificationCenter';\nimport Textarea from '@mezzanine-ui/react/Textarea';\nimport { Typography } from '@mezzanine-ui/react';\nimport type { NotificationSeverity } from '@mezzanine-ui/core/notification-center';\nimport type { DropdownOption } from '@mezzanine-ui/core/dropdown/dropdown';\nimport {\n archiveNotifications,\n decideTask,\n listNotifications,\n markAllNotificationsRead,\n markNotificationRead,\n unarchiveNotifications,\n type NotificationRecord,\n type NotificationResolution,\n type NotificationType,\n} from '@rytass/bpm-core-client/workflow';\nimport { useAuth } from '../lib/auth-provider';\nimport { useNotificationDrawer } from '../lib/notification-drawer-provider';\nimport { useNotificationUnread } from '../lib/notification-unread-provider';\nimport { useRouterAdapter } from '../lib/router-adapter';\nimport { useBPMRoutes } from '../lib/routes-config';\nimport { BPMFormField } from './bpm-form-field';\n\ntype FilterValue = 'all' | 'read' | 'unread';\n\ntype TimeGroup = 'today' | 'yesterday' | 'past7Days' | 'earlier';\n\nconst TIME_GROUP_ORDER: readonly TimeGroup[] = [\n 'today',\n 'yesterday',\n 'past7Days',\n 'earlier',\n];\n\nconst TIME_GROUP_LABEL: Readonly<Record<TimeGroup, string>> = {\n earlier: '更早',\n past7Days: '過去七天',\n today: '今天',\n yesterday: '昨天',\n};\n\nconst PAGE_SIZE = 50;\n\n/** Identifiers for the per-notification `...` dropdown menu entries. */\ntype NotificationAction =\n | 'approve'\n | 'archive'\n | 'reject'\n | 'unarchive'\n | 'view'\n | 'read';\n\n/** Identifier for the filter-bar dropdown entry toggling the archived view. */\nconst TOGGLE_ARCHIVED_OPTION_ID = 'toggleArchived';\n\n/**\n * Build the `...` dropdown options for one notification. Approve / reject are\n * offered only while the server still reports the notification as `actionable`\n * (an unresolved task assignment) — once the task is decided / cancelled the\n * backend flips `actionable` to false, so a stale \"同意\" can never appear.\n * A task that fills in form fields (`hasFillableFields`) cannot be approved\n * from here — the fill has to be entered on the case page — so its \"同意\"\n * becomes \"開啟案件\".\n * \"查看案件\" needs an `instanceId`; \"標為已讀\" only shows while unread.\n * Archiving is independent of read state, so the entry flips between\n * \"封存\" / \"取消封存\" for every notification.\n */\nfunction buildNotificationOptions(\n record: NotificationRecord,\n): readonly DropdownOption[] {\n const canReject = readNotificationAllowReject(record) !== false;\n const opensToFill =\n record.actionable &&\n Boolean(record.instanceId) &&\n readNotificationHasFillableFields(record);\n\n return [\n ...(record.actionable\n ? ([\n opensToFill\n ? { id: 'view', name: '開啟案件' }\n : { id: 'approve', name: '同意' },\n ...(canReject ? [{ id: 'reject', name: '拒絕' }] : []),\n ] satisfies DropdownOption[])\n : []),\n ...(record.instanceId && !opensToFill\n ? ([{ id: 'view', name: '查看案件' }] satisfies DropdownOption[])\n : []),\n ...(record.status !== 'READ'\n ? ([{ id: 'read', name: '標為已讀' }] satisfies DropdownOption[])\n : []),\n record.archivedAt\n ? { id: 'unarchive', name: '取消封存' }\n : { id: 'archive', name: '封存' },\n ];\n}\n\n/**\n * Title shown for a resolved task-assignment notification, replacing the\n * stored \"新的待簽任務\" wording so a decided card no longer reads as pending.\n * The stored `body` is kept as historical context (which case / node).\n */\nconst RESOLVED_TITLE: Readonly<Record<NotificationResolution, string>> = {\n APPROVED: '簽核任務已同意',\n REJECTED: '簽核任務已拒絕',\n RETURNED: '簽核任務已退回',\n SUPERSEDED: '簽核任務已結束',\n TRANSFERRED: '簽核任務已轉派',\n};\n\nfunction resolveDisplayTitle(record: NotificationRecord): string {\n return record.resolution ? RESOLVED_TITLE[record.resolution] : record.title;\n}\n\n/**\n * Severity (icon colour) for a notification. Once resolved, it reflects the\n * outcome — green for approved, red for rejected, neutral otherwise — instead\n * of the original by-type colour.\n */\nfunction resolveSeverity(record: NotificationRecord): NotificationSeverity {\n if (record.resolution === 'APPROVED') return 'success';\n if (record.resolution === 'REJECTED') return 'error';\n if (record.resolution) return 'info';\n return toSeverity(record.type);\n}\n\n/**\n * Right-side notification drawer mounted at the root by `<Providers>`.\n * Opens / closes via `useNotificationDrawer()`, polls\n * `listNotifications()` for the current member, supports filter\n * (`all` / `read` / `unread`), per-row mark-read, per-row archive / unarchive,\n * bulk mark-all-read, and load-more pagination. Archived notifications are\n * hidden until the filter-bar menu turns \"顯示已封存\" on. Clicking a row with an\n * `instanceId` navigates to `/instances/<id>` via the host's router adapter.\n */\nexport function NotificationDrawer(): ReactElement | null {\n const router = useRouterAdapter();\n const routes = useBPMRoutes();\n const { member } = useAuth();\n const { close, isOpen } = useNotificationDrawer();\n const { refreshUnreadCount } = useNotificationUnread();\n const currentMemberId = member?.memberId ?? null;\n const [rows, setRows] = useState<readonly NotificationRecord[]>([]);\n const [totalCount, setTotalCount] = useState(0);\n const [page, setPage] = useState(1);\n const [loading, setLoading] = useState(false);\n const [bulkLoading, setBulkLoading] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const [notice, setNotice] = useState<string | null>(null);\n const [filter, setFilter] = useState<FilterValue>('all');\n const [includeArchived, setIncludeArchived] = useState(false);\n const [approveTarget, setApproveTarget] = useState<NotificationRecord | null>(\n null,\n );\n const [approveComment, setApproveComment] = useState('');\n const [rejectTarget, setRejectTarget] = useState<NotificationRecord | null>(\n null,\n );\n const [rejectReason, setRejectReason] = useState('');\n const [deciding, setDeciding] = useState(false);\n\n const trimmedApproveComment = approveComment.trim();\n const trimmedRejectReason = rejectReason.trim();\n\n const loadPage = useCallback(\n async (nextPage: number, append: boolean): Promise<boolean> => {\n if (!currentMemberId) return false;\n setLoading(true);\n setError(null);\n try {\n const result = await listNotifications({\n includeArchived,\n includeRead: true,\n page: nextPage,\n pageSize: PAGE_SIZE,\n recipientMemberId: currentMemberId,\n });\n setRows((current): readonly NotificationRecord[] =>\n append ? [...current, ...result.notifications] : result.notifications,\n );\n setTotalCount(result.totalCount);\n setPage(nextPage);\n await refreshUnreadCount();\n return true;\n } catch (e: unknown) {\n setError(readErrorMessage(e));\n return false;\n } finally {\n setLoading(false);\n }\n },\n [currentMemberId, includeArchived, refreshUnreadCount],\n );\n\n useEffect((): void => {\n if (!isOpen || !currentMemberId) return;\n setError(null);\n setNotice(null);\n void loadPage(1, false);\n }, [isOpen, currentMemberId, loadPage]);\n\n const handleFilterChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>): void => {\n const next = event.target.value;\n if (next === 'all' || next === 'read' || next === 'unread') setFilter(next);\n },\n [],\n );\n\n const handleMarkAllRead = useCallback(async (): Promise<void> => {\n if (!currentMemberId || bulkLoading) return;\n setBulkLoading(true);\n setError(null);\n try {\n await markAllNotificationsRead({ recipientMemberId: currentMemberId });\n await loadPage(1, false);\n } catch (e: unknown) {\n setError(readErrorMessage(e));\n } finally {\n setBulkLoading(false);\n }\n }, [bulkLoading, currentMemberId, loadPage]);\n\n const handleLoadMore = useCallback((): void => {\n if (loading) return;\n void loadPage(page + 1, true);\n }, [loading, loadPage, page]);\n\n const handleMarkRead = useCallback(\n async (id: string): Promise<void> => {\n if (!currentMemberId) return;\n try {\n await markNotificationRead({ id, readerMemberId: currentMemberId });\n await loadPage(1, false);\n } catch (e: unknown) {\n setError(readErrorMessage(e));\n }\n },\n [currentMemberId, loadPage],\n );\n\n const handleArchive = useCallback(\n async (record: NotificationRecord): Promise<void> => {\n if (!currentMemberId) return;\n setError(null);\n setNotice(null);\n try {\n // Name the notification the way the row does — `title` is the raw\n // stored title, which can differ from the rendered one.\n const label = resolveDisplayTitle(record);\n\n if (record.archivedAt) {\n await unarchiveNotifications({ ids: [record.id] });\n setNotice(`已將「${label}」移出封存。`);\n } else {\n await archiveNotifications({ ids: [record.id] });\n setNotice(`已封存「${label}」。`);\n }\n await loadPage(1, false);\n } catch (e: unknown) {\n setError(readErrorMessage(e));\n }\n },\n [currentMemberId, loadPage],\n );\n\n const handleFilterAreaSelect = useCallback((option: DropdownOption): void => {\n if (option.id !== TOGGLE_ARCHIVED_OPTION_ID) return;\n setNotice(null);\n setIncludeArchived((current): boolean => !current);\n }, []);\n\n const handleOpenInstance = useCallback(\n async (record: NotificationRecord): Promise<void> => {\n if (!record.instanceId || !currentMemberId) return;\n try {\n if (record.status !== 'READ') {\n await markNotificationRead({\n id: record.id,\n readerMemberId: currentMemberId,\n });\n await refreshUnreadCount();\n }\n close();\n router.push(routes.caseDetail(record.instanceId));\n } catch (e: unknown) {\n setError(readErrorMessage(e));\n }\n },\n [close, currentMemberId, refreshUnreadCount, router, routes],\n );\n\n const openApproveModal = useCallback((record: NotificationRecord): void => {\n setError(null);\n setApproveTarget(record);\n setApproveComment('');\n }, []);\n\n const closeApproveModal = useCallback((): void => {\n if (deciding) return;\n setApproveTarget(null);\n setApproveComment('');\n }, [deciding]);\n\n const handleApproveConfirm = useCallback(async (): Promise<void> => {\n const target = approveTarget;\n if (!target?.taskId || !currentMemberId || deciding) return;\n setDeciding(true);\n setError(null);\n setNotice(null);\n try {\n await decideTask({\n action: 'APPROVED',\n comment: trimmedApproveComment || null,\n decidedByMemberId: currentMemberId,\n taskId: target.taskId,\n });\n const refreshed = await loadPage(1, false);\n if (!refreshed) return;\n setApproveTarget(null);\n setApproveComment('');\n setNotice(`已同意「${target.title}」。`);\n } catch (e: unknown) {\n setError(readErrorMessage(e));\n } finally {\n setDeciding(false);\n }\n }, [\n approveTarget,\n currentMemberId,\n deciding,\n loadPage,\n trimmedApproveComment,\n ]);\n\n const openRejectModal = useCallback((record: NotificationRecord): void => {\n setRejectTarget(record);\n setRejectReason('');\n }, []);\n\n const closeRejectModal = useCallback((): void => {\n setRejectTarget(null);\n setRejectReason('');\n }, []);\n\n const handleRejectConfirm = useCallback(async (): Promise<void> => {\n const target = rejectTarget;\n if (!target?.taskId || !currentMemberId || !trimmedRejectReason || deciding)\n return;\n setDeciding(true);\n setError(null);\n setNotice(null);\n try {\n await decideTask({\n action: 'REJECTED',\n comment: trimmedRejectReason,\n decidedByMemberId: currentMemberId,\n taskId: target.taskId,\n });\n setRejectTarget(null);\n setRejectReason('');\n setNotice(`已拒絕「${target.title}」。`);\n await loadPage(1, false);\n } catch (e: unknown) {\n setError(readErrorMessage(e));\n } finally {\n setDeciding(false);\n }\n }, [currentMemberId, deciding, loadPage, rejectTarget, trimmedRejectReason]);\n\n const handleBadgeSelect = useCallback(\n (record: NotificationRecord, option: DropdownOption): void => {\n const action = option.id as NotificationAction;\n if (action === 'approve') openApproveModal(record);\n else if (action === 'reject') openRejectModal(record);\n else if (action === 'view') void handleOpenInstance(record);\n else if (action === 'read') void handleMarkRead(record.id);\n else if (action === 'archive' || action === 'unarchive')\n void handleArchive(record);\n },\n [\n handleArchive,\n handleMarkRead,\n handleOpenInstance,\n openApproveModal,\n openRejectModal,\n ],\n );\n\n /**\n * Whether an event that reached the card wrapper actually happened inside the\n * card, and not on one of its action controls.\n *\n * Two escape hatches are needed. The `...` menu button (and its `<svg>` icon —\n * hence the `Element` check, SVG nodes are not HTMLElements) sits inside the\n * card and must open the dropdown rather than navigate. The dropdown itself\n * renders into a portal, and React replays events along the component tree\n * rather than the DOM tree, so picking \"封存\" also reaches this handler even\n * though the `<li role=\"option\">` lives outside the card's DOM — and it is not\n * a `<button>`, so the first guard alone misses it.\n */\n const isCardActivation = useCallback(\n (target: EventTarget | null, card: HTMLDivElement): boolean => {\n if (!(target instanceof Node) || !card.contains(target)) return false;\n\n return !(target instanceof Element && target.closest('button'));\n },\n [],\n );\n\n const handleCardActivate = useCallback(\n (record: NotificationRecord, event: ReactMouseEvent<HTMLDivElement>): void => {\n if (!isCardActivation(event.target, event.currentTarget)) return;\n void handleOpenInstance(record);\n },\n [handleOpenInstance, isCardActivation],\n );\n\n const handleCardKeyDown = useCallback(\n (\n record: NotificationRecord,\n event: ReactKeyboardEvent<HTMLDivElement>,\n ): void => {\n if (event.key !== 'Enter' && event.key !== ' ') return;\n if (!isCardActivation(event.target, event.currentTarget)) return;\n event.preventDefault();\n void handleOpenInstance(record);\n },\n [handleOpenInstance, isCardActivation],\n );\n\n const filteredRows = useMemo(\n (): readonly NotificationRecord[] =>\n rows.filter((row): boolean => {\n if (filter === 'all') return true;\n if (filter === 'read') return row.status === 'READ';\n return row.status !== 'READ';\n }),\n [filter, rows],\n );\n\n const groupedRows = useMemo(\n (): ReadonlyArray<readonly [TimeGroup, readonly NotificationRecord[]]> => {\n const now = new Date();\n const buckets = TIME_GROUP_ORDER.reduce<\n Record<TimeGroup, NotificationRecord[]>\n >(\n (accumulator, group) => {\n accumulator[group] = [];\n return accumulator;\n },\n { earlier: [], past7Days: [], today: [], yesterday: [] },\n );\n filteredRows.forEach((row): void => {\n buckets[resolveTimeGroup(row.createdAt, now)].push(row);\n });\n return TIME_GROUP_ORDER.map(\n (group) => [group, buckets[group]] as const,\n ).filter(([, items]) => items.length > 0);\n },\n [filteredRows],\n );\n\n const hasMore = rows.length < totalCount;\n\n if (!currentMemberId) return null;\n\n return (\n <>\n <Drawer\n bottomGhostActionDisabled={bulkLoading || loading}\n bottomGhostActionLoading={bulkLoading}\n bottomGhostActionText=\"全部標為已讀\"\n bottomOnGhostActionClick={(): void => {\n void handleMarkAllRead();\n }}\n bottomOnPrimaryActionClick={(): void => {\n handleLoadMore();\n }}\n bottomPrimaryActionDisabled={!hasMore || loading}\n bottomPrimaryActionLoading={loading && hasMore}\n bottomPrimaryActionText={hasMore ? '載入更多' : '已顯示全部'}\n contentKey={`${filter}:${includeArchived}:${rows.length}`}\n filterAreaAllRadioLabel=\"全部\"\n filterAreaOnRadioChange={handleFilterChange}\n filterAreaOnSelect={handleFilterAreaSelect}\n filterAreaOptions={[\n {\n id: TOGGLE_ARCHIVED_OPTION_ID,\n name: includeArchived ? '隱藏已封存' : '顯示已封存',\n },\n ]}\n filterAreaReadRadioLabel=\"已讀\"\n filterAreaShow\n filterAreaUnreadRadioLabel=\"未讀\"\n filterAreaValue={filter}\n headerTitle=\"通知中心\"\n isBottomDisplay\n isHeaderDisplay\n onClose={close}\n open={isOpen}\n size=\"medium\"\n >\n <div role=\"list\">\n {error ? (\n <p\n role=\"alert\"\n style={{\n color: 'var(--mzn-color-text-error, #d92d20)',\n padding: '12px 16px',\n }}\n >\n {error}\n </p>\n ) : null}\n {notice ? (\n <p\n role=\"status\"\n style={{\n color: 'var(--mzn-color-text-success, #079455)',\n padding: '12px 16px',\n }}\n >\n {notice}\n </p>\n ) : null}\n {groupedRows.length === 0 ? (\n <p\n style={{\n color: 'var(--mzn-color-text-secondary, #6b7280)',\n padding: '24px 16px',\n textAlign: 'center',\n }}\n >\n {loading ? '載入中…' : '目前沒有通知'}\n </p>\n ) : null}\n {groupedRows.map(([group, items]) => (\n <Fragment key={group}>\n {items.map((record, itemIndex) => {\n const openable = record.instanceId !== null;\n\n return (\n <div\n key={record.id}\n onClick={\n openable\n ? (event: ReactMouseEvent<HTMLDivElement>): void => {\n handleCardActivate(record, event);\n }\n : undefined\n }\n onKeyDown={\n openable\n ? (event: ReactKeyboardEvent<HTMLDivElement>): void => {\n handleCardKeyDown(record, event);\n }\n : undefined\n }\n role={openable ? 'button' : undefined}\n style={openable ? { cursor: 'pointer' } : undefined}\n tabIndex={openable ? 0 : undefined}\n >\n <NotificationCenter\n appendTips={record.archivedAt ? '已封存' : undefined}\n description={record.body}\n onBadgeSelect={(option: DropdownOption): void => {\n handleBadgeSelect(record, option);\n }}\n options={[...buildNotificationOptions(record)]}\n prependTips={\n itemIndex === 0 ? TIME_GROUP_LABEL[group] : undefined\n }\n reference={record.id}\n severity={resolveSeverity(record)}\n showBadge={record.status !== 'READ'}\n timeStamp={record.createdAt}\n title={resolveDisplayTitle(record)}\n type=\"drawer\"\n />\n </div>\n );\n })}\n </Fragment>\n ))}\n </div>\n </Drawer>\n <Modal\n cancelText=\"取消\"\n confirmText=\"送出同意\"\n loading={deciding}\n modalType=\"standard\"\n onCancel={closeApproveModal}\n onClose={closeApproveModal}\n onConfirm={(): void => {\n void handleApproveConfirm();\n }}\n open={approveTarget !== null}\n showModalFooter\n showModalHeader\n size=\"regular\"\n supportingText=\"可以留下同意說明,內容會記錄在簽核歷程;不填也可以直接送出。\"\n title=\"簽核意見\"\n >\n {error ? (\n <Typography color=\"text-error\" role=\"alert\" variant=\"body\">\n {error}\n </Typography>\n ) : null}\n <BPMFormField label=\"簽核意見\" name=\"notificationApproveComment\">\n <Textarea\n autoFocus\n onChange={(event: ChangeEvent<HTMLTextAreaElement>): void => {\n setApproveComment(event.target.value);\n }}\n placeholder=\"選填,例如補充核准條件或提醒事項\"\n rows={4}\n value={approveComment}\n />\n </BPMFormField>\n </Modal>\n <Modal\n cancelText=\"取消\"\n confirmButtonProps={{\n disabled: !trimmedRejectReason,\n variant: 'destructive-primary',\n }}\n confirmText=\"送出拒絕\"\n loading={deciding}\n modalStatusType=\"error\"\n modalType=\"standard\"\n onCancel={closeRejectModal}\n onClose={closeRejectModal}\n onConfirm={(): void => {\n void handleRejectConfirm();\n }}\n open={rejectTarget !== null}\n showModalFooter\n showModalHeader\n size=\"regular\"\n supportingText=\"拒絕案件時必須留下原因,供發起人與後續追蹤查看。\"\n title=\"拒絕原因\"\n >\n <Textarea\n autoFocus\n onChange={(event: ChangeEvent<HTMLTextAreaElement>): void => {\n setRejectReason(event.target.value);\n }}\n placeholder=\"請輸入拒絕原因\"\n rows={4}\n value={rejectReason}\n />\n </Modal>\n </>\n );\n}\n\nfunction toSeverity(type: NotificationType): NotificationSeverity {\n if (type === 'SLA_OVERDUE') return 'error';\n if (type === 'SLA_WARNING') return 'warning';\n if (type === 'INSTANCE_COMPLETED') return 'success';\n return 'info';\n}\n\nfunction resolveTimeGroup(value: string, now: Date): TimeGroup {\n const notificationDate = new Date(value);\n if (Number.isNaN(notificationDate.getTime())) return 'earlier';\n const nowStartOfDay = new Date(now.getFullYear(), now.getMonth(), now.getDate());\n const notificationStartOfDay = new Date(\n notificationDate.getFullYear(),\n notificationDate.getMonth(),\n notificationDate.getDate(),\n );\n if (notificationStartOfDay.getTime() === nowStartOfDay.getTime()) return 'today';\n const yesterdayStartOfDay = new Date(nowStartOfDay);\n yesterdayStartOfDay.setDate(yesterdayStartOfDay.getDate() - 1);\n if (notificationStartOfDay.getTime() === yesterdayStartOfDay.getTime())\n return 'yesterday';\n const diffInDays =\n (now.getTime() - notificationDate.getTime()) / (1000 * 60 * 60 * 24);\n if (diffInDays <= 7) return 'past7Days';\n return 'earlier';\n}\n\nfunction readErrorMessage(error: unknown): string {\n return error instanceof Error ? error.message : '發生未知錯誤';\n}\n\nfunction readNotificationAllowReject(\n record: NotificationRecord,\n): boolean | null {\n try {\n const payload: unknown = JSON.parse(record.payloadJson);\n\n if (isRecord(payload) && typeof payload.allowReject === 'boolean') {\n return payload.allowReject;\n }\n\n return record.allowReject;\n } catch {\n return record.allowReject;\n }\n}\n\n/**\n * `TASK_ASSIGNED` / `TASK_TRANSFERRED` payloads carry `hasFillableFields`;\n * older notifications do not, which reads as `false`.\n */\nfunction readNotificationHasFillableFields(\n record: NotificationRecord,\n): boolean {\n try {\n const payload: unknown = JSON.parse(record.payloadJson);\n\n return isRecord(payload) && payload.hasFillableFields === true;\n } catch {\n return false;\n }\n}\n\nfunction isRecord(value: unknown): value is Readonly<Record<string, unknown>> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n","'use client';\n\nimport type { ReactElement, ReactNode } from 'react';\nimport {\n CalendarConfigProviderMoment,\n CalendarLocale,\n} from '@mezzanine-ui/react/moment';\nimport { AuthProvider } from './auth-provider';\nimport {\n BPMLanguageProvider,\n DEFAULT_BPM_LANGUAGE,\n type BPMLanguage,\n} from './language-provider';\nimport { NotificationDrawer } from '../components/notification-drawer';\nimport { NotificationDrawerProvider } from './notification-drawer-provider';\nimport { NotificationUnreadProvider } from './notification-unread-provider';\n\ninterface ProvidersProps {\n readonly children: ReactNode;\n /** Override Mezzanine calendar locale. Defaults to `CalendarLocale.ZH_TW`. */\n readonly locale?: CalendarLocale;\n /**\n * Language BPM views write their messages in, such as publish-lint errors.\n * Defaults to `'zh-TW'`. Pass the user's choice as state to let them switch.\n * Independent of `locale`, which only formats calendar dates.\n */\n readonly language?: BPMLanguage;\n /**\n * Public paths that should not trigger redirect to `/login` when there\n * is no session. Forwarded to `<AuthProvider>`. Defaults to `['/login']`.\n */\n readonly publicPaths?: readonly string[];\n /** Where to send unauthenticated users. Defaults to `'/login'`. */\n readonly loginPath?: string;\n}\n\n/**\n * One-stop BPM admin provider stack. Wires:\n *\n * - Mezzanine UI calendar locale (moment-based, `ZH_TW` by default)\n * - `<BPMLanguageProvider>` (message language, `'zh-TW'` by default)\n * - `<AuthProvider>` (BPM session via REST `/auth/*`)\n * - `<NotificationUnreadProvider>` (polls unread count)\n * - `<NotificationDrawerProvider>` (controls drawer open/close state)\n * - `<NotificationDrawer />` mounted at the root so the host navigation\n * bell (`<BPMNotificationBellButton />` or any custom trigger calling\n * `useNotificationDrawer().open`) can open it.\n *\n * Consumer hosts wrap this **inside** a `<RouterAdapterProvider>` (provided\n * by the `pages/*` subpath shims when consuming via Next.js, or wired by\n * hand for other frameworks).\n */\nexport function Providers({\n children,\n locale = CalendarLocale.ZH_TW,\n language = DEFAULT_BPM_LANGUAGE,\n publicPaths,\n loginPath,\n}: ProvidersProps): ReactElement {\n return (\n <CalendarConfigProviderMoment locale={locale}>\n <BPMLanguageProvider language={language}>\n <AuthProvider publicPaths={publicPaths} loginPath={loginPath}>\n <NotificationUnreadProvider>\n <NotificationDrawerProvider>\n {children}\n <NotificationDrawer />\n </NotificationDrawerProvider>\n </NotificationUnreadProvider>\n </AuthProvider>\n </BPMLanguageProvider>\n </CalendarConfigProviderMoment>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAmBA,IAAMc,IACJC,EAAqD,IAAI;AAgB3D,SAAgBC,EAA2B,EACzC,eACgD;CAChD,IAAM,CAACC,GAAQC,KAAaC,EAAS,EAAK,GAEpCC,IAAOC,QAAwB;EACnC,EAAU,EAAI;CAChB,GAAG,CAAC,CAAC,GACCC,IAAQD,QAAwB;EACpC,EAAU,EAAK;CACjB,GAAG,CAAC,CAAC,GACCE,IAASF,QAAwB;EACrC,GAAW,MAAY,CAACG,CAAO;CACjC,GAAG,CAAC,CAAC,GAECC,IAAQC,SACL;EAAE;EAAO;EAAQ;EAAM;CAAO,IACrC;EAACJ;EAAOL;EAAQG;EAAMG;CAAM,CAC9B;CAEA,OACE,kBAACT,EAA0B,UAA3B;EAA2C;EACxC;CACiC,CAAA;AAExC;AAMA,SAAgBa,IAAwD;CAUtE,OATgBC,EAAWd,CACtB,KACI;EACL,aAAmB,KAAA;EACnB,QAAQ;EACR,YAAkB,KAAA;EAClB,cAAoB,KAAA;CACtB;AAGJ;;AC1DA,IAAMe,IACJd,EAAqD,IAAI;AAe3D,SAAgBe,EAA2B,EACzC,eACgD;CAChD,IAAM,EAAE,cAAW3B,EAAQ,GACrB4B,IAAkBC,GAAQ,YAAY,MACtC,CAACC,GAAaC,KAAkBf,EAAS,CAAC,GAE1CgB,IAAqBd,EAAY,YAA6B;EAClE,IAAI,CAACU,GAEH,OADAG,EAAe,CAAC,GACT;EAET,IAAME,IAAO,MAAMC,EAA4BN,CAAe;EAE9D,OADAG,EAAeE,CA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A,kBAAC4I,GAAD;IAA2B;IAAwB;IACjD,UAAA,kBAACnH,GAAD,EAAA,UACE,kBAACd,GAAD,EAAA,UAAA,CACGkI,GACD,kBAAC5F,GAAD,CAAqB,CAAA,CACK,EAAA,CAAA,EACF,CAAA;GAChB,CAAA;EACK,CAAA;CACO,CAAA;AAElC"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";const e=require("./rolldown-runtime-BocRIvOZ.cjs"),t=require("./auth-provider-4BeCw7cI.cjs"),n=require("./language-provider-Bdnx3Gxl.cjs"),r=require("./router-adapter--gYs13E8.cjs"),i=require("./routes-config-C1j_vFKo.cjs"),a=require("./bpm-form-field-Bc6k4ZEO.cjs");let o=require("react"),s=require("@mezzanine-ui/react"),c=require("react/jsx-runtime"),l=require("@rytass/bpm-core-client/workflow"),u=require("@mezzanine-ui/react/moment"),d=require("@mezzanine-ui/react/Drawer");d=e.t(d,1);let f=require("@mezzanine-ui/react/Modal");f=e.t(f,1);let p=require("@mezzanine-ui/react/NotificationCenter");p=e.t(p,1);let m=require("@mezzanine-ui/react/Textarea");m=e.t(m,1);var h=(0,o.createContext)(null);function g({children:e}){let[t,n]=(0,o.useState)(!1),r=(0,o.useCallback)(()=>{n(!0)},[]),i=(0,o.useCallback)(()=>{n(!1)},[]),a=(0,o.useCallback)(()=>{n(e=>!e)},[]),s=(0,o.useMemo)(()=>({close:i,isOpen:t,open:r,toggle:a}),[i,t,r,a]);return(0,c.jsx)(h.Provider,{value:s,children:e})}function _(){return(0,o.useContext)(h)||{close:()=>void 0,isOpen:!1,open:()=>void 0,toggle:()=>void 0}}var v=(0,o.createContext)(null);function y({children:e}){let{member:n}=t.n(),r=n?.memberId??null,[i,a]=(0,o.useState)(0),s=(0,o.useCallback)(async()=>{if(!r)return a(0),0;let e=await(0,l.readUnreadNotificationCount)(r);return a(e),e},[r]);(0,o.useEffect)(()=>{let e=!0;return(async()=>{try{let t=await s();e&&a(t)}catch{e&&a(0)}})(),()=>{e=!1}},[s]);let u=(0,o.useMemo)(()=>({refreshUnreadCount:s,unreadCount:i}),[s,i]);return(0,c.jsx)(v.Provider,{value:u,children:e})}function ee(){return(0,o.useContext)(v)||{refreshUnreadCount:async()=>0,unreadCount:0}}var b=[`today`,`yesterday`,`past7Days`,`earlier`],te={earlier:`更早`,past7Days:`過去七天`,today:`今天`,yesterday:`昨天`},ne=50,x=`toggleArchived`;function re(e){let t=E(e)!==!1,n=e.actionable&&!!e.instanceId&&D(e);return[...e.actionable?[n?{id:`view`,name:`開啟案件`}:{id:`approve`,name:`同意`},...t?[{id:`reject`,name:`拒絕`}]:[]]:[],...e.instanceId&&!n?[{id:`view`,name:`查看案件`}]:[],...e.status===`READ`?[]:[{id:`read`,name:`標為已讀`}],e.archivedAt?{id:`unarchive`,name:`取消封存`}:{id:`archive`,name:`封存`}]}var S={APPROVED:`簽核任務已同意`,REJECTED:`簽核任務已拒絕`,RETURNED:`簽核任務已退回`,SUPERSEDED:`簽核任務已結束`,TRANSFERRED:`簽核任務已轉派`};function ie(e){return e.resolution?S[e.resolution]:e.title}function ae(e){return e.resolution===`APPROVED`?`success`:e.resolution===`REJECTED`?`error`:e.resolution?`info`:w(e.type)}function C(){let e=r.r(),n=i.r(),{member:u}=t.n(),{close:h,isOpen:g}=_(),{refreshUnreadCount:v}=ee(),y=u?.memberId??null,[S,C]=(0,o.useState)([]),[w,E]=(0,o.useState)(0),[D,O]=(0,o.useState)(1),[k,A]=(0,o.useState)(!1),[j,M]=(0,o.useState)(!1),[N,P]=(0,o.useState)(null),[F,I]=(0,o.useState)(null),[L,se]=(0,o.useState)(`all`),[R,ce]=(0,o.useState)(!1),[z,B]=(0,o.useState)(null),[V,H]=(0,o.useState)(``),[U,W]=(0,o.useState)(null),[G,K]=(0,o.useState)(``),[q,J]=(0,o.useState)(!1),le=V.trim(),Y=G.trim(),X=(0,o.useCallback)(async(e,t)=>{if(!y)return!1;A(!0),P(null);try{let n=await(0,l.listNotifications)({includeArchived:R,includeRead:!0,page:e,pageSize:ne,recipientMemberId:y});return C(e=>t?[...e,...n.notifications]:n.notifications),E(n.totalCount),O(e),await v(),!0}catch(e){return P(T(e)),!1}finally{A(!1)}},[y,R,v]);(0,o.useEffect)(()=>{g&&y&&(P(null),I(null),X(1,!1))},[g,y,X]);let ue=(0,o.useCallback)(e=>{let t=e.target.value;(t===`all`||t===`read`||t===`unread`)&&se(t)},[]),de=(0,o.useCallback)(async()=>{if(y&&!j){M(!0),P(null);try{await(0,l.markAllNotificationsRead)({recipientMemberId:y}),await X(1,!1)}catch(e){P(T(e))}finally{M(!1)}}},[j,y,X]),fe=(0,o.useCallback)(()=>{k||X(D+1,!0)},[k,X,D]),pe=(0,o.useCallback)(async e=>{if(y)try{await(0,l.markNotificationRead)({id:e,readerMemberId:y}),await X(1,!1)}catch(e){P(T(e))}},[y,X]),me=(0,o.useCallback)(async e=>{if(y){P(null),I(null);try{let t=ie(e);e.archivedAt?(await(0,l.unarchiveNotifications)({ids:[e.id]}),I(`已將「${t}」移出封存。`)):(await(0,l.archiveNotifications)({ids:[e.id]}),I(`已封存「${t}」。`)),await X(1,!1)}catch(e){P(T(e))}}},[y,X]),he=(0,o.useCallback)(e=>{e.id===x&&(I(null),ce(e=>!e))},[]),Z=(0,o.useCallback)(async t=>{if(t.instanceId&&y)try{t.status!==`READ`&&(await(0,l.markNotificationRead)({id:t.id,readerMemberId:y}),await v()),h(),e.push(n.caseDetail(t.instanceId))}catch(e){P(T(e))}},[h,y,v,e,n]),ge=(0,o.useCallback)(e=>{P(null),B(e),H(``)},[]),_e=(0,o.useCallback)(()=>{q||(B(null),H(``))},[q]),ve=(0,o.useCallback)(async()=>{let e=z;if(e?.taskId&&y&&!q){J(!0),P(null),I(null);try{if(await(0,l.decideTask)({action:`APPROVED`,comment:le||null,decidedByMemberId:y,taskId:e.taskId}),!await X(1,!1))return;B(null),H(``),I(`已同意「${e.title}」。`)}catch(e){P(T(e))}finally{J(!1)}}},[z,y,q,X,le]),ye=(0,o.useCallback)(e=>{W(e),K(``)},[]),be=(0,o.useCallback)(()=>{W(null),K(``)},[]),xe=(0,o.useCallback)(async()=>{let e=U;if(e?.taskId&&y&&Y&&!q){J(!0),P(null),I(null);try{await(0,l.decideTask)({action:`REJECTED`,comment:Y,decidedByMemberId:y,taskId:e.taskId}),W(null),K(``),I(`已拒絕「${e.title}」。`),await X(1,!1)}catch(e){P(T(e))}finally{J(!1)}}},[y,q,X,U,Y]),Se=(0,o.useCallback)((e,t)=>{let n=t.id;n===`approve`?ge(e):n===`reject`?ye(e):n===`view`?Z(e):n===`read`?pe(e.id):(n===`archive`||n===`unarchive`)&&me(e)},[me,pe,Z,ge,ye]),Q=(0,o.useCallback)((e,t)=>!(e instanceof Node)||!t.contains(e)?!1:!(e instanceof Element&&e.closest(`button`)),[]),Ce=(0,o.useCallback)((e,t)=>{Q(t.target,t.currentTarget)&&Z(e)},[Z,Q]),we=(0,o.useCallback)((e,t)=>{(t.key===`Enter`||t.key===` `)&&Q(t.target,t.currentTarget)&&(t.preventDefault(),Z(e))},[Z,Q]),Te=(0,o.useMemo)(()=>S.filter(e=>L===`all`?!0:L===`read`?e.status===`READ`:e.status!==`READ`),[L,S]),Ee=(0,o.useMemo)(()=>{let e=new Date,t=b.reduce((e,t)=>(e[t]=[],e),{earlier:[],past7Days:[],today:[],yesterday:[]});return Te.forEach(n=>{t[oe(n.createdAt,e)].push(n)}),b.map(e=>[e,t[e]]).filter(([,e])=>e.length>0)},[Te]),$=S.length<w;return y?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(d.default,{bottomGhostActionDisabled:j||k,bottomGhostActionLoading:j,bottomGhostActionText:`全部標為已讀`,bottomOnGhostActionClick:()=>{de()},bottomOnPrimaryActionClick:()=>{fe()},bottomPrimaryActionDisabled:!$||k,bottomPrimaryActionLoading:k&&$,bottomPrimaryActionText:$?`載入更多`:`已顯示全部`,contentKey:`${L}:${R}:${S.length}`,filterAreaAllRadioLabel:`全部`,filterAreaOnRadioChange:ue,filterAreaOnSelect:he,filterAreaOptions:[{id:x,name:R?`隱藏已封存`:`顯示已封存`}],filterAreaReadRadioLabel:`已讀`,filterAreaShow:!0,filterAreaUnreadRadioLabel:`未讀`,filterAreaValue:L,headerTitle:`通知中心`,isBottomDisplay:!0,isHeaderDisplay:!0,onClose:h,open:g,size:`medium`,children:(0,c.jsxs)(`div`,{role:`list`,children:[N?(0,c.jsx)(`p`,{role:`alert`,style:{color:`var(--mzn-color-text-error, #d92d20)`,padding:`12px 16px`},children:N}):null,F?(0,c.jsx)(`p`,{role:`status`,style:{color:`var(--mzn-color-text-success, #079455)`,padding:`12px 16px`},children:F}):null,Ee.length===0?(0,c.jsx)(`p`,{style:{color:`var(--mzn-color-text-secondary, #6b7280)`,padding:`24px 16px`,textAlign:`center`},children:k?`載入中…`:`目前沒有通知`}):null,Ee.map(([e,t])=>(0,c.jsx)(o.Fragment,{children:t.map((t,n)=>{let r=t.instanceId!==null;return(0,c.jsx)(`div`,{onClick:r?e=>{Ce(t,e)}:void 0,onKeyDown:r?e=>{we(t,e)}:void 0,role:r?`button`:void 0,style:r?{cursor:`pointer`}:void 0,tabIndex:r?0:void 0,children:(0,c.jsx)(p.default,{appendTips:t.archivedAt?`已封存`:void 0,description:t.body,onBadgeSelect:e=>{Se(t,e)},options:[...re(t)],prependTips:n===0?te[e]:void 0,reference:t.id,severity:ae(t),showBadge:t.status!==`READ`,timeStamp:t.createdAt,title:ie(t),type:`drawer`})},t.id)})},e))]})}),(0,c.jsxs)(f.default,{cancelText:`取消`,confirmText:`送出同意`,loading:q,modalType:`standard`,onCancel:_e,onClose:_e,onConfirm:()=>{ve()},open:z!==null,showModalFooter:!0,showModalHeader:!0,size:`regular`,supportingText:`可以留下同意說明,內容會記錄在簽核歷程;不填也可以直接送出。`,title:`簽核意見`,children:[N?(0,c.jsx)(s.Typography,{color:`text-error`,role:`alert`,variant:`body`,children:N}):null,(0,c.jsx)(a.t,{label:`簽核意見`,name:`notificationApproveComment`,children:(0,c.jsx)(m.default,{autoFocus:!0,onChange:e=>{H(e.target.value)},placeholder:`選填,例如補充核准條件或提醒事項`,rows:4,value:V})})]}),(0,c.jsx)(f.default,{cancelText:`取消`,confirmButtonProps:{disabled:!Y,variant:`destructive-primary`},confirmText:`送出拒絕`,loading:q,modalStatusType:`error`,modalType:`standard`,onCancel:be,onClose:be,onConfirm:()=>{xe()},open:U!==null,showModalFooter:!0,showModalHeader:!0,size:`regular`,supportingText:`拒絕案件時必須留下原因,供發起人與後續追蹤查看。`,title:`拒絕原因`,children:(0,c.jsx)(m.default,{autoFocus:!0,onChange:e=>{K(e.target.value)},placeholder:`請輸入拒絕原因`,rows:4,value:G})})]}):null}function w(e){return e===`SLA_OVERDUE`?`error`:e===`SLA_WARNING`?`warning`:e===`INSTANCE_COMPLETED`?`success`:`info`}function oe(e,t){let n=new Date(e);if(Number.isNaN(n.getTime()))return`earlier`;let r=new Date(t.getFullYear(),t.getMonth(),t.getDate()),i=new Date(n.getFullYear(),n.getMonth(),n.getDate());if(i.getTime()===r.getTime())return`today`;let a=new Date(r);return a.setDate(a.getDate()-1),i.getTime()===a.getTime()?`yesterday`:(t.getTime()-n.getTime())/864e5<=7?`past7Days`:`earlier`}function T(e){return e instanceof Error?e.message:`發生未知錯誤`}function E(e){try{let t=JSON.parse(e.payloadJson);return O(t)&&typeof t.allowReject==`boolean`?t.allowReject:e.allowReject}catch{return e.allowReject}}function D(e){try{let t=JSON.parse(e.payloadJson);return O(t)&&t.hasFillableFields===!0}catch{return!1}}function O(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function k({children:e,locale:r=u.CalendarLocale.ZH_TW,language:i=n.r,publicPaths:a,loginPath:o}){return(0,c.jsx)(u.CalendarConfigProviderMoment,{locale:r,children:(0,c.jsx)(n.t,{language:i,children:(0,c.jsx)(t.t,{publicPaths:a,loginPath:o,children:(0,c.jsx)(y,{children:(0,c.jsxs)(g,{children:[e,(0,c.jsx)(C,{})]})})})})})}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return k}});
|
|
2
|
-
//# sourceMappingURL=providers-D_KAgOOu.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"providers-D_KAgOOu.cjs","names":["createContext","useState","useCallback","useMemo","useContext","createContext","useAuth","useState","useCallback","readUnreadNotificationCount","useMemo","useContext","useRouterAdapter","useBPMRoutes","useAuth","useState","useCallback","listNotifications","markAllNotificationsRead","markNotificationRead","unarchiveNotifications","archiveNotifications","decideTask","useMemo","_Fragment","Drawer","Fragment","NotificationCenter","Modal","Typography","BPMFormField","Textarea","CalendarLocale","DEFAULT_BPM_LANGUAGE","CalendarConfigProviderMoment","BPMLanguageProvider","AuthProvider","require_rolldown_runtime","require_auth_provider","require_language_provider","require_router_adapter","require_routes_config","require_bpm_form_field","react","_mezzanine_ui_react","react_jsx_runtime","_rytass_bpm_core_client_workflow","_mezzanine_ui_react_moment","_mezzanine_ui_react_Drawer","_mezzanine_ui_react_Modal","_mezzanine_ui_react_NotificationCenter","_mezzanine_ui_react_Textarea","NotificationDrawerContext","NotificationDrawerProvider","isOpen","setIsOpen","open","close","toggle","current","value","useNotificationDrawer","NotificationUnreadContext","NotificationUnreadProvider","currentMemberId","member","unreadCount","setUnreadCount","refreshUnreadCount","next","active","useNotificationUnread","TIME_GROUP_ORDER","TIME_GROUP_LABEL","PAGE_SIZE","TOGGLE_ARCHIVED_OPTION_ID","buildNotificationOptions","canReject","readNotificationAllowReject","record","opensToFill","readNotificationHasFillableFields","RESOLVED_TITLE","resolveDisplayTitle","resolveSeverity","toSeverity","NotificationDrawer","router","routes","rows","setRows","totalCount","setTotalCount","page","setPage","loading","setLoading","bulkLoading","setBulkLoading","error","setError","notice","setNotice","filter","setFilter","includeArchived","setIncludeArchived","approveTarget","setApproveTarget","approveComment","setApproveComment","rejectTarget","setRejectTarget","rejectReason","setRejectReason","deciding","setDeciding","trimmedApproveComment","trimmedRejectReason","loadPage","result","nextPage","append","readErrorMessage","handleFilterChange","event","handleMarkAllRead","handleLoadMore","handleMarkRead","handleArchive","label","handleFilterAreaSelect","option","handleOpenInstance","openApproveModal","closeApproveModal","handleApproveConfirm","target","openRejectModal","closeRejectModal","handleRejectConfirm","handleBadgeSelect","action","isCardActivation","card","handleCardActivate","handleCardKeyDown","filteredRows","row","groupedRows","now","buckets","group","accumulator","resolveTimeGroup","items","hasMore","openable","itemIndex","type","notificationDate","nowStartOfDay","notificationStartOfDay","yesterdayStartOfDay","payload","isRecord","Providers","children"],"sources":["../../src/lib/notification-drawer-provider.tsx","../../src/lib/notification-unread-provider.tsx","../../src/components/notification-drawer.tsx","../../src/lib/providers.tsx"],"sourcesContent":["'use client';\n\nimport {\n createContext,\n useCallback,\n useContext,\n useMemo,\n useState,\n type ReactElement,\n type ReactNode,\n} from 'react';\n\ninterface NotificationDrawerContextValue {\n readonly close: () => void;\n readonly isOpen: boolean;\n readonly open: () => void;\n readonly toggle: () => void;\n}\n\nconst NotificationDrawerContext =\n createContext<NotificationDrawerContextValue | null>(null);\n\ninterface NotificationDrawerProviderProps {\n readonly children: ReactNode;\n}\n\n/**\n * Controls the open/closed state of the BPM notification drawer. Wraps\n * children with a context that `<NotificationDrawer />` reads to mount /\n * hide itself, and that the host navigation reads (via\n * `<BPMNotificationBellButton />` or `useNotificationDrawer().open`) to\n * open the drawer when the bell icon is clicked.\n *\n * When used outside this provider, the returned hook is a safe no-op so\n * components don't crash in test or storybook environments.\n */\nexport function NotificationDrawerProvider({\n children,\n}: NotificationDrawerProviderProps): ReactElement {\n const [isOpen, setIsOpen] = useState(false);\n\n const open = useCallback((): void => {\n setIsOpen(true);\n }, []);\n const close = useCallback((): void => {\n setIsOpen(false);\n }, []);\n const toggle = useCallback((): void => {\n setIsOpen((current) => !current);\n }, []);\n\n const value = useMemo<NotificationDrawerContextValue>(\n () => ({ close, isOpen, open, toggle }),\n [close, isOpen, open, toggle],\n );\n\n return (\n <NotificationDrawerContext.Provider value={value}>\n {children}\n </NotificationDrawerContext.Provider>\n );\n}\n\n/**\n * Read the BPM notification drawer's open state and control helpers.\n * Returns a no-op stub when used outside `<NotificationDrawerProvider>`.\n */\nexport function useNotificationDrawer(): NotificationDrawerContextValue {\n const context = useContext(NotificationDrawerContext);\n if (!context) {\n return {\n close: (): void => undefined,\n isOpen: false,\n open: (): void => undefined,\n toggle: (): void => undefined,\n };\n }\n return context;\n}\n","'use client';\n\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useState,\n type ReactElement,\n type ReactNode,\n} from 'react';\nimport { readUnreadNotificationCount } from '@rytass/bpm-core-client/workflow';\nimport { useAuth } from './auth-provider';\n\ninterface NotificationUnreadContextValue {\n readonly refreshUnreadCount: () => Promise<number>;\n readonly unreadCount: number;\n}\n\nconst NotificationUnreadContext =\n createContext<NotificationUnreadContextValue | null>(null);\n\ninterface NotificationUnreadProviderProps {\n readonly children: ReactNode;\n}\n\n/**\n * Polls BPM for the current member's unread notification count via\n * `readUnreadNotificationCount` and exposes it through context for the\n * host navigation (`<BPMNotificationBellButton />` badge or any custom\n * trigger using `useNotificationUnread().unreadCount`) and the BPM\n * `<NotificationDrawer />` (header count). Refresh is triggered on\n * mount and whenever the auth member id changes; consumers can call\n * `refreshUnreadCount()` after acknowledging a notification.\n */\nexport function NotificationUnreadProvider({\n children,\n}: NotificationUnreadProviderProps): ReactElement {\n const { member } = useAuth();\n const currentMemberId = member?.memberId ?? null;\n const [unreadCount, setUnreadCount] = useState(0);\n\n const refreshUnreadCount = useCallback(async (): Promise<number> => {\n if (!currentMemberId) {\n setUnreadCount(0);\n return 0;\n }\n const next = await readUnreadNotificationCount(currentMemberId);\n setUnreadCount(next);\n return next;\n }, [currentMemberId]);\n\n useEffect((): (() => void) => {\n let active = true;\n void (async () => {\n try {\n const next = await refreshUnreadCount();\n if (active) setUnreadCount(next);\n } catch {\n if (active) setUnreadCount(0);\n }\n })();\n return (): void => {\n active = false;\n };\n }, [refreshUnreadCount]);\n\n const value = useMemo<NotificationUnreadContextValue>(\n () => ({ refreshUnreadCount, unreadCount }),\n [refreshUnreadCount, unreadCount],\n );\n\n return (\n <NotificationUnreadContext.Provider value={value}>\n {children}\n </NotificationUnreadContext.Provider>\n );\n}\n\n/**\n * Read the current unread-notification count and a manual refresh helper.\n * Returns a zero/no-op stub when used outside\n * `<NotificationUnreadProvider>`.\n */\nexport function useNotificationUnread(): NotificationUnreadContextValue {\n const context = useContext(NotificationUnreadContext);\n if (!context) {\n return {\n refreshUnreadCount: async (): Promise<number> => 0,\n unreadCount: 0,\n };\n }\n return context;\n}\n","'use client';\n\nimport {\n Fragment,\n useCallback,\n useEffect,\n useMemo,\n useState,\n type ChangeEvent,\n type KeyboardEvent as ReactKeyboardEvent,\n type MouseEvent as ReactMouseEvent,\n type ReactElement,\n} from 'react';\nimport Drawer from '@mezzanine-ui/react/Drawer';\nimport Modal from '@mezzanine-ui/react/Modal';\nimport NotificationCenter from '@mezzanine-ui/react/NotificationCenter';\nimport Textarea from '@mezzanine-ui/react/Textarea';\nimport { Typography } from '@mezzanine-ui/react';\nimport type { NotificationSeverity } from '@mezzanine-ui/core/notification-center';\nimport type { DropdownOption } from '@mezzanine-ui/core/dropdown/dropdown';\nimport {\n archiveNotifications,\n decideTask,\n listNotifications,\n markAllNotificationsRead,\n markNotificationRead,\n unarchiveNotifications,\n type NotificationRecord,\n type NotificationResolution,\n type NotificationType,\n} from '@rytass/bpm-core-client/workflow';\nimport { useAuth } from '../lib/auth-provider';\nimport { useNotificationDrawer } from '../lib/notification-drawer-provider';\nimport { useNotificationUnread } from '../lib/notification-unread-provider';\nimport { useRouterAdapter } from '../lib/router-adapter';\nimport { useBPMRoutes } from '../lib/routes-config';\nimport { BPMFormField } from './bpm-form-field';\n\ntype FilterValue = 'all' | 'read' | 'unread';\n\ntype TimeGroup = 'today' | 'yesterday' | 'past7Days' | 'earlier';\n\nconst TIME_GROUP_ORDER: readonly TimeGroup[] = [\n 'today',\n 'yesterday',\n 'past7Days',\n 'earlier',\n];\n\nconst TIME_GROUP_LABEL: Readonly<Record<TimeGroup, string>> = {\n earlier: '更早',\n past7Days: '過去七天',\n today: '今天',\n yesterday: '昨天',\n};\n\nconst PAGE_SIZE = 50;\n\n/** Identifiers for the per-notification `...` dropdown menu entries. */\ntype NotificationAction =\n | 'approve'\n | 'archive'\n | 'reject'\n | 'unarchive'\n | 'view'\n | 'read';\n\n/** Identifier for the filter-bar dropdown entry toggling the archived view. */\nconst TOGGLE_ARCHIVED_OPTION_ID = 'toggleArchived';\n\n/**\n * Build the `...` dropdown options for one notification. Approve / reject are\n * offered only while the server still reports the notification as `actionable`\n * (an unresolved task assignment) — once the task is decided / cancelled the\n * backend flips `actionable` to false, so a stale \"同意\" can never appear.\n * A task that fills in form fields (`hasFillableFields`) cannot be approved\n * from here — the fill has to be entered on the case page — so its \"同意\"\n * becomes \"開啟案件\".\n * \"查看案件\" needs an `instanceId`; \"標為已讀\" only shows while unread.\n * Archiving is independent of read state, so the entry flips between\n * \"封存\" / \"取消封存\" for every notification.\n */\nfunction buildNotificationOptions(\n record: NotificationRecord,\n): readonly DropdownOption[] {\n const canReject = readNotificationAllowReject(record) !== false;\n const opensToFill =\n record.actionable &&\n Boolean(record.instanceId) &&\n readNotificationHasFillableFields(record);\n\n return [\n ...(record.actionable\n ? ([\n opensToFill\n ? { id: 'view', name: '開啟案件' }\n : { id: 'approve', name: '同意' },\n ...(canReject ? [{ id: 'reject', name: '拒絕' }] : []),\n ] satisfies DropdownOption[])\n : []),\n ...(record.instanceId && !opensToFill\n ? ([{ id: 'view', name: '查看案件' }] satisfies DropdownOption[])\n : []),\n ...(record.status !== 'READ'\n ? ([{ id: 'read', name: '標為已讀' }] satisfies DropdownOption[])\n : []),\n record.archivedAt\n ? { id: 'unarchive', name: '取消封存' }\n : { id: 'archive', name: '封存' },\n ];\n}\n\n/**\n * Title shown for a resolved task-assignment notification, replacing the\n * stored \"新的待簽任務\" wording so a decided card no longer reads as pending.\n * The stored `body` is kept as historical context (which case / node).\n */\nconst RESOLVED_TITLE: Readonly<Record<NotificationResolution, string>> = {\n APPROVED: '簽核任務已同意',\n REJECTED: '簽核任務已拒絕',\n RETURNED: '簽核任務已退回',\n SUPERSEDED: '簽核任務已結束',\n TRANSFERRED: '簽核任務已轉派',\n};\n\nfunction resolveDisplayTitle(record: NotificationRecord): string {\n return record.resolution ? RESOLVED_TITLE[record.resolution] : record.title;\n}\n\n/**\n * Severity (icon colour) for a notification. Once resolved, it reflects the\n * outcome — green for approved, red for rejected, neutral otherwise — instead\n * of the original by-type colour.\n */\nfunction resolveSeverity(record: NotificationRecord): NotificationSeverity {\n if (record.resolution === 'APPROVED') return 'success';\n if (record.resolution === 'REJECTED') return 'error';\n if (record.resolution) return 'info';\n return toSeverity(record.type);\n}\n\n/**\n * Right-side notification drawer mounted at the root by `<Providers>`.\n * Opens / closes via `useNotificationDrawer()`, polls\n * `listNotifications()` for the current member, supports filter\n * (`all` / `read` / `unread`), per-row mark-read, per-row archive / unarchive,\n * bulk mark-all-read, and load-more pagination. Archived notifications are\n * hidden until the filter-bar menu turns \"顯示已封存\" on. Clicking a row with an\n * `instanceId` navigates to `/instances/<id>` via the host's router adapter.\n */\nexport function NotificationDrawer(): ReactElement | null {\n const router = useRouterAdapter();\n const routes = useBPMRoutes();\n const { member } = useAuth();\n const { close, isOpen } = useNotificationDrawer();\n const { refreshUnreadCount } = useNotificationUnread();\n const currentMemberId = member?.memberId ?? null;\n const [rows, setRows] = useState<readonly NotificationRecord[]>([]);\n const [totalCount, setTotalCount] = useState(0);\n const [page, setPage] = useState(1);\n const [loading, setLoading] = useState(false);\n const [bulkLoading, setBulkLoading] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const [notice, setNotice] = useState<string | null>(null);\n const [filter, setFilter] = useState<FilterValue>('all');\n const [includeArchived, setIncludeArchived] = useState(false);\n const [approveTarget, setApproveTarget] = useState<NotificationRecord | null>(\n null,\n );\n const [approveComment, setApproveComment] = useState('');\n const [rejectTarget, setRejectTarget] = useState<NotificationRecord | null>(\n null,\n );\n const [rejectReason, setRejectReason] = useState('');\n const [deciding, setDeciding] = useState(false);\n\n const trimmedApproveComment = approveComment.trim();\n const trimmedRejectReason = rejectReason.trim();\n\n const loadPage = useCallback(\n async (nextPage: number, append: boolean): Promise<boolean> => {\n if (!currentMemberId) return false;\n setLoading(true);\n setError(null);\n try {\n const result = await listNotifications({\n includeArchived,\n includeRead: true,\n page: nextPage,\n pageSize: PAGE_SIZE,\n recipientMemberId: currentMemberId,\n });\n setRows((current): readonly NotificationRecord[] =>\n append ? [...current, ...result.notifications] : result.notifications,\n );\n setTotalCount(result.totalCount);\n setPage(nextPage);\n await refreshUnreadCount();\n return true;\n } catch (e: unknown) {\n setError(readErrorMessage(e));\n return false;\n } finally {\n setLoading(false);\n }\n },\n [currentMemberId, includeArchived, refreshUnreadCount],\n );\n\n useEffect((): void => {\n if (!isOpen || !currentMemberId) return;\n setError(null);\n setNotice(null);\n void loadPage(1, false);\n }, [isOpen, currentMemberId, loadPage]);\n\n const handleFilterChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>): void => {\n const next = event.target.value;\n if (next === 'all' || next === 'read' || next === 'unread') setFilter(next);\n },\n [],\n );\n\n const handleMarkAllRead = useCallback(async (): Promise<void> => {\n if (!currentMemberId || bulkLoading) return;\n setBulkLoading(true);\n setError(null);\n try {\n await markAllNotificationsRead({ recipientMemberId: currentMemberId });\n await loadPage(1, false);\n } catch (e: unknown) {\n setError(readErrorMessage(e));\n } finally {\n setBulkLoading(false);\n }\n }, [bulkLoading, currentMemberId, loadPage]);\n\n const handleLoadMore = useCallback((): void => {\n if (loading) return;\n void loadPage(page + 1, true);\n }, [loading, loadPage, page]);\n\n const handleMarkRead = useCallback(\n async (id: string): Promise<void> => {\n if (!currentMemberId) return;\n try {\n await markNotificationRead({ id, readerMemberId: currentMemberId });\n await loadPage(1, false);\n } catch (e: unknown) {\n setError(readErrorMessage(e));\n }\n },\n [currentMemberId, loadPage],\n );\n\n const handleArchive = useCallback(\n async (record: NotificationRecord): Promise<void> => {\n if (!currentMemberId) return;\n setError(null);\n setNotice(null);\n try {\n // Name the notification the way the row does — `title` is the raw\n // stored title, which can differ from the rendered one.\n const label = resolveDisplayTitle(record);\n\n if (record.archivedAt) {\n await unarchiveNotifications({ ids: [record.id] });\n setNotice(`已將「${label}」移出封存。`);\n } else {\n await archiveNotifications({ ids: [record.id] });\n setNotice(`已封存「${label}」。`);\n }\n await loadPage(1, false);\n } catch (e: unknown) {\n setError(readErrorMessage(e));\n }\n },\n [currentMemberId, loadPage],\n );\n\n const handleFilterAreaSelect = useCallback((option: DropdownOption): void => {\n if (option.id !== TOGGLE_ARCHIVED_OPTION_ID) return;\n setNotice(null);\n setIncludeArchived((current): boolean => !current);\n }, []);\n\n const handleOpenInstance = useCallback(\n async (record: NotificationRecord): Promise<void> => {\n if (!record.instanceId || !currentMemberId) return;\n try {\n if (record.status !== 'READ') {\n await markNotificationRead({\n id: record.id,\n readerMemberId: currentMemberId,\n });\n await refreshUnreadCount();\n }\n close();\n router.push(routes.caseDetail(record.instanceId));\n } catch (e: unknown) {\n setError(readErrorMessage(e));\n }\n },\n [close, currentMemberId, refreshUnreadCount, router, routes],\n );\n\n const openApproveModal = useCallback((record: NotificationRecord): void => {\n setError(null);\n setApproveTarget(record);\n setApproveComment('');\n }, []);\n\n const closeApproveModal = useCallback((): void => {\n if (deciding) return;\n setApproveTarget(null);\n setApproveComment('');\n }, [deciding]);\n\n const handleApproveConfirm = useCallback(async (): Promise<void> => {\n const target = approveTarget;\n if (!target?.taskId || !currentMemberId || deciding) return;\n setDeciding(true);\n setError(null);\n setNotice(null);\n try {\n await decideTask({\n action: 'APPROVED',\n comment: trimmedApproveComment || null,\n decidedByMemberId: currentMemberId,\n taskId: target.taskId,\n });\n const refreshed = await loadPage(1, false);\n if (!refreshed) return;\n setApproveTarget(null);\n setApproveComment('');\n setNotice(`已同意「${target.title}」。`);\n } catch (e: unknown) {\n setError(readErrorMessage(e));\n } finally {\n setDeciding(false);\n }\n }, [\n approveTarget,\n currentMemberId,\n deciding,\n loadPage,\n trimmedApproveComment,\n ]);\n\n const openRejectModal = useCallback((record: NotificationRecord): void => {\n setRejectTarget(record);\n setRejectReason('');\n }, []);\n\n const closeRejectModal = useCallback((): void => {\n setRejectTarget(null);\n setRejectReason('');\n }, []);\n\n const handleRejectConfirm = useCallback(async (): Promise<void> => {\n const target = rejectTarget;\n if (!target?.taskId || !currentMemberId || !trimmedRejectReason || deciding)\n return;\n setDeciding(true);\n setError(null);\n setNotice(null);\n try {\n await decideTask({\n action: 'REJECTED',\n comment: trimmedRejectReason,\n decidedByMemberId: currentMemberId,\n taskId: target.taskId,\n });\n setRejectTarget(null);\n setRejectReason('');\n setNotice(`已拒絕「${target.title}」。`);\n await loadPage(1, false);\n } catch (e: unknown) {\n setError(readErrorMessage(e));\n } finally {\n setDeciding(false);\n }\n }, [currentMemberId, deciding, loadPage, rejectTarget, trimmedRejectReason]);\n\n const handleBadgeSelect = useCallback(\n (record: NotificationRecord, option: DropdownOption): void => {\n const action = option.id as NotificationAction;\n if (action === 'approve') openApproveModal(record);\n else if (action === 'reject') openRejectModal(record);\n else if (action === 'view') void handleOpenInstance(record);\n else if (action === 'read') void handleMarkRead(record.id);\n else if (action === 'archive' || action === 'unarchive')\n void handleArchive(record);\n },\n [\n handleArchive,\n handleMarkRead,\n handleOpenInstance,\n openApproveModal,\n openRejectModal,\n ],\n );\n\n /**\n * Whether an event that reached the card wrapper actually happened inside the\n * card, and not on one of its action controls.\n *\n * Two escape hatches are needed. The `...` menu button (and its `<svg>` icon —\n * hence the `Element` check, SVG nodes are not HTMLElements) sits inside the\n * card and must open the dropdown rather than navigate. The dropdown itself\n * renders into a portal, and React replays events along the component tree\n * rather than the DOM tree, so picking \"封存\" also reaches this handler even\n * though the `<li role=\"option\">` lives outside the card's DOM — and it is not\n * a `<button>`, so the first guard alone misses it.\n */\n const isCardActivation = useCallback(\n (target: EventTarget | null, card: HTMLDivElement): boolean => {\n if (!(target instanceof Node) || !card.contains(target)) return false;\n\n return !(target instanceof Element && target.closest('button'));\n },\n [],\n );\n\n const handleCardActivate = useCallback(\n (record: NotificationRecord, event: ReactMouseEvent<HTMLDivElement>): void => {\n if (!isCardActivation(event.target, event.currentTarget)) return;\n void handleOpenInstance(record);\n },\n [handleOpenInstance, isCardActivation],\n );\n\n const handleCardKeyDown = useCallback(\n (\n record: NotificationRecord,\n event: ReactKeyboardEvent<HTMLDivElement>,\n ): void => {\n if (event.key !== 'Enter' && event.key !== ' ') return;\n if (!isCardActivation(event.target, event.currentTarget)) return;\n event.preventDefault();\n void handleOpenInstance(record);\n },\n [handleOpenInstance, isCardActivation],\n );\n\n const filteredRows = useMemo(\n (): readonly NotificationRecord[] =>\n rows.filter((row): boolean => {\n if (filter === 'all') return true;\n if (filter === 'read') return row.status === 'READ';\n return row.status !== 'READ';\n }),\n [filter, rows],\n );\n\n const groupedRows = useMemo(\n (): ReadonlyArray<readonly [TimeGroup, readonly NotificationRecord[]]> => {\n const now = new Date();\n const buckets = TIME_GROUP_ORDER.reduce<\n Record<TimeGroup, NotificationRecord[]>\n >(\n (accumulator, group) => {\n accumulator[group] = [];\n return accumulator;\n },\n { earlier: [], past7Days: [], today: [], yesterday: [] },\n );\n filteredRows.forEach((row): void => {\n buckets[resolveTimeGroup(row.createdAt, now)].push(row);\n });\n return TIME_GROUP_ORDER.map(\n (group) => [group, buckets[group]] as const,\n ).filter(([, items]) => items.length > 0);\n },\n [filteredRows],\n );\n\n const hasMore = rows.length < totalCount;\n\n if (!currentMemberId) return null;\n\n return (\n <>\n <Drawer\n bottomGhostActionDisabled={bulkLoading || loading}\n bottomGhostActionLoading={bulkLoading}\n bottomGhostActionText=\"全部標為已讀\"\n bottomOnGhostActionClick={(): void => {\n void handleMarkAllRead();\n }}\n bottomOnPrimaryActionClick={(): void => {\n handleLoadMore();\n }}\n bottomPrimaryActionDisabled={!hasMore || loading}\n bottomPrimaryActionLoading={loading && hasMore}\n bottomPrimaryActionText={hasMore ? '載入更多' : '已顯示全部'}\n contentKey={`${filter}:${includeArchived}:${rows.length}`}\n filterAreaAllRadioLabel=\"全部\"\n filterAreaOnRadioChange={handleFilterChange}\n filterAreaOnSelect={handleFilterAreaSelect}\n filterAreaOptions={[\n {\n id: TOGGLE_ARCHIVED_OPTION_ID,\n name: includeArchived ? '隱藏已封存' : '顯示已封存',\n },\n ]}\n filterAreaReadRadioLabel=\"已讀\"\n filterAreaShow\n filterAreaUnreadRadioLabel=\"未讀\"\n filterAreaValue={filter}\n headerTitle=\"通知中心\"\n isBottomDisplay\n isHeaderDisplay\n onClose={close}\n open={isOpen}\n size=\"medium\"\n >\n <div role=\"list\">\n {error ? (\n <p\n role=\"alert\"\n style={{\n color: 'var(--mzn-color-text-error, #d92d20)',\n padding: '12px 16px',\n }}\n >\n {error}\n </p>\n ) : null}\n {notice ? (\n <p\n role=\"status\"\n style={{\n color: 'var(--mzn-color-text-success, #079455)',\n padding: '12px 16px',\n }}\n >\n {notice}\n </p>\n ) : null}\n {groupedRows.length === 0 ? (\n <p\n style={{\n color: 'var(--mzn-color-text-secondary, #6b7280)',\n padding: '24px 16px',\n textAlign: 'center',\n }}\n >\n {loading ? '載入中…' : '目前沒有通知'}\n </p>\n ) : null}\n {groupedRows.map(([group, items]) => (\n <Fragment key={group}>\n {items.map((record, itemIndex) => {\n const openable = record.instanceId !== null;\n\n return (\n <div\n key={record.id}\n onClick={\n openable\n ? (event: ReactMouseEvent<HTMLDivElement>): void => {\n handleCardActivate(record, event);\n }\n : undefined\n }\n onKeyDown={\n openable\n ? (event: ReactKeyboardEvent<HTMLDivElement>): void => {\n handleCardKeyDown(record, event);\n }\n : undefined\n }\n role={openable ? 'button' : undefined}\n style={openable ? { cursor: 'pointer' } : undefined}\n tabIndex={openable ? 0 : undefined}\n >\n <NotificationCenter\n appendTips={record.archivedAt ? '已封存' : undefined}\n description={record.body}\n onBadgeSelect={(option: DropdownOption): void => {\n handleBadgeSelect(record, option);\n }}\n options={[...buildNotificationOptions(record)]}\n prependTips={\n itemIndex === 0 ? TIME_GROUP_LABEL[group] : undefined\n }\n reference={record.id}\n severity={resolveSeverity(record)}\n showBadge={record.status !== 'READ'}\n timeStamp={record.createdAt}\n title={resolveDisplayTitle(record)}\n type=\"drawer\"\n />\n </div>\n );\n })}\n </Fragment>\n ))}\n </div>\n </Drawer>\n <Modal\n cancelText=\"取消\"\n confirmText=\"送出同意\"\n loading={deciding}\n modalType=\"standard\"\n onCancel={closeApproveModal}\n onClose={closeApproveModal}\n onConfirm={(): void => {\n void handleApproveConfirm();\n }}\n open={approveTarget !== null}\n showModalFooter\n showModalHeader\n size=\"regular\"\n supportingText=\"可以留下同意說明,內容會記錄在簽核歷程;不填也可以直接送出。\"\n title=\"簽核意見\"\n >\n {error ? (\n <Typography color=\"text-error\" role=\"alert\" variant=\"body\">\n {error}\n </Typography>\n ) : null}\n <BPMFormField label=\"簽核意見\" name=\"notificationApproveComment\">\n <Textarea\n autoFocus\n onChange={(event: ChangeEvent<HTMLTextAreaElement>): void => {\n setApproveComment(event.target.value);\n }}\n placeholder=\"選填,例如補充核准條件或提醒事項\"\n rows={4}\n value={approveComment}\n />\n </BPMFormField>\n </Modal>\n <Modal\n cancelText=\"取消\"\n confirmButtonProps={{\n disabled: !trimmedRejectReason,\n variant: 'destructive-primary',\n }}\n confirmText=\"送出拒絕\"\n loading={deciding}\n modalStatusType=\"error\"\n modalType=\"standard\"\n onCancel={closeRejectModal}\n onClose={closeRejectModal}\n onConfirm={(): void => {\n void handleRejectConfirm();\n }}\n open={rejectTarget !== null}\n showModalFooter\n showModalHeader\n size=\"regular\"\n supportingText=\"拒絕案件時必須留下原因,供發起人與後續追蹤查看。\"\n title=\"拒絕原因\"\n >\n <Textarea\n autoFocus\n onChange={(event: ChangeEvent<HTMLTextAreaElement>): void => {\n setRejectReason(event.target.value);\n }}\n placeholder=\"請輸入拒絕原因\"\n rows={4}\n value={rejectReason}\n />\n </Modal>\n </>\n );\n}\n\nfunction toSeverity(type: NotificationType): NotificationSeverity {\n if (type === 'SLA_OVERDUE') return 'error';\n if (type === 'SLA_WARNING') return 'warning';\n if (type === 'INSTANCE_COMPLETED') return 'success';\n return 'info';\n}\n\nfunction resolveTimeGroup(value: string, now: Date): TimeGroup {\n const notificationDate = new Date(value);\n if (Number.isNaN(notificationDate.getTime())) return 'earlier';\n const nowStartOfDay = new Date(now.getFullYear(), now.getMonth(), now.getDate());\n const notificationStartOfDay = new Date(\n notificationDate.getFullYear(),\n notificationDate.getMonth(),\n notificationDate.getDate(),\n );\n if (notificationStartOfDay.getTime() === nowStartOfDay.getTime()) return 'today';\n const yesterdayStartOfDay = new Date(nowStartOfDay);\n yesterdayStartOfDay.setDate(yesterdayStartOfDay.getDate() - 1);\n if (notificationStartOfDay.getTime() === yesterdayStartOfDay.getTime())\n return 'yesterday';\n const diffInDays =\n (now.getTime() - notificationDate.getTime()) / (1000 * 60 * 60 * 24);\n if (diffInDays <= 7) return 'past7Days';\n return 'earlier';\n}\n\nfunction readErrorMessage(error: unknown): string {\n return error instanceof Error ? error.message : '發生未知錯誤';\n}\n\nfunction readNotificationAllowReject(\n record: NotificationRecord,\n): boolean | null {\n try {\n const payload: unknown = JSON.parse(record.payloadJson);\n\n if (isRecord(payload) && typeof payload.allowReject === 'boolean') {\n return payload.allowReject;\n }\n\n return record.allowReject;\n } catch {\n return record.allowReject;\n }\n}\n\n/**\n * `TASK_ASSIGNED` / `TASK_TRANSFERRED` payloads carry `hasFillableFields`;\n * older notifications do not, which reads as `false`.\n */\nfunction readNotificationHasFillableFields(\n record: NotificationRecord,\n): boolean {\n try {\n const payload: unknown = JSON.parse(record.payloadJson);\n\n return isRecord(payload) && payload.hasFillableFields === true;\n } catch {\n return false;\n }\n}\n\nfunction isRecord(value: unknown): value is Readonly<Record<string, unknown>> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n","'use client';\n\nimport type { ReactElement, ReactNode } from 'react';\nimport {\n CalendarConfigProviderMoment,\n CalendarLocale,\n} from '@mezzanine-ui/react/moment';\nimport { AuthProvider } from './auth-provider';\nimport {\n BPMLanguageProvider,\n DEFAULT_BPM_LANGUAGE,\n type BPMLanguage,\n} from './language-provider';\nimport { NotificationDrawer } from '../components/notification-drawer';\nimport { NotificationDrawerProvider } from './notification-drawer-provider';\nimport { NotificationUnreadProvider } from './notification-unread-provider';\n\ninterface ProvidersProps {\n readonly children: ReactNode;\n /** Override Mezzanine calendar locale. Defaults to `CalendarLocale.ZH_TW`. */\n readonly locale?: CalendarLocale;\n /**\n * Language BPM views write their messages in, such as publish-lint errors.\n * Defaults to `'zh-TW'`. Pass the user's choice as state to let them switch.\n * Independent of `locale`, which only formats calendar dates.\n */\n readonly language?: BPMLanguage;\n /**\n * Public paths that should not trigger redirect to `/login` when there\n * is no session. Forwarded to `<AuthProvider>`. Defaults to `['/login']`.\n */\n readonly publicPaths?: readonly string[];\n /** Where to send unauthenticated users. Defaults to `'/login'`. */\n readonly loginPath?: string;\n}\n\n/**\n * One-stop BPM admin provider stack. Wires:\n *\n * - Mezzanine UI calendar locale (moment-based, `ZH_TW` by default)\n * - `<BPMLanguageProvider>` (message language, `'zh-TW'` by default)\n * - `<AuthProvider>` (BPM session via REST `/auth/*`)\n * - `<NotificationUnreadProvider>` (polls unread count)\n * - `<NotificationDrawerProvider>` (controls drawer open/close state)\n * - `<NotificationDrawer />` mounted at the root so the host navigation\n * bell (`<BPMNotificationBellButton />` or any custom trigger calling\n * `useNotificationDrawer().open`) can open it.\n *\n * Consumer hosts wrap this **inside** a `<RouterAdapterProvider>` (provided\n * by the `pages/*` subpath shims when consuming via Next.js, or wired by\n * hand for other frameworks).\n */\nexport function Providers({\n children,\n locale = CalendarLocale.ZH_TW,\n language = DEFAULT_BPM_LANGUAGE,\n publicPaths,\n loginPath,\n}: ProvidersProps): ReactElement {\n return (\n <CalendarConfigProviderMoment locale={locale}>\n <BPMLanguageProvider language={language}>\n <AuthProvider publicPaths={publicPaths} loginPath={loginPath}>\n <NotificationUnreadProvider>\n <NotificationDrawerProvider>\n {children}\n <NotificationDrawer />\n </NotificationDrawerProvider>\n </NotificationUnreadProvider>\n </AuthProvider>\n </BPMLanguageProvider>\n </CalendarConfigProviderMoment>\n );\n}\n"],"mappings":"A,0qBAmBA,IAAMoD,GAAA,EACJpD,EAAAA,cAAAA,CAAqD,IAAI,EAgB3D,SAAgBqD,EAA2B,CACzC,YACgD,CAChD,GAAM,CAACC,EAAQC,IAAA,EAAatD,EAAAA,SAAAA,CAAS,EAAK,EAEpCuD,GAAA,EAAOtD,EAAAA,YAAAA,KAAwB,CACnCqD,EAAU,EAAI,CAChB,EAAG,CAAC,CAAC,EACCE,GAAA,EAAQvD,EAAAA,YAAAA,KAAwB,CACpCqD,EAAU,EAAK,CACjB,EAAG,CAAC,CAAC,EACCG,GAAA,EAASxD,EAAAA,YAAAA,KAAwB,CACrCqD,EAAW,GAAY,CAACI,CAAO,CACjC,EAAG,CAAC,CAAC,EAECC,GAAA,EAAQzD,EAAAA,QAAAA,MACL,CAAE,QAAO,SAAQ,OAAM,QAAO,GACrC,CAACsD,EAAOH,EAAQE,EAAME,CAAM,CAC9B,EAEA,OACE,EAAAb,EAAA,IAAA,CAACO,EAA0B,SAA3B,CAA2C,QACxC,UACiC,CAAA,CAExC,CAMA,SAAgBS,GAAwD,CAUtE,OATM,EAAUzD,EAAAA,WAAAA,CAAWgD,CACtB,GACI,CACL,UAAmB,IAAA,GACnB,OAAQ,GACR,SAAkB,IAAA,GAClB,WAAoB,IAAA,EACtB,CAGJ,CC1DA,IAAMU,GAAA,EACJzD,EAAAA,cAAAA,CAAqD,IAAI,EAe3D,SAAgB0D,EAA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