@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
@@ -1,26 +1,47 @@
1
1
  <script setup lang="ts">
2
2
  import { GhostAvatar, GhostBadge, GhostCard } from '@ghostvue/themes'
3
3
 
4
+ // An inline portrait keeps the sample self-contained. In an app this is the
5
+ // member's photo URL.
6
+ const adaPhoto =
7
+ 'data:image/svg+xml,' +
8
+ encodeURIComponent(
9
+ '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">' +
10
+ '<rect width="64" height="64" fill="#4338ca"/>' +
11
+ '<circle cx="32" cy="25" r="12" fill="#c7d2fe"/>' +
12
+ '<path d="M10 64c2-14 11-22 22-22s20 8 22 22z" fill="#c7d2fe"/>' +
13
+ '</svg>',
14
+ )
15
+
4
16
  const members = [
5
17
  {
6
18
  name: 'Ada Lovelace',
7
19
  role: 'Design Systems',
8
20
  badge: 'Owner',
9
- tone: 'accent' as const,
21
+ tone: 'accent',
22
+ src: adaPhoto,
10
23
  },
11
24
  {
12
25
  name: 'Grace Hopper',
13
26
  role: 'Platform Infrastructure',
14
27
  badge: 'Maintainer',
15
- tone: 'neutral' as const,
28
+ tone: 'neutral',
29
+ // Nothing is served at this path, so the image fails to load and the
30
+ // avatar keeps showing the initials.
31
+ src: '/avatars/grace-hopper.jpg',
16
32
  },
17
33
  {
18
34
  name: 'Alan Turing',
19
35
  role: 'Accessibility QA',
20
36
  badge: 'Reviewer',
21
- tone: 'neutral' as const,
37
+ tone: 'neutral',
38
+ // No photo on file: an empty src shows the initials without a request.
39
+ src: '',
22
40
  },
23
41
  ] as const
42
+
43
+ // The release bot below is the fourth member.
44
+ const memberCount = members.length + 1
24
45
  </script>
25
46
 
26
47
  <template>
