All files / libs/design-system/ext/src/lib/forms/formik-cell-select FormikCellSelect.tsx

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

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 28 29 30 31 32 33 34 35 36 37 38 39 40 411x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x  
import {
  CellSelect,
  type CellSelectOption,
  type CellSelectProps,
  type SelectOptionGroup,
} from '@allshares/studio-design-system';
import { useFormikFieldAdapter, type FormikFieldProps } from '@amalia/ext/formik';
 
export type FormikCellSelectProps<
  TOption extends CellSelectOption = CellSelectOption,
  TIsMultiple extends boolean | undefined = undefined,
  TUseOptionAsValue extends boolean | undefined = undefined,
  TIsClearable extends boolean | undefined = true,
  TGroup extends SelectOptionGroup<TOption> = SelectOptionGroup<TOption>,
> = FormikFieldProps<
  Omit<CellSelectProps<TOption, undefined, TIsMultiple, TUseOptionAsValue, TIsClearable, TGroup>, 'row'>
>;
 
export const FormikCellSelect = function FormikCellSelect<
  TOption extends CellSelectOption = CellSelectOption,
  TIsMultiple extends boolean | undefined = undefined,
  TUseOptionAsValue extends boolean | undefined = undefined,
  TIsClearable extends boolean | undefined = true,
  TGroup extends SelectOptionGroup<TOption> = SelectOptionGroup<TOption>,
>({ validate, ...props }: FormikCellSelectProps<TOption, TIsMultiple, TUseOptionAsValue, TIsClearable, TGroup>) {
  const { ...formikFieldProps } = useFormikFieldAdapter<
    CellSelectProps<TOption, undefined, TIsMultiple, TUseOptionAsValue, TIsClearable, TGroup>['value']
  >({
    ...props,
    validate,
  });
 
  return (
    <CellSelect
      {...props}
      {...formikFieldProps}
      row={undefined}
    />
  );
};