@vef-framework-react/form-editor 2.5.0 → 2.7.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/dist/cjs/components/button/index.cjs +1 -1
- package/dist/cjs/components/checkbox-group-field/index.cjs +1 -1
- package/dist/cjs/components/code-editor/index.cjs +1 -1
- package/dist/cjs/components/date-field/index.cjs +1 -1
- package/dist/cjs/components/field-entries.cjs +1 -1
- package/dist/cjs/components/mobile/checkbox-group.cjs +1 -1
- package/dist/cjs/components/mobile/input-cell.cjs +1 -1
- package/dist/cjs/components/mobile/number.cjs +1 -1
- package/dist/cjs/components/mobile/switch.cjs +1 -1
- package/dist/cjs/components/mobile/textfield.cjs +1 -1
- package/dist/cjs/components/number-field/index.cjs +1 -1
- package/dist/cjs/components/radio-field/index.cjs +1 -1
- package/dist/cjs/components/select-field/index.cjs +1 -1
- package/dist/cjs/components/textfield/index.cjs +1 -1
- package/dist/cjs/editor/canvas/canvas-field.cjs +1 -1
- package/dist/cjs/editor/canvas/canvas.cjs +1 -1
- package/dist/cjs/editor/canvas/drop-zones.cjs +1 -1
- package/dist/cjs/editor/canvas/json-split-view.cjs +1 -1
- package/dist/cjs/editor/canvas/subform-column-eligibility.cjs +1 -1
- package/dist/cjs/editor/context-sources.cjs +1 -0
- package/dist/cjs/editor/dnd.cjs +1 -1
- package/dist/cjs/editor/editor-layout-context.cjs +1 -1
- package/dist/cjs/editor/form-config/form-config-drawer.cjs +1 -1
- package/dist/cjs/editor/form-config/linkage-overview.cjs +1 -0
- package/dist/cjs/editor/form-editor.cjs +1 -1
- package/dist/cjs/editor/palette/palette-group.cjs +1 -1
- package/dist/cjs/editor/preview-runtime-context.cjs +1 -1
- package/dist/cjs/editor/properties/container-properties.cjs +1 -1
- package/dist/cjs/editor/properties/entries/index.cjs +1 -1
- package/dist/cjs/editor/properties/entries/linkage/action-editor.cjs +2 -2
- package/dist/cjs/editor/properties/entries/linkage/actions-editor.cjs +1 -1
- package/dist/cjs/editor/properties/entries/linkage/condition-editor.cjs +1 -1
- package/dist/cjs/editor/properties/entries/linkage/container-linkage-section.cjs +1 -1
- package/dist/cjs/editor/properties/entries/linkage/expression-input.cjs +1 -0
- package/dist/cjs/editor/properties/entries/linkage/linkage-rules-entry.cjs +1 -1
- package/dist/cjs/editor/properties/entries/linkage/mutators.cjs +1 -1
- package/dist/cjs/editor/properties/entries/linkage/options.cjs +1 -1
- package/dist/cjs/editor/properties/entries/linkage/rule-diagnostics.cjs +1 -1
- package/dist/cjs/editor/properties/entries/linkage/rule-list-editor.cjs +1 -1
- package/dist/cjs/editor/properties/entries/linkage/trigger-editor.cjs +1 -1
- package/dist/cjs/editor/properties/entries/linkage/use-linkage-editor-model.cjs +1 -1
- package/dist/cjs/editor/properties/form-linkage-panel.cjs +1 -1
- package/dist/cjs/editor/properties/form-variables-panel.cjs +1 -1
- package/dist/cjs/editor/properties/properties-panel.cjs +1 -1
- package/dist/cjs/editor/properties/properties-provider.cjs +1 -1
- package/dist/cjs/editor/remove-node-confirm.cjs +2 -1
- package/dist/cjs/editor/schema-apply.cjs +2 -2
- package/dist/cjs/editor/toolbar/notify.cjs +1 -1
- package/dist/cjs/editor/toolbar/toolbar.cjs +2 -1
- package/dist/cjs/engine/conversion/index.cjs +1 -1
- package/dist/cjs/engine/keys.cjs +1 -1
- package/dist/cjs/engine/linkage/cycle.cjs +1 -1
- package/dist/cjs/engine/linkage/default-evaluator.cjs +1 -1
- package/dist/cjs/engine/linkage/effects.cjs +1 -1
- package/dist/cjs/engine/linkage/evaluator.cjs +1 -1
- package/dist/cjs/engine/linkage/index.cjs +1 -1
- package/dist/cjs/engine/linkage/operators.cjs +1 -1
- package/dist/cjs/engine/linkage/source-tracking.cjs +1 -1
- package/dist/cjs/engine/linkage/taxonomy.cjs +1 -1
- package/dist/cjs/engine/linkage/validator.cjs +1 -1
- package/dist/cjs/engine/registry/form-field-registry.cjs +1 -1
- package/dist/cjs/engine/schema/column-type.cjs +1 -0
- package/dist/cjs/engine/schema/edit-ops.cjs +1 -1
- package/dist/cjs/engine/schema/permission-bridge.cjs +1 -1
- package/dist/cjs/engine/schema/presentation.cjs +1 -1
- package/dist/cjs/engine/schema/reconcile.cjs +1 -1
- package/dist/cjs/engine/schema/validate.cjs +1 -1
- package/dist/cjs/engine/schema/walk.cjs +1 -1
- package/dist/cjs/engine/validation.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/render/form-renderer.cjs +1 -1
- package/dist/cjs/render/stack-style.cjs +1 -1
- package/dist/cjs/render/submit.cjs +1 -1
- package/dist/cjs/runtime/effects.cjs +1 -1
- package/dist/cjs/runtime/runtime-state-controller.cjs +1 -1
- package/dist/cjs/runtime/stabilize-state-map.cjs +1 -1
- package/dist/cjs/store/form-store.cjs +1 -1
- package/dist/cjs/types/index.cjs +1 -1
- package/dist/es/components/button/index.js +18 -18
- package/dist/es/components/checkbox-group-field/index.js +20 -19
- package/dist/es/components/code-editor/code-editor-input.js +1 -1
- package/dist/es/components/code-editor/index.js +31 -31
- package/dist/es/components/containers/index.js +1 -1
- package/dist/es/components/date-field/index.js +4 -2
- package/dist/es/components/display/index.js +1 -1
- package/dist/es/components/field-entries.js +22 -5
- package/dist/es/components/mobile/alert-block.js +1 -1
- package/dist/es/components/mobile/button.js +1 -1
- package/dist/es/components/mobile/checkbox-group.js +18 -18
- package/dist/es/components/mobile/date-adapters.js +1 -1
- package/dist/es/components/mobile/date.js +1 -1
- package/dist/es/components/mobile/daterange.js +1 -1
- package/dist/es/components/mobile/datetime.js +1 -1
- package/dist/es/components/mobile/definitions.js +1 -1
- package/dist/es/components/mobile/divider.js +1 -1
- package/dist/es/components/mobile/input-cell.js +13 -9
- package/dist/es/components/mobile/number.js +30 -35
- package/dist/es/components/mobile/option-group.js +1 -1
- package/dist/es/components/mobile/paragraph.js +1 -1
- package/dist/es/components/mobile/picker-trigger.js +1 -1
- package/dist/es/components/mobile/radio.js +1 -1
- package/dist/es/components/mobile/scope.js +1 -1
- package/dist/es/components/mobile/select.js +1 -1
- package/dist/es/components/mobile/switch.js +43 -19
- package/dist/es/components/mobile/textarea.js +1 -1
- package/dist/es/components/mobile/textfield.js +30 -26
- package/dist/es/components/mobile/theme.js +1 -1
- package/dist/es/components/number-field/index.js +28 -16
- package/dist/es/components/radio-field/index.js +30 -18
- package/dist/es/components/select-field/index.js +28 -16
- package/dist/es/components/switch-field/index.js +1 -1
- package/dist/es/components/textarea-field/index.js +1 -1
- package/dist/es/components/textfield/index.js +29 -28
- package/dist/es/editor/canvas/canvas-field.js +13 -11
- package/dist/es/editor/canvas/canvas.js +259 -248
- package/dist/es/editor/canvas/drop-indicator.js +1 -1
- package/dist/es/editor/canvas/drop-zones.js +31 -23
- package/dist/es/editor/canvas/json-split-view.js +73 -73
- package/dist/es/editor/canvas/mobile-seed-state.js +1 -1
- package/dist/es/editor/canvas/phone-frame.js +1 -1
- package/dist/es/editor/canvas/subform-column-eligibility.js +2 -2
- package/dist/es/editor/canvas/subform-table-cell.js +1 -1
- package/dist/es/editor/context-sources.js +21 -0
- package/dist/es/editor/dnd.js +2 -2
- package/dist/es/editor/editor-layout-context.js +2 -2
- package/dist/es/editor/footer/footer.js +1 -1
- package/dist/es/editor/form-config/form-basics-tab.js +1 -1
- package/dist/es/editor/form-config/form-config-drawer.js +125 -103
- package/dist/es/editor/form-config/linkage-overview.js +96 -0
- package/dist/es/editor/form-config/outline-tab.js +1 -1
- package/dist/es/editor/form-editor.js +97 -91
- package/dist/es/editor/palette/field-groups.js +1 -1
- package/dist/es/editor/palette/palette-group.js +3 -2
- package/dist/es/editor/palette/palette-item.js +1 -1
- package/dist/es/editor/palette/palette-panel.js +1 -1
- package/dist/es/editor/preview-effects.js +1 -1
- package/dist/es/editor/preview-runtime-context.js +3 -3
- package/dist/es/editor/properties/block-layout-section.js +1 -1
- package/dist/es/editor/properties/container-properties.js +16 -24
- package/dist/es/editor/properties/entries/built-ins.js +1 -1
- package/dist/es/editor/properties/entries/checkbox-entry.js +1 -1
- package/dist/es/editor/properties/entries/coerce.js +1 -1
- package/dist/es/editor/properties/entries/entry-field.js +1 -1
- package/dist/es/editor/properties/entries/icon-entry.js +1 -1
- package/dist/es/editor/properties/entries/index.js +10 -9
- package/dist/es/editor/properties/entries/key-entry.js +1 -1
- package/dist/es/editor/properties/entries/linkage/action-editor.js +117 -136
- package/dist/es/editor/properties/entries/linkage/actions-editor.js +13 -14
- package/dist/es/editor/properties/entries/linkage/condition-editor.js +158 -163
- package/dist/es/editor/properties/entries/linkage/container-linkage-section.js +18 -20
- package/dist/es/editor/properties/entries/linkage/expression-input.js +17 -0
- package/dist/es/editor/properties/entries/linkage/index.js +1 -1
- package/dist/es/editor/properties/entries/linkage/linkage-rules-entry.js +9 -11
- package/dist/es/editor/properties/entries/linkage/mutators.js +13 -13
- package/dist/es/editor/properties/entries/linkage/options.js +4 -4
- package/dist/es/editor/properties/entries/linkage/rule-diagnostics.js +30 -20
- package/dist/es/editor/properties/entries/linkage/rule-list-editor.js +29 -32
- package/dist/es/editor/properties/entries/linkage/styles.js +1 -1
- package/dist/es/editor/properties/entries/linkage/trigger-editor.js +10 -11
- package/dist/es/editor/properties/entries/linkage/use-linkage-editor-model.js +12 -13
- package/dist/es/editor/properties/entries/linkage/use-stable-options.js +1 -1
- package/dist/es/editor/properties/entries/number-entry.js +1 -1
- package/dist/es/editor/properties/entries/options-source/index.js +1 -1
- package/dist/es/editor/properties/entries/options-source/source-mutators.js +1 -1
- package/dist/es/editor/properties/entries/select-entry.js +1 -1
- package/dist/es/editor/properties/entries/text-entry.js +1 -1
- package/dist/es/editor/properties/form-data-sources-panel.js +1 -1
- package/dist/es/editor/properties/form-linkage-panel.js +2 -4
- package/dist/es/editor/properties/form-variables-panel.js +4 -4
- package/dist/es/editor/properties/option-editors.js +1 -1
- package/dist/es/editor/properties/panel-header.js +1 -1
- package/dist/es/editor/properties/properties-empty.js +1 -1
- package/dist/es/editor/properties/properties-header.js +1 -1
- package/dist/es/editor/properties/properties-panel.js +9 -9
- package/dist/es/editor/properties/properties-provider.js +6 -10
- package/dist/es/editor/properties/properties-tabs.js +1 -1
- package/dist/es/editor/properties/use-confirmable-kind-switch.js +1 -1
- package/dist/es/editor/remove-node-confirm.js +24 -29
- package/dist/es/editor/schema-apply.js +15 -17
- package/dist/es/editor/styles.js +1 -1
- package/dist/es/editor/toolbar/notify.js +9 -8
- package/dist/es/editor/toolbar/schema-io.js +1 -1
- package/dist/es/editor/toolbar/toolbar.js +61 -55
- package/dist/es/editor/use-editor-shortcuts.js +1 -1
- package/dist/es/editor/validation-summary.js +1 -1
- package/dist/es/engine/assert-never.js +1 -1
- package/dist/es/engine/conversion/index.js +2 -2
- package/dist/es/engine/ids.js +1 -1
- package/dist/es/engine/keys.js +28 -20
- package/dist/es/engine/linkage/cycle.js +6 -6
- package/dist/es/engine/linkage/default-evaluator.js +37 -32
- package/dist/es/engine/linkage/effects.js +13 -12
- package/dist/es/engine/linkage/evaluator.js +50 -47
- package/dist/es/engine/linkage/index.js +9 -8
- package/dist/es/engine/linkage/operators.js +51 -24
- package/dist/es/engine/linkage/source-tracking.js +15 -12
- package/dist/es/engine/linkage/taxonomy.js +12 -12
- package/dist/es/engine/linkage/validator.js +59 -50
- package/dist/es/engine/registry/defaults-mobile.js +1 -1
- package/dist/es/engine/registry/defaults.js +1 -1
- package/dist/es/engine/registry/form-field-registry.js +6 -6
- package/dist/es/engine/schema/column-type.js +38 -0
- package/dist/es/engine/schema/edit-ops.js +14 -11
- package/dist/es/engine/schema/mutate.js +1 -1
- package/dist/es/engine/schema/nodes.js +1 -1
- package/dist/es/engine/schema/permission-bridge.js +17 -22
- package/dist/es/engine/schema/presentation.js +2 -3
- package/dist/es/engine/schema/reconcile.js +4 -8
- package/dist/es/engine/schema/removal-impact.js +1 -1
- package/dist/es/engine/schema/rewrite.js +1 -1
- package/dist/es/engine/schema/validate.js +74 -71
- package/dist/es/engine/schema/walk.js +2 -2
- package/dist/es/engine/validation.js +15 -11
- package/dist/es/icons.js +1 -1
- package/dist/es/index.js +4 -3
- package/dist/es/render/chrome/mobile-chrome.js +1 -1
- package/dist/es/render/chrome/pc-chrome.js +1 -1
- package/dist/es/render/chrome/subform-shell.js +1 -1
- package/dist/es/render/data-source-context.js +0 -0
- package/dist/es/render/flex-style.js +1 -1
- package/dist/es/render/form-field.js +1 -1
- package/dist/es/render/form-renderer.js +180 -217
- package/dist/es/render/grid-style.js +1 -1
- package/dist/es/render/parts/field-shell.js +1 -1
- package/dist/es/render/parts/label.js +1 -1
- package/dist/es/render/parts/options-status.js +1 -1
- package/dist/es/render/stack-style.js +2 -2
- package/dist/es/render/subform-columns.js +1 -1
- package/dist/es/render/submit.js +6 -6
- package/dist/es/runtime/effects.js +37 -34
- package/dist/es/runtime/resolve-scope-values.js +1 -1
- package/dist/es/runtime/runtime-context.js +1 -1
- package/dist/es/runtime/runtime-state-controller.js +8 -8
- package/dist/es/runtime/stabilize-state-map.js +5 -3
- package/dist/es/store/engine-provider.js +1 -1
- package/dist/es/store/form-store.js +14 -8
- package/dist/es/types/chrome.js +1 -1
- package/dist/es/types/component.js +1 -1
- package/dist/es/types/data-source.js +1 -1
- package/dist/es/types/index.js +6 -5
- package/dist/es/types/linkage.js +1 -1
- package/dist/es/types/properties.js +1 -1
- package/dist/es/types/schema.js +1 -1
- package/dist/types/components/field-entries.d.ts +15 -1
- package/dist/types/components/mobile/input-cell.d.ts +5 -0
- package/dist/types/components/mobile/switch.d.ts +9 -8
- package/dist/types/components/mobile/textfield.d.ts +3 -0
- package/dist/types/editor/canvas/drop-zones.d.ts +12 -1
- package/dist/types/editor/context-sources.d.ts +19 -0
- package/dist/types/editor/dnd.d.ts +5 -4
- package/dist/types/editor/form-config/linkage-overview.d.ts +8 -0
- package/dist/types/editor/form-editor.d.ts +23 -5
- package/dist/types/editor/preview-runtime-context.d.ts +3 -3
- package/dist/types/editor/properties/entries/linkage/action-editor.d.ts +0 -5
- package/dist/types/editor/properties/entries/linkage/actions-editor.d.ts +0 -5
- package/dist/types/editor/properties/entries/linkage/condition-editor.d.ts +1 -6
- package/dist/types/editor/properties/entries/linkage/expression-input.d.ts +22 -0
- package/dist/types/editor/properties/entries/linkage/rule-diagnostics.d.ts +10 -0
- package/dist/types/editor/properties/entries/linkage/rule-list-editor.d.ts +0 -5
- package/dist/types/editor/properties/entries/linkage/trigger-editor.d.ts +0 -5
- package/dist/types/editor/properties/entries/linkage/use-linkage-editor-model.d.ts +5 -10
- package/dist/types/editor/properties/entries/linkage/use-stable-options.d.ts +4 -4
- package/dist/types/editor/properties/form-variables-panel.d.ts +1 -1
- package/dist/types/editor/toolbar/notify.d.ts +17 -1
- package/dist/types/editor/toolbar/toolbar.d.ts +9 -1
- package/dist/types/engine/keys.d.ts +11 -1
- package/dist/types/engine/linkage/default-evaluator.d.ts +6 -7
- package/dist/types/engine/linkage/effects.d.ts +2 -2
- package/dist/types/engine/linkage/evaluator.d.ts +12 -6
- package/dist/types/engine/linkage/index.d.ts +1 -1
- package/dist/types/engine/linkage/operators.d.ts +7 -5
- package/dist/types/engine/linkage/taxonomy.d.ts +4 -3
- package/dist/types/engine/registry/form-field-registry.d.ts +1 -1
- package/dist/types/engine/schema/column-type.d.ts +30 -0
- package/dist/types/engine/validation.d.ts +7 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/render/form-renderer.d.ts +6 -7
- package/dist/types/render/submit.d.ts +4 -4
- package/dist/types/runtime/effects.d.ts +3 -3
- package/dist/types/runtime/runtime-state-controller.d.ts +5 -5
- package/dist/types/store/form-store.d.ts +7 -0
- package/dist/types/types/linkage.d.ts +30 -10
- package/dist/types/types/schema.d.ts +15 -1
- package/package.json +6 -12
- package/dist/cjs/editor/properties/entries/linkage/expression-assist.cjs +0 -1
- package/dist/es/editor/properties/entries/linkage/expression-assist.js +0 -86
- package/dist/types/editor/properties/entries/linkage/expression-assist.d.ts +0 -33
- package/dist/types/test-expression-engine.d.ts +0 -25
- /package/dist/types/{editor/properties/entries/linkage/expression-assist.test.d.ts → engine/schema/column-type.test.d.ts} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReactElement, ReactNode, Ref } from 'react';
|
|
2
2
|
import { DeviceRegistries, FormFieldRegistry } from '../engine/registry/form-field-registry';
|
|
3
3
|
import { EditorDeviceMode, EditorViewMode } from '../store/form-store';
|
|
4
|
-
import { DataSourceResolver,
|
|
4
|
+
import { DataSourceResolver, EvaluationContext, FormSchema, LinkageContextSource, LinkageEvaluators } from '../types';
|
|
5
5
|
import { ToolbarBrand, Toolbar } from './toolbar/toolbar';
|
|
6
6
|
import { PalettePanel } from './palette/palette-panel';
|
|
7
7
|
import { PropertiesPanel } from './properties/properties-panel';
|
|
@@ -51,10 +51,18 @@ export interface FormEditorProviderProps {
|
|
|
51
51
|
*/
|
|
52
52
|
dataSourceResolver?: DataSourceResolver;
|
|
53
53
|
/**
|
|
54
|
-
* Host
|
|
54
|
+
* Host evaluation scope (`$user` / `$node`, variable overrides), forwarded to
|
|
55
55
|
* the live preview so host-context expressions evaluate truthfully.
|
|
56
56
|
*/
|
|
57
|
-
|
|
57
|
+
evaluationContext?: EvaluationContext;
|
|
58
|
+
/**
|
|
59
|
+
* Host-declared global-context properties the visual condition builder
|
|
60
|
+
* offers as leaf-condition sources beside the form's own fields — e.g.
|
|
61
|
+
* `{ key: "$user.departmentId", label: "发起人部门" }`. Pure design-time
|
|
62
|
+
* metadata: the runtime resolves the path against `evaluationContext`
|
|
63
|
+
* whether or not it was declared here.
|
|
64
|
+
*/
|
|
65
|
+
contextSources?: LinkageContextSource[];
|
|
58
66
|
onSchemaChange?: (schema: FormSchema) => void;
|
|
59
67
|
/**
|
|
60
68
|
* Curated imperative handle — lets a host shell read/replace the schema and
|
|
@@ -72,7 +80,7 @@ export interface FormEditorProviderProps {
|
|
|
72
80
|
* render; updating them afterwards has no effect (editor state is bootstrapped
|
|
73
81
|
* once per mount — use {@link FormEditorApi.setSchema} to replace the schema).
|
|
74
82
|
*/
|
|
75
|
-
export declare function FormEditorProvider({ apiRef, children, dataSourceResolver, evaluators,
|
|
83
|
+
export declare function FormEditorProvider({ apiRef, children, contextSources, dataSourceResolver, evaluators, evaluationContext, initialSchema, onSchemaChange, registries: registriesProp, registry: registryProp }: FormEditorProviderProps): ReactElement;
|
|
76
84
|
export interface FormEditorShellProps {
|
|
77
85
|
children: ReactNode;
|
|
78
86
|
}
|
|
@@ -109,6 +117,16 @@ export interface FormEditorProps extends Omit<FormEditorProviderProps, "children
|
|
|
109
117
|
* button is not rendered at all.
|
|
110
118
|
*/
|
|
111
119
|
onPublish?: (schema: FormSchema) => void;
|
|
120
|
+
/**
|
|
121
|
+
* Label for the publish button (defaults to "发布"). Ignored when `onPublish`
|
|
122
|
+
* is omitted (the button is not rendered).
|
|
123
|
+
*/
|
|
124
|
+
publishText?: string;
|
|
125
|
+
/**
|
|
126
|
+
* Whether the publish button shows a loading state. Ignored when `onPublish`
|
|
127
|
+
* is omitted.
|
|
128
|
+
*/
|
|
129
|
+
publishLoading?: boolean;
|
|
112
130
|
}
|
|
113
131
|
/**
|
|
114
132
|
* The pre-composed visual form editor: provider + shell + the canonical
|
|
@@ -129,7 +147,7 @@ export interface FormEditorProps extends Omit<FormEditorProviderProps, "children
|
|
|
129
147
|
* </FormEditor.Provider>
|
|
130
148
|
* ```
|
|
131
149
|
*/
|
|
132
|
-
declare function FormEditorRoot({ brand, onPublish, ...providerProps }: FormEditorProps): ReactElement;
|
|
150
|
+
declare function FormEditorRoot({ brand, onPublish, publishText, publishLoading, ...providerProps }: FormEditorProps): ReactElement;
|
|
133
151
|
export declare const FormEditor: typeof FormEditorRoot & {
|
|
134
152
|
Provider: typeof FormEditorProvider;
|
|
135
153
|
Shell: typeof FormEditorShell;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { DataSourceResolver,
|
|
2
|
+
import { DataSourceResolver, EvaluationContext, LinkageEvaluators } from '../types';
|
|
3
3
|
/**
|
|
4
4
|
* Host-injected runtime capabilities the editor's live preview (and JSON split
|
|
5
5
|
* render) need so the in-designer `FormRenderer` behaves like the deployed form:
|
|
6
6
|
* remote / ref data sources resolve, a custom linkage engine runs, and the host
|
|
7
|
-
*
|
|
7
|
+
* evaluation scope (`$user` / `$node`) is present. Mirrors the slots
|
|
8
8
|
* `FormRendererProps` already exposes; the editor only forwards them.
|
|
9
9
|
*/
|
|
10
10
|
export interface PreviewRuntime {
|
|
11
11
|
evaluators?: LinkageEvaluators;
|
|
12
12
|
dataSourceResolver?: DataSourceResolver;
|
|
13
|
-
|
|
13
|
+
evaluationContext?: EvaluationContext;
|
|
14
14
|
}
|
|
15
15
|
export declare function PreviewRuntimeProvider({ children, value }: {
|
|
16
16
|
children: ReactNode;
|
|
@@ -25,11 +25,6 @@ export interface ActionEditorProps {
|
|
|
25
25
|
* action's `retrigger` (edge vs. always) apply, so the toggle shows just here.
|
|
26
26
|
*/
|
|
27
27
|
isConditionTrigger: boolean;
|
|
28
|
-
/**
|
|
29
|
-
* Declared form-variable names, feeding the expression editors' completion
|
|
30
|
-
* and unknown-key lint (same assist the condition editor gets).
|
|
31
|
-
*/
|
|
32
|
-
variableNames?: string[];
|
|
33
28
|
onChange: (next: FieldLinkageAction) => void;
|
|
34
29
|
onRemove: () => void;
|
|
35
30
|
}
|
|
@@ -27,11 +27,6 @@ export interface ActionsEditorProps {
|
|
|
27
27
|
* Form-global data sources offered as a `refresh_data_source` target.
|
|
28
28
|
*/
|
|
29
29
|
dataSourceOptions: SourceFieldOption[];
|
|
30
|
-
/**
|
|
31
|
-
* Declared form-variable names, forwarded into each action's expression
|
|
32
|
-
* editors for completion / lint.
|
|
33
|
-
*/
|
|
34
|
-
variableNames?: string[];
|
|
35
30
|
onChange: (next: FieldLinkageAction[]) => void;
|
|
36
31
|
}
|
|
37
32
|
/**
|
|
@@ -4,11 +4,6 @@ import { SourceFieldOption } from './options';
|
|
|
4
4
|
export interface ConditionEditorProps {
|
|
5
5
|
condition: LinkageCondition;
|
|
6
6
|
sourceOptions: SourceFieldOption[];
|
|
7
|
-
/**
|
|
8
|
-
* Declared form-variable names, feeding `$vars.` autocompletion in
|
|
9
|
-
* expression mode.
|
|
10
|
-
*/
|
|
11
|
-
variableNames?: string[];
|
|
12
7
|
/**
|
|
13
8
|
* The owning block's data-binding key. The expression → visual switch
|
|
14
9
|
* seeds its first condition with another field when one exists — a
|
|
@@ -21,7 +16,7 @@ export interface ConditionEditorProps {
|
|
|
21
16
|
* Top-level wrapper. The root condition is always a `group` or an
|
|
22
17
|
* `expression` — a bare `leaf` is never the rule's top condition. Mode
|
|
23
18
|
* switching here is a destructive replace (group ↔ expression) because
|
|
24
|
-
* there is no general way to reverse-translate a free-form
|
|
19
|
+
* there is no general way to reverse-translate a free-form JS expression
|
|
25
20
|
* back into a structured tree; a switch that would discard authored content
|
|
26
21
|
* is gated behind a confirmation.
|
|
27
22
|
*/
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Completion is off for linkage sources: without the (removed) scope-aware
|
|
4
|
+
* assist, CodeMirror would only offer generic JavaScript keyword noise.
|
|
5
|
+
* Shared with the script editor, which uses CodeEditor directly.
|
|
6
|
+
*/
|
|
7
|
+
export declare const NO_COMPLETION_SETUP: {
|
|
8
|
+
readonly autocompletion: false;
|
|
9
|
+
};
|
|
10
|
+
interface ExpressionInputProps {
|
|
11
|
+
minHeight?: number;
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
value: string;
|
|
14
|
+
onChange: (source: string) => void;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Single-expression editor for linkage conditions and action values: a
|
|
18
|
+
* compact CodeMirror bound to plain JavaScript — syntax highlighting, no
|
|
19
|
+
* completion, no gutters.
|
|
20
|
+
*/
|
|
21
|
+
export declare const ExpressionInput: FC<ExpressionInputProps>;
|
|
22
|
+
export {};
|
|
@@ -7,6 +7,16 @@ import { ValidationIssue } from '../../../../engine/validation';
|
|
|
7
7
|
* not card-addressable and are dropped here.
|
|
8
8
|
*/
|
|
9
9
|
export declare function groupIssuesByRule(issues: readonly ValidationIssue[]): Map<string, ValidationIssue[]>;
|
|
10
|
+
/**
|
|
11
|
+
* Reference-reconcile a freshly-grouped issue map against the prior one.
|
|
12
|
+
* {@link groupIssuesByRule} allocates fresh buckets on every revalidation
|
|
13
|
+
* (every schema edit moves the deferred layer reference), which would hand
|
|
14
|
+
* every issue-carrying RuleCard a new `issues` prop identity — busting its
|
|
15
|
+
* memo on each keystroke anywhere in the form. A bucket whose content is
|
|
16
|
+
* unchanged keeps its previous array reference; a fully unchanged map keeps
|
|
17
|
+
* its own reference (mirroring the runtime's `stabilizeStateMap`).
|
|
18
|
+
*/
|
|
19
|
+
export declare function stabilizeIssueBuckets(prev: Map<string, ValidationIssue[]> | undefined, next: Map<string, ValidationIssue[]>): Map<string, ValidationIssue[]>;
|
|
10
20
|
export interface RuleDiagnosticsProps {
|
|
11
21
|
issues: readonly ValidationIssue[];
|
|
12
22
|
}
|
|
@@ -26,11 +26,6 @@ export interface RuleListEditorProps {
|
|
|
26
26
|
* reading its own key).
|
|
27
27
|
*/
|
|
28
28
|
sourceOptions: SourceFieldOption[];
|
|
29
|
-
/**
|
|
30
|
-
* Declared form-variable names, feeding `$vars.` autocompletion in the
|
|
31
|
-
* expression-mode condition editor.
|
|
32
|
-
*/
|
|
33
|
-
variableNames?: string[];
|
|
34
29
|
/**
|
|
35
30
|
* The owning block's data-binding key (when keyed). Seeds the expression →
|
|
36
31
|
* visual switch with a different field, mirroring rule creation.
|
|
@@ -8,11 +8,6 @@ export interface TriggerEditorProps {
|
|
|
8
8
|
*/
|
|
9
9
|
triggerKinds: readonly LinkageTriggerKind[];
|
|
10
10
|
sourceOptions: SourceFieldOption[];
|
|
11
|
-
/**
|
|
12
|
-
* Declared form-variable names, forwarded to the expression-mode condition
|
|
13
|
-
* editor for `$vars.` autocompletion.
|
|
14
|
-
*/
|
|
15
|
-
variableNames?: string[];
|
|
16
11
|
/**
|
|
17
12
|
* The owning block's data-binding key, forwarded so the expression → visual
|
|
18
13
|
* switch seeds with a different field when one exists.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FieldLinkage, FormDataSource,
|
|
1
|
+
import { FieldLinkage, FormDataSource, PresentationLayer } from '../../../../types';
|
|
2
2
|
import { SourceFieldOption } from './options';
|
|
3
3
|
import { groupIssuesByRule } from './rule-diagnostics';
|
|
4
4
|
export interface LinkageEditorModel {
|
|
@@ -11,10 +11,6 @@ export interface LinkageEditorModel {
|
|
|
11
11
|
* The form's named data sources, for a `refresh_data_source` action.
|
|
12
12
|
*/
|
|
13
13
|
dataSourceOptions: SourceFieldOption[];
|
|
14
|
-
/**
|
|
15
|
-
* Declared `$vars` names, for the expression editors' completion.
|
|
16
|
-
*/
|
|
17
|
-
variableNames: string[];
|
|
18
14
|
/**
|
|
19
15
|
* Validator issues hung onto each rule by id, for live in-card diagnostics.
|
|
20
16
|
*/
|
|
@@ -23,10 +19,10 @@ export interface LinkageEditorModel {
|
|
|
23
19
|
/**
|
|
24
20
|
* The shared model behind every linkage editor host — the field-level entry, the
|
|
25
21
|
* container section, and the form-level events panel. Each resolves the same
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
22
|
+
* three things (same-scope field options, data-source options, deferred rule
|
|
23
|
+
* diagnostics) and differed only in which layer/scope they walk and whether the
|
|
24
|
+
* form-level linkage participates; that wiring lived copy-pasted across all
|
|
25
|
+
* three.
|
|
30
26
|
*
|
|
31
27
|
* `nodeId` is the node whose own value scope the sources resolve in (`null` for
|
|
32
28
|
* the form-level root scope). `formLinkage` is threaded only by the form panel so
|
|
@@ -41,6 +37,5 @@ export declare function useLinkageEditorModel(args: {
|
|
|
41
37
|
layer: PresentationLayer;
|
|
42
38
|
nodeId: string | null;
|
|
43
39
|
dataSources: FormDataSource[] | undefined;
|
|
44
|
-
variables: FormVariable[] | undefined;
|
|
45
40
|
formLinkage?: FieldLinkage;
|
|
46
41
|
}): LinkageEditorModel;
|
|
@@ -5,10 +5,10 @@ import { SourceFieldOption } from './options';
|
|
|
5
5
|
* The candidate walks rebuild the array on every store edit (the layer
|
|
6
6
|
* reference moves per keystroke), but the candidate SET only changes when a
|
|
7
7
|
* field is added / removed / re-keyed / re-labeled. Downstream the array
|
|
8
|
-
* identity feeds
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
8
|
+
* identity feeds `RuleCard`'s memo props (`sourceOptions` / `targetOptions`,
|
|
9
|
+
* see linkage-rules-entry.tsx) — a fresh reference per keystroke would
|
|
10
|
+
* re-render every rule card (and its mounted CodeMirror) on every edit
|
|
11
|
+
* anywhere in the form.
|
|
12
12
|
*
|
|
13
13
|
* The ref write happens during render but is idempotent for a given content,
|
|
14
14
|
* so StrictMode double-renders and discarded concurrent renders stay
|
|
@@ -6,7 +6,7 @@ export interface FormVariablesPanelProps {
|
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
8
|
* Form-global variable manager. Each variable surfaces to expressions as
|
|
9
|
-
* `$vars.<name>` with its `defaultValue`; the runtime seeds the
|
|
9
|
+
* `$vars.<name>` with its `defaultValue`; the runtime seeds the evaluation scope
|
|
10
10
|
* from this list.
|
|
11
11
|
*
|
|
12
12
|
* Add and type/default edits flow through `onChange` (the drawer patches
|
|
@@ -10,4 +10,20 @@ export declare function notify(kind: NotifyKind, text: string): void;
|
|
|
10
10
|
* shown and the title alone would drop the actual report.
|
|
11
11
|
*/
|
|
12
12
|
export declare function infoDialog(title: string, content: ReactNode, detail?: string): void;
|
|
13
|
-
export
|
|
13
|
+
export interface ConfirmDialogOptions {
|
|
14
|
+
onOk: () => void;
|
|
15
|
+
/**
|
|
16
|
+
* Visual intent of the confirm button.
|
|
17
|
+
*
|
|
18
|
+
* @default "danger"
|
|
19
|
+
*/
|
|
20
|
+
okType?: "danger" | "primary";
|
|
21
|
+
/**
|
|
22
|
+
* Plain-text rendering of a rich (React) `content` for the `$vef`-less
|
|
23
|
+
* native fallback, where the React body cannot be shown and the title alone
|
|
24
|
+
* would drop the substance of the question (mirrors `infoDialog`'s
|
|
25
|
+
* `detail`). Unnecessary when `content` is already a string.
|
|
26
|
+
*/
|
|
27
|
+
detail?: string;
|
|
28
|
+
}
|
|
29
|
+
export declare function confirmDialog(title: string, content: ReactNode, options: ConfirmDialogOptions): void;
|
|
@@ -25,6 +25,14 @@ export interface ToolbarProps {
|
|
|
25
25
|
* rendered at all.
|
|
26
26
|
*/
|
|
27
27
|
onPublish?: (schema: FormSchema) => void;
|
|
28
|
+
/**
|
|
29
|
+
* Label for the publish button (defaults to "发布").
|
|
30
|
+
*/
|
|
31
|
+
publishText?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Whether the publish button shows a loading state.
|
|
34
|
+
*/
|
|
35
|
+
publishLoading?: boolean;
|
|
28
36
|
}
|
|
29
37
|
/**
|
|
30
38
|
* Editor top toolbar. Houses brand, summary, device / view-mode switches,
|
|
@@ -38,4 +46,4 @@ export interface ToolbarProps {
|
|
|
38
46
|
* - `drawer`: import/export/clear collapse into a "更多" menu, the toggle pills
|
|
39
47
|
* drop their labels, and the summary chip hides
|
|
40
48
|
*/
|
|
41
|
-
export declare function Toolbar({ brand, onPublish }: ToolbarProps): ReactElement;
|
|
49
|
+
export declare function Toolbar({ brand, onPublish, publishText, publishLoading }: ToolbarProps): ReactElement;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Block, FormField, KeyedFormField, KeyedNodeUnion, PresentationLayer, Validatable } from '../types';
|
|
1
|
+
import { Block, FormField, FormSchema, KeyedFormField, KeyedNodeUnion, PresentationLayer, Validatable } from '../types';
|
|
2
2
|
import { ScopePath } from './schema/walk';
|
|
3
3
|
/**
|
|
4
4
|
* Generate a unique data-binding key for a keyed node within a value scope.
|
|
@@ -45,6 +45,16 @@ export declare function isKeyedField(field: FormField): field is KeyedFormField;
|
|
|
45
45
|
* across the field union without a cast.
|
|
46
46
|
*/
|
|
47
47
|
export declare function isValidatableField(field: FormField): field is FormField & Validatable;
|
|
48
|
+
/**
|
|
49
|
+
* Visit each root-scope keyed leaf field across both device presentations,
|
|
50
|
+
* de-duplicated by key with the pc tree scanned first (so pc wins a label /
|
|
51
|
+
* config collision). The shared projection walk behind `toColumnDefinitions`
|
|
52
|
+
* and `toFormFieldDefinitions` — the cross-package field inventories must
|
|
53
|
+
* agree on which fields exist, so they share one definition of the scan.
|
|
54
|
+
* Subform-scoped fields are excluded: consumers address fields by bare `key`,
|
|
55
|
+
* which cannot reach a scoped `lines[i].amount` path.
|
|
56
|
+
*/
|
|
57
|
+
export declare function walkUniqueRootKeyedFields(schema: FormSchema, visit: (field: KeyedFormField) => void): void;
|
|
48
58
|
/**
|
|
49
59
|
* Collect the data-binding keys used directly within one value scope (siblings
|
|
50
60
|
* that must stay mutually unique). Keys nested under a deeper subform scope are
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function defaultEvaluateExpression(source: string, values: Record<string, unknown>, context?:
|
|
3
|
-
export declare function defaultEvaluateAssignExpression(source: string, values: Record<string, unknown>, context?:
|
|
4
|
-
export declare function defaultEvaluateScriptAction(source: string, values: Record<string, unknown>, context?:
|
|
1
|
+
import { EvaluationContext, LinkageEvaluators, LinkageScriptResult } from '../../types';
|
|
2
|
+
export declare function defaultEvaluateExpression(source: string, values: Record<string, unknown>, context?: EvaluationContext): boolean;
|
|
3
|
+
export declare function defaultEvaluateAssignExpression(source: string, values: Record<string, unknown>, context?: EvaluationContext): unknown;
|
|
4
|
+
export declare function defaultEvaluateScriptAction(source: string, values: Record<string, unknown>, context?: EvaluationContext): LinkageScriptResult | void;
|
|
5
5
|
/**
|
|
6
6
|
* Resolves a host-supplied {@link LinkageEvaluators} to a fully populated set,
|
|
7
|
-
* filling missing expression slots with the
|
|
8
|
-
*
|
|
9
|
-
* dispatcher.
|
|
7
|
+
* filling missing expression and script slots with the default `new Function`
|
|
8
|
+
* evaluators and effects with the no-op dispatcher.
|
|
10
9
|
*/
|
|
11
10
|
export declare function resolveLinkageEvaluators(overrides?: LinkageEvaluators): Required<LinkageEvaluators>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EffectAction,
|
|
1
|
+
import { EffectAction, EvaluationContext, FieldLinkageRule, LinkageCondition, LinkageEvaluators, LinkageTriggerKind, RuntimeSchema } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* The side-effect lane (pure half).
|
|
4
4
|
*
|
|
@@ -59,7 +59,7 @@ export declare function collectConditionEffectRules(schema: RuntimeSchema): Cond
|
|
|
59
59
|
* aligned with {@link collectConditionEffectRules}'s output, so the runtime can
|
|
60
60
|
* diff against the previous vector to detect rising edges.
|
|
61
61
|
*/
|
|
62
|
-
export declare function evaluateConditionEffectTruths(rules: ConditionEffectRule[], values: Record<string, unknown>, evaluators: Required<LinkageEvaluators>, context?:
|
|
62
|
+
export declare function evaluateConditionEffectTruths(rules: ConditionEffectRule[], values: Record<string, unknown>, evaluators: Required<LinkageEvaluators>, context?: EvaluationContext): boolean[];
|
|
63
63
|
/**
|
|
64
64
|
* The effect actions to run when a given edge trigger fires. Returns the
|
|
65
65
|
* flattened effect actions of every rule whose trigger matches `kind` (state
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Block,
|
|
1
|
+
import { Block, EvaluationContext, LinkageActionValue, LinkageCondition, LinkageEvaluators, RuntimeSchema } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* Runtime state derived for a single field from its linkage rules. Mirrors
|
|
4
4
|
* the shape consumed by `FormRenderer` / `RuntimeStateController` — kept as a
|
|
@@ -19,7 +19,7 @@ export interface EvaluateLinkageOptions {
|
|
|
19
19
|
* scripts. Omitted at design time; the runtime composes it from the form's
|
|
20
20
|
* variables and the host context.
|
|
21
21
|
*/
|
|
22
|
-
|
|
22
|
+
evaluationContext?: EvaluationContext;
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
25
|
* Evaluates one field's linkage in two phases:
|
|
@@ -43,21 +43,27 @@ export declare function evaluateRuntimeStates(schema: RuntimeSchema, values: Rec
|
|
|
43
43
|
* appropriately so a large tree never evaluates more leaves than needed.
|
|
44
44
|
* Exported so the effect lane can re-evaluate a rule's trigger condition for
|
|
45
45
|
* rising-edge detection without duplicating the recursion.
|
|
46
|
+
*
|
|
47
|
+
* Structurally defensive: a missing / non-object condition, a group without a
|
|
48
|
+
* `children` array, or an out-of-contract `kind` degrades to "no match" — the
|
|
49
|
+
* render path may evaluate a host-supplied schema that never passed
|
|
50
|
+
* `validateLinkageSchema`, and `matchLeaf`'s "never crash the renderer"
|
|
51
|
+
* contract must hold for shape, not just for values.
|
|
46
52
|
*/
|
|
47
|
-
export declare function matchCondition(condition: LinkageCondition, values: Record<string, unknown>, evaluators: Required<LinkageEvaluators>, context?:
|
|
53
|
+
export declare function matchCondition(condition: LinkageCondition, values: Record<string, unknown>, evaluators: Required<LinkageEvaluators>, context?: EvaluationContext): boolean;
|
|
48
54
|
/**
|
|
49
55
|
* Resolve a {@link LinkageActionValue} to a concrete value: a literal verbatim,
|
|
50
56
|
* or an expression run through the injected evaluator. Shared by the state
|
|
51
57
|
* lane's `assign` and the effect lane's value-bearing actions (`set_field` /
|
|
52
58
|
* `alert` / `navigate`).
|
|
53
59
|
*/
|
|
54
|
-
export declare function resolveActionValue(actionValue: LinkageActionValue, values: Record<string, unknown>, evaluators: Required<LinkageEvaluators>, context?:
|
|
60
|
+
export declare function resolveActionValue(actionValue: LinkageActionValue, values: Record<string, unknown>, evaluators: Required<LinkageEvaluators>, context?: EvaluationContext): unknown;
|
|
55
61
|
/**
|
|
56
62
|
* Build the `$vars` map from a schema's form-global variable declarations,
|
|
57
63
|
* keyed by variable name with each `defaultValue`. The runtime merges this with
|
|
58
|
-
* any host-supplied overrides to form the
|
|
64
|
+
* any host-supplied overrides to form the evaluation context's `variables`.
|
|
59
65
|
*/
|
|
60
|
-
export declare function
|
|
66
|
+
export declare function deriveEvaluationVariables(schema: RuntimeSchema): Record<string, unknown>;
|
|
61
67
|
/**
|
|
62
68
|
* Builds the initial value map for a form from its schema. Each root-scope
|
|
63
69
|
* keyed field is seeded with a type-appropriate empty value (see
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { formatIssueMessage, type ValidationIssue, type ValidationIssueCode, type ValidationSeverity } from '../validation';
|
|
2
2
|
export { defaultEvaluateAssignExpression, defaultEvaluateExpression, defaultEvaluateScriptAction, resolveLinkageEvaluators } from './default-evaluator';
|
|
3
3
|
export { collectConditionEffectRules, evaluateConditionEffectTruths, getFieldEventTriggerKinds, getTriggerEffectActions, type ConditionEffectRule } from './effects';
|
|
4
|
-
export { deriveDefaultValues,
|
|
4
|
+
export { deriveDefaultValues, deriveEvaluationVariables, emptyRuntimeState, evaluateLinkage, evaluateRuntimeStates, resolveActionValue, type EvaluateLinkageOptions, type RuntimeFieldState } from './evaluator';
|
|
5
5
|
export { isEmptyRuntimeValue, LINKAGE_OPERATORS } from './operators';
|
|
6
6
|
export { getLinkageSourceKeys } from './source-tracking';
|
|
7
7
|
export { ALERT_LEVELS, EFFECT_ACTION_TYPES, FIELD_EVENT_TRIGGER_KINDS, FIELD_TRIGGER_KINDS, FORM_TRIGGER_KINDS, isEffectAction, isFieldEventTriggerKind, isStateAction, KEYED_ONLY_ACTIONS, LINKAGE_ACTION_TYPES, STATE_ACTION_TYPES } from './taxonomy';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LinkageConditionLeaf, LinkageOperator } from '../../types';
|
|
1
|
+
import { EvaluationContext, LinkageConditionLeaf, LinkageOperator } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* The full set of supported leaf operators, in display order. Mirrors the
|
|
4
4
|
* union `LinkageOperator` and is used both by the editor UI (to render the
|
|
@@ -16,8 +16,10 @@ export declare const LINKAGE_OPERATORS: readonly LinkageOperator[];
|
|
|
16
16
|
*/
|
|
17
17
|
export declare function isEmptyRuntimeValue(value: unknown): boolean;
|
|
18
18
|
/**
|
|
19
|
-
* Evaluates a leaf condition against the current form values
|
|
20
|
-
*
|
|
21
|
-
*
|
|
19
|
+
* Evaluates a leaf condition against the current form values (or, for a
|
|
20
|
+
* `$`-rooted source path, the evaluation context — see
|
|
21
|
+
* {@link resolveLeafSourceValue}). Operators fall back to `false` rather than
|
|
22
|
+
* throw when the source value is of an unexpected type, so a malformed
|
|
23
|
+
* condition can never crash the renderer.
|
|
22
24
|
*/
|
|
23
|
-
export declare function matchLeaf(leaf: LinkageConditionLeaf, values: Record<string, unknown
|
|
25
|
+
export declare function matchLeaf(leaf: LinkageConditionLeaf, values: Record<string, unknown>, context?: EvaluationContext): boolean;
|
|
@@ -13,9 +13,10 @@ export declare const LINKAGE_ACTION_TYPES: readonly LinkageActionType[];
|
|
|
13
13
|
export declare function isStateAction(action: FieldLinkageAction): action is StateAction;
|
|
14
14
|
/**
|
|
15
15
|
* Narrows an action to the effect family — fired by the side-effect lane,
|
|
16
|
-
* skipped by the state lane.
|
|
17
|
-
*
|
|
18
|
-
*
|
|
16
|
+
* skipped by the state lane. A positive membership test (not the negation of
|
|
17
|
+
* {@link isStateAction}): on the unvalidated render path an out-of-contract
|
|
18
|
+
* `action.type` must classify as NEITHER family, not silently become an
|
|
19
|
+
* effect.
|
|
19
20
|
*/
|
|
20
21
|
export declare function isEffectAction(action: FieldLinkageAction): action is EffectAction;
|
|
21
22
|
/**
|
|
@@ -20,6 +20,7 @@ export declare class FormFieldRegistry {
|
|
|
20
20
|
* `useSyncExternalStore` snapshot this number to know when to re-read.
|
|
21
21
|
*/
|
|
22
22
|
private revision;
|
|
23
|
+
private notify;
|
|
23
24
|
register(definition: FieldDefinition): void;
|
|
24
25
|
unregister(type: string): boolean;
|
|
25
26
|
get(type: string): FieldDefinition | undefined;
|
|
@@ -64,7 +65,6 @@ export declare class FormFieldRegistry {
|
|
|
64
65
|
* only its identity (changing on every mutation) matters.
|
|
65
66
|
*/
|
|
66
67
|
getRevision(): number;
|
|
67
|
-
private notify;
|
|
68
68
|
}
|
|
69
69
|
/**
|
|
70
70
|
* One {@link FormFieldRegistry} per target device. The editor and renderer
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ColumnDataType, FormField, FormSchema } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* A keyed field projected to its table-storage column shape: the dialect-
|
|
4
|
+
* independent logical type plus the parameters the backend needs to render a
|
|
5
|
+
* precise SQL type (VARCHAR(maxLength), DECIMAL(_, precision)). Structurally
|
|
6
|
+
* feeds the backend's `FormFieldDefinition` columnType / maxLength / precision.
|
|
7
|
+
*/
|
|
8
|
+
export interface ColumnDefinition {
|
|
9
|
+
key: string;
|
|
10
|
+
columnType: ColumnDataType;
|
|
11
|
+
maxLength?: number;
|
|
12
|
+
precision?: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Infer a keyed field's column type from its widget, honoring an explicit
|
|
16
|
+
* `columnType` override first. Most widgets map deterministically; only the
|
|
17
|
+
* value-ambiguous ones need the override: number is integer or decimal by its
|
|
18
|
+
* `precision`, and select/radio default to string but can be pinned to integer
|
|
19
|
+
* when their option values are numeric. Unknown / consumer-registered widgets
|
|
20
|
+
* fall back to a lossless string/text column.
|
|
21
|
+
*/
|
|
22
|
+
export declare function inferColumnType(field: FormField): ColumnDataType;
|
|
23
|
+
/**
|
|
24
|
+
* Project a form schema to its ordered table-storage column inventory — the same
|
|
25
|
+
* root-scope keyed-leaf projection `toFormFieldDefinitions` uses (subform-scoped
|
|
26
|
+
* fields and non-keyed presentation excluded), deduped by key across both device
|
|
27
|
+
* presentations with pc winning a collision. Each entry carries the inferred (or
|
|
28
|
+
* overridden) column type plus the maxLength / precision the backend needs.
|
|
29
|
+
*/
|
|
30
|
+
export declare function toColumnDefinitions(schema: FormSchema): ColumnDefinition[];
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
/**
|
|
22
22
|
* Stable machine-readable identifiers for every issue the validators emit.
|
|
23
23
|
*/
|
|
24
|
-
export type ValidationIssueCode = "schema_not_object" | "id_required" | "duplicate_id" | "version_unsupported" | "presentation_not_object" | "variables_invalid" | "data_sources_invalid" | "block_not_object" | "children_not_array" | "tabs_empty" | "tab_malformed" | "type_required" | "unknown_field_type" | "key_required" | "stray_key" | "stray_key_on_container" | "duplicate_key" | "key_invalid_charset" | "span_invalid" | "flex_invalid" | "column_width_invalid" | "gap_invalid" | "columns_invalid" | "variant_invalid" | "title_invalid" | "display_text_invalid" | "rows_bound_invalid" | "subform_table_column" | "validate_malformed" | "validate_range_invalid" | "pattern_invalid" | "data_source_invalid" | "data_source_ref_unknown" | "request_malformed" | "request_incomplete" | "linkage_malformed" | "rules_not_array" | "rule_malformed" | "trigger_malformed" | "trigger_kind_invalid" | "trigger_requires_keyed_leaf" | "condition_malformed" | "condition_kind_invalid" | "logic_invalid" | "condition_group_empty" | "operator_invalid" | "source_key_empty" | "source_key_unresolved" | "source_empty" | "actions_not_array" | "actions_empty" | "action_malformed" | "action_unknown_type" | "state_action_on_edge_trigger" | "state_action_on_form_scope" | "action_requires_keyed_leaf" | "defaults_requires_keyed_leaf" | "defaults_on_form_scope" | "default_hidden_unreachable" | "target_key_empty" | "target_key_unresolved" | "variable_empty" | "data_source_id_empty" | "value_malformed" | "alert_level_invalid" | "retrigger_invalid" | "retrigger_ignored" | "self_reference" | "cycle_detected";
|
|
24
|
+
export type ValidationIssueCode = "schema_not_object" | "id_required" | "duplicate_id" | "version_unsupported" | "presentation_not_object" | "variables_invalid" | "data_sources_invalid" | "block_not_object" | "children_not_array" | "tabs_empty" | "tab_malformed" | "type_required" | "unknown_field_type" | "key_required" | "stray_key" | "stray_key_on_container" | "duplicate_key" | "key_invalid_charset" | "span_invalid" | "flex_invalid" | "column_width_invalid" | "gap_invalid" | "columns_invalid" | "variant_invalid" | "subform_variant_invalid" | "title_invalid" | "display_text_invalid" | "rows_bound_invalid" | "subform_table_column" | "validate_malformed" | "validate_range_invalid" | "pattern_invalid" | "data_source_invalid" | "data_source_ref_unknown" | "request_malformed" | "request_incomplete" | "linkage_malformed" | "rules_not_array" | "rule_malformed" | "trigger_malformed" | "trigger_kind_invalid" | "trigger_requires_keyed_leaf" | "condition_malformed" | "condition_kind_invalid" | "logic_invalid" | "condition_group_empty" | "operator_invalid" | "source_key_empty" | "source_key_unresolved" | "source_empty" | "actions_not_array" | "actions_empty" | "action_malformed" | "action_unknown_type" | "state_action_on_edge_trigger" | "state_action_on_form_scope" | "action_requires_keyed_leaf" | "defaults_requires_keyed_leaf" | "defaults_on_form_scope" | "default_hidden_unreachable" | "target_key_empty" | "target_key_unresolved" | "variable_empty" | "data_source_id_empty" | "value_malformed" | "alert_level_invalid" | "retrigger_invalid" | "retrigger_ignored" | "self_reference" | "cycle_detected";
|
|
25
25
|
export type ValidationSeverity = "error" | "warning";
|
|
26
26
|
/**
|
|
27
27
|
* One problem found while validating a schema. `path` points at the offending
|
|
@@ -111,6 +111,12 @@ type ParamlessCode = Exclude<ValidationIssueCode, ParamCode>;
|
|
|
111
111
|
*/
|
|
112
112
|
export declare function formatIssueMessage<C extends ParamCode>(code: C, params: ValidationIssueParams[C]): string;
|
|
113
113
|
export declare function formatIssueMessage(code: ParamlessCode): string;
|
|
114
|
+
/**
|
|
115
|
+
* One issue rendered as `path:message` (or the bare message when it carries
|
|
116
|
+
* no path) — the plain-text line format shared by the apply pipeline's
|
|
117
|
+
* error/warning reports and the dialogs' `$vef`-less fallbacks.
|
|
118
|
+
*/
|
|
119
|
+
export declare function formatIssueLine(issue: ValidationIssue): string;
|
|
114
120
|
/**
|
|
115
121
|
* Build a {@link ValidationIssue}, deriving `severity` and `message` from the
|
|
116
122
|
* central tables so emit sites only state location + code (+ params / rule id).
|
package/dist/types/index.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export { ALERT_LEVELS, defaultEvaluateAssignExpression, defaultEvaluateExpressio
|
|
|
22
22
|
export { createDefaultRegistry, registerDefaults } from './engine/registry/defaults';
|
|
23
23
|
export { createDefaultMobileRegistry } from './engine/registry/defaults-mobile';
|
|
24
24
|
export { FormFieldRegistry, type DeviceRegistries } from './engine/registry/form-field-registry';
|
|
25
|
+
export { inferColumnType, toColumnDefinitions, type ColumnDefinition } from './engine/schema/column-type';
|
|
25
26
|
export { cloneBlock, insertBlock, moveBlock, setFlex, setSpan, type DropTarget } from './engine/schema/edit-ops';
|
|
26
27
|
export { editField, removeBlock, updateNode } from './engine/schema/mutate';
|
|
27
28
|
export { createEmptySchema } from './engine/schema/nodes';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactElement, Ref } from 'react';
|
|
2
2
|
import { RuntimeFormValues } from '../runtime/types';
|
|
3
|
-
import { DataSourceResolver,
|
|
3
|
+
import { DataSourceResolver, EvaluationContext, FormSchema, LinkageEvaluators, PresentationDevice } from '../types';
|
|
4
4
|
export interface FormRendererProps {
|
|
5
5
|
schema: FormSchema;
|
|
6
6
|
/**
|
|
@@ -12,10 +12,9 @@ export interface FormRendererProps {
|
|
|
12
12
|
defaultValues?: RuntimeFormValues;
|
|
13
13
|
disabled?: boolean;
|
|
14
14
|
/**
|
|
15
|
-
* Overrides for the dynamic linkage evaluators. Expression
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* sandbox, a custom expression engine, or a DSL.
|
|
15
|
+
* Overrides for the dynamic linkage evaluators. Expression and script slots
|
|
16
|
+
* fall back to plain-JavaScript `new Function` compilation. Host projects
|
|
17
|
+
* only need overrides for a sandbox, a custom expression engine, or a DSL.
|
|
19
18
|
*/
|
|
20
19
|
evaluators?: LinkageEvaluators;
|
|
21
20
|
/**
|
|
@@ -24,12 +23,12 @@ export interface FormRendererProps {
|
|
|
24
23
|
*/
|
|
25
24
|
dataSourceResolver?: DataSourceResolver;
|
|
26
25
|
/**
|
|
27
|
-
* Host-supplied
|
|
26
|
+
* Host-supplied evaluation scope. `$vars` here merges over (and overrides) the
|
|
28
27
|
* schema's variable defaults; `$user` / `$node` carry runtime context. The
|
|
29
28
|
* form derives `$vars` from `schema.variables` on its own, so this is only
|
|
30
29
|
* needed to supply user / node context or override a variable at runtime.
|
|
31
30
|
*/
|
|
32
|
-
|
|
31
|
+
evaluationContext?: EvaluationContext;
|
|
33
32
|
onSubmit?: (values: RuntimeFormValues) => void | Promise<void>;
|
|
34
33
|
/**
|
|
35
34
|
* Imperative handle for host chrome (a Modal footer's 确定/取消, an external
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RuntimeFieldState } from '../engine/linkage';
|
|
2
2
|
import { RuntimeFormValues } from '../runtime/types';
|
|
3
|
-
import { Block,
|
|
3
|
+
import { Block, EvaluationContext, KeyedFormField, LinkageEvaluators, RuntimeSchema, SubformNode } from '../types';
|
|
4
4
|
/**
|
|
5
5
|
* Build the submit payload for one value scope: each keyed field / subform that
|
|
6
6
|
* is not **effectively** hidden — by its own linkage or any ancestor container's
|
|
@@ -13,7 +13,7 @@ import { Block, ExpressionContext, KeyedFormField, LinkageEvaluators, RuntimeSch
|
|
|
13
13
|
export declare function filterSubmitValues(args: {
|
|
14
14
|
blocks: Block[];
|
|
15
15
|
evaluators: LinkageEvaluators | undefined;
|
|
16
|
-
|
|
16
|
+
evaluationContext: EvaluationContext | undefined;
|
|
17
17
|
values: RuntimeFormValues;
|
|
18
18
|
}): RuntimeFormValues;
|
|
19
19
|
/**
|
|
@@ -44,7 +44,7 @@ export declare function collectSubmitErrors(args: {
|
|
|
44
44
|
blocks: Block[];
|
|
45
45
|
disabled: boolean;
|
|
46
46
|
evaluators: LinkageEvaluators | undefined;
|
|
47
|
-
|
|
47
|
+
evaluationContext: EvaluationContext | undefined;
|
|
48
48
|
namePrefix: string;
|
|
49
49
|
values: RuntimeFormValues;
|
|
50
50
|
}): Record<string, string>;
|
|
@@ -57,7 +57,7 @@ export declare function collectSubmitErrors(args: {
|
|
|
57
57
|
export declare function validateRuntimeField(args: {
|
|
58
58
|
disabled: boolean;
|
|
59
59
|
evaluators: LinkageEvaluators | undefined;
|
|
60
|
-
|
|
60
|
+
evaluationContext: EvaluationContext | undefined;
|
|
61
61
|
field: KeyedFormField;
|
|
62
62
|
namePrefix: string;
|
|
63
63
|
value: unknown;
|