@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,56 @@
1
+ <script setup lang="ts">
2
+ import { ref } from 'vue'
3
+
4
+ import {
5
+ GhostButton,
6
+ GhostDropdownMenu,
7
+ GhostDropdownMenuCheckboxItem,
8
+ GhostDropdownMenuContent,
9
+ GhostDropdownMenuItem,
10
+ GhostDropdownMenuTrigger,
11
+ GhostSubmenu,
12
+ GhostSubmenuContent,
13
+ GhostSubmenuTrigger,
14
+ } from '@ghostvue/themes'
15
+
16
+ const includeNotes = ref(false)
17
+ const message = ref('Choose a format to export this report.')
18
+
19
+ function exportReport(format: string): void {
20
+ message.value = `Prepared ${format}${includeNotes.value ? ' with notes' : ''}.`
21
+ }
22
+ </script>
23
+
24
+ <template>
25
+ <div>
26
+ <GhostDropdownMenu>
27
+ <GhostDropdownMenuTrigger
28
+ :as="GhostButton"
29
+ variant="outline"
30
+ tone="neutral"
31
+ >
32
+ Report actions
33
+ </GhostDropdownMenuTrigger>
34
+ <GhostDropdownMenuContent aria-label="Report actions">
35
+ <GhostDropdownMenuItem @select="message = 'Report copied.'">
36
+ Copy report
37
+ </GhostDropdownMenuItem>
38
+ <GhostSubmenu>
39
+ <GhostSubmenuTrigger>Export</GhostSubmenuTrigger>
40
+ <GhostSubmenuContent portal>
41
+ <GhostDropdownMenuCheckboxItem v-model:checked="includeNotes">
42
+ Include notes
43
+ </GhostDropdownMenuCheckboxItem>
44
+ <GhostDropdownMenuItem @select="exportReport('PDF')">
45
+ PDF
46
+ </GhostDropdownMenuItem>
47
+ <GhostDropdownMenuItem @select="exportReport('CSV')">
48
+ CSV
49
+ </GhostDropdownMenuItem>
50
+ </GhostSubmenuContent>
51
+ </GhostSubmenu>
52
+ </GhostDropdownMenuContent>
53
+ </GhostDropdownMenu>
54
+ <p role="status">{{ message }}</p>
55
+ </div>
56
+ </template>
@@ -1,11 +1,12 @@
1
1
  <script setup lang="ts">
2
- import { computed, ref } from 'vue'
2
+ import { computed, ref, useTemplateRef } from 'vue'
3
3
 
4
4
  import {
5
5
  GhostButton,
6
6
  GhostCard,
7
7
  GhostEmptyState,
8
8
  GhostInput,
9
+ type GhostInputExposed,
9
10
  } from '@ghostvue/themes'
10
11
 
11
12
  const query = ref('canary-eu')
@@ -22,8 +23,22 @@ const matches = computed(() => {
22
23
  return deployments.filter((item) => item.includes(normalized))
23
24
  })
24
25
 
26
+ // The empty state is static copy, so the count below is the live result: it
27
+ // stays mounted and its text changes in place as the filter narrows or clears.
28
+ const resultText = computed(() => {
29
+ const total = deployments.length
30
+ const count = matches.value.length
31
+ if (!query.value.trim()) return `Showing all ${String(total)} environments`
32
+ return `${String(count)} of ${String(total)} environments match`
33
+ })
34
+
35
+ const filterInput = useTemplateRef<GhostInputExposed>('filterInput')
36
+
25
37
  function clearSearch(): void {
26
38
  query.value = ''
39
+ // Both clear buttons unmount once the filter is empty. Return focus to the
40
+ // filter so keyboard users keep their place and can type a new query.
41
+ filterInput.value?.focus()
27
42
  }
28
43
  </script>
29
44
 
