banhaten 0.1.3 → 0.2.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/CHANGELOG.md +45 -0
- package/CONTRIBUTING.md +44 -0
- package/README.md +65 -13
- package/SECURITY.md +15 -0
- package/banhaten.config.example.json +0 -2
- package/docs/design-system/README.md +9 -0
- package/docs/design-system/adoption-quality-remediation.md +87 -0
- package/docs/design-system/agent-usage.md +13 -0
- package/docs/design-system/appearance-presets.md +6 -1
- package/docs/design-system/component-docs-pattern.md +81 -0
- package/docs/design-system/component-token-consistency-audit.md +13 -3
- package/docs/design-system/components/README.md +3 -2
- package/docs/design-system/components/accordion.md +16 -0
- package/docs/design-system/components/activity-feed.md +15 -1
- package/docs/design-system/components/alert-dialog.md +17 -0
- package/docs/design-system/components/alert.md +46 -14
- package/docs/design-system/components/aspect-ratio.md +15 -0
- package/docs/design-system/components/attribute.md +16 -0
- package/docs/design-system/components/autocomplete.md +19 -0
- package/docs/design-system/components/avatar.md +18 -0
- package/docs/design-system/components/badge.md +19 -0
- package/docs/design-system/components/banner.md +15 -1
- package/docs/design-system/components/breadcrumbs.md +14 -0
- package/docs/design-system/components/button-group.md +34 -0
- package/docs/design-system/components/button.md +18 -0
- package/docs/design-system/components/card.md +18 -1
- package/docs/design-system/components/carousel.md +20 -3
- package/docs/design-system/components/catalog-components.md +15 -1
- package/docs/design-system/components/chart.md +15 -0
- package/docs/design-system/components/checkbox.md +16 -0
- package/docs/design-system/components/collapsible.md +15 -0
- package/docs/design-system/components/command.md +15 -0
- package/docs/design-system/components/context-menu.md +15 -0
- package/docs/design-system/components/date-picker.md +21 -1
- package/docs/design-system/components/divider.md +16 -0
- package/docs/design-system/components/empty-state.md +17 -0
- package/docs/design-system/components/field.md +17 -0
- package/docs/design-system/components/file-upload.md +14 -0
- package/docs/design-system/components/hover-card.md +15 -0
- package/docs/design-system/components/input-group.md +17 -0
- package/docs/design-system/components/input-otp.md +18 -0
- package/docs/design-system/components/input.md +43 -7
- package/docs/design-system/components/item.md +72 -0
- package/docs/design-system/components/kbd.md +18 -0
- package/docs/design-system/components/label.md +16 -0
- package/docs/design-system/components/menu.md +17 -0
- package/docs/design-system/components/menubar.md +15 -0
- package/docs/design-system/components/modal.md +25 -4
- package/docs/design-system/components/native-select.md +18 -0
- package/docs/design-system/components/navigation-menu.md +15 -0
- package/docs/design-system/components/onboarding-step-list-item.md +15 -1
- package/docs/design-system/components/page-header.md +15 -1
- package/docs/design-system/components/pagination.md +30 -8
- package/docs/design-system/components/popover.md +19 -0
- package/docs/design-system/components/progress-slider.md +18 -0
- package/docs/design-system/components/progress.md +17 -0
- package/docs/design-system/components/radio-card.md +16 -0
- package/docs/design-system/components/radio-group.md +17 -0
- package/docs/design-system/components/resizable.md +15 -0
- package/docs/design-system/components/scroll-area.md +15 -0
- package/docs/design-system/components/segmented-control.md +71 -0
- package/docs/design-system/components/select.md +44 -7
- package/docs/design-system/components/sheet.md +17 -0
- package/docs/design-system/components/sidebar.md +15 -0
- package/docs/design-system/components/skeleton.md +18 -0
- package/docs/design-system/components/slideout.md +14 -0
- package/docs/design-system/components/slider.md +20 -0
- package/docs/design-system/components/social-button.md +21 -3
- package/docs/design-system/components/spinner.md +16 -0
- package/docs/design-system/components/steps.md +14 -0
- package/docs/design-system/components/table.md +15 -1
- package/docs/design-system/components/tabs.md +17 -0
- package/docs/design-system/components/tag.md +17 -0
- package/docs/design-system/components/textarea.md +16 -0
- package/docs/design-system/components/timeline.md +14 -0
- package/docs/design-system/components/toast.md +17 -0
- package/docs/design-system/components/toggle.md +17 -0
- package/docs/design-system/components/toolbar.md +21 -1
- package/docs/design-system/components/tooltip.md +18 -1
- package/docs/design-system/density-and-elevation.md +44 -0
- package/docs/design-system/direction-and-localization.md +23 -0
- package/docs/design-system/form-recipes.md +73 -0
- package/docs/design-system/gap-promotion-policy.md +21 -0
- package/docs/design-system/gap-promotion-report.md +166 -0
- package/docs/design-system/installation.md +68 -0
- package/docs/design-system/launch-comparison-shadcn.md +98 -0
- package/docs/design-system/registry-and-cli.md +30 -7
- package/docs/design-system/release-policy.md +30 -0
- package/docs/design-system/roadmap.md +14 -0
- package/docs/design-system/support-matrix.md +23 -0
- package/docs/design-system/tabs.md +1 -1
- package/docs/design-system/token-governance.md +23 -1
- package/package.json +29 -15
- package/registry/component-contract.json +40 -0
- package/registry/components/alert-dialog.tsx +1 -1
- package/registry/components/alert.tsx +86 -65
- package/registry/components/autocomplete.tsx +23 -9
- package/registry/components/avatar.tsx +7 -7
- package/registry/components/badge.tsx +1 -1
- package/registry/components/button-group.tsx +321 -4
- package/registry/components/button.tsx +38 -17
- package/registry/components/card.tsx +68 -59
- package/registry/components/carousel.tsx +53 -5
- package/registry/components/chart.tsx +36 -3
- package/registry/components/checkbox.tsx +3 -3
- package/registry/components/collapsible.tsx +1 -1
- package/registry/components/command.tsx +1 -1
- package/registry/components/context-menu.tsx +1 -1
- package/registry/components/date-picker.tsx +245 -104
- package/registry/components/expanded/ActivityFeed.tsx +6 -15
- package/registry/components/expanded/Banner.tsx +3 -3
- package/registry/components/expanded/Breadcrumbs.tsx +5 -5
- package/registry/components/expanded/CatalogComponentsShowcase.tsx +13 -13
- package/registry/components/expanded/CatalogDivider.tsx +1 -1
- package/registry/components/expanded/EmptyState.tsx +1 -1
- package/registry/components/expanded/FileUpload.tsx +9 -2
- package/registry/components/expanded/OnboardingStepListItem.tsx +2 -4
- package/registry/components/expanded/PageHeader.tsx +13 -13
- package/registry/components/expanded/Slideout.tsx +15 -415
- package/registry/components/expanded/Steps.tsx +4 -4
- package/registry/components/expanded/Table.tsx +116 -69
- package/registry/components/expanded/Timeline.tsx +3 -3
- package/registry/components/expanded/activityFeed.css +1 -1
- package/registry/components/expanded/breadcrumbs.css +1 -1
- package/registry/components/expanded/divider.css +1 -1
- package/registry/components/expanded/emptyState.css +1 -1
- package/registry/components/expanded/fileUpload.css +6 -6
- package/registry/components/expanded/slideout.css +9 -685
- package/registry/components/expanded/steps.css +3 -3
- package/registry/components/expanded/table.css +2 -2
- package/registry/components/expanded/timeline.css +2 -2
- package/registry/components/input-content.ts +1 -0
- package/registry/components/input-otp.tsx +13 -3
- package/registry/components/input.tsx +68 -43
- package/registry/components/item.tsx +189 -0
- package/registry/components/kbd.tsx +111 -4
- package/registry/components/menu.tsx +31 -245
- package/registry/components/menubar.tsx +1 -1
- package/registry/components/modal.tsx +142 -102
- package/registry/components/native-select.tsx +2 -2
- package/registry/components/pagination.tsx +80 -58
- package/registry/components/popover.tsx +162 -664
- package/registry/components/radio-card.tsx +116 -87
- package/registry/components/segmented-control.tsx +87 -0
- package/registry/components/select-content.tsx +2 -2
- package/registry/components/select.tsx +52 -16
- package/registry/components/sheet.tsx +1 -1
- package/registry/components/sidebar.tsx +1 -1
- package/registry/components/skeleton.css +0 -3
- package/registry/components/social-button.tsx +47 -25
- package/registry/components/spinner.tsx +18 -55
- package/registry/components/tabs.css +1 -1
- package/registry/components/tabs.tsx +8 -4
- package/registry/components/tag.tsx +2 -2
- package/registry/components/textarea.tsx +3 -3
- package/registry/components/toast.tsx +16 -11
- package/registry/components/toggle.tsx +2 -2
- package/registry/components/toolbar.tsx +89 -17
- package/registry/components/tooltip.tsx +1 -1
- package/registry/examples/alert-demo.tsx +25 -5
- package/registry/examples/attribute-demo.tsx +1 -1
- package/registry/examples/autocomplete-demo.tsx +3 -3
- package/registry/examples/avatar-demo.tsx +7 -7
- package/registry/examples/badge-demo.tsx +1 -1
- package/registry/examples/button-demo.tsx +6 -6
- package/registry/examples/button-group-demo.tsx +23 -2
- package/registry/examples/card-demo.tsx +46 -8
- package/registry/examples/carousel-demo.tsx +20 -2
- package/registry/examples/chart-demo.tsx +1 -1
- package/registry/examples/checkbox-demo.tsx +5 -5
- package/registry/examples/collection-filter-bar-demo.tsx +135 -0
- package/registry/examples/command-demo.tsx +3 -3
- package/registry/examples/{expanded/command-bar-demo.tsx → command-palette-demo.tsx} +5 -15
- package/registry/examples/context-menu-demo.tsx +1 -1
- package/registry/examples/control-density-contract-demo.tsx +61 -0
- package/registry/examples/date-picker-demo.tsx +12 -12
- package/registry/examples/divider-demo.tsx +3 -3
- package/registry/examples/expanded/banner-demo.tsx +1 -1
- package/registry/examples/expanded/breadcrumbs-demo.tsx +1 -1
- package/registry/examples/expanded/empty-state-demo.tsx +1 -1
- package/registry/examples/expanded/file-upload-demo.tsx +1 -1
- package/registry/examples/expanded/onboarding-step-demo.tsx +1 -1
- package/registry/examples/expanded/slideout-demo.tsx +2 -2
- package/registry/examples/expanded/steps-demo.tsx +1 -1
- package/registry/examples/expanded/tabs-demo.tsx +1 -1
- package/registry/examples/expanded/timeline-demo.tsx +1 -1
- package/registry/examples/hover-card-demo.tsx +2 -2
- package/registry/examples/input-demo.tsx +6 -6
- package/registry/examples/input-otp-demo.tsx +4 -4
- package/registry/examples/item-demo.tsx +46 -0
- package/registry/examples/kbd-demo.tsx +1 -1
- package/registry/examples/label-demo.tsx +1 -1
- package/registry/examples/menu-demo.tsx +1 -1
- package/registry/examples/modal-demo.tsx +67 -9
- package/registry/examples/navigation-menu-demo.tsx +1 -1
- package/registry/examples/pagination-demo.tsx +6 -3
- package/registry/examples/popover-demo.tsx +19 -19
- package/registry/examples/progress-demo.tsx +1 -1
- package/registry/examples/progress-slider-demo.tsx +1 -1
- package/registry/examples/radio-card-demo.tsx +4 -4
- package/registry/examples/radio-group-demo.tsx +2 -2
- package/registry/examples/resizable-demo.tsx +1 -1
- package/registry/examples/results-toolbar-demo.tsx +44 -0
- package/registry/examples/scroll-area-demo.tsx +3 -3
- package/registry/examples/segmented-control-demo.tsx +39 -0
- package/registry/examples/select-demo.tsx +1 -1
- package/registry/examples/sidebar-demo.tsx +1 -1
- package/registry/examples/slider-demo.tsx +3 -3
- package/registry/examples/social-button-demo.tsx +18 -8
- package/registry/examples/spinner-demo.tsx +13 -13
- package/registry/examples/tabs-demo.tsx +1 -1
- package/registry/examples/tag-demo.tsx +1 -1
- package/registry/examples/textarea-demo.tsx +4 -4
- package/registry/examples/toast-demo.tsx +1 -1
- package/registry/examples/toggle-demo.tsx +6 -6
- package/registry/examples/tooltip-demo.tsx +4 -4
- package/registry/guidance/USAGE.md +27 -0
- package/registry/hooks/use-direction.ts +193 -13
- package/registry/index.json +5311 -377
- package/registry/styles/globals.css +2440 -4061
- package/registry.json +119 -149
- package/schema/config.schema.json +11 -8
- package/schema/registry.schema.json +150 -45
- package/schema/tokens.schema.json +134 -34
- package/src/cli/command-line.js +194 -0
- package/src/cli/config-editors.js +9 -0
- package/src/cli/doctor.js +399 -0
- package/src/cli/file-transaction.js +295 -0
- package/src/cli/global-css.js +153 -0
- package/src/cli/index.js +567 -1613
- package/src/cli/install-plan.js +592 -0
- package/src/cli/install-receipt.js +171 -0
- package/src/cli/jsonc.js +203 -0
- package/src/cli/package-install-state.js +254 -0
- package/src/cli/package-manager.js +238 -0
- package/src/cli/package-plan.js +185 -0
- package/src/cli/package-version.js +97 -0
- package/src/cli/registry-query.js +207 -0
- package/src/cli/reporting.js +55 -0
- package/src/cli/schema-validation.js +19 -0
- package/src/cli/source-scanner.js +686 -0
- package/src/cli/vite-config.js +478 -0
- package/tokens/banhaten.tokens.json +4312 -309
- package/docs/design-system/components/command-bar.md +0 -57
- package/registry/components/expanded/BannerBoard.tsx +0 -225
- package/registry/components/expanded/CatalogTag.tsx +0 -85
- package/registry/components/expanded/CommandBar.tsx +0 -386
- package/registry/components/expanded/IconExplorer.tsx +0 -612
- package/registry/components/expanded/TimelineShowcase.tsx +0 -158
- package/registry/components/expanded/commandBar.css +0 -470
- package/registry/components/expanded/iconExplorer.css +0 -764
- package/registry/components/expanded/iconPacks.ts +0 -866
- package/registry/components/expanded/tag.css +0 -148
- package/registry/examples/expanded/icons-demo.tsx +0 -5
- package/tokens/Color mode.zip +0 -0
- package/tokens/Numbers.zip +0 -0
- package/tokens/Radius.zip +0 -0
- package/tokens/Theme.zip +0 -0
|
@@ -1,386 +0,0 @@
|
|
|
1
|
-
import "./commandBar.css";
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
ArrowUpDownIcon as LucideArrowUpDownIcon,
|
|
5
|
-
BookOpenIcon,
|
|
6
|
-
CommandIcon,
|
|
7
|
-
CornerDownLeftIcon,
|
|
8
|
-
SearchIcon as LucideSearchIcon,
|
|
9
|
-
XIcon,
|
|
10
|
-
} from "lucide-react";
|
|
11
|
-
|
|
12
|
-
import { Button } from "@/components/ui/button";
|
|
13
|
-
|
|
14
|
-
export type CommandBarType = "default" | "recent" | "results" | "no-result";
|
|
15
|
-
export type CommandBarBreakpoint = "desktop" | "mobile";
|
|
16
|
-
|
|
17
|
-
export type CommandBarProps = {
|
|
18
|
-
breakpoint?: CommandBarBreakpoint;
|
|
19
|
-
className?: string;
|
|
20
|
-
dir?: "ltr" | "rtl";
|
|
21
|
-
nodeId?: string;
|
|
22
|
-
type?: CommandBarType;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
type CommandBarCopy = {
|
|
26
|
-
clear: string;
|
|
27
|
-
commands: string;
|
|
28
|
-
description: string;
|
|
29
|
-
navigate: string;
|
|
30
|
-
noResults: string;
|
|
31
|
-
open: string;
|
|
32
|
-
placeholder: string;
|
|
33
|
-
recent: string;
|
|
34
|
-
results: string;
|
|
35
|
-
searchFor: string;
|
|
36
|
-
searchText: string;
|
|
37
|
-
tags: string[];
|
|
38
|
-
title: string;
|
|
39
|
-
tryDifferent: string;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
type CommandRow = {
|
|
43
|
-
readonly highlighted?: boolean;
|
|
44
|
-
readonly shortcut?: boolean;
|
|
45
|
-
readonly visual: "avatar" | "icon";
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const shortcutLabel = "Command K";
|
|
49
|
-
|
|
50
|
-
const ltrCopy: CommandBarCopy = {
|
|
51
|
-
clear: "Clear search",
|
|
52
|
-
commands: "Commands",
|
|
53
|
-
description: "Item description",
|
|
54
|
-
navigate: "Navigate",
|
|
55
|
-
noResults: "No results found",
|
|
56
|
-
open: "Open",
|
|
57
|
-
placeholder: "Search or type a command",
|
|
58
|
-
recent: "Recent",
|
|
59
|
-
results: "Results",
|
|
60
|
-
searchFor: "Search for",
|
|
61
|
-
searchText: "Search Text",
|
|
62
|
-
tags: ["All", "Tasks", "People", "Files", "Docs", "Comments"],
|
|
63
|
-
title: "Title",
|
|
64
|
-
tryDifferent: "Try using different keywords",
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
const rtlCopy: CommandBarCopy = {
|
|
68
|
-
clear: "\u0645\u0633\u062d \u0627\u0644\u0628\u062d\u062b",
|
|
69
|
-
commands: "\u0627\u0644\u0623\u0648\u0627\u0645\u0631",
|
|
70
|
-
description: "\u0627\u0644\u0646\u0635 \u0627\u0644\u062b\u0627\u0646\u0648\u064a",
|
|
71
|
-
navigate: "\u062a\u0646\u0642\u0644",
|
|
72
|
-
noResults:
|
|
73
|
-
"\u0644\u0645 \u064a\u062a\u0645 \u0627\u0644\u0639\u062b\u0648\u0631 \u0639\u0644\u0649 \u0646\u062a\u0627\u0626\u062c",
|
|
74
|
-
open: "\u0641\u062a\u062d",
|
|
75
|
-
placeholder:
|
|
76
|
-
"\u0627\u0628\u062d\u062b \u0623\u0648 \u0627\u0643\u062a\u0628 \u0623\u0645\u0631\u064b\u0627",
|
|
77
|
-
recent: "\u0627\u0644\u0623\u062e\u064a\u0631\u0629",
|
|
78
|
-
results: "\u0627\u0644\u0646\u062a\u0627\u0626\u062c",
|
|
79
|
-
searchFor: "\u0627\u0628\u062d\u062b \u0639\u0646",
|
|
80
|
-
searchText: "\u0646\u0635 \u0627\u0644\u0628\u062d\u062b",
|
|
81
|
-
tags: [
|
|
82
|
-
"\u0627\u0644\u0643\u0644",
|
|
83
|
-
"\u0627\u0644\u0645\u0647\u0627\u0645",
|
|
84
|
-
"\u0627\u0644\u0623\u0634\u062e\u0627\u0635",
|
|
85
|
-
"\u0627\u0644\u0645\u0644\u0641\u0627\u062a",
|
|
86
|
-
"\u0627\u0644\u0645\u0633\u062a\u0646\u062f\u0627\u062a",
|
|
87
|
-
"\u0627\u0644\u062a\u0639\u0644\u064a\u0642\u0627\u062a",
|
|
88
|
-
],
|
|
89
|
-
title: "\u0627\u0644\u0639\u0646\u0648\u0627\u0646",
|
|
90
|
-
tryDifferent:
|
|
91
|
-
"\u062c\u0631\u0628 \u0627\u0633\u062a\u062e\u062f\u0627\u0645 \u0643\u0644\u0645\u0627\u062a \u0645\u062e\u062a\u0644\u0641\u0629",
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
const recentRows = [
|
|
95
|
-
{ visual: "icon", shortcut: true },
|
|
96
|
-
{ visual: "avatar" },
|
|
97
|
-
{ visual: "icon", shortcut: true, highlighted: true },
|
|
98
|
-
{ visual: "icon", shortcut: true },
|
|
99
|
-
{ visual: "icon", shortcut: true },
|
|
100
|
-
] as const;
|
|
101
|
-
|
|
102
|
-
const commandRows = [
|
|
103
|
-
{ visual: "icon", shortcut: true },
|
|
104
|
-
{ visual: "icon", shortcut: true },
|
|
105
|
-
{ visual: "icon", shortcut: true },
|
|
106
|
-
{ visual: "icon", shortcut: true },
|
|
107
|
-
{ visual: "icon", shortcut: true },
|
|
108
|
-
{ visual: "icon", shortcut: true },
|
|
109
|
-
] as const;
|
|
110
|
-
|
|
111
|
-
const resultRows = [
|
|
112
|
-
{ visual: "icon", shortcut: true },
|
|
113
|
-
{ visual: "avatar" },
|
|
114
|
-
{ visual: "icon", shortcut: true, highlighted: true },
|
|
115
|
-
{ visual: "icon", shortcut: true },
|
|
116
|
-
{ visual: "icon", shortcut: true },
|
|
117
|
-
{ visual: "avatar" },
|
|
118
|
-
{ visual: "icon", shortcut: true },
|
|
119
|
-
{ visual: "icon", shortcut: true },
|
|
120
|
-
{ visual: "icon", shortcut: true },
|
|
121
|
-
] as const;
|
|
122
|
-
|
|
123
|
-
export function CommandBar({
|
|
124
|
-
breakpoint = "desktop",
|
|
125
|
-
className = "",
|
|
126
|
-
dir = "ltr",
|
|
127
|
-
nodeId,
|
|
128
|
-
type = "default",
|
|
129
|
-
}: CommandBarProps) {
|
|
130
|
-
const rtl = dir === "rtl";
|
|
131
|
-
const copy = rtl ? rtlCopy : ltrCopy;
|
|
132
|
-
const filled = type === "results" || type === "no-result";
|
|
133
|
-
const hasPanel = type !== "default";
|
|
134
|
-
const hasFooter = breakpoint === "desktop" && (type === "recent" || type === "results");
|
|
135
|
-
|
|
136
|
-
return (
|
|
137
|
-
<section
|
|
138
|
-
aria-label="Command bar"
|
|
139
|
-
className={[
|
|
140
|
-
"ds-command-bar",
|
|
141
|
-
`ds-command-bar--${breakpoint}`,
|
|
142
|
-
`ds-command-bar--${type}`,
|
|
143
|
-
rtl ? "ds-command-bar--rtl" : "ds-command-bar--ltr",
|
|
144
|
-
className,
|
|
145
|
-
]
|
|
146
|
-
.filter(Boolean)
|
|
147
|
-
.join(" ")}
|
|
148
|
-
data-node-id={nodeId}
|
|
149
|
-
dir={dir}
|
|
150
|
-
>
|
|
151
|
-
<div className={breakpoint === "mobile" ? "ds-command-bar__input-wrap" : undefined}>
|
|
152
|
-
<SearchInput
|
|
153
|
-
breakpoint={breakpoint}
|
|
154
|
-
copy={copy}
|
|
155
|
-
filled={filled}
|
|
156
|
-
hasDivider={hasPanel && breakpoint === "desktop"}
|
|
157
|
-
/>
|
|
158
|
-
</div>
|
|
159
|
-
|
|
160
|
-
{type === "recent" && <RecentPanel copy={copy} />}
|
|
161
|
-
{type === "results" && <ResultsPanel copy={copy} />}
|
|
162
|
-
{type === "no-result" && <EmptyPanel copy={copy} />}
|
|
163
|
-
{hasFooter && <CommandFooter copy={copy} />}
|
|
164
|
-
</section>
|
|
165
|
-
);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
function SearchInput({
|
|
169
|
-
breakpoint,
|
|
170
|
-
copy,
|
|
171
|
-
filled,
|
|
172
|
-
hasDivider,
|
|
173
|
-
}: {
|
|
174
|
-
breakpoint: CommandBarBreakpoint;
|
|
175
|
-
copy: CommandBarCopy;
|
|
176
|
-
filled: boolean;
|
|
177
|
-
hasDivider: boolean;
|
|
178
|
-
}) {
|
|
179
|
-
const className = [
|
|
180
|
-
"ds-command-bar__search",
|
|
181
|
-
filled ? "ds-command-bar__search--filled" : "ds-command-bar__search--default",
|
|
182
|
-
hasDivider ? "ds-command-bar__search--divider" : "",
|
|
183
|
-
]
|
|
184
|
-
.filter(Boolean)
|
|
185
|
-
.join(" ");
|
|
186
|
-
const iconSize = breakpoint === "mobile" ? 20 : 24;
|
|
187
|
-
const content = (
|
|
188
|
-
<>
|
|
189
|
-
<span className="ds-command-bar__search-content">
|
|
190
|
-
<SearchIcon size={iconSize} />
|
|
191
|
-
<span className={filled ? "ds-command-bar__search-text" : "ds-command-bar__placeholder"}>
|
|
192
|
-
{filled ? copy.searchText : copy.placeholder}
|
|
193
|
-
</span>
|
|
194
|
-
</span>
|
|
195
|
-
{filled ? (
|
|
196
|
-
<button aria-label={copy.clear} className="ds-command-bar__close" type="button">
|
|
197
|
-
<CloseIcon />
|
|
198
|
-
</button>
|
|
199
|
-
) : (
|
|
200
|
-
breakpoint === "desktop" && <Shortcut />
|
|
201
|
-
)}
|
|
202
|
-
</>
|
|
203
|
-
);
|
|
204
|
-
|
|
205
|
-
if (filled) {
|
|
206
|
-
return (
|
|
207
|
-
<div className={className} role="search">
|
|
208
|
-
{content}
|
|
209
|
-
</div>
|
|
210
|
-
);
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
return (
|
|
214
|
-
<button className={className} type="button">
|
|
215
|
-
{content}
|
|
216
|
-
</button>
|
|
217
|
-
);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
function RecentPanel({ copy }: { copy: CommandBarCopy }) {
|
|
221
|
-
return (
|
|
222
|
-
<div className="ds-command-bar__content">
|
|
223
|
-
<div className="ds-command-bar__main">
|
|
224
|
-
<CommandSection copy={copy} items={recentRows} label={copy.recent} />
|
|
225
|
-
<CommandSection copy={copy} items={commandRows} label={copy.commands} />
|
|
226
|
-
</div>
|
|
227
|
-
</div>
|
|
228
|
-
);
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
function ResultsPanel({ copy }: { copy: CommandBarCopy }) {
|
|
232
|
-
return (
|
|
233
|
-
<div className="ds-command-bar__content">
|
|
234
|
-
<div className="ds-command-bar__main">
|
|
235
|
-
<FilterSection copy={copy} />
|
|
236
|
-
<CommandSection copy={copy} items={resultRows} label={copy.results} />
|
|
237
|
-
</div>
|
|
238
|
-
</div>
|
|
239
|
-
);
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
function EmptyPanel({ copy }: { copy: CommandBarCopy }) {
|
|
243
|
-
return (
|
|
244
|
-
<div className="ds-command-bar__empty">
|
|
245
|
-
<div className="ds-command-bar__empty-wrap">
|
|
246
|
-
<span className="ds-command-bar__empty-icon">
|
|
247
|
-
<SearchIcon size={24} />
|
|
248
|
-
</span>
|
|
249
|
-
<strong>{copy.noResults}</strong>
|
|
250
|
-
<span>{copy.tryDifferent}</span>
|
|
251
|
-
</div>
|
|
252
|
-
</div>
|
|
253
|
-
);
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
function FilterSection({ copy }: { copy: CommandBarCopy }) {
|
|
257
|
-
return (
|
|
258
|
-
<div className="ds-command-bar__filter">
|
|
259
|
-
<SectionHeading>{copy.searchFor}</SectionHeading>
|
|
260
|
-
<div className="ds-command-bar__tags" aria-label={copy.searchFor}>
|
|
261
|
-
{copy.tags.map((tag) => (
|
|
262
|
-
<Button
|
|
263
|
-
className="ds-command-bar__tag"
|
|
264
|
-
key={tag}
|
|
265
|
-
size="sm"
|
|
266
|
-
type="button"
|
|
267
|
-
variant="secondary"
|
|
268
|
-
>
|
|
269
|
-
{tag}
|
|
270
|
-
</Button>
|
|
271
|
-
))}
|
|
272
|
-
</div>
|
|
273
|
-
</div>
|
|
274
|
-
);
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
function CommandSection({
|
|
278
|
-
copy,
|
|
279
|
-
items,
|
|
280
|
-
label,
|
|
281
|
-
}: {
|
|
282
|
-
copy: CommandBarCopy;
|
|
283
|
-
items: ReadonlyArray<CommandRow>;
|
|
284
|
-
label: string;
|
|
285
|
-
}) {
|
|
286
|
-
return (
|
|
287
|
-
<div className="ds-command-bar__section">
|
|
288
|
-
<SectionHeading>{label}</SectionHeading>
|
|
289
|
-
<div className="ds-command-bar__group">
|
|
290
|
-
{items.map((item, index) => (
|
|
291
|
-
<CommandItem copy={copy} item={item} key={`${label}-${index}`} />
|
|
292
|
-
))}
|
|
293
|
-
</div>
|
|
294
|
-
</div>
|
|
295
|
-
);
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
function SectionHeading({ children }: { children: string }) {
|
|
299
|
-
return (
|
|
300
|
-
<div className="ds-command-bar__section-heading">
|
|
301
|
-
<span>{children}</span>
|
|
302
|
-
</div>
|
|
303
|
-
);
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
function CommandItem({
|
|
307
|
-
copy,
|
|
308
|
-
item,
|
|
309
|
-
}: {
|
|
310
|
-
copy: CommandBarCopy;
|
|
311
|
-
item: CommandRow;
|
|
312
|
-
}) {
|
|
313
|
-
return (
|
|
314
|
-
<button
|
|
315
|
-
className={["ds-command-bar__item", item.highlighted ? "is-highlighted" : ""].filter(Boolean).join(" ")}
|
|
316
|
-
type="button"
|
|
317
|
-
>
|
|
318
|
-
{item.visual === "avatar" ? <Avatar /> : <IconWrap />}
|
|
319
|
-
<span className="ds-command-bar__item-copy">
|
|
320
|
-
<strong>{copy.title}</strong>
|
|
321
|
-
<span>{copy.description}</span>
|
|
322
|
-
</span>
|
|
323
|
-
{item.shortcut && <Shortcut />}
|
|
324
|
-
</button>
|
|
325
|
-
);
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
function CommandFooter({ copy }: { copy: CommandBarCopy }) {
|
|
329
|
-
return (
|
|
330
|
-
<footer className="ds-command-bar__footer">
|
|
331
|
-
<span className="ds-command-bar__footer-content">
|
|
332
|
-
<span className="ds-command-bar__footer-hint">
|
|
333
|
-
<ArrowUpDownIcon />
|
|
334
|
-
<span>{copy.navigate}</span>
|
|
335
|
-
</span>
|
|
336
|
-
<span className="ds-command-bar__footer-hint">
|
|
337
|
-
<EnterIcon />
|
|
338
|
-
<span>{copy.open}</span>
|
|
339
|
-
</span>
|
|
340
|
-
</span>
|
|
341
|
-
</footer>
|
|
342
|
-
);
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
function Shortcut() {
|
|
346
|
-
return (
|
|
347
|
-
<kbd aria-label={shortcutLabel} className="ds-command-bar__shortcut">
|
|
348
|
-
<CommandIcon aria-hidden="true" className="ds-command-bar__shortcut-icon" />
|
|
349
|
-
<span aria-hidden="true" className="ds-command-bar__shortcut-key">
|
|
350
|
-
K
|
|
351
|
-
</span>
|
|
352
|
-
</kbd>
|
|
353
|
-
);
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
function IconWrap() {
|
|
357
|
-
return (
|
|
358
|
-
<span className="ds-command-bar__icon-wrap">
|
|
359
|
-
<BookIcon />
|
|
360
|
-
</span>
|
|
361
|
-
);
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
function Avatar() {
|
|
365
|
-
return <span aria-hidden="true" className="ds-command-bar__avatar" />;
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
function SearchIcon({ size = 24 }: { size?: number }) {
|
|
369
|
-
return <LucideSearchIcon aria-hidden="true" height={size} strokeWidth={2} width={size} />;
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
function CloseIcon() {
|
|
373
|
-
return <XIcon aria-hidden="true" height="20" strokeWidth={2.2} width="20" />;
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
function BookIcon() {
|
|
377
|
-
return <BookOpenIcon aria-hidden="true" height="20" strokeWidth={1.8} width="20" />;
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
function ArrowUpDownIcon() {
|
|
381
|
-
return <LucideArrowUpDownIcon aria-hidden="true" height="16" strokeWidth={1.9} width="16" />;
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
function EnterIcon() {
|
|
385
|
-
return <CornerDownLeftIcon aria-hidden="true" height="16" strokeWidth={1.9} width="16" />;
|
|
386
|
-
}
|