@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.
- package/CHANGELOG.md +52 -0
- package/dist/chunks/{FormBuilderView-vQfVc08Z.js → FormBuilderView-CFRiw04B.js} +563 -475
- package/dist/chunks/FormBuilderView-CFRiw04B.js.map +1 -0
- package/dist/chunks/FormBuilderView-CpUgbSbt.cjs +3 -0
- package/dist/chunks/FormBuilderView-CpUgbSbt.cjs.map +1 -0
- package/dist/chunks/FormRendererView-GfbVWEGa.js +1321 -0
- package/dist/chunks/FormRendererView-GfbVWEGa.js.map +1 -0
- package/dist/chunks/FormRendererView-lYSaR8CQ.cjs +6 -0
- package/dist/chunks/FormRendererView-lYSaR8CQ.cjs.map +1 -0
- package/dist/chunks/{compose-DtfX8DQ9.cjs → compose-Bb5bUVFd.cjs} +2 -2
- package/dist/chunks/{compose-DtfX8DQ9.cjs.map → compose-Bb5bUVFd.cjs.map} +1 -1
- package/dist/chunks/{compose-D9ipJpF_.js → compose-egQlRjuZ.js} +5 -4
- package/dist/chunks/{compose-D9ipJpF_.js.map → compose-egQlRjuZ.js.map} +1 -1
- package/dist/chunks/{delegations-BfhCDz5e.js → delegations-9-yvWWws.js} +3 -2
- package/dist/chunks/delegations-9-yvWWws.js.map +1 -0
- package/dist/chunks/delegations-CVmtpkRn.cjs +2 -0
- package/dist/chunks/delegations-CVmtpkRn.cjs.map +1 -0
- package/dist/chunks/delegations-CrfjsH94.cjs +2 -0
- package/dist/chunks/delegations-CrfjsH94.cjs.map +1 -0
- package/dist/chunks/{delegations-DBh5TT6G.js → delegations-CxnNvTCc.js} +3 -2
- package/dist/chunks/delegations-CxnNvTCc.js.map +1 -0
- package/dist/chunks/designer-CX9bhYJS.cjs +69 -0
- package/dist/chunks/designer-CX9bhYJS.cjs.map +1 -0
- package/dist/chunks/{designer-ubnZbP-A.js → designer-CZDlQ9Nf.js} +2341 -1584
- package/dist/chunks/designer-CZDlQ9Nf.js.map +1 -0
- package/dist/chunks/{detail-C6XKZjlF.js → detail-ByZV1XaI.js} +853 -840
- package/dist/chunks/detail-ByZV1XaI.js.map +1 -0
- package/dist/chunks/detail-ChseSF55.cjs +5 -0
- package/dist/chunks/detail-ChseSF55.cjs.map +1 -0
- package/dist/chunks/{approver-filled-form-B4zPg9kz.cjs → instance-error-message-DTARGbGo.cjs} +2 -2
- package/dist/chunks/instance-error-message-DTARGbGo.cjs.map +1 -0
- package/dist/chunks/{approver-filled-form-Bgazhbvd.js → instance-error-message-q6gy5evy.js} +44 -36
- package/dist/chunks/instance-error-message-q6gy5evy.js.map +1 -0
- package/dist/chunks/workflow-chat-prompt-B4wCFKPB.js +25 -0
- package/dist/chunks/workflow-chat-prompt-B4wCFKPB.js.map +1 -0
- package/dist/chunks/workflow-chat-prompt-B803qVdt.cjs +27 -0
- package/dist/chunks/workflow-chat-prompt-B803qVdt.cjs.map +1 -0
- package/dist/next/workflow-chat-route.cjs +8 -19
- package/dist/next/workflow-chat-route.cjs.map +1 -1
- package/dist/next/workflow-chat-route.d.cts +92 -4
- package/dist/next/workflow-chat-route.d.ts +92 -4
- package/dist/next/workflow-chat-route.js +127 -19
- package/dist/next/workflow-chat-route.js.map +1 -1
- package/dist/pages/admin/delegations/index.cjs +1 -1
- package/dist/pages/admin/delegations/index.js +1 -1
- package/dist/pages/delegations/index.cjs +1 -1
- package/dist/pages/delegations/index.js +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/admin/delegations/index.cjs +1 -1
- package/dist/views/admin/delegations/index.js +1 -1
- package/dist/views/admin/index.cjs +1 -1
- package/dist/views/admin/index.js +1 -1
- package/dist/views/delegations/index.cjs +1 -1
- package/dist/views/delegations/index.js +1 -1
- package/dist/views/forms/builder/index.cjs +1 -1
- package/dist/views/forms/builder/index.js +1 -1
- package/dist/views/forms/renderer/FormRendererView.d.cts +25 -2
- package/dist/views/forms/renderer/FormRendererView.d.ts +25 -2
- package/dist/views/forms/renderer/file-upload-field.d.cts +84 -0
- package/dist/views/forms/renderer/file-upload-field.d.ts +84 -0
- package/dist/views/forms/renderer/form-data-source-field.d.cts +9 -1
- package/dist/views/forms/renderer/form-data-source-field.d.ts +9 -1
- package/dist/views/forms/renderer/form-value-readers.d.cts +7 -0
- package/dist/views/forms/renderer/form-value-readers.d.ts +7 -0
- package/dist/views/forms/renderer/index.cjs +1 -1
- package/dist/views/forms/renderer/index.d.cts +1 -0
- package/dist/views/forms/renderer/index.d.ts +1 -0
- package/dist/views/forms/renderer/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/InstanceFormSection.d.cts +20 -3
- package/dist/views/instances/detail/sections/InstanceFormSection.d.ts +20 -3
- package/dist/views/instances/detail/sections/shared.d.cts +1 -2
- package/dist/views/instances/detail/sections/shared.d.ts +1 -2
- package/dist/views/instances/instance-error-message.d.cts +5 -0
- package/dist/views/instances/instance-error-message.d.ts +5 -0
- package/dist/views/instances/new/index.cjs +1 -1
- package/dist/views/instances/new/index.cjs.map +1 -1
- package/dist/views/instances/new/index.js +79 -76
- package/dist/views/instances/new/index.js.map +1 -1
- package/dist/views/templates/compose/index.cjs +1 -1
- package/dist/views/templates/compose/index.js +1 -1
- package/dist/views/templates/designer/designer-version-labels.d.cts +7 -0
- package/dist/views/templates/designer/designer-version-labels.d.ts +7 -0
- package/dist/views/templates/designer/expression/DialectUpgradeModal.d.cts +25 -0
- package/dist/views/templates/designer/expression/DialectUpgradeModal.d.ts +25 -0
- package/dist/views/templates/designer/expression/ExpressionField.d.cts +79 -0
- package/dist/views/templates/designer/expression/ExpressionField.d.ts +79 -0
- package/dist/views/templates/designer/expression/use-workflow-expression-references.d.cts +22 -0
- package/dist/views/templates/designer/expression/use-workflow-expression-references.d.ts +22 -0
- package/dist/views/templates/designer/expression/workflow-expression-edits.d.cts +58 -0
- package/dist/views/templates/designer/expression/workflow-expression-edits.d.ts +58 -0
- package/dist/views/templates/designer/expression/workflow-expression-tools.d.cts +14 -0
- package/dist/views/templates/designer/expression/workflow-expression-tools.d.ts +14 -0
- package/dist/views/templates/designer/field-access-matrix/FieldAccessMatrixDrawer.d.cts +7 -1
- package/dist/views/templates/designer/field-access-matrix/FieldAccessMatrixDrawer.d.ts +7 -1
- package/dist/views/templates/designer/index.cjs +1 -1
- package/dist/views/templates/designer/index.js +1 -1
- package/dist/views/templates/designer/notify-webhook-designer.d.cts +8 -0
- package/dist/views/templates/designer/notify-webhook-designer.d.ts +8 -0
- package/dist/views/templates/designer/use-workflow-designer-controller.d.cts +8 -2
- package/dist/views/templates/designer/use-workflow-designer-controller.d.ts +8 -2
- package/dist/views/templates/designer/workflow-chat-prompt.d.cts +18 -0
- package/dist/views/templates/designer/workflow-chat-prompt.d.ts +18 -0
- package/package.json +3 -3
- package/dist/chunks/FormBuilderView-CHaAQL5v.cjs +0 -3
- package/dist/chunks/FormBuilderView-CHaAQL5v.cjs.map +0 -1
- package/dist/chunks/FormBuilderView-vQfVc08Z.js.map +0 -1
- package/dist/chunks/FormRendererView-CTLlG13b.js +0 -1106
- package/dist/chunks/FormRendererView-CTLlG13b.js.map +0 -1
- package/dist/chunks/FormRendererView-ChmM_4Yc.cjs +0 -4
- package/dist/chunks/FormRendererView-ChmM_4Yc.cjs.map +0 -1
- package/dist/chunks/approver-filled-form-B4zPg9kz.cjs.map +0 -1
- package/dist/chunks/approver-filled-form-Bgazhbvd.js.map +0 -1
- package/dist/chunks/delegations-BfhCDz5e.js.map +0 -1
- package/dist/chunks/delegations-BmFGcuhA.cjs +0 -2
- package/dist/chunks/delegations-BmFGcuhA.cjs.map +0 -1
- package/dist/chunks/delegations-CcS0SHbf.cjs +0 -2
- package/dist/chunks/delegations-CcS0SHbf.cjs.map +0 -1
- package/dist/chunks/delegations-DBh5TT6G.js.map +0 -1
- package/dist/chunks/designer-Df79YzUn.cjs +0 -65
- package/dist/chunks/designer-Df79YzUn.cjs.map +0 -1
- package/dist/chunks/designer-ubnZbP-A.js.map +0 -1
- package/dist/chunks/detail-BBC9kqXd.cjs +0 -5
- package/dist/chunks/detail-BBC9kqXd.cjs.map +0 -1
- 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-
|
|
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 +1 @@
|
|
|
1
|
-
export { t as FormRenderer, t as FormRendererView,
|
|
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-
|
|
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-
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
|
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
|
|
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 {};
|
|
@@ -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/
|
|
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
|