@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.
- package/dist/assets/bundle.json +2 -2
- package/dist/assets/component-exports.json +1 -0
- package/dist/assets/docs/pages.json +1 -1
- package/dist/assets/examples/catalog.json +1 -1
- package/dist/assets/examples/sources/accordion/billing-faq.vue +123 -0
- package/dist/assets/examples/sources/avatar/team-roster.vue +69 -5
- package/dist/assets/examples/sources/badge/release-channels.vue +1 -1
- package/dist/assets/examples/sources/breadcrumb/basic.vue +60 -15
- package/dist/assets/examples/sources/button/refresh-status.vue +95 -0
- package/dist/assets/examples/sources/calendar/availability.vue +235 -0
- package/dist/assets/examples/sources/calendar/office-locale.vue +197 -0
- package/dist/assets/examples/sources/card/project-summary.vue +38 -3
- package/dist/assets/examples/sources/checkbox-group/basic.vue +56 -0
- package/dist/assets/examples/sources/checkbox-group/field.vue +73 -0
- package/dist/assets/examples/sources/checkbox-group/form.vue +100 -0
- package/dist/assets/examples/sources/checkbox-group/headless.vue +68 -0
- package/dist/assets/examples/sources/checkbox-group/notification-preferences.vue +380 -0
- package/dist/assets/examples/sources/collapsible/shipment-history.vue +135 -0
- package/dist/assets/examples/sources/combobox/review-request-form.vue +415 -0
- package/dist/assets/examples/sources/command-palette/async.vue +60 -12
- package/dist/assets/examples/sources/command-palette/basic.vue +123 -2
- package/dist/assets/examples/sources/command-palette/shortcut.vue +132 -5
- package/dist/assets/examples/sources/command-palette/themed.vue +44 -4
- package/dist/assets/examples/sources/command-palette/virtualized.vue +124 -3
- package/dist/assets/examples/sources/context-menu/themed.vue +81 -26
- package/dist/assets/examples/sources/data-table/themed-invoices.vue +219 -44
- package/dist/assets/examples/sources/date-picker/controlled.vue +8 -293
- package/dist/assets/examples/sources/date-picker/custom-format.vue +6 -295
- package/dist/assets/examples/sources/date-picker/nested-dialog.vue +28 -350
- package/dist/assets/examples/sources/date-picker/rtl.vue +5 -294
- package/dist/assets/examples/sources/date-picker/themed.vue +2 -2
- package/dist/assets/examples/sources/date-picker/validation.vue +8 -294
- package/dist/assets/examples/sources/dropdown-menu/nested-export.vue +56 -0
- package/dist/assets/examples/sources/empty-state/search-results.vue +26 -1
- package/dist/assets/examples/sources/field/billing-address-headless.vue +93 -0
- package/dist/assets/examples/sources/field/billing-address.vue +192 -0
- package/dist/assets/examples/sources/field/checkbox.vue +10 -2
- package/dist/assets/examples/sources/field/themed.vue +12 -11
- package/dist/assets/examples/sources/file-upload/asset-submission.vue +96 -36
- package/dist/assets/examples/sources/form/async-validation.vue +180 -0
- package/dist/assets/examples/sources/form/composable.vue +146 -0
- package/dist/assets/examples/sources/form/nested-webhooks.vue +233 -0
- package/dist/assets/examples/sources/form/profile-schema.vue +376 -0
- package/dist/assets/examples/sources/inline-alert/billing-notices.vue +26 -5
- package/dist/assets/examples/sources/inline-alert/feed-status.vue +229 -0
- package/dist/assets/examples/sources/input/clearable-search-headless.vue +162 -0
- package/dist/assets/examples/sources/input/clearable-search.vue +225 -0
- package/dist/assets/examples/sources/input/unit-suffix.vue +109 -0
- package/dist/assets/examples/sources/interactive-surface/basic.vue +20 -8
- package/dist/assets/examples/sources/interactive-surface/feature-tiles.vue +42 -8
- package/dist/assets/examples/sources/kbd/command-shortcuts.vue +0 -1
- package/dist/assets/examples/sources/link/documentation-footer.vue +11 -4
- package/dist/assets/examples/sources/link/router.vue +9 -5
- package/dist/assets/examples/sources/menubar/themed.vue +46 -10
- package/dist/assets/examples/sources/number-input/order-limits.vue +5 -0
- package/dist/assets/examples/sources/number-input/themed.vue +12 -6
- package/dist/assets/examples/sources/number-input/workshop-booking.vue +207 -0
- package/dist/assets/examples/sources/pagination/controlled.vue +83 -18
- package/dist/assets/examples/sources/pagination/ellipsis.vue +44 -14
- package/dist/assets/examples/sources/pagination/themed.vue +161 -21
- package/dist/assets/examples/sources/presence/basic.vue +81 -0
- package/dist/assets/examples/sources/presence/portal.vue +92 -0
- package/dist/assets/examples/sources/progress/report-export.vue +160 -0
- package/dist/assets/examples/sources/scroll-area/activity-feed.vue +0 -1
- package/dist/assets/examples/sources/scroll-area/horizontal.vue +169 -14
- package/dist/assets/examples/sources/scroll-area/themed.vue +42 -3
- package/dist/assets/examples/sources/scroll-spy/themed.vue +180 -31
- package/dist/assets/examples/sources/select/alert-routing-form.vue +356 -0
- package/dist/assets/examples/sources/select/multiple-form.vue +201 -0
- package/dist/assets/examples/sources/select/multiple-labels.vue +142 -0
- package/dist/assets/examples/sources/skeleton/profile-loading.vue +28 -4
- package/dist/assets/examples/sources/slider/audio-mixer.vue +8 -2
- package/dist/assets/examples/sources/slider/price-filter.vue +162 -0
- package/dist/assets/examples/sources/slider/vertical.vue +3 -2
- package/dist/assets/examples/sources/spinner/sync-status.vue +13 -10
- package/dist/assets/examples/sources/switch/form.vue +43 -11
- package/dist/assets/examples/sources/table/contain-horizontal.vue +24 -12
- package/dist/assets/examples/sources/table/row-headers.vue +118 -19
- package/dist/assets/examples/sources/tabs/review-sections.vue +43 -0
- package/dist/assets/examples/sources/tags-input/headless-field.vue +31 -0
- package/dist/assets/examples/sources/tags-input/project-labels.vue +64 -0
- package/dist/assets/examples/sources/tags-input/read-only.vue +12 -0
- package/dist/assets/examples/sources/toast/themed.vue +42 -19
- package/dist/assets/examples/sources/toolbar/themed.vue +22 -4
- package/dist/assets/examples/sources/tooltip/themed.vue +12 -1
- package/dist/assets/examples/sources/tree/themed.vue +70 -17
- package/dist/assets/manifests/themes/ghost-accordion.manifest.json +1 -0
- package/dist/assets/manifests/themes/ghost-button.manifest.json +1 -0
- package/dist/assets/manifests/themes/ghost-calendar.manifest.json +3 -1
- package/dist/assets/manifests/themes/ghost-checkbox-group.manifest.json +90 -0
- package/dist/assets/manifests/themes/ghost-collapsible.manifest.json +1 -0
- package/dist/assets/manifests/themes/ghost-combobox.manifest.json +1 -0
- package/dist/assets/manifests/themes/ghost-command-palette.manifest.json +2 -1
- package/dist/assets/manifests/themes/ghost-date-picker.manifest.json +5 -0
- package/dist/assets/manifests/themes/ghost-dropdown-menu.manifest.json +9 -0
- package/dist/assets/manifests/themes/ghost-field.manifest.json +10 -2
- package/dist/assets/manifests/themes/ghost-inline-alert.manifest.json +1 -0
- package/dist/assets/manifests/themes/ghost-input.manifest.json +3 -1
- package/dist/assets/manifests/themes/ghost-link.manifest.json +2 -1
- package/dist/assets/manifests/themes/ghost-number-input.manifest.json +1 -0
- package/dist/assets/manifests/themes/ghost-pagination.manifest.json +6 -2
- package/dist/assets/manifests/themes/ghost-progress.manifest.json +1 -0
- package/dist/assets/manifests/themes/ghost-radio-group-item.manifest.json +63 -0
- package/dist/assets/manifests/themes/ghost-scroll-area.manifest.json +12 -2
- package/dist/assets/manifests/themes/ghost-select.manifest.json +3 -0
- package/dist/assets/manifests/themes/ghost-slider.manifest.json +1 -0
- package/dist/assets/manifests/themes/ghost-table.manifest.json +2 -1
- package/dist/assets/manifests/themes/ghost-tags-input.manifest.json +255 -0
- package/dist/assets/manifests/vue/ghost-checkbox-group.manifest.json +173 -0
- package/dist/assets/manifests/vue/ghost-command-palette-content.manifest.json +6 -2
- package/dist/assets/manifests/vue/ghost-command-palette-overlay.manifest.json +6 -2
- package/dist/assets/manifests/vue/ghost-command-palette.manifest.json +0 -1
- package/dist/assets/manifests/vue/ghost-context-menu-content.manifest.json +3 -3
- package/dist/assets/manifests/vue/ghost-context-menu.manifest.json +1 -1
- package/dist/assets/manifests/vue/ghost-data-table-preset.manifest.json +1 -1
- package/dist/assets/manifests/vue/ghost-data-table-table.manifest.json +1 -1
- package/dist/assets/manifests/vue/ghost-data-table.manifest.json +99 -2
- package/dist/assets/manifests/vue/ghost-date-picker-content.manifest.json +12 -3
- package/dist/assets/manifests/vue/ghost-date-picker.manifest.json +1 -6
- package/dist/assets/manifests/vue/ghost-dialog-content.manifest.json +6 -2
- package/dist/assets/manifests/vue/ghost-dialog-overlay.manifest.json +6 -2
- package/dist/assets/manifests/vue/ghost-drawer-content.manifest.json +6 -2
- package/dist/assets/manifests/vue/ghost-drawer-overlay.manifest.json +6 -2
- package/dist/assets/manifests/vue/ghost-field-error.manifest.json +12 -1
- package/dist/assets/manifests/vue/ghost-field.manifest.json +35 -3
- package/dist/assets/manifests/vue/ghost-form.manifest.json +221 -0
- package/dist/assets/manifests/vue/ghost-hover-card-content.manifest.json +12 -3
- package/dist/assets/manifests/vue/ghost-input.manifest.json +2 -1
- package/dist/assets/manifests/vue/ghost-link.manifest.json +1 -2
- package/dist/assets/manifests/vue/ghost-menubar-content.manifest.json +3 -3
- package/dist/assets/manifests/vue/ghost-menubar.manifest.json +4 -4
- package/dist/assets/manifests/vue/ghost-pagination.manifest.json +0 -2
- package/dist/assets/manifests/vue/ghost-popover-content.manifest.json +6 -2
- package/dist/assets/manifests/vue/ghost-presence.manifest.json +96 -0
- package/dist/assets/manifests/vue/ghost-scroll-area.manifest.json +0 -1
- package/dist/assets/manifests/vue/ghost-select-content.manifest.json +6 -1
- package/dist/assets/manifests/vue/ghost-select-group.manifest.json +6 -1
- package/dist/assets/manifests/vue/ghost-select-label.manifest.json +6 -1
- package/dist/assets/manifests/vue/ghost-select-option.manifest.json +6 -1
- package/dist/assets/manifests/vue/ghost-select-trigger.manifest.json +6 -1
- package/dist/assets/manifests/vue/ghost-select-value.manifest.json +18 -2
- package/dist/assets/manifests/vue/ghost-select.manifest.json +18 -6
- package/dist/assets/manifests/vue/ghost-submenu-content.manifest.json +168 -0
- package/dist/assets/manifests/vue/ghost-submenu-trigger.manifest.json +102 -0
- package/dist/assets/manifests/vue/ghost-submenu.manifest.json +59 -0
- package/dist/assets/manifests/vue/ghost-table.manifest.json +0 -2
- package/dist/assets/manifests/vue/ghost-tabs.manifest.json +2 -1
- package/dist/assets/manifests/vue/ghost-tags-input.manifest.json +260 -0
- package/dist/assets/tokens.json +15 -0
- package/dist/components.d.ts +5 -0
- package/dist/components.js +80 -11
- package/package.json +1 -1
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { reactive, ref } from 'vue'
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
GhostForm,
|
|
6
|
+
type GhostFormSubmitPayload,
|
|
7
|
+
type StandardSchemaV1,
|
|
8
|
+
} from '@ghostvue/vue'
|
|
9
|
+
import {
|
|
10
|
+
GhostButton,
|
|
11
|
+
GhostCard,
|
|
12
|
+
GhostField,
|
|
13
|
+
GhostFieldControl,
|
|
14
|
+
GhostFieldDescription,
|
|
15
|
+
GhostFieldError,
|
|
16
|
+
GhostFieldLabel,
|
|
17
|
+
GhostInput,
|
|
18
|
+
} from '@ghostvue/themes'
|
|
19
|
+
|
|
20
|
+
interface HandleInput {
|
|
21
|
+
slug: string
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface HandleOutput {
|
|
25
|
+
slug: string
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const reservedSlugs = new Set(['admin', 'billing', 'system'])
|
|
29
|
+
|
|
30
|
+
const handleSchema: StandardSchemaV1<HandleInput, HandleOutput> = {
|
|
31
|
+
'~standard': {
|
|
32
|
+
version: 1,
|
|
33
|
+
vendor: 'example',
|
|
34
|
+
async validate(raw) {
|
|
35
|
+
const data = raw as HandleInput
|
|
36
|
+
const slug = data.slug.trim().toLowerCase()
|
|
37
|
+
await new Promise((resolve) => setTimeout(resolve, 60))
|
|
38
|
+
if (!/^[a-z0-9-]{3,}$/.test(slug)) {
|
|
39
|
+
return {
|
|
40
|
+
issues: [
|
|
41
|
+
{
|
|
42
|
+
message: 'Use at least 3 lowercase letters, numbers, or hyphens.',
|
|
43
|
+
path: ['slug'],
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (reservedSlugs.has(slug)) {
|
|
49
|
+
return {
|
|
50
|
+
issues: [
|
|
51
|
+
{
|
|
52
|
+
message: `"${slug}" is reserved by the platform.`,
|
|
53
|
+
path: ['slug'],
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return { value: { slug } }
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const values = reactive<HandleInput>({ slug: 'acme-cloud' })
|
|
64
|
+
const savedSlug = ref('')
|
|
65
|
+
|
|
66
|
+
function handleSave({
|
|
67
|
+
output,
|
|
68
|
+
setFieldErrors,
|
|
69
|
+
waitUntil,
|
|
70
|
+
}: GhostFormSubmitPayload<HandleOutput, HandleInput>): void {
|
|
71
|
+
waitUntil(
|
|
72
|
+
new Promise<void>((resolve) => {
|
|
73
|
+
setTimeout(() => {
|
|
74
|
+
if (output.slug === 'taken-org') {
|
|
75
|
+
setFieldErrors('slug', ['This workspace handle was just claimed.'])
|
|
76
|
+
} else {
|
|
77
|
+
savedSlug.value = output.slug
|
|
78
|
+
}
|
|
79
|
+
resolve()
|
|
80
|
+
}, 80)
|
|
81
|
+
}),
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function handleReset(): void {
|
|
86
|
+
values.slug = 'acme-cloud'
|
|
87
|
+
savedSlug.value = ''
|
|
88
|
+
}
|
|
89
|
+
</script>
|
|
90
|
+
|
|
91
|
+
<template>
|
|
92
|
+
<GhostForm
|
|
93
|
+
v-slot="{ isValidating, isSubmitting }"
|
|
94
|
+
class="async-form"
|
|
95
|
+
:schema="handleSchema"
|
|
96
|
+
:values="values"
|
|
97
|
+
validate-on="blur"
|
|
98
|
+
@submit="handleSave"
|
|
99
|
+
@reset="handleReset"
|
|
100
|
+
>
|
|
101
|
+
<GhostCard as="section" aria-labelledby="async-form-title">
|
|
102
|
+
<template #header>
|
|
103
|
+
<h2 id="async-form-title" class="async-form__title">
|
|
104
|
+
Claim workspace URL
|
|
105
|
+
</h2>
|
|
106
|
+
</template>
|
|
107
|
+
|
|
108
|
+
<div class="async-form__body">
|
|
109
|
+
<GhostField name="slug" required>
|
|
110
|
+
<GhostFieldLabel>Workspace handle</GhostFieldLabel>
|
|
111
|
+
<GhostFieldDescription>
|
|
112
|
+
Checked asynchronously on blur and submit. Try "admin" or
|
|
113
|
+
"taken-org".
|
|
114
|
+
</GhostFieldDescription>
|
|
115
|
+
<GhostFieldControl v-slot="field">
|
|
116
|
+
<GhostInput
|
|
117
|
+
v-bind="field"
|
|
118
|
+
v-model="values.slug"
|
|
119
|
+
name="slug"
|
|
120
|
+
block
|
|
121
|
+
/>
|
|
122
|
+
</GhostFieldControl>
|
|
123
|
+
<GhostFieldError />
|
|
124
|
+
</GhostField>
|
|
125
|
+
</div>
|
|
126
|
+
|
|
127
|
+
<template #footer>
|
|
128
|
+
<div class="async-form__actions">
|
|
129
|
+
<p class="async-form__status" role="status">
|
|
130
|
+
<template v-if="isValidating">Checking availability…</template>
|
|
131
|
+
<template v-else-if="savedSlug">
|
|
132
|
+
Claimed https://ghostvue.dev/{{ savedSlug }}
|
|
133
|
+
</template>
|
|
134
|
+
</p>
|
|
135
|
+
<GhostButton type="reset" variant="ghost" tone="neutral">
|
|
136
|
+
Reset
|
|
137
|
+
</GhostButton>
|
|
138
|
+
<GhostButton type="submit" :loading="isSubmitting">
|
|
139
|
+
Claim handle
|
|
140
|
+
</GhostButton>
|
|
141
|
+
</div>
|
|
142
|
+
</template>
|
|
143
|
+
</GhostCard>
|
|
144
|
+
</GhostForm>
|
|
145
|
+
</template>
|
|
146
|
+
|
|
147
|
+
<style scoped>
|
|
148
|
+
.async-form {
|
|
149
|
+
max-inline-size: 30rem;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.async-form__title {
|
|
153
|
+
color: var(--ghost-text-default);
|
|
154
|
+
font-size: var(--ghost-type-size-lg);
|
|
155
|
+
font-weight: var(--ghost-type-weight-semibold);
|
|
156
|
+
line-height: var(--ghost-type-line-tight);
|
|
157
|
+
margin: 0;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.async-form__body {
|
|
161
|
+
display: grid;
|
|
162
|
+
gap: var(--ghost-space-stack-md);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.async-form__status {
|
|
166
|
+
color: var(--ghost-text-muted);
|
|
167
|
+
flex: 1 1 auto;
|
|
168
|
+
font-size: var(--ghost-type-size-sm);
|
|
169
|
+
margin: 0;
|
|
170
|
+
overflow-wrap: anywhere;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.async-form__actions {
|
|
174
|
+
align-items: center;
|
|
175
|
+
display: flex;
|
|
176
|
+
flex-wrap: wrap;
|
|
177
|
+
gap: var(--ghost-space-gap-sm);
|
|
178
|
+
justify-content: flex-end;
|
|
179
|
+
}
|
|
180
|
+
</style>
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { reactive, ref } from 'vue'
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
GhostButton,
|
|
6
|
+
GhostField,
|
|
7
|
+
GhostFieldControl,
|
|
8
|
+
GhostFieldError,
|
|
9
|
+
GhostFieldLabel,
|
|
10
|
+
GhostInput,
|
|
11
|
+
useGhostForm,
|
|
12
|
+
type StandardSchemaV1,
|
|
13
|
+
} from '@ghostvue/vue'
|
|
14
|
+
|
|
15
|
+
interface InviteInput {
|
|
16
|
+
email: string
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface InviteOutput {
|
|
20
|
+
email: string
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const inviteSchema: StandardSchemaV1<InviteInput, InviteOutput> = {
|
|
24
|
+
'~standard': {
|
|
25
|
+
version: 1,
|
|
26
|
+
vendor: 'example',
|
|
27
|
+
validate(raw) {
|
|
28
|
+
const data = raw as InviteInput
|
|
29
|
+
const email = data.email.trim().toLowerCase()
|
|
30
|
+
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) {
|
|
31
|
+
return {
|
|
32
|
+
issues: [
|
|
33
|
+
{
|
|
34
|
+
message: 'Enter a valid teammate email address.',
|
|
35
|
+
path: ['email'],
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return { value: { email } }
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const values = reactive<InviteInput>({ email: '' })
|
|
46
|
+
const invitedEmail = ref('')
|
|
47
|
+
|
|
48
|
+
const form = useGhostForm({
|
|
49
|
+
schema: inviteSchema,
|
|
50
|
+
values,
|
|
51
|
+
onSubmit({ output }) {
|
|
52
|
+
invitedEmail.value = output.email
|
|
53
|
+
},
|
|
54
|
+
onReset() {
|
|
55
|
+
values.email = ''
|
|
56
|
+
invitedEmail.value = ''
|
|
57
|
+
},
|
|
58
|
+
})
|
|
59
|
+
</script>
|
|
60
|
+
|
|
61
|
+
<template>
|
|
62
|
+
<form class="headless-form" v-bind="form.formProps.value">
|
|
63
|
+
<GhostField name="email" required class="headless-form__field">
|
|
64
|
+
<GhostFieldLabel class="headless-form__label">
|
|
65
|
+
Teammate email
|
|
66
|
+
</GhostFieldLabel>
|
|
67
|
+
<GhostFieldControl v-slot="field">
|
|
68
|
+
<GhostInput
|
|
69
|
+
v-bind="field"
|
|
70
|
+
v-model="values.email"
|
|
71
|
+
type="email"
|
|
72
|
+
name="email"
|
|
73
|
+
class="headless-form__input"
|
|
74
|
+
/>
|
|
75
|
+
</GhostFieldControl>
|
|
76
|
+
<GhostFieldError class="headless-form__error" />
|
|
77
|
+
</GhostField>
|
|
78
|
+
|
|
79
|
+
<div class="headless-form__actions">
|
|
80
|
+
<GhostButton type="submit" class="headless-form__button">
|
|
81
|
+
Send invite
|
|
82
|
+
</GhostButton>
|
|
83
|
+
<p class="headless-form__status" role="status">
|
|
84
|
+
{{ invitedEmail ? `Invited ${invitedEmail}` : '' }}
|
|
85
|
+
</p>
|
|
86
|
+
</div>
|
|
87
|
+
</form>
|
|
88
|
+
</template>
|
|
89
|
+
|
|
90
|
+
<style scoped>
|
|
91
|
+
.headless-form {
|
|
92
|
+
display: grid;
|
|
93
|
+
gap: 0.75rem;
|
|
94
|
+
max-inline-size: 24rem;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.headless-form__field {
|
|
98
|
+
display: grid;
|
|
99
|
+
gap: 0.35rem;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.headless-form__label {
|
|
103
|
+
color: var(--ghost-text-default, CanvasText);
|
|
104
|
+
font-size: 0.875rem;
|
|
105
|
+
font-weight: 600;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.headless-form__input {
|
|
109
|
+
background: var(--ghost-surface-default-bg, Canvas);
|
|
110
|
+
border: 1px solid var(--ghost-border-default, GrayText);
|
|
111
|
+
border-radius: 0.375rem;
|
|
112
|
+
color: var(--ghost-text-default, CanvasText);
|
|
113
|
+
padding: 0.5rem 0.75rem;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.headless-form__input[aria-invalid='true'] {
|
|
117
|
+
border-color: var(--ghost-status-danger-border, Mark);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.headless-form__error {
|
|
121
|
+
color: var(--ghost-status-danger-fg, CanvasText);
|
|
122
|
+
font-size: 0.875rem;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.headless-form__actions {
|
|
126
|
+
align-items: center;
|
|
127
|
+
display: flex;
|
|
128
|
+
flex-wrap: wrap;
|
|
129
|
+
gap: 0.75rem;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.headless-form__button {
|
|
133
|
+
background: var(--ghost-action-primary-bg, ButtonFace);
|
|
134
|
+
border: 1px solid var(--ghost-border-default, ButtonBorder);
|
|
135
|
+
border-radius: 0.375rem;
|
|
136
|
+
color: var(--ghost-action-primary-fg, ButtonText);
|
|
137
|
+
cursor: pointer;
|
|
138
|
+
padding: 0.5rem 0.9rem;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.headless-form__status {
|
|
142
|
+
color: var(--ghost-text-muted, CanvasText);
|
|
143
|
+
font-size: 0.875rem;
|
|
144
|
+
margin: 0;
|
|
145
|
+
}
|
|
146
|
+
</style>
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { reactive, ref } from 'vue'
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
GhostForm,
|
|
6
|
+
type GhostFormSubmitPayload,
|
|
7
|
+
type StandardSchemaV1,
|
|
8
|
+
} from '@ghostvue/vue'
|
|
9
|
+
import {
|
|
10
|
+
GhostButton,
|
|
11
|
+
GhostCard,
|
|
12
|
+
GhostField,
|
|
13
|
+
GhostFieldControl,
|
|
14
|
+
GhostFieldError,
|
|
15
|
+
GhostFieldLabel,
|
|
16
|
+
GhostInput,
|
|
17
|
+
GhostSelect,
|
|
18
|
+
GhostSelectContent,
|
|
19
|
+
GhostSelectOption,
|
|
20
|
+
GhostSelectTrigger,
|
|
21
|
+
GhostSelectValue,
|
|
22
|
+
} from '@ghostvue/themes'
|
|
23
|
+
|
|
24
|
+
interface WebhooksInput {
|
|
25
|
+
channel: string
|
|
26
|
+
endpoints: { url: string }[]
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface WebhooksOutput {
|
|
30
|
+
channel: string
|
|
31
|
+
endpoints: { url: URL }[]
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const webhooksSchema: StandardSchemaV1<WebhooksInput, WebhooksOutput> = {
|
|
35
|
+
'~standard': {
|
|
36
|
+
version: 1,
|
|
37
|
+
vendor: 'example',
|
|
38
|
+
validate(raw) {
|
|
39
|
+
const data = raw as WebhooksInput
|
|
40
|
+
const issues: StandardSchemaV1.Issue[] = []
|
|
41
|
+
if (!data.channel) {
|
|
42
|
+
issues.push({ message: 'Select an event stream.', path: ['channel'] })
|
|
43
|
+
}
|
|
44
|
+
const endpoints: { url: URL }[] = []
|
|
45
|
+
data.endpoints.forEach((entry, index) => {
|
|
46
|
+
try {
|
|
47
|
+
const parsed = new URL(entry.url.trim())
|
|
48
|
+
if (parsed.protocol !== 'https:') {
|
|
49
|
+
issues.push({
|
|
50
|
+
message: 'Webhook URL must use https://.',
|
|
51
|
+
path: ['endpoints', index, 'url'],
|
|
52
|
+
})
|
|
53
|
+
return
|
|
54
|
+
}
|
|
55
|
+
endpoints.push({ url: parsed })
|
|
56
|
+
} catch {
|
|
57
|
+
issues.push({
|
|
58
|
+
message: 'Enter a valid HTTPS URL.',
|
|
59
|
+
path: ['endpoints', index, 'url'],
|
|
60
|
+
})
|
|
61
|
+
}
|
|
62
|
+
})
|
|
63
|
+
if (issues.length > 0) {
|
|
64
|
+
return { issues }
|
|
65
|
+
}
|
|
66
|
+
return { value: { channel: data.channel, endpoints } }
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const values = reactive<WebhooksInput>({
|
|
72
|
+
channel: 'billing',
|
|
73
|
+
endpoints: [
|
|
74
|
+
{ url: 'https://hooks.example.com/billing' },
|
|
75
|
+
{ url: 'https://hooks.example.com/backup' },
|
|
76
|
+
],
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
const savedMessage = ref('')
|
|
80
|
+
|
|
81
|
+
function addEndpoint(): void {
|
|
82
|
+
values.endpoints.push({ url: '' })
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function removeEndpoint(index: number): void {
|
|
86
|
+
if (values.endpoints.length <= 1) return
|
|
87
|
+
values.endpoints.splice(index, 1)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function handleSave({
|
|
91
|
+
output,
|
|
92
|
+
}: GhostFormSubmitPayload<WebhooksOutput, WebhooksInput>): void {
|
|
93
|
+
savedMessage.value = `Configured ${String(output.endpoints.length)} ${output.channel} endpoint(s).`
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function handleReset(): void {
|
|
97
|
+
values.channel = 'billing'
|
|
98
|
+
values.endpoints = [
|
|
99
|
+
{ url: 'https://hooks.example.com/billing' },
|
|
100
|
+
{ url: 'https://hooks.example.com/backup' },
|
|
101
|
+
]
|
|
102
|
+
savedMessage.value = ''
|
|
103
|
+
}
|
|
104
|
+
</script>
|
|
105
|
+
|
|
106
|
+
<template>
|
|
107
|
+
<GhostForm
|
|
108
|
+
class="webhooks-form"
|
|
109
|
+
:schema="webhooksSchema"
|
|
110
|
+
:values="values"
|
|
111
|
+
validate-on="blur"
|
|
112
|
+
@submit="handleSave"
|
|
113
|
+
@reset="handleReset"
|
|
114
|
+
>
|
|
115
|
+
<GhostCard as="section" aria-labelledby="webhooks-form-title">
|
|
116
|
+
<template #header>
|
|
117
|
+
<h2 id="webhooks-form-title" class="webhooks-form__title">
|
|
118
|
+
Event webhooks
|
|
119
|
+
</h2>
|
|
120
|
+
</template>
|
|
121
|
+
|
|
122
|
+
<div class="webhooks-form__fields">
|
|
123
|
+
<GhostField name="channel" required>
|
|
124
|
+
<GhostFieldLabel>Event stream</GhostFieldLabel>
|
|
125
|
+
<GhostFieldControl v-slot="field">
|
|
126
|
+
<GhostSelect v-model="values.channel">
|
|
127
|
+
<GhostSelectTrigger v-bind="field">
|
|
128
|
+
<GhostSelectValue placeholder="Choose a stream" />
|
|
129
|
+
</GhostSelectTrigger>
|
|
130
|
+
<GhostSelectContent>
|
|
131
|
+
<GhostSelectOption value="billing">
|
|
132
|
+
Billing events
|
|
133
|
+
</GhostSelectOption>
|
|
134
|
+
<GhostSelectOption value="audit"> Audit log </GhostSelectOption>
|
|
135
|
+
</GhostSelectContent>
|
|
136
|
+
</GhostSelect>
|
|
137
|
+
</GhostFieldControl>
|
|
138
|
+
<GhostFieldError />
|
|
139
|
+
</GhostField>
|
|
140
|
+
|
|
141
|
+
<div
|
|
142
|
+
v-for="(endpoint, index) in values.endpoints"
|
|
143
|
+
:key="index"
|
|
144
|
+
class="webhooks-form__row"
|
|
145
|
+
>
|
|
146
|
+
<GhostField :name="`endpoints.${index}.url`" required>
|
|
147
|
+
<GhostFieldLabel>Endpoint {{ index + 1 }}</GhostFieldLabel>
|
|
148
|
+
<div class="webhooks-form__input-row">
|
|
149
|
+
<GhostFieldControl v-slot="field">
|
|
150
|
+
<GhostInput
|
|
151
|
+
v-bind="field"
|
|
152
|
+
v-model="endpoint.url"
|
|
153
|
+
type="url"
|
|
154
|
+
:name="`endpoints.${index}.url`"
|
|
155
|
+
block
|
|
156
|
+
/>
|
|
157
|
+
</GhostFieldControl>
|
|
158
|
+
<GhostButton
|
|
159
|
+
v-if="values.endpoints.length > 1"
|
|
160
|
+
type="button"
|
|
161
|
+
variant="ghost"
|
|
162
|
+
tone="neutral"
|
|
163
|
+
@click="removeEndpoint(index)"
|
|
164
|
+
>
|
|
165
|
+
Remove
|
|
166
|
+
</GhostButton>
|
|
167
|
+
</div>
|
|
168
|
+
<GhostFieldError />
|
|
169
|
+
</GhostField>
|
|
170
|
+
</div>
|
|
171
|
+
|
|
172
|
+
<div>
|
|
173
|
+
<GhostButton type="button" variant="outline" @click="addEndpoint">
|
|
174
|
+
Add endpoint
|
|
175
|
+
</GhostButton>
|
|
176
|
+
</div>
|
|
177
|
+
</div>
|
|
178
|
+
|
|
179
|
+
<template #footer>
|
|
180
|
+
<div class="webhooks-form__actions">
|
|
181
|
+
<p class="webhooks-form__status" role="status">
|
|
182
|
+
{{ savedMessage }}
|
|
183
|
+
</p>
|
|
184
|
+
<GhostButton type="reset" variant="ghost" tone="neutral">
|
|
185
|
+
Reset
|
|
186
|
+
</GhostButton>
|
|
187
|
+
<GhostButton type="submit">Save endpoints</GhostButton>
|
|
188
|
+
</div>
|
|
189
|
+
</template>
|
|
190
|
+
</GhostCard>
|
|
191
|
+
</GhostForm>
|
|
192
|
+
</template>
|
|
193
|
+
|
|
194
|
+
<style scoped>
|
|
195
|
+
.webhooks-form {
|
|
196
|
+
max-inline-size: 32rem;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.webhooks-form__title {
|
|
200
|
+
color: var(--ghost-text-default);
|
|
201
|
+
font-size: var(--ghost-type-size-lg);
|
|
202
|
+
font-weight: var(--ghost-type-weight-semibold);
|
|
203
|
+
line-height: var(--ghost-type-line-tight);
|
|
204
|
+
margin: 0;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
.webhooks-form__fields {
|
|
208
|
+
display: grid;
|
|
209
|
+
gap: var(--ghost-space-stack-md);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
.webhooks-form__input-row {
|
|
213
|
+
align-items: center;
|
|
214
|
+
display: flex;
|
|
215
|
+
gap: var(--ghost-space-gap-sm);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
.webhooks-form__actions {
|
|
219
|
+
align-items: center;
|
|
220
|
+
display: flex;
|
|
221
|
+
flex-wrap: wrap;
|
|
222
|
+
gap: var(--ghost-space-gap-sm);
|
|
223
|
+
justify-content: flex-end;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
.webhooks-form__status {
|
|
227
|
+
color: var(--ghost-text-muted);
|
|
228
|
+
flex: 1 1 auto;
|
|
229
|
+
font-size: var(--ghost-type-size-sm);
|
|
230
|
+
margin: 0;
|
|
231
|
+
overflow-wrap: anywhere;
|
|
232
|
+
}
|
|
233
|
+
</style>
|