@webx-ui/module-inbox 0.6.8 → 0.8.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormEditorPage-BoHzlFfz.js","sources":["../src/FormAntispam.vue","../src/FormEmbed.vue","../src/FormGeneral.vue","../src/recipients.ts","../src/FormNotifications.vue","../src/FormEditorPage.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed } from 'vue'\nimport { useTranslate } from '@webx-ui/module-admin'\nimport {\n WxAlert,\n WxCard,\n WxFormItem,\n WxInputNumber,\n WxSelect,\n WxSwitch,\n WxText,\n} from '@webx-ui/core'\nimport { option } from './options'\nimport type { CaptchaProvider, CaptchaSite, FormOptions } from './types'\n\n/**\n * The four layers in front of the door (§7), as the three anybody would want to change.\n *\n * The origin check is not here: it is not a dial, it is a fact about where the site is served\n * from, and it lives in the configuration with the rest of the deployment. The captcha keys\n * are not here either — they are the site's, one pair for every form, and a secret repeated\n * in each form's settings is a secret scattered over rows (§5).\n *\n * What is here is what the site has, under the select: a reCAPTCHA key of the wrong kind is\n * the widget's \"Invalid key type\" and nothing else, and the select alone gives an editor no\n * way of knowing which kind the site expects.\n */\nconst options = defineModel<FormOptions>({ required: true })\n\nconst props = defineProps<{\n /** From the form as the server sent it; absent on a server older than this. */\n site?: Record<CaptchaProvider, CaptchaSite>\n}>()\n\nconst t = useTranslate('webx-inbox')\n\nconst honeypot = option<boolean>(options, 'antispam.honeypot', true)\nconst seconds = option<number>(options, 'antispam.min_seconds', 3)\nconst throttle = option<number>(options, 'antispam.throttle', 5)\nconst captcha = option<string>(options, 'antispam.captcha', 'off')\n\nconst captchas = computed(() => [\n { value: 'off', label: t('panel.captcha-off') },\n { value: 'recaptcha', label: t('panel.captcha-recaptcha') },\n { value: 'turnstile', label: t('panel.captcha-turnstile') },\n])\n\n/** The provider chosen and what the site has for it, or null for none. */\nconst chosen = computed(() => {\n const provider = captcha.value\n\n if (provider !== 'recaptcha' && provider !== 'turnstile') return null\n\n return { provider, site: props.site?.[provider] ?? null }\n})\n\nconst kind = computed(() => {\n const site = chosen.value?.site\n\n return site ? t(`panel.captcha-${chosen.value!.provider}-${site.type}`) : null\n})\n</script>\n\n<template>\n <wx-card>\n <wx-form-item :help=\"t('panel.honeypot-help')\">\n <wx-switch v-model=\"honeypot\" :label=\"t('panel.honeypot')\" />\n </wx-form-item>\n\n <wx-form-item :label=\"t('panel.min-seconds')\" :help=\"t('panel.min-seconds-help')\">\n <wx-input-number v-model=\"seconds\" :min=\"0\" :max=\"120\" />\n </wx-form-item>\n\n <wx-form-item :label=\"t('panel.throttle')\" :help=\"t('panel.throttle-help')\">\n <wx-input-number v-model=\"throttle\" :min=\"0\" :max=\"120\" />\n </wx-form-item>\n\n <wx-form-item :label=\"t('panel.captcha')\" :help=\"t('panel.captcha-keys')\">\n <wx-select v-model=\"captcha\" :options=\"captchas\" />\n </wx-form-item>\n\n <wx-text v-if=\"kind\" size=\"sm\" tone=\"muted\">{{ kind }}</wx-text>\n\n <wx-alert\n v-if=\"chosen?.site && !chosen.site.configured\"\n type=\"warning\"\n variant=\"soft\"\n :closable=\"false\"\n :description=\"t('panel.captcha-unconfigured')\"\n />\n </wx-card>\n</template>\n","<script setup lang=\"ts\">\nimport { computed } from 'vue'\nimport { useAdmin, useTranslate } from '@webx-ui/module-admin'\nimport { toast, WxAction, WxCard, WxTable, WxText, type TableColumn } from '@webx-ui/core'\nimport { useInboxMessages } from './i18n'\nimport type { InboxField, InboxForm } from './types'\n\n/**\n * How the form gets onto a page.\n *\n * Two answers and both are one line, because the module's whole public half is one tag (§10):\n * a template prints it, and a block type prints the same thing so that an editor never opens\n * a template at all.\n *\n * Under them, the names. A hidden field is filled in by the page it stands on — the address\n * somebody wrote from, the product they were looking at, the campaign that brought them — and\n * the only way to fill one in is to know what it is called (§2.6).\n *\n * Where a block's template lives depends on the site: with `module-blocks` it is written in\n * the panel's Blocks section, and a hint pointing at `resources/views/blocks/…` sent people\n * looking for a file that is not there. Without it, a block type is the site's own view.\n */\nconst props = defineProps<{ form: InboxForm; slug: string; fields: InboxField[] }>()\n\nuseInboxMessages()\nconst t = useTranslate('webx-inbox')\nconst admin = useAdmin()\n\nconst hasBlocks = computed(\n () => admin.state.manifest?.modules.some((module) => module.id === 'blocks') ?? false,\n)\n\nconst blade = computed(() => `<x-webx-inbox::form slug=\"${props.slug}\" />`)\n\nconst block = computed(() =>\n hasBlocks.value\n ? blade.value\n : `{{-- resources/views/blocks/contact.blade.php --}}\\n<x-webx-inbox::form slug=\"${props.slug}\" />`,\n)\n\n/** The first hidden field, so the example fills a name this form actually has. */\nconst hidden = computed(\n () => props.fields.find((field) => field.type === 'hidden' && field.is_enabled)?.key ?? 'page',\n)\n\nconst extras = computed(\n () =>\n `<x-webx-inbox::form slug=\"${props.slug}\" :values=\"['${hidden.value}' => url()->current()]\" />\\n` +\n `<x-webx-inbox::form slug=\"${props.slug}\" placement=\"footer\" />`,\n)\n\nconst columns = computed<TableColumn<InboxField>[]>(() => [\n { key: 'key', label: t('fields.name') },\n { key: 'title', label: t('fields.title') },\n { key: 'type', label: t('fields.type'), hideBelow: 520 },\n])\n\n/** Only the ones a page can actually fill in or a visitor can actually answer. */\nconst listed = computed(() => props.fields.filter((field) => field.is_enabled))\n\nasync function copy(text: string): Promise<void> {\n try {\n await navigator.clipboard.writeText(text)\n toast.success(t('panel.copied'))\n } catch {\n // A browser that refuses the clipboard — an insecure origin, a denied permission — still\n // shows the line, and selecting it by hand is what anybody does next anyway.\n }\n}\n</script>\n\n<template>\n <div class=\"wx-inbox-embed\">\n <wx-card :title=\"t('panel.embed-blade')\">\n <wx-text size=\"sm\" tone=\"muted\">{{ t('panel.embed-blade-help') }}</wx-text>\n\n <div class=\"wx-inbox-embed__snippet\">\n <code>{{ blade }}</code>\n <wx-action icon=\"copy\" :title=\"t('panel.copy')\" @click=\"copy(blade)\" />\n </div>\n </wx-card>\n\n <wx-card :title=\"t('panel.embed-block')\">\n <wx-text size=\"sm\" tone=\"muted\">\n {{ t(hasBlocks ? 'panel.embed-block-panel-help' : 'panel.embed-block-help') }}\n </wx-text>\n\n <div class=\"wx-inbox-embed__snippet\">\n <code>{{ block }}</code>\n <wx-action icon=\"copy\" :title=\"t('panel.copy')\" @click=\"copy(block)\" />\n </div>\n </wx-card>\n\n <wx-card :title=\"t('panel.embed-extras')\">\n <wx-text size=\"sm\" tone=\"muted\">{{ t('panel.embed-extras-help') }}</wx-text>\n\n <div class=\"wx-inbox-embed__snippet\">\n <code>{{ extras }}</code>\n <wx-action icon=\"copy\" :title=\"t('panel.copy')\" @click=\"copy(extras)\" />\n </div>\n </wx-card>\n\n <wx-card :title=\"t('panel.embed-names')\">\n <wx-text size=\"sm\" tone=\"muted\">{{ t('panel.embed-names-help') }}</wx-text>\n\n <wx-table\n :data=\"listed\"\n :columns=\"columns\"\n row-key=\"id\"\n flush\n :empty-text=\"t('fields.no-fields')\"\n >\n <template #cell-key=\"{ row }\">\n <wx-text mono size=\"sm\">fields[{{ row.key }}]</wx-text>\n </template>\n\n <template #cell-title=\"{ row }\">\n {{ Object.values(row.title)[0] ?? row.key }}\n </template>\n\n <template #cell-type=\"{ row }\">\n {{ t(`fields.type-${row.type}`) }}\n </template>\n </wx-table>\n </wx-card>\n </div>\n</template>\n\n<style scoped>\n.wx-inbox-embed {\n display: flex;\n flex-direction: column;\n gap: var(--wx-space-16);\n}\n\n.wx-inbox-embed__snippet {\n display: flex;\n align-items: center;\n gap: var(--wx-space-8);\n margin-top: var(--wx-space-12);\n padding: var(--wx-space-10) var(--wx-space-12);\n border: 1px solid var(--wx-border-default);\n border-radius: var(--wx-radius-md);\n background: var(--wx-bg-subtle);\n}\n\n.wx-inbox-embed__snippet code {\n flex: 1 1 auto;\n min-width: 0;\n overflow-x: auto;\n white-space: pre;\n font-family: var(--wx-font-family-mono);\n font-size: var(--wx-font-size-sm);\n}\n</style>\n","<script setup lang=\"ts\">\nimport { useTranslate } from '@webx-ui/module-admin'\nimport { WxCard, WxFormItem, WxInput, WxSwitch, type LocalizedValue } from '@webx-ui/core'\nimport LocalizedRichText from './LocalizedRichText.vue'\nimport { option } from './options'\nimport type { FormOptions } from './types'\n\n/**\n * What the form is, and what it says once it has been sent.\n *\n * The two halves are on two cards because they are read at two different times: the first is\n * set up once, the second is the sentence a visitor sees and is rewritten whenever the\n * marketing does.\n */\ndefineProps<{ errors: Record<string, string[]> }>()\n\nconst settings = defineModel<{ slug: string; title: LocalizedValue; is_enabled: boolean }>(\n 'settings',\n { required: true },\n)\n\nconst options = defineModel<FormOptions>('options', { required: true })\n\nconst t = useTranslate('webx-inbox')\n\nconst heading = option<LocalizedValue>(options, 'thank-you.heading', {})\nconst text = option<LocalizedValue>(options, 'thank-you.text', {})\nconst submit = option<LocalizedValue>(options, 'design.submit-text', {})\nconst redirect = option<string>(options, 'redirect', '')\n</script>\n\n<template>\n <div class=\"wx-inbox-general\">\n <wx-card>\n <wx-form-item :label=\"t('panel.title')\" :error=\"errors.title?.[0]\" required>\n <wx-input v-model=\"settings.title\" localized />\n </wx-form-item>\n\n <wx-form-item\n :label=\"t('panel.slug')\"\n :help=\"t('panel.slug-help')\"\n :error=\"errors.slug?.[0]\"\n required\n >\n <wx-input v-model=\"settings.slug\" placeholder=\"contact\" />\n </wx-form-item>\n\n <wx-form-item :help=\"t('panel.is-enabled-help')\">\n <wx-switch v-model=\"settings.is_enabled\" :label=\"t('panel.is-enabled')\" />\n </wx-form-item>\n </wx-card>\n\n <wx-card :title=\"t('panel.after-sending')\">\n <wx-form-item :label=\"t('panel.submit-text')\">\n <wx-input v-model=\"submit\" localized />\n </wx-form-item>\n\n <wx-form-item :label=\"t('panel.thank-you-heading')\">\n <wx-input v-model=\"heading\" localized />\n </wx-form-item>\n\n <!-- Printed raw on the site, which is why it is written where formatting is possible. -->\n <wx-form-item :label=\"t('panel.thank-you-text')\">\n <localized-rich-text v-model=\"text\" />\n </wx-form-item>\n\n <wx-form-item :label=\"t('panel.redirect')\" :help=\"t('panel.redirect-help')\">\n <wx-input v-model=\"redirect\" placeholder=\"/thank-you\" />\n </wx-form-item>\n </wx-card>\n </div>\n</template>\n\n<style scoped>\n.wx-inbox-general {\n display: flex;\n flex-direction: column;\n gap: var(--wx-space-16);\n}\n</style>\n","import type { Recipient, RecipientProblem, RecipientState } from './types'\n\n/**\n * Whether a letter would reach somebody, judged on the recipients as they stand in the editor.\n *\n * The server says it for what was saved (`InboxForm.recipients`): who is deleted, who is\n * switched off. The editor has to say it before a save too, so this reads the list being edited\n * and borrows the server's verdict only for the administrators it already knows about — one\n * picked a moment ago from the list of people who may read the section is somebody who exists.\n */\n\n/** Loose on purpose: the server checks the address for real, this only spots an empty line. */\nconst ADDRESS = /^[^\\s@]+@[^\\s@]+$/\n\nexport function isAdmin(recipient: Recipient): recipient is { admin_id: number } {\n return 'admin_id' in recipient\n}\n\n/** Why this recipient would not get a letter, or null when it would. */\nexport function problemOf(\n recipient: Recipient,\n reported: RecipientState[] = [],\n): RecipientProblem | null {\n if (isAdmin(recipient)) {\n const known = reported.find(\n (one) => one.type === 'admin' && one.admin_id === recipient.admin_id,\n )\n\n return known?.problem ?? null\n }\n\n return ADDRESS.test((recipient.email ?? '').trim()) ? null : 'invalid_email'\n}\n\n/** Whether anybody on the list would be written to. */\nexport function reachesAnybody(\n recipients: Recipient[] | undefined,\n reported: RecipientState[] = [],\n): boolean {\n return (recipients ?? []).some((recipient) => problemOf(recipient, reported) === null)\n}\n","<script setup lang=\"ts\">\nimport { computed, onMounted, ref } from 'vue'\nimport { useRouter } from 'vue-router'\nimport { useAdmin, useTranslate, WxRelationsField } from '@webx-ui/module-admin'\nimport {\n confirm,\n WxAction,\n WxAlert,\n WxButton,\n WxIcon,\n WxCard,\n WxFormItem,\n WxInput,\n WxLink,\n WxSelect,\n WxSpace,\n WxText,\n} from '@webx-ui/core'\nimport { createInboxApi } from './api'\nimport { option } from './options'\nimport { isAdmin, problemOf } from './recipients'\nimport type { FormOptions, InboxField, InboxRecipient, Recipient, RecipientState } from './types'\n\n/**\n * Who hears that something arrived (§9).\n *\n * Two kinds of recipient and they are not interchangeable. An administrator is written to at\n * the address on their account and in the language they keep the panel in, so changing either\n * changes it everywhere; a typed address is written to in the language the submission came in.\n * The list offered is not every administrator but the ones who may open a submission — a\n * notification is a link, and sending one to somebody who gets a 403 looks like the panel is\n * broken rather than like the form is.\n *\n * Beside the letter, and never instead of it: the channels of the notifications module, when it\n * is installed (NOTIFICATIONS §15.2) — a Telegram chat, another letter with its own template.\n * The picker asks the event's target on the server for names, so this package needs nothing of\n * that module's code; a site without it never sees the card.\n */\nconst props = defineProps<{\n fields: InboxField[]\n errors: Record<string, string[]>\n /** What the server said about the saved list: who is deleted or switched off. */\n reported?: RecipientState[]\n /** Whether the notifications module is installed — the server says so on the form. */\n notifications?: boolean\n}>()\n\nconst options = defineModel<FormOptions>({ required: true })\n\nconst context = useAdmin()\nconst api = createInboxApi(context)\nconst t = useTranslate('webx-inbox')\n\nconst admins = ref<InboxRecipient[]>([])\n\nconst recipients = option<Recipient[]>(options, 'recipients', [])\nconst emailField = option<string>(options, 'email_field', '')\nconst channels = option<number[]>(options, 'notify_channels', [])\n\nconst router = useRouter()\n\n/* The channels are set up in their own section; only somebody who may do it gets the way there. */\nconst canSetUp = computed(() => context.can('notifications.manage'))\nconst channelsLink = computed(() => `${context.basePath}/notifications`.replace(/\\/{2,}/g, '/'))\n\n/* Inside the panel, without loading it again: the address is for a middle click. */\nfunction setUpChannels(event: MouseEvent): void {\n if (event.metaKey || event.ctrlKey || event.shiftKey || event.button !== 0) return\n\n event.preventDefault()\n void router.push('/notifications')\n}\n\nonMounted(async () => {\n try {\n admins.value = await api.recipients()\n } catch {\n // Only the shortcut is gone: an address can still be typed, and that is the half of this\n // that has to work.\n }\n})\n\nconst adminOptions = computed(() =>\n admins.value.map((admin) => ({ value: admin.id, label: `${admin.name} · ${admin.email}` })),\n)\n\n/** The fields that could hold the sender's address, plus the option of naming none. */\nconst emailOptions = computed(() => [\n { value: '', label: t('panel.no-email-field') },\n ...props.fields\n .filter((field) => field.type === 'email')\n .map((field) => ({ value: field.key, label: field.key })),\n])\n\n/*\n * Only the administrators' problems are said beside the row: an address being typed is not\n * wrong yet, and the server refuses a bad one on save in words of its own.\n */\nfunction adminProblem(recipient: Recipient): string | null {\n if (!isAdmin(recipient)) return null\n\n const problem = problemOf(recipient, props.reported)\n\n return problem === null ? null : t(`panel.recipient-${problem}`)\n}\n\nfunction add(recipient: Recipient): void {\n recipients.value = [...recipients.value, recipient]\n}\n\n/**\n * A recipient goes behind a question, unless there is nothing there to lose.\n *\n * The row that was just added and never filled in is a blank line, and asking about a blank\n * line teaches the reader to click through the question without reading it — which is the\n * one thing a confirmation must not do.\n */\nasync function remove(index: number): Promise<void> {\n const recipient = recipients.value[index]\n const written =\n recipient !== undefined && (isAdmin(recipient) || (recipient.email ?? '').trim() !== '')\n\n if (written) {\n const agreed = await confirm({\n title: t('panel.remove-recipient-title'),\n message: t('panel.remove-recipient-text'),\n confirmText: t('panel.remove'),\n cancelText: t('panel.cancel'),\n tone: 'danger',\n })\n\n if (!agreed) return\n }\n\n recipients.value = recipients.value.filter((_, at) => at !== index)\n}\n\nfunction setAdmin(index: number, id: number): void {\n recipients.value = recipients.value.map((one, at) => (at === index ? { admin_id: id } : one))\n}\n\nfunction setEmail(index: number, email: string): void {\n recipients.value = recipients.value.map((one, at) => (at === index ? { email } : one))\n}\n</script>\n\n<template>\n <div class=\"wx-inbox-notifications\">\n <wx-card :title=\"t('panel.recipients')\">\n <wx-text size=\"sm\" tone=\"muted\">{{ t('panel.recipients-help') }}</wx-text>\n\n <wx-alert\n v-if=\"errors['options.recipients']\"\n type=\"danger\"\n variant=\"soft\"\n :description=\"errors['options.recipients']?.[0]\"\n />\n\n <div class=\"wx-inbox-recipients\">\n <wx-text v-if=\"recipients.length === 0\" size=\"sm\" tone=\"placeholder\">\n {{ t('panel.no-recipients') }}\n </wx-text>\n\n <div\n v-for=\"(recipient, index) in recipients\"\n :key=\"index\"\n class=\"wx-inbox-recipients__item\"\n >\n <div class=\"wx-inbox-recipients__row\">\n <wx-select\n v-if=\"isAdmin(recipient)\"\n :model-value=\"recipient.admin_id\"\n :options=\"adminOptions\"\n @update:model-value=\"(id) => setAdmin(index, Number(id))\"\n />\n <wx-input\n v-else\n :model-value=\"recipient.email\"\n type=\"email\"\n placeholder=\"sales@example.com\"\n @update:model-value=\"(email) => setEmail(index, String(email))\"\n />\n\n <!-- Red, like every other way of taking something away in the panel: the colour is\n what tells the two buttons of a row apart before either is read. -->\n <wx-action\n icon=\"trash\"\n tone=\"danger\"\n :title=\"t('panel.remove')\"\n @click=\"remove(index)\"\n />\n </div>\n <wx-text v-if=\"adminProblem(recipient)\" size=\"sm\" tone=\"danger\">\n {{ adminProblem(recipient) }}\n </wx-text>\n </div>\n </div>\n\n <wx-space size=\"sm\">\n <wx-button\n variant=\"outline\"\n icon=\"user\"\n :disabled=\"adminOptions.length === 0\"\n @click=\"add({ admin_id: Number(adminOptions[0]?.value) })\"\n >\n {{ t('panel.add-admin') }}\n </wx-button>\n <wx-button variant=\"outline\" @click=\"add({ email: '' })\">\n <template #icon><wx-icon name=\"mail\" /></template>\n {{ t('panel.add-email') }}\n </wx-button>\n </wx-space>\n\n <wx-form-item\n :label=\"t('panel.email-field')\"\n :help=\"t('panel.email-field-help')\"\n :error=\"errors['options.email_field']?.[0]\"\n >\n <wx-select v-model=\"emailField\" :options=\"emailOptions\" />\n </wx-form-item>\n </wx-card>\n\n <wx-card v-if=\"props.notifications\" :title=\"t('panel.notify-through')\">\n <wx-text size=\"sm\" tone=\"muted\">{{ t('panel.notify-through-help') }}</wx-text>\n\n <div class=\"wx-inbox-channels\">\n <wx-relations-field\n v-model=\"channels\"\n target=\"notify-inbox-submission\"\n :sortable=\"false\"\n :add-text=\"t('panel.pick-channels')\"\n :empty-text=\"t('panel.no-channels')\"\n />\n <wx-link v-if=\"canSetUp\" :href=\"channelsLink\" size=\"sm\" @click=\"setUpChannels\">{{\n t('panel.set-up-channels')\n }}</wx-link>\n </div>\n </wx-card>\n </div>\n</template>\n\n<style scoped>\n/* The letter and the channels: two cards, the panel's step between them. */\n.wx-inbox-notifications {\n display: flex;\n flex-direction: column;\n gap: var(--wx-gap, var(--wx-space-16));\n}\n\n/*\n * As wide as a field, because that is what each row is: an address is typed into it and read\n * back off it. The rows are not form items — one of them is a select, the next an input, and\n * both carry a bin — so the cap that a form item applies has to be said here.\n */\n.wx-inbox-recipients {\n display: flex;\n flex-direction: column;\n gap: var(--wx-space-8);\n margin-block: var(--wx-space-12);\n max-width: var(--wx-field-max-width, 640px);\n}\n\n.wx-inbox-channels {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n gap: var(--wx-space-8);\n margin-block-start: var(--wx-space-12);\n max-width: var(--wx-field-max-width, 640px);\n}\n\n.wx-inbox-channels > :first-child {\n align-self: stretch;\n}\n\n.wx-inbox-recipients__item {\n display: flex;\n flex-direction: column;\n gap: var(--wx-space-4);\n}\n\n.wx-inbox-recipients__row {\n display: flex;\n align-items: center;\n gap: var(--wx-space-8);\n}\n\n.wx-inbox-recipients__row > :first-child {\n flex: 1 1 auto;\n min-width: 0;\n}\n</style>\n","<script setup lang=\"ts\">\nimport { computed, reactive, ref, watch } from 'vue'\nimport { useRoute, useRouter } from 'vue-router'\nimport { useAdmin, useErrorText, useTranslate, WxScreenHead } from '@webx-ui/module-admin'\nimport {\n localizedValue,\n toast,\n useLocales,\n WxActionBar,\n WxAlert,\n WxBadge,\n WxButton,\n WxCard,\n WxSkeleton,\n WxTab,\n WxTabs,\n type LocalizedValue,\n} from '@webx-ui/core'\nimport FieldList from './FieldList.vue'\nimport FormAntispam from './FormAntispam.vue'\nimport FormEmbed from './FormEmbed.vue'\nimport FormGeneral from './FormGeneral.vue'\nimport FormNotifications from './FormNotifications.vue'\nimport { createInboxApi } from './api'\nimport { reachesAnybody } from './recipients'\nimport { useInboxMessages } from './i18n'\nimport type { FormOptions, InboxField, InboxForm, Recipient } from './types'\n\n/**\n * One form: what it is called, what it asks, who hears about it, and how it is put on a page.\n *\n * Five tabs and one save. The fields are the exception — a question is written in its own\n * dialog and saved on its own, because it is a row with an identity (§2.1) and because a\n * dragged order that waited for a save button would be an order nobody trusts.\n */\nconst props = withDefaults(defineProps<{ base?: string }>(), { base: '/inbox' })\n\nconst context = useAdmin()\nconst api = createInboxApi(context)\nconst route = useRoute()\nconst router = useRouter()\nconst locales = useLocales()\nuseInboxMessages()\n\nconst t = useTranslate('webx-inbox')\n/* Not the server's `message`: the panel says how a request failed in its own words. */\nconst message = useErrorText()\n\nconst form = ref<InboxForm | null>(null)\nconst fields = ref<InboxField[]>([])\nconst loading = ref(true)\nconst saving = ref(false)\nconst errors = ref<Record<string, string[]>>({})\n\nconst settings = reactive<{ slug: string; title: LocalizedValue; is_enabled: boolean }>({\n slug: '',\n title: {},\n is_enabled: true,\n})\n\nconst options = ref<FormOptions>({})\n\nconst TABS = ['general', 'fields', 'notifications', 'antispam', 'embed']\n\n/* Opened on the tab the address names, so the audit's \"open\" lands on the recipients. */\nconst tab = ref(TABS.includes(String(route.query.tab)) ? String(route.query.tab) : 'general')\n\n/*\n * Said above the tabs and not only inside Notifications: a form that tells nobody works in\n * every way somebody can see — the site thanks the visitor, the panel keeps the enquiry — so\n * the only place the gap shows is a line nobody went looking for.\n */\nconst silent = computed(\n () =>\n settings.is_enabled &&\n !reachesAnybody(options.value.recipients as Recipient[] | undefined, form.value?.recipients) &&\n !channelsSend.value,\n)\n\n/*\n * A channel chosen and switched on tells somebody too. One chosen since the form was loaded is\n * taken at its word until the save says otherwise: the server names only what was saved.\n */\nconst channelsSend = computed(() => {\n if (form.value?.notifications !== true) return false\n\n const reported = form.value.channels ?? []\n\n return (options.value.notify_channels ?? []).some(\n (id) => reported.find((channel) => channel.id === id)?.sends ?? true,\n )\n})\n\nconst canManage = computed(() => context.can('inbox.manage'))\n\nconst id = computed(() => Number(route.params.id))\n\nconst name = computed(() =>\n form.value === null ? '' : localizedValue(settings.title, locales.active.value, settings.slug),\n)\n\n/** Where a submission would come back to: the section, with this form already chosen. */\nconst backTo = computed(() => `${props.base}?form=${id.value}`)\n\nasync function load(): Promise<void> {\n loading.value = true\n\n try {\n const loaded = await api.form(id.value)\n\n form.value = loaded\n fields.value = loaded.fields ?? []\n settings.slug = loaded.slug\n settings.title = { ...loaded.title }\n settings.is_enabled = loaded.is_enabled\n options.value = { ...loaded.options }\n } catch (error) {\n toast.danger(message(error))\n void router.replace(props.base)\n } finally {\n loading.value = false\n }\n}\n\nwatch(id, () => void load(), { immediate: true })\n\nasync function save(): Promise<void> {\n saving.value = true\n errors.value = {}\n\n try {\n const saved = await api.saveForm(id.value, {\n slug: settings.slug.trim(),\n title: settings.title,\n is_enabled: settings.is_enabled,\n options: options.value,\n })\n\n form.value = saved\n toast.success(t('panel.saved'))\n } catch (error) {\n const body = (error as { body?: { errors?: Record<string, string[]> } }).body\n\n if (body?.errors) {\n errors.value = body.errors\n toast.danger(t('panel.failed'))\n } else {\n toast.danger(message(error))\n }\n } finally {\n saving.value = false\n }\n}\n</script>\n\n<template>\n <!--\n Not a screen that fills its column, whatever the first draft said. `data-wx-fill` makes the\n screen exactly as tall as the window, and nothing inside these tabs scrolls on its own — so\n a form longer than the window grew straight through the box, and the save bar, which is the\n next thing in the column, was drawn across the middle of it with fields still going on\n underneath. What this screen wants is the ordinary thing: the page scrolls, the bar sticks\n to the bottom of it, and `WxMain` gives the screen a floor to push that bar down to.\n -->\n <div class=\"wx-inbox-editor\">\n <!-- On a card, like everything else on this screen: a bare skeleton flush against the\n page is a shape the form that follows it never takes, so the screen jumps twice —\n once when the card appears around it, once when the fields land inside. -->\n <wx-card v-if=\"loading\">\n <wx-skeleton title :rows=\"8\" />\n </wx-card>\n\n <template v-else-if=\"form\">\n <wx-screen-head\n class=\"wx-inbox-editor__head\"\n :title=\"name\"\n :subtitle=\"form.slug\"\n :back=\"backTo\"\n :back-label=\"t('panel.forms')\"\n >\n <template #title-after>\n <wx-badge v-if=\"!settings.is_enabled\" type=\"default\">{{ t('panel.off') }}</wx-badge>\n </template>\n </wx-screen-head>\n\n <!--\n Every tab is mounted at once and the hidden ones keep their state: somebody who wrote\n a thank-you, went to look at the fields and came back should find it still written.\n -->\n <wx-alert\n v-if=\"silent\"\n class=\"wx-inbox-editor__silent\"\n type=\"warning\"\n variant=\"soft\"\n :closable=\"false\"\n :title=\"t('panel.notifies-nobody')\"\n :description=\"t('panel.notifies-nobody-text')\"\n />\n\n <wx-tabs v-model=\"tab\" class=\"wx-inbox-editor__tabs\" keep-alive>\n <wx-tab value=\"general\" :label=\"t('panel.tab-general')\">\n <form-general v-model:settings=\"settings\" v-model:options=\"options\" :errors=\"errors\" />\n </wx-tab>\n\n <wx-tab value=\"fields\" :label=\"t('panel.tab-fields')\">\n <field-list v-model=\"fields\" :form=\"form\" :can-manage=\"canManage\" />\n </wx-tab>\n\n <wx-tab value=\"notifications\" :label=\"t('panel.tab-notifications')\">\n <form-notifications\n v-model=\"options\"\n :fields=\"fields\"\n :errors=\"errors\"\n :reported=\"form.recipients\"\n :notifications=\"form.notifications\"\n />\n </wx-tab>\n\n <wx-tab value=\"antispam\" :label=\"t('panel.tab-antispam')\">\n <form-antispam v-model=\"options\" :site=\"form.captcha\" />\n </wx-tab>\n\n <wx-tab value=\"embed\" :label=\"t('panel.tab-embed')\">\n <form-embed :form=\"form\" :slug=\"settings.slug\" :fields=\"fields\" />\n </wx-tab>\n </wx-tabs>\n\n <wx-action-bar v-if=\"canManage\">\n <wx-button type=\"primary\" :loading=\"saving\" @click=\"save\">{{ t('panel.save') }}</wx-button>\n </wx-action-bar>\n </template>\n </div>\n</template>\n\n<style scoped>\n.wx-inbox-editor {\n display: flex;\n flex-direction: column;\n /* The panel's own step, which is smaller on a phone than on a desktop. */\n gap: var(--wx-gap, var(--wx-space-16));\n}\n\n/* The tabs take what is left of the column, so the save bar under them is at its bottom\n rather than under the last field. Nothing inside them scrolls on its own — the page does. */\n/* The address it posts to, in the type an address is written in. */\n.wx-inbox-editor__head :deep(.wx-screen-head__subtitle) {\n font-family: var(--wx-font-family-mono);\n}\n\n.wx-inbox-editor__tabs {\n flex: 1 1 auto;\n}\n</style>\n"],"names":["options","_useModel","__props","props","t","useTranslate","honeypot","option","seconds","throttle","captcha","captchas","computed","chosen","provider","kind","site","_createBlock","_unref","WxCard","_createVNode","WxFormItem","WxSwitch","$event","WxInputNumber","WxSelect","WxText","WxAlert","useInboxMessages","admin","useAdmin","hasBlocks","module","blade","block","hidden","field","extras","columns","listed","copy","text","toast","_openBlock","_createElementBlock","_hoisted_1","_createElementVNode","_hoisted_2","WxAction","_cache","_createTextVNode","_toDisplayString","_hoisted_3","_hoisted_4","WxTable","_withCtx","row","settings","heading","submit","redirect","WxInput","LocalizedRichText","ADDRESS","isAdmin","recipient","problemOf","reported","one","reachesAnybody","recipients","context","api","createInboxApi","admins","ref","emailField","channels","router","useRouter","canSetUp","channelsLink","setUpChannels","event","onMounted","adminOptions","emailOptions","adminProblem","problem","add","remove","index","confirm","_","at","setAdmin","id","setEmail","email","_Fragment","_renderList","WxSpace","WxButton","WxIcon","WxRelationsField","WxLink","route","useRoute","locales","useLocales","message","useErrorText","form","fields","loading","saving","errors","reactive","tab","silent","channelsSend","channel","canManage","name","localizedValue","backTo","load","loaded","error","watch","save","saved","body","WxSkeleton","WxScreenHead","WxBadge","WxTabs","WxTab","FormGeneral","FieldList","FormNotifications","FormAntispam","FormEmbed","WxActionBar"],"mappings":";;;;;;;;;;;;;;;AA2BA,UAAMA,IAAUC,EAAwBC,GAAA,YAAmB,GAErDC,IAAQD,GAKRE,IAAIC,EAAa,YAAY,GAE7BC,IAAWC,EAAgBP,GAAS,qBAAqB,EAAI,GAC7DQ,IAAUD,EAAeP,GAAS,wBAAwB,CAAC,GAC3DS,IAAWF,EAAeP,GAAS,qBAAqB,CAAC,GACzDU,IAAUH,EAAeP,GAAS,oBAAoB,KAAK,GAE3DW,IAA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,MAAK;AAAA,kBACf,eAAeA,EAAA,MAAK;AAAA,gBAAA;;;;YAIzB5F,EAESF,EAAAuH,CAAA,GAAA;AAAA,cAFD,OAAM;AAAA,cAAY,OAAOvH,EAAAd,CAAA,EAAC,oBAAA;AAAA,YAAA;yBAChC,MAAwD;AAAA,gBAAxDgB,EAAwDyH,IAAA;AAAA,8BAAhC7I,EAAA;AAAA,gEAAAA,EAAO,QAAAuB;AAAA,kBAAG,MAAMyF,EAAA,MAAK;AAAA,gBAAA;;;;YAG/C5F,EAESF,EAAAuH,CAAA,GAAA;AAAA,cAFD,OAAM;AAAA,cAAS,OAAOvH,EAAAd,CAAA,EAAC,iBAAA;AAAA,YAAA;yBAC7B,MAAkE;AAAA,gBAAlEgB,EAAkE0H,IAAA;AAAA,kBAArD,MAAM9B,EAAA;AAAA,kBAAO,MAAM9F,EAAAuC,CAAA,EAAS;AAAA,kBAAO,QAAQwD,EAAA;AAAA,gBAAA;;;;;;;QAIvCS,EAAA,cAArBzG,EAEgBC,EAAA6H,EAAA,GAAA,EAAA,KAAA,KAAA;AAAA,qBADd,MAA2F;AAAA,YAA3F3H,EAA2FF,EAAAoF,EAAA,GAAA;AAAA,cAAhF,MAAK;AAAA,cAAW,SAASa,EAAA;AAAA,cAAS,SAAOe;AAAA,YAAA;yBAAM,MAAqB;AAAA,oBAAlBhH,EAAAd,CAAA,EAAC,YAAA,CAAA,GAAA,CAAA;AAAA,cAAA;;;;;;;;;;"}
@@ -0,0 +1,18 @@
1
+ type __VLS_Props = {
2
+ disabled?: boolean;
3
+ placeholder?: string;
4
+ emptyText?: string;
5
+ };
6
+ type __VLS_PublicProps = {
7
+ modelValue?: string | null;
8
+ } & __VLS_Props;
9
+ declare const _default: import('vue').DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
10
+ "update:modelValue": (value: string | null) => any;
11
+ }, string, import('vue').PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
12
+ "onUpdate:modelValue"?: ((value: string | null) => any) | undefined;
13
+ }>, {
14
+ placeholder: string;
15
+ disabled: boolean;
16
+ emptyText: string;
17
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
18
+ export default _default;
@@ -8,12 +8,19 @@ import { FormOptions, InboxField, RecipientState } from './types';
8
8
  * The list offered is not every administrator but the ones who may open a submission — a
9
9
  * notification is a link, and sending one to somebody who gets a 403 looks like the panel is
10
10
  * broken rather than like the form is.
11
+ *
12
+ * Beside the letter, and never instead of it: the channels of the notifications module, when it
13
+ * is installed (NOTIFICATIONS §15.2) — a Telegram chat, another letter with its own template.
14
+ * The picker asks the event's target on the server for names, so this package needs nothing of
15
+ * that module's code; a site without it never sees the card.
11
16
  */
12
17
  type __VLS_Props = {
13
18
  fields: InboxField[];
14
19
  errors: Record<string, string[]>;
15
20
  /** What the server said about the saved list: who is deleted or switched off. */
16
21
  reported?: RecipientState[];
22
+ /** Whether the notifications module is installed — the server says so on the form. */
23
+ notifications?: boolean;
17
24
  };
18
25
  type __VLS_PublicProps = {
19
26
  modelValue: FormOptions;
@@ -22,5 +29,5 @@ declare const _default: import('vue').DefineComponent<__VLS_PublicProps, {}, {},
22
29
  "update:modelValue": (value: FormOptions) => any;
23
30
  }, string, import('vue').PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
24
31
  "onUpdate:modelValue"?: ((value: FormOptions) => any) | undefined;
25
- }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLElement>;
32
+ }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
26
33
  export default _default;
