@react-typed-forms/schemas 3.0.0-dev.76 → 3.0.0-dev.77

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.
@@ -2,11 +2,11 @@
2
2
  "files": {
3
3
  "packages/schemas/.rush/temp/shrinkwrap-deps.json": "6ad43bbf71e5f191d9f571da269a25bb4d9e8909",
4
4
  "packages/schemas/package.json": "2785351ab91d60b4fff87823a082d24fb5b6dda8",
5
- "packages/schemas/src/controlRender.tsx": "24db6564d9793bb7236bbf19aea759e26391ffff",
6
- "packages/schemas/src/hooks.ts": "64cf3ef2b5151231c9ffbc26da34002a3cab867d",
5
+ "packages/schemas/src/controlRender.tsx": "8f985c464635df4ea471535da80c2d002eb0b4a3",
6
+ "packages/schemas/src/hooks.ts": "89bcc068bd3a38a25f733cc1404649af82510e91",
7
7
  "packages/schemas/src/index.ts": "b15fbb6de132cd912cf8141d5c4d2329e947546e",
8
8
  "packages/schemas/src/schemaBuilder.ts": "3a36cbc35f70fca2b561f6d4ddc1bd1030eeb3f6",
9
- "packages/schemas/src/types.ts": "88168cc68de0d9784e0e60430bee4d084ee3fa68",
9
+ "packages/schemas/src/types.ts": "31659d00c1a1cfb2808af2c43c8a1c0ec271458d",
10
10
  "packages/schemas/tsconfig.json": "52e4f044fa580f4e0ad5830f3cfca574e2788372"
11
11
  },
12
12
  "arguments": "rimraf ./lib/ && tsc "
@@ -8,6 +8,7 @@ export interface FormEditHooks {
8
8
  useActionProperties(formState: FormEditState, definition: ActionControlDefinition): ActionControlProperties;
9
9
  }
