@micacms/editor-ui 0.5.0-rc.2 → 0.5.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/{ChangesView-CSjnT0fh.js → ChangesView-DVLSWguI.js} +2 -2
- package/dist/assets/{ChangesView-CSjnT0fh.js.map → ChangesView-DVLSWguI.js.map} +1 -1
- package/dist/assets/CollectionView-Dm0AZ-4T.js +2 -0
- package/dist/assets/CollectionView-Dm0AZ-4T.js.map +1 -0
- package/dist/assets/ConfirmDialog.vue_vue_type_script_setup_true_lang-BY6pag2U.js +2 -0
- package/dist/assets/{ConfirmDialog.vue_vue_type_script_setup_true_lang-C073kW3p.js.map → ConfirmDialog.vue_vue_type_script_setup_true_lang-BY6pag2U.js.map} +1 -1
- package/dist/assets/{DashboardView-BpelkVGe.js → DashboardView-DHf6CKvk.js} +2 -2
- package/dist/assets/{DashboardView-BpelkVGe.js.map → DashboardView-DHf6CKvk.js.map} +1 -1
- package/dist/assets/EntryView-DX4MCIIz.js +2 -0
- package/dist/assets/EntryView-DX4MCIIz.js.map +1 -0
- package/dist/assets/{LoginView-BmnX2zOD.js → LoginView-D3ztIdgO.js} +2 -2
- package/dist/assets/{LoginView-BmnX2zOD.js.map → LoginView-D3ztIdgO.js.map} +1 -1
- package/dist/assets/{MediaView-Dp2botAQ.js → MediaView-CeF4DCQR.js} +2 -2
- package/dist/assets/{MediaView-Dp2botAQ.js.map → MediaView-CeF4DCQR.js.map} +1 -1
- package/dist/assets/{NotFoundView-ByEOgkxm.js → NotFoundView-DvofX918.js} +2 -2
- package/dist/assets/{NotFoundView-ByEOgkxm.js.map → NotFoundView-DvofX918.js.map} +1 -1
- package/dist/assets/ObjectField--_IMDLHp.js +2 -0
- package/dist/assets/{ObjectField-BSITpnGH.js.map → ObjectField--_IMDLHp.js.map} +1 -1
- package/dist/assets/{PageHeader.vue_vue_type_script_setup_true_lang-DJWhe1Ye.js → PageHeader.vue_vue_type_script_setup_true_lang-Cr0v1G7O.js} +2 -2
- package/dist/assets/{PageHeader.vue_vue_type_script_setup_true_lang-DJWhe1Ye.js.map → PageHeader.vue_vue_type_script_setup_true_lang-Cr0v1G7O.js.map} +1 -1
- package/dist/assets/ReadOnlyNotice.vue_vue_type_script_setup_true_lang-BtfQSv1l.js +7 -0
- package/dist/assets/ReadOnlyNotice.vue_vue_type_script_setup_true_lang-BtfQSv1l.js.map +1 -0
- package/dist/assets/{RepeaterField-BnXDf3wL.js → RepeaterField-CRo8CLz6.js} +2 -2
- package/dist/assets/{RepeaterField-BnXDf3wL.js.map → RepeaterField-CRo8CLz6.js.map} +1 -1
- package/dist/assets/SingletonView-C1VhZ6Vv.js +2 -0
- package/dist/assets/SingletonView-C1VhZ6Vv.js.map +1 -0
- package/dist/assets/{SystemView-C6RAZvd2.js → SystemView-Bc2he_Af.js} +2 -2
- package/dist/assets/{SystemView-C6RAZvd2.js.map → SystemView-Bc2he_Af.js.map} +1 -1
- package/dist/assets/{arrow-right-DD5BWXHV.js → arrow-right-D8-sqdXS.js} +2 -2
- package/dist/assets/{arrow-right-DD5BWXHV.js.map → arrow-right-D8-sqdXS.js.map} +1 -1
- package/dist/assets/{arrow-up-Bdxg9_RJ.js → arrow-up-Bg3MuXmP.js} +2 -2
- package/dist/assets/{arrow-up-Bdxg9_RJ.js.map → arrow-up-Bg3MuXmP.js.map} +1 -1
- package/dist/assets/{chevron-down-CcJtiSTR.js → chevron-down-CnhoXsgY.js} +2 -2
- package/dist/assets/{chevron-down-CcJtiSTR.js.map → chevron-down-CnhoXsgY.js.map} +1 -1
- package/dist/assets/{index-BsOOwFCf.js → index-BHBq4-Io.js} +3 -3
- package/dist/assets/{index-BsOOwFCf.js.map → index-BHBq4-Io.js.map} +1 -1
- package/dist/assets/{useField-BxptRsz_.js → useField-vKkdSfn7.js} +2 -2
- package/dist/assets/{useField-BxptRsz_.js.map → useField-vKkdSfn7.js.map} +1 -1
- package/dist/assets/{useUnsavedChanges-FB5XcFfI.js → useUnsavedChanges-FKPfUHdo.js} +17 -17
- package/dist/assets/useUnsavedChanges-FKPfUHdo.js.map +1 -0
- package/dist/index.html +1 -1
- package/package.json +2 -2
- package/dist/assets/CollectionView-BlLAhVVi.js +0 -2
- package/dist/assets/CollectionView-BlLAhVVi.js.map +0 -1
- package/dist/assets/ConfirmDialog.vue_vue_type_script_setup_true_lang-C073kW3p.js +0 -2
- package/dist/assets/EntryView-DZuhqJnd.js +0 -2
- package/dist/assets/EntryView-DZuhqJnd.js.map +0 -1
- package/dist/assets/ObjectField-BSITpnGH.js +0 -2
- package/dist/assets/SingletonView-Cb8Qq_gr.js +0 -2
- package/dist/assets/SingletonView-Cb8Qq_gr.js.map +0 -1
- package/dist/assets/plus-CgaTSYYb.js +0 -7
- package/dist/assets/plus-CgaTSYYb.js.map +0 -1
- package/dist/assets/useUnsavedChanges-FB5XcFfI.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EntryView-DX4MCIIz.js","sources":["../../src/views/EntryView.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/**\n * Entry editor. Saved is not Published: a save joins the pending changes, and\n * unsaved work stays in the form. `revision` goes back with the save, so a\n * concurrent save gets a 409 instead of an overwrite. The slug is the address:\n * changing it moves the entry, and the route follows.\n */\n\nimport { computed, onMounted, ref } from \"vue\";\nimport { useRouter } from \"vue-router\";\n\nimport { defaultValues, type FieldIssue } from \"@micacms/core\";\n\nimport { api, ApiError, type EntryDetail } from \"@/api\";\nimport ConfirmDialog from \"@/components/ConfirmDialog.vue\";\nimport FieldList from \"@/components/fields/FieldList.vue\";\nimport PageHeader from \"@/components/PageHeader.vue\";\nimport ReadOnlyNotice from \"@/components/ReadOnlyNotice.vue\";\nimport { useUnsavedChanges } from \"@/composables/useUnsavedChanges\";\nimport { useSchema } from \"@/stores/schema\";\nimport { useStaging } from \"@/stores/staging\";\nimport { useToast } from \"@/stores/toast\";\n\nconst props = defineProps<{ collection: string; slug?: string }>();\n\nconst router = useRouter();\nconst schema = useSchema();\nconst staging = useStaging();\nconst toast = useToast();\n\nconst definition = computed(() => schema.collection(props.collection));\n\nconst entry = ref<EntryDetail | null>(null);\nconst values = ref<Record<string, unknown>>({});\nconst issues = ref<FieldIssue[]>([]);\nconst loading = ref(true);\nconst saving = ref(false);\nconst conflict = ref(false);\nconst confirmDelete = ref(false);\n\n/** This entry was changed on the website while it has a draft here: Mica's own clone only. */\nconst websiteConflict = computed(() =>\n (staging.status.value?.sync?.conflicts ?? []).some(\n (item) =>\n item.target?.kind === \"entry\" && item.target.collection === props.collection && item.target.slug === props.slug,\n ),\n);\nconst references = ref<Array<{ collection: string; title: string }>>([]);\n\n/**\n * The version this form was opened against; `null` on a new entry, so a\n * duplicate slug is a conflict.\n */\nconst revision = ref<string | null>(null);\n\nconst unsaved = useUnsavedChanges(values);\nconst dirty = unsaved.dirty;\n\nconst isNew = computed(() => !props.slug);\n\nconst title = computed(() => {\n const def = definition.value;\n if (!def) return \"Entry\";\n const value = values.value[def.titleField];\n if (typeof value === \"string\" && value.trim()) return value.trim();\n return isNew.value ? `New ${def.labelSingular.toLowerCase()}` : \"Untitled\";\n});\n\n/**\n * Where this entry lives, from the server: a directory with rich text or media,\n * else one `.json` file.\n */\nconst location = computed(() => entry.value?.path ?? \"Not saved yet\");\n\nfunction setBaseline(detail: EntryDetail): void {\n entry.value = detail;\n values.value = structuredClone(detail.data);\n revision.value = detail.revision;\n issues.value = [];\n conflict.value = false;\n unsaved.markClean();\n}\n\nasync function open(slug: string): Promise<void> {\n setBaseline(await api.entries.get(props.collection, slug));\n}\n\nonMounted(async () => {\n const def = definition.value;\n if (!def) {\n loading.value = false;\n return;\n }\n\n try {\n if (props.slug) {\n await open(props.slug);\n } else {\n // A fresh entry starts as a full skeleton so every input is bound. The\n // skeleton itself is not an edit, so it becomes the baseline.\n values.value = defaultValues(def.fields);\n revision.value = null;\n unsaved.markClean();\n }\n } catch (error) {\n toast.error(error instanceof ApiError ? error.message : \"Could not open this entry.\");\n await router.replace({ name: \"collection\", params: { collection: props.collection } });\n } finally {\n loading.value = false;\n }\n});\n\nasync function save(): Promise<void> {\n if (definition.value?.readOnly) return;\n saving.value = true;\n issues.value = [];\n\n const payload = { data: values.value, revision: revision.value };\n\n try {\n const saved = props.slug\n ? await api.entries.update(props.collection, props.slug, payload)\n : await api.entries.create(props.collection, payload);\n\n // The server derives and de-duplicates the slug and can move the entry:\n // re-open at what it decided.\n unsaved.markClean();\n toast.success(saved.renamed ? `Saved as “${saved.slug}”.` : \"Saved.\");\n void staging.refresh();\n\n if (saved.slug !== props.slug) {\n await router.replace({\n name: \"entry\",\n params: { collection: props.collection, slug: saved.slug },\n });\n return;\n }\n\n await open(saved.slug);\n } catch (error) {\n if (error instanceof ApiError && error.status === 409) {\n // The form keeps the editor's work; a reload is their decision.\n conflict.value = true;\n toast.error(\"This entry was changed while you were editing it — by a colleague or on the website.\");\n } else if (error instanceof ApiError && error.issues.length > 0) {\n issues.value = error.issues;\n toast.error(error.message, `${error.issues.length} field(s) need attention.`);\n requestAnimationFrame(() => {\n document\n .querySelector('[aria-invalid=\"true\"], .field-error')\n ?.scrollIntoView({ behavior: \"smooth\", block: \"center\" });\n });\n } else {\n toast.error(error instanceof ApiError ? error.message : \"Could not save this entry.\");\n }\n } finally {\n saving.value = false;\n }\n}\n\n/** Takes the version now in the repository, discarding this form's edits. */\nasync function reload(): Promise<void> {\n if (!props.slug) return;\n try {\n await open(props.slug);\n toast.success(\"Reloaded from the repository.\");\n } catch (error) {\n toast.error(error instanceof ApiError ? error.message : \"Could not reload this entry.\");\n }\n}\n\nasync function askDelete(): Promise<void> {\n references.value = [];\n if (props.slug) {\n try {\n const { references: found } = await api.entries.references(props.collection, props.slug);\n references.value = found.map((item) => ({\n collection: schema.collection(item.collection)?.label ?? item.collection,\n title: item.title,\n }));\n } catch {\n // The warning is a courtesy; a failure to fetch it must not block deletion.\n }\n }\n confirmDelete.value = true;\n}\n\nasync function remove(): Promise<void> {\n if (!props.slug) return;\n try {\n await api.entries.remove(props.collection, props.slug);\n unsaved.release();\n toast.success(\"Deleted.\");\n void staging.refresh();\n await router.replace({ name: \"collection\", params: { collection: props.collection } });\n } catch (error) {\n toast.error(error instanceof ApiError ? error.message : \"Could not delete this entry.\");\n } finally {\n confirmDelete.value = false;\n }\n}\n</script>\n\n<template>\n <template v-if=\"definition\">\n <PageHeader\n :title=\"title\"\n :subtitle=\"location\"\n :back=\"{ name: 'collection', params: { collection } }\"\n :back-label=\"definition.label\"\n >\n <template v-if=\"!definition.readOnly\">\n <span :class=\"['badge', dirty ? 'border-accent bg-accent-soft text-accent' : 'text-success']\">\n <span class=\"h-1.5 w-1.5 rounded-full bg-current\" aria-hidden=\"true\" />\n {{ dirty ? \"Unsaved\" : \"Saved\" }}\n </span>\n <button type=\"button\" class=\"btn-primary\" :disabled=\"saving || !dirty\" @click=\"save\">\n {{ saving ? \"Saving…\" : \"Save changes\" }}\n </button>\n </template>\n </PageHeader>\n\n <div class=\"mx-auto max-w-3xl px-4 py-6 sm:px-6\">\n <p v-if=\"loading\" class=\"text-sm text-muted\">Loading…</p>\n\n <template v-else>\n <ReadOnlyNotice v-if=\"definition.readOnly\" :reason=\"definition.readOnly\" />\n\n <div\n v-if=\"websiteConflict\"\n role=\"alert\"\n class=\"mb-5 rounded-md border border-warning/15 bg-warning-soft p-4\"\n >\n <p class=\"text-sm font-medium text-warning\">This entry was changed on the website while you edited</p>\n <p class=\"mt-1 text-xs text-muted\">\n Your saved version is kept. Choose which version to publish on the Publish page.\n </p>\n <RouterLink :to=\"{ name: 'changes' }\" class=\"btn-secondary mt-2.5 inline-flex\">Choose a version</RouterLink>\n </div>\n\n <div\n v-if=\"conflict\"\n role=\"alert\"\n class=\"mb-5 rounded-md border border-warning/15 bg-warning-soft p-4\"\n >\n <p class=\"text-sm font-medium text-warning\">This entry changed while you were editing</p>\n <p class=\"mt-1 text-xs text-muted\">\n Your changes are still here and have not been saved. Copy anything you need, then load\n the current version — or open the repository to see what changed.\n </p>\n <button type=\"button\" class=\"btn-secondary mt-2.5\" @click=\"reload\">\n Discard mine and reload\n </button>\n </div>\n\n <div\n v-if=\"issues.length\"\n role=\"alert\"\n class=\"mb-5 rounded-md border border-danger/15 bg-danger-soft p-4\"\n >\n <p class=\"text-sm font-medium text-danger\">\n {{ issues.length }} field{{ issues.length === 1 ? \"\" : \"s\" }} need attention\n </p>\n <ul class=\"mt-1.5 space-y-0.5 text-xs text-danger\">\n <li v-for=\"issue in issues\" :key=\"issue.path\">{{ issue.message }}</li>\n </ul>\n </div>\n\n <form novalidate @submit.prevent=\"save\">\n <FieldList\n v-model=\"values\"\n :fields=\"definition.fields\"\n :issues=\"issues\"\n :disabled=\"saving || !!definition.readOnly\"\n :collection=\"collection\"\n :entry-slug=\"slug\"\n />\n\n <!-- Enter in a text input should save, not do nothing. -->\n <button v-if=\"!definition.readOnly\" type=\"submit\" class=\"sr-only\">Save</button>\n </form>\n\n <div v-if=\"!isNew && !definition.readOnly\" class=\"mt-10 border-t border-line pt-5\">\n <button type=\"button\" class=\"btn-danger\" @click=\"askDelete\">\n Delete this {{ definition.labelSingular.toLowerCase() }}\n </button>\n </div>\n </template>\n </div>\n\n <ConfirmDialog\n :open=\"confirmDelete\"\n :title=\"`Delete “${title}”?`\"\n confirm-label=\"Delete\"\n destructive\n @cancel=\"confirmDelete = false\"\n @confirm=\"remove\"\n >\n <p>\n This removes <code>{{ location }}</code>. Like any edit, the removal joins the pending\n changes and reaches the repository when they are published.\n </p>\n\n <div v-if=\"references.length\" class=\"mt-3 rounded-md border border-warning/15 bg-warning-soft p-4\">\n <p class=\"text-sm font-medium text-warning\">\n {{ references.length }} other entr{{ references.length === 1 ? \"y\" : \"ies\" }} link to this\n one:\n </p>\n <ul class=\"mt-1 list-inside list-disc text-xs\">\n <li v-for=\"(item, index) in references\" :key=\"index\">\n {{ item.title }} ({{ item.collection }})\n </li>\n </ul>\n </div>\n </ConfirmDialog>\n </template>\n\n <div v-else class=\"p-8 text-center text-sm text-muted\">\n There is no collection called \"{{ collection }}\".\n </div>\n</template>\n"],"names":["props","__props","router","useRouter","schema","useSchema","staging","useStaging","toast","useToast","definition","computed","entry","ref","values","issues","loading","saving","conflict","confirmDelete","websiteConflict","_b","_a","item","references","revision","unsaved","useUnsavedChanges","dirty","isNew","title","def","value","location","setBaseline","detail","open","slug","api","onMounted","defaultValues","error","ApiError","save","payload","saved","reload","askDelete","found","remove","_createElementBlock","_Fragment","_createVNode","PageHeader","_createElementVNode","_unref","_createTextVNode","_hoisted_1","_hoisted_2","_hoisted_3","_createBlock","ReadOnlyNotice","_openBlock","_hoisted_4","_cache","_component_RouterLink","_hoisted_5","_hoisted_6","_hoisted_7","_toDisplayString","_hoisted_8","_renderList","issue","FieldList","$event","_hoisted_9","_hoisted_10","ConfirmDialog","_hoisted_11","_hoisted_12","_hoisted_13","index","_hoisted_14"],"mappings":"07CAuBA,MAAMA,EAAQC,EAERC,EAASC,EAAA,EACTC,EAASC,GAAA,EACTC,EAAUC,GAAA,EACVC,EAAQC,EAAA,EAERC,EAAaC,EAAS,IAAMP,EAAO,WAAWJ,EAAM,UAAU,CAAC,EAE/DY,EAAQC,EAAwB,IAAI,EACpCC,EAASD,EAA6B,EAAE,EACxCE,EAASF,EAAkB,EAAE,EAC7BG,EAAUH,EAAI,EAAI,EAClBI,EAASJ,EAAI,EAAK,EAClBK,EAAWL,EAAI,EAAK,EACpBM,EAAgBN,EAAI,EAAK,EAGzBO,EAAkBT,EAAS,IAAA,SAC9B,SAAAU,GAAAC,EAAAhB,EAAQ,OAAO,QAAf,YAAAgB,EAAsB,OAAtB,YAAAD,EAA4B,YAAa,CAAA,GAAI,KAC3CE,GAAA,OACC,QAAAD,EAAAC,EAAK,SAAL,YAAAD,EAAa,QAAS,SAAWC,EAAK,OAAO,aAAevB,EAAM,YAAcuB,EAAK,OAAO,OAASvB,EAAM,KAAA,EAC/G,EAEIwB,EAAaX,EAAkD,EAAE,EAMjEY,EAAWZ,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,MAAW,MAAM,EAAG,cAAW6C,EAAG7C,EAAA,MAAW,sBAA6B,sBAE/E,CAAA,EACA8B,EAIK,KAJL0B,GAIK,EAHHlB,EAAA,EAAA,EAAAZ,EAEKC,EAAA,KAAAoB,EAFuB/C,EAAA,MAAU,CAA1BD,EAAM0D,KAAlBnB,IAAAZ,EAEK,KAAA,CAFoC,IAAK+B,KACzC1D,EAAK,KAAK,EAAG,KAAE8C,EAAG9C,EAAK,UAAU,EAAG,KACzC,CAAA,0DAMRuC,EAAA,EAAAZ,EAEM,MAFNgC,GAAuD,mCACtBb,EAAGpE,EAAA,UAAU,EAAG,MACjD,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{d as _,o as h,c as a,a as t,_ as b,t as u,b as d,e as v,u as w,f as k,r as f,g as c,h as i}from"./index-
|
|
2
|
-
//# sourceMappingURL=LoginView-
|
|
1
|
+
import{d as _,o as h,c as a,a as t,_ as b,t as u,b as d,e as v,u as w,f as k,r as f,g as c,h as i}from"./index-BHBq4-Io.js";const S={key:0,class:"grid min-h-full place-items-center p-6"},q={key:1,class:"grid min-h-full place-items-center p-6"},T={class:"w-full max-w-sm"},C={class:"card space-y-4 p-5"},M={key:0,role:"alert",class:"rounded-md border border-danger/15 bg-danger-soft px-4 py-3 text-sm text-danger"},R=["disabled"],V={key:1,class:"text-center text-xs text-muted"},B={class:"font-medium"},N={key:0,class:"mt-4 text-center text-xs text-muted"},E=_({__name:"LoginView",setup(A){const r=w(),m=k(),l=f(!1),o=f(null),p=c(()=>{var e;return(e=r.config.value)==null?void 0:e.provider}),n=c(()=>{var e;return((e=r.config.value)==null?void 0:e.authRequired)===!1}),y=c(()=>{const e=m.query.redirect;return typeof e=="string"&&e.startsWith("/admin")?e:"/admin/"}),x={rate_limited:"Too many sign-in attempts. Wait a few minutes, then sign in again.",expired:"That sign-in attempt expired or was not started here. Please try again.",failed:"Sign-in could not be completed. Please try again.",not_admitted:"You are signed in at your provider, but that account has no access to this site. Ask whoever runs it to add you.",too_large:"Sign-in could not be completed: your account details are too large."};h(()=>{const e=m.query.error;typeof e=="string"&&(o.value=x[e]??"Sign-in could not be completed."),n.value&&!o.value&&g()});function g(){l.value=!0,r.signIn(y.value)}return(e,s)=>n.value&&!o.value?(i(),a("div",S,[...s[0]||(s[0]=[t("p",{class:"text-sm text-muted"},"Opening the editor…",-1)])])):(i(),a("div",q,[t("div",T,[s[3]||(s[3]=t("div",{class:"mb-7 flex flex-col items-center gap-4 text-center"},[t("img",{src:b,alt:"micacms",class:"h-8 w-auto"}),t("div",null,[t("h1",{class:"text-lg font-semibold tracking-tight"},"Sign in to Mica"),t("p",{class:"mt-0.5 text-sm text-muted"},"Manage your website content.")])],-1)),t("div",C,[o.value?(i(),a("p",M,u(o.value),1)):d("",!0),t("button",{type:"button",class:"btn-primary w-full",disabled:l.value,onClick:g},u(l.value?"Redirecting…":n.value?"Continue":"Sign in"),9,R),p.value&&!n.value?(i(),a("p",V,[s[1]||(s[1]=v(" You will be taken to ",-1)),t("span",B,u(p.value),1),s[2]||(s[2]=v(" to sign in. ",-1))])):d("",!0)]),n.value?d("",!0):(i(),a("p",N," Mica does not hold your password. Trouble signing in is a question for whoever runs your identity provider; no access once you are in is a question for a site administrator. "))])]))}});export{E as default};
|
|
2
|
+
//# sourceMappingURL=LoginView-D3ztIdgO.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LoginView-
|
|
1
|
+
{"version":3,"file":"LoginView-D3ztIdgO.js","sources":["../../src/views/LoginView.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/**\n * Sign in.\n *\n * There is no form. Mica does not hold passwords, so there is nothing for an\n * editor to type here — the button hands the browser to the identity provider,\n * which does the actual authenticating and sends it back.\n *\n * The error banner exists because the round trip can fail after the provider\n * is satisfied: someone can authenticate perfectly well and still not be\n * admitted to this site, and that has to read as \"ask for access\", not as\n * \"your password was wrong\".\n *\n * In local mode this screen is not reached at all: there is no provider, no\n * account and nobody to be, and the session starts as the page is served. The\n * redirect below is the fallback for the one way in that skips that — a\n * browser still holding `/admin/login` from an earlier session.\n */\n\nimport { computed, onMounted, ref } from \"vue\";\nimport { useRoute } from \"vue-router\";\n\nimport { useSession } from \"@/stores/session\";\n\nconst session = useSession();\nconst route = useRoute();\n\nconst busy = ref(false);\n\n/** Set by the callback when it bounces the browser back here with a reason. */\nconst error = ref<string | null>(null);\n\nconst provider = computed(() => session.config.value?.provider);\n/** Local mode: no provider to send anybody to, so there is nothing to show. */\nconst authDisabled = computed(() => session.config.value?.authRequired === false);\n\n/** Where to land afterwards. Always a path on this server. */\nconst returnTo = computed(() => {\n const redirect = route.query[\"redirect\"];\n return typeof redirect === \"string\" && redirect.startsWith(\"/admin\")\n ? redirect\n : \"/admin/\";\n});\n\n/** The callback sends a code, never a sentence, so the URL carries no address (#150). */\nconst REFUSALS: Record<string, string> = {\n rate_limited: \"Too many sign-in attempts. Wait a few minutes, then sign in again.\",\n expired: \"That sign-in attempt expired or was not started here. Please try again.\",\n failed: \"Sign-in could not be completed. Please try again.\",\n not_admitted: \"You are signed in at your provider, but that account has no access to this site. Ask whoever runs it to add you.\",\n too_large: \"Sign-in could not be completed: your account details are too large.\",\n};\n\nonMounted(() => {\n const reason = route.query[\"error\"];\n if (typeof reason === \"string\") error.value = REFUSALS[reason] ?? \"Sign-in could not be completed.\";\n\n // No provider, no question to ask. Straight to the editor.\n if (authDisabled.value && !error.value) signIn();\n});\n\nfunction signIn(): void {\n busy.value = true;\n session.signIn(returnTo.value);\n}\n</script>\n\n<template>\n <!-- Local mode: a held breath, not a screen. -->\n <div v-if=\"authDisabled && !error\" class=\"grid min-h-full place-items-center p-6\">\n <p class=\"text-sm text-muted\">Opening the editor…</p>\n </div>\n\n <div v-else class=\"grid min-h-full place-items-center p-6\">\n <div class=\"w-full max-w-sm\">\n <div class=\"mb-7 flex flex-col items-center gap-4 text-center\">\n <img src=\"/brand/micacms-wordmark.svg\" alt=\"micacms\" class=\"h-8 w-auto\" />\n <div>\n <h1 class=\"text-lg font-semibold tracking-tight\">Sign in to Mica</h1>\n <p class=\"mt-0.5 text-sm text-muted\">Manage your website content.</p>\n </div>\n </div>\n\n <div class=\"card space-y-4 p-5\">\n <p v-if=\"error\" role=\"alert\" class=\"rounded-md border border-danger/15 bg-danger-soft px-4 py-3 text-sm text-danger\">\n {{ error }}\n </p>\n\n <button type=\"button\" class=\"btn-primary w-full\" :disabled=\"busy\" @click=\"signIn\">\n {{ busy ? \"Redirecting…\" : authDisabled ? \"Continue\" : \"Sign in\" }}\n </button>\n\n <p v-if=\"provider && !authDisabled\" class=\"text-center text-xs text-muted\">\n You will be taken to <span class=\"font-medium\">{{ provider }}</span> to sign in.\n </p>\n </div>\n\n <p v-if=\"!authDisabled\" class=\"mt-4 text-center text-xs text-muted\">\n Mica does not hold your password. Trouble signing in is a question for\n whoever runs your identity provider; no access once you are in is a\n question for a site administrator.\n </p>\n </div>\n </div>\n</template>\n"],"names":["session","useSession","route","useRoute","busy","ref","error","provider","computed","_a","authDisabled","returnTo","redirect","REFUSALS","onMounted","reason","signIn","_openBlock","_createElementBlock","_hoisted_1","_cache","_createElementVNode","_hoisted_2","_hoisted_3","_imports_0","_hoisted_4","_hoisted_5","_toDisplayString","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9"],"mappings":"6kBAwBA,MAAMA,EAAUC,EAAA,EACVC,EAAQC,EAAA,EAERC,EAAOC,EAAI,EAAK,EAGhBC,EAAQD,EAAmB,IAAI,EAE/BE,EAAWC,EAAS,IAAA,OAAM,OAAAC,EAAAT,EAAQ,OAAO,QAAf,YAAAS,EAAsB,SAAQ,EAExDC,EAAeF,EAAS,IAAA,OAAM,QAAAC,EAAAT,EAAQ,OAAO,QAAf,YAAAS,EAAsB,gBAAiB,GAAK,EAG1EE,EAAWH,EAAS,IAAM,CAC9B,MAAMI,EAAWV,EAAM,MAAM,SAC7B,OAAO,OAAOU,GAAa,UAAYA,EAAS,WAAW,QAAQ,EAC/DA,EACA,S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AQ,EAAA,CAAA,gBAAU,gBACtE,EAAA,EAAA,eAGQG,EAAA,oBAAVQ,EAII,IAJJa,EAAoE,iLAIpE"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{d as I,o as P,c as o,j as E,w as O,l as p,a as t,
|
|
2
|
-
//# sourceMappingURL=MediaView-
|
|
1
|
+
import{d as I,o as P,c as o,j as E,w as O,l as p,a as t,v as W,x as q,t as r,F as _,k as N,i as v,b as S,z as b,C as V,r as c,g as w,A as B,n as G,h as n,e as H,m as J}from"./index-BHBq4-Io.js";import{_ as K}from"./PageHeader.vue_vue_type_script_setup_true_lang-Cr0v1G7O.js";import{f as k}from"./format-Cpnr2As6.js";const Q={class:"btn-primary cursor-pointer"},R=["disabled"],X={class:"mb-3 flex flex-wrap items-center gap-2"},Y={key:0,class:"py-12 text-center text-sm text-muted"},Z={key:1,class:"card px-4 py-12 text-center"},ee={class:"text-sm font-medium"},te={key:2,class:"grid gap-5 lg:grid-cols-[1fr_20rem]"},se={class:"space-y-6"},le={class:"mb-2 font-mono text-xs text-muted"},ae={class:"grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-4"},oe=["aria-pressed","onClick"],ne={class:"block aspect-4/3 bg-canvas"},ie=["src"],re={key:1,class:"flex h-full w-full items-center justify-center text-xs font-semibold uppercase text-muted"},de={class:"block px-2 py-1.5"},ue={class:"block truncate text-xs font-medium"},ce={class:"block text-[11px] text-muted"},pe={key:0,class:"card h-fit p-4 lg:sticky lg:top-5"},fe={class:"mt-3 overflow-hidden rounded-lg border border-line bg-canvas"},me=["src"],ve={key:1,class:"p-6 text-center text-xs text-muted"},he={class:"mt-4 space-y-1 text-xs text-muted"},ge={class:"flex justify-between gap-3"},ye={key:0,class:"flex justify-between gap-3"},xe={class:"flex justify-between gap-3"},_e={class:"mt-3 border-t border-line pt-3"},be={class:"mt-1 break-all font-mono text-[11px]"},we={class:"mt-3 flex gap-2"},ke=["href"],De=I({__name:"MediaView",setup(Ce){const f=G(),u=c([]),y=c(!0),h=c(!1),m=c(""),g=c(!1),a=c(null),x=c(null),C=l=>l.mimeType.startsWith("image/"),L=l=>{const e=l.split("/");return e.pop(),e.join("/")||"/"},T=w(()=>{const l=m.value.trim().toLowerCase();return l?u.value.filter(e=>e.path.toLowerCase().includes(l)):u.value}),U=w(()=>{const l=new Map;for(const e of T.value){const s=L(e.path),d=l.get(s);d?d.push(e):l.set(s,[e])}return[...l].sort(([e],[s])=>e.localeCompare(s))}),A=w(()=>u.value.reduce((l,e)=>l+e.size,0));async function $(){y.value=!0;try{u.value=(await v.media.list()).items;const l=u.value.find(e=>{var s;return e.path===((s=a.value)==null?void 0:s.path)});a.value=l??null}catch(l){f.error(l instanceof B?l.message:"Could not load the media library.")}finally{y.value=!1}}P($);async function j(l){const e=Array.from(l??[]);if(e.length!==0){h.value=!0;try{const{items:s}=await v.media.upload(e);f.success(`Uploaded ${s.length} file${s.length===1?"":"s"}.`),J().refresh(),await $(),a.value=u.value.find(d=>{var i;return d.path===((i=s[0])==null?void 0:i.path)})??null}catch(s){f.error(s instanceof B?s.message:"The upload failed.")}finally{h.value=!1,x.value&&(x.value.value="")}}}async function F(l){try{await navigator.clipboard.writeText(l),f.success("Path copied.")}catch{f.error("Could not copy. Select the path and copy it by hand.")}}return(l,e)=>(n(),o(_,null,[E(K,{title:"Media",subtitle:`${u.value.length} file${u.value.length===1?"":"s"} · ${p(k)(A.value)}`},{default:O(()=>[t("label",Q,[t("input",{ref_key:"fileInput",ref:x,type:"file",multiple:"",class:"sr-only",disabled:h.value,onChange:e[0]||(e[0]=s=>j(s.target.files))},null,40,R),H(" "+r(h.value?"Uploading…":"Upload files"),1)])]),_:1},8,["subtitle"]),t("div",{class:V(["mx-auto max-w-5xl px-4 py-5 sm:px-6",g.value&&"rounded-md outline-2 outline-dashed outline-ink"]),onDragover:e[3]||(e[3]=b(s=>g.value=!0,["prevent"])),onDragleave:e[4]||(e[4]=b(s=>g.value=!1,["prevent"])),onDrop:e[5]||(e[5]=b(s=>{var d;g.value=!1,j(((d=s.dataTransfer)==null?void 0:d.files)??null)},["prevent"]))},[t("div",X,[W(t("input",{"onUpdate:modelValue":e[1]||(e[1]=s=>m.value=s),type:"search",placeholder:"Search by name or folder…",class:"input max-w-64","aria-label":"Search media"},null,512),[[q,m.value]])]),y.value?(n(),o("p",Y,"Loading…")):T.value.length===0?(n(),o("div",Z,[t("p",ee,r(m.value?`Nothing matches "${m.value}".`:"No files yet."),1),e[6]||(e[6]=t("p",{class:"mt-1 text-sm text-muted"}," Drag files anywhere on this page to upload them. ",-1))])):(n(),o("div",te,[t("div",se,[(n(!0),o(_,null,N(U.value,([s,d])=>(n(),o("section",{key:s},[t("h2",le,r(s),1),t("ul",ae,[(n(!0),o(_,null,N(d,i=>{var z,D;return n(),o("li",{key:i.path},[t("button",{type:"button","aria-pressed":((z=a.value)==null?void 0:z.path)===i.path,class:V(["block w-full overflow-hidden rounded-lg border text-left transition",((D=a.value)==null?void 0:D.path)===i.path?"border-accent ring-2 ring-accent/25":"border-line hover:border-accent/40"]),onClick:Te=>{var M;return a.value=((M=a.value)==null?void 0:M.path)===i.path?null:i}},[t("span",ne,[C(i)?(n(),o("img",{key:0,src:p(v).media.url(i.path),alt:"",loading:"lazy",class:"h-full w-full object-cover"},null,8,ie)):(n(),o("span",re,r(i.mimeType.split("/")[1]),1))]),t("span",de,[t("span",ue,r(i.filename),1),t("span",ce,r(p(k)(i.size)),1)])],10,oe)])}),128))])]))),128))]),a.value?(n(),o("aside",pe,[e[11]||(e[11]=t("h2",{class:"text-sm font-semibold"},"File details",-1)),t("div",fe,[C(a.value)?(n(),o("img",{key:0,src:p(v).media.url(a.value.path),alt:"",class:"max-h-48 w-full object-contain"},null,8,me)):(n(),o("p",ve,r(a.value.mimeType),1))]),t("dl",he,[t("div",ge,[e[7]||(e[7]=t("dt",null,"Type",-1)),t("dd",null,r(a.value.mimeType),1)]),a.value.width?(n(),o("div",ye,[e[8]||(e[8]=t("dt",null,"Dimensions",-1)),t("dd",null,r(a.value.width)+" × "+r(a.value.height),1)])):S("",!0),t("div",xe,[e[9]||(e[9]=t("dt",null,"Size",-1)),t("dd",null,r(p(k)(a.value.size)),1)])]),t("div",_e,[e[10]||(e[10]=t("p",{class:"field-label"},"Path in the repository",-1)),t("p",be,r(a.value.path),1)]),t("div",we,[t("button",{type:"button",class:"btn-secondary flex-1",onClick:e[2]||(e[2]=s=>F(a.value.path))}," Copy path "),t("a",{href:p(v).media.url(a.value.path),target:"_blank",rel:"noopener noreferrer",class:"btn-secondary flex-1"}," Open ",8,ke)])])):S("",!0)]))],34)],64))}});export{De as default};
|
|
2
|
+
//# sourceMappingURL=MediaView-CeF4DCQR.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MediaView-Dp2botAQ.js","sources":["../../src/views/MediaView.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/**\n * Media library — a view of the files in the content repository.\n *\n * See what is there, and add to it. Two things it deliberately does not offer:\n *\n * - **Alt text.** Not a property of a file: the same photograph means\n * different things in different places, so it belongs to the field that\n * uses the image, next to the content it describes.\n * - **Rename and delete.** A media file is referenced by its path, so moving\n * or removing one is a change to every entry that points at it — a job for\n * a commit and a review, not for a button that quietly leaves gaps on the\n * website.\n *\n * Files are grouped by directory, which is meaningful here: an entry's images\n * sit beside the entry.\n */\n\nimport { computed, onMounted, ref } from \"vue\";\n\nimport { api, ApiError, type MediaItem } from \"@/api\";\nimport PageHeader from \"@/components/PageHeader.vue\";\nimport { formatBytes } from \"@/lib/format\";\nimport { useStaging } from \"@/stores/staging\";\nimport { useToast } from \"@/stores/toast\";\n\nconst toast = useToast();\n\nconst items = ref<MediaItem[]>([]);\nconst loading = ref(true);\nconst uploading = ref(false);\nconst search = ref(\"\");\nconst dragging = ref(false);\nconst selected = ref<MediaItem | null>(null);\nconst fileInput = ref<HTMLInputElement | null>(null);\n\nconst isImage = (item: MediaItem): boolean => item.mimeType.startsWith(\"image/\");\n\n/** The directory a file sits in; `media` is the shared one. */\nconst folderOf = (path: string): string => {\n const parts = path.split(\"/\");\n parts.pop();\n return parts.join(\"/\") || \"/\";\n};\n\nconst matching = computed(() => {\n const term = search.value.trim().toLowerCase();\n return term ? items.value.filter((item) => item.path.toLowerCase().includes(term)) : items.value;\n});\n\n/** Grouped by directory, in path order — the order the repository has them. */\nconst folders = computed(() => {\n const groups = new Map<string, MediaItem[]>();\n for (const item of matching.value) {\n const folder = folderOf(item.path);\n const group = groups.get(folder);\n if (group) group.push(item);\n else groups.set(folder, [item]);\n }\n return [...groups].sort(([a], [b]) => a.localeCompare(b));\n});\n\nconst totalBytes = computed(() => items.value.reduce((sum, item) => sum + item.size, 0));\n\nasync function load(): Promise<void> {\n loading.value = true;\n try {\n items.value = (await api.media.list()).items;\n // The chosen file may have gone from the repository between loads.\n const stillThere = items.value.find((item) => item.path === selected.value?.path);\n selected.value = stillThere ?? null;\n } catch (error) {\n toast.error(error instanceof ApiError ? error.message : \"Could not load the media library.\");\n } finally {\n loading.value = false;\n }\n}\n\nonMounted(load);\n\nasync function upload(files: FileList | File[] | null): Promise<void> {\n const list = Array.from(files ?? []);\n if (list.length === 0) return;\n\n uploading.value = true;\n try {\n const { items: uploaded } = await api.media.upload(list);\n toast.success(`Uploaded ${uploaded.length} file${uploaded.length === 1 ? \"\" : \"s\"}.`);\n void useStaging().refresh();\n await load();\n selected.value = items.value.find((item) => item.path === uploaded[0]?.path) ?? null;\n } catch (error) {\n toast.error(error instanceof ApiError ? error.message : \"The upload failed.\");\n } finally {\n uploading.value = false;\n if (fileInput.value) fileInput.value.value = \"\";\n }\n}\n\nasync function copyPath(path: string): Promise<void> {\n try {\n await navigator.clipboard.writeText(path);\n toast.success(\"Path copied.\");\n } catch {\n // Clipboard access is denied in some browsers unless the page is focused.\n toast.error(\"Could not copy. Select the path and copy it by hand.\");\n }\n}\n</script>\n\n<template>\n <PageHeader\n title=\"Media\"\n :subtitle=\"`${items.length} file${items.length === 1 ? '' : 's'} · ${formatBytes(totalBytes)}`\"\n >\n <label class=\"btn-primary cursor-pointer\">\n <input\n ref=\"fileInput\"\n type=\"file\"\n multiple\n class=\"sr-only\"\n :disabled=\"uploading\"\n @change=\"upload(($event.target as HTMLInputElement).files)\"\n />\n {{ uploading ? \"Uploading…\" : \"Upload files\" }}\n </label>\n </PageHeader>\n\n <div\n class=\"mx-auto max-w-5xl px-4 py-5 sm:px-6\"\n :class=\"dragging && 'rounded-md outline-2 outline-dashed outline-ink'\"\n @dragover.prevent=\"dragging = true\"\n @dragleave.prevent=\"dragging = false\"\n @drop.prevent=\"\n dragging = false;\n upload($event.dataTransfer?.files ?? null);\n \"\n >\n <div class=\"mb-3 flex flex-wrap items-center gap-2\">\n <input\n v-model=\"search\"\n type=\"search\"\n placeholder=\"Search by name or folder…\"\n class=\"input max-w-64\"\n aria-label=\"Search media\"\n />\n </div>\n\n <p v-if=\"loading\" class=\"py-12 text-center text-sm text-muted\">Loading…</p>\n\n <div v-else-if=\"matching.length === 0\" class=\"card px-4 py-12 text-center\">\n <p class=\"text-sm font-medium\">\n {{ search ? `Nothing matches \"${search}\".` : \"No files yet.\" }}\n </p>\n <p class=\"mt-1 text-sm text-muted\">\n Drag files anywhere on this page to upload them.\n </p>\n </div>\n\n <div v-else class=\"grid gap-5 lg:grid-cols-[1fr_20rem]\">\n <div class=\"space-y-6\">\n <section v-for=\"[folder, files] in folders\" :key=\"folder\">\n <h2 class=\"mb-2 font-mono text-xs text-muted\">{{ folder }}</h2>\n\n <ul class=\"grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-4\">\n <li v-for=\"item in files\" :key=\"item.path\">\n <button\n type=\"button\"\n :aria-pressed=\"selected?.path === item.path\"\n :class=\"[\n 'block w-full overflow-hidden rounded-lg border text-left transition',\n selected?.path === item.path\n ? 'border-accent ring-2 ring-accent/25'\n : 'border-line hover:border-accent/40',\n ]\"\n @click=\"selected = selected?.path === item.path ? null : item\"\n >\n <span class=\"block aspect-4/3 bg-canvas\">\n <img\n v-if=\"isImage(item)\"\n :src=\"api.media.url(item.path)\"\n alt=\"\"\n loading=\"lazy\"\n class=\"h-full w-full object-cover\"\n />\n <span\n v-else\n class=\"flex h-full w-full items-center justify-center text-xs font-semibold uppercase text-muted\"\n >\n {{ item.mimeType.split(\"/\")[1] }}\n </span>\n </span>\n\n <span class=\"block px-2 py-1.5\">\n <span class=\"block truncate text-xs font-medium\">{{ item.filename }}</span>\n <span class=\"block text-[11px] text-muted\">{{ formatBytes(item.size) }}</span>\n </span>\n </button>\n </li>\n </ul>\n </section>\n </div>\n\n <aside v-if=\"selected\" class=\"card h-fit p-4 lg:sticky lg:top-5\">\n <h2 class=\"text-sm font-semibold\">File details</h2>\n\n <div class=\"mt-3 overflow-hidden rounded-lg border border-line bg-canvas\">\n <img\n v-if=\"isImage(selected)\"\n :src=\"api.media.url(selected.path)\"\n alt=\"\"\n class=\"max-h-48 w-full object-contain\"\n />\n <p v-else class=\"p-6 text-center text-xs text-muted\">\n {{ selected.mimeType }}\n </p>\n </div>\n\n <dl class=\"mt-4 space-y-1 text-xs text-muted\">\n <div class=\"flex justify-between gap-3\">\n <dt>Type</dt>\n <dd>{{ selected.mimeType }}</dd>\n </div>\n <div v-if=\"selected.width\" class=\"flex justify-between gap-3\">\n <dt>Dimensions</dt>\n <dd>{{ selected.width }} × {{ selected.height }}</dd>\n </div>\n <div class=\"flex justify-between gap-3\">\n <dt>Size</dt>\n <dd>{{ formatBytes(selected.size) }}</dd>\n </div>\n </dl>\n\n <!-- The path is the file's identity: it is what a field stores and what\n appears in the diff, so it is worth being able to copy. -->\n <div class=\"mt-3 border-t border-line pt-3\">\n <p class=\"field-label\">Path in the repository</p>\n <p class=\"mt-1 break-all font-mono text-[11px]\">{{ selected.path }}</p>\n </div>\n\n <div class=\"mt-3 flex gap-2\">\n <button type=\"button\" class=\"btn-secondary flex-1\" @click=\"copyPath(selected.path)\">\n Copy path\n </button>\n <a\n :href=\"api.media.url(selected.path)\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n class=\"btn-secondary flex-1\"\n >\n Open\n </a>\n </div>\n </aside>\n </div>\n </div>\n</template>\n"],"names":["toast","useToast","items","ref","loading","uploading","search","dragging","selected","fileInput","isImage","item","folderOf","path","parts","matching","computed","term","folders","groups","folder","group","a","b","totalBytes","sum","load","api","stillThere","_a","error","ApiError","onMounted","upload","files","list","uploaded","useStaging","copyPath","_createVNode","PageHeader","_unref","formatBytes","_createElementVNode","_hoisted_1","$event","_createTextVNode","_normalizeClass","_cache","_withModifiers","_hoisted_3","_createElementBlock","_hoisted_4","_openBlock","_hoisted_5","_hoisted_6","_toDisplayString","_hoisted_7","_hoisted_8","_Fragment","_renderList","_hoisted_9","_hoisted_10","_b","_hoisted_12","_hoisted_14","_hoisted_15","_hoisted_16","_hoisted_17","_hoisted_18","_hoisted_19","_hoisted_21","_hoisted_22","_hoisted_23","_hoisted_24","_hoisted_25","_hoisted_26","_hoisted_27","_hoisted_28","_hoisted_29"],"mappings":"8jDA0BA,MAAMA,EAAQC,EAAA,EAERC,EAAQC,EAAiB,EAAE,EAC3BC,EAAUD,EAAI,EAAI,EAClBE,EAAYF,EAAI,EAAK,EACrBG,EAASH,EAAI,EAAE,EACfI,EAAWJ,EAAI,EAAK,EACpBK,EAAWL,EAAsB,IAAI,EACrCM,EAAYN,EAA6B,IAAI,EAE7CO,EAAWC,GAA6BA,EAAK,SAAS,WAAW,QAAQ,EAGzEC,EAAYC,GAAyB,CACzC,MAAMC,EAAQD,EAAK,MAAM,GAAG,EAC5B,OAAAC,EAAM,IAAA,EACCA,EAAM,KAAK,GAAG,GAAK,GAC5B,EAEMC,EAAWC,EAAS,IAAM,CAC9B,MAAMC,EAAOX,EAAO,MAAM,KAAA,EAAO,YAAA,EACjC,OAAOW,EAAOf,EAAM,MAAM,OAAQS,GAASA,EAAK,KAAK,YAAA,EAAc,SAASM,CAAI,CAAC,EAAIf,EAAM,KAC7F,CAAC,EAGKgB,EAAUF,EAAS,IAAM,CAC7B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AAyC,KAAA,KAAAa,EAAlCf,EAAAC,CAAA,EAAYlC,EAAA,MAAS,IAAI,CAAA,EAAA,CAAA,CAAA,KAMpCmC,EAGM,MAHNiC,GAGM,CAFJ5B,EAAA,EAAA,IAAAA,EAAA,EAAA,EAAAL,EAAiD,IAAA,CAA9C,MAAM,aAAA,EAAc,yBAAsB,EAAA,GAC7CA,EAAuE,IAAvEkC,GAAuErB,EAApBhD,EAAA,MAAS,IAAI,EAAA,CAAA,CAAA,GAGlEmC,EAYM,MAZNmC,GAYM,CAXJnC,EAES,SAAA,CAFD,KAAK,SAAS,MAAM,uBAAwB,QAAKK,EAAA,CAAA,IAAAA,EAAA,CAAA,EAAAH,GAAEP,EAAS9B,EAAA,MAAS,IAAI,EAAA,EAAG,aAEpF,EACAmC,EAOI,IAAA,CAND,KAAMF,KAAI,MAAM,IAAIjC,EAAA,MAAS,IAAI,EAClC,OAAO,SACP,IAAI,sBACJ,MAAM,sBAAA,EACP,SAED,EAAAuE,EAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"MediaView-CeF4DCQR.js","sources":["../../src/views/MediaView.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/**\n * Media library — a view of the files in the content repository.\n *\n * See what is there, and add to it. Two things it deliberately does not offer:\n *\n * - **Alt text.** Not a property of a file: the same photograph means\n * different things in different places, so it belongs to the field that\n * uses the image, next to the content it describes.\n * - **Rename and delete.** A media file is referenced by its path, so moving\n * or removing one is a change to every entry that points at it — a job for\n * a commit and a review, not for a button that quietly leaves gaps on the\n * website.\n *\n * Files are grouped by directory, which is meaningful here: an entry's images\n * sit beside the entry.\n */\n\nimport { computed, onMounted, ref } from \"vue\";\n\nimport { api, ApiError, type MediaItem } from \"@/api\";\nimport PageHeader from \"@/components/PageHeader.vue\";\nimport { formatBytes } from \"@/lib/format\";\nimport { useStaging } from \"@/stores/staging\";\nimport { useToast } from \"@/stores/toast\";\n\nconst toast = useToast();\n\nconst items = ref<MediaItem[]>([]);\nconst loading = ref(true);\nconst uploading = ref(false);\nconst search = ref(\"\");\nconst dragging = ref(false);\nconst selected = ref<MediaItem | null>(null);\nconst fileInput = ref<HTMLInputElement | null>(null);\n\nconst isImage = (item: MediaItem): boolean => item.mimeType.startsWith(\"image/\");\n\n/** The directory a file sits in; `media` is the shared one. */\nconst folderOf = (path: string): string => {\n const parts = path.split(\"/\");\n parts.pop();\n return parts.join(\"/\") || \"/\";\n};\n\nconst matching = computed(() => {\n const term = search.value.trim().toLowerCase();\n return term ? items.value.filter((item) => item.path.toLowerCase().includes(term)) : items.value;\n});\n\n/** Grouped by directory, in path order — the order the repository has them. */\nconst folders = computed(() => {\n const groups = new Map<string, MediaItem[]>();\n for (const item of matching.value) {\n const folder = folderOf(item.path);\n const group = groups.get(folder);\n if (group) group.push(item);\n else groups.set(folder, [item]);\n }\n return [...groups].sort(([a], [b]) => a.localeCompare(b));\n});\n\nconst totalBytes = computed(() => items.value.reduce((sum, item) => sum + item.size, 0));\n\nasync function load(): Promise<void> {\n loading.value = true;\n try {\n items.value = (await api.media.list()).items;\n // The chosen file may have gone from the repository between loads.\n const stillThere = items.value.find((item) => item.path === selected.value?.path);\n selected.value = stillThere ?? null;\n } catch (error) {\n toast.error(error instanceof ApiError ? error.message : \"Could not load the media library.\");\n } finally {\n loading.value = false;\n }\n}\n\nonMounted(load);\n\nasync function upload(files: FileList | File[] | null): Promise<void> {\n const list = Array.from(files ?? []);\n if (list.length === 0) return;\n\n uploading.value = true;\n try {\n const { items: uploaded } = await api.media.upload(list);\n toast.success(`Uploaded ${uploaded.length} file${uploaded.length === 1 ? \"\" : \"s\"}.`);\n void useStaging().refresh();\n await load();\n selected.value = items.value.find((item) => item.path === uploaded[0]?.path) ?? null;\n } catch (error) {\n toast.error(error instanceof ApiError ? error.message : \"The upload failed.\");\n } finally {\n uploading.value = false;\n if (fileInput.value) fileInput.value.value = \"\";\n }\n}\n\nasync function copyPath(path: string): Promise<void> {\n try {\n await navigator.clipboard.writeText(path);\n toast.success(\"Path copied.\");\n } catch {\n // Clipboard access is denied in some browsers unless the page is focused.\n toast.error(\"Could not copy. Select the path and copy it by hand.\");\n }\n}\n</script>\n\n<template>\n <PageHeader\n title=\"Media\"\n :subtitle=\"`${items.length} file${items.length === 1 ? '' : 's'} · ${formatBytes(totalBytes)}`\"\n >\n <label class=\"btn-primary cursor-pointer\">\n <input\n ref=\"fileInput\"\n type=\"file\"\n multiple\n class=\"sr-only\"\n :disabled=\"uploading\"\n @change=\"upload(($event.target as HTMLInputElement).files)\"\n />\n {{ uploading ? \"Uploading…\" : \"Upload files\" }}\n </label>\n </PageHeader>\n\n <div\n class=\"mx-auto max-w-5xl px-4 py-5 sm:px-6\"\n :class=\"dragging && 'rounded-md outline-2 outline-dashed outline-ink'\"\n @dragover.prevent=\"dragging = true\"\n @dragleave.prevent=\"dragging = false\"\n @drop.prevent=\"\n dragging = false;\n upload($event.dataTransfer?.files ?? null);\n \"\n >\n <div class=\"mb-3 flex flex-wrap items-center gap-2\">\n <input\n v-model=\"search\"\n type=\"search\"\n placeholder=\"Search by name or folder…\"\n class=\"input max-w-64\"\n aria-label=\"Search media\"\n />\n </div>\n\n <p v-if=\"loading\" class=\"py-12 text-center text-sm text-muted\">Loading…</p>\n\n <div v-else-if=\"matching.length === 0\" class=\"card px-4 py-12 text-center\">\n <p class=\"text-sm font-medium\">\n {{ search ? `Nothing matches \"${search}\".` : \"No files yet.\" }}\n </p>\n <p class=\"mt-1 text-sm text-muted\">\n Drag files anywhere on this page to upload them.\n </p>\n </div>\n\n <div v-else class=\"grid gap-5 lg:grid-cols-[1fr_20rem]\">\n <div class=\"space-y-6\">\n <section v-for=\"[folder, files] in folders\" :key=\"folder\">\n <h2 class=\"mb-2 font-mono text-xs text-muted\">{{ folder }}</h2>\n\n <ul class=\"grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-4\">\n <li v-for=\"item in files\" :key=\"item.path\">\n <button\n type=\"button\"\n :aria-pressed=\"selected?.path === item.path\"\n :class=\"[\n 'block w-full overflow-hidden rounded-lg border text-left transition',\n selected?.path === item.path\n ? 'border-accent ring-2 ring-accent/25'\n : 'border-line hover:border-accent/40',\n ]\"\n @click=\"selected = selected?.path === item.path ? null : item\"\n >\n <span class=\"block aspect-4/3 bg-canvas\">\n <img\n v-if=\"isImage(item)\"\n :src=\"api.media.url(item.path)\"\n alt=\"\"\n loading=\"lazy\"\n class=\"h-full w-full object-cover\"\n />\n <span\n v-else\n class=\"flex h-full w-full items-center justify-center text-xs font-semibold uppercase text-muted\"\n >\n {{ item.mimeType.split(\"/\")[1] }}\n </span>\n </span>\n\n <span class=\"block px-2 py-1.5\">\n <span class=\"block truncate text-xs font-medium\">{{ item.filename }}</span>\n <span class=\"block text-[11px] text-muted\">{{ formatBytes(item.size) }}</span>\n </span>\n </button>\n </li>\n </ul>\n </section>\n </div>\n\n <aside v-if=\"selected\" class=\"card h-fit p-4 lg:sticky lg:top-5\">\n <h2 class=\"text-sm font-semibold\">File details</h2>\n\n <div class=\"mt-3 overflow-hidden rounded-lg border border-line bg-canvas\">\n <img\n v-if=\"isImage(selected)\"\n :src=\"api.media.url(selected.path)\"\n alt=\"\"\n class=\"max-h-48 w-full object-contain\"\n />\n <p v-else class=\"p-6 text-center text-xs text-muted\">\n {{ selected.mimeType }}\n </p>\n </div>\n\n <dl class=\"mt-4 space-y-1 text-xs text-muted\">\n <div class=\"flex justify-between gap-3\">\n <dt>Type</dt>\n <dd>{{ selected.mimeType }}</dd>\n </div>\n <div v-if=\"selected.width\" class=\"flex justify-between gap-3\">\n <dt>Dimensions</dt>\n <dd>{{ selected.width }} × {{ selected.height }}</dd>\n </div>\n <div class=\"flex justify-between gap-3\">\n <dt>Size</dt>\n <dd>{{ formatBytes(selected.size) }}</dd>\n </div>\n </dl>\n\n <!-- The path is the file's identity: it is what a field stores and what\n appears in the diff, so it is worth being able to copy. -->\n <div class=\"mt-3 border-t border-line pt-3\">\n <p class=\"field-label\">Path in the repository</p>\n <p class=\"mt-1 break-all font-mono text-[11px]\">{{ selected.path }}</p>\n </div>\n\n <div class=\"mt-3 flex gap-2\">\n <button type=\"button\" class=\"btn-secondary flex-1\" @click=\"copyPath(selected.path)\">\n Copy path\n </button>\n <a\n :href=\"api.media.url(selected.path)\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n class=\"btn-secondary flex-1\"\n >\n Open\n </a>\n </div>\n </aside>\n </div>\n </div>\n</template>\n"],"names":["toast","useToast","items","ref","loading","uploading","search","dragging","selected","fileInput","isImage","item","folderOf","path","parts","matching","computed","term","folders","groups","folder","group","a","b","totalBytes","sum","load","api","stillThere","_a","error","ApiError","onMounted","upload","files","list","uploaded","useStaging","copyPath","_createVNode","PageHeader","_unref","formatBytes","_createElementVNode","_hoisted_1","$event","_createTextVNode","_normalizeClass","_cache","_withModifiers","_hoisted_3","_createElementBlock","_hoisted_4","_openBlock","_hoisted_5","_hoisted_6","_toDisplayString","_hoisted_7","_hoisted_8","_Fragment","_renderList","_hoisted_9","_hoisted_10","_b","_hoisted_12","_hoisted_14","_hoisted_15","_hoisted_16","_hoisted_17","_hoisted_18","_hoisted_19","_hoisted_21","_hoisted_22","_hoisted_23","_hoisted_24","_hoisted_25","_hoisted_26","_hoisted_27","_hoisted_28","_hoisted_29"],"mappings":"8jDA0BA,MAAMA,EAAQC,EAAA,EAERC,EAAQC,EAAiB,EAAE,EAC3BC,EAAUD,EAAI,EAAI,EAClBE,EAAYF,EAAI,EAAK,EACrBG,EAASH,EAAI,EAAE,EACfI,EAAWJ,EAAI,EAAK,EACpBK,EAAWL,EAAsB,IAAI,EACrCM,EAAYN,EAA6B,IAAI,EAE7CO,EAAWC,GAA6BA,EAAK,SAAS,WAAW,QAAQ,EAGzEC,EAAYC,GAAyB,CACzC,MAAMC,EAAQD,EAAK,MAAM,GAAG,EAC5B,OAAAC,EAAM,IAAA,EACCA,EAAM,KAAK,GAAG,GAAK,GAC5B,EAEMC,EAAWC,EAAS,IAAM,CAC9B,MAAMC,EAAOX,EAAO,MA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,EAAG,MAAGgD,EAAGhD,EAAA,MAAS,MAAM,EAAA,CAAA,CAAA,aAE/CmC,EAGM,MAHNgC,GAGM,CAFJ3B,EAAA,CAAA,IAAAA,EAAA,CAAA,EAAAL,EAAa,UAAT,OAAI,EAAA,GACRA,EAAyC,KAAA,KAAAa,EAAlCf,EAAAC,CAAA,EAAYlC,EAAA,MAAS,IAAI,CAAA,EAAA,CAAA,CAAA,KAMpCmC,EAGM,MAHNiC,GAGM,CAFJ5B,EAAA,EAAA,IAAAA,EAAA,EAAA,EAAAL,EAAiD,IAAA,CAA9C,MAAM,aAAA,EAAc,yBAAsB,EAAA,GAC7CA,EAAuE,IAAvEkC,GAAuErB,EAApBhD,EAAA,MAAS,IAAI,EAAA,CAAA,CAAA,GAGlEmC,EAYM,MAZNmC,GAYM,CAXJnC,EAES,SAAA,CAFD,KAAK,SAAS,MAAM,uBAAwB,QAAKK,EAAA,CAAA,IAAAA,EAAA,CAAA,EAAAH,GAAEP,EAAS9B,EAAA,MAAS,IAAI,EAAA,EAAG,aAEpF,EACAmC,EAOI,IAAA,CAND,KAAMF,KAAI,MAAM,IAAIjC,EAAA,MAAS,IAAI,EAClC,OAAO,SACP,IAAI,sBACJ,MAAM,sBAAA,EACP,SAED,EAAAuE,EAAA,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Y as s,h as n,c as a,a as e,j as r,w as d,e as i,p as m}from"./index-
|
|
2
|
-
//# sourceMappingURL=NotFoundView-
|
|
1
|
+
import{Y as s,h as n,c as a,a as e,j as r,w as d,e as i,p as m}from"./index-BHBq4-Io.js";const l={},c={class:"grid min-h-[60vh] place-items-center p-6 text-center"};function p(x,t){const o=m("RouterLink");return n(),a("div",c,[e("div",null,[t[1]||(t[1]=e("p",{class:"text-sm font-semibold text-muted"},"Not found",-1)),t[2]||(t[2]=e("h1",{class:"mt-1 text-xl font-semibold tracking-tight"},"This page does not exist",-1)),t[3]||(t[3]=e("p",{class:"mt-1.5 text-sm text-muted"}," The link may be out of date, or the content may have been deleted. ",-1)),r(o,{to:{name:"dashboard"},class:"btn-primary mt-5"},{default:d(()=>[...t[0]||(t[0]=[i("Back to overview",-1)])]),_:1})])])}const f=s(l,[["render",p]]);export{f as default};
|
|
2
|
+
//# sourceMappingURL=NotFoundView-DvofX918.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotFoundView-
|
|
1
|
+
{"version":3,"file":"NotFoundView-DvofX918.js","sources":["../../src/views/NotFoundView.vue"],"sourcesContent":["<template>\n <div class=\"grid min-h-[60vh] place-items-center p-6 text-center\">\n <div>\n <p class=\"text-sm font-semibold text-muted\">Not found</p>\n <h1 class=\"mt-1 text-xl font-semibold tracking-tight\">This page does not exist</h1>\n <p class=\"mt-1.5 text-sm text-muted\">\n The link may be out of date, or the content may have been deleted.\n </p>\n <RouterLink :to=\"{ name: 'dashboard' }\" class=\"btn-primary mt-5\">Back to overview</RouterLink>\n </div>\n </div>\n</template>\n"],"names":["_hoisted_1","_openBlock","_createElementBlock","_createElementVNode","_cache","_createVNode","_component_RouterLink"],"mappings":"oGACOA,EAAA,CAAA,MAAM,sDAAsD,0CAAjE,OAAAC,EAAA,EAAAC,EASM,MATNF,EASM,CARJG,EAOM,MAAA,KAAA,CANJC,EAAA,CAAA,IAAAA,EAAA,CAAA,EAAAD,EAAyD,IAAA,CAAtD,MAAM,kCAAkC,EAAC,YAAS,EAAA,GACrDC,EAAA,CAAA,IAAAA,EAAA,CAAA,EAAAD,EAAmF,KAAA,CAA/E,MAAM,2CAA2C,EAAC,2BAAwB,EAAA,GAC9EC,EAAA,CAAA,IAAAA,EAAA,CAAA,EAAAD,EAEI,IAAA,CAFD,MAAM,2BAA2B,EAAC,uEAErC,EAAA,GACAE,EAA8FC,EAAA,CAAjF,GAAI,CAAA,KAAA,WAAA,EAAuB,MAAM,+BAAmB,IAAgB,CAAA,GAAAF,EAAA,CAAA,IAAAA,EAAA,CAAA,EAAA,GAAhB,mBAAgB,EAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{d as C,r as k,h as a,c as d,a as m,t as n,l as o,s as x,w,b as u,C as y,S as B,v as S,Z as D,j as N,g as c}from"./index-BHBq4-Io.js";import{_ as j}from"./useUnsavedChanges-FKPfUHdo.js";import{u as $}from"./useField-vKkdSfn7.js";import{C as z}from"./chevron-down-CnhoXsgY.js";import"./arrow-right-D8-sqdXS.js";import"./ReadOnlyNotice.vue_vue_type_script_setup_true_lang-BtfQSv1l.js";const F={class:"card overflow-hidden"},I={class:"sr-only"},E={class:"text-sm font-semibold"},O={key:0,class:"badge bg-danger-soft text-danger"},U={class:"border-t border-line p-4 sm:p-5"},W={key:0,class:"mb-4 text-xs text-muted"},Z={key:0,class:"px-4 pb-3 text-xs font-medium text-danger"},L=C({__name:"ObjectField",props:{field:{},path:{},issues:{},disabled:{type:Boolean},modelValue:{},collection:{},entrySlug:{}},emits:["update:modelValue"],setup(t,{emit:g}){const s=t,V=g,e=c(()=>s.field),{label:p,error:v}=$(s),f=k(!e.value.collapsed),_=c(()=>s.modelValue&&typeof s.modelValue=="object"?s.modelValue:{}),b=c(()=>{var r;return((r=s.issues)==null?void 0:r.some(l=>l.path.startsWith(`${s.path}.`)))??!1}),i=c(()=>f.value||b.value);return(r,l)=>(a(),d("fieldset",F,[m("legend",I,n(o(p)),1),(a(),x(B(e.value.collapsible?"button":"div"),{type:e.value.collapsible?"button":void 0,"aria-expanded":e.value.collapsible?i.value:void 0,class:y(["flex w-full items-center gap-2 px-4 py-3 text-left",e.value.collapsible&&"hover:bg-canvas"]),onClick:l[0]||(l[0]=h=>e.value.collapsible?f.value=!i.value:void 0)},{default:w(()=>[m("span",E,n(o(p)),1),b.value?(a(),d("span",O," Needs attention ")):u("",!0),e.value.collapsible?(a(),x(o(z),{key:1,size:16,class:y(["ml-auto h-4 w-4 text-muted transition",i.value&&"rotate-180"]),"aria-hidden":"true"},null,8,["class"])):u("",!0)]),_:1},8,["type","aria-expanded","class"])),S(m("div",U,[e.value.description?(a(),d("p",W,n(e.value.description),1)):u("",!0),N(j,{fields:e.value.fields,"model-value":_.value,path:t.path,issues:t.issues,disabled:t.disabled||e.value.readonly,collection:t.collection,"entry-slug":t.entrySlug,"onUpdate:modelValue":l[1]||(l[1]=h=>V("update:modelValue",h))},null,8,["fields","model-value","path","issues","disabled","collection","entry-slug"])],512),[[D,i.value]]),o(v)?(a(),d("p",Z,n(o(v)),1)):u("",!0)]))}});export{L as default};
|
|
2
|
+
//# sourceMappingURL=ObjectField--_IMDLHp.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObjectField
|
|
1
|
+
{"version":3,"file":"ObjectField--_IMDLHp.js","sources":["../../src/components/fields/ObjectField.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/**\n * Nested object. Recurses through `FieldList`, so nesting depth is unbounded.\n */\n\nimport { computed, ref } from \"vue\";\nimport { ChevronDown } from \"@lucide/vue\";\n\nimport type { ObjectField } from \"@micacms/core\";\n\nimport FieldList from \"./FieldList.vue\";\nimport { useField, type FieldProps } from \"@/composables/useField\";\n\nconst props = defineProps<\n FieldProps & { modelValue: unknown; collection?: string; entrySlug?: string }\n>();\nconst emit = defineEmits<{ \"update:modelValue\": [Record<string, unknown>] }>();\n\nconst field = computed(() => props.field as ObjectField);\nconst { label, error } = useField(props);\n\nconst open = ref(!field.value.collapsed);\n\nconst value = computed<Record<string, unknown>>(() =>\n props.modelValue && typeof props.modelValue === \"object\"\n ? (props.modelValue as Record<string, unknown>)\n : {},\n);\n\n// A collapsed group that hides an error is a trap; force it open.\nconst hasIssueInside = computed(\n () => props.issues?.some((issue) => issue.path.startsWith(`${props.path}.`)) ?? false,\n);\n\nconst expanded = computed(() => open.value || hasIssueInside.value);\n</script>\n\n<template>\n <fieldset class=\"card overflow-hidden\">\n <legend class=\"sr-only\">{{ label }}</legend>\n\n <component\n :is=\"field.collapsible ? 'button' : 'div'\"\n :type=\"field.collapsible ? 'button' : undefined\"\n :aria-expanded=\"field.collapsible ? expanded : undefined\"\n :class=\"[\n 'flex w-full items-center gap-2 px-4 py-3 text-left',\n field.collapsible && 'hover:bg-canvas',\n ]\"\n @click=\"field.collapsible ? (open = !expanded) : undefined\"\n >\n <span class=\"text-sm font-semibold\">{{ label }}</span>\n\n <span\n v-if=\"hasIssueInside\"\n class=\"badge bg-danger-soft text-danger\"\n >\n Needs attention\n </span>\n\n <ChevronDown\n v-if=\"field.collapsible\"\n :size=\"16\"\n :class=\"['ml-auto h-4 w-4 text-muted transition', expanded && 'rotate-180']\"\n aria-hidden=\"true\"\n />\n </component>\n\n <div v-show=\"expanded\" class=\"border-t border-line p-4 sm:p-5\">\n <p v-if=\"field.description\" class=\"mb-4 text-xs text-muted\">\n {{ field.description }}\n </p>\n\n <FieldList\n :fields=\"field.fields\"\n :model-value=\"value\"\n :path=\"path\"\n :issues=\"issues\"\n :disabled=\"disabled || field.readonly\"\n :collection=\"collection\"\n :entry-slug=\"entrySlug\"\n @update:model-value=\"emit('update:modelValue', $event)\"\n />\n </div>\n\n <p v-if=\"error\" class=\"px-4 pb-3 text-xs font-medium text-danger\">{{ error }}</p>\n </fieldset>\n</template>\n"],"names":["props","__props","emit","__emit","field","computed","label","error","useField","open","ref","value","hasIssueInside","_a","issue","expanded","_openBlock","_createElementBlock","_hoisted_1","_createElementVNode","_hoisted_2","_toDisplayString","_unref","_createBlock","_resolveDynamicComponent","_normalizeClass","_cache","$event","_hoisted_3","_hoisted_4","ChevronDown","_withDirectives","_hoisted_5","_hoisted_6","_createVNode","FieldList","_hoisted_7"],"mappings":"m1BAaA,MAAMA,EAAQC,EAGRC,EAAOC,EAEPC,EAAQC,EAAS,IAAML,EAAM,KAAoB,EACjD,CAAE,MAAAM,EAAO,MAAAC,GAAUC,EAASR,CAAK,EAEjCS,EAAOC,EAAI,CAACN,EAAM,MAAM,SAAS,EAEjCO,EAAQN,EAAkC,IAC9CL,EAAM,YAAc,OAAOA,EAAM,YAAe,SAC3CA,E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,sBAAkByB,EAAA,CAAA,IAAAA,EAAA,CAAA,EAAAC,GAAEzB,EAAI,oBAAsByB,CAAM,EAAA,kGAb5CZ,EAAA,KAAQ,CAAA,GAiBZO,EAAAf,CAAA,OAATU,EAAiF,IAAjFmB,EAAiFf,EAAZC,EAAAf,CAAA,CAAK,EAAA,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{D as r,d as l,c as n,a as t,
|
|
1
|
+
import{D as r,d as l,c as n,a as t,s as d,w as m,b as o,t as a,E as x,p as u,h as s,j as h,l as f,e as k}from"./index-BHBq4-Io.js";/**
|
|
2
2
|
* @license @lucide/vue v1.37.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/const b=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],_=r("chevron-left",b),p={class:"border-b border-line bg-raised"},g={class:"mx-auto flex max-w-5xl flex-wrap items-center gap-4 px-4 py-4 sm:px-6"},v={class:"min-w-0 flex-1"},w={class:"truncate font-display text-2xl font-normal leading-8 tracking-tight"},y={key:1,class:"mt-1 truncate text-xs text-muted"},L={class:"flex shrink-0 items-center gap-2"},N=l({__name:"PageHeader",props:{title:{},subtitle:{},back:{},backLabel:{}},setup(e){return(c,B)=>{const i=u("RouterLink");return s(),n("header",p,[t("div",g,[t("div",v,[e.back?(s(),d(i,{key:0,to:e.back,class:"mb-0.5 inline-flex items-center gap-1 text-xs font-medium text-muted hover:text-ink"},{default:m(()=>[h(f(_),{size:14,"aria-hidden":"true"}),k(" "+a(e.backLabel??"Back"),1)]),_:1},8,["to"])):o("",!0),t("h1",w,a(e.title),1),e.subtitle?(s(),n("p",y,a(e.subtitle),1)):o("",!0)]),t("div",L,[x(c.$slots,"default")])])])}}});export{N as _};
|
|
7
|
-
//# sourceMappingURL=PageHeader.vue_vue_type_script_setup_true_lang-
|
|
7
|
+
//# sourceMappingURL=PageHeader.vue_vue_type_script_setup_true_lang-Cr0v1G7O.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PageHeader.vue_vue_type_script_setup_true_lang-
|
|
1
|
+
{"version":3,"file":"PageHeader.vue_vue_type_script_setup_true_lang-Cr0v1G7O.js","sources":["../../../../common/temp/node_modules/.pnpm/@lucide+vue@1.37.0_vue@3.5.42_typescript@5.9.3_/node_modules/@lucide/vue/dist/esm/icons/chevron-left.mjs","../../src/components/PageHeader.vue"],"sourcesContent":["/**\n * @license @lucide/vue v1.37.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconNode = [[\"path\", { d: \"m15 18-6-6 6-6\", key: \"1wnfg3\" }]];\nconst ChevronLeft = createLucideIcon(\"chevron-left\", __iconNode);\n\nexport { __iconNode, ChevronLeft as default };\n//# sourceMappingURL=chevron-left.mjs.map\n","<script setup lang=\"ts\">\nimport { ChevronLeft } from \"@lucide/vue\";\n\ndefineProps<{\n title: string;\n subtitle?: string | null;\n /** Rendered as a back link above the title. */\n back?: { name: string; params?: Record<string, string> } | null;\n backLabel?: string;\n}>();\n</script>\n\n<template>\n <header class=\"border-b border-line bg-raised\">\n <div class=\"mx-auto flex max-w-5xl flex-wrap items-center gap-4 px-4 py-4 sm:px-6\">\n <div class=\"min-w-0 flex-1\">\n <RouterLink\n v-if=\"back\"\n :to=\"back\"\n class=\"mb-0.5 inline-flex items-center gap-1 text-xs font-medium text-muted hover:text-ink\"\n >\n <ChevronLeft :size=\"14\" aria-hidden=\"true\" />\n {{ backLabel ?? \"Back\" }}\n </RouterLink>\n\n <h1 class=\"truncate font-display text-2xl font-normal leading-8 tracking-tight\">{{ title }}</h1>\n <p v-if=\"subtitle\" class=\"mt-1 truncate text-xs text-muted\">{{ subtitle }}</p>\n </div>\n\n <div class=\"flex shrink-0 items-center gap-2\">\n <slot />\n </div>\n </div>\n </header>\n</template>\n"],"names":["__iconNode","ChevronLeft","createLucideIcon","_openBlock","_createElementBlock","_hoisted_1","_createElementVNode","_hoisted_2","_hoisted_3","__props","_createBlock","_component_RouterLink","_createVNode","_unref","_createTextVNode","_hoisted_4","_toDisplayString","_hoisted_5","_hoisted_6","_renderSlot","_ctx"],"mappings":"mIAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GASA,MAAMA,EAAa,CAAC,CAAC,OAAQ,CAAE,EAAG,iBAAkB,IAAK,QAAQ,CAAE,CAAC,EAC9DC,EAAcC,EAAiB,eAAgBF,CAAU,ocCG7D,OAAAG,EAAA,EAAAC,EAoBS,SApBTC,EAoBS,CAnBPC,EAkBM,MAlBNC,EAkBM,CAjBJD,EAYM,MAZNE,EAYM,CAVIC,EAAA,UADRC,EAOaC,EAAA,OALV,GAAIF,EAAA,KACL,MAAM,qFAAA,aAEN,IAA6C,CAA7CG,EAA6CC,EAAAZ,CAAA,EAAA,CAA/B,KAAM,GAAI,cAAY,MAAA,GAASa,EAAA,MAC1CL,EAAA,WAAS,MAAA,EAAA,CAAA,CAAA,4BAGdH,EAAgG,KAAhGS,EAAgGC,EAAbP,EAAA,KAAK,EAAA,CAAA,EAC/EA,EAAA,cAATL,EAA8E,IAA9Ea,EAA8ED,EAAfP,EAAA,QAAQ,EAAA,CAAA,cAGzEH,EAEM,MAFNY,EAEM,CADJC,EAAQC,EAAA,OAAA,SAAA,CAAA","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{D as o,d as n,c as a,a as s,t as r,h as c}from"./index-BHBq4-Io.js";/**
|
|
2
|
+
* @license @lucide/vue v1.37.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const d=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],_=o("plus",d),i={role:"status",class:"mb-5 rounded-md border border-warning/15 bg-warning-soft p-4"},p={class:"mt-1 text-xs text-muted"},u=n({__name:"ReadOnlyNotice",props:{reason:{}},setup(t){return(l,e)=>(c(),a("div",i,[e[0]||(e[0]=s("p",{class:"text-sm font-medium text-warning"},"Read-only in this version of Mica",-1)),s("p",p,r(t.reason),1)]))}});export{_ as P,u as _};
|
|
7
|
+
//# sourceMappingURL=ReadOnlyNotice.vue_vue_type_script_setup_true_lang-BtfQSv1l.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReadOnlyNotice.vue_vue_type_script_setup_true_lang-BtfQSv1l.js","sources":["../../../../common/temp/node_modules/.pnpm/@lucide+vue@1.37.0_vue@3.5.42_typescript@5.9.3_/node_modules/@lucide/vue/dist/esm/icons/plus.mjs","../../src/components/ReadOnlyNotice.vue"],"sourcesContent":["/**\n * @license @lucide/vue v1.37.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconNode = [\n [\"path\", { d: \"M5 12h14\", key: \"1ays0h\" }],\n [\"path\", { d: \"M12 5v14\", key: \"s699le\" }]\n];\nconst Plus = createLucideIcon(\"plus\", __iconNode);\n\nexport { __iconNode, Plus as default };\n//# sourceMappingURL=plus.mjs.map\n","<script setup lang=\"ts\">\n/** Why this collection or singleton cannot be edited here: the model is newer than this Mica. */\ndefineProps<{ reason: string }>();\n</script>\n\n<template>\n <div role=\"status\" class=\"mb-5 rounded-md border border-warning/15 bg-warning-soft p-4\">\n <p class=\"text-sm font-medium text-warning\">Read-only in this version of Mica</p>\n <p class=\"mt-1 text-xs text-muted\">{{ reason }}</p>\n </div>\n</template>\n"],"names":["__iconNode","Plus","createLucideIcon","_openBlock","_createElementBlock","_hoisted_1","_cache","_createElementVNode","_hoisted_2","_toDisplayString","__props"],"mappings":"2EAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GASA,MAAMA,EAAa,CACjB,CAAC,OAAQ,CAAE,EAAG,WAAY,IAAK,QAAQ,CAAE,EACzC,CAAC,OAAQ,CAAE,EAAG,WAAY,IAAK,QAAQ,CAAE,CAC3C,EACMC,EAAOC,EAAiB,OAAQF,CAAU,mMCP9CG,EAAA,EAAAC,EAGM,MAHNC,EAGM,CAFJC,EAAA,CAAA,IAAAA,EAAA,CAAA,EAAAC,EAAiF,IAAA,CAA9E,MAAM,kCAAA,EAAmC,oCAAiC,EAAA,GAC7EA,EAAmD,IAAnDC,EAAmDC,EAAbC,EAAA,MAAM,EAAA,CAAA,CAAA","x_google_ignoreList":[0]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{D as w,d as j,h as i,c,a as o,e as V,t as r,l as h,b as f,F as B,k as R,j as v,C as I,
|
|
1
|
+
import{D as w,d as j,h as i,c,a as o,e as V,t as r,l as h,b as f,F as B,k as R,j as v,C as I,v as U,Z as H,g as _,r as P}from"./index-BHBq4-Io.js";import{_ as T,d as q}from"./useUnsavedChanges-FKPfUHdo.js";import{u as E,h as W}from"./useField-vKkdSfn7.js";import{C as Z}from"./chevron-down-CnhoXsgY.js";import{A as G,a as J}from"./arrow-up-Bg3MuXmP.js";import{P as K}from"./ReadOnlyNotice.vue_vue_type_script_setup_true_lang-BtfQSv1l.js";import"./arrow-right-D8-sqdXS.js";/**
|
|
2
2
|
* @license @lucide/vue v1.37.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -9,4 +9,4 @@ import{D as w,d as j,h as i,c,a as o,e as V,t as r,l as h,b as f,F as B,k as R,j
|
|
|
9
9
|
* This source code is licensed under the ISC license.
|
|
10
10
|
* See the LICENSE file in the root directory of this source tree.
|
|
11
11
|
*/const X=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],Y=w("trash-2",X),ee={class:"field-label mb-1.5"},te={key:0,class:"text-danger","aria-hidden":"true"},se={key:0,class:"field-hint -mt-1 mb-2"},ae={key:1,class:"space-y-2"},le={class:"flex items-center gap-1 bg-canvas/60 px-3 py-2"},oe=["aria-expanded","onClick"],ne={class:"truncate text-sm font-medium"},de={key:0,class:"badge shrink-0 bg-danger-soft text-danger"},ie={class:"flex shrink-0 items-center gap-0.5"},ce=["disabled","onClick"],re={class:"sr-only"},ue=["disabled","onClick"],he={class:"sr-only"},me=["disabled","onClick"],ve={class:"sr-only"},pe=["disabled","onClick"],ye={class:"sr-only"},be={class:"border-t border-line p-4"},fe={key:2,class:"rounded-lg border border-dashed border-line px-4 py-5 text-center text-sm text-muted"},_e=["disabled"],ge={key:3,class:"ml-2 text-xs text-muted"},ke={key:4,class:"field-error"},Ne=j({__name:"RepeaterField",props:{field:{},path:{},issues:{},disabled:{type:Boolean},modelValue:{},collection:{},entrySlug:{}},emits:["update:modelValue"],setup(d,{emit:x}){const p=d,$=x,l=_(()=>p.field),{label:M,error:k}=E(p),m=P(new Set),n=_(()=>Array.isArray(p.modelValue)?p.modelValue:[]),g=_(()=>l.value.max!==void 0&&n.value.length>=l.value.max),z=_(()=>l.value.min!==void 0&&n.value.length<=l.value.min);function y(s,t){var u;const a=l.value.itemLabel,e=a?s[a]:void 0;return typeof e=="string"&&e.trim()?e.trim():`${W(((u=l.value.addLabel)==null?void 0:u.replace(/^Add\s+/i,""))??"Item")} ${t+1}`}function N(s){var t;return((t=p.issues)==null?void 0:t.some(a=>a.path.startsWith(`${p.path}.${s}.`)))??!1}function b(s){$("update:modelValue",s)}function A(){b([...n.value,q(l.value.fields)])}function S(s){const t=n.value[s];if(!t)return;const a=[...n.value];a.splice(s+1,0,structuredClone(t)),b(a)}function D(s){b(n.value.filter((t,a)=>a!==s)),m.value=new Set([...m.value].filter(t=>t!==s).map(t=>t>s?t-1:t))}function C(s,t){const a=s+t;if(a<0||a>=n.value.length)return;const e=[...n.value];[e[s],e[a]]=[e[a],e[s]],b(e)}function F(s,t){b(n.value.map((a,e)=>e===s?t:a))}function L(s){const t=new Set(m.value);t.has(s)?t.delete(s):t.add(s),m.value=t}return(s,t)=>(i(),c("fieldset",null,[o("legend",ee,[V(r(h(M))+" ",1),l.value.required?(i(),c("span",te,"*")):f("",!0)]),l.value.description?(i(),c("p",se,r(l.value.description),1)):f("",!0),n.value.length?(i(),c("ol",ae,[(i(!0),c(B,null,R(n.value,(a,e)=>(i(),c("li",{key:e,class:"card overflow-hidden"},[o("div",le,[o("button",{type:"button",class:"flex min-w-0 flex-1 items-center gap-2 text-left","aria-expanded":!m.value.has(e),onClick:u=>L(e)},[v(h(Z),{size:16,class:I(["h-4 w-4 shrink-0 text-muted transition",!m.value.has(e)&&"rotate-180"]),"aria-hidden":"true"},null,8,["class"]),o("span",ne,r(y(a,e)),1),N(e)?(i(),c("span",de," Needs attention ")):f("",!0)],8,oe),o("div",ie,[o("button",{type:"button",class:"btn-ghost px-1.5 py-1",disabled:d.disabled||e===0,onClick:u=>C(e,-1)},[v(h(G),{size:16,"aria-hidden":"true"}),o("span",re,'Move "'+r(y(a,e))+'" up',1)],8,ce),o("button",{type:"button",class:"btn-ghost px-1.5 py-1",disabled:d.disabled||e===n.value.length-1,onClick:u=>C(e,1)},[v(h(J),{size:16,"aria-hidden":"true"}),o("span",he,'Move "'+r(y(a,e))+'" down',1)],8,ue),o("button",{type:"button",class:"btn-ghost px-1.5 py-1",disabled:d.disabled||g.value,onClick:u=>S(e)},[v(h(Q),{size:16,"aria-hidden":"true"}),o("span",ve,'Duplicate "'+r(y(a,e))+'"',1)],8,me),o("button",{type:"button",class:"btn-ghost px-1.5 py-1 hover:text-danger",disabled:d.disabled||z.value,onClick:u=>D(e)},[v(h(Y),{size:16,"aria-hidden":"true"}),o("span",ye,'Remove "'+r(y(a,e))+'"',1)],8,pe)])]),U(o("div",be,[v(T,{fields:l.value.fields,"model-value":a,path:`${d.path}.${e}`,issues:d.issues,disabled:d.disabled||l.value.readonly,collection:d.collection,"entry-slug":d.entrySlug,"onUpdate:modelValue":u=>F(e,u)},null,8,["fields","model-value","path","issues","disabled","collection","entry-slug","onUpdate:modelValue"])],512),[[H,!m.value.has(e)]])]))),128))])):(i(),c("p",fe," Nothing added yet. ")),o("button",{type:"button",class:"btn-secondary mt-2",disabled:d.disabled||l.value.readonly||g.value,onClick:A},[v(h(K),{size:16,"aria-hidden":"true"}),V(" "+r(l.value.addLabel??"Add item"),1)],8,_e),g.value?(i(),c("span",ge," Maximum of "+r(l.value.max)+" reached. ",1)):f("",!0),h(k)?(i(),c("p",ke,r(h(k)),1)):f("",!0)]))}});export{Ne as default};
|
|
12
|
-
//# sourceMappingURL=RepeaterField-
|
|
12
|
+
//# sourceMappingURL=RepeaterField-CRo8CLz6.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RepeaterField-BnXDf3wL.js","sources":["../../../../common/temp/node_modules/.pnpm/@lucide+vue@1.37.0_vue@3.5.42_typescript@5.9.3_/node_modules/@lucide/vue/dist/esm/icons/copy.mjs","../../../../common/temp/node_modules/.pnpm/@lucide+vue@1.37.0_vue@3.5.42_typescript@5.9.3_/node_modules/@lucide/vue/dist/esm/icons/trash-2.mjs","../../src/components/fields/RepeaterField.vue"],"sourcesContent":["/**\n * @license @lucide/vue v1.37.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconNode = [\n [\"rect\", { width: \"14\", height: \"14\", x: \"8\", y: \"8\", rx: \"2\", ry: \"2\", key: \"17jyea\" }],\n [\"path\", { d: \"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2\", key: \"zix9uf\" }]\n];\nconst Copy = createLucideIcon(\"copy\", __iconNode);\n\nexport { __iconNode, Copy as default };\n//# sourceMappingURL=copy.mjs.map\n","/**\n * @license @lucide/vue v1.37.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconNode = [\n [\"path\", { d: \"M10 11v6\", key: \"nco0om\" }],\n [\"path\", { d: \"M14 11v6\", key: \"outv1u\" }],\n [\"path\", { d: \"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6\", key: \"miytrc\" }],\n [\"path\", { d: \"M3 6h18\", key: \"d0wm0j\" }],\n [\"path\", { d: \"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2\", key: \"e791ji\" }]\n];\nconst Trash2 = createLucideIcon(\"trash-2\", __iconNode);\n\nexport { __iconNode, Trash2 as default };\n//# sourceMappingURL=trash-2.mjs.map\n","<script setup lang=\"ts\">\n/**\n * Repeating group of fields.\n *\n * Reordering is done with buttons rather than drag-and-drop: it works with a\n * keyboard, on a tablet, and with a screen reader, none of which are true of a\n * drag handle without a great deal more code.\n */\n\nimport { computed, ref } from \"vue\";\nimport { ArrowDown, ArrowUp, ChevronDown, Copy, Plus, Trash2 } from \"@lucide/vue\";\n\nimport { defaultValues, type RepeaterField } from \"@micacms/core\";\n\nimport FieldList from \"./FieldList.vue\";\nimport { humanise, useField, type FieldProps } from \"@/composables/useField\";\n\nconst props = defineProps<\n FieldProps & { modelValue: unknown; collection?: string; entrySlug?: string }\n>();\nconst emit = defineEmits<{ \"update:modelValue\": [Record<string, unknown>[]] }>();\n\nconst field = computed(() => props.field as RepeaterField);\nconst { label, error } = useField(props);\n\nconst collapsed = ref(new Set<number>());\n\nconst rows = computed<Record<string, unknown>[]>(() =>\n Array.isArray(props.modelValue) ? (props.modelValue as Record<string, unknown>[]) : [],\n);\n\nconst atMax = computed(() => field.value.max !== undefined && rows.value.length >= field.value.max);\nconst atMin = computed(() => field.value.min !== undefined && rows.value.length <= field.value.min);\n\n/** Row summary: the declared `itemLabel` child, else a positional fallback. */\nfunction summaryFor(row: Record<string, unknown>, index: number): string {\n const key = field.value.itemLabel;\n const value = key ? row[key] : undefined;\n if (typeof value === \"string\" && value.trim()) return value.trim();\n return `${humanise(field.value.addLabel?.replace(/^Add\\s+/i, \"\") ?? \"Item\")} ${index + 1}`;\n}\n\nfunction rowHasIssue(index: number): boolean {\n return props.issues?.some((issue) => issue.path.startsWith(`${props.path}.${index}.`)) ?? false;\n}\n\nfunction emitRows(next: Record<string, unknown>[]): void {\n emit(\"update:modelValue\", next);\n}\n\nfunction add(): void {\n // A new row starts as a complete skeleton so every input is bound.\n emitRows([...rows.value, defaultValues(field.value.fields)]);\n}\n\nfunction duplicate(index: number): void {\n const source = rows.value[index];\n if (!source) return;\n const next = [...rows.value];\n next.splice(index + 1, 0, structuredClone(source));\n emitRows(next);\n}\n\nfunction remove(index: number): void {\n emitRows(rows.value.filter((_, position) => position !== index));\n collapsed.value = new Set(\n [...collapsed.value].filter((item) => item !== index).map((item) => (item > index ? item - 1 : item)),\n );\n}\n\nfunction move(index: number, direction: -1 | 1): void {\n const target = index + direction;\n if (target < 0 || target >= rows.value.length) return;\n\n const next = [...rows.value];\n [next[index], next[target]] = [next[target]!, next[index]!];\n emitRows(next);\n}\n\nfunction updateRow(index: number, value: Record<string, unknown>): void {\n emitRows(rows.value.map((row, position) => (position === index ? value : row)));\n}\n\nfunction toggle(index: number): void {\n const next = new Set(collapsed.value);\n if (next.has(index)) next.delete(index);\n else next.add(index);\n collapsed.value = next;\n}\n</script>\n\n<template>\n <fieldset>\n <legend class=\"field-label mb-1.5\">\n {{ label }}\n <span v-if=\"field.required\" class=\"text-danger\" aria-hidden=\"true\">*</span>\n </legend>\n\n <p v-if=\"field.description\" class=\"field-hint -mt-1 mb-2\">{{ field.description }}</p>\n\n <ol v-if=\"rows.length\" class=\"space-y-2\">\n <li v-for=\"(row, index) in rows\" :key=\"index\" class=\"card overflow-hidden\">\n <div class=\"flex items-center gap-1 bg-canvas/60 px-3 py-2\">\n <button\n type=\"button\"\n class=\"flex min-w-0 flex-1 items-center gap-2 text-left\"\n :aria-expanded=\"!collapsed.has(index)\"\n @click=\"toggle(index)\"\n >\n <ChevronDown\n :size=\"16\"\n :class=\"[\n 'h-4 w-4 shrink-0 text-muted transition',\n !collapsed.has(index) && 'rotate-180',\n ]\"\n aria-hidden=\"true\"\n />\n <span class=\"truncate text-sm font-medium\">{{ summaryFor(row, index) }}</span>\n <span\n v-if=\"rowHasIssue(index)\"\n class=\"badge shrink-0 bg-danger-soft text-danger\"\n >\n Needs attention\n </span>\n </button>\n\n <div class=\"flex shrink-0 items-center gap-0.5\">\n <button\n type=\"button\"\n class=\"btn-ghost px-1.5 py-1\"\n :disabled=\"disabled || index === 0\"\n @click=\"move(index, -1)\"\n >\n <ArrowUp :size=\"16\" aria-hidden=\"true\" />\n <span class=\"sr-only\">Move \"{{ summaryFor(row, index) }}\" up</span>\n </button>\n\n <button\n type=\"button\"\n class=\"btn-ghost px-1.5 py-1\"\n :disabled=\"disabled || index === rows.length - 1\"\n @click=\"move(index, 1)\"\n >\n <ArrowDown :size=\"16\" aria-hidden=\"true\" />\n <span class=\"sr-only\">Move \"{{ summaryFor(row, index) }}\" down</span>\n </button>\n\n <button\n type=\"button\"\n class=\"btn-ghost px-1.5 py-1\"\n :disabled=\"disabled || atMax\"\n @click=\"duplicate(index)\"\n >\n <Copy :size=\"16\" aria-hidden=\"true\" />\n <span class=\"sr-only\">Duplicate \"{{ summaryFor(row, index) }}\"</span>\n </button>\n\n <button\n type=\"button\"\n class=\"btn-ghost px-1.5 py-1 hover:text-danger\"\n :disabled=\"disabled || atMin\"\n @click=\"remove(index)\"\n >\n <Trash2 :size=\"16\" aria-hidden=\"true\" />\n <span class=\"sr-only\">Remove \"{{ summaryFor(row, index) }}\"</span>\n </button>\n </div>\n </div>\n\n <div v-show=\"!collapsed.has(index)\" class=\"border-t border-line p-4\">\n <FieldList\n :fields=\"field.fields\"\n :model-value=\"row\"\n :path=\"`${path}.${index}`\"\n :issues=\"issues\"\n :disabled=\"disabled || field.readonly\"\n :collection=\"collection\"\n :entry-slug=\"entrySlug\"\n @update:model-value=\"updateRow(index, $event)\"\n />\n </div>\n </li>\n </ol>\n\n <p v-else class=\"rounded-lg border border-dashed border-line px-4 py-5 text-center text-sm text-muted\">\n Nothing added yet.\n </p>\n\n <button\n type=\"button\"\n class=\"btn-secondary mt-2\"\n :disabled=\"disabled || field.readonly || atMax\"\n @click=\"add\"\n >\n <Plus :size=\"16\" aria-hidden=\"true\" />\n {{ field.addLabel ?? \"Add item\" }}\n </button>\n\n <span v-if=\"atMax\" class=\"ml-2 text-xs text-muted\">\n Maximum of {{ field.max }} reached.\n </span>\n\n <p v-if=\"error\" class=\"field-error\">{{ error }}</p>\n </fieldset>\n</template>\n"],"names":["__iconNode","Copy","createLucideIcon","Trash2","props","__props","emit","__emit","field","computed","label","error","useField","collapsed","ref","rows","atMax","atMin","summaryFor","row","index","key","value","humanise","_a","rowHasIssue","issue","emitRows","next","add","defaultValues","duplicate","source","remove","_","position","item","move","direction","target","updateRow","toggle","_createElementBlock","_createElementVNode","_hoisted_1","_createTextVNode","_toDisplayString","_unref","_hoisted_2","_openBlock","_hoisted_3","_hoisted_4","_Fragment","_renderList","_hoisted_5","$event","_createVNode","ChevronDown","_normalizeClass","_hoisted_7","_hoisted_8","_hoisted_9","ArrowUp","_hoisted_11","ArrowDown","_hoisted_13","_hoisted_15","_hoisted_17","_withDirectives","_hoisted_18","FieldList","_hoisted_19","Plus","_hoisted_21","_hoisted_22"],"mappings":"0aAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GASA,MAAMA,EAAa,CACjB,CAAC,OAAQ,CAAE,MAAO,KAAM,OAAQ,KAAM,EAAG,IAAK,EAAG,IAAK,GAAI,IAAK,GAAI,IAAK,IAAK,SAAU,EACvF,CAAC,OAAQ,CAAE,EAAG,0DAA2D,IAAK,QAAQ,CAAE,CAC1F,EACM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,EAAA,UACZ,sBAAkBkD,GAAEf,EAAUpB,EAAOmC,CAAM,CAAA,yHATlC1C,EAAA,MAAU,IAAIO,CAAK,CAAA,CAAA,qBAerCsB,EAEI,IAFJ6B,GAAuG,sBAEvG,GAEA5B,EAQS,SAAA,CAPP,KAAK,SACL,MAAM,qBACL,SAAUtC,EAAA,UAAYG,QAAM,UAAYQ,EAAA,MACxC,QAAOa,CAAA,GAER2B,EAAsCT,EAAAyB,CAAA,EAAA,CAA/B,KAAM,GAAI,cAAY,MAAA,KAAS,IACtC1B,EAAGtC,EAAA,MAAM,UAAQ,UAAA,EAAA,CAAA,CAAA,QAGPQ,EAAA,WAAZ0B,EAEO,OAFP+B,GAAmD,iBACnCjE,EAAA,MAAM,GAAG,EAAG,aAC5B,CAAA,YAESuC,EAAApC,CAAA,OAAT+B,EAAmD,IAAnDgC,GAAmD5B,EAAZC,EAAApC,CAAA,CAAK,EAAA,CAAA","x_google_ignoreList":[0,1]}
|
|
1
|
+
{"version":3,"file":"RepeaterField-CRo8CLz6.js","sources":["../../../../common/temp/node_modules/.pnpm/@lucide+vue@1.37.0_vue@3.5.42_typescript@5.9.3_/node_modules/@lucide/vue/dist/esm/icons/copy.mjs","../../../../common/temp/node_modules/.pnpm/@lucide+vue@1.37.0_vue@3.5.42_typescript@5.9.3_/node_modules/@lucide/vue/dist/esm/icons/trash-2.mjs","../../src/components/fields/RepeaterField.vue"],"sourcesContent":["/**\n * @license @lucide/vue v1.37.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconNode = [\n [\"rect\", { width: \"14\", height: \"14\", x: \"8\", y: \"8\", rx: \"2\", ry: \"2\", key: \"17jyea\" }],\n [\"path\", { d: \"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2\", key: \"zix9uf\" }]\n];\nconst Copy = createLucideIcon(\"copy\", __iconNode);\n\nexport { __iconNode, Copy as default };\n//# sourceMappingURL=copy.mjs.map\n","/**\n * @license @lucide/vue v1.37.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconNode = [\n [\"path\", { d: \"M10 11v6\", key: \"nco0om\" }],\n [\"path\", { d: \"M14 11v6\", key: \"outv1u\" }],\n [\"path\", { d: \"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6\", key: \"miytrc\" }],\n [\"path\", { d: \"M3 6h18\", key: \"d0wm0j\" }],\n [\"path\", { d: \"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2\", key: \"e791ji\" }]\n];\nconst Trash2 = createLucideIcon(\"trash-2\", __iconNode);\n\nexport { __iconNode, Trash2 as default };\n//# sourceMappingURL=trash-2.mjs.map\n","<script setup lang=\"ts\">\n/**\n * Repeating group of fields.\n *\n * Reordering is done with buttons rather than drag-and-drop: it works with a\n * keyboard, on a tablet, and with a screen reader, none of which are true of a\n * drag handle without a great deal more code.\n */\n\nimport { computed, ref } from \"vue\";\nimport { ArrowDown, ArrowUp, ChevronDown, Copy, Plus, Trash2 } from \"@lucide/vue\";\n\nimport { defaultValues, type RepeaterField } from \"@micacms/core\";\n\nimport FieldList from \"./FieldList.vue\";\nimport { humanise, useField, type FieldProps } from \"@/composables/useField\";\n\nconst props = defineProps<\n FieldProps & { modelValue: unknown; collection?: string; entrySlug?: string }\n>();\nconst emit = defineEmits<{ \"update:modelValue\": [Record<string, unknown>[]] }>();\n\nconst field = computed(() => props.field as RepeaterField);\nconst { label, error } = useField(props);\n\nconst collapsed = ref(new Set<number>());\n\nconst rows = computed<Record<string, unknown>[]>(() =>\n Array.isArray(props.modelValue) ? (props.modelValue as Record<string, unknown>[]) : [],\n);\n\nconst atMax = computed(() => field.value.max !== undefined && rows.value.length >= field.value.max);\nconst atMin = computed(() => field.value.min !== undefined && rows.value.length <= field.value.min);\n\n/** Row summary: the declared `itemLabel` child, else a positional fallback. */\nfunction summaryFor(row: Record<string, unknown>, index: number): string {\n const key = field.value.itemLabel;\n const value = key ? row[key] : undefined;\n if (typeof value === \"string\" && value.trim()) return value.trim();\n return `${humanise(field.value.addLabel?.replace(/^Add\\s+/i, \"\") ?? \"Item\")} ${index + 1}`;\n}\n\nfunction rowHasIssue(index: number): boolean {\n return props.issues?.some((issue) => issue.path.startsWith(`${props.path}.${index}.`)) ?? false;\n}\n\nfunction emitRows(next: Record<string, unknown>[]): void {\n emit(\"update:modelValue\", next);\n}\n\nfunction add(): void {\n // A new row starts as a complete skeleton so every input is bound.\n emitRows([...rows.value, defaultValues(field.value.fields)]);\n}\n\nfunction duplicate(index: number): void {\n const source = rows.value[index];\n if (!source) return;\n const next = [...rows.value];\n next.splice(index + 1, 0, structuredClone(source));\n emitRows(next);\n}\n\nfunction remove(index: number): void {\n emitRows(rows.value.filter((_, position) => position !== index));\n collapsed.value = new Set(\n [...collapsed.value].filter((item) => item !== index).map((item) => (item > index ? item - 1 : item)),\n );\n}\n\nfunction move(index: number, direction: -1 | 1): void {\n const target = index + direction;\n if (target < 0 || target >= rows.value.length) return;\n\n const next = [...rows.value];\n [next[index], next[target]] = [next[target]!, next[index]!];\n emitRows(next);\n}\n\nfunction updateRow(index: number, value: Record<string, unknown>): void {\n emitRows(rows.value.map((row, position) => (position === index ? value : row)));\n}\n\nfunction toggle(index: number): void {\n const next = new Set(collapsed.value);\n if (next.has(index)) next.delete(index);\n else next.add(index);\n collapsed.value = next;\n}\n</script>\n\n<template>\n <fieldset>\n <legend class=\"field-label mb-1.5\">\n {{ label }}\n <span v-if=\"field.required\" class=\"text-danger\" aria-hidden=\"true\">*</span>\n </legend>\n\n <p v-if=\"field.description\" class=\"field-hint -mt-1 mb-2\">{{ field.description }}</p>\n\n <ol v-if=\"rows.length\" class=\"space-y-2\">\n <li v-for=\"(row, index) in rows\" :key=\"index\" class=\"card overflow-hidden\">\n <div class=\"flex items-center gap-1 bg-canvas/60 px-3 py-2\">\n <button\n type=\"button\"\n class=\"flex min-w-0 flex-1 items-center gap-2 text-left\"\n :aria-expanded=\"!collapsed.has(index)\"\n @click=\"toggle(index)\"\n >\n <ChevronDown\n :size=\"16\"\n :class=\"[\n 'h-4 w-4 shrink-0 text-muted transition',\n !collapsed.has(index) && 'rotate-180',\n ]\"\n aria-hidden=\"true\"\n />\n <span class=\"truncate text-sm font-medium\">{{ summaryFor(row, index) }}</span>\n <span\n v-if=\"rowHasIssue(index)\"\n class=\"badge shrink-0 bg-danger-soft text-danger\"\n >\n Needs attention\n </span>\n </button>\n\n <div class=\"flex shrink-0 items-center gap-0.5\">\n <button\n type=\"button\"\n class=\"btn-ghost px-1.5 py-1\"\n :disabled=\"disabled || index === 0\"\n @click=\"move(index, -1)\"\n >\n <ArrowUp :size=\"16\" aria-hidden=\"true\" />\n <span class=\"sr-only\">Move \"{{ summaryFor(row, index) }}\" up</span>\n </button>\n\n <button\n type=\"button\"\n class=\"btn-ghost px-1.5 py-1\"\n :disabled=\"disabled || index === rows.length - 1\"\n @click=\"move(index, 1)\"\n >\n <ArrowDown :size=\"16\" aria-hidden=\"true\" />\n <span class=\"sr-only\">Move \"{{ summaryFor(row, index) }}\" down</span>\n </button>\n\n <button\n type=\"button\"\n class=\"btn-ghost px-1.5 py-1\"\n :disabled=\"disabled || atMax\"\n @click=\"duplicate(index)\"\n >\n <Copy :size=\"16\" aria-hidden=\"true\" />\n <span class=\"sr-only\">Duplicate \"{{ summaryFor(row, index) }}\"</span>\n </button>\n\n <button\n type=\"button\"\n class=\"btn-ghost px-1.5 py-1 hover:text-danger\"\n :disabled=\"disabled || atMin\"\n @click=\"remove(index)\"\n >\n <Trash2 :size=\"16\" aria-hidden=\"true\" />\n <span class=\"sr-only\">Remove \"{{ summaryFor(row, index) }}\"</span>\n </button>\n </div>\n </div>\n\n <div v-show=\"!collapsed.has(index)\" class=\"border-t border-line p-4\">\n <FieldList\n :fields=\"field.fields\"\n :model-value=\"row\"\n :path=\"`${path}.${index}`\"\n :issues=\"issues\"\n :disabled=\"disabled || field.readonly\"\n :collection=\"collection\"\n :entry-slug=\"entrySlug\"\n @update:model-value=\"updateRow(index, $event)\"\n />\n </div>\n </li>\n </ol>\n\n <p v-else class=\"rounded-lg border border-dashed border-line px-4 py-5 text-center text-sm text-muted\">\n Nothing added yet.\n </p>\n\n <button\n type=\"button\"\n class=\"btn-secondary mt-2\"\n :disabled=\"disabled || field.readonly || atMax\"\n @click=\"add\"\n >\n <Plus :size=\"16\" aria-hidden=\"true\" />\n {{ field.addLabel ?? \"Add item\" }}\n </button>\n\n <span v-if=\"atMax\" class=\"ml-2 text-xs text-muted\">\n Maximum of {{ field.max }} reached.\n </span>\n\n <p v-if=\"error\" class=\"field-error\">{{ error }}</p>\n </fieldset>\n</template>\n"],"names":["__iconNode","Copy","createLucideIcon","Trash2","props","__props","emit","__emit","field","computed","label","error","useField","collapsed","ref","rows","atMax","atMin","summaryFor","row","index","key","value","humanise","_a","rowHasIssue","issue","emitRows","next","add","defaultValues","duplicate","source","remove","_","position","item","move","direction","target","updateRow","toggle","_createElementBlock","_createElementVNode","_hoisted_1","_createTextVNode","_toDisplayString","_unref","_hoisted_2","_openBlock","_hoisted_3","_hoisted_4","_Fragment","_renderList","_hoisted_5","$event","_createVNode","ChevronDown","_normalizeClass","_hoisted_7","_hoisted_8","_hoisted_9","ArrowUp","_hoisted_11","ArrowDown","_hoisted_13","_hoisted_15","_hoisted_17","_withDirectives","_hoisted_18","FieldList","_hoisted_19","Plus","_hoisted_21","_hoisted_22"],"mappings":"wdAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GASA,MAAMA,EAAa,CACjB,CAAC,OAAQ,CAAE,MAAO,KAAM,OAAQ,KAAM,EAAG,IAAK,EAAG,IAAK,GAAI,IAAK,GAAI,IAAK,IAAK,SAAU,EACvF,CAAC,OAAQ,CAAE,EAAG,0DAA2D,IAAK,QAAQ,CAAE,CAC1F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AAYA,EAAA,UACZ,sBAAkBkD,GAAEf,EAAUpB,EAAOmC,CAAM,CAAA,yHATlC1C,EAAA,MAAU,IAAIO,CAAK,CAAA,CAAA,qBAerCsB,EAEI,IAFJ6B,GAAuG,sBAEvG,GAEA5B,EAQS,SAAA,CAPP,KAAK,SACL,MAAM,qBACL,SAAUtC,EAAA,UAAYG,QAAM,UAAYQ,EAAA,MACxC,QAAOa,CAAA,GAER2B,EAAsCT,EAAAyB,CAAA,EAAA,CAA/B,KAAM,GAAI,cAAY,MAAA,KAAS,IACtC1B,EAAGtC,EAAA,MAAM,UAAQ,UAAA,EAAA,CAAA,CAAA,QAGPQ,EAAA,WAAZ0B,EAEO,OAFP+B,GAAmD,iBACnCjE,EAAA,MAAM,GAAG,EAAG,aAC5B,CAAA,YAESuC,EAAApC,CAAA,OAAT+B,EAAmD,IAAnDgC,GAAmD5B,EAAZC,EAAApC,CAAA,CAAK,EAAA,CAAA","x_google_ignoreList":[0,1]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{d as A,o as E,q as F,c as a,j as C,w as B,a as n,F as y,t as r,b as u,s as M,k as R,z as j,g as L,r as d,i as $,A as b,p as q,n as P,h as t,e as D,l as x,C as Y,m as G,y as H}from"./index-BHBq4-Io.js";import{u as I,_ as J,w as K}from"./useUnsavedChanges-FKPfUHdo.js";import{_ as Q}from"./PageHeader.vue_vue_type_script_setup_true_lang-Cr0v1G7O.js";import{_ as W}from"./ReadOnlyNotice.vue_vue_type_script_setup_true_lang-BtfQSv1l.js";import"./useField-vKkdSfn7.js";import"./arrow-right-D8-sqdXS.js";const X=["disabled"],Z={class:"mx-auto max-w-3xl px-4 py-6 sm:px-6"},ee={key:0,class:"text-sm text-muted"},te={key:0,class:"mb-5 text-sm text-muted"},se={key:2,role:"alert",class:"mb-5 rounded-md border border-warning/15 bg-warning-soft p-4"},ae={key:3,role:"alert",class:"mb-5 rounded-md border border-warning/15 bg-warning-soft p-4"},ne={key:4,role:"alert",class:"mb-5 rounded-md border border-danger/15 bg-danger-soft p-4"},oe={class:"text-sm font-medium text-danger"},le={class:"mt-1.5 space-y-0.5 text-xs text-danger"},ie={key:0,type:"submit",class:"sr-only"},re={key:1,class:"p-8 text-center text-sm text-muted"},fe=A({__name:"SingletonView",props:{name:{}},setup(S){const c=S,U=H(),V=G(),m=P(),s=L(()=>U.singleton(c.name)),v=d({}),l=d([]),w=d(null),_=d(!0),g=d(!1),f=d(!1),z=L(()=>{var o,e;return(((e=(o=V.status.value)==null?void 0:o.sync)==null?void 0:e.conflicts)??[]).some(h=>{var i;return((i=h.target)==null?void 0:i.kind)==="singleton"&&h.target.name===c.name})}),O=d(""),{dirty:p,markClean:T}=I(v);async function k(){var o;_.value=!0;try{const e=await $.singletons.get(c.name);v.value=structuredClone(K(((o=s.value)==null?void 0:o.fields)??{},e.data)),w.value=e.revision,O.value=e.path,l.value=[],f.value=!1,T()}catch(e){m.error(e instanceof b?e.message:"Could not load these settings.")}finally{_.value=!1}}E(k),F(()=>c.name,k);async function N(){var o;if(!((o=s.value)!=null&&o.readOnly)){g.value=!0,l.value=[];try{const e=await $.singletons.save(c.name,v.value,w.value);w.value=e.revision,f.value=!1,T(),m.success("Settings saved."),V.refresh()}catch(e){e instanceof b&&e.status===409?(f.value=!0,m.error("These settings were changed while you were editing them — by a colleague or on the website.")):e instanceof b&&e.issues.length>0?(l.value=e.issues,m.error(e.message,`${e.issues.length} field(s) need attention.`)):m.error(e instanceof b?e.message:"Could not save these settings.")}finally{g.value=!1}}}return(o,e)=>{const h=q("RouterLink");return s.value?(t(),a(y,{key:0},[C(Q,{title:s.value.label,subtitle:O.value},{default:B(()=>[s.value.readOnly?u("",!0):(t(),a(y,{key:0},[n("span",{class:Y(["badge",x(p)?"border-accent bg-accent-soft text-accent":"text-success"])},[e[1]||(e[1]=n("span",{class:"h-1.5 w-1.5 rounded-full bg-current","aria-hidden":"true"},null,-1)),D(" "+r(x(p)?"Unsaved":"Saved"),1)],2),n("button",{type:"button",class:"btn-primary",disabled:g.value||!x(p),onClick:N},r(g.value?"Saving…":x(p)?"Save changes":"Saved"),9,X)],64))]),_:1},8,["title","subtitle"]),n("div",Z,[_.value?(t(),a("p",ee,"Loading…")):(t(),a(y,{key:1},[s.value.description?(t(),a("p",te,r(s.value.description),1)):u("",!0),s.value.readOnly?(t(),M(W,{key:1,reason:s.value.readOnly},null,8,["reason"])):u("",!0),z.value?(t(),a("div",se,[e[3]||(e[3]=n("p",{class:"text-sm font-medium text-warning"},"These settings were changed on the website while you edited",-1)),e[4]||(e[4]=n("p",{class:"mt-1 text-xs text-muted"}," Your saved version is kept. Choose which version to publish on the Publish page. ",-1)),C(h,{to:{name:"changes"},class:"btn-secondary mt-2.5 inline-flex"},{default:B(()=>[...e[2]||(e[2]=[D("Choose a version",-1)])]),_:1})])):u("",!0),f.value?(t(),a("div",ae,[e[5]||(e[5]=n("p",{class:"text-sm font-medium text-warning"},"These settings changed while you were editing",-1)),e[6]||(e[6]=n("p",{class:"mt-1 text-xs text-muted"}," Nothing has been saved. Copy anything you need, then load the current version. ",-1)),n("button",{type:"button",class:"btn-secondary mt-2.5",onClick:k}," Discard mine and reload ")])):u("",!0),l.value.length?(t(),a("div",ne,[n("p",oe,r(l.value.length)+" field"+r(l.value.length===1?"":"s")+" need attention ",1),n("ul",le,[(t(!0),a(y,null,R(l.value,i=>(t(),a("li",{key:i.path},r(i.message),1))),128))])])):u("",!0),n("form",{novalidate:"",onSubmit:j(N,["prevent"])},[C(J,{modelValue:v.value,"onUpdate:modelValue":e[0]||(e[0]=i=>v.value=i),fields:s.value.fields,issues:l.value,disabled:g.value||!!s.value.readOnly},null,8,["modelValue","fields","issues","disabled"]),s.value.readOnly?u("",!0):(t(),a("button",ie,"Save"))],32)],64))])],64)):(t(),a("div",re,' There are no settings called "'+r(S.name)+'". ',1))}}});export{fe as default};
|
|
2
|
+
//# sourceMappingURL=SingletonView-C1VhZ6Vv.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SingletonView-C1VhZ6Vv.js","sources":["../../src/views/SingletonView.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/**\n * Singleton editor: the entry editor without the parts that need a slug (no\n * rename, no delete, no list). `revision` goes back with the save, so a second\n * editor cannot be overwritten in silence.\n */\n\nimport { computed, onMounted, ref, watch } from \"vue\";\n\nimport { withDefaults as fillDefaults, type FieldIssue } from \"@micacms/core\";\n\nimport { api, ApiError } from \"@/api\";\nimport FieldList from \"@/components/fields/FieldList.vue\";\nimport PageHeader from \"@/components/PageHeader.vue\";\nimport ReadOnlyNotice from \"@/components/ReadOnlyNotice.vue\";\nimport { useUnsavedChanges } from \"@/composables/useUnsavedChanges\";\nimport { useSchema } from \"@/stores/schema\";\nimport { useStaging } from \"@/stores/staging\";\nimport { useToast } from \"@/stores/toast\";\n\nconst props = defineProps<{ name: string }>();\n\nconst schema = useSchema();\nconst staging = useStaging();\nconst toast = useToast();\n\nconst definition = computed(() => schema.singleton(props.name));\n\nconst values = ref<Record<string, unknown>>({});\nconst issues = ref<FieldIssue[]>([]);\nconst revision = ref<string | null>(null);\nconst loading = ref(true);\nconst saving = ref(false);\nconst conflict = ref(false);\n\n/**\n * These settings were changed on the website while they have a draft here:\n * Mica's own clone only.\n */\nconst websiteConflict = computed(() =>\n (staging.status.value?.sync?.conflicts ?? []).some(\n (item) => item.target?.kind === \"singleton\" && item.target.name === props.name,\n ),\n);\n\n/** Where these settings live, as the server reports it. */\nconst location = ref(\"\");\n\nconst { dirty, markClean } = useUnsavedChanges(values);\n\nasync function load(): Promise<void> {\n loading.value = true;\n try {\n const detail = await api.singletons.get(props.name);\n // Defaults fill in fields added to the model since the file was written.\n values.value = structuredClone(fillDefaults(definition.value?.fields ?? {}, detail.data));\n revision.value = detail.revision;\n location.value = detail.path;\n issues.value = [];\n conflict.value = false;\n markClean();\n } catch (error) {\n toast.error(error instanceof ApiError ? error.message : \"Could not load these settings.\");\n } finally {\n loading.value = false;\n }\n}\n\nonMounted(load);\nwatch(() => props.name, load);\n\nasync function save(): Promise<void> {\n if (definition.value?.readOnly) return;\n saving.value = true;\n issues.value = [];\n\n try {\n const saved = await api.singletons.save(props.name, values.value, revision.value);\n revision.value = saved.revision;\n conflict.value = false;\n markClean();\n toast.success(\"Settings saved.\");\n void staging.refresh();\n } catch (error) {\n if (error instanceof ApiError && error.status === 409) {\n conflict.value = true;\n toast.error(\"These settings were changed while you were editing them — by a colleague or on the website.\");\n } else if (error instanceof ApiError && error.issues.length > 0) {\n issues.value = error.issues;\n toast.error(error.message, `${error.issues.length} field(s) need attention.`);\n } else {\n toast.error(error instanceof ApiError ? error.message : \"Could not save these settings.\");\n }\n } finally {\n saving.value = false;\n }\n}\n</script>\n\n<template>\n <template v-if=\"definition\">\n <PageHeader :title=\"definition.label\" :subtitle=\"location\">\n <template v-if=\"!definition.readOnly\">\n <span :class=\"['badge', dirty ? 'border-accent bg-accent-soft text-accent' : 'text-success']\">\n <span class=\"h-1.5 w-1.5 rounded-full bg-current\" aria-hidden=\"true\" />\n {{ dirty ? \"Unsaved\" : \"Saved\" }}\n </span>\n <button type=\"button\" class=\"btn-primary\" :disabled=\"saving || !dirty\" @click=\"save\">\n {{ saving ? \"Saving…\" : dirty ? \"Save changes\" : \"Saved\" }}\n </button>\n </template>\n </PageHeader>\n\n <div class=\"mx-auto max-w-3xl px-4 py-6 sm:px-6\">\n <p v-if=\"loading\" class=\"text-sm text-muted\">Loading…</p>\n\n <template v-else>\n <p v-if=\"definition.description\" class=\"mb-5 text-sm text-muted\">\n {{ definition.description }}\n </p>\n\n <ReadOnlyNotice v-if=\"definition.readOnly\" :reason=\"definition.readOnly\" />\n\n <div\n v-if=\"websiteConflict\"\n role=\"alert\"\n class=\"mb-5 rounded-md border border-warning/15 bg-warning-soft p-4\"\n >\n <p class=\"text-sm font-medium text-warning\">These settings were changed on the website while you edited</p>\n <p class=\"mt-1 text-xs text-muted\">\n Your saved version is kept. Choose which version to publish on the Publish page.\n </p>\n <RouterLink :to=\"{ name: 'changes' }\" class=\"btn-secondary mt-2.5 inline-flex\">Choose a version</RouterLink>\n </div>\n\n <div\n v-if=\"conflict\"\n role=\"alert\"\n class=\"mb-5 rounded-md border border-warning/15 bg-warning-soft p-4\"\n >\n <p class=\"text-sm font-medium text-warning\">These settings changed while you were editing</p>\n <p class=\"mt-1 text-xs text-muted\">\n Nothing has been saved. Copy anything you need, then load the current version.\n </p>\n <button type=\"button\" class=\"btn-secondary mt-2.5\" @click=\"load\">\n Discard mine and reload\n </button>\n </div>\n\n <div\n v-if=\"issues.length\"\n role=\"alert\"\n class=\"mb-5 rounded-md border border-danger/15 bg-danger-soft p-4\"\n >\n <p class=\"text-sm font-medium text-danger\">\n {{ issues.length }} field{{ issues.length === 1 ? \"\" : \"s\" }} need attention\n </p>\n <ul class=\"mt-1.5 space-y-0.5 text-xs text-danger\">\n <li v-for=\"issue in issues\" :key=\"issue.path\">{{ issue.message }}</li>\n </ul>\n </div>\n\n <form novalidate @submit.prevent=\"save\">\n <FieldList\n v-model=\"values\"\n :fields=\"definition.fields\"\n :issues=\"issues\"\n :disabled=\"saving || !!definition.readOnly\"\n />\n <button v-if=\"!definition.readOnly\" type=\"submit\" class=\"sr-only\">Save</button>\n </form>\n </template>\n </div>\n </template>\n\n <div v-else class=\"p-8 text-center text-sm text-muted\">\n There are no settings called \"{{ name }}\".\n </div>\n</template>\n"],"names":["props","__props","schema","useSchema","staging","useStaging","toast","useToast","definition","computed","values","ref","issues","revision","loading","saving","conflict","websiteConflict","_b","_a","item","location","dirty","markClean","useUnsavedChanges","load","detail","api","fillDefaults","error","ApiError","onMounted","watch","save","saved","_createElementBlock","_Fragment","_createVNode","PageHeader","_createElementVNode","_unref","_createTextVNode","_toDisplayString","_hoisted_1","_hoisted_2","_hoisted_3","_openBlock","_hoisted_4","_createBlock","ReadOnlyNotice","_hoisted_5","_cache","_component_RouterLink","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","_renderList","issue","FieldList","$event","_hoisted_10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,KAFLiB,GAEK,QADHrB,EAAsEC,EAAA,KAAAqB,EAAlD7C,EAAA,MAAT8C,QAAXvB,EAAsE,KAAA,CAAzC,IAAKuB,EAAM,IAAA,EAAShB,EAAAgB,EAAM,OAAO,EAAA,CAAA,wBAIlEnB,EAQO,OAAA,CARD,WAAA,GAAY,WAAgBN,EAAI,CAAA,SAAA,CAAA,CAAA,GACpCI,EAKEsB,EAAA,YAJSjD,EAAA,2CAAAA,EAAM,MAAAkD,GACd,OAAQpD,EAAA,MAAW,OACnB,OAAQI,EAAA,MACR,SAAUG,EAAA,OAAM,CAAA,CAAMP,EAAA,MAAW,QAAA,sDAErBA,EAAA,MAAW,uBAA1B2B,EAA+E,SAA/E0B,GAAkE,MAAI,uBAM9Ef,EAAA,EAAAX,EAEM,MAFN2B,GAAuD,kCACvBpB,EAAGzC,EAAA,IAAI,EAAG,MAC1C,CAAA"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{d as M,o as U,c as a,j as h,w as b,a as e,F as u,t as o,l as p,k as v,b as d,e as c,r as $,i as E,A as I,n as N,h as i,G as V,g as R,p as D,Y as F}from"./index-
|
|
1
|
+
import{d as M,o as U,c as a,j as h,w as b,a as e,F as u,t as o,l as p,k as v,b as d,e as c,r as $,i as E,A as I,n as N,h as i,G as V,g as R,p as D,Y as F}from"./index-BHBq4-Io.js";import{_ as O}from"./PageHeader.vue_vue_type_script_setup_true_lang-Cr0v1G7O.js";import{a as C,b as j,f}from"./format-Cpnr2As6.js";import{A as q}from"./arrow-right-D8-sqdXS.js";const H=["disabled"],z=["disabled"],W={class:"mx-auto max-w-5xl space-y-6 px-4 py-5 pb-12 sm:px-6"},Y={key:0,class:"text-sm text-muted"},G={"aria-labelledby":"glance-heading"},K={class:"grid grid-cols-2 gap-3 lg:grid-cols-4"},P={class:"card p-4"},Z={class:"mt-1 text-2xl font-semibold tabular-nums"},J={class:"mt-1 text-xs text-muted"},Q={class:"card p-4"},X={class:"mt-1 text-2xl font-semibold tabular-nums"},ee={class:"mt-1 text-xs text-muted"},te=["datetime"],se={class:"card p-4"},oe={class:"mt-1 text-2xl font-semibold tabular-nums"},ne={class:"mt-1 text-xs text-muted"},le={class:"card p-4"},ae={class:"mt-1 text-2xl font-semibold tabular-nums"},ie={class:"mt-1 text-xs text-muted"},de={class:"card p-4","aria-labelledby":"model-heading"},re={class:"spec mt-3"},ue={class:"tabular-nums"},ce={class:"mt-2 space-y-1.5"},me={class:"w-28 shrink-0 truncate"},pe={class:"h-1.5 min-w-0 flex-1 rounded-full bg-canvas","aria-hidden":"true"},ye={class:"w-8 shrink-0 text-right text-xs tabular-nums text-muted"},he={class:"card overflow-hidden","aria-labelledby":"collections-heading"},ve={class:"overflow-x-auto"},xe={class:"w-full text-sm"},be={class:"divide-y divide-line"},fe={class:"px-4 py-2.5"},ge={class:"mono block text-muted"},_e={class:"px-4 py-2.5 text-right tabular-nums"},we={class:"px-4 py-2.5 text-right tabular-nums"},ke={key:0,class:"block text-xs text-muted"},$e={class:"mono hidden px-4 py-2.5 text-muted sm:table-cell"},Re={class:"hidden px-4 py-2.5 text-xs text-muted sm:table-cell"},Ce={key:0,class:"card p-4","aria-labelledby":"singletons-heading"},Se={class:"spec mt-3"},Ae={class:"tabular-nums"},Le={key:1,class:"card p-4","aria-labelledby":"relations-heading"},Te={class:"mt-3 space-y-1.5 text-sm"},Be={class:"font-medium"},Me={class:"mono text-muted"},Ue={key:0,class:"badge bg-accent-soft text-accent"},Ee={class:"card p-4","aria-labelledby":"repository-heading"},Ie={key:0,class:"mt-3 rounded-md border border-warning/15 bg-warning-soft px-4 py-3 text-xs text-warning"},Ne={key:1,class:"mt-3 rounded-md border border-danger/15 bg-danger-soft px-4 py-3 text-xs text-danger"},Ve={class:"spec mt-3"},De={key:0},Fe={class:"mono"},Oe={key:1},je={class:"mono"},qe={class:"mono"},He={key:2},ze={key:0,class:"text-danger"},We={key:3},Ye={class:"tabular-nums"},Ge={class:"tabular-nums"},Ke={class:"tabular-nums"},Pe={class:"card p-4","aria-labelledby":"deployment-heading"},Ze={key:0,class:"mt-3 rounded-md border border-warning/15 bg-warning-soft px-4 py-3 text-xs text-warning"},Je={class:"spec mt-3"},Qe={class:"mono"},Xe={class:"mono"},et={class:"mono"},tt={key:0},st={class:"mono"},ot={class:"tabular-nums"},nt={class:"tabular-nums"},lt={class:"mono"},at={key:1},it={class:"mono"},dt={key:2},rt={class:"tabular-nums"},ut={key:3},ct={class:"mono"},mt=M({__name:"SystemView",setup(pt){const x=N(),s=$(null),y=$(!0);async function g(){y.value=!0;try{s.value=await E.system()}catch(n){x.error(n instanceof I?n.message:"Could not load the system information.")}finally{y.value=!1}}U(g);const _={url:"URL"};function S(n){if(_[n])return _[n];const t=n.replace(/([A-Z])/g," $1").toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)}const A=R(()=>{var n;return Math.max(1,...(((n=s.value)==null?void 0:n.schema.kinds)??[]).map(t=>t.count))}),w=R(()=>{var t,m;const n=new Map;for(const r of((t=s.value)==null?void 0:t.schema.collections)??[])n.set(`collection:${r.name}`,r.label);for(const r of((m=s.value)==null?void 0:m.schema.singletons)??[])n.set(`singleton:${r.name}`,r.label);return n});function L(n){return w.value.get(`collection:${n}`)??n}function T(){const n=s.value;return n?[`Mica ${n.cms.version} (${n.cms.environment})`,`Node ${n.cms.node} on ${n.cms.platform}, up ${C(n.cms.uptimeSeconds)}`,`Schema — ${n.schema.totals.collections} collections, ${n.schema.totals.singletons} singletons, ${n.schema.totals.total} fields`,`Repository ${n.repository.url??n.repository.origin}`+(n.repository.branch?` (branch ${n.repository.branch})`:""),`Working tree ${n.repository.owner==="managed"?"Mica's own clone":"the developer's checkout"}`+(n.repository.head?`, at ${n.repository.head.slice(0,7)}`:""),`Repository holds ${n.repository.entries} entries and ${n.repository.media.files} media files (${n.repository.media.readable})`,...n.repository.cloneBytes!==null?[`Clone ${f(n.repository.cloneBytes)} on the data volume`]:[],...n.repository.sync?[`Last sync ${n.repository.sync.lastSyncAt??"never"}`+(n.repository.sync.error?`, failing since ${n.repository.sync.error.since}: ${n.repository.sync.error.message}`:""),...n.repository.sync.restartRequired?["Restart needed: the content model changed"]:[],...n.repository.sync.refused?[`Last publication refused: ${n.repository.sync.refused.reason}`]:[]]:[],`Site ${n.deployment.site}`,`Base URL ${n.deployment.baseUrl}`,`Content model ${n.deployment.schemaOrigin}`,`Content root ${n.deployment.contentRoot}`,`Authentication ${n.deployment.auth}`,`Admission ${n.deployment.admission??"none"}`].join(`
|
|
2
2
|
`):""}async function B(){try{await navigator.clipboard.writeText(T()),x.success("Report copied to the clipboard.")}catch{x.error("Could not copy. Select the values you need instead.")}}return(n,t)=>{var r,k;const m=D("RouterLink");return i(),a(u,null,[h(O,{title:"System",subtitle:s.value?`Mica ${s.value.cms.version} · ${s.value.cms.environment}`:null},{default:b(()=>[e("button",{type:"button",class:"btn-ghost",disabled:y.value,onClick:g},"Refresh",8,H),e("button",{type:"button",class:"btn-secondary",disabled:!s.value,onClick:B}," Copy report ",8,z)]),_:1},8,["subtitle"]),e("div",W,[y.value?(i(),a("p",Y,"Loading…")):s.value?(i(),a(u,{key:1},[e("section",G,[t[4]||(t[4]=e("h2",{id:"glance-heading",class:"sr-only"},"At a glance",-1)),e("dl",K,[e("div",P,[t[0]||(t[0]=e("dt",{class:"text-sm text-muted"},"Version",-1)),e("dd",Z,o(s.value.cms.version),1),e("dd",J,o(s.value.cms.environment),1)]),e("div",Q,[t[1]||(t[1]=e("dt",{class:"text-sm text-muted"},"Uptime",-1)),e("dd",X,o(p(C)(s.value.cms.uptimeSeconds)),1),e("dd",ee,[e("time",{datetime:s.value.cms.startedAt},o(p(j)(s.value.cms.startedAt)),9,te)])]),e("div",se,[t[2]||(t[2]=e("dt",{class:"text-sm text-muted"},"Content model",-1)),e("dd",oe,o(s.value.schema.totals.total),1),e("dd",ne," fields in "+o(s.value.schema.totals.collections)+" collections, "+o(s.value.schema.totals.singletons)+" singletons ",1)]),e("div",le,[t[3]||(t[3]=e("dt",{class:"text-sm text-muted"},"In the repository",-1)),e("dd",ae,o(s.value.repository.entries),1),e("dd",ie," entries · "+o(s.value.repository.media.files)+" media files ",1)])])]),e("section",de,[t[6]||(t[6]=e("h2",{id:"model-heading",class:"text-sm font-semibold"},"Content model",-1)),t[7]||(t[7]=e("p",{class:"mt-1 text-xs text-muted"}," The schema this server was handed at startup. The same file describes the model to the Astro build, so the editor and the website cannot disagree about it. ",-1)),e("dl",re,[e("div",null,[t[5]||(t[5]=e("dt",null,"Required fields",-1)),e("dd",ue,o(s.value.schema.totals.required)+" of "+o(s.value.schema.totals.total),1)])]),t[8]||(t[8]=e("h3",{class:"mt-5 text-xs font-semibold uppercase tracking-wider text-muted"},"Field types",-1)),e("ul",ce,[(i(!0),a(u,null,v(s.value.schema.kinds,l=>(i(),a("li",{key:l.kind,class:"flex items-center gap-3 text-sm"},[e("span",me,o(S(l.kind)),1),e("span",pe,[e("span",{class:"block h-full rounded-full bg-accent/60",style:V({width:`${l.count/A.value*100}%`})},null,4)]),e("span",ye,o(l.count),1)]))),128))])]),e("section",he,[t[11]||(t[11]=e("h2",{id:"collections-heading",class:"border-b border-line px-4 py-3 text-sm font-semibold"}," Collections ",-1)),e("div",ve,[e("table",xe,[t[9]||(t[9]=e("caption",{class:"sr-only"},"Collections in the content model, with their entry counts",-1)),t[10]||(t[10]=e("thead",null,[e("tr",{class:"border-b border-line text-left text-xs text-muted"},[e("th",{scope:"col",class:"px-4 py-2 font-medium"},"Collection"),e("th",{scope:"col",class:"px-4 py-2 text-right font-medium"},"Entries"),e("th",{scope:"col",class:"px-4 py-2 text-right font-medium"},"Fields"),e("th",{scope:"col",class:"hidden px-4 py-2 font-medium sm:table-cell"},"Title / slug"),e("th",{scope:"col",class:"hidden px-4 py-2 font-medium sm:table-cell"},"Ordering")])],-1)),e("tbody",be,[(i(!0),a(u,null,v(s.value.schema.collections,l=>(i(),a("tr",{key:l.name},[e("td",fe,[h(m,{to:{name:"collection",params:{collection:l.name}},class:"font-medium hover:text-accent"},{default:b(()=>[c(o(l.label),1)]),_:2},1032,["to"]),e("span",ge,o(l.name),1)]),e("td",_e,o(l.entries),1),e("td",we,[c(o(l.fields.top)+" ",1),l.fields.total>l.fields.top?(i(),a("span",ke,o(l.fields.total)+" with nested ",1)):d("",!0)]),e("td",$e,o(l.titleField??"—")+" / "+o(l.slugField??"—"),1),e("td",Re,o(l.sortable?"Manual":"Automatic"),1)]))),128))])])])]),s.value.schema.singletons.length?(i(),a("section",Ce,[t[12]||(t[12]=e("h2",{id:"singletons-heading",class:"text-sm font-semibold"},"Singletons",-1)),e("dl",Se,[(i(!0),a(u,null,v(s.value.schema.singletons,l=>(i(),a("div",{key:l.name},[e("dt",null,[h(m,{to:{name:"singleton",params:{name:l.name}},class:"hover:text-accent"},{default:b(()=>[c(o(l.label),1)]),_:2},1032,["to"])]),e("dd",Ae,o(l.fields.top)+" field"+o(l.fields.top===1?"":"s"),1)]))),128))])])):d("",!0),s.value.schema.relations.length?(i(),a("section",Le,[t[13]||(t[13]=e("h2",{id:"relations-heading",class:"text-sm font-semibold"},"Relations",-1)),t[14]||(t[14]=e("p",{class:"mt-1 text-xs text-muted"}," Deleting an entry that is referenced here is warned about before it happens. ",-1)),e("ul",Te,[(i(!0),a(u,null,v(s.value.schema.relations,l=>(i(),a("li",{key:`${l.fromType}:${l.from}.${l.path}`,class:"flex flex-wrap items-baseline gap-x-2"},[e("span",Be,o(w.value.get(`${l.fromType}:${l.from}`)??l.from),1),e("span",Me,o(l.path),1),h(p(q),{size:14,class:"text-muted","aria-hidden":"true"}),e("span",null,o(L(l.to)),1),l.multiple?(i(),a("span",Ue,"many")):d("",!0)]))),128))])])):d("",!0),e("section",Ee,[t[22]||(t[22]=e("h2",{id:"repository-heading",class:"text-sm font-semibold"},"Content repository",-1)),t[23]||(t[23]=e("p",{class:"mt-1 text-xs text-muted"}," The source of truth for the website. Everything here is a file under version control, so the site can be rebuilt from it without this server. ",-1)),(r=s.value.repository.sync)!=null&&r.restartRequired?(i(),a("p",Ie," Restart needed: the content model changed in the repository. Editing goes on; publishing waits for the restart. ")):d("",!0),(k=s.value.repository.sync)!=null&&k.refused?(i(),a("p",Ne," The repository refused the last publication: "+o(s.value.repository.sync.refused.reason),1)):d("",!0),e("dl",Ve,[s.value.repository.url?(i(),a("div",De,[t[15]||(t[15]=e("dt",null,"Remote",-1)),e("dd",Fe,o(s.value.repository.url),1)])):d("",!0),s.value.repository.branch?(i(),a("div",Oe,[t[16]||(t[16]=e("dt",null,"Branch",-1)),e("dd",je,[c(o(s.value.repository.branch),1),s.value.repository.head?(i(),a(u,{key:0},[c(" at "+o(s.value.repository.head.slice(0,7)),1)],64)):d("",!0)])])):d("",!0),e("div",null,[t[17]||(t[17]=e("dt",null,"Working tree",-1)),e("dd",qe,o(s.value.repository.origin),1)]),s.value.repository.sync?(i(),a("div",He,[t[18]||(t[18]=e("dt",null,"Last sync",-1)),e("dd",null,[c(o(s.value.repository.sync.lastSyncAt?new Date(s.value.repository.sync.lastSyncAt).toLocaleString():"not yet")+" ",1),s.value.repository.sync.error?(i(),a("span",ze," — failing since "+o(new Date(s.value.repository.sync.error.since).toLocaleString())+": "+o(s.value.repository.sync.error.message),1)):d("",!0)])])):d("",!0),s.value.repository.cloneBytes!==null?(i(),a("div",We,[t[19]||(t[19]=e("dt",null,"Clone size",-1)),e("dd",Ye,o(p(f)(s.value.repository.cloneBytes)),1)])):d("",!0),e("div",null,[t[20]||(t[20]=e("dt",null,"Entries",-1)),e("dd",Ge,o(s.value.repository.entries),1)]),e("div",null,[t[21]||(t[21]=e("dt",null,"Media",-1)),e("dd",Ke,o(s.value.repository.media.files)+" files · "+o(s.value.repository.media.readable),1)])])]),e("section",Pe,[t[37]||(t[37]=e("h2",{id:"deployment-heading",class:"text-sm font-semibold"},"Deployment",-1)),t[38]||(t[38]=e("p",{class:"mt-1 text-xs text-muted"}," How this Mica is configured. Secrets are never shown — only whether they are set. ",-1)),s.value.deployment.generatedSecrets.length?(i(),a("p",Ze," Running with generated development secrets ("+o(s.value.deployment.generatedSecrets.join(", "))+"). Everyone is signed out on restart — set these before this deployment is used for real. ",1)):d("",!0),e("dl",Je,[e("div",null,[t[24]||(t[24]=e("dt",null,"Site",-1)),e("dd",Qe,o(s.value.deployment.site),1)]),e("div",null,[t[25]||(t[25]=e("dt",null,"Base URL",-1)),e("dd",Xe,o(s.value.deployment.baseUrl),1)]),e("div",null,[t[26]||(t[26]=e("dt",null,"Content model",-1)),e("dd",et,o(s.value.deployment.schemaOrigin),1)]),s.value.deployment.contentRoot?(i(),a("div",tt,[t[27]||(t[27]=e("dt",null,"Content root",-1)),e("dd",st,o(s.value.deployment.contentRoot),1)])):d("",!0),e("div",null,[t[28]||(t[28]=e("dt",null,"Runtime",-1)),e("dd",null,o(s.value.cms.node)+" on "+o(s.value.cms.platform),1)]),e("div",null,[t[29]||(t[29]=e("dt",null,"Memory in use",-1)),e("dd",ot,o(p(f)(s.value.deployment.memoryBytes)),1)]),e("div",null,[t[30]||(t[30]=e("dt",null,"Upload limit",-1)),e("dd",nt,o(s.value.deployment.maxUploadReadable),1)]),e("div",null,[t[31]||(t[31]=e("dt",null,"Authentication",-1)),e("dd",lt,o(s.value.deployment.auth),1)]),s.value.deployment.admission?(i(),a("div",at,[t[32]||(t[32]=e("dt",null,"Who may edit",-1)),e("dd",it,o(s.value.deployment.admission),1)])):d("",!0),s.value.deployment.sessionTtlHours!==null?(i(),a("div",dt,[t[33]||(t[33]=e("dt",null,"Session lifetime",-1)),e("dd",rt,o(s.value.deployment.sessionTtlHours)+" h, idle out after "+o(s.value.deployment.sessionIdleHours)+" h ",1)])):d("",!0),e("div",null,[t[34]||(t[34]=e("dt",null,"Trust proxy headers",-1)),e("dd",null,o(s.value.deployment.trustProxy?"Yes":"No"),1)]),s.value.deployment.adminOrigins.length?(i(),a("div",ut,[t[35]||(t[35]=e("dt",null,"Extra admin origins",-1)),e("dd",ct,o(s.value.deployment.adminOrigins.join(", ")),1)])):d("",!0),e("div",null,[t[36]||(t[36]=e("dt",null,"Log level",-1)),e("dd",null,o(s.value.deployment.logLevel),1)])])])],64)):d("",!0)])],64)}}}),bt=F(mt,[["__scopeId","data-v-a209d5e3"]]);export{bt as default};
|
|
3
|
-
//# sourceMappingURL=SystemView-
|
|
3
|
+
//# sourceMappingURL=SystemView-Bc2he_Af.js.map
|