Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
refactor: select component - part 6
Brad Barbin83514f0f0807
diff --git a/apps/carbon/app/components/Combobox.tsx b/apps/carbon/app/components/Combobox.tsxindex e383ae3f0d..8f10995eda 100644--- a/apps/carbon/app/components/Combobox.tsx+++ b/apps/carbon/app/components/Combobox.tsx@@ -58,9 +58,13 @@ const Combobox = forwardRef<HTMLButtonElement, ComboboxProps>(ref={ref}{...props}>- {value- ? options.find((option) => option.value === value)?.label- : placeholder ?? "Select"}+ {value ? (+ options.find((option) => option.value === value)?.label+ ) : (+ <span className="text-muted-foreground">+ {placeholder ?? "Select"}+ </span>+ )}</CommandTrigger></PopoverTrigger><PopoverContent className="min-w-[200px] w-[--radix-popover-trigger-width] p-0">diff --git a/apps/carbon/app/components/Form/Abilities.tsx b/apps/carbon/app/components/Form/Abilities.tsxindex 859e4a0150..fe9de803f3 100644--- a/apps/carbon/app/components/Form/Abilities.tsx+++ b/apps/carbon/app/components/Form/Abilities.tsx@@ -1,41 +1,14 @@-import type { MultiValue } from "@carbon/react";-import {- FormControl,- FormErrorMessage,- FormHelperText,- FormLabel,- ReactSelect,- useMount,-} from "@carbon/react";+import { useMount } from "@carbon/react";import { useFetcher } from "@remix-run/react";import { useMemo } from "react";-import { useControlField, useField } from "remix-validated-form";import type { getAbilitiesList } from "~/modules/resources";import { path } from "~/utils/path";-import type { SelectProps } from "./Select";+import type { MultiSelectProps } from "./MultiSelect";+import MultiSelect from "./MultiSelect";-type AbilitiesSelectProps = Omit<SelectProps, "options" | "onChange"> & {- onChange?: (- selections: MultiValue<{- value: string;- label: string;- }>- ) => void;-};--const Abilities = ({- name,- label = "Abilities",- helperText,- isLoading,- isReadOnly,- placeholder = "Select Abilities",- onChange,- ...props-}: AbilitiesSelectProps) => {- const { error } = useField(name);- const [value, setValue] = useControlField<string[]>(name);+type AbilitiesSelectProps = Omit<MultiSelectProps, "options" | "value">;+const Abilities = (props: AbilitiesSelectProps) => {const abilityFetcher =useFetcher<Awaited<ReturnType<typeof getAbilitiesList>>>();@@ -54,45 +27,12 @@ const Abilities = ({[abilityFetcher.data]);- const handleChange = (- selections: MultiValue<{ value: string; label: string }>- ) => {- const newValue = selections.map((s) => s.value as string) || [];- setValue(newValue);- onChange?.(selections);- };-- const controlledValue = useMemo(- () => options?.filter((option) => value?.includes(option.value)) ?? [],- [value, options]- );-return (- <FormControl isInvalid={!!error}>- {label && <FormLabel htmlFor={name}>{label}</FormLabel>}- {value.map((selection, index) => (- <input- key={`${name}[${index}]`}- type="hidden"- name={`${name}[${index}]`}- value={selection}- />- ))}- <ReactSelect- {...props}- isMulti- value={controlledValue}- isLoading={isLoading}- options={options}- placeholder={placeholder}- onChange={handleChange}- />- {error ? (- <FormErrorMessage>{error}</FormErrorMessage>- ) : (- helperText && <FormHelperText>{helperText}</FormHelperText>- )}- </FormControl>+ <MultiSelect+ options={options}+ {...props}+ label={props?.label ?? "Ability"}+ />);};diff --git a/apps/carbon/app/components/Form/MultiSelect.tsx b/apps/carbon/app/components/Form/MultiSelect.tsxnew file mode 100644index 0000000000..0bf2423251--- /dev/null+++ b/apps/carbon/app/components/Form/MultiSelect.tsx@@ -0,0 +1,67 @@+import {+ FormControl,+ FormErrorMessage,+ FormHelperText,+ FormLabel,+} from "@carbon/react";++import { useControlField, useField } from "remix-validated-form";+import { MultiSelect as MultiSelectBase } from "~/components";+import type { MultiSelectProps as MultiSelectBaseProps } from "~/components/MultiSelect";++export type MultiSelectProps = Omit<+ MultiSelectBaseProps,+ "onChange" | "value"+> & {+ name: string;+ label?: string;+ helperText?: string;+ onChange?: (newValue: { value: string; label: string }[]) => void;+};++const MultiSelect = ({+ name,+ label,+ helperText,+ ...props+}: MultiSelectProps) => {+ const { error } = useField(name);+ const [value, setValue] = useControlField<string[]>(name);++ const onChange = (value: string[]) => {+ props?.onChange?.(props.options.filter((o) => value.includes(o.value)));+ };++ return (+ <FormControl isInvalid={!!error}>+ {label && <FormLabel htmlFor={name}>{label}</FormLabel>}+ {value.filter(Boolean).map((selection, index) => (+ <input+ key={`${name}[${index}]`}+ type="hidden"+ name={`${name}[${index}]`}+ value={selection}+ />+ ))}+ <MultiSelectBase+ {...props}+ value={value.filter(Boolean)}+ onChange={(newValue) => {+ setValue(newValue ?? "");+ onChange(newValue ?? "");+ }}+ className="w-full"+ />++ {error ? (+ <FormErrorMessage>{error}</FormErrorMessage>+ ) : (+ helperText && <FormHelperText>{helperText}</FormHelperText>+ )}+ </FormControl>+ );+};++MultiSelect.displayName = "MultiSelect";++export default MultiSelect;diff --git a/apps/carbon/app/components/Form/Timezone.tsx b/apps/carbon/app/components/Form/Timezone.tsxindex 29248b3d4c..720ade95c4 100644--- a/apps/carbon/app/components/Form/Timezone.tsx+++ b/apps/carbon/app/components/Form/Timezone.tsx@@ -3,65 +3,253 @@ import {FormErrorMessage,FormHelperText,FormLabel,- ReactSelect as SelectBase,- createFilter,+ HStack,+ IconButton,+ Select as SelectBase,+ SelectContent,+ SelectGroup,+ SelectItem,+ SelectLabel,+ SelectTrigger,+ SelectValue,} from "@carbon/react";-import { useMemo } from "react";-import { useField } from "remix-validated-form";-import { timezonesGroupedByCountry } from "~/config/timezones";+import { MdClose } from "react-icons/md";+import { useControlField, useField } from "remix-validated-form";+import {} from "~/components";+import type { SelectProps } from "./Select";-export type TimezoneProps = {- name: string;- label?: string;- helperText?: string;- isReadOnly?: boolean;- isLoading?: boolean;- placeholder?: string;- onChange?: (- newValue: { value: string | number; label: string } | null- ) => void;+const timezones: {+ label: string;+ options: {+ label: string;+ value: string;+ }[];+}[] = [+ {+ label: "North America",+ options: [+ {+ label: "Eastern Time",+ value: "America/New_York",+ },+ {+ label: "Central Time",+ value: "America/Chicago",+ },+ {+ label: "Mountain Time",+ value: "America/Denver",+ },+ {+ label: "Pacific Time",+ value: "America/Los_Angeles",+ },+ {+ label: "Alaska Time",+ value: "America/Anchorage",+ },+ {+ label: "Hawaii Time",+ value: "Pacific/Honolulu",+ },+ ],+ },+ {+ label: "Europe & Africa",+ options: [+ {+ label: "Greenwich Mean Time",+ value: "Europe/London",+ },+ {+ label: "Central European Time",+ value: "Europe/Berlin",+ },+ {+ label: "Eastern European Time",+ value: "Europe/Moscow",+ },+ {+ label: "Western European Summer Time",+ value: "Europe/Lisbon",+ },+ {+ label: "Central Africa Time",+ value: "Africa/Nairobi",+ },+ {+ label: "East Africa Time",+ value: "Africa/Addis_Ababa",+ },+ {+ label: "South Africa Standard Time",+ value: "Africa/Johannesburg",+ },+ ],+ },+ {+ label: "Asia",+ options: [+ {+ label: "Moscow Standard Time",+ value: "Europe/Moscow",+ },+ {+ label: "India Standard Time",+ value: "Asia/Kolkata",+ },+ {+ label: "China Standard Time",+ value: "Asia/Shanghai",+ },+ {+ label: "Japan Standard Time",+ value: "Asia/Tokyo",+ },+ {+ label: "Korea Standard Time",+ value: "Asia/Seoul",+ },+ {+ label: "Singapore Standard Time",+ value: "Asia/Singapore",+ },+ {+ label: "Australia Eastern Time",+ value: "Australia/Sydney",+ },+ {+ label: "Australia Central Time",+ value: "Australia/Darwin",+ },+ {+ label: "Australia Western Time",+ value: "Australia/Perth",+ },+ {+ label: "Indonesia Standard Time",+ value: "Asia/Jakarta",+ },+ ],+ },+ {+ label: "Australia & Pacific",+ options: [+ {+ label: "Australia Eastern Time",+ value: "Australia/Sydney",+ },+ {+ label: "Australia Central Time",+ value: "Australia/Darwin",+ },+ {+ label: "Australia Western Time",+ value: "Australia/Perth",+ },+ {+ label: "New Zealand Standard Time",+ value: "Pacific/Auckland",+ },+ {+ label: "Fiji Time",+ value: "Pacific/Fiji",+ },+ ],+ },+ {+ label: "South America",+ options: [+ {+ label: "Brasilia Time",+ value: "America/Sao_Paulo",+ },+ {+ label: "Argentina Time",+ value: "America/Argentina/Buenos_Aires",+ },+ {+ label: "Chile Time",+ value: "America/Santiago",+ },+ {+ label: "Peru Time",+ value: "America/Lima",+ },+ {+ label: "Colombia Time",+ value: "America/Bogota",+ },+ {+ label: "Venezuela Time",+ value: "America/Caracas",+ },+ ],+ },+];++type TimezoneProps = Omit<SelectProps, "options"> & {+ size: "sm" | "md" | "lg";};const Timezone = ({name,label,helperText,- isLoading,isReadOnly,+ isClearable,placeholder,- onChange,+ size,...props}: TimezoneProps) => {- const { getInputProps, error, defaultValue } = useField(name);- const initialValue = useMemo(- () =>- timezonesGroupedByCountry- .flatMap((group) => group.options)- .find((option) => option.value === defaultValue),- [defaultValue]- );+ const { getInputProps, error } = useField(name);+ const [value, setValue] = useControlField<string | undefined>(name);return (<FormControl isInvalid={!!error}>{label && <FormLabel htmlFor={name}>{label}</FormLabel>}- <SelectBase+ <input{...getInputProps({- // @ts-ignoreid: name,})}- {...props}- defaultValue={initialValue}- isReadOnly={isReadOnly}- isLoading={isLoading}- options={timezonesGroupedByCountry}- // Only search the labels (not the values)- filterOption={createFilter({- matchFrom: "any",- stringify: (option) => `${option.label}`,- })}- placeholder={placeholder ?? "Select a timezone"}- onChange={onChange ?? undefined}+ type="hidden"+ name={name}+ id={name}+ value={value ?? undefined}/>+ <HStack spacing={1}>+ <SelectBase+ value={value}+ onValueChange={(value) => setValue(value)}+ disabled={isReadOnly}+ >+ <SelectTrigger size={size} className="min-w-[160px]">+ <SelectValue placeholder={placeholder} />+ </SelectTrigger>+ <SelectContent>+ {timezones.map(({ label, options }) => (+ <SelectGroup key={label}>+ <SelectLabel>{label}</SelectLabel>+ {options.map((option) => (+ <SelectItem key={option.value} value={option.value}>+ {option.label}+ </SelectItem>+ ))}+ </SelectGroup>+ ))}+ </SelectContent>+ </SelectBase>+ {isClearable && !isReadOnly && value && (+ <IconButton+ variant="ghost"+ aria-label="Clear"+ icon={<MdClose />}+ onClick={() => setValue("")}+ size={size === "sm" ? "md" : size}+ />+ )}+ </HStack>+{error ? (<FormErrorMessage>{error}</FormErrorMessage>) : (diff --git a/apps/carbon/app/components/MultiSelect.tsx b/apps/carbon/app/components/MultiSelect.tsxnew file mode 100644index 0000000000..ff29a1dc30--- /dev/null+++ b/apps/carbon/app/components/MultiSelect.tsx@@ -0,0 +1,129 @@+import {+ Badge,+ Button,+ Command,+ CommandEmpty,+ CommandGroup,+ CommandInput,+ CommandItem,+ Popover,+ PopoverContent,+ PopoverTrigger,+ cn,+ multiSelectTriggerVariants,+} from "@carbon/react";+import type { ComponentPropsWithoutRef } from "react";+import { forwardRef, useState } from "react";+import { MdClose } from "react-icons/md";+import { RxCheck, RxMagnifyingGlass } from "react-icons/rx";++export type MultiSelectProps = Omit<+ ComponentPropsWithoutRef<"button">,+ "onChange" | "value"+> & {+ size?: "sm" | "md" | "lg";+ value: string[];+ options: {+ label: string;+ value: string;+ }[];+ isReadOnly?: boolean;+ placeholder?: string;+ onChange: (selected: string[]) => void;+};++const MultiSelect = forwardRef<HTMLButtonElement, MultiSelectProps>(+ (+ { size, value, options, isReadOnly, placeholder, onChange, ...props },+ ref+ ) => {+ const [open, setOpen] = useState(false);++ const handleUnselect = (item: string) => {+ onChange(value.filter((i) => i !== item));+ };++ const hasSelections = value.length > 0;++ return (+ <Popover>+ <PopoverTrigger asChild>+ <Button+ variant="secondary"+ role="combobox"+ aria-expanded={open}+ className={cn(multiSelectTriggerVariants({ size, hasSelections }))}+ onClick={() => setOpen(!open)}+ >+ {hasSelections ? (+ <div className="flex gap-1 flex-wrap">+ {value.map((item) => (+ <Badge+ key={item}+ variant="secondary"+ onClick={() => handleUnselect(item)}+ >+ {options.find((option) => option.value === item)?.label}+ <button+ className="ml-1 ring-offset-background rounded-full outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2"+ onKeyDown={(e) => {+ if (e.key === "Enter") {+ handleUnselect(item);+ }+ }}+ onMouseDown={(e) => {+ e.preventDefault();+ e.stopPropagation();+ }}+ onClick={() => handleUnselect(item)}+ >+ <MdClose className="h-3 w-3 text-muted-foreground hover:text-foreground" />+ </button>+ </Badge>+ ))}+ </div>+ ) : (+ <span className="text-muted-foreground">+ {placeholder ?? "Select"}+ </span>+ )}++ <RxMagnifyingGlass className="h-4 w-4 shrink-0 opacity-50" />+ </Button>+ </PopoverTrigger>+ <PopoverContent className="min-w-[200px] w-[--radix-popover-trigger-width] p-0">+ <Command>+ <CommandInput placeholder="Search..." className="h-9" />+ <CommandEmpty>No option found.</CommandEmpty>+ <CommandGroup className="max-h-64 overflow-auto">+ {options.map((option) => (+ <CommandItem+ key={option.value}+ onSelect={() => {+ onChange(+ value.includes(option.value)+ ? value.filter((item) => item !== option.value)+ : [...value, option.value]+ );+ setOpen(true);+ }}+ >+ <RxCheck+ className={cn(+ "mr-2 h-4 w-4",+ value.includes(option.value) ? "opacity-100" : "opacity-0"+ )}+ />+ {option.label}+ </CommandItem>+ ))}+ </CommandGroup>+ </Command>+ </PopoverContent>+ </Popover>+ );+ }+);+MultiSelect.displayName = "MultiSelect";++export default MultiSelect;diff --git a/apps/carbon/app/components/index.ts b/apps/carbon/app/components/index.tsindex eb56862b9a..790859306d 100644--- a/apps/carbon/app/components/index.ts+++ b/apps/carbon/app/components/index.ts@@ -3,7 +3,17 @@ import Avatar from "./Avatar";import Combobox from "./Combobox";import Contact from "./Contact";import CreatableCombobox from "./CreateableCombobox";+import MultiSelect from "./MultiSelect";import Select from "./Select";import Table from "./Table";-export { Address, Avatar, Combobox, Contact, CreatableCombobox, Select, Table };+export {+ Address,+ Avatar,+ Combobox,+ Contact,+ CreatableCombobox,+ MultiSelect,+ Select,+ Table,+};diff --git a/packages/react/src/Badge.tsx b/packages/react/src/Badge.tsxnew file mode 100644index 0000000000..6d6f79c9bb--- /dev/null+++ b/packages/react/src/Badge.tsx@@ -0,0 +1,36 @@+import { cva, type VariantProps } from "class-variance-authority";+import type { HTMLAttributes } from "react";++import { cn } from "~/utils/cn";++const badgeVariants = cva(+ "inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",+ {+ variants: {+ variant: {+ default:+ "border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",+ secondary:+ "border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",+ destructive:+ "border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",+ outline: "text-foreground",+ },+ },+ defaultVariants: {+ variant: "default",+ },+ }+);++export interface BadgeProps+ extends HTMLAttributes<HTMLDivElement>,+ VariantProps<typeof badgeVariants> {}++function Badge({ className, variant, ...props }: BadgeProps) {+ return (+ <div className={cn(badgeVariants({ variant }), className)} {...props} />+ );+}++export { Badge, badgeVariants };diff --git a/packages/react/src/Command.tsx b/packages/react/src/Command.tsxindex 259ecc24fe..fc5f4a98a6 100644--- a/packages/react/src/Command.tsx+++ b/packages/react/src/Command.tsx@@ -187,6 +187,59 @@ const commandTriggerVariants = cva(});+export const multiSelectTriggerVariants = cva(+ "w-full justify-between font-normal",+ {+ variants: {+ size: {+ lg: "text-base",+ md: "text-base",+ sm: "text-sm",+ },+ hasSelections: {+ true: "h-full",+ false: "",+ },+ },+ compoundVariants: [+ {+ size: "lg",+ hasSelections: true,+ class: "py-3 px-4",+ },+ {+ size: "lg",+ hasSelections: false,+ class: "h-12",+ },+ {+ size: "md",+ hasSelections: true,+ class: "py-2 px-3",+ },+ {+ size: "md",+ hasSelections: false,+ class: "h-10",+ },+ {+ size: "sm",+ hasSelections: true,+ class: "py-1 px-2",+ },+ {+ size: "sm",+ hasSelections: false,+ class: "h-8",+ },+ ],+ defaultVariants: {+ size: "md",+ hasSelections: false,+ },+ }+);+interface CommandTriggerPropsextends ComponentPropsWithoutRef<"button">,VariantProps<typeof commandTriggerVariants> {}diff --git a/packages/react/src/ReactSelect/components/containers.tsx b/packages/react/src/ReactSelect/components/containers.tsxdeleted file mode 100644index 98a464fb02..0000000000--- a/packages/react/src/ReactSelect/components/containers.tsx+++ /dev/null@@ -1,137 +0,0 @@-import { cva } from "class-variance-authority";-import clsx from "clsx";-import type {- ContainerProps,- GroupBase,- IndicatorsContainerProps,- ValueContainerProps,-} from "react-select";-import { cn } from "~/utils/cn";--export const SelectContainer = <- Option,- IsMulti extends boolean,- Group extends GroupBase<Option>->(- props: ContainerProps<Option, IsMulti, Group>-) => {- const {- children,- className,- innerProps,- isDisabled,- isRtl,- hasValue,- selectProps: { maxW, minW, w },- } = props;-- return (- <div- {...innerProps}- className={clsx(- "relative",- {- rtl: isRtl,- "cursor-not-allowed": isDisabled,- "--is-disabled": isDisabled,- "--is-rtl": isRtl,- "--has-value": hasValue,- },- className- )}- style={{- maxWidth: maxW,- minWidth: minW,- width: w,- }}- >- {children}- </div>- );-};--const valueContainerVariants = cva(- "flex items-center flex-1 py-0.5 flex-wrap relative overflow-hidden value-container",- {- variants: {- size: {- lg: "px-4 text-lg",- md: "px-4 text-base",- sm: "px-3 text-sm",- },- isReadOnly: {- true: "bg-muted",- },- isMulti: {- true: "value-container--is-multi",- },- hasValue: {- true: "value-container--has-value",- },- },- defaultVariants: {- size: "md",- isReadOnly: false,- isMulti: false,- },- }-);--export const ValueContainer = <- Option,- IsMulti extends boolean,- Group extends GroupBase<Option>->(- props: ValueContainerProps<Option, IsMulti, Group>-) => {- const {- children,- className,- isMulti,- hasValue,- innerProps,- selectProps: { size, isReadOnly },- } = props;-- return (- <div- {...innerProps}- className={cn(- valueContainerVariants({ size, isReadOnly, isMulti, hasValue }),- className- )}- >- {children}- </div>- );-};--export const IndicatorsContainer = <- Option,- IsMulti extends boolean,- Group extends GroupBase<Option>->(- props: IndicatorsContainerProps<Option, IsMulti, Group>-) => {- const {- children,- className,- innerProps,- selectProps: { isReadOnly },- } = props;-- return (- <div- {...innerProps}- className={clsx(- "flex items-center self-stretch shrink-0 indicators",- {- "bg-muted": isReadOnly,- },- className- )}- >- {children}- </div>- );-};diff --git a/packages/react/src/ReactSelect/components/control.tsx b/packages/react/src/ReactSelect/components/control.tsxdeleted file mode 100644index 26f3de8299..0000000000--- a/packages/react/src/ReactSelect/components/control.tsx+++ /dev/null@@ -1,238 +0,0 @@-import { cva } from "class-variance-authority";-import { MdClose, MdKeyboardArrowDown } from "react-icons/md";-import type {- ClearIndicatorProps,- ControlProps,- DropdownIndicatorProps,- GroupBase,- IndicatorSeparatorProps,- LoadingIndicatorProps,-} from "react-select";-import { cn } from "~/utils/cn";-import { dataAttr } from "~/utils/dom";--const controlVariants = cva(- "bg-background relative flex items-center justify-between flex-wrap p-0 overflow-hidden min-w-[180px] shadow-sm focus-within:outline-none ring-1 ring-border focus-within:ring-1 focus-within:ring-ring control",- {- variants: {- size: {- lg: "h-12 rounded-lg",- md: "h-10 rounded-md",- sm: "h-8 rounded",- },- w: {- full: "w-full",- },- isDisabled: {- true: "opacity-50 disabled:cursor-not-allowed pointer-events-none control--is-disabled",- },- isReadOnly: {- true: "bg-muted",- },- isInvalid: {- true: "ring-destructive focus-within:ring-offset-1 focus-within:ring-2 focus-within:ring-destructive",- },- isFocused: {- true: "control--is-focused",- },- menuIsOpen: {- true: "control--menu-is-open",- },- },- defaultVariants: {- size: "md",- isDisabled: false,- isReadOnly: false,- isInvalid: false,- isFocused: false,- menuIsOpen: false,- },- }-);--const Control = <- Option,- IsMulti extends boolean,- Group extends GroupBase<Option>->(- props: ControlProps<Option, IsMulti, Group>-) => {- const {- className,- children,- innerRef,- innerProps,- isDisabled,- isFocused,- menuIsOpen,- selectProps: { size, isInvalid, isReadOnly, w },- } = props;-- return (- <div- ref={innerRef}- className={cn(- controlVariants({- size,- isDisabled,- isReadOnly,- isInvalid,- isFocused,- menuIsOpen,- }),- className- )}- {...innerProps}- data-focus={isFocused ? dataAttr(true) : undefined}- data-focus-visible={isFocused ? dataAttr(true) : undefined}- data-invalid={isInvalid ? dataAttr(true) : undefined}- data-disabled={isDisabled ? dataAttr(true) : undefined}- aria-readonly={isReadOnly ? dataAttr(true) : undefined}- style={{- width: typeof w === "number" ? `${w}px` : undefined,- }}- >- {children}- </div>- );-};--export const IndicatorSeparator = <- Option,- IsMulti extends boolean,- Group extends GroupBase<Option>->(- props: IndicatorSeparatorProps<Option, IsMulti, Group>-) => {- return <div className="hidden" />;-};--const dropdownIndicatorVariants = cva(- "flex items-center justify-center h-full border-0 mr-2 ml-1 indicator dropdown-indicator",- {- variants: {- size: {- lg: "text-2xl",- md: "text-xl",- sm: "text-lg",- },- },- defaultVariants: {- size: "md",- },- }-);--export const DropdownIndicator = <- Option,- IsMulti extends boolean,- Group extends GroupBase<Option>->(- props: DropdownIndicatorProps<Option, IsMulti, Group>-) => {- const {- children,- className,- innerProps,- selectProps: { size },- } = props;-- return (- <div- {...innerProps}- className={cn(dropdownIndicatorVariants({ size }), className)}- >- {children || <MdKeyboardArrowDown />}- </div>- );-};--const clearIndicatorVariants = cva(- "flex items-center justify-center h-full border-0 mx-1 flex-shrink-0 indicator clear-indicator cursor-pointer",- {- variants: {- size: {- lg: "text-2xl",- md: "text-xl",- sm: "text-lg",- },- },- defaultVariants: {- size: "md",- },- }-);--export const ClearIndicator = <- Option,- IsMulti extends boolean,- Group extends GroupBase<Option>->(- props: ClearIndicatorProps<Option, IsMulti, Group>-) => {- const {- children,- className,- innerProps,- selectProps: { size },- } = props;-- return (- <div- role="button"- className={cn(clearIndicatorVariants({ size }), className)}- aria-label="Clear selected options"- {...innerProps}- >- {children || <MdClose />}- </div>- );-};--const loadingIndicatorVariants = cva(- "animate-spin inline-block mx-1 text-muted-foreground indicator loading-indicator",- {- variants: {- size: {- lg: "h-6 w-6",- md: "h-5 w-5",- sm: "h-4 w-4",- },- },- defaultVariants: {- size: "md",- },- }-);--export const LoadingIndicator = <- Option,- IsMulti extends boolean,- Group extends GroupBase<Option>->(- props: LoadingIndicatorProps<Option, IsMulti, Group>-) => {- const {- className,- selectProps: { size },- } = props;-- return (- <svg- xmlns="http://www.w3.org/2000/svg"- width="24"- height="24"- viewBox="0 0 24 24"- fill="none"- stroke="currentColor"- strokeWidth="2"- strokeLinecap="round"- strokeLinejoin="round"- className={cn(loadingIndicatorVariants({ size }), className)}- >- <path d="M21 12a9 9 0 1 1-6.219-8.56"></path>- </svg>- );-};--export default Control;diff --git a/packages/react/src/ReactSelect/components/index.tsx b/packages/react/src/ReactSelect/components/index.tsxdeleted file mode 100644index 0efecf65a1..0000000000--- a/packages/react/src/ReactSelect/components/index.tsx+++ /dev/null@@ -1,54 +0,0 @@-import {- IndicatorsContainer,- SelectContainer,- ValueContainer,-} from "./containers";-import Control, {- ClearIndicator,- DropdownIndicator,- IndicatorSeparator,- LoadingIndicator,-} from "./control";-import Input from "./input";-// import Menu, {-// Group,-// GroupHeading,-// LoadingMessage,-// MenuList,-// NoOptionsMessage,-// Option,-// } from "./menu";-// import MultiValue, {-// MultiValueContainer,-// MultiValueLabel,-// MultiValueRemove,-// } from "./multi-value";-// import Placeholder from "./placeholder";-// import SingleValue from "./single-value";--const carbonComponents = {- ClearIndicator,- Control,- DropdownIndicator,- // Group,- // GroupHeading,- IndicatorSeparator,- IndicatorsContainer,- Input,- LoadingIndicator,- // LoadingMessage,- // Menu,- // MenuList,- // MultiValue,- // MultiValueContainer,- // MultiValueLabel,- // MultiValueRemove,- // NoOptionsMessage,- // Option,- // Placeholder,- SelectContainer,- // SingleValue,- ValueContainer,-};--export default carbonComponents;diff --git a/packages/react/src/ReactSelect/components/input.tsx b/packages/react/src/ReactSelect/components/input.tsxdeleted file mode 100644index adba3faa98..0000000000--- a/packages/react/src/ReactSelect/components/input.tsx+++ /dev/null@@ -1,57 +0,0 @@-import { cva } from "class-variance-authority";-import type { GroupBase, InputProps } from "react-select";-import { cn } from "~/utils/cn";-import { cleanCommonProps } from "../utils";--const inputVariants = cva(- "color-inherit background-0 w-full outline-0 focus-visible:outline-0 focus-visible:ring-0",- {- variants: {- isHidden: {- true: "opacity-0 pointer-events-none",- false: "opacity-100 pointer-events-auto",- },- },- defaultVariants: {- isHidden: false,- },- }-);--const Input = <- Option,- IsMulti extends boolean,- Group extends GroupBase<Option>->(- props: InputProps<Option, IsMulti, Group>-) => {- const {- className,- value,- selectProps: { isReadOnly, isRequired },- } = props;- const { innerRef, isDisabled, isHidden, inputClassName, ...innerProps } =- cleanCommonProps(props);-- return (- <div- className={cn(- "flex-1 inline-grid grid-area-[1 / 1 / 2 / 3] mx-[0.5] py-1 text-inherit min-w-[2px] border-0 margin-0 outline-0 after:content-[attr(data-value) ' '] after:visibility-hidden after:whitespace-pre after:px-0 after:py-0",- className- )}- data-value={value || ""}- >- <input- className={cn(inputVariants({ isHidden }), inputClassName)}- ref={innerRef}- disabled={isDisabled}- readOnly={isReadOnly ? true : undefined}- aria-readonly={isReadOnly ? true : undefined}- aria-required={isRequired ? true : undefined}- {...innerProps}- />- </div>- );-};--export default Input;diff --git a/packages/react/src/ReactSelect/components/menu.tsx b/packages/react/src/ReactSelect/components/menu.tsxdeleted file mode 100644index 2341a75227..0000000000--- a/packages/react/src/ReactSelect/components/menu.tsx+++ /dev/null@@ -1,497 +0,0 @@-import { Box } from "@chakra-ui/layout";-import { Menu as ChakraMenu, MenuIcon } from "@chakra-ui/menu";-import type { PropsOf, SystemStyleObject } from "@chakra-ui/system";-import { useColorModeValue, useMultiStyleConfig } from "@chakra-ui/system";-import React from "react";-import type {- CoercedMenuPlacement,- GroupBase,- GroupHeadingProps,- GroupProps,- MenuListProps,- MenuProps,- NoticeProps,- OptionProps,-} from "react-select";-import { FixedSizeList as List } from "react-window";-import type { SizeProps, ThemeObject } from "../types";-import { useSize } from "../utils";--const alignToControl = (placement: CoercedMenuPlacement) => {- const placementToCSSProp = { bottom: "top", top: "bottom" };- return placement ? placementToCSSProp[placement] : "top";-};--const Menu = <Option, IsMulti extends boolean, Group extends GroupBase<Option>>(- props: MenuProps<Option, IsMulti, Group>-) => {- const { className, cx, children, innerProps, innerRef, placement } = props;-- const initialSx: SystemStyleObject = {- position: "absolute",- [alignToControl(placement)]: "100%",- marginY: "8px",- width: "100%",- zIndex: 1,- };-- const sx = initialSx;-- return (- <ChakraMenu>- <Box- {...innerProps}- ref={innerRef}- className={cx({ menu: true }, className)}- sx={sx}- >- {children}- </Box>- </ChakraMenu>- );-};--export default Menu;--const MenuItemHeightBySize = {- sm: 31,- md: 37,- lg: 43,-} as const;--interface OptionTypeBase {- [key: string]: any;-}--export const MenuList = <- Option,- IsMulti extends boolean,- Group extends GroupBase<Option>->(- props: MenuListProps<Option, IsMulti, Group>-) => {- const {- className,- cx,- innerRef,- maxHeight,- isMulti,- innerProps,- selectProps: { size: sizeProp },- } = props;-- const list = React.useRef<List>(null);- const menuStyles = useMultiStyleConfig("Menu");-- // We're pulling in the border radius from the theme for the input component- // so we can match the menu lists' border radius to it, but in 2.8.0 the value- // was changed to being pulled from a theme variable instead of being hardcoded- const size = useSize(sizeProp);- const inputStyles = useMultiStyleConfig("Input", {- size,- });- const fieldStyles = inputStyles.field as Record<string, string>;-- const initialSx: SystemStyleObject = {- ...menuStyles.list,- minW: "100%",- maxHeight: `${maxHeight}px`,- overflowY: "auto",- // This is hacky, but it works. May be removed in the future- "--input-border-radius": fieldStyles?.["--input-border-radius"],- borderRadius: fieldStyles?.borderRadius || menuStyles.list?.borderRadius,- position: "relative", // required for offset[Height, Top] > keyboard scroll- WebkitOverflowScrolling: "touch",- };-- const sx = initialSx;-- const children = React.useMemo<React.ReactElement[]>(() => {- const _children = React.Children.toArray(- props.children- ) as React.ReactElement[];-- const head = _children[0] || {};-- if (- React.isValidElement<- OptionProps<OptionTypeBase, boolean, GroupBase<OptionTypeBase>>- >(head)- ) {- const { props: { data: { options = [] } = {} } = {} } = head;- const groupedChildrenLength = options.length;- const isGrouped = groupedChildrenLength > 0;- const flattenedChildren = isGrouped- ? flattenGroupedChildren(_children as React.ReactElement[])- : [];-- return isGrouped ? flattenedChildren : _children;- } else {- return [];- }- }, [props.children]);-- const itemCount = Array.isArray(children) ? children.length : 0;- const itemHeight = MenuItemHeightBySize[size ?? "md"];- const initialOffset = itemHeight * getCurrentIndex(children);-- return (- <Box- {...innerProps}- className={cx(- {- "menu-list": true,- "menu-list--is-multi": isMulti,- },- className- )}- sx={sx}- >- <List- width="100%"- ref={list}- outerRef={innerRef}- height={Math.min(maxHeight, itemHeight * itemCount + 4)}- itemCount={itemCount}- itemData={children}- itemSize={itemHeight}- initialScrollOffset={initialOffset}- >- {({ data, index, style }: any) => {- return (- <div- style={{- ...style,- top: `${parseFloat(style.top.toString())}px`,- }}- >- {data[index]}- </div>- );- }}- </List>- </Box>- );-};--export const LoadingMessage = <- Option,- IsMulti extends boolean,- Group extends GroupBase<Option>->(- props: NoticeProps<Option, IsMulti, Group>-) => {- const {- children,- className,- cx,- innerProps,- selectProps: { size: sizeProp },- } = props;-- const size = useSize(sizeProp);-- const verticalPaddings: SizeProps = {- sm: "6px",- md: "8px",- lg: "10px",- };-- const initialSx: SystemStyleObject = {- color: "chakra-subtle-text",- textAlign: "center",- paddingY: verticalPaddings[size],- fontSize: size,- };-- const sx = initialSx;-- return (- <Box- {...innerProps}- className={cx(- {- "menu-notice": true,- "menu-notice--loading": true,- },- className- )}- sx={sx}- >- {children}- </Box>- );-};--export const NoOptionsMessage = <- Option,- IsMulti extends boolean,- Group extends GroupBase<Option>->(- props: NoticeProps<Option, IsMulti, Group>-) => {- const {- children,- className,- cx,- innerProps,- selectProps: { size: sizeProp },- } = props;-- const size = useSize(sizeProp);-- const verticalPaddings: SizeProps = {- sm: "6px",- md: "8px",- lg: "10px",- };-- const initialSx: SystemStyleObject = {- color: "chakra-subtle-text",- textAlign: "center",- paddingY: verticalPaddings[size],- fontSize: size,- };-- const sx = initialSx;-- return (- <Box- {...innerProps}- className={cx(- {- "menu-notice": true,- "menu-notice--no-options": true,- },- className- )}- sx={sx}- >- {children}- </Box>- );-};--export const Group = <- Option,- IsMulti extends boolean,- Group extends GroupBase<Option>->(- props: GroupProps<Option, IsMulti, Group>-) => {- const {- children,- className,- cx,- theme,- getStyles,- Heading,- headingProps,- label,- selectProps,- innerProps,- getClassNames,- } = props;-- const sx = {};-- return (- <Box {...innerProps} className={cx({ group: true }, className)} sx={sx}>- <Heading- {...headingProps}- selectProps={selectProps}- cx={cx}- theme={theme}- getStyles={getStyles}- getClassNames={getClassNames}- >- {label}- </Heading>- <Box>{children}</Box>- </Box>- );-};--export const GroupHeading = <- Option,- IsMulti extends boolean,- Group extends GroupBase<Option>->(- props: GroupHeadingProps<Option, IsMulti, Group>-) => {- const {- cx,- className,- children,- selectProps: { size: sizeProp, hasStickyGroupHeaders },- } = props;-- const menuStyles = useMultiStyleConfig("Menu");-- const size = useSize(sizeProp);-- const fontSizes: SizeProps = {- sm: "xs",- md: "sm",- lg: "md",- };- const paddings: SizeProps = {- sm: "0.4rem 0.8rem",- md: "0.5rem 1rem",- lg: "0.6rem 1.2rem",- };-- const initialSx: SystemStyleObject = {- ...menuStyles.groupTitle,- fontSize: fontSizes[size],- padding: paddings[size],- margin: 0,- borderBottomWidth: hasStickyGroupHeaders ? "1px" : 0,- position: hasStickyGroupHeaders ? "sticky" : "static",- top: -2,- bg: menuStyles.list.bg,- zIndex: 1,- };-- const sx = initialSx;-- return (- <Box className={cx({ "group-heading": true }, className)} sx={sx}>- {children}- </Box>- );-};--/**- * The `CheckIcon` component from the Chakra UI Menu- *- * @see {@link https://github.com/chakra-ui/chakra-ui/blob/eb0316ddf96dd259433724062e923c33e6eee729/packages/components/menu/src/menu-item-option.tsx#L10-L17}- */-const CheckIcon: React.FC<PropsOf<"svg">> = (props) => (- <svg viewBox="0 0 14 14" width="1em" height="1em" {...props}>- <polygon- fill="currentColor"- points="5.5 11.9993304 14 3.49933039 12.5 2 5.5 8.99933039 1.5 4.9968652 0 6.49933039"- />- </svg>-);--export const Option = <- Option,- IsMulti extends boolean,- Group extends GroupBase<Option>->(- props: OptionProps<Option, IsMulti, Group>-) => {- const {- className,- cx,- innerRef,- innerProps,- children,- isFocused,- isDisabled,- isSelected,- selectProps: {- size: sizeProp,- isMulti,- hideSelectedOptions,- selectedOptionStyle,- },- } = props;-- const size = useSize(sizeProp);-- const menuItemStyles: ThemeObject = useMultiStyleConfig("Menu").item;-- const paddings: SizeProps = {- sm: "0.3rem 0.6rem",- md: "0.4rem 0.8rem",- lg: "0.5rem 1rem",- };-- const selectedBg = useColorModeValue(`blue.500`, `blue.300`);- const selectedColor = useColorModeValue("white", "black");-- // Don't create exta space for the checkmark if using a multi select with- // options that dissapear when they're selected- const showCheckIcon: boolean =- selectedOptionStyle === "check" &&- (!isMulti || hideSelectedOptions === false);-- const shouldHighlight: boolean =- selectedOptionStyle === "color" && isSelected;-- const initialSx: SystemStyleObject = {- ...menuItemStyles,- display: "flex",- alignItems: "center",- width: "100%",- textAlign: "start",- fontSize: size,- padding: paddings[size],- ...(isFocused && menuItemStyles._focus),- ...(shouldHighlight && {- bg: selectedBg,- color: selectedColor,- _active: { bg: selectedBg },- }),- ...(isDisabled && menuItemStyles._disabled),- ...(isDisabled && { _active: {} }),- };-- const sx = initialSx;-- return (- <Box- {...innerProps}- role="button"- className={cx(- {- option: true,- "option--is-disabled": isDisabled,- "option--is-focused": isFocused,- "option--is-selected": isSelected,- },- className- )}- sx={sx}- ref={innerRef}- data-disabled={isDisabled ? true : undefined}- aria-disabled={isDisabled ? true : undefined}- >- {showCheckIcon && (- <MenuIcon- fontSize="0.8em"- marginEnd="0.75rem"- opacity={isSelected ? 1 : 0}- >- <CheckIcon />- </MenuIcon>- )}- {children}- </Box>- );-};--export function flattenGroupedChildren(children: React.ReactElement[]) {- return children.reduce<React.ReactElement[]>((result, child) => {- const {- props: { children: nestedChildren = [] },- } = child;-- return [- ...result,- React.cloneElement(child, { type: "group" }, []),- ...nestedChildren,- ];- }, []);-}--export function isFocused({ props: { isFocused } }: React.ReactElement) {- return isFocused === true;-}--export function getCurrentIndex(children: React.ReactElement[]) {- return Math.max(children.findIndex(isFocused), 0);-}diff --git a/packages/react/src/ReactSelect/components/multi-value.tsx b/packages/react/src/ReactSelect/components/multi-value.tsxdeleted file mode 100644index 5b0bd530fc..0000000000--- a/packages/react/src/ReactSelect/components/multi-value.tsx+++ /dev/null@@ -1,211 +0,0 @@-import type { IconProps, SystemStyleObject } from "@chakra-ui/react";-import { Box, Icon, chakra, useMultiStyleConfig } from "@chakra-ui/react";--import type {- GroupBase,- MultiValueGenericProps,- MultiValueProps,- MultiValueRemoveProps,-} from "react-select";--const hasColorScheme = (option: unknown): option is { colorScheme: unknown } =>- typeof option === "object" && option !== null && "colorScheme" in option;--const hasIsFixed = (option: unknown): option is { isFixed: unknown } =>- typeof option === "object" && option !== null && "isFixed" in option;--const hasVariant = (option: unknown): option is { variant: unknown } =>- typeof option === "object" && option !== null && "variant" in option;--const MultiValue = <- Option = unknown,- IsMulti extends boolean = boolean,- Group extends GroupBase<Option> = GroupBase<Option>->(- props: MultiValueProps<Option, IsMulti, Group>-) => {- const {- children,- className,- components,- cx,- data,- innerProps,- isDisabled,- isFocused,- removeProps,- selectProps,- } = props;-- const { Container, Label, Remove } = components;-- const { size } = selectProps;-- let optionColorScheme = "";- let optionVariant = "";- let optionIsFixed = false;-- if (hasColorScheme(data) && typeof data.colorScheme === "string") {- optionColorScheme = data.colorScheme;- }-- if (hasVariant(data) && typeof data.variant === "string") {- optionVariant = data.variant;- }-- if (hasIsFixed(data)) {- optionIsFixed = !!data.isFixed;- }-- const tagStyles = useMultiStyleConfig("Tag", {- size,- colorScheme: optionColorScheme,- variant: optionVariant || (optionIsFixed ? "solid" : "subtle"),- });-- const containerInitialSx: SystemStyleObject = {- ...tagStyles.container,- display: "inline-flex",- verticalAlign: "top",- alignItems: "center",- maxWidth: "100%",- margin: "0.125rem",- };- const containerSx: SystemStyleObject = containerInitialSx;-- const labelInitialSx: SystemStyleObject = tagStyles.label;- const labelSx = labelInitialSx;-- const removeInitialSx: SystemStyleObject = {- display: "flex",- alignItems: "center",- justifyContent: "center",- ...tagStyles.closeButton,- };- const removeSx = removeInitialSx;-- return (- <Container- data={data}- innerProps={{- className: cx(- {- "multi-value": true,- "multi-value--is-disabled": isDisabled,- },- className- ),- ...innerProps,- }}- sx={containerSx}- selectProps={selectProps}- >- <Label- data={data}- innerProps={{- className: cx(- {- "multi-value__label": true,- },- className- ),- }}- sx={labelSx}- selectProps={selectProps}- >- {children}- </Label>- <Remove- data={data}- innerProps={{- className: cx(- {- "multi-value__remove": true,- },- className- ),- "aria-label": `Remove ${children || "option"}`,- ...removeProps,- }}- sx={removeSx}- selectProps={selectProps}- isFocused={isFocused}- />- </Container>- );-};--const MultiValueContainer = <- Option = unknown,- IsMulti extends boolean = boolean,- Group extends GroupBase<Option> = GroupBase<Option>->(- props: MultiValueGenericProps<Option, IsMulti, Group>-) => {- const { children, innerProps, sx } = props;-- return (- <chakra.span {...innerProps} sx={sx}>- {children}- </chakra.span>- );-};--const MultiValueLabel = <- Option = unknown,- IsMulti extends boolean = boolean,- Group extends GroupBase<Option> = GroupBase<Option>->(- props: MultiValueGenericProps<Option, IsMulti, Group>-) => {- const { children, innerProps, sx } = props;-- return (- <chakra.span {...innerProps} sx={sx}>- {children}- </chakra.span>- );-};--/**- * Borrowed from Chakra UI Tag source- *- * @see {@link https://github.com/chakra-ui/chakra-ui/blob/13c6d2e08b61e179773be4722bb81173dd599306/packages/tag/src/tag.tsx#L75}- */-const TagCloseIcon = (props: IconProps) => (- <Icon verticalAlign="inherit" viewBox="0 0 512 512" {...props}>- <path- fill="currentColor"- d="M289.94 256l95-95A24 24 0 00351 127l-95 95-95-95a24 24 0 00-34 34l95 95-95 95a24 24 0 1034 34l95-95 95 95a24 24 0 0034-34z"- />- </Icon>-);--const MultiValueRemove = <- Option = unknown,- IsMulti extends boolean = boolean,- Group extends GroupBase<Option> = GroupBase<Option>->(- props: MultiValueRemoveProps<Option, IsMulti, Group>-) => {- const { children, innerProps, isFocused, data, sx } = props;-- if (hasIsFixed(data) && data.isFixed) {- return null;- }-- return (- <Box- {...innerProps}- role="button"- sx={sx}- data-focus={isFocused ? true : undefined}- data-focus-visible={isFocused ? true : undefined}- >- {children || <TagCloseIcon />}- </Box>- );-};--export { MultiValueContainer, MultiValueLabel, MultiValueRemove };-export default MultiValue;diff --git a/packages/react/src/ReactSelect/components/placeholder.tsx b/packages/react/src/ReactSelect/components/placeholder.tsxdeleted file mode 100644index c0018851a7..0000000000--- a/packages/react/src/ReactSelect/components/placeholder.tsx+++ /dev/null@@ -1,56 +0,0 @@-import type { SystemStyleObject } from "@chakra-ui/react";-import { Box, useColorModeValue } from "@chakra-ui/react";-import type { GroupBase, PlaceholderProps } from "react-select";--const Placeholder = <- Option,- IsMulti extends boolean,- Group extends GroupBase<Option>->(- props: PlaceholderProps<Option, IsMulti, Group>-) => {- const {- children,- className,- cx,- innerProps,- selectProps: { chakraStyles },- } = props;-- /**- * The chakra UI global placeholder color- *- * @see {@link https://github.com/chakra-ui/chakra-ui/blob/13c6d2e08b61e179773be4722bb81173dd599306/packages/theme/src/styles.ts#L13}- */- const placeholderColor = useColorModeValue("gray.500", "whiteAlpha.400");-- const initialSx: SystemStyleObject = {- color: placeholderColor,- mx: "0.125rem",- position: "absolute",- top: "50%",- transform: "translateY(-50%)",- userSelect: "none",- };-- const sx = chakraStyles?.placeholder- ? chakraStyles.placeholder(initialSx, props)- : initialSx;-- return (- <Box- {...innerProps}- className={cx(- {- placeholder: true,- },- className- )}- sx={sx}- >- {children}- </Box>- );-};--export default Placeholder;diff --git a/packages/react/src/ReactSelect/components/single-value.tsx b/packages/react/src/ReactSelect/components/single-value.tsxdeleted file mode 100644index 5b7a437a5c..0000000000--- a/packages/react/src/ReactSelect/components/single-value.tsx+++ /dev/null@@ -1,45 +0,0 @@-import type { SystemStyleObject } from "@chakra-ui/react";-import { Box } from "@chakra-ui/react";-import type { GroupBase, SingleValueProps } from "react-select";--const SingleValue = <- Option,- IsMulti extends boolean,- Group extends GroupBase<Option>->(- props: SingleValueProps<Option, IsMulti, Group>-) => {- const { children, className, cx, isDisabled, innerProps } = props;-- const initialSx: SystemStyleObject = {- label: "singleValue",- mx: "0.125rem",- maxWidth: `calc(100% - 0.5rem)`,- overflow: "hidden",- position: "absolute",- textOverflow: "ellipsis",- whiteSpace: "nowrap",- top: "50%",- transform: "translateY(-50%)",- };-- const sx = initialSx;-- return (- <Box- className={cx(- {- "single-value": true,- "single-value--is-disabled": isDisabled,- },- className- )}- sx={sx}- {...innerProps}- >- {children}- </Box>- );-};--export default SingleValue;diff --git a/packages/react/src/ReactSelect/index.ts b/packages/react/src/ReactSelect/index.tsdeleted file mode 100644index 3f8e86b881..0000000000--- a/packages/react/src/ReactSelect/index.ts+++ /dev/null@@ -1,31 +0,0 @@-import "./module-augmentation";--export { default as AsyncCreatableSelect } from "./select/async-creatable-select";-export { default as AsyncSelect } from "./select/async-select";-export { default as CreatableSelect } from "./select/creatable-select";-export { default as Select } from "./select/select";--export { default as carbonComponents } from "./components";-export { default as useSelectProps } from "./useSelectProps";--export type { AsyncCreatableSelectComponent } from "./select/async-creatable-select";-export type { AsyncSelectComponent } from "./select/async-select";-export type { CreatableSelectComponent } from "./select/creatable-select";-export type { SelectComponent } from "./select/select";--export type {- OptionBase,- SelectedOptionStyle,- Size,- SizeProps,- StylesFunction,- TagVariant,-} from "./types";--// Forward all available exports from the original `react-select` package-export * from "react-select";-export { useAsync } from "react-select/async";-export type { AsyncProps } from "react-select/async";-export type { AsyncCreatableProps } from "react-select/async-creatable";-export { useCreatable } from "react-select/creatable";-export type { CreatableProps } from "react-select/creatable";diff --git a/packages/react/src/ReactSelect/module-augmentation.ts b/packages/react/src/ReactSelect/module-augmentation.tsdeleted file mode 100644index e40babe681..0000000000--- a/packages/react/src/ReactSelect/module-augmentation.ts+++ /dev/null@@ -1,162 +0,0 @@-/* eslint-disable @typescript-eslint/no-unused-vars */-import type { GroupBase } from "react-select";-import type { SelectedOptionStyle } from "./types";--/**- * Module augmentation is used to add extra props to the existing interfaces- * from `react-select` as per the docs- *- * @see {@link https://react-select.com/typescript#custom-select-props}- */-declare module "react-select/dist/declarations/src/Select" {- export interface Props<- Option,- IsMulti extends boolean,- Group extends GroupBase<Option>- > {- /**- * The max width of the menu container- *- */- maxW?: number;-- /**- * The min width of the menu container- *- */- minW?: number;- /**- * The width of the menu container- */- w?: "full" | number;-- /**- * The size of the base control; matches the sizes of the Input- * component with the exception of `xs`. A [responsive style array/object](https://chakra-ui.com/docs/features/responsive-styles) can- * also be passed.- *- * Options: `sm` | `md` | `lg`- *- * @defaultValue `md`- */-- size?: "sm" | "md" | "lg";-- /**- * Determines whether or not to style the input with the invalid border- * color.- *- * If the `aria-invalid` prop is not passed, this prop will also set that- *- * @defaultValue `false`- */- isInvalid?: boolean;-- /**- * If `true`, the form control will be `readonly`.- *- * @defaultValue `false`- * @see {@link https://github.com/csandman/chakra-react-select#isinvalid--default-false--isreadonly---default-false}- * @see {@link https://chakra-ui.com/docs/components/input/props}- * @see {@link https://chakra-ui.com/docs/components/form-control/props}- */- isReadOnly?: boolean;-- /**- * 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- *- * @see {@link https://chakra-ui.com/docs/components/input/props}- * @see {@link https://chakra-ui.com/docs/components/form-control/props}- */- isRequired?: boolean;-- /**- * Passing `true` for this prop will make the group headers- * `position: sticky` and keep them stuck to the top while their- * corresponding group is in view.- *- * @defaultValue `false`- * @deprecated This prop should probably not have existed and will be- * removed soon.- */- hasStickyGroupHeaders?: boolean;-- /**- * Whether to style a selected option by highlighting it in a solid color- * or adding a check mark next to it like the chakra `Menu` component.- *- * Options: `color` | `check`- *- * @defaultValue `color`- */- selectedOptionStyle?: SelectedOptionStyle;- }-}--declare module "react-select/dist/declarations/src/components/MultiValue" {- export interface MultiValueProps<- Option,- IsMulti extends boolean,- Group extends GroupBase<Option>- > {}-- export interface MultiValueGenericProps<- Option,- IsMulti extends boolean,- Group extends GroupBase<Option>- > {}-- export interface MultiValueRemoveProps<- Option,- IsMulti extends boolean,- Group extends GroupBase<Option>- > {- isFocused: boolean;- }-}--declare module "react-select/dist/declarations/src/components/indicators" {- export interface LoadingIndicatorProps<- Option,- IsMulti extends boolean,- Group extends GroupBase<Option>- > {- /**- * The size prop for the Chakra `<Spinner />` component.- *- * Defaults to one size smaller than the overall Select's size.- */- spinnerSize?: "xs" | "sm" | "md" | "lg" | "xl";-- /**- * The speed of the spinner represented by the time it takes to make one full rotation.- *- * This speed is represented by a- * [CSS `<time>`](https://developer.mozilla.org/en-US/docs/Web/CSS/time)- * variable which uses either seconds or milliseconds.- *- * @defaultValue `0.45s`- * @example- * ```jsx- * <Spinner speed="0.2s"/>- * ```- * @see {@link https://chakra-ui.com/docs/components/spinner/props}- */- speed?: string;-- /**- * The thickness of the spinner.- *- * @defaultValue `2px`- * @example- * ```jsx- * <Spinner thickness="4px"/>- * ```- * @see {@link https://chakra-ui.com/docs/components/spinner/props}- */- thickness?: string;- }-}diff --git a/packages/react/src/ReactSelect/select/async-creatable-select.tsx b/packages/react/src/ReactSelect/select/async-creatable-select.tsxdeleted file mode 100644index 069922dfbd..0000000000--- a/packages/react/src/ReactSelect/select/async-creatable-select.tsx+++ /dev/null@@ -1,32 +0,0 @@-import type { MutableRefObject, ReactElement, RefAttributes } from "react";-import { forwardRef } from "react";-import type { GroupBase, SelectInstance } from "react-select";-import type { AsyncCreatableProps } from "react-select/async-creatable";-import AsyncCreatableReactSelect from "react-select/async-creatable";-import useSelectProps from "../useSelectProps";--export type AsyncCreatableSelectComponent = <- Option = unknown,- IsMulti extends boolean = false,- Group extends GroupBase<Option> = GroupBase<Option>->(- props: AsyncCreatableProps<Option, IsMulti, Group> &- RefAttributes<SelectInstance<Option, IsMulti, Group>>-) => ReactElement;--// eslint-disable-next-line react/display-name-const AsyncCreatableSelect = forwardRef(- <Option, IsMulti extends boolean, Group extends GroupBase<Option>>(- props: AsyncCreatableProps<Option, IsMulti, Group>,- ref:- | ((instance: SelectInstance<Option, IsMulti, Group> | null) => void)- | MutableRefObject<SelectInstance<Option, IsMulti, Group> | null>- | null- ) => {- const chakraSelectProps = useSelectProps(props);-- return <AsyncCreatableReactSelect ref={ref} {...chakraSelectProps} />;- }-) as AsyncCreatableSelectComponent;--export default AsyncCreatableSelect;diff --git a/packages/react/src/ReactSelect/select/async-select.tsx b/packages/react/src/ReactSelect/select/async-select.tsxdeleted file mode 100644index 9b62c43ca3..0000000000--- a/packages/react/src/ReactSelect/select/async-select.tsx+++ /dev/null@@ -1,32 +0,0 @@-import type { MutableRefObject, ReactElement, RefAttributes } from "react";-import { forwardRef } from "react";-import type { GroupBase, SelectInstance } from "react-select";-import type { AsyncProps } from "react-select/async";-import AsyncReactSelect from "react-select/async";-import useSelectProps from "../useSelectProps";--export type AsyncSelectComponent = <- Option = unknown,- IsMulti extends boolean = false,- Group extends GroupBase<Option> = GroupBase<Option>->(- props: AsyncProps<Option, IsMulti, Group> &- RefAttributes<SelectInstance<Option, IsMulti, Group>>-) => ReactElement;--// eslint-disable-next-line react/display-name-const AsyncSelect = forwardRef(- <Option, IsMulti extends boolean, Group extends GroupBase<Option>>(- props: AsyncProps<Option, IsMulti, Group>,- ref:- | ((instance: SelectInstance<Option, IsMulti, Group> | null) => void)- | MutableRefObject<SelectInstance<Option, IsMulti, Group> | null>- | null- ) => {- const chakraSelectProps = useSelectProps(props);-- return <AsyncReactSelect ref={ref} {...chakraSelectProps} />;- }-) as AsyncSelectComponent;--export default AsyncSelect;diff --git a/packages/react/src/ReactSelect/select/creatable-select.tsx b/packages/react/src/ReactSelect/select/creatable-select.tsxdeleted file mode 100644index a13df987c1..0000000000--- a/packages/react/src/ReactSelect/select/creatable-select.tsx+++ /dev/null@@ -1,32 +0,0 @@-import type { MutableRefObject, ReactElement, RefAttributes } from "react";-import { forwardRef } from "react";-import type { GroupBase, SelectInstance } from "react-select";-import type { CreatableProps } from "react-select/creatable";-import CreatableReactSelect from "react-select/creatable";-import useSelectProps from "../useSelectProps";--export type CreatableSelectComponent = <- Option = unknown,- IsMulti extends boolean = false,- Group extends GroupBase<Option> = GroupBase<Option>->(- props: CreatableProps<Option, IsMulti, Group> &- RefAttributes<SelectInstance<Option, IsMulti, Group>>-) => ReactElement;--// eslint-disable-next-line react/display-name-const CreatableSelect = forwardRef(- <Option, IsMulti extends boolean, Group extends GroupBase<Option>>(- props: CreatableProps<Option, IsMulti, Group>,- ref:- | ((instance: SelectInstance<Option, IsMulti, Group> | null) => void)- | MutableRefObject<SelectInstance<Option, IsMulti, Group> | null>- | null- ) => {- const chakraSelectProps = useSelectProps(props);-- return <CreatableReactSelect ref={ref} {...chakraSelectProps} />;- }-) as CreatableSelectComponent;--export default CreatableSelect;diff --git a/packages/react/src/ReactSelect/select/select.tsx b/packages/react/src/ReactSelect/select/select.tsxdeleted file mode 100644index 98db998abf..0000000000--- a/packages/react/src/ReactSelect/select/select.tsx+++ /dev/null@@ -1,31 +0,0 @@-import type { MutableRefObject, ReactElement, RefAttributes } from "react";-import { forwardRef } from "react";-import type { GroupBase, Props, SelectInstance } from "react-select";-import ReactSelect from "react-select";-import useSelectProps from "../useSelectProps";--export type SelectComponent = <- Option = unknown,- IsMulti extends boolean = false,- Group extends GroupBase<Option> = GroupBase<Option>->(- props: Props<Option, IsMulti, Group> &- RefAttributes<SelectInstance<Option, IsMulti, Group>>-) => ReactElement;--// eslint-disable-next-line react/display-name-const Select = forwardRef(- <Option, IsMulti extends boolean, Group extends GroupBase<Option>>(- props: Props<Option, IsMulti, Group>,- ref:- | ((instance: SelectInstance<Option, IsMulti, Group> | null) => void)- | MutableRefObject<SelectInstance<Option, IsMulti, Group> | null>- | null- ) => {- const chakraSelectProps = useSelectProps(props);-- return <ReactSelect ref={ref} {...chakraSelectProps} />;- }-) as SelectComponent;--export default Select;diff --git a/packages/react/src/ReactSelect/types.ts b/packages/react/src/ReactSelect/types.tsdeleted file mode 100644index f292964c8a..0000000000--- a/packages/react/src/ReactSelect/types.ts+++ /dev/null@@ -1,108 +0,0 @@-import type {- Pseudos,- ResponsiveObject,- SystemStyleObject,-} from "@chakra-ui/system";-import type {- ClearIndicatorProps,- ContainerProps,- ControlProps,- DropdownIndicatorProps,- GroupBase,- GroupHeadingProps,- GroupProps,- IndicatorSeparatorProps,- IndicatorsContainerProps,- InputProps,- LoadingIndicatorProps,- MenuListProps,- MenuProps,- MultiValueProps,- NoticeProps,- OptionProps,- PlaceholderProps,- SingleValueProps,- ValueContainerProps,-} from "react-select";--/**- * This is needed because Chakra improperly types their `SystemStyleObject` to not include pseudo selectors,- * even though the objects actually include them.- *- * @see {@link https://github.com/chakra-ui/chakra-ui/issues/6261}- */-export type ThemeObject = SystemStyleObject & {- [K in keyof Pseudos]?: SystemStyleObject;-};--export interface SizeProps<PropType = string | number> {- sm: PropType;- md: PropType;- lg: PropType;-}--export type Size = "sm" | "md" | "lg";--export type SizeProp = Size | ResponsiveObject<Size> | Size[];--export type TagVariant = "subtle" | "solid" | "outline" | (string & {});--export type SelectedOptionStyle = "color" | "check";--export type Variant =- | "outline"- | "filled"- | "flushed"- | "unstyled"- | (string & {});--export type StylesFunction<ComponentProps> = (- provided: SystemStyleObject,- state: ComponentProps-) => SystemStyleObject;--export interface ChakraStylesConfig<- Option = unknown,- IsMulti extends boolean = boolean,- Group extends GroupBase<Option> = GroupBase<Option>-> {- clearIndicator?: StylesFunction<ClearIndicatorProps<Option, IsMulti, Group>>;- container?: StylesFunction<ContainerProps<Option, IsMulti, Group>>;- control?: StylesFunction<ControlProps<Option, IsMulti, Group>>;- dropdownIndicator?: StylesFunction<- DropdownIndicatorProps<Option, IsMulti, Group>- >;- downChevron?: StylesFunction<DropdownIndicatorProps<Option, IsMulti, Group>>;- crossIcon?: StylesFunction<ClearIndicatorProps<Option, IsMulti, Group>>;- group?: StylesFunction<GroupProps<Option, IsMulti, Group>>;- groupHeading?: StylesFunction<GroupHeadingProps<Option, IsMulti, Group>>;- indicatorsContainer?: StylesFunction<- IndicatorsContainerProps<Option, IsMulti, Group>- >;- indicatorSeparator?: StylesFunction<- IndicatorSeparatorProps<Option, IsMulti, Group>- >;- input?: StylesFunction<InputProps<Option, IsMulti, Group>>;- inputContainer?: StylesFunction<InputProps<Option, IsMulti, Group>>;- loadingIndicator?: StylesFunction<- LoadingIndicatorProps<Option, IsMulti, Group>- >;- loadingMessage?: StylesFunction<NoticeProps<Option, IsMulti, Group>>;- menu?: StylesFunction<MenuProps<Option, IsMulti, Group>>;- menuList?: StylesFunction<MenuListProps<Option, IsMulti, Group>>;- multiValue?: StylesFunction<MultiValueProps<Option, IsMulti, Group>>;- multiValueLabel?: StylesFunction<MultiValueProps<Option, IsMulti, Group>>;- multiValueRemove?: StylesFunction<MultiValueProps<Option, IsMulti, Group>>;- noOptionsMessage?: StylesFunction<NoticeProps<Option, IsMulti, Group>>;- option?: StylesFunction<OptionProps<Option, IsMulti, Group>>;- placeholder?: StylesFunction<PlaceholderProps<Option, IsMulti, Group>>;- singleValue?: StylesFunction<SingleValueProps<Option, IsMulti, Group>>;- valueContainer?: StylesFunction<ValueContainerProps<Option, IsMulti, Group>>;-}--export interface OptionBase {- variant?: string;- colorScheme?: string;- isFixed?: boolean;- isDisabled?: boolean;-}diff --git a/packages/react/src/ReactSelect/useSelectProps.ts b/packages/react/src/ReactSelect/useSelectProps.tsdeleted file mode 100644index e6bc466220..0000000000--- a/packages/react/src/ReactSelect/useSelectProps.ts+++ /dev/null@@ -1,69 +0,0 @@-import type { GroupBase, Props } from "react-select";-import { createFilter } from "react-select";-import { ariaAttr } from "~/utils/dom";-import carbonComponents from "./components";--const useSelectProps = <- Option,- IsMulti extends boolean = false,- Group extends GroupBase<Option> = GroupBase<Option>->({- components = {},- theme,- size,- isDisabled,- isInvalid,- isReadOnly,- isRequired,- inputId,- selectedOptionStyle = "check",- filterOption,- onFocus,- onBlur,- menuIsOpen,- ...props-}: Props<Option, IsMulti, Group>): Props<Option, IsMulti, Group> => {- const inputProps = {- id: inputId,- disabled: isDisabled,- readOnly: isReadOnly,- required: isRequired,- "aria-invalid": ariaAttr(isInvalid),- "aria-required": ariaAttr(isRequired),- "aria-readonly": ariaAttr(isReadOnly),- onFocus,- onBlur,- };-- // Unless `menuIsOpen` is controlled, disable it if the select is readonly- const realMenuIsOpen =- menuIsOpen ?? (inputProps.readOnly ? false : undefined);-- const select: Props<Option, IsMulti, Group> = {- // Allow overriding of custom components- components: {- ...carbonComponents,- ...components,- },- // Custom select props- size,- // Extract custom props from form control- onFocus: inputProps.onFocus,- onBlur: inputProps.onBlur,- isDisabled: inputProps.disabled,- isInvalid: !!inputProps["aria-invalid"],- inputId: inputProps.id,- isReadOnly: inputProps.readOnly,- menuIsOpen: realMenuIsOpen,- ...props,- filterOption: filterOption ?? createFilter({ ignoreAccents: false }),-- // aria-invalid can be passed to react-select, so we allow that to- // override the `isInvalid` prop- "aria-invalid": props["aria-invalid"] ?? inputProps["aria-invalid"],- };-- return select;-};--export default useSelectProps;diff --git a/packages/react/src/ReactSelect/utils.ts b/packages/react/src/ReactSelect/utils.tsdeleted file mode 100644index 5821a89569..0000000000--- a/packages/react/src/ReactSelect/utils.ts+++ /dev/null@@ -1,88 +0,0 @@-import { useBreakpointValue } from "@chakra-ui/media-query";-import { useTheme } from "@chakra-ui/system";-import type { CommonPropsAndClassName, GroupBase } from "react-select";-import type { Size, SizeProp } from "./types";--/**- * Clean Common Props- *- * 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}- */-export const cleanCommonProps = <- Option,- IsMulti extends boolean,- Group extends GroupBase<Option>,- AdditionalProps->(- props: Partial<CommonPropsAndClassName<Option, IsMulti, Group>> &- AdditionalProps-): Omit<- AdditionalProps,- keyof CommonPropsAndClassName<Option, IsMulti, Group>-> => {- // className- const {- className, // not listed in commonProps documentation, needs to be removed to allow Emotion to generate classNames- clearValue,- cx,- getStyles,- getClassNames,- getValue,- hasValue,- isMulti,- isRtl,- options, // not listed in commonProps documentation- selectOption,- selectProps,- setValue,- theme, // not listed in commonProps documentation- ...innerProps- } = props;- return { ...innerProps };-};--/** A typeguard to ensure the default size on the Input component is valid. */-const isSize = (size: unknown): size is Size => {- const isString = typeof size === "string";- return isString && ["sm", "md", "lg"].includes(size);-};--const getDefaultSize = (size: unknown): Size => {- if (isSize(size)) {- return size;- }-- if (size === "xs") {- return "sm";- }-- // This shouldn't be necessary but it might help the size get closer to the- // user's goal if they have `xl` as a custom size.- if (size === "xl") {- return "lg";- }-- return "md";-};--export const useSize = (size: SizeProp | undefined): Size => {- const chakraTheme = useTheme();- const defaultSize = getDefaultSize(- chakraTheme.components.Input.defaultProps.size- );-- // Ensure that the size used is one of the options, either `sm`, `md`, or `lg`- const definedSize: SizeProp = size ?? defaultSize;- // Or, if a breakpoint is passed, get the size based on the current screen size- const realSize: Size =- useBreakpointValue<Size>(- typeof definedSize === "string" ? [definedSize] : definedSize,- {- fallback: "md",- }- ) || defaultSize;-- return realSize;-};diff --git a/packages/react/src/index.tsx b/packages/react/src/index.tsxindex caa22a3708..94f71c6b8d 100644--- a/packages/react/src/index.tsx+++ b/packages/react/src/index.tsx@@ -1,4 +1,5 @@import { ActionMenu } from "./ActionMenu";+import { Badge } from "./Badge";import type { ButtonProps } from "./Button";import { Button } from "./Button";import {@@ -22,6 +23,7 @@ import {CommandSeparator,CommandShortcut,CommandTrigger,+ multiSelectTriggerVariants,} from "./Command";import { ContextMenu } from "./ContextMenu";import { Count } from "./Count";@@ -82,18 +84,6 @@ import {ModalTrigger,} from "./Modal";import { Popover, PopoverContent, PopoverTrigger } from "./Popover";-import type {- GroupBase,- MultiValue,- OptionBase,- OptionProps,- SingleValue,-} from "./ReactSelect";-import {- CreatableSelect,- Select as ReactSelect,- createFilter,-} from "./ReactSelect";import {Select,SelectContent,@@ -133,6 +123,7 @@ import { cn } from "./utils/cn";export {ActionMenu,+ Badge,Button,Card,CardAction,@@ -154,7 +145,6 @@ export {CommandTrigger,ContextMenu,Count,- CreatableSelect,DataTable,DataTableColumnHeader,DatePicker,@@ -207,7 +197,6 @@ export {Popover,PopoverContent,PopoverTrigger,- ReactSelect,Select,SelectContent,SelectGroup,@@ -232,7 +221,7 @@ export {TooltipTrigger,VStack,cn,- createFilter,+ multiSelectTriggerVariants,theme,useColor,useDebounce,@@ -246,12 +235,4 @@ export {useNotification,useOutsideClick,};-export type {- ButtonProps,- GroupBase,- InputProps,- MultiValue,- OptionBase,- OptionProps,- SingleValue,-};+export type { ButtonProps, InputProps };