All files / libs/design-system/ext/src/lib/forms/formik-date-picker FormikDatePicker.tsx

100% Statements 27/27
100% Branches 1/1
100% Functions 1/1
100% Lines 27/27

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 281x 1x 1x 1x 1x 1x 1x 1x 1x 1x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 1x 1x  
import { memo } from 'react';
 
import { DatePicker, type DatePickerProps } from '@allshares/studio-design-system';
import { useFormikFieldAdapter, type FormikFieldProps } from '@amalia/ext/formik';
 
export type FormikDatePickerProps<TWithRange extends boolean | undefined = undefined> = FormikFieldProps<
  DatePickerProps<TWithRange>
>;
 
export const FormikDatePickerBase = function FormikDatePicker<TWithRange extends boolean | undefined = undefined>({
  validate, // Omit validate and any props not passed to DatePicker.
  ...props
}: FormikDatePickerProps<TWithRange>) {
  const formikFieldProps = useFormikFieldAdapter<DatePickerProps<TWithRange>['value']>({
    ...props,
    validate,
  });
 
  return (
    <DatePicker<TWithRange>
      {...props}
      {...formikFieldProps}
    />
  );
};
 
export const FormikDatePicker = memo(FormikDatePickerBase) as typeof FormikDatePickerBase;