10
10
  export interface DataControlProperties {
11
+ readonly: boolean;
11
12
  visible: boolean;
12
13
  options: FieldOption[] | undefined;
13
14
  defaultValue: any;
@@ -31,6 +32,7 @@ export interface ControlData {
31
32
  export interface FormEditState {
32
33
  fields: SchemaField[];
33
34
  data: Control<ControlData>;
35
+ readonly?: boolean;
34
36
  }
35
37
  export interface FormRendererComponents {
36
38
  renderData: (props: DataRendererProps, control: Control<any>, element: boolean, renderers: FormRendererComponents) => ReactElement;
package/lib/hooks.d.ts CHANGED
@@ -3,7 +3,7 @@ import { DataControlProperties, FormEditHooks, FormEditState } from "./controlRe
3
3
  export type ExpressionHook = (expr: EntityExpression, formState: FormEditState) => any;
4
4
  export declare function useDefaultValue(definition: DataControlDefinition, field: ScalarField, formState: FormEditState, useExpression: ExpressionHook): any;
5
5
  export declare function useIsControlVisible(definition: ControlDefinition, formState: FormEditState, useExpression: ExpressionHook): boolean;
6
- export declare function getDefaultScalarControlProperties(control: DataControlDefinition, field: ScalarField, visible: boolean, defaultValue: any): DataControlProperties;
6
+ export declare function getDefaultScalarControlProperties(control: DataControlDefinition, field: ScalarField, visible: boolean, defaultValue: any, readonly?: boolean): DataControlProperties;
7
7
  export declare function getOptionsForScalarField(field: ScalarField): FieldOption[] | undefined;
8
8
  export declare const defaultExpressionHook: ExpressionHook;
9
9
  export declare function createFormEditHooks(useExpression: ExpressionHook): FormEditHooks;
package/lib/hooks.js CHANGED
@@ -33,12 +33,14 @@ function useIsControlVisible(definition, formState, useExpression) {
33
33
  Boolean(typeControl.value && onlyForTypes.includes(typeControl.value)));
34
34
  }
35
35
  exports.useIsControlVisible = useIsControlVisible;
36
- function getDefaultScalarControlProperties(control, field, visible, defaultValue) {
36
+ function getDefaultScalarControlProperties(control, field, visible, defaultValue, readonly) {
37
+ var _a, _b;
37
38
  return {
38
39
  defaultValue,
39
40
  options: getOptionsForScalarField(field),
40
- required: control.required,
41
+ required: (_a = control.required) !== null && _a !== void 0 ? _a : false,
41
42
  visible,
43
+ readonly: (_b = readonly !== null && readonly !== void 0 ? readonly : control.readonly) !== null && _b !== void 0 ? _b : false,
42
44
  };
43
45
  }
44
46
  exports.getDefaultScalarControlProperties = getDefaultScalarControlProperties;
@@ -66,7 +68,7 @@ function createFormEditHooks(useExpression) {
66
68
  useDataProperties(formState, definition, field) {
67
69
  const visible = useIsControlVisible(definition, formState, useExpression);
68
70
  const defaultValue = useDefaultValue(definition, field, formState, useExpression);
69
- return getDefaultScalarControlProperties(definition, field, visible, defaultValue);
71
+ return getDefaultScalarControlProperties(definition, field, visible, defaultValue, formState.readonly);
70
72
  },
71
73
  useDisplayProperties: (fs, definition) => {
72
74
  const visible = useIsControlVisible(definition, fs, useExpression);
package/lib/types.d.ts CHANGED
@@ -1,7 +1,3 @@
1
- export interface AllClasses {
2
- schemaField: SchemaField;
3
- control: ControlDefinition;
4
- }
5
1
  export interface SchemaField {
6
2
  schemaType: SchemaFieldType;
7
3
  field: string;
@@ -104,10 +100,10 @@ export interface AccordionAdornment extends ControlAdornment {
104
100
  export interface DataControlDefinition extends ControlDefinition {
105
101
  type: ControlDefinitionType.Data;
106
102
  field: string;
107
- required: boolean;
103
+ required?: boolean;
108
104
  renderOptions: RenderOptions;
109
105
  defaultValue?: any;
110
- noEdit: boolean;
106
+ readonly?: boolean;
111
107
  }
112
108
  export interface RenderOptions {
113
109
  type: DataRenderType;
package/lib/types.js CHANGED
@@ -1,9 +1,4 @@
1
1
  "use strict";
2
- //----------------------
3
- // <auto-generated>
4
- // Generated using the NSwag toolchain v13.18.2.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v13.0.0.0)) (http://NSwag.org)
5
- // </auto-generated>
6
- //----------------------
7
2
  Object.defineProperty(exports, "__esModule", { value: true });
8
3
  exports.DisplayDataType = exports.GroupRenderType = exports.SyncTextType = exports.DataRenderType = exports.ControlAdornmentType = exports.ExpressionType = exports.DynamicPropertyType = exports.ControlDefinitionType = exports.FieldType = exports.SchemaFieldType = void 0;
9
4
  var SchemaFieldType;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-typed-forms/schemas",
3
- "version": "3.0.0-dev.76",
3
+ "version": "3.0.0-dev.77",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -24,7 +24,7 @@
24
24
  "material-ui"
25
25
  ],
26
26
  "dependencies": {
27
- "@react-typed-forms/core": "3.0.0-dev.76"
27
+ "@react-typed-forms/core": "3.0.0-dev.77"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@types/react": "^18.0.22",
package/schemas.build.log CHANGED
@@ -1,2 +0,0 @@
1
- Invoking: rimraf ./lib/ && tsc
2
-
@@ -43,6 +43,7 @@ export interface FormEditHooks {
43
43
  }
44
44
 
45
45
  export interface DataControlProperties {
46
+ readonly: boolean;
46
47
  visible: boolean;
47
48
  options: FieldOption[] | undefined;
48
49
  defaultValue: any;
@@ -74,6 +75,7 @@ export interface ControlData {
74
75
  export interface FormEditState {
75
76
  fields: SchemaField[];
76
77
  data: Control<ControlData>;
78
+ readonly?: boolean;
77
79
  }
78
80
 
79
81
  export interface FormRendererComponents {
package/src/hooks.ts CHANGED
@@ -78,13 +78,15 @@ export function getDefaultScalarControlProperties(
78
78
  control: DataControlDefinition,
79
79
  field: ScalarField,
80
80
  visible: boolean,
81
- defaultValue: any
81
+ defaultValue: any,
82
+ readonly?: boolean
82
83
  ): DataControlProperties {
83
84
  return {
84
85
  defaultValue,
85
86
  options: getOptionsForScalarField(field),
86
- required: control.required,
87
+ required: control.required ?? false,
87
88
  visible,
89
+ readonly: readonly ?? control.readonly ?? false,
88
90
  };
89
91
  }
90
92
 
@@ -133,7 +135,8 @@ export function createFormEditHooks(
133
135
  definition,
134
136
  field,
135
137
  visible,
136
- defaultValue
138
+ defaultValue,
139
+ formState.readonly
137
140
  );
138
141
  },
139
142
  useDisplayProperties: (fs, definition) => {
package/src/types.ts CHANGED
@@ -1,19 +1,3 @@
1
- //----------------------
2
- // <auto-generated>
3
- // Generated using the NSwag toolchain v13.18.2.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v13.0.0.0)) (http://NSwag.org)
4
- // </auto-generated>
5
- //----------------------
6
-
7
- /* tslint:disable */
8
- /* eslint-disable */
9
-
10
- // ReSharper disable InconsistentNaming
11
-
12
- export interface AllClasses {
13
- schemaField: SchemaField;
14
- control: ControlDefinition;
15
- }
16
-
17
1
  export interface SchemaField {
18
2
  schemaType: SchemaFieldType;
19
3
  field: string;
@@ -142,10 +126,10 @@ export interface AccordionAdornment extends ControlAdornment {
142
126
  export interface DataControlDefinition extends ControlDefinition {
143
127
  type: ControlDefinitionType.Data;
144
128
  field: string;
145
- required: boolean;
129
+ required?: boolean;
146
130
  renderOptions: RenderOptions;
147
131
  defaultValue?: any;
148
- noEdit: boolean;
132
+ readonly?: boolean;
149
133
  }
150
134
 
151
135
  export interface RenderOptions {