@conscience-technology/ovenn 0.7.4 → 0.7.6
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 +43 -4
- package/assets/components/AIMessage/AIMessage.module.css +10 -0
- package/assets/components/AIMessage/AIMessage.tsx +6 -2
- package/assets/components/AttachmentThumb/AttachmentThumb.tsx +1 -0
- package/assets/components/Breadcrumb/Breadcrumb.module.css +82 -23
- package/assets/components/Breadcrumb/Breadcrumb.tsx +44 -26
- package/assets/components/Breadcrumb/index.ts +1 -0
- package/assets/components/Button/Button.module.css +2 -4
- package/assets/components/Callout/Callout.module.css +44 -18
- package/assets/components/Callout/Callout.tsx +9 -4
- package/assets/components/Callout/index.ts +1 -1
- package/assets/components/Canvas/Canvas.module.css +13 -0
- package/assets/components/Canvas/Canvas.tsx +378 -94
- package/assets/components/Canvas/clipboard.ts +5 -1
- package/assets/components/Canvas/collision.ts +5 -1
- package/assets/components/Canvas/graph.ts +14 -5
- package/assets/components/Canvas/history.ts +11 -4
- package/assets/components/Canvas/index.ts +2 -1
- package/assets/components/Canvas/types.ts +36 -1
- package/assets/components/CanvasEdge/tokens.css +14 -1
- package/assets/components/CanvasNode/tokens.css +13 -10
- package/assets/components/ChatComposer/ChatComposer.tsx +1 -1
- package/assets/components/ChatInput/ChatInput.tsx +1 -1
- package/assets/components/ColorField/ColorField.module.css +6 -1
- package/assets/components/ColorPicker/ColorPicker.module.css +3 -0
- package/assets/components/CommandPalette/CommandPalette.module.css +114 -0
- package/assets/components/CommandPalette/CommandPalette.tsx +206 -21
- package/assets/components/CommandPalette/index.ts +1 -0
- package/assets/components/Drawer/Drawer.module.css +30 -0
- package/assets/components/Drawer/Drawer.tsx +75 -16
- package/assets/components/Drawer/index.ts +1 -0
- package/assets/components/FileIcon/FileIcon.tsx +1 -0
- package/assets/components/FileIcon/fileExtMap.ts +1 -0
- package/assets/components/Icon/Icon.tsx +3 -0
- package/assets/components/Input/Input.module.css +3 -3
- package/assets/components/Onboarding/OnboardingAxisPanel.tsx +1 -1
- package/assets/components/Onboarding/OnboardingPage.tsx +13 -11
- package/assets/components/Onboarding/actions.ts +9 -9
- package/assets/components/Select/Select.module.css +1 -1
- package/assets/components/SocialLoginButton/SocialLoginButton.module.css +198 -0
- package/assets/components/SocialLoginButton/SocialLoginButton.tsx +86 -0
- package/assets/components/SocialLoginButton/assets/amazon.svg +1 -0
- package/assets/components/SocialLoginButton/assets/apple.svg +3 -0
- package/assets/components/SocialLoginButton/assets/discord.svg +3 -0
- package/assets/components/SocialLoginButton/assets/facebook-white.png +0 -0
- package/assets/components/SocialLoginButton/assets/facebook.png +0 -0
- package/assets/components/SocialLoginButton/assets/github.svg +3 -0
- package/assets/components/SocialLoginButton/assets/google-mark.png +0 -0
- package/assets/components/SocialLoginButton/assets/kakao.svg +3 -0
- package/assets/components/SocialLoginButton/assets/line-icon.png +0 -0
- package/assets/components/SocialLoginButton/assets/line-white.png +0 -0
- package/assets/components/SocialLoginButton/assets/linkedin-white.png +0 -0
- package/assets/components/SocialLoginButton/assets/linkedin.png +0 -0
- package/assets/components/SocialLoginButton/assets/microsoft.svg +6 -0
- package/assets/components/SocialLoginButton/assets/naver.png +0 -0
- package/assets/components/SocialLoginButton/assets/slack.svg +17 -0
- package/assets/components/SocialLoginButton/assets/spotify.svg +3 -0
- package/assets/components/SocialLoginButton/assets/twitch.svg +21 -0
- package/assets/components/SocialLoginButton/assets/wechat.png +0 -0
- package/assets/components/SocialLoginButton/assets/x.svg +3 -0
- package/assets/components/SocialLoginButton/index.ts +2 -0
- package/assets/components/SocialLoginButton/provider-tokens.css +30 -0
- package/assets/components/SocialLoginButton/providers.ts +23 -0
- package/assets/components/TableRowEdit/TableRowEdit.tsx +2 -2
- package/assets/components/ThemeController.tsx +2 -2
- package/assets/components/TimelineView/TimelineView.tsx +4 -2
- package/assets/components/Tooltip/Tooltip.module.css +1 -0
- package/assets/components/_data.ts +1 -1
- package/assets/components/_utils.css +1 -0
- package/assets/components/component-registry.json +30 -1
- package/assets/components/index.ts +1 -0
- package/assets/components/side-effect-css.d.ts +5 -0
- package/assets/components/themeBootScript.ts +7 -1
- package/assets/components/tokens.css +14 -6
- package/assets/prompts/ASSEMBLY.md +4 -0
- package/assets/prompts/CASCADE.md +2 -2
- package/assets/prompts/CATALOG.md +2 -1
- package/assets/prompts/PRINCIPLES.md +4 -8
- package/assets/prompts/RULES.md +19 -1
- package/assets/prompts/SLOTS.md +2 -4
- package/assets/prompts/WORKFLOW_DESIGN.md +0 -4
- package/assets/prompts/axes/icon.md +1 -1
- package/assets/prompts/axes/material.md +4 -4
- package/assets/prompts/axes/motion.md +1 -1
- package/assets/prompts/axes/shape.md +2 -2
- package/assets/prompts/axes/voice.md +1 -1
- package/assets/prompts/components/_variants.md +4 -4
- package/assets/prompts/components/accordion.md +4 -4
- package/assets/prompts/components/ai-message.md +6 -2
- package/assets/prompts/components/attachment-item.md +2 -2
- package/assets/prompts/components/breadcrumb.md +11 -5
- package/assets/prompts/components/button.md +3 -3
- package/assets/prompts/components/callout.md +8 -4
- package/assets/prompts/components/canvas-edge.md +1 -1
- package/assets/prompts/components/canvas-node.md +1 -1
- package/assets/prompts/components/canvas.md +24 -8
- package/assets/prompts/components/card.md +1 -2
- package/assets/prompts/components/chart-bar.md +1 -1
- package/assets/prompts/components/chat-input.md +1 -1
- package/assets/prompts/components/checkbox.md +5 -5
- package/assets/prompts/components/color-field.md +2 -2
- package/assets/prompts/components/command-palette.md +55 -47
- package/assets/prompts/components/context-menu.md +5 -5
- package/assets/prompts/components/date-picker.md +2 -2
- package/assets/prompts/components/drawer.md +17 -3
- package/assets/prompts/components/dropdown-menu.md +3 -3
- package/assets/prompts/components/event-list-item.md +4 -4
- package/assets/prompts/components/file-icon.md +2 -2
- package/assets/prompts/components/gallery-item.md +1 -1
- package/assets/prompts/components/hint.md +3 -3
- package/assets/prompts/components/kanban.md +2 -3
- package/assets/prompts/components/list-item.md +12 -12
- package/assets/prompts/components/menu-item.md +2 -2
- package/assets/prompts/components/message-table.md +4 -4
- package/assets/prompts/components/onboarding.md +3 -3
- package/assets/prompts/components/page-header.md +6 -7
- package/assets/prompts/components/quotation-bar.md +1 -1
- package/assets/prompts/components/select.md +1 -1
- package/assets/prompts/components/shortcut.md +3 -3
- package/assets/prompts/components/sidebar.md +5 -4
- package/assets/prompts/components/social-login-button.md +117 -0
- package/assets/prompts/components/stepper.md +1 -1
- package/assets/prompts/components/tab-strip.md +2 -2
- package/assets/prompts/components/table-row-edit.md +6 -6
- package/assets/prompts/components/table-row-select.md +1 -1
- package/assets/prompts/components/tabs.md +5 -2
- package/assets/prompts/components/textarea.md +1 -1
- package/assets/prompts/components/toast.md +3 -3
- package/assets/prompts/components/tooltip.md +3 -3
- package/assets/prompts/components/topbar.md +1 -1
- package/assets/prompts/design-examples/ai-chat-full-page.png +0 -0
- package/assets/prompts/design-examples/catalog.json +9 -9
- package/assets/prompts/design-examples/sources/ai-chat-full-page/ChatExperience.module.css +37 -1
- package/assets/prompts/design-examples/sources/ai-chat-full-page/ChatExperience.tsx +113 -18
- package/assets/prompts/design-examples/sources/ai-chat-full-page/FullPageChat.tsx +2 -2
- package/assets/prompts/design-examples/sources/ai-chat-full-page/REFERENCE.md +3 -1
- package/assets/prompts/design-examples/sources/ai-chat-full-page/useChatDemo.ts +99 -51
- package/assets/prompts/primitives/scroll.md +1 -1
- package/assets/prompts/recipes/README.md +5 -6
- package/assets/prompts/recipes/meta-line.md +2 -2
- package/assets/prompts/recipes/page-header.md +2 -2
- package/assets/prompts/recipes/section-header.md +1 -1
- package/assets/prompts/themes/_SCHEMA.md +2 -2
- package/assets/prompts/tokens/material.md +5 -2
- package/assets/prompts/tokens/radius.md +1 -1
- package/assets/prompts/use-cases/chat-chat-input.md +382 -74
- package/assets/prompts/use-cases/data-list-item.md +38 -431
- package/assets/prompts/use-cases/feedback-drawer.md +112 -33
- package/assets/prompts/use-cases/overlay-command-palette.md +2004 -0
- package/assets/prompts/use-cases/structure-canvas.md +1016 -0
- package/assets/skills/ovenn-validate/SKILL.md +1 -1
- package/assets/skills/ovenn-validate/scripts/lib/component-usage.js +7 -1
- package/assets/skills/ovenn-validate/scripts/lib/engine.mjs +105 -0
- package/assets/skills/ovenn-validate/scripts/lib/engine.test.mjs +46 -0
- package/assets/skills/ovenn-validate/scripts/lib/source-utils.mjs +5 -3
- package/assets/skills/ovenn-validate/scripts/rules/doc-sync.mjs +28 -5
- package/assets/skills/ovenn-validate/scripts/rules/doc-sync.test.mjs +15 -0
- package/assets/skills/ovenn-validate/scripts/rules/ghost-tokens.mjs +7 -0
- package/assets/skills/ovenn-validate/scripts/rules/hardcoded.mjs +61 -30
- package/assets/skills/ovenn-validate/scripts/rules/memory-rules.mjs +7 -4
- package/assets/skills/ovenn-validate/scripts/rules/memory-rules.test.mjs +3 -0
- package/assets/skills/ovenn-validate/scripts/validate.mjs +8 -136
- package/assets/skills/ovenn-wireframe/SKILL.md +1 -1
- package/bin/ovenn.js +8 -0
- package/package.json +2 -2
- package/src/commands/check.js +70 -0
- package/src/commands/info.js +32 -7
- package/src/commands/init.js +26 -30
- package/src/commands/setup-checks.js +80 -0
- package/src/commands/update.js +90 -18
- package/src/data/ctds-releases.json +1 -0
- package/src/utils/assets.js +5 -0
- package/src/utils/component-usage.js +7 -1
- package/src/utils/design-workflow.js +6 -2
- package/src/utils/doctor.js +7 -1
- package/src/utils/legacy-ctds.js +169 -0
- package/src/utils/managed-assets.js +16 -3
- package/src/utils/route.js +17 -0
- package/src/utils/rules-context.js +91 -0
- package/src/utils/update-transaction.js +16 -3
- package/assets/prompts/FEEDBACK_PROCESS.md +0 -19
- package/assets/prompts/GUIDE.md +0 -307
- package/assets/prompts/MEMORY.md +0 -202
- package/assets/prompts/TEMPLATE_PREVIEWS.md +0 -21
- package/assets/prompts/components/README.md +0 -84
|
@@ -0,0 +1,2004 @@
|
|
|
1
|
+
# Command Palette 사용 사례 소스
|
|
2
|
+
|
|
3
|
+
<!-- Generated by scripts/build-use-cases.mjs. Edit original TSX/CSS, then regenerate. -->
|
|
4
|
+
|
|
5
|
+
### 사례 목록
|
|
6
|
+
|
|
7
|
+
- Expanding topbar search
|
|
8
|
+
- Nested navigation
|
|
9
|
+
- File search with preview
|
|
10
|
+
- Workspace commands
|
|
11
|
+
- Application launcher
|
|
12
|
+
|
|
13
|
+
문서: /en/components/overlay/command-palette#use-cases
|
|
14
|
+
|
|
15
|
+
문서 페이지에서 렌더하는 사례입니다.
|
|
16
|
+
|
|
17
|
+
### 조회 방법
|
|
18
|
+
|
|
19
|
+
get_guide(topic="use-cases/overlay-command-palette", sections=["사례 목록", "파일 목록"])로 먼저 확인하고, 필요한 Section 또는 Source 파일 헤딩만 sections로 조회하세요. 전체 문서는 문서 페이지의 다른 예제도 포함합니다. 공용 컴포넌트 계약은 get_component로 읽고, 예제의 docs 전용 셸·locale·import 경로는 대상 프로젝트에 맞게 조합하세요. 이 연결은 디자인 승인이나 기능 검증을 뜻하지 않습니다.
|
|
20
|
+
|
|
21
|
+
### 파일 목록
|
|
22
|
+
|
|
23
|
+
- `web/app/[lang]/components/overlay/command-palette/_strings.tsx`
|
|
24
|
+
- `web/app/[lang]/components/overlay/command-palette/page.tsx`
|
|
25
|
+
- `web/examples/command-palette/DetailPalettes.module.css`
|
|
26
|
+
- `web/examples/command-palette/DetailPalettes.tsx`
|
|
27
|
+
- `web/examples/command-palette/ExpandingSearch.module.css`
|
|
28
|
+
- `web/examples/command-palette/ExpandingSearch.tsx`
|
|
29
|
+
- `web/examples/command-palette/ReferencePalettes.module.css`
|
|
30
|
+
- `web/examples/command-palette/ReferencePalettes.tsx`
|
|
31
|
+
|
|
32
|
+
### Section: web/app/[lang]/components/overlay/command-palette/page.tsx#use-cases
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
<section id="use-cases">
|
|
36
|
+
<h2>{t.useCases.heading}</h2>
|
|
37
|
+
<h3>{t.useCases.expanding}</h3>
|
|
38
|
+
<p className="desc">{t.useCases.expandingDesc}</p>
|
|
39
|
+
<ExampleBlock previewWidth="full" code={`<Topbar.Center>
|
|
40
|
+
<CommandPalette
|
|
41
|
+
open={open}
|
|
42
|
+
onOpenChange={setOpen}
|
|
43
|
+
presentation="expand"
|
|
44
|
+
dimmed={false}
|
|
45
|
+
trigger={<CommandPalette.Trigger variant="neutral">Search documents</CommandPalette.Trigger>}
|
|
46
|
+
>
|
|
47
|
+
<CommandPalette.Input placeholder="Search documents" />
|
|
48
|
+
<CommandPalette.List>
|
|
49
|
+
<CommandPalette.Empty />
|
|
50
|
+
<CommandPalette.Item onSelect={() => setOpen(false)}>
|
|
51
|
+
Redwood Design System
|
|
52
|
+
</CommandPalette.Item>
|
|
53
|
+
</CommandPalette.List>
|
|
54
|
+
</CommandPalette>
|
|
55
|
+
</Topbar.Center>`}>
|
|
56
|
+
<ExpandingSearch lang={lang} />
|
|
57
|
+
</ExampleBlock>
|
|
58
|
+
<h3>{t.useCases.nested}</h3>
|
|
59
|
+
<p className="desc">{t.useCases.nestedDesc}</p>
|
|
60
|
+
<ExampleBlock previewWidth="full">
|
|
61
|
+
<DetailPalette kind="nested" lang={lang} />
|
|
62
|
+
</ExampleBlock>
|
|
63
|
+
<h3>{t.useCases.preview}</h3>
|
|
64
|
+
<p className="desc">{t.useCases.previewDesc}</p>
|
|
65
|
+
<ExampleBlock previewWidth="full">
|
|
66
|
+
<DetailPalette kind="preview" lang={lang} />
|
|
67
|
+
</ExampleBlock>
|
|
68
|
+
<h3>{t.useCases.workspace}</h3>
|
|
69
|
+
<ExampleBlock previewWidth="full">
|
|
70
|
+
<ReferencePalette kind="workspace" lang={lang} />
|
|
71
|
+
</ExampleBlock>
|
|
72
|
+
<h3>{t.useCases.launcher}</h3>
|
|
73
|
+
<ExampleBlock previewWidth="full">
|
|
74
|
+
<ReferencePalette kind="launcher" lang={lang} />
|
|
75
|
+
</ExampleBlock>
|
|
76
|
+
</section>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Source: web/app/[lang]/components/overlay/command-palette/_strings.tsx
|
|
80
|
+
|
|
81
|
+
````tsx
|
|
82
|
+
import { Code } from "@/components/Code";
|
|
83
|
+
import { Shortcut } from "@/components/Shortcut";
|
|
84
|
+
import type { ReactNode } from "react";
|
|
85
|
+
|
|
86
|
+
type Strings = {
|
|
87
|
+
title: string;
|
|
88
|
+
lead: string;
|
|
89
|
+
useCases: { heading: string; workspace: string; launcher: string; expanding: string; expandingDesc: string; nested: string; nestedDesc: string; preview: string; previewDesc: string };
|
|
90
|
+
|
|
91
|
+
usage: {
|
|
92
|
+
heading: string;
|
|
93
|
+
desc: ReactNode;
|
|
94
|
+
searchButton: string;
|
|
95
|
+
placeholder: string;
|
|
96
|
+
empty: string;
|
|
97
|
+
dashboard: string;
|
|
98
|
+
projects: string;
|
|
99
|
+
settings: string;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
playground: {
|
|
103
|
+
desc: ReactNode;
|
|
104
|
+
openButton: string;
|
|
105
|
+
lastRun: string;
|
|
106
|
+
placeholder: string;
|
|
107
|
+
pages: string;
|
|
108
|
+
dashboard: string;
|
|
109
|
+
projects: string;
|
|
110
|
+
settings: string;
|
|
111
|
+
empty: string;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
withGroups: {
|
|
115
|
+
heading: string;
|
|
116
|
+
desc: ReactNode;
|
|
117
|
+
placeholder: string;
|
|
118
|
+
empty: string;
|
|
119
|
+
pages: string;
|
|
120
|
+
dashboard: string;
|
|
121
|
+
projects: string;
|
|
122
|
+
actions: string;
|
|
123
|
+
newDoc: string;
|
|
124
|
+
uploadFile: string;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
withShortcuts: {
|
|
128
|
+
heading: string;
|
|
129
|
+
desc: ReactNode;
|
|
130
|
+
placeholder: string;
|
|
131
|
+
empty: string;
|
|
132
|
+
frequent: string;
|
|
133
|
+
newDoc: string;
|
|
134
|
+
uploadFile: string;
|
|
135
|
+
copyLink: string;
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
emptyState: {
|
|
139
|
+
heading: string;
|
|
140
|
+
desc: ReactNode;
|
|
141
|
+
placeholder: string;
|
|
142
|
+
empty: string;
|
|
143
|
+
dashboard: string;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
api: {
|
|
147
|
+
heading: string;
|
|
148
|
+
itemHeading: string;
|
|
149
|
+
triggerRows: { size: string; variant: string; shortcut: string };
|
|
150
|
+
inputRows: { value: string; onValueChange: string; leadingIcon: string; trailing: string };
|
|
151
|
+
columns: { prop: string; type: string; default: string; desc: string };
|
|
152
|
+
rows: {
|
|
153
|
+
open: string;
|
|
154
|
+
onOpenChange: string;
|
|
155
|
+
size: string;
|
|
156
|
+
label: string;
|
|
157
|
+
labelDefault: string;
|
|
158
|
+
presentation: string;
|
|
159
|
+
trigger: string;
|
|
160
|
+
dimmed: string;
|
|
161
|
+
onEscapeKeyDown: string;
|
|
162
|
+
value: string;
|
|
163
|
+
className: string;
|
|
164
|
+
};
|
|
165
|
+
itemRows: {
|
|
166
|
+
leadingIcon: string;
|
|
167
|
+
shortcut: string;
|
|
168
|
+
onSelect: string;
|
|
169
|
+
disabled: string;
|
|
170
|
+
};
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
const en: Strings = {
|
|
175
|
+
useCases: { heading: "Use cases", workspace: "Workspace commands", launcher: "Application launcher", nested: "Nested navigation", nestedDesc: "Open a project to search its files. Use Back or Escape to restore the previous search and selection.", preview: "File search with preview", previewDesc: "Selection updates the preview. Use Enter or Open for details, and filter by file ownership.", expanding: "Expanding topbar search", expandingDesc: "The search field expands from the topbar. Keep background dimming off for this pattern." },
|
|
176
|
+
title: "Command Palette",
|
|
177
|
+
lead: "Find pages and run actions from one search field.",
|
|
178
|
+
|
|
179
|
+
usage: {
|
|
180
|
+
heading: "Usage",
|
|
181
|
+
desc: (
|
|
182
|
+
<>
|
|
183
|
+
Open from a search button or <Code>useCommandPaletteHotkey</Code>. Connect each item to an action, then close with <Code>onOpenChange(false)</Code>.
|
|
184
|
+
</>
|
|
185
|
+
),
|
|
186
|
+
searchButton: "Search",
|
|
187
|
+
placeholder: "Search or type a command",
|
|
188
|
+
empty: "No results",
|
|
189
|
+
dashboard: "Dashboard",
|
|
190
|
+
projects: "Projects",
|
|
191
|
+
settings: "Settings",
|
|
192
|
+
},
|
|
193
|
+
|
|
194
|
+
playground: {
|
|
195
|
+
desc: (
|
|
196
|
+
<>
|
|
197
|
+
Change the result size, icons, and shortcut labels. Use <Shortcut>⌘K</Shortcut> while focused inside this playground to open or close it.
|
|
198
|
+
</>
|
|
199
|
+
),
|
|
200
|
+
openButton: "Open palette",
|
|
201
|
+
lastRun: "Last run:",
|
|
202
|
+
placeholder: "Search or type a command",
|
|
203
|
+
pages: "Pages",
|
|
204
|
+
dashboard: "Dashboard",
|
|
205
|
+
projects: "Projects",
|
|
206
|
+
settings: "Settings",
|
|
207
|
+
empty: "No results",
|
|
208
|
+
},
|
|
209
|
+
|
|
210
|
+
withGroups: {
|
|
211
|
+
heading: "Groups",
|
|
212
|
+
desc: (
|
|
213
|
+
<>
|
|
214
|
+
Use <Code>CommandPalette.Group</Code> to separate pages from actions.
|
|
215
|
+
</>
|
|
216
|
+
),
|
|
217
|
+
placeholder: "Search or type a command",
|
|
218
|
+
empty: "No results",
|
|
219
|
+
pages: "Pages",
|
|
220
|
+
dashboard: "Dashboard",
|
|
221
|
+
projects: "Projects",
|
|
222
|
+
actions: "Actions",
|
|
223
|
+
newDoc: "New doc",
|
|
224
|
+
uploadFile: "Upload file",
|
|
225
|
+
},
|
|
226
|
+
|
|
227
|
+
withShortcuts: {
|
|
228
|
+
heading: "Shortcuts",
|
|
229
|
+
desc: (
|
|
230
|
+
<>
|
|
231
|
+
Use <Code>shortcut</Code> to display a key combination. Register its keyboard handler separately.
|
|
232
|
+
</>
|
|
233
|
+
),
|
|
234
|
+
placeholder: "Search or type a command",
|
|
235
|
+
empty: "No results",
|
|
236
|
+
frequent: "Frequent actions",
|
|
237
|
+
newDoc: "New doc",
|
|
238
|
+
uploadFile: "Upload file",
|
|
239
|
+
copyLink: "Copy share link",
|
|
240
|
+
},
|
|
241
|
+
|
|
242
|
+
emptyState: {
|
|
243
|
+
heading: "Empty State",
|
|
244
|
+
desc: (
|
|
245
|
+
<>
|
|
246
|
+
<Code>CommandPalette.Empty</Code> shows an empty state when the search has no matches.
|
|
247
|
+
</>
|
|
248
|
+
),
|
|
249
|
+
placeholder: "Type anything",
|
|
250
|
+
empty: "No results",
|
|
251
|
+
dashboard: "Dashboard",
|
|
252
|
+
},
|
|
253
|
+
|
|
254
|
+
api: {
|
|
255
|
+
heading: "API Reference",
|
|
256
|
+
itemHeading: "CommandPalette.Item",
|
|
257
|
+
triggerRows: {
|
|
258
|
+
size: "Search trigger height. Independent of the result row size.",
|
|
259
|
+
variant: "Button appearance. Use outline for a border or neutral for a light fill.",
|
|
260
|
+
shortcut: "Shortcut hint. Set null to hide it. Register its keyboard handler separately.",
|
|
261
|
+
},
|
|
262
|
+
inputRows: {
|
|
263
|
+
value: "Search text. Separate from the selected item value on Root.",
|
|
264
|
+
onValueChange: "Called when the search text changes.",
|
|
265
|
+
leadingIcon: "Search field icon. Set null to hide it.",
|
|
266
|
+
trailing: "Content after the search field, such as a shortcut or Back button.",
|
|
267
|
+
},
|
|
268
|
+
columns: { prop: "Prop", type: "Type", default: "Default", desc: "Description" },
|
|
269
|
+
rows: {
|
|
270
|
+
open: "Open state.",
|
|
271
|
+
onOpenChange: "Open state change callback.",
|
|
272
|
+
size: "Result row size. This does not change the palette width or trigger height.",
|
|
273
|
+
label: "Screen reader label.",
|
|
274
|
+
labelDefault: "Search commands",
|
|
275
|
+
presentation: "Dialog overlay, inline search, or a panel expanding from its trigger.",
|
|
276
|
+
trigger: "A CommandPalette.Trigger rendered outside the search panel. The expand presentation uses its position as the animation origin.",
|
|
277
|
+
onEscapeKeyDown: "Escape handler for dialog and expand. Prevent default to navigate back inside a nested view before closing the dialog.",
|
|
278
|
+
dimmed: "Background dimming. Set false for topbar expansion. Outside-click dismissal and focus management stay enabled.",
|
|
279
|
+
value: "Selected item value. Input value controls the search query separately.",
|
|
280
|
+
className: "Class for the outer palette. Set width and max-height in CSS.",
|
|
281
|
+
},
|
|
282
|
+
itemRows: {
|
|
283
|
+
leadingIcon: "Icon on the left of the label.",
|
|
284
|
+
shortcut: "Shortcut label. Register its keyboard handler separately.",
|
|
285
|
+
onSelect: "Runs when an item is selected. Call onOpenChange(false) to close the palette.",
|
|
286
|
+
disabled: "Disabled. Excluded from keyboard navigation.",
|
|
287
|
+
},
|
|
288
|
+
},
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
const ko: Strings = {
|
|
292
|
+
useCases: { heading: "사용사례", workspace: "워크스페이스 명령", launcher: "애플리케이션 런처", nested: "하위 화면 탐색", nestedDesc: "프로젝트를 열어 내부 파일을 검색해 보세요. 뒤로 버튼이나 Escape로 돌아가면 이전 검색어와 선택이 복원돼요.", preview: "파일 검색과 프리뷰", previewDesc: "선택한 파일의 프리뷰와 정보를 나란히 보여줘요. Enter나 열기로 상세를 확인할 수 있어요.", expanding: "탑바에서 확장되는 검색", expandingDesc: "검색창을 누르면 같은 자리에서 펼쳐져요. 탑바 확장형은 배경 딤을 끄는 것을 권장해요." },
|
|
293
|
+
title: "Command Palette",
|
|
294
|
+
lead: "페이지를 찾거나 작업을 실행하는 검색창이에요.",
|
|
295
|
+
|
|
296
|
+
usage: {
|
|
297
|
+
heading: "사용법",
|
|
298
|
+
desc: (
|
|
299
|
+
<>
|
|
300
|
+
검색 버튼이나 <Code>useCommandPaletteHotkey</Code>로 열어요. 항목에 작업을 연결하고, 실행 후 <Code>onOpenChange(false)</Code>로 닫아 주세요.
|
|
301
|
+
</>
|
|
302
|
+
),
|
|
303
|
+
searchButton: "검색",
|
|
304
|
+
placeholder: "검색 또는 명령어 입력",
|
|
305
|
+
empty: "결과가 없어요",
|
|
306
|
+
dashboard: "대시보드",
|
|
307
|
+
projects: "프로젝트",
|
|
308
|
+
settings: "설정",
|
|
309
|
+
},
|
|
310
|
+
|
|
311
|
+
playground: {
|
|
312
|
+
desc: (
|
|
313
|
+
<>
|
|
314
|
+
결과 항목 크기와 아이콘, 단축키 표시를 바꿔 보세요. 플레이그라운드 안에서 <Shortcut>⌘K</Shortcut>로 열고 닫을 수 있어요.
|
|
315
|
+
</>
|
|
316
|
+
),
|
|
317
|
+
openButton: "명령 검색 열기",
|
|
318
|
+
lastRun: "마지막 실행:",
|
|
319
|
+
placeholder: "검색 또는 명령어 입력",
|
|
320
|
+
pages: "페이지",
|
|
321
|
+
dashboard: "대시보드",
|
|
322
|
+
projects: "프로젝트",
|
|
323
|
+
settings: "설정",
|
|
324
|
+
empty: "결과가 없어요",
|
|
325
|
+
},
|
|
326
|
+
|
|
327
|
+
withGroups: {
|
|
328
|
+
heading: "그룹 구분",
|
|
329
|
+
desc: (
|
|
330
|
+
<>
|
|
331
|
+
페이지와 작업처럼 성격이 다른 항목은 <Code>CommandPalette.Group</Code>으로 나눠요.
|
|
332
|
+
</>
|
|
333
|
+
),
|
|
334
|
+
placeholder: "검색 또는 명령어 입력",
|
|
335
|
+
empty: "결과가 없어요",
|
|
336
|
+
pages: "페이지",
|
|
337
|
+
dashboard: "대시보드",
|
|
338
|
+
projects: "프로젝트",
|
|
339
|
+
actions: "작업",
|
|
340
|
+
newDoc: "새 문서",
|
|
341
|
+
uploadFile: "파일 업로드",
|
|
342
|
+
},
|
|
343
|
+
|
|
344
|
+
withShortcuts: {
|
|
345
|
+
heading: "단축키 조합",
|
|
346
|
+
desc: (
|
|
347
|
+
<>
|
|
348
|
+
<Code>shortcut</Code>으로 단축키를 표시해요. 실제 키 동작은 별도로 연결해 주세요.
|
|
349
|
+
</>
|
|
350
|
+
),
|
|
351
|
+
placeholder: "검색 또는 명령어 입력",
|
|
352
|
+
empty: "결과가 없어요",
|
|
353
|
+
frequent: "자주 쓰는 작업",
|
|
354
|
+
newDoc: "새 문서",
|
|
355
|
+
uploadFile: "파일 업로드",
|
|
356
|
+
copyLink: "공유 링크 복사",
|
|
357
|
+
},
|
|
358
|
+
|
|
359
|
+
emptyState: {
|
|
360
|
+
heading: "검색 결과가 없을 때",
|
|
361
|
+
desc: (
|
|
362
|
+
<>
|
|
363
|
+
검색 결과가 없으면 <Code>CommandPalette.Empty</Code>가 빈 상태를 보여줘요.
|
|
364
|
+
</>
|
|
365
|
+
),
|
|
366
|
+
placeholder: "아무거나 입력해보세요",
|
|
367
|
+
empty: "결과가 없어요",
|
|
368
|
+
dashboard: "대시보드",
|
|
369
|
+
},
|
|
370
|
+
|
|
371
|
+
api: {
|
|
372
|
+
heading: "속성",
|
|
373
|
+
itemHeading: "CommandPalette.Item",
|
|
374
|
+
triggerRows: {
|
|
375
|
+
size: "닫혀 있는 검색 트리거의 높이예요. 결과 행 크기와 따로 조절해요.",
|
|
376
|
+
variant: "Button의 모양을 사용해요. outline은 테두리, neutral은 연한 채움이에요.",
|
|
377
|
+
shortcut: "표시할 단축키예요. null이면 숨겨요. 키 동작은 별도로 연결해 주세요.",
|
|
378
|
+
},
|
|
379
|
+
inputRows: {
|
|
380
|
+
value: "검색어예요. Root의 선택 항목 값과 구분해요.",
|
|
381
|
+
onValueChange: "검색어가 바뀌면 호출해요.",
|
|
382
|
+
leadingIcon: "입력창 왼쪽 아이콘이에요. null이면 숨겨요.",
|
|
383
|
+
trailing: "입력창 오른쪽에 단축키나 뒤로 버튼을 넣을 수 있어요.",
|
|
384
|
+
},
|
|
385
|
+
columns: { prop: "속성", type: "타입", default: "기본값", desc: "설명" },
|
|
386
|
+
rows: {
|
|
387
|
+
open: "검색창의 열림 상태예요.",
|
|
388
|
+
onOpenChange: "열림 상태가 바뀌면 호출해요.",
|
|
389
|
+
size: "결과 행의 크기예요. 팔레트 너비나 검색 트리거 높이는 바꾸지 않아요.",
|
|
390
|
+
label: "스크린리더에 전달할 이름이에요.",
|
|
391
|
+
labelDefault: "명령 검색",
|
|
392
|
+
presentation: "다이얼로그, 인라인 또는 트리거에서 확장되는 검색으로 표시해요.",
|
|
393
|
+
trigger: "패널 밖에 표시할 CommandPalette.Trigger예요. expand는 이 위치에서 펼쳐져요.",
|
|
394
|
+
onEscapeKeyDown: "dialog와 expand의 Escape 동작이에요. preventDefault 후 이전 화면으로 돌아갈 수 있어요.",
|
|
395
|
+
dimmed: "배경을 어둡게 표시해요. 탑바 확장형은 false를 권장해요.",
|
|
396
|
+
value: "선택한 항목 값이에요. 검색어는 Input의 value로 별도 제어해요.",
|
|
397
|
+
className: "외곽 스타일을 지정할 클래스예요. 너비와 최대 높이는 CSS로 조절해요.",
|
|
398
|
+
},
|
|
399
|
+
itemRows: {
|
|
400
|
+
leadingIcon: "항목 왼쪽에 표시할 아이콘이에요.",
|
|
401
|
+
shortcut: "오른쪽에 표시할 단축키예요. 키 동작은 별도로 연결해 주세요.",
|
|
402
|
+
onSelect: "항목을 선택하면 호출해요. 닫으려면 onOpenChange(false)를 연결해 주세요.",
|
|
403
|
+
disabled: "선택과 실행을 막고 키보드 탐색에서 제외해요.",
|
|
404
|
+
},
|
|
405
|
+
},
|
|
406
|
+
};
|
|
407
|
+
|
|
408
|
+
export const strings = { en, ko };
|
|
409
|
+
export type { Strings };
|
|
410
|
+
````
|
|
411
|
+
|
|
412
|
+
### Source: web/app/[lang]/components/overlay/command-palette/page.tsx
|
|
413
|
+
|
|
414
|
+
````tsx
|
|
415
|
+
"use client";
|
|
416
|
+
|
|
417
|
+
import { PreviewButton } from "@/app/_components/PreviewButton";
|
|
418
|
+
|
|
419
|
+
import { useState } from "react";
|
|
420
|
+
import { usePathname } from "next/navigation";
|
|
421
|
+
import { CommandPalette } from "@/components/CommandPalette";
|
|
422
|
+
import { Icon } from "@/components/Icon";
|
|
423
|
+
import { Code } from "@/components/Code";
|
|
424
|
+
import { Shortcut } from "@/components/Shortcut";
|
|
425
|
+
import { ExampleBlock } from "../../../../_components/ExampleBlock";
|
|
426
|
+
import { Playground } from "../../../../_components/Playground";
|
|
427
|
+
import { DocsTable } from "../../../../_components/DocsTable";
|
|
428
|
+
import { localeFromPathname } from "../../../../_dict";
|
|
429
|
+
import { strings } from "./_strings";
|
|
430
|
+
import { ReferencePalette } from "@/examples/command-palette/ReferencePalettes";
|
|
431
|
+
import { DetailPalette } from "@/examples/command-palette/DetailPalettes";
|
|
432
|
+
import { ExpandingSearch } from "@/examples/command-palette/ExpandingSearch";
|
|
433
|
+
|
|
434
|
+
const PG_SIZES = ["sm", "md"] as const;
|
|
435
|
+
type PgSize = (typeof PG_SIZES)[number];
|
|
436
|
+
|
|
437
|
+
export default function CommandPalettePage() {
|
|
438
|
+
const lang = localeFromPathname(usePathname() ?? "/");
|
|
439
|
+
const t = strings[lang];
|
|
440
|
+
const apiColumns = [
|
|
441
|
+
{ key: "prop", label: t.api.columns.prop, width: 160 },
|
|
442
|
+
{ key: "type", label: t.api.columns.type, flex: true, minWidth: 220 },
|
|
443
|
+
{ key: "default", label: t.api.columns.default, width: 120 },
|
|
444
|
+
{ key: "desc", label: t.api.columns.desc, flex: true, minWidth: 240 },
|
|
445
|
+
];
|
|
446
|
+
|
|
447
|
+
const [usageOpen, setUsageOpen] = useState(false);
|
|
448
|
+
|
|
449
|
+
const [pgOpen, setPgOpen] = useState(false);
|
|
450
|
+
const [pgSize, setPgSize] = useState<PgSize>("md");
|
|
451
|
+
const [pgShortcuts, setPgShortcuts] = useState(true);
|
|
452
|
+
const [pgIcons, setPgIcons] = useState(true);
|
|
453
|
+
const [pgLast, setPgLast] = useState<string>("");
|
|
454
|
+
|
|
455
|
+
const [groupsOpen, setGroupsOpen] = useState(false);
|
|
456
|
+
const [shortcutsOpen, setShortcutsOpen] = useState(false);
|
|
457
|
+
const [emptyOpen, setEmptyOpen] = useState(false);
|
|
458
|
+
|
|
459
|
+
function runPg(label: string) {
|
|
460
|
+
setPgLast(label);
|
|
461
|
+
setPgOpen(false);
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
return (
|
|
465
|
+
<>
|
|
466
|
+
<h1 className="page-title">{t.title}</h1>
|
|
467
|
+
<p className="page-lead">{t.lead}</p>
|
|
468
|
+
|
|
469
|
+
<section id="usage" className="section-first">
|
|
470
|
+
<h2>{t.usage.heading}</h2>
|
|
471
|
+
<p className="desc">{t.usage.desc}</p>
|
|
472
|
+
<ExampleBlock
|
|
473
|
+
code={`import { useState } from "react";
|
|
474
|
+
import { Button } from "@/components/Button";
|
|
475
|
+
import { CommandPalette } from "@/components/CommandPalette";
|
|
476
|
+
|
|
477
|
+
const [open, setOpen] = useState(false);
|
|
478
|
+
|
|
479
|
+
<Button variant="outline" onClick={() => setOpen(true)}>${strings.en.usage.searchButton}</Button>
|
|
480
|
+
<CommandPalette open={open} onOpenChange={setOpen}>
|
|
481
|
+
<CommandPalette.Input placeholder="${strings.en.usage.placeholder}" />
|
|
482
|
+
<CommandPalette.List>
|
|
483
|
+
<CommandPalette.Empty>${strings.en.usage.empty}</CommandPalette.Empty>
|
|
484
|
+
<CommandPalette.Item leadingIcon="house" onSelect={() => setOpen(false)}>${strings.en.usage.dashboard}</CommandPalette.Item>
|
|
485
|
+
</CommandPalette.List>
|
|
486
|
+
</CommandPalette>`}
|
|
487
|
+
>
|
|
488
|
+
<PreviewButton
|
|
489
|
+
leftIcon={<Icon name="search" />}
|
|
490
|
+
badge={<Shortcut>⌘K</Shortcut>}
|
|
491
|
+
onClick={() => setUsageOpen(true)}
|
|
492
|
+
>
|
|
493
|
+
{strings.en.usage.searchButton}
|
|
494
|
+
</PreviewButton>
|
|
495
|
+
<CommandPalette open={usageOpen} onOpenChange={setUsageOpen}>
|
|
496
|
+
<CommandPalette.Input placeholder={strings.en.usage.placeholder} />
|
|
497
|
+
<CommandPalette.List>
|
|
498
|
+
<CommandPalette.Empty>{strings.en.usage.empty}</CommandPalette.Empty>
|
|
499
|
+
<CommandPalette.Item
|
|
500
|
+
leadingIcon="house"
|
|
501
|
+
onSelect={() => setUsageOpen(false)}
|
|
502
|
+
>
|
|
503
|
+
{strings.en.usage.dashboard}
|
|
504
|
+
</CommandPalette.Item>
|
|
505
|
+
<CommandPalette.Item
|
|
506
|
+
leadingIcon="table"
|
|
507
|
+
onSelect={() => setUsageOpen(false)}
|
|
508
|
+
>
|
|
509
|
+
{strings.en.usage.projects}
|
|
510
|
+
</CommandPalette.Item>
|
|
511
|
+
<CommandPalette.Item
|
|
512
|
+
leadingIcon="gear"
|
|
513
|
+
onSelect={() => setUsageOpen(false)}
|
|
514
|
+
>
|
|
515
|
+
{strings.en.usage.settings}
|
|
516
|
+
</CommandPalette.Item>
|
|
517
|
+
</CommandPalette.List>
|
|
518
|
+
</CommandPalette>
|
|
519
|
+
</ExampleBlock>
|
|
520
|
+
</section>
|
|
521
|
+
|
|
522
|
+
<Playground showHeading={false} data-command-playground onKeyDownCapture={(event) => {
|
|
523
|
+
if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "k" && !event.nativeEvent.isComposing) {
|
|
524
|
+
event.preventDefault();
|
|
525
|
+
event.stopPropagation();
|
|
526
|
+
setPgOpen((current) => !current);
|
|
527
|
+
}
|
|
528
|
+
}}
|
|
529
|
+
desc={t.playground.desc}
|
|
530
|
+
axes={[
|
|
531
|
+
{
|
|
532
|
+
label: "size",
|
|
533
|
+
value: pgSize,
|
|
534
|
+
onChange: (v) => setPgSize(v as PgSize),
|
|
535
|
+
options: PG_SIZES,
|
|
536
|
+
},
|
|
537
|
+
]}
|
|
538
|
+
toggles={[
|
|
539
|
+
{ label: "icons", value: pgIcons, onChange: setPgIcons },
|
|
540
|
+
{ label: "shortcuts", value: pgShortcuts, onChange: setPgShortcuts },
|
|
541
|
+
]}
|
|
542
|
+
>
|
|
543
|
+
<div
|
|
544
|
+
style={{
|
|
545
|
+
display: "flex",
|
|
546
|
+
flexDirection: "column",
|
|
547
|
+
alignItems: "stretch",
|
|
548
|
+
gap: "var(--space-2)",
|
|
549
|
+
width: "var(--input-w-lg)",
|
|
550
|
+
}}
|
|
551
|
+
>
|
|
552
|
+
<PreviewButton
|
|
553
|
+
leftIcon={<Icon name="search" />}
|
|
554
|
+
badge={<Shortcut>⌘K</Shortcut>}
|
|
555
|
+
onClick={() => setPgOpen(true)}
|
|
556
|
+
>
|
|
557
|
+
{strings.en.playground.openButton}
|
|
558
|
+
</PreviewButton>
|
|
559
|
+
{pgLast && (
|
|
560
|
+
<span style={{ fontSize: "var(--text-xs)", color: "var(--fg-muted)", textAlign: "center" }}>
|
|
561
|
+
{strings.en.playground.lastRun} <Code>{pgLast}</Code>
|
|
562
|
+
</span>
|
|
563
|
+
)}
|
|
564
|
+
</div>
|
|
565
|
+
<CommandPalette open={pgOpen} onOpenChange={setPgOpen} size={pgSize}>
|
|
566
|
+
<CommandPalette.Input placeholder={strings.en.playground.placeholder} />
|
|
567
|
+
<CommandPalette.List>
|
|
568
|
+
<CommandPalette.Empty>{strings.en.playground.empty}</CommandPalette.Empty>
|
|
569
|
+
<CommandPalette.Group heading={strings.en.playground.pages}>
|
|
570
|
+
<CommandPalette.Item
|
|
571
|
+
leadingIcon={pgIcons ? "house" : undefined}
|
|
572
|
+
shortcut={pgShortcuts ? "⌘1" : undefined}
|
|
573
|
+
onSelect={() => runPg(strings.en.playground.dashboard)}
|
|
574
|
+
>
|
|
575
|
+
{strings.en.playground.dashboard}
|
|
576
|
+
</CommandPalette.Item>
|
|
577
|
+
<CommandPalette.Item
|
|
578
|
+
leadingIcon={pgIcons ? "table" : undefined}
|
|
579
|
+
shortcut={pgShortcuts ? "⌘2" : undefined}
|
|
580
|
+
onSelect={() => runPg(strings.en.playground.projects)}
|
|
581
|
+
>
|
|
582
|
+
{strings.en.playground.projects}
|
|
583
|
+
</CommandPalette.Item>
|
|
584
|
+
<CommandPalette.Item
|
|
585
|
+
leadingIcon={pgIcons ? "gear" : undefined}
|
|
586
|
+
shortcut={pgShortcuts ? "⌘," : undefined}
|
|
587
|
+
onSelect={() => runPg(strings.en.playground.settings)}
|
|
588
|
+
>
|
|
589
|
+
{strings.en.playground.settings}
|
|
590
|
+
</CommandPalette.Item>
|
|
591
|
+
</CommandPalette.Group>
|
|
592
|
+
</CommandPalette.List>
|
|
593
|
+
</CommandPalette>
|
|
594
|
+
</Playground>
|
|
595
|
+
|
|
596
|
+
<section id="with-groups">
|
|
597
|
+
<h2>{t.withGroups.heading}</h2>
|
|
598
|
+
<p className="desc">{t.withGroups.desc}</p>
|
|
599
|
+
<ExampleBlock
|
|
600
|
+
code={`<CommandPalette.List>
|
|
601
|
+
<CommandPalette.Group heading="${strings.en.withGroups.pages}">
|
|
602
|
+
<CommandPalette.Item leadingIcon="house">${strings.en.withGroups.dashboard}</CommandPalette.Item>
|
|
603
|
+
<CommandPalette.Item leadingIcon="table">${strings.en.withGroups.projects}</CommandPalette.Item>
|
|
604
|
+
</CommandPalette.Group>
|
|
605
|
+
<CommandPalette.Separator />
|
|
606
|
+
<CommandPalette.Group heading="${strings.en.withGroups.actions}">
|
|
607
|
+
<CommandPalette.Item leadingIcon="plus">${strings.en.withGroups.newDoc}</CommandPalette.Item>
|
|
608
|
+
</CommandPalette.Group>
|
|
609
|
+
</CommandPalette.List>`}
|
|
610
|
+
>
|
|
611
|
+
<PreviewButton
|
|
612
|
+
leftIcon={<Icon name="search" />}
|
|
613
|
+
onClick={() => setGroupsOpen(true)}
|
|
614
|
+
>
|
|
615
|
+
{strings.en.playground.openButton}
|
|
616
|
+
</PreviewButton>
|
|
617
|
+
<CommandPalette open={groupsOpen} onOpenChange={setGroupsOpen}>
|
|
618
|
+
<CommandPalette.Input placeholder={strings.en.withGroups.placeholder} />
|
|
619
|
+
<CommandPalette.List>
|
|
620
|
+
<CommandPalette.Empty>{strings.en.withGroups.empty}</CommandPalette.Empty>
|
|
621
|
+
<CommandPalette.Group heading={strings.en.withGroups.pages}>
|
|
622
|
+
<CommandPalette.Item
|
|
623
|
+
leadingIcon="house"
|
|
624
|
+
onSelect={() => setGroupsOpen(false)}
|
|
625
|
+
>
|
|
626
|
+
{strings.en.withGroups.dashboard}
|
|
627
|
+
</CommandPalette.Item>
|
|
628
|
+
<CommandPalette.Item
|
|
629
|
+
leadingIcon="table"
|
|
630
|
+
onSelect={() => setGroupsOpen(false)}
|
|
631
|
+
>
|
|
632
|
+
{strings.en.withGroups.projects}
|
|
633
|
+
</CommandPalette.Item>
|
|
634
|
+
</CommandPalette.Group>
|
|
635
|
+
<CommandPalette.Separator />
|
|
636
|
+
<CommandPalette.Group heading={strings.en.withGroups.actions}>
|
|
637
|
+
<CommandPalette.Item
|
|
638
|
+
leadingIcon="plus"
|
|
639
|
+
onSelect={() => setGroupsOpen(false)}
|
|
640
|
+
>
|
|
641
|
+
{strings.en.withGroups.newDoc}
|
|
642
|
+
</CommandPalette.Item>
|
|
643
|
+
<CommandPalette.Item
|
|
644
|
+
leadingIcon="upload-simple"
|
|
645
|
+
onSelect={() => setGroupsOpen(false)}
|
|
646
|
+
>
|
|
647
|
+
{strings.en.withGroups.uploadFile}
|
|
648
|
+
</CommandPalette.Item>
|
|
649
|
+
</CommandPalette.Group>
|
|
650
|
+
</CommandPalette.List>
|
|
651
|
+
</CommandPalette>
|
|
652
|
+
</ExampleBlock>
|
|
653
|
+
</section>
|
|
654
|
+
|
|
655
|
+
<section id="with-shortcuts">
|
|
656
|
+
<h2>{t.withShortcuts.heading}</h2>
|
|
657
|
+
<p className="desc">{t.withShortcuts.desc}</p>
|
|
658
|
+
<ExampleBlock
|
|
659
|
+
code={`<CommandPalette.Item
|
|
660
|
+
leadingIcon="plus"
|
|
661
|
+
shortcut="⌘N"
|
|
662
|
+
onSelect={createDoc}
|
|
663
|
+
>
|
|
664
|
+
${strings.en.withShortcuts.newDoc}
|
|
665
|
+
</CommandPalette.Item>`}
|
|
666
|
+
>
|
|
667
|
+
<PreviewButton
|
|
668
|
+
leftIcon={<Icon name="search" />}
|
|
669
|
+
onClick={() => setShortcutsOpen(true)}
|
|
670
|
+
>
|
|
671
|
+
{strings.en.playground.openButton}
|
|
672
|
+
</PreviewButton>
|
|
673
|
+
<CommandPalette open={shortcutsOpen} onOpenChange={setShortcutsOpen}>
|
|
674
|
+
<CommandPalette.Input placeholder={strings.en.withShortcuts.placeholder} />
|
|
675
|
+
<CommandPalette.List>
|
|
676
|
+
<CommandPalette.Empty>{strings.en.withShortcuts.empty}</CommandPalette.Empty>
|
|
677
|
+
<CommandPalette.Group heading={strings.en.withShortcuts.frequent}>
|
|
678
|
+
<CommandPalette.Item
|
|
679
|
+
leadingIcon="plus"
|
|
680
|
+
shortcut="⌘N"
|
|
681
|
+
onSelect={() => setShortcutsOpen(false)}
|
|
682
|
+
>
|
|
683
|
+
{strings.en.withShortcuts.newDoc}
|
|
684
|
+
</CommandPalette.Item>
|
|
685
|
+
<CommandPalette.Item
|
|
686
|
+
leadingIcon="upload-simple"
|
|
687
|
+
shortcut="⌘U"
|
|
688
|
+
onSelect={() => setShortcutsOpen(false)}
|
|
689
|
+
>
|
|
690
|
+
{strings.en.withShortcuts.uploadFile}
|
|
691
|
+
</CommandPalette.Item>
|
|
692
|
+
<CommandPalette.Item
|
|
693
|
+
leadingIcon="share-network"
|
|
694
|
+
shortcut="⇧⌘S"
|
|
695
|
+
onSelect={() => setShortcutsOpen(false)}
|
|
696
|
+
>
|
|
697
|
+
{strings.en.withShortcuts.copyLink}
|
|
698
|
+
</CommandPalette.Item>
|
|
699
|
+
</CommandPalette.Group>
|
|
700
|
+
</CommandPalette.List>
|
|
701
|
+
</CommandPalette>
|
|
702
|
+
</ExampleBlock>
|
|
703
|
+
</section>
|
|
704
|
+
|
|
705
|
+
<section id="empty-state">
|
|
706
|
+
<h2>{t.emptyState.heading}</h2>
|
|
707
|
+
<p className="desc">{t.emptyState.desc}</p>
|
|
708
|
+
<ExampleBlock
|
|
709
|
+
code={`<CommandPalette.List>
|
|
710
|
+
<CommandPalette.Empty>${strings.en.emptyState.empty}</CommandPalette.Empty>
|
|
711
|
+
<CommandPalette.Item>...</CommandPalette.Item>
|
|
712
|
+
</CommandPalette.List>`}
|
|
713
|
+
>
|
|
714
|
+
<PreviewButton
|
|
715
|
+
leftIcon={<Icon name="search" />}
|
|
716
|
+
onClick={() => setEmptyOpen(true)}
|
|
717
|
+
>
|
|
718
|
+
{strings.en.playground.openButton}
|
|
719
|
+
</PreviewButton>
|
|
720
|
+
<CommandPalette open={emptyOpen} onOpenChange={setEmptyOpen}>
|
|
721
|
+
<CommandPalette.Input placeholder={strings.en.emptyState.placeholder} />
|
|
722
|
+
<CommandPalette.List>
|
|
723
|
+
<CommandPalette.Empty>{strings.en.emptyState.empty}</CommandPalette.Empty>
|
|
724
|
+
<CommandPalette.Item onSelect={() => setEmptyOpen(false)}>
|
|
725
|
+
{strings.en.emptyState.dashboard}
|
|
726
|
+
</CommandPalette.Item>
|
|
727
|
+
</CommandPalette.List>
|
|
728
|
+
</CommandPalette>
|
|
729
|
+
</ExampleBlock>
|
|
730
|
+
</section>
|
|
731
|
+
|
|
732
|
+
<section id="use-cases">
|
|
733
|
+
<h2>{t.useCases.heading}</h2>
|
|
734
|
+
<h3>{t.useCases.expanding}</h3>
|
|
735
|
+
<p className="desc">{t.useCases.expandingDesc}</p>
|
|
736
|
+
<ExampleBlock previewWidth="full" code={`<Topbar.Center>
|
|
737
|
+
<CommandPalette
|
|
738
|
+
open={open}
|
|
739
|
+
onOpenChange={setOpen}
|
|
740
|
+
presentation="expand"
|
|
741
|
+
dimmed={false}
|
|
742
|
+
trigger={<CommandPalette.Trigger variant="neutral">Search documents</CommandPalette.Trigger>}
|
|
743
|
+
>
|
|
744
|
+
<CommandPalette.Input placeholder="Search documents" />
|
|
745
|
+
<CommandPalette.List>
|
|
746
|
+
<CommandPalette.Empty />
|
|
747
|
+
<CommandPalette.Item onSelect={() => setOpen(false)}>
|
|
748
|
+
Redwood Design System
|
|
749
|
+
</CommandPalette.Item>
|
|
750
|
+
</CommandPalette.List>
|
|
751
|
+
</CommandPalette>
|
|
752
|
+
</Topbar.Center>`}>
|
|
753
|
+
<ExpandingSearch lang={lang} />
|
|
754
|
+
</ExampleBlock>
|
|
755
|
+
<h3>{t.useCases.nested}</h3>
|
|
756
|
+
<p className="desc">{t.useCases.nestedDesc}</p>
|
|
757
|
+
<ExampleBlock previewWidth="full">
|
|
758
|
+
<DetailPalette kind="nested" lang={lang} />
|
|
759
|
+
</ExampleBlock>
|
|
760
|
+
<h3>{t.useCases.preview}</h3>
|
|
761
|
+
<p className="desc">{t.useCases.previewDesc}</p>
|
|
762
|
+
<ExampleBlock previewWidth="full">
|
|
763
|
+
<DetailPalette kind="preview" lang={lang} />
|
|
764
|
+
</ExampleBlock>
|
|
765
|
+
<h3>{t.useCases.workspace}</h3>
|
|
766
|
+
<ExampleBlock previewWidth="full">
|
|
767
|
+
<ReferencePalette kind="workspace" lang={lang} />
|
|
768
|
+
</ExampleBlock>
|
|
769
|
+
<h3>{t.useCases.launcher}</h3>
|
|
770
|
+
<ExampleBlock previewWidth="full">
|
|
771
|
+
<ReferencePalette kind="launcher" lang={lang} />
|
|
772
|
+
</ExampleBlock>
|
|
773
|
+
</section>
|
|
774
|
+
|
|
775
|
+
<section id="api">
|
|
776
|
+
<h2>{t.api.heading}</h2>
|
|
777
|
+
<DocsTable
|
|
778
|
+
columns={[
|
|
779
|
+
{ key: "prop", label: t.api.columns.prop, width: 160 },
|
|
780
|
+
{ key: "type", label: t.api.columns.type, flex: true, minWidth: 220 },
|
|
781
|
+
{ key: "default", label: t.api.columns.default, width: 120 },
|
|
782
|
+
{ key: "desc", label: t.api.columns.desc, flex: true, minWidth: 240 },
|
|
783
|
+
]}
|
|
784
|
+
rows={[
|
|
785
|
+
{ prop: <Code>open</Code>, type: <Code>boolean</Code>, default: "", desc: t.api.rows.open },
|
|
786
|
+
{ prop: <Code>onOpenChange</Code>, type: <Code>(open) => void</Code>, default: "", desc: t.api.rows.onOpenChange },
|
|
787
|
+
{ prop: <Code>size</Code>, type: <Code>'sm' | 'md'</Code>, default: <Code>'md'</Code>, desc: t.api.rows.size },
|
|
788
|
+
{ prop: <Code>label</Code>, type: <Code>string</Code>, default: <Code>'{t.api.rows.labelDefault}'</Code>, desc: t.api.rows.label },
|
|
789
|
+
{ prop: <Code>presentation</Code>, type: <Code>'dialog' | 'inline' | 'expand'</Code>, default: <Code>'dialog'</Code>, desc: t.api.rows.presentation },
|
|
790
|
+
{ prop: <Code>trigger</Code>, type: <Code>ReactNode</Code>, default: "", desc: t.api.rows.trigger },
|
|
791
|
+
{ prop: <Code>dimmed</Code>, type: <Code>boolean</Code>, default: <Code>true</Code>, desc: t.api.rows.dimmed },
|
|
792
|
+
{ prop: <Code>onEscapeKeyDown</Code>, type: <Code>(event: KeyboardEvent) => void</Code>, default: "", desc: t.api.rows.onEscapeKeyDown },
|
|
793
|
+
{ prop: <Code>value / onValueChange</Code>, type: <Code>string / (value: string) => void</Code>, default: "", desc: t.api.rows.value },
|
|
794
|
+
{ prop: <Code>className</Code>, type: <Code>string</Code>, default: "", desc: t.api.rows.className },
|
|
795
|
+
]}
|
|
796
|
+
/>
|
|
797
|
+
|
|
798
|
+
<h3><Code>CommandPalette.Trigger</Code></h3>
|
|
799
|
+
<DocsTable columns={apiColumns} rows={[
|
|
800
|
+
{ prop: <Code>size</Code>, type: <Code>ButtonSize</Code>, default: <Code>'md'</Code>, desc: t.api.triggerRows.size },
|
|
801
|
+
{ prop: <Code>variant</Code>, type: <Code>ButtonVariant</Code>, default: <Code>'outline'</Code>, desc: t.api.triggerRows.variant },
|
|
802
|
+
{ prop: <Code>shortcut</Code>, type: <Code>string | null</Code>, default: <Code>'⌘K'</Code>, desc: t.api.triggerRows.shortcut },
|
|
803
|
+
]} />
|
|
804
|
+
|
|
805
|
+
<h3><Code>CommandPalette.Input</Code></h3>
|
|
806
|
+
<DocsTable columns={apiColumns} rows={[
|
|
807
|
+
{ prop: <Code>value</Code>, type: <Code>string</Code>, default: "", desc: t.api.inputRows.value },
|
|
808
|
+
{ prop: <Code>onValueChange</Code>, type: <Code>(value: string) => void</Code>, default: "", desc: t.api.inputRows.onValueChange },
|
|
809
|
+
{ prop: <Code>leadingIcon</Code>, type: <Code>IconName | null</Code>, default: <Code>'search'</Code>, desc: t.api.inputRows.leadingIcon },
|
|
810
|
+
{ prop: <Code>trailing</Code>, type: <Code>ReactNode</Code>, default: "", desc: t.api.inputRows.trailing },
|
|
811
|
+
]} />
|
|
812
|
+
|
|
813
|
+
<h3>
|
|
814
|
+
<Code>{t.api.itemHeading}</Code>
|
|
815
|
+
</h3>
|
|
816
|
+
<DocsTable
|
|
817
|
+
columns={[
|
|
818
|
+
{ key: "prop", label: t.api.columns.prop, width: 160 },
|
|
819
|
+
{ key: "type", label: t.api.columns.type, flex: true, minWidth: 220 },
|
|
820
|
+
{ key: "default", label: t.api.columns.default, width: 120 },
|
|
821
|
+
{ key: "desc", label: t.api.columns.desc, flex: true, minWidth: 240 },
|
|
822
|
+
]}
|
|
823
|
+
rows={[
|
|
824
|
+
{ prop: <Code>leadingIcon</Code>, type: <Code>IconName</Code>, default: "", desc: t.api.itemRows.leadingIcon },
|
|
825
|
+
{ prop: <Code>shortcut</Code>, type: <Code>string</Code>, default: "", desc: t.api.itemRows.shortcut },
|
|
826
|
+
{ prop: <Code>onSelect</Code>, type: <Code>(value: string) => void</Code>, default: "", desc: t.api.itemRows.onSelect },
|
|
827
|
+
{ prop: <Code>disabled</Code>, type: <Code>boolean</Code>, default: <Code>false</Code>, desc: t.api.itemRows.disabled },
|
|
828
|
+
]}
|
|
829
|
+
/>
|
|
830
|
+
</section>
|
|
831
|
+
</>
|
|
832
|
+
);
|
|
833
|
+
}
|
|
834
|
+
````
|
|
835
|
+
|
|
836
|
+
### Source: web/examples/command-palette/DetailPalettes.module.css
|
|
837
|
+
|
|
838
|
+
````css
|
|
839
|
+
.example {
|
|
840
|
+
width: 100%;
|
|
841
|
+
min-width: 0;
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
.toolbar {
|
|
845
|
+
display: flex;
|
|
846
|
+
justify-content: center;
|
|
847
|
+
margin-bottom: var(--space-2);
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
.palette {
|
|
851
|
+
--detail-height: calc(var(--size-2) * 66);
|
|
852
|
+
width: calc(100vw - var(--space-8));
|
|
853
|
+
max-height: min(80dvh, var(--detail-height));
|
|
854
|
+
top: max(var(--space-4), calc((100dvh - var(--detail-height)) / 2));
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
.palette[data-presentation="inline"] {
|
|
858
|
+
max-height: var(--detail-height);
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
.wide {
|
|
862
|
+
max-width: calc(var(--size-2) * 96);
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
.wide[data-presentation="inline"] {
|
|
866
|
+
height: var(--detail-height);
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
.header {
|
|
870
|
+
display: flex;
|
|
871
|
+
align-items: center;
|
|
872
|
+
flex-shrink: 0;
|
|
873
|
+
min-height: var(--size-12);
|
|
874
|
+
border-bottom: var(--hairline) solid var(--material-border, var(--border));
|
|
875
|
+
padding-inline: var(--space-2);
|
|
876
|
+
gap: var(--space-1);
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
.header > div:not(.scope) {
|
|
880
|
+
flex: 1;
|
|
881
|
+
min-width: 0;
|
|
882
|
+
border-bottom: 0;
|
|
883
|
+
padding-inline: var(--space-2);
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
.header[data-has-back] > div:not(.scope) {
|
|
887
|
+
padding-inline-start: 0;
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
.headerTitle {
|
|
891
|
+
min-width: 0;
|
|
892
|
+
font-size: var(--text-base);
|
|
893
|
+
line-height: var(--lh-base);
|
|
894
|
+
letter-spacing: var(--tracking-normal);
|
|
895
|
+
font-weight: var(--font-weight-regular);
|
|
896
|
+
overflow: hidden;
|
|
897
|
+
text-overflow: ellipsis;
|
|
898
|
+
white-space: nowrap;
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
.scope {
|
|
902
|
+
width: calc(var(--size-2) * 14);
|
|
903
|
+
flex-shrink: 0;
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
.view {
|
|
907
|
+
display: flex;
|
|
908
|
+
flex-direction: column;
|
|
909
|
+
flex: 1;
|
|
910
|
+
min-height: 0;
|
|
911
|
+
animation: detail-enter var(--duration-fast) var(--ease-out);
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
.listView {
|
|
915
|
+
display: flex;
|
|
916
|
+
flex-direction: column;
|
|
917
|
+
flex: 1;
|
|
918
|
+
min-height: 0;
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
.results {
|
|
922
|
+
min-width: 0;
|
|
923
|
+
padding: var(--space-2);
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
.results:has([cmdk-empty]),
|
|
927
|
+
.results:has([cmdk-empty]) > [cmdk-list-sizer] {
|
|
928
|
+
display: flex;
|
|
929
|
+
flex-direction: column;
|
|
930
|
+
flex: 1;
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
.row {
|
|
934
|
+
min-height: var(--size-10);
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
.palette:not(.wide) .row {
|
|
938
|
+
min-height: calc(var(--size-10) - var(--space-1));
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
.row [data-slot="menu-item-label"] {
|
|
942
|
+
min-width: 0;
|
|
943
|
+
overflow: hidden;
|
|
944
|
+
text-overflow: ellipsis;
|
|
945
|
+
white-space: nowrap;
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
.row [data-slot="menu-item-trailing"] {
|
|
949
|
+
color: var(--fg-subtle);
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
.split {
|
|
953
|
+
display: grid;
|
|
954
|
+
grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.3fr);
|
|
955
|
+
flex: 1;
|
|
956
|
+
min-height: 0;
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
.preview {
|
|
960
|
+
min-width: 0;
|
|
961
|
+
min-height: 0;
|
|
962
|
+
overflow: auto;
|
|
963
|
+
overscroll-behavior: contain;
|
|
964
|
+
border-inline-start: var(--hairline) solid var(--material-border, var(--border));
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
.media {
|
|
968
|
+
height: calc(var(--size-2) * 24);
|
|
969
|
+
display: flex;
|
|
970
|
+
justify-content: center;
|
|
971
|
+
padding: var(--space-3);
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
.image {
|
|
975
|
+
--preview-ratio: 16 / 10;
|
|
976
|
+
aspect-ratio: var(--preview-ratio);
|
|
977
|
+
height: 100%;
|
|
978
|
+
max-width: 100%;
|
|
979
|
+
background: var(--bg-muted);
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
.document {
|
|
983
|
+
padding: var(--space-5);
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
.document h4,
|
|
987
|
+
.fileTitle {
|
|
988
|
+
margin: var(--space-3) 0 var(--space-2);
|
|
989
|
+
font-size: var(--text-base);
|
|
990
|
+
font-weight: var(--font-weight-semibold);
|
|
991
|
+
line-height: var(--lh-base);
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
.document p {
|
|
995
|
+
margin: 0;
|
|
996
|
+
color: var(--fg-muted);
|
|
997
|
+
font-size: var(--text-sm);
|
|
998
|
+
line-height: var(--lh-base);
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
.details {
|
|
1002
|
+
padding: var(--space-4);
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
.details > h4 {
|
|
1006
|
+
margin: 0 0 var(--space-2);
|
|
1007
|
+
color: var(--fg-muted);
|
|
1008
|
+
font-size: var(--text-xs);
|
|
1009
|
+
font-weight: var(--font-weight-medium);
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
.metadata {
|
|
1013
|
+
margin: 0;
|
|
1014
|
+
font-size: var(--text-xs);
|
|
1015
|
+
line-height: var(--lh-xs);
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
.metadata > div {
|
|
1019
|
+
display: grid;
|
|
1020
|
+
grid-template-columns: auto minmax(0, 1fr);
|
|
1021
|
+
gap: var(--space-4);
|
|
1022
|
+
padding-block: var(--space-1_5);
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
.metadata dt {
|
|
1026
|
+
color: var(--fg-subtle);
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
.metadata dd {
|
|
1030
|
+
margin: 0;
|
|
1031
|
+
text-align: end;
|
|
1032
|
+
overflow-wrap: anywhere;
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
.fullPreview {
|
|
1036
|
+
min-height: 0;
|
|
1037
|
+
overflow: auto;
|
|
1038
|
+
overscroll-behavior: contain;
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
.preview:focus-visible,
|
|
1042
|
+
.fullPreview:focus-visible {
|
|
1043
|
+
outline: none;
|
|
1044
|
+
background: var(--bg-subtle);
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
.fullPreview .media {
|
|
1048
|
+
height: calc(var(--size-2) * 26);
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
.fileTitle {
|
|
1052
|
+
margin-inline: var(--space-4);
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
.noPreview,
|
|
1056
|
+
.empty {
|
|
1057
|
+
display: flex;
|
|
1058
|
+
align-items: center;
|
|
1059
|
+
justify-content: center;
|
|
1060
|
+
min-height: calc(var(--size-2) * 20);
|
|
1061
|
+
padding: var(--space-4);
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
.empty {
|
|
1065
|
+
flex: 1;
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
.noPreview {
|
|
1069
|
+
min-height: 100%;
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
.footer {
|
|
1073
|
+
justify-content: space-between;
|
|
1074
|
+
min-height: var(--size-10);
|
|
1075
|
+
padding: var(--space-2) var(--space-3);
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
.hint {
|
|
1079
|
+
display: inline-flex;
|
|
1080
|
+
align-items: center;
|
|
1081
|
+
gap: var(--space-1_5);
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
@keyframes detail-enter {
|
|
1085
|
+
from { opacity: 0; transform: translateX(var(--space-2)); }
|
|
1086
|
+
to { opacity: 1; transform: translateX(0); }
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
:root[data-motion="none"] .view {
|
|
1090
|
+
animation: none;
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
@media (prefers-reduced-motion: reduce) {
|
|
1094
|
+
.view { animation: none; }
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
@media (max-width: 640px) {
|
|
1098
|
+
.split {
|
|
1099
|
+
grid-template-columns: minmax(0, 1fr);
|
|
1100
|
+
grid-template-rows: minmax(0, 0.8fr) minmax(0, 1.2fr);
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
.preview {
|
|
1104
|
+
border-inline-start: 0;
|
|
1105
|
+
border-top: var(--hairline) solid var(--material-border, var(--border));
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
````
|
|
1109
|
+
|
|
1110
|
+
### Source: web/examples/command-palette/DetailPalettes.tsx
|
|
1111
|
+
|
|
1112
|
+
````tsx
|
|
1113
|
+
"use client";
|
|
1114
|
+
|
|
1115
|
+
import { useEffect, useLayoutEffect, useRef, useState, type KeyboardEvent } from "react";
|
|
1116
|
+
import { PreviewButton } from "@/app/_components/PreviewButton";
|
|
1117
|
+
import { Button } from "@/components/Button";
|
|
1118
|
+
import { CommandPalette } from "@/components/CommandPalette";
|
|
1119
|
+
import { EmptyState } from "@/components/EmptyState";
|
|
1120
|
+
import { FileIcon, type FileIconType } from "@/components/FileIcon";
|
|
1121
|
+
import { Icon } from "@/components/Icon";
|
|
1122
|
+
import { IconButton } from "@/components/IconButton";
|
|
1123
|
+
import { Select } from "@/components/Select";
|
|
1124
|
+
import { Shortcut } from "@/components/Shortcut";
|
|
1125
|
+
import styles from "./DetailPalettes.module.css";
|
|
1126
|
+
|
|
1127
|
+
type File = { id: string; folder: string; name: string; type: FileIconType; format: string; size: string; modified: string; mine: boolean; text: string };
|
|
1128
|
+
const FOLDERS = [ { id: "design", name: "Design system" }, { id: "mobile", name: "Mobile app" } ];
|
|
1129
|
+
const FILES: File[] = [
|
|
1130
|
+
{ id: "social", folder: "design", name: "Brand social image", type: "image", format: "PNG", size: "2.4 MB", modified: "2026-11-18", mine: true, text: "Social image for the Redwood design system launch." },
|
|
1131
|
+
{ id: "guide", folder: "design", name: "Component guidelines", type: "document", format: "PDF", size: "1.8 MB", modified: "2026-11-17", mine: true, text: "Use shared components for navigation, input, feedback, and content. Keep keyboard behavior and focus consistent across views." },
|
|
1132
|
+
{ id: "tokens", folder: "design", name: "Design tokens", type: "document", format: "JSON", size: "38 KB", modified: "2026-11-15", mine: false, text: "Color, spacing, typography, and motion tokens are shared across the workspace." },
|
|
1133
|
+
{ id: "flows", folder: "mobile", name: "Navigation flows", type: "image", format: "PNG", size: "840 KB", modified: "2026-11-18", mine: false, text: "Navigation flows for the mobile application." },
|
|
1134
|
+
{ id: "release", folder: "mobile", name: "Release presentation", type: "presentation", format: "Keynote", size: "4.1 MB", modified: "2026-11-16", mine: true, text: "The release introduces updated navigation and a simplified onboarding flow." },
|
|
1135
|
+
{ id: "icons", folder: "design", name: "Icon library", type: "image", format: "SVG", size: "128 KB", modified: "2026-11-14", mine: false, text: "Shared interface icons for navigation and content actions." },
|
|
1136
|
+
{ id: "accessibility", folder: "design", name: "Accessibility checklist", type: "document", format: "PDF", size: "320 KB", modified: "2026-11-13", mine: false, text: "Verify keyboard access, readable labels, focus restoration, and empty states before release." },
|
|
1137
|
+
{ id: "changelog", folder: "design", name: "Component changelog", type: "document", format: "Markdown", size: "18 KB", modified: "2026-11-12", mine: false, text: "The latest update adds nested command navigation and file previews." },
|
|
1138
|
+
{ id: "app-icon", folder: "mobile", name: "App icon source", type: "image", format: "SVG", size: "96 KB", modified: "2026-11-11", mine: false, text: "Source asset for the mobile application icon." },
|
|
1139
|
+
{ id: "onboarding", folder: "mobile", name: "Onboarding specification", type: "document", format: "PDF", size: "680 KB", modified: "2026-11-10", mine: false, text: "Introduce the workspace, request required permissions, and guide users to their first project." },
|
|
1140
|
+
];
|
|
1141
|
+
type View = { folder: string | null; file: string | null; query: string; selected: string };
|
|
1142
|
+
|
|
1143
|
+
export function DetailPalette({ kind, lang = "en" }: { kind: "nested" | "preview"; lang?: "ko" | "en" }) {
|
|
1144
|
+
const ko = lang === "ko";
|
|
1145
|
+
const split = kind === "preview";
|
|
1146
|
+
const [open, setOpen] = useState(false);
|
|
1147
|
+
const [scope, setScope] = useState("all");
|
|
1148
|
+
const [view, setView] = useState<View>({ folder: null, file: null, query: "", selected: split ? FILES[0].id : FOLDERS[0].id });
|
|
1149
|
+
const [history, setHistory] = useState<View[]>([]);
|
|
1150
|
+
const input = useRef<HTMLInputElement>(null);
|
|
1151
|
+
const backButton = useRef<HTMLButtonElement>(null);
|
|
1152
|
+
const launcher = useRef<HTMLButtonElement>(null);
|
|
1153
|
+
const restoring = useRef(false);
|
|
1154
|
+
const restoreFrame = useRef(0);
|
|
1155
|
+
const navigationPending = useRef(false);
|
|
1156
|
+
useEffect(() => () => cancelAnimationFrame(restoreFrame.current), []);
|
|
1157
|
+
useLayoutEffect(() => {
|
|
1158
|
+
if (!navigationPending.current) return;
|
|
1159
|
+
navigationPending.current = false;
|
|
1160
|
+
(input.current ?? backButton.current)?.focus({ preventScroll: true });
|
|
1161
|
+
}, [view.folder, view.file]);
|
|
1162
|
+
const files = FILES.filter((file) => (scope === "all" || file.mine) && (!view.folder || file.folder === view.folder));
|
|
1163
|
+
const activeFile = files.find((file) => file.id === (view.file ?? view.selected));
|
|
1164
|
+
const folder = FOLDERS.find((item) => item.id === view.folder);
|
|
1165
|
+
const focusSearch = () => requestAnimationFrame(() => (input.current ?? backButton.current)?.focus({ preventScroll: true }));
|
|
1166
|
+
const enter = (next: Partial<View>, selected = view.selected) => {
|
|
1167
|
+
cancelAnimationFrame(restoreFrame.current);
|
|
1168
|
+
restoring.current = false;
|
|
1169
|
+
navigationPending.current = true;
|
|
1170
|
+
setHistory((current) => [...current, { ...view, selected }]);
|
|
1171
|
+
setView({ folder: view.folder, file: null, query: "", selected: "", ...next });
|
|
1172
|
+
};
|
|
1173
|
+
const goBack = () => {
|
|
1174
|
+
const previous = history.at(-1);
|
|
1175
|
+
if (!previous) return;
|
|
1176
|
+
cancelAnimationFrame(restoreFrame.current);
|
|
1177
|
+
navigationPending.current = true;
|
|
1178
|
+
restoring.current = true;
|
|
1179
|
+
setHistory((current) => current.slice(0, -1));
|
|
1180
|
+
setView({ ...previous, selected: "" });
|
|
1181
|
+
restoreFrame.current = requestAnimationFrame(() => {
|
|
1182
|
+
setView(previous);
|
|
1183
|
+
restoring.current = false;
|
|
1184
|
+
});
|
|
1185
|
+
};
|
|
1186
|
+
const openFile = () => {
|
|
1187
|
+
if (activeFile) enter({ file: activeFile.id });
|
|
1188
|
+
};
|
|
1189
|
+
const controlKeys = (event: KeyboardEvent) => {
|
|
1190
|
+
// Buttons and Select handle their own keyboard activation, not cmdk selection.
|
|
1191
|
+
if (event.key !== "Escape") event.stopPropagation();
|
|
1192
|
+
};
|
|
1193
|
+
const handleKeys = (event: KeyboardEvent<HTMLDivElement>) => {
|
|
1194
|
+
if (event.defaultPrevented || event.nativeEvent.isComposing) return;
|
|
1195
|
+
if (event.key === "Escape" && !open && history.length) {
|
|
1196
|
+
event.preventDefault();
|
|
1197
|
+
event.stopPropagation();
|
|
1198
|
+
goBack();
|
|
1199
|
+
}
|
|
1200
|
+
if (event.target !== input.current) return;
|
|
1201
|
+
if (event.key === "Backspace" && !view.query && history.length) {
|
|
1202
|
+
event.preventDefault();
|
|
1203
|
+
goBack();
|
|
1204
|
+
}
|
|
1205
|
+
if (event.key === "Enter" && split && !view.file && activeFile) {
|
|
1206
|
+
event.preventDefault();
|
|
1207
|
+
event.stopPropagation();
|
|
1208
|
+
openFile();
|
|
1209
|
+
}
|
|
1210
|
+
};
|
|
1211
|
+
const empty = <EmptyState size="sm" icon="search" title={ko ? "결과가 없어요" : "No results"}
|
|
1212
|
+
description={ko ? "다른 검색어를 입력해 보세요." : "Try a different search."} />;
|
|
1213
|
+
const metadata = (file: File) => (
|
|
1214
|
+
<dl className={styles.metadata}>
|
|
1215
|
+
{[
|
|
1216
|
+
[ko ? "파일명" : "Name", file.name],
|
|
1217
|
+
[ko ? "위치" : "Location", FOLDERS.find((item) => item.id === file.folder)!.name],
|
|
1218
|
+
[ko ? "형식" : "Format", file.format],
|
|
1219
|
+
[ko ? "크기" : "Size", file.size],
|
|
1220
|
+
[ko ? "수정일" : "Modified", file.modified],
|
|
1221
|
+
].map(([label, value]) => <div key={label}><dt>{label}</dt><dd>{value}</dd></div>)}
|
|
1222
|
+
</dl>
|
|
1223
|
+
);
|
|
1224
|
+
const preview = (file: File, full = false) => (
|
|
1225
|
+
<>
|
|
1226
|
+
{file.type === "image" ? (
|
|
1227
|
+
<div className={styles.media}>
|
|
1228
|
+
<div className={styles.image} role="img" aria-label={file.name + (ko ? " 이미지 미리보기 자리" : " image preview placeholder")} />
|
|
1229
|
+
</div>
|
|
1230
|
+
) : (
|
|
1231
|
+
<div className={styles.document}>
|
|
1232
|
+
<FileIcon type={file.type} size="lg" />
|
|
1233
|
+
<h4>{file.name}</h4>
|
|
1234
|
+
<p>{file.text}</p>
|
|
1235
|
+
</div>
|
|
1236
|
+
)}
|
|
1237
|
+
{full && file.type === "image" && <h4 className={styles.fileTitle}>{file.name}</h4>}
|
|
1238
|
+
<div className={styles.details}>
|
|
1239
|
+
<h4>{ko ? "파일 정보" : "File information"}</h4>
|
|
1240
|
+
{metadata(file)}
|
|
1241
|
+
</div>
|
|
1242
|
+
</>
|
|
1243
|
+
);
|
|
1244
|
+
return (
|
|
1245
|
+
<div className={styles.example} data-command-detail={kind}>
|
|
1246
|
+
<div className={styles.toolbar}>
|
|
1247
|
+
<PreviewButton ref={launcher} size="sm" onClick={() => setOpen(true)}
|
|
1248
|
+
rightIcon={<Icon name="arrows-out-simple" />}>
|
|
1249
|
+
{ko ? "팝업으로 열기" : "Open dialog"}
|
|
1250
|
+
</PreviewButton>
|
|
1251
|
+
</div>
|
|
1252
|
+
<CommandPalette open={open} onOpenChange={setOpen} presentation={open ? "dialog" : "inline"}
|
|
1253
|
+
size="sm" label={split ? (ko ? "파일 검색과 프리뷰" : "File search and preview") : (ko ? "하위 명령 탐색" : "Nested commands")}
|
|
1254
|
+
className={[styles.palette, split ? styles.wide : ""].join(" ")}
|
|
1255
|
+
value={view.selected} onValueChange={(selected) => {
|
|
1256
|
+
if (!restoring.current) setView((current) => ({ ...current, selected }));
|
|
1257
|
+
}}
|
|
1258
|
+
onKeyDown={handleKeys}
|
|
1259
|
+
onEscapeKeyDown={(event) => {
|
|
1260
|
+
if (history.length) { event.preventDefault(); goBack(); }
|
|
1261
|
+
}}
|
|
1262
|
+
onCloseAutoFocus={(event) => { event.preventDefault(); launcher.current?.focus({ preventScroll: true }); }}>
|
|
1263
|
+
<div className={styles.header} data-has-back={history.length > 0 || undefined}>
|
|
1264
|
+
{history.length > 0 && <IconButton ref={backButton} size="md" variant="ghost" icon={<Icon name="arrow-left" />}
|
|
1265
|
+
aria-label={ko ? "뒤로" : "Back"} onKeyDown={controlKeys} onClick={goBack} />}
|
|
1266
|
+
{view.file && activeFile ? <span className={styles.headerTitle}>{activeFile.name}</span> : (
|
|
1267
|
+
<CommandPalette.Input ref={input} value={view.query}
|
|
1268
|
+
onValueChange={(query) => setView((current) => ({ ...current, query }))}
|
|
1269
|
+
aria-label={ko ? "파일과 폴더 검색" : "Search files and folders"}
|
|
1270
|
+
placeholder={folder ? (ko ? folder.name + "에서 검색" : "Search " + folder.name) : (ko ? "파일과 폴더 검색" : "Search files and folders")}
|
|
1271
|
+
leadingIcon={history.length ? null : "search"} />
|
|
1272
|
+
)}
|
|
1273
|
+
{split && !view.file && <div className={styles.scope} onKeyDown={controlKeys}>
|
|
1274
|
+
<Select size="sm" variant="outline" width="fill" value={scope} onValueChange={(value) => {
|
|
1275
|
+
setScope(value);
|
|
1276
|
+
setView((current) => ({ ...current, query: "", selected: FILES.find((file) => value === "all" || file.mine)!.id }));
|
|
1277
|
+
focusSearch();
|
|
1278
|
+
}}>
|
|
1279
|
+
<Select.Trigger aria-label={ko ? "검색 범위" : "Search scope"} />
|
|
1280
|
+
<Select.Content><Select.Item value="all">{ko ? "모든 파일" : "All files"}</Select.Item>
|
|
1281
|
+
<Select.Item value="mine">{ko ? "내 파일" : "My files"}</Select.Item></Select.Content>
|
|
1282
|
+
</Select>
|
|
1283
|
+
</div>}
|
|
1284
|
+
</div>
|
|
1285
|
+
<div key={view.file ?? view.folder ?? "root"} className={styles.view}>
|
|
1286
|
+
{view.file && activeFile ? (
|
|
1287
|
+
<article className={styles.fullPreview} tabIndex={0} onKeyDown={controlKeys}
|
|
1288
|
+
aria-label={ko ? "열린 파일" : "Opened file"}>{preview(activeFile, true)}</article>
|
|
1289
|
+
) : (
|
|
1290
|
+
<div className={split ? styles.split : styles.listView}>
|
|
1291
|
+
<CommandPalette.List className={styles.results}>
|
|
1292
|
+
<CommandPalette.Empty className={styles.empty}>{empty}</CommandPalette.Empty>
|
|
1293
|
+
<CommandPalette.Group heading={folder?.name ?? (split ? (ko ? "파일" : "Files") : (ko ? "프로젝트" : "Projects"))}>
|
|
1294
|
+
{!split && !folder ? FOLDERS.map((item) => (
|
|
1295
|
+
<CommandPalette.Item key={item.id} value={item.id} keywords={[item.name]} className={styles.row}
|
|
1296
|
+
leadingActions={[<FileIcon key="folder" type="folder" size="sm" />]}
|
|
1297
|
+
trailingActions={[<Icon key="next" name="caret-right" />]}
|
|
1298
|
+
onSelect={() => enter({ folder: item.id, selected: FILES.find((file) => file.folder === item.id)!.id }, item.id)}>
|
|
1299
|
+
{item.name}
|
|
1300
|
+
</CommandPalette.Item>
|
|
1301
|
+
)) : files.map((file) => (
|
|
1302
|
+
<CommandPalette.Item key={file.id} value={file.id} keywords={[file.name, file.format]} className={styles.row}
|
|
1303
|
+
leadingActions={[<FileIcon key="file" type={file.type} size="sm" />]}
|
|
1304
|
+
onKeyDownCapture={(event) => {
|
|
1305
|
+
if (split && event.key === "Enter" && !event.nativeEvent.isComposing) {
|
|
1306
|
+
event.preventDefault();
|
|
1307
|
+
event.stopPropagation();
|
|
1308
|
+
enter({ file: file.id }, file.id);
|
|
1309
|
+
}
|
|
1310
|
+
}}
|
|
1311
|
+
onSelect={() => split ? setView((current) => ({ ...current, selected: file.id })) : enter({ file: file.id }, file.id)}>
|
|
1312
|
+
{file.name}
|
|
1313
|
+
</CommandPalette.Item>
|
|
1314
|
+
))}
|
|
1315
|
+
</CommandPalette.Group>
|
|
1316
|
+
</CommandPalette.List>
|
|
1317
|
+
{split && <aside className={styles.preview} tabIndex={0} onKeyDown={controlKeys}
|
|
1318
|
+
aria-label={ko ? "선택한 파일 미리보기" : "Selected file preview"}>
|
|
1319
|
+
{activeFile ? preview(activeFile) : <div className={styles.noPreview}>
|
|
1320
|
+
<EmptyState size="sm" icon="file" title={ko ? "선택한 파일이 없어요" : "No file selected"} />
|
|
1321
|
+
</div>}
|
|
1322
|
+
</aside>}
|
|
1323
|
+
</div>
|
|
1324
|
+
)}
|
|
1325
|
+
</div>
|
|
1326
|
+
<CommandPalette.Footer className={styles.footer}>
|
|
1327
|
+
{history.length > 0 ? <span className={styles.hint}><Shortcut>{["esc"]}</Shortcut>{ko ? "뒤로" : "Back"}</span>
|
|
1328
|
+
: <span className={styles.hint}><Shortcut>↑↓</Shortcut>{ko ? "이동" : "Navigate"}</span>}
|
|
1329
|
+
{split && !view.file ? <Button size="xs" variant="ghost" disabled={!activeFile} onKeyDown={controlKeys} onClick={openFile}>
|
|
1330
|
+
<span className={styles.hint}>{ko ? "열기" : "Open"}<Shortcut>↵</Shortcut></span>
|
|
1331
|
+
</Button> : !view.file && <span className={styles.hint}><Shortcut>↵</Shortcut>{ko ? "열기" : "Open"}</span>}
|
|
1332
|
+
</CommandPalette.Footer>
|
|
1333
|
+
</CommandPalette>
|
|
1334
|
+
</div>
|
|
1335
|
+
);
|
|
1336
|
+
}
|
|
1337
|
+
````
|
|
1338
|
+
|
|
1339
|
+
### Source: web/examples/command-palette/ExpandingSearch.module.css
|
|
1340
|
+
|
|
1341
|
+
````css
|
|
1342
|
+
.example {
|
|
1343
|
+
width: 100%;
|
|
1344
|
+
min-width: 0;
|
|
1345
|
+
background: var(--bg);
|
|
1346
|
+
border: var(--hairline) solid var(--border);
|
|
1347
|
+
border-radius: var(--radius-lg);
|
|
1348
|
+
corner-shape: var(--corner-shape);
|
|
1349
|
+
overflow: hidden;
|
|
1350
|
+
}
|
|
1351
|
+
|
|
1352
|
+
.topbar {
|
|
1353
|
+
border-bottom: var(--hairline) solid var(--border);
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1356
|
+
.workspace {
|
|
1357
|
+
font-size: var(--text-sm);
|
|
1358
|
+
font-weight: var(--font-weight-medium);
|
|
1359
|
+
}
|
|
1360
|
+
|
|
1361
|
+
.search {
|
|
1362
|
+
width: min(100%, calc(var(--size-2) * 40));
|
|
1363
|
+
min-width: 0;
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
.document {
|
|
1367
|
+
min-height: calc(var(--size-2) * 28);
|
|
1368
|
+
padding: var(--space-6);
|
|
1369
|
+
color: var(--fg-muted);
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
.document h4 {
|
|
1373
|
+
margin: var(--space-3) 0 var(--space-2);
|
|
1374
|
+
color: var(--fg);
|
|
1375
|
+
font-size: var(--text-lg);
|
|
1376
|
+
font-weight: var(--font-weight-semibold);
|
|
1377
|
+
}
|
|
1378
|
+
|
|
1379
|
+
.document p {
|
|
1380
|
+
margin: 0;
|
|
1381
|
+
max-width: calc(var(--size-2) * 52);
|
|
1382
|
+
font-size: var(--text-sm);
|
|
1383
|
+
line-height: var(--lh-base);
|
|
1384
|
+
}
|
|
1385
|
+
|
|
1386
|
+
.hint {
|
|
1387
|
+
display: inline-flex;
|
|
1388
|
+
align-items: center;
|
|
1389
|
+
gap: var(--space-1_5);
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
@media (max-width: 640px) {
|
|
1393
|
+
.workspace {
|
|
1394
|
+
display: none;
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1397
|
+
````
|
|
1398
|
+
|
|
1399
|
+
### Source: web/examples/command-palette/ExpandingSearch.tsx
|
|
1400
|
+
|
|
1401
|
+
````tsx
|
|
1402
|
+
"use client";
|
|
1403
|
+
|
|
1404
|
+
import { useState } from "react";
|
|
1405
|
+
import { CommandPalette } from "@/components/CommandPalette";
|
|
1406
|
+
import { Icon } from "@/components/Icon";
|
|
1407
|
+
import { Shortcut } from "@/components/Shortcut";
|
|
1408
|
+
import { Topbar } from "@/components/Topbar";
|
|
1409
|
+
import { EmptyState } from "@/components/EmptyState";
|
|
1410
|
+
import styles from "./ExpandingSearch.module.css";
|
|
1411
|
+
|
|
1412
|
+
const DOCUMENTS = [
|
|
1413
|
+
{ id: "design", title: "Redwood Design System", text: "Component guidelines and design decisions for the Redwood workspace." },
|
|
1414
|
+
{ id: "roadmap", title: "Q3 Product Roadmap", text: "Product priorities, milestones, and the next release schedule." },
|
|
1415
|
+
{ id: "mobile", title: "Mobile App Redesign", text: "Navigation patterns and layouts for the mobile application." },
|
|
1416
|
+
];
|
|
1417
|
+
|
|
1418
|
+
export function ExpandingSearch({ lang = "en" }: { lang?: "en" | "ko" }) {
|
|
1419
|
+
const [open, setOpen] = useState(false);
|
|
1420
|
+
const [document, setDocument] = useState(DOCUMENTS[0]);
|
|
1421
|
+
const ko = lang === "ko";
|
|
1422
|
+
return (
|
|
1423
|
+
<div className={styles.example} onKeyDownCapture={(event) => {
|
|
1424
|
+
if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "k" && !event.nativeEvent.isComposing) {
|
|
1425
|
+
event.preventDefault();
|
|
1426
|
+
event.stopPropagation();
|
|
1427
|
+
setOpen((value) => !value);
|
|
1428
|
+
}
|
|
1429
|
+
}}>
|
|
1430
|
+
<Topbar size="sm" className={styles.topbar}>
|
|
1431
|
+
<Topbar.Leading><Icon name="stack" /><span className={styles.workspace}>Workspace</span></Topbar.Leading>
|
|
1432
|
+
<Topbar.Center>
|
|
1433
|
+
<div className={styles.search}>
|
|
1434
|
+
<CommandPalette open={open} onOpenChange={setOpen} presentation="expand" dimmed={false} size="sm"
|
|
1435
|
+
label={ko ? "문서 검색" : "Search documents"}
|
|
1436
|
+
trigger={<CommandPalette.Trigger variant="neutral">{ko ? "문서 검색" : "Search documents"}</CommandPalette.Trigger>}>
|
|
1437
|
+
<CommandPalette.Input placeholder={ko ? "문서 이름을 입력하세요" : "Search documents"}
|
|
1438
|
+
aria-label={ko ? "문서 이름" : "Document name"} trailing={<Shortcut>{["esc"]}</Shortcut>} />
|
|
1439
|
+
<CommandPalette.List>
|
|
1440
|
+
<CommandPalette.Empty>
|
|
1441
|
+
<EmptyState size="sm" icon="search" title={ko ? "결과가 없어요" : "No results"}
|
|
1442
|
+
description={ko ? "다른 검색어를 입력해 보세요." : "Try a different search."} />
|
|
1443
|
+
</CommandPalette.Empty>
|
|
1444
|
+
<CommandPalette.Group heading={ko ? "프로젝트 문서" : "Project documents"}>
|
|
1445
|
+
{DOCUMENTS.map((item) => (
|
|
1446
|
+
<CommandPalette.Item key={item.id} value={item.title} leadingIcon="file-text"
|
|
1447
|
+
onSelect={() => { setDocument(item); setOpen(false); }}>
|
|
1448
|
+
{item.title}
|
|
1449
|
+
</CommandPalette.Item>
|
|
1450
|
+
))}
|
|
1451
|
+
</CommandPalette.Group>
|
|
1452
|
+
</CommandPalette.List>
|
|
1453
|
+
<CommandPalette.Footer>
|
|
1454
|
+
<span className={styles.hint}><Shortcut>↑↓</Shortcut>{ko ? "이동" : "Navigate"}</span>
|
|
1455
|
+
<span className={styles.hint}><Shortcut>↵</Shortcut>{ko ? "열기" : "Open"}</span>
|
|
1456
|
+
</CommandPalette.Footer>
|
|
1457
|
+
</CommandPalette>
|
|
1458
|
+
</div>
|
|
1459
|
+
</Topbar.Center>
|
|
1460
|
+
</Topbar>
|
|
1461
|
+
<div className={styles.document} aria-live="polite">
|
|
1462
|
+
<Icon name="file-text" />
|
|
1463
|
+
<h4>{document.title}</h4>
|
|
1464
|
+
<p>{document.text}</p>
|
|
1465
|
+
</div>
|
|
1466
|
+
</div>
|
|
1467
|
+
);
|
|
1468
|
+
}
|
|
1469
|
+
````
|
|
1470
|
+
|
|
1471
|
+
### Source: web/examples/command-palette/ReferencePalettes.module.css
|
|
1472
|
+
|
|
1473
|
+
````css
|
|
1474
|
+
.example {
|
|
1475
|
+
width: 100%;
|
|
1476
|
+
min-width: 0;
|
|
1477
|
+
}
|
|
1478
|
+
|
|
1479
|
+
.exampleToolbar {
|
|
1480
|
+
display: flex;
|
|
1481
|
+
justify-content: center;
|
|
1482
|
+
margin-bottom: var(--space-2);
|
|
1483
|
+
}
|
|
1484
|
+
|
|
1485
|
+
.example > .exampleToolbar:last-child {
|
|
1486
|
+
margin-top: var(--space-3);
|
|
1487
|
+
margin-bottom: 0;
|
|
1488
|
+
}
|
|
1489
|
+
|
|
1490
|
+
.palette {
|
|
1491
|
+
--reference-row-height: var(--size-10);
|
|
1492
|
+
--reference-header-height: calc(var(--size-2) * 7);
|
|
1493
|
+
--reference-height: calc(var(--size-2) * 77);
|
|
1494
|
+
width: min(calc(100vw - var(--space-6)), calc(var(--size-2) * 74));
|
|
1495
|
+
max-width: calc(var(--size-2) * 74);
|
|
1496
|
+
max-height: min(var(--reference-height), calc(100dvh - var(--space-8)));
|
|
1497
|
+
top: max(var(--space-4), calc((100dvh - var(--reference-height)) / 2));
|
|
1498
|
+
color: var(--fg);
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1501
|
+
.palette[data-presentation="inline"] {
|
|
1502
|
+
height: auto;
|
|
1503
|
+
max-height: var(--reference-height);
|
|
1504
|
+
}
|
|
1505
|
+
|
|
1506
|
+
.palette[data-presentation="inline"]:has([cmdk-empty]) {
|
|
1507
|
+
height: var(--reference-height);
|
|
1508
|
+
}
|
|
1509
|
+
|
|
1510
|
+
.palette > [cmdk-root] > :first-child {
|
|
1511
|
+
height: var(--reference-header-height);
|
|
1512
|
+
padding-inline: var(--space-4);
|
|
1513
|
+
gap: var(--space-2);
|
|
1514
|
+
}
|
|
1515
|
+
|
|
1516
|
+
.palette [cmdk-input] {
|
|
1517
|
+
font-size: var(--text-base);
|
|
1518
|
+
}
|
|
1519
|
+
|
|
1520
|
+
.palette [cmdk-input]::placeholder {
|
|
1521
|
+
opacity: var(--placeholder-opacity);
|
|
1522
|
+
}
|
|
1523
|
+
|
|
1524
|
+
.palette [cmdk-group-heading] > * {
|
|
1525
|
+
min-height: var(--size-8);
|
|
1526
|
+
padding: 0 var(--space-2);
|
|
1527
|
+
margin: 0;
|
|
1528
|
+
color: var(--fg-subtle);
|
|
1529
|
+
font-size: var(--text-xs);
|
|
1530
|
+
font-weight: var(--font-weight-medium);
|
|
1531
|
+
}
|
|
1532
|
+
|
|
1533
|
+
.palette [cmdk-group-heading] [data-slot="menu-item-label"] {
|
|
1534
|
+
width: 100%;
|
|
1535
|
+
}
|
|
1536
|
+
|
|
1537
|
+
.commandGroup {
|
|
1538
|
+
position: relative;
|
|
1539
|
+
}
|
|
1540
|
+
|
|
1541
|
+
.clear {
|
|
1542
|
+
position: absolute;
|
|
1543
|
+
inset-block-start: var(--space-1);
|
|
1544
|
+
inset-inline-end: var(--space-2);
|
|
1545
|
+
color: var(--fg-subtle);
|
|
1546
|
+
}
|
|
1547
|
+
|
|
1548
|
+
.results {
|
|
1549
|
+
padding: var(--space-2);
|
|
1550
|
+
}
|
|
1551
|
+
|
|
1552
|
+
.results:has([cmdk-empty]) {
|
|
1553
|
+
display: flex;
|
|
1554
|
+
flex-direction: column;
|
|
1555
|
+
}
|
|
1556
|
+
|
|
1557
|
+
.results:has([cmdk-empty]) > [cmdk-list-sizer] {
|
|
1558
|
+
display: flex;
|
|
1559
|
+
flex-direction: column;
|
|
1560
|
+
flex: 1;
|
|
1561
|
+
}
|
|
1562
|
+
|
|
1563
|
+
.empty {
|
|
1564
|
+
flex: 1;
|
|
1565
|
+
display: flex;
|
|
1566
|
+
align-items: center;
|
|
1567
|
+
justify-content: center;
|
|
1568
|
+
padding: var(--space-4);
|
|
1569
|
+
}
|
|
1570
|
+
|
|
1571
|
+
.row {
|
|
1572
|
+
min-height: var(--reference-row-height);
|
|
1573
|
+
padding-inline: var(--space-2);
|
|
1574
|
+
border-radius: var(--radius-sm);
|
|
1575
|
+
font-size: var(--text-sm);
|
|
1576
|
+
}
|
|
1577
|
+
|
|
1578
|
+
.row [data-slot="menu-item-leading"] {
|
|
1579
|
+
color: var(--fg-muted);
|
|
1580
|
+
}
|
|
1581
|
+
|
|
1582
|
+
.rowText {
|
|
1583
|
+
display: flex;
|
|
1584
|
+
align-items: baseline;
|
|
1585
|
+
gap: var(--space-2);
|
|
1586
|
+
min-width: 0;
|
|
1587
|
+
}
|
|
1588
|
+
|
|
1589
|
+
.rowText > :first-child {
|
|
1590
|
+
overflow: hidden;
|
|
1591
|
+
text-overflow: ellipsis;
|
|
1592
|
+
white-space: nowrap;
|
|
1593
|
+
}
|
|
1594
|
+
|
|
1595
|
+
.meta {
|
|
1596
|
+
flex-shrink: 1;
|
|
1597
|
+
min-width: 0;
|
|
1598
|
+
overflow: hidden;
|
|
1599
|
+
text-overflow: ellipsis;
|
|
1600
|
+
white-space: nowrap;
|
|
1601
|
+
font-weight: var(--font-weight-regular);
|
|
1602
|
+
color: var(--fg-subtle);
|
|
1603
|
+
}
|
|
1604
|
+
|
|
1605
|
+
.members {
|
|
1606
|
+
margin-inline-end: var(--space-1);
|
|
1607
|
+
}
|
|
1608
|
+
|
|
1609
|
+
.person.person {
|
|
1610
|
+
--_avatar-bg: var(--bg-muted);
|
|
1611
|
+
--_avatar-fg: var(--fg-muted);
|
|
1612
|
+
background: var(--bg-muted);
|
|
1613
|
+
color: var(--fg-muted);
|
|
1614
|
+
font-size: var(--text-2xs);
|
|
1615
|
+
}
|
|
1616
|
+
|
|
1617
|
+
.jump {
|
|
1618
|
+
padding: var(--space-0_5) var(--space-1_5);
|
|
1619
|
+
background: var(--bg-subtle);
|
|
1620
|
+
border-radius: var(--radius-sm);
|
|
1621
|
+
color: var(--fg-muted);
|
|
1622
|
+
font-size: var(--text-xs);
|
|
1623
|
+
white-space: nowrap;
|
|
1624
|
+
}
|
|
1625
|
+
|
|
1626
|
+
.divider {
|
|
1627
|
+
margin: var(--space-3) calc(var(--space-2) * -1) var(--space-2);
|
|
1628
|
+
}
|
|
1629
|
+
|
|
1630
|
+
.footer {
|
|
1631
|
+
min-height: var(--size-12);
|
|
1632
|
+
justify-content: flex-start;
|
|
1633
|
+
flex-wrap: wrap;
|
|
1634
|
+
gap: var(--space-3);
|
|
1635
|
+
padding: var(--space-2) var(--space-4);
|
|
1636
|
+
font-size: var(--text-xs);
|
|
1637
|
+
}
|
|
1638
|
+
|
|
1639
|
+
.footerHint {
|
|
1640
|
+
display: inline-flex;
|
|
1641
|
+
align-items: center;
|
|
1642
|
+
gap: var(--space-1_5);
|
|
1643
|
+
white-space: nowrap;
|
|
1644
|
+
}
|
|
1645
|
+
|
|
1646
|
+
.footerAction {
|
|
1647
|
+
color: var(--fg-muted);
|
|
1648
|
+
}
|
|
1649
|
+
|
|
1650
|
+
.launcher {
|
|
1651
|
+
--reference-height: calc(var(--size-2) * 82);
|
|
1652
|
+
}
|
|
1653
|
+
|
|
1654
|
+
.filters {
|
|
1655
|
+
display: flex;
|
|
1656
|
+
gap: var(--space-1_5);
|
|
1657
|
+
padding: var(--space-2) var(--space-4);
|
|
1658
|
+
flex-shrink: 0;
|
|
1659
|
+
overflow-x: auto;
|
|
1660
|
+
}
|
|
1661
|
+
|
|
1662
|
+
.filters button {
|
|
1663
|
+
flex-shrink: 0;
|
|
1664
|
+
}
|
|
1665
|
+
|
|
1666
|
+
.launcher .results {
|
|
1667
|
+
padding-top: 0;
|
|
1668
|
+
}
|
|
1669
|
+
|
|
1670
|
+
.launcher [cmdk-group-heading] > * {
|
|
1671
|
+
min-height: var(--size-10);
|
|
1672
|
+
font-size: var(--text-sm);
|
|
1673
|
+
color: var(--fg-subtle);
|
|
1674
|
+
}
|
|
1675
|
+
|
|
1676
|
+
.launcher .footer > :first-child {
|
|
1677
|
+
margin-inline-end: auto;
|
|
1678
|
+
}
|
|
1679
|
+
|
|
1680
|
+
.selection {
|
|
1681
|
+
margin: var(--space-3) 0 0;
|
|
1682
|
+
font-size: var(--text-sm);
|
|
1683
|
+
color: var(--fg-muted);
|
|
1684
|
+
}
|
|
1685
|
+
|
|
1686
|
+
@media (max-width: 640px) {
|
|
1687
|
+
.palette {
|
|
1688
|
+
--reference-height: calc(var(--size-2) * 70);
|
|
1689
|
+
}
|
|
1690
|
+
|
|
1691
|
+
.launcher {
|
|
1692
|
+
--reference-height: calc(var(--size-2) * 78);
|
|
1693
|
+
}
|
|
1694
|
+
|
|
1695
|
+
.jump {
|
|
1696
|
+
display: none;
|
|
1697
|
+
}
|
|
1698
|
+
|
|
1699
|
+
.rowText {
|
|
1700
|
+
gap: var(--space-1_5);
|
|
1701
|
+
}
|
|
1702
|
+
|
|
1703
|
+
.rowText > :first-child {
|
|
1704
|
+
flex-shrink: 0;
|
|
1705
|
+
max-width: 100%;
|
|
1706
|
+
}
|
|
1707
|
+
|
|
1708
|
+
.meta {
|
|
1709
|
+
font-size: var(--text-xs);
|
|
1710
|
+
}
|
|
1711
|
+
|
|
1712
|
+
.footer {
|
|
1713
|
+
gap: var(--space-2);
|
|
1714
|
+
padding-inline: var(--space-3);
|
|
1715
|
+
}
|
|
1716
|
+
}
|
|
1717
|
+
````
|
|
1718
|
+
|
|
1719
|
+
### Source: web/examples/command-palette/ReferencePalettes.tsx
|
|
1720
|
+
|
|
1721
|
+
````tsx
|
|
1722
|
+
"use client";
|
|
1723
|
+
|
|
1724
|
+
import { useRef, useState, type KeyboardEvent } from "react";
|
|
1725
|
+
import { Avatar, AvatarGroup } from "@/components/Avatar";
|
|
1726
|
+
import { Badge } from "@/components/Badge";
|
|
1727
|
+
import { PreviewButton } from "@/app/_components/PreviewButton";
|
|
1728
|
+
import { Button } from "@/components/Button";
|
|
1729
|
+
import { Chip } from "@/components/Chip";
|
|
1730
|
+
import { CommandPalette } from "@/components/CommandPalette";
|
|
1731
|
+
import { EmptyState } from "@/components/EmptyState";
|
|
1732
|
+
import { Icon, type IconName } from "@/components/Icon";
|
|
1733
|
+
import { Shortcut } from "@/components/Shortcut";
|
|
1734
|
+
import styles from "./ReferencePalettes.module.css";
|
|
1735
|
+
|
|
1736
|
+
type Kind = "workspace" | "launcher";
|
|
1737
|
+
type Category = "Apps" | "People" | "Files" | "Commands";
|
|
1738
|
+
type Entry = {
|
|
1739
|
+
id: string;
|
|
1740
|
+
label: string;
|
|
1741
|
+
icon: IconName;
|
|
1742
|
+
meta?: string;
|
|
1743
|
+
category?: Category;
|
|
1744
|
+
keys?: string;
|
|
1745
|
+
members?: string[];
|
|
1746
|
+
count?: number;
|
|
1747
|
+
};
|
|
1748
|
+
|
|
1749
|
+
const PROJECTS: Entry[] = [
|
|
1750
|
+
{ id: "redwood", label: "Redwood Design System", icon: "folder", members: ["Alex Kim", "Jamie Chen", "Taylor Morgan"] },
|
|
1751
|
+
{ id: "roadmap", label: "Q3 Product Roadmap", icon: "folder", members: ["Alex Kim", "Jamie Chen", "Taylor Morgan", "Mike Dean", "Sarah Lee", "Jin Park"] },
|
|
1752
|
+
{ id: "redesign", label: "Mobile App Redesign", icon: "folder", members: ["Sarah Lee", "Mike Dean"] },
|
|
1753
|
+
{ id: "messages", label: "Messages", icon: "chat-circle", count: 4 },
|
|
1754
|
+
{ id: "claude", label: "Open in Claude", icon: "sparkle" },
|
|
1755
|
+
];
|
|
1756
|
+
const ACTIONS: Entry[] = [
|
|
1757
|
+
{ id: "project", label: "Create new project", icon: "stack" },
|
|
1758
|
+
{ id: "issue", label: "Create new issue", icon: "warning-circle" },
|
|
1759
|
+
{ id: "task", label: "Create new task", icon: "rows" },
|
|
1760
|
+
{ id: "reminder", label: "Set reminder", icon: "bell" },
|
|
1761
|
+
{ id: "advanced", label: "Advanced search", icon: "search" },
|
|
1762
|
+
];
|
|
1763
|
+
const PROMPTS: Entry[] = [
|
|
1764
|
+
{ id: "email", label: "Compose an Email", icon: "envelope", meta: "Gmail", category: "Commands", keys: "⌘⌥G" },
|
|
1765
|
+
{ id: "schedule", label: "Manage my Schedule", icon: "calendar", meta: "Calendar", category: "Commands", keys: "⌘⌃C" },
|
|
1766
|
+
{ id: "doc", label: "Create a Doc", icon: "file-text", meta: "Notion", category: "Commands", keys: "⌘N" },
|
|
1767
|
+
];
|
|
1768
|
+
const RECENT: Entry[] = [
|
|
1769
|
+
{ id: "inbox", label: "My Inbox", icon: "envelope", meta: "Gmail", category: "Apps", keys: "⌘I" },
|
|
1770
|
+
{ id: "all-hands", label: "All Hands notes", icon: "file-text", meta: "Docs", category: "Files" },
|
|
1771
|
+
{ id: "new-task", label: "New Task", icon: "check-square", meta: "Todoist", category: "Commands", keys: "⌘⌥N" },
|
|
1772
|
+
{ id: "mike", label: "Mike Dean", icon: "user", meta: "mike@compname.com", category: "People" },
|
|
1773
|
+
];
|
|
1774
|
+
const APPLICATIONS: Entry[] = [
|
|
1775
|
+
{ id: "slack", label: "Slack", icon: "hash", category: "Apps", keys: "⌘3" },
|
|
1776
|
+
{ id: "notion", label: "Notion", icon: "file-text", category: "Apps" },
|
|
1777
|
+
];
|
|
1778
|
+
const CATEGORIES: Category[] = ["Apps", "People", "Files", "Commands"];
|
|
1779
|
+
|
|
1780
|
+
export function ReferencePalette({ kind, lang = "en" }: { kind: Kind; lang?: "en" | "ko" }) {
|
|
1781
|
+
const workspace = kind === "workspace";
|
|
1782
|
+
const [open, setOpen] = useState(false);
|
|
1783
|
+
const [query, setQuery] = useState("");
|
|
1784
|
+
const [selected, setSelected] = useState(workspace ? "issue" : "schedule");
|
|
1785
|
+
const [category, setCategory] = useState<Category | null>(null);
|
|
1786
|
+
const [recents, setRecents] = useState(PROJECTS);
|
|
1787
|
+
const [actions, setActions] = useState(ACTIONS);
|
|
1788
|
+
const [parent, setParent] = useState<Entry | null>(null);
|
|
1789
|
+
const [last, setLast] = useState("");
|
|
1790
|
+
const launchButton = useRef<HTMLButtonElement>(null);
|
|
1791
|
+
const input = useRef<HTMLInputElement>(null);
|
|
1792
|
+
const visible = (entries: Entry[]) => entries.filter((entry) => !category || entry.category === category);
|
|
1793
|
+
const groups = parent
|
|
1794
|
+
? [{ label: parent.label, entries: [
|
|
1795
|
+
{ id: "open", label: "Open", icon: "arrow-right" as IconName },
|
|
1796
|
+
{ id: "details", label: "View details", icon: "file-text" as IconName },
|
|
1797
|
+
] }]
|
|
1798
|
+
: workspace
|
|
1799
|
+
? [{ label: "Recent", entries: recents }, { label: "Actions", entries: actions }]
|
|
1800
|
+
: [{ label: "AI Prompts", entries: visible(PROMPTS) }, { label: "Recent", entries: visible(RECENT) }, { label: "Applications", entries: visible(APPLICATIONS) }];
|
|
1801
|
+
const entries = groups.flatMap((group) => group.entries);
|
|
1802
|
+
const goBack = () => {
|
|
1803
|
+
setParent(null);
|
|
1804
|
+
setQuery("");
|
|
1805
|
+
setSelected(workspace ? "issue" : "schedule");
|
|
1806
|
+
input.current?.focus({ preventScroll: true });
|
|
1807
|
+
};
|
|
1808
|
+
const select = (entry: Entry) => {
|
|
1809
|
+
if (workspace) return;
|
|
1810
|
+
setQuery("");
|
|
1811
|
+
setLast(parent ? parent.label + ": " + entry.label : entry.label);
|
|
1812
|
+
setParent(null);
|
|
1813
|
+
if (open) setOpen(false);
|
|
1814
|
+
else input.current?.focus({ preventScroll: true });
|
|
1815
|
+
};
|
|
1816
|
+
const handleKeys = (event: KeyboardEvent<HTMLDivElement>) => {
|
|
1817
|
+
if (event.nativeEvent.isComposing || event.keyCode === 229) return;
|
|
1818
|
+
if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "k") {
|
|
1819
|
+
event.preventDefault();
|
|
1820
|
+
event.stopPropagation();
|
|
1821
|
+
onOpenChange(!open);
|
|
1822
|
+
return;
|
|
1823
|
+
}
|
|
1824
|
+
if (!workspace && (event.metaKey || event.ctrlKey) && event.key === "Enter") {
|
|
1825
|
+
event.preventDefault();
|
|
1826
|
+
const entry = entries.find((item) => item.id === selected);
|
|
1827
|
+
if (entry && !parent) {
|
|
1828
|
+
setParent(entry);
|
|
1829
|
+
setQuery("");
|
|
1830
|
+
setSelected("open");
|
|
1831
|
+
}
|
|
1832
|
+
return;
|
|
1833
|
+
}
|
|
1834
|
+
if (event.metaKey && event.key === "/") {
|
|
1835
|
+
event.preventDefault();
|
|
1836
|
+
input.current?.focus();
|
|
1837
|
+
}
|
|
1838
|
+
if (parent && (event.key === "Escape" || ((event.key === "ArrowLeft" || event.key === "Backspace") && !query && event.target === input.current))) {
|
|
1839
|
+
event.preventDefault();
|
|
1840
|
+
event.stopPropagation();
|
|
1841
|
+
goBack();
|
|
1842
|
+
}
|
|
1843
|
+
if (!parent && event.key === "Escape" && !open) setQuery("");
|
|
1844
|
+
if (!workspace && (event.metaKey || event.ctrlKey)) {
|
|
1845
|
+
const key = event.key.toUpperCase();
|
|
1846
|
+
const match = entries.find((entry) => {
|
|
1847
|
+
const keys = entry.keys;
|
|
1848
|
+
return keys && keys.endsWith(key) && keys.includes("⌥") === event.altKey && keys.includes("⌃") === event.ctrlKey;
|
|
1849
|
+
});
|
|
1850
|
+
if (match) {
|
|
1851
|
+
event.preventDefault();
|
|
1852
|
+
select(match);
|
|
1853
|
+
}
|
|
1854
|
+
}
|
|
1855
|
+
};
|
|
1856
|
+
const controlKeys = (event: KeyboardEvent<HTMLElement>) => {
|
|
1857
|
+
if (event.key === "Enter" || event.key === " ") event.stopPropagation();
|
|
1858
|
+
};
|
|
1859
|
+
const onOpenChange = (next: boolean) => {
|
|
1860
|
+
setOpen(next);
|
|
1861
|
+
setQuery("");
|
|
1862
|
+
setParent(null);
|
|
1863
|
+
setSelected(workspace ? "issue" : "schedule");
|
|
1864
|
+
};
|
|
1865
|
+
|
|
1866
|
+
return (
|
|
1867
|
+
<div className={styles.example} data-palette-example={kind}>
|
|
1868
|
+
<div className={styles.exampleToolbar}>
|
|
1869
|
+
<PreviewButton ref={launchButton} size="sm" rightIcon={<Icon name="arrows-out" />}
|
|
1870
|
+
onClick={() => onOpenChange(true)}>
|
|
1871
|
+
{lang === "ko" ? "팝업으로 열기" : "Open dialog"}
|
|
1872
|
+
</PreviewButton>
|
|
1873
|
+
</div>
|
|
1874
|
+
<CommandPalette open={open} onOpenChange={onOpenChange}
|
|
1875
|
+
presentation={open ? "dialog" : "inline"}
|
|
1876
|
+
label={workspace ? "Workspace commands" : "Application launcher"}
|
|
1877
|
+
value={selected} onValueChange={setSelected} onKeyDown={handleKeys}
|
|
1878
|
+
className={[styles.palette, workspace ? styles.workspace : styles.launcher].join(" ")}
|
|
1879
|
+
onCloseAutoFocus={(event) => {
|
|
1880
|
+
event.preventDefault();
|
|
1881
|
+
launchButton.current?.focus({ preventScroll: true });
|
|
1882
|
+
}}>
|
|
1883
|
+
<CommandPalette.Input ref={input} value={query} onValueChange={setQuery}
|
|
1884
|
+
aria-label={workspace ? "Search workspace commands" : "Search applications and commands"}
|
|
1885
|
+
placeholder={parent ? "Search in " + parent.label : workspace ? "Type a command or search" : "Search or type a command"}
|
|
1886
|
+
trailing={parent
|
|
1887
|
+
? <Button size="xs" variant="ghost" onKeyDown={controlKeys} leftIcon={<Icon name="arrow-left" />} onClick={goBack}>Back</Button>
|
|
1888
|
+
: workspace ? <Shortcut size="sm">⌘/</Shortcut> : undefined}
|
|
1889
|
+
/>
|
|
1890
|
+
{!workspace && !parent && (
|
|
1891
|
+
<div className={styles.filters} role="group" aria-label="Filter results">
|
|
1892
|
+
{CATEGORIES.map((item) => (
|
|
1893
|
+
<Chip key={item} onKeyDown={controlKeys} size="lg" variant="outline" selected={category === item}
|
|
1894
|
+
onPressedChange={(pressed) => {
|
|
1895
|
+
setCategory(pressed ? item : null);
|
|
1896
|
+
setQuery("");
|
|
1897
|
+
setSelected("");
|
|
1898
|
+
}}>
|
|
1899
|
+
{item}
|
|
1900
|
+
</Chip>
|
|
1901
|
+
))}
|
|
1902
|
+
</div>
|
|
1903
|
+
)}
|
|
1904
|
+
<CommandPalette.List className={styles.results}>
|
|
1905
|
+
<CommandPalette.Empty className={styles.empty}>
|
|
1906
|
+
<EmptyState
|
|
1907
|
+
size="sm"
|
|
1908
|
+
icon="search"
|
|
1909
|
+
title="No results found"
|
|
1910
|
+
description="Try a different search or reset your filters."
|
|
1911
|
+
actions={<Button size="sm" variant="outline" onKeyDown={controlKeys} onClick={() => {
|
|
1912
|
+
setQuery("");
|
|
1913
|
+
setCategory(null);
|
|
1914
|
+
setParent(null);
|
|
1915
|
+
setRecents(PROJECTS);
|
|
1916
|
+
setActions(ACTIONS);
|
|
1917
|
+
input.current?.focus({ preventScroll: true });
|
|
1918
|
+
}}>Reset search</Button>}
|
|
1919
|
+
/>
|
|
1920
|
+
</CommandPalette.Empty>
|
|
1921
|
+
{groups.map((group, index) => (
|
|
1922
|
+
<div key={group.label}>
|
|
1923
|
+
{workspace && index > 0 && <CommandPalette.Separator className={styles.divider} />}
|
|
1924
|
+
<CommandPalette.Group heading={group.label} className={styles.commandGroup}>
|
|
1925
|
+
{workspace && !parent && (
|
|
1926
|
+
<Button variant="ghost" size="xs" aria-label={"Clear " + group.label.toLowerCase()}
|
|
1927
|
+
className={styles.clear} onKeyDown={controlKeys}
|
|
1928
|
+
onClick={() => {
|
|
1929
|
+
if (group.label === "Recent") setRecents([]);
|
|
1930
|
+
else setActions([]);
|
|
1931
|
+
input.current?.focus({ preventScroll: true });
|
|
1932
|
+
}}>
|
|
1933
|
+
Clear
|
|
1934
|
+
</Button>
|
|
1935
|
+
)}
|
|
1936
|
+
{group.entries.map((entry) => (
|
|
1937
|
+
<CommandPalette.Item key={entry.id} value={entry.id} keywords={[entry.label, entry.meta ?? "", entry.category ?? ""]}
|
|
1938
|
+
className={styles.row}
|
|
1939
|
+
leadingActions={entry.id === "mike"
|
|
1940
|
+
? [<Avatar key="avatar" alt="Mike Dean" icon={<Icon name="user" />} size="sm" className={styles.person} />]
|
|
1941
|
+
: [<Icon key="icon" name={entry.icon} />]}
|
|
1942
|
+
trailingActions={workspace
|
|
1943
|
+
? entry.members
|
|
1944
|
+
? [
|
|
1945
|
+
<AvatarGroup key="members" size="sm" shape="rounded" max={4} className={styles.members}>
|
|
1946
|
+
{entry.members.map((name) => <Avatar key={name} alt={name} icon={<Icon name="user" />} className={styles.person} />)}
|
|
1947
|
+
</AvatarGroup>,
|
|
1948
|
+
<span key="jump" className={styles.jump}>Open</span>,
|
|
1949
|
+
]
|
|
1950
|
+
: entry.count
|
|
1951
|
+
? [<Badge key="count" size="sm" variant="soft">{entry.count}</Badge>]
|
|
1952
|
+
: [<Icon key="arrow" name="caret-right" size="var(--icon-size-sm)" />]
|
|
1953
|
+
: entry.keys ? [<Shortcut key="keys" size="sm">{entry.keys}</Shortcut>] : undefined}
|
|
1954
|
+
onSelect={() => select(entry)}>
|
|
1955
|
+
<span className={styles.rowText}>
|
|
1956
|
+
<CommandPalette.Highlight text={entry.label} />
|
|
1957
|
+
{entry.meta && <span className={styles.meta}>{entry.meta}</span>}
|
|
1958
|
+
</span>
|
|
1959
|
+
</CommandPalette.Item>
|
|
1960
|
+
))}
|
|
1961
|
+
</CommandPalette.Group>
|
|
1962
|
+
</div>
|
|
1963
|
+
))}
|
|
1964
|
+
</CommandPalette.List>
|
|
1965
|
+
<CommandPalette.Footer className={styles.footer}>
|
|
1966
|
+
{workspace ? (
|
|
1967
|
+
<>
|
|
1968
|
+
<span className={styles.footerHint}><Shortcut size="sm">↑↓</Shortcut> navigate</span>
|
|
1969
|
+
<span className={styles.footerHint}><Shortcut size="sm">↵</Shortcut> open</span>
|
|
1970
|
+
<span className={styles.footerHint}><Shortcut size="sm">{[parent ? "←" : "esc"]}</Shortcut>{parent ? "parent" : open ? "close" : "clear"}</span>
|
|
1971
|
+
</>
|
|
1972
|
+
) : (
|
|
1973
|
+
<>
|
|
1974
|
+
<span className={styles.footerHint}>Next <Shortcut size="sm"><span>tab</span></Shortcut></span>
|
|
1975
|
+
<span className={styles.footerHint}>Open <Shortcut size="sm">↵</Shortcut></span>
|
|
1976
|
+
<Button size="xs" variant="ghost" onKeyDown={controlKeys} className={styles.footerAction}
|
|
1977
|
+
disabled={!entries.some((entry) => entry.id === selected) || !!parent}
|
|
1978
|
+
onClick={() => {
|
|
1979
|
+
const entry = entries.find((item) => item.id === selected);
|
|
1980
|
+
if (entry) {
|
|
1981
|
+
setParent(entry);
|
|
1982
|
+
setQuery("");
|
|
1983
|
+
setSelected("open");
|
|
1984
|
+
input.current?.focus();
|
|
1985
|
+
}
|
|
1986
|
+
}}>
|
|
1987
|
+
<span className={styles.footerHint}>Actions <Shortcut size="sm">⌘↵</Shortcut></span>
|
|
1988
|
+
</Button>
|
|
1989
|
+
</>
|
|
1990
|
+
)}
|
|
1991
|
+
</CommandPalette.Footer>
|
|
1992
|
+
</CommandPalette>
|
|
1993
|
+
{!workspace && last && <p className={styles.selection} role="status">{last}</p>}
|
|
1994
|
+
{(recents.length === 0 || actions.length === 0) && workspace && (
|
|
1995
|
+
<div className={styles.exampleToolbar}>
|
|
1996
|
+
<PreviewButton size="sm" onClick={() => { setRecents(PROJECTS); setActions(ACTIONS); }}>
|
|
1997
|
+
{lang === "ko" ? "예제 초기화" : "Reset example"}
|
|
1998
|
+
</PreviewButton>
|
|
1999
|
+
</div>
|
|
2000
|
+
)}
|
|
2001
|
+
</div>
|
|
2002
|
+
);
|
|
2003
|
+
}
|
|
2004
|
+
````
|