@ghostvue/mcp 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. package/dist/assets/bundle.json +2 -2
  2. package/dist/assets/component-exports.json +1 -0
  3. package/dist/assets/docs/pages.json +1 -1
  4. package/dist/assets/examples/catalog.json +1 -1
  5. package/dist/assets/examples/sources/accordion/billing-faq.vue +123 -0
  6. package/dist/assets/examples/sources/avatar/team-roster.vue +69 -5
  7. package/dist/assets/examples/sources/badge/release-channels.vue +1 -1
  8. package/dist/assets/examples/sources/breadcrumb/basic.vue +60 -15
  9. package/dist/assets/examples/sources/button/refresh-status.vue +95 -0
  10. package/dist/assets/examples/sources/calendar/availability.vue +235 -0
  11. package/dist/assets/examples/sources/calendar/office-locale.vue +197 -0
  12. package/dist/assets/examples/sources/card/project-summary.vue +38 -3
  13. package/dist/assets/examples/sources/checkbox-group/basic.vue +56 -0
  14. package/dist/assets/examples/sources/checkbox-group/field.vue +73 -0
  15. package/dist/assets/examples/sources/checkbox-group/form.vue +100 -0
  16. package/dist/assets/examples/sources/checkbox-group/headless.vue +68 -0
  17. package/dist/assets/examples/sources/checkbox-group/notification-preferences.vue +380 -0
  18. package/dist/assets/examples/sources/collapsible/shipment-history.vue +135 -0
  19. package/dist/assets/examples/sources/combobox/review-request-form.vue +415 -0
  20. package/dist/assets/examples/sources/command-palette/async.vue +60 -12
  21. package/dist/assets/examples/sources/command-palette/basic.vue +123 -2
  22. package/dist/assets/examples/sources/command-palette/shortcut.vue +132 -5
  23. package/dist/assets/examples/sources/command-palette/themed.vue +44 -4
  24. package/dist/assets/examples/sources/command-palette/virtualized.vue +124 -3
  25. package/dist/assets/examples/sources/context-menu/themed.vue +81 -26
  26. package/dist/assets/examples/sources/data-table/themed-invoices.vue +219 -44
  27. package/dist/assets/examples/sources/date-picker/controlled.vue +8 -293
  28. package/dist/assets/examples/sources/date-picker/custom-format.vue +6 -295
  29. package/dist/assets/examples/sources/date-picker/nested-dialog.vue +28 -350
  30. package/dist/assets/examples/sources/date-picker/rtl.vue +5 -294
  31. package/dist/assets/examples/sources/date-picker/themed.vue +2 -2
  32. package/dist/assets/examples/sources/date-picker/validation.vue +8 -294
  33. package/dist/assets/examples/sources/dropdown-menu/nested-export.vue +56 -0
  34. package/dist/assets/examples/sources/empty-state/search-results.vue +26 -1
  35. package/dist/assets/examples/sources/field/billing-address-headless.vue +93 -0
  36. package/dist/assets/examples/sources/field/billing-address.vue +192 -0
  37. package/dist/assets/examples/sources/field/checkbox.vue +10 -2
  38. package/dist/assets/examples/sources/field/themed.vue +12 -11
  39. package/dist/assets/examples/sources/file-upload/asset-submission.vue +96 -36
  40. package/dist/assets/examples/sources/form/async-validation.vue +180 -0
  41. package/dist/assets/examples/sources/form/composable.vue +146 -0
  42. package/dist/assets/examples/sources/form/nested-webhooks.vue +233 -0
  43. package/dist/assets/examples/sources/form/profile-schema.vue +376 -0
  44. package/dist/assets/examples/sources/inline-alert/billing-notices.vue +26 -5
  45. package/dist/assets/examples/sources/inline-alert/feed-status.vue +229 -0
  46. package/dist/assets/examples/sources/input/clearable-search-headless.vue +162 -0
  47. package/dist/assets/examples/sources/input/clearable-search.vue +225 -0
  48. package/dist/assets/examples/sources/input/unit-suffix.vue +109 -0
  49. package/dist/assets/examples/sources/interactive-surface/basic.vue +20 -8
  50. package/dist/assets/examples/sources/interactive-surface/feature-tiles.vue +42 -8
  51. package/dist/assets/examples/sources/kbd/command-shortcuts.vue +0 -1
  52. package/dist/assets/examples/sources/link/documentation-footer.vue +11 -4
  53. package/dist/assets/examples/sources/link/router.vue +9 -5
  54. package/dist/assets/examples/sources/menubar/themed.vue +46 -10
  55. package/dist/assets/examples/sources/number-input/order-limits.vue +5 -0
  56. package/dist/assets/examples/sources/number-input/themed.vue +12 -6
  57. package/dist/assets/examples/sources/number-input/workshop-booking.vue +207 -0
  58. package/dist/assets/examples/sources/pagination/controlled.vue +83 -18
  59. package/dist/assets/examples/sources/pagination/ellipsis.vue +44 -14
  60. package/dist/assets/examples/sources/pagination/themed.vue +161 -21
  61. package/dist/assets/examples/sources/presence/basic.vue +81 -0
  62. package/dist/assets/examples/sources/presence/portal.vue +92 -0
  63. package/dist/assets/examples/sources/progress/report-export.vue +160 -0
  64. package/dist/assets/examples/sources/scroll-area/activity-feed.vue +0 -1
  65. package/dist/assets/examples/sources/scroll-area/horizontal.vue +169 -14
  66. package/dist/assets/examples/sources/scroll-area/themed.vue +42 -3
  67. package/dist/assets/examples/sources/scroll-spy/themed.vue +180 -31
  68. package/dist/assets/examples/sources/select/alert-routing-form.vue +356 -0
  69. package/dist/assets/examples/sources/select/multiple-form.vue +201 -0
  70. package/dist/assets/examples/sources/select/multiple-labels.vue +142 -0
  71. package/dist/assets/examples/sources/skeleton/profile-loading.vue +28 -4
  72. package/dist/assets/examples/sources/slider/audio-mixer.vue +8 -2
  73. package/dist/assets/examples/sources/slider/price-filter.vue +162 -0
  74. package/dist/assets/examples/sources/slider/vertical.vue +3 -2
  75. package/dist/assets/examples/sources/spinner/sync-status.vue +13 -10
  76. package/dist/assets/examples/sources/switch/form.vue +43 -11
  77. package/dist/assets/examples/sources/table/contain-horizontal.vue +24 -12
  78. package/dist/assets/examples/sources/table/row-headers.vue +118 -19
  79. package/dist/assets/examples/sources/tabs/review-sections.vue +43 -0
  80. package/dist/assets/examples/sources/tags-input/headless-field.vue +31 -0
  81. package/dist/assets/examples/sources/tags-input/project-labels.vue +64 -0
  82. package/dist/assets/examples/sources/tags-input/read-only.vue +12 -0
  83. package/dist/assets/examples/sources/toast/themed.vue +42 -19
  84. package/dist/assets/examples/sources/toolbar/themed.vue +22 -4
  85. package/dist/assets/examples/sources/tooltip/themed.vue +12 -1
  86. package/dist/assets/examples/sources/tree/themed.vue +70 -17
  87. package/dist/assets/manifests/themes/ghost-accordion.manifest.json +1 -0
  88. package/dist/assets/manifests/themes/ghost-button.manifest.json +1 -0
  89. package/dist/assets/manifests/themes/ghost-calendar.manifest.json +3 -1
  90. package/dist/assets/manifests/themes/ghost-checkbox-group.manifest.json +90 -0
  91. package/dist/assets/manifests/themes/ghost-collapsible.manifest.json +1 -0
  92. package/dist/assets/manifests/themes/ghost-combobox.manifest.json +1 -0
  93. package/dist/assets/manifests/themes/ghost-command-palette.manifest.json +2 -1
  94. package/dist/assets/manifests/themes/ghost-date-picker.manifest.json +5 -0
  95. package/dist/assets/manifests/themes/ghost-dropdown-menu.manifest.json +9 -0
  96. package/dist/assets/manifests/themes/ghost-field.manifest.json +10 -2
  97. package/dist/assets/manifests/themes/ghost-inline-alert.manifest.json +1 -0
  98. package/dist/assets/manifests/themes/ghost-input.manifest.json +3 -1
  99. package/dist/assets/manifests/themes/ghost-link.manifest.json +2 -1
  100. package/dist/assets/manifests/themes/ghost-number-input.manifest.json +1 -0
  101. package/dist/assets/manifests/themes/ghost-pagination.manifest.json +6 -2
  102. package/dist/assets/manifests/themes/ghost-progress.manifest.json +1 -0
  103. package/dist/assets/manifests/themes/ghost-radio-group-item.manifest.json +63 -0
  104. package/dist/assets/manifests/themes/ghost-scroll-area.manifest.json +12 -2
  105. package/dist/assets/manifests/themes/ghost-select.manifest.json +3 -0
  106. package/dist/assets/manifests/themes/ghost-slider.manifest.json +1 -0
  107. package/dist/assets/manifests/themes/ghost-table.manifest.json +2 -1
  108. package/dist/assets/manifests/themes/ghost-tags-input.manifest.json +255 -0
  109. package/dist/assets/manifests/vue/ghost-checkbox-group.manifest.json +173 -0
  110. package/dist/assets/manifests/vue/ghost-command-palette-content.manifest.json +6 -2
  111. package/dist/assets/manifests/vue/ghost-command-palette-overlay.manifest.json +6 -2
  112. package/dist/assets/manifests/vue/ghost-command-palette.manifest.json +0 -1
  113. package/dist/assets/manifests/vue/ghost-context-menu-content.manifest.json +3 -3
  114. package/dist/assets/manifests/vue/ghost-context-menu.manifest.json +1 -1
  115. package/dist/assets/manifests/vue/ghost-data-table-preset.manifest.json +1 -1
  116. package/dist/assets/manifests/vue/ghost-data-table-table.manifest.json +1 -1
  117. package/dist/assets/manifests/vue/ghost-data-table.manifest.json +99 -2
  118. package/dist/assets/manifests/vue/ghost-date-picker-content.manifest.json +12 -3
  119. package/dist/assets/manifests/vue/ghost-date-picker.manifest.json +1 -6
  120. package/dist/assets/manifests/vue/ghost-dialog-content.manifest.json +6 -2
  121. package/dist/assets/manifests/vue/ghost-dialog-overlay.manifest.json +6 -2
  122. package/dist/assets/manifests/vue/ghost-drawer-content.manifest.json +6 -2
  123. package/dist/assets/manifests/vue/ghost-drawer-overlay.manifest.json +6 -2
  124. package/dist/assets/manifests/vue/ghost-field-error.manifest.json +12 -1
  125. package/dist/assets/manifests/vue/ghost-field.manifest.json +35 -3
  126. package/dist/assets/manifests/vue/ghost-form.manifest.json +221 -0
  127. package/dist/assets/manifests/vue/ghost-hover-card-content.manifest.json +12 -3
  128. package/dist/assets/manifests/vue/ghost-input.manifest.json +2 -1
  129. package/dist/assets/manifests/vue/ghost-link.manifest.json +1 -2
  130. package/dist/assets/manifests/vue/ghost-menubar-content.manifest.json +3 -3
  131. package/dist/assets/manifests/vue/ghost-menubar.manifest.json +4 -4
  132. package/dist/assets/manifests/vue/ghost-pagination.manifest.json +0 -2
  133. package/dist/assets/manifests/vue/ghost-popover-content.manifest.json +6 -2
  134. package/dist/assets/manifests/vue/ghost-presence.manifest.json +96 -0
  135. package/dist/assets/manifests/vue/ghost-scroll-area.manifest.json +0 -1
  136. package/dist/assets/manifests/vue/ghost-select-content.manifest.json +6 -1
  137. package/dist/assets/manifests/vue/ghost-select-group.manifest.json +6 -1
  138. package/dist/assets/manifests/vue/ghost-select-label.manifest.json +6 -1
  139. package/dist/assets/manifests/vue/ghost-select-option.manifest.json +6 -1
  140. package/dist/assets/manifests/vue/ghost-select-trigger.manifest.json +6 -1
  141. package/dist/assets/manifests/vue/ghost-select-value.manifest.json +18 -2
  142. package/dist/assets/manifests/vue/ghost-select.manifest.json +18 -6
  143. package/dist/assets/manifests/vue/ghost-submenu-content.manifest.json +168 -0
  144. package/dist/assets/manifests/vue/ghost-submenu-trigger.manifest.json +102 -0
  145. package/dist/assets/manifests/vue/ghost-submenu.manifest.json +59 -0
  146. package/dist/assets/manifests/vue/ghost-table.manifest.json +0 -2
  147. package/dist/assets/manifests/vue/ghost-tabs.manifest.json +2 -1
  148. package/dist/assets/manifests/vue/ghost-tags-input.manifest.json +260 -0
  149. package/dist/assets/tokens.json +15 -0
  150. package/dist/components.d.ts +5 -0
  151. package/dist/components.js +80 -11
  152. package/package.json +1 -1
