@vef-framework-react/approval 2.24.0 → 2.25.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 (81) hide show
  1. package/dist/cjs/components/action-dialog/index.cjs +1 -0
  2. package/dist/cjs/components/detail/action-modals.cjs +1 -1
  3. package/dist/cjs/components/detail/admin.cjs +1 -1
  4. package/dist/cjs/components/detail/index.cjs +1 -1
  5. package/dist/cjs/components/form-panel/index.cjs +1 -1
  6. package/dist/cjs/pages/admin-page/tasks.cjs +1 -1
  7. package/dist/cjs/pages/flow-page/designer/flow-step.cjs +1 -1
  8. package/dist/cjs/pages/flow-page/designer/form-step.cjs +1 -1
  9. package/dist/cjs/pages/flow-page/designer/index.cjs +1 -1
  10. package/dist/cjs/pages/initiate-page/start-drawer.cjs +1 -1
  11. package/dist/cjs/plugins/form-context.cjs +1 -0
  12. package/dist/es/api/admin-api.js +1 -1
  13. package/dist/es/api/category-api.js +1 -1
  14. package/dist/es/api/delegation-api.js +1 -1
  15. package/dist/es/api/flow-api.js +1 -1
  16. package/dist/es/api/index.js +1 -1
  17. package/dist/es/api/instance-api.js +1 -1
  18. package/dist/es/api/my-api.js +1 -1
  19. package/dist/es/api/query.js +1 -1
  20. package/dist/es/components/action-dialog/index.js +60 -0
  21. package/dist/es/components/detail/action-modals.js +264 -233
  22. package/dist/es/components/detail/admin.js +3 -1
  23. package/dist/es/components/detail/drawer.js +1 -1
  24. package/dist/es/components/detail/index.js +3 -1
  25. package/dist/es/components/flow-graph/index.js +1 -1
  26. package/dist/es/components/flow-graph/node.js +1 -1
  27. package/dist/es/components/flow-graph/people-overlay.js +1 -1
  28. package/dist/es/components/flow-graph/people.js +1 -1
  29. package/dist/es/components/form-panel/index.js +23 -20
  30. package/dist/es/components/format.js +1 -1
  31. package/dist/es/components/icon.js +1 -1
  32. package/dist/es/components/index.js +1 -1
  33. package/dist/es/components/principal/index.js +1 -1
  34. package/dist/es/components/status/colors.js +1 -1
  35. package/dist/es/components/status/index.js +1 -1
  36. package/dist/es/components/status/labels.js +1 -1
  37. package/dist/es/components/timeline/index.js +1 -1
  38. package/dist/es/components/user/index.js +1 -1
  39. package/dist/es/index.js +1 -1
  40. package/dist/es/pages/admin-page/index.js +1 -1
  41. package/dist/es/pages/admin-page/instances.js +1 -1
  42. package/dist/es/pages/admin-page/metrics.js +1 -1
  43. package/dist/es/pages/admin-page/projections.js +1 -1
  44. package/dist/es/pages/admin-page/tasks.js +66 -70
  45. package/dist/es/pages/category-page/columns.js +1 -1
  46. package/dist/es/pages/category-page/form.js +1 -1
  47. package/dist/es/pages/category-page/index.js +1 -1
  48. package/dist/es/pages/delegation-page/columns.js +1 -1
  49. package/dist/es/pages/delegation-page/form.js +1 -1
  50. package/dist/es/pages/delegation-page/index.js +1 -1
  51. package/dist/es/pages/flow-page/columns.js +1 -1
  52. package/dist/es/pages/flow-page/designer/basic-step.js +1 -1
  53. package/dist/es/pages/flow-page/designer/flow-step.js +16 -34
  54. package/dist/es/pages/flow-page/designer/form-step.js +54 -65
  55. package/dist/es/pages/flow-page/designer/index.js +197 -186
  56. package/dist/es/pages/flow-page/designer/review-step.js +1 -1
  57. package/dist/es/pages/flow-page/designer/types.js +1 -1
  58. package/dist/es/pages/flow-page/index.js +1 -1
  59. package/dist/es/pages/flow-page/search.js +1 -1
  60. package/dist/es/pages/flow-page/versions.js +1 -1
  61. package/dist/es/pages/index.js +1 -1
  62. package/dist/es/pages/initiate-page/index.js +1 -1
  63. package/dist/es/pages/initiate-page/start-drawer.js +3 -1
  64. package/dist/es/pages/my-instances-page/index.js +1 -1
  65. package/dist/es/pages/task-center-page/index.js +1 -1
  66. package/dist/es/pages/task-center-page/search.js +1 -1
  67. package/dist/es/permissions.js +1 -1
  68. package/dist/es/plugins/form-context.js +34 -0
  69. package/dist/es/plugins/index.js +1 -1
  70. package/dist/es/types/enums.js +1 -1
  71. package/dist/es/types/index.js +1 -1
  72. package/dist/types/components/action-dialog/index.d.ts +44 -0
  73. package/dist/types/components/form-panel/index.d.ts +15 -3
  74. package/dist/types/index.d.ts +1 -0
  75. package/dist/types/pages/flow-page/designer/flow-step.d.ts +6 -5
  76. package/dist/types/pages/flow-page/designer/form-step.d.ts +9 -10
  77. package/dist/types/plugins/form-context.d.ts +30 -0
  78. package/dist/types/plugins/index.d.ts +25 -5
  79. package/dist/types/types/admin.d.ts +5 -0
  80. package/dist/types/types/my.d.ts +15 -0
  81. package/package.json +7 -7