@@ -30,7 +51,7 @@ const members = [
30
51
  <div class="avatar-roster__header">
31
52
  <span class="avatar-roster__title">Core maintainers</span>
32
53
  <GhostBadge tone="neutral" variant="outline" size="sm">
33
- {{ members.length }} members
54
+ {{ memberCount }} members
34
55
  </GhostBadge>
35
56
  </div>
36
57
  </template>
@@ -42,7 +63,16 @@ const members = [
42
63
  class="avatar-roster__row"
43
64
  >
44
65
  <div class="avatar-roster__person">
45
- <GhostAvatar :name="member.name" size="md" />
66
+ <!-- The visible name beside the avatar already names the person,
67
+ so the whole avatar is decorative: alt="" silences the photo
68
+ and aria-hidden keeps fallback initials from being read
69
+ before the name. -->
70
+ <GhostAvatar
71
+ :name="member.name"
72
+ :src="member.src"
73
+ alt=""
74
+ aria-hidden="true"
75
+ />
46
76
  <div class="avatar-roster__meta">
47
77
  <span class="avatar-roster__name">{{ member.name }}</span>
48
78
  <span class="avatar-roster__role">{{ member.role }}</span>
@@ -52,6 +82,38 @@ const members = [
52
82
  {{ member.badge }}
53
83
  </GhostBadge>
54
84
  </li>
85
+
86
+ <li class="avatar-roster__row">
87
+ <div class="avatar-roster__person">
88
+ <!-- Initials would read "RB"; a service account reads better as an
89
+ icon. The icon is hidden because the name follows it. -->
90
+ <GhostAvatar name="Release bot">
91
+ <template #fallback>
92
+ <svg
93
+ aria-hidden="true"
94
+ viewBox="0 0 24 24"
95
+ width="18"
96
+ height="18"
97
+ fill="none"
98
+ stroke="currentColor"
99
+ stroke-width="2"
100
+ stroke-linecap="round"
101
+ stroke-linejoin="round"
102
+ >
103
+ <rect x="4" y="8" width="16" height="12" rx="3" />
104
+ <path d="M12 4v4M9 13h.01M15 13h.01M9 17h6" />
105
+ </svg>
106
+ </template>
107
+ </GhostAvatar>
108
+ <div class="avatar-roster__meta">
109
+ <span class="avatar-roster__name">Release bot</span>
110
+ <span class="avatar-roster__role">Publishes tagged builds</span>
111
+ </div>
112
+ </div>
113
+ <GhostBadge tone="neutral" variant="outline" size="sm">
114
+ Automation
115
+ </GhostBadge>
116
+ </li>
55
117
  </ul>
56
118
  </GhostCard>
57
119
  </div>
@@ -89,6 +151,8 @@ const members = [
89
151
  align-items: start;
90
152
  display: grid;
91
153
  gap: var(--ghost-space-gap-sm);
154
+ /* Keep the role badge at its own width when it stacks under the name. */
155
+ justify-items: start;
92
156
  }
93
157
 
94
158
  .avatar-roster__person {
@@ -33,7 +33,7 @@ const channels = [
33
33
  <div class="badge-showcase__header">
34
34
  <span class="badge-showcase__title">Release channels</span>
35
35
  <GhostBadge variant="ghost" tone="neutral" size="sm">
36
- 3 active
36
+ Sample data
37
37
  </GhostBadge>
38
38
  </div>
39
39
  </template>
@@ -10,19 +10,64 @@ import {
10
10
  </script>
11
11
 
12
12
  <template>
13
- <GhostBreadcrumb aria-label="Project trail">
14
- <GhostBreadcrumbList>
15
- <GhostBreadcrumbItem>
16
- <GhostBreadcrumbLink href="#">Home</GhostBreadcrumbLink>
17
- <GhostBreadcrumbSeparator />
18
- </GhostBreadcrumbItem>
19
- <GhostBreadcrumbItem>
20
- <GhostBreadcrumbLink href="#">Projects</GhostBreadcrumbLink>
21
- <GhostBreadcrumbSeparator />
22
- </GhostBreadcrumbItem>
23
- <GhostBreadcrumbItem>
24
- <GhostBreadcrumbPage>GhostVue</GhostBreadcrumbPage>
25
- </GhostBreadcrumbItem>
26
- </GhostBreadcrumbList>
27
- </GhostBreadcrumb>
13
+ <div class="breadcrumb-demo">
14
+ <GhostBreadcrumb aria-label="Project trail">
15
+ <GhostBreadcrumbList>
16
+ <GhostBreadcrumbItem>
17
+ <GhostBreadcrumbLink href="#">Home</GhostBreadcrumbLink>
18
+ <GhostBreadcrumbSeparator />
19
+ </GhostBreadcrumbItem>
20
+ <GhostBreadcrumbItem>
21
+ <GhostBreadcrumbLink href="#">Projects</GhostBreadcrumbLink>
22
+ <GhostBreadcrumbSeparator />
23
+ </GhostBreadcrumbItem>
24
+ <GhostBreadcrumbItem>
25
+ <GhostBreadcrumbPage>GhostVue</GhostBreadcrumbPage>
26
+ </GhostBreadcrumbItem>
27
+ </GhostBreadcrumbList>
28
+ </GhostBreadcrumb>
29
+ </div>
28
30
  </template>
31
+
32
+ <!--
33
+ The headless parts render semantic markup only. This consumer CSS lays the
34
+ trail out inline and styles the parts through their data-part hooks; the
35
+ system-color fallbacks keep it readable without a theme.
36
+ -->
37
+ <style>
38
+ .breadcrumb-demo [data-part='list'] {
39
+ align-items: center;
40
+ display: flex;
41
+ flex-wrap: wrap;
42
+ gap: 0.25rem;
43
+ list-style: none;
44
+ margin: 0;
45
+ padding: 0;
46
+ }
47
+
48
+ .breadcrumb-demo [data-part='item'] {
49
+ align-items: center;
50
+ display: inline-flex;
51
+ gap: 0.25rem;
52
+ margin: 0;
53
+ }
54
+
55
+ .breadcrumb-demo [data-part='link'] {
56
+ color: var(--ghost-text-primary, LinkText);
57
+ }
58
+
59
+ .breadcrumb-demo [data-part='link']:focus-visible {
60
+ outline: var(--ghost-focus-ring-width, 2px) solid
61
+ var(--ghost-focus-ring-color, Highlight);
62
+ outline-offset: 2px;
63
+ }
64
+
65
+ .breadcrumb-demo [data-part='separator'] {
66
+ color: var(--ghost-text-muted, GrayText);
67
+ }
68
+
69
+ .breadcrumb-demo [data-part='page'] {
70
+ color: var(--ghost-text-default, CanvasText);
71
+ font-weight: 600;
72
+ }
73
+ </style>
@@ -0,0 +1,95 @@
1
+ <script setup lang="ts">
2
+ import { onBeforeUnmount, ref } from 'vue'
3
+
4
+ import { GhostButton } from '@ghostvue/themes'
5
+
6
+ type RefreshResult = 'idle' | 'pending' | 'failed' | 'updated'
7
+
8
+ const result = ref<RefreshResult>('idle')
9
+ const attempts = ref(0)
10
+ let requestTimer: ReturnType<typeof setTimeout> | undefined
11
+
12
+ const messages: Record<RefreshResult, string> = {
13
+ idle: 'Last checked 5 minutes ago.',
14
+ pending: 'Checking 3 deployments…',
15
+ failed: 'Could not reach the build server. Try again.',
16
+ updated: 'All 3 deployments are healthy.',
17
+ }
18
+
19
+ /*
20
+ * The application owns the request. `loading` only blocks activation while
21
+ * it runs: the button stays focused and keeps its name, so a keyboard user
22
+ * can retry from where they are once the failure clears the pending state.
23
+ * The first attempt fails so the example shows that recovery path.
24
+ */
25
+ function refresh(): void {
26
+ attempts.value += 1
27
+ const fails = attempts.value === 1
28
+ result.value = 'pending'
29
+ requestTimer = setTimeout(() => {
30
+ result.value = fails ? 'failed' : 'updated'
31
+ }, 900)
32
+ }
33
+
34
+ onBeforeUnmount(() => {
35
+ clearTimeout(requestTimer)
36
+ })
37
+ </script>
38
+
39
+ <template>
40
+ <div class="refresh-status">
41
+ <div class="refresh-status__summary">
42
+ <span class="refresh-status__title">Production deployments</span>
43
+ <!-- A polite region announces each outcome without moving focus. -->
44
+ <span class="refresh-status__message" :data-result="result" role="status">
45
+ {{ messages[result] }}
46
+ </span>
47
+ </div>
48
+ <GhostButton
49
+ variant="outline"
50
+ tone="neutral"
51
+ :loading="result === 'pending'"
52
+ @click="refresh"
53
+ >
54
+ Refresh status
55
+ </GhostButton>
56
+ </div>
57
+ </template>
58
+
59
+ <style scoped>
60
+ .refresh-status {
61
+ display: grid;
62
+ gap: var(--ghost-space-gap-sm);
63
+ justify-items: start;
64
+ }
65
+
66
+ .refresh-status__summary {
67
+ display: grid;
68
+ gap: var(--ghost-space-gap-xs);
69
+ min-inline-size: 0;
70
+ }
71
+
72
+ .refresh-status__title {
73
+ color: var(--ghost-text-default);
74
+ font-size: var(--ghost-type-size-md);
75
+ font-weight: var(--ghost-type-weight-semibold);
76
+ line-height: var(--ghost-type-line-snug);
77
+ }
78
+
79
+ .refresh-status__message {
80
+ color: var(--ghost-text-muted);
81
+ font-size: var(--ghost-type-size-sm);
82
+ line-height: var(--ghost-type-line-normal);
83
+ }
84
+
85
+ .refresh-status__message[data-result='failed'] {
86
+ color: var(--ghost-text-danger);
87
+ }
88
+
89
+ @container ghost-demo (min-width: 30rem) {
90
+ .refresh-status {
91
+ align-items: center;
92
+ grid-template-columns: minmax(0, 1fr) auto;
93
+ }
94
+ }
95
+ </style>
@@ -0,0 +1,235 @@
1
+ <script setup lang="ts">
2
+ import { computed, shallowRef } from 'vue'
3
+
4
+ import {
5
+ CalendarDate,
6
+ GhostButton,
7
+ GhostCalendar,
8
+ GhostCalendarGrid,
9
+ GhostCalendarHeader,
10
+ GhostCalendarHeading,
11
+ GhostCalendarNextButton,
12
+ GhostCalendarPrevButton,
13
+ GhostCard,
14
+ } from '@ghostvue/themes'
15
+
16
+ /** Range mode proposes inclusive `{ start, end }` values. */
17
+ interface BookingRange {
18
+ start: CalendarDate
19
+ end: CalendarDate
20
+ }
21
+
22
+ // A fixed "today" keeps the demo, its tests, and its screenshots stable.
23
+ const today = new CalendarDate(2024, 6, 3)
24
+ const visibleMonth = new CalendarDate(2024, 6, 1)
25
+
26
+ // Days another team already holds. They render struck through and cannot be
27
+ // picked, but a range may still be dragged across them, so the summary
28
+ // checks for overlap before the request can be sent.
29
+ const booked = [
30
+ new CalendarDate(2024, 6, 12),
31
+ new CalendarDate(2024, 6, 13),
32
+ new CalendarDate(2024, 6, 24),
33
+ new CalendarDate(2024, 6, 25),
34
+ new CalendarDate(2024, 6, 26),
35
+ ]
36
+
37
+ function isBooked(date: CalendarDate): boolean {
38
+ return booked.some((day) => day.compare(date) === 0)
39
+ }
40
+
41
+ const range = shallowRef<BookingRange | null>({
42
+ start: new CalendarDate(2024, 6, 17),
43
+ end: new CalendarDate(2024, 6, 20),
44
+ })
45
+
46
+ /*
47
+ * The calendar treats any one-day value as an open start, so after a
48
+ * finished one-day booking its next proposal would extend that day instead
49
+ * of starting a new booking. The example tracks the open start itself:
50
+ * `select` fires after `update:modelValue` for every accepted click, so a
51
+ * click with no open start replaces the proposal with a fresh one-day start,
52
+ * and the next click completes it (the same day twice is a one-day booking).
53
+ */
54
+ const awaitingEnd = shallowRef(false)
55
+
56
+ function onSelect(date: CalendarDate): void {
57
+ if (awaitingEnd.value) {
58
+ awaitingEnd.value = false
59
+ return
60
+ }
61
+ range.value = { start: date, end: date }
62
+ awaitingEnd.value = true
63
+ }
64
+
65
+ function clear(): void {
66
+ // `null` keeps the calendar controlled while empty and drops a pending start.
67
+ range.value = null
68
+ awaitingEnd.value = false
69
+ }
70
+
71
+ const dayFormat = new Intl.DateTimeFormat('en-US', {
72
+ weekday: 'short',
73
+ month: 'short',
74
+ day: 'numeric',
75
+ timeZone: 'UTC',
76
+ })
77
+
78
+ function formatDay(date: CalendarDate): string {
79
+ return dayFormat.format(date.toDate('UTC'))
80
+ }
81
+
82
+ const conflict = computed(() => {
83
+ const value = range.value
84
+ if (!value || awaitingEnd.value) return false
85
+ return booked.some(
86
+ (day) => day.compare(value.start) >= 0 && day.compare(value.end) <= 0,
87
+ )
88
+ })
89
+
90
+ const summary = computed(() => {
91
+ const value = range.value
92
+ if (!value) return 'Choose the first day of your booking.'
93
+ if (awaitingEnd.value) {
94
+ return `Starts ${formatDay(value.start)}. Choose the last day.`
95
+ }
96
+ if (conflict.value) {
97
+ return 'This range includes booked days. Choose dates without a strikethrough.'
98
+ }
99
+ // `end` is inclusive, so a one-day booking still counts as one day.
100
+ const days = value.end.compare(value.start) + 1
101
+ const dates =
102
+ days === 1
103
+ ? formatDay(value.start)
104
+ : `${formatDay(value.start)} – ${formatDay(value.end)}`
105
+ return `${dates} · ${String(days)} ${days === 1 ? 'day' : 'days'}`
106
+ })
107
+
108
+ const canRequest = computed(
109
+ () => range.value !== null && !awaitingEnd.value && !conflict.value,
110
+ )
111
+
112
+ const requested = shallowRef<string | null>(null)
113
+
114
+ function request(): void {
115
+ requested.value = summary.value
116
+ }
117
+ </script>
118
+
119
+ <template>
120
+ <GhostCard class="studio-booking">
121
+ <template #header>
122
+ <div class="studio-booking__header">
123
+ <h2 class="studio-booking__title">Book Studio B</h2>
124
+ <p class="studio-booking__meta">
125
+ Struck-through days are booked or already past.
126
+ </p>
127
+ </div>
128
+ </template>
129
+
130
+ <GhostCalendar
131
+ v-model="range"
132
+ selection-mode="range"
133
+ :default-visible-month="visibleMonth"
134
+ :today="today"
135
+ :min-value="today"
136
+ :is-date-disabled="isBooked"
137
+ @select="onSelect"
138
+ >
139
+ <GhostCalendarHeader class="studio-booking__nav">
140
+ <GhostCalendarHeading />
141
+ <GhostCalendarPrevButton />
142
+ <GhostCalendarNextButton />
143
+ </GhostCalendarHeader>
144
+ <GhostCalendarGrid />
145
+ </GhostCalendar>
146
+
147
+ <template #footer>
148
+ <div class="studio-booking__footer">
149
+ <p
150
+ class="studio-booking__summary"
151
+ :data-conflict="conflict || undefined"
152
+ role="status"
153
+ aria-live="polite"
154
+ >
155
+ {{ summary }}
156
+ </p>
157
+ <div class="studio-booking__actions">
158
+ <GhostButton
159
+ variant="outline"
160
+ tone="neutral"
161
+ size="sm"
162
+ :disabled="range === null"
163
+ @click="clear"
164
+ >
165
+ Clear dates
166
+ </GhostButton>
167
+ <GhostButton size="sm" :disabled="!canRequest" @click="request">
168
+ Request booking
169
+ </GhostButton>
170
+ </div>
171
+ <p v-if="requested" class="studio-booking__requested">
172
+ Requested: {{ requested }}
173
+ </p>
174
+ </div>
175
+ </template>
176
+ </GhostCard>
177
+ </template>
178
+
179
+ <style scoped>
180
+ .studio-booking {
181
+ inline-size: 100%;
182
+ max-inline-size: 22rem;
183
+ }
184
+
185
+ .studio-booking__header {
186
+ display: grid;
187
+ gap: var(--ghost-space-gap-xs);
188
+ }
189
+
190
+ /* Reset the docs prose heading so the card title keeps the card's type scale. */
191
+ .studio-booking__title {
192
+ border: 0;
193
+ color: var(--ghost-surface-fg);
194
+ font-size: var(--ghost-type-size-md);
195
+ font-weight: var(--ghost-type-weight-semibold);
196
+ line-height: var(--ghost-type-line-tight);
197
+ margin: 0;
198
+ padding: 0;
199
+ }
200
+
201
+ .studio-booking__meta,
202
+ .studio-booking__requested {
203
+ color: var(--ghost-text-muted);
204
+ font-size: var(--ghost-type-size-xs);
205
+ margin: 0;
206
+ }
207
+
208
+ .studio-booking__nav :deep(.ghost-calendar-heading) {
209
+ text-align: start;
210
+ }
211
+
212
+ .studio-booking__footer {
213
+ display: grid;
214
+ gap: var(--ghost-space-gap-sm);
215
+ inline-size: 100%;
216
+ }
217
+
218
+ .studio-booking__summary {
219
+ color: var(--ghost-surface-fg);
220
+ font-size: var(--ghost-type-size-sm);
221
+ font-variant-numeric: tabular-nums;
222
+ margin: 0;
223
+ }
224
+
225
+ .studio-booking__summary[data-conflict] {
226
+ color: var(--ghost-text-danger);
227
+ }
228
+
229
+ .studio-booking__actions {
230
+ display: flex;
231
+ flex-wrap: wrap;
232
+ gap: var(--ghost-space-gap-xs);
233
+ justify-content: flex-end;
234
+ }
235
+ </style>