From 10818572324a7298fecbda8437247c5f48dde5be Mon Sep 17 00:00:00 2001
From: asimonok <sashasimonok@gmail.com>
Date: Thu, 16 Nov 2023 21:33:56 +0300
Subject: [PATCH] Fix typings

---
 src/components/ElementEditor/ElementEditor.tsx       |  4 ++--
 .../FormElementsEditor/FormElementsEditor.test.tsx   | 12 ++++++------
 src/constants/default.ts                             |  2 --
 3 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/src/components/ElementEditor/ElementEditor.tsx b/src/components/ElementEditor/ElementEditor.tsx
index e8adbd4c..a95e9a07 100644
--- a/src/components/ElementEditor/ElementEditor.tsx
+++ b/src/components/ElementEditor/ElementEditor.tsx
@@ -296,7 +296,7 @@ export const ElementEditor: React.FC<Props> = ({
               onChange={(event: ChangeEvent<HTMLInputElement>) => {
                 onChange({
                   ...element,
-                  min: ToNumberValue(event.target.value),
+                  min: event.target.value ? Number(event.target.value) : undefined,
                 });
               }}
               type="number"
@@ -311,7 +311,7 @@ export const ElementEditor: React.FC<Props> = ({
               onChange={(event: ChangeEvent<HTMLInputElement>) => {
                 onChange({
                   ...element,
-                  max: ToNumberValue(event.target.value),
+                  max: event.target.value ? Number(event.target.value) : undefined,
                 });
               }}
               type="number"
diff --git a/src/components/FormElementsEditor/FormElementsEditor.test.tsx b/src/components/FormElementsEditor/FormElementsEditor.test.tsx
index daeab74d..744b57ca 100644
--- a/src/components/FormElementsEditor/FormElementsEditor.test.tsx
+++ b/src/components/FormElementsEditor/FormElementsEditor.test.tsx
@@ -192,8 +192,8 @@ describe('Form Elements Editor', () => {
        */
       const elementSelectors = openElement(newElementId, newElementType);
 
-      expect(elementSelectors.fieldNumberMin()).toHaveValue(NumberDefault.min);
-      expect(elementSelectors.fieldNumberMax()).toHaveValue(NumberDefault.max);
+      expect(elementSelectors.fieldNumberMin()).toHaveValue(null);
+      expect(elementSelectors.fieldNumberMax()).toHaveValue(null);
     });
 
     it('Should add Code element with default parameters', async () => {
@@ -996,7 +996,7 @@ describe('Form Elements Editor', () => {
       expect(onChange).toHaveBeenCalledWith(
         expect.arrayContaining([
           expect.objectContaining({
-            min: null,
+            min: undefined,
           }),
         ])
       );
@@ -1036,7 +1036,7 @@ describe('Form Elements Editor', () => {
       expect(onChange).toHaveBeenCalledWith(
         expect.arrayContaining([
           expect.objectContaining({
-            max: null,
+            max: undefined,
           }),
         ])
       );
@@ -1380,8 +1380,8 @@ describe('Form Elements Editor', () => {
         await act(() => fireEvent.change(elementSelectors.fieldType(), { target: { value: FormElementType.NUMBER } }));
 
         expect(elementSelectors.fieldType()).toHaveValue(FormElementType.NUMBER);
-        expect(elementSelectors.fieldNumberMin()).toHaveValue(NumberDefault.min);
-        expect(elementSelectors.fieldNumberMax()).toHaveValue(NumberDefault.max);
+        expect(elementSelectors.fieldNumberMin()).toHaveValue(null);
+        expect(elementSelectors.fieldNumberMax()).toHaveValue(null);
       });
 
       it('Should set default Code options if NewType=CODE', async () => {
diff --git a/src/constants/default.ts b/src/constants/default.ts
index 0ce62f84..610c6c2a 100644
--- a/src/constants/default.ts
+++ b/src/constants/default.ts
@@ -93,8 +93,6 @@ export const SaveDefaultTextDefault = 'Save Default';
  * Number Defaults
  */
 export const NumberDefault: NumberOptions = {
-  min: null,
-  max: null,
   value: 0,
 };