@react-typed-forms/schemas 1.0.0-dev.17 → 1.0.0-dev.19

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/lib/types.d.ts CHANGED
@@ -1,234 +1,265 @@
1
- export interface SchemaField {
2
- type: string;
3
- field: string;
4
- displayName?: string | null;
5
- tags?: string[] | null;
6
- system?: boolean | null;
7
- collection?: boolean | null;
8
- onlyForTypes?: string[] | null;
9
- required?: boolean | null;
10
- defaultValue?: any;
11
- isTypeField?: boolean | null;
12
- searchable?: boolean | null;
13
- options?: FieldOption[] | null;
14
- /**
15
- * @deprecated Use options directly
16
- */
17
- restrictions?: SchemaRestrictions | undefined | null;
18
- }
19
- export declare enum FieldType {
20
- String = "String",
21
- Bool = "Bool",
22
- Int = "Int",
23
- Date = "Date",
24
- DateTime = "DateTime",
25
- Double = "Double",
26
- EntityRef = "EntityRef",
27
- Compound = "Compound",
28
- AutoId = "AutoId",
29
- Image = "Image",
30
- Any = "Any"
31
- }
32
- export interface EntityRefField extends SchemaField {
33
- type: FieldType.EntityRef;
34
- entityRefType: string;
35
- parentField: string;
36
- }
37
- export interface SchemaRestrictions {
38
- options?: FieldOption[] | null;
39
- }
40
- export interface FieldOption {
41
- name: string;
42
- value: any;
43
- }
44
- export interface CompoundField extends SchemaField {
45
- type: FieldType.Compound;
46
- children: SchemaField[];
47
- treeChildren?: boolean;
48
- }
49
- export type AnyControlDefinition = DataControlDefinition | GroupedControlsDefinition | ActionControlDefinition | DisplayControlDefinition;
50
- export interface ControlDefinition {
51
- type: string;
52
- title?: string | null;
53
- dynamic?: DynamicProperty[] | null;
54
- adornments?: ControlAdornment[] | null;
55
- }
56
- export declare enum ControlDefinitionType {
57
- Data = "Data",
58
- Group = "Group",
59
- Display = "Display",
60
- Action = "Action"
61
- }
62
- export interface DynamicProperty {
63
- type: string;
64
- expr: EntityExpression;
65
- }
66
- export declare enum DynamicPropertyType {
67
- Visible = "Visible",
68
- DefaultValue = "DefaultValue"
69
- }
70
- export interface EntityExpression {
71
- type: string;
72
- }
73
- export declare enum ExpressionType {
74
- Jsonata = "Jsonata",
75
- FieldValue = "FieldValue",
76
- UserMatch = "UserMatch"
77
- }
78
- export interface JsonataExpression extends EntityExpression {
79
- type: ExpressionType.Jsonata;
80
- expression: string;
81
- }
82
- export interface FieldValueExpression extends EntityExpression {
83
- type: ExpressionType.FieldValue;
84
- field: string;
85
- value: any;
86
- }
87
- export interface UserMatchExpression extends EntityExpression {
88
- type: ExpressionType.UserMatch;
89
- userMatch: string;
90
- }
91
- export interface ControlAdornment {
92
- type: string;
93
- }
94
- export declare enum ControlAdornmentType {
95
- Tooltip = "Tooltip",
96
- Accordion = "Accordion"
97
- }
98
- export interface TooltipAdornment extends ControlAdornment {
99
- type: ControlAdornmentType.Tooltip;
100
- tooltip: string;
101
- }
102
- export interface AccordionAdornment extends ControlAdornment {
103
- type: ControlAdornmentType.Accordion;
104
- title: string;
105
- defaultExpanded: boolean;
106
- }
107
- export interface DataControlDefinition extends ControlDefinition {
108
- type: ControlDefinitionType.Data;
109
- field: string;
110
- required?: boolean | null;
111
- renderOptions?: RenderOptions | null;
112
- defaultValue?: any;
113
- readonly?: boolean | null;
114
- }
115
- export interface RenderOptions {
116
- type: string;
117
- }
118
- export declare enum DataRenderType {
119
- Standard = "Standard",
120
- Radio = "Radio",
121
- HtmlEditor = "HtmlEditor",
122
- IconList = "IconList",
123
- CheckList = "CheckList",
124
- UserSelection = "UserSelection",
125
- Synchronised = "Synchronised",
126
- IconSelector = "IconSelector",
127
- DateTime = "DateTime"
128
- }
129
- export interface RadioButtonRenderOptions extends RenderOptions {
130
- type: DataRenderType.Radio;
131
- }
132
- export interface StandardRenderer extends RenderOptions {
133
- type: DataRenderType.Standard;
134
- }
135
- export interface HtmlEditorRenderOptions extends RenderOptions {
136
- type: DataRenderType.HtmlEditor;
137
- allowImages: boolean;
138
- }
139
- export interface DateTimeRenderOptions extends RenderOptions {
140
- type: DataRenderType.DateTime;
141
- format?: string | null;
142
- }
143
- export interface IconListRenderOptions extends RenderOptions {
144
- type: DataRenderType.IconList;
145
- iconMappings: IconMapping[];
146
- }
147
- export interface IconMapping {
148
- value: string;
149
- materialIcon?: string | null;
150
- }
151
- export interface CheckListRenderOptions extends RenderOptions {
152
- type: DataRenderType.CheckList;
153
- }
154
- export interface SynchronisedRenderOptions extends RenderOptions {
155
- type: DataRenderType.Synchronised;
156
- fieldToSync: string;
157
- syncType: SyncTextType;
158
- }
159
- export declare enum SyncTextType {
160
- Camel = "Camel",
161
- Snake = "Snake",
162
- Pascal = "Pascal"
163
- }
164
- export interface UserSelectionRenderOptions extends RenderOptions {
165
- type: DataRenderType.UserSelection;
166
- noGroups: boolean;
167
- noUsers: boolean;
168
- }
169
- export interface IconSelectionRenderOptions extends RenderOptions {
170
- type: DataRenderType.IconSelector;
171
- }
172
- export interface GroupedControlsDefinition extends ControlDefinition {
173
- type: ControlDefinitionType.Group;
174
- children: ControlDefinition[];
175
- compoundField?: string | null;
176
- groupOptions: GroupRenderOptions;
177
- }
178
- export interface GroupRenderOptions {
179
- type: string;
180
- hideTitle?: boolean | null;
181
- }
182
- export declare enum GroupRenderType {
183
- Standard = "Standard",
184
- Grid = "Grid",
185
- GroupElement = "GroupElement"
186
- }
187
- export interface StandardGroupRenderer extends GroupRenderOptions {
188
- type: GroupRenderType.Standard;
189
- }
190
- export interface GroupElementRenderer extends GroupRenderOptions {
191
- type: GroupRenderType.GroupElement;
192
- value: any;
193
- }
194
- export interface GridRenderer extends GroupRenderOptions {
195
- type: GroupRenderType.Grid;
196
- columns?: number | null;
197
- }
198
- export interface DisplayControlDefinition extends ControlDefinition {
199
- type: ControlDefinitionType.Display;
200
- displayData: DisplayData;
201
- }
202
- export interface DisplayData {
203
- type: string;
204
- }
205
- export declare enum DisplayDataType {
206
- Text = "Text",
207
- Html = "Html"
208
- }
209
- export interface TextDisplay extends DisplayData {
210
- type: DisplayDataType.Text;
211
- text: string;
212
- }
213
- export interface HtmlDisplay extends DisplayData {
214
- type: DisplayDataType.Html;
215
- html: string;
216
- }
217
- export interface ActionControlDefinition extends ControlDefinition {
218
- type: ControlDefinitionType.Action;
219
- actionId: string;
220
- }
221
- export declare function isDataControlDefinition(x: ControlDefinition): x is DataControlDefinition;
222
- export declare function isGroupControlsDefinition(x: ControlDefinition): x is GroupedControlsDefinition;
223
- export declare function isDisplayControlsDefinition(x: ControlDefinition): x is DisplayControlDefinition;
224
- export declare function isActionControlsDefinition(x: ControlDefinition): x is ActionControlDefinition;
225
- export interface ControlVisitor<A> {
226
- data(d: DataControlDefinition): A;
227
- group(d: GroupedControlsDefinition): A;
228
- display(d: DisplayControlDefinition): A;
229
- action(d: ActionControlDefinition): A;
230
- }
231
- export declare function visitControlDefinition<A>(x: ControlDefinition, visitor: ControlVisitor<A>, defaultValue: (c: ControlDefinition) => A): A;
232
- export declare function dataControl(field: string, options?: Partial<DataControlDefinition>): DataControlDefinition;
233
- export declare function fieldValueExpr(field: string, value: any): FieldValueExpression;
234
- export declare function visibility(expr: EntityExpression): DynamicProperty;
1
+ export interface SchemaField {
2
+ type: string;
3
+ field: string;
4
+ displayName?: string | null;
5
+ tags?: string[] | null;
6
+ system?: boolean | null;
7
+ collection?: boolean | null;
8
+ onlyForTypes?: string[] | null;
9
+ required?: boolean | null;
10
+ defaultValue?: any;
11
+ isTypeField?: boolean | null;
12
+ searchable?: boolean | null;
13
+ options?: FieldOption[] | null;
14
+ validators?: SchemaValidator[] | null;
15
+ }
16
+ export declare enum FieldType {
17
+ String = "String",
18
+ Bool = "Bool",
19
+ Int = "Int",
20
+ Date = "Date",
21
+ DateTime = "DateTime",
22
+ Double = "Double",
23
+ EntityRef = "EntityRef",
24
+ Compound = "Compound",
25
+ AutoId = "AutoId",
26
+ Image = "Image",
27
+ Any = "Any"
28
+ }
29
+ export interface EntityRefField extends SchemaField {
30
+ type: FieldType.EntityRef;
31
+ entityRefType: string;
32
+ parentField: string;
33
+ }
34
+ export interface FieldOption {
35
+ name: string;
36
+ value: any;
37
+ }
38
+ export interface CompoundField extends SchemaField {
39
+ type: FieldType.Compound;
40
+ children: SchemaField[];
41
+ treeChildren?: boolean;
42
+ }
43
+ export type AnyControlDefinition = DataControlDefinition | GroupedControlsDefinition | ActionControlDefinition | DisplayControlDefinition;
44
+ export interface ControlDefinition {
45
+ type: string;
46
+ title?: string | null;
47
+ dynamic?: DynamicProperty[] | null;
48
+ adornments?: ControlAdornment[] | null;
49
+ }
50
+ export declare enum ControlDefinitionType {
51
+ Data = "Data",
52
+ Group = "Group",
53
+ Display = "Display",
54
+ Action = "Action"
55
+ }
56
+ export interface DynamicProperty {
57
+ type: string;
58
+ expr: EntityExpression;
59
+ }
60
+ export declare enum DynamicPropertyType {
61
+ Visible = "Visible",
62
+ DefaultValue = "DefaultValue"
63
+ }
64
+ export interface EntityExpression {
65
+ type: string;
66
+ }
67
+ export declare enum ExpressionType {
68
+ Jsonata = "Jsonata",
69
+ FieldValue = "FieldValue",
70
+ UserMatch = "UserMatch"
71
+ }
72
+ export interface JsonataExpression extends EntityExpression {
73
+ type: ExpressionType.Jsonata;
74
+ expression: string;
75
+ }
76
+ export interface FieldValueExpression extends EntityExpression {
77
+ type: ExpressionType.FieldValue;
78
+ field: string;
79
+ value: any;
80
+ }
81
+ export interface UserMatchExpression extends EntityExpression {
82
+ type: ExpressionType.UserMatch;
83
+ userMatch: string;
84
+ }
85
+ export interface ControlAdornment {
86
+ type: string;
87
+ }
88
+ export declare enum AdornmentPlacement {
89
+ ControlStart = "ControlStart",
90
+ ControlEnd = "ControlEnd",
91
+ LabelStart = "LabelStart",
92
+ LabelEnd = "LabelEnd"
93
+ }
94
+ export declare enum ControlAdornmentType {
95
+ Tooltip = "Tooltip",
96
+ Accordion = "Accordion",
97
+ HelpText = "HelpText"
98
+ }
99
+ export interface TooltipAdornment extends ControlAdornment {
100
+ type: ControlAdornmentType.Tooltip;
101
+ tooltip: string;
102
+ }
103
+ export interface AccordionAdornment extends ControlAdornment {
104
+ type: ControlAdornmentType.Accordion;
105
+ title: string;
106
+ defaultExpanded: boolean;
107
+ }
108
+ export interface HelpTextAdornment extends ControlAdornment {
109
+ type: ControlAdornmentType.HelpText;
110
+ helpText: string;
111
+ placement: AdornmentPlacement;
112
+ }
113
+ export interface DataControlDefinition extends ControlDefinition {
114
+ type: ControlDefinitionType.Data;
115
+ field: string;
116
+ required?: boolean | null;
117
+ renderOptions?: RenderOptions | null;
118
+ defaultValue?: any;
119
+ readonly?: boolean | null;
120
+ validators?: SchemaValidator[] | null;
121
+ }
122
+ export interface RenderOptions {
123
+ type: string;
124
+ }
125
+ export declare enum DataRenderType {
126
+ Standard = "Standard",
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
+ }
138
+ export interface RadioButtonRenderOptions extends RenderOptions {
139
+ type: DataRenderType.Radio;
140
+ }
141
+ export interface StandardRenderer extends RenderOptions {
142
+ type: DataRenderType.Standard;
143
+ }
144
+ export interface HtmlEditorRenderOptions extends RenderOptions {
145
+ type: DataRenderType.HtmlEditor;
146
+ allowImages: boolean;
147
+ }
148
+ export interface DateTimeRenderOptions extends RenderOptions {
149
+ type: DataRenderType.DateTime;
150
+ format?: string | null;
151
+ }
152
+ export interface IconListRenderOptions extends RenderOptions {
153
+ type: DataRenderType.IconList;
154
+ iconMappings: IconMapping[];
155
+ }
156
+ export interface IconMapping {
157
+ value: string;
158
+ materialIcon?: string | null;
159
+ }
160
+ export interface CheckListRenderOptions extends RenderOptions {
161
+ type: DataRenderType.CheckList;
162
+ }
163
+ export interface SynchronisedRenderOptions extends RenderOptions {
164
+ type: DataRenderType.Synchronised;
165
+ fieldToSync: string;
166
+ syncType: SyncTextType;
167
+ }
168
+ export declare enum SyncTextType {
169
+ Camel = "Camel",
170
+ Snake = "Snake",
171
+ Pascal = "Pascal"
172
+ }
173
+ export interface UserSelectionRenderOptions extends RenderOptions {
174
+ type: DataRenderType.UserSelection;
175
+ noGroups: boolean;
176
+ noUsers: boolean;
177
+ }
178
+ export interface IconSelectionRenderOptions extends RenderOptions {
179
+ type: DataRenderType.IconSelector;
180
+ }
181
+ export interface GroupedControlsDefinition extends ControlDefinition {
182
+ type: ControlDefinitionType.Group;
183
+ children: ControlDefinition[];
184
+ compoundField?: string | null;
185
+ groupOptions: GroupRenderOptions;
186
+ }
187
+ export interface GroupRenderOptions {
188
+ type: string;
189
+ hideTitle?: boolean | null;
190
+ }
191
+ export declare enum GroupRenderType {
192
+ Standard = "Standard",
193
+ Grid = "Grid",
194
+ GroupElement = "GroupElement"
195
+ }
196
+ export interface StandardGroupRenderer extends GroupRenderOptions {
197
+ type: GroupRenderType.Standard;
198
+ }
199
+ export interface GroupElementRenderer extends GroupRenderOptions {
200
+ type: GroupRenderType.GroupElement;
201
+ value: any;
202
+ }
203
+ export interface GridRenderer extends GroupRenderOptions {
204
+ type: GroupRenderType.Grid;
205
+ columns?: number | null;
206
+ }
207
+ export interface DisplayControlDefinition extends ControlDefinition {
208
+ type: ControlDefinitionType.Display;
209
+ displayData: DisplayData;
210
+ }
211
+ export interface DisplayData {
212
+ type: string;
213
+ }
214
+ export declare enum DisplayDataType {
215
+ Text = "Text",
216
+ Html = "Html"
217
+ }
218
+ export interface TextDisplay extends DisplayData {
219
+ type: DisplayDataType.Text;
220
+ text: string;
221
+ }
222
+ export interface HtmlDisplay extends DisplayData {
223
+ type: DisplayDataType.Html;
224
+ html: string;
225
+ }
226
+ export interface ActionControlDefinition extends ControlDefinition {
227
+ type: ControlDefinitionType.Action;
228
+ actionId: string;
229
+ }
230
+ export declare enum ValidatorType {
231
+ Jsonata = "Jsonata",
232
+ Date = "Date"
233
+ }
234
+ export interface SchemaValidator {
235
+ type: string;
236
+ }
237
+ export interface JsonataValidator extends SchemaValidator {
238
+ type: ValidatorType.Jsonata;
239
+ expression: string;
240
+ }
241
+ export declare enum DateComparison {
242
+ NotBefore = "NotBefore",
243
+ NotAfter = "NotAfter"
244
+ }
245
+ export interface DateValidator extends SchemaValidator {
246
+ type: ValidatorType.Date;
247
+ comparison: DateComparison;
248
+ fixedDate?: string | null;
249
+ daysFromCurrent?: number | null;
250
+ }
251
+ export declare function isDataControlDefinition(x: ControlDefinition): x is DataControlDefinition;
252
+ export declare function isGroupControlsDefinition(x: ControlDefinition): x is GroupedControlsDefinition;
253
+ export declare function isDisplayControlsDefinition(x: ControlDefinition): x is DisplayControlDefinition;
254
+ export declare function isActionControlsDefinition(x: ControlDefinition): x is ActionControlDefinition;
255
+ export interface ControlVisitor<A> {
256
+ data(d: DataControlDefinition): A;
257
+ group(d: GroupedControlsDefinition): A;
258
+ display(d: DisplayControlDefinition): A;
259
+ action(d: ActionControlDefinition): A;
260
+ }
261
+ export declare function visitControlDefinition<A>(x: ControlDefinition, visitor: ControlVisitor<A>, defaultValue: (c: ControlDefinition) => A): A;
262
+ export declare function dataControl(field: string, options?: Partial<DataControlDefinition>): DataControlDefinition;
263
+ export declare function fieldValueExpr(field: string, value: any): FieldValueExpression;
264
+ export declare function visibility(expr: EntityExpression): DynamicProperty;
265
+ export declare function isGridRenderer(options: GroupRenderOptions): options is GridRenderer;
package/lib/util.d.ts CHANGED
@@ -1,3 +1,22 @@
1
- import { SchemaField } from "./types";
2
- export declare function fieldHasTag(field: SchemaField, tag: string): boolean;
3
- export declare function fieldDisplayName(field: SchemaField): string;
1
+ import { CompoundField, ControlDefinition, DataControlDefinition, FieldOption, GroupedControlsDefinition, SchemaField } from "./types";
2
+ export declare function applyDefaultValues(v: {
3
+ [k: string]: any;
4
+ } | undefined, fields: SchemaField[]): any;
5
+ export declare function applyDefaultForField(v: any, field: SchemaField, parent: SchemaField[], notElement?: boolean): any;
6
+ export declare function defaultValueForFields(fields: SchemaField[]): any;
7
+ export declare function defaultValueForField(sf: SchemaField): any;
8
+ export declare function elementValueForField(sf: SchemaField): any;
9
+ export declare function findScalarField(fields: SchemaField[], field: string): SchemaField | undefined;
10
+ export declare function findCompoundField(fields: SchemaField[], field: string): CompoundField | undefined;
11
+ export declare function findField(fields: SchemaField[], field: string): SchemaField | undefined;
12
+ export declare function isScalarField(sf: SchemaField): sf is SchemaField;
13
+ export declare function isCompoundField(sf: SchemaField): sf is CompoundField;
14
+ export declare function isDataControl(c: ControlDefinition): c is DataControlDefinition;
15
+ export declare function isGroupControl(c: ControlDefinition): c is GroupedControlsDefinition;
16
+ export declare function fieldHasTag(field: SchemaField, tag: string): boolean;
17
+ export declare function fieldDisplayName(field: SchemaField): string;
18
+ export declare function hasOptions(o: {
19
+ options: FieldOption[] | undefined | null;
20
+ }): boolean;
21
+ export declare function defaultControlForField(sf: SchemaField): DataControlDefinition | GroupedControlsDefinition;
22
+ export declare function addMissingControls(fields: SchemaField[], controls: ControlDefinition[]): ControlDefinition[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-typed-forms/schemas",
3
- "version": "1.0.0-dev.17",
3
+ "version": "1.0.0-dev.19",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -24,7 +24,9 @@
24
24
  "material-ui"
25
25
  ],
