@vef-framework-react/form-editor 2.9.0 → 2.10.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/editor/canvas/canvas-field.cjs +1 -1
- package/dist/cjs/editor/canvas/canvas.cjs +1 -1
- package/dist/cjs/editor/canvas/container-drag-chip.cjs +1 -0
- package/dist/cjs/editor/canvas/use-scroll-selection-into-view.cjs +1 -0
- package/dist/cjs/editor/dnd.cjs +1 -1
- package/dist/cjs/editor/form-editor.cjs +1 -1
- package/dist/cjs/editor/properties/block-layout-section.cjs +1 -1
- package/dist/cjs/editor/properties/option-editors.cjs +1 -1
- package/dist/cjs/editor/properties/properties-panel.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/schema/edit-ops.cjs +1 -1
- package/dist/cjs/engine/schema/validate.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/field-write.cjs +1 -0
- package/dist/cjs/runtime/runtime-state-controller.cjs +1 -1
- package/dist/cjs/store/form-store.cjs +1 -1
- package/dist/es/components/button/index.js +1 -1
- package/dist/es/components/checkbox-group-field/index.js +1 -1
- package/dist/es/components/code-editor/code-editor-input.js +1 -1
- package/dist/es/components/code-editor/index.js +1 -1
- package/dist/es/components/containers/index.js +1 -1
- package/dist/es/components/date-field/index.js +1 -1
- package/dist/es/components/display/index.js +1 -1
- package/dist/es/components/field-entries.js +1 -1
- 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 +1 -1
- 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 +1 -1
- package/dist/es/components/mobile/number.js +1 -1
- 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 +1 -1
- package/dist/es/components/mobile/textarea.js +1 -1
- package/dist/es/components/mobile/textfield.js +1 -1
- package/dist/es/components/mobile/theme.js +1 -1
- package/dist/es/components/number-field/index.js +1 -1
- package/dist/es/components/radio-field/index.js +1 -1
- package/dist/es/components/select-field/index.js +1 -1
- 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 +1 -1
- package/dist/es/editor/canvas/canvas-field.js +95 -93
- package/dist/es/editor/canvas/canvas.js +242 -235
- package/dist/es/editor/canvas/container-drag-chip.js +91 -0
- package/dist/es/editor/canvas/drop-indicator.js +1 -1
- package/dist/es/editor/canvas/drop-zones.js +1 -1
- package/dist/es/editor/canvas/json-split-view.js +1 -1
- 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 +1 -1
- package/dist/es/editor/canvas/subform-table-cell.js +1 -1
- package/dist/es/editor/canvas/use-scroll-selection-into-view.js +15 -0
- package/dist/es/editor/context-sources.js +1 -1
- package/dist/es/editor/dnd.js +7 -4
- package/dist/es/editor/editor-layout-context.js +1 -1
- 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 +1 -1
- package/dist/es/editor/form-config/linkage-overview.js +1 -1
- package/dist/es/editor/form-config/outline-tab.js +1 -1
- package/dist/es/editor/form-editor.js +104 -93
- package/dist/es/editor/palette/field-groups.js +1 -1
- package/dist/es/editor/palette/palette-group.js +1 -1
- 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 +1 -1
- package/dist/es/editor/properties/block-layout-section.js +156 -49
- package/dist/es/editor/properties/container-properties.js +1 -1
- 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 +1 -1
- package/dist/es/editor/properties/entries/key-entry.js +1 -1
- package/dist/es/editor/properties/entries/linkage/action-editor.js +1 -1
- package/dist/es/editor/properties/entries/linkage/actions-editor.js +1 -1
- package/dist/es/editor/properties/entries/linkage/condition-editor.js +1 -1
- package/dist/es/editor/properties/entries/linkage/container-linkage-section.js +1 -1
- package/dist/es/editor/properties/entries/linkage/expression-input.js +1 -1
- package/dist/es/editor/properties/entries/linkage/index.js +1 -1
- package/dist/es/editor/properties/entries/linkage/linkage-rules-entry.js +1 -1
- package/dist/es/editor/properties/entries/linkage/mutators.js +1 -1
- package/dist/es/editor/properties/entries/linkage/options.js +1 -1
- package/dist/es/editor/properties/entries/linkage/rule-diagnostics.js +1 -1
- package/dist/es/editor/properties/entries/linkage/rule-list-editor.js +1 -1
- package/dist/es/editor/properties/entries/linkage/styles.js +1 -1
- package/dist/es/editor/properties/entries/linkage/trigger-editor.js +1 -1
- package/dist/es/editor/properties/entries/linkage/use-linkage-editor-model.js +1 -1
- 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 +1 -1
- package/dist/es/editor/properties/form-variables-panel.js +1 -1
- package/dist/es/editor/properties/option-editors.js +142 -86
- 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 +18 -18
- package/dist/es/editor/properties/properties-provider.js +1 -1
- 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 +1 -1
- package/dist/es/editor/schema-apply.js +1 -1
- package/dist/es/editor/styles.js +1 -1
- package/dist/es/editor/toolbar/notify.js +1 -1
- package/dist/es/editor/toolbar/schema-io.js +1 -1
- package/dist/es/editor/toolbar/toolbar.js +1 -1
- 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 +1 -1
- package/dist/es/engine/ids.js +1 -1
- package/dist/es/engine/keys.js +1 -1
- package/dist/es/engine/linkage/cycle.js +1 -1
- package/dist/es/engine/linkage/default-evaluator.js +1 -1
- package/dist/es/engine/linkage/effects.js +1 -1
- package/dist/es/engine/linkage/evaluator.js +58 -40
- package/dist/es/engine/linkage/index.js +6 -6
- package/dist/es/engine/linkage/operators.js +2 -2
- package/dist/es/engine/linkage/source-tracking.js +1 -1
- package/dist/es/engine/linkage/taxonomy.js +1 -1
- package/dist/es/engine/linkage/validator.js +1 -1
- 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 +1 -1
- package/dist/es/engine/schema/column-type.js +1 -1
- package/dist/es/engine/schema/edit-ops.js +79 -58
- 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 +1 -1
- package/dist/es/engine/schema/presentation.js +1 -1
- package/dist/es/engine/schema/reconcile.js +1 -1
- 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 +25 -3
- package/dist/es/engine/schema/walk.js +1 -1
- package/dist/es/engine/validation.js +2 -1
- package/dist/es/icons.js +1 -1
- package/dist/es/index.js +20 -19
- 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 +269 -236
- 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 +18 -2
- package/dist/es/render/subform-columns.js +1 -1
- package/dist/es/render/submit.js +44 -32
- package/dist/es/runtime/effects.js +56 -50
- package/dist/es/runtime/field-write.js +17 -0
- 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 +70 -63
- package/dist/es/runtime/stabilize-state-map.js +1 -1
- package/dist/es/store/engine-provider.js +1 -1
- package/dist/es/store/form-store.js +68 -61
- 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 +1 -1
- 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/editor/canvas/container-drag-chip.d.ts +12 -0
- package/dist/types/editor/canvas/container-drag-chip.test.d.ts +1 -0
- package/dist/types/editor/canvas/use-scroll-selection-into-view.d.ts +21 -0
- package/dist/types/editor/canvas/use-scroll-selection-into-view.test.d.ts +1 -0
- package/dist/types/editor/dnd.d.ts +21 -1
- package/dist/types/editor/properties/block-layout-section.d.ts +6 -5
- package/dist/types/editor/properties/block-layout-section.test.d.ts +1 -0
- package/dist/types/editor/properties/option-editors.d.ts +13 -0
- package/dist/types/editor/properties/properties-panel.d.ts +2 -2
- package/dist/types/engine/linkage/evaluator.d.ts +25 -1
- package/dist/types/engine/linkage/index.d.ts +1 -1
- package/dist/types/engine/linkage/operators.d.ts +13 -5
- package/dist/types/engine/schema/edit-ops.d.ts +12 -1
- package/dist/types/engine/validation.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/render/form-renderer.d.ts +27 -1
- package/dist/types/render/form-renderer.field-permissions.test.d.ts +1 -0
- package/dist/types/render/stack-style.d.ts +14 -1
- package/dist/types/render/submit.d.ts +26 -4
- package/dist/types/runtime/effects.d.ts +11 -1
- package/dist/types/runtime/field-write.d.ts +37 -0
- package/dist/types/runtime/runtime-state-controller.d.ts +3 -2
- package/dist/types/store/form-store.d.ts +9 -1
- package/dist/types/types/linkage.d.ts +16 -0
- package/dist/types/types/schema.d.ts +33 -0
- package/package.json +5 -5
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactElement, Ref } from 'react';
|
|
2
2
|
import { RuntimeFormValues } from '../runtime/types';
|
|
3
|
-
import { DataSourceResolver, EvaluationContext, FormSchema, LinkageEvaluators, PresentationDevice } from '../types';
|
|
3
|
+
import { DataSourceResolver, EvaluationContext, FieldPermission, FormSchema, LinkageEvaluators, PresentationDevice } from '../types';
|
|
4
4
|
export interface FormRendererProps {
|
|
5
5
|
schema: FormSchema;
|
|
6
6
|
/**
|
|
@@ -11,6 +11,20 @@ export interface FormRendererProps {
|
|
|
11
11
|
device?: PresentationDevice;
|
|
12
12
|
defaultValues?: RuntimeFormValues;
|
|
13
13
|
disabled?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Server-resolved per-field interactivity clamp (see {@link FieldPermission}),
|
|
16
|
+
* keyed by the field's data-binding `key`. The clamp is the OUTER bound —
|
|
17
|
+
* linkage may narrow further but never widen past it: `"hidden"` unmounts the
|
|
18
|
+
* field and drops its value from the submit payload, `"visible"` renders it
|
|
19
|
+
* read-only (excluded from payload and validation), `"required"` forces the
|
|
20
|
+
* empty-value check even without a static `validate.required`, and
|
|
21
|
+
* `"editable"` changes nothing. An absent prop OR an absent key means no
|
|
22
|
+
* clamp for that field — the renderer stays fully generic; hosts that want a
|
|
23
|
+
* default-deny posture materialize the full map server-side. Keys address
|
|
24
|
+
* root-scope keyed nodes only: a keyed subform is clamped whole (its template
|
|
25
|
+
* fields are never addressed individually).
|
|
26
|
+
*/
|
|
27
|
+
fieldPermissions?: Record<string, FieldPermission>;
|
|
14
28
|
/**
|
|
15
29
|
* Overrides for the dynamic linkage evaluators. Expression and script slots
|
|
16
30
|
* fall back to plain-JavaScript `new Function` compilation. Host projects
|
|
@@ -53,7 +67,19 @@ export interface FormRendererProps {
|
|
|
53
67
|
export interface FormRendererApi {
|
|
54
68
|
submit: () => Promise<void>;
|
|
55
69
|
reset: () => void;
|
|
70
|
+
/**
|
|
71
|
+
* The RAW live form state — including hidden fields' seeded defaults and
|
|
72
|
+
* read-only (non-writable-clamped) values. For the payload the submit
|
|
73
|
+
* pipeline would actually deliver, use {@link getSubmitValues}.
|
|
74
|
+
*/
|
|
56
75
|
getValues: () => RuntimeFormValues;
|
|
76
|
+
/**
|
|
77
|
+
* Exactly what the submit pipeline would deliver to `onSubmit` right now:
|
|
78
|
+
* the live values run through the same payload filtering (effectively-hidden
|
|
79
|
+
* fields dropped, non-writable-clamped keys excluded, subforms recursed per
|
|
80
|
+
* row) — without running validation or the submit lifecycle.
|
|
81
|
+
*/
|
|
82
|
+
getSubmitValues: () => RuntimeFormValues;
|
|
57
83
|
}
|
|
58
84
|
/**
|
|
59
85
|
* Runtime renderer for a form schema.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
import { GapScale, StackSlot } from '../types';
|
|
2
3
|
/**
|
|
3
4
|
* Pixel realization of each {@link GapScale}, shared by the runtime renderer and
|
|
4
5
|
* the editor canvas so a stack's vertical rhythm reads identically in both. The
|
|
@@ -17,3 +18,15 @@ export declare const DEFAULT_STACK_GAP: number;
|
|
|
17
18
|
* {@link DEFAULT_STACK_GAP} for the root document).
|
|
18
19
|
*/
|
|
19
20
|
export declare function resolveStackGap(scale: GapScale | undefined, fallback: number): number;
|
|
21
|
+
/**
|
|
22
|
+
* Resolve a block's {@link StackSlot} to a wrapper style. Shared by the runtime
|
|
23
|
+
* renderer and the editor canvas so a stack-sized block reads identically in
|
|
24
|
+
* both. An omitted width resolves to `100%` rather than `undefined`: the runtime
|
|
25
|
+
* wrapper is a direct flex-column item, where an `auto` cross-axis margin would
|
|
26
|
+
* otherwise cancel the flex stretch and collapse the block to content width —
|
|
27
|
+
* `100%` gives the auto margin real free space to distribute, so it stays a
|
|
28
|
+
* no-op at full width and becomes a cap-and-center once `maxWidth` bites, exactly
|
|
29
|
+
* matching the canvas wrapper's block-flow behaviour. The align margins only bite
|
|
30
|
+
* once a width (or maxWidth) narrows the block below the stack.
|
|
31
|
+
*/
|
|
32
|
+
export declare function stackSlotStyle(slot: StackSlot): CSSProperties;
|
|
@@ -1,19 +1,27 @@
|
|
|
1
1
|
import { RuntimeFieldState } from '../engine/linkage';
|
|
2
2
|
import { RuntimeFormValues } from '../runtime/types';
|
|
3
|
-
import { Block, EvaluationContext, KeyedFormField, LinkageEvaluators, RuntimeSchema, SubformNode } from '../types';
|
|
3
|
+
import { Block, EvaluationContext, FieldPermission, 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
|
|
7
7
|
* (a field inside a linkage-hidden section is just as invisible as a field
|
|
8
8
|
* hidden directly) — contributes its value; a hidden one is dropped whole.
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* per
|
|
9
|
+
* A key the server clamped non-writable (`"visible"` / `"hidden"`) is dropped
|
|
10
|
+
* too: the payload carries only writable keys (plus unclamped ones). Subforms
|
|
11
|
+
* recurse per row against that row's own record, so "hidden ⇒ not submitted"
|
|
12
|
+
* holds at every scope. Runs only on submit (a cold path), so the per-call tree
|
|
13
|
+
* walk is fine.
|
|
12
14
|
*/
|
|
13
15
|
export declare function filterSubmitValues(args: {
|
|
14
16
|
blocks: Block[];
|
|
15
17
|
evaluators: LinkageEvaluators | undefined;
|
|
16
18
|
evaluationContext: EvaluationContext | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Server-resolved clamp for THIS scope's keys. Only the root call passes it;
|
|
21
|
+
* the per-row recursion drops it — a template field is never clamped
|
|
22
|
+
* individually (the subform node itself carries the clamp).
|
|
23
|
+
*/
|
|
24
|
+
fieldPermissions?: Record<string, FieldPermission>;
|
|
17
25
|
values: RuntimeFormValues;
|
|
18
26
|
}): RuntimeFormValues;
|
|
19
27
|
/**
|
|
@@ -45,6 +53,13 @@ export declare function collectSubmitErrors(args: {
|
|
|
45
53
|
disabled: boolean;
|
|
46
54
|
evaluators: LinkageEvaluators | undefined;
|
|
47
55
|
evaluationContext: EvaluationContext | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Server-resolved clamp for the root scope's keys. Folded into the linkage
|
|
58
|
+
* evaluation, so a non-writable field is exempt through the existing
|
|
59
|
+
* hidden / disabled exemption and a `"required"` clamp fails an empty value
|
|
60
|
+
* even without a static `validate.required`.
|
|
61
|
+
*/
|
|
62
|
+
fieldPermissions?: Record<string, FieldPermission>;
|
|
48
63
|
namePrefix: string;
|
|
49
64
|
values: RuntimeFormValues;
|
|
50
65
|
}): Record<string, string>;
|
|
@@ -59,6 +74,13 @@ export declare function validateRuntimeField(args: {
|
|
|
59
74
|
evaluators: LinkageEvaluators | undefined;
|
|
60
75
|
evaluationContext: EvaluationContext | undefined;
|
|
61
76
|
field: KeyedFormField;
|
|
77
|
+
/**
|
|
78
|
+
* Server-resolved clamp for the field's own value scope. The renderer passes
|
|
79
|
+
* the map for root-scope fields and `undefined` inside subform rows (a
|
|
80
|
+
* template field is never clamped individually), keeping "rendered
|
|
81
|
+
* read-only" and "skips validation" in agreement for clamped fields.
|
|
82
|
+
*/
|
|
83
|
+
fieldPermissions?: Record<string, FieldPermission>;
|
|
62
84
|
namePrefix: string;
|
|
63
85
|
value: unknown;
|
|
64
86
|
values: RuntimeFormValues;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactElement, ReactNode } from 'react';
|
|
2
|
-
import { EffectAction, EvaluationContext, LinkageEvaluators, RuntimeSchema } from '../types';
|
|
2
|
+
import { EffectAction, EvaluationContext, FieldPermission, LinkageEvaluators, RuntimeSchema } from '../types';
|
|
3
3
|
import { RuntimeForm, RuntimeFormValues } from './types';
|
|
4
4
|
/**
|
|
5
5
|
* Run a list of effect actions in one value scope (root form or subform row).
|
|
@@ -51,6 +51,11 @@ export declare function dispatchFormEffects(args: {
|
|
|
51
51
|
actions: EffectAction[];
|
|
52
52
|
evaluators: LinkageEvaluators | undefined;
|
|
53
53
|
evaluationContext: EvaluationContext | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* The root scope's server permission clamp — form-scope effects always fire
|
|
56
|
+
* against the root value scope, so their `set_field` writes gate on it.
|
|
57
|
+
*/
|
|
58
|
+
fieldPermissions: Record<string, FieldPermission> | undefined;
|
|
54
59
|
form: RuntimeForm;
|
|
55
60
|
sinks: EffectSinks;
|
|
56
61
|
}): Promise<void>;
|
|
@@ -69,6 +74,11 @@ export declare function dispatchFormEffects(args: {
|
|
|
69
74
|
export declare function useScopeEffects(args: {
|
|
70
75
|
evaluators: LinkageEvaluators | undefined;
|
|
71
76
|
evaluationContext: EvaluationContext | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* This scope's server permission clamp for `set_field` writes. Root scope
|
|
79
|
+
* only — per-row controllers pass `undefined` (see `LinkageScope`).
|
|
80
|
+
*/
|
|
81
|
+
fieldPermissions: Record<string, FieldPermission> | undefined;
|
|
72
82
|
form: RuntimeForm;
|
|
73
83
|
prefix: string;
|
|
74
84
|
schema: RuntimeSchema;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { FieldPermission } from '../types';
|
|
2
|
+
import { RuntimeForm } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* The single gate for every programmatic form-value write: the state lane's
|
|
5
|
+
* `assign` applications (`applyScopedAssignments`) and the effect lane's
|
|
6
|
+
* `set_field` both land here, so the server permission clamp holds on every
|
|
7
|
+
* write path — not just user edits.
|
|
8
|
+
*
|
|
9
|
+
* - **Permission guard**: `fieldPermissions` is the firing scope's clamp map.
|
|
10
|
+
* The root scope carries the host map; subform-row scopes pass `undefined` —
|
|
11
|
+
* the same threading rule as the clamp in `evaluateRuntimeStates` (top-level
|
|
12
|
+
* permissions never address a template field). A write whose target's
|
|
13
|
+
* top-level key is clamped non-writable (`"visible"` / `"hidden"`) is dropped
|
|
14
|
+
* silently, mirroring the render path's "never crash the renderer" posture.
|
|
15
|
+
* - **No-op bail**: a write of the value the target already holds is dropped.
|
|
16
|
+
* TanStack's `setBy` mints a new values object even for an identical leaf,
|
|
17
|
+
* which would read as a value change and re-fire an opaque-condition `always`
|
|
18
|
+
* rule forever. Deep-equal because an expression-resolved value may be a
|
|
19
|
+
* fresh but content-equal object.
|
|
20
|
+
* - **Meta-free**: the write never runs the target's onChange listeners or
|
|
21
|
+
* marks it touched, so a programmatic write (e.g. a `load` effect) never
|
|
22
|
+
* surfaces a premature validation error. Validation itself still runs
|
|
23
|
+
* (`dontValidate` stays default) so a written value is checked like an edit.
|
|
24
|
+
*/
|
|
25
|
+
export declare function writeFieldValue(args: {
|
|
26
|
+
fieldPermissions: Record<string, FieldPermission> | undefined;
|
|
27
|
+
form: RuntimeForm;
|
|
28
|
+
/**
|
|
29
|
+
* The target's key within the firing value scope (`set_field`'s `targetKey`).
|
|
30
|
+
*/
|
|
31
|
+
key: string;
|
|
32
|
+
/**
|
|
33
|
+
* The scope's field-name prefix: `""` at the root, `"lines[0]."` in a row.
|
|
34
|
+
*/
|
|
35
|
+
prefix: string;
|
|
36
|
+
value: unknown;
|
|
37
|
+
}): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactElement, ReactNode } from 'react';
|
|
2
|
-
import { EvaluationContext, LinkageEvaluators, RuntimeSchema } from '../types';
|
|
2
|
+
import { EvaluationContext, FieldPermission, LinkageEvaluators, RuntimeSchema } from '../types';
|
|
3
3
|
import { EffectSinks } from './effects';
|
|
4
4
|
import { RuntimeForm } from './types';
|
|
5
5
|
/**
|
|
@@ -7,10 +7,11 @@ import { RuntimeForm } from './types';
|
|
|
7
7
|
* form-values object. `form.store.state.values` is one shared reference per
|
|
8
8
|
* write, so the default `Object.is` compare on the selector is correct here.
|
|
9
9
|
*/
|
|
10
|
-
export declare function RuntimeStateController({ children, evaluators, evaluationContext, form, schema, sinks }: {
|
|
10
|
+
export declare function RuntimeStateController({ children, evaluators, evaluationContext, fieldPermissions, form, schema, sinks }: {
|
|
11
11
|
children: ReactNode;
|
|
12
12
|
evaluators: LinkageEvaluators | undefined;
|
|
13
13
|
evaluationContext: EvaluationContext | undefined;
|
|
14
|
+
fieldPermissions: Record<string, FieldPermission> | undefined;
|
|
14
15
|
form: RuntimeForm;
|
|
15
16
|
schema: RuntimeSchema;
|
|
16
17
|
sinks: EffectSinks;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { UnboundStore, StoreProviderProps, UseStore } from '@vef-framework-react/core';
|
|
2
2
|
import { DropTarget } from '../engine/schema/edit-ops';
|
|
3
|
-
import { Block, FieldDefinition, FlexSlot, FormField, FormSchema, GapScale, PresentationDevice, PresentationLayer } from '../types';
|
|
3
|
+
import { Block, FieldDefinition, FlexSlot, FormField, FormSchema, GapScale, PresentationDevice, PresentationLayer, StackSlot } from '../types';
|
|
4
4
|
import { ComponentType } from 'react';
|
|
5
5
|
export type { DropTarget } from '../engine/schema/edit-ops';
|
|
6
6
|
export { createEmptySchema } from '../engine/schema/nodes';
|
|
@@ -164,6 +164,14 @@ export interface FormEditorStoreState {
|
|
|
164
164
|
nodeId: string;
|
|
165
165
|
width: number | undefined;
|
|
166
166
|
}) => void;
|
|
167
|
+
/**
|
|
168
|
+
* Set a block's stack sizing + placement (used when the block is a direct child
|
|
169
|
+
* of a stack body — root / section / tab / stack subform).
|
|
170
|
+
*/
|
|
171
|
+
setStackSlot: (args: {
|
|
172
|
+
nodeId: string;
|
|
173
|
+
slot: StackSlot | undefined;
|
|
174
|
+
}) => void;
|
|
167
175
|
/**
|
|
168
176
|
* Apply a pure updater to a single leaf field. The properties panel forwards
|
|
169
177
|
* updaters from each `PropertyEntry.write` lens, keeping the action
|
|
@@ -292,6 +292,22 @@ export interface EffectDispatchContext {
|
|
|
292
292
|
*/
|
|
293
293
|
resolveValue: (value: LinkageActionValue) => unknown;
|
|
294
294
|
}
|
|
295
|
+
/**
|
|
296
|
+
* Server-resolved per-field interactivity clamp. Lockstep contract: mirrors the
|
|
297
|
+
* Go backend's `approval.Permission` and approval-flow-editor's
|
|
298
|
+
* `FieldPermission` literal-for-literal.
|
|
299
|
+
*
|
|
300
|
+
* The clamp is the OUTER bound on a keyed node's runtime state — linkage may
|
|
301
|
+
* only narrow (hide / disable) within it, never widen past it:
|
|
302
|
+
*
|
|
303
|
+
* - `"hidden"` — never mounted, value never submitted.
|
|
304
|
+
* - `"visible"` — mounted read-only (via the disabled channel), value never
|
|
305
|
+
* submitted, exempt from validation, never required.
|
|
306
|
+
* - `"editable"` — no clamp; linkage governs alone.
|
|
307
|
+
* - `"required"` — editable and always required, overruling a linkage
|
|
308
|
+
* `optional` outcome.
|
|
309
|
+
*/
|
|
310
|
+
export type FieldPermission = "visible" | "editable" | "hidden" | "required";
|
|
295
311
|
/**
|
|
296
312
|
* Extra scope surfaced to expressions and scripts alongside the form values.
|
|
297
313
|
* The default evaluator exposes these as `$vars` / `$user` / `$node` (plus
|
|
@@ -85,6 +85,35 @@ export interface FlexSlot {
|
|
|
85
85
|
shrink?: number;
|
|
86
86
|
basis?: string;
|
|
87
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* A length as an explicit value + unit — the visual editor authors sizing this
|
|
90
|
+
* way rather than raw CSS strings, so a persisted length is always a valid,
|
|
91
|
+
* re-editable dimension (no `calc()` / typo to parse back). `px` is absolute;
|
|
92
|
+
* `%` is relative to the block's stack width.
|
|
93
|
+
*/
|
|
94
|
+
export interface CssLength {
|
|
95
|
+
value: number;
|
|
96
|
+
unit: "px" | "%";
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Per-block sizing + horizontal placement, honored when the block is a direct
|
|
100
|
+
* child of a STACK body — the document root, a {@link SectionNode}, a
|
|
101
|
+
* {@link TabsNode} pane, or a {@link StackSubform}. That is the one parent
|
|
102
|
+
* context that otherwise leaves a block full-width; grid cells size by `span`
|
|
103
|
+
* and flex slots by {@link FlexSlot}, so this is ignored there (a block carries
|
|
104
|
+
* at most one meaningful layout prop, selected by its parent).
|
|
105
|
+
*
|
|
106
|
+
* `width` / `minWidth` / `maxWidth` map to the CSS box constraints of the same
|
|
107
|
+
* name; combine them for responsive sizing (e.g. `width` 100% capped by a
|
|
108
|
+
* `maxWidth`). `align` places the block on the cross axis once it is narrower
|
|
109
|
+
* than the stack (a no-op at full width).
|
|
110
|
+
*/
|
|
111
|
+
export interface StackSlot {
|
|
112
|
+
width?: CssLength;
|
|
113
|
+
minWidth?: CssLength;
|
|
114
|
+
maxWidth?: CssLength;
|
|
115
|
+
align?: "start" | "center" | "end";
|
|
116
|
+
}
|
|
88
117
|
/**
|
|
89
118
|
* A "block" is any node in the layout tree — a leaf field or a container.
|
|
90
119
|
* Blocks stack vertically in their parent's order.
|
|
@@ -97,6 +126,9 @@ export interface FlexSlot {
|
|
|
97
126
|
* - `columnWidth` is a fixed pixel width honored only when the block is a column
|
|
98
127
|
* of a {@link TableSubform}; omitted means the column shares the table's
|
|
99
128
|
* remaining width with the other auto columns. Ignored outside a table subform.
|
|
129
|
+
* - `stack` sizes and places the block when it is a direct child of a stack body
|
|
130
|
+
* (root / section / tab / stack subform); omitted means full width. Ignored in a
|
|
131
|
+
* grid / flex / table subform, where `span` / `flex` / `columnWidth` apply.
|
|
100
132
|
* - `linkage` is honored on any block: `show` / `hide` / `enable` / `disable`
|
|
101
133
|
* apply to leaves and containers alike (a container's `disable` propagates to
|
|
102
134
|
* its descendants at runtime). The value-bearing actions (`require` /
|
|
@@ -107,6 +139,7 @@ interface BlockBase extends NodeBase {
|
|
|
107
139
|
span?: number;
|
|
108
140
|
flex?: FlexSlot;
|
|
109
141
|
columnWidth?: number;
|
|
142
|
+
stack?: StackSlot;
|
|
110
143
|
linkage?: FieldLinkage;
|
|
111
144
|
}
|
|
112
145
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vef-framework-react/form-editor",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.10.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Form editor for VEF framework",
|
|
6
6
|
"keywords": [
|
|
@@ -46,10 +46,10 @@
|
|
|
46
46
|
"@emotion/react": "^11.14.0",
|
|
47
47
|
"antd-mobile": "^5.42.3",
|
|
48
48
|
"lucide-react": "^1.23.0",
|
|
49
|
-
"@vef-framework-react/components": "2.
|
|
50
|
-
"@vef-framework-react/shared": "2.
|
|
51
|
-
"@vef-framework-react/
|
|
52
|
-
"@vef-framework-react/
|
|
49
|
+
"@vef-framework-react/components": "2.10.0",
|
|
50
|
+
"@vef-framework-react/shared": "2.10.0",
|
|
51
|
+
"@vef-framework-react/core": "2.10.0",
|
|
52
|
+
"@vef-framework-react/hooks": "2.10.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"react": "^19.2.7"
|