From 13b4cabaf81d8a9a2738894f57ce7ebd01407c17 Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Wed, 27 Jul 2022 16:18:51 -0400 Subject: [PATCH] fix(striker-ui): add undefined to type map --- striker-ui/components/InputWithRef.tsx | 1 + striker-ui/lib/consts/MAP_TO_VALUE_CONVERTER.ts | 1 + striker-ui/lib/isEmpty.ts | 1 + striker-ui/types/MapToType.d.ts | 1 + 4 files changed, 4 insertions(+) diff --git a/striker-ui/components/InputWithRef.tsx b/striker-ui/components/InputWithRef.tsx index dbca96cb..b5c5bb7b 100644 --- a/striker-ui/components/InputWithRef.tsx +++ b/striker-ui/components/InputWithRef.tsx @@ -36,6 +36,7 @@ type InputForwardedRefContent = { const MAP_TO_INITIAL_VALUE: MapToType = { number: 0, string: '', + undefined, }; const INPUT_WITH_REF_DEFAULT_PROPS: Required< diff --git a/striker-ui/lib/consts/MAP_TO_VALUE_CONVERTER.ts b/striker-ui/lib/consts/MAP_TO_VALUE_CONVERTER.ts index 20e0334d..e9943ade 100644 --- a/striker-ui/lib/consts/MAP_TO_VALUE_CONVERTER.ts +++ b/striker-ui/lib/consts/MAP_TO_VALUE_CONVERTER.ts @@ -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; diff --git a/striker-ui/lib/isEmpty.ts b/striker-ui/lib/isEmpty.ts index d4cd34c8..5e3f3608 100644 --- a/striker-ui/lib/isEmpty.ts +++ b/striker-ui/lib/isEmpty.ts @@ -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 = ( diff --git a/striker-ui/types/MapToType.d.ts b/striker-ui/types/MapToType.d.ts index 0e34996f..f234df80 100644 --- a/striker-ui/types/MapToType.d.ts +++ b/striker-ui/types/MapToType.d.ts @@ -1,6 +1,7 @@ declare type MapToType = { number: number; string: string; + undefined: undefined; }; declare type MapToValueConverter = {