`.
+
+- Added the possibility to use sections with `` and ``
+- Refactored the `` (from ``) to fit our API, no need for the extra `` anymore. Instead you can do ``, same for the other components
+- Renamed `- ` to `
);
@@ -174,10 +174,10 @@ test('uses field structure', () => {
test('opens the suggestions on user input', async () => {
render(
- Spinach
- Carrots
- Broccoli
- Garlic
+ Spinach
+ Carrots
+ Broccoli
+ Garlic
);
@@ -191,10 +191,10 @@ test('opens the suggestions on user input', async () => {
test('opens the suggestions on focus', async () => {
render(
- Spinach
- Carrots
- Broccoli
- Garlic
+ Spinach
+ Carrots
+ Broccoli
+ Garlic
);
@@ -208,10 +208,10 @@ test('opens the suggestions on focus', async () => {
test('opens the suggestions on arrow down (manual)', async () => {
render(
- Spinach
- Carrots
- Broccoli
- Garlic
+ Spinach
+ Carrots
+ Broccoli
+ Garlic
);
@@ -225,10 +225,10 @@ test('opens the suggestions on arrow down (manual)', async () => {
test('shows suggestions based on user input', async () => {
render(
- Spinach
- Carrots
- Broccoli
- Garlic
+ Spinach
+ Carrots
+ Broccoli
+ Garlic
);
@@ -245,10 +245,10 @@ test('shows suggestions based on user input', async () => {
test('supports disabling suggestions', async () => {
render(
- Spinach
- Carrots
- Broccoli
- Garlic
+ Spinach
+ Carrots
+ Broccoli
+ Garlic
);
@@ -259,13 +259,37 @@ test('supports disabling suggestions', async () => {
expect(spinach).toHaveAttribute('aria-disabled', 'true');
});
+test('supports sections', async () => {
+ render(
+
+
+ one
+ two
+
+
+ three
+ four
+
+
+ );
+
+ const input = screen.getAllByLabelText('Label')[0];
+ await user.type(input, 'o');
+
+ const s1 = await screen.findByText('Section 1');
+ const s2 = await screen.findByText('Section 2');
+
+ expect(s1).toBeVisible();
+ expect(s2).toBeVisible();
+});
+
test('supporst showing a help text', () => {
render(
- Spinach
- Carrots
- Broccoli
- Garlic
+ Spinach
+ Carrots
+ Broccoli
+ Garlic
);
@@ -275,10 +299,10 @@ test('supporst showing a help text', () => {
test('supporst showing an error', () => {
render(
- Spinach
- Carrots
- Broccoli
- Garlic
+ Spinach
+ Carrots
+ Broccoli
+ Garlic
);
@@ -288,10 +312,10 @@ test('supporst showing an error', () => {
test('supports default value', () => {
render(
- Spinach
- Carrots
- Broccoli
- Garlic
+ Spinach
+ Carrots
+ Broccoli
+ Garlic
);
@@ -304,10 +328,10 @@ test('can be controlled', async () => {
return (
<>
- Spinach
- Carrots
- Broccoli
- Garlic
+ Spinach
+ Carrots
+ Broccoli
+ Garlic
{value}
>
@@ -325,10 +349,10 @@ test('can be controlled', async () => {
test('supports autocompletion', async () => {
render(
- Spinach
- Carrots
- Broccoli
- Garlic
+ Spinach
+ Carrots
+ Broccoli
+ Garlic
);
@@ -344,10 +368,10 @@ test('supports autocompletion', async () => {
test('supports clear input value', async () => {
render(
- Spinach
- Carrots
- Broccoli
- Garlic
+ Spinach
+ Carrots
+ Broccoli
+ Garlic
);
@@ -365,10 +389,10 @@ test('supports submit handler', async () => {
render(
- Spinach
- Carrots
- Broccoli
- Garlic
+ Spinach
+ Carrots
+ Broccoli
+ Garlic
);
diff --git a/packages/components/src/Autocomplete/Autocomplete.tsx b/packages/components/src/Autocomplete/Autocomplete.tsx
index f2fbbdfa6e..13479ffe6e 100644
--- a/packages/components/src/Autocomplete/Autocomplete.tsx
+++ b/packages/components/src/Autocomplete/Autocomplete.tsx
@@ -163,7 +163,15 @@ interface AutocompleteComponent
extends ForwardRefExoticComponent<
AutocompleteProps & RefAttributes
> {
- Item: typeof ListBox.Item;
+ /**
+ * Options for the Combobox.
+ */
+ Option: typeof ListBox.Item;
+
+ /**
+ * Section for the Combobox, to put options in.
+ */
+ Section: typeof ListBox.Section;
}
// Component
@@ -209,6 +217,7 @@ const _Autocomplete = forwardRef(
}
) as AutocompleteComponent;
-_Autocomplete.Item = ListBox.Item;
+_Autocomplete.Option = ListBox.Item;
+_Autocomplete.Section = ListBox.Section;
export { _Autocomplete as Autocomplete };
diff --git a/packages/components/src/ComboBox/ComboBox.stories.tsx b/packages/components/src/ComboBox/ComboBox.stories.tsx
index feb0c2491f..31ce2b7034 100644
--- a/packages/components/src/ComboBox/ComboBox.stories.tsx
+++ b/packages/components/src/ComboBox/ComboBox.stories.tsx
@@ -3,6 +3,7 @@ import { Meta, StoryObj } from '@storybook/react';
import { Key, useState } from 'react';
import { useAsyncList } from '@react-stately/data';
import { Stack } from '../Stack';
+import { Text } from '../Text';
import { ComboBox } from './ComboBox';
const meta = {
@@ -99,7 +100,7 @@ const meta = {
width: 'full',
menuTrigger: 'input',
placeholder: undefined,
- label: '',
+ label: 'Label',
},
} satisfies Meta;
@@ -109,14 +110,14 @@ export const Basic: StoryObj = {
render: args => {
return (
- Red Panda
- Cat
- Dog
- Aardvark
- Kangaroo
- Snake
- Vegan
- Margrita
+ Red Panda
+ Cat
+ Dog
+ Aardvark
+ Kangaroo
+ Snake
+ Vegan
+ Margrita
);
},
@@ -136,11 +137,11 @@ export const Controlled: StoryObj = {
label="Animals"
{...args}
>
- Red Panda
- Cat
- Dog
- Aardvark
- Kangaroo
+ Red Panda
+ Cat
+ Dog
+ Aardvark
+ Kangaroo
current: {current}, selected: {id?.toString()}
@@ -174,11 +175,40 @@ export const AsyncLoading: StoryObj = {
{...args}
>
{(item: { name: string }) => (
-
+
{item.name}
-
+
)}