-
-
Notifications
You must be signed in to change notification settings - Fork 7.1k
feat(VCommandPalette): add new command palette component #22403
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+2,284
−10
Merged
Changes from 19 commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
6598653
feat(VCommandPalette): introduce command palette component
MatthewAry bc0ba6e
Add missing localizations
MatthewAry cbe8d53
refactor(VCommandPalette): WIP Navigation Logic
MatthewAry ae5b0b3
refactor(VCommandPalette): streamline item handling and navigation
MatthewAry 79c4bcf
refactor(VCommandPalette): update localization and documentation
MatthewAry a842e93
Fix lint
MatthewAry 4016bac
Lint fixes
MatthewAry 4911d22
dirty fix for search
J-Sek afe7533
types for slots
J-Sek d79053e
use VSheet instead of VCard, load styles
J-Sek d8de285
readonly `selectedIndex`
J-Sek caa42de
refactor: simplify initial focus
J-Sek ed39599
simplify refs
J-Sek 6876db1
refactor(VCommandPalette): enhance input handling and styling
MatthewAry 80ddb4e
fix(VCommandPalette): add cleanup for hotkey listener on unmount
MatthewAry 94a5cb5
Woops Clean up last commit
MatthewAry 5d7b4aa
fix(VCommandPalette): improve focus handling and item value binding
MatthewAry ab2f8d6
Make Provide/Inject more aligned with project
MatthewAry 7ef726e
Lint Fixes
MatthewAry 8cc8f22
feat: add `list-props`
J-Sek d77bf26
docs: describe `list-props` + sort
J-Sek 2408e20
docs: fix usage example
J-Sek f9eb65f
fix: missing activator slot (+ reorder imports)
J-Sek 3552a3b
fix missing click handler in usage.vue script
J-Sek aee9c68
docs: fix usage example (drop v-model="dialog")
J-Sek 8c77ac9
refactor(VCommandPalette): remove location prop and update documentation
MatthewAry ca45f45
fix(VCommandPalette): update default input icon and improve icon set
MatthewAry ea12b9f
refactor(VCommandPalette): simplify dialog props and enhance icon set
MatthewAry d5aaa49
feat(VCommandPalette): add max-width prop to examples
MatthewAry 0e9334e
chore: consolidate docs icons
J-Sek bd221fc
chore: correct defaults
J-Sek 6f09982
chore: input autofocus + suppress autocomplete
J-Sek 03644ec
docs: fix usage example
J-Sek 613b760
chore: extract Sass variables
J-Sek a7fd2cb
refactor: expose dialog props
J-Sek b6c995a
feat: pass density to input and list
J-Sek b4a37ac
fix: keep subheader and dividers when filtering
J-Sek 1cf8c80
fix: avoid showing 2 dividers next to each other
J-Sek 24facd8
feat: additional slots
J-Sek ddc6254
Merge branch 'dev' into matthewary/v-command-palette-r2
J-Sek df9d7ed
docs: descriptions for new slots
J-Sek e516154
docs: options API scripts for new examples
J-Sek a259e61
chore: drop TS from example
J-Sek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| { | ||
| "props": { | ||
| "modelValue": "Controls the visibility of the command palette dialog. Use `v-model` for two-way binding.", | ||
| "search": "The current search query. Use `v-model:search` to control or monitor the search input value.", | ||
| "items": "Array of command palette items. Objects should have **title** and optionally **subtitle**, **prependIcon**, **appendIcon**, **prependAvatar**, **appendAvatar**, **hotkey**, **onClick**, **to**, **href**, and **value** properties. Use `type: 'subheader'` with a **title** for section headers, or `type: 'divider'` for visual separators between groups.", | ||
| "hotkey": "Global keyboard shortcut to toggle the palette. Accepts hotkey strings like `'ctrl+shift+p'` or `'meta+j'`. The shortcut is automatically registered on mount and cleaned up on unmount.", | ||
| "placeholder": "Placeholder text displayed in the search input. Defaults to the `$vuetify.command.search` locale string.", | ||
| "inputIcon": "Icon to display at the start of the search input field. Defaults to `'mdi-magnify'`.", | ||
| "noDataText": "Text displayed when no items match the current search query. Defaults to `$vuetify.noDataText`.", | ||
| "location": "Controls the position of the dialog. Supports values like `'top'`, `'bottom'`, `'center'` and combinations. Passed to the underlying **v-dialog**.", | ||
| "activator": "Element to use as the activator. Set to `'parent'` to use the parent element, or provide a CSS selector or element reference. Passed to the underlying **v-dialog**.", | ||
| "dialogProps": "Additional props to pass through to the underlying **v-dialog** component. Useful for customizing behavior like `persistent`, `fullscreen`, `width`, `maxWidth`, etc." | ||
| }, | ||
| "events": { | ||
| "update:modelValue": "Emitted when the dialog visibility changes.", | ||
| "update:search": "Emitted when the search query changes.", | ||
| "click:item": "Emitted when an item is clicked or activated via Enter key. The payload includes the selected item object and the triggering event (MouseEvent or KeyboardEvent). The palette automatically closes after this event." | ||
| }, | ||
| "slots": { | ||
| "prepend": "Content to render above the search input, inside the command palette card. Useful for headers, breadcrumbs, or instructions.", | ||
| "input": "Custom search input field. Replaces the default **v-text-field**. Useful for providing a completely custom search implementation.", | ||
| "append": "Content to render below the items list, inside the command palette card. Useful for footers, keyboard shortcut hints, or additional actions.", | ||
| "no-data": "Custom content to display when no items match the search query. Replaces the default no-data message." | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
206 changes: 206 additions & 0 deletions
206
packages/docs/src/examples/v-command-palette/prop-dialog.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,206 @@ | ||
| <template> | ||
| <v-container fluid> | ||
| <v-row> | ||
| <v-col cols="12" md="4"> | ||
| <v-card> | ||
| <v-card-title>Default (Center)</v-card-title> | ||
| <v-card-text> | ||
| <v-btn block @click="dialogs.default = true"> | ||
| Open Default | ||
| </v-btn> | ||
| </v-card-text> | ||
| </v-card> | ||
|
|
||
| <v-command-palette | ||
| v-model="dialogs.default" | ||
| :items="items" | ||
| placeholder="Search..." | ||
| @click:item="handleClick" | ||
| ></v-command-palette> | ||
| </v-col> | ||
|
|
||
| <v-col cols="12" md="4"> | ||
| <v-card> | ||
| <v-card-title>Top Position</v-card-title> | ||
| <v-card-text> | ||
| <v-btn block @click="dialogs.top = true"> | ||
| Open at Top | ||
| </v-btn> | ||
| </v-card-text> | ||
| </v-card> | ||
|
|
||
| <v-command-palette | ||
| v-model="dialogs.top" | ||
| :items="items" | ||
| location="top" | ||
| placeholder="Search..." | ||
| @click:item="handleClick" | ||
| ></v-command-palette> | ||
| </v-col> | ||
|
|
||
| <v-col cols="12" md="4"> | ||
| <v-card> | ||
| <v-card-title>Parent Activator</v-card-title> | ||
| <v-card-text> | ||
| <v-btn block> | ||
| Click to Open | ||
| <v-command-palette | ||
| v-model="dialogs.activator" | ||
| :items="items" | ||
| activator="parent" | ||
| placeholder="Search..." | ||
| @click:item="handleClick" | ||
| ></v-command-palette> | ||
| </v-btn> | ||
| </v-card-text> | ||
| </v-card> | ||
| </v-col> | ||
| </v-row> | ||
|
|
||
| <v-row> | ||
| <v-col cols="12"> | ||
| <v-card> | ||
| <v-card-title>Custom Dialog Props</v-card-title> | ||
| <v-card-text> | ||
| <v-btn block @click="dialogs.custom = true"> | ||
| Open Persistent (No Close on Click Outside) | ||
| </v-btn> | ||
| </v-card-text> | ||
| </v-card> | ||
|
|
||
| <v-command-palette | ||
| v-model="dialogs.custom" | ||
| :dialog-props="{ persistent: true }" | ||
| :items="items" | ||
| placeholder="Search..." | ||
| @click:item="handleClick" | ||
| ></v-command-palette> | ||
| </v-col> | ||
| </v-row> | ||
|
|
||
| <v-snackbar v-model="snackbar" :timeout="2000"> | ||
| Selected: {{ selectedItem }} | ||
| </v-snackbar> | ||
| </v-container> | ||
| </template> | ||
|
|
||
| <script setup> | ||
| import { ref } from 'vue' | ||
|
|
||
| const dialogs = ref({ | ||
| default: false, | ||
| top: false, | ||
| activator: false, | ||
| custom: false, | ||
| }) | ||
|
|
||
| const snackbar = ref(false) | ||
| const selectedItem = ref('') | ||
|
|
||
| const items = [ | ||
| { | ||
| title: 'New File', | ||
| subtitle: 'Create a new file', | ||
| prependIcon: 'mdi-file-plus', | ||
| value: 'new-file', | ||
| }, | ||
| { | ||
| title: 'New Folder', | ||
| subtitle: 'Create a new folder', | ||
| prependIcon: 'mdi-folder-plus', | ||
| value: 'new-folder', | ||
| }, | ||
| { | ||
| title: 'Open', | ||
| subtitle: 'Open a file or project', | ||
| prependIcon: 'mdi-folder-open', | ||
| value: 'open', | ||
| }, | ||
| { | ||
| type: 'divider', | ||
| }, | ||
| { | ||
| type: 'subheader', | ||
| title: 'Recent', | ||
| }, | ||
| { | ||
| title: 'Project Alpha', | ||
| subtitle: 'Last opened 2 hours ago', | ||
| prependIcon: 'mdi-folder', | ||
| value: 'project-alpha', | ||
| }, | ||
| { | ||
| title: 'Project Beta', | ||
| subtitle: 'Last opened yesterday', | ||
| prependIcon: 'mdi-folder', | ||
| value: 'project-beta', | ||
| }, | ||
| ] | ||
|
|
||
| function handleClick (item) { | ||
| selectedItem.value = item.title | ||
| snackbar.value = true | ||
| } | ||
| </script> | ||
|
|
||
| <script> | ||
| export default { | ||
| data () { | ||
| return { | ||
| dialogs: { | ||
| default: false, | ||
| top: false, | ||
| activator: false, | ||
| custom: false, | ||
| }, | ||
| snackbar: false, | ||
| selectedItem: '', | ||
| items: [ | ||
| { | ||
| title: 'New File', | ||
| subtitle: 'Create a new file', | ||
| prependIcon: 'mdi-file-plus', | ||
| value: 'new-file', | ||
| }, | ||
| { | ||
| title: 'New Folder', | ||
| subtitle: 'Create a new folder', | ||
| prependIcon: 'mdi-folder-plus', | ||
| value: 'new-folder', | ||
| }, | ||
| { | ||
| title: 'Open', | ||
| subtitle: 'Open a file or project', | ||
| prependIcon: 'mdi-folder-open', | ||
| value: 'open', | ||
| }, | ||
| { | ||
| type: 'divider', | ||
| }, | ||
| { | ||
| type: 'subheader', | ||
| title: 'Recent', | ||
| }, | ||
| { | ||
| title: 'Project Alpha', | ||
| subtitle: 'Last opened 2 hours ago', | ||
| prependIcon: 'mdi-folder', | ||
| value: 'project-alpha', | ||
| }, | ||
| { | ||
| title: 'Project Beta', | ||
| subtitle: 'Last opened yesterday', | ||
| prependIcon: 'mdi-folder', | ||
| value: 'project-beta', | ||
| }, | ||
| ], | ||
| } | ||
| }, | ||
| methods: { | ||
| handleClick (item) { | ||
| this.selectedItem = item.title | ||
| this.snackbar = true | ||
| }, | ||
| }, | ||
| } | ||
| </script> | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.