@onehat/ui 0.3.108 → 0.3.110
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/package.json
CHANGED
|
@@ -127,6 +127,7 @@ function Form(props) {
|
|
|
127
127
|
[containerWidth, setContainerWidth] = useState(),
|
|
128
128
|
initialValues = _.merge(startingValues, (record && !record.isDestroyed ? record.submitValues : {})),
|
|
129
129
|
defaultValues = isMultiple ? getNullFieldValues(initialValues, Repository) : initialValues, // when multiple entities, set all default values to null
|
|
130
|
+
validatorToUse = validator || (isMultiple ? disableRequiredYupFields(Repository?.schema?.model?.validator) : Repository?.schema?.model?.validator) || yup.object(),
|
|
130
131
|
{
|
|
131
132
|
control,
|
|
132
133
|
formState,
|
|
@@ -142,7 +143,7 @@ function Form(props) {
|
|
|
142
143
|
// setFocus,
|
|
143
144
|
getValues: formGetValues,
|
|
144
145
|
// getFieldState,
|
|
145
|
-
|
|
146
|
+
trigger,
|
|
146
147
|
} = useForm({
|
|
147
148
|
mode: 'onChange', // onChange | onBlur | onSubmit | onTouched | all
|
|
148
149
|
// reValidateMode: 'onChange', // onChange | onBlur | onSubmit
|
|
@@ -157,7 +158,7 @@ function Form(props) {
|
|
|
157
158
|
// delayError: 0,
|
|
158
159
|
// shouldUnregister: false,
|
|
159
160
|
// shouldUseNativeValidation: false,
|
|
160
|
-
resolver: yupResolver(
|
|
161
|
+
resolver: yupResolver(validatorToUse),
|
|
161
162
|
context: { isPhantom },
|
|
162
163
|
}),
|
|
163
164
|
buildFromColumnsConfig = () => {
|
|
@@ -297,6 +298,7 @@ function Form(props) {
|
|
|
297
298
|
useSelectorId = false,
|
|
298
299
|
isHidden = false,
|
|
299
300
|
getDynamicProps,
|
|
301
|
+
getIsRequired,
|
|
300
302
|
...propsToPass
|
|
301
303
|
} = item,
|
|
302
304
|
editorTypeProps = {};
|
|
@@ -483,7 +485,7 @@ function Form(props) {
|
|
|
483
485
|
}
|
|
484
486
|
onChange(newValue);
|
|
485
487
|
if (onEditorChange) {
|
|
486
|
-
onEditorChange(newValue, formSetValue, formGetValues, formState);
|
|
488
|
+
onEditorChange(newValue, formSetValue, formGetValues, formState, trigger);
|
|
487
489
|
}
|
|
488
490
|
}}
|
|
489
491
|
onBlur={onBlur}
|
|
@@ -521,11 +523,11 @@ function Form(props) {
|
|
|
521
523
|
|
|
522
524
|
let isRequired = false,
|
|
523
525
|
requiredIndicator = null;
|
|
524
|
-
if (
|
|
526
|
+
if (getIsRequired) {
|
|
527
|
+
isRequired = getIsRequired(formGetValues, formState);
|
|
528
|
+
} else if (validatorToUse?.fields && validatorToUse.fields[name]?.exclusiveTests?.required) {
|
|
525
529
|
// submitted validator
|
|
526
|
-
|
|
527
|
-
isRequired = true;
|
|
528
|
-
}
|
|
530
|
+
isRequired = true;
|
|
529
531
|
} else if ((propertyDef?.validator?.spec && !propertyDef.validator.spec.optional) ||
|
|
530
532
|
(propertyDef?.requiredIfPhantom && isPhantom) ||
|
|
531
533
|
(propertyDef?.requiredIfNotPhantom && !isPhantom)) {
|