26
26
  "dependencies": {
27
- "@react-typed-forms/core": "^3.0.0-dev.111",
27
+ "@react-typed-forms/core": "^3.0.0-dev.116",
28
+ "clsx": "^1 || ^2",
29
+ "jsonata": "^2.0.3",
28
30
  "react": "^18.2.0"
29
31
  },
30
32
  "devDependencies": {
@@ -32,12 +34,14 @@
32
34
  "@types/react": "^18.2.28",
33
35
  "microbundle": "^0.15.1",
34
36
  "nswag": "^13.18.2",
35
- "rimraf": "^3.0.2"
37
+ "prettier": "^3.0.3",
38
+ "rimraf": "^3.0.2",
39
+ "typescript": "^5.2.2"
36
40
  },
37
41
  "gitHead": "698e16cd3ab31b7dd0528fc76536f4d3205ce8c6",
38
42
  "scripts": {
39
43
  "build": "rimraf ./lib/ && microbundle -f cjs --no-compress --jsx React.createElement --jsxFragment React.Fragment",
40
- "watch": "tsc -w",
44
+ "watch": "microbundle -w -f cjs --no-compress --jsx React.createElement --jsxFragment React.Fragment",
41
45
  "gencode": "nswag swagger2tsclient /input:http://localhost:5216/swagger/v1/swagger.json /runtime:Net60 /output:src/types.ts /GenerateClientClasses:false /MarkOptionalProperties:false /Template:Fetch /TypeStyle:Interface /DateTimeType:string"
42
46
  }
43
47
  }