@react-typed-forms/schemas 1.0.0-dev.23 → 1.0.0-dev.24
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/.rush/temp/operation/build/state.json +1 -1
- package/.rush/temp/shrinkwrap-deps.json +173 -163
- package/lib/controlRender.d.ts +2 -2
- package/lib/index.js +4 -4
- package/lib/index.js.map +1 -1
- package/package.json +2 -2
- package/src/controlRender.tsx +2 -2
- package/src/hooks.tsx +7 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-typed-forms/schemas",
|
|
3
|
-
"version": "1.0.0-dev.
|
|
3
|
+
"version": "1.0.0-dev.24",
|
|
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.
|
|
27
|
+
"@react-typed-forms/core": "^3.0.0-dev.117",
|
|
28
28
|
"clsx": "^1 || ^2",
|
|
29
29
|
"jsonata": "^2.0.3",
|
|
30
30
|
"react": "^18.2.0"
|
package/src/controlRender.tsx
CHANGED
|
@@ -33,7 +33,7 @@ export interface SchemaHooks {
|
|
|
33
33
|
): Control<any | undefined>;
|
|
34
34
|
useValidators(
|
|
35
35
|
formState: FormEditState,
|
|
36
|
-
isVisible: boolean,
|
|
36
|
+
isVisible: boolean | undefined,
|
|
37
37
|
control: Control<any>,
|
|
38
38
|
required: boolean,
|
|
39
39
|
validations?: SchemaValidator[] | null,
|
|
@@ -137,7 +137,7 @@ export interface FormRenderer {
|
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
export interface Visibility {
|
|
140
|
-
value: boolean;
|
|
140
|
+
value: boolean | undefined;
|
|
141
141
|
canChange: boolean;
|
|
142
142
|
}
|
|
143
143
|
export interface LabelRendererProps {
|
package/src/hooks.tsx
CHANGED
|
@@ -84,7 +84,7 @@ export function useIsControlVisible(
|
|
|
84
84
|
formState,
|
|
85
85
|
).value;
|
|
86
86
|
return {
|
|
87
|
-
value:
|
|
87
|
+
value: exprValue,
|
|
88
88
|
canChange: true,
|
|
89
89
|
};
|
|
90
90
|
}
|
|
@@ -188,7 +188,7 @@ export function createDefaultSchemaHooks(): SchemaHooks {
|
|
|
188
188
|
|
|
189
189
|
function useValidators(
|
|
190
190
|
formState: FormEditState,
|
|
191
|
-
isVisible: boolean,
|
|
191
|
+
isVisible: boolean | undefined,
|
|
192
192
|
control: Control<any>,
|
|
193
193
|
required: boolean,
|
|
194
194
|
validators?: SchemaValidator[] | null,
|
|
@@ -197,7 +197,9 @@ export function createDefaultSchemaHooks(): SchemaHooks {
|
|
|
197
197
|
useValidator(
|
|
198
198
|
control,
|
|
199
199
|
(v) =>
|
|
200
|
-
isVisible && (v == null || v
|
|
200
|
+
isVisible === true && (v == null || v === "")
|
|
201
|
+
? "Please enter a value"
|
|
202
|
+
: null,
|
|
201
203
|
"required",
|
|
202
204
|
);
|
|
203
205
|
validators?.forEach((v, i) => {
|
|
@@ -277,7 +279,7 @@ export function createFormEditHooks(schemaHooks: SchemaHooks): FormEditHooks {
|
|
|
277
279
|
const scalarControl = formState.data.fields[field.field];
|
|
278
280
|
|
|
279
281
|
useEffect(() => {
|
|
280
|
-
if (
|
|
282
|
+
if (isVisible === false) scalarControl.value = null;
|
|
281
283
|
else if (scalarControl.current.value == null) {
|
|
282
284
|
scalarControl.value = defaultValue;
|
|
283
285
|
}
|
|
@@ -332,7 +334,7 @@ export function createFormEditHooks(schemaHooks: SchemaHooks): FormEditHooks {
|
|
|
332
334
|
const newFs: RenderControlOptions = {
|
|
333
335
|
...fs,
|
|
334
336
|
fields: field ? field.children : fs.fields,
|
|
335
|
-
invisible:
|
|
337
|
+
invisible: visible.value === false || fs.invisible,
|
|
336
338
|
};
|
|
337
339
|
const data = field ? fs.data.fields[field.field] : fs.data;
|
|
338
340
|
const groupProps = {
|