@rytass/bpm-core-react 0.18.1 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/dist/chunks/{FormBuilderView-vQfVc08Z.js → FormBuilderView-CFRiw04B.js} +563 -475
  3. package/dist/chunks/FormBuilderView-CFRiw04B.js.map +1 -0
  4. package/dist/chunks/FormBuilderView-CpUgbSbt.cjs +3 -0
  5. package/dist/chunks/FormBuilderView-CpUgbSbt.cjs.map +1 -0
  6. package/dist/chunks/FormRendererView-GfbVWEGa.js +1321 -0
  7. package/dist/chunks/FormRendererView-GfbVWEGa.js.map +1 -0
  8. package/dist/chunks/FormRendererView-lYSaR8CQ.cjs +6 -0
  9. package/dist/chunks/FormRendererView-lYSaR8CQ.cjs.map +1 -0
  10. package/dist/chunks/{compose-DtfX8DQ9.cjs → compose-Bb5bUVFd.cjs} +2 -2
  11. package/dist/chunks/{compose-DtfX8DQ9.cjs.map → compose-Bb5bUVFd.cjs.map} +1 -1
  12. package/dist/chunks/{compose-D9ipJpF_.js → compose-egQlRjuZ.js} +5 -4
  13. package/dist/chunks/{compose-D9ipJpF_.js.map → compose-egQlRjuZ.js.map} +1 -1
  14. package/dist/chunks/{delegations-BfhCDz5e.js → delegations-9-yvWWws.js} +3 -2
  15. package/dist/chunks/delegations-9-yvWWws.js.map +1 -0
  16. package/dist/chunks/delegations-CVmtpkRn.cjs +2 -0
  17. package/dist/chunks/delegations-CVmtpkRn.cjs.map +1 -0
  18. package/dist/chunks/delegations-CrfjsH94.cjs +2 -0
  19. package/dist/chunks/delegations-CrfjsH94.cjs.map +1 -0
  20. package/dist/chunks/{delegations-DBh5TT6G.js → delegations-CxnNvTCc.js} +3 -2
  21. package/dist/chunks/delegations-CxnNvTCc.js.map +1 -0
  22. package/dist/chunks/designer-CX9bhYJS.cjs +69 -0
  23. package/dist/chunks/designer-CX9bhYJS.cjs.map +1 -0
  24. package/dist/chunks/{designer-ubnZbP-A.js → designer-CZDlQ9Nf.js} +2341 -1584
  25. package/dist/chunks/designer-CZDlQ9Nf.js.map +1 -0
  26. package/dist/chunks/{detail-C6XKZjlF.js → detail-ByZV1XaI.js} +853 -840
  27. package/dist/chunks/detail-ByZV1XaI.js.map +1 -0
  28. package/dist/chunks/detail-ChseSF55.cjs +5 -0
  29. package/dist/chunks/detail-ChseSF55.cjs.map +1 -0
  30. package/dist/chunks/{approver-filled-form-B4zPg9kz.cjs → instance-error-message-DTARGbGo.cjs} +2 -2
  31. package/dist/chunks/instance-error-message-DTARGbGo.cjs.map +1 -0
  32. package/dist/chunks/{approver-filled-form-Bgazhbvd.js → instance-error-message-q6gy5evy.js} +44 -36
  33. package/dist/chunks/instance-error-message-q6gy5evy.js.map +1 -0
  34. package/dist/chunks/workflow-chat-prompt-B4wCFKPB.js +25 -0
  35. package/dist/chunks/workflow-chat-prompt-B4wCFKPB.js.map +1 -0
  36. package/dist/chunks/workflow-chat-prompt-B803qVdt.cjs +27 -0
  37. package/dist/chunks/workflow-chat-prompt-B803qVdt.cjs.map +1 -0
  38. package/dist/next/workflow-chat-route.cjs +8 -19
  39. package/dist/next/workflow-chat-route.cjs.map +1 -1
  40. package/dist/next/workflow-chat-route.d.cts +92 -4
  41. package/dist/next/workflow-chat-route.d.ts +92 -4
  42. package/dist/next/workflow-chat-route.js +127 -19
  43. package/dist/next/workflow-chat-route.js.map +1 -1
  44. package/dist/pages/admin/delegations/index.cjs +1 -1
  45. package/dist/pages/admin/delegations/index.js +1 -1
  46. package/dist/pages/delegations/index.cjs +1 -1
  47. package/dist/pages/delegations/index.js +1 -1
  48. package/dist/pages/instances/detail/index.cjs +1 -1
  49. package/dist/pages/instances/detail/index.js +1 -1
  50. package/dist/pages/templates/compose/index.cjs +1 -1
  51. package/dist/pages/templates/compose/index.js +1 -1
  52. package/dist/pages/templates/designer/index.cjs +1 -1
  53. package/dist/pages/templates/designer/index.js +1 -1
  54. package/dist/views/admin/delegations/index.cjs +1 -1
  55. package/dist/views/admin/delegations/index.js +1 -1
  56. package/dist/views/admin/index.cjs +1 -1
  57. package/dist/views/admin/index.js +1 -1
  58. package/dist/views/delegations/index.cjs +1 -1
  59. package/dist/views/delegations/index.js +1 -1
  60. package/dist/views/forms/builder/index.cjs +1 -1
  61. package/dist/views/forms/builder/index.js +1 -1
  62. package/dist/views/forms/renderer/FormRendererView.d.cts +25 -2
  63. package/dist/views/forms/renderer/FormRendererView.d.ts +25 -2
  64. package/dist/views/forms/renderer/file-upload-field.d.cts +84 -0
  65. package/dist/views/forms/renderer/file-upload-field.d.ts +84 -0
  66. package/dist/views/forms/renderer/form-data-source-field.d.cts +9 -1
  67. package/dist/views/forms/renderer/form-data-source-field.d.ts +9 -1
  68. package/dist/views/forms/renderer/form-value-readers.d.cts +7 -0
  69. package/dist/views/forms/renderer/form-value-readers.d.ts +7 -0
  70. package/dist/views/forms/renderer/index.cjs +1 -1
  71. package/dist/views/forms/renderer/index.d.cts +1 -0
  72. package/dist/views/forms/renderer/index.d.ts +1 -0
  73. package/dist/views/forms/renderer/index.js +1 -1
  74. package/dist/views/instances/detail/index.cjs +1 -1
  75. package/dist/views/instances/detail/index.js +1 -1
  76. package/dist/views/instances/detail/sections/InstanceFormSection.d.cts +20 -3
  77. package/dist/views/instances/detail/sections/InstanceFormSection.d.ts +20 -3
  78. package/dist/views/instances/detail/sections/shared.d.cts +1 -2
  79. package/dist/views/instances/detail/sections/shared.d.ts +1 -2
  80. package/dist/views/instances/instance-error-message.d.cts +5 -0
  81. package/dist/views/instances/instance-error-message.d.ts +5 -0
  82. package/dist/views/instances/new/index.cjs +1 -1
  83. package/dist/views/instances/new/index.cjs.map +1 -1
  84. package/dist/views/instances/new/index.js +79 -76
  85. package/dist/views/instances/new/index.js.map +1 -1
  86. package/dist/views/templates/compose/index.cjs +1 -1
  87. package/dist/views/templates/compose/index.js +1 -1
  88. package/dist/views/templates/designer/designer-version-labels.d.cts +7 -0
  89. package/dist/views/templates/designer/designer-version-labels.d.ts +7 -0
  90. package/dist/views/templates/designer/expression/DialectUpgradeModal.d.cts +25 -0
  91. package/dist/views/templates/designer/expression/DialectUpgradeModal.d.ts +25 -0
  92. package/dist/views/templates/designer/expression/ExpressionField.d.cts +79 -0
  93. package/dist/views/templates/designer/expression/ExpressionField.d.ts +79 -0
  94. package/dist/views/templates/designer/expression/use-workflow-expression-references.d.cts +22 -0
  95. package/dist/views/templates/designer/expression/use-workflow-expression-references.d.ts +22 -0
  96. package/dist/views/templates/designer/expression/workflow-expression-edits.d.cts +58 -0
  97. package/dist/views/templates/designer/expression/workflow-expression-edits.d.ts +58 -0
  98. package/dist/views/templates/designer/expression/workflow-expression-tools.d.cts +14 -0
  99. package/dist/views/templates/designer/expression/workflow-expression-tools.d.ts +14 -0
  100. package/dist/views/templates/designer/field-access-matrix/FieldAccessMatrixDrawer.d.cts +7 -1
  101. package/dist/views/templates/designer/field-access-matrix/FieldAccessMatrixDrawer.d.ts +7 -1
  102. package/dist/views/templates/designer/index.cjs +1 -1
  103. package/dist/views/templates/designer/index.js +1 -1
  104. package/dist/views/templates/designer/notify-webhook-designer.d.cts +8 -0
  105. package/dist/views/templates/designer/notify-webhook-designer.d.ts +8 -0
  106. package/dist/views/templates/designer/use-workflow-designer-controller.d.cts +8 -2
  107. package/dist/views/templates/designer/use-workflow-designer-controller.d.ts +8 -2
  108. package/dist/views/templates/designer/workflow-chat-prompt.d.cts +18 -0
  109. package/dist/views/templates/designer/workflow-chat-prompt.d.ts +18 -0
  110. package/package.json +3 -3
  111. package/dist/chunks/FormBuilderView-CHaAQL5v.cjs +0 -3
  112. package/dist/chunks/FormBuilderView-CHaAQL5v.cjs.map +0 -1
  113. package/dist/chunks/FormBuilderView-vQfVc08Z.js.map +0 -1
  114. package/dist/chunks/FormRendererView-CTLlG13b.js +0 -1106
  115. package/dist/chunks/FormRendererView-CTLlG13b.js.map +0 -1
  116. package/dist/chunks/FormRendererView-ChmM_4Yc.cjs +0 -4
  117. package/dist/chunks/FormRendererView-ChmM_4Yc.cjs.map +0 -1
  118. package/dist/chunks/approver-filled-form-B4zPg9kz.cjs.map +0 -1
  119. package/dist/chunks/approver-filled-form-Bgazhbvd.js.map +0 -1
  120. package/dist/chunks/delegations-BfhCDz5e.js.map +0 -1
  121. package/dist/chunks/delegations-BmFGcuhA.cjs +0 -2
  122. package/dist/chunks/delegations-BmFGcuhA.cjs.map +0 -1
  123. package/dist/chunks/delegations-CcS0SHbf.cjs +0 -2
  124. package/dist/chunks/delegations-CcS0SHbf.cjs.map +0 -1
  125. package/dist/chunks/delegations-DBh5TT6G.js.map +0 -1
  126. package/dist/chunks/designer-Df79YzUn.cjs +0 -65
  127. package/dist/chunks/designer-Df79YzUn.cjs.map +0 -1
  128. package/dist/chunks/designer-ubnZbP-A.js.map +0 -1
  129. package/dist/chunks/detail-BBC9kqXd.cjs +0 -5
  130. package/dist/chunks/detail-BBC9kqXd.cjs.map +0 -1
  131. package/dist/chunks/detail-C6XKZjlF.js.map +0 -1
