From dfe6f353542ed5d971ddb196e0857166280ec7e4 Mon Sep 17 00:00:00 2001 From: brendanjbond Date: Sat, 7 Sep 2024 15:15:50 -0500 Subject: [PATCH] isPartialDay no longer returns false on empty value; type guards handle undefined components --- src/utils/date.ts | 2 +- src/utils/formUtil.ts | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/utils/date.ts b/src/utils/date.ts index f119bb40..bb3d69e9 100644 --- a/src/utils/date.ts +++ b/src/utils/date.ts @@ -138,7 +138,7 @@ export const getDateValidationFormat = (component: DayComponent) => { export const isPartialDay = (component: DayComponent, value: string | undefined) => { if (!value) { - return false; + return true; } const [DAY, MONTH, YEAR] = component.dayFirst ? [0, 1, 2] : [1, 0, 2]; const values = value.split('/'); diff --git a/src/utils/formUtil.ts b/src/utils/formUtil.ts index 94925034..97fb8c34 100644 --- a/src/utils/formUtil.ts +++ b/src/utils/formUtil.ts @@ -1129,15 +1129,15 @@ export function findComponent(components: any, key: any, path: any, fn: any) { }); } -const isCheckboxComponent = (component: Component): component is CheckboxComponent => component.type === 'checkbox'; -const isDataGridComponent = (component: Component): component is DataGridComponent => component.type === 'datagrid'; -const isEditGridComponent = (component: Component): component is EditGridComponent => component.type === 'editgrid'; -const isDataTableComponent = (component: Component): component is DataTableComponent => component.type === 'datatable'; -const hasChildComponents = (component: any): component is HasChildComponents => component.components != null; -const isDateTimeComponent = (component: Component): component is DateTimeComponent => component.type === 'datetime'; -const isSelectBoxesComponent = (component: Component): component is SelectBoxesComponent => component.type === 'selectboxes'; -const isTextAreaComponent = (component: Component): component is TextAreaComponent => component.type === 'textarea'; -const isTextFieldComponent = (component: Component): component is TextFieldComponent => component.type === 'textfield'; +const isCheckboxComponent = (component: any): component is CheckboxComponent => component?.type === 'checkbox'; +const isDataGridComponent = (component: any): component is DataGridComponent => component?.type === 'datagrid'; +const isEditGridComponent = (component: any): component is EditGridComponent => component?.type === 'editgrid'; +const isDataTableComponent = (component: any): component is DataTableComponent => component?.type === 'datatable'; +const hasChildComponents = (component: any): component is HasChildComponents => component?.components != null; +const isDateTimeComponent = (component: any): component is DateTimeComponent => component?.type === 'datetime'; +const isSelectBoxesComponent = (component: any): component is SelectBoxesComponent => component?.type === 'selectboxes'; +const isTextAreaComponent = (component: any): component is TextAreaComponent => component?.type === 'textarea'; +const isTextFieldComponent = (component: any): component is TextFieldComponent => component?.type === 'textfield'; export function getEmptyValue(component: Component) { switch (component.type) {