UNPKG

@hhgtech/hhg-components

Version:
54 lines (53 loc) 1.91 kB
import { FieldPath, FieldValues, RegisterOptions } from 'react-hook-form'; import { ButtonProps } from "../../../mantine"; import { HealthToolFormWrapperProps } from "../healthTools/formWrapper"; export type BmiObjective = 'lose-weight' | 'maintain-weight' | 'gain-weight'; export type BmiUnitSystem = 'metric' | 'imperial'; export type BmiFormValue = { gender?: 'male' | 'female'; age?: number; weight?: number | ''; height?: number | ''; objective?: BmiObjective; bmi?: number; unit?: BmiUnitSystem; question1?: boolean; question2?: boolean; newsletter?: boolean; }; export type BmiFormValueKeys = keyof BmiFormValue; export type Rule = Omit<RegisterOptions<FieldValues, FieldPath<FieldValues>>, 'valueAsNumber' | 'valueAsDate' | 'setValueAs' | 'disabled'>; export type BMIUnit = { minAge: number; maxAge: number; minHeight: number; maxHeight: number; minWeight: number; maxWeight: number; heightConvert: (val: number) => number; weightConvert: (val: number) => number; }; export type BmiFormProps = { value?: BmiFormValue; onChange?: (value: BmiFormValue) => void; onSubmit?: (value: BmiFormValue) => void; className?: string; bmiGenerated: Record<keyof BmiFormValue, { label: string; rule?: Rule | undefined; }>; bmiUnit: BMIUnit; /** * When false, BmiForm behaves like the previous fixed-unit version: * no unit picker UI, and conversion uses `bmiUnit.heightConvert/weightConvert`. */ enableUnitPicker?: boolean; defaultUnitSystem?: BmiUnitSystem; submitProps?: ButtonProps; withAdditionalQuestion?: boolean; isMobile?: boolean; } & HealthToolFormWrapperProps; export declare function getBmi({ weight: weightProps, height: heightProps, }: { weight: number; height: number; }): number;