@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/lib/controlRender.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { Key, ReactElement, ReactNode } from "react";
|
|
|
3
3
|
import { Control } from "@react-typed-forms/core";
|
|
4
4
|
export interface SchemaHooks {
|
|
5
5
|
useExpression(expr: EntityExpression, formState: FormEditState): Control<any | undefined>;
|
|
6
|
-
useValidators(formState: FormEditState, isVisible: boolean, control: Control<any>, required: boolean, validations?: SchemaValidator[] | null): void;
|
|
6
|
+
useValidators(formState: FormEditState, isVisible: boolean | undefined, control: Control<any>, required: boolean, validations?: SchemaValidator[] | null): void;
|
|
7
7
|
}
|
|
8
8
|
export interface FormEditHooks {
|
|
9
9
|
useDataProperties(formState: FormEditState, definition: DataControlDefinition, field: SchemaField): DataRendererProps;
|
|
@@ -79,7 +79,7 @@ export interface FormRenderer {
|
|
|
79
79
|
renderAdornment: (props: AdornmentProps) => AdornmentRenderer;
|
|
80
80
|
}
|
|
81
81
|
export interface Visibility {
|
|
82
|
-
value: boolean;
|
|
82
|
+
value: boolean | undefined;
|
|
83
83
|
canChange: boolean;
|
|
84
84
|
}
|
|
85
85
|
export interface LabelRendererProps {
|
package/lib/index.js
CHANGED
|
@@ -624,7 +624,7 @@ function useIsControlVisible(definition, formState, hooks) {
|
|
|
624
624
|
if (visibleExpression && visibleExpression.expr) {
|
|
625
625
|
var exprValue = hooks.useExpression(visibleExpression.expr, formState).value;
|
|
626
626
|
return {
|
|
627
|
-
value:
|
|
627
|
+
value: exprValue,
|
|
628
628
|
canChange: true
|
|
629
629
|
};
|
|
630
630
|
}
|
|
@@ -710,7 +710,7 @@ function createDefaultSchemaHooks() {
|
|
|
710
710
|
}
|
|
711
711
|
function useValidators(formState, isVisible, control, required, validators) {
|
|
712
712
|
if (required) core.useValidator(control, function (v) {
|
|
713
|
-
return isVisible && (v == null || v
|
|
713
|
+
return isVisible === true && (v == null || v === "") ? "Please enter a value" : null;
|
|
714
714
|
}, "required");
|
|
715
715
|
validators == null || validators.forEach(function (v, i) {
|
|
716
716
|
switch (v.type) {
|
|
@@ -767,7 +767,7 @@ function createFormEditHooks(schemaHooks) {
|
|
|
767
767
|
var defaultValue = useDefaultValue(definition, field, formState, schemaHooks);
|
|
768
768
|
var scalarControl = formState.data.fields[field.field];
|
|
769
769
|
React.useEffect(function () {
|
|
770
|
-
if (
|
|
770
|
+
if (isVisible === false) scalarControl.value = null;else if (scalarControl.current.value == null) {
|
|
771
771
|
scalarControl.value = defaultValue;
|
|
772
772
|
}
|
|
773
773
|
}, [isVisible, defaultValue]);
|
|
@@ -803,7 +803,7 @@ function createFormEditHooks(schemaHooks) {
|
|
|
803
803
|
var field = definition.compoundField ? findCompoundField(fs.fields, definition.compoundField) : undefined;
|
|
804
804
|
var newFs = _extends({}, fs, {
|
|
805
805
|
fields: field ? field.children : fs.fields,
|
|
806
|
-
invisible:
|
|
806
|
+
invisible: visible.value === false || fs.invisible
|
|
807
807
|
});
|
|
808
808
|
var data = field ? fs.data.fields[field.field] : fs.data;
|
|
809
809
|
var groupProps = {
|