@@ -26,15 +26,21 @@ const lastCommand = ref('None yet')
26
26
 
27
27
  /*
28
28
  * The application owns the shortcut. The palette installs no global
29
- * listener; this one calls the exposed `open()`. Focus returns to whatever
29
+ * listener; this one calls the exposed `open()`. Mod+K is the usual
30
+ * choice; this app binds Mod+J because its site search owns Mod+K. Focus returns to whatever
30
31
  * was focused when the shortcut fired (here, the draft) because the dialog
31
32
  * saves the opener even without a visible trigger.
32
33
  */
33
34
  function onKeydown(event: KeyboardEvent): void {
35
+ // Leave a press another handler already claimed, or one inside an IME
36
+ // composition, alone.
37
+ if (event.defaultPrevented || event.isComposing) {
38
+ return
39
+ }
34
40
  if (
35
41
  (event.metaKey || event.ctrlKey) &&
36
42
  !event.altKey &&
37
- event.key.toLowerCase() === 'k'
43
+ event.key.toLowerCase() === 'j'
38
44
  ) {
39
45
  event.preventDefault()
40
46
  palette.value?.open()
@@ -57,7 +63,7 @@ function onCommand({ id }: GhostCommandPaletteCommandPayload): void {
57
63
  <template>
58
64
  <div>
59
65
  <p>
60
- Press <GhostKbd :keys="['mod']">K</GhostKbd> anywhere on this page to open
66
+ Press <GhostKbd :keys="['mod']">J</GhostKbd> anywhere on this page to open
61
67
  the formatting commands.
62
68
  </p>
63
69
  <textarea aria-label="Draft" rows="3">Release notes draft</textarea>
@@ -65,8 +71,8 @@ function onCommand({ id }: GhostCommandPaletteCommandPayload): void {
65
71
  Last command: <output>{{ lastCommand }}</output>
66
72
  </p>
67
73
  <GhostCommandPalette ref="palette" @command="onCommand">
68
- <GhostCommandPaletteOverlay />
69
- <GhostCommandPaletteContent>
74
+ <GhostCommandPaletteOverlay class="command-palette-demo__overlay" />
75
+ <GhostCommandPaletteContent class="command-palette-demo">
70
76
  <GhostCommandPaletteTitle>Formatting commands</GhostCommandPaletteTitle>
71
77
  <GhostCommandPaletteInput placeholder="Type a command" />
72
78
  <GhostCommandPaletteList>
@@ -85,3 +91,124 @@ function onCommand({ id }: GhostCommandPaletteCommandPayload): void {
85
91
  </GhostCommandPalette>
86
92
  </div>
87
93
  </template>
94
+
95
+ <style>
96
+ /*
97
+ * Headless GhostCommandPalette ships behavior only: the overlay and content
98
+ * are portaled to <body> with no position, surface or item states. This
99
+ * consumer CSS is unscoped on purpose, because portaled parts do not carry
100
+ * the component's scoped attribute, and prefixed so it cannot collide with
101
+ * page styles. Parts below the content are reached through `data-part`.
102
+ *
103
+ * Colors read GhostVue semantic tokens when a theme is loaded and fall back
104
+ * to CSS system colors, which follow light and dark on their own. Rows keep
105
+ * fixed geometry: highlight and disabled only change color. The highlight
106
+ * follows `data-highlighted`, because focus stays in the input. Nothing
107
+ * animates, so reduced motion needs no override.
108
+ */
109
+ .command-palette-demo__overlay {
110
+ background-color: rgb(0 0 0 / 45%);
111
+ inset: 0;
112
+ position: fixed;
113
+ z-index: 50;
114
+ }
115
+
116
+ /* Anchored near the top so the input stays put as results change. */
117
+ .command-palette-demo {
118
+ background-color: var(--ghost-elevation-4-bg, Canvas);
119
+ border: 1px solid var(--ghost-elevation-4-border, GrayText);
120
+ border-radius: var(--ghost-radius-lg, 0.5rem);
121
+ box-shadow: var(--ghost-elevation-4-shadow, 0 1rem 2rem rgb(0 0 0 / 25%));
122
+ box-sizing: border-box;
123
+ color: var(--ghost-surface-fg, CanvasText);
124
+ display: grid;
125
+ gap: 0.5rem;
126
+ inline-size: min(calc(100vw - 2rem), 32rem);
127
+ left: 50%;
128
+ max-block-size: calc(100dvh - 2rem);
129
+ overflow: auto;
130
+ padding: 0.75rem;
131
+ position: fixed;
132
+ top: min(12dvh, 8rem);
133
+ transform: translateX(-50%);
134
+ z-index: 50;
135
+ }
136
+
137
+ .command-palette-demo [data-part='title'] {
138
+ border: 0;
139
+ font-size: 0.875rem;
140
+ font-weight: 600;
141
+ letter-spacing: normal;
142
+ line-height: 1.4;
143
+ margin: 0;
144
+ padding: 0;
145
+ }
146
+
147
+ .command-palette-demo [data-part='input'] {
148
+ background-color: var(--ghost-surface-bg, Field);
149
+ border: 1px solid var(--ghost-border-strong, GrayText);
150
+ border-radius: var(--ghost-radius-md, 0.375rem);
151
+ box-sizing: border-box;
152
+ color: var(--ghost-text-default, FieldText);
153
+ font: inherit;
154
+ inline-size: 100%;
155
+ padding: 0.5rem 0.75rem;
156
+ }
157
+
158
+ .command-palette-demo [data-part='input']:focus-visible {
159
+ outline: 2px solid var(--ghost-focus-ring-color, Highlight);
160
+ outline-offset: 2px;
161
+ }
162
+
163
+ .command-palette-demo [data-part='list'] {
164
+ max-block-size: min(50dvh, 18rem);
165
+ overflow: auto;
166
+ }
167
+
168
+ .command-palette-demo [data-part='label'] {
169
+ color: var(--ghost-text-muted, GrayText);
170
+ font-size: 0.75rem;
171
+ font-weight: 600;
172
+ padding: 0.25rem 0.75rem;
173
+ }
174
+
175
+ .command-palette-demo [data-part='separator'] {
176
+ border-block-start: 1px solid var(--ghost-border-default, GrayText);
177
+ margin-block: 0.25rem;
178
+ }
179
+
180
+ .command-palette-demo [role='option'] {
181
+ border-radius: var(--ghost-radius-sm, 0.25rem);
182
+ cursor: default;
183
+ /* A transparent outline turns into a visible ring under forced colors. */
184
+ outline: 2px solid transparent;
185
+ outline-offset: -2px;
186
+ padding: 0.375rem 0.75rem;
187
+ }
188
+
189
+ .command-palette-demo [role='option'][data-highlighted] {
190
+ background-color: var(--ghost-action-primary-bg, Highlight);
191
+ color: var(--ghost-action-primary-fg, HighlightText);
192
+ }
193
+
194
+ .command-palette-demo [role='option'][aria-disabled='true'] {
195
+ color: var(--ghost-text-muted, GrayText);
196
+ cursor: not-allowed;
197
+ }
198
+
199
+ .command-palette-demo [data-part='empty'],
200
+ .command-palette-demo > p {
201
+ color: var(--ghost-text-muted, GrayText);
202
+ font-size: 0.875rem;
203
+ margin: 0;
204
+ padding: 0.375rem 0.75rem;
205
+ }
206
+
207
+ @media (forced-colors: active) {
208
+ .command-palette-demo [role='option'][data-highlighted] {
209
+ background-color: Highlight;
210
+ color: HighlightText;
211
+ forced-color-adjust: none;
212
+ }
213
+ }
214
+ </style>
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import { computed, ref } from 'vue'
2
+ import { computed, onBeforeUnmount, onMounted, ref, useTemplateRef } from 'vue'
3
3
 
4
4
  import {
5
5
  GhostButton,
@@ -17,6 +17,7 @@ import {
17
17
  GhostCommandPaletteTrigger,
18
18
  GhostKbd,
19
19
  type GhostCommandPaletteCommandPayload,
20
+ type GhostCommandPaletteExposed,
20
21
  } from '@ghostvue/themes'
21
22
 
22
23
  interface Command {
@@ -46,9 +47,40 @@ const groups: { id: string; label: string; commands: Command[] }[] = [
46
47
  },
47
48
  ]
48
49
 
50
+ const palette = useTemplateRef<GhostCommandPaletteExposed>('palette')
49
51
  const search = ref('')
50
52
  const lastCommand = ref('None yet')
51
53
 
54
+ /*
55
+ * The application owns the shortcut that the trigger advertises: the palette
56
+ * installs no global listener. Mod+K is the usual choice; this app binds
57
+ * Mod+J because its site search already owns Mod+K. Skip a press another
58
+ * handler already claimed (`defaultPrevented`) or one that belongs to an IME
59
+ * composition. Focus returns to whatever was focused when the shortcut fired.
60
+ */
61
+ function onKeydown(event: KeyboardEvent): void {
62
+ if (
63
+ event.defaultPrevented ||
64
+ event.isComposing ||
65
+ event.altKey ||
66
+ event.shiftKey ||
67
+ !(event.metaKey || event.ctrlKey) ||
68
+ event.key.toLowerCase() !== 'j'
69
+ ) {
70
+ return
71
+ }
72
+ event.preventDefault()
73
+ palette.value?.open()
74
+ }
75
+
76
+ onMounted(() => {
77
+ window.addEventListener('keydown', onKeydown)
78
+ })
79
+
80
+ onBeforeUnmount(() => {
81
+ window.removeEventListener('keydown', onKeydown)
82
+ })
83
+
52
84
  const visibleGroups = computed(() => {
53
85
  const query = search.value.trim().toLowerCase()
54
86
  return groups
@@ -70,10 +102,18 @@ function runCommand({ id }: GhostCommandPaletteCommandPayload): void {
70
102
 
71
103
  <template>
72
104
  <div class="palette-themed">
73
- <GhostCommandPalette v-model:search="search" @command="runCommand">
74
- <GhostCommandPaletteTrigger :as="GhostButton" variant="outline">
105
+ <GhostCommandPalette
106
+ ref="palette"
107
+ v-model:search="search"
108
+ @command="runCommand"
109
+ >
110
+ <GhostCommandPaletteTrigger
111
+ :as="GhostButton"
112
+ variant="outline"
113
+ aria-keyshortcuts="Control+J Meta+J"
114
+ >
75
115
  Search commands
76
- <GhostKbd :keys="['mod']">K</GhostKbd>
116
+ <GhostKbd :keys="['mod']">J</GhostKbd>
77
117
  </GhostCommandPaletteTrigger>
78
118
  <GhostCommandPaletteOverlay />
79
119
  <GhostCommandPaletteContent>
@@ -48,11 +48,11 @@ function onCommand({ id }: GhostCommandPaletteCommandPayload): void {
48
48
  <div>
49
49
  <GhostCommandPalette v-model:search="search" @command="onCommand">
50
50
  <GhostCommandPaletteTrigger>Find a record</GhostCommandPaletteTrigger>
51
- <GhostCommandPaletteOverlay />
52
- <GhostCommandPaletteContent>
51
+ <GhostCommandPaletteOverlay class="command-palette-demo__overlay" />
52
+ <GhostCommandPaletteContent class="command-palette-demo">
53
53
  <GhostCommandPaletteTitle>Find a record</GhostCommandPaletteTitle>
54
54
  <GhostCommandPaletteInput placeholder="Record number" />
55
- <GhostCommandPaletteList style="max-block-size: 16rem; overflow: auto">
55
+ <GhostCommandPaletteList>
56
56
  <GhostCommandPaletteItem
57
57
  v-for="record in mounted"
58
58
  :id="record.id"
@@ -73,3 +73,124 @@ function onCommand({ id }: GhostCommandPaletteCommandPayload): void {
73
73
  </p>
74
74
  </div>
75
75
  </template>
76
+
77
+ <style>
78
+ /*
79
+ * Headless GhostCommandPalette ships behavior only: the overlay and content
80
+ * are portaled to <body> with no position, surface or item states. This
81
+ * consumer CSS is unscoped on purpose, because portaled parts do not carry
82
+ * the component's scoped attribute, and prefixed so it cannot collide with
83
+ * page styles. Parts below the content are reached through `data-part`.
84
+ *
85
+ * Colors read GhostVue semantic tokens when a theme is loaded and fall back
86
+ * to CSS system colors, which follow light and dark on their own. Rows keep
87
+ * fixed geometry: highlight and disabled only change color. The highlight
88
+ * follows `data-highlighted`, because focus stays in the input. Nothing
89
+ * animates, so reduced motion needs no override.
90
+ */
91
+ .command-palette-demo__overlay {
92
+ background-color: rgb(0 0 0 / 45%);
93
+ inset: 0;
94
+ position: fixed;
95
+ z-index: 50;
96
+ }
97
+
98
+ /* Anchored near the top so the input stays put as results change. */
99
+ .command-palette-demo {
100
+ background-color: var(--ghost-elevation-4-bg, Canvas);
101
+ border: 1px solid var(--ghost-elevation-4-border, GrayText);
102
+ border-radius: var(--ghost-radius-lg, 0.5rem);
103
+ box-shadow: var(--ghost-elevation-4-shadow, 0 1rem 2rem rgb(0 0 0 / 25%));
104
+ box-sizing: border-box;
105
+ color: var(--ghost-surface-fg, CanvasText);
106
+ display: grid;
107
+ gap: 0.5rem;
108
+ inline-size: min(calc(100vw - 2rem), 32rem);
109
+ left: 50%;
110
+ max-block-size: calc(100dvh - 2rem);
111
+ overflow: auto;
112
+ padding: 0.75rem;
113
+ position: fixed;
114
+ top: min(12dvh, 8rem);
115
+ transform: translateX(-50%);
116
+ z-index: 50;
117
+ }
118
+
119
+ .command-palette-demo [data-part='title'] {
120
+ border: 0;
121
+ font-size: 0.875rem;
122
+ font-weight: 600;
123
+ letter-spacing: normal;
124
+ line-height: 1.4;
125
+ margin: 0;
126
+ padding: 0;
127
+ }
128
+
129
+ .command-palette-demo [data-part='input'] {
130
+ background-color: var(--ghost-surface-bg, Field);
131
+ border: 1px solid var(--ghost-border-strong, GrayText);
132
+ border-radius: var(--ghost-radius-md, 0.375rem);
133
+ box-sizing: border-box;
134
+ color: var(--ghost-text-default, FieldText);
135
+ font: inherit;
136
+ inline-size: 100%;
137
+ padding: 0.5rem 0.75rem;
138
+ }
139
+
140
+ .command-palette-demo [data-part='input']:focus-visible {
141
+ outline: 2px solid var(--ghost-focus-ring-color, Highlight);
142
+ outline-offset: 2px;
143
+ }
144
+
145
+ .command-palette-demo [data-part='list'] {
146
+ max-block-size: min(50dvh, 18rem);
147
+ overflow: auto;
148
+ }
149
+
150
+ .command-palette-demo [data-part='label'] {
151
+ color: var(--ghost-text-muted, GrayText);
152
+ font-size: 0.75rem;
153
+ font-weight: 600;
154
+ padding: 0.25rem 0.75rem;
155
+ }
156
+
157
+ .command-palette-demo [data-part='separator'] {
158
+ border-block-start: 1px solid var(--ghost-border-default, GrayText);
159
+ margin-block: 0.25rem;
160
+ }
161
+
162
+ .command-palette-demo [role='option'] {
163
+ border-radius: var(--ghost-radius-sm, 0.25rem);
164
+ cursor: default;
165
+ /* A transparent outline turns into a visible ring under forced colors. */
166
+ outline: 2px solid transparent;
167
+ outline-offset: -2px;
168
+ padding: 0.375rem 0.75rem;
169
+ }
170
+
171
+ .command-palette-demo [role='option'][data-highlighted] {
172
+ background-color: var(--ghost-action-primary-bg, Highlight);
173
+ color: var(--ghost-action-primary-fg, HighlightText);
174
+ }
175
+
176
+ .command-palette-demo [role='option'][aria-disabled='true'] {
177
+ color: var(--ghost-text-muted, GrayText);
178
+ cursor: not-allowed;
179
+ }
180
+
181
+ .command-palette-demo [data-part='empty'],
182
+ .command-palette-demo > p {
183
+ color: var(--ghost-text-muted, GrayText);
184
+ font-size: 0.875rem;
185
+ margin: 0;
186
+ padding: 0.375rem 0.75rem;
187
+ }
188
+
189
+ @media (forced-colors: active) {
190
+ .command-palette-demo [role='option'][data-highlighted] {
191
+ background-color: Highlight;
192
+ color: HighlightText;
193
+ forced-color-adjust: none;
194
+ }
195
+ }
196
+ </style>
@@ -13,6 +13,9 @@ import {
13
13
  GhostContextMenuRadioItem,
14
14
  GhostContextMenuSeparator,
15
15
  GhostContextMenuTrigger,
16
+ GhostSubmenu,
17
+ GhostSubmenuContent,
18
+ GhostSubmenuTrigger,
16
19
  } from '@ghostvue/themes'
17
20
 
18
21
  interface ProjectFile {
@@ -52,12 +55,39 @@ const statusMessage = ref(
52
55
  'Right-click any file row or press Shift+F10 for actions.',
53
56
  )
54
57
 
55
- function openFile(file: ProjectFile): void {
56
- statusMessage.value = `Opened "${file.name}".`
58
+ function openFile(file: ProjectFile, app: string): void {
59
+ statusMessage.value = `Opened "${file.name}" in ${app}.`
57
60
  }
58
61
 
62
+ // Name the copy after its source ("Token audit copy.csv", then "copy 2"),
63
+ // skipping names already in the list so every row stays distinct.
64
+ function copyName(name: string): string {
65
+ const dot = name.lastIndexOf('.')
66
+ const base = dot > 0 ? name.slice(0, dot) : name
67
+ const extension = dot > 0 ? name.slice(dot) : ''
68
+ const taken = new Set(files.value.map((file) => file.name))
69
+ let candidate = `${base} copy${extension}`
70
+ for (let count = 2; taken.has(candidate); count += 1) {
71
+ candidate = `${base} copy ${String(count)}${extension}`
72
+ }
73
+ return candidate
74
+ }
75
+
76
+ let copies = 0
77
+
78
+ // The copy lands right below its source. Focus still returns to the row that
79
+ // opened the menu, so the next Shift+F10 acts on the same file.
59
80
  function duplicateFile(file: ProjectFile): void {
60
- statusMessage.value = `Duplicated "${file.name}".`
81
+ copies += 1
82
+ const copy: ProjectFile = {
83
+ ...file,
84
+ id: `${file.id}-copy-${String(copies)}`,
85
+ name: copyName(file.name),
86
+ updated: 'Updated just now',
87
+ pinned: false,
88
+ }
89
+ files.value.splice(files.value.indexOf(file) + 1, 0, copy)
90
+ statusMessage.value = `Duplicated "${file.name}" as "${copy.name}".`
61
91
  }
62
92
 
63
93
  function setPinned(file: ProjectFile, pinned: boolean): void {
@@ -105,13 +135,23 @@ function setDensity(value: string): void {
105
135
  </span>
106
136
  </GhostContextMenuTrigger>
107
137
 
108
- <GhostContextMenuContent data-testid="context-themed-content">
138
+ <GhostContextMenuContent
139
+ :aria-label="`Actions for ${file.name}`"
140
+ data-testid="context-themed-content"
141
+ >
109
142
  <GhostContextMenuLabel>{{ file.name }}</GhostContextMenuLabel>
110
143
  <GhostContextMenuSeparator decorative />
111
- <GhostContextMenuItem @select="openFile(file)">
112
- <span class="context-menu__indicator" aria-hidden="true" />
113
- Open
114
- </GhostContextMenuItem>
144
+ <GhostSubmenu>
145
+ <GhostSubmenuTrigger>Open with</GhostSubmenuTrigger>
146
+ <GhostSubmenuContent>
147
+ <GhostContextMenuItem @select="openFile(file, 'Preview')">
148
+ Preview
149
+ </GhostContextMenuItem>
150
+ <GhostContextMenuItem @select="openFile(file, 'Editor')">
151
+ Editor
152
+ </GhostContextMenuItem>
153
+ </GhostSubmenuContent>
154
+ </GhostSubmenu>
115
155
  <GhostContextMenuItem @select="duplicateFile(file)">
116
156
  <span class="context-menu__indicator" aria-hidden="true" />
117
157
  Duplicate
@@ -127,24 +167,39 @@ function setDensity(value: string): void {
127
167
  Pin to top
128
168
  </GhostContextMenuCheckboxItem>
129
169
  <GhostContextMenuSeparator decorative />
130
- <GhostContextMenuLabel>Row density</GhostContextMenuLabel>
131
- <GhostContextMenuRadioGroup
132
- :model-value="density"
133
- @update:model-value="setDensity"
134
- >
135
- <GhostContextMenuRadioItem value="compact">
136
- <span class="context-menu__indicator" aria-hidden="true">
137
- {{ density === 'compact' ? '●' : '' }}
138
- </span>
139
- Compact
140
- </GhostContextMenuRadioItem>
141
- <GhostContextMenuRadioItem value="comfortable">
142
- <span class="context-menu__indicator" aria-hidden="true">
143
- {{ density === 'comfortable' ? '●' : '' }}
144
- </span>
145
- Comfortable
146
- </GhostContextMenuRadioItem>
147
- </GhostContextMenuRadioGroup>
170
+ <GhostSubmenu>
171
+ <GhostSubmenuTrigger>View</GhostSubmenuTrigger>
172
+ <GhostSubmenuContent portal>
173
+ <GhostSubmenu>
174
+ <GhostSubmenuTrigger>Row density</GhostSubmenuTrigger>
175
+ <GhostSubmenuContent>
176
+ <GhostContextMenuRadioGroup
177
+ :model-value="density"
178
+ @update:model-value="setDensity"
179
+ >
180
+ <GhostContextMenuRadioItem value="compact">
181
+ <span
182
+ class="context-menu__indicator"
183
+ aria-hidden="true"
184
+ >
185
+ {{ density === 'compact' ? '●' : '' }}
186
+ </span>
187
+ Compact
188
+ </GhostContextMenuRadioItem>
189
+ <GhostContextMenuRadioItem value="comfortable">
190
+ <span
191
+ class="context-menu__indicator"
192
+ aria-hidden="true"
193
+ >
194
+ {{ density === 'comfortable' ? '●' : '' }}
195
+ </span>
196
+ Comfortable
197
+ </GhostContextMenuRadioItem>
198
+ </GhostContextMenuRadioGroup>
199
+ </GhostSubmenuContent>
200
+ </GhostSubmenu>
201
+ </GhostSubmenuContent>
202
+ </GhostSubmenu>
148
203
  </GhostContextMenuContent>
149
204
  </GhostContextMenu>
150
205
  </li>