An open source design system that's fully customizable and agent ready
TypeScript
feat(selector): themeable empty-state target on Selector and MultiSelector (#4756)
freddymetad52d2cbd1b08
diff --git a/.changeset/selector-empty-state-target.md b/.changeset/selector-empty-state-target.mdnew file mode 100644index 0000000000..93cc5687be--- /dev/null+++ b/.changeset/selector-empty-state-target.md@@ -0,0 +1,7 @@+---+'@astryxdesign/core': patch+---++[feat] Selector and MultiSelector: expose the empty ("No results found") state as a themeable target (`astryx-selector-empty-state` / `astryx-multi-selector-empty-state`). Lets themes restyle the empty state without structural CSS selectors — consumers previously had to reach it via fragile structural selectors because no stable target existed. (The search field is a TextInput, so its placeholder is reachable today via `.astryx-text-input::placeholder`; a Selector-scoped placeholder seam would require a TextInput change and is left as a possible follow-up.)++@freddymetadiff --git a/packages/core/src/MultiSelector/MultiSelector.doc.mjs b/packages/core/src/MultiSelector/MultiSelector.doc.mjsindex 193b951594..d7ad6d353f 100644--- a/packages/core/src/MultiSelector/MultiSelector.doc.mjs+++ b/packages/core/src/MultiSelector/MultiSelector.doc.mjs@@ -25,6 +25,7 @@ export const docs = {visualProps: ['variant', 'size', 'status'],},{className: 'astryx-multi-selector-clear-icon'},+ {className: 'astryx-multi-selector-empty-state'},{className: 'astryx-multi-selector-indicator-icon',states: ['state'],diff --git a/packages/core/src/MultiSelector/MultiSelector.test.tsx b/packages/core/src/MultiSelector/MultiSelector.test.tsxindex a96b50bb07..f4a0399a1a 100644--- a/packages/core/src/MultiSelector/MultiSelector.test.tsx+++ b/packages/core/src/MultiSelector/MultiSelector.test.tsx@@ -1509,6 +1509,29 @@ describe('MultiSelector statusVariant forwarding', () => {});});+describe('MultiSelector empty-state theme target', () => {+ const OPTIONS = ['Apple', 'Banana', 'Cherry'];++ it('renders the astryx-multi-selector-empty-state target on the "No results found" element', async () => {+ const user = userEvent.setup();+ const {container} = render(+ <MultiSelector+ label="Fruit"+ options={OPTIONS}+ value={[]}+ onChange={() => {}}+ hasSearch+ />,+ );+ await user.click(screen.getByRole('button', {name: 'Fruit'}));+ await user.type(screen.getByRole('combobox', h), 'xyz');++ const empty = container.querySelector('.astryx-multi-selector-empty-state');+ expect(empty).not.toBeNull();+ expect(empty).toHaveTextContent('No results found');+ });+});+describe('MultiSelector clear icon theme target', () => {const ICON_OPTIONS = ['Apple', 'Banana', 'Orange'];diff --git a/packages/core/src/MultiSelector/MultiSelector.tsx b/packages/core/src/MultiSelector/MultiSelector.tsxindex 0568f65d3d..6ba2eac61f 100644--- a/packages/core/src/MultiSelector/MultiSelector.tsx+++ b/packages/core/src/MultiSelector/MultiSelector.tsx@@ -1343,7 +1343,10 @@ export function MultiSelector<T extends MultiSelectorOptionType>({<divkey="empty"role="presentation"- {...stylex.props(styles.emptyState)}>+ {...mergeProps(+ themeProps('multi-selector-empty-state'),+ stylex.props(styles.emptyState),+ )}>No results found</div>,);diff --git a/packages/core/src/Selector/Selector.doc.mjs b/packages/core/src/Selector/Selector.doc.mjsindex 669c859bd4..d9101fecb4 100644--- a/packages/core/src/Selector/Selector.doc.mjs+++ b/packages/core/src/Selector/Selector.doc.mjs@@ -26,6 +26,7 @@ export const docs = {visualProps: ['variant', 'size', 'status'],},{className: 'astryx-selector-option'},+ {className: 'astryx-selector-empty-state'},{className: 'astryx-selector-clear-icon'},{className: 'astryx-selector-indicator-icon', states: ['state']},{className: 'astryx-selector-check'},diff --git a/packages/core/src/Selector/Selector.test.tsx b/packages/core/src/Selector/Selector.test.tsxindex bbc2f174ab..65d61dbcf3 100644--- a/packages/core/src/Selector/Selector.test.tsx+++ b/packages/core/src/Selector/Selector.test.tsx@@ -1460,6 +1460,28 @@ describe('Selector statusVariant forwarding', () => {});});+describe('Selector empty-state theme target', () => {+ const OPTIONS = ['Apple', 'Banana', 'Cherry'];++ it('renders the astryx-selector-empty-state target on the "No results found" element', async () => {+ const user = userEvent.setup();+ const {container} = render(+ <Selector+ label="Fruit"+ options={OPTIONS}+ onChange={() => {}}+ hasSearch+ />,+ );+ await user.click(screen.getByRole('button', {name: 'Fruit'}));+ await user.type(screen.getByRole('combobox', h), 'xyz');++ const empty = container.querySelector('.astryx-selector-empty-state');+ expect(empty).not.toBeNull();+ expect(empty).toHaveTextContent('No results found');+ });+});+describe('Selector clear icon theme target', () => {// Resolve the clear glyph span (the astryx-icon element inside the clear// button), independent of the theme target class.diff --git a/packages/core/src/Selector/Selector.tsx b/packages/core/src/Selector/Selector.tsxindex c1d703db2b..71f2963b92 100644--- a/packages/core/src/Selector/Selector.tsx+++ b/packages/core/src/Selector/Selector.tsx@@ -1098,7 +1098,10 @@ export function Selector<T extends SelectorOptionType>(<divkey="empty"role="presentation"- {...stylex.props(styles.emptyState)}>+ {...mergeProps(+ themeProps('selector-empty-state'),+ stylex.props(styles.emptyState),+ )}>No results found</div>,];