Skip to content

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.

refactor: select component - part 1

Brad Barbinf3d38986dbfc
diff --git a/apps/carbon/app/components/Form/Select.tsx b/apps/carbon/app/components/Form/Select.tsx
index 03296578f3..95fe01d7fb 100644
--- a/apps/carbon/app/components/Form/Select.tsx
+++ b/apps/carbon/app/components/Form/Select.tsx
@@ -13,8 +13,9 @@ export type SelectProps = {
label?: string;
options: { value: string | number; label: string }[];
helperText?: string;
- isReadOnly?: boolean;
+ isClearable?: boolean;
isLoading?: boolean;
+ isReadOnly?: boolean;
placeholder?: string;
onChange?: (newValue: { value: string | number; label: string }) => void;
};
@@ -24,6 +25,7 @@ const Select = ({
label,
options,
helperText,
+ isClearable,
isLoading,
isReadOnly,
placeholder,
@@ -47,8 +49,9 @@ const Select = ({
})}
{...props}
defaultValue={initialValue}
- isReadOnly={isReadOnly}
+ isClearable={isClearable}
isLoading={isLoading}
+ isReadOnly={isReadOnly}
options={options}
placeholder={placeholder}
w="full"
@@ -56,7 +59,12 @@ const Select = ({
onChange={onChange ?? undefined}
/>
) : (
- <SelectBase isLoading={isLoading} options={[]} w="full" />
+ <SelectBase
+ isLoading={isLoading}
+ isReadOnly={isReadOnly}
+ options={[]}
+ w="full"
+ />
)}
{error ? (
diff --git a/apps/carbon/app/modules/accounting/ui/AccountCategories/AccountCategoriesTableFilters/AccountCategoriesTableFilters.tsx b/apps/carbon/app/modules/accounting/ui/AccountCategories/AccountCategoriesTableFilters/AccountCategoriesTableFilters.tsx
index 654abf3924..df96c13d2f 100644
--- a/apps/carbon/app/modules/accounting/ui/AccountCategories/AccountCategoriesTableFilters/AccountCategoriesTableFilters.tsx
+++ b/apps/carbon/app/modules/accounting/ui/AccountCategories/AccountCategoriesTableFilters/AccountCategoriesTableFilters.tsx
@@ -15,12 +15,7 @@ const AttributeCategoriesTableFilters = () => {
className="px-4 py-3 justify-between border-b border-border w-full"
>
<HStack>
- <DebouncedInput
- param="name"
- size="sm"
- minW={180}
- placeholder="Search"
- />
+ <DebouncedInput param="name" size="sm" placeholder="Search" />
<Select
size="sm"
placeholder="Income Balance"
diff --git a/apps/carbon/app/modules/accounting/ui/Currencies/CurrenciesTableFilters/CurrenciesTableFilters.tsx b/apps/carbon/app/modules/accounting/ui/Currencies/CurrenciesTableFilters/CurrenciesTableFilters.tsx
index bcbcb7be0d..925d8e1c48 100644
--- a/apps/carbon/app/modules/accounting/ui/Currencies/CurrenciesTableFilters/CurrenciesTableFilters.tsx
+++ b/apps/carbon/app/modules/accounting/ui/Currencies/CurrenciesTableFilters/CurrenciesTableFilters.tsx
@@ -14,12 +14,7 @@ const CurrenciesTableFilters = () => {
className="px-4 py-3 justify-between border-b border-border w-full"
>
<HStack>
- <DebouncedInput
- param="name"
- size="sm"
- minW={180}
- placeholder="Search"
- />
+ <DebouncedInput param="name" size="sm" placeholder="Search" />
</HStack>
<HStack>
{permissions.can("create", "accounting") && (
diff --git a/apps/carbon/app/modules/accounting/ui/PaymentTerms/PaymentTermsTableFilters/PaymentTermsTableFilters.tsx b/apps/carbon/app/modules/accounting/ui/PaymentTerms/PaymentTermsTableFilters/PaymentTermsTableFilters.tsx
index ae9057da33..da33b6857a 100644
--- a/apps/carbon/app/modules/accounting/ui/PaymentTerms/PaymentTermsTableFilters/PaymentTermsTableFilters.tsx
+++ b/apps/carbon/app/modules/accounting/ui/PaymentTerms/PaymentTermsTableFilters/PaymentTermsTableFilters.tsx
@@ -14,12 +14,7 @@ const PaymentTermsTableFilters = () => {
className="px-4 py-3 justify-between border-b border-border w-full"
>
<HStack>
- <DebouncedInput
- param="name"
- size="sm"
- minW={180}
- placeholder="Search"
- />
+ <DebouncedInput param="name" size="sm" placeholder="Search" />
</HStack>
<HStack>
{permissions.can("create", "accounting") && (
diff --git a/apps/carbon/app/modules/documents/ui/Documents/DocumentsTableFilters/DocumentsTableFilters.tsx b/apps/carbon/app/modules/documents/ui/Documents/DocumentsTableFilters/DocumentsTableFilters.tsx
index 3946e67c80..61854119d7 100644
--- a/apps/carbon/app/modules/documents/ui/Documents/DocumentsTableFilters/DocumentsTableFilters.tsx
+++ b/apps/carbon/app/modules/documents/ui/Documents/DocumentsTableFilters/DocumentsTableFilters.tsx
@@ -37,12 +37,7 @@ const DocumentsTableFilters = ({ labels }: DocumentTableFiltersProps) => {
spacing={4}
>
<HStack>
- <DebouncedInput
- param="search"
- size="sm"
- minW={180}
- placeholder="Search"
- />
+ <DebouncedInput param="search" size="sm" placeholder="Search" />
<Select
size="sm"
value={documentTypeOptions.find(
diff --git a/apps/carbon/app/modules/inventory/ui/Receipts/ReceiptsTableFilters/ReceiptsTableFilters.tsx b/apps/carbon/app/modules/inventory/ui/Receipts/ReceiptsTableFilters/ReceiptsTableFilters.tsx
index 1cc9f4dcdf..d4fcdab65c 100644
--- a/apps/carbon/app/modules/inventory/ui/Receipts/ReceiptsTableFilters/ReceiptsTableFilters.tsx
+++ b/apps/carbon/app/modules/inventory/ui/Receipts/ReceiptsTableFilters/ReceiptsTableFilters.tsx
@@ -33,12 +33,7 @@ const ReceiptsTableFilters = ({ locations }: ReceiptsTableFiltersProps) => {
spacing={4}
>
<HStack>
- <DebouncedInput
- param="search"
- size="sm"
- minW={180}
- placeholder="Search"
- />
+ <DebouncedInput param="search" size="sm" placeholder="Search" />
<Select
size="sm"
value={sourceDocumentOptions.find(
diff --git a/apps/carbon/app/modules/inventory/ui/ShippingMethods/ShippingMethodsTableFilters/ShippingMethodsTableFilters.tsx b/apps/carbon/app/modules/inventory/ui/ShippingMethods/ShippingMethodsTableFilters/ShippingMethodsTableFilters.tsx
index 1f18b1eeb7..539c620fae 100644
--- a/apps/carbon/app/modules/inventory/ui/ShippingMethods/ShippingMethodsTableFilters/ShippingMethodsTableFilters.tsx
+++ b/apps/carbon/app/modules/inventory/ui/ShippingMethods/ShippingMethodsTableFilters/ShippingMethodsTableFilters.tsx
@@ -14,12 +14,7 @@ const ShippingMethodsTableFilters = () => {
spacing={4}
>
<HStack>
- <DebouncedInput
- param="name"
- size="sm"
- minW={180}
- placeholder="Search"
- />
+ <DebouncedInput param="name" size="sm" placeholder="Search" />
</HStack>
<HStack>
{permissions.can("create", "inventory") && (
diff --git a/apps/carbon/app/modules/invoicing/ui/PurchaseInvoices/PurchaseInvoicesTableFilters/PurchaseInvoicesTableFilters.tsx b/apps/carbon/app/modules/invoicing/ui/PurchaseInvoices/PurchaseInvoicesTableFilters/PurchaseInvoicesTableFilters.tsx
index aae435ef11..d5f63db65d 100644
--- a/apps/carbon/app/modules/invoicing/ui/PurchaseInvoices/PurchaseInvoicesTableFilters/PurchaseInvoicesTableFilters.tsx
+++ b/apps/carbon/app/modules/invoicing/ui/PurchaseInvoices/PurchaseInvoicesTableFilters/PurchaseInvoicesTableFilters.tsx
@@ -32,12 +32,7 @@ const PurchaseInvoicesTableFilters = () => {
spacing={4}
>
<HStack>
- <DebouncedInput
- param="search"
- size="sm"
- minW={180}
- placeholder="Search"
- />
+ <DebouncedInput param="search" size="sm" placeholder="Search" />
<Select
size="sm"
value={purchaseInvoiceStatusOptions.find(
diff --git a/apps/carbon/app/modules/parts/ui/PartGroups/PartGroupsTableFilters/PartGroupsTableFilters.tsx b/apps/carbon/app/modules/parts/ui/PartGroups/PartGroupsTableFilters/PartGroupsTableFilters.tsx
index a941db4776..3f424001d9 100644
--- a/apps/carbon/app/modules/parts/ui/PartGroups/PartGroupsTableFilters/PartGroupsTableFilters.tsx
+++ b/apps/carbon/app/modules/parts/ui/PartGroups/PartGroupsTableFilters/PartGroupsTableFilters.tsx
@@ -14,12 +14,7 @@ const PartGroupsTableFilters = () => {
spacing={4}
>
<HStack>
- <DebouncedInput
- param="name"
- size="sm"
- minW={180}
- placeholder="Search"
- />
+ <DebouncedInput param="name" size="sm" placeholder="Search" />
</HStack>
<HStack>
{permissions.can("create", "parts") && (
diff --git a/apps/carbon/app/modules/parts/ui/Parts/PartsTableFilters/PartsTableFilters.tsx b/apps/carbon/app/modules/parts/ui/Parts/PartsTableFilters/PartsTableFilters.tsx
index 3c2487de92..c01e67bb12 100644
--- a/apps/carbon/app/modules/parts/ui/Parts/PartsTableFilters/PartsTableFilters.tsx
+++ b/apps/carbon/app/modules/parts/ui/Parts/PartsTableFilters/PartsTableFilters.tsx
@@ -30,12 +30,7 @@ const PartsTableFilters = ({ partGroups }: PartsTableFiltersProps) => {
spacing={4}
>
<HStack>
- <DebouncedInput
- param="search"
- size="sm"
- minW={180}
- placeholder="Search Parts"
- />
+ <DebouncedInput param="search" size="sm" placeholder="Search Parts" />
{partGroupsOptions.length > 0 && (
<Select
size="sm"
diff --git a/apps/carbon/app/modules/parts/ui/Services/ServicesTableFilters/ServicesTableFilters.tsx b/apps/carbon/app/modules/parts/ui/Services/ServicesTableFilters/ServicesTableFilters.tsx
index 4bdde1e05a..49588b8254 100644
--- a/apps/carbon/app/modules/parts/ui/Services/ServicesTableFilters/ServicesTableFilters.tsx
+++ b/apps/carbon/app/modules/parts/ui/Services/ServicesTableFilters/ServicesTableFilters.tsx
@@ -33,7 +33,6 @@ const ServicesTableFilters = ({ partGroups }: ServicesTableFiltersProps) => {
<DebouncedInput
param="search"
size="sm"
- minW={180}
placeholder="Search Services"
/>
{partGroupsOptions.length > 0 && (
diff --git a/apps/carbon/app/modules/parts/ui/UnitOfMeasure/UnitOfMeasuresTableFilters/UnitOfMeasuresTableFilters.tsx b/apps/carbon/app/modules/parts/ui/UnitOfMeasure/UnitOfMeasuresTableFilters/UnitOfMeasuresTableFilters.tsx
index d0a188e115..9c64c6a5b1 100644
--- a/apps/carbon/app/modules/parts/ui/UnitOfMeasure/UnitOfMeasuresTableFilters/UnitOfMeasuresTableFilters.tsx
+++ b/apps/carbon/app/modules/parts/ui/UnitOfMeasure/UnitOfMeasuresTableFilters/UnitOfMeasuresTableFilters.tsx
@@ -13,12 +13,7 @@ const UnitOfMeasuresTableFilters = () => {
spacing={4}
>
<HStack>
- <DebouncedInput
- param="name"
- size="sm"
- minW={180}
- placeholder="Search"
- />
+ <DebouncedInput param="name" size="sm" placeholder="Search" />
</HStack>
<HStack>
{permissions.can("create", "parts") && (
diff --git a/apps/carbon/app/modules/purchasing/ui/PurchaseOrders/PurchaseOrdersTableFilters/PurchaseOrdersTableFilters.tsx b/apps/carbon/app/modules/purchasing/ui/PurchaseOrders/PurchaseOrdersTableFilters/PurchaseOrdersTableFilters.tsx
index 32f7fbef09..3f9d378e17 100644
--- a/apps/carbon/app/modules/purchasing/ui/PurchaseOrders/PurchaseOrdersTableFilters/PurchaseOrdersTableFilters.tsx
+++ b/apps/carbon/app/modules/purchasing/ui/PurchaseOrders/PurchaseOrdersTableFilters/PurchaseOrdersTableFilters.tsx
@@ -30,12 +30,7 @@ const PurchaseOrdersTableFilters = () => {
spacing={4}
>
<HStack>
- <DebouncedInput
- param="search"
- size="sm"
- minW={180}
- placeholder="Search"
- />
+ <DebouncedInput param="search" size="sm" placeholder="Search" />
<Select
size="sm"
value={purchaseOrderStatusOptions.find(
diff --git a/apps/carbon/app/modules/purchasing/ui/SupplierTypes/SupplierTypesTableFilters/SupplierTypesTableFilters.tsx b/apps/carbon/app/modules/purchasing/ui/SupplierTypes/SupplierTypesTableFilters/SupplierTypesTableFilters.tsx
index 6266077ab3..bcaf9a30ce 100644
--- a/apps/carbon/app/modules/purchasing/ui/SupplierTypes/SupplierTypesTableFilters/SupplierTypesTableFilters.tsx
+++ b/apps/carbon/app/modules/purchasing/ui/SupplierTypes/SupplierTypesTableFilters/SupplierTypesTableFilters.tsx
@@ -14,12 +14,7 @@ const SupplierTypesTableFilters = () => {
spacing={4}
>
<HStack>
- <DebouncedInput
- param="name"
- size="sm"
- minW={180}
- placeholder="Search"
- />
+ <DebouncedInput param="name" size="sm" placeholder="Search" />
</HStack>
<HStack>
{permissions.can("create", "purchasing") && (
diff --git a/apps/carbon/app/modules/purchasing/ui/Suppliers/SuppliersTableFilters/SuppliersTableFilters.tsx b/apps/carbon/app/modules/purchasing/ui/Suppliers/SuppliersTableFilters/SuppliersTableFilters.tsx
index 2a27ead58f..781c2c7fe5 100644
--- a/apps/carbon/app/modules/purchasing/ui/Suppliers/SuppliersTableFilters/SuppliersTableFilters.tsx
+++ b/apps/carbon/app/modules/purchasing/ui/Suppliers/SuppliersTableFilters/SuppliersTableFilters.tsx
@@ -36,12 +36,7 @@ const SuppliersTableFilters = ({
spacing={4}
>
<HStack>
- <DebouncedInput
- param="name"
- size="sm"
- minW={180}
- placeholder="Search"
- />
+ <DebouncedInput param="name" size="sm" placeholder="Search" />
{supplierTypeOptions.length > 0 && (
<Select
size="sm"
diff --git a/apps/carbon/app/modules/resources/ui/Abilities/AbilitiesTableFilters/AbilitiesTableFilters.tsx b/apps/carbon/app/modules/resources/ui/Abilities/AbilitiesTableFilters/AbilitiesTableFilters.tsx
index 2b0bb6892d..2634b65ca0 100644
--- a/apps/carbon/app/modules/resources/ui/Abilities/AbilitiesTableFilters/AbilitiesTableFilters.tsx
+++ b/apps/carbon/app/modules/resources/ui/Abilities/AbilitiesTableFilters/AbilitiesTableFilters.tsx
@@ -14,12 +14,7 @@ const AbilitiesTableFilters = () => {
spacing={4}
>
<HStack>
- <DebouncedInput
- param="name"
- size="sm"
- minW={180}
- placeholder="Search"
- />
+ <DebouncedInput param="name" size="sm" placeholder="Search" />
</HStack>
<HStack>
{permissions.can("create", "resources") && (
diff --git a/apps/carbon/app/modules/resources/ui/Attributes/AttributeCategoriesTableFilters/AttributeCategoriesTableFilters.tsx b/apps/carbon/app/modules/resources/ui/Attributes/AttributeCategoriesTableFilters/AttributeCategoriesTableFilters.tsx
index 70a8ba7d2b..5d9abacca2 100644
--- a/apps/carbon/app/modules/resources/ui/Attributes/AttributeCategoriesTableFilters/AttributeCategoriesTableFilters.tsx
+++ b/apps/carbon/app/modules/resources/ui/Attributes/AttributeCategoriesTableFilters/AttributeCategoriesTableFilters.tsx
@@ -14,12 +14,7 @@ const AttributeCategoriesTableFilters = () => {
spacing={4}
>
<HStack>
- <DebouncedInput
- param="name"
- size="sm"
- minW={180}
- placeholder="Search"
- />
+ <DebouncedInput param="name" size="sm" placeholder="Search" />
</HStack>
<HStack>
{permissions.can("update", "resources") && (
diff --git a/apps/carbon/app/modules/resources/ui/Contractors/ContractorsTableFilters/ContractorsTableFilters.tsx b/apps/carbon/app/modules/resources/ui/Contractors/ContractorsTableFilters/ContractorsTableFilters.tsx
index 73983e5cbd..e87cd495bc 100644
--- a/apps/carbon/app/modules/resources/ui/Contractors/ContractorsTableFilters/ContractorsTableFilters.tsx
+++ b/apps/carbon/app/modules/resources/ui/Contractors/ContractorsTableFilters/ContractorsTableFilters.tsx
@@ -27,12 +27,7 @@ const ContractorsTableFilters = ({
spacing={4}
>
<HStack>
- <DebouncedInput
- param="name"
- size="sm"
- minW={180}
- placeholder="Search"
- />
+ <DebouncedInput param="name" size="sm" placeholder="Search" />
<Select
size="sm"
value={abilitiesOptions.find(
diff --git a/apps/carbon/app/modules/resources/ui/Departments/DepartmentsTableFilters/DepartmentsTableFilters.tsx b/apps/carbon/app/modules/resources/ui/Departments/DepartmentsTableFilters/DepartmentsTableFilters.tsx
index b9901705c5..41ca45094b 100644
--- a/apps/carbon/app/modules/resources/ui/Departments/DepartmentsTableFilters/DepartmentsTableFilters.tsx
+++ b/apps/carbon/app/modules/resources/ui/Departments/DepartmentsTableFilters/DepartmentsTableFilters.tsx
@@ -14,12 +14,7 @@ const DepartmentsTableFilters = () => {
spacing={4}
>
<HStack>
- <DebouncedInput
- param="name"
- size="sm"
- minW={180}
- placeholder="Search"
- />
+ <DebouncedInput param="name" size="sm" placeholder="Search" />
</HStack>
<HStack>
{permissions.can("create", "resources") && (
diff --git a/apps/carbon/app/modules/resources/ui/Equipment/EquipmentTypesTableFilters/EquipmentTypesTableFilters.tsx b/apps/carbon/app/modules/resources/ui/Equipment/EquipmentTypesTableFilters/EquipmentTypesTableFilters.tsx
index eeb4b5bd39..7e735d8b77 100644
--- a/apps/carbon/app/modules/resources/ui/Equipment/EquipmentTypesTableFilters/EquipmentTypesTableFilters.tsx
+++ b/apps/carbon/app/modules/resources/ui/Equipment/EquipmentTypesTableFilters/EquipmentTypesTableFilters.tsx
@@ -14,12 +14,7 @@ const EquipmentTypesTableFilters = () => {
spacing={4}
>
<HStack>
- <DebouncedInput
- param="name"
- size="sm"
- minW={180}
- placeholder="Search"
- />
+ <DebouncedInput param="name" size="sm" placeholder="Search" />
</HStack>
<HStack>
{permissions.can("update", "resources") && (
diff --git a/apps/carbon/app/modules/resources/ui/Holidays/HolidaysTableFilters/HolidaysTableFilters.tsx b/apps/carbon/app/modules/resources/ui/Holidays/HolidaysTableFilters/HolidaysTableFilters.tsx
index 3cfa66f923..1d4f7ab94f 100644
--- a/apps/carbon/app/modules/resources/ui/Holidays/HolidaysTableFilters/HolidaysTableFilters.tsx
+++ b/apps/carbon/app/modules/resources/ui/Holidays/HolidaysTableFilters/HolidaysTableFilters.tsx
@@ -23,12 +23,7 @@ const HolidaysTableFilters = ({ years }: HolidaysTableFiltersProps) => {
spacing={4}
>
<HStack>
- <DebouncedInput
- param="name"
- size="sm"
- minW={180}
- placeholder="Search"
- />
+ <DebouncedInput param="name" size="sm" placeholder="Search" />
<Select
size="sm"
value={
diff --git a/apps/carbon/app/modules/resources/ui/Locations/LocationsTableFilters/LocationsTableFilters.tsx b/apps/carbon/app/modules/resources/ui/Locations/LocationsTableFilters/LocationsTableFilters.tsx
index 3b4a0776c6..b8cc63c4a0 100644
--- a/apps/carbon/app/modules/resources/ui/Locations/LocationsTableFilters/LocationsTableFilters.tsx
+++ b/apps/carbon/app/modules/resources/ui/Locations/LocationsTableFilters/LocationsTableFilters.tsx
@@ -14,12 +14,7 @@ const LocationsTableFilters = () => {
spacing={4}
>
<HStack>
- <DebouncedInput
- param="name"
- size="sm"
- minW={180}
- placeholder="Search"
- />
+ <DebouncedInput param="name" size="sm" placeholder="Search" />
</HStack>
<HStack>
{permissions.can("create", "resources") && (
diff --git a/apps/carbon/app/modules/resources/ui/Partners/PartnersTableFilters/PartnersTableFilters.tsx b/apps/carbon/app/modules/resources/ui/Partners/PartnersTableFilters/PartnersTableFilters.tsx
index 6f6602ba98..ed60db0740 100644
--- a/apps/carbon/app/modules/resources/ui/Partners/PartnersTableFilters/PartnersTableFilters.tsx
+++ b/apps/carbon/app/modules/resources/ui/Partners/PartnersTableFilters/PartnersTableFilters.tsx
@@ -25,12 +25,7 @@ const PartnersTableFilters = ({ abilities }: PartnersTableFiltersProps) => {
spacing={4}
>
<HStack>
- <DebouncedInput
- param="name"
- size="sm"
- minW={180}
- placeholder="Search"
- />
+ <DebouncedInput param="name" size="sm" placeholder="Search" />
<Select
size="sm"
value={abilitiesOptions.find(
diff --git a/apps/carbon/app/modules/resources/ui/People/PeopleTableFilters/PeopleTableFilters.tsx b/apps/carbon/app/modules/resources/ui/People/PeopleTableFilters/PeopleTableFilters.tsx
index 32cd8c63e2..22d868ef7d 100644
--- a/apps/carbon/app/modules/resources/ui/People/PeopleTableFilters/PeopleTableFilters.tsx
+++ b/apps/carbon/app/modules/resources/ui/People/PeopleTableFilters/PeopleTableFilters.tsx
@@ -24,12 +24,7 @@ const PeopleTableFilters = ({ employeeTypes }: PeopleTableFiltersProps) => {
spacing={4}
>
<HStack>
- <DebouncedInput
- param="name"
- size="sm"
- minW={180}
- placeholder="Search"
- />
+ <DebouncedInput param="name" size="sm" placeholder="Search" />
<Select
size="sm"
value={employeeTypeOptions.find(
diff --git a/apps/carbon/app/modules/resources/ui/Shifts/ShiftsTableFilters/ShiftsTableFilters.tsx b/apps/carbon/app/modules/resources/ui/Shifts/ShiftsTableFilters/ShiftsTableFilters.tsx
index 03e127e062..8da627bdd2 100644
--- a/apps/carbon/app/modules/resources/ui/Shifts/ShiftsTableFilters/ShiftsTableFilters.tsx
+++ b/apps/carbon/app/modules/resources/ui/Shifts/ShiftsTableFilters/ShiftsTableFilters.tsx
@@ -25,12 +25,7 @@ const ShiftsTableFilters = ({ locations }: ShiftsTableFiltersProps) => {
spacing={4}
>
<HStack>
- <DebouncedInput
- param="name"
- size="sm"
- minW={180}
- placeholder="Search"
- />
+ <DebouncedInput param="name" size="sm" placeholder="Search" />
<Select
size="sm"
value={locationOptions.find(
diff --git a/apps/carbon/app/modules/resources/ui/WorkCells/WorkCellTypesTableFilters/WorkCellTypesTableFilters.tsx b/apps/carbon/app/modules/resources/ui/WorkCells/WorkCellTypesTableFilters/WorkCellTypesTableFilters.tsx
index e0860debbb..c4080466b7 100644
--- a/apps/carbon/app/modules/resources/ui/WorkCells/WorkCellTypesTableFilters/WorkCellTypesTableFilters.tsx
+++ b/apps/carbon/app/modules/resources/ui/WorkCells/WorkCellTypesTableFilters/WorkCellTypesTableFilters.tsx
@@ -14,12 +14,7 @@ const WorkCellTypesTableFilters = () => {
spacing={4}
>
<HStack>
- <DebouncedInput
- param="name"
- size="sm"
- minW={180}
- placeholder="Search"
- />
+ <DebouncedInput param="name" size="sm" placeholder="Search" />
</HStack>
<HStack>
{permissions.can("update", "resources") && (
diff --git a/apps/carbon/app/modules/sales/ui/CustomerTypes/CustomerTypesTableFilters/CustomerTypesTableFilters.tsx b/apps/carbon/app/modules/sales/ui/CustomerTypes/CustomerTypesTableFilters/CustomerTypesTableFilters.tsx
index aa4e2d76c4..47075dbfe8 100644
--- a/apps/carbon/app/modules/sales/ui/CustomerTypes/CustomerTypesTableFilters/CustomerTypesTableFilters.tsx
+++ b/apps/carbon/app/modules/sales/ui/CustomerTypes/CustomerTypesTableFilters/CustomerTypesTableFilters.tsx
@@ -14,12 +14,7 @@ const CustomerTypesTableFilters = () => {
spacing={4}
>
<HStack>
- <DebouncedInput
- param="name"
- size="sm"
- minW={180}
- placeholder="Search"
- />
+ <DebouncedInput param="name" size="sm" placeholder="Search" />
</HStack>
<HStack>
{permissions.can("create", "sales") && (
diff --git a/apps/carbon/app/modules/sales/ui/Customers/CustomersTableFilters/CustomersTableFilters.tsx b/apps/carbon/app/modules/sales/ui/Customers/CustomersTableFilters/CustomersTableFilters.tsx
index f0048f44c3..ece79aa8bd 100644
--- a/apps/carbon/app/modules/sales/ui/Customers/CustomersTableFilters/CustomersTableFilters.tsx
+++ b/apps/carbon/app/modules/sales/ui/Customers/CustomersTableFilters/CustomersTableFilters.tsx
@@ -35,12 +35,7 @@ const CustomersTableFilters = ({
spacing={4}
>
<HStack>
- <DebouncedInput
- param="name"
- size="sm"
- minW={180}
- placeholder="Search"
- />
+ <DebouncedInput param="name" size="sm" placeholder="Search" />
{customerTypeOptions.length > 0 && (
<Select
size="sm"
diff --git a/apps/carbon/app/modules/settings/ui/Sequences/SequencesTableFilters/SequencesTableFilters.tsx b/apps/carbon/app/modules/settings/ui/Sequences/SequencesTableFilters/SequencesTableFilters.tsx
index 4e68dcf773..6dab43348e 100644
--- a/apps/carbon/app/modules/settings/ui/Sequences/SequencesTableFilters/SequencesTableFilters.tsx
+++ b/apps/carbon/app/modules/settings/ui/Sequences/SequencesTableFilters/SequencesTableFilters.tsx
@@ -5,12 +5,7 @@ const SequencesTableFilters = () => {
return (
<HStack className="px-4 py-3 justify-between border-b border-border w-full">
<HStack>
- <DebouncedInput
- param="name"
- size="sm"
- minW={180}
- placeholder="Search"
- />
+ <DebouncedInput param="name" size="sm" placeholder="Search" />
</HStack>
</HStack>
);
diff --git a/apps/carbon/app/modules/users/ui/Customers/CustomerAccountsTableFilters/CustomerAccountsTableFilters.tsx b/apps/carbon/app/modules/users/ui/Customers/CustomerAccountsTableFilters/CustomerAccountsTableFilters.tsx
index aedf9055b1..17d84c9642 100644
--- a/apps/carbon/app/modules/users/ui/Customers/CustomerAccountsTableFilters/CustomerAccountsTableFilters.tsx
+++ b/apps/carbon/app/modules/users/ui/Customers/CustomerAccountsTableFilters/CustomerAccountsTableFilters.tsx
@@ -27,12 +27,7 @@ const CustomerAccountsTableFilters = ({
spacing={4}
>
<HStack>
- <DebouncedInput
- param="name"
- size="sm"
- minW={180}
- placeholder="Search"
- />
+ <DebouncedInput param="name" size="sm" placeholder="Search" />
<Select
size="sm"
value={customerTypeOptions.find(
diff --git a/apps/carbon/app/modules/users/ui/EmployeeTypes/EmployeeTypesTableFilters/EmployeeTypesTableFilters.tsx b/apps/carbon/app/modules/users/ui/EmployeeTypes/EmployeeTypesTableFilters/EmployeeTypesTableFilters.tsx
index ee8a10b775..bdfdfcf3c8 100644
--- a/apps/carbon/app/modules/users/ui/EmployeeTypes/EmployeeTypesTableFilters/EmployeeTypesTableFilters.tsx
+++ b/apps/carbon/app/modules/users/ui/EmployeeTypes/EmployeeTypesTableFilters/EmployeeTypesTableFilters.tsx
@@ -14,12 +14,7 @@ const EmployeeTypesTableFilters = () => {
spacing={4}
>
<HStack>
- <DebouncedInput
- param="name"
- size="sm"
- minW={180}
- placeholder="Search"
- />
+ <DebouncedInput param="name" size="sm" placeholder="Search" />
</HStack>
<HStack>
{permissions.can("create", "users") && (
diff --git a/apps/carbon/app/modules/users/ui/Employees/EmployeesTableFilters/EmployeesTableFilters.tsx b/apps/carbon/app/modules/users/ui/Employees/EmployeesTableFilters/EmployeesTableFilters.tsx
index 545cb26fae..7a9e4f3014 100644
--- a/apps/carbon/app/modules/users/ui/Employees/EmployeesTableFilters/EmployeesTableFilters.tsx
+++ b/apps/carbon/app/modules/users/ui/Employees/EmployeesTableFilters/EmployeesTableFilters.tsx
@@ -27,12 +27,7 @@ const EmployeesTableFilters = ({
spacing={4}
>
<HStack>
- <DebouncedInput
- param="name"
- size="sm"
- minW={180}
- placeholder="Search"
- />
+ <DebouncedInput param="name" size="sm" placeholder="Search" />
<Select
size="sm"
value={employeeTypeOptions.find(
diff --git a/apps/carbon/app/modules/users/ui/Groups/GroupsTableFilters/GroupsTableFilters.tsx b/apps/carbon/app/modules/users/ui/Groups/GroupsTableFilters/GroupsTableFilters.tsx
index 1750eb5514..57ee4e8cea 100644
--- a/apps/carbon/app/modules/users/ui/Groups/GroupsTableFilters/GroupsTableFilters.tsx
+++ b/apps/carbon/app/modules/users/ui/Groups/GroupsTableFilters/GroupsTableFilters.tsx
@@ -14,12 +14,7 @@ const GroupsTableFilters = () => {
spacing={4}
>
<HStack>
- <DebouncedInput
- param="name"
- size="sm"
- minW={180}
- placeholder="Search"
- />
+ <DebouncedInput param="name" size="sm" placeholder="Search" />
</HStack>
<HStack>
{permissions.can("create", "users") && (
diff --git a/apps/carbon/app/modules/users/ui/Suppliers/SupplierAccountsTableFilters/SupplierAccountsTableFilters.tsx b/apps/carbon/app/modules/users/ui/Suppliers/SupplierAccountsTableFilters/SupplierAccountsTableFilters.tsx
index 55bffef506..f5adcecc63 100644
--- a/apps/carbon/app/modules/users/ui/Suppliers/SupplierAccountsTableFilters/SupplierAccountsTableFilters.tsx
+++ b/apps/carbon/app/modules/users/ui/Suppliers/SupplierAccountsTableFilters/SupplierAccountsTableFilters.tsx
@@ -27,12 +27,7 @@ const SupplierAccountsTableFilters = ({
spacing={4}
>
<HStack>
- <DebouncedInput
- param="name"
- size="sm"
- minW={180}
- placeholder="Search"
- />
+ <DebouncedInput param="name" size="sm" placeholder="Search" />
<Select
size="sm"
value={supplierTypeOptions.find(
diff --git a/package-lock.json b/package-lock.json
index ebe890ab81..64a4f96545 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -23037,9 +23037,9 @@
}
},
"node_modules/react-select": {
- "version": "5.7.7",
- "resolved": "https://registry.npmjs.org/react-select/-/react-select-5.7.7.tgz",
- "integrity": "sha512-HhashZZJDRlfF/AKj0a0Lnfs3sRdw/46VJIRd8IbB9/Ovr74+ZIwkAdSBjSPXsFMG+u72c5xShqwLSKIJllzqw==",
+ "version": "5.8.0",
+ "resolved": "https://registry.npmjs.org/react-select/-/react-select-5.8.0.tgz",
+ "integrity": "sha512-TfjLDo58XrhP6VG5M/Mi56Us0Yt8X7xD6cDybC7yoRMUNm7BGO7qk8J0TLQOua/prb8vUOtsfnXZwfm30HGsAA==",
"dependencies": {
"@babel/runtime": "^7.12.0",
"@emotion/cache": "^11.4.0",
@@ -29210,7 +29210,7 @@
"dompurify": "3.0.5",
"is-hotkey": "^0.2.0",
"react-colorful": "^5.6.1",
- "react-select": "^5.5.1",
+ "react-select": "^5.8.0",
"react-window": "^1.8.9",
"tailwind-merge": "^2.2.0",
"tailwind-scrollbar": "^3.0.5",
diff --git a/packages/react/package.json b/packages/react/package.json
index 7c317c8418..ece0b211cb 100644
--- a/packages/react/package.json
+++ b/packages/react/package.json
@@ -76,7 +76,7 @@
"dompurify": "3.0.5",
"is-hotkey": "^0.2.0",
"react-colorful": "^5.6.1",
- "react-select": "^5.5.1",
+ "react-select": "^5.8.0",
"react-window": "^1.8.9",
"tailwind-merge": "^2.2.0",
"tailwind-scrollbar": "^3.0.5",
diff --git a/packages/react/src/Select/chakra-components/containers.tsx b/packages/react/src/Select/chakra-components/containers.tsx
deleted file mode 100644
index 52f3c8bf55..0000000000
--- a/packages/react/src/Select/chakra-components/containers.tsx
+++ /dev/null
@@ -1,160 +0,0 @@
-import type { SystemStyleObject } from "@chakra-ui/react";
-import { Box, useMultiStyleConfig } from "@chakra-ui/react";
-import type {
- ContainerProps,
- GroupBase,
- IndicatorsContainerProps,
- ValueContainerProps,
-} from "react-select";
-
-export const SelectContainer = <
- Option,
- IsMulti extends boolean,
- Group extends GroupBase<Option>
->(
- props: ContainerProps<Option, IsMulti, Group>
-) => {
- const {
- children,
- className,
- cx,
- innerProps,
- isDisabled,
- isRtl,
- hasValue,
- // @ts-ignore
- selectProps: { chakraStyles, borderRadius, maxW, minW, w },
- } = props;
-
- const initialSx: SystemStyleObject = {
- position: "relative",
- direction: isRtl ? "rtl" : undefined,
- ...(isDisabled ? { cursor: "not-allowed" } : {}),
- };
-
- const sx = chakraStyles?.container
- ? chakraStyles.container(initialSx, props)
- : initialSx;
-
- return (
- <Box
- {...innerProps}
- className={cx(
- {
- "--is-disabled": isDisabled,
- "--is-rtl": isRtl,
- "--has-value": hasValue,
- },
- className
- )}
- borderRadius={borderRadius}
- maxW={maxW}
- minW={minW}
- w={w}
- sx={sx}
- >
- {children}
- </Box>
- );
-};
-
-export const ValueContainer = <
- Option,
- IsMulti extends boolean,
- Group extends GroupBase<Option>
->(
- props: ValueContainerProps<Option, IsMulti, Group>
-) => {
- const {
- children,
- className,
- cx,
- isMulti,
- hasValue,
- innerProps,
- selectProps: { size, chakraStyles, isReadOnly },
- } = props;
-
- // Getting the css from input instead of select
- // to fit better with each of the variants
- const inputStyles = useMultiStyleConfig("Input", {
- size,
- });
-
- const initialSx: SystemStyleObject = {
- display: "flex",
- alignItems: "center",
- flex: 1,
- paddingY: "2px",
- paddingX: inputStyles.field.px,
- flexWrap: "wrap",
- WebkitOverflowScrolling: "touch",
- position: "relative",
- overflow: "hidden",
- bg: isReadOnly ? "gray.100" : undefined,
- };
-
- const sx = chakraStyles?.valueContainer
- ? chakraStyles.valueContainer(initialSx, props)
- : initialSx;
-
- return (
- <Box
- {...innerProps}
- className={cx(
- {
- "value-container": true,
- "value-container--is-multi": isMulti,
- "value-container--has-value": hasValue,
- },
- className
- )}
- sx={sx}
- >
- {children}
- </Box>
- );
-};
-
-export const IndicatorsContainer = <
- Option,
- IsMulti extends boolean,
- Group extends GroupBase<Option>
->(
- props: IndicatorsContainerProps<Option, IsMulti, Group>
-) => {
- const {
- children,
- className,
- cx,
- innerProps,
- selectProps: { chakraStyles, isReadOnly },
- } = props;
-
- const initialSx: SystemStyleObject = {
- display: "flex",
- alignItems: "center",
- alignSelf: "stretch",
- flexShrink: 0,
- bg: isReadOnly ? "gray.100" : undefined,
- };
-
- const sx = chakraStyles?.indicatorsContainer
- ? chakraStyles.indicatorsContainer(initialSx, props)
- : initialSx;
-
- return (
- <Box
- {...innerProps}
- className={cx(
- {
- indicators: true,
- },
- className
- )}
- sx={sx}
- >
- {children}
- </Box>
- );
-};
diff --git a/packages/react/src/Select/chakra-components/control.tsx b/packages/react/src/Select/chakra-components/control.tsx
deleted file mode 100644
index b75ed1f0ce..0000000000
--- a/packages/react/src/Select/chakra-components/control.tsx
+++ /dev/null
@@ -1,370 +0,0 @@
-import type { IconProps } from "@chakra-ui/icon";
-import { Icon } from "@chakra-ui/icon";
-import { Box, Divider } from "@chakra-ui/layout";
-import { Spinner } from "@chakra-ui/spinner";
-import type { SystemStyleObject } from "@chakra-ui/system";
-import { useMultiStyleConfig, useStyleConfig } from "@chakra-ui/system";
-import type {
- ClearIndicatorProps,
- ControlProps,
- DropdownIndicatorProps,
- GroupBase,
- IndicatorSeparatorProps,
- LoadingIndicatorProps,
-} from "react-select";
-import { useColor } from "../../hooks";
-import type { SizeProps } from "../types";
-import { useSize } from "../utils";
-
-const Control = <
- Option,
- IsMulti extends boolean,
- Group extends GroupBase<Option>
->(
- props: ControlProps<Option, IsMulti, Group>
-) => {
- const {
- className,
- cx,
- children,
- innerRef,
- innerProps,
- isDisabled,
- isFocused,
- menuIsOpen,
- selectProps: {
- chakraStyles,
- size: sizeProp,
- variant,
- focusBorderColor,
- errorBorderColor,
- isInvalid,
- isReadOnly,
- w,
- },
- } = props;
-
- const size = useSize(sizeProp);
- const white = useColor("white");
- const gray100 = useColor("gray.100");
- const {
- field: { height, h, ...fieldStyles },
- } = useMultiStyleConfig("Input", {
- size,
- variant,
- focusBorderColor,
- errorBorderColor,
- });
-
- /**
- * `@chakra-ui/[email protected]` introduced a breaking change that switched from using `h` to `height` for the Input sizing.
- *
- * We need to keep checking for either to maintain backwards compatibility.
- *
- * @see {@link https://github.com/chakra-ui/chakra-ui/releases/tag/%40chakra-ui%2Ftheme%403.2.0}
- */
- const minH = height || h;
-
- const initialSx: SystemStyleObject = {
- ...fieldStyles,
- position: "relative",
- display: "flex",
- alignItems: "center",
- justifyContent: "space-between",
- flexWrap: "wrap",
- padding: 0,
- overflow: "hidden",
- height: "auto",
- minH,
- minW: 180,
- ...(isDisabled ? { pointerEvents: "none" } : {}),
- backgroundColor: isReadOnly ? gray100 : white,
- };
-
- const sx = chakraStyles?.control
- ? chakraStyles.control(initialSx, props)
- : initialSx;
-
- return (
- <Box
- ref={innerRef}
- className={cx(
- {
- control: true,
- "control--is-disabled": isDisabled,
- "control--is-focused": isFocused,
- "control--menu-is-open": menuIsOpen,
- },
- className
- )}
- sx={sx}
- {...innerProps}
- data-focus={isFocused ? true : undefined}
- data-focus-visible={isFocused ? true : undefined}
- data-invalid={isInvalid ? true : undefined}
- data-disabled={isDisabled ? true : undefined}
- aria-readonly={isReadOnly ? true : undefined}
- width={w}
- >
- {children}
- </Box>
- );
-};
-
-export const IndicatorSeparator = <
- Option,
- IsMulti extends boolean,
- Group extends GroupBase<Option>
->(
- props: IndicatorSeparatorProps<Option, IsMulti, Group>
-) => {
- const {
- className,
- cx,
- selectProps: { chakraStyles, useBasicStyles, variant },
- } = props;
-
- const initialSx: SystemStyleObject = {
- opacity: 1,
- ...(useBasicStyles || variant !== "outline" ? { display: "none" } : {}),
- };
-
- const sx = chakraStyles?.indicatorSeparator
- ? chakraStyles.indicatorSeparator(initialSx, props)
- : initialSx;
-
- return (
- <Divider
- className={cx({ "indicator-separator": true }, className)}
- sx={sx}
- orientation="vertical"
- />
- );
-};
-
-/**
- * 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}
- */
-export const DownChevron = (props: IconProps) => (
- <Icon {...props}>
- <path
- fill="currentColor"
- d="M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z"
- />
- </Icon>
-);
-
-export const DropdownIndicator = <
- Option,
- IsMulti extends boolean,
- Group extends GroupBase<Option>
->(
- props: DropdownIndicatorProps<Option, IsMulti, Group>
-) => {
- const {
- children,
- className,
- cx,
- innerProps,
- selectProps: {
- chakraStyles,
- useBasicStyles,
- size: sizeProp,
- focusBorderColor,
- errorBorderColor,
- variant,
- },
- } = props;
-
- const size = useSize(sizeProp);
- const inputStyles = useMultiStyleConfig("Input", {
- size,
- variant,
- focusBorderColor,
- errorBorderColor,
- });
-
- const iconSizes: SizeProps = {
- sm: "16px",
- md: "20px",
- lg: "24px",
- };
- const iconSize = iconSizes[size];
-
- const initialSx: SystemStyleObject = {
- ...inputStyles.addon,
- display: "flex",
- alignItems: "center",
- justifyContent: "center",
- height: "100%",
- borderRadius: 0,
- borderWidth: 0,
- fontSize: iconSize,
- ...(useBasicStyles && {
- background: "transparent",
- padding: 0,
- width: 6,
- marginRight: 2,
- marginLeft: 1,
- cursor: "inherit",
- }),
- };
- const sx = chakraStyles?.dropdownIndicator
- ? chakraStyles.dropdownIndicator(initialSx, props)
- : initialSx;
-
- const initialIconStyles = {
- height: "1em",
- width: "1em",
- };
- const iconSx: SystemStyleObject = chakraStyles?.downChevron
- ? chakraStyles.downChevron(initialIconStyles, props)
- : initialIconStyles;
-
- return (
- <Box
- {...innerProps}
- className={cx(
- {
- indicator: true,
- "dropdown-indicator": true,
- },
- className
- )}
- sx={sx}
- >
- {children || <DownChevron sx={iconSx} />}
- </Box>
- );
-};
-
-/**
- * Borrowed from Chakra UI source
- *
- * @see {@link https://github.com/chakra-ui/chakra-ui/blob/13c6d2e08b61e179773be4722bb81173dd599306/packages/close-button/src/close-button.tsx#L14}
- */
-export const CrossIcon = (props: IconProps) => (
- <Icon focusable="false" aria-hidden {...props}>
- <path
- fill="currentColor"
- d="M.439,21.44a1.5,1.5,0,0,0,2.122,2.121L11.823,14.3a.25.25,0,0,1,.354,0l9.262,9.263a1.5,1.5,0,1,0,2.122-2.121L14.3,12.177a.25.25,0,0,1,0-.354l9.263-9.262A1.5,1.5,0,0,0,21.439.44L12.177,9.7a.25.25,0,0,1-.354,0L2.561.44A1.5,1.5,0,0,0,.439,2.561L9.7,11.823a.25.25,0,0,1,0,.354Z"
- />
- </Icon>
-);
-
-export const ClearIndicator = <
- Option,
- IsMulti extends boolean,
- Group extends GroupBase<Option>
->(
- props: ClearIndicatorProps<Option, IsMulti, Group>
-) => {
- const {
- children,
- className,
- cx,
- innerProps,
- selectProps: { chakraStyles, size: sizeProp },
- } = props;
-
- const size = useSize(sizeProp);
- const closeButtonStyles = useStyleConfig("CloseButton", {
- size,
- });
-
- const initialSx: SystemStyleObject = {
- ...closeButtonStyles,
- marginX: 1,
- display: "flex",
- alignItems: "center",
- justifyContent: "center",
- flexShrink: 0,
- cursor: "pointer",
- };
- const sx = chakraStyles?.clearIndicator
- ? chakraStyles.clearIndicator(initialSx, props)
- : initialSx;
-
- const initialIconStyles: SystemStyleObject = {
- width: "1em",
- height: "1em",
- };
- const iconSx: SystemStyleObject = chakraStyles?.crossIcon
- ? chakraStyles.crossIcon(initialIconStyles, props)
- : initialIconStyles;
-
- return (
- <Box
- role="button"
- className={cx(
- {
- indicator: true,
- "clear-indicator": true,
- },
- className
- )}
- sx={sx}
- aria-label="Clear selected options"
- {...innerProps}
- >
- {children || <CrossIcon sx={iconSx} />}
- </Box>
- );
-};
-
-export const LoadingIndicator = <
- Option,
- IsMulti extends boolean,
- Group extends GroupBase<Option>
->(
- props: LoadingIndicatorProps<Option, IsMulti, Group>
-) => {
- const {
- className,
- cx,
- innerProps,
- selectProps: { chakraStyles, size: sizeProp },
- color,
- emptyColor,
- speed,
- thickness,
- spinnerSize: propsSpinnerSize,
- } = props;
-
- const size = useSize(sizeProp);
- const spinnerSizes: SizeProps<string> = {
- sm: "xs",
- md: "sm",
- lg: "md",
- };
- const spinnerSize = spinnerSizes[size];
-
- const initialSx: SystemStyleObject = { marginRight: 3 };
-
- const sx = chakraStyles?.loadingIndicator
- ? chakraStyles.loadingIndicator(initialSx, props)
- : initialSx;
-
- return (
- <Spinner
- className={cx(
- {
- indicator: true,
- "loading-indicator": true,
- },
- className
- )}
- sx={sx}
- {...innerProps}
- size={propsSpinnerSize || spinnerSize}
- color={color}
- emptyColor={emptyColor}
- speed={speed}
- thickness={thickness}
- />
- );
-};
-
-export default Control;
diff --git a/packages/react/src/Select/chakra-components/input.tsx b/packages/react/src/Select/chakra-components/input.tsx
deleted file mode 100644
index ab6d16a60b..0000000000
--- a/packages/react/src/Select/chakra-components/input.tsx
+++ /dev/null
@@ -1,83 +0,0 @@
-import type { SystemStyleObject } from "@chakra-ui/react";
-import { Box, chakra } from "@chakra-ui/react";
-import type { GroupBase, InputProps } from "react-select";
-import { cleanCommonProps } from "../utils";
-
-const Input = <
- Option,
- IsMulti extends boolean,
- Group extends GroupBase<Option>
->(
- props: InputProps<Option, IsMulti, Group>
-) => {
- const {
- className,
- cx,
- value,
- selectProps: { chakraStyles, isReadOnly, isRequired },
- } = props;
- const { innerRef, isDisabled, isHidden, inputClassName, ...innerProps } =
- cleanCommonProps(props);
-
- const spacingSx: SystemStyleObject = {
- gridArea: "1 / 2",
- font: "inherit",
- minW: "2px",
- border: 0,
- margin: 0,
- outline: 0,
- };
-
- const initialContainerSx: SystemStyleObject = {
- flex: "1 1 auto",
- display: "inline-grid",
- gridArea: "1 / 1 / 2 / 3",
- gridTemplateColumns: "0 min-content",
- color: "inherit",
- marginX: "0.125rem",
- paddingY: "0.125rem",
- _after: {
- content: 'attr(data-value) " "',
- visibility: "hidden",
- whiteSpace: "pre",
- padding: 0,
- ...spacingSx,
- },
- };
- const containerSx = chakraStyles?.inputContainer
- ? chakraStyles.inputContainer(initialContainerSx, props)
- : initialContainerSx;
-
- const initialInputSx: SystemStyleObject = {
- label: "input",
- color: "inherit",
- background: 0,
- opacity: isHidden ? 0 : 1,
- width: "100%",
- ...spacingSx,
- };
- const inputSx = chakraStyles?.input
- ? chakraStyles.input(initialInputSx, props)
- : initialInputSx;
-
- return (
- <Box
- className={cx({ "input-container": true }, className)}
- data-value={value || ""}
- sx={containerSx}
- >
- <chakra.input
- className={cx({ input: true }, inputClassName)}
- ref={innerRef}
- sx={inputSx}
- disabled={isDisabled}
- readOnly={isReadOnly ? true : undefined}
- aria-readonly={isReadOnly ? true : undefined}
- aria-required={isRequired ? true : undefined}
- {...innerProps}
- />
- </Box>
- );
-};
-
-export default Input;
diff --git a/packages/react/src/Select/components/containers.tsx b/packages/react/src/Select/components/containers.tsx
new file mode 100644
index 0000000000..98a464fb02
--- /dev/null
+++ b/packages/react/src/Select/components/containers.tsx
@@ -0,0 +1,137 @@
+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/Select/components/control.tsx b/packages/react/src/Select/components/control.tsx
new file mode 100644
index 0000000000..26f3de8299
--- /dev/null
+++ b/packages/react/src/Select/components/control.tsx
@@ -0,0 +1,238 @@
+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/Select/chakra-components/index.tsx b/packages/react/src/Select/components/index.tsx
similarity index 100%
rename from packages/react/src/Select/chakra-components/index.tsx
rename to packages/react/src/Select/components/index.tsx
diff --git a/packages/react/src/Select/components/input.tsx b/packages/react/src/Select/components/input.tsx
new file mode 100644
index 0000000000..adba3faa98
--- /dev/null
+++ b/packages/react/src/Select/components/input.tsx
@@ -0,0 +1,57 @@
+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/Select/chakra-components/menu.tsx b/packages/react/src/Select/components/menu.tsx
similarity index 88%
rename from packages/react/src/Select/chakra-components/menu.tsx
rename to packages/react/src/Select/components/menu.tsx
index cce0a0c160..2aafa85d87 100644
--- a/packages/react/src/Select/chakra-components/menu.tsx
+++ b/packages/react/src/Select/components/menu.tsx
@@ -25,15 +25,7 @@ const alignToControl = (placement: CoercedMenuPlacement) => {
const Menu = <Option, IsMulti extends boolean, Group extends GroupBase<Option>>(
props: MenuProps<Option, IsMulti, Group>
) => {
- const {
- className,
- cx,
- children,
- innerProps,
- innerRef,
- placement,
- selectProps: { chakraStyles },
- } = props;
+ const { className, cx, children, innerProps, innerRef, placement } = props;
const initialSx: SystemStyleObject = {
position: "absolute",
@@ -43,9 +35,7 @@ const Menu = <Option, IsMulti extends boolean, Group extends GroupBase<Option>>(
zIndex: 1,
};
- const sx = chakraStyles?.menu
- ? chakraStyles.menu(initialSx, props)
- : initialSx;
+ const sx = initialSx;
return (
<ChakraMenu>
@@ -87,13 +77,7 @@ export const MenuList = <
maxHeight,
isMulti,
innerProps,
- selectProps: {
- chakraStyles,
- size: sizeProp,
- variant,
- focusBorderColor,
- errorBorderColor,
- },
+ selectProps: { size: sizeProp, focusBorderColor, errorBorderColor },
} = props;
const list = React.useRef<List>(null);
@@ -105,7 +89,6 @@ export const MenuList = <
const size = useSize(sizeProp);
const inputStyles = useMultiStyleConfig("Input", {
size,
- variant,
focusBorderColor,
errorBorderColor,
});
@@ -123,9 +106,7 @@ export const MenuList = <
WebkitOverflowScrolling: "touch",
};
- const sx = chakraStyles?.menuList
- ? chakraStyles.menuList(initialSx, props)
- : initialSx;
+ const sx = initialSx;
const children = React.useMemo<React.ReactElement[]>(() => {
const _children = React.Children.toArray(
@@ -207,7 +188,7 @@ export const LoadingMessage = <
className,
cx,
innerProps,
- selectProps: { chakraStyles, size: sizeProp },
+ selectProps: { size: sizeProp },
} = props;
const size = useSize(sizeProp);
@@ -225,9 +206,7 @@ export const LoadingMessage = <
fontSize: size,
};
- const sx = chakraStyles?.loadingMessage
- ? chakraStyles.loadingMessage(initialSx, props)
- : initialSx;
+ const sx = initialSx;
return (
<Box
@@ -258,7 +237,7 @@ export const NoOptionsMessage = <
className,
cx,
innerProps,
- selectProps: { chakraStyles, size: sizeProp },
+ selectProps: { size: sizeProp },
} = props;
const size = useSize(sizeProp);
@@ -276,9 +255,7 @@ export const NoOptionsMessage = <
fontSize: size,
};
- const sx = chakraStyles?.noOptionsMessage
- ? chakraStyles.noOptionsMessage(initialSx, props)
- : initialSx;
+ const sx = initialSx;
return (
<Box
@@ -318,9 +295,7 @@ export const Group = <
getClassNames,
} = props;
- const { chakraStyles } = selectProps;
-
- const sx = chakraStyles?.group ? chakraStyles.group({}, props) : {};
+ const sx = {};
return (
<Box {...innerProps} className={cx({ group: true }, className)} sx={sx}>
@@ -350,7 +325,7 @@ export const GroupHeading = <
cx,
className,
children,
- selectProps: { chakraStyles, size: sizeProp, hasStickyGroupHeaders },
+ selectProps: { size: sizeProp, hasStickyGroupHeaders },
} = props;
const menuStyles = useMultiStyleConfig("Menu");
@@ -380,9 +355,7 @@ export const GroupHeading = <
zIndex: 1,
};
- const sx = chakraStyles?.groupHeading
- ? chakraStyles.groupHeading(initialSx, props)
- : initialSx;
+ const sx = initialSx;
return (
<Box className={cx({ "group-heading": true }, className)} sx={sx}>
@@ -422,7 +395,6 @@ export const Option = <
isDisabled,
isSelected,
selectProps: {
- chakraStyles,
size: sizeProp,
isMulti,
hideSelectedOptions,
@@ -441,11 +413,6 @@ export const Option = <
lg: "0.5rem 1rem",
};
- /**
- * Use the same selected color as the border of the select component
- *
- * @see {@link https://github.com/chakra-ui/chakra-ui/blob/13c6d2e08b61e179773be4722bb81173dd599306/packages/theme/src/components/input.ts#L73}
- */
const selectedBg = useColorModeValue(
`${selectedOptionColorScheme}.500`,
`${selectedOptionColorScheme}.300`
@@ -479,9 +446,7 @@ export const Option = <
...(isDisabled && { _active: {} }),
};
- const sx = chakraStyles?.option
- ? chakraStyles.option(initialSx, props)
- : initialSx;
+ const sx = initialSx;
return (
<Box
diff --git a/packages/react/src/Select/chakra-components/multi-value.tsx b/packages/react/src/Select/components/multi-value.tsx
similarity index 87%
rename from packages/react/src/Select/chakra-components/multi-value.tsx
rename to packages/react/src/Select/components/multi-value.tsx
index 6e1978da87..5b0bd530fc 100644
--- a/packages/react/src/Select/chakra-components/multi-value.tsx
+++ b/packages/react/src/Select/components/multi-value.tsx
@@ -1,5 +1,5 @@
import type { IconProps, SystemStyleObject } from "@chakra-ui/react";
-import { Box, chakra, Icon, useMultiStyleConfig } from "@chakra-ui/react";
+import { Box, Icon, chakra, useMultiStyleConfig } from "@chakra-ui/react";
import type {
GroupBase,
@@ -39,7 +39,7 @@ const MultiValue = <
const { Container, Label, Remove } = components;
- const { chakraStyles, colorScheme, tagVariant, size } = selectProps;
+ const { size } = selectProps;
let optionColorScheme = "";
let optionVariant = "";
@@ -59,9 +59,8 @@ const MultiValue = <
const tagStyles = useMultiStyleConfig("Tag", {
size,
- colorScheme: optionColorScheme || colorScheme,
- variant:
- optionVariant || tagVariant || (optionIsFixed ? "solid" : "subtle"),
+ colorScheme: optionColorScheme,
+ variant: optionVariant || (optionIsFixed ? "solid" : "subtle"),
});
const containerInitialSx: SystemStyleObject = {
@@ -72,14 +71,10 @@ const MultiValue = <
maxWidth: "100%",
margin: "0.125rem",
};
- const containerSx: SystemStyleObject = chakraStyles?.multiValue
- ? chakraStyles.multiValue(containerInitialSx, props)
- : containerInitialSx;
+ const containerSx: SystemStyleObject = containerInitialSx;
const labelInitialSx: SystemStyleObject = tagStyles.label;
- const labelSx = chakraStyles?.multiValueLabel
- ? chakraStyles.multiValueLabel(labelInitialSx, props)
- : labelInitialSx;
+ const labelSx = labelInitialSx;
const removeInitialSx: SystemStyleObject = {
display: "flex",
@@ -87,9 +82,7 @@ const MultiValue = <
justifyContent: "center",
...tagStyles.closeButton,
};
- const removeSx = chakraStyles?.multiValueRemove
- ? chakraStyles.multiValueRemove(removeInitialSx, props)
- : removeInitialSx;
+ const removeSx = removeInitialSx;
return (
<Container
diff --git a/packages/react/src/Select/chakra-components/placeholder.tsx b/packages/react/src/Select/components/placeholder.tsx
similarity index 100%
rename from packages/react/src/Select/chakra-components/placeholder.tsx
rename to packages/react/src/Select/components/placeholder.tsx
diff --git a/packages/react/src/Select/chakra-components/single-value.tsx b/packages/react/src/Select/components/single-value.tsx
similarity index 79%
rename from packages/react/src/Select/chakra-components/single-value.tsx
rename to packages/react/src/Select/components/single-value.tsx
index a69ec5a00e..5b7a437a5c 100644
--- a/packages/react/src/Select/chakra-components/single-value.tsx
+++ b/packages/react/src/Select/components/single-value.tsx
@@ -9,14 +9,7 @@ const SingleValue = <
>(
props: SingleValueProps<Option, IsMulti, Group>
) => {
- const {
- children,
- className,
- cx,
- isDisabled,
- innerProps,
- selectProps: { chakraStyles },
- } = props;
+ const { children, className, cx, isDisabled, innerProps } = props;
const initialSx: SystemStyleObject = {
label: "singleValue",
@@ -30,9 +23,7 @@ const SingleValue = <
transform: "translateY(-50%)",
};
- const sx = chakraStyles?.singleValue
- ? chakraStyles.singleValue(initialSx, props)
- : initialSx;
+ const sx = initialSx;
return (
<Box
diff --git a/packages/react/src/Select/index.ts b/packages/react/src/Select/index.ts
index 29edbe4ff4..3f8e86b881 100644
--- a/packages/react/src/Select/index.ts
+++ b/packages/react/src/Select/index.ts
@@ -1,32 +1,31 @@
import "./module-augmentation";
-export { default as Select } from "./select/select";
-export { default as CreatableSelect } from "./select/creatable-select";
-export { default as AsyncSelect } from "./select/async-select";
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 chakraComponents } from "./chakra-components";
-export { default as useChakraSelectProps } from "./use-chakra-select-props";
+export { default as carbonComponents } from "./components";
+export { default as useSelectProps } from "./useSelectProps";
-export type { SelectComponent } from "./select/select";
-export type { CreatableSelectComponent } from "./select/creatable-select";
-export type { AsyncSelectComponent } from "./select/async-select";
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 {
- SizeProps,
- Size,
- TagVariant,
+ OptionBase,
SelectedOptionStyle,
+ Size,
+ SizeProps,
StylesFunction,
- ChakraStylesConfig,
- OptionBase,
+ TagVariant,
} from "./types";
// Forward all available exports from the original `react-select` package
export * from "react-select";
export { useAsync } from "react-select/async";
-export { useCreatable } from "react-select/creatable";
export type { AsyncProps } from "react-select/async";
-export type { CreatableProps } from "react-select/creatable";
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/Select/module-augmentation.ts b/packages/react/src/Select/module-augmentation.ts
index fa60c30697..e40babe681 100644
--- a/packages/react/src/Select/module-augmentation.ts
+++ b/packages/react/src/Select/module-augmentation.ts
@@ -1,13 +1,6 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
-import type { SystemStyleObject } from "@chakra-ui/system";
-import type { GroupBase, StylesConfig, ThemeConfig } from "react-select";
-import type {
- ChakraStylesConfig,
- SelectedOptionStyle,
- SizeProp,
- TagVariant,
- Variant,
-} from "./types";
+import type { GroupBase } from "react-select";
+import type { SelectedOptionStyle } from "./types";
/**
* Module augmentation is used to add extra props to the existing interfaces
@@ -21,21 +14,33 @@ declare module "react-select/dist/declarations/src/Select" {
IsMulti extends boolean,
Group extends GroupBase<Option>
> {
- w?: string | number;
+ /**
+ * 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 chakra Input
+ * 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`
- * @see {@link https://github.com/csandman/chakra-react-select#size--options-responsivevaluesm--md--lg--default-md}
- * @see {@link https://chakra-ui.com/docs/components/input#changing-the-size-of-the-input}
*/
- size?: SizeProp;
+ size?: "sm" | "md" | "lg";
/**
* Determines whether or not to style the input with the invalid border
@@ -44,9 +49,6 @@ declare module "react-select/dist/declarations/src/Select" {
* If the `aria-invalid` prop is not passed, this prop will also set that
*
* @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}
*/
isInvalid?: boolean;
@@ -71,31 +73,6 @@ declare module "react-select/dist/declarations/src/Select" {
*/
isRequired?: boolean;
- /**
- * A color name that matches a key from your chakra theme and will
- * determine the color scheme of your `MultiValue` component.
- *
- * The styling matches the chakra `Tag` component.
- *
- * @defaultValue `"gray"`
- * @see {@link https://github.com/csandman/chakra-react-select#colorscheme}
- * @see {@link https://chakra-ui.com/docs/components/tag/props}
- */
- colorScheme?: string;
-
- /**
- * The `variant` prop that will be forwarded to your `MultiValue` component
- * which is represented by a chakra `Tag`. You can also use any custom
- * variants you have added to your theme.
- *
- * Options: "subtle" | "solid" | "outline"
- *
- * @defaultValue `subtle`
- * @see {@link https://github.com/csandman/chakra-react-select#tagvariant--options-subtle--solid--outline--default-subtle}
- * @see {@link https://chakra-ui.com/docs/data-display/tag#props}
- */
- tagVariant?: TagVariant;
-
/**
* Passing `true` for this prop will make the group headers
* `position: sticky` and keep them stuck to the top while their
@@ -114,89 +91,8 @@ declare module "react-select/dist/declarations/src/Select" {
* Options: `color` | `check`
*
* @defaultValue `color`
- * @see {@link https://github.com/csandman/chakra-react-select#selectedoptionstyle--options-color--check--default-color}
- * @see {@link https://chakra-ui.com/docs/components/menu#menu-option-groups}
*/
selectedOptionStyle?: SelectedOptionStyle;
-
- /**
- * The color scheme to style an option with when using the
- * `selectedOptionStyle="color"` prop. Uses the `500` value in light mode
- * and the `300` value in dark mode.
- *
- * @defaultValue `blue`
- * @see {@link https://github.com/csandman/chakra-react-select#selectedoptioncolorscheme--default-blue}
- */
- selectedOptionColorScheme?: string;
-
- /**
- * @deprecated Replaced by {@link selectedOptionColorScheme}
- */
- selectedOptionColor?: string;
-
- /**
- * The color value to style the border of the `Control` with when the
- * select is focused.
- *
- * @defaultValue Light mode: `blue.500` | Dark mode: `blue.300`
- * @see {@link https://github.com/csandman/chakra-react-select#focusbordercolor--default-blue500--errorbordercolor--default-red500}
- * @see {@link https://chakra-ui.com/docs/components/input#changing-the-focus-and-error-border-colors}
- */
- focusBorderColor?: string;
-
- /**
- * The color value to style the border of the `Control` with when
- * `isInvalid` is passed to the select.
- *
- * @defaultValue Light mode: `red.500` | Dark mode: `red.300`
- * @see {@link https://github.com/csandman/chakra-react-select#focusbordercolor--default-blue500--errorbordercolor--default-red500}
- * @see {@link https://chakra-ui.com/docs/components/input#changing-the-focus-and-error-border-colors}
- */
- errorBorderColor?: string;
-
- /**
- * Style transformation methods for each of the rendered components using,
- * Chakra's `SystemStyleObject` and the props passed into each component.
- *
- * @see {@link https://github.com/csandman/chakra-react-select#chakrastyles}
- * @see {@link https://react-select.com/styles#style-object}
- */
- chakraStyles?: ChakraStylesConfig<Option, IsMulti, Group>;
-
- /**
- * If passed, the dropdown indicator will be styled the same as Chakra UI's
- * `Select` component.
- *
- * @defaultValue `false`
- * @see {@link https://github.com/csandman/chakra-react-select#usebasicstyles--default-false}
- * @see {@link https://chakra-ui.com/docs/components/select}
- */
- useBasicStyles?: boolean;
-
- /**
- * The main style variant of the `Select` component. This will use styles
- * from Chakra's `Input` component and any custom variants you have added to
- * your theme may be used.
- *
- * Options: `outline` | `filled` | `flushed` | `unstyled`
- *
- * @defaultValue `outline`
- * @see {@link https://chakra-ui.com/docs/components/select#changing-the-appearance}
- * @see {@link https://github.com/csandman/chakra-react-select#variant--options-outline--filled--flushed--unstyled--default-outline}
- */
- variant?: Variant;
-
- /**
- * @deprecated This prop is not used in `chakra-react-select`, use
- * {@link chakraStyles} instead.
- */
- styles: StylesConfig<Option, IsMulti, Group>;
-
- /**
- * @deprecated This prop is not used in `chakra-react-select`, all theme
- * values are pulled from your Chakra UI theme.
- */
- theme?: ThemeConfig;
}
}
@@ -205,17 +101,13 @@ declare module "react-select/dist/declarations/src/components/MultiValue" {
Option,
IsMulti extends boolean,
Group extends GroupBase<Option>
- > {
- sx: SystemStyleObject;
- }
+ > {}
export interface MultiValueGenericProps<
Option,
IsMulti extends boolean,
Group extends GroupBase<Option>
- > {
- sx: SystemStyleObject;
- }
+ > {}
export interface MultiValueRemoveProps<
Option,
@@ -223,7 +115,6 @@ declare module "react-select/dist/declarations/src/components/MultiValue" {
Group extends GroupBase<Option>
> {
isFocused: boolean;
- sx: SystemStyleObject;
}
}
@@ -233,29 +124,10 @@ declare module "react-select/dist/declarations/src/components/indicators" {
IsMulti extends boolean,
Group extends GroupBase<Option>
> {
- /**
- * The color of the filled in area of the spinner.
- *
- * Defaults to your Chakra theme's text color.
- *
- * @defaultValue Light mode: `gray.700` | Dark mode: `whiteAlpha.900`
- */
- color?: string;
-
- /**
- * The color of the empty area in the spinner.
- *
- * @defaultValue `transparent`
- * @see {@link https://chakra-ui.com/docs/components/spinner#spinner-with-empty-area-color}
- */
- emptyColor?: string;
-
/**
* The size prop for the Chakra `<Spinner />` component.
*
* Defaults to one size smaller than the overall Select's size.
- *
- * @see {@link https://chakra-ui.com/docs/components/spinner#spinner-with-different-size}
*/
spinnerSize?: "xs" | "sm" | "md" | "lg" | "xl";
diff --git a/packages/react/src/Select/select/async-creatable-select.tsx b/packages/react/src/Select/select/async-creatable-select.tsx
index 9df47099b9..069922dfbd 100644
--- a/packages/react/src/Select/select/async-creatable-select.tsx
+++ b/packages/react/src/Select/select/async-creatable-select.tsx
@@ -3,7 +3,7 @@ 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 useChakraSelectProps from "../use-chakra-select-props";
+import useSelectProps from "../useSelectProps";
export type AsyncCreatableSelectComponent = <
Option = unknown,
@@ -23,7 +23,7 @@ const AsyncCreatableSelect = forwardRef(
| MutableRefObject<SelectInstance<Option, IsMulti, Group> | null>
| null
) => {
- const chakraSelectProps = useChakraSelectProps(props);
+ const chakraSelectProps = useSelectProps(props);
return <AsyncCreatableReactSelect ref={ref} {...chakraSelectProps} />;
}
diff --git a/packages/react/src/Select/select/async-select.tsx b/packages/react/src/Select/select/async-select.tsx
index 23f8cfe21a..9b62c43ca3 100644
--- a/packages/react/src/Select/select/async-select.tsx
+++ b/packages/react/src/Select/select/async-select.tsx
@@ -3,7 +3,7 @@ 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 useChakraSelectProps from "../use-chakra-select-props";
+import useSelectProps from "../useSelectProps";
export type AsyncSelectComponent = <
Option = unknown,
@@ -23,7 +23,7 @@ const AsyncSelect = forwardRef(
| MutableRefObject<SelectInstance<Option, IsMulti, Group> | null>
| null
) => {
- const chakraSelectProps = useChakraSelectProps(props);
+ const chakraSelectProps = useSelectProps(props);
return <AsyncReactSelect ref={ref} {...chakraSelectProps} />;
}
diff --git a/packages/react/src/Select/select/creatable-select.tsx b/packages/react/src/Select/select/creatable-select.tsx
index cb7d41a34c..a13df987c1 100644
--- a/packages/react/src/Select/select/creatable-select.tsx
+++ b/packages/react/src/Select/select/creatable-select.tsx
@@ -3,7 +3,7 @@ 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 useChakraSelectProps from "../use-chakra-select-props";
+import useSelectProps from "../useSelectProps";
export type CreatableSelectComponent = <
Option = unknown,
@@ -23,7 +23,7 @@ const CreatableSelect = forwardRef(
| MutableRefObject<SelectInstance<Option, IsMulti, Group> | null>
| null
) => {
- const chakraSelectProps = useChakraSelectProps(props);
+ const chakraSelectProps = useSelectProps(props);
return <CreatableReactSelect ref={ref} {...chakraSelectProps} />;
}
diff --git a/packages/react/src/Select/select/select.tsx b/packages/react/src/Select/select/select.tsx
index 5b9c4343f3..98db998abf 100644
--- a/packages/react/src/Select/select/select.tsx
+++ b/packages/react/src/Select/select/select.tsx
@@ -2,7 +2,7 @@ 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 useChakraSelectProps from "../use-chakra-select-props";
+import useSelectProps from "../useSelectProps";
export type SelectComponent = <
Option = unknown,
@@ -22,7 +22,7 @@ const Select = forwardRef(
| MutableRefObject<SelectInstance<Option, IsMulti, Group> | null>
| null
) => {
- const chakraSelectProps = useChakraSelectProps(props);
+ const chakraSelectProps = useSelectProps(props);
return <ReactSelect ref={ref} {...chakraSelectProps} />;
}
diff --git a/packages/react/src/Select/use-chakra-select-props.ts b/packages/react/src/Select/use-chakra-select-props.ts
deleted file mode 100644
index 3b7509432a..0000000000
--- a/packages/react/src/Select/use-chakra-select-props.ts
+++ /dev/null
@@ -1,106 +0,0 @@
-import { useFormControl } from "@chakra-ui/form-control";
-import { useTheme } from "@chakra-ui/system";
-import type { GroupBase, Props } from "react-select";
-import { createFilter } from "react-select";
-import chakraComponents from "./chakra-components";
-import type { SelectedOptionStyle } from "./types";
-
-const useChakraSelectProps = <
- Option,
- IsMulti extends boolean = false,
- Group extends GroupBase<Option> = GroupBase<Option>
->({
- components = {},
- theme,
- size,
- colorScheme = "gray",
- isDisabled,
- isInvalid,
- isReadOnly,
- isRequired,
- inputId,
- tagVariant,
- selectedOptionStyle = "color",
- selectedOptionColorScheme,
- selectedOptionColor,
- variant,
- filterOption,
- focusBorderColor,
- errorBorderColor,
- chakraStyles = {},
- onFocus,
- onBlur,
- menuIsOpen,
- ...props
-}: Props<Option, IsMulti, Group>): Props<Option, IsMulti, Group> => {
- const chakraTheme = useTheme();
- const { variant: defaultVariant } = chakraTheme.components.Input.defaultProps;
-
- // Combine the props passed into the component with the props that can be set
- // on a surrounding form control to get the values of `isDisabled` and
- // `isInvalid`
- const inputProps = useFormControl({
- id: inputId,
- isDisabled,
- isInvalid,
- isRequired,
- isReadOnly,
- onFocus,
- onBlur,
- });
-
- // Unless `menuIsOpen` is controlled, disable it if the select is readonly
- const realMenuIsOpen =
- menuIsOpen ?? (inputProps.readOnly ? false : undefined);
-
- // Ensure that the selected option style is either `color` or `check`
- let realSelectedOptionStyle: SelectedOptionStyle = selectedOptionStyle;
- const selectedOptionStyleOptions: SelectedOptionStyle[] = ["color", "check"];
- if (!selectedOptionStyleOptions.includes(selectedOptionStyle)) {
- realSelectedOptionStyle = "color";
- }
-
- // Ensure that the color used for the selected options is a string
- let realSelectedOptionColorScheme: string =
- selectedOptionColorScheme || selectedOptionColor || "gray";
- if (typeof realSelectedOptionColorScheme !== "string") {
- realSelectedOptionColorScheme = "gray";
- }
-
- const select: Props<Option, IsMulti, Group> = {
- // Allow overriding of custom components
- components: {
- ...chakraComponents,
- ...components,
- },
- // Custom select props
- colorScheme,
- size,
- tagVariant,
- selectedOptionStyle: realSelectedOptionStyle,
- selectedOptionColorScheme: realSelectedOptionColorScheme,
- variant: variant ?? defaultVariant,
- chakraStyles,
- focusBorderColor,
- errorBorderColor,
- // 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,
- useBasicStyles: true,
- 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 useChakraSelectProps;
diff --git a/packages/react/src/Select/useSelectProps.ts b/packages/react/src/Select/useSelectProps.ts
new file mode 100644
index 0000000000..f536cb5ab8
--- /dev/null
+++ b/packages/react/src/Select/useSelectProps.ts
@@ -0,0 +1,72 @@
+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> => {
+ console.log({ isReadOnly });
+ const inputProps = {
+ id: inputId,
+ disabled: isDisabled,
+ readOnly: isReadOnly,
+ required: isRequired,
+ "aria-invalid": ariaAttr(isInvalid),
+ "aria-required": ariaAttr(isRequired),
+ "aria-readonly": ariaAttr(isReadOnly),
+ onFocus,
+ onBlur,
+ };
+
+ console.log({ inputProps });
+
+ // 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/turbo.json b/turbo.json
index 9bdb4537b2..84eafde49f 100644
--- a/turbo.json
+++ b/turbo.json
@@ -16,6 +16,9 @@
"dependsOn": ["^build"],
"outputs": ["api/index.js", "api/build/**", "public/build/**"]
},
+ "@carbon/documents#build": {
+ "dependsOn": ["^build"]
+ },
"test": {
"outputs": ["coverage/**"],
"dependsOn": []