@camunda/design-system 0.80.0 → 0.81.0
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/dist/src/components/ui/app-header.d.ts +8 -1
- package/dist/src/components/ui/app-header.d.ts.map +1 -1
- package/dist/src/components/ui/app-header.js +6 -2
- package/dist/src/components/ui/app-header.js.map +1 -1
- package/dist/src/components/ui/command-palette.assignability.d.ts +33 -0
- package/dist/src/components/ui/command-palette.assignability.d.ts.map +1 -0
- package/dist/src/components/ui/command-palette.assignability.js +33 -0
- package/dist/src/components/ui/command-palette.assignability.js.map +1 -0
- package/dist/src/components/ui/command-palette.d.ts +86 -0
- package/dist/src/components/ui/command-palette.d.ts.map +1 -0
- package/dist/src/components/ui/command-palette.js +220 -0
- package/dist/src/components/ui/command-palette.js.map +1 -0
- package/dist/src/components/ui/command.d.ts +23 -4
- package/dist/src/components/ui/command.d.ts.map +1 -1
- package/dist/src/components/ui/command.js +28 -6
- package/dist/src/components/ui/command.js.map +1 -1
- package/dist/src/components/ui/kbd.d.ts +5 -0
- package/dist/src/components/ui/kbd.d.ts.map +1 -0
- package/dist/src/components/ui/kbd.js +34 -0
- package/dist/src/components/ui/kbd.js.map +1 -0
- package/dist/src/components/ui/search-trigger.d.ts +19 -0
- package/dist/src/components/ui/search-trigger.d.ts.map +1 -0
- package/dist/src/components/ui/search-trigger.js +31 -0
- package/dist/src/components/ui/search-trigger.js.map +1 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +4 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/lib/i18n/dictionary.d.ts +22 -0
- package/dist/src/lib/i18n/dictionary.d.ts.map +1 -1
- package/dist/src/lib/i18n/dictionary.js +19 -0
- package/dist/src/lib/i18n/dictionary.js.map +1 -1
- package/dist/src/lib/keyboard-shortcut.d.ts +38 -0
- package/dist/src/lib/keyboard-shortcut.d.ts.map +1 -0
- package/dist/src/lib/keyboard-shortcut.js +134 -0
- package/dist/src/lib/keyboard-shortcut.js.map +1 -0
- package/dist/src/specs/schema.d.ts +1 -1
- package/dist/src/specs/schema.d.ts.map +1 -1
- package/dist/styles.css +109 -0
- package/eslint-rules/no-hardcoded-i18n-prop.js +1 -1
- package/package.json +1 -1
|
@@ -16,6 +16,13 @@ export interface AppHeaderProps extends React.ComponentProps<"header"> {
|
|
|
16
16
|
logo?: React.ReactNode;
|
|
17
17
|
appName?: string;
|
|
18
18
|
breadcrumb?: React.ReactNode;
|
|
19
|
+
/**
|
|
20
|
+
* The global-search trigger: a `SearchTrigger` that opens `CommandPalette`. Rendered after
|
|
21
|
+
* `trailing` and before `globalActions`, and never yields. From `lg` up the trigger is a
|
|
22
|
+
* field-shaped button, below `lg` an icon button. Unset, the header renders as it did before
|
|
23
|
+
* this slot existed.
|
|
24
|
+
*/
|
|
25
|
+
search?: React.ReactNode;
|
|
19
26
|
trailing?: React.ReactNode;
|
|
20
27
|
actions?: React.ReactNode;
|
|
21
28
|
globalActions?: GlobalActionButton[];
|
|
@@ -48,5 +55,5 @@ export interface AppHeaderProps extends React.ComponentProps<"header"> {
|
|
|
48
55
|
*/
|
|
49
56
|
sidebarCollapsedWidth?: string;
|
|
50
57
|
}
|
|
51
|
-
export declare function AppHeader({ logo, appName, breadcrumb, trailing, actions, globalActions, tools, activeToolKey, onActiveToolChange, skipToContentTargetId, skipToContentLabel, showSidebarTrigger, sidebarCollapsedWidth, className, children, ...props }: AppHeaderProps): React.JSX.Element;
|
|
58
|
+
export declare function AppHeader({ logo, appName, breadcrumb, search, trailing, actions, globalActions, tools, activeToolKey, onActiveToolChange, skipToContentTargetId, skipToContentLabel, showSidebarTrigger, sidebarCollapsedWidth, className, children, ...props }: AppHeaderProps): React.JSX.Element;
|
|
52
59
|
//# sourceMappingURL=app-header.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-header.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/app-header.t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CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAClD,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,gJAAgJ;IAChJ,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,2GAA2G;IAC3G,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B;;;;;;OAMG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED,wBAAgB,SAAS,CAAC,EACxB,IAAI,EACJ,OAAO,EACP,UAAU,EACV,MAAM,EACN,QAAQ,EACR,OAAO,EACP,aAAa,EAEb,KAAK,EACL,aAAa,EACb,kBAAkB,EAClB,qBAAqB,EACrB,kBAAkB,EAClB,kBAAyB,EACzB,qBAAgC,EAChC,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,cAAc,qBAyJhB"}
|
|
@@ -41,7 +41,7 @@ import { HeaderTools, useHeaderTools } from "./nav-tools.js";
|
|
|
41
41
|
* every segment carries.
|
|
42
42
|
*/
|
|
43
43
|
const BREADCRUMB_SLOT_FLOOR_PX = 144;
|
|
44
|
-
export function AppHeader({ logo, appName, breadcrumb, trailing, actions, globalActions,
|
|
44
|
+
export function AppHeader({ logo, appName, breadcrumb, search, trailing, actions, globalActions,
|
|
45
45
|
// Destructured before the spread below, or they land on the <header> as unknown attributes.
|
|
46
46
|
tools, activeToolKey, onActiveToolChange, skipToContentTargetId, skipToContentLabel, showSidebarTrigger = true, sidebarCollapsedWidth = "3.5rem", className, children, ...props }) {
|
|
47
47
|
const sidebar = useSidebar();
|
|
@@ -98,7 +98,11 @@ tools, activeToolKey, onActiveToolChange, skipToContentTargetId, skipToContentLa
|
|
|
98
98
|
// (DS `Badge`, the canonical content here, is `shrink-0` with
|
|
99
99
|
// `whitespace-nowrap`). The clip lands on this box's trailing edge, so under
|
|
100
100
|
// RTL it removes the START of the text rather than its end.
|
|
101
|
-
_jsx("div", { "data-slot": "app-header-trailing", className: "min-w-0 overflow-hidden", children: trailing })),
|
|
101
|
+
_jsx("div", { "data-slot": "app-header-trailing", className: "min-w-0 overflow-hidden", children: trailing })), search ? (
|
|
102
|
+
// `shrink-0`: like every action, a clipped search button is one the user cannot reach.
|
|
103
|
+
// An icon button's glyph sits 10px inside its box, so the field form takes 10px more on
|
|
104
|
+
// its left to sit as far from the badge as it does from the next icon.
|
|
105
|
+
_jsx("div", { "data-slot": "app-header-search", className: "shrink-0 has-[[data-slot=search-trigger][data-variant=field]]:ml-2.5 lg:has-[[data-slot=search-trigger][data-variant=auto]]:ml-2.5", children: search })) : null, globalActions
|
|
102
106
|
?.filter((action) => action.element || action.icon)
|
|
103
107
|
.map((action) => action.element ? (_jsx(React.Fragment, { children: action.element }, action.key)) : (_jsx(Button, { variant: "ghost", size: "icon", "aria-label": action.label, onClick: action.onClick, children: action.icon ? (_jsx(action.icon, { "aria-hidden": true, className: "size-4" })) : null }, action.key))), tools !== undefined && tools.length > 0 && (_jsx(HeaderTools, { tools: tools, ...headerTools })), actions] })] }));
|
|
104
108
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-header.js","sourceRoot":"","sources":["../../../../src/components/ui/app-header.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAgB,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,cAAc,EAAuB,MAAM,aAAa,CAAC;AAE/E;;;;;;;;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O,YAEtB,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CACb,KAAC,MAAM,CAAC,IAAI,yBAAa,SAAS,EAAC,QAAQ,GAAG,CAC/C,CAAC,CAAC,CAAC,IAAI,IARH,MAAM,CAAC,GAAG,CASR,CACV,CACF,EACF,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,CAC1C,KAAC,WAAW,IAAC,KAAK,EAAE,KAAK,KAAM,WAAW,GAAI,CAC/C,EACA,OAAO,IACJ,IACC,CACV,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compile-time fixture for the `CommandPalette` drop-in contract. Nothing imports this file: it
|
|
3
|
+
* exists to be type-checked, and `npm run typecheck` is what runs it.
|
|
4
|
+
*
|
|
5
|
+
* The point it pins: Control's local `CommandDialog` and `Kbd` can be deleted in favour of these
|
|
6
|
+
* two, so each prop type Control declares must assign to ours. Control is not a dependency of this
|
|
7
|
+
* package, so its declarations are re-declared here from
|
|
8
|
+
* `packages/control-ui/src/components/ui/command-dialog.tsx`, the same approach
|
|
9
|
+
* `nav-tools.assignability.ts` takes for C3's tool shape. If a line below stops compiling, the
|
|
10
|
+
* swap would break at Control's call sites too.
|
|
11
|
+
*/
|
|
12
|
+
import * as React from "react";
|
|
13
|
+
import type { Dialog } from "./dialog.js";
|
|
14
|
+
import { type CommandPaletteProps } from "./command-palette.js";
|
|
15
|
+
import { Kbd } from "./kbd.js";
|
|
16
|
+
/** Control's declaration, verbatim. `Dialog` is the design system's `Dialog` root. */
|
|
17
|
+
interface ControlCommandDialogProps extends React.ComponentProps<typeof Dialog> {
|
|
18
|
+
title?: string;
|
|
19
|
+
description?: string;
|
|
20
|
+
shouldFilter?: boolean;
|
|
21
|
+
loop?: boolean;
|
|
22
|
+
contentClassName?: string;
|
|
23
|
+
children: React.ReactNode;
|
|
24
|
+
}
|
|
25
|
+
export declare const asDsProps: CommandPaletteProps;
|
|
26
|
+
type ControlCommandDialog = (props: ControlCommandDialogProps) => React.ReactNode;
|
|
27
|
+
export declare const dsAsControlDialog: ControlCommandDialog;
|
|
28
|
+
export declare const asDsKbdProps: React.ComponentProps<typeof Kbd>;
|
|
29
|
+
type ControlKbd = (props: React.ComponentProps<"kbd">) => React.ReactNode;
|
|
30
|
+
export declare const dsAsControlKbd: ControlKbd;
|
|
31
|
+
export declare const controlCallSite: React.FunctionComponentElement<CommandPaletteProps>;
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=command-palette.assignability.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-palette.assignability.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/command-palette.assignability.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAkB,KAAK,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAE5B,sFAAsF;AACtF,UAAU,yBAA0B,SAAQ,KAAK,CAAC,cAAc,CAC9D,OAAO,MAAM,CACd;IACC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAKD,eAAO,MAAM,SAAS,EAAE,mBAA6B,CAAC;AAItD,KAAK,oBAAoB,GAAG,CAC1B,KAAK,EAAE,yBAAyB,KAC7B,KAAK,CAAC,SAAS,CAAC;AACrB,eAAO,MAAM,iBAAiB,EAAE,oBAAqC,CAAC;AAItE,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,GAAG,CAAmB,CAAC;AAE9E,KAAK,UAAU,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,KAAK,CAAC,SAAS,CAAC;AAC1E,eAAO,MAAM,cAAc,EAAE,UAAgB,CAAC;AAK9C,eAAO,MAAM,eAAe,qDAS1B,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compile-time fixture for the `CommandPalette` drop-in contract. Nothing imports this file: it
|
|
3
|
+
* exists to be type-checked, and `npm run typecheck` is what runs it.
|
|
4
|
+
*
|
|
5
|
+
* The point it pins: Control's local `CommandDialog` and `Kbd` can be deleted in favour of these
|
|
6
|
+
* two, so each prop type Control declares must assign to ours. Control is not a dependency of this
|
|
7
|
+
* package, so its declarations are re-declared here from
|
|
8
|
+
* `packages/control-ui/src/components/ui/command-dialog.tsx`, the same approach
|
|
9
|
+
* `nav-tools.assignability.ts` takes for C3's tool shape. If a line below stops compiling, the
|
|
10
|
+
* swap would break at Control's call sites too.
|
|
11
|
+
*/
|
|
12
|
+
import * as React from "react";
|
|
13
|
+
import { CommandPalette } from "./command-palette.js";
|
|
14
|
+
import { Kbd } from "./kbd.js";
|
|
15
|
+
// 1. Control's props assign to ours: `CommandPaletteProps` is a supertype of them.
|
|
16
|
+
export const asDsProps = control;
|
|
17
|
+
export const dsAsControlDialog = CommandPalette;
|
|
18
|
+
export const asDsKbdProps = controlKbdProps;
|
|
19
|
+
export const dsAsControlKbd = Kbd;
|
|
20
|
+
// 4. Control's real call site. Its `contentClassName` is kept only so the swap compiles. The
|
|
21
|
+
// component's own `sm:top-*` wins from `sm` up, so a migration drops that string and takes the
|
|
22
|
+
// fixed size and position.
|
|
23
|
+
export const controlCallSite = React.createElement(CommandPalette, {
|
|
24
|
+
open: true,
|
|
25
|
+
onOpenChange: () => { },
|
|
26
|
+
title: "Command palette",
|
|
27
|
+
description: "Search for pages, clusters and actions.",
|
|
28
|
+
shouldFilter: false,
|
|
29
|
+
loop: true,
|
|
30
|
+
contentClassName: "top-[88px] translate-y-0 sm:max-w-[720px]",
|
|
31
|
+
children: React.createElement(Kbd, null, "↑"),
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=command-palette.assignability.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-palette.assignability.js","sourceRoot":"","sources":["../../../../src/components/ui/command-palette.assignability.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,cAAc,EAA4B,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAgB5B,mFAAmF;AACnF,MAAM,CAAC,MAAM,SAAS,GAAwB,OAAO,CAAC;AAOtD,MAAM,CAAC,MAAM,iBAAiB,GAAyB,cAAc,CAAC;AAItE,MAAM,CAAC,MAAM,YAAY,GAAqC,eAAe,CAAC;AAG9E,MAAM,CAAC,MAAM,cAAc,GAAe,GAAG,CAAC;AAE9C,6FAA6F;AAC7F,kGAAkG;AAClG,8BAA8B;AAC9B,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,CAAC,aAAa,CAAC,cAAc,EAAE;IACjE,IAAI,EAAE,IAAI;IACV,YAAY,EAAE,GAAG,EAAE,GAAE,CAAC;IACtB,KAAK,EAAE,iBAAiB;IACxB,WAAW,EAAE,yCAAyC;IACtD,YAAY,EAAE,KAAK;IACnB,IAAI,EAAE,IAAI;IACV,gBAAgB,EAAE,2CAA2C;IAC7D,QAAQ,EAAE,KAAK,CAAC,aAAa,CAAC,GAAG,EAAE,IAAI,EAAE,GAAG,CAAC;CAC9C,CAAC,CAAC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Command, CommandItem } from "./command.js";
|
|
3
|
+
import { type NavIcon } from "./nav-icon.js";
|
|
4
|
+
type CommandPaletteProps = {
|
|
5
|
+
open?: boolean;
|
|
6
|
+
defaultOpen?: boolean;
|
|
7
|
+
onOpenChange?: (open: boolean) => void;
|
|
8
|
+
modal?: boolean;
|
|
9
|
+
/** Accessible name of the dialog and the input. Visually hidden. */
|
|
10
|
+
title?: string;
|
|
11
|
+
/** Visually hidden description. Pass your own when you add footer `hints`. */
|
|
12
|
+
description?: string;
|
|
13
|
+
/** cmdk's built-in filter. Pass `false` when the consumer filters. */
|
|
14
|
+
shouldFilter?: boolean;
|
|
15
|
+
/** Wrap the highlight from the last row to the first. */
|
|
16
|
+
loop?: boolean;
|
|
17
|
+
/** Toggle the palette with ⌘K or Ctrl+K. Pass it on one palette per page. */
|
|
18
|
+
globalShortcut?: boolean;
|
|
19
|
+
/** Close the palette after a `CommandResultItem`'s `onSelect`. Default `true`. */
|
|
20
|
+
closeOnSelect?: boolean;
|
|
21
|
+
value?: string;
|
|
22
|
+
onValueChange?: (value: string) => void;
|
|
23
|
+
filter?: React.ComponentProps<typeof Command>["filter"];
|
|
24
|
+
/**
|
|
25
|
+
* Compatibility passthrough for a local palette being swapped for this one. Merged last, so it
|
|
26
|
+
* overrides the fixed size and position. Don't use it for new code.
|
|
27
|
+
*/
|
|
28
|
+
contentClassName?: string;
|
|
29
|
+
children: React.ReactNode;
|
|
30
|
+
};
|
|
31
|
+
declare function CommandPalette({ open: openProp, defaultOpen, onOpenChange, modal, title, description, shouldFilter, loop, globalShortcut, closeOnSelect, value, onValueChange, filter, contentClassName, children, }: CommandPaletteProps): React.JSX.Element;
|
|
32
|
+
type CommandResultItemProps = Omit<React.ComponentProps<typeof CommandItem>, "children" | "value" | "checked" | "asChild"> & {
|
|
33
|
+
/** The row's name and the text the match highlight applies to. */
|
|
34
|
+
label: string;
|
|
35
|
+
/** Drawn in a tile before the label. */
|
|
36
|
+
icon?: NavIcon;
|
|
37
|
+
/** What kind of thing the row is, such as "BPMN". Starts the secondary line. */
|
|
38
|
+
type?: string;
|
|
39
|
+
/** Where the result sits, outermost first. Follows the type on the secondary line. */
|
|
40
|
+
location?: string[];
|
|
41
|
+
/** Secondary text. Follows the location, and is highlighted like the label. */
|
|
42
|
+
description?: string;
|
|
43
|
+
/** A `StatusIcon` or `Badge`. Needs its own text alternative. */
|
|
44
|
+
status?: React.ReactNode;
|
|
45
|
+
/** Trailing keys of a shortcut, one string per key, drawn as one cap: ["⌘", "N"] is "⌘N". */
|
|
46
|
+
shortcut?: string[];
|
|
47
|
+
/** What Enter does, shown with a ↵ cap on the highlighted row only. Default "Open". */
|
|
48
|
+
actionLabel?: string;
|
|
49
|
+
/** The text to highlight. Defaults to the palette's search text. */
|
|
50
|
+
query?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Pass an id when label, location and description can collide. The built-in filter still
|
|
53
|
+
* matches the label, location and description, which are added to `keywords`.
|
|
54
|
+
*/
|
|
55
|
+
value?: string;
|
|
56
|
+
};
|
|
57
|
+
declare function CommandResultItem({ label, icon: Icon, type, location, description, status, shortcut, actionLabel, query, value, keywords, className, onSelect, ...props }: CommandResultItemProps): React.JSX.Element;
|
|
58
|
+
/**
|
|
59
|
+
* "Searching…" with a spinner. Render it after `CommandList`, never inside it. Its own markup is
|
|
60
|
+
* hidden from assistive tech: the dialog's live region carries the message.
|
|
61
|
+
*/
|
|
62
|
+
declare function CommandLoading({ label, className, ...props }: Omit<React.ComponentProps<"div">, "children"> & {
|
|
63
|
+
label?: string;
|
|
64
|
+
}): React.JSX.Element;
|
|
65
|
+
/**
|
|
66
|
+
* A failed load with an optional retry button. Render it after `CommandList`, never inside it.
|
|
67
|
+
*/
|
|
68
|
+
declare function CommandError({ message, onRetry, retryLabel, className, ...props }: Omit<React.ComponentProps<"div">, "children"> & {
|
|
69
|
+
message?: string;
|
|
70
|
+
onRetry?: () => void;
|
|
71
|
+
retryLabel?: string;
|
|
72
|
+
}): React.JSX.Element;
|
|
73
|
+
type CommandPaletteHint = {
|
|
74
|
+
keys: string[];
|
|
75
|
+
label: string;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* The key-hint bar: navigate, open, close, plus any extra `hints`, each key or chord drawn as one
|
|
79
|
+
* cap. While a `useCommandShortcut` binding is active, the right edge shows that shortcut.
|
|
80
|
+
* Display only, and hidden from assistive tech because the dialog's description says the same.
|
|
81
|
+
*/
|
|
82
|
+
declare function CommandPaletteFooter({ hints, className, ...props }: Omit<React.ComponentProps<"div">, "children"> & {
|
|
83
|
+
hints?: CommandPaletteHint[];
|
|
84
|
+
}): React.JSX.Element;
|
|
85
|
+
export { CommandPalette, CommandPaletteFooter, CommandError, CommandLoading, CommandResultItem, type CommandPaletteHint, type CommandPaletteProps, type CommandResultItemProps, };
|
|
86
|
+
//# sourceMappingURL=command-palette.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-palette.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/command-palette.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAgB/B,OAAO,EACL,OAAO,EAEP,WAAW,EAGZ,MAAM,WAAW,CAAC;AAQnB,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AA+F1C,KAAK,mBAAmB,GAAG;IACzB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,oEAAoE;IACpE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8EAA8E;IAC9E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sEAAsE;IACtE,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,yDAAyD;IACzD,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,6EAA6E;IAC7E,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,kFAAkF;IAClF,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BAAsB,GAC5B,CAAC"}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { useCommandState } from "cmdk";
|
|
5
|
+
import { ChevronRight } from "../../icons/lucide.js";
|
|
6
|
+
import { useC4Dictionary } from "../../lib/i18n/context.js";
|
|
7
|
+
import { formatChord, useCommandShortcut, useCommandShortcutActive, useEscapeKeyLabel, useModifierKeyLabel, } from "../../lib/keyboard-shortcut.js";
|
|
8
|
+
import { cn } from "../../lib/utils.js";
|
|
9
|
+
import { Alert, AlertDescription } from "./alert.js";
|
|
10
|
+
import { Button } from "./button.js";
|
|
11
|
+
import { Command, CommandPaletteContext, CommandItem, useCommandPaletteContext, } from "./command.js";
|
|
12
|
+
import { Dialog, DialogContent, DialogDescription, DialogTitle, } from "./dialog.js";
|
|
13
|
+
import { Kbd } from "./kbd.js";
|
|
14
|
+
import {} from "./nav-icon.js";
|
|
15
|
+
import { SpinnerIcon } from "./spinner.js";
|
|
16
|
+
// How long the query has to stay unchanged before the result count is announced.
|
|
17
|
+
const ANNOUNCE_DELAY_MS = 500;
|
|
18
|
+
// Size comes from the dialog's `md` tier. Position is pinned near the top so the input does not
|
|
19
|
+
// move as the list changes height. `contentClassName` is merged after these.
|
|
20
|
+
const CONTENT_CLASSES = cn("top-4 translate-y-0 gap-0 overflow-hidden p-0 sm:top-[12dvh]", "[&_[data-slot=command-list]]:max-h-[min(32rem,calc(100dvh-12rem))]",
|
|
21
|
+
// The close button is for touch users, who have no Escape key.
|
|
22
|
+
"sm:[&>[data-slot=dialog-close]]:hidden max-sm:[&>[data-slot=dialog-close]]:top-0.5 max-sm:[&>[data-slot=dialog-close]]:right-1 max-sm:[&_[data-slot=command-input-wrapper]]:pr-10", "data-open:animate-none data-closed:animate-none motion-safe:data-open:animate-in motion-safe:data-closed:animate-out");
|
|
23
|
+
function useOpenState({ open: openProp, defaultOpen = false, onOpenChange, }) {
|
|
24
|
+
const [uncontrolledOpen, setUncontrolledOpen] = React.useState(defaultOpen);
|
|
25
|
+
const isControlled = openProp !== undefined;
|
|
26
|
+
const open = isControlled ? openProp : uncontrolledOpen;
|
|
27
|
+
const setOpen = React.useCallback((next) => {
|
|
28
|
+
if (!isControlled)
|
|
29
|
+
setUncontrolledOpen(next);
|
|
30
|
+
onOpenChange?.(next);
|
|
31
|
+
}, [isControlled, onOpenChange]);
|
|
32
|
+
return [open, setOpen];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The palette's one persistent status region. It lives inside the dialog content, because a modal
|
|
36
|
+
* dialog hides everything outside it from assistive tech. Text is written only after the region
|
|
37
|
+
* has mounted, so a palette that opens already loading still announces.
|
|
38
|
+
*/
|
|
39
|
+
function PaletteLiveRegion({ loadingLabel, hasError, }) {
|
|
40
|
+
const { t } = useC4Dictionary();
|
|
41
|
+
const search = useCommandState((state) => state.search);
|
|
42
|
+
const count = useCommandState((state) => state.filtered.count);
|
|
43
|
+
const [message, setMessage] = React.useState("");
|
|
44
|
+
const initialSearch = React.useRef(search);
|
|
45
|
+
const queryChanged = React.useRef(false);
|
|
46
|
+
React.useEffect(() => {
|
|
47
|
+
let text = "";
|
|
48
|
+
let delay = 0;
|
|
49
|
+
let isCount = false;
|
|
50
|
+
if (search !== initialSearch.current)
|
|
51
|
+
queryChanged.current = true;
|
|
52
|
+
if (loadingLabel !== null) {
|
|
53
|
+
text = loadingLabel;
|
|
54
|
+
}
|
|
55
|
+
else if (!hasError && queryChanged.current) {
|
|
56
|
+
// While `CommandError` shows, its alert speaks for the palette: a count here would announce
|
|
57
|
+
// a failed search as "No results".
|
|
58
|
+
text = t("commandPalette.resultCount", { count });
|
|
59
|
+
delay = ANNOUNCE_DELAY_MS;
|
|
60
|
+
isCount = true;
|
|
61
|
+
}
|
|
62
|
+
// Screen readers announce a change to the text, so the same count for a new query would be
|
|
63
|
+
// silent; a trailing no-break space alternates to make the text differ. Counts only: an
|
|
64
|
+
// unchanged loading label stays put, or it would repeat on every keystroke.
|
|
65
|
+
const timer = setTimeout(() => setMessage((previous) => isCount && previous === text ? `${text}\u00a0` : text), delay);
|
|
66
|
+
return () => clearTimeout(timer);
|
|
67
|
+
}, [loadingLabel, hasError, search, count, t]);
|
|
68
|
+
return (_jsx("div", { role: "status", "data-slot": "command-palette-live-region", className: "sr-only", children: message }));
|
|
69
|
+
}
|
|
70
|
+
function CommandPalette({ open: openProp, defaultOpen, onOpenChange, modal, title, description, shouldFilter, loop, globalShortcut = false, closeOnSelect = true, value, onValueChange, filter, contentClassName, children, }) {
|
|
71
|
+
const { t } = useC4Dictionary();
|
|
72
|
+
const [open, setOpen] = useOpenState({
|
|
73
|
+
open: openProp,
|
|
74
|
+
defaultOpen,
|
|
75
|
+
onOpenChange,
|
|
76
|
+
});
|
|
77
|
+
useCommandShortcut(() => setOpen(!open), {
|
|
78
|
+
enabled: globalShortcut,
|
|
79
|
+
open,
|
|
80
|
+
});
|
|
81
|
+
const [loadings, setLoadings] = React.useState([]);
|
|
82
|
+
const [errorCount, setErrorCount] = React.useState(0);
|
|
83
|
+
const registerLoading = React.useCallback((label) => {
|
|
84
|
+
const entry = { label };
|
|
85
|
+
setLoadings((current) => [...current, entry]);
|
|
86
|
+
return () => setLoadings((current) => current.filter((e) => e !== entry));
|
|
87
|
+
}, []);
|
|
88
|
+
const registerError = React.useCallback(() => {
|
|
89
|
+
setErrorCount((current) => current + 1);
|
|
90
|
+
return () => setErrorCount((current) => current - 1);
|
|
91
|
+
}, []);
|
|
92
|
+
const close = React.useCallback(() => setOpen(false), [setOpen]);
|
|
93
|
+
const listLabel = t("commandPalette.results");
|
|
94
|
+
const hasStatus = loadings.length > 0 || errorCount > 0;
|
|
95
|
+
const contextValue = React.useMemo(() => ({
|
|
96
|
+
listLabel,
|
|
97
|
+
hasStatus,
|
|
98
|
+
registerLoading,
|
|
99
|
+
registerError,
|
|
100
|
+
closeOnSelect,
|
|
101
|
+
close,
|
|
102
|
+
}), [
|
|
103
|
+
listLabel,
|
|
104
|
+
hasStatus,
|
|
105
|
+
registerLoading,
|
|
106
|
+
registerError,
|
|
107
|
+
closeOnSelect,
|
|
108
|
+
close,
|
|
109
|
+
]);
|
|
110
|
+
const resolvedTitle = title ?? t("commandPalette.title");
|
|
111
|
+
return (_jsx(Dialog, { open: open, onOpenChange: setOpen, modal: modal, children: _jsxs(DialogContent, { size: "md", className: cn(CONTENT_CLASSES, contentClassName), children: [_jsx(DialogTitle, { className: "sr-only", children: resolvedTitle }), _jsx(DialogDescription, { className: "sr-only", children: description ?? t("commandPalette.description") }), _jsx(CommandPaletteContext.Provider, { value: contextValue, children: _jsxs(Command, { className: "rounded-xl", label: resolvedTitle, shouldFilter: shouldFilter, loop: loop, vimBindings: false, value: value, onValueChange: onValueChange, filter: filter, children: [children, _jsx(PaletteLiveRegion, { loadingLabel: loadings.at(-1)?.label ?? null, hasError: errorCount > 0 })] }) })] }) }));
|
|
112
|
+
}
|
|
113
|
+
function escapeRegExp(text) {
|
|
114
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
115
|
+
}
|
|
116
|
+
function splitByQuery(text, query) {
|
|
117
|
+
const terms = query
|
|
118
|
+
.trim()
|
|
119
|
+
.split(/\s+/)
|
|
120
|
+
.filter(Boolean)
|
|
121
|
+
.sort((a, b) => b.length - a.length);
|
|
122
|
+
if (terms.length === 0)
|
|
123
|
+
return [{ text, match: false }];
|
|
124
|
+
const pattern = new RegExp(terms.map(escapeRegExp).join("|"), "gi");
|
|
125
|
+
const parts = [];
|
|
126
|
+
let last = 0;
|
|
127
|
+
for (const found of text.matchAll(pattern)) {
|
|
128
|
+
const start = found.index ?? 0;
|
|
129
|
+
if (found[0] === "")
|
|
130
|
+
continue;
|
|
131
|
+
if (start > last)
|
|
132
|
+
parts.push({ text: text.slice(last, start), match: false });
|
|
133
|
+
parts.push({ text: found[0], match: true });
|
|
134
|
+
last = start + found[0].length;
|
|
135
|
+
}
|
|
136
|
+
if (last < text.length)
|
|
137
|
+
parts.push({ text: text.slice(last), match: false });
|
|
138
|
+
return parts;
|
|
139
|
+
}
|
|
140
|
+
// A plain span with a heavier weight: `<mark>` and `<strong>` would change what a screen reader
|
|
141
|
+
// announces for the option.
|
|
142
|
+
function Highlighted({ text, query }) {
|
|
143
|
+
return (_jsx(_Fragment, { children: splitByQuery(text, query).map((part, index) => part.match ? (_jsx("span", { className: "font-semibold", children: part.text }, index)) : (_jsx(React.Fragment, { children: part.text }, index))) }));
|
|
144
|
+
}
|
|
145
|
+
function CommandResultItem({ label, icon: Icon, type, location, description, status, shortcut, actionLabel, query, value, keywords, className, onSelect, ...props }) {
|
|
146
|
+
const { t } = useC4Dictionary();
|
|
147
|
+
const dialog = useCommandPaletteContext();
|
|
148
|
+
const search = useCommandState((state) => state.search);
|
|
149
|
+
const highlightQuery = query ?? search;
|
|
150
|
+
const separator = t("commandPalette.locationSeparator");
|
|
151
|
+
const searchText = [label, ...(location ?? []), description].filter((part) => Boolean(part));
|
|
152
|
+
const resolvedValue = value ?? searchText.join(" ");
|
|
153
|
+
// cmdk filters on `value` and `keywords` only, so an id `value` needs the visible text here.
|
|
154
|
+
const resolvedKeywords = value === undefined ? keywords : [...(keywords ?? []), ...searchText];
|
|
155
|
+
const secondary = [];
|
|
156
|
+
if (type)
|
|
157
|
+
secondary.push(type);
|
|
158
|
+
if (location !== undefined && location.length > 0) {
|
|
159
|
+
secondary.push(location.map((segment, index) => (_jsxs(React.Fragment, { children: [index > 0 && (_jsxs(_Fragment, { children: [_jsx(ChevronRight, { "aria-hidden": "true", className: "mx-0.5 inline size-3 align-[-0.125rem]" }), _jsx("span", { className: "sr-only", children: separator })] })), segment] }, index))));
|
|
160
|
+
}
|
|
161
|
+
if (description) {
|
|
162
|
+
secondary.push(_jsx(Highlighted, { text: description, query: highlightQuery }));
|
|
163
|
+
}
|
|
164
|
+
return (_jsxs(CommandItem, { value: resolvedValue, keywords: resolvedKeywords, className: cn("group/result gap-3 px-2 py-2", className), onSelect: (selected) => {
|
|
165
|
+
onSelect?.(selected);
|
|
166
|
+
if (dialog?.closeOnSelect)
|
|
167
|
+
dialog.close();
|
|
168
|
+
}, ...props, children: [Icon && (_jsx("span", { "data-slot": "command-result-icon", "aria-hidden": "true", className: "flex size-8 shrink-0 items-center justify-center rounded-md bg-accent-background-strong", children: _jsx(Icon, { "aria-hidden": "true", className: "size-4 text-accent-foreground-strong" }) })), _jsxs("span", { "data-slot": "command-result-body", className: "flex min-w-0 flex-1 flex-col gap-0.5", children: [_jsxs("span", { className: "flex items-center gap-1.5", children: [_jsx("span", { className: "min-w-0 break-words", children: _jsx(Highlighted, { text: label, query: highlightQuery }) }), status] }), secondary.length > 0 && (_jsx("span", { "data-slot": "command-result-secondary", className: "min-w-0 text-xs break-words text-neutral-foreground-subtle", children: secondary.map((part, index) => (_jsxs(React.Fragment, { children: [index > 0 && (_jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": "true", children: " \u00B7 " }), _jsx("span", { className: "sr-only", children: separator })] })), part] }, index))) }))] }), shortcut && shortcut.length > 0 && (_jsx(Kbd, { className: "shrink-0", children: formatChord(shortcut) })), _jsxs("span", { "data-slot": "command-result-action", "aria-hidden": "true", className: "hidden shrink-0 items-center gap-1.5 text-xs text-neutral-foreground-subtle group-data-[selected=true]/result:flex", children: [actionLabel ?? t("commandPalette.actionOpen"), _jsx(Kbd, { children: "\u21B5" })] })] }));
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* "Searching…" with a spinner. Render it after `CommandList`, never inside it. Its own markup is
|
|
172
|
+
* hidden from assistive tech: the dialog's live region carries the message.
|
|
173
|
+
*/
|
|
174
|
+
function CommandLoading({ label, className, ...props }) {
|
|
175
|
+
const { t } = useC4Dictionary();
|
|
176
|
+
const registerLoading = useCommandPaletteContext()?.registerLoading;
|
|
177
|
+
const text = label ?? t("commandPalette.searching");
|
|
178
|
+
React.useLayoutEffect(() => registerLoading?.(text), [registerLoading, text]);
|
|
179
|
+
return (_jsxs("div", { "data-slot": "command-loading", "aria-hidden": "true", className: cn("flex items-center justify-center gap-2 py-4 text-sm text-neutral-foreground-subtle", className), ...props, children: [_jsx(SpinnerIcon, {}), text] }));
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* A failed load with an optional retry button. Render it after `CommandList`, never inside it.
|
|
183
|
+
*/
|
|
184
|
+
function CommandError({ message, onRetry, retryLabel, className, ...props }) {
|
|
185
|
+
const { t } = useC4Dictionary();
|
|
186
|
+
const registerError = useCommandPaletteContext()?.registerError;
|
|
187
|
+
React.useLayoutEffect(() => registerError?.(), [registerError]);
|
|
188
|
+
return (_jsx("div", { "data-slot": "command-error", className: cn("p-2", className), ...props, children: _jsx(Alert, { variant: "destructive", children: _jsxs("div", { className: "flex flex-wrap items-center justify-between gap-x-3 gap-y-3", children: [_jsx(AlertDescription, { children: message ?? t("commandPalette.error") }), onRetry && (
|
|
189
|
+
// `-my-0.5` keeps the row one text line tall, so the alert icon stays level with it.
|
|
190
|
+
_jsx(Button, { variant: "secondary", size: "xs", className: "-my-0.5", onClick: onRetry,
|
|
191
|
+
// cmdk's root handles Enter by selecting the highlighted row and cancelling the
|
|
192
|
+
// keypress, which would swallow the button's own activation.
|
|
193
|
+
onKeyDown: (event) => {
|
|
194
|
+
if (event.key === "Enter")
|
|
195
|
+
event.stopPropagation();
|
|
196
|
+
}, children: retryLabel ?? t("commandPalette.retry") }))] }) }) }));
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* The key-hint bar: navigate, open, close, plus any extra `hints`, each key or chord drawn as one
|
|
200
|
+
* cap. While a `useCommandShortcut` binding is active, the right edge shows that shortcut.
|
|
201
|
+
* Display only, and hidden from assistive tech because the dialog's description says the same.
|
|
202
|
+
*/
|
|
203
|
+
function CommandPaletteFooter({ hints, className, ...props }) {
|
|
204
|
+
const { t } = useC4Dictionary();
|
|
205
|
+
const escapeLabel = useEscapeKeyLabel();
|
|
206
|
+
const modifier = useModifierKeyLabel();
|
|
207
|
+
const shortcutBound = useCommandShortcutActive();
|
|
208
|
+
const allHints = [
|
|
209
|
+
{ caps: ["↑", "↓"], label: t("commandPalette.hintNavigate") },
|
|
210
|
+
{ caps: ["↵"], label: t("commandPalette.hintOpen") },
|
|
211
|
+
{ caps: [escapeLabel], label: t("commandPalette.hintClose") },
|
|
212
|
+
...(hints ?? []).map((hint) => ({
|
|
213
|
+
caps: [formatChord(hint.keys)],
|
|
214
|
+
label: hint.label,
|
|
215
|
+
})),
|
|
216
|
+
];
|
|
217
|
+
return (_jsxs("div", { "data-slot": "command-palette-footer", "aria-hidden": "true", className: cn("flex flex-wrap items-center gap-x-4 gap-y-1 border-t border-border px-3 py-2 text-xs text-neutral-foreground-subtle", className), ...props, children: [allHints.map((hint, index) => (_jsxs("span", { className: "flex items-center gap-1.5", children: [_jsx("span", { className: "flex items-center gap-1", children: hint.caps.map((cap) => (_jsx(Kbd, { children: cap }, cap))) }), hint.label] }, index))), shortcutBound && (_jsxs("span", { className: "ml-auto flex items-center gap-1.5", children: [t("commandPalette.hintShortcut"), _jsx(Kbd, { children: formatChord([modifier, "K"]) })] }))] }));
|
|
218
|
+
}
|
|
219
|
+
export { CommandPalette, CommandPaletteFooter, CommandError, CommandLoading, CommandResultItem, };
|
|
220
|
+
//# sourceMappingURL=command-palette.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-palette.js","sourceRoot":"","sources":["../../../../src/components/ui/command-palette.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,wB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CAChB,gBAAM,SAAS,EAAC,mCAAmC,aAChD,CAAC,CAAC,6BAA6B,CAAC,EACjC,KAAC,GAAG,cAAE,WAAW,CAAC,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,GAAO,IACpC,CACR,IACG,CACP,CAAC;AACJ,CAAC;AAED,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,YAAY,EACZ,cAAc,EACd,iBAAiB,GAIlB,CAAC"}
|
|
@@ -1,17 +1,36 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { Command as CommandPrimitive } from "cmdk";
|
|
3
|
+
interface CommandPaletteContextValue {
|
|
4
|
+
/** Name of the results listbox, already translated. */
|
|
5
|
+
listLabel: string;
|
|
6
|
+
/** True while a `CommandLoading` or `CommandError` is mounted in the dialog. */
|
|
7
|
+
hasStatus: boolean;
|
|
8
|
+
registerLoading: (label: string) => () => void;
|
|
9
|
+
registerError: () => () => void;
|
|
10
|
+
closeOnSelect: boolean;
|
|
11
|
+
close: () => void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Provided by `CommandPalette`. Not part of the public API: it lets the `Command` parts adapt
|
|
15
|
+
* inside a palette, and `null` outside one, where they behave as before.
|
|
16
|
+
*/
|
|
17
|
+
declare const CommandPaletteContext: React.Context<CommandPaletteContextValue | null>;
|
|
18
|
+
declare function useCommandPaletteContext(): CommandPaletteContextValue | null;
|
|
3
19
|
declare function Command({ className, children, ...props }: React.ComponentProps<typeof CommandPrimitive>): React.JSX.Element;
|
|
4
20
|
type CommandInputProps = Omit<React.ComponentProps<typeof CommandPrimitive.Input>, "ref"> & {
|
|
5
21
|
ref?: React.Ref<HTMLDivElement>;
|
|
6
22
|
};
|
|
7
23
|
declare const CommandInput: React.ForwardRefExoticComponent<Omit<CommandInputProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
8
|
-
declare function CommandList({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.List>): React.JSX.Element;
|
|
24
|
+
declare function CommandList({ className, label, ...props }: React.ComponentProps<typeof CommandPrimitive.List>): React.JSX.Element;
|
|
9
25
|
/**
|
|
10
26
|
* Shown when no item matches. Render it as a sibling of `CommandList`, not
|
|
11
27
|
* inside it: the list is `role="listbox"`, which may only contain options and
|
|
12
|
-
* groups (axe `aria-required-children`).
|
|
28
|
+
* groups (axe `aria-required-children`). With no children (`undefined`; `null`
|
|
29
|
+
* still renders nothing) it says which query found nothing, or "No results
|
|
30
|
+
* found" while the query is empty. Inside a `CommandPalette` it is
|
|
31
|
+
* hidden while a `CommandLoading` or `CommandError` is mounted.
|
|
13
32
|
*/
|
|
14
|
-
declare function CommandEmpty({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.Empty>): React.JSX.Element;
|
|
33
|
+
declare function CommandEmpty({ className, children, ...props }: React.ComponentProps<typeof CommandPrimitive.Empty>): React.JSX.Element | null;
|
|
15
34
|
declare function CommandGroup({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.Group>): React.JSX.Element;
|
|
16
35
|
/**
|
|
17
36
|
* A decorative rule between groups, hidden while a search is active (as cmdk's
|
|
@@ -32,5 +51,5 @@ declare function CommandItem({ className, checked, children, ...props }: React.C
|
|
|
32
51
|
checked?: boolean;
|
|
33
52
|
}): React.JSX.Element;
|
|
34
53
|
declare function CommandShortcut({ className, ...props }: React.ComponentProps<"span">): React.JSX.Element;
|
|
35
|
-
export { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, };
|
|
54
|
+
export { Command, CommandPaletteContext, useCommandPaletteContext, type CommandPaletteContextValue, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, };
|
|
36
55
|
//# sourceMappingURL=command.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/command.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC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AAC,cAAc,CAAC,OAAO,gBAAgB,CAAC,KAAK,CAAC,4BAqBrD;AAED,iBAAS,YAAY,CAAC,EACpB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,gBAAgB,CAAC,KAAK,CAAC,qBAWrD;AAED;;;;;GAKG;AACH,iBAAS,gBAAgB,CAAC,EACxB,SAAS,EACT,YAAY,EACZ,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG;IAAE,YAAY,CAAC,EAAE,OAAO,CAAA;CAAE,4BAW1D;AAED;;;;;GAKG;AACH,iBAAS,WAAW,CAAC,EACnB,SAAS,EACT,OAAO,EACP,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,gBAAgB,CAAC,IAAI,CAAC,GAAG;IACtD,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,qBAeA;AAED,iBAAS,eAAe,CAAC,EACvB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,qBAW9B;AAED,OAAO,EACL,OAAO,EACP,qBAAqB,EACrB,wBAAwB,EACxB,KAAK,0BAA0B,EAC/B,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,eAAe,GAChB,CAAC"}
|
|
@@ -3,9 +3,18 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { Command as CommandPrimitive, useCommandState } from "cmdk";
|
|
5
5
|
import { SearchIcon } from "../../icons/lucide.js";
|
|
6
|
+
import { useC4Dictionary } from "../../lib/i18n/context.js";
|
|
6
7
|
import { cn } from "../../lib/utils.js";
|
|
7
8
|
import { withRef } from "../../lib/with-ref.js";
|
|
8
9
|
import { CheckboxVisual } from "./checkbox.js";
|
|
10
|
+
/**
|
|
11
|
+
* Provided by `CommandPalette`. Not part of the public API: it lets the `Command` parts adapt
|
|
12
|
+
* inside a palette, and `null` outside one, where they behave as before.
|
|
13
|
+
*/
|
|
14
|
+
const CommandPaletteContext = React.createContext(null);
|
|
15
|
+
function useCommandPaletteContext() {
|
|
16
|
+
return React.useContext(CommandPaletteContext);
|
|
17
|
+
}
|
|
9
18
|
/**
|
|
10
19
|
* Keeps `aria-activedescendant` on the input and list pointing at the
|
|
11
20
|
* highlighted item. cmdk 1.1.1 computes it from the DOM before the items
|
|
@@ -44,16 +53,29 @@ function CommandInputImpl({ ref, className, ...props }) {
|
|
|
44
53
|
return (_jsxs("div", { ref: ref, "data-slot": "command-input-wrapper", className: "flex h-9 items-center gap-1.5 border-b px-2.5", children: [_jsx(SearchIcon, { className: "size-4 shrink-0 text-neutral-foreground-subtle", "aria-hidden": "true" }), _jsx(CommandPrimitive.Input, { "data-slot": "command-input", className: cn("flex h-9 w-full rounded-md bg-transparent py-2 text-sm outline-hidden placeholder:text-neutral-foreground-subtle disabled:cursor-not-allowed disabled:opacity-50", className), ...props })] }));
|
|
45
54
|
}
|
|
46
55
|
const CommandInput = withRef(CommandInputImpl);
|
|
47
|
-
function CommandList({ className, ...props }) {
|
|
48
|
-
|
|
56
|
+
function CommandList({ className, label, ...props }) {
|
|
57
|
+
const dialog = useCommandPaletteContext();
|
|
58
|
+
return (_jsx(CommandPrimitive.List, { "data-slot": "command-list", label: label ?? dialog?.listLabel, className: cn("max-h-72 scroll-py-1 overflow-x-hidden overflow-y-auto", className), ...props }));
|
|
49
59
|
}
|
|
50
60
|
/**
|
|
51
61
|
* Shown when no item matches. Render it as a sibling of `CommandList`, not
|
|
52
62
|
* inside it: the list is `role="listbox"`, which may only contain options and
|
|
53
|
-
* groups (axe `aria-required-children`).
|
|
63
|
+
* groups (axe `aria-required-children`). With no children (`undefined`; `null`
|
|
64
|
+
* still renders nothing) it says which query found nothing, or "No results
|
|
65
|
+
* found" while the query is empty. Inside a `CommandPalette` it is
|
|
66
|
+
* hidden while a `CommandLoading` or `CommandError` is mounted.
|
|
54
67
|
*/
|
|
55
|
-
function CommandEmpty({ className, ...props }) {
|
|
56
|
-
|
|
68
|
+
function CommandEmpty({ className, children, ...props }) {
|
|
69
|
+
const { t } = useC4Dictionary();
|
|
70
|
+
const dialog = useCommandPaletteContext();
|
|
71
|
+
const search = useCommandState((state) => state.search);
|
|
72
|
+
if (dialog?.hasStatus)
|
|
73
|
+
return null;
|
|
74
|
+
return (_jsx(CommandPrimitive.Empty, { "data-slot": "command-empty", className: cn("py-5 text-center text-sm text-neutral-foreground-subtle", className), ...props, children: children === undefined
|
|
75
|
+
? search === ""
|
|
76
|
+
? t("command.noResults")
|
|
77
|
+
: t("command.noResultsFor", { query: search })
|
|
78
|
+
: children }));
|
|
57
79
|
}
|
|
58
80
|
function CommandGroup({ className, ...props }) {
|
|
59
81
|
return (_jsx(CommandPrimitive.Group, { "data-slot": "command-group", className: cn("overflow-hidden p-1 text-popover-foreground [&_[cmdk-group-heading]]:px-1.5 [&_[cmdk-group-heading]]:py-1 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-neutral-foreground-subtle", className), ...props }));
|
|
@@ -82,5 +104,5 @@ function CommandItem({ className, checked, children, ...props }) {
|
|
|
82
104
|
function CommandShortcut({ className, ...props }) {
|
|
83
105
|
return (_jsx("span", { "data-slot": "command-shortcut", className: cn("ml-auto text-xs tracking-widest text-neutral-foreground-subtle", className), ...props }));
|
|
84
106
|
}
|
|
85
|
-
export { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, };
|
|
107
|
+
export { Command, CommandPaletteContext, useCommandPaletteContext, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, };
|
|
86
108
|
//# sourceMappingURL=command.js.map
|