base-cmdk 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -5,8 +5,6 @@ Fast, composable, unstyled command menu for **React 19** built on **Base UI**
5
5
  [![npm version](https://img.shields.io/npm/v/base-cmdk)](https://www.npmjs.com/package/base-cmdk)
6
6
  [![license](https://img.shields.io/npm/l/base-cmdk)](./LICENSE)
7
7
 
8
- **[Live interactive demo →](https://ui.kipivo.com/components/command-menu)**
9
-
10
8
  ---
11
9
 
12
10
  ## Why `base-cmdk`?
@@ -23,7 +21,7 @@ Fast, composable, unstyled command menu for **React 19** built on **Base UI**
23
21
  | Works with arbitrary custom wrappers around `Command.Item` | Fragile | Fragile | **Yes** |
24
22
  | Respects nested hidden groups, `[hidden]`, and `[inert]` ancestors | Partial | Partial | **Yes** |
25
23
  | Dynamic `keywords`, item renames, dynamic `filter`, and dynamic `disabled` | Partial | Partial | **Yes** |
26
- | Native ESM + TypeScript (`NodeNext`) declarations | CJS/ESM | ESM | **Pure ESM + strict `.d.ts`** |
24
+ | Native ESM + TypeScript (`NodeNext`) declarations | CJS/ESM | ESM | **Pure ESM (Rolldown / `tsdown`) + `.d.ts`** |
27
25
 
28
26
  ---
29
27
 
@@ -112,15 +110,31 @@ export function CommandPalette() {
112
110
 
113
111
  ---
114
112
 
115
- ## Development & Verification
113
+ ## Development & Preview
116
114
 
117
115
  ```bash
118
116
  bun install
117
+ bun run dev
118
+ ```
119
+
120
+ Open `http://127.0.0.1:5173` to launch the local Vite playground with both inline and `⌘K` dialog examples.
121
+
122
+ To build with `tsdown` (Rolldown) and run the full verification suite:
123
+
124
+ ```bash
119
125
  bunx playwright install chromium
120
126
  bun run check
121
127
  ```
122
128
 
123
- `bun run check` type-checks, builds `dist/`, packs the npm tarball, installs it into an isolated consumer directory, and runs Node ESM, TypeScript `NodeNext`, SSR, React 19 `StrictMode` hydration, and 24 Playwright interaction scenarios.
129
+ `bun run check` type-checks, builds `dist/` with `tsdown`, builds the Vite playground, packs the npm tarball, installs it into an isolated consumer directory, and runs Node ESM, TypeScript `NodeNext`, SSR, React 19 `StrictMode` hydration, and 24 Playwright interaction scenarios.
130
+
131
+ ### Releasing
132
+
133
+ ```bash
134
+ bun run release patch # or minor / major / x.y.z
135
+ ```
136
+
137
+ This runs `bun run check`, bumps `package.json`, commits and pushes the `vX.Y.Z` tag, and triggers GitHub Actions (`publish.yml`) to publish via npm Trusted Publishing (OIDC) with provenance and create the GitHub Release.
124
138
 
125
139
  ---
126
140
 
package/dist/index.d.ts CHANGED
@@ -1,10 +1,251 @@
1
+ import * as React from "react";
2
+ import { Dialog } from "@base-ui/react/dialog";
3
+ type Children = {
4
+ children?: React.ReactNode;
5
+ };
6
+ type DivProps = React.ComponentPropsWithoutRef<"div">;
7
+ type LoadingProps = Children & DivProps & {
8
+ /** Estimated progress of loading asynchronous options. */
9
+ progress?: number;
10
+ /**
11
+ * Accessible label for this loading progressbar. Not shown visibly.
12
+ */
13
+ label?: string;
14
+ };
15
+ type EmptyProps = DivProps;
16
+ type SeparatorProps = DivProps & {
17
+ /** Whether this separator should always be rendered. Useful if you disable automatic filtering. */
18
+ alwaysRender?: boolean;
19
+ };
20
+ type DialogProps = Omit<Dialog.Root.Props, "children"> & CommandProps & {
21
+ /** Provide a className to the Dialog overlay. */
22
+ overlayClassName?: string;
23
+ /** Provide a className to the Dialog content. */
24
+ contentClassName?: string;
25
+ /** Provide a custom element the Dialog should portal into. */
26
+ container?: HTMLElement | null;
27
+ };
28
+ type ListProps = Children & DivProps & {
29
+ /**
30
+ * Accessible label for this List of suggestions. Not shown visibly.
31
+ */
32
+ label?: string;
33
+ };
34
+ type ItemProps = Children & Omit<DivProps, "disabled" | "onSelect" | "value"> & {
35
+ /** Whether this item is currently disabled. */
36
+ disabled?: boolean;
37
+ /** Event handler for when this item is selected, either via click or keyboard selection. */
38
+ onSelect?: (value: string) => void;
39
+ /**
40
+ * A unique value for this item.
41
+ * If no value is provided, it will be inferred from `children` or the rendered `textContent`. If your `textContent` changes between renders, you _must_ provide a stable, unique `value`.
42
+ */
43
+ value?: string;
44
+ /** Optional keywords to match against when filtering. */
45
+ keywords?: string[];
46
+ /** Whether this item is forcibly rendered regardless of filtering. */
47
+ forceMount?: boolean;
48
+ };
49
+ type GroupProps = Children & Omit<DivProps, "heading" | "value"> & {
50
+ /** Optional heading to render for this group. */
51
+ heading?: React.ReactNode;
52
+ /** If no heading is provided, you must provide a value that is unique for this group. */
53
+ value?: string;
54
+ /** Whether this group is forcibly rendered regardless of filtering. */
55
+ forceMount?: boolean;
56
+ };
57
+ type InputProps = Omit<React.ComponentPropsWithoutRef<"input">, "value" | "onChange" | "type"> & {
58
+ /**
59
+ * Optional controlled state for the value of the search input.
60
+ */
61
+ value?: string;
62
+ /**
63
+ * Event handler called when the search value changes.
64
+ */
65
+ onValueChange?: (search: string) => void;
66
+ };
67
+ type CommandFilter = (value: string, search: string, keywords?: string[]) => number;
68
+ type CommandProps = Children & DivProps & {
69
+ /**
70
+ * Accessible label for this command menu. Not shown visibly.
71
+ */
72
+ label?: string;
73
+ /**
74
+ * Optionally set to `false` to turn off the automatic filtering and sorting.
75
+ * If `false`, you must conditionally render valid items based on the search query yourself.
76
+ */
77
+ shouldFilter?: boolean;
78
+ /** Initial input query for SSR when the input is rendered by another component. */
79
+ defaultSearch?: string;
80
+ /**
81
+ * Custom filter function for whether each command menu item should matches the given search query.
82
+ * It should return a number between 0 and 1, with 1 being the best match and 0 being hidden entirely.
83
+ * By default, uses the `command-score` library.
84
+ */
85
+ filter?: CommandFilter;
86
+ /**
87
+ * Optional default item value when it is initially rendered.
88
+ */
89
+ defaultValue?: string;
90
+ /**
91
+ * Optional controlled state of the selected command menu item.
92
+ */
93
+ value?: string;
94
+ /**
95
+ * Event handler called when the selected item of the menu changes.
96
+ */
97
+ onValueChange?: (value: string) => void;
98
+ /**
99
+ * Optionally set to `true` to turn on looping around when using the arrow keys.
100
+ */
101
+ loop?: boolean;
102
+ /** Cycle between groups with Tab and Shift+Tab in single-input palettes. */
103
+ tabToGroup?: boolean;
104
+ /**
105
+ * Optionally set to `true` to disable selection via pointer events.
106
+ */
107
+ disablePointerSelection?: boolean;
108
+ /**
109
+ * Set to `false` to disable ctrl+n/j/p/k shortcuts. Defaults to `true`.
110
+ */
111
+ vimBindings?: boolean;
112
+ };
113
+ type State = {
114
+ readonly search: string;
115
+ readonly value: string;
116
+ readonly selectedItemId?: string;
117
+ readonly ready: boolean;
118
+ readonly filtered: {
119
+ readonly ranked: boolean;
120
+ readonly count: number;
121
+ readonly items: ReadonlyMap<string, number>;
122
+ readonly groups: ReadonlySet<string>;
123
+ };
124
+ };
125
+ export declare const defaultFilter: CommandFilter;
126
+ export declare const CommandRoot: React.ForwardRefExoticComponent<{
127
+ children?: React.ReactNode;
128
+ } & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
129
+ label?: string;
130
+ shouldFilter?: boolean;
131
+ defaultSearch?: string;
132
+ filter?: CommandFilter;
133
+ defaultValue?: string;
134
+ value?: string;
135
+ onValueChange?: (value: string) => void;
136
+ loop?: boolean;
137
+ tabToGroup?: boolean;
138
+ disablePointerSelection?: boolean;
139
+ vimBindings?: boolean;
140
+ } & React.RefAttributes<HTMLDivElement>>;
141
+ /**
142
+ * Command menu item. Becomes active on pointer enter or through keyboard navigation.
143
+ * Preferably pass a `value`, otherwise the value will be inferred from `children` or
144
+ * the rendered item's `textContent`.
145
+ */
146
+ export declare const CommandItem: React.ForwardRefExoticComponent<{
147
+ children?: React.ReactNode;
148
+ } & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "disabled" | "onSelect" | "value"> & {
149
+ disabled?: boolean;
150
+ onSelect?: (value: string) => void;
151
+ value?: string;
152
+ keywords?: string[];
153
+ forceMount?: boolean;
154
+ } & React.RefAttributes<HTMLDivElement>>;
155
+ /**
156
+ * Group command menu items together with a heading.
157
+ * Grouped items are always shown together.
158
+ */
159
+ export declare const CommandGroup: React.ForwardRefExoticComponent<{
160
+ children?: React.ReactNode;
161
+ } & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "heading" | "value"> & {
162
+ heading?: React.ReactNode;
163
+ value?: string;
164
+ forceMount?: boolean;
165
+ } & React.RefAttributes<HTMLDivElement>>;
166
+ /**
167
+ * A visual and semantic separator between items or groups.
168
+ * Visible when the search query is empty or `alwaysRender` is true, hidden otherwise.
169
+ */
170
+ export declare const CommandSeparator: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
171
+ alwaysRender?: boolean;
172
+ } & React.RefAttributes<HTMLDivElement>>;
173
+ /**
174
+ * Command menu input.
175
+ * All props are forwarded to the underyling `input` element.
176
+ */
177
+ export declare const CommandInput: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref">, "onChange" | "type" | "value"> & {
178
+ value?: string;
179
+ onValueChange?: (search: string) => void;
180
+ } & React.RefAttributes<HTMLInputElement>>;
181
+ /**
182
+ * Contains `Item`, `Group`, and `Separator`.
183
+ * Use the `--cmdk-list-height` CSS variable to animate height based on the number of results.
184
+ */
185
+ export declare const CommandList: React.ForwardRefExoticComponent<{
186
+ children?: React.ReactNode;
187
+ } & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
188
+ label?: string;
189
+ } & React.RefAttributes<HTMLDivElement>>;
190
+ /**
191
+ * Renders the command menu in a Base UI Dialog.
192
+ */
193
+ export declare const CommandDialog: React.ForwardRefExoticComponent<Omit<Dialog.Root.Props<unknown>, "children"> & {
194
+ children?: React.ReactNode;
195
+ } & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
196
+ label?: string;
197
+ shouldFilter?: boolean;
198
+ defaultSearch?: string;
199
+ filter?: CommandFilter;
200
+ defaultValue?: string;
201
+ value?: string;
202
+ onValueChange?: (value: string) => void;
203
+ loop?: boolean;
204
+ tabToGroup?: boolean;
205
+ disablePointerSelection?: boolean;
206
+ vimBindings?: boolean;
207
+ } & {
208
+ overlayClassName?: string;
209
+ contentClassName?: string;
210
+ container?: HTMLElement | null;
211
+ } & React.RefAttributes<HTMLDivElement>>;
212
+ /**
213
+ * Automatically renders when there are no results for the search query.
214
+ */
215
+ export declare const CommandEmpty: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
216
+ /**
217
+ * You should conditionally render this with `progress` while loading asynchronous items.
218
+ */
219
+ export declare const CommandLoading: React.ForwardRefExoticComponent<{
220
+ children?: React.ReactNode;
221
+ } & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
222
+ progress?: number;
223
+ label?: string;
224
+ } & React.RefAttributes<HTMLDivElement>>;
225
+ /** Run a selector against the store state. */
226
+ export declare function useCommandState<T>(selector: (state: State) => T): T;
1
227
  export declare const Command: import("react").ForwardRefExoticComponent<{
2
- children?: import("react").ReactNode;
228
+ children?: import("react").ReactNode;
3
229
  } & Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
