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

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,234 @@
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
+ /**
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;
package/lib/util.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { SchemaField } from "./types";
2
+ export declare function fieldHasTag(field: SchemaField, tag: string): boolean;
3
+ export declare function fieldDisplayName(field: SchemaField): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-typed-forms/schemas",
3
- "version": "1.0.0-dev.15",
3
+ "version": "1.0.0-dev.17",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -24,18 +24,19 @@
24
24
  "material-ui"
25
25
  ],
26
26
  "dependencies": {
27
- "@react-typed-forms/core": "^*"
27
+ "@react-typed-forms/core": "^3.0.0-dev.111",
28
+ "react": "^18.2.0"
28
29
  },
29
30
  "devDependencies": {
31
+ "@react-typed-forms/transform": "^0.1.0",
30
32
  "@types/react": "^18.2.28",
33
+ "microbundle": "^0.15.1",
31
34
  "nswag": "^13.18.2",
32
- "react": "^18.2.0",
33
- "react-dom": "^18.2.0",
34
35
  "rimraf": "^3.0.2"
35
36
  },
36
37
  "gitHead": "698e16cd3ab31b7dd0528fc76536f4d3205ce8c6",
37
38
  "scripts": {
38
- "build": "rimraf ./lib/ && tsc",
39
+ "build": "rimraf ./lib/ && microbundle -f cjs --no-compress --jsx React.createElement --jsxFragment React.Fragment",
39
40
  "watch": "tsc -w",
40
41
  "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"
41
42
  }
@@ -22,7 +22,7 @@ import React, {
22
22
  useContext,
23
23
  } from "react";
24
24
  import { Control, newControl } from "@react-typed-forms/core";
25
- import { fieldDisplayName } from "./index";
25
+ import { fieldDisplayName } from "./util";
26
26
 
27
27
  export type ExpressionHook = (
28
28
  expr: EntityExpression,
@@ -337,6 +337,7 @@ export function renderControl<S extends ControlDefinition>(
337
337
  }
338
338
  }
339
339
 
340
+ /** @trackControls */
340
341
  function DataRenderer({
341
342
  hooks,
342
343
  formState,
@@ -368,6 +369,7 @@ function DataRenderer({
368
369
  );
369
370
  }
370
371
 
372
+ /** @trackControls */
371
373
  function ActionRenderer({
372
374
  hooks,
373
375
  formState,
@@ -389,6 +391,7 @@ function ActionRenderer({
389
391
  );
390
392
  }
391
393
 
394
+ /** @trackControls */
392
395
  function GroupRenderer({
393
396
  hooks,
394
397
  formState,
@@ -448,6 +451,7 @@ function GroupRenderer({
448
451
  );
449
452
  }
450
453
 
454
+ /** @trackControls */
451
455
  function DisplayRenderer({
452
456
  hooks,
453
457
  wrapElem,
package/src/index.ts CHANGED
@@ -1,14 +1,5 @@
1
- import { SchemaField } from "./types";
2
-
3
1
  export * from "./types";
4
2
  export * from "./schemaBuilder";
5
3
  export * from "./controlRender";
6
4
  export * from "./hooks";
7
-
8
- export function fieldHasTag(field: SchemaField, tag: string) {
9
- return Boolean(field.tags?.includes(tag));
10
- }
11
-
12
- export function fieldDisplayName(field: SchemaField) {
13
- return field.displayName ?? field.field;
14
- }
5
+ export * from "./util";
package/src/util.ts ADDED
@@ -0,0 +1,9 @@
1
+ import { SchemaField } from "./types";
2
+
3
+ export function fieldHasTag(field: SchemaField, tag: string) {
4
+ return Boolean(field.tags?.includes(tag));
5
+ }
6
+
7
+ export function fieldDisplayName(field: SchemaField) {
8
+ return field.displayName ?? field.field;
9
+ }
package/tsconfig.json CHANGED
@@ -1,18 +1,19 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "target": "ES2015",
3
+ "target": "ESNext",
4
4
  "lib": ["dom", "dom.iterable", "esnext"],
5
5
  "allowJs": true,
6
6
  "skipLibCheck": true,
7
7
  "strict": true,
8
+ "noEmit": true,
8
9
  "forceConsistentCasingInFileNames": true,
9
10
  "esModuleInterop": true,
10
11
  "declaration": true,
11
- "module": "CommonJS",
12
+ "module": "ESNext",
12
13
  "moduleResolution": "node",
13
14
  "resolveJsonModule": true,
14
15
  "isolatedModules": true,
15
- "jsx": "react",
16
+ "jsx": "preserve",
16
17
  "outDir": "lib"
17
18
  },
18
19
  "include": ["src/**/*.ts", "src/**/*.tsx"],
@@ -1 +0,0 @@
1
- Invoking: rimraf ./lib/ && tsc