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 = { const MAP_TO_INITIAL_VALUE: MapToType = {
number: 0, number: 0,
string: '', string: '',
undefined,
}; };
const INPUT_WITH_REF_DEFAULT_PROPS: Required< const INPUT_WITH_REF_DEFAULT_PROPS: Required<

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

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

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

Loading…
Cancel
Save