@bsm-form/core 0.39.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/index.cjs +5221 -0
- package/dist/index.d.cts +591 -0
- package/dist/index.d.ts +591 -0
- package/dist/index.js +5196 -0
- package/package.json +37 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,591 @@
|
|
|
1
|
+
import * as _bsm_form_schema from '@bsm-form/schema';
|
|
2
|
+
import { ToastVariant, ToastPosition, Condition, DisplayEventType, FieldEventType, TableInteraction, DialogEventType, DrawerEventType, RepeatOperation, Node, ActionNode, DisplayNode, FieldNode, LayoutNode, ValidationRule, FormSchema, TableTagValueMapping } from '@bsm-form/schema';
|
|
3
|
+
|
|
4
|
+
type FormEngineNotification = {
|
|
5
|
+
message: string;
|
|
6
|
+
variant: ToastVariant;
|
|
7
|
+
position?: ToastPosition;
|
|
8
|
+
/** Display duration in milliseconds. */
|
|
9
|
+
duration?: number;
|
|
10
|
+
};
|
|
11
|
+
type InvokeContext = {
|
|
12
|
+
values: Record<string, unknown>;
|
|
13
|
+
resources: Record<string, unknown>;
|
|
14
|
+
row?: Record<string, unknown>;
|
|
15
|
+
item?: Record<string, unknown>;
|
|
16
|
+
};
|
|
17
|
+
type InvokeHandler = (ctx: InvokeContext) => void | Promise<void>;
|
|
18
|
+
/** Sync visibility / when-branch predicate. Must not return a Promise. */
|
|
19
|
+
type PredicateHandler = (ctx: InvokeContext) => boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Sync field validator. `true` = valid; string = error message.
|
|
22
|
+
* Must not return a Promise.
|
|
23
|
+
*/
|
|
24
|
+
type ValidatorHandler = (ctx: InvokeContext) => true | string;
|
|
25
|
+
/** Sync computed value producer. Must not return a Promise. */
|
|
26
|
+
type ComputerHandler = (ctx: InvokeContext) => unknown;
|
|
27
|
+
type FormEngineEnvironment = {
|
|
28
|
+
request: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
29
|
+
log: (message: string) => void;
|
|
30
|
+
navigate: (to: string) => void;
|
|
31
|
+
notify: (notification: FormEngineNotification) => void;
|
|
32
|
+
/** Host-registered handlers keyed by invoke Step `name`. */
|
|
33
|
+
invoke: Record<string, InvokeHandler>;
|
|
34
|
+
/** Host-registered sync predicates for `{ type: "invoke", name }` conditions. */
|
|
35
|
+
predicates: Record<string, PredicateHandler>;
|
|
36
|
+
/** Host-registered sync validators for `{ type: "invoke", name }` rules. */
|
|
37
|
+
validators: Record<string, ValidatorHandler>;
|
|
38
|
+
/** Host-registered sync computers for `{ operator: "invoke", name }` computed. */
|
|
39
|
+
computers: Record<string, ComputerHandler>;
|
|
40
|
+
};
|
|
41
|
+
declare function createFormEngineEnvironment(overrides?: Partial<FormEngineEnvironment>): FormEngineEnvironment;
|
|
42
|
+
declare function isThenable(value: unknown): value is PromiseLike<unknown>;
|
|
43
|
+
|
|
44
|
+
declare const conditions: {
|
|
45
|
+
run(ctx: PipelineContext): void;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
declare class DependencyGraph {
|
|
49
|
+
private forward;
|
|
50
|
+
private reverse;
|
|
51
|
+
addDependency(from: string, to: string): void;
|
|
52
|
+
private addEdge;
|
|
53
|
+
private wouldCreateCycle;
|
|
54
|
+
getAffected(field: string): string[];
|
|
55
|
+
getDependencies(field: string): string[];
|
|
56
|
+
getDependentsDeep(field: string): string[];
|
|
57
|
+
getAffectedInOrder(fields: Iterable<string>): string[];
|
|
58
|
+
sortTopologically(fields: Iterable<string>): string[];
|
|
59
|
+
extractDependencies(conditions: readonly Condition[]): string[];
|
|
60
|
+
clear(): void;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
declare class EventBus<TEvent> {
|
|
64
|
+
private listeners;
|
|
65
|
+
emit(event: TEvent): void;
|
|
66
|
+
subscribe(listener: Listener<TEvent>): () => void;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
type StepRunOptions = {
|
|
70
|
+
row?: Record<string, unknown>;
|
|
71
|
+
item?: Record<string, unknown>;
|
|
72
|
+
/** Values-mode Repeat item index for remove/move/duplicate defaults. */
|
|
73
|
+
itemIndex?: number;
|
|
74
|
+
/** Parent values-mode path prefix (e.g. `todos.0`) for nested repeats. */
|
|
75
|
+
valuePrefix?: string;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
declare class FormEngine {
|
|
79
|
+
private runtimeTree;
|
|
80
|
+
private values;
|
|
81
|
+
private resources;
|
|
82
|
+
private initialValues?;
|
|
83
|
+
private initialResources?;
|
|
84
|
+
bus: EventBus<FormEvent>;
|
|
85
|
+
private graph;
|
|
86
|
+
private stepRunner;
|
|
87
|
+
private environment;
|
|
88
|
+
private fieldNodes;
|
|
89
|
+
private actionNodes;
|
|
90
|
+
private displayNodes;
|
|
91
|
+
private stepperNodes;
|
|
92
|
+
private paginationNodes;
|
|
93
|
+
private tabsNodes;
|
|
94
|
+
private accordionNodes;
|
|
95
|
+
private dialogNodes;
|
|
96
|
+
private drawerNodes;
|
|
97
|
+
private repeatNodes;
|
|
98
|
+
private accordionItemNodes;
|
|
99
|
+
private valuesRepeatMetas;
|
|
100
|
+
private valuesRepeatFieldIds;
|
|
101
|
+
private itemFieldState;
|
|
102
|
+
private state;
|
|
103
|
+
private pendingActionIds;
|
|
104
|
+
private pendingTableInteractions;
|
|
105
|
+
private runningFieldEvents;
|
|
106
|
+
private runningLayoutEvents;
|
|
107
|
+
private resourceInFlight;
|
|
108
|
+
private computedMap;
|
|
109
|
+
private batchDepth;
|
|
110
|
+
private hasPendingStateUpdate;
|
|
111
|
+
private initializationPromise?;
|
|
112
|
+
private skipLoadStepsOnInitialize;
|
|
113
|
+
constructor(runtimeTree: RuntimeNode, environment?: Partial<FormEngineEnvironment>);
|
|
114
|
+
runLoadSteps(): Promise<void>;
|
|
115
|
+
initialize(options?: {
|
|
116
|
+
skipLoadSteps?: boolean;
|
|
117
|
+
}): Promise<void>;
|
|
118
|
+
private performInitialization;
|
|
119
|
+
private buildNodeIndexes;
|
|
120
|
+
private getFieldNode;
|
|
121
|
+
private hydrateValues;
|
|
122
|
+
getError(name: string): string | undefined;
|
|
123
|
+
touch(name: string): void;
|
|
124
|
+
isVisible(name: string): boolean;
|
|
125
|
+
isDisabled(name: string): boolean;
|
|
126
|
+
isTouched(name: string): boolean;
|
|
127
|
+
isDirty(name: string): boolean;
|
|
128
|
+
isFormDisabled(): boolean;
|
|
129
|
+
setValue(name: string, value: unknown): void;
|
|
130
|
+
setResource(path: string, value: unknown): void;
|
|
131
|
+
getState(): {
|
|
132
|
+
pendingActionIds: string[];
|
|
133
|
+
pendingTableInteractions: string[];
|
|
134
|
+
resourceInFlight: string[];
|
|
135
|
+
isSubmitting: boolean;
|
|
136
|
+
isSubmitted: boolean;
|
|
137
|
+
isValidating: boolean;
|
|
138
|
+
isLoading: boolean;
|
|
139
|
+
initializationStatus: InitializationStatus;
|
|
140
|
+
initializationError?: unknown;
|
|
141
|
+
};
|
|
142
|
+
isResourceInFlight(path: string): boolean;
|
|
143
|
+
isOptionsSourceLoading(fieldName: string): boolean;
|
|
144
|
+
markResourceInFlight(saveAs: string): void;
|
|
145
|
+
clearResourceInFlight(saveAs: string): void;
|
|
146
|
+
getStepperState(stepperId: string): StepperState | undefined;
|
|
147
|
+
getPaginationState(paginationId: string): PaginationState | undefined;
|
|
148
|
+
changePagination(paginationId: string, page: number, pageSize: number): Promise<PaginationChangeResult>;
|
|
149
|
+
getTabsState(tabsId: string): TabsState | undefined;
|
|
150
|
+
changeTabs(tabsId: string, tabId: string): Promise<TabsChangeResult>;
|
|
151
|
+
getAccordionState(accordionId: string): AccordionState | undefined;
|
|
152
|
+
changeAccordion(accordionId: string, nextValue: string | string[]): Promise<AccordionChangeResult>;
|
|
153
|
+
getDialogState(dialogId: string): DialogState | undefined;
|
|
154
|
+
getDrawerState(drawerId: string): DrawerState | undefined;
|
|
155
|
+
setValues(nextValues: Record<string, unknown>): void;
|
|
156
|
+
getValue(name: string): unknown;
|
|
157
|
+
getTree(): RuntimeNode;
|
|
158
|
+
getValues(): FormValues;
|
|
159
|
+
getResources(): Record<string, unknown>;
|
|
160
|
+
getErrors(): Record<string, string>;
|
|
161
|
+
getSnapshot(): FormSnapshot;
|
|
162
|
+
subscribe(listener: () => void): () => void;
|
|
163
|
+
isValid(): boolean;
|
|
164
|
+
private getActionNode;
|
|
165
|
+
getBindValue(path: string): unknown;
|
|
166
|
+
batch<T>(operation: () => T | Promise<T>): Promise<T>;
|
|
167
|
+
executeAction(actionName: string, options?: StepRunOptions): Promise<unknown>;
|
|
168
|
+
private executeSubmitAction;
|
|
169
|
+
private runSubmitValidation;
|
|
170
|
+
executeDisplayEvent(nodeId: string, event: DisplayEventType, options?: StepRunOptions): Promise<void>;
|
|
171
|
+
executeFieldEvent(nodeId: string, event: FieldEventType, options?: StepRunOptions): Promise<void>;
|
|
172
|
+
private findFieldNodeById;
|
|
173
|
+
executeTableInteraction(nodeId: string, interaction: TableInteraction): Promise<void>;
|
|
174
|
+
openDialog(dialogId: string): Promise<DialogTransitionResult>;
|
|
175
|
+
closeDialog(dialogId: string): Promise<DialogTransitionResult>;
|
|
176
|
+
executeDialogStep(dialogId: string, operation: DialogEventType): Promise<DialogTransitionResult>;
|
|
177
|
+
openDrawer(drawerId: string): Promise<DrawerTransitionResult>;
|
|
178
|
+
closeDrawer(drawerId: string): Promise<DrawerTransitionResult>;
|
|
179
|
+
executeDrawerStep(drawerId: string, operation: DrawerEventType): Promise<DrawerTransitionResult>;
|
|
180
|
+
goToStep(stepperId: string, stepId: string): Promise<StepperNavigationResult>;
|
|
181
|
+
nextStep(stepperId: string): Promise<StepperNavigationResult>;
|
|
182
|
+
previousStep(stepperId: string): Promise<StepperNavigationResult>;
|
|
183
|
+
validateStep(stepperId: string, stepId: string): {
|
|
184
|
+
valid: boolean;
|
|
185
|
+
errors: Record<string, string>;
|
|
186
|
+
};
|
|
187
|
+
submit(): {
|
|
188
|
+
valid: boolean;
|
|
189
|
+
errors: {
|
|
190
|
+
[x: string]: string;
|
|
191
|
+
};
|
|
192
|
+
snapshot: FormSnapshot;
|
|
193
|
+
};
|
|
194
|
+
reset(): void;
|
|
195
|
+
onValueChanged({ name, value }: {
|
|
196
|
+
name: string;
|
|
197
|
+
value: unknown;
|
|
198
|
+
}): void;
|
|
199
|
+
private applyValueChanges;
|
|
200
|
+
private touchAll;
|
|
201
|
+
private createFullPipelineContext;
|
|
202
|
+
private getConditionState;
|
|
203
|
+
private reevaluateConditions;
|
|
204
|
+
private syncPendingState;
|
|
205
|
+
private settleAllFields;
|
|
206
|
+
private transitionDialog;
|
|
207
|
+
private transitionDrawer;
|
|
208
|
+
private transitionOverlay;
|
|
209
|
+
private getStepperSteps;
|
|
210
|
+
private getAvailableSteps;
|
|
211
|
+
private isStepAvailable;
|
|
212
|
+
private resetStepperStates;
|
|
213
|
+
private resetPaginationStates;
|
|
214
|
+
private resetTabsStates;
|
|
215
|
+
private resetAccordionStates;
|
|
216
|
+
private createAccordionState;
|
|
217
|
+
private runLayoutChangeEvent;
|
|
218
|
+
private createPaginationState;
|
|
219
|
+
private resetOverlayStates;
|
|
220
|
+
private reconcileStepperStates;
|
|
221
|
+
private validateStepNode;
|
|
222
|
+
private createStepperNavigationResult;
|
|
223
|
+
private notifyStateUpdated;
|
|
224
|
+
/** Emit even inside `batch` so UI can observe in-flight resource fetches. */
|
|
225
|
+
private notifyStateUpdatedImmediate;
|
|
226
|
+
private buildDependencyGraph;
|
|
227
|
+
getOptions(name: string): {
|
|
228
|
+
label: string;
|
|
229
|
+
value: _bsm_form_schema.SelectOptionValue;
|
|
230
|
+
}[] | {
|
|
231
|
+
disabled?: unknown;
|
|
232
|
+
label: unknown;
|
|
233
|
+
value: unknown;
|
|
234
|
+
}[];
|
|
235
|
+
getTableRows(nodeId: string, options?: {
|
|
236
|
+
item?: Record<string, unknown>;
|
|
237
|
+
}): Record<string, unknown>[];
|
|
238
|
+
getTypographyText(nodeId: string, options?: {
|
|
239
|
+
item?: Record<string, unknown>;
|
|
240
|
+
}): string;
|
|
241
|
+
getTagText(nodeId: string, options?: {
|
|
242
|
+
item?: Record<string, unknown>;
|
|
243
|
+
}): string;
|
|
244
|
+
getTagPresentation(nodeId: string, options?: {
|
|
245
|
+
item?: Record<string, unknown>;
|
|
246
|
+
}): {
|
|
247
|
+
label: string;
|
|
248
|
+
variant?: string;
|
|
249
|
+
};
|
|
250
|
+
getAccordionItemTitle(nodeId: string, options?: {
|
|
251
|
+
item?: Record<string, unknown>;
|
|
252
|
+
}): string;
|
|
253
|
+
getRepeatItems(nodeId: string, options?: {
|
|
254
|
+
valuePrefix?: string;
|
|
255
|
+
}): Record<string, unknown>[];
|
|
256
|
+
mutateRepeat(target: string, operation: RepeatOperation, options?: {
|
|
257
|
+
from?: string;
|
|
258
|
+
field?: string;
|
|
259
|
+
index?: number;
|
|
260
|
+
to?: number;
|
|
261
|
+
item?: Record<string, unknown>;
|
|
262
|
+
valuePrefix?: string;
|
|
263
|
+
}): Promise<RepeatMutationResult>;
|
|
264
|
+
private resolveField;
|
|
265
|
+
private ensureItemFieldState;
|
|
266
|
+
private readValuesRepeatLength;
|
|
267
|
+
private buildRepeatItem;
|
|
268
|
+
private validateValuesRepeatFields;
|
|
269
|
+
private touchAllValuesRepeatFields;
|
|
270
|
+
private pruneItemFieldState;
|
|
271
|
+
private shiftItemFieldState;
|
|
272
|
+
private rebuildItemFieldStateOrder;
|
|
273
|
+
private runRepeatEvent;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
declare const validation: {
|
|
277
|
+
run(ctx: PipelineContext): void;
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
type RuntimeNodeState = {
|
|
281
|
+
visible: boolean;
|
|
282
|
+
disabled: boolean;
|
|
283
|
+
touched: boolean;
|
|
284
|
+
dirty: boolean;
|
|
285
|
+
error?: string;
|
|
286
|
+
/** Present only on `stepper` layout nodes. */
|
|
287
|
+
activeStepId?: string;
|
|
288
|
+
/** Present only on `dialog` and `drawer` overlay layout nodes. */
|
|
289
|
+
open?: boolean;
|
|
290
|
+
/** Present only on `pagination` layout nodes. */
|
|
291
|
+
page?: number;
|
|
292
|
+
/** Present only on `pagination` layout nodes. */
|
|
293
|
+
pageSize?: number;
|
|
294
|
+
/** Present only on `tabs` layout nodes. */
|
|
295
|
+
activeTabId?: string;
|
|
296
|
+
/** Present only on `accordion` layout nodes. */
|
|
297
|
+
openItemIds?: string[];
|
|
298
|
+
};
|
|
299
|
+
type RuntimeNode = {
|
|
300
|
+
id: string;
|
|
301
|
+
schema: Node;
|
|
302
|
+
state: RuntimeNodeState;
|
|
303
|
+
children: RuntimeNode[];
|
|
304
|
+
};
|
|
305
|
+
type RuntimeTree = {
|
|
306
|
+
root: RuntimeNode;
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
type ActionContext = {
|
|
310
|
+
values: Record<string, unknown>;
|
|
311
|
+
engine: FormEngine;
|
|
312
|
+
};
|
|
313
|
+
type ActionHandler = (ctx: ActionContext) => Promise<unknown> | unknown;
|
|
314
|
+
type FormEngineConfig = {
|
|
315
|
+
actions?: Record<string, ActionHandler>;
|
|
316
|
+
};
|
|
317
|
+
type FormValues = Record<string, unknown>;
|
|
318
|
+
type InitializationStatus = "idle" | "loading" | "ready" | "failed";
|
|
319
|
+
type FormEngineState = {
|
|
320
|
+
isSubmitting: boolean;
|
|
321
|
+
isSubmitted: boolean;
|
|
322
|
+
isValidating: boolean;
|
|
323
|
+
isLoading: boolean;
|
|
324
|
+
initializationStatus: InitializationStatus;
|
|
325
|
+
initializationError?: unknown;
|
|
326
|
+
/** Action node ids currently running custom steps. */
|
|
327
|
+
pendingActionIds: readonly string[];
|
|
328
|
+
/** Table interaction keys currently running (`nodeId:rowClick` or `nodeId:columnId:actionId`). */
|
|
329
|
+
pendingTableInteractions: readonly string[];
|
|
330
|
+
/** Resource relative paths currently being written by an in-flight API `saveAs`. */
|
|
331
|
+
resourceInFlight: readonly string[];
|
|
332
|
+
};
|
|
333
|
+
type FormSnapshot = {
|
|
334
|
+
values: Record<string, unknown>;
|
|
335
|
+
nodes: Map<string, RuntimeNode>;
|
|
336
|
+
};
|
|
337
|
+
type PipelineContext = {
|
|
338
|
+
tree: RuntimeNode;
|
|
339
|
+
values: FormValues;
|
|
340
|
+
changedField: string;
|
|
341
|
+
value: unknown;
|
|
342
|
+
affectedFields?: string[];
|
|
343
|
+
computedMap?: Map<string, RuntimeNode>;
|
|
344
|
+
resources?: Record<string, unknown>;
|
|
345
|
+
environment?: FormEngineEnvironment;
|
|
346
|
+
state?: Pick<FormEngineState, "isLoading" | "initializationStatus" | "pendingActionIds" | "resourceInFlight"> & {
|
|
347
|
+
/** Mirrors `FormEngine.isValid()` for `$state.isValid` conditions. */
|
|
348
|
+
isValid?: boolean;
|
|
349
|
+
};
|
|
350
|
+
};
|
|
351
|
+
type FormErrors = Record<string, string | undefined>;
|
|
352
|
+
type StepperState = {
|
|
353
|
+
activeStepId?: string;
|
|
354
|
+
canGoNext: boolean;
|
|
355
|
+
canGoPrevious: boolean;
|
|
356
|
+
};
|
|
357
|
+
type StepperNavigationReason = "changed" | "already-active" | "not-ready" | "stepper-not-found" | "step-not-found" | "step-unavailable" | "validation-failed" | "no-next-step" | "no-previous-step";
|
|
358
|
+
type StepperNavigationResult = {
|
|
359
|
+
reached: boolean;
|
|
360
|
+
changed: boolean;
|
|
361
|
+
activeStepId?: string;
|
|
362
|
+
reason: StepperNavigationReason;
|
|
363
|
+
errors: Record<string, string>;
|
|
364
|
+
};
|
|
365
|
+
type PaginationState = {
|
|
366
|
+
page: number;
|
|
367
|
+
pageSize: number;
|
|
368
|
+
totalItems: number;
|
|
369
|
+
totalPages: number;
|
|
370
|
+
};
|
|
371
|
+
type PaginationChangeReason = "changed" | "already-current" | "not-ready" | "pagination-not-found" | "invalid-page" | "invalid-page-size";
|
|
372
|
+
type PaginationChangeResult = PaginationState & {
|
|
373
|
+
changed: boolean;
|
|
374
|
+
reason: PaginationChangeReason;
|
|
375
|
+
};
|
|
376
|
+
type TabsState = {
|
|
377
|
+
activeTabId?: string;
|
|
378
|
+
};
|
|
379
|
+
type TabsChangeReason = "changed" | "already-active" | "not-ready" | "tabs-not-found" | "tab-not-found";
|
|
380
|
+
type TabsChangeResult = TabsState & {
|
|
381
|
+
changed: boolean;
|
|
382
|
+
reason: TabsChangeReason;
|
|
383
|
+
};
|
|
384
|
+
type AccordionState = {
|
|
385
|
+
openItemIds: string[];
|
|
386
|
+
type: "single" | "multiple";
|
|
387
|
+
};
|
|
388
|
+
type AccordionChangeReason = "changed" | "already-current" | "not-ready" | "accordion-not-found" | "invalid-item";
|
|
389
|
+
type AccordionChangeResult = AccordionState & {
|
|
390
|
+
changed: boolean;
|
|
391
|
+
reason: AccordionChangeReason;
|
|
392
|
+
};
|
|
393
|
+
type DialogState = {
|
|
394
|
+
open: boolean;
|
|
395
|
+
};
|
|
396
|
+
type DialogTransitionReason = "opened" | "closed" | "already-open" | "already-closed" | "not-ready" | "dialog-not-found";
|
|
397
|
+
type DialogTransitionResult = {
|
|
398
|
+
changed: boolean;
|
|
399
|
+
open: boolean;
|
|
400
|
+
reason: DialogTransitionReason;
|
|
401
|
+
};
|
|
402
|
+
type DrawerState = {
|
|
403
|
+
open: boolean;
|
|
404
|
+
};
|
|
405
|
+
type DrawerTransitionReason = "opened" | "closed" | "already-open" | "already-closed" | "not-ready" | "drawer-not-found";
|
|
406
|
+
type DrawerTransitionResult = {
|
|
407
|
+
changed: boolean;
|
|
408
|
+
open: boolean;
|
|
409
|
+
reason: DrawerTransitionReason;
|
|
410
|
+
};
|
|
411
|
+
type FormState = {
|
|
412
|
+
values: FormValues;
|
|
413
|
+
errors: FormErrors;
|
|
414
|
+
};
|
|
415
|
+
type DependencyMap = Map<string, Set<string>>;
|
|
416
|
+
type FormEvent = {
|
|
417
|
+
type: "VALUE_CHANGED";
|
|
418
|
+
payload: {
|
|
419
|
+
name: string;
|
|
420
|
+
value: unknown;
|
|
421
|
+
};
|
|
422
|
+
} | {
|
|
423
|
+
type: "STATE_UPDATED";
|
|
424
|
+
};
|
|
425
|
+
type RepeatMutationReason = "changed" | "not-ready" | "repeat-not-found" | "not-values-mode" | "min-items" | "max-items" | "index-out-of-range" | "invalid-target";
|
|
426
|
+
type RepeatMutationResult = {
|
|
427
|
+
changed: boolean;
|
|
428
|
+
reason: RepeatMutationReason;
|
|
429
|
+
length: number;
|
|
430
|
+
index?: number;
|
|
431
|
+
};
|
|
432
|
+
|
|
433
|
+
type LoadingPropState = {
|
|
434
|
+
isLoading: boolean;
|
|
435
|
+
pendingActionIds?: readonly string[];
|
|
436
|
+
resourceInFlight?: readonly string[];
|
|
437
|
+
};
|
|
438
|
+
/**
|
|
439
|
+
* Resolves schema `props.loading` (boolean or `$state` / `$pending` binding)
|
|
440
|
+
* to a boolean for design-system components.
|
|
441
|
+
*/
|
|
442
|
+
declare function resolveLoadingProp(loading: unknown, state?: LoadingPropState): boolean;
|
|
443
|
+
|
|
444
|
+
type FieldAdapterInput = {
|
|
445
|
+
schema: FieldNode;
|
|
446
|
+
field: {
|
|
447
|
+
value: unknown;
|
|
448
|
+
error?: string;
|
|
449
|
+
disabled?: boolean;
|
|
450
|
+
touched?: boolean;
|
|
451
|
+
touch: () => void;
|
|
452
|
+
};
|
|
453
|
+
setValue: (v: unknown) => void;
|
|
454
|
+
/** Engine snapshot for resolving `$state.*` / `$pending.*` loading bindings. */
|
|
455
|
+
state?: LoadingPropState;
|
|
456
|
+
/** Extra runtime loading (e.g. options source in flight). */
|
|
457
|
+
loading?: boolean;
|
|
458
|
+
};
|
|
459
|
+
type ActionAdapterInput = {
|
|
460
|
+
schema: ActionNode;
|
|
461
|
+
onClick: () => void;
|
|
462
|
+
loading?: boolean;
|
|
463
|
+
disabled?: boolean;
|
|
464
|
+
state?: LoadingPropState;
|
|
465
|
+
};
|
|
466
|
+
type LayoutAdapterInput<TChildren = unknown> = {
|
|
467
|
+
schema: LayoutNode;
|
|
468
|
+
children: TChildren;
|
|
469
|
+
};
|
|
470
|
+
type DisplayAdapterInput = {
|
|
471
|
+
schema: DisplayNode;
|
|
472
|
+
onClose?: () => void;
|
|
473
|
+
onAction?: () => void;
|
|
474
|
+
onClick?: () => void;
|
|
475
|
+
/** Runtime disabled (e.g. from `disabledWhen`). */
|
|
476
|
+
disabled?: boolean;
|
|
477
|
+
};
|
|
478
|
+
|
|
479
|
+
type OptionsConfig = {
|
|
480
|
+
source: string;
|
|
481
|
+
labelField: string;
|
|
482
|
+
valueField: string;
|
|
483
|
+
} | {
|
|
484
|
+
items: {
|
|
485
|
+
label: string;
|
|
486
|
+
value: string | number;
|
|
487
|
+
}[];
|
|
488
|
+
};
|
|
489
|
+
type Listener<T> = (event: T) => void;
|
|
490
|
+
type ValidationResult = {
|
|
491
|
+
valid: boolean;
|
|
492
|
+
error?: string;
|
|
493
|
+
};
|
|
494
|
+
type Validator<Rule extends ValidationRule = ValidationRule> = (value: unknown, rule: Rule) => ValidationResult;
|
|
495
|
+
|
|
496
|
+
declare function compileSchema(node: Node): RuntimeNode;
|
|
497
|
+
|
|
498
|
+
declare function createRuntimeNode(schema: Node): RuntimeNode;
|
|
499
|
+
|
|
500
|
+
declare function traverseNode(node: RuntimeNode, callback: (node: RuntimeNode) => void): void;
|
|
501
|
+
|
|
502
|
+
type BuiltinValidationType = Exclude<ValidationRule["type"], "invoke">;
|
|
503
|
+
type ValidationRegistry = {
|
|
504
|
+
[Type in BuiltinValidationType]: Validator<Extract<ValidationRule, {
|
|
505
|
+
type: Type;
|
|
506
|
+
}>>;
|
|
507
|
+
};
|
|
508
|
+
declare const validationRegistry: ValidationRegistry;
|
|
509
|
+
|
|
510
|
+
type ValidateFieldOptions = {
|
|
511
|
+
environment?: FormEngineEnvironment;
|
|
512
|
+
values?: Record<string, unknown>;
|
|
513
|
+
resources?: Record<string, unknown>;
|
|
514
|
+
row?: Record<string, unknown>;
|
|
515
|
+
item?: Record<string, unknown>;
|
|
516
|
+
};
|
|
517
|
+
declare function validateField(node: FieldNode, value: unknown, options?: ValidateFieldOptions): ValidationResult;
|
|
518
|
+
|
|
519
|
+
declare function validateSchema(schema: FormSchema, values: Record<string, unknown>): {
|
|
520
|
+
valid: boolean;
|
|
521
|
+
errors: Record<string, string>;
|
|
522
|
+
};
|
|
523
|
+
|
|
524
|
+
type ConditionStateSnapshot = {
|
|
525
|
+
isLoading: boolean;
|
|
526
|
+
initializationStatus: InitializationStatus;
|
|
527
|
+
/** Same semantics as `FormEngine.isValid()` after the latest validation settle. */
|
|
528
|
+
isValid?: boolean;
|
|
529
|
+
pendingActionIds?: readonly string[];
|
|
530
|
+
resourceInFlight?: readonly string[];
|
|
531
|
+
};
|
|
532
|
+
|
|
533
|
+
declare function runConditionEngine(node: RuntimeNode, values: Record<string, unknown>, state?: ConditionStateSnapshot): void;
|
|
534
|
+
|
|
535
|
+
declare function adaptField({ schema, field, setValue, state, loading, }: FieldAdapterInput): {
|
|
536
|
+
value: {};
|
|
537
|
+
onChange: (v: unknown) => void;
|
|
538
|
+
onBlur: () => void;
|
|
539
|
+
error: boolean | undefined;
|
|
540
|
+
disabled: boolean;
|
|
541
|
+
helperText: string | undefined;
|
|
542
|
+
loading: boolean;
|
|
543
|
+
};
|
|
544
|
+
|
|
545
|
+
declare function adaptLayout<TChildren>({ schema, children, }: LayoutAdapterInput<TChildren>): {
|
|
546
|
+
children: TChildren;
|
|
547
|
+
direction: "row" | "column";
|
|
548
|
+
className: unknown;
|
|
549
|
+
columns: unknown;
|
|
550
|
+
gap: unknown;
|
|
551
|
+
rowGap: unknown;
|
|
552
|
+
columnGap: unknown;
|
|
553
|
+
alignItems: unknown;
|
|
554
|
+
justifyContent: unknown;
|
|
555
|
+
flexWrap: unknown;
|
|
556
|
+
viewportClassName: unknown;
|
|
557
|
+
scrollAreaType: unknown;
|
|
558
|
+
dir: unknown;
|
|
559
|
+
scrollHideDelay: unknown;
|
|
560
|
+
ariaLabel: unknown;
|
|
561
|
+
badgeContent: unknown;
|
|
562
|
+
badgeShow: unknown;
|
|
563
|
+
badgeType: unknown;
|
|
564
|
+
badgeOffsetX: unknown;
|
|
565
|
+
badgeOffsetY: unknown;
|
|
566
|
+
cardDivider: unknown;
|
|
567
|
+
};
|
|
568
|
+
|
|
569
|
+
declare function adaptAction({ schema, onClick, loading, disabled, state, }: ActionAdapterInput): {
|
|
570
|
+
children: unknown;
|
|
571
|
+
onClick: () => void;
|
|
572
|
+
loading: boolean;
|
|
573
|
+
disabled: boolean;
|
|
574
|
+
variant: unknown;
|
|
575
|
+
};
|
|
576
|
+
|
|
577
|
+
declare function adaptDisplay({ schema, onClose, onAction, onClick, disabled, }: DisplayAdapterInput): {
|
|
578
|
+
disabled?: boolean | undefined;
|
|
579
|
+
onClick?: (() => void) | undefined;
|
|
580
|
+
onAction?: (() => void) | undefined;
|
|
581
|
+
onClose?: (() => void) | undefined;
|
|
582
|
+
};
|
|
583
|
+
|
|
584
|
+
/**
|
|
585
|
+
* Resolve a tag value mapping by string key (table columns and Tag `from` + `map`).
|
|
586
|
+
*/
|
|
587
|
+
declare function resolveTagValueMapping(value: unknown, map: Record<string, TableTagValueMapping> | undefined): TableTagValueMapping | undefined;
|
|
588
|
+
declare function tagMapKey(value: unknown): string | undefined;
|
|
589
|
+
declare function formatTagSourceValue(value: unknown): string;
|
|
590
|
+
|
|
591
|
+
export { type AccordionChangeReason, type AccordionChangeResult, type AccordionState, type ActionAdapterInput, type ActionContext, type ActionHandler, type ComputerHandler, DependencyGraph, type DependencyMap, type DialogState, type DialogTransitionReason, type DialogTransitionResult, type DisplayAdapterInput, type DrawerState, type DrawerTransitionReason, type DrawerTransitionResult, EventBus, type FieldAdapterInput, FormEngine, type FormEngineConfig, type FormEngineEnvironment, type FormEngineNotification, type FormEngineState, type FormErrors, type FormEvent, type FormSnapshot, type FormState, type FormValues, type InitializationStatus, type InvokeContext, type InvokeHandler, type LayoutAdapterInput, type Listener, type OptionsConfig, type PaginationChangeReason, type PaginationChangeResult, type PaginationState, type PipelineContext, type PredicateHandler, type RepeatMutationReason, type RepeatMutationResult, type RuntimeNode, type RuntimeNodeState, type RuntimeTree, type StepRunOptions, type StepperNavigationReason, type StepperNavigationResult, type StepperState, type TabsChangeReason, type TabsChangeResult, type TabsState, type ValidateFieldOptions, type ValidationResult, type Validator, type ValidatorHandler, adaptAction, adaptDisplay, adaptField, adaptLayout, compileSchema, conditions, createFormEngineEnvironment, createRuntimeNode, formatTagSourceValue, isThenable, resolveLoadingProp, resolveTagValueMapping, runConditionEngine, tagMapKey, traverseNode, validateField, validateSchema, validation, validationRegistry };
|