@@ -1,4 +1,4 @@
1
- /*! @vef-framework-react/approval v2.24.0 made by Venus | 2026-09-28T10:02:07.034Z */
1
+ /*! @vef-framework-react/approval v2.25.0 made by Venus | 2026-10-13T08:59:38.583Z */
2
2
  //#region src/types/enums.ts
3
3
  var e = [
4
4
  "approved",
@@ -1,3 +1,3 @@
1
- /*! @vef-framework-react/approval v2.24.0 made by Venus | 2026-09-28T10:02:07.034Z */
1
+ /*! @vef-framework-react/approval v2.25.0 made by Venus | 2026-10-13T08:59:38.583Z */
2
2
  import { BUILTIN_INITIATOR_KINDS as e, FINAL_INSTANCE_STATUSES as t, isFinalInstanceStatus as n } from "./enums.js";
3
3
  export { e as BUILTIN_INITIATOR_KINDS, t as FINAL_INSTANCE_STATUSES, n as isFinalInstanceStatus };
@@ -0,0 +1,44 @@
1
+ import { ReactNode } from 'react';
2
+ export interface ActionDialogProps {
3
+ open: boolean;
4
+ title: string;
5
+ onClose: () => void;
6
+ /**
7
+ * The action form — its draft and its {@link ActionFooter}.
8
+ */
9
+ children: ReactNode;
10
+ }
11
+ /**
12
+ * Hosts a confirm-style action form. The form owns its draft and footer, so
13
+ * typing re-renders the form alone and never the Modal: a Modal re-rendered on
14
+ * every keystroke re-runs its portal's dependency-less container effect
15
+ * (@rc-component/portal), whose no-op state update React cannot always skip,
16
+ * and fast typing then stacks those updates past React's nested-update limit.
17
+ * destroyOnHidden remounts the form on every opening — which is what resets
18
+ * its draft — and keeps a closed dialog's portal unmounted altogether.
19
+ */
20
+ export declare function ActionDialog({ open, title, onClose, children }: ActionDialogProps): import("@emotion/react/jsx-runtime").JSX.Element;
21
+ export interface ActionFooterProps {
22
+ okText: string;
23
+ /**
24
+ * Renders the ok button in danger style.
25
+ */
26
+ danger?: boolean;
27
+ disabled?: boolean;
28
+ submitting: boolean;
29
+ onCancel: () => void;
30
+ onOk: () => void;
31
+ }
32
+ /**
33
+ * The cancel / confirm pair an {@link ActionDialog} form renders below itself.
34
+ */
35
+ export declare function ActionFooter({ okText, danger, disabled, submitting, onCancel, onOk }: ActionFooterProps): import("@emotion/react/jsx-runtime").JSX.Element;
36
+ /**
37
+ * Drives one confirm-style dialog: local `submitting` while the async confirm
38
+ * runs, closing only on success (errors are surfaced by the mutation layer
39
+ * and keep the dialog open for retry).
40
+ */
41
+ export declare function useConfirm(onClose: () => void): {
42
+ submitting: boolean;
43
+ run: (action: () => Promise<void>) => Promise<void>;
44
+ };
@@ -1,6 +1,6 @@
1
1
  import { FormRendererApi, FormSchema, PresentationDevice } from '@vef-framework-react/form-editor';
2
2
  import { RefObject } from 'react';
3
- import { FieldPermission, FormData } from '../../types';
3
+ import { FieldPermission, FormData, UserInfo } from '../../types';
4
4
  export interface InstanceFormPanelProps {
5
5
  /**
6
6
  * The version-pinned host form-designer document. Absent for flows without
@@ -16,6 +16,17 @@ export interface InstanceFormPanelProps {
16
16
  * The server-resolved per-field interactivity clamp, applied verbatim.
17
17
  */
18
18
  fieldPermissions?: Record<string, FieldPermission>;
19
+ /**
20
+ * The instance's applicant — the form's `$applicant`. On the start form it
21
+ * is the snapshot the instance is about to record; everywhere else it is the
22
+ * instance's own, so a rule about the initiator reads the same initiator for
23
+ * every participant who opens the form.
24
+ */
25
+ applicant?: UserInfo;
26
+ /**
27
+ * The form-visible host globals — the form's `$globals`.
28
+ */
29
+ globals?: Record<string, unknown>;
19
30
  /**
20
31
  * Force the whole form read-only (viewers with nothing to execute).
21
32
  */
@@ -33,6 +44,7 @@ export interface InstanceFormPanelProps {
33
44
  * The instance form, rendered against the version-pinned schema with the
34
45
  * viewer's field permissions clamped on: `hidden` unmounts, `visible` renders
35
46
  * read-only, `editable`/`required` grant write strength. Field registries
36
- * come from `ApprovalProvider` (defaulting to the approval profile).
47
+ * come from `ApprovalProvider` (defaulting to the approval profile); the
48
+ * applicant and the form-visible globals form its evaluation context.
37
49
  */
38
- export declare function InstanceFormPanel({ schema, formData, fieldPermissions, disabled, device, apiRef, onSubmit }: InstanceFormPanelProps): import("@emotion/react/jsx-runtime").JSX.Element;
50
+ export declare function InstanceFormPanel({ schema, formData, fieldPermissions, applicant, globals, disabled, device, apiRef, onSubmit }: InstanceFormPanelProps): import("@emotion/react/jsx-runtime").JSX.Element;
@@ -5,5 +5,6 @@ export { APPROVAL_PERMISSIONS } from './permissions';
5
5
  export type { ActionLogPermissionCodes, ApprovalPermissions, BindingPermissionCodes, CategoryPermissionCodes, DelegationPermissionCodes, FlowPermissionCodes, InstancePermissionCodes, MetricsPermissionCodes, TaskPermissionCodes } from './permissions';
6
6
  export { ApprovalProvider, toEditorPlugins, useApprovalPlugins } from './plugins';
7
7
  export type { ApprovalPlugins, ApprovalProviderProps, ResolvedApprovalPlugins } from './plugins';
8
+ export type { FormGlobalDefinition } from './plugins/form-context';
8
9
  export * from './types';
9
10
  export type { EditorPlugins, KindDescriptor, PickerProps, PrincipalKind, SelectionMode } from '@vef-framework-react/approval-flow-editor';
@@ -1,16 +1,17 @@
1
- import { EditorPlugins, FlowDefinition, FlowValidationError } from '@vef-framework-react/approval-flow-editor';
1
+ import { EditorPlugins, FlowDefinition } from '@vef-framework-react/approval-flow-editor';
2
2
  export interface FlowStepProps {
3
3
  /**
4
4
  * Seed definition; honored on the editor's first mount only.
5
5
  */
6
6
  value: FlowDefinition;
7
7
  plugins: EditorPlugins;
8
- errors: FlowValidationError[];
9
8
  onChange: (definition: FlowDefinition) => void;
10
9
  }
11
10
  /**
12
11
  * Step 3 — design the flow graph. The field-permission and condition
13
- * surfaces read the fields designed in step 2 via `plugins.formFields`; a
14
- * structurally invalid graph blocks completion.
12
+ * surfaces read the fields designed in step 2 via `plugins.formFields`. The
13
+ * editor's own toolbar indicator lists the deploy-contract problems and
14
+ * locates each one on the canvas, so the canvas keeps its full height; a
15
+ * structurally invalid graph blocks completion from the wizard's footer.
15
16
  */
16
- export declare function FlowStep({ value, plugins, errors, onChange }: FlowStepProps): import("@emotion/react/jsx-runtime").JSX.Element;
17
+ export declare function FlowStep({ value, plugins, onChange }: FlowStepProps): import("@emotion/react/jsx-runtime").JSX.Element;
@@ -1,4 +1,3 @@
1
- import { ApprovalSchemaIssue } from '@vef-framework-react/approval-form-bridge';
2
1
  import { DeviceRegistries, FormSchema } from '@vef-framework-react/form-editor';
3
2
  import { StorageMode } from '../../../types';
4
3
  export interface FormStepProps {
@@ -8,11 +7,6 @@ export interface FormStepProps {
8
7
  * mount only.
9
8
  */
10
9
  initialSchema?: FormSchema;
11
- /**
12
- * Save-gate diagnostics (structural + projection) for the current schema;
13
- * errors block the next step, warnings are informational.
14
- */
15
- issues: ApprovalSchemaIssue[];
16
10
  /**
17
11
  * The approval-profile registries, owned by the designer so the editor and
18
12
  * the save gate share one instance.
@@ -24,8 +18,13 @@ export interface FormStepProps {
24
18
  /**
25
19
  * Step 2 — design the form. The rich schema deploys verbatim
26
20
  * (`DeployFlowCmd.FormSchema`); the backend derives the flat field list at
27
- * deploy, and the storage mode decides how that model persists. The
28
- * approval-form-bridge projection runs on change as a client-side pre-check
29
- * of the server parser.
21
+ * deploy, and the storage mode decides how that model persists.
22
+ *
23
+ * Every diagnostic — the editor's structural ones and the approval contract's
24
+ * (the bridge projection, a client-side pre-check of the server parser) —
25
+ * lives in the editor's own status bar, where each one jumps to its field, so
26
+ * the canvas keeps its full height; the wizard's footer only says why the step
27
+ * cannot advance. The applicant attributes and the host's form globals are
28
+ * offered as system variables.
30
29
  */
31
- export declare function FormStep({ storageMode, initialSchema, issues, registries, onStorageModeChange, onSchemaChange }: FormStepProps): import("@emotion/react/jsx-runtime").JSX.Element;
30
+ export declare function FormStep({ storageMode, initialSchema, registries, onStorageModeChange, onSchemaChange }: FormStepProps): import("@emotion/react/jsx-runtime").JSX.Element;
@@ -0,0 +1,30 @@
1
+ import { EvaluationContext, LinkageContextSource } from '@vef-framework-react/form-editor';
2
+ import { UserInfo } from '../types';
3
+ /**
4
+ * A host global an approval form may read, declared so the form designer can
5
+ * offer it. The value itself comes from the backend: the host's
6
+ * `InstanceGlobalsResolver` produces it and its `FormGlobalsExposer` names it,
7
+ * which is what ships it to the form as `$globals.<key>`.
8
+ */
9
+ export interface FormGlobalDefinition {
10
+ /**
11
+ * The global's key, exactly as the resolver produces it.
12
+ */
13
+ key: string;
14
+ /**
15
+ * Display name in the designer, e.g. `"发起人职称"`.
16
+ */
17
+ label: string;
18
+ }
19
+ /**
20
+ * The system variables the approval form designer offers: the built-in
21
+ * applicant attributes, then the host's declared form globals.
22
+ */
23
+ export declare function toFormContextSources(formGlobals: readonly FormGlobalDefinition[] | undefined): LinkageContextSource[];
24
+ /**
25
+ * The evaluation context an approval form runs under: the instance's applicant
26
+ * as `$applicant` and its form-visible globals as `$globals`. Never `$user`:
27
+ * the form is evaluated for every participant, and a rule about the initiator
28
+ * must read the same initiator for each of them.
29
+ */
30
+ export declare function toFormEvaluationContext(applicant: UserInfo | undefined, globals: Record<string, unknown> | undefined): EvaluationContext;
@@ -1,7 +1,8 @@
1
1
  import { EditorPlugins, FormFieldDefinition, PickerProps } from '@vef-framework-react/approval-flow-editor';
2
- import { DataSourceResolver, DeviceRegistries, LinkageEvaluators } from '@vef-framework-react/form-editor';
2
+ import { DataSourceApi, DataSourceResolver, DeviceRegistries, LinkageEvaluators } from '@vef-framework-react/form-editor';
3
3
  import { FC, PropsWithChildren, ReactNode } from 'react';
4
4
  import { KindOptions } from '../types';
5
+ import { FormGlobalDefinition } from './form-context';
5
6
  /**
6
7
  * Host-integration points shared by every approval page and component. Wrap
7
8
  * the approval routes in one `ApprovalProvider` and every picker, registry,
@@ -33,19 +34,38 @@ export interface ApprovalPlugins {
33
34
  * `Instance.Globals` at instance start.
34
35
  */
35
36
  globalSubjects?: FormFieldDefinition[];
37
+ /**
38
+ * The host globals the backend exposes to approval forms (the host's globals
39
+ * resolver implementing `FormGlobalsExposer`), declared so the form designer
40
+ * offers them as `$globals.<key>` system variables beside the built-in
41
+ * `$applicant` attributes. Keep the keys in lockstep with the resolver's
42
+ * `FormGlobalKeys`, as `globalSubjects` are kept with the keys it resolves:
43
+ * a key exposed there but not declared here still evaluates at runtime yet is
44
+ * not offered, and one declared here but not exposed is offered yet always
45
+ * reads as empty.
46
+ */
47
+ formGlobals?: FormGlobalDefinition[];
36
48
  /**
37
49
  * Turns a form's remote data-source request into options. Without one, every
38
50
  * remote source in an approval form resolves to an empty list — the designer
39
51
  * lets you configure the request, but nothing fetches it. Wire the host's
40
- * API client here.
52
+ * API client here; the form designer's preview uses it too.
41
53
  */
42
54
  dataSourceResolver?: DataSourceResolver;
55
+ /**
56
+ * The host's catalog of option APIs. The form designer's remote data sources
57
+ * then lead with a picker ("部门列表") instead of a hand-typed endpoint and
58
+ * field mapping. A pick is stored as the request itself, so the runtime still
59
+ * fetches through `dataSourceResolver`, which must serve every endpoint
60
+ * listed here.
61
+ */
62
+ dataSourceApis?: DataSourceApi[];
43
63
  /**
44
64
  * Overrides for expression / script evaluation in form linkage and in
45
65
  * data-source parameters bound to the form. Optional: the form runtime falls
46
- * back to its built-in JavaScript evaluator (`$form` / `$vars` / `$user` /
47
- * `$node` in scope), so wire this only to swap in a different expression
48
- * language or sandbox.
66
+ * back to its built-in JavaScript evaluator (`$form` / `$vars` /
67
+ * `$applicant` / `$globals` in scope), so wire this only to swap in a
68
+ * different expression language or sandbox.
49
69
  */
50
70
  evaluators?: LinkageEvaluators;
51
71
  /**
@@ -54,6 +54,11 @@ export interface AdminInstanceInfo {
54
54
  currentNodeName?: string;
55
55
  businessRef?: string;
56
56
  formData?: FormData;
57
+ /**
58
+ * The form-visible part of the instance's globals snapshot — the form's
59
+ * `$globals`, as resolved at initiation. Absent when the flow exposes none.
60
+ */
61
+ globals?: Record<string, unknown>;
57
62
  createdAt: string;
58
63
  finishedAt?: string;
59
64
  }
@@ -31,6 +31,16 @@ export interface StartForm {
31
31
  versionId: string;
32
32
  version: number;
33
33
  formSchema?: FormSchema;
34
+ /**
35
+ * The snapshot the instance will record if the caller starts it now — the
36
+ * form's `$applicant`, resolved exactly as starting resolves it.
37
+ */
38
+ applicant: UserInfo;
39
+ /**
40
+ * The host globals the flow exposes to its form, resolved for the caller —
41
+ * the form's `$globals`. Absent when the flow exposes none.
42
+ */
43
+ globals?: Record<string, unknown>;
34
44
  }
35
45
  /**
36
46
  * An approval instance submitted by the current user, mirroring
@@ -124,6 +134,11 @@ export interface MyInstanceInfo {
124
134
  currentNodeName?: string;
125
135
  businessRef?: string;
126
136
  formData?: FormData;
137
+ /**
138
+ * The form-visible part of the instance's globals snapshot — the form's
139
+ * `$globals`, as resolved at initiation. Absent when the flow exposes none.
140
+ */
141
+ globals?: Record<string, unknown>;
127
142
  createdAt: string;
128
143
  finishedAt?: string;
129
144
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vef-framework-react/approval",
3
- "version": "2.24.0",
3
+ "version": "2.25.0",
4
4
  "private": false,
5
5
  "description": "Approval engine pages and runtime components for VEF framework",
6
6
  "keywords": [
@@ -44,12 +44,12 @@
44
44
  "@xyflow/react": "^12.11.1",
45
45
  "dayjs": "^1.11.0",
46
46
  "lucide-react": "^1.23.0",
47
- "@vef-framework-react/approval-form-bridge": "2.24.0",
48
- "@vef-framework-react/components": "2.24.0",
49
- "@vef-framework-react/form-editor": "2.24.0",
50
- "@vef-framework-react/approval-flow-editor": "2.24.0",
51
- "@vef-framework-react/shared": "2.24.0",
52
- "@vef-framework-react/core": "2.24.0"
47
+ "@vef-framework-react/approval-flow-editor": "2.25.0",
48
+ "@vef-framework-react/approval-form-bridge": "2.25.0",
49
+ "@vef-framework-react/core": "2.25.0",
50
+ "@vef-framework-react/components": "2.25.0",
51
+ "@vef-framework-react/form-editor": "2.25.0",
52
+ "@vef-framework-react/shared": "2.25.0"
53
53
  },
54
54
  "devDependencies": {
55
55
  "react": "^19.2.7"