fix(striker-ui): add undefined to type map

main
Tsu-ba-me 2 years ago
parent a91fc0fc65
commit 13b4cabaf8
  1. 1
      striker-ui/components/InputWithRef.tsx
  2. 1
      striker-ui/lib/consts/MAP_TO_VALUE_CONVERTER.ts
  3. 1
      striker-ui/lib/isEmpty.ts
  4. 1
      striker-ui/types/MapToType.d.ts

@ -36,6 +36,7 @@ type InputForwardedRefContent<TypeName extends keyof MapToType> = {
const MAP_TO_INITIAL_VALUE: MapToType = {
number: 0,
string: '',
undefined,
};
const INPUT_WITH_REF_DEFAULT_PROPS: Required<

@ -1,6 +1,7 @@
const MAP_TO_VALUE_CONVERTER: MapToValueConverter = {
number: (value) => parseInt(String(value), 10) || 0,
string: (value) => String(value),
undefined: () => undefined,
};
export default MAP_TO_VALUE_CONVERTER;

@ -7,6 +7,7 @@ type MapToValueIsEmptyFunction = {
const MAP_TO_VALUE_IS_EMPTY_FUNCTION: MapToValueIsEmptyFunction = {
number: (value = 0) => value === 0,
string: (value = '') => value.trim().length === 0,
undefined: () => true,
};
const isEmpty = <TypeName extends keyof MapToType>(

@ -1,6 +1,7 @@
declare type MapToType = {
number: number;
string: string;
undefined: undefined;
};
declare type MapToValueConverter = {

Loading…
Cancel
Save