@@ -0,0 +1,387 @@
1
+ import { defineComponent as J, ref as _, openBlock as d, createBlock as p, unref as e, isRef as re, withCtx as l, createElementVNode as R, createVNode as o, createTextVNode as V, toDisplayString as F, useTemplateRef as ie, computed as $, watch as ue, createSlots as E, createElementBlock as ce, Fragment as de, createCommentVNode as L, normalizeClass as A } from "vue";
2
+ import { useRoute as pe, useRouter as fe } from "vue-router";
3
+ import { useAdmin as K, useTranslate as Q, useErrorText as X, WxListScreen as me, WxRowMenu as ve } from "@webx-ui/module-admin";
4
+ import { useModal as be, WxDialog as xe, WxFormItem as O, WxInput as P, WxSpace as ye, WxButton as T, toast as y, useLocales as _e, createModal as ge, WxCard as we, WxListDetail as ke, WxSkeleton as j, WxEmpty as We, WxIcon as N, WxSortableList as he, WxText as G, WxIndicator as H, WxAction as Ce, localizedValue as Ve, confirm as Fe } from "@webx-ui/core";
5
+ import { c as Y, u as Z, _ as Ie, S as Se } from "./index-BQj2UlUS.js";
6
+ const qe = { class: "wx-inbox-create" }, $e = /* @__PURE__ */ J({
7
+ __name: "FormCreateDialog",
8
+ setup(U) {
9
+ const { resolve: I, dismiss: w, open: m } = be(), k = K(), g = Y(k);
10
+ Z();
11
+ const f = Q("webx-inbox"), a = X(), v = _({}), u = _(""), b = _(!1), W = _({});
12
+ function S(c) {
13
+ return W.value[c]?.[0];
14
+ }
15
+ async function q() {
16
+ b.value = !0, W.value = {};
17
+ try {
18
+ I(
19
+ await g.createForm({
20
+ title: v.value,
21
+ slug: u.value.trim(),
22
+ is_enabled: !0,
23
+ options: {}
24
+ })
25
+ );
26
+ } catch (c) {
27
+ const i = c.body;
28
+ i?.errors ? (W.value = i.errors, y.danger(f("panel.failed"))) : y.danger(a(c));
29
+ } finally {
30
+ b.value = !1;
31
+ }
32
+ }
33
+ return (c, i) => (d(), p(e(xe), {
34
+ open: e(m),
35
+ "onUpdate:open": i[3] || (i[3] = (x) => re(m) ? m.value = x : null),
36
+ title: e(f)("panel.new-form-title"),
37
+ width: 520
38
+ }, {
39
+ footer: l(() => [
40
+ o(e(ye), { size: "sm" }, {
41
+ default: l(() => [
42
+ o(e(T), {
43
+ variant: "outline",
44
+ onClick: i[2] || (i[2] = (x) => e(w)())
45
+ }, {
46
+ default: l(() => [
47
+ V(F(e(f)("panel.cancel")), 1)
48
+ ]),
49
+ _: 1
50
+ }),
51
+ o(e(T), {
52
+ type: "primary",
53
+ loading: b.value,
54
+ onClick: q
55
+ }, {
56
+ default: l(() => [
57
+ V(F(e(f)("panel.save")), 1)
58
+ ]),
59
+ _: 1
60
+ }, 8, ["loading"])
61
+ ]),
62
+ _: 1
63
+ })
64
+ ]),
65
+ default: l(() => [
66
+ R("div", qe, [
67
+ o(e(O), {
68
+ label: e(f)("panel.title"),
69
+ error: S("title"),
70
+ required: ""
71
+ }, {
72
+ default: l(() => [
73
+ o(e(P), {
74
+ modelValue: v.value,
75
+ "onUpdate:modelValue": i[0] || (i[0] = (x) => v.value = x),
76
+ localized: "",
77
+ autofocus: ""
78
+ }, null, 8, ["modelValue"])
79
+ ]),
80
+ _: 1
81
+ }, 8, ["label", "error"]),
82
+ o(e(O), {
83
+ label: e(f)("panel.slug"),
84
+ help: e(f)("panel.slug-help"),
85
+ error: S("slug")
86
+ }, {
87
+ default: l(() => [
88
+ o(e(P), {
89
+ modelValue: u.value,
90
+ "onUpdate:modelValue": i[1] || (i[1] = (x) => u.value = x),
91
+ placeholder: "contact"
92
+ }, null, 8, ["modelValue"])
93
+ ]),
94
+ _: 1
95
+ }, 8, ["label", "help", "error"])
96
+ ])
97
+ ]),
98
+ _: 1
99
+ }, 8, ["open", "title"]));
100
+ }
101
+ }), ze = /* @__PURE__ */ Ie($e, [["__scopeId", "data-v-55fb40d8"]]), Te = ["onClick"], Me = { class: "wx-inbox-form__name" }, Ee = /* @__PURE__ */ J({
102
+ __name: "InboxPage",
103
+ props: {
104
+ base: { default: "/inbox" }
105
+ },
106
+ setup(U) {
107
+ const I = U, w = K(), m = Y(w), k = pe(), g = fe(), f = _e();
108
+ Z();
109
+ const a = Q("webx-inbox"), v = X(), u = _([]), b = _(!0), W = ie("pane"), S = _(!0), q = _(!1), c = $(() => w.can("inbox.manage")), i = ge(ze), x = $(
110
+ () => w.state.manifest?.modules.find((t) => t.id === "inbox")?.title ?? a("module.title")
111
+ ), M = $(() => {
112
+ const t = k.query.form;
113
+ return typeof t == "string" && t !== "" ? Number(t) : null;
114
+ }), h = $(() => u.value.find((t) => t.id === M.value) ?? null);
115
+ function z(t) {
116
+ return Ve(t.title, f.active.value, t.slug);
117
+ }
118
+ async function C() {
119
+ b.value = !0;
120
+ try {
121
+ u.value = await m.forms();
122
+ } catch (t) {
123
+ y.danger(v(t));
124
+ } finally {
125
+ b.value = !1;
126
+ }
127
+ }
128
+ C(), ue([u, h], () => {
129
+ u.value.length === 0 || h.value !== null || g.replace({ query: { ...k.query, form: String(u.value[0].id) } });
130
+ });
131
+ function ee(t, s) {
132
+ g.replace({ query: { ...k.query, form: String(t.id) } }), s();
133
+ }
134
+ function D(t) {
135
+ g.push(`${I.base}/forms/${t.id}`);
136
+ }
137
+ function te(t) {
138
+ return c.value ? [
139
+ { key: "settings", icon: "settings", label: a("panel.settings"), run: () => D(t) },
140
+ { key: "duplicate", icon: "copy", label: a("panel.duplicate"), run: () => ae(t) },
141
+ // A form that has taken submissions is switched off, never deleted (§2.4). The line is
142
+ // left out rather than greyed: a menu is a list of what is possible.
143
+ ...t.submissions_count === 0 ? [
144
+ {
145
+ key: "delete",
146
+ icon: "trash",
147
+ label: a("panel.delete"),
148
+ danger: !0,
149
+ run: () => le(t)
150
+ }
151
+ ] : []
152
+ ] : [];
153
+ }
154
+ async function B() {
155
+ const t = await i({});
156
+ t && (await C(), D(t));
157
+ }
158
+ async function ae(t) {
159
+ try {
160
+ const s = await m.duplicateForm(t.id);
161
+ y.success(a("panel.duplicated")), await C(), D(s);
162
+ } catch (s) {
163
+ y.danger(v(s));
164
+ }
165
+ }
166
+ async function le(t) {
167
+ if (await Fe({
168
+ title: a("panel.delete-form-title", { form: z(t) }),
169
+ message: a("panel.delete-form-text"),
170
+ confirmText: a("panel.delete"),
171
+ cancelText: a("panel.cancel"),
172
+ tone: "danger"
173
+ }))
174
+ try {
175
+ if (await m.removeForm(t.id), y.success(a("panel.deleted")), M.value === t.id) {
176
+ const r = { ...k.query };
177
+ delete r.form, g.replace({ query: r });
178
+ }
179
+ await C();
180
+ } catch (r) {
181
+ y.danger(v(r));
182
+ }
183
+ }
184
+ async function ne() {
185
+ try {
186
+ await m.sortForms(u.value.map((t) => t.id));
187
+ } catch (t) {
188
+ y.danger(v(t, a("panel.reorder-failed"))), await C();
189
+ }
190
+ }
191
+ const oe = $(() => {
192
+ const t = [];
193
+ return c.value && t.push({
194
+ key: "statuses",
195
+ label: a("panel.statuses"),
196
+ icon: "tag",
197
+ run: () => {
198
+ g.push(`${I.base}/statuses`);
199
+ }
200
+ }), w.can("inbox.update") && h.value !== null && t.push({
201
+ key: "new-submission",
202
+ label: a("panel.new-submission"),
203
+ icon: "plus",
204
+ primary: !0,
205
+ run: () => {
206
+ W.value?.create();
207
+ }
208
+ }), t;
209
+ });
210
+ return (t, s) => (d(), p(e(me), {
211
+ title: x.value,
212
+ actions: oe.value,
213
+ card: !1
214
+ }, E({
215
+ default: l(() => [
216
+ o(e(we), {
217
+ class: "wx-inbox",
218
+ padding: "none"
219
+ }, {
220
+ default: l(() => [
221
+ o(e(ke), {
222
+ "filters-open": q.value,
223
+ "onUpdate:filtersOpen": s[2] || (s[2] = (r) => q.value = r),
224
+ class: "wx-inbox__panes",
225
+ "filters-width": 270,
226
+ "detail-min": 420,
227
+ "filters-title": e(a)("panel.forms"),
228
+ onFiltersInline: s[3] || (s[3] = (r) => S.value = r)
229
+ }, {
230
+ filters: l(({ inline: r, close: se }) => [
231
+ b.value ? (d(), p(e(j), {
232
+ key: 0,
233
+ class: "wx-inbox__loading",
234
+ rows: 5
235
+ })) : (d(), ce(de, { key: 1 }, [
236
+ !r && c.value ? (d(), p(e(T), {
237
+ key: 0,
238
+ class: "wx-inbox__new-form",
239
+ variant: "outline",
240
+ block: "",
241
+ onClick: B
242
+ }, {
243
+ icon: l(() => [
244
+ o(e(N), { name: "plus" })
245
+ ]),
246
+ default: l(() => [
247
+ V(" " + F(e(a)("panel.new-form")), 1)
248
+ ]),
249
+ _: 1
250
+ })) : L("", !0),
251
+ o(e(he), {
252
+ modelValue: u.value,
253
+ "onUpdate:modelValue": s[1] || (s[1] = (n) => u.value = n),
254
+ class: A(["wx-inbox__forms", { "is-panel": !r }]),
255
+ plain: "",
256
+ size: "sm",
257
+ "item-key": "id",
258
+ "item-label": z,
259
+ "drag-label": e(a)("panel.reorder"),
260
+ disabled: !c.value,
261
+ title: r ? e(a)("panel.forms") : void 0,
262
+ onMove: ne
263
+ }, E({
264
+ default: l(({ item: n }) => [
265
+ R("button", {
266
+ type: "button",
267
+ class: A(["wx-inbox-form", { "is-current": n.id === M.value, "is-off": !n.is_enabled }]),
268
+ onClick: (De) => ee(n, se)
269
+ }, [
270
+ R("span", Me, [
271
+ o(e(G), {
272
+ truncate: "",
273
+ weight: "medium",
274
+ tone: n.is_enabled ? "default" : "muted"
275
+ }, {
276
+ default: l(() => [
277
+ V(F(z(n)), 1)
278
+ ]),
279
+ _: 2
280
+ }, 1032, ["tone"]),
281
+ n.is_enabled && n.notifies === !1 ? (d(), p(e(N), {
282
+ key: 0,
283
+ class: "wx-inbox-form__silent",
284
+ name: "warning",
285
+ label: e(a)("panel.notifies-nobody-short"),
286
+ title: e(a)("panel.notifies-nobody-short")
287
+ }, null, 8, ["label", "title"])) : L("", !0),
288
+ n.unread_count ? (d(), p(e(H), {
289
+ key: 1,
290
+ class: "wx-inbox-form__count",
291
+ type: "primary",
292
+ value: n.unread_count,
293
+ label: e(a)("panel.unread")
294
+ }, null, 8, ["value", "label"])) : n.submissions_count ? (d(), p(e(H), {
295
+ key: 2,
296
+ class: "wx-inbox-form__count",
297
+ type: "neutral",
298
+ value: n.submissions_count,
299
+ label: e(a)("panel.submissions")
300
+ }, null, 8, ["value", "label"])) : L("", !0)
301
+ ]),
302
+ o(e(G), {
303
+ size: "sm",
304
+ tone: "muted",
305
+ truncate: ""
306
+ }, {
307
+ default: l(() => [
308
+ V(F(n.slug), 1)
309
+ ]),
310
+ _: 2
311
+ }, 1024)
312
+ ], 10, Te)
313
+ ]),
314
+ actions: l(({ item: n }) => [
315
+ o(e(ve), {
316
+ actions: te(n),
317
+ label: z(n)
318
+ }, null, 8, ["actions", "label"])
319
+ ]),
320
+ _: 2
321
+ }, [
322
+ r && c.value ? {
323
+ name: "extra",
324
+ fn: l(() => [
325
+ o(e(Ce), {
326
+ icon: "plus",
327
+ size: "sm",
328
+ title: e(a)("panel.new-form"),
329
+ onClick: B
330
+ }, null, 8, ["title"])
331
+ ]),
332
+ key: "0"
333
+ } : void 0
334
+ ]), 1032, ["modelValue", "class", "drag-label", "disabled", "title"])
335
+ ], 64))
336
+ ]),
337
+ list: l(() => [
338
+ b.value ? (d(), p(e(j), {
339
+ key: 0,
340
+ class: "wx-inbox__loading",
341
+ rows: 6
342
+ })) : h.value ? (d(), p(Se, {
343
+ ref_key: "pane",
344
+ ref: W,
345
+ key: h.value.id,
346
+ form: h.value,
347
+ base: I.base,
348
+ onChanged: C
349
+ }, null, 8, ["form", "base"])) : (d(), p(e(We), {
350
+ key: 2,
351
+ title: e(a)("panel.no-forms"),
352
+ description: e(a)("panel.no-forms-help")
353
+ }, null, 8, ["title", "description"]))
354
+ ]),
355
+ _: 1
356
+ }, 8, ["filters-open", "filters-title"])
357
+ ]),
358
+ _: 1
359
+ })
360
+ ]),
361
+ _: 2
362
+ }, [
363
+ S.value ? void 0 : {
364
+ name: "actions",
365
+ fn: l(() => [
366
+ o(e(T), {
367
+ variant: "outline",
368
+ onClick: s[0] || (s[0] = (r) => q.value = !0)
369
+ }, {
370
+ icon: l(() => [
371
+ o(e(N), { name: "list" })
372
+ ]),
373
+ default: l(() => [
374
+ V(" " + F(e(a)("panel.forms")), 1)
375
+ ]),
376
+ _: 1
377
+ })
378
+ ]),
379
+ key: "0"
380
+ }
381
+ ]), 1032, ["title", "actions"]));
382
+ }
383
+ });
384
+ export {
385
+ Ee as default
386
+ };
387
+ //# sourceMappingURL=InboxPage-CCYXnZed.js.map