@@ -3,9 +3,16 @@ import { FormDataSourceValueSnapshots, FormDefinitionSchema, FormFieldDefinition
3
3
  import { FormRendererValues } from '@rytass/bpm-core-client/form';
4
4
  import { ResolvedFieldAccess } from '@rytass/bpm-core-shared';
5
5
  import { FormDataSourceFieldState, FormRendererDataSourceContext } from './form-data-source-field.cjs';
6
+ import { FileUploadFieldState, FormRendererAttachment } from './file-upload-field.cjs';
6
7
  export interface FormRendererProps {
7
8
  readonly dataSourceContext?: FormRendererDataSourceContext;
8
9
  readonly dataSourceInitialValues?: FormRendererValues;
10
+ /**
11
+ * Attachments the form's `file_upload` values may refer to (for example the
12
+ * instance's `listAttachments`). A field lists each id it holds by the name
13
+ * and size found here.
14
+ */
15
+ readonly attachments?: readonly FormRendererAttachment[];
9
16
  readonly emptyText?: string;
10
17
  readonly errors?: Readonly<Record<string, string>>;
11
18
  /**
@@ -24,7 +31,23 @@ export interface FormRendererProps {
24
31
  readonly fieldLabelMarkers?: Readonly<Record<string, string>>;
25
32
  readonly maxWidth?: CSSProperties['maxWidth'];
26
33
  readonly onChange?: (values: FormRendererValues) => void;
27
- readonly onDataSourceStateChange?: (fieldKey: string, state: Pick<FormDataSourceFieldState, 'hasValue' | 'invalidValues' | 'status'>) => void;
34
+ readonly onDataSourceStateChange?: (fieldKey: string, state: Pick<FormDataSourceFieldState, 'hasValue' | 'invalidValues' | 'selectionExpired' | 'status'>) => void;
35
+ /**
36
+ * Called when a `file_upload` field starts or settles an upload. A host
37
+ * that submits the form refuses to while any field reports a pending or
38
+ * failed upload (`readFileUploadSubmissionBlockMessage`): those files are
39
+ * listed but not in the value.
40
+ */
41
+ readonly onFileUploadStateChange?: (fieldKey: string, state: FileUploadFieldState) => void;
42
+ /**
43
+ * Opens an attachment a `file_upload` field lists. Without it, only files
44
+ * picked in this form can be downloaded from the field.
45
+ */
46
+ readonly onDownloadAttachment?: (attachmentId: string) => void;
47
+ /**
48
+ * Uploads a file picked in a `file_upload` field and returns the attachment
49
+ * id the value then holds. Without it a `file_upload` field cannot upload.
50
+ */
28
51
  readonly onUploadAttachment?: (field: FormFieldDefinition, file: File) => Promise<{
29
52
  readonly id: string;
30
53
  }>;
@@ -35,5 +58,5 @@ export interface FormRendererProps {
35
58
  readonly uiSchema: FormUiSchema;
36
59
  readonly value?: FormRendererValues;
37
60
  }
38
- export declare function FormRenderer({ dataSourceContext, dataSourceInitialValues, emptyText, errors, fieldAccess, fieldLabelMarkers, maxWidth, onChange, onDataSourceStateChange, onUploadAttachment, optionSnapshots, readonly, schema, singleColumn, uiSchema, value, }: FormRendererProps): ReactElement;
61
+ export declare function FormRenderer({ attachments, dataSourceContext, dataSourceInitialValues, emptyText, errors, fieldAccess, fieldLabelMarkers, maxWidth, onChange, onDataSourceStateChange, onDownloadAttachment, onFileUploadStateChange, onUploadAttachment, optionSnapshots, readonly, schema, singleColumn, uiSchema, value, }: FormRendererProps): ReactElement;
39
62
  export { FormRenderer as FormRendererView };
@@ -3,9 +3,16 @@ import { FormDataSourceValueSnapshots, FormDefinitionSchema, FormFieldDefinition
3
3
  import { FormRendererValues } from '@rytass/bpm-core-client/form';
4
4
  import { ResolvedFieldAccess } from '@rytass/bpm-core-shared';
5
5
  import { FormDataSourceFieldState, FormRendererDataSourceContext } from './form-data-source-field.js';
6
+ import { FileUploadFieldState, FormRendererAttachment } from './file-upload-field.js';
6
7
  export interface FormRendererProps {
7
8
  readonly dataSourceContext?: FormRendererDataSourceContext;
8
9
  readonly dataSourceInitialValues?: FormRendererValues;
10
+ /**
11
+ * Attachments the form's `file_upload` values may refer to (for example the
12
+ * instance's `listAttachments`). A field lists each id it holds by the name
13
+ * and size found here.
14
+ */
15
+ readonly attachments?: readonly FormRendererAttachment[];
9
16
  readonly emptyText?: string;
10
17
  readonly errors?: Readonly<Record<string, string>>;
11
18
  /**
@@ -24,7 +31,23 @@ export interface FormRendererProps {
24
31
  readonly fieldLabelMarkers?: Readonly<Record<string, string>>;
25
32
  readonly maxWidth?: CSSProperties['maxWidth'];
26
33
  readonly onChange?: (values: FormRendererValues) => void;
27
- readonly onDataSourceStateChange?: (fieldKey: string, state: Pick<FormDataSourceFieldState, 'hasValue' | 'invalidValues' | 'status'>) => void;
34
+ readonly onDataSourceStateChange?: (fieldKey: string, state: Pick<FormDataSourceFieldState, 'hasValue' | 'invalidValues' | 'selectionExpired' | 'status'>) => void;
35
+ /**
36
+ * Called when a `file_upload` field starts or settles an upload. A host
37
+ * that submits the form refuses to while any field reports a pending or
38
+ * failed upload (`readFileUploadSubmissionBlockMessage`): those files are
39
+ * listed but not in the value.
40
+ */
41
+ readonly onFileUploadStateChange?: (fieldKey: string, state: FileUploadFieldState) => void;
42
+ /**
43
+ * Opens an attachment a `file_upload` field lists. Without it, only files
44
+ * picked in this form can be downloaded from the field.
45
+ */
46
+ readonly onDownloadAttachment?: (attachmentId: string) => void;
47
+ /**
48
+ * Uploads a file picked in a `file_upload` field and returns the attachment
49
+ * id the value then holds. Without it a `file_upload` field cannot upload.
50
+ */
28
51
  readonly onUploadAttachment?: (field: FormFieldDefinition, file: File) => Promise<{
29
52
  readonly id: string;
30
53
  }>;
@@ -35,5 +58,5 @@ export interface FormRendererProps {
35
58
  readonly uiSchema: FormUiSchema;
36
59
  readonly value?: FormRendererValues;
37
60
  }
38
- export declare function FormRenderer({ dataSourceContext, dataSourceInitialValues, emptyText, errors, fieldAccess, fieldLabelMarkers, maxWidth, onChange, onDataSourceStateChange, onUploadAttachment, optionSnapshots, readonly, schema, singleColumn, uiSchema, value, }: FormRendererProps): ReactElement;
61
+ export declare function FormRenderer({ attachments, dataSourceContext, dataSourceInitialValues, emptyText, errors, fieldAccess, fieldLabelMarkers, maxWidth, onChange, onDataSourceStateChange, onDownloadAttachment, onFileUploadStateChange, onUploadAttachment, optionSnapshots, readonly, schema, singleColumn, uiSchema, value, }: FormRendererProps): ReactElement;
39
62
  export { FormRenderer as FormRendererView };
@@ -0,0 +1,84 @@
1
+ import { ReactElement } from 'react';
2
+ import { FileUploadFieldDefinition, FormFieldDefinition, FormFieldValue } from '@rytass/bpm-core-shared/form';
3
+ /**
4
+ * What a `file_upload` field needs to know about an attachment it did not
5
+ * upload itself (a resubmitted case, a stored instance) to list it. The shape
6
+ * is a subset of `AttachmentRecord`, so a host passes its attachment list as is.
7
+ */
8
+ export interface FormRendererAttachment {
9
+ readonly filename: string;
10
+ readonly id: string;
11
+ readonly sizeBytes: number | string;
12
+ }
13
+ /**
14
+ * Where a `file_upload` field stands, reported to the host through
15
+ * `FormRenderer`'s `onFileUploadStateChange`.
16
+ */
17
+ export interface FileUploadFieldState {
18
+ /** Files that failed to upload. They are listed, but not in the value. */
19
+ readonly failedCount: number;
20
+ /** Files still uploading. They are listed, but not in the value yet. */
21
+ readonly pendingCount: number;
22
+ }
23
+ /**
24
+ * The copy to show when a submission is refused because a `file_upload` field
25
+ * has not settled. An upload still running is a "wait a moment"; a failed one
26
+ * needs the filler to retry or remove it. Returns `null` when nothing blocks.
27
+ *
28
+ * Without this check a submit made while a file is uploading sends the form
29
+ * without that attachment, although the field lists the file.
30
+ */
31
+ export declare function readFileUploadSubmissionBlockMessage(states: readonly Pick<FileUploadFieldState, 'failedCount' | 'pendingCount'>[]): string | null;
32
+ export interface FileUploadFieldStates {
33
+ /** `readFileUploadSubmissionBlockMessage` over every field reported so far. */
34
+ readonly blockMessage: string | null;
35
+ /** Pass to `FormRenderer`'s `onFileUploadStateChange`. */
36
+ readonly onFileUploadStateChange: (fieldKey: string, state: FileUploadFieldState) => void;
37
+ }
38
+ /**
39
+ * Collects what a form's `file_upload` fields report, for a host that has to
40
+ * refuse a submit while one of them is uploading or holds a failed upload.
41
+ */
42
+ export declare function useFileUploadFieldStates(): FileUploadFieldStates;
43
+ export interface FileUploadFieldControlProps {
44
+ /** Metadata for listing attachments this control did not upload. */
45
+ readonly attachments?: readonly FormRendererAttachment[];
46
+ readonly field: FileUploadFieldDefinition;
47
+ /**
48
+ * Receives the attachment ids the field now holds. Like a controlled input,
49
+ * the host renders the value back: the list shows the value it is given.
50
+ */
51
+ readonly onChange: (value: FormFieldValue | undefined) => void;
52
+ /** Opens an attachment the value holds. Without it, only files picked here download. */
53
+ readonly onDownloadAttachment?: (attachmentId: string) => void;
54
+ readonly onStateChange?: (state: FileUploadFieldState) => void;
55
+ readonly onUploadAttachment?: (field: FormFieldDefinition, file: File) => Promise<{
56
+ readonly id: string;
57
+ }>;
58
+ readonly readonly: boolean;
59
+ readonly value: FormFieldValue | undefined;
60
+ }
61
+ /**
62
+ * The `file_upload` control.
63
+ *
64
+ * Mezzanine's `Upload` is fully controlled: it renders `files` and resets its
65
+ * working list to that prop after every render, so the list is built here.
66
+ *
67
+ * What is attached is the host's value, and only that: every id it holds is
68
+ * listed — a file picked here by its own `File`, any other id by the name and
69
+ * size in `attachments` (or as an unnamed attachment without them) — so each
70
+ * one can be removed and counts towards `maxFiles`. Uploads still running and
71
+ * uploads that failed are listed too, in the order `Upload` keeps, but are not
72
+ * in the value; `onStateChange` reports them so the host can refuse a submit.
73
+ *
74
+ * The value emitted on a change is read off the list `Upload` hands back —
75
+ * the finished files in it, in order — never off this control's state. That
76
+ * list is `Upload`'s own working copy, which it updates the moment it emits,
77
+ * so it is current even when two uploads finish before the host re-renders.
78
+ * `Upload` calls the `onChange` it captured when a file was picked, so it is
79
+ * given a stable function that forwards to the latest handler.
80
+ *
81
+ * Without `onUploadAttachment` nothing can be uploaded, so the control is
82
+ * disabled and says so rather than listing a file no attachment stands behind.
83
+ */
84
+ export declare function FileUploadFieldControl({ attachments, field, onChange, onDownloadAttachment, onStateChange, onUploadAttachment, readonly, value, }: FileUploadFieldControlProps): ReactElement;
@@ -0,0 +1,84 @@
1
+ import { ReactElement } from 'react';
2
+ import { FileUploadFieldDefinition, FormFieldDefinition, FormFieldValue } from '@rytass/bpm-core-shared/form';
3
+ /**
4
+ * What a `file_upload` field needs to know about an attachment it did not
5
+ * upload itself (a resubmitted case, a stored instance) to list it. The shape
6
+ * is a subset of `AttachmentRecord`, so a host passes its attachment list as is.
7
+ */
8
+ export interface FormRendererAttachment {
9
+ readonly filename: string;
10
+ readonly id: string;
11
+ readonly sizeBytes: number | string;
12
+ }
13
+ /**
14
+ * Where a `file_upload` field stands, reported to the host through
15
+ * `FormRenderer`'s `onFileUploadStateChange`.
16
+ */
17
+ export interface FileUploadFieldState {
18
+ /** Files that failed to upload. They are listed, but not in the value. */
19
+ readonly failedCount: number;
20
+ /** Files still uploading. They are listed, but not in the value yet. */
21
+ readonly pendingCount: number;
22
+ }
23
+ /**
24
+ * The copy to show when a submission is refused because a `file_upload` field
25
+ * has not settled. An upload still running is a "wait a moment"; a failed one
26
+ * needs the filler to retry or remove it. Returns `null` when nothing blocks.
27
+ *
28
+ * Without this check a submit made while a file is uploading sends the form
29
+ * without that attachment, although the field lists the file.
30
+ */
31
+ export declare function readFileUploadSubmissionBlockMessage(states: readonly Pick<FileUploadFieldState, 'failedCount' | 'pendingCount'>[]): string | null;
32
+ export interface FileUploadFieldStates {
33
+ /** `readFileUploadSubmissionBlockMessage` over every field reported so far. */
34
+ readonly blockMessage: string | null;
35
+ /** Pass to `FormRenderer`'s `onFileUploadStateChange`. */
36
+ readonly onFileUploadStateChange: (fieldKey: string, state: FileUploadFieldState) => void;
37
+ }
38
+ /**
39
+ * Collects what a form's `file_upload` fields report, for a host that has to
40
+ * refuse a submit while one of them is uploading or holds a failed upload.
41
+ */
42
+ export declare function useFileUploadFieldStates(): FileUploadFieldStates;
43
+ export interface FileUploadFieldControlProps {
44
+ /** Metadata for listing attachments this control did not upload. */
45
+ readonly attachments?: readonly FormRendererAttachment[];
46
+ readonly field: FileUploadFieldDefinition;
47
+ /**
48
+ * Receives the attachment ids the field now holds. Like a controlled input,
49
+ * the host renders the value back: the list shows the value it is given.
50
+ */
51
+ readonly onChange: (value: FormFieldValue | undefined) => void;
52
+ /** Opens an attachment the value holds. Without it, only files picked here download. */
53
+ readonly onDownloadAttachment?: (attachmentId: string) => void;
54
+ readonly onStateChange?: (state: FileUploadFieldState) => void;
55
+ readonly onUploadAttachment?: (field: FormFieldDefinition, file: File) => Promise<{
56
+ readonly id: string;
57
+ }>;
58
+ readonly readonly: boolean;
59
+ readonly value: FormFieldValue | undefined;
60
+ }
61
+ /**
62
+ * The `file_upload` control.
63
+ *
64
+ * Mezzanine's `Upload` is fully controlled: it renders `files` and resets its
65
+ * working list to that prop after every render, so the list is built here.
66
+ *
67
+ * What is attached is the host's value, and only that: every id it holds is
68
+ * listed — a file picked here by its own `File`, any other id by the name and
69
+ * size in `attachments` (or as an unnamed attachment without them) — so each
70
+ * one can be removed and counts towards `maxFiles`. Uploads still running and
71
+ * uploads that failed are listed too, in the order `Upload` keeps, but are not
72
+ * in the value; `onStateChange` reports them so the host can refuse a submit.
73
+ *
74
+ * The value emitted on a change is read off the list `Upload` hands back —
75
+ * the finished files in it, in order — never off this control's state. That
76
+ * list is `Upload`'s own working copy, which it updates the moment it emits,
77
+ * so it is current even when two uploads finish before the host re-renders.
78
+ * `Upload` calls the `onChange` it captured when a file was picked, so it is
79
+ * given a stable function that forwards to the latest handler.
80
+ *
81
+ * Without `onUploadAttachment` nothing can be uploaded, so the control is
82
+ * disabled and says so rather than listing a file no attachment stands behind.
83
+ */
84
+ export declare function FileUploadFieldControl({ attachments, field, onChange, onDownloadAttachment, onStateChange, onUploadAttachment, readonly, value, }: FileUploadFieldControlProps): ReactElement;
@@ -21,6 +21,14 @@ export interface FormDataSourceFieldState {
21
21
  readonly onSearch: (searchText: string) => void;
22
22
  readonly options: readonly FormFieldOption[];
23
23
  readonly retry: () => void;
24
+ /**
25
+ * True when the held value was valid for the form it was picked in, an
26
+ * `EXPRESSION` binding's inputs have changed since, and the host's resolve
27
+ * no longer accounts for it. The status is then `INVALID` and the message is
28
+ * the host's `FORM_DATA_SOURCE_VALUE_NOT_RESOLVED` copy — the same sentence
29
+ * a `FIELD` binding's stale value gets when the submission is refused.
30
+ */
31
+ readonly selectionExpired?: boolean;
24
32
  readonly status: FormDataSourceFieldStatus;
25
33
  }
26
34
  /**
@@ -62,4 +70,4 @@ export declare function isFormDataSourceFieldSubmissionBlocked(state: Pick<FormD
62
70
  *
63
71
  * Returns `null` when nothing blocks the submission.
64
72
  */
65
- export declare function readFormDataSourceSubmissionBlockMessage(states: readonly Pick<FormDataSourceFieldState, 'hasValue' | 'status'>[]): string | null;
73
+ export declare function readFormDataSourceSubmissionBlockMessage(states: readonly Pick<FormDataSourceFieldState, 'hasValue' | 'selectionExpired' | 'status'>[]): string | null;
@@ -21,6 +21,14 @@ export interface FormDataSourceFieldState {
21
21
  readonly onSearch: (searchText: string) => void;
22
22
  readonly options: readonly FormFieldOption[];
23
23
  readonly retry: () => void;
24
+ /**
25
+ * True when the held value was valid for the form it was picked in, an
26
+ * `EXPRESSION` binding's inputs have changed since, and the host's resolve
27
+ * no longer accounts for it. The status is then `INVALID` and the message is
28
+ * the host's `FORM_DATA_SOURCE_VALUE_NOT_RESOLVED` copy — the same sentence
29
+ * a `FIELD` binding's stale value gets when the submission is refused.
30
+ */
31
+ readonly selectionExpired?: boolean;
24
32
  readonly status: FormDataSourceFieldStatus;
25
33
  }
26
34
  /**
@@ -62,4 +70,4 @@ export declare function isFormDataSourceFieldSubmissionBlocked(state: Pick<FormD
62
70
  *
63
71
  * Returns `null` when nothing blocks the submission.
64
72
  */
65
- export declare function readFormDataSourceSubmissionBlockMessage(states: readonly Pick<FormDataSourceFieldState, 'hasValue' | 'status'>[]): string | null;
73
+ export declare function readFormDataSourceSubmissionBlockMessage(states: readonly Pick<FormDataSourceFieldState, 'hasValue' | 'selectionExpired' | 'status'>[]): string | null;
@@ -0,0 +1,7 @@
1
+ import { FormFieldValue } from '@rytass/bpm-core-shared/form';
2
+ /**
3
+ * A multi-value field's ids or option values, or `[]` for anything else.
4
+ * A table value is also an array, so the element check is what separates a
5
+ * multi-select or `file_upload` value from table rows.
6
+ */
7
+ export declare function readStringArrayValue(value: FormFieldValue | undefined): readonly string[];
@@ -0,0 +1,7 @@
1
+ import { FormFieldValue } from '@rytass/bpm-core-shared/form';
2
+ /**
3
+ * A multi-value field's ids or option values, or `[]` for anything else.
4
+ * A table value is also an array, so the element check is what separates a
5
+ * multi-select or `file_upload` value from table rows.
6
+ */
7
+ export declare function readStringArrayValue(value: FormFieldValue | undefined): readonly string[];
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../chunks/FormRendererView-ChmM_4Yc.cjs");exports.FormRenderer=e.t,exports.FormRendererView=e.t,exports.isFormDataSourceFieldSubmissionBlocked=e.a,exports.readFormDataSourceFieldStatusMessage=e.o,exports.readFormDataSourceSubmissionBlockMessage=e.s,exports.useFormDataSourceField=e.c;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../chunks/FormRendererView-lYSaR8CQ.cjs");exports.FormRenderer=e.t,exports.FormRendererView=e.t,exports.isFormDataSourceFieldSubmissionBlocked=e.s,exports.readFileUploadSubmissionBlockMessage=e.a,exports.readFormDataSourceFieldStatusMessage=e.c,exports.readFormDataSourceSubmissionBlockMessage=e.l,exports.useFormDataSourceField=e.u;
@@ -1,2 +1,3 @@
1
1
  export * from './FormRendererView.cjs';
2
2
  export * from './form-data-source-field.cjs';
3
+ export { readFileUploadSubmissionBlockMessage, type FileUploadFieldState, type FormRendererAttachment, } from './file-upload-field.cjs';
@@ -1,2 +1,3 @@
1
1
  export * from './FormRendererView.js';
2
2
  export * from './form-data-source-field.js';
3
+ export { readFileUploadSubmissionBlockMessage, type FileUploadFieldState, type FormRendererAttachment, } from './file-upload-field.js';
@@ -1 +1 @@
1
- export { t as FormRenderer, t as FormRendererView, a as isFormDataSourceFieldSubmissionBlocked, o as readFormDataSourceFieldStatusMessage, s as readFormDataSourceSubmissionBlockMessage, c as useFormDataSourceField } from "../../../chunks/FormRendererView-CTLlG13b.js";
1
+ export { t as FormRenderer, t as FormRendererView, s as isFormDataSourceFieldSubmissionBlocked, a as readFileUploadSubmissionBlockMessage, c as readFormDataSourceFieldStatusMessage, l as readFormDataSourceSubmissionBlockMessage, u as useFormDataSourceField } from "../../../chunks/FormRendererView-GfbVWEGa.js";
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../chunks/detail-BBC9kqXd.cjs");exports.InstanceAttachmentsSection=e.o,exports.InstanceDetailView=e.t,exports.InstanceFormSection=e.s,exports.InstanceHistorySection=e.r,exports.InstanceSignaturesSection=e.i,exports.InstanceTasksSection=e.a,exports.InstanceWebhookDeliveriesSection=e.n;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../chunks/detail-ChseSF55.cjs");exports.InstanceAttachmentsSection=e.o,exports.InstanceDetailView=e.t,exports.InstanceFormSection=e.s,exports.InstanceHistorySection=e.r,exports.InstanceSignaturesSection=e.i,exports.InstanceTasksSection=e.a,exports.InstanceWebhookDeliveriesSection=e.n;
@@ -1 +1 @@
1
- export { o as InstanceAttachmentsSection, t as InstanceDetailView, s as InstanceFormSection, r as InstanceHistorySection, i as InstanceSignaturesSection, a as InstanceTasksSection, n as InstanceWebhookDeliveriesSection } from "../../../chunks/detail-C6XKZjlF.js";
1
+ export { o as InstanceAttachmentsSection, t as InstanceDetailView, s as InstanceFormSection, r as InstanceHistorySection, i as InstanceSignaturesSection, a as InstanceTasksSection, n as InstanceWebhookDeliveriesSection } from "../../../chunks/detail-ByZV1XaI.js";
@@ -3,6 +3,7 @@ import { ResolvedFieldAccess } from '@rytass/bpm-core-shared';
3
3
  import { FormDefinitionSchema, FormFieldDefinition } from '@rytass/bpm-core-shared/form';
4
4
  import { ApprovalInstanceRecord, WorkflowFormData } from '@rytass/bpm-core-client/workflow';
5
5
  import { FormDataSourceFieldState } from '../../../forms/renderer/form-data-source-field.cjs';
6
+ import { FileUploadFieldState, FormRendererAttachment } from '../../../forms/renderer/file-upload-field.cjs';
6
7
  /** The fill state of the viewer's own task at a node that fills in fields. */
7
8
  export interface InstanceFormSectionFill {
8
9
  /** Field errors from the page's check or the server's, keyed by path. */
@@ -48,7 +49,7 @@ export interface InstanceFormSectionProps {
48
49
  /** Called when the form data changes in the resubmit flow. */
49
50
  readonly onResubmitFormChange: (values: WorkflowFormData) => void;
50
51
  /** Called when a dynamic option field changes validation state. */
51
- readonly onDataSourceStateChange: (fieldKey: string, state: Pick<FormDataSourceFieldState, 'hasValue' | 'invalidValues' | 'status'>) => void;
52
+ readonly onDataSourceStateChange: (fieldKey: string, state: Pick<FormDataSourceFieldState, 'hasValue' | 'invalidValues' | 'selectionExpired' | 'status'>) => void;
52
53
  /** Called when the user clicks "重新送出". */
53
54
  readonly onResubmitInstance: () => void;
54
55
  /**
@@ -59,7 +60,23 @@ export interface InstanceFormSectionProps {
59
60
  readonly resubmitComment?: string;
60
61
  /** Called when the applicant edits the resubmission comment. */
61
62
  readonly onResubmitCommentChange?: ((value: string) => void) | null;
62
- /** Called when an attachment upload is requested via the form field. */
63
+ /**
64
+ * The instance's attachments, so a `file_upload` field lists the files its
65
+ * value holds by name.
66
+ */
67
+ readonly attachments?: readonly FormRendererAttachment[];
68
+ /** Opens an attachment a `file_upload` field lists. */
69
+ readonly onDownloadAttachment?: (attachmentId: string) => void;
70
+ /**
71
+ * Called when a `file_upload` field starts or settles an upload, so the
72
+ * container can refuse to resubmit while one is unsettled.
73
+ */
74
+ readonly onFileUploadStateChange?: (fieldKey: string, state: FileUploadFieldState) => void;
75
+ /**
76
+ * Uploads a file picked in a `file_upload` field while resubmitting. A fill
77
+ * node never edits one: an approver cannot fill in a `file_upload` field
78
+ * (ADR 20, refused at publish).
79
+ */
63
80
  readonly onUploadAttachment: (field: FormFieldDefinition, file: File) => Promise<{
64
81
  readonly id: string;
65
82
  }>;
@@ -69,4 +86,4 @@ export interface InstanceFormSectionProps {
69
86
  * Displays the form in read-only mode normally, or editable mode when the
70
87
  * instance has been returned and the current member can resubmit it.
71
88
  */
72
- export declare function InstanceFormSection({ canResubmitInstance, deciding, error, fieldAccess, fieldLabelMarkers, fill, instance, loading, onDataSourceStateChange, onResubmitFormChange, onReloadAfterConflict, onResubmitCommentChange, onResubmitInstance, onUploadAttachment, resubmitComment, resubmitFormData, resubmitFormErrors, }: InstanceFormSectionProps): ReactElement;
89
+ export declare function InstanceFormSection({ attachments, canResubmitInstance, deciding, error, fieldAccess, fieldLabelMarkers, fill, instance, loading, onDataSourceStateChange, onDownloadAttachment, onFileUploadStateChange, onResubmitFormChange, onReloadAfterConflict, onResubmitCommentChange, onResubmitInstance, onUploadAttachment, resubmitComment, resubmitFormData, resubmitFormErrors, }: InstanceFormSectionProps): ReactElement;
@@ -3,6 +3,7 @@ import { ResolvedFieldAccess } from '@rytass/bpm-core-shared';
3
3
  import { FormDefinitionSchema, FormFieldDefinition } from '@rytass/bpm-core-shared/form';
4
4
  import { ApprovalInstanceRecord, WorkflowFormData } from '@rytass/bpm-core-client/workflow';
5
5
  import { FormDataSourceFieldState } from '../../../forms/renderer/form-data-source-field.js';
6
+ import { FileUploadFieldState, FormRendererAttachment } from '../../../forms/renderer/file-upload-field.js';
6
7
  /** The fill state of the viewer's own task at a node that fills in fields. */
7
8
  export interface InstanceFormSectionFill {
8
9
  /** Field errors from the page's check or the server's, keyed by path. */
@@ -48,7 +49,7 @@ export interface InstanceFormSectionProps {
48
49
  /** Called when the form data changes in the resubmit flow. */
49
50
  readonly onResubmitFormChange: (values: WorkflowFormData) => void;
50
51
  /** Called when a dynamic option field changes validation state. */
51
- readonly onDataSourceStateChange: (fieldKey: string, state: Pick<FormDataSourceFieldState, 'hasValue' | 'invalidValues' | 'status'>) => void;
52
+ readonly onDataSourceStateChange: (fieldKey: string, state: Pick<FormDataSourceFieldState, 'hasValue' | 'invalidValues' | 'selectionExpired' | 'status'>) => void;
52
53
  /** Called when the user clicks "重新送出". */
53
54
  readonly onResubmitInstance: () => void;
54
55
  /**
@@ -59,7 +60,23 @@ export interface InstanceFormSectionProps {
59
60
  readonly resubmitComment?: string;
60
61
  /** Called when the applicant edits the resubmission comment. */
61
62
  readonly onResubmitCommentChange?: ((value: string) => void) | null;
62
- /** Called when an attachment upload is requested via the form field. */
63
+ /**
64
+ * The instance's attachments, so a `file_upload` field lists the files its
65
+ * value holds by name.
66
+ */
67
+ readonly attachments?: readonly FormRendererAttachment[];
68
+ /** Opens an attachment a `file_upload` field lists. */
69
+ readonly onDownloadAttachment?: (attachmentId: string) => void;
70
+ /**
71
+ * Called when a `file_upload` field starts or settles an upload, so the
72
+ * container can refuse to resubmit while one is unsettled.
73
+ */
74
+ readonly onFileUploadStateChange?: (fieldKey: string, state: FileUploadFieldState) => void;
75
+ /**
76
+ * Uploads a file picked in a `file_upload` field while resubmitting. A fill
77
+ * node never edits one: an approver cannot fill in a `file_upload` field
78
+ * (ADR 20, refused at publish).
79
+ */
63
80
  readonly onUploadAttachment: (field: FormFieldDefinition, file: File) => Promise<{
64
81
  readonly id: string;
65
82
  }>;
@@ -69,4 +86,4 @@ export interface InstanceFormSectionProps {
69
86
  * Displays the form in read-only mode normally, or editable mode when the
70
87
  * instance has been returned and the current member can resubmit it.
71
88
  */
72
- export declare function InstanceFormSection({ canResubmitInstance, deciding, error, fieldAccess, fieldLabelMarkers, fill, instance, loading, onDataSourceStateChange, onResubmitFormChange, onReloadAfterConflict, onResubmitCommentChange, onResubmitInstance, onUploadAttachment, resubmitComment, resubmitFormData, resubmitFormErrors, }: InstanceFormSectionProps): ReactElement;
89
+ export declare function InstanceFormSection({ attachments, canResubmitInstance, deciding, error, fieldAccess, fieldLabelMarkers, fill, instance, loading, onDataSourceStateChange, onDownloadAttachment, onFileUploadStateChange, onResubmitFormChange, onReloadAfterConflict, onResubmitCommentChange, onResubmitInstance, onUploadAttachment, resubmitComment, resubmitFormData, resubmitFormErrors, }: InstanceFormSectionProps): ReactElement;
@@ -72,7 +72,7 @@ export declare function readNumberField(record: Readonly<Record<string, unknown>
72
72
  export declare function isPresentText(value: string | null): value is string;
73
73
  export declare function isRecord(value: unknown): value is Readonly<Record<string, unknown>>;
74
74
  export declare function isPendingTask(task: TaskRecord): boolean;
75
- export declare function readErrorMessage(error: unknown): string;
75
+ export { readErrorMessage } from '../../instance-error-message.cjs';
76
76
  export declare function formatFileSize(sizeBytes: number): string;
77
77
  export declare function readShortHash(hash: string): string;
78
78
  export declare function readInstanceStateLabel(state: string): string;
@@ -147,4 +147,3 @@ export declare function readNodeRuntimeState(node: WorkflowNode, tasks: readonly
147
147
  statusLabel: string;
148
148
  tone: RuntimeTone;
149
149
  }>;
150
- export {};
@@ -72,7 +72,7 @@ export declare function readNumberField(record: Readonly<Record<string, unknown>
72
72
  export declare function isPresentText(value: string | null): value is string;
73
73
  export declare function isRecord(value: unknown): value is Readonly<Record<string, unknown>>;
74
74
  export declare function isPendingTask(task: TaskRecord): boolean;
75
- export declare function readErrorMessage(error: unknown): string;
75
+ export { readErrorMessage } from '../../instance-error-message.js';
76
76
  export declare function formatFileSize(sizeBytes: number): string;
77
77
  export declare function readShortHash(hash: string): string;
78
78
  export declare function readInstanceStateLabel(state: string): string;
@@ -147,4 +147,3 @@ export declare function readNodeRuntimeState(node: WorkflowNode, tasks: readonly
147
147
  statusLabel: string;
148
148
  tone: RuntimeTone;
149
149
  }>;
150
- export {};
@@ -0,0 +1,5 @@
1
+ /**
2
+ * The message a case page shows for a failed request: a stable server code
3
+ * translated into words, otherwise the server's own message.
4
+ */
5
+ export declare function readErrorMessage(error: unknown): string;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * The message a case page shows for a failed request: a stable server code
3
+ * translated into words, otherwise the server's own message.
4
+ */
5
+ export declare function readErrorMessage(error: unknown): string;
@@ -1,2 +1,2 @@
1
- "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../chunks/rolldown-runtime-BocRIvOZ.cjs"),t=require("../../../chunks/approver-filled-form-B4zPg9kz.cjs"),n=require("../../../chunks/format-date-time-D-cx5M8z.cjs"),r=require("../../../chunks/auth-provider-4BeCw7cI.cjs"),i=require("../../../chunks/router-adapter--gYs13E8.cjs"),a=require("../../../chunks/routes-config-C1j_vFKo.cjs"),o=require("../../../chunks/FormRendererView-ChmM_4Yc.cjs");let s=require("react"),c=require("@mezzanine-ui/react"),l=require("react/jsx-runtime"),u=require("@rytass/bpm-core-client/workflow"),d=require("@mezzanine-ui/react/ContentHeader");d=e.t(d,1);let f=require("@mezzanine-ui/icons"),p=require("@rytass/bpm-core-client/form");var m={display:`grid`,gap:16};function h(e={}){return(0,l.jsx)(s.Suspense,{fallback:(0,l.jsx)(_,{}),children:(0,l.jsx)(g,{templateId:e.templateId??void 0})})}function g({templateId:e}){let h=i.r(),g=a.r(),{member:_}=r.n(),y=_?.memberId??null,b=e??null,[x,S]=(0,s.useState)(null),[C,w]=(0,s.useState)({}),[T,E]=(0,s.useState)([]),[D,O]=(0,s.useState)(null),[k,A]=(0,s.useState)({}),[j,M]=(0,s.useState)(!0),[N,P]=(0,s.useState)(!1),[F,I]=(0,s.useState)({}),L=(0,s.useMemo)(()=>x?t.n(x.formVersion.schema,x.templateVersion.workflowDefinition):null,[x]),R=(0,s.useCallback)((e,t)=>{I(n=>{let r=n[e];return r?.hasValue===t.hasValue&&r.status===t.status?n:{...n,[e]:{hasValue:t.hasValue,status:t.status}}})},[]);(0,s.useEffect)(()=>{b?U(b):H()},[b]);let z=(0,s.useMemo)(()=>T.map(e=>({...e,key:e.id,updatedAt:n.t(e.updatedAt),versionLabel:`v${e.version}`})),[T]),B=(0,s.useMemo)(()=>[{dataIndex:`name`,key:`name`,title:`模板名稱`,width:240},{dataIndex:`versionLabel`,key:`versionLabel`,title:`發布版本`,width:120},{dataIndex:`updatedAt`,key:`updatedAt`,title:`更新時間`,width:220}],[]),V=(0,s.useMemo)(()=>({render:e=>[{name:`發起`,onClick:()=>h.push(g.caseNew(e.id)),variant:`base-primary`}],variant:`base-secondary`,width:88}),[h]);async function H(){M(!0),O(null),S(null),I({});try{E(await(0,u.listLaunchableTemplates)())}catch(e){O(v(e))}finally{M(!1)}}async function U(e){M(!0),O(null),E([]),I({});try{S(await(0,u.readLaunchContext)(e))}catch(e){O(v(e))}finally{M(!1)}}async function W(){if(!x||!L||!y)return;P(!0),O(null),A({});let e=o.s(Object.values(F));if(e){O(e),P(!1);return}let n=t.r((0,p.buildFormRendererValues)(L.fields,C),x.templateVersion.workflowDefinition);try{let e=await(0,p.validateFormRendererValuesInWorker)({schema:L,uiSchema:x.formVersion.uiSchema,values:n});if(!e.valid){A(e.errors),O(`請先修正表單中標示的欄位。`),e.firstInvalidFieldKey&&(0,p.focusFormRendererField)(e.firstInvalidFieldKey);return}let t=await(0,u.submitApprovalInstance)({formData:n,initiatorMemberId:y,templateId:x.template.id,title:(0,u.readFormDataCaseTitle)({fallbackTitle:x.template.name,formData:n,schema:L,uiSchema:x.formVersion.uiSchema})});h.push(g.caseDetail(t))}catch(e){O(v(e))}finally{P(!1)}}async function G(e,t){if(!y)throw Error(`尚未登入,無法上傳附件`);return{id:(await(0,u.uploadAttachment)({file:t,formFieldPath:`form.${e.fieldKey}`})).id}}return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(c.PageHeader,{children:(0,l.jsx)(d.default,{description:x?`${x.template.name} · 表單 v${x.formVersion.version}`:`選擇可發起的已發布模板後填寫表單內容。`,title:`發起簽核`,children:x?(0,l.jsx)(c.Button,{disabled:j||N,icon:f.CheckedIcon,iconType:`leading`,onClick:W,variant:`base-primary`,children:`送出`}):null})}),(0,l.jsx)(c.SectionGroup,{children:(0,l.jsx)(c.Section,{children:(0,l.jsxs)(`div`,{style:m,children:[D?(0,l.jsx)(c.Typography,{color:`text-error`,variant:`body`,children:D}):null,j?(0,l.jsx)(c.Typography,{color:`text-neutral`,variant:`body`,children:`載入中...`}):null,x&&L?(0,l.jsx)(o.t,{dataSourceContext:{kind:`runtime`,templateId:x.template.id},errors:k,maxWidth:480,onChange:e=>{w(e),A({})},onDataSourceStateChange:R,onUploadAttachment:G,schema:L,singleColumn:!0,uiSchema:x.formVersion.uiSchema,value:C}):null,!b&&!j?z.length>0?(0,l.jsx)(c.Table,{actions:V,columns:B,dataSource:z,fullWidth:!0}):(0,l.jsx)(c.Typography,{color:`text-neutral`,variant:`body`,children:`目前沒有可發起的已發布模板。`}):null]})})})]})}function _(){return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(c.PageHeader,{children:(0,l.jsx)(d.default,{description:`選擇可發起的已發布模板後填寫表單內容。`,title:`發起簽核`})}),(0,l.jsx)(c.SectionGroup,{children:(0,l.jsx)(c.Section,{children:(0,l.jsx)(c.Typography,{color:`text-neutral`,variant:`body`,children:`載入中...`})})})]})}function v(e){return(0,p.readFormDataSourceErrorMessage)(e)||(e instanceof Error?e.message:`發生未知錯誤`)}exports.InstanceNewView=h;
1
+ "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../chunks/rolldown-runtime-BocRIvOZ.cjs"),t=require("../../../chunks/instance-error-message-DTARGbGo.cjs"),n=require("../../../chunks/format-date-time-D-cx5M8z.cjs"),r=require("../../../chunks/auth-provider-4BeCw7cI.cjs"),i=require("../../../chunks/router-adapter--gYs13E8.cjs"),a=require("../../../chunks/routes-config-C1j_vFKo.cjs"),o=require("../../../chunks/FormRendererView-lYSaR8CQ.cjs");let s=require("react"),c=require("@mezzanine-ui/react"),l=require("react/jsx-runtime"),u=require("@rytass/bpm-core-client/workflow"),d=require("@mezzanine-ui/react/ContentHeader");d=e.t(d,1);let f=require("@mezzanine-ui/icons"),p=require("@rytass/bpm-core-client/form");var m={display:`grid`,gap:16};function h(e={}){return(0,l.jsx)(s.Suspense,{fallback:(0,l.jsx)(_,{}),children:(0,l.jsx)(g,{templateId:e.templateId??void 0})})}function g({templateId:e}){let h=i.r(),g=a.r(),{member:_}=r.n(),v=_?.memberId??null,y=e??null,[b,x]=(0,s.useState)(null),[S,C]=(0,s.useState)({}),[w,T]=(0,s.useState)([]),[E,D]=(0,s.useState)(null),[O,k]=(0,s.useState)({}),[A,j]=(0,s.useState)(!0),[M,N]=(0,s.useState)(!1),[P,F]=(0,s.useState)({}),I=o.o(),L=(0,s.useMemo)(()=>b?t.r(b.formVersion.schema,b.templateVersion.workflowDefinition):null,[b]),R=(0,s.useCallback)((e,t)=>{F(n=>{let r=n[e];return r?.hasValue===t.hasValue&&r.selectionExpired===(t.selectionExpired===!0)&&r.status===t.status?n:{...n,[e]:{hasValue:t.hasValue,selectionExpired:t.selectionExpired===!0,status:t.status}}})},[]);(0,s.useEffect)(()=>{y?U(y):H()},[y]);let z=(0,s.useMemo)(()=>w.map(e=>({...e,key:e.id,updatedAt:n.t(e.updatedAt),versionLabel:`v${e.version}`})),[w]),B=(0,s.useMemo)(()=>[{dataIndex:`name`,key:`name`,title:`模板名稱`,width:240},{dataIndex:`versionLabel`,key:`versionLabel`,title:`發布版本`,width:120},{dataIndex:`updatedAt`,key:`updatedAt`,title:`更新時間`,width:220}],[]),V=(0,s.useMemo)(()=>({render:e=>[{name:`發起`,onClick:()=>h.push(g.caseNew(e.id)),variant:`base-primary`}],variant:`base-secondary`,width:88}),[h]);async function H(){j(!0),D(null),x(null),F({});try{T(await(0,u.listLaunchableTemplates)())}catch(e){D(t.t(e))}finally{j(!1)}}async function U(e){j(!0),D(null),T([]),F({});try{x(await(0,u.readLaunchContext)(e))}catch(e){D(t.t(e))}finally{j(!1)}}async function W(){if(!b||!L||!v)return;N(!0),D(null),k({});let e=o.l(Object.values(P));if(e){D(e),N(!1);return}if(I.blockMessage){D(I.blockMessage),N(!1);return}let n=t.i((0,p.buildFormRendererValues)(L.fields,S),b.templateVersion.workflowDefinition);try{let e=await(0,p.validateFormRendererValuesInWorker)({schema:L,uiSchema:b.formVersion.uiSchema,values:n});if(!e.valid){k(e.errors),D(`請先修正表單中標示的欄位。`),e.firstInvalidFieldKey&&(0,p.focusFormRendererField)(e.firstInvalidFieldKey);return}let t=await(0,u.submitApprovalInstance)({formData:n,initiatorMemberId:v,templateId:b.template.id,title:(0,u.readFormDataCaseTitle)({fallbackTitle:b.template.name,formData:n,schema:L,uiSchema:b.formVersion.uiSchema})});h.push(g.caseDetail(t))}catch(e){D(t.t(e))}finally{N(!1)}}async function G(e,t){if(!v)throw Error(`尚未登入,無法上傳附件`);return{id:(await(0,u.uploadAttachment)({file:t,formFieldPath:`form.${e.fieldKey}`})).id}}return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(c.PageHeader,{children:(0,l.jsx)(d.default,{description:b?`${b.template.name} · 表單 v${b.formVersion.version}`:`選擇可發起的已發布模板後填寫表單內容。`,title:`發起簽核`,children:b?(0,l.jsx)(c.Button,{disabled:A||M,icon:f.CheckedIcon,iconType:`leading`,onClick:W,variant:`base-primary`,children:`送出`}):null})}),(0,l.jsx)(c.SectionGroup,{children:(0,l.jsx)(c.Section,{children:(0,l.jsxs)(`div`,{style:m,children:[E?(0,l.jsx)(c.Typography,{color:`text-error`,variant:`body`,children:E}):null,A?(0,l.jsx)(c.Typography,{color:`text-neutral`,variant:`body`,children:`載入中...`}):null,b&&L?(0,l.jsx)(o.t,{dataSourceContext:{kind:`runtime`,templateId:b.template.id},errors:O,maxWidth:480,onChange:e=>{C(e),k({})},onDataSourceStateChange:R,onFileUploadStateChange:I.onFileUploadStateChange,onUploadAttachment:G,schema:L,singleColumn:!0,uiSchema:b.formVersion.uiSchema,value:S}):null,!y&&!A?z.length>0?(0,l.jsx)(c.Table,{actions:V,columns:B,dataSource:z,fullWidth:!0}):(0,l.jsx)(c.Typography,{color:`text-neutral`,variant:`body`,children:`目前沒有可發起的已發布模板。`}):null]})})})]})}function _(){return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(c.PageHeader,{children:(0,l.jsx)(d.default,{description:`選擇可發起的已發布模板後填寫表單內容。`,title:`發起簽核`})}),(0,l.jsx)(c.SectionGroup,{children:(0,l.jsx)(c.Section,{children:(0,l.jsx)(c.Typography,{color:`text-neutral`,variant:`body`,children:`載入中...`})})})]})}exports.InstanceNewView=h;
2
2
  //# sourceMappingURL=index.cjs.map