230
+ label?: string;
231
+ shouldFilter?: boolean;
232
+ defaultSearch?: string;
233
+ filter?: CommandFilter;
234
+ defaultValue?: string;
235
+ value?: string;
236
+ onValueChange?: (value: string) => void;
237
+ loop?: boolean;
238
+ tabToGroup?: boolean;
239
+ disablePointerSelection?: boolean;
240
+ vimBindings?: boolean;
241
+ } & import("react").RefAttributes<HTMLDivElement>> & {
242
+ Dialog: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react").DialogRoot.Props<unknown>, "children"> & {
243
+ children?: import("react").ReactNode;
244
+ } & Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
4
245
  label?: string;
5
246
  shouldFilter?: boolean;
6
247
  defaultSearch?: string;
7
- filter?: import("./types.js").CommandFilter;
248
+ filter?: CommandFilter;
8
249
  defaultValue?: string;
9
250
  value?: string;
10
251
  onValueChange?: (value: string) => void;
@@ -12,63 +253,45 @@ export declare const Command: import("react").ForwardRefExoticComponent<{
12
253
  tabToGroup?: boolean;
13
254
  disablePointerSelection?: boolean;
14
255
  vimBindings?: boolean;
15
- } & import("react").RefAttributes<HTMLDivElement>> & {
16
- Dialog: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react").DialogRoot.Props<unknown>, "children"> & {
17
- children?: import("react").ReactNode;
18
- } & Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
19
- label?: string;
20
- shouldFilter?: boolean;
21
- defaultSearch?: string;
22
- filter?: import("./types.js").CommandFilter;
23
- defaultValue?: string;
24
- value?: string;
25
- onValueChange?: (value: string) => void;
26
- loop?: boolean;
27
- tabToGroup?: boolean;
28
- disablePointerSelection?: boolean;
29
- vimBindings?: boolean;
30
- } & {
31
- overlayClassName?: string;
32
- contentClassName?: string;
33
- container?: HTMLElement | null;
34
- } & import("react").RefAttributes<HTMLDivElement>>;
35
- Empty: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
36
- Group: import("react").ForwardRefExoticComponent<{
37
- children?: import("react").ReactNode;
38
- } & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "heading" | "value"> & {
39
- heading?: import("react").ReactNode;
40
- value?: string;
41
- forceMount?: boolean;
42
- } & import("react").RefAttributes<HTMLDivElement>>;
43
- Input: import("react").ForwardRefExoticComponent<Omit<Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref">, "onChange" | "type" | "value"> & {
44
- value?: string;
45
- onValueChange?: (search: string) => void;
46
- } & import("react").RefAttributes<HTMLInputElement>>;
47
- Item: import("react").ForwardRefExoticComponent<{
48
- children?: import("react").ReactNode;
49
- } & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "disabled" | "onSelect" | "value"> & {
50
- disabled?: boolean;
51
- onSelect?: (value: string) => void;
52
- value?: string;
53
- keywords?: string[];
54
- forceMount?: boolean;
55
- } & import("react").RefAttributes<HTMLDivElement>>;
56
- List: import("react").ForwardRefExoticComponent<{
57
- children?: import("react").ReactNode;
58
- } & Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
59
- label?: string;
60
- } & import("react").RefAttributes<HTMLDivElement>>;
61
- Loading: import("react").ForwardRefExoticComponent<{
62
- children?: import("react").ReactNode;
63
- } & Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
64
- progress?: number;
65
- label?: string;
66
- } & import("react").RefAttributes<HTMLDivElement>>;
67
- Separator: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
68
- alwaysRender?: boolean;
69
- } & import("react").RefAttributes<HTMLDivElement>>;
256
+ } & {
257
+ overlayClassName?: string;
258
+ contentClassName?: string;
259
+ container?: HTMLElement | null;
260
+ } & import("react").RefAttributes<HTMLDivElement>>;
261
+ Empty: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
262
+ Group: import("react").ForwardRefExoticComponent<{
263
+ children?: import("react").ReactNode;
264
+ } & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "heading" | "value"> & {
265
+ heading?: import("react").ReactNode;
266
+ value?: string;
267
+ forceMount?: boolean;
268
+ } & import("react").RefAttributes<HTMLDivElement>>;
269
+ Input: import("react").ForwardRefExoticComponent<Omit<Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref">, "onChange" | "type" | "value"> & {
270
+ value?: string;
271
+ onValueChange?: (search: string) => void;
272
+ } & import("react").RefAttributes<HTMLInputElement>>;
273
+ Item: import("react").ForwardRefExoticComponent<{
274
+ children?: import("react").ReactNode;
275
+ } & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "disabled" | "onSelect" | "value"> & {
276
+ disabled?: boolean;
277
+ onSelect?: (value: string) => void;
278
+ value?: string;
279
+ keywords?: string[];
280
+ forceMount?: boolean;
281
+ } & import("react").RefAttributes<HTMLDivElement>>;
282
+ List: import("react").ForwardRefExoticComponent<{
283
+ children?: import("react").ReactNode;
284
+ } & Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
285
+ label?: string;
286
+ } & import("react").RefAttributes<HTMLDivElement>>;
287
+ Loading: import("react").ForwardRefExoticComponent<{
288
+ children?: import("react").ReactNode;
289
+ } & Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
290
+ progress?: number;
291
+ label?: string;
292
+ } & import("react").RefAttributes<HTMLDivElement>>;
293
+ Separator: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
294
+ alwaysRender?: boolean;
295
+ } & import("react").RefAttributes<HTMLDivElement>>;
70
296
  };
71
- export { CommandRoot, defaultFilter } from "./root.js";
72
- export { CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandLoading, CommandSeparator, } from "./parts.js";
73
- export { useCommandState } from "./context.js";
74
- export type { CommandFilter, CommandProps, DialogProps, EmptyProps, GroupProps, InputProps, ItemProps, ListProps, LoadingProps, SeparatorProps, State as CommandState, } from "./types.js";
297
+ export type { CommandFilter, CommandProps, State as CommandState, DialogProps, EmptyProps, GroupProps, InputProps, ItemProps, ListProps, LoadingProps, SeparatorProps };