Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

feat: graduate XDSCommandPalette to core (#1126)

Cindy Zhang670d7a095cbf
diff --git a/apps/storybook/stories/CommandPalette.stories.tsx b/apps/storybook/stories/CommandPalette.stories.tsx
index a8af2a92db..4fb99b093a 100644
--- a/apps/storybook/stories/CommandPalette.stories.tsx
+++ b/apps/storybook/stories/CommandPalette.stories.tsx
@@ -13,14 +13,14 @@ import {
XDSCommandPaletteItem,
XDSCommandPaletteGroup,
XDSCommandPaletteFooter,
-} from '@xds/lab';
+} from '@xds/core/CommandPalette';
import {XDSButton} from '@xds/core/Button';
import {XDSIcon} from '@xds/core/Icon';
import {createStaticSource} from '@xds/core/Typeahead';
import type {XDSSearchSource, XDSSearchableItem} from '@xds/core/Typeahead';
const meta: Meta<typeof XDSCommandPalette> = {
- title: 'Lab/XDSCommandPalette',
+ title: 'CommandPalette/XDSCommandPalette',
component: XDSCommandPalette,
tags: ['autodocs'],
};
diff --git a/packages/core/package.json b/packages/core/package.json
index 9e7f1adfb0..c5afc03800 100644
--- a/packages/core/package.json
+++ b/packages/core/package.json
@@ -106,6 +106,12 @@
"import": "./dist/Collapsible/index.mjs",
"require": "./dist/Collapsible/index.js"
},
+ "./CommandPalette": {
+ "source": "./src/CommandPalette/index.ts",
+ "types": "./dist/CommandPalette/index.d.ts",
+ "import": "./dist/CommandPalette/index.mjs",
+ "require": "./dist/CommandPalette/index.js"
+ },
"./DateInput": {
"source": "./src/DateInput/index.ts",
"types": "./dist/DateInput/index.d.ts",
diff --git a/packages/lab/src/CommandPalette/CommandPaletteContext.ts b/packages/core/src/CommandPalette/CommandPaletteContext.ts
similarity index 96%
rename from packages/lab/src/CommandPalette/CommandPaletteContext.ts
rename to packages/core/src/CommandPalette/CommandPaletteContext.ts
index 3f95a0ea4e..f344380704 100644
--- a/packages/lab/src/CommandPalette/CommandPaletteContext.ts
+++ b/packages/core/src/CommandPalette/CommandPaletteContext.ts
@@ -6,7 +6,7 @@
*/
import {createContext, useContext} from 'react';
-import type {XDSSearchableItem} from '@xds/core/Typeahead';
+import type {XDSSearchableItem} from '../Typeahead';
export interface CommandPaletteContextValue {
/** Current search query. */
diff --git a/packages/lab/src/CommandPalette/XDSCommandPalette.test.tsx b/packages/core/src/CommandPalette/XDSCommandPalette.test.tsx
similarity index 100%
rename from packages/lab/src/CommandPalette/XDSCommandPalette.test.tsx
rename to packages/core/src/CommandPalette/XDSCommandPalette.test.tsx
diff --git a/packages/lab/src/CommandPalette/XDSCommandPalette.tsx b/packages/core/src/CommandPalette/XDSCommandPalette.tsx
similarity index 98%
rename from packages/lab/src/CommandPalette/XDSCommandPalette.tsx
rename to packages/core/src/CommandPalette/XDSCommandPalette.tsx
index 737512c492..63f8ece58e 100644
--- a/packages/lab/src/CommandPalette/XDSCommandPalette.tsx
+++ b/packages/core/src/CommandPalette/XDSCommandPalette.tsx
@@ -22,16 +22,16 @@ import {
useTransition,
type ReactNode,
} from 'react';
-import {XDSDialog} from '@xds/core/Dialog';
+import {XDSDialog} from '../Dialog';
import {
XDSLayout,
XDSLayoutHeader,
XDSLayoutContent,
XDSLayoutFooter,
-} from '@xds/core/Layout';
-import type {XDSSearchSource, XDSSearchableItem} from '@xds/core/Typeahead';
-import {useCombobox} from '@xds/core/Selector';
-import type {XDSSelectorOptionData} from '@xds/core/Selector';
+} from '../Layout';
+import type {XDSSearchSource, XDSSearchableItem} from '../Typeahead';
+import {useCombobox} from '../Selector';
+import type {XDSSelectorOptionData} from '../Selector';
import {CommandPaletteContext} from './CommandPaletteContext';
import {XDSCommandPaletteList} from './XDSCommandPaletteList';
import {XDSCommandPaletteItem} from './XDSCommandPaletteItem';
diff --git a/packages/lab/src/CommandPalette/XDSCommandPaletteEmpty.tsx b/packages/core/src/CommandPalette/XDSCommandPaletteEmpty.tsx
similarity index 97%
rename from packages/lab/src/CommandPalette/XDSCommandPaletteEmpty.tsx
rename to packages/core/src/CommandPalette/XDSCommandPaletteEmpty.tsx
index d7b1156576..15a19c0fb4 100644
--- a/packages/lab/src/CommandPalette/XDSCommandPaletteEmpty.tsx
+++ b/packages/core/src/CommandPalette/XDSCommandPaletteEmpty.tsx
@@ -17,7 +17,7 @@ import {
spacingVars,
typeScaleVars,
typographyVars,
-} from '@xds/core/theme/tokens.stylex';
+} from '../theme/tokens.stylex';
const styles = stylex.create({
empty: {
diff --git a/packages/lab/src/CommandPalette/XDSCommandPaletteFooter.test.tsx b/packages/core/src/CommandPalette/XDSCommandPaletteFooter.test.tsx
similarity index 100%
rename from packages/lab/src/CommandPalette/XDSCommandPaletteFooter.test.tsx
rename to packages/core/src/CommandPalette/XDSCommandPaletteFooter.test.tsx
diff --git a/packages/lab/src/CommandPalette/XDSCommandPaletteFooter.tsx b/packages/core/src/CommandPalette/XDSCommandPaletteFooter.tsx
similarity index 93%
rename from packages/lab/src/CommandPalette/XDSCommandPaletteFooter.tsx
rename to packages/core/src/CommandPalette/XDSCommandPaletteFooter.tsx
index aa107d815b..88d338860e 100644
--- a/packages/lab/src/CommandPalette/XDSCommandPaletteFooter.tsx
+++ b/packages/core/src/CommandPalette/XDSCommandPaletteFooter.tsx
@@ -12,15 +12,15 @@
import type {ReactNode} from 'react';
import * as stylex from '@stylexjs/stylex';
-import type {XDSBaseProps} from '@xds/core/XDSBaseProps';
-import {xdsClassName, mergeProps} from '@xds/core/utils';
+import type {XDSBaseProps} from '../XDSBaseProps';
+import {xdsClassName, mergeProps} from '../utils';
import {
colorVars,
spacingVars,
typeScaleVars,
typographyVars,
-} from '@xds/core/theme/tokens.stylex';
-import {XDSKbd} from '@xds/core/Kbd';
+} from '../theme/tokens.stylex';
+import {XDSKbd} from '../Kbd';
const styles = stylex.create({
footer: {
diff --git a/packages/lab/src/CommandPalette/XDSCommandPaletteGroup.test.tsx b/packages/core/src/CommandPalette/XDSCommandPaletteGroup.test.tsx
similarity index 100%
rename from packages/lab/src/CommandPalette/XDSCommandPaletteGroup.test.tsx
rename to packages/core/src/CommandPalette/XDSCommandPaletteGroup.test.tsx
diff --git a/packages/lab/src/CommandPalette/XDSCommandPaletteGroup.tsx b/packages/core/src/CommandPalette/XDSCommandPaletteGroup.tsx
similarity index 93%
rename from packages/lab/src/CommandPalette/XDSCommandPaletteGroup.tsx
rename to packages/core/src/CommandPalette/XDSCommandPaletteGroup.tsx
index 0597eeca50..6e6ab4cd02 100644
--- a/packages/lab/src/CommandPalette/XDSCommandPaletteGroup.tsx
+++ b/packages/core/src/CommandPalette/XDSCommandPaletteGroup.tsx
@@ -12,14 +12,14 @@
import type {ReactNode} from 'react';
import * as stylex from '@stylexjs/stylex';
-import type {XDSBaseProps} from '@xds/core/XDSBaseProps';
-import {xdsClassName, mergeProps} from '@xds/core/utils';
+import type {XDSBaseProps} from '../XDSBaseProps';
+import {xdsClassName, mergeProps} from '../utils';
import {
colorVars,
spacingVars,
typeScaleVars,
typographyVars,
-} from '@xds/core/theme/tokens.stylex';
+} from '../theme/tokens.stylex';
const styles = stylex.create({
group: {
diff --git a/packages/lab/src/CommandPalette/XDSCommandPaletteInput.test.tsx b/packages/core/src/CommandPalette/XDSCommandPaletteInput.test.tsx
similarity index 100%
rename from packages/lab/src/CommandPalette/XDSCommandPaletteInput.test.tsx
rename to packages/core/src/CommandPalette/XDSCommandPaletteInput.test.tsx
diff --git a/packages/lab/src/CommandPalette/XDSCommandPaletteInput.tsx b/packages/core/src/CommandPalette/XDSCommandPaletteInput.tsx
similarity index 97%
rename from packages/lab/src/CommandPalette/XDSCommandPaletteInput.tsx
rename to packages/core/src/CommandPalette/XDSCommandPaletteInput.tsx
index 46185b135e..352142966c 100644
--- a/packages/lab/src/CommandPalette/XDSCommandPaletteInput.tsx
+++ b/packages/core/src/CommandPalette/XDSCommandPaletteInput.tsx
@@ -20,16 +20,16 @@ import {
} from 'react';
import * as stylex from '@stylexjs/stylex';
import type {StyleXStyles} from '@stylexjs/stylex';
-import {XDSIcon} from '@xds/core/Icon';
-import {XDSSpinner} from '@xds/core/Spinner';
-import {xdsClassName, mergeProps} from '@xds/core/utils';
+import {XDSIcon} from '../Icon';
+import {XDSSpinner} from '../Spinner';
+import {xdsClassName, mergeProps} from '../utils';
import {
colorVars,
typeScaleVars,
spacingVars,
typographyVars,
textSizeVars,
-} from '@xds/core/theme/tokens.stylex';
+} from '../theme/tokens.stylex';
import {useCommandPaletteContext} from './CommandPaletteContext';
const styles = stylex.create({
diff --git a/packages/lab/src/CommandPalette/XDSCommandPaletteItem.test.tsx b/packages/core/src/CommandPalette/XDSCommandPaletteItem.test.tsx
similarity index 96%
rename from packages/lab/src/CommandPalette/XDSCommandPaletteItem.test.tsx
rename to packages/core/src/CommandPalette/XDSCommandPaletteItem.test.tsx
index d891bd069e..061193468c 100644
--- a/packages/lab/src/CommandPalette/XDSCommandPaletteItem.test.tsx
+++ b/packages/core/src/CommandPalette/XDSCommandPaletteItem.test.tsx
@@ -69,7 +69,10 @@ describe('XDSCommandPaletteItem', () => {
Item
</XDSCommandPaletteItem>,
);
- expect(screen.getByRole('option')).toHaveAttribute('aria-selected', 'false');
+ expect(screen.getByRole('option')).toHaveAttribute(
+ 'aria-selected',
+ 'false',
+ );
});
it('sets data-value attribute', () => {
diff --git a/packages/lab/src/CommandPalette/XDSCommandPaletteItem.tsx b/packages/core/src/CommandPalette/XDSCommandPaletteItem.tsx
similarity index 95%
rename from packages/lab/src/CommandPalette/XDSCommandPaletteItem.tsx
rename to packages/core/src/CommandPalette/XDSCommandPaletteItem.tsx
index cf57a99a0c..0179b13a0e 100644
--- a/packages/lab/src/CommandPalette/XDSCommandPaletteItem.tsx
+++ b/packages/core/src/CommandPalette/XDSCommandPaletteItem.tsx
@@ -12,15 +12,15 @@
import {useCallback, useEffect, useMemo, useRef, type ReactNode} from 'react';
import * as stylex from '@stylexjs/stylex';
-import type {XDSBaseProps} from '@xds/core/XDSBaseProps';
-import {xdsClassName, mergeProps} from '@xds/core/utils';
+import type {XDSBaseProps} from '../XDSBaseProps';
+import {xdsClassName, mergeProps} from '../utils';
import {
colorVars,
spacingVars,
radiusVars,
typographyVars,
textSizeVars,
-} from '@xds/core/theme/tokens.stylex';
+} from '../theme/tokens.stylex';
import {useCommandPaletteContext} from './CommandPaletteContext';
const HOVER_HOVER = '@media (hover: hover)';
@@ -66,7 +66,10 @@ const styles = stylex.create({
},
});
-export interface XDSCommandPaletteItemProps extends XDSBaseProps<HTMLDivElement> {
+export interface XDSCommandPaletteItemProps extends Omit<
+ XDSBaseProps<HTMLDivElement>,
+ 'onChange' | 'onSelect'
+> {
/** Ref forwarded to the root element. */
ref?: React.Ref<HTMLDivElement>;
/** Unique value for identification and selection. */
diff --git a/packages/lab/src/CommandPalette/XDSCommandPaletteList.test.tsx b/packages/core/src/CommandPalette/XDSCommandPaletteList.test.tsx
similarity index 100%
rename from packages/lab/src/CommandPalette/XDSCommandPaletteList.test.tsx
rename to packages/core/src/CommandPalette/XDSCommandPaletteList.test.tsx
diff --git a/packages/lab/src/CommandPalette/XDSCommandPaletteList.tsx b/packages/core/src/CommandPalette/XDSCommandPaletteList.tsx
similarity index 92%
rename from packages/lab/src/CommandPalette/XDSCommandPaletteList.tsx
rename to packages/core/src/CommandPalette/XDSCommandPaletteList.tsx
index 19d2ff89ba..57e88cf5bb 100644
--- a/packages/lab/src/CommandPalette/XDSCommandPaletteList.tsx
+++ b/packages/core/src/CommandPalette/XDSCommandPaletteList.tsx
@@ -13,9 +13,9 @@
import type {ReactNode} from 'react';
import * as stylex from '@stylexjs/stylex';
-import type {XDSBaseProps} from '@xds/core/XDSBaseProps';
-import {xdsClassName, mergeProps} from '@xds/core/utils';
-import {spacingVars} from '@xds/core/theme/tokens.stylex';
+import type {XDSBaseProps} from '../XDSBaseProps';
+import {xdsClassName, mergeProps} from '../utils';
+import {spacingVars} from '../theme/tokens.stylex';
import {useCommandPaletteContext} from './CommandPaletteContext';
const styles = stylex.create({
diff --git a/packages/lab/src/CommandPalette/index.ts b/packages/core/src/CommandPalette/index.ts
similarity index 94%
rename from packages/lab/src/CommandPalette/index.ts
rename to packages/core/src/CommandPalette/index.ts
index 05edae7951..a0e0e7b941 100644
--- a/packages/lab/src/CommandPalette/index.ts
+++ b/packages/core/src/CommandPalette/index.ts
@@ -2,7 +2,7 @@
* @file index.ts
* @input Imports CommandPalette components and types
* @output Exports all CommandPalette components and types
- * @position Component entry point; re-exported by /packages/lab/src/index.ts
+ * @position Component entry point; re-exported by /packages/core/src/index.ts
*
* SYNC: When modified, update this header
*/
diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts
index 6037ac9568..24a068af59 100644
--- a/packages/core/src/index.ts
+++ b/packages/core/src/index.ts
@@ -24,6 +24,7 @@ export * from './Card';
export * from './Calendar';
export * from './Center';
export * from './CodeBlock';
+export * from './CommandPalette';
export * from './CheckboxInput';
export * from './Collapsible';
export * from './RadioList';
diff --git a/packages/lab/src/CommandPalette/CommandPalette.doc.mjs b/packages/lab/src/CommandPalette/CommandPalette.doc.mjs
deleted file mode 100644
index 26e235930f..0000000000
--- a/packages/lab/src/CommandPalette/CommandPalette.doc.mjs
+++ /dev/null
@@ -1,118 +0,0 @@
-/** @type {import('../docs-types').ComponentDoc} */
-
-export const docs = {
- name: 'CommandPalette',
- description:
- 'A searchSource-driven command palette dialog. Provide a search source, get filtering, keyboard navigation, and selection for free. Uses the same XDSSearchSource interface as XDSTypeahead.',
- features: [
- 'searchSource: Same XDSSearchSource interface as XDSTypeahead — static, async, or hybrid',
- 'Progressive disclosure: No children = default rendering; children render function = full control',
- 'Auto-grouping: Items with auxiliaryData.group are auto-grouped in default rendering',
- 'createStaticSource: Utility for static lists with optional keyword matching',
- 'Async support: isBusy context signal + spinner in input while search resolves',
- 'Keyboard navigation: Arrow keys, Enter to select, Escape to close',
- 'Picker mode: value/onValueChange for persistent selection',
- ],
- examples: [
- {
- label: 'Simplest — default rendering',
- code: `import {XDSCommandPalette, XDSCommandPaletteInput, XDSCommandPaletteFooter} from '@xds/lab';
-import {createStaticSource} from '@xds/core/Typeahead';
-import {useState} from 'react';
-
-const source = createStaticSource([
- {id: 'home', label: 'Home'},
- {id: 'settings', label: 'Settings'},
-]);
-
-function Example() {
- const [isOpen, setIsOpen] = useState(false);
- return (
- <XDSCommandPalette
- isOpen={isOpen}
- onOpenChange={setIsOpen}
- searchSource={source}
- input={<XDSCommandPaletteInput placeholder="Search..." />}
- footer={<XDSCommandPaletteFooter />}
- />
- );
-}`,
- },
- {
- label: 'Custom rendering with groups',
- code: `import {XDSCommandPalette, XDSCommandPaletteInput, XDSCommandPaletteItem, XDSCommandPaletteGroup} from '@xds/lab';
-import {createStaticSource} from '@xds/core/Typeahead';
-
-<XDSCommandPalette
- isOpen={isOpen}
- onOpenChange={setIsOpen}
- searchSource={source}
- input={<XDSCommandPaletteInput placeholder="Search..." />}>
- {(items) => {
- const grouped = items.filter(i => i.auxiliaryData?.group === 'Navigation');
- return (
- <XDSCommandPaletteGroup heading="Navigation">
- {grouped.map(item => (
- <XDSCommandPaletteItem key={item.id} value={item.id}>
- {item.label}
- </XDSCommandPaletteItem>
- ))}
- </XDSCommandPaletteGroup>
- );
- }}
-</XDSCommandPalette>`,
- },
- ],
- props: {
- isOpen: {
- type: 'boolean',
- required: true,
- description: 'Whether the command palette is open.',
- },
- onOpenChange: {
- type: '(isOpen: boolean) => void',
- required: true,
- description: 'Called when the palette visibility changes.',
- },
- searchSource: {
- type: 'XDSSearchSource<T>',
- required: true,
- description: 'Search source providing items via search(query) and bootstrap(). Use createStaticSource for static lists.',
- },
- input: {
- type: 'ReactNode',
- description: 'Input slot — typically XDSCommandPaletteInput.',
- },
- footer: {
- type: 'ReactNode',
- description: 'Footer slot — typically XDSCommandPaletteFooter.',
- },
- children: {
- type: '(items: T[]) => ReactNode',
- description: 'Custom render function. When omitted, default rendering is used (label text, auto-grouped by auxiliaryData.group).',
- },
- value: {
- type: 'string',
- description: 'Controlled selected value for picker mode.',
- },
- onValueChange: {
- type: '(value: string) => void',
- description: 'Called when the selected value changes.',
- },
- label: {
- type: 'string',
- default: "'Command palette'",
- description: 'Accessible label for the dialog.',
- },
- width: {
- type: 'number | string',
- default: '640',
- description: 'Width of the dialog.',
- },
- maxHeight: {
- type: 'number | string',
- default: '480',
- description: 'Maximum height of the dialog.',
- },
- },
-};
diff --git a/packages/lab/src/CommandPalette/README.md b/packages/lab/src/CommandPalette/README.md
deleted file mode 100644
index 117e223cb8..0000000000
--- a/packages/lab/src/CommandPalette/README.md
+++ /dev/null
@@ -1,34 +0,0 @@
-# CommandPalette
-
-Command palette dialog for quick access to commands, navigation, and search.
-
-## Architecture
-
-The command palette is built incrementally as composable pieces:
-
-1. **XDSCommandPalette** — Dialog shell with flex column layout (this PR)
-2. **XDSCommandPaletteInput** — Search input with icon (planned)
-3. **XDSCommandPaletteList / Item / Group** — Scrollable item list (planned)
-4. **XDSCommandPaletteFooter** — Keyboard shortcut hints (planned)
-5. **CommandPaletteContext** — State management provider (planned)
-
-## Files
-
-| File | Purpose |
-| ---------------------------- | --------------------------- |
-| `XDSCommandPalette.tsx` | Root dialog shell component |
-| `index.ts` | Public exports |
-| `README.md` | This file |
-| `XDSCommandPalette.test.tsx` | Unit tests |
-
-## Usage
-
-```tsx
-import {XDSCommandPalette} from '@xds/core/CommandPalette';
-
-const [isOpen, setIsOpen] = useState(false);
-
-<XDSCommandPalette isOpen={isOpen} onOpenChange={setIsOpen}>
- {/* Sub-components go here */}
-</XDSCommandPalette>;
-```
diff --git a/packages/lab/src/index.ts b/packages/lab/src/index.ts
index caf886bbce..112a9bf7d7 100644
--- a/packages/lab/src/index.ts
+++ b/packages/lab/src/index.ts
@@ -8,25 +8,6 @@
* This package is never published to npm.
*/
-export {
- XDSCommandPalette,
- type XDSCommandPaletteProps,
- XDSCommandPaletteInput,
- type XDSCommandPaletteInputProps,
- XDSCommandPaletteList,
- type XDSCommandPaletteListProps,
- XDSCommandPaletteItem,
- type XDSCommandPaletteItemProps,
- XDSCommandPaletteGroup,
- type XDSCommandPaletteGroupProps,
- XDSCommandPaletteFooter,
- type XDSCommandPaletteFooterProps,
- useCommandPaletteContext,
- type CommandPaletteContextValue,
- defaultFilter,
- type CommandPaletteFilterFn,
-} from './CommandPalette';
-
// Code components — syntax highlighting domain
export {XDSCodeBlock, type XDSCodeBlockProps} from './CodeBlock';
export {XDSCodeEditor, type XDSCodeEditorProps} from './CodeEditor';