@@ -33,6 +48,7 @@ function clearSearch(): void {
33
48
  <template #header>
34
49
  <div class="empty-showcase__toolbar">
35
50
  <GhostInput
51
+ ref="filterInput"
36
52
  v-model="query"
37
53
  aria-label="Filter deployments"
38
54
  placeholder="Filter deployments"
@@ -51,6 +67,8 @@ function clearSearch(): void {
51
67
  </div>
52
68
  </template>
53
69
 
70
+ <p class="empty-showcase__count" role="status">{{ resultText }}</p>
71
+
54
72
  <ul v-if="matches.length > 0" class="empty-showcase__list">
55
73
  <li v-for="item in matches" :key="item" class="empty-showcase__item">
56
74
  {{ item }}
@@ -107,6 +125,13 @@ function clearSearch(): void {
107
125
  flex: 1 1 12rem;
108
126
  }
109
127
 
128
+ .empty-showcase__count {
129
+ color: var(--ghost-text-muted);
130
+ font-size: var(--ghost-type-size-xs);
131
+ line-height: var(--ghost-type-line-normal);
132
+ margin: 0 0 var(--ghost-space-stack-sm);
133
+ }
134
+
110
135
  .empty-showcase__list {
111
136
  display: grid;
112
137
  gap: var(--ghost-space-gap-xs);
@@ -0,0 +1,93 @@
1
+ <script setup lang="ts">
2
+ import { useId } from 'vue'
3
+
4
+ import {
5
+ GhostField,
6
+ GhostFieldControl,
7
+ GhostFieldDescription,
8
+ GhostFieldLabel,
9
+ GhostInput,
10
+ } from '@ghostvue/vue'
11
+
12
+ // Each copy of the recipe references its own hint, including during hydration.
13
+ const hintId = useId()
14
+ </script>
15
+
16
+ <template>
17
+ <form class="address" @submit.prevent>
18
+ <fieldset class="address__group" :aria-describedby="hintId">
19
+ <legend class="address__legend">Shipping address</legend>
20
+ <p :id="hintId" class="address__hint">Deliveries go to this address.</p>
21
+
22
+ <GhostField class="address__field">
23
+ <GhostFieldLabel>Street address</GhostFieldLabel>
24
+ <GhostFieldDescription class="address__hint">
25
+ Include your apartment number.
26
+ </GhostFieldDescription>
27
+ <GhostFieldControl v-slot="field">
28
+ <GhostInput
29
+ v-bind="field"
30
+ name="shipping-street"
31
+ autocomplete="shipping address-line1"
32
+ default-value="200 Lake Ave"
33
+ class="address__input"
34
+ />
35
+ </GhostFieldControl>
36
+ </GhostField>
37
+
38
+ <GhostField class="address__field">
39
+ <GhostFieldLabel>City</GhostFieldLabel>
40
+ <GhostFieldControl v-slot="field">
41
+ <GhostInput
42
+ v-bind="field"
43
+ name="shipping-city"
44
+ autocomplete="shipping address-level2"
45
+ default-value="Duluth"
46
+ class="address__input"
47
+ />
48
+ </GhostFieldControl>
49
+ </GhostField>
50
+ </fieldset>
51
+ </form>
52
+ </template>
53
+
54
+ <style scoped>
55
+ .address {
56
+ max-inline-size: 24rem;
57
+ }
58
+
59
+ .address__group {
60
+ /* currentColor keeps the frame readable in light and dark hosts. */
61
+ border: 1px solid color-mix(in srgb, currentColor 35%, transparent);
62
+ border-radius: 0.5rem;
63
+ display: grid;
64
+ gap: 0.75rem;
65
+ margin: 0;
66
+ min-inline-size: 0;
67
+ padding: 0.75rem 1rem 1rem;
68
+ }
69
+
70
+ .address__legend {
71
+ font-weight: 600;
72
+ padding-inline: 0.25rem;
73
+ }
74
+
75
+ .address__field {
76
+ display: grid;
77
+ gap: 0.25rem;
78
+ }
79
+
80
+ .address__hint {
81
+ font-size: 0.875rem;
82
+ margin: 0;
83
+ }
84
+
85
+ .address__input {
86
+ background: transparent;
87
+ border: 1px solid color-mix(in srgb, currentColor 60%, transparent);
88
+ color: inherit;
89
+ border-radius: 0.375rem;
90
+ font: inherit;
91
+ padding: 0.375rem 0.5rem;
92
+ }
93
+ </style>
@@ -0,0 +1,192 @@
1
+ <script setup lang="ts">
2
+ import { computed, ref, useId } from 'vue'
3
+
4
+ import {
5
+ GhostButton,
6
+ GhostField,
7
+ GhostFieldControl,
8
+ GhostFieldError,
9
+ GhostFieldLabel,
10
+ GhostInput,
11
+ GhostRadioGroup,
12
+ GhostRadioGroupItem,
13
+ } from '@ghostvue/themes'
14
+
15
+ const props = withDefaults(
16
+ defineProps<{
17
+ id?: string | undefined
18
+ legend?: string | undefined
19
+ labelledBy?: string | undefined
20
+ describedBy?: string | undefined
21
+ hintId?: string | undefined
22
+ errorId?: string | undefined
23
+ cityId?: string | undefined
24
+ initialGroupError?: boolean
25
+ }>(),
26
+ {
27
+ legend: 'Billing address',
28
+ id: undefined,
29
+ labelledBy: undefined,
30
+ describedBy: undefined,
31
+ hintId: undefined,
32
+ errorId: undefined,
33
+ cityId: undefined,
34
+ },
35
+ )
36
+ const instanceId = useId()
37
+ const base = computed(() => props.id ?? instanceId)
38
+ const hint = computed(() => props.hintId ?? `${base.value}-hint`)
39
+ const error = computed(() => props.errorId ?? `${base.value}-error`)
40
+ const disabled = ref(false)
41
+ const groupError = ref(props.initialGroupError)
42
+ const cityError = ref(false)
43
+ const submitted = ref<string>()
44
+ const description = computed(() => {
45
+ const ids = (props.describedBy ?? '')
46
+ .split(/\s+/)
47
+ .filter((id) => id && (groupError.value || id !== error.value))
48
+ return [
49
+ ...new Set([
50
+ ...ids,
51
+ hint.value,
52
+ ...(groupError.value ? [error.value] : []),
53
+ ]),
54
+ ].join(' ')
55
+ })
56
+
57
+ const savedCadence = ref('')
58
+ function saveCadence(event: SubmitEvent) {
59
+ if (!(event.currentTarget instanceof HTMLFormElement)) return
60
+ const cadence = new FormData(event.currentTarget).get('cadence')
61
+ if (typeof cadence === 'string') savedCadence.value = cadence
62
+ }
63
+
64
+ function save(event: SubmitEvent) {
65
+ if (!(event.currentTarget instanceof HTMLFormElement)) return
66
+ const entries = Array.from(
67
+ new FormData(event.currentTarget),
68
+ ([name, value]) =>
69
+ `${name}=${typeof value === 'string' ? value : value.name}`,
70
+ )
71
+ submitted.value = entries.join(', ') || 'No address fields submitted.'
72
+ }
73
+ </script>
74
+
75
+ <template>
76
+ <div class="address-recipe">
77
+ <form @submit.prevent="save">
78
+ <fieldset
79
+ :id="base"
80
+ :disabled="disabled"
81
+ :aria-labelledby="labelledBy"
82
+ :aria-describedby="description"
83
+ :aria-invalid="groupError || undefined"
84
+ >
85
+ <legend>{{ legend }}</legend>
86
+ <p :id="hint">Use the address on your invoice.</p>
87
+ <p v-if="groupError" :id="error">Check the street and city together.</p>
88
+ <GhostField>
89
+ <GhostFieldLabel>Street address</GhostFieldLabel>
90
+ <p :id="`${base}-street-hint`">Include your apartment number.</p>
91
+ <GhostFieldControl v-slot="field">
92
+ <GhostInput
93
+ v-bind="field"
94
+ :aria-describedby="`${base}-street-hint`"
95
+ name="street"
96
+ autocomplete="billing address-line1"
97
+ default-value="14 Oak St"
98
+ />
99
+ </GhostFieldControl>
100
+ </GhostField>
101
+ <GhostField :id="cityId ?? `${base}-city`" :invalid="cityError">
102
+ <GhostFieldLabel>City</GhostFieldLabel>
103
+ <p :id="`${base}-city-hint`">Use the postal city name.</p>
104
+ <GhostFieldControl v-slot="field">
105
+ <GhostInput
106
+ v-bind="field"
107
+ :aria-describedby="
108
+ cityError
109
+ ? `${base}-city-hint ${base}-city-error`
110
+ : `${base}-city-hint`
111
+ "
112
+ name="city"
113
+ autocomplete="billing address-level2"
114
+ default-value="Madison"
115
+ />
116
+ </GhostFieldControl>
117
+ <GhostFieldError v-if="cityError" :id="`${base}-city-error`"
118
+ >Check the city on your invoice.</GhostFieldError
119
+ >
120
+ </GhostField>
121
+ </fieldset>
122
+ <GhostButton type="submit">Save address</GhostButton>
123
+ <output aria-label="Submitted entries">{{ submitted }}</output>
124
+ </form>
125
+ <details>
126
+ <summary>Example settings</summary>
127
+ <label
128
+ ><input v-model="disabled" type="checkbox" /> Disable address
129
+ fields</label
130
+ >
131
+ <label
132
+ ><input v-model="groupError" type="checkbox" /> Show group error</label
133
+ >
134
+ <label
135
+ ><input v-model="cityError" type="checkbox" /> Show city error</label
136
+ >
137
+ </details>
138
+ <details>
139
+ <summary>Group a single radio question</summary>
140
+ <form @submit.prevent="saveCadence">
141
+ <GhostRadioGroup as="fieldset" name="cadence" default-value="annual">
142
+ <legend>Billing cadence</legend>
143
+ <label><GhostRadioGroupItem value="monthly" /> Monthly</label>
144
+ <label><GhostRadioGroupItem value="annual" /> Annual</label>
145
+ </GhostRadioGroup>
146
+ <GhostButton type="submit">Save cadence</GhostButton>
147
+ <output aria-label="Submitted cadence">{{ savedCadence }}</output>
148
+ </form>
149
+ </details>
150
+ </div>
151
+ </template>
152
+
153
+ <style scoped>
154
+ .address-recipe {
155
+ max-inline-size: 34rem;
156
+ min-inline-size: 0;
157
+ overflow-wrap: anywhere;
158
+ }
159
+ form,
160
+ fieldset {
161
+ display: grid;
162
+ gap: var(--ghost-space-gap-sm);
163
+ }
164
+ form {
165
+ justify-items: start;
166
+ }
167
+ fieldset {
168
+ box-sizing: border-box;
169
+ grid-template-columns: minmax(0, 1fr);
170
+ inline-size: 100%;
171
+ margin-inline: 0;
172
+ min-inline-size: 0;
173
+ border: var(--ghost-border-hairline-width) solid var(--ghost-border-default);
174
+ border-radius: var(--ghost-radius-md);
175
+ padding: var(--ghost-space-inset-md);
176
+ }
177
+ legend {
178
+ max-inline-size: 100%;
179
+ font-weight: var(--ghost-type-weight-semibold);
180
+ }
181
+ p {
182
+ margin: 0;
183
+ }
184
+ details {
185
+ margin-block-start: var(--ghost-space-gap-sm);
186
+ }
187
+ details[open] label {
188
+ display: flex;
189
+ align-items: baseline;
190
+ gap: var(--ghost-space-gap-xs);
191
+ }
192
+ </style>
@@ -6,14 +6,14 @@ import {
6
6
  GhostField,
7
7
  GhostFieldControl,
8
8
  GhostFieldLabel,
9
- } from '@ghostvue/vue'
9
+ } from '@ghostvue/themes'
10
10
 
11
11
  const digest = ref(false)
12
12
  </script>
13
13
 
14
14
  <template>
15
15
  <GhostField>
16
- <GhostFieldLabel associate="wrap">
16
+ <GhostFieldLabel associate="wrap" class="digest-label">
17
17
  <GhostFieldControl v-slot="field">
18
18
  <GhostCheckbox v-bind="field" v-model="digest" name="digest" />
19
19
  </GhostFieldControl>
@@ -21,3 +21,11 @@ const digest = ref(false)
21
21
  </GhostFieldLabel>
22
22
  </GhostField>
23
23
  </template>
24
+
25
+ <style scoped>
26
+ .digest-label {
27
+ display: inline-flex;
28
+ align-items: center;
29
+ gap: var(--ghost-space-gap-xs);
30
+ }
31
+ </style>
@@ -9,19 +9,20 @@ import {
9
9
  GhostInput,
10
10
  } from '@ghostvue/themes'
11
11
 
12
+ // Colors and density come from the `data-ghost-theme` host on `<html>`. Do
13
+ // not wrap the template in `.ghost-theme`: that class hosts the default
14
+ // palette and would override the app's flagship around the field.
12
15
  const region = ref('')
13
16
  </script>
14
17
 
15
18
  <template>
16
- <div class="ghost-theme">
17
- <GhostField>
18
- <GhostFieldLabel>Data region</GhostFieldLabel>
19
- <GhostFieldDescription>
20
- Stored replicas stay in this region.
21
- </GhostFieldDescription>
22
- <GhostFieldControl v-slot="field">
23
- <GhostInput v-bind="field" v-model="region" name="region" />
24
- </GhostFieldControl>
25
- </GhostField>
26
- </div>
19
+ <GhostField>
20
+ <GhostFieldLabel>Data region</GhostFieldLabel>
21
+ <GhostFieldDescription>
22
+ Stored replicas stay in this region.
23
+ </GhostFieldDescription>
24
+ <GhostFieldControl v-slot="field">
25
+ <GhostInput v-bind="field" v-model="region" name="region" />
26
+ </GhostFieldControl>
27
+ </GhostField>
27
28
  </template>
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import { ref } from 'vue'
2
+ import { computed, shallowRef, useTemplateRef } from 'vue'
3
3
 
4
4
  import {
5
5
  GhostButton,
@@ -15,18 +15,39 @@ import {
15
15
  GhostFileUploadItemRemove,
16
16
  GhostFileUploadList,
17
17
  GhostFileUploadTrigger,
18
+ type GhostFileUploadExposed,
19
+ type GhostFileUploadRejection,
20
+ type GhostFileUploadValidate,
18
21
  } from '@ghostvue/themes'
19
22
 
20
- const seeded = [
23
+ const MAX_FILES = 3
24
+
25
+ // Two assets are already attached, so one slot is left before the limit.
26
+ const files = shallowRef<File[]>([
21
27
  new File(['architecture-spec'], 'architecture-spec.pdf', {
22
28
  type: 'application/pdf',
23
29
  }),
24
30
  new File(['brand-mark'], 'brand-mark.svg', { type: 'image/svg+xml' }),
25
- ]
31
+ ])
32
+ const rejections = shallowRef<GhostFileUploadRejection[]>([])
33
+ const submitError = shallowRef('')
34
+ // Names read back from FormData on submit; null until the form is submitted.
35
+ const submitted = shallowRef<string[] | null>(null)
36
+ const upload = useTemplateRef<GhostFileUploadExposed>('upload')
37
+
38
+ // Visible error text: the live region alone does not satisfy WCAG 3.3.1.
39
+ const errors = computed(() =>
40
+ submitError.value
41
+ ? [submitError.value]
42
+ : rejections.value.map((rejection) => rejection.message),
43
+ )
26
44
 
27
- const files = ref<File[]>(seeded)
28
- const rejectionMessage = ref('')
29
- const submitted = ref(false)
45
+ // The review keys assets by file name, so a second file with the same name
46
+ // is rejected. Remove the attached one first to replace it.
47
+ const rejectSameName: GhostFileUploadValidate = (file, { files: current }) =>
48
+ current.some((existing) => existing.name === file.name)
49
+ ? 'a file with this name is already attached'
50
+ : null
30
51
 
31
52
  function formatSize(bytes: number): string {
32
53
  return bytes < 1024
@@ -34,29 +55,47 @@ function formatSize(bytes: number): string {
34
55
  : `${String(Math.round(bytes / 1024))} KB`
35
56
  }
36
57
 
37
- function handleReject(): void {
38
- rejectionMessage.value =
39
- 'Some files were skipped. Upload up to 3 PDF, PNG, or SVG files under 5 MB.'
40
- submitted.value = false
58
+ // update:modelValue runs before reject, so a mixed batch clears the old
59
+ // errors here and then shows only the new rejections.
60
+ function onFilesChange(next: File[]): void {
61
+ files.value = next
62
+ rejections.value = []
63
+ submitError.value = ''
64
+ submitted.value = null
41
65
  }
42
66
 
43
- function handleChange(next: File[]): void {
44
- files.value = next
45
- rejectionMessage.value = ''
46
- submitted.value = false
67
+ // An invalid-only selection emits reject without update:modelValue, so this
68
+ // also clears the empty-submit error: the file-specific rejections replace it
69
+ // and stay visible until the list changes.
70
+ function onReject(next: GhostFileUploadRejection[]): void {
71
+ rejections.value = next
72
+ submitError.value = ''
73
+ submitted.value = null
47
74
  }
48
75
 
49
- function submit(): void {
50
- if (files.value.length === 0) {
51
- rejectionMessage.value = 'Attach at least one asset before submitting.'
76
+ function onSubmit(event: SubmitEvent): void {
77
+ const form = event.currentTarget
78
+ if (!(form instanceof HTMLFormElement)) return
79
+ // The upload's hidden form input holds exactly the attached list, so this
80
+ // is what a native multipart submit would send. Nothing leaves the page.
81
+ // An empty file input still contributes one nameless File, so skip it.
82
+ const names = new FormData(form)
83
+ .getAll('assets')
84
+ .flatMap((value) =>
85
+ value instanceof File && value.name !== '' ? [value.name] : [],
86
+ )
87
+ if (names.length === 0) {
88
+ submitError.value = 'Attach at least one asset before submitting.'
89
+ submitted.value = null
90
+ upload.value?.focus()
52
91
  return
53
92
  }
54
- submitted.value = true
93
+ submitted.value = names
55
94
  }
56
95
  </script>
57
96
 
58
97
  <template>
59
- <form class="upload-form" @submit.prevent="submit">
98
+ <form class="upload-form" @submit.prevent="onSubmit">
60
99
  <GhostCard as="section" aria-labelledby="upload-title">
61
100
  <template #header>
62
101
  <div class="upload-form__header">
@@ -64,33 +103,41 @@ function submit(): void {
64
103
  Release packet assets
65
104
  </h2>
66
105
  <p class="upload-form__lead">
67
- Attach specification PDFs or vector marks for the design review.
106
+ Attach specification PDFs or brand marks for the design review.
68
107
  </p>
69
108
  </div>
70
109
  </template>
71
110
 
72
- <GhostField :invalid="rejectionMessage !== ''">
111
+ <GhostField :invalid="errors.length > 0">
73
112
  <GhostFieldLabel>Attachments</GhostFieldLabel>
74
113
  <GhostFieldDescription>
75
- Up to 3 files (PDF, PNG, or SVG, max 5 MB each).
114
+ Up to 3 PDF, PNG, or SVG files, 5 MB each.
76
115
  </GhostFieldDescription>
77
116
  <GhostFieldControl v-slot="field">
78
117
  <GhostFileUpload
79
- v-slot="{ entries }"
118
+ ref="upload"
119
+ v-slot="{ entries, remaining }"
80
120
  v-bind="field"
81
121
  :model-value="files"
122
+ name="assets"
82
123
  accept=".pdf,.png,.svg"
83
- :max-files="3"
84
- :max-file-size="5 * 1024 * 1024"
85
- multiple
86
- @update:model-value="handleChange"
87
- @reject="handleReject"
124
+ :max-files="MAX_FILES"
125
+ :max-file-size="5_000_000"
126
+ :validate="rejectSameName"
127
+ @update:model-value="onFilesChange"
128
+ @reject="onReject"
88
129
  >
89
130
  <GhostFileUploadDropzone v-slot="{ dragging }">
90
131
  <strong>
91
132
  {{ dragging ? 'Drop files to attach' : 'Drag and drop files' }}
92
133
  </strong>
93
- <span>Or browse from your computer</span>
134
+ <span>
135
+ {{
136
+ remaining === 0
137
+ ? 'All 3 slots are used. Remove a file to add another.'
138
+ : `${String(remaining)} of 3 slots left.`
139
+ }}
140
+ </span>
94
141
  <GhostFileUploadTrigger>Choose files</GhostFileUploadTrigger>
95
142
  </GhostFileUploadDropzone>
96
143
 
@@ -112,19 +159,22 @@ function submit(): void {
112
159
  </GhostFileUploadList>
113
160
  </GhostFileUpload>
114
161
  </GhostFieldControl>
115
- <GhostFieldError v-if="rejectionMessage">
116
- {{ rejectionMessage }}
162
+ <GhostFieldError as="div" class="upload-form__errors">
163
+ <p v-for="(message, index) in errors" :key="`${index}-${message}`">
164
+ {{ message }}
165
+ </p>
117
166
  </GhostFieldError>
118
167
  </GhostField>
119
168
 
120
169
  <template #footer>
121
170
  <div class="upload-form__actions">
122
171
  <p class="upload-form__status" role="status">
123
- {{
124
- submitted
125
- ? `Submitted ${files.length} file${files.length === 1 ? '' : 's'}.`
126
- : `${files.length} of 3 slots used`
127
- }}
172
+ <template v-if="submitted">
173
+ Submitted {{ submitted.length }}
174
+ {{ submitted.length === 1 ? 'file' : 'files' }} as “assets”:
175
+ {{ submitted.join(', ') }}.
176
+ </template>
177
+ <template v-else>Not submitted yet.</template>
128
178
  </p>
129
179
  <GhostButton type="submit" class="upload-form__action">
130
180
  Submit packet
@@ -163,6 +213,16 @@ function submit(): void {
163
213
  overflow-wrap: anywhere;
164
214
  }
165
215
 
216
+ .upload-form__errors {
217
+ display: grid;
218
+ gap: var(--ghost-space-gap-xs);
219
+ overflow-wrap: anywhere;
220
+ }
221
+
222
+ .upload-form__errors p {
223
+ margin: 0;
224
+ }
225
+
166
226
  .upload-form__filename {
167
227
  min-inline-size: 0;
168
228
  overflow-wrap: anywhere;