From 5ca998741e978a6be402475548f0a5f4fef2def0 Mon Sep 17 00:00:00 2001 From: csandman Date: Thu, 26 Oct 2023 18:54:07 -0400 Subject: [PATCH 1/8] Simplify theme typings --- src/index.ts | 1 + src/module-augmentation.ts | 7 ++++--- src/types.ts | 12 +++++------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/index.ts b/src/index.ts index 29edbe4..2027831 100644 --- a/src/index.ts +++ b/src/index.ts @@ -18,6 +18,7 @@ export type { Size, TagVariant, SelectedOptionStyle, + ColorScheme, StylesFunction, ChakraStylesConfig, OptionBase, diff --git a/src/module-augmentation.ts b/src/module-augmentation.ts index 132519e..acec7f0 100644 --- a/src/module-augmentation.ts +++ b/src/module-augmentation.ts @@ -3,6 +3,7 @@ import type { SystemStyleObject } from "@chakra-ui/system"; import type { GroupBase, StylesConfig, ThemeConfig } from "react-select"; import type { ChakraStylesConfig, + ColorScheme, SelectedOptionStyle, SizeProp, TagVariant, @@ -86,7 +87,7 @@ declare module "react-select/base" { * @see {@link https://github.com/csandman/chakra-react-select#colorscheme} * @see {@link https://chakra-ui.com/docs/components/tag/props} */ - colorScheme?: string; + colorScheme?: ColorScheme; /** * The `variant` prop that will be forwarded to your `MultiValue` component @@ -132,12 +133,12 @@ declare module "react-select/base" { * @defaultValue `blue` * @see {@link https://github.com/csandman/chakra-react-select#selectedoptioncolorscheme--default-blue} */ - selectedOptionColorScheme?: string; + selectedOptionColorScheme?: ColorScheme; /** * @deprecated Replaced by {@link selectedOptionColorScheme} */ - selectedOptionColor?: string; + selectedOptionColor?: ColorScheme; /** * The color value to style the border of the `Control` with when the diff --git a/src/types.ts b/src/types.ts index 87cb0bc..1e8fa5d 100644 --- a/src/types.ts +++ b/src/types.ts @@ -2,6 +2,7 @@ import type { Pseudos, ResponsiveObject, SystemStyleObject, + ThemeTypings, } from "@chakra-ui/system"; import type { ClearIndicatorProps, @@ -45,16 +46,13 @@ export type Size = "sm" | "md" | "lg"; export type SizeProp = Size | ResponsiveObject | Size[]; -export type TagVariant = "subtle" | "solid" | "outline" | (string & {}); +export type TagVariant = ThemeTypings["components"]["Tag"]["variants"]; export type SelectedOptionStyle = "color" | "check"; -export type Variant = - | "outline" - | "filled" - | "flushed" - | "unstyled" - | (string & {}); +export type Variant = ThemeTypings["components"]["Input"]["variants"]; + +export type ColorScheme = ThemeTypings["colorSchemes"]; export type StylesFunction = ( provided: SystemStyleObject, From 342f8490d2d23e607e43bfe2ed5e5a8dee6ff7c0 Mon Sep 17 00:00:00 2001 From: csandman Date: Thu, 26 Oct 2023 18:55:57 -0400 Subject: [PATCH 2/8] Update doc comment links --- src/chakra-components/control.tsx | 5 +++-- src/module-augmentation.ts | 7 +++++-- src/utils.ts | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/chakra-components/control.tsx b/src/chakra-components/control.tsx index 17f4679..46b828a 100644 --- a/src/chakra-components/control.tsx +++ b/src/chakra-components/control.tsx @@ -139,7 +139,8 @@ export const IndicatorSeparator = < /** * Borrowed from the `@chakra-ui/icons` package to prevent needing it as a dependency * - * @see {@link https://github.com/chakra-ui/chakra-ui/blob/main/packages/icons/src/ChevronDown.tsx} + * @see {@link https://github.com/chakra-ui/chakra-ui/blob/61f965a/packages/components/icons/src/ChevronDown.tsx} + * @see {@link https://github.com/chakra-ui/chakra-ui/blob/61f965a/packages/components/select/src/select.tsx#L168-L179} */ export const DownChevron = (props: IconProps) => ( @@ -237,7 +238,7 @@ export const DropdownIndicator = < /** * Borrowed from Chakra UI source * - * @see {@link https://github.com/chakra-ui/chakra-ui/blob/13c6d2e08b61e179773be4722bb81173dd599306/packages/close-button/src/close-button.tsx#L14} + * @see {@link https://github.com/chakra-ui/chakra-ui/blob/61f965a/packages/components/close-button/src/close-button.tsx#L12-L21} */ export const CrossIcon = (props: IconProps) => ( diff --git a/src/module-augmentation.ts b/src/module-augmentation.ts index acec7f0..2f2b74f 100644 --- a/src/module-augmentation.ts +++ b/src/module-augmentation.ts @@ -69,11 +69,14 @@ declare module "react-select/base" { /** * If true, the form control will be required. This has 2 side effects: * - * - The `FormLabel` will show a required indicator - * - The form element (e.g, Input) will have `aria-required` set to true + * - The hidden input element will get the required attribute, triggering native form validation on submit + * - The combobox input will have `aria-required` set to true * * @see {@link https://chakra-ui.com/docs/components/input/props} * @see {@link https://chakra-ui.com/docs/components/form-control/props} + @@ -86,7 +87,7 @@ declare module "react-select/base" { + * @see {@link https://github.com/csandman/chakra-react-select#colorscheme} + * @see {@link https://chakra-ui.com/docs/components/tag/props} */ isRequired?: boolean; diff --git a/src/utils.ts b/src/utils.ts index bd941e6..520de23 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -8,7 +8,7 @@ import type { Size, SizeProp } from "./types"; * * Borrowed from the original `react-select` package * - * @see {@link https://github.com/JedWatson/react-select/blob/edf5265ee0158c026c9e8527a6d0490a5ac2ef23/packages/react-select/src/utils.ts#L75-L110} + * @see {@link https://github.com/JedWatson/react-select/blob/2f94e8d/packages/react-select/src/utils.ts#L79-L110} */ export const cleanCommonProps = < Option, From 19837d11abb5c76135e3d151cad02e7099a0567e Mon Sep 17 00:00:00 2001 From: csandman Date: Thu, 26 Oct 2023 18:58:55 -0400 Subject: [PATCH 3/8] Add other aria props missing from DownChevron --- src/chakra-components/control.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chakra-components/control.tsx b/src/chakra-components/control.tsx index 46b828a..067bf4c 100644 --- a/src/chakra-components/control.tsx +++ b/src/chakra-components/control.tsx @@ -143,7 +143,7 @@ export const IndicatorSeparator = < * @see {@link https://github.com/chakra-ui/chakra-ui/blob/61f965a/packages/components/select/src/select.tsx#L168-L179} */ export const DownChevron = (props: IconProps) => ( - +