@phtngyn/cms 0.2.0-beta.4 → 0.2.0-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/README.md +31 -13
  2. package/package.json +7 -7
  3. package/src/ApplicationTypes.d.ts +3 -3
  4. package/src/Authoring.d.ts +11 -3
  5. package/src/{Configuration-BU-UyGoH.js → Configuration-JQ1qyaU0.js} +347 -189
  6. package/src/Configuration-JQ1qyaU0.js.map +1 -0
  7. package/src/Configuration.d.ts +1 -1
  8. package/src/Content.d.ts +7 -6
  9. package/src/Content.js +106 -47
  10. package/src/Content.js.map +1 -1
  11. package/src/ContentTransfer-BxwswWn3.js +86 -0
  12. package/src/ContentTransfer-BxwswWn3.js.map +1 -0
  13. package/src/{ContentTransfer-CRQet3QJ.d.ts → ContentTransfer-Z9FHyLez.d.ts} +33 -9
  14. package/src/{DocumentEngine-ClhFXW9M.js → DocumentEngine-j6Vi7nQo.js} +279 -178
  15. package/src/DocumentEngine-j6Vi7nQo.js.map +1 -0
  16. package/src/DocumentModel.d.ts +9 -2
  17. package/src/DocumentModel.js +17 -4
  18. package/src/DocumentModel.js.map +1 -1
  19. package/src/{Forms-DoB56hfe.js → Forms-CX-hwmJF.js} +18 -11
  20. package/src/Forms-CX-hwmJF.js.map +1 -0
  21. package/src/{Forms-BbkE7QfC.js → Forms-CfNPTiCr.js} +2 -2
  22. package/src/{Forms-BbkE7QfC.js.map → Forms-CfNPTiCr.js.map} +1 -1
  23. package/src/Media-j1bTritO.js +112 -0
  24. package/src/Media-j1bTritO.js.map +1 -0
  25. package/src/Module.js +0 -4
  26. package/src/Module.js.map +1 -1
  27. package/src/References-CCPDAPve.js +45 -0
  28. package/src/References-CCPDAPve.js.map +1 -0
  29. package/src/{S3MediaObjects-CR3p1WTg.js → S3MediaObjects-BRuPQbxl.js} +454 -516
  30. package/src/S3MediaObjects-BRuPQbxl.js.map +1 -0
  31. package/src/cli/content.js +6 -5
  32. package/src/cli/content.js.map +1 -1
  33. package/src/cli.js +16 -3
  34. package/src/cli.js.map +1 -1
  35. package/src/{connection-D5S9Iph-.js → connection-BP80q4d-.js} +2 -2
  36. package/src/{connection-D5S9Iph-.js.map → connection-BP80q4d-.js.map} +1 -1
  37. package/src/{dev-lifecycle-D3f9-upa.js → dev-lifecycle-CExksm2R.js} +27 -7
  38. package/src/dev-lifecycle-CExksm2R.js.map +1 -0
  39. package/src/{installation-fZtNxtoW.js → installation-BoG8E3nJ.js} +7982 -7155
  40. package/src/installation-BoG8E3nJ.js.map +1 -0
  41. package/src/internal/authoring-catalog.js +2 -2
  42. package/src/internal/authoring-compiler.js +35 -9
  43. package/src/internal/authoring-compiler.js.map +1 -1
  44. package/src/internal/authoring-metadata.js +14 -5
  45. package/src/internal/authoring-metadata.js.map +1 -1
  46. package/src/internal/configuration.js +27 -3
  47. package/src/internal/configuration.js.map +1 -1
  48. package/src/internal/dev-lifecycle.js +2 -2
  49. package/src/internal/document-model.js +134 -43
  50. package/src/internal/document-model.js.map +1 -1
  51. package/src/internal/field-metadata.js +2 -1
  52. package/src/internal/field-metadata.js.map +1 -1
  53. package/src/internal/form-capabilities.js +1 -1
  54. package/src/{location-CPX7oj0o.js → location-CMNGO3lU.js} +2 -2
  55. package/src/{location-CPX7oj0o.js.map → location-CMNGO3lU.js.map} +1 -1
  56. package/src/{metadata-BEZPWh-3.js → metadata-UzZmjwxM.js} +2 -2
  57. package/src/{metadata-BEZPWh-3.js.map → metadata-UzZmjwxM.js.map} +1 -1
  58. package/src/{models-C9kF9JlQ.js → models-5j67LMqW.js} +4 -4
  59. package/src/{models-C9kF9JlQ.js.map → models-5j67LMqW.js.map} +1 -1
  60. package/src/{models-ChRxBChy.js → models-VmGmG19-.js} +42 -130
  61. package/src/models-VmGmG19-.js.map +1 -0
  62. package/src/runtime/delivery/DocumentRenderer.js +5 -1
  63. package/src/runtime/delivery/DocumentRenderer.js.map +1 -1
  64. package/src/runtime/delivery/context.js +1 -1
  65. package/src/runtime/delivery/plugin.js +2 -2
  66. package/src/runtime/delivery/preview.d.ts +1 -1
  67. package/src/runtime/delivery/types.d.ts +1 -1
  68. package/src/runtime/delivery/useCmsDocumentSeo.d.ts +1 -1
  69. package/src/runtime/forms/document.js +2 -2
  70. package/src/runtime/forms/useCmsForm.js +2 -2
  71. package/src/runtime/installation.js +1 -1
  72. package/src/runtime/plugin.js +1 -1
  73. package/src/runtime/preview/CmsStudioPreviewMarker.js +18 -4
  74. package/src/runtime/preview/CmsStudioPreviewMarker.js.map +1 -1
  75. package/src/runtime/preview/connection.js +1 -1
  76. package/src/runtime/preview/controller.js +65 -74
  77. package/src/runtime/preview/controller.js.map +1 -1
  78. package/src/runtime/preview/overlay.js +85 -28
  79. package/src/runtime/preview/overlay.js.map +1 -1
  80. package/src/runtime/preview/plugin.client.js +4 -4
  81. package/src/runtime/preview/preview.css +50 -36
  82. package/src/runtime/preview/protocol.d.ts +11 -5
  83. package/src/runtime/preview/protocol.js +17 -5
  84. package/src/runtime/preview/protocol.js.map +1 -1
  85. package/src/runtime/preview/regions.js +142 -0
  86. package/src/runtime/preview/regions.js.map +1 -0
  87. package/src/runtime/preview/store.js +1 -1
  88. package/src/runtime/sitemap.js +9 -10
  89. package/src/runtime/sitemap.js.map +1 -1
  90. package/src/{scalars-B2lgGUnj.js → scalars-CVZqT3L0.js} +2 -6
  91. package/src/scalars-CVZqT3L0.js.map +1 -0
  92. package/src/{store-CCsjHaZm.js → store-PKKB8xa2.js} +49 -66
  93. package/src/store-PKKB8xa2.js.map +1 -0
  94. package/src/{types-DutFRtaG.d.ts → types-DZ0IV-Ow.d.ts} +14 -3
  95. package/studio/CreateDocumentDialog-DqvusuGU.js +335 -0
  96. package/studio/{documentPlanning-CDb31mnl.js → SelectMenu-BgikeouH.js} +16292 -12303
  97. package/studio/{editor-Bzlh3zXt.js → editor-P2rB7Csp.js} +11228 -11927
  98. package/studio/host.css +1 -1
  99. package/studio/host.js +28987 -34295
  100. package/studio/rolldown-runtime-Dy4uBu1J.js +11 -0
  101. package/src/Configuration-BU-UyGoH.js.map +0 -1
  102. package/src/ContentTransfer-BhF9G56s.js +0 -57
  103. package/src/ContentTransfer-BhF9G56s.js.map +0 -1
  104. package/src/DocumentEngine-ClhFXW9M.js.map +0 -1
  105. package/src/Forms-DoB56hfe.js.map +0 -1
  106. package/src/S3MediaObjects-CR3p1WTg.js.map +0 -1
  107. package/src/dev-lifecycle-D3f9-upa.js.map +0 -1
  108. package/src/installation-fZtNxtoW.js.map +0 -1
  109. package/src/models-ChRxBChy.js.map +0 -1
  110. package/src/runtime/preview/targets.js +0 -101
  111. package/src/runtime/preview/targets.js.map +0 -1
  112. package/src/scalars-B2lgGUnj.js.map +0 -1
  113. package/src/store-CCsjHaZm.js.map +0 -1
  114. package/studio/CreateDocumentDialog-DJ8c0WZb.js +0 -256
  115. package/studio/dom-to-image-more.min-D6jGGdrW.js +0 -877
  116. package/studio/rolldown-runtime-B0aSnxlc.js +0 -20
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store-PKKB8xa2.js","names":["CmsMarkdownDocumentSchema"],"sources":["../../../../document/src/PreviewProjection.ts","../../../src/runtime/preview/store.ts"],"sourcesContent":["import type { CmsMarkdownDocument, MarkdownNode } from '@internal/protocol/Documents'\nimport type { EditorNodeId } from '@internal/protocol/Documents'\nimport { CmsMarkdownDocument as CmsMarkdownDocumentSchema } from '@internal/protocol/Documents'\nimport { Predicate, Result, Schema } from 'effect'\nimport { mutableJson, mutableJsonObject } from './internal/comark/document-adapter'\nimport { editorMetadata } from './internal/editor/metadata'\n\nexport interface PreviewProjectionMarkers {\n readonly edgeProperty: string\n readonly kindProperty: string\n readonly nodeProperty: string\n readonly tag: string\n}\n\nexport interface PreviewProjection {\n readonly body: CmsMarkdownDocument\n readonly fallbacks: Readonly<Record<string, string>>\n}\n\nexport class PreviewProjectionInvalid extends Schema.TaggedError<PreviewProjectionInvalid>()(\n 'PreviewProjection.Invalid',\n {\n message: Schema.NonEmptyString,\n cause: Schema.Defect(),\n },\n) {}\n\nconst NATIVE_BLOCK_TAGS = new Set([\n 'blockquote',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n 'hr',\n 'img',\n 'li',\n 'math',\n 'ol',\n 'p',\n 'pre',\n 'table',\n 'tbody',\n 'td',\n 'th',\n 'thead',\n 'tr',\n 'ul',\n])\n\nexport function projectPreviewDocument(\n body: CmsMarkdownDocument,\n markers: PreviewProjectionMarkers,\n): Result.Result<PreviewProjection, PreviewProjectionInvalid> {\n return Result.try({\n try: () => projectPreviewDocumentUnsafe(body, markers),\n catch: (cause) =>\n new PreviewProjectionInvalid({\n cause,\n message: cause instanceof Error && cause.message ? cause.message : 'The preview projection is invalid.',\n }),\n })\n}\n\nfunction projectPreviewDocumentUnsafe(body: CmsMarkdownDocument, markers: PreviewProjectionMarkers): PreviewProjection {\n const fallbacks: Record<string, string> = {}\n let identifiedTargets = 0\n\n function cloneNode(\n node: MarkdownNode,\n componentId?: EditorNodeId,\n slotId?: EditorNodeId,\n ): ReadonlyArray<Schema.Json> {\n if (Predicate.isString(node) || node[0] === null) return [mutableJson(node)]\n const [tag, originalAttributes, ...originalChildren] = node\n const isSlot = tag === 'template'\n const isNative = NATIVE_BLOCK_TAGS.has(tag)\n const attributes = mutableJsonObject(originalAttributes)\n const metadata = editorMetadata(attributes)\n const id = metadata?.nodeId\n\n if (id) {\n identifiedTargets++\n const parentId = slotId ?? componentId\n\n if (parentId) fallbacks[id] = parentId\n }\n\n const nextComponentId = !isNative && !isSlot && id ? id : componentId\n\n const implicitSlotId =\n id && metadata?.implicitSlotId && !isNative && !isSlot && hasImplicitDefaultContent(originalChildren)\n ? metadata.implicitSlotId\n : undefined\n\n const children = originalChildren.flatMap((child) => {\n const childSlotId = explicitSlotId(child) ?? (isSlot ? id : implicitSlotId) ?? slotId\n const projected = cloneNode(child, nextComponentId, childSlotId)\n\n return implicitSlotId && !isSlot && !isSlotNode(child)\n ? previewRange(implicitSlotId, 'field', projected, markers)\n : projected\n })\n\n if (id && implicitSlotId) fallbacks[implicitSlotId] = id\n\n if (isSlot && id && componentId) fallbacks[id] = componentId\n\n const cloned: Schema.Json = [tag, attributes, ...children]\n\n if (isSlot && id && componentId) return [[tag, attributes, ...previewRange(id, 'field', children, markers)]]\n\n if (id && isNative) return previewRange(id, 'native', [cloned], markers)\n\n if (id && !isSlot) return previewRange(id, 'component', [cloned], markers)\n\n return [cloned]\n }\n\n const nodes = body.nodes.flatMap((node) => cloneNode(node))\n\n if (body.nodes.length && !identifiedTargets)\n throw new Error('Studio preview requires an identified authoring document.')\n\n return {\n body: CmsMarkdownDocumentSchema.make({\n frontmatter: mutableJsonObject(body.frontmatter),\n meta: mutableJsonObject(body.meta),\n nodes,\n }),\n fallbacks,\n }\n}\n\nfunction previewRange(\n nodeId: EditorNodeId,\n kind: 'component' | 'field' | 'native',\n children: ReadonlyArray<Schema.Json>,\n markers: PreviewProjectionMarkers,\n): ReadonlyArray<Schema.Json> {\n const marker = (edge: 'end' | 'start'): Schema.Json => [\n markers.tag,\n {\n [markers.edgeProperty]: edge,\n [markers.kindProperty]: kind,\n [markers.nodeProperty]: nodeId,\n },\n ]\n\n return [marker('start'), ...children, marker('end')]\n}\n\nfunction explicitSlotId(node: MarkdownNode): EditorNodeId | undefined {\n if (Predicate.isString(node) || node[0] !== 'template') return undefined\n\n return editorMetadata(node[1])?.nodeId\n}\n\nfunction isSlotNode(node: MarkdownNode): boolean {\n return !Predicate.isString(node) && node[0] === 'template'\n}\n\nfunction hasImplicitDefaultContent(nodes: ReadonlyArray<MarkdownNode>): boolean {\n const hasExplicitDefault = nodes.some(\n (node) => Array.isArray(node) && node[0] === 'template' && node[1].name === 'default',\n )\n\n return (\n !hasExplicitDefault && nodes.some((node) => (Predicate.isString(node) ? Boolean(node) : node[0] !== 'template'))\n )\n}\n","import { prepareFormDocument } from '../forms/document'\nimport type { ComponentDefinition } from '@internal/protocol/Configuration'\nimport type { RenderedCompiledDocument, RenderedDocumentManifest } from '@internal/protocol/Preview'\nimport { projectPreviewDocument } from '@internal/document/PreviewProjection'\nimport { CollectionName } from '@internal/protocol/Configuration'\nimport { DocumentId, PublicPath } from '@internal/protocol/Documents'\nimport { Result } from 'effect'\nimport { createComarkContext } from 'comark'\nimport { shallowRef } from 'vue'\nimport type { DeliveryDocument as PreviewCompiledDocument } from '../delivery/types'\nimport type { DocumentPreviewStore, PreviewDocumentRole } from '../delivery/preview'\nimport { toPreviewRenderDocument } from './comark-document'\nimport {\n CMS_PREVIEW_EDGE_PROPERTY,\n CMS_PREVIEW_KIND_PROPERTY,\n CMS_PREVIEW_MARKER_TAG,\n CMS_PREVIEW_NODE_PROPERTY,\n} from './protocol'\n\nexport { documentPreviewStoreKey, type DocumentPreviewStore, type PreviewDocumentRole } from '../delivery/preview'\n\nexport type { DeliveryDocument as PreviewCompiledDocument } from '../delivery/types'\n\nexport interface StudioPreviewStore extends DocumentPreviewStore {\n readonly manifest: () => RenderedDocumentManifest\n readonly patch: (document: PreviewCompiledDocument) => Promise<Readonly<Record<string, string>>>\n readonly routeChanged: () => void\n readonly subscribe: (listener: (manifest: RenderedDocumentManifest) => void) => () => void\n}\n\nexport function createStudioPreviewStore(\n route: () => RenderedDocumentManifest['route'],\n forms: () => ReadonlyArray<ComponentDefinition> = () => [],\n): StudioPreviewStore {\n const context = createComarkContext()\n const patches = shallowRef(new Map<string, PreviewCompiledDocument>())\n\n const registrations = new Map<\n symbol,\n { readonly document: PreviewCompiledDocument; readonly role: PreviewDocumentRole }\n >()\n\n const listeners = new Set<(manifest: RenderedDocumentManifest) => void>()\n\n const manifest = (): RenderedDocumentManifest => ({\n documents: renderedDocuments(registrations.values(), patches.value),\n route: route(),\n })\n\n const notify = (): void => {\n const value = manifest()\n\n for (const listener of listeners) listener(value)\n }\n\n return {\n manifest,\n // oxlint-disable-next-line effecttsgo/async-function -- The Promise contract turns synchronous projection failures into patch rejections for the preview controller.\n async patch(document) {\n const preview = createPreviewDocument(document.body)\n const patched = prepareFormDocument({ ...document, body: preview.body }, forms(), true)\n patches.value = new Map(patches.value).set(document.id, patched)\n const renderBody = toPreviewRenderDocument(patched.body)\n context.get(document.id, renderBody).set(renderBody)\n notify()\n\n return preview.fallbacks\n },\n register(document, role) {\n const registration = Symbol(document.id)\n registrations.set(registration, { document, role })\n notify()\n\n return () => {\n registrations.delete(registration)\n notify()\n }\n },\n resolve(document) {\n return patches.value.get(document.id) ?? document\n },\n routeChanged: notify,\n subscribe(listener) {\n listeners.add(listener)\n listener(manifest())\n\n return () => listeners.delete(listener)\n },\n }\n}\n\nfunction renderedDocuments(\n registrations: Iterable<{ readonly document: PreviewCompiledDocument; readonly role: PreviewDocumentRole }>,\n patches: ReadonlyMap<string, PreviewCompiledDocument>,\n): ReadonlyArray<RenderedCompiledDocument> {\n const priority = { embedded: 1, primary: 4, related: 2, summary: 3 } satisfies Record<PreviewDocumentRole, number>\n const documents = new Map<string, RenderedCompiledDocument>()\n\n for (const registration of registrations) {\n const document = patches.get(registration.document.id) ?? registration.document\n const current = documents.get(document.id)\n\n if (current && priority[current.role] >= priority[registration.role]) continue\n documents.set(document.id, {\n collection: CollectionName.make(document.collection),\n documentId: DocumentId.make(document.id),\n path: PublicPath.make(document.path),\n role: registration.role,\n title: document.title,\n })\n }\n\n return [...documents.values()].sort(\n (left, right) => priority[right.role] - priority[left.role] || left.title.localeCompare(right.title),\n )\n}\n\nfunction createPreviewDocument(body: PreviewCompiledDocument['body']) {\n const projection = projectPreviewDocument(body, {\n edgeProperty: CMS_PREVIEW_EDGE_PROPERTY,\n kindProperty: CMS_PREVIEW_KIND_PROPERTY,\n nodeProperty: CMS_PREVIEW_NODE_PROPERTY,\n tag: CMS_PREVIEW_MARKER_TAG,\n })\n\n if (Result.isFailure(projection)) throw projection.failure\n\n return projection.success\n}\n"],"mappings":";;;;;;;;;;;;AAmBA,IAAa,2BAAb,cAA8C,OAAO,YAAsC,CAAC,CAC1F,6BACA;CACE,SA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A,cAAc;EACd,UAAU,UAAU;GAClB,UAAU,IAAI,QAAQ;GACtB,SAAS,SAAS,CAAC;GAEnB,aAAa,UAAU,OAAO,QAAQ;EACxC;CACF;AACF;AAEA,SAAS,kBACP,eACA,SACyC;CACzC,MAAM,WAAW;EAAE,UAAU;EAAG,SAAS;EAAG,SAAS;EAAG,SAAS;CAAE;CACnE,MAAM,4BAAY,IAAI,IAAsC;CAE5D,KAAK,MAAM,gBAAgB,eAAe;EACxC,MAAM,WAAW,QAAQ,IAAI,aAAa,SAAS,EAAE,KAAK,aAAa;EACvE,MAAM,UAAU,UAAU,IAAI,SAAS,EAAE;EAEzC,IAAI,WAAW,SAAS,QAAQ,SAAS,SAAS,aAAa,OAAO;EACtE,UAAU,IAAI,SAAS,IAAI;GACzB,YAAY,eAAe,KAAK,SAAS,UAAU;GACnD,YAAY,WAAW,KAAK,SAAS,EAAE;GACvC,MAAM,WAAW,KAAK,SAAS,IAAI;GACnC,MAAM,aAAa;GACnB,OAAO,SAAS;EAClB,CAAC;CACH;CAEA,OAAO,CAAC,GAAG,UAAU,OAAO,CAAC,CAAC,CAAC,MAC5B,MAAM,UAAU,SAAS,MAAM,QAAQ,SAAS,KAAK,SAAS,KAAK,MAAM,cAAc,MAAM,KAAK,CACrG;AACF;AAEA,SAAS,sBAAsB,MAAuC;CACpE,MAAM,aAAa,uBAAuB,MAAM;EAC9C,cAAc;EACd,cAAc;EACd,cAAc;EACd,KAAK;CACP,CAAC;CAED,IAAI,OAAO,UAAU,UAAU,GAAG,MAAM,WAAW;CAEnD,OAAO,WAAW;AACpB"}
@@ -33,6 +33,11 @@ interface DeliveryDocument {
33
33
  readonly draft: boolean;
34
34
  readonly engineFingerprint: string;
35
35
  readonly id: string;
36
+ readonly identity: {
37
+ readonly collection: string;
38
+ readonly documentId: string;
39
+ readonly locale?: string;
40
+ };
36
41
  readonly issues: ReadonlyArray<{
37
42
  readonly code: string;
38
43
  readonly collection?: string;
@@ -41,11 +46,18 @@ interface DeliveryDocument {
41
46
  readonly locale?: string;
42
47
  readonly message: string;
43
48
  readonly severity: 'error' | 'warning';
44
- readonly sourcePath?: string;
49
+ readonly documentId?: string;
45
50
  }>;
46
51
  readonly key: string;
47
52
  readonly locale?: string;
48
53
  readonly path: string;
54
+ readonly placement: {
55
+ readonly kind: 'home';
56
+ } | {
57
+ readonly kind: 'entry';
58
+ readonly parentDocumentId: string;
59
+ readonly slug: string;
60
+ };
49
61
  readonly resolvedSeo?: ResolvedSeo;
50
62
  readonly seo?: DocumentSeo;
51
63
  readonly source: {
@@ -64,7 +76,6 @@ interface DeliveryDocument {
64
76
  };
65
77
  };
66
78
  }>;
67
- readonly path: string;
68
79
  readonly publishedAt?: DateTime.Utc;
69
80
  };
70
81
  readonly title: string;
@@ -87,4 +98,4 @@ interface DeliveryDocumentQuery {
87
98
  }
88
99
  //#endregion
89
100
  export { DeliveryJson as a, DeliveryMarkdownNode as c, DeliveryDocumentQuerySort as i, DeliveryDocumentPage as n, DeliveryJsonObject as o, DeliveryDocumentQuery as r, DeliveryMarkdownDocument as s, DeliveryDocument as t };
90
- //# sourceMappingURL=types-DutFRtaG.d.ts.map
101
+ //# sourceMappingURL=types-DZ0IV-Ow.d.ts.map
@@ -0,0 +1,335 @@
1
+ import { $ as e, Bt as t, Dt as n, Et as r, It as i, Nt as a, Pt as o, Q as s, Y as c, at as l, cn as u, dn as d, en as f, et as p, ht as m, mt as h, nt as g, on as _, q as ee, st as v, tt as y, wt as b } from "./editor-P2rB7Csp.js";
2
+ import { Ai as x, F as te, Fa as S, I as ne, L as re, Mi as C, Mr as w, Nr as T, O as ie, P as E, Pr as D, j as ae, ji as O, jr as oe, lr as k, n as A, pa as j, r as se, t as ce, ur as M, xr as le, z as ue } from "./SelectMenu-BgikeouH.js";
3
+ //#region virtual:nuxt-ui-templates/ui/collapsible.ts
4
+ var N = { slots: {
5
+ root: "",
6
+ content: "data-[state=open]:animate-[collapsible-down_200ms_var(--ease-out)] data-[state=closed]:animate-[collapsible-up_200ms_var(--ease-out)] data-[state=closed]:overflow-hidden"
7
+ } }, de = {
8
+ __name: "Collapsible",
9
+ props: {
10
+ as: {
11
+ type: null,
12
+ required: !1
13
+ },
14
+ class: {
15
+ type: null,
16
+ required: !1
17
+ },
18
+ ui: {
19
+ type: Object,
20
+ required: !1
21
+ },
22
+ defaultOpen: {
23
+ type: Boolean,
24
+ required: !1
25
+ },
26
+ open: {
27
+ type: Boolean,
28
+ required: !1
29
+ },
30
+ disabled: {
31
+ type: Boolean,
32
+ required: !1
33
+ },
34
+ unmountOnHide: {
35
+ type: Boolean,
36
+ required: !1,
37
+ default: !0
38
+ }
39
+ },
40
+ emits: ["update:open"],
41
+ setup(e, { emit: r }) {
42
+ let i = e, a = r, c = o(), d = D("collapsible", i), f = j(), h = T(S(d, "as", "defaultOpen", "open", "disabled", "unmountOnHide"), a), g = s(() => w({
43
+ extend: N,
44
+ ...f.ui?.collapsible || {}
45
+ })());
46
+ return (e, r) => (b(), p(_(C), m(_(h), {
47
+ "data-slot": "root",
48
+ class: g.value.root({ class: [_(d).ui?.root, _(d).class] })
49
+ }), {
50
+ default: t(({ open: r }) => [c.default ? (b(), p(_(x), {
51
+ key: 0,
52
+ "as-child": ""
53
+ }, {
54
+ default: t(() => [n(e.$slots, "default", { open: r })]),
55
+ _: 2
56
+ }, 1024)) : y("", !0), l(_(O), {
57
+ "data-slot": "content",
58
+ class: u(g.value.content({ class: _(d).ui?.content }))
59
+ }, {
60
+ default: t(() => [n(e.$slots, "content")]),
61
+ _: 3
62
+ }, 8, ["class"])]),
63
+ _: 3
64
+ }, 16, ["class"]));
65
+ }
66
+ }, fe = { key: 2 }, pe = { class: "grid grid-flow-col auto-cols-fr overflow-x-auto rounded-md border border-default" }, me = ["aria-pressed", "onClick"], he = { class: "block truncate" }, P = { key: 3 }, F = {
67
+ key: 4,
68
+ class: "overflow-hidden rounded-md border border-default bg-elevated/20"
69
+ }, I = {
70
+ type: "button",
71
+ class: "group flex w-full min-w-0 items-center gap-3 px-3 py-2.5 text-left transition-[background-color,transform] duration-150 ease-out hover:bg-elevated/50 active:scale-[0.99] motion-reduce:transition-none"
72
+ }, L = { class: "min-w-0 flex-1" }, ge = { class: "block truncate text-xs text-muted" }, _e = { class: "shrink-0 text-xs font-medium text-muted group-hover:text-highlighted" }, ve = { class: "grid gap-4 border-t border-default px-3 py-3 sm:grid-cols-2" }, ye = {
73
+ key: 5,
74
+ class: "-mt-2 text-xs text-error"
75
+ }, be = {
76
+ key: 6,
77
+ class: "-mt-2 text-xs text-error"
78
+ }, xe = { class: "flex w-full justify-end gap-2" }, R = "__top_level__", z = /* @__PURE__ */ v({
79
+ __name: "CreateDocumentDialog",
80
+ props: /*@__PURE__*/ h({
81
+ catalog: {},
82
+ context: {}
83
+ }, {
84
+ open: { type: Boolean },
85
+ openModifiers: {}
86
+ }),
87
+ emits: /*@__PURE__*/ h(["close"], ["update:open"]),
88
+ setup(n, { emit: o }) {
89
+ let m = o, h = a(n, "open"), v = E(), x = v.bootstrap.documents, S = x.types.filter((e) => e.canCreate), C = (x.locales?.locales ?? []).map((e) => ({
90
+ label: $(e),
91
+ value: String(e)
92
+ })), w = f(""), T = f(!1), D = f(""), O = f(""), j = f(!1), N = f(""), z = f(R), B = f(x.locales?.defaultLocale ?? ""), V = f(!1), H = s(() => {
93
+ let e = S.map((e) => ({
94
+ collection: e.collection,
95
+ key: `entry:${e.collection}`,
96
+ kind: "entry",
97
+ label: e.label,
98
+ type: e,
99
+ urlHint: e.routes.entry.replace(/:[a-z][\w.]*\*?/giu, "…")
100
+ }));
101
+ return [...S.filter((e) => !n.catalog.entries.value.some((t) => t.document.collection === e.collection && t.document.locale === (B.value || void 0) && t.document.placement.kind === "home")).flatMap((e) => {
102
+ let t = A(x, {
103
+ collection: e.collection,
104
+ locale: B.value || void 0,
105
+ placement: { kind: "home" },
106
+ title: "Home"
107
+ });
108
+ return k(t) || n.catalog.entries.value.some((e) => e.document.path === t.success.path) ? [] : [{
109
+ collection: e.collection,
110
+ key: `home:${e.collection}`,
111
+ kind: "home",
112
+ label: "Home",
113
+ type: e,
114
+ urlHint: t.success.path
115
+ }];
116
+ }), ...e];
117
+ }), U = s(() => H.value.find((e) => e.key === N.value)), W = s(() => n.catalog.entries.value.find((e) => e.document.collection === U.value?.collection && e.document.locale === (B.value || void 0) && e.document.placement.kind === "home")), Se = s(() => H.value.length > 1 ? "Choose a page type and add a title." : "Add a title to get started."), Ce = s(() => U.value?.kind === "home" ? "Homepage" : z.value === R || z.value === W.value?.document.id ? "Top level" : n.catalog.byId(z.value)?.document.title ?? "Selected location"), we = s(() => {
118
+ let e = [Ce.value];
119
+ return C.length && e.unshift($(B.value)), e.join(" · ");
120
+ }), G = s(() => {
121
+ if (U.value?.kind === "home") return { kind: "home" };
122
+ let e = z.value === R ? W.value?.document.id : z.value;
123
+ return e ? {
124
+ kind: "entry",
125
+ parentDocumentId: e,
126
+ slug: O.value
127
+ } : void 0;
128
+ }), K = s(() => {
129
+ let e = U.value, t = G.value;
130
+ if (!e || !t || e.kind === "entry" && !O.value.trim()) return;
131
+ let r = {
132
+ collection: e.collection,
133
+ placement: t,
134
+ title: D.value || "Untitled"
135
+ }, i = r.placement.kind === "entry" ? n.catalog.byId(r.placement.parentDocumentId)?.document.path : void 0;
136
+ return A(x, B.value ? {
137
+ ...r,
138
+ locale: B.value
139
+ } : r, i);
140
+ }), q = s(() => {
141
+ let e = K.value;
142
+ return e && M(e) ? e.success : void 0;
143
+ }), J = s(() => {
144
+ let e = K.value;
145
+ return e && k(e) ? e.failure : "";
146
+ }), Y = s(() => q.value && n.catalog.entries.value.some((e) => e.document.path === q.value?.path)), X = s(() => {
147
+ let e = U.value;
148
+ if (!e || e.kind === "home" || !e.type.hierarchy) return [];
149
+ let t = n.catalog.entries.value.flatMap((t) => t.document.collection !== e.collection || t.document.locale !== (B.value || void 0) || t.document.placement.kind === "home" ? [] : [{
150
+ description: String(t.document.path),
151
+ label: t.document.title,
152
+ value: String(t.document.id)
153
+ }]);
154
+ return n.context?.parent && !t.some((e) => e.value === n.context.parent) && t.push({
155
+ description: n.context.parent,
156
+ label: "Selected location",
157
+ value: n.context.parent
158
+ }), [{
159
+ description: "Add this page directly below the homepage.",
160
+ label: "Top level",
161
+ value: R
162
+ }, ...t];
163
+ }), Z = s(() => !!D.value.trim() && !!U.value && !!q.value && !Y.value);
164
+ i(D, (e) => {
165
+ j.value || (O.value = se(e));
166
+ }), i(N, () => z.value = R, { flush: "sync" }), i(B, () => {
167
+ z.value = R, U.value || (N.value = Q());
168
+ }, { flush: "sync" }), i(h, (e) => {
169
+ e && (w.value = "", D.value = "", O.value = "", j.value = !1, V.value = !1, B.value = n.context?.locale ?? x.locales?.defaultLocale ?? "", N.value = n.context?.collection ? `entry:${n.context.collection}` : Q(), z.value = n.context?.parent === W.value?.document.id ? R : n.context?.parent || R, n.context?.slug && (O.value = n.context.slug, j.value = !0));
170
+ }, { immediate: !0 });
171
+ async function Te() {
172
+ let e = U.value, t = G.value;
173
+ if (Z.value && e && t && !T.value) {
174
+ T.value = !0, w.value = "";
175
+ try {
176
+ let r = {
177
+ collection: e.collection,
178
+ placement: t,
179
+ title: D.value
180
+ }, i = await v.gateway.documents.create(B.value ? {
181
+ ...r,
182
+ locale: B.value
183
+ } : r);
184
+ await n.catalog.refresh(!0);
185
+ let a = n.catalog.byId(i.documentId);
186
+ if (!a) throw Error("The page was created but could not be opened.");
187
+ m("close", a.document.id);
188
+ } catch (e) {
189
+ w.value = ue(e);
190
+ } finally {
191
+ T.value = !1;
192
+ }
193
+ }
194
+ }
195
+ function Q() {
196
+ return H.value[0]?.key ?? "";
197
+ }
198
+ function $(e) {
199
+ try {
200
+ return new Intl.DisplayNames(void 0, { type: "language" }).of(e) ?? e.toLocaleUpperCase();
201
+ } catch {
202
+ return e.toLocaleUpperCase();
203
+ }
204
+ }
205
+ return (n, i) => {
206
+ let a = re, o = te, s = ne, f = oe, m = ie, v = ce, x = de, S = le, E = ae;
207
+ return b(), p(E, {
208
+ open: h.value,
209
+ "onUpdate:open": i[7] ||= (e) => h.value = e,
210
+ title: "Create page",
211
+ description: Se.value,
212
+ ui: { content: "max-w-lg" }
213
+ }, {
214
+ body: t(() => [e("form", {
215
+ id: "create-document-form",
216
+ class: "space-y-4",
217
+ onSubmit: ee(Te, ["prevent"])
218
+ }, [
219
+ w.value ? (b(), p(a, {
220
+ key: 0,
221
+ description: w.value,
222
+ color: "error",
223
+ variant: "subtle"
224
+ }, null, 8, ["description"])) : y("", !0),
225
+ H.value.length ? H.value.length > 1 ? (b(), g("fieldset", fe, [i[8] ||= e("legend", { class: "mb-2 text-sm font-medium text-highlighted" }, "Page type", -1), e("div", pe, [(b(!0), g(c, null, r(H.value, (t) => (b(), g("button", {
226
+ key: t.key,
227
+ type: "button",
228
+ "aria-pressed": t.key === N.value,
229
+ class: u(["min-w-28 border-l border-default px-3 py-2 text-center text-sm transition-[color,background-color,transform] duration-150 ease-out first:border-l-0 active:scale-[0.98] motion-reduce:transition-none", t.key === N.value ? "bg-muted font-medium text-highlighted" : "bg-default text-muted hover:bg-muted/50 hover:text-highlighted"]),
230
+ onClick: (e) => N.value = t.key
231
+ }, [e("span", he, d(t.label), 1)], 10, me))), 128))])])) : y("", !0) : (b(), p(a, {
232
+ key: 1,
233
+ title: "Document creation is not configured",
234
+ description: "A developer needs to make at least one collection creatable in Studio.",
235
+ color: "warning",
236
+ variant: "subtle"
237
+ })),
238
+ U.value ? (b(), g("div", P, [l(s, {
239
+ label: "Title",
240
+ required: ""
241
+ }, {
242
+ default: t(() => [l(o, {
243
+ modelValue: D.value,
244
+ "onUpdate:modelValue": i[0] ||= (e) => D.value = e,
245
+ autofocus: "",
246
+ placeholder: "About us",
247
+ class: "w-full"
248
+ }, null, 8, ["modelValue"])]),
249
+ _: 1
250
+ })])) : y("", !0),
251
+ U.value ? (b(), g("div", F, [l(x, {
252
+ open: V.value,
253
+ "onUpdate:open": i[5] ||= (e) => V.value = e
254
+ }, {
255
+ content: t(() => [e("div", ve, [
256
+ _(C).length ? (b(), p(s, {
257
+ key: 0,
258
+ label: "Language"
259
+ }, {
260
+ default: t(() => [l(m, {
261
+ modelValue: B.value,
262
+ "onUpdate:modelValue": i[1] ||= (e) => B.value = e,
263
+ items: _(C),
264
+ "value-key": "value",
265
+ class: "w-full"
266
+ }, null, 8, ["modelValue", "items"])]),
267
+ _: 1
268
+ })) : y("", !0),
269
+ U.value.kind === "entry" && U.value.type.hierarchy ? (b(), p(s, {
270
+ key: 1,
271
+ label: "Location",
272
+ class: u(_(C).length ? "" : "sm:col-span-2")
273
+ }, {
274
+ default: t(() => [l(v, {
275
+ modelValue: z.value,
276
+ "onUpdate:modelValue": i[2] ||= (e) => z.value = e,
277
+ "aria-label": "Location",
278
+ items: X.value,
279
+ "value-key": "value",
280
+ "filter-fields": ["label", "description"],
281
+ "search-input": { placeholder: "Search pages…" },
282
+ class: "w-full"
283
+ }, null, 8, ["modelValue", "items"])]),
284
+ _: 1
285
+ }, 8, ["class"])) : y("", !0),
286
+ U.value.kind === "entry" ? (b(), p(s, {
287
+ key: 2,
288
+ label: "Page address",
289
+ description: "The final part of this page's web address.",
290
+ class: "sm:col-span-2",
291
+ required: ""
292
+ }, {
293
+ default: t(() => [l(o, {
294
+ modelValue: O.value,
295
+ "onUpdate:modelValue": [i[3] ||= (e) => O.value = e, i[4] ||= (e) => j.value = !0],
296
+ placeholder: "about-us",
297
+ class: "w-full"
298
+ }, null, 8, ["modelValue"])]),
299
+ _: 1
300
+ })) : y("", !0)
301
+ ])]),
302
+ default: t(() => [e("button", I, [
303
+ e("span", L, [e("span", ge, d(we.value), 1), e("span", { class: u(["mt-0.5 block truncate font-mono text-xs", Y.value || J.value ? "text-error" : "text-highlighted"]) }, d(q.value?.path || U.value.urlHint), 3)]),
304
+ e("span", _e, d(V.value ? "Done" : "Edit details"), 1),
305
+ l(f, {
306
+ name: "i-lucide-chevron-down",
307
+ class: u(["size-3.5 shrink-0 text-dimmed transition-transform duration-150 ease-out motion-reduce:transition-none", V.value ? "rotate-180" : ""])
308
+ }, null, 8, ["class"])
309
+ ])]),
310
+ _: 1
311
+ }, 8, ["open"])])) : y("", !0),
312
+ Y.value ? (b(), g("p", ye, "This page address is already in use.")) : J.value ? (b(), g("p", be, d(J.value), 1)) : y("", !0)
313
+ ], 32)]),
314
+ footer: t(() => [e("div", xe, [l(S, {
315
+ color: "neutral",
316
+ variant: "ghost",
317
+ label: "Cancel",
318
+ class: "transition-transform duration-150 ease-out active:scale-[0.97] motion-reduce:transition-none",
319
+ onClick: i[6] ||= (e) => h.value = !1
320
+ }), l(S, {
321
+ type: "submit",
322
+ form: "create-document-form",
323
+ color: "neutral",
324
+ label: "Create page",
325
+ class: "transition-transform duration-150 ease-out active:scale-[0.97] motion-reduce:transition-none",
326
+ loading: T.value,
327
+ disabled: !Z.value
328
+ }, null, 8, ["loading", "disabled"])])]),
329
+ _: 1
330
+ }, 8, ["open", "description"]);
331
+ };
332
+ }
333
+ });
334
+ //#endregion
335
+ export { z as default };