@astroapps/forms-core 1.0.1
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/TODO.txt +3 -0
- package/lib/controlDefinition.d.ts +436 -0
- package/lib/defaultSchemaInterface.d.ts +28 -0
- package/lib/entityExpression.d.ts +33 -0
- package/lib/evalExpression.d.ts +15 -0
- package/lib/formNode.d.ts +45 -0
- package/lib/formState.d.ts +44 -0
- package/lib/index.cjs +1813 -0
- package/lib/index.cjs.map +1 -0
- package/lib/index.d.ts +12 -0
- package/lib/index.js +1521 -0
- package/lib/index.js.map +1 -0
- package/lib/schemaBuilder.d.ts +67 -0
- package/lib/schemaDataNode.d.ts +36 -0
- package/lib/schemaField.d.ts +122 -0
- package/lib/schemaInterface.d.ts +102 -0
- package/lib/schemaNode.d.ts +54 -0
- package/lib/schemaValidator.d.ts +27 -0
- package/lib/util.d.ts +14 -0
- package/lib/validators.d.ts +23 -0
- package/package.json +60 -0
- package/src/controlDefinition.ts +704 -0
- package/src/defaultSchemaInterface.ts +201 -0
- package/src/entityExpression.ts +39 -0
- package/src/evalExpression.ts +118 -0
- package/src/formNode.ts +249 -0
- package/src/formState.ts +491 -0
- package/src/index.ts +12 -0
- package/src/schemaBuilder.ts +318 -0
- package/src/schemaDataNode.ts +188 -0
- package/src/schemaField.ts +155 -0
- package/src/schemaInterface.ts +135 -0
- package/src/schemaNode.ts +285 -0
- package/src/schemaValidator.ts +32 -0
- package/src/util.ts +50 -0
- package/src/validators.ts +220 -0
- package/tsconfig.json +21 -0
package/TODO.txt
ADDED
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
import { SchemaValidator } from "./schemaValidator";
|
|
2
|
+
import { SchemaField } from "./schemaField";
|
|
3
|
+
import { EntityExpression } from "./entityExpression";
|
|
4
|
+
import { SchemaDataNode } from "./schemaDataNode";
|
|
5
|
+
import { SchemaNode } from "./schemaNode";
|
|
6
|
+
/**
|
|
7
|
+
* Represents any control definition.
|
|
8
|
+
*/
|
|
9
|
+
export type AnyControlDefinition = DataControlDefinition | GroupedControlsDefinition | ActionControlDefinition | DisplayControlDefinition;
|
|
10
|
+
/**
|
|
11
|
+
* Represents a control definition.
|
|
12
|
+
*/
|
|
13
|
+
export interface ControlDefinition {
|
|
14
|
+
type: string;
|
|
15
|
+
id?: string | null;
|
|
16
|
+
childRefId?: string | null;
|
|
17
|
+
title?: string | null;
|
|
18
|
+
hidden?: boolean | null;
|
|
19
|
+
styleClass?: string | null;
|
|
20
|
+
textClass?: string | null;
|
|
21
|
+
layoutClass?: string | null;
|
|
22
|
+
labelClass?: string | null;
|
|
23
|
+
labelTextClass?: string | null;
|
|
24
|
+
placement?: string | null;
|
|
25
|
+
dynamic?: DynamicProperty[] | null;
|
|
26
|
+
adornments?: ControlAdornment[] | null;
|
|
27
|
+
children?: ControlDefinition[] | null;
|
|
28
|
+
}
|
|
29
|
+
export declare enum ControlDefinitionType {
|
|
30
|
+
Data = "Data",
|
|
31
|
+
Group = "Group",
|
|
32
|
+
Display = "Display",
|
|
33
|
+
Action = "Action"
|
|
34
|
+
}
|
|
35
|
+
export interface DynamicProperty {
|
|
36
|
+
type: string;
|
|
37
|
+
expr: EntityExpression;
|
|
38
|
+
}
|
|
39
|
+
export declare enum DynamicPropertyType {
|
|
40
|
+
Visible = "Visible",
|
|
41
|
+
DefaultValue = "DefaultValue",
|
|
42
|
+
Readonly = "Readonly",
|
|
43
|
+
Disabled = "Disabled",
|
|
44
|
+
Display = "Display",
|
|
45
|
+
Style = "Style",
|
|
46
|
+
LayoutStyle = "LayoutStyle",
|
|
47
|
+
AllowedOptions = "AllowedOptions",
|
|
48
|
+
Label = "Label",
|
|
49
|
+
ActionData = "ActionData"
|
|
50
|
+
}
|
|
51
|
+
export interface ControlAdornment {
|
|
52
|
+
type: string;
|
|
53
|
+
}
|
|
54
|
+
export declare enum AdornmentPlacement {
|
|
55
|
+
ControlStart = "ControlStart",
|
|
56
|
+
ControlEnd = "ControlEnd",
|
|
57
|
+
LabelStart = "LabelStart",
|
|
58
|
+
LabelEnd = "LabelEnd"
|
|
59
|
+
}
|
|
60
|
+
export declare enum ControlAdornmentType {
|
|
61
|
+
Tooltip = "Tooltip",
|
|
62
|
+
Accordion = "Accordion",
|
|
63
|
+
HelpText = "HelpText",
|
|
64
|
+
Icon = "Icon",
|
|
65
|
+
SetField = "SetField",
|
|
66
|
+
Optional = "Optional"
|
|
67
|
+
}
|
|
68
|
+
export declare enum IconLibrary {
|
|
69
|
+
FontAwesome = "FontAwesome",
|
|
70
|
+
Material = "Material",
|
|
71
|
+
CssClass = "CssClass"
|
|
72
|
+
}
|
|
73
|
+
export interface IconReference {
|
|
74
|
+
library: string;
|
|
75
|
+
name: string;
|
|
76
|
+
}
|
|
77
|
+
export interface IconAdornment extends ControlAdornment {
|
|
78
|
+
type: ControlAdornmentType.Icon;
|
|
79
|
+
iconClass: string;
|
|
80
|
+
icon?: IconReference;
|
|
81
|
+
placement?: AdornmentPlacement | null;
|
|
82
|
+
}
|
|
83
|
+
export interface TooltipAdornment extends ControlAdornment {
|
|
84
|
+
type: ControlAdornmentType.Tooltip;
|
|
85
|
+
tooltip: string;
|
|
86
|
+
}
|
|
87
|
+
export interface AccordionAdornment extends ControlAdornment {
|
|
88
|
+
type: ControlAdornmentType.Accordion;
|
|
89
|
+
title: string;
|
|
90
|
+
defaultExpanded?: boolean | null;
|
|
91
|
+
}
|
|
92
|
+
export interface HelpTextAdornment extends ControlAdornment {
|
|
93
|
+
type: ControlAdornmentType.HelpText;
|
|
94
|
+
helpText: string;
|
|
95
|
+
placement?: AdornmentPlacement | null;
|
|
96
|
+
}
|
|
97
|
+
export interface SetFieldAdornment extends ControlAdornment {
|
|
98
|
+
type: ControlAdornmentType.SetField;
|
|
99
|
+
field: string;
|
|
100
|
+
defaultOnly?: boolean | null;
|
|
101
|
+
expression?: EntityExpression;
|
|
102
|
+
}
|
|
103
|
+
export interface OptionalAdornment extends ControlAdornment {
|
|
104
|
+
type: ControlAdornmentType.Optional;
|
|
105
|
+
placement?: AdornmentPlacement | null;
|
|
106
|
+
allowNull?: boolean;
|
|
107
|
+
editSelectable?: boolean;
|
|
108
|
+
}
|
|
109
|
+
export interface DataControlDefinition extends ControlDefinition {
|
|
110
|
+
type: ControlDefinitionType.Data;
|
|
111
|
+
field: string;
|
|
112
|
+
required?: boolean | null;
|
|
113
|
+
renderOptions?: RenderOptions | null;
|
|
114
|
+
defaultValue?: any;
|
|
115
|
+
readonly?: boolean | null;
|
|
116
|
+
disabled?: boolean | null;
|
|
117
|
+
validators?: SchemaValidator[] | null;
|
|
118
|
+
hideTitle?: boolean | null;
|
|
119
|
+
dontClearHidden?: boolean | null;
|
|
120
|
+
}
|
|
121
|
+
export interface RenderOptions {
|
|
122
|
+
type: string;
|
|
123
|
+
}
|
|
124
|
+
export declare enum DataRenderType {
|
|
125
|
+
Standard = "Standard",
|
|
126
|
+
Textfield = "Textfield",
|
|
127
|
+
Radio = "Radio",
|
|
128
|
+
HtmlEditor = "HtmlEditor",
|
|
129
|
+
IconList = "IconList",
|
|
130
|
+
CheckList = "CheckList",
|
|
131
|
+
UserSelection = "UserSelection",
|
|
132
|
+
Synchronised = "Synchronised",
|
|
133
|
+
IconSelector = "IconSelector",
|
|
134
|
+
DateTime = "DateTime",
|
|
135
|
+
Checkbox = "Checkbox",
|
|
136
|
+
Dropdown = "Dropdown",
|
|
137
|
+
DisplayOnly = "DisplayOnly",
|
|
138
|
+
Group = "Group",
|
|
139
|
+
NullToggle = "NullToggle",
|
|
140
|
+
Autocomplete = "Autocomplete",
|
|
141
|
+
Jsonata = "Jsonata",
|
|
142
|
+
Array = "Array",
|
|
143
|
+
ArrayElement = "ArrayElement",
|
|
144
|
+
ElementSelected = "ElementSelected"
|
|
145
|
+
}
|
|
146
|
+
export interface TextfieldRenderOptions extends RenderOptions {
|
|
147
|
+
type: DataRenderType.Textfield;
|
|
148
|
+
placeholder?: string | null;
|
|
149
|
+
multiline?: boolean | null;
|
|
150
|
+
}
|
|
151
|
+
export interface AutocompleteRenderOptions extends RenderOptions, AutocompleteClasses {
|
|
152
|
+
type: DataRenderType.Autocomplete;
|
|
153
|
+
}
|
|
154
|
+
export interface AutocompleteClasses {
|
|
155
|
+
listContainerClass?: string | null;
|
|
156
|
+
listEntryClass?: string | null;
|
|
157
|
+
chipContainerClass?: string | null;
|
|
158
|
+
chipCloseButtonClass?: string | null;
|
|
159
|
+
placeholder?: string | null;
|
|
160
|
+
}
|
|
161
|
+
export interface CheckEntryClasses {
|
|
162
|
+
entryWrapperClass?: string | null;
|
|
163
|
+
selectedClass?: string | null;
|
|
164
|
+
notSelectedClass?: string | null;
|
|
165
|
+
}
|
|
166
|
+
export interface RadioButtonRenderOptions extends RenderOptions, CheckEntryClasses {
|
|
167
|
+
type: DataRenderType.Radio;
|
|
168
|
+
}
|
|
169
|
+
export interface StandardRenderer extends RenderOptions {
|
|
170
|
+
type: DataRenderType.Standard;
|
|
171
|
+
}
|
|
172
|
+
export interface DataGroupRenderOptions extends RenderOptions {
|
|
173
|
+
type: DataRenderType.Group;
|
|
174
|
+
groupOptions?: GroupRenderOptions;
|
|
175
|
+
}
|
|
176
|
+
export interface HtmlEditorRenderOptions extends RenderOptions {
|
|
177
|
+
type: DataRenderType.HtmlEditor;
|
|
178
|
+
allowImages: boolean;
|
|
179
|
+
}
|
|
180
|
+
export interface DateTimeRenderOptions extends RenderOptions {
|
|
181
|
+
type: DataRenderType.DateTime;
|
|
182
|
+
format?: string | null;
|
|
183
|
+
forceMidnight?: boolean;
|
|
184
|
+
forceStandard?: boolean;
|
|
185
|
+
}
|
|
186
|
+
export interface IconListRenderOptions extends RenderOptions {
|
|
187
|
+
type: DataRenderType.IconList;
|
|
188
|
+
iconMappings: IconMapping[];
|
|
189
|
+
}
|
|
190
|
+
export interface DisplayOnlyRenderOptions extends RenderOptions {
|
|
191
|
+
type: DataRenderType.DisplayOnly;
|
|
192
|
+
emptyText?: string | null;
|
|
193
|
+
sampleText?: string | null;
|
|
194
|
+
}
|
|
195
|
+
export interface IconMapping {
|
|
196
|
+
value: string;
|
|
197
|
+
materialIcon?: string | null;
|
|
198
|
+
}
|
|
199
|
+
export interface JsonataRenderOptions extends RenderOptions {
|
|
200
|
+
type: DataRenderType.Jsonata;
|
|
201
|
+
expression: string;
|
|
202
|
+
}
|
|
203
|
+
export interface JsonataRenderOptions extends RenderOptions {
|
|
204
|
+
type: DataRenderType.Jsonata;
|
|
205
|
+
expression: string;
|
|
206
|
+
}
|
|
207
|
+
export interface ArrayRenderOptions extends RenderOptions {
|
|
208
|
+
type: DataRenderType.Array;
|
|
209
|
+
addText?: string | null;
|
|
210
|
+
addActionId?: string | null;
|
|
211
|
+
removeText?: string | null;
|
|
212
|
+
removeActionId?: string | null;
|
|
213
|
+
editText?: string | null;
|
|
214
|
+
editActionId?: string | null;
|
|
215
|
+
noAdd?: boolean | null;
|
|
216
|
+
noRemove?: boolean | null;
|
|
217
|
+
noReorder?: boolean | null;
|
|
218
|
+
editExternal?: boolean | null;
|
|
219
|
+
}
|
|
220
|
+
export interface ArrayElementRenderOptions extends RenderOptions {
|
|
221
|
+
type: DataRenderType.ArrayElement;
|
|
222
|
+
showInline?: boolean | null;
|
|
223
|
+
}
|
|
224
|
+
export interface ElementSelectedRenderOptions extends RenderOptions {
|
|
225
|
+
type: DataRenderType.ElementSelected;
|
|
226
|
+
elementExpression: EntityExpression;
|
|
227
|
+
}
|
|
228
|
+
export type ArrayActionOptions = Pick<ArrayRenderOptions, "addText" | "addActionId" | "removeText" | "removeActionId" | "noAdd" | "noRemove" | "noReorder" | "editExternal" | "editActionId" | "editText"> & {
|
|
229
|
+
readonly?: boolean;
|
|
230
|
+
disabled?: boolean;
|
|
231
|
+
designMode?: boolean;
|
|
232
|
+
};
|
|
233
|
+
export interface CheckListRenderOptions extends RenderOptions, CheckEntryClasses {
|
|
234
|
+
type: DataRenderType.CheckList;
|
|
235
|
+
}
|
|
236
|
+
export interface SynchronisedRenderOptions extends RenderOptions {
|
|
237
|
+
type: DataRenderType.Synchronised;
|
|
238
|
+
fieldToSync: string;
|
|
239
|
+
syncType: SyncTextType;
|
|
240
|
+
}
|
|
241
|
+
export declare enum SyncTextType {
|
|
242
|
+
Camel = "Camel",
|
|
243
|
+
Snake = "Snake",
|
|
244
|
+
Pascal = "Pascal"
|
|
245
|
+
}
|
|
246
|
+
export interface UserSelectionRenderOptions extends RenderOptions {
|
|
247
|
+
type: DataRenderType.UserSelection;
|
|
248
|
+
noGroups: boolean;
|
|
249
|
+
noUsers: boolean;
|
|
250
|
+
}
|
|
251
|
+
export interface IconSelectionRenderOptions extends RenderOptions {
|
|
252
|
+
type: DataRenderType.IconSelector;
|
|
253
|
+
}
|
|
254
|
+
export interface GroupedControlsDefinition extends ControlDefinition {
|
|
255
|
+
type: ControlDefinitionType.Group;
|
|
256
|
+
compoundField?: string | null;
|
|
257
|
+
groupOptions?: GroupRenderOptions;
|
|
258
|
+
}
|
|
259
|
+
export interface GroupRenderOptions {
|
|
260
|
+
type: string;
|
|
261
|
+
hideTitle?: boolean | null;
|
|
262
|
+
childStyleClass?: string | null;
|
|
263
|
+
childLayoutClass?: string | null;
|
|
264
|
+
childLabelClass?: string | null;
|
|
265
|
+
displayOnly?: boolean | null;
|
|
266
|
+
}
|
|
267
|
+
export interface ActionOptions {
|
|
268
|
+
actionId: string;
|
|
269
|
+
actionText?: string | null;
|
|
270
|
+
actionData?: string | null;
|
|
271
|
+
icon?: IconReference | null;
|
|
272
|
+
actionStyle?: ActionStyle | null;
|
|
273
|
+
iconPlacement?: IconPlacement | null;
|
|
274
|
+
}
|
|
275
|
+
export declare enum GroupRenderType {
|
|
276
|
+
Standard = "Standard",
|
|
277
|
+
Grid = "Grid",
|
|
278
|
+
Flex = "Flex",
|
|
279
|
+
Tabs = "Tabs",
|
|
280
|
+
GroupElement = "GroupElement",
|
|
281
|
+
SelectChild = "SelectChild",
|
|
282
|
+
Inline = "Inline",
|
|
283
|
+
Wizard = "Wizard",
|
|
284
|
+
Dialog = "Dialog",
|
|
285
|
+
Contents = "Contents"
|
|
286
|
+
}
|
|
287
|
+
export interface DialogRenderOptions extends GroupRenderOptions {
|
|
288
|
+
type: GroupRenderType.Dialog;
|
|
289
|
+
title?: string | null;
|
|
290
|
+
}
|
|
291
|
+
export interface StandardGroupRenderer extends GroupRenderOptions {
|
|
292
|
+
type: GroupRenderType.Standard;
|
|
293
|
+
}
|
|
294
|
+
export interface FlexRenderer extends GroupRenderOptions {
|
|
295
|
+
type: GroupRenderType.Flex;
|
|
296
|
+
direction?: string | null;
|
|
297
|
+
gap?: string | null;
|
|
298
|
+
}
|
|
299
|
+
export interface GroupElementRenderer extends GroupRenderOptions {
|
|
300
|
+
type: GroupRenderType.GroupElement;
|
|
301
|
+
value: any;
|
|
302
|
+
}
|
|
303
|
+
export interface GridRenderer extends GroupRenderOptions {
|
|
304
|
+
type: GroupRenderType.Grid;
|
|
305
|
+
columns?: number | null;
|
|
306
|
+
rowClass?: string | null;
|
|
307
|
+
}
|
|
308
|
+
export interface TabsRenderOptions extends GroupRenderOptions {
|
|
309
|
+
type: GroupRenderType.Tabs;
|
|
310
|
+
contentClass?: string;
|
|
311
|
+
}
|
|
312
|
+
export interface WizardRenderOptions extends GroupRenderOptions {
|
|
313
|
+
type: GroupRenderType.Wizard;
|
|
314
|
+
}
|
|
315
|
+
export interface SelectChildRenderer extends GroupRenderOptions {
|
|
316
|
+
type: GroupRenderType.SelectChild;
|
|
317
|
+
childIndexExpression?: EntityExpression | null;
|
|
318
|
+
}
|
|
319
|
+
export interface DisplayControlDefinition extends ControlDefinition {
|
|
320
|
+
type: ControlDefinitionType.Display;
|
|
321
|
+
displayData: DisplayData;
|
|
322
|
+
}
|
|
323
|
+
export interface DisplayData {
|
|
324
|
+
type: string;
|
|
325
|
+
}
|
|
326
|
+
export declare enum DisplayDataType {
|
|
327
|
+
Text = "Text",
|
|
328
|
+
Html = "Html",
|
|
329
|
+
Icon = "Icon",
|
|
330
|
+
Custom = "Custom"
|
|
331
|
+
}
|
|
332
|
+
export interface TextDisplay extends DisplayData {
|
|
333
|
+
type: DisplayDataType.Text;
|
|
334
|
+
text: string;
|
|
335
|
+
}
|
|
336
|
+
export interface IconDisplay extends DisplayData {
|
|
337
|
+
type: DisplayDataType.Icon;
|
|
338
|
+
iconClass: string;
|
|
339
|
+
icon?: IconReference | null;
|
|
340
|
+
}
|
|
341
|
+
export interface HtmlDisplay extends DisplayData {
|
|
342
|
+
type: DisplayDataType.Html;
|
|
343
|
+
html: string;
|
|
344
|
+
}
|
|
345
|
+
export interface CustomDisplay extends DisplayData {
|
|
346
|
+
type: DisplayDataType.Custom;
|
|
347
|
+
customId: string;
|
|
348
|
+
}
|
|
349
|
+
export interface ActionControlDefinition extends ControlDefinition {
|
|
350
|
+
type: ControlDefinitionType.Action;
|
|
351
|
+
actionId: string;
|
|
352
|
+
actionData?: string | null;
|
|
353
|
+
icon?: IconReference | null;
|
|
354
|
+
actionStyle?: ActionStyle | null;
|
|
355
|
+
iconPlacement?: IconPlacement | null;
|
|
356
|
+
}
|
|
357
|
+
export declare enum ActionStyle {
|
|
358
|
+
Button = "Button",
|
|
359
|
+
Secondary = "Secondary",
|
|
360
|
+
Link = "Link",
|
|
361
|
+
Group = "Group"
|
|
362
|
+
}
|
|
363
|
+
export declare enum IconPlacement {
|
|
364
|
+
BeforeText = "BeforeText",
|
|
365
|
+
AfterText = "AfterText",
|
|
366
|
+
ReplaceText = "ReplaceText"
|
|
367
|
+
}
|
|
368
|
+
export interface ControlVisitor<A> {
|
|
369
|
+
data(d: DataControlDefinition): A;
|
|
370
|
+
group(d: GroupedControlsDefinition): A;
|
|
371
|
+
display(d: DisplayControlDefinition): A;
|
|
372
|
+
action(d: ActionControlDefinition): A;
|
|
373
|
+
}
|
|
374
|
+
export declare function visitControlDefinition<A>(x: ControlDefinition, visitor: ControlVisitor<A>, defaultValue: (c: ControlDefinition) => A): A;
|
|
375
|
+
export declare function isGridRenderer(options: GroupRenderOptions): options is GridRenderer;
|
|
376
|
+
export declare function isWizardRenderer(options: GroupRenderOptions): options is WizardRenderOptions;
|
|
377
|
+
export declare function isDialogRenderer(options: GroupRenderOptions): options is DialogRenderOptions;
|
|
378
|
+
export declare function isInlineRenderer(options: GroupRenderOptions): options is GridRenderer;
|
|
379
|
+
export declare function isSelectChildRenderer(options: GroupRenderOptions): options is SelectChildRenderer;
|
|
380
|
+
export declare function isTabsRenderer(options: GroupRenderOptions): options is TabsRenderOptions;
|
|
381
|
+
export declare function isFlexRenderer(options: GroupRenderOptions): options is FlexRenderer;
|
|
382
|
+
export declare function isDisplayOnlyRenderer(options: RenderOptions): options is DisplayOnlyRenderOptions;
|
|
383
|
+
export declare function isTextfieldRenderer(options: RenderOptions): options is TextfieldRenderOptions;
|
|
384
|
+
export declare function isDateTimeRenderer(options: RenderOptions): options is DateTimeRenderOptions;
|
|
385
|
+
export declare function isAutocompleteRenderer(options: RenderOptions): options is AutocompleteRenderOptions;
|
|
386
|
+
export declare function isAutoCompleteClasses(options?: RenderOptions | null): options is AutocompleteClasses & RenderOptions;
|
|
387
|
+
export declare function isDataGroupRenderer(options?: RenderOptions | null): options is DataGroupRenderOptions;
|
|
388
|
+
export declare function isArrayRenderer(options: RenderOptions): options is ArrayRenderOptions;
|
|
389
|
+
export declare function isDataControl(c: ControlDefinition): c is DataControlDefinition;
|
|
390
|
+
export declare function isGroupControl(c: ControlDefinition): c is GroupedControlsDefinition;
|
|
391
|
+
export declare function isActionControl(c: ControlDefinition): c is ActionControlDefinition;
|
|
392
|
+
export declare function isDisplayControl(c: ControlDefinition): c is DisplayControlDefinition;
|
|
393
|
+
export declare function isTextDisplay(d: DisplayData): d is TextDisplay;
|
|
394
|
+
export declare function isHtmlDisplay(d: DisplayData): d is HtmlDisplay;
|
|
395
|
+
export declare function isCheckEntryClasses(options?: RenderOptions | null): options is CheckEntryClasses & RenderOptions;
|
|
396
|
+
export declare function traverseParents<A, B extends {
|
|
397
|
+
parent?: B | undefined;
|
|
398
|
+
}>(current: B | undefined, get: (b: B) => A, until?: (b: B) => boolean): A[];
|
|
399
|
+
export declare function getRootDataNode(dataNode: SchemaDataNode): SchemaDataNode;
|
|
400
|
+
export declare function getJsonPath(dataNode: SchemaDataNode): (string | number)[];
|
|
401
|
+
export declare function getSchemaPath(schemaNode: SchemaNode): SchemaField[];
|
|
402
|
+
export declare function getSchemaFieldList(schema: SchemaNode): SchemaField[];
|
|
403
|
+
export declare function fontAwesomeIcon(icon: string): {
|
|
404
|
+
library: IconLibrary;
|
|
405
|
+
name: string;
|
|
406
|
+
};
|
|
407
|
+
/**
|
|
408
|
+
* Checks if a control definition is readonly.
|
|
409
|
+
* @param c - The control definition to check.
|
|
410
|
+
* @returns True if the control definition is readonly, false otherwise.
|
|
411
|
+
*/
|
|
412
|
+
export declare function isControlReadonly(c: ControlDefinition): boolean;
|
|
413
|
+
/**
|
|
414
|
+
* Checks if a control definition is disabled.
|
|
415
|
+
* @param c - The control definition to check.
|
|
416
|
+
* @returns True if the control definition is disabled, false otherwise.
|
|
417
|
+
*/
|
|
418
|
+
export declare function isControlDisabled(c: ControlDefinition): boolean;
|
|
419
|
+
/**
|
|
420
|
+
* Returns the group renderer options for a control definition.
|
|
421
|
+
* @param {ControlDefinition} def - The control definition to get the group renderer options for.
|
|
422
|
+
* @returns {GroupRenderOptions | undefined} - The group renderer options, or undefined if not applicable.
|
|
423
|
+
*/
|
|
424
|
+
export declare function getGroupRendererOptions(def: ControlDefinition): GroupRenderOptions | undefined;
|
|
425
|
+
/**
|
|
426
|
+
* Checks if a control definition is display-only.
|
|
427
|
+
* @param {ControlDefinition} def - The control definition to check.
|
|
428
|
+
* @returns {boolean} - True if the control definition is display-only, false otherwise.
|
|
429
|
+
*/
|
|
430
|
+
export declare function isControlDisplayOnly(def: ControlDefinition): boolean;
|
|
431
|
+
/**
|
|
432
|
+
* Returns the display-only render options for a control definition.
|
|
433
|
+
* @param d - The control definition to get the display-only render options for.
|
|
434
|
+
* @returns The display-only render options, or undefined if not applicable.
|
|
435
|
+
*/
|
|
436
|
+
export declare function getDisplayOnlyOptions(d: ControlDefinition): DisplayOnlyRenderOptions | undefined;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { EqualityFunc, FieldOption, SchemaField, ValidationMessageType } from "./schemaField";
|
|
2
|
+
import { SchemaInterface } from "./schemaInterface";
|
|
3
|
+
import { SchemaDataNode } from "./schemaDataNode";
|
|
4
|
+
import { SchemaNode } from "./schemaNode";
|
|
5
|
+
import { Control, ControlSetup } from "@astroapps/controls";
|
|
6
|
+
export declare class DefaultSchemaInterface implements SchemaInterface {
|
|
7
|
+
protected boolStrings: [string, string];
|
|
8
|
+
protected parseDateTime: (s: string) => number;
|
|
9
|
+
constructor(boolStrings?: [string, string], parseDateTime?: (s: string) => number);
|
|
10
|
+
parseToMillis(field: SchemaField, v: string): number;
|
|
11
|
+
validationMessageText(field: SchemaField, messageType: ValidationMessageType, actual: any, expected: any): string;
|
|
12
|
+
getDataOptions(node: SchemaDataNode): FieldOption[] | null | undefined;
|
|
13
|
+
getNodeOptions(node: SchemaNode): FieldOption[] | null | undefined;
|
|
14
|
+
getOptions({ options }: SchemaField): FieldOption[] | null | undefined;
|
|
15
|
+
getFilterOptions(array: SchemaDataNode, field: SchemaNode): FieldOption[] | undefined | null;
|
|
16
|
+
isEmptyValue(f: SchemaField, value: any): boolean;
|
|
17
|
+
searchText(field: SchemaField, value: any): string;
|
|
18
|
+
textValueForData(dataNode: SchemaDataNode): string | undefined;
|
|
19
|
+
textValue(field: SchemaField, value: any, element?: boolean | undefined, options?: FieldOption[] | null): string | undefined;
|
|
20
|
+
controlLength(f: SchemaField, control: Control<any>): number;
|
|
21
|
+
valueLength(field: SchemaField, value: any): number;
|
|
22
|
+
compareValue(field: SchemaField, v1: unknown, v2: unknown): number;
|
|
23
|
+
compoundFieldSetup(f: SchemaNode): [string, ControlSetup<any>][];
|
|
24
|
+
compoundFieldEquality(f: SchemaNode): [string, EqualityFunc][];
|
|
25
|
+
makeEqualityFunc(field: SchemaNode, element?: boolean): EqualityFunc;
|
|
26
|
+
makeControlSetup(field: SchemaNode, element?: boolean): ControlSetup<any>;
|
|
27
|
+
}
|
|
28
|
+
export declare const defaultSchemaInterface: SchemaInterface;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export interface EntityExpression {
|
|
2
|
+
type: string;
|
|
3
|
+
}
|
|
4
|
+
export declare enum ExpressionType {
|
|
5
|
+
Jsonata = "Jsonata",
|
|
6
|
+
Data = "Data",
|
|
7
|
+
DataMatch = "FieldValue",
|
|
8
|
+
UserMatch = "UserMatch",
|
|
9
|
+
NotEmpty = "NotEmpty",
|
|
10
|
+
UUID = "UUID"
|
|
11
|
+
}
|
|
12
|
+
export interface JsonataExpression extends EntityExpression {
|
|
13
|
+
type: ExpressionType.Jsonata;
|
|
14
|
+
expression: string;
|
|
15
|
+
}
|
|
16
|
+
export interface DataExpression extends EntityExpression {
|
|
17
|
+
type: ExpressionType.Data;
|
|
18
|
+
field: string;
|
|
19
|
+
}
|
|
20
|
+
export interface DataMatchExpression extends EntityExpression {
|
|
21
|
+
type: ExpressionType.DataMatch;
|
|
22
|
+
field: string;
|
|
23
|
+
value: any;
|
|
24
|
+
}
|
|
25
|
+
export interface NotEmptyExpression extends EntityExpression {
|
|
26
|
+
type: ExpressionType.NotEmpty;
|
|
27
|
+
field: string;
|
|
28
|
+
empty?: boolean | null;
|
|
29
|
+
}
|
|
30
|
+
export interface UserMatchExpression extends EntityExpression {
|
|
31
|
+
type: ExpressionType.UserMatch;
|
|
32
|
+
userMatch: string;
|
|
33
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { EntityExpression, JsonataExpression } from "./entityExpression";
|
|
2
|
+
import { CleanupScope, Value } from "@astroapps/controls";
|
|
3
|
+
import { SchemaDataNode } from "./schemaDataNode";
|
|
4
|
+
import { SchemaInterface } from "./schemaInterface";
|
|
5
|
+
export interface ExpressionEvalContext {
|
|
6
|
+
scope: CleanupScope;
|
|
7
|
+
returnResult: (k: unknown) => void;
|
|
8
|
+
dataNode: SchemaDataNode;
|
|
9
|
+
schemaInterface: SchemaInterface;
|
|
10
|
+
variables?: Value<Record<string, any> | undefined>;
|
|
11
|
+
}
|
|
12
|
+
export type ExpressionEval<T extends EntityExpression> = (expr: T, context: ExpressionEvalContext) => void;
|
|
13
|
+
export declare const jsonataEval: ExpressionEval<JsonataExpression>;
|
|
14
|
+
export declare const uuidEval: ExpressionEval<EntityExpression>;
|
|
15
|
+
export declare const defaultEvaluators: Record<string, ExpressionEval<any>>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ControlDefinition, DataControlDefinition } from "./controlDefinition";
|
|
2
|
+
import { SchemaDataNode } from "./schemaDataNode";
|
|
3
|
+
export type ControlMap = {
|
|
4
|
+
[k: string]: ControlDefinition;
|
|
5
|
+
};
|
|
6
|
+
export declare class FormNode {
|
|
7
|
+
id: string;
|
|
8
|
+
definition: ControlDefinition;
|
|
9
|
+
tree: FormTree;
|
|
10
|
+
parent?: FormNode | undefined;
|
|
11
|
+
constructor(id: string, definition: ControlDefinition, tree: FormTree, parent?: FormNode | undefined);
|
|
12
|
+
visit<A>(visitFn: (n: FormNode) => A | undefined): A | undefined;
|
|
13
|
+
getResolvedChildren(): ControlDefinition[];
|
|
14
|
+
createChildNode(childId: string, childDef: ControlDefinition): FormNode;
|
|
15
|
+
getChildNodes(): FormNode[];
|
|
16
|
+
getUnresolvedChildNodes(): FormNode[];
|
|
17
|
+
}
|
|
18
|
+
export interface FormTreeLookup {
|
|
19
|
+
getForm(formId: string): FormTree | undefined;
|
|
20
|
+
}
|
|
21
|
+
export declare abstract class FormTree implements FormTreeLookup {
|
|
22
|
+
abstract rootNode: FormNode;
|
|
23
|
+
abstract getByRefId(id: string): ControlDefinition | undefined;
|
|
24
|
+
abstract getForm(formId: string): FormTree | undefined;
|
|
25
|
+
getChildId(parentId: string, childId: string, control: ControlDefinition): string;
|
|
26
|
+
}
|
|
27
|
+
export declare function createControlMap(control: ControlDefinition): ControlMap;
|
|
28
|
+
export declare function legacyFormNode(definition: ControlDefinition): FormNode;
|
|
29
|
+
export declare function createFormTree(controls: ControlDefinition[], getForm?: FormTreeLookup): FormTree;
|
|
30
|
+
export declare function createFormLookup<A extends Record<string, ControlDefinition[]>>(formMap: A): {
|
|
31
|
+
getForm(formId: keyof A): FormTree;
|
|
32
|
+
};
|
|
33
|
+
export declare function fieldPathForDefinition(c: ControlDefinition): string[] | undefined;
|
|
34
|
+
export declare function lookupDataNode(c: ControlDefinition, parentNode: SchemaDataNode): SchemaDataNode | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* @deprecated use visitFormNodeData instead
|
|
37
|
+
*/
|
|
38
|
+
export declare function visitControlDataArray<A>(controls: ControlDefinition[] | undefined | null, context: SchemaDataNode, cb: (definition: DataControlDefinition, node: SchemaDataNode) => A | undefined): A | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* @deprecated use visitFormDataInContext instead
|
|
41
|
+
*/
|
|
42
|
+
export declare function visitControlData<A>(definition: ControlDefinition, ctx: SchemaDataNode, cb: (definition: DataControlDefinition, field: SchemaDataNode) => A | undefined): A | undefined;
|
|
43
|
+
export type ControlDataVisitor<A> = (dataNode: SchemaDataNode, definition: DataControlDefinition) => A | undefined;
|
|
44
|
+
export declare function visitFormData<A>(node: FormNode, dataNode: SchemaDataNode, cb: ControlDataVisitor<A>, notSelf?: boolean): A | undefined;
|
|
45
|
+
export declare function visitFormDataInContext<A>(parentContext: SchemaDataNode, node: FormNode, cb: ControlDataVisitor<A>): A | undefined;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { FormNode } from "./formNode";
|
|
2
|
+
import { SchemaDataNode } from "./schemaDataNode";
|
|
3
|
+
import { ControlDefinition } from "./controlDefinition";
|
|
4
|
+
import { SchemaInterface } from "./schemaInterface";
|
|
5
|
+
import { FieldOption } from "./schemaField";
|
|
6
|
+
import { Control } from "@astroapps/controls";
|
|
7
|
+
import { ExpressionEval, ExpressionEvalContext } from "./evalExpression";
|
|
8
|
+
import { EntityExpression } from "./entityExpression";
|
|
9
|
+
export interface ControlState {
|
|
10
|
+
definition: ControlDefinition;
|
|
11
|
+
schemaInterface: SchemaInterface;
|
|
12
|
+
dataNode?: SchemaDataNode | undefined;
|
|
13
|
+
stateId?: string;
|
|
14
|
+
style?: object;
|
|
15
|
+
layoutStyle?: object;
|
|
16
|
+
allowedOptions?: any[];
|
|
17
|
+
readonly: boolean;
|
|
18
|
+
hidden: boolean;
|
|
19
|
+
disabled: boolean;
|
|
20
|
+
clearHidden: boolean;
|
|
21
|
+
variables: Record<string, any>;
|
|
22
|
+
}
|
|
23
|
+
export interface FormContextOptions {
|
|
24
|
+
readonly?: boolean | null;
|
|
25
|
+
hidden?: boolean | null;
|
|
26
|
+
disabled?: boolean | null;
|
|
27
|
+
clearHidden?: boolean;
|
|
28
|
+
stateKey?: string;
|
|
29
|
+
variables?: Record<string, any>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Interface representing the form context data.
|
|
33
|
+
*/
|
|
34
|
+
export interface FormContextData {
|
|
35
|
+
option?: FieldOption;
|
|
36
|
+
optionSelected?: boolean;
|
|
37
|
+
}
|
|
38
|
+
export interface FormState {
|
|
39
|
+
getControlState(parent: SchemaDataNode, formNode: FormNode, context: FormContextOptions): ControlState;
|
|
40
|
+
cleanup(): void;
|
|
41
|
+
evalExpression(expr: EntityExpression, context: ExpressionEvalContext): void;
|
|
42
|
+
}
|
|
43
|
+
export declare function createFormState(schemaInterface: SchemaInterface, evaluators?: Record<string, ExpressionEval<any>>): FormState;
|
|
44
|
+
export declare function createOverrideProxy<A extends object, B extends Record<string, any>>(proxyFor: A, handlers: Control<B>): A;
|