From e926f5babb77e7f1bf9622ef85681be08fbd1e8a Mon Sep 17 00:00:00 2001 From: Haider Alshamma Date: Tue, 31 Dec 2024 16:05:10 -0500 Subject: [PATCH] chore: better and more accurate types --- src/AsyncSelect/AsyncSelect.tsx | 3 ++- src/AsyncSelect/AsyncSelectComponents.tsx | 10 +--------- src/Select/Select.tsx | 14 ++++---------- src/Select/SelectOption.tsx | 20 +++++--------------- src/Select/customReactSelectStyles.tsx | 11 ++++++++--- 5 files changed, 20 insertions(+), 38 deletions(-) diff --git a/src/AsyncSelect/AsyncSelect.tsx b/src/AsyncSelect/AsyncSelect.tsx index 43e83afd7..231f74a25 100644 --- a/src/AsyncSelect/AsyncSelect.tsx +++ b/src/AsyncSelect/AsyncSelect.tsx @@ -81,7 +81,6 @@ const AsyncSelect = forwardRef( defaultOptions, loadOptions, isClearable, - variant, iconLeft, ...props }: AsyncSelectProps, @@ -91,6 +90,7 @@ const AsyncSelect = forwardRef( | null ) => { const { t } = useTranslation(); + const variant = useComponentVariant(); const theme = useTheme(); const spaceProps = getSubset(props, propTypes.space); const error = !!(errorMessage || errorList); @@ -112,6 +112,7 @@ const AsyncSelect = forwardRef( hasIcon: Boolean(iconLeft), theme, error, + variant, maxHeight, windowed: false, hasDefaultOptions: Boolean(defaultOptions), diff --git a/src/AsyncSelect/AsyncSelectComponents.tsx b/src/AsyncSelect/AsyncSelectComponents.tsx index a1bce426a..824ee99d8 100644 --- a/src/AsyncSelect/AsyncSelectComponents.tsx +++ b/src/AsyncSelect/AsyncSelectComponents.tsx @@ -12,7 +12,6 @@ import { import { components, GroupBase } from "react-select"; import { OptionProps } from "react-select"; import { IconName } from "@nulogy/icons"; -import { useComponentVariant } from "../NDSProvider/ComponentVariantContext"; import type { ComponentVariant } from "../NDSProvider/ComponentVariantContext"; import { StyledOption } from "../Select/SelectOption"; import { InputIcon } from "../Icon/Icon"; @@ -106,15 +105,8 @@ export const SelectMenu = >( props: OptionProps & { variant?: ComponentVariant } ) { - const variant = useComponentVariant(props.variant); - return ( - + {props.children} ); diff --git a/src/Select/Select.tsx b/src/Select/Select.tsx index 6086d7d06..0b7ffea5d 100644 --- a/src/Select/Select.tsx +++ b/src/Select/Select.tsx @@ -8,9 +8,9 @@ import { Field } from "../Form"; import { MaybeFieldLabel } from "../FieldLabel"; import { InlineValidation } from "../Validation"; import customStyles from "../Select/customReactSelectStyles"; +import { useComponentVariant } from "../NDSProvider/ComponentVariantContext"; import { getSubset } from "../utils/subset"; import { addStyledProps, StyledProps } from "../StyledProps"; -import { ComponentVariant, useComponentVariant } from "../NDSProvider/ComponentVariantContext"; import { SelectControl, SelectMultiValue, @@ -35,7 +35,6 @@ interface CustomProps