From 29925b79767cc63340d578061fc79eda36f6671e Mon Sep 17 00:00:00 2001 From: silvioprog Date: Thu, 26 Sep 2024 12:37:44 -0300 Subject: [PATCH] refactor(Select): replace defaultProps property --- .../forms/Select/CreatableSelect.tsx | 21 +++++++++++--- src/components/forms/Select/Select.tsx | 29 +++++++++++-------- 2 files changed, 34 insertions(+), 16 deletions(-) diff --git a/src/components/forms/Select/CreatableSelect.tsx b/src/components/forms/Select/CreatableSelect.tsx index dd91b9e6b..4bb3359ae 100644 --- a/src/components/forms/Select/CreatableSelect.tsx +++ b/src/components/forms/Select/CreatableSelect.tsx @@ -6,7 +6,6 @@ import cls from 'classnames'; import { Strong } from '../../Text'; import { TextVariants } from '../../Text/Text.enums'; import { useSelectProps } from './useSelectProps'; -import Select from './Select'; import { CreatableSelectProps } from './Select.types'; import { CLX_COMPONENT } from '../../../theme/constants'; @@ -20,9 +19,25 @@ const renderCreateLabel = (createNewLabel: string) => (inputValue: string) => function CreatableSelect({ createNewLabel = 'Create', isAsync = false, + placeholder = '', + isInvalid = false, + isDisabled = false, + isClearable = false, + maxPillLabelLength = 16, + isMenuPositionRelative = false, + className = '', ...props }: CreatableSelectProps): React.ReactElement { - const selectProps = useSelectProps(props); + const selectProps = useSelectProps({ + placeholder, + isInvalid, + isDisabled, + isClearable, + maxPillLabelLength, + isMenuPositionRelative, + className, + ...props, + }); if (isAsync) { return ( @@ -43,8 +58,6 @@ function CreatableSelect({ ); } -CreatableSelect.defaultProps = Select.defaultProps; - CreatableSelect.displayName = 'CreatableSelect'; export default CreatableSelect; diff --git a/src/components/forms/Select/Select.tsx b/src/components/forms/Select/Select.tsx index 31c8adad6..8ede120ea 100644 --- a/src/components/forms/Select/Select.tsx +++ b/src/components/forms/Select/Select.tsx @@ -9,10 +9,25 @@ import { CLX_COMPONENT } from '../../../theme/constants'; function Select({ isAsync = false, + placeholder = '', + isInvalid = false, + isDisabled = false, + isClearable = false, + maxPillLabelLength = 16, + isMenuPositionRelative = false, + className = '', ...props }: SelectProps): React.ReactElement { - const selectProps = useSelectProps(props); - const { className } = props; + const selectProps = useSelectProps({ + placeholder, + isInvalid, + isDisabled, + isClearable, + maxPillLabelLength, + isMenuPositionRelative, + className, + ...props, + }); if (isAsync) { return ( @@ -28,16 +43,6 @@ function Select({ ); } -Select.defaultProps = { - placeholder: '', - isInvalid: false, - isDisabled: false, - isClearable: false, - maxPillLabelLength: 16, - isMenuPositionRelative: false, - className: '', -}; - Select.displayName = 'Select'; export default Select;