From ed479f13512529a2ec989de0837f9f507599bb55 Mon Sep 17 00:00:00 2001 From: Ajmal Noushad Date: Mon, 5 Feb 2024 20:38:41 +0530 Subject: [PATCH 1/3] Allow overriding `allowClear` --- src/components/DatePicker.jsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/components/DatePicker.jsx b/src/components/DatePicker.jsx index 82d16e57d..612b08b4b 100644 --- a/src/components/DatePicker.jsx +++ b/src/components/DatePicker.jsx @@ -48,6 +48,7 @@ const DatePicker = forwardRef( value, labelProps, required = false, + allowClear = true, ...otherProps }, ref @@ -149,9 +150,15 @@ const DatePicker = forwardRef( suffixIcon={} superNextIcon={} superPrevIcon={} - allowClear={{ - clearIcon: , - }} + allowClear={ + allowClear + ? { + clearIcon: ( + + ), + } + : false + } /> {!!error && typeof error === "string" && (

Date: Mon, 5 Feb 2024 20:43:11 +0530 Subject: [PATCH 2/3] Cleanup, updated types --- index.d.ts | 1 + src/components/DatePicker.jsx | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/index.d.ts b/index.d.ts index dd0e4295d..26dbb6eb0 100644 --- a/index.d.ts +++ b/index.d.ts @@ -199,6 +199,7 @@ export type DatePickerProps = { id?: string; disabled?: boolean; labelProps?: LabelProps; + allowClear?: boolean; [key: string]: any; }; diff --git a/src/components/DatePicker.jsx b/src/components/DatePicker.jsx index 612b08b4b..bcd6b4a68 100644 --- a/src/components/DatePicker.jsx +++ b/src/components/DatePicker.jsx @@ -151,13 +151,13 @@ const DatePicker = forwardRef( superNextIcon={} superPrevIcon={} allowClear={ - allowClear + allowClear === true ? { clearIcon: ( ), } - : false + : allowClear } /> {!!error && typeof error === "string" && ( @@ -251,6 +251,10 @@ DatePicker.propTypes = { * To specify whether the Date picker is required or not. */ required: PropTypes.bool, + /** + * To specify whether the Date picker value can be cleared or not. + */ + allowClear: PropTypes.bool, }; export default DatePicker; From 2b437b4fc3b6b783a6c8c377c34766aac962dd24 Mon Sep 17 00:00:00 2001 From: Ajmal Noushad Date: Mon, 5 Feb 2024 20:51:44 +0530 Subject: [PATCH 3/3] cleanup --- src/components/DatePicker.jsx | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/components/DatePicker.jsx b/src/components/DatePicker.jsx index bcd6b4a68..c172b749c 100644 --- a/src/components/DatePicker.jsx +++ b/src/components/DatePicker.jsx @@ -151,13 +151,9 @@ const DatePicker = forwardRef( superNextIcon={} superPrevIcon={} allowClear={ - allowClear === true - ? { - clearIcon: ( - - ), - } - : allowClear + allowClear && { + clearIcon: , + } } /> {!!error && typeof error === "string" && (