@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
@@ -0,0 +1,356 @@
1
+ <script setup lang="ts">
2
+ import { nextTick, ref } from 'vue'
3
+
4
+ import {
5
+ GhostButton,
6
+ GhostCard,
7
+ GhostField,
8
+ GhostFieldControl,
9
+ GhostFieldDescription,
10
+ GhostFieldError,
11
+ GhostFieldLabel,
12
+ GhostSelect,
13
+ GhostSelectContent,
14
+ GhostSelectOption,
15
+ GhostSelectTrigger,
16
+ GhostSelectValue,
17
+ } from '@ghostvue/themes'
18
+
19
+ // Deterministic local data: option values are what the form submits.
20
+ const severities = [
21
+ { value: 'critical', label: 'Critical only' },
22
+ { value: 'high', label: 'High and above' },
23
+ { value: 'all', label: 'Every alert' },
24
+ ] as const
25
+
26
+ const channels = [
27
+ { value: 'pager', label: 'Page the on-call phone' },
28
+ { value: 'slack', label: 'Post to #incidents' },
29
+ { value: 'email', label: 'Email the team list' },
30
+ ] as const
31
+
32
+ const owners = [
33
+ { value: 'platform', label: 'Platform on-call' },
34
+ { value: 'payments', label: 'Payments on-call' },
35
+ { value: 'support', label: 'Support leads' },
36
+ ] as const
37
+
38
+ const labels: Record<string, string> = Object.fromEntries(
39
+ [...severities, ...channels, ...owners].map((option) => [
40
+ option.value,
41
+ option.label,
42
+ ]),
43
+ )
44
+
45
+ interface SubmittedEntry {
46
+ name: string
47
+ value: string
48
+ }
49
+
50
+ const ownerMissing = ref(false)
51
+ const submitted = ref<SubmittedEntry[]>([])
52
+ const status = ref('')
53
+
54
+ /*
55
+ * `novalidate` turns off the browser's bubbles, but `checkValidity()` still
56
+ * runs native constraint validation. The required Select's hidden input
57
+ * fails it, fires `invalid`, and the trigger gets `aria-invalid` on its own;
58
+ * the field error and focus move are this form's choices.
59
+ */
60
+ async function save(event: SubmitEvent): Promise<void> {
61
+ // Read before awaiting: currentTarget is cleared once dispatch ends.
62
+ const form = event.currentTarget
63
+ if (!(form instanceof HTMLFormElement)) return
64
+ if (!form.checkValidity()) {
65
+ ownerMissing.value = true
66
+ submitted.value = []
67
+ status.value = ''
68
+ // Wait for aria-invalid to render, then focus the control to fix.
69
+ await nextTick()
70
+ form.querySelector<HTMLElement>('[aria-invalid="true"]')?.focus()
71
+ return
72
+ }
73
+ // Exactly what a native submit would send: one entry per named Select.
74
+ submitted.value = [...new FormData(form)].map(([name, value]) => ({
75
+ name,
76
+ value: typeof value === 'string' ? value : value.name,
77
+ }))
78
+ status.value = 'Alert routing saved.'
79
+ }
80
+
81
+ // Native reset restores each Select's `default-value`; clear our own state.
82
+ function onReset(): void {
83
+ ownerMissing.value = false
84
+ submitted.value = []
85
+ status.value = 'Form reset to the saved defaults.'
86
+ }
87
+
88
+ function onOwnerChange(): void {
89
+ ownerMissing.value = false
90
+ }
91
+ </script>
92
+
93
+ <template>
94
+ <form class="routing" novalidate @submit.prevent="save" @reset="onReset">
95
+ <GhostCard as="section" aria-labelledby="routing-title">
96
+ <template #header>
97
+ <div class="routing__header">
98
+ <h2 id="routing-title" class="routing__title">Alert routing</h2>
99
+ <p class="routing__lead">
100
+ Decide who hears about checkout-service incidents.
101
+ </p>
102
+ </div>
103
+ </template>
104
+
105
+ <div class="routing__fields">
106
+ <GhostField>
107
+ <GhostFieldLabel>Minimum severity</GhostFieldLabel>
108
+ <GhostFieldControl v-slot="field">
109
+ <GhostSelect name="severity" default-value="high">
110
+ <GhostSelectTrigger v-bind="field">
111
+ <GhostSelectValue />
112
+ <svg
113
+ class="routing__chevron"
114
+ viewBox="0 0 16 16"
115
+ aria-hidden="true"
116
+ >
117
+ <path d="m4 6 4 4 4-4" />
118
+ </svg>
119
+ </GhostSelectTrigger>
120
+ <GhostSelectContent :offset="6">
121
+ <GhostSelectOption
122
+ v-for="option in severities"
123
+ :key="option.value"
124
+ :value="option.value"
125
+ >
126
+ {{ option.label }}
127
+ </GhostSelectOption>
128
+ </GhostSelectContent>
129
+ </GhostSelect>
130
+ </GhostFieldControl>
131
+ </GhostField>
132
+
133
+ <GhostField>
134
+ <GhostFieldLabel>Notify by</GhostFieldLabel>
135
+ <GhostFieldControl v-slot="field">
136
+ <GhostSelect name="channel" default-value="slack">
137
+ <GhostSelectTrigger v-bind="field">
138
+ <GhostSelectValue />
139
+ <svg
140
+ class="routing__chevron"
141
+ viewBox="0 0 16 16"
142
+ aria-hidden="true"
143
+ >
144
+ <path d="m4 6 4 4 4-4" />
145
+ </svg>
146
+ </GhostSelectTrigger>
147
+ <GhostSelectContent :offset="6">
148
+ <GhostSelectOption
149
+ v-for="option in channels"
150
+ :key="option.value"
151
+ :value="option.value"
152
+ >
153
+ {{ option.label }}
154
+ </GhostSelectOption>
155
+ </GhostSelectContent>
156
+ </GhostSelect>
157
+ </GhostFieldControl>
158
+ </GhostField>
159
+
160
+ <GhostField required :invalid="ownerMissing">
161
+ <GhostFieldLabel required>Escalation owner</GhostFieldLabel>
162
+ <GhostFieldDescription>
163
+ Paged when an alert is not acknowledged in 15 minutes.
164
+ </GhostFieldDescription>
165
+ <GhostFieldControl v-slot="field">
166
+ <!-- `required` on the root enables native form validation. -->
167
+ <GhostSelect
168
+ name="escalation"
169
+ required
170
+ placeholder="Choose an owner"
171
+ @update:model-value="onOwnerChange"
172
+ >
173
+ <GhostSelectTrigger v-bind="field">
174
+ <GhostSelectValue />
175
+ <svg
176
+ class="routing__chevron"
177
+ viewBox="0 0 16 16"
178
+ aria-hidden="true"
179
+ >
180
+ <path d="m4 6 4 4 4-4" />
181
+ </svg>
182
+ </GhostSelectTrigger>
183
+ <GhostSelectContent :offset="6">
184
+ <GhostSelectOption
185
+ v-for="option in owners"
186
+ :key="option.value"
187
+ :value="option.value"
188
+ >
189
+ {{ option.label }}
190
+ </GhostSelectOption>
191
+ </GhostSelectContent>
192
+ </GhostSelect>
193
+ </GhostFieldControl>
194
+ <GhostFieldError v-if="ownerMissing">
195
+ Choose who gets escalations.
196
+ </GhostFieldError>
197
+ </GhostField>
198
+ </div>
199
+
200
+ <template #footer>
201
+ <div class="routing__footer">
202
+ <p class="routing__status" role="status">{{ status }}</p>
203
+ <div class="routing__actions">
204
+ <GhostButton type="reset" variant="ghost" tone="neutral">
205
+ Reset
206
+ </GhostButton>
207
+ <GhostButton type="submit">Save routing</GhostButton>
208
+ </div>
209
+ </div>
210
+ <section
211
+ v-if="submitted.length > 0"
212
+ class="routing__submitted"
213
+ aria-labelledby="routing-submitted-title"
214
+ >
215
+ <h3 id="routing-submitted-title" class="routing__submitted-title">
216
+ Submitted form data
217
+ </h3>
218
+ <dl class="routing__entries">
219
+ <div
220
+ v-for="entry in submitted"
221
+ :key="entry.name"
222
+ class="routing__entry"
223
+ >
224
+ <dt>
225
+ <code>{{ entry.name }}</code>
226
+ </dt>
227
+ <dd>
228
+ <code>{{ entry.value }}</code>
229
+ <span class="routing__entry-label">
230
+ {{ labels[entry.value] }}
231
+ </span>
232
+ </dd>
233
+ </div>
234
+ </dl>
235
+ </section>
236
+ </template>
237
+ </GhostCard>
238
+ </form>
239
+ </template>
240
+
241
+ <style scoped>
242
+ /* The form keeps a readable measure and shrinks with the preview on phones. */
243
+ .routing {
244
+ max-inline-size: 32rem;
245
+ }
246
+
247
+ .routing__header {
248
+ display: grid;
249
+ gap: var(--ghost-space-gap-xs);
250
+ padding-block-end: var(--ghost-space-stack-sm);
251
+ }
252
+
253
+ /* Native text picks up docs prose styles, so each element resets its own. */
254
+ .routing__title,
255
+ .routing__submitted-title {
256
+ border: 0;
257
+ color: var(--ghost-text-default);
258
+ font-size: var(--ghost-type-size-lg);
259
+ font-weight: var(--ghost-type-weight-semibold);
260
+ line-height: var(--ghost-type-line-tight);
261
+ margin: 0;
262
+ padding: 0;
263
+ }
264
+
265
+ .routing__submitted-title {
266
+ font-size: var(--ghost-type-size-sm);
267
+ }
268
+
269
+ .routing__lead,
270
+ .routing__status {
271
+ color: var(--ghost-text-muted);
272
+ font-size: var(--ghost-type-size-sm);
273
+ line-height: var(--ghost-type-line-snug);
274
+ margin: 0;
275
+ }
276
+
277
+ /* A zero track minimum lets a long selected label truncate in its trigger. */
278
+ .routing__fields {
279
+ display: grid;
280
+ gap: var(--ghost-space-stack-lg);
281
+ grid-template-columns: minmax(0, 1fr);
282
+ }
283
+
284
+ /* Decorative; inherits the trigger color, including the invalid state. */
285
+ .routing__chevron {
286
+ block-size: 1em;
287
+ fill: none;
288
+ inline-size: 1em;
289
+ stroke: currentcolor;
290
+ stroke-linecap: round;
291
+ stroke-linejoin: round;
292
+ stroke-width: 1.5;
293
+ }
294
+
295
+ .routing__footer {
296
+ align-items: center;
297
+ display: flex;
298
+ flex-wrap: wrap;
299
+ gap: var(--ghost-space-gap-sm) var(--ghost-space-gap-md);
300
+ justify-content: flex-end;
301
+ }
302
+
303
+ .routing__status {
304
+ flex: 1 1 10rem;
305
+ }
306
+
307
+ .routing__actions {
308
+ display: flex;
309
+ gap: var(--ghost-space-gap-sm);
310
+ }
311
+
312
+ .routing__submitted {
313
+ border-block-start: var(--ghost-border-hairline-width) solid
314
+ var(--ghost-border-default);
315
+ display: grid;
316
+ gap: var(--ghost-space-gap-sm);
317
+ margin-block-start: var(--ghost-space-stack-md);
318
+ padding-block-start: var(--ghost-space-stack-md);
319
+ }
320
+
321
+ .routing__entries {
322
+ display: grid;
323
+ gap: var(--ghost-space-gap-xs);
324
+ margin: 0;
325
+ }
326
+
327
+ .routing__entry {
328
+ column-gap: var(--ghost-space-gap-md);
329
+ display: grid;
330
+ font-size: var(--ghost-type-size-sm);
331
+ grid-template-columns: minmax(0, 7rem) minmax(0, 1fr);
332
+ line-height: var(--ghost-type-line-snug);
333
+ }
334
+
335
+ .routing__entry dt,
336
+ .routing__entry dd {
337
+ margin: 0;
338
+ min-inline-size: 0;
339
+ overflow-wrap: anywhere;
340
+ }
341
+
342
+ .routing__entry code {
343
+ background: none;
344
+ color: var(--ghost-text-default);
345
+ /* Reset docs inline-code styles; the token set has no mono family. */
346
+ border-radius: 0;
347
+ font: inherit;
348
+ font-weight: var(--ghost-type-weight-medium);
349
+ padding: 0;
350
+ }
351
+
352
+ .routing__entry-label {
353
+ color: var(--ghost-text-muted);
354
+ margin-inline-start: var(--ghost-space-gap-sm);
355
+ }
356
+ </style>
@@ -0,0 +1,201 @@
1
+ <script setup lang="ts">
2
+ import { nextTick, ref } from 'vue'
3
+
4
+ import {
5
+ GhostButton,
6
+ GhostCard,
7
+ GhostField,
8
+ GhostFieldControl,
9
+ GhostFieldDescription,
10
+ GhostFieldError,
11
+ GhostFieldLabel,
12
+ GhostSelect,
13
+ GhostSelectContent,
14
+ GhostSelectOption,
15
+ GhostSelectTrigger,
16
+ GhostSelectValue,
17
+ } from '@ghostvue/themes'
18
+
19
+ const channels = [
20
+ { value: 'email', label: 'Email digest' },
21
+ { value: 'slack', label: 'Slack channel' },
22
+ { value: 'pager', label: 'Pager alert' },
23
+ { value: 'webhook', label: 'Audit webhook' },
24
+ ] as const
25
+
26
+ const defaultChannels = ['email', 'slack'] as const
27
+
28
+ const channelsMissing = ref(false)
29
+ const submittedChannels = ref<string[] | null>(null)
30
+ const status = ref('')
31
+
32
+ async function save(event: SubmitEvent): Promise<void> {
33
+ const form = event.currentTarget
34
+ if (!(form instanceof HTMLFormElement)) return
35
+ if (!form.checkValidity()) {
36
+ channelsMissing.value = true
37
+ submittedChannels.value = null
38
+ status.value = ''
39
+ await nextTick()
40
+ form.querySelector<HTMLElement>('[aria-invalid="true"]')?.focus()
41
+ return
42
+ }
43
+ channelsMissing.value = false
44
+ submittedChannels.value = new FormData(form)
45
+ .getAll('channels')
46
+ .map((entry) => (typeof entry === 'string' ? entry : entry.name))
47
+ status.value = 'Notification rules saved.'
48
+ }
49
+
50
+ function onReset(): void {
51
+ channelsMissing.value = false
52
+ submittedChannels.value = null
53
+ status.value = 'Restored default channels.'
54
+ }
55
+
56
+ function onChannelsChange(next: string[]): void {
57
+ if (next.length > 0) {
58
+ channelsMissing.value = false
59
+ }
60
+ }
61
+ </script>
62
+
63
+ <template>
64
+ <form class="multi-form" novalidate @submit.prevent="save" @reset="onReset">
65
+ <GhostCard as="section" aria-labelledby="multi-form-title">
66
+ <template #header>
67
+ <div class="multi-form__header">
68
+ <h2 id="multi-form-title" class="multi-form__title">
69
+ Notification channels
70
+ </h2>
71
+ <p class="multi-form__lead">
72
+ Multiple values submit as repeated FormData entries and restore on
73
+ reset.
74
+ </p>
75
+ </div>
76
+ </template>
77
+
78
+ <GhostField required :invalid="channelsMissing">
79
+ <GhostFieldLabel required>Delivery channels</GhostFieldLabel>
80
+ <GhostFieldDescription>
81
+ Choose at least one channel before saving.
82
+ </GhostFieldDescription>
83
+ <GhostFieldControl v-slot="field">
84
+ <GhostSelect
85
+ multiple
86
+ name="channels"
87
+ required
88
+ :default-value="defaultChannels"
89
+ placeholder="Choose channels"
90
+ @update:model-value="onChannelsChange"
91
+ >
92
+ <GhostSelectTrigger v-bind="field">
93
+ <GhostSelectValue />
94
+ <svg
95
+ class="multi-form__chevron"
96
+ viewBox="0 0 16 16"
97
+ aria-hidden="true"
98
+ >
99
+ <path d="m4 6 4 4 4-4" />
100
+ </svg>
101
+ </GhostSelectTrigger>
102
+ <GhostSelectContent :offset="6">
103
+ <GhostSelectOption
104
+ v-for="option in channels"
105
+ :key="option.value"
106
+ :value="option.value"
107
+ >
108
+ {{ option.label }}
109
+ </GhostSelectOption>
110
+ </GhostSelectContent>
111
+ </GhostSelect>
112
+ </GhostFieldControl>
113
+ <GhostFieldError v-if="channelsMissing">
114
+ Select at least one delivery channel.
115
+ </GhostFieldError>
116
+ </GhostField>
117
+
118
+ <template #footer>
119
+ <div class="multi-form__footer">
120
+ <p class="multi-form__status" role="status">{{ status }}</p>
121
+ <div class="multi-form__actions">
122
+ <GhostButton type="reset" variant="ghost" tone="neutral">
123
+ Reset
124
+ </GhostButton>
125
+ <GhostButton type="submit">Save channels</GhostButton>
126
+ </div>
127
+ </div>
128
+ <p v-if="submittedChannels !== null" class="multi-form__output">
129
+ <code>FormData.getAll('channels')</code>:
130
+ <code>{{ JSON.stringify(submittedChannels) }}</code>
131
+ </p>
132
+ </template>
133
+ </GhostCard>
134
+ </form>
135
+ </template>
136
+
137
+ <style scoped>
138
+ .multi-form {
139
+ max-inline-size: 30rem;
140
+ }
141
+
142
+ .multi-form__header {
143
+ display: grid;
144
+ gap: var(--ghost-space-gap-xs);
145
+ padding-block-end: var(--ghost-space-stack-sm);
146
+ }
147
+
148
+ .multi-form__title {
149
+ border: 0;
150
+ color: var(--ghost-text-default);
151
+ font-size: var(--ghost-type-size-lg);
152
+ font-weight: var(--ghost-type-weight-semibold);
153
+ line-height: var(--ghost-type-line-tight);
154
+ margin: 0;
155
+ padding: 0;
156
+ }
157
+
158
+ .multi-form__lead,
159
+ .multi-form__status,
160
+ .multi-form__output {
161
+ color: var(--ghost-text-muted);
162
+ font-size: var(--ghost-type-size-sm);
163
+ line-height: var(--ghost-type-line-snug);
164
+ margin: 0;
165
+ }
166
+
167
+ .multi-form__chevron {
168
+ block-size: 1em;
169
+ fill: none;
170
+ inline-size: 1em;
171
+ stroke: currentcolor;
172
+ stroke-linecap: round;
173
+ stroke-linejoin: round;
174
+ stroke-width: 1.5;
175
+ }
176
+
177
+ .multi-form__footer {
178
+ align-items: center;
179
+ display: flex;
180
+ flex-wrap: wrap;
181
+ gap: var(--ghost-space-gap-sm) var(--ghost-space-gap-md);
182
+ justify-content: flex-end;
183
+ }
184
+
185
+ .multi-form__status {
186
+ flex: 1 1 10rem;
187
+ }
188
+
189
+ .multi-form__actions {
190
+ display: flex;
191
+ gap: var(--ghost-space-gap-sm);
192
+ }
193
+
194
+ .multi-form__output {
195
+ border-block-start: var(--ghost-border-hairline-width) solid
196
+ var(--ghost-border-default);
197
+ color: var(--ghost-text-default);
198
+ margin-block-start: var(--ghost-space-stack-md);
199
+ padding-block-start: var(--ghost-space-stack-md);
200
+ }
201
+ </style>
@@ -0,0 +1,142 @@
1
+ <script setup lang="ts">
2
+ import { ref } from 'vue'
3
+
4
+ import {
5
+ GhostBadge,
6
+ GhostField,
7
+ GhostFieldControl,
8
+ GhostFieldDescription,
9
+ GhostFieldLabel,
10
+ GhostSelect,
11
+ GhostSelectContent,
12
+ GhostSelectOption,
13
+ GhostSelectTrigger,
14
+ GhostSelectValue,
15
+ } from '@ghostvue/themes'
16
+
17
+ const labelOptions = [
18
+ { value: 'bug', label: 'Bug' },
19
+ { value: 'docs', label: 'Documentation' },
20
+ { value: 'a11y', label: 'Accessibility' },
21
+ { value: 'perf', label: 'Performance' },
22
+ { value: 'triage', label: 'Needs triage' },
23
+ ] as const
24
+
25
+ const labelNames = Object.fromEntries(
26
+ labelOptions.map((option) => [option.value, option.label]),
27
+ ) as Record<string, string>
28
+
29
+ const issueLabels = ref<string[]>(['bug', 'a11y'])
30
+ const summaryLabels = ref<string[]>(['docs', 'perf', 'triage'])
31
+ </script>
32
+
33
+ <template>
34
+ <div class="multi-labels">
35
+ <GhostField>
36
+ <GhostFieldLabel>Issue labels</GhostFieldLabel>
37
+ <GhostFieldDescription>
38
+ Space or Enter toggles an option and keeps the list open.
39
+ </GhostFieldDescription>
40
+ <GhostFieldControl v-slot="field">
41
+ <GhostSelect v-model="issueLabels" multiple placeholder="Add labels">
42
+ <GhostSelectTrigger v-bind="field">
43
+ <GhostSelectValue />
44
+ <svg
45
+ class="multi-labels__chevron"
46
+ viewBox="0 0 16 16"
47
+ aria-hidden="true"
48
+ >
49
+ <path d="m4 6 4 4 4-4" />
50
+ </svg>
51
+ </GhostSelectTrigger>
52
+ <GhostSelectContent :offset="6">
53
+ <GhostSelectOption
54
+ v-for="option in labelOptions"
55
+ :key="option.value"
56
+ :value="option.value"
57
+ >
58
+ {{ option.label }}
59
+ </GhostSelectOption>
60
+ </GhostSelectContent>
61
+ </GhostSelect>
62
+ </GhostFieldControl>
63
+ </GhostField>
64
+
65
+ <GhostField>
66
+ <GhostFieldLabel>Custom summary slot</GhostFieldLabel>
67
+ <GhostFieldDescription>
68
+ Scoped slot props expose selected values and labels in selection order.
69
+ </GhostFieldDescription>
70
+ <GhostFieldControl v-slot="field">
71
+ <GhostSelect
72
+ v-model="summaryLabels"
73
+ multiple
74
+ placeholder="Pick categories"
75
+ >
76
+ <GhostSelectTrigger v-bind="field">
77
+ <GhostSelectValue>
78
+ <template #default="{ values, labels }">
79
+ {{
80
+ values.length === 1
81
+ ? labels[0]
82
+ : `${String(values.length)} labels selected`
83
+ }}
84
+ </template>
85
+ </GhostSelectValue>
86
+ <svg
87
+ class="multi-labels__chevron"
88
+ viewBox="0 0 16 16"
89
+ aria-hidden="true"
90
+ >
91
+ <path d="m4 6 4 4 4-4" />
92
+ </svg>
93
+ </GhostSelectTrigger>
94
+ <GhostSelectContent :offset="6">
95
+ <GhostSelectOption
96
+ v-for="option in labelOptions"
97
+ :key="option.value"
98
+ :value="option.value"
99
+ >
100
+ {{ option.label }}
101
+ </GhostSelectOption>
102
+ </GhostSelectContent>
103
+ </GhostSelect>
104
+ </GhostFieldControl>
105
+ </GhostField>
106
+
107
+ <div
108
+ v-if="summaryLabels.length > 0"
109
+ class="multi-labels__selected"
110
+ aria-label="Selected categories"
111
+ >
112
+ <GhostBadge v-for="value in summaryLabels" :key="value" tone="neutral">
113
+ {{ labelNames[value] ?? value }}
114
+ </GhostBadge>
115
+ </div>
116
+ </div>
117
+ </template>
118
+
119
+ <style scoped>
120
+ .multi-labels {
121
+ display: grid;
122
+ gap: var(--ghost-space-stack-lg);
123
+ grid-template-columns: minmax(0, 1fr);
124
+ max-inline-size: 28rem;
125
+ }
126
+
127
+ .multi-labels__chevron {
128
+ block-size: 1em;
129
+ fill: none;
130
+ inline-size: 1em;
131
+ stroke: currentcolor;
132
+ stroke-linecap: round;
133
+ stroke-linejoin: round;
134
+ stroke-width: 1.5;
135
+ }
136
+
137
+ .multi-labels__selected {
138
+ display: flex;
139
+ flex-wrap: wrap;
140
+ gap: var(--ghost-space-gap-xs);
141
+ }
142
+ </style>