Skip to content

Commit

Permalink
build(rhf): update to 7.48.2 and fix error types
Browse files Browse the repository at this point in the history
  • Loading branch information
EtienneDOYON committed Nov 13, 2023
1 parent 6a55eac commit a1c91bf
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 133 deletions.
2 changes: 1 addition & 1 deletion libs/form-builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@bedrockstreaming/form-builder",
"version": "0.8.4",
"dependencies": {
"react-hook-form": "7.27.0"
"react-hook-form": "7.48.2"
},
"peerDependencies": {
"react": "17.0.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export interface FormFieldProps {
dictionary: Dictionary;
validation?: Validations;
errors?: ErrorOption;
setFieldValue?: SetFieldValue<string | number>;
setFieldValue?: SetFieldValue<FieldValues>;
triggerValidationField?: (value: Path<FieldValues>) => void;
propRef?: Ref;
disabled?: boolean;
Expand Down
4 changes: 2 additions & 2 deletions libs/form-builder/src/lib/utils/conditionalFields.utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { UseFormGetValues, FieldValues, FieldErrors } from 'react-hook-form';
import { UseFormGetValues, FieldValues, FieldErrors, FieldError } from 'react-hook-form';
import { ExtraValidation, FormField, FormFields } from '../types';

export interface ShouldDisplayField {
Expand All @@ -24,7 +24,7 @@ export const shouldDisplayField = ({ dependsOn, getValues, extraValidation, erro
// When the validate option is disabled
// Check for specific validation error
if (!dependRule.validate) {
const validationError = fieldError && fieldError[dependRule.key];
const validationError = fieldError && fieldError[dependRule.key as keyof FieldError];
return dependsOnConditions.push(!!fieldValue && !validationError);
}

Expand Down
2 changes: 1 addition & 1 deletion libs/form-builder/src/lib/utils/validation.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export interface GetFieldRulesArgs {
extraValidation?: ExtraValidation;
}

export interface FieldRules extends RegisterOptions {
export type FieldRules = RegisterOptions & {
validate?: { [key: string]: (value?: any) => Promise<boolean> | boolean };
}

Expand Down
2 changes: 1 addition & 1 deletion libs/form-context/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"peerDependencies": {
"react": "17.0.2",
"@bedrockstreaming/form-builder": "0.8.1",
"react-hook-form": "7.27.0"
"react-hook-form": "7.48.2"
},
"devDependencies": {
"deep-freeze": "0.0.1"
Expand Down
2 changes: 1 addition & 1 deletion libs/form-editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"@mui/material": "5.2.2",
"@mui/styles": "5.2.2",
"react": "17.0.2",
"react-hook-form": "7.27.0",
"react-hook-form": "7.48.2",
"react-redux": "7.2.6"
}
}
2 changes: 1 addition & 1 deletion libs/form-redux/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"@bedrockstreaming/form-builder": "0.8.1",
"@hookform/devtools": "4.0.2",
"react": "17.0.2",
"react-hook-form": "7.27.0"
"react-hook-form": "7.48.2"
},
"devDependencies": {
"deep-freeze": "0.0.1"
Expand Down
2 changes: 1 addition & 1 deletion libs/form-validation-rule-list/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"peerDependencies": {
"react": "17.0.2",
"@bedrockstreaming/form-builder": "0.8.1",
"react-hook-form": "7.27.0"
"react-hook-form": "7.48.2"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const identity = (value: string) => value;

export const getValidationRulesHints = ({ t = identity, errors, validation, config }: GetValidationRulesHintsArgs) => {
return Object.values(validation).reduce((acc, { message, key }) => {
// @ts-ignore
return DEFAULT_RULES_NAMES[key] ? acc : [...acc, rule(t(message, config), () => !errors?.types[key])];
}, [] as Array<RuleObject>);
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"prism-react-renderer": "1.2.1",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-hook-form": "7.27.0",
"react-hook-form": "7.48.2",
"react-redux": "7.2.6",
"react-router-dom": "5.2.0",
"redux": "4.1.2",
Expand Down
Loading

0 comments on commit a1c91bf

Please sign in to comment.