tinyzoo 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (391) hide show
  1. package/LICENSE +10 -0
  2. package/README.md +46 -2
  3. package/app/app.config.ts +35 -0
  4. package/app/assets/brand/characters/bright/bird.svg +1 -0
  5. package/app/assets/brand/characters/bright/bunny.svg +1 -0
  6. package/app/assets/brand/characters/bright/elephant.svg +1 -0
  7. package/app/assets/brand/characters/bright/fox.svg +1 -0
  8. package/app/assets/brand/characters/bright/frog.svg +1 -0
  9. package/app/assets/brand/characters/bright/octopus.svg +1 -0
  10. package/app/assets/brand/characters/muted/bee.svg +1 -0
  11. package/app/assets/brand/characters/muted/bird.svg +1 -0
  12. package/app/assets/brand/characters/muted/butterfly.svg +1 -0
  13. package/app/assets/brand/characters/muted/chick.svg +1 -0
  14. package/app/assets/brand/characters/muted/cow.svg +1 -0
  15. package/app/assets/brand/characters/muted/deer.svg +1 -0
  16. package/app/assets/brand/characters/muted/duck.svg +1 -0
  17. package/app/assets/brand/characters/muted/elephant.svg +1 -0
  18. package/app/assets/brand/characters/muted/fox.svg +1 -0
  19. package/app/assets/brand/characters/muted/hedgehog.svg +1 -0
  20. package/app/assets/brand/characters/muted/koala.svg +1 -0
  21. package/app/assets/brand/characters/muted/ladybug.svg +1 -0
  22. package/app/assets/brand/characters/muted/lion.svg +1 -0
  23. package/app/assets/brand/characters/muted/mouse.svg +1 -0
  24. package/app/assets/brand/characters/muted/octopus.svg +1 -0
  25. package/app/assets/brand/characters/muted/owl.svg +1 -0
  26. package/app/assets/brand/characters/muted/panda.svg +1 -0
  27. package/app/assets/brand/characters/muted/penguin.svg +1 -0
  28. package/app/assets/brand/characters/muted/pig.svg +1 -0
  29. package/app/assets/brand/characters/muted/poodle.svg +1 -0
  30. package/app/assets/brand/characters/muted/raccoon.svg +1 -0
  31. package/app/assets/brand/characters/muted/seal.svg +1 -0
  32. package/app/assets/brand/characters/muted/sheep.svg +1 -0
  33. package/app/assets/brand/characters/muted/snail.svg +1 -0
  34. package/app/assets/brand/characters/muted/turtle.svg +1 -0
  35. package/app/assets/brand/characters/muted/whale.svg +1 -0
  36. package/app/assets/brand/logo/favicon.svg +1 -0
  37. package/app/assets/brand/logo/logo-primary-reversed.svg +1 -0
  38. package/app/assets/brand/logo/logo-primary.svg +1 -0
  39. package/app/assets/brand/logo/mascot-reversed.svg +1 -0
  40. package/app/assets/brand/logo/mascot.svg +1 -0
  41. package/app/assets/brand/logo/wordmark-reversed.svg +1 -0
  42. package/app/assets/brand/logo/wordmark.svg +1 -0
  43. package/app/assets/css/cms-admin.css +607 -0
  44. package/app/components/CmsBlocks.vue +30 -0
  45. package/app/components/CmsCell.vue +16 -0
  46. package/app/components/CmsCellBadge.vue +18 -0
  47. package/app/components/CmsCellBlocks.vue +9 -0
  48. package/app/components/CmsCellBoolean.vue +12 -0
  49. package/app/components/CmsCellCode.vue +7 -0
  50. package/app/components/CmsCellColor.vue +13 -0
  51. package/app/components/CmsCellDate.vue +10 -0
  52. package/app/components/CmsCellExcerpt.vue +21 -0
  53. package/app/components/CmsCellGallery.vue +10 -0
  54. package/app/components/CmsCellGroup.vue +23 -0
  55. package/app/components/CmsCellNumber.vue +7 -0
  56. package/app/components/CmsCellRelation.vue +8 -0
  57. package/app/components/CmsCellText.vue +12 -0
  58. package/app/components/CmsCellThumb.vue +18 -0
  59. package/app/components/CmsConfirmDialog.vue +55 -0
  60. package/app/components/CmsContent.vue +103 -0
  61. package/app/components/CmsDayPicker.vue +44 -0
  62. package/app/components/CmsEmptyState.vue +35 -0
  63. package/app/components/CmsField.vue +111 -0
  64. package/app/components/CmsFieldBlocks.vue +353 -0
  65. package/app/components/CmsFieldBoolean.vue +8 -0
  66. package/app/components/CmsFieldColor.vue +42 -0
  67. package/app/components/CmsFieldDate.vue +131 -0
  68. package/app/components/CmsFieldGallery.vue +114 -0
  69. package/app/components/CmsFieldGroup.vue +53 -0
  70. package/app/components/CmsFieldMedia.vue +219 -0
  71. package/app/components/CmsFieldNumber.vue +11 -0
  72. package/app/components/CmsFieldRelationMany.vue +54 -0
  73. package/app/components/CmsFieldRelationOne.vue +47 -0
  74. package/app/components/CmsFieldRichText.vue +45 -0
  75. package/app/components/CmsFieldSelect.vue +41 -0
  76. package/app/components/CmsFieldSlug.vue +46 -0
  77. package/app/components/CmsFieldText.vue +75 -0
  78. package/app/components/CmsFormSections.vue +150 -0
  79. package/app/components/CmsHighlight.vue +22 -0
  80. package/app/components/CmsImage.vue +39 -0
  81. package/app/components/CmsLinkPicker.vue +122 -0
  82. package/app/components/CmsLinkTarget.vue +35 -0
  83. package/app/components/CmsListFilters.vue +107 -0
  84. package/app/components/CmsLiveNotice.vue +64 -0
  85. package/app/components/CmsLoadError.vue +24 -0
  86. package/app/components/CmsMascot.vue +10 -0
  87. package/app/components/CmsMediaLibrary.vue +114 -0
  88. package/app/components/CmsMediaPreview.vue +34 -0
  89. package/app/components/CmsMediaThumb.vue +22 -0
  90. package/app/components/CmsMoment.vue +42 -0
  91. package/app/components/CmsNav.vue +39 -0
  92. package/app/components/CmsPage.vue +86 -0
  93. package/app/components/CmsPasswordInput.vue +22 -0
  94. package/app/components/CmsPresence.vue +29 -0
  95. package/app/components/CmsPreviewPanel.vue +131 -0
  96. package/app/components/CmsPublishReview.vue +102 -0
  97. package/app/components/CmsRevisions.vue +195 -0
  98. package/app/components/CmsRichTextEditor.vue +290 -0
  99. package/app/components/CmsSearch.vue +99 -0
  100. package/app/components/CmsSection.vue +20 -0
  101. package/app/components/CmsSingletonForm.vue +283 -0
  102. package/app/components/CmsStatusBadge.vue +21 -0
  103. package/app/components/CmsTime.vue +16 -0
  104. package/app/components/CmsTranslationRef.vue +27 -0
  105. package/app/components/CmsTreeList.vue +453 -0
  106. package/app/components/CmsUnsavedText.vue +34 -0
  107. package/app/components/CmsWordmark.vue +10 -0
  108. package/app/composables/useCmsAdminHead.ts +18 -0
  109. package/app/composables/useCmsCollab.ts +165 -0
  110. package/app/composables/useCmsConfirm.ts +39 -0
  111. package/app/composables/useCmsEntryActions.ts +75 -0
  112. package/app/composables/useCmsFocus.ts +13 -0
  113. package/app/composables/useCmsForm.ts +273 -0
  114. package/app/composables/useCmsI18n.ts +185 -0
  115. package/app/composables/useCmsLinkTargets.ts +84 -0
  116. package/app/composables/useCmsLive.ts +199 -0
  117. package/app/composables/useCmsSearch.ts +62 -0
  118. package/app/composables/useCmsSeo.ts +99 -0
  119. package/app/composables/useCmsSignedIn.ts +24 -0
  120. package/app/composables/useCmsUiLocale.ts +24 -0
  121. package/app/i18n/cs.ts +781 -0
  122. package/app/i18n/de.ts +781 -0
  123. package/app/i18n/en.ts +782 -0
  124. package/app/i18n/types.ts +22 -0
  125. package/app/layouts/admin.vue +224 -0
  126. package/app/layouts/cms-auth.vue +37 -0
  127. package/app/middleware/cms-api-not-a-page.global.ts +10 -0
  128. package/app/middleware/cms-auth.global.ts +16 -0
  129. package/app/pages/admin/[entity]/[id].vue +1109 -0
  130. package/app/pages/admin/[entity]/index.vue +733 -0
  131. package/app/pages/admin/account.vue +117 -0
  132. package/app/pages/admin/forgot.vue +50 -0
  133. package/app/pages/admin/index.vue +184 -0
  134. package/app/pages/admin/invite/[token].vue +73 -0
  135. package/app/pages/admin/login.vue +84 -0
  136. package/app/pages/admin/media.vue +494 -0
  137. package/app/pages/admin/privacy.vue +193 -0
  138. package/app/pages/admin/reset/[token].vue +52 -0
  139. package/app/pages/admin/setup.vue +87 -0
  140. package/app/pages/admin/styleguide.vue +261 -0
  141. package/app/pages/admin/team.vue +258 -0
  142. package/app/plugins/cmsLivePreview.client.ts +20 -0
  143. package/app/plugins/cmsSignedOut.client.ts +31 -0
  144. package/app/utils/cmsBlockType.ts +11 -0
  145. package/app/utils/cmsBrand.ts +38 -0
  146. package/app/utils/cmsDiff.ts +83 -0
  147. package/app/utils/cmsFetch.ts +7 -0
  148. package/app/utils/cmsFocusInvalid.ts +22 -0
  149. package/app/utils/cmsIssues.ts +128 -0
  150. package/app/utils/cmsJson.ts +28 -0
  151. package/app/utils/cmsMedia.ts +63 -0
  152. package/app/utils/cmsSections.ts +154 -0
  153. package/app/utils/cmsTime.ts +41 -0
  154. package/cli/backup.ts +713 -0
  155. package/cli/breaking.ts +174 -0
  156. package/cli/content-migrate.ts +239 -0
  157. package/cli/db.ts +86 -0
  158. package/cli/export.ts +336 -0
  159. package/cli/generate.ts +146 -0
  160. package/cli/import.ts +643 -0
  161. package/cli/index.ts +140 -0
  162. package/cli/links-convert.ts +291 -0
  163. package/cli/seed-engine.ts +705 -0
  164. package/cli/seed.ts +339 -0
  165. package/cli/status.ts +49 -0
  166. package/cli/tar.ts +304 -0
  167. package/cli/transfer.ts +677 -0
  168. package/cli/up.ts +27 -0
  169. package/cli/upgrade.ts +60 -0
  170. package/cli/versions.ts +60 -0
  171. package/forms/components/CmsForm.vue +186 -0
  172. package/forms/index.ts +203 -0
  173. package/forms/messages.ts +104 -0
  174. package/forms/retention.ts +48 -0
  175. package/forms/server/form.get.ts +12 -0
  176. package/forms/server/form.post.ts +109 -0
  177. package/forms/server/formSettings.ts +12 -0
  178. package/forms/server/forms.ts +127 -0
  179. package/module.ts +373 -0
  180. package/nuxt.config.ts +43 -0
  181. package/package.json +99 -3
  182. package/server/api/cms/[entity]/[id]/revisions/[rev].get.ts +19 -0
  183. package/server/api/cms/[entity]/[id]/revisions/index.get.ts +14 -0
  184. package/server/api/cms/[entity]/[id].delete.ts +52 -0
  185. package/server/api/cms/[entity]/[id].get.ts +21 -0
  186. package/server/api/cms/[entity]/[id].patch.ts +116 -0
  187. package/server/api/cms/[entity]/_export.get.ts +69 -0
  188. package/server/api/cms/[entity]/_move.post.ts +81 -0
  189. package/server/api/cms/[entity]/_order.post.ts +49 -0
  190. package/server/api/cms/[entity]/_tree.get.ts +41 -0
  191. package/server/api/cms/[entity]/index.get.ts +62 -0
  192. package/server/api/cms/[entity]/index.post.ts +38 -0
  193. package/server/api/cms/[entity]/options.get.ts +55 -0
  194. package/server/api/cms/_auth/accept.post.ts +33 -0
  195. package/server/api/cms/_auth/forgot.post.ts +39 -0
  196. package/server/api/cms/_auth/invite/[token].get.ts +18 -0
  197. package/server/api/cms/_auth/login.post.ts +42 -0
  198. package/server/api/cms/_auth/logout.post.ts +7 -0
  199. package/server/api/cms/_auth/me.get.ts +5 -0
  200. package/server/api/cms/_auth/me.patch.ts +32 -0
  201. package/server/api/cms/_auth/password.post.ts +29 -0
  202. package/server/api/cms/_auth/reset.post.ts +34 -0
  203. package/server/api/cms/_auth/setup.post.ts +46 -0
  204. package/server/api/cms/_auth/status.get.ts +18 -0
  205. package/server/api/cms/_collab/session.get.ts +30 -0
  206. package/server/api/cms/_collab/socket.ts +51 -0
  207. package/server/api/cms/_collab/unsaved.delete.ts +16 -0
  208. package/server/api/cms/_graph.get.ts +20 -0
  209. package/server/api/cms/_links/resolve.post.ts +17 -0
  210. package/server/api/cms/_links.get.ts +81 -0
  211. package/server/api/cms/_live.ts +30 -0
  212. package/server/api/cms/_media/[id]/usage.get.ts +14 -0
  213. package/server/api/cms/_media/[id].delete.ts +29 -0
  214. package/server/api/cms/_media/[id].get.ts +13 -0
  215. package/server/api/cms/_media/[id].patch.ts +64 -0
  216. package/server/api/cms/_media/exists.post.ts +15 -0
  217. package/server/api/cms/_media/img/[id]/[file].get.ts +42 -0
  218. package/server/api/cms/_media/index.get.ts +44 -0
  219. package/server/api/cms/_media/index.post.ts +147 -0
  220. package/server/api/cms/_media/raw/[...key].get.ts +85 -0
  221. package/server/api/cms/_media/raw/[...key].head.ts +2 -0
  222. package/server/api/cms/_overview.get.ts +87 -0
  223. package/server/api/cms/_preview.post.ts +17 -0
  224. package/server/api/cms/_privacy/delete.post.ts +14 -0
  225. package/server/api/cms/_privacy/export.post.ts +25 -0
  226. package/server/api/cms/_privacy/lookup.post.ts +27 -0
  227. package/server/api/cms/_search.get.ts +17 -0
  228. package/server/api/cms/_singleton/[name].get.ts +19 -0
  229. package/server/api/cms/_singleton/[name].put.ts +76 -0
  230. package/server/api/cms/_users/[id]/resend.post.ts +25 -0
  231. package/server/api/cms/_users/[id].delete.ts +21 -0
  232. package/server/api/cms/_users/[id].patch.ts +45 -0
  233. package/server/api/cms/_users/index.get.ts +28 -0
  234. package/server/api/cms/_users/index.post.ts +39 -0
  235. package/server/api/content/[entity]/[slug].get.ts +74 -0
  236. package/server/api/content/[entity]/index.get.ts +100 -0
  237. package/server/api/content/_global/[name].get.ts +23 -0
  238. package/server/api/content/_search.get.ts +28 -0
  239. package/server/api/content/_sitemap.get.ts +8 -0
  240. package/server/api/content/_tree/[entity].get.ts +31 -0
  241. package/server/api/content-types.ts.get.ts +17 -0
  242. package/server/api/health/live.get.ts +10 -0
  243. package/server/api/health/ready.get.ts +21 -0
  244. package/server/api/openapi.get.ts +48 -0
  245. package/server/api/openapi.json.get.ts +32 -0
  246. package/server/db/driver.ts +8 -0
  247. package/server/mail/mailer.ts +43 -0
  248. package/server/middleware/cms-0-headers.ts +37 -0
  249. package/server/middleware/cms-0-migrate-gate.ts +14 -0
  250. package/server/middleware/cms-csrf.ts +28 -0
  251. package/server/middleware/cms-limits.ts +20 -0
  252. package/server/middleware/cms-redirects.ts +21 -0
  253. package/server/middleware/cms-session.ts +41 -0
  254. package/server/middleware/cms-z-plugin-access.ts +15 -0
  255. package/server/plugins/cms-0-config-check.ts +35 -0
  256. package/server/plugins/cms-changes.ts +53 -0
  257. package/server/plugins/cms-content-etag.ts +21 -0
  258. package/server/plugins/cms-errors.ts +45 -0
  259. package/server/plugins/cms-migrate.ts +5 -0
  260. package/server/plugins/cms-plugins.ts +17 -0
  261. package/server/plugins/cms-search.ts +12 -0
  262. package/server/plugins/cms-setup-code.ts +15 -0
  263. package/server/routes/sitemap.xml.get.ts +25 -0
  264. package/server/store/redis.ts +95 -0
  265. package/server/store/types.ts +21 -0
  266. package/server/tasks/cms/retention.ts +10 -0
  267. package/server/tasks/cms/scheduled.ts +10 -0
  268. package/server/tasks/cms/search-reindex.ts +12 -0
  269. package/server/utils/cmsAudit.ts +29 -0
  270. package/server/utils/cmsAuth.ts +143 -0
  271. package/server/utils/cmsBlocks.ts +47 -0
  272. package/server/utils/cmsChanges.ts +222 -0
  273. package/server/utils/cmsCollab.ts +286 -0
  274. package/server/utils/cmsCollabServer.ts +451 -0
  275. package/server/utils/cmsCollate.ts +27 -0
  276. package/server/utils/cmsContent.ts +376 -0
  277. package/server/utils/cmsCrud.ts +361 -0
  278. package/server/utils/cmsCsv.ts +24 -0
  279. package/server/utils/cmsDb.ts +23 -0
  280. package/server/utils/cmsDemo.ts +36 -0
  281. package/server/utils/cmsEmails.ts +125 -0
  282. package/server/utils/cmsErrors.ts +40 -0
  283. package/server/utils/cmsFold.ts +17 -0
  284. package/server/utils/cmsImageSizes.ts +51 -0
  285. package/server/utils/cmsJson.ts +6 -0
  286. package/server/utils/cmsLinkAddress.ts +50 -0
  287. package/server/utils/cmsLinks.ts +248 -0
  288. package/server/utils/cmsListQuery.ts +93 -0
  289. package/server/utils/cmsLive.ts +392 -0
  290. package/server/utils/cmsLocales.ts +96 -0
  291. package/server/utils/cmsMail.ts +28 -0
  292. package/server/utils/cmsMediaGc.ts +188 -0
  293. package/server/utils/cmsMediaKeys.ts +62 -0
  294. package/server/utils/cmsMigrate.ts +86 -0
  295. package/server/utils/cmsPreviewDraft.ts +72 -0
  296. package/server/utils/cmsPrivacy.ts +176 -0
  297. package/server/utils/cmsPublished.ts +57 -0
  298. package/server/utils/cmsRange.ts +38 -0
  299. package/server/utils/cmsRateLimit.ts +82 -0
  300. package/server/utils/cmsRedirects.ts +160 -0
  301. package/server/utils/cmsRetention.ts +61 -0
  302. package/server/utils/cmsRevisions.ts +103 -0
  303. package/server/utils/cmsScheduler.ts +45 -0
  304. package/server/utils/cmsScrub.ts +107 -0
  305. package/server/utils/cmsSearch.ts +354 -0
  306. package/server/utils/cmsSession.ts +102 -0
  307. package/server/utils/cmsSetupCode.ts +97 -0
  308. package/server/utils/cmsSitemap.ts +176 -0
  309. package/server/utils/cmsStorage.ts +580 -0
  310. package/server/utils/cmsStore.ts +109 -0
  311. package/server/utils/cmsTooMany.ts +9 -0
  312. package/server/utils/cmsTranslationWrite.ts +186 -0
  313. package/server/utils/cmsTree.ts +251 -0
  314. package/server/utils/cmsTreeAddress.ts +65 -0
  315. package/server/utils/cmsUpload.ts +197 -0
  316. package/server/utils/cmsWebhooks.ts +101 -0
  317. package/shared/json.ts +11 -0
  318. package/shared/richtext-editor.ts +56 -0
  319. package/shared/richtext-normalize.ts +33 -0
  320. package/shared/richtext-paste.ts +151 -0
  321. package/shared/storage-delivery.ts +53 -0
  322. package/src/blocks.ts +624 -0
  323. package/src/changes.ts +54 -0
  324. package/src/content-shape.ts +340 -0
  325. package/src/deprecate.ts +64 -0
  326. package/src/descriptor.ts +149 -0
  327. package/src/docs.ts +27 -0
  328. package/src/emitter.ts +94 -0
  329. package/src/entity.ts +624 -0
  330. package/src/errorReport.ts +41 -0
  331. package/src/fields.ts +465 -0
  332. package/src/i18n.ts +26 -0
  333. package/src/index.ts +54 -0
  334. package/src/linkref.ts +31 -0
  335. package/src/links.ts +179 -0
  336. package/src/locales.ts +39 -0
  337. package/src/media.ts +48 -0
  338. package/src/migrate.ts +236 -0
  339. package/src/openapi.ts +377 -0
  340. package/src/paths.ts +88 -0
  341. package/src/plugin.ts +505 -0
  342. package/src/presets.ts +230 -0
  343. package/src/richtext.ts +88 -0
  344. package/src/sdk.ts +181 -0
  345. package/src/search.ts +312 -0
  346. package/src/seed.ts +225 -0
  347. package/src/setupCode.ts +30 -0
  348. package/src/system.ts +219 -0
  349. package/src/tree.ts +421 -0
  350. package/src/upgrades.ts +137 -0
  351. package/starter/.env.example +10 -0
  352. package/starter/README.md +65 -0
  353. package/starter/app/app.config.ts +10 -0
  354. package/starter/app/app.vue +12 -0
  355. package/starter/app/assets/css/main.css +15 -0
  356. package/starter/app/components/global/BlockContact.vue +15 -0
  357. package/starter/app/components/global/BlockCta.vue +15 -0
  358. package/starter/app/components/global/BlockHero.vue +23 -0
  359. package/starter/app/components/global/BlockImage.vue +13 -0
  360. package/starter/app/components/global/BlockText.vue +12 -0
  361. package/starter/app/composables/useSite.ts +77 -0
  362. package/starter/app/error.vue +28 -0
  363. package/starter/app/layouts/default.vue +106 -0
  364. package/starter/app/lib/cms-content.ts +152 -0
  365. package/starter/app/pages/[...slug].vue +66 -0
  366. package/starter/app/pages/hledat.vue +59 -0
  367. package/starter/app/pages/index.vue +20 -0
  368. package/starter/cms.config.ts +137 -0
  369. package/starter/compose.yaml +15 -0
  370. package/starter/drizzle.config.ts +8 -0
  371. package/starter/gitignore.txt +8 -0
  372. package/starter/nuxt.config.ts +13 -0
  373. package/starter/package.json +38 -0
  374. package/starter/scripts/typecheck.mjs +38 -0
  375. package/starter/seed/index.ts +297 -0
  376. package/starter/seed/media/about.jpg +0 -0
  377. package/starter/seed/media/hero.jpg +0 -0
  378. package/starter/seed/media/logo.png +0 -0
  379. package/starter/seed/media/news-bread.jpg +0 -0
  380. package/starter/seed/media/news-morning.jpg +0 -0
  381. package/starter/server/db/migrations/0000_init.sql +269 -0
  382. package/starter/server/db/migrations/0001_page_tree.sql +5 -0
  383. package/starter/server/db/migrations/0002_opening_hours_per_language.sql +1 -0
  384. package/starter/server/db/migrations/meta/0000_snapshot.json +1890 -0
  385. package/starter/server/db/migrations/meta/0001_snapshot.json +1887 -0
  386. package/starter/server/db/migrations/meta/0002_snapshot.json +1893 -0
  387. package/starter/server/db/migrations/meta/_journal.json +27 -0
  388. package/starter/server/db/schema.ts +253 -0
  389. package/starter/server/plugins/sitemap.ts +11 -0
  390. package/starter/server/routes/robots.txt.get.ts +12 -0
  391. package/starter/tsconfig.json +9 -0
@@ -0,0 +1,114 @@
1
+ <script setup lang="ts">
2
+ // Reusable media-library picker. Browse/search existing uploads or add a new one,
3
+ // then `select` it. Used by the media field widget and the rich-text image tool.
4
+ const props = defineProps<{ accept?: string }>()
5
+ const open = defineModel<boolean>('open', { default: false })
6
+ const emit = defineEmits<{ select: [media: any] }>()
7
+ const toast = useToast()
8
+ const { t } = useCmsI18n()
9
+
10
+ const items = ref<any[]>([])
11
+ const total = ref(0)
12
+ const page = ref(1)
13
+ const limit = 24
14
+ const q = ref('')
15
+ const loading = ref(false)
16
+ const uploading = ref(false)
17
+ const fileInput = ref<HTMLInputElement | null>(null)
18
+
19
+ async function load(reset = false) {
20
+ loading.value = true
21
+ try {
22
+ const res: any = await $fetch('/api/cms/_media', { query: { q: q.value, page: page.value, limit, accept: props.accept ?? '' } })
23
+ items.value = reset ? res.items : [...items.value, ...res.items]
24
+ total.value = res.total
25
+ } catch (err: any) {
26
+ toast.add({ title: t('media.loadFailed'), description: cmsRequestError(err, t as any), color: 'error', icon: 'i-lucide-x' })
27
+ } finally {
28
+ loading.value = false
29
+ }
30
+ }
31
+
32
+ watch(open, (o) => { if (o) { page.value = 1; load(true) } })
33
+ let debounce: ReturnType<typeof setTimeout>
34
+ watch(q, () => { clearTimeout(debounce); debounce = setTimeout(() => { page.value = 1; load(true) }, 250) })
35
+
36
+ const canLoadMore = computed(() => items.value.length < total.value)
37
+ function more() { page.value++; load() }
38
+
39
+ // Client-side filter by the field's `accept` (e.g. "image/*") so a picker only
40
+ // offers compatible assets, while the library itself stays one shared store.
41
+ function matches(m: any) {
42
+ if (!props.accept || props.accept === '*') return true
43
+ return props.accept.split(',').some((raw) => {
44
+ const a = raw.trim()
45
+ if (a.endsWith('/*')) return String(m.mime).startsWith(a.slice(0, -1))
46
+ return m.mime === a
47
+ })
48
+ }
49
+ const visible = computed(() => items.value.filter(matches))
50
+
51
+ function choose(m: any) {
52
+ emit('select', m)
53
+ open.value = false
54
+ }
55
+
56
+ function pick() { fileInput.value?.click() }
57
+ async function onUpload(e: Event) {
58
+ const file = (e.target as HTMLInputElement).files?.[0]
59
+ if (!file) return
60
+ uploading.value = true
61
+ try {
62
+ const fd = new FormData()
63
+ fd.append('file', file)
64
+ fd.append('library', '1')
65
+ const rec: any = await cmsUploadFile(fd)
66
+ items.value.unshift(rec)
67
+ choose(rec)
68
+ } catch (err: any) {
69
+ toast.add({ title: t('media.uploadFailed'), description: cmsRequestError(err, t as any), color: 'error', icon: 'i-lucide-x' })
70
+ } finally {
71
+ uploading.value = false
72
+ if (fileInput.value) fileInput.value.value = ''
73
+ }
74
+ }
75
+ </script>
76
+
77
+ <template>
78
+ <UModal v-model:open="open" :title="t('media.libraryTitle')" :ui="{ content: 'sm:max-w-3xl' }">
79
+ <template #body>
80
+ <input ref="fileInput" type="file" class="hidden" :accept="accept" @change="onUpload">
81
+
82
+ <div class="flex items-center gap-2 mb-4">
83
+ <UInput v-model="q" icon="i-lucide-search" :placeholder="t('media.searchPlaceholder')" class="flex-1" :loading="loading" />
84
+ <UButton icon="i-lucide-upload" :loading="uploading" @click="pick">{{ t('media.upload') }}</UButton>
85
+ </div>
86
+
87
+ <div v-if="!visible.length && !loading" class="py-16 text-center text-muted">
88
+ <UIcon name="i-lucide-image-off" class="size-8 mx-auto mb-2 text-dimmed" />
89
+ <p>{{ q ? t('media.noMatches') : t('media.empty') }}</p>
90
+ </div>
91
+
92
+ <div v-else class="grid grid-cols-2 sm:grid-cols-4 gap-3 max-h-[55vh] overflow-y-auto">
93
+ <button
94
+ v-for="m in visible" :key="m.id" type="button"
95
+ class="group text-left rounded-lg border border-default overflow-hidden hover:ring-2 hover:ring-primary/50 transition"
96
+ @click="choose(m)"
97
+ >
98
+ <div class="aspect-square bg-elevated/40 flex items-center justify-center overflow-hidden">
99
+ <CmsMediaThumb :media="m" />
100
+ </div>
101
+ <div class="p-1.5">
102
+ <p class="truncate text-xs font-medium">{{ m.name || m.alt || m.key.split('/').pop() }}</p>
103
+ <p v-if="m.name && m.alt" class="truncate text-xs text-muted">{{ m.alt }}</p>
104
+ <p class="truncate text-[10px] text-muted">{{ m.mime }}</p>
105
+ </div>
106
+ </button>
107
+ </div>
108
+
109
+ <div v-if="canLoadMore" class="mt-4 text-center">
110
+ <UButton variant="outline" color="neutral" size="sm" :loading="loading" @click="more">{{ t('media.loadMore') }}</UButton>
111
+ </div>
112
+ </template>
113
+ </UModal>
114
+ </template>
@@ -0,0 +1,34 @@
1
+ <script setup lang="ts">
2
+ // A file shown properly where it is opened (the library's panel, a media field): a picture
3
+ // as itself, a video in a player and a sound with its controls — the browser's own, so the
4
+ // keyboard, captions menus and phones' full-screen all work — and anything else as a card
5
+ // with its name that opens the file. `preload="metadata"`: nothing big downloads until Play.
6
+ const props = defineProps<{ media: any; /** Picture: how it sits in its box. */ fit?: 'cover' | 'contain'; width?: number }>()
7
+ const { t } = useCmsI18n()
8
+ const kind = computed(() => cmsMediaKind(props.media))
9
+ const name = computed(() => props.media?.name || String(props.media?.key ?? '').split('/').pop() || '')
10
+ </script>
11
+
12
+ <template>
13
+ <video
14
+ v-if="kind === 'video'" :src="media.url" controls preload="metadata" playsinline
15
+ class="block w-full max-h-[22rem] bg-black" :aria-label="t('media.videoLabel', { name })"
16
+ />
17
+ <div v-else-if="kind === 'audio'" class="flex flex-col gap-2 p-3">
18
+ <span class="flex items-center gap-2 text-sm text-highlighted"><UIcon name="i-lucide-music" class="size-4 shrink-0 text-muted" aria-hidden="true" /><span class="truncate">{{ name }}</span></span>
19
+ <audio :src="media.url" controls preload="metadata" class="w-full" :aria-label="t('media.audioLabel', { name })" />
20
+ </div>
21
+ <img
22
+ v-else-if="kind === 'image'" :src="cmsThumbUrl(media, width ?? 960)" :alt="media.alt ?? ''"
23
+ :width="media.width || undefined" :height="media.height || undefined" decoding="async"
24
+ class="block w-full" :class="fit === 'cover' ? 'size-full object-cover' : 'max-h-[22rem] object-contain mx-auto'"
25
+ @error="(e: Event) => cmsThumbFallback(e, media.url)"
26
+ >
27
+ <a v-else :href="media.url" target="_blank" rel="noopener" class="flex items-center gap-3 p-3 hover:bg-elevated/60">
28
+ <span class="grid size-9 shrink-0 place-items-center rounded-md border border-default bg-default">
29
+ <UIcon :name="cmsMediaIcon(media)" class="size-5 text-muted" aria-hidden="true" />
30
+ </span>
31
+ <span class="min-w-0"><span class="block truncate text-sm font-medium text-highlighted">{{ name }}</span></span>
32
+ <UIcon name="i-lucide-arrow-up-right" class="ml-auto size-4 shrink-0 text-dimmed" aria-hidden="true" />
33
+ </a>
34
+ </template>
@@ -0,0 +1,22 @@
1
+ <script setup lang="ts">
2
+ // A library file drawn small: a picture as its smaller copy (a few kB, not the original),
3
+ // anything else as an icon for its kind (a film strip, a note, a document) — the grid never
4
+ // loads a video or a PDF just to show a tile.
5
+ const props = defineProps<{ media: any; fit?: 'cover' | 'contain'; width?: number }>()
6
+ const kind = computed(() => cmsMediaKind(props.media))
7
+ const src = computed(() => cmsThumbUrl(props.media, props.width ?? 320))
8
+ const style = computed(() => (props.media?.focalX != null ? { objectPosition: `${props.media.focalX}% ${props.media.focalY}%` } : undefined))
9
+ const ext = computed(() => String(props.media?.key ?? props.media?.name ?? '').split('.').pop()?.slice(0, 5).toUpperCase())
10
+ </script>
11
+
12
+ <template>
13
+ <img
14
+ v-if="kind === 'image'" :src="src" :alt="media.alt ?? ''" loading="lazy" decoding="async"
15
+ class="size-full" :class="fit === 'contain' ? 'object-contain' : 'object-cover'" :style="style"
16
+ @error="(e: Event) => cmsThumbFallback(e, media.url)"
17
+ >
18
+ <span v-else class="flex size-full flex-col items-center justify-center gap-1 text-muted">
19
+ <UIcon :name="cmsMediaIcon(media)" class="size-8" aria-hidden="true" />
20
+ <span v-if="ext" class="text-[0.6875rem] font-medium tracking-wide">{{ ext }}</span>
21
+ </span>
22
+ </template>
@@ -0,0 +1,42 @@
1
+ <script setup lang="ts">
2
+ // A small brand moment that arrives after something good happened ("It's on the
3
+ // website."): one animal, a Manrope line, one sentence and up to two ways on. It
4
+ // sits in the corner (full width on phones), goes away by itself after a while,
5
+ // and never covers the page with a modal or confetti.
6
+ const props = withDefaults(defineProps<{
7
+ title: string
8
+ description?: string
9
+ animal?: string
10
+ /** Seconds before it leaves by itself (0: stays). */
11
+ timeout?: number
12
+ }>(), { animal: 'whale', timeout: 12 })
13
+ const open = defineModel<boolean>('open', { default: false })
14
+ const { t } = useCmsI18n()
15
+ const character = computed(() => cmsCharacter(props.animal))
16
+
17
+ let timer: ReturnType<typeof setTimeout> | null = null
18
+ watch(open, (v) => {
19
+ if (timer) clearTimeout(timer)
20
+ if (v && props.timeout) timer = setTimeout(() => { open.value = false }, props.timeout * 1000)
21
+ }, { immediate: true })
22
+ onBeforeUnmount(() => { if (timer) clearTimeout(timer) })
23
+ </script>
24
+
25
+ <template>
26
+ <Teleport to="body">
27
+ <div
28
+ v-if="open" role="status" aria-live="polite"
29
+ class="cms-rise fixed inset-x-3 bottom-3 z-50 sm:inset-x-auto sm:right-6 sm:bottom-6 sm:w-[25rem] cms-card flex items-start gap-4 p-4 shadow-[0_18px_40px_-14px_rgba(0,0,0,.35)]"
30
+ >
31
+ <img :src="character.url" alt="" class="h-12 w-auto shrink-0 select-none mt-0.5" draggable="false">
32
+ <div class="min-w-0 flex-1">
33
+ <p class="cms-display text-base text-highlighted">{{ title }}</p>
34
+ <p v-if="description" class="text-sm text-muted text-pretty">{{ description }}</p>
35
+ <div v-if="$slots.default" class="mt-2.5 flex flex-wrap gap-1.5">
36
+ <slot />
37
+ </div>
38
+ </div>
39
+ <UButton color="neutral" variant="ghost" size="xs" icon="i-lucide-x" class="-mr-1 -mt-1" :aria-label="t('common.close')" @click="open = false" />
40
+ </div>
41
+ </Teleport>
42
+ </template>
@@ -0,0 +1,39 @@
1
+ <script setup lang="ts">
2
+ // A site menu from the CMS (defineNavigation): links with their dropdowns, as plain
3
+ // nested lists — style it like any list. Internal links go through NuxtLink; external
4
+ // ones and "open in a new tab" links open safely. A link whose page is gone or not
5
+ // published (no `url`) is left out; one that still has working dropdown links stays as
6
+ // a heading without a link.
7
+ //
8
+ // const { data: nav } = await useFetch('/api/content/_global/navigation')
9
+ // <CmsNav :links="nav?.item?.main" aria-label="Hlavní menu" />
10
+ const props = defineProps<{ links: { id: string; label: string; url: string | null; newTab?: boolean | null; sub?: boolean | null }[] | null | undefined }>()
11
+ const tree = computed(() => {
12
+ const out: any[] = []
13
+ for (const l of props.links ?? []) {
14
+ const parent = out[out.length - 1]
15
+ if (l.sub && parent) parent.children.push(l)
16
+ else out.push({ ...l, children: [] })
17
+ }
18
+ return out
19
+ .map((l) => ({ ...l, children: l.children.filter((c: any) => !!c.url) }))
20
+ .filter((l) => !!l.url || l.children.length > 0)
21
+ })
22
+ const external = (url: string) => /^(https?:)?\/\//.test(url) || /^(mailto|tel):/.test(url)
23
+ </script>
24
+
25
+ <template>
26
+ <nav class="cms-nav">
27
+ <ul>
28
+ <li v-for="l in tree" :key="l.id" :class="l.children.length ? 'cms-nav__has-children' : undefined">
29
+ <NuxtLink v-if="l.url" :to="l.url" :external="external(l.url)" :target="l.newTab ? '_blank' : undefined" :rel="l.newTab || external(l.url) ? 'noopener' : undefined">{{ l.label }}</NuxtLink>
30
+ <span v-else>{{ l.label }}</span>
31
+ <ul v-if="l.children.length">
32
+ <li v-for="c in l.children" :key="c.id">
33
+ <NuxtLink :to="c.url" :external="external(c.url)" :target="c.newTab ? '_blank' : undefined" :rel="c.newTab || external(c.url) ? 'noopener' : undefined">{{ c.label }}</NuxtLink>
34
+ </li>
35
+ </ul>
36
+ </li>
37
+ </ul>
38
+ </nav>
39
+ </template>
@@ -0,0 +1,86 @@
1
+ <script setup lang="ts">
2
+ // The frame of every admin page: a sticky top bar (where you are + the page's
3
+ // actions, always reachable) over a scrolling body with the page title.
4
+ // Pages add no outer padding of their own — `.cms-page` owns the gutters.
5
+ //
6
+ // Two kinds of top bar:
7
+ // - lists and settings: breadcrumbs ("Home › News");
8
+ // - editors: `back` + the `status` slot — "‹ News · Draft · Saved" — the same bar for
9
+ // every editor arrangement, so moving between them never feels like another product.
10
+ //
11
+ // Landmarks: the body is the page's `<main id="cms-main">` (the skip link in the admin
12
+ // layout jumps to it) and holds the page's one `<h1>` — the `title`, or the screen-reader-only
13
+ // `heading` of a screen that shows its own big title (the editors, the media library). The top
14
+ // bar is navigation, not a heading: the breadcrumb is a labelled `nav`.
15
+ export interface CmsCrumb { label: string; to?: string }
16
+ const { t } = useCmsI18n()
17
+ defineProps<{
18
+ title?: string
19
+ /** The page's `<h1>` for screen readers when the screen draws its own title (an editor's title field). */
20
+ heading?: string
21
+ description?: string
22
+ breadcrumbs?: CmsCrumb[]
23
+ /** Editors: where "back" goes (replaces the breadcrumbs). */
24
+ back?: CmsCrumb
25
+ /** Narrow reading column (forms) instead of the full content width. */
26
+ narrow?: boolean
27
+ /** No width limit and no gutters (the page lays itself out, e.g. form + preview). */
28
+ flush?: boolean
29
+ /** Wide but with gutters (the Preview arrangement). */
30
+ wide?: boolean
31
+ }>()
32
+ </script>
33
+
34
+ <template>
35
+ <UDashboardPanel :ui="{ body: 'p-0 sm:p-0 gap-0' }">
36
+ <template #header>
37
+ <UDashboardNavbar :ui="{ root: 'bg-(--cms-page-bg)/85 backdrop-blur border-b border-default h-(--ui-header-height) gap-2 px-3 sm:px-6', left: 'min-w-0 gap-1.5', right: 'gap-1.5 sm:gap-2 shrink-0' }">
38
+ <!-- `left` (not `title`): the navbar would wrap the title slot in an <h1>, and the bar is not the page's heading -->
39
+ <template #left>
40
+ <div v-if="back" class="flex items-center gap-2 min-w-0 text-sm">
41
+ <NuxtLink
42
+ :to="back.to" class="inline-flex items-center gap-1 -ml-1.5 px-1.5 py-1 rounded-md font-medium text-highlighted hover:bg-elevated/60 shrink-0 sm:max-w-[45vw] lg:max-w-none"
43
+ >
44
+ <UIcon name="i-lucide-chevron-left" class="size-4 shrink-0" />
45
+ <!-- phones: the arrow alone (the bar is short); its name is still read out -->
46
+ <span class="truncate max-sm:sr-only">{{ back.label }}</span>
47
+ </NuxtLink>
48
+ <div v-if="$slots.status" class="flex items-center gap-2 min-w-0 text-muted">
49
+ <span class="text-dimmed max-sm:hidden" aria-hidden="true">·</span>
50
+ <slot name="status" />
51
+ </div>
52
+ </div>
53
+ <nav v-else-if="breadcrumbs?.length" :aria-label="t('nav.breadcrumb')" class="min-w-0">
54
+ <ol class="flex items-center gap-1.5 text-sm min-w-0">
55
+ <li v-for="(c, i) in breadcrumbs" :key="i" class="flex items-center gap-1.5 min-w-0" :class="i < breadcrumbs.length - 1 ? 'shrink-0 max-sm:hidden' : ''">
56
+ <NuxtLink v-if="c.to && i < breadcrumbs.length - 1" :to="c.to" class="text-muted hover:text-highlighted transition-colors">{{ c.label }}</NuxtLink>
57
+ <span v-else class="font-medium text-highlighted truncate" aria-current="page">{{ c.label }}</span>
58
+ <UIcon v-if="i < breadcrumbs.length - 1" name="i-lucide-chevron-right" class="size-3.5 text-dimmed shrink-0" />
59
+ </li>
60
+ </ol>
61
+ </nav>
62
+ </template>
63
+ <template #right>
64
+ <slot name="actions" />
65
+ </template>
66
+ </UDashboardNavbar>
67
+ </template>
68
+
69
+ <template #body>
70
+ <main id="cms-main" tabindex="-1" class="cms-page" :class="[narrow ? 'cms-page--narrow' : '', flush ? 'cms-page--flush' : '', wide ? 'cms-page--wide' : '']">
71
+ <h1 v-if="heading && !title" class="sr-only">{{ heading }}</h1>
72
+ <header v-if="title || $slots.meta" class="mb-6 flex flex-wrap items-end justify-between gap-x-6 gap-y-3">
73
+ <div class="min-w-0">
74
+ <div class="flex items-baseline gap-3 flex-wrap">
75
+ <h1 class="cms-display text-[1.75rem] leading-tight text-highlighted">{{ title }}</h1>
76
+ <slot name="badge" />
77
+ </div>
78
+ <p v-if="description" class="mt-1 text-sm text-muted max-w-2xl text-pretty">{{ description }}</p>
79
+ </div>
80
+ <slot name="meta" />
81
+ </header>
82
+ <slot />
83
+ </main>
84
+ </template>
85
+ </UDashboardPanel>
86
+ </template>
@@ -0,0 +1,22 @@
1
+ <script setup lang="ts">
2
+ // Password field with a show/hide toggle.
3
+ defineProps<{ autocomplete?: string; placeholder?: string; autofocus?: boolean }>()
4
+ const model = defineModel<string>({ default: '' })
5
+ const visible = ref(false)
6
+ const { t } = useCmsI18n()
7
+ </script>
8
+
9
+ <template>
10
+ <UInput
11
+ v-model="model" :type="visible ? 'text' : 'password'" :autocomplete="autocomplete ?? 'current-password'"
12
+ :placeholder="placeholder" :autofocus="autofocus" class="w-full" :ui="{ trailing: 'pe-1' }"
13
+ >
14
+ <template #trailing>
15
+ <UButton
16
+ color="neutral" variant="link" size="sm" :icon="visible ? 'i-lucide-eye-off' : 'i-lucide-eye'"
17
+ :aria-label="visible ? t('auth.hidePassword') : t('auth.showPassword')" :aria-pressed="visible"
18
+ @click="visible = !visible"
19
+ />
20
+ </template>
21
+ </UInput>
22
+ </template>
@@ -0,0 +1,29 @@
1
+ <script setup lang="ts">
2
+ // Who else has this open: small avatars in the page header; a pencil badge on the
3
+ // ones with unsaved changes (shape, not only colour). The tooltip and the hidden
4
+ // text say the same for screen readers and keyboards. Names come from the server
5
+ // (their accounts), never the browser.
6
+ import type { LivePerson } from '../composables/useCmsLive'
7
+
8
+ const props = defineProps<{ people: LivePerson[] }>()
9
+ const { t } = useCmsI18n()
10
+ const shown = computed(() => props.people.slice(0, 3))
11
+ const label = computed(() => props.people
12
+ .map((p) => t(p.editing ? 'live.editing' : 'live.viewing', { name: p.name }))
13
+ .join(' · '))
14
+ </script>
15
+
16
+ <template>
17
+ <UTooltip v-if="people.length" :text="label">
18
+ <div class="flex items-center -space-x-1.5 mr-1 rounded-full focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--ui-primary)" tabindex="0">
19
+ <span class="sr-only" role="status">{{ t('live.presence') }}: {{ label }}</span>
20
+ <span v-for="p in shown" :key="p.id" class="relative inline-flex" aria-hidden="true">
21
+ <UAvatar :alt="p.name" size="xs" class="ring-2 ring-(--ui-bg)" />
22
+ <span v-if="p.editing" class="absolute -bottom-1 -right-1 grid place-items-center size-3.5 rounded-full bg-warning text-inverted ring-2 ring-(--ui-bg)">
23
+ <UIcon name="i-lucide-pencil" class="size-2" />
24
+ </span>
25
+ </span>
26
+ <span v-if="people.length > shown.length" class="pl-2.5 text-xs text-muted" aria-hidden="true">+{{ people.length - shown.length }}</span>
27
+ </div>
28
+ </UTooltip>
29
+ </template>
@@ -0,0 +1,131 @@
1
+ <script setup lang="ts">
2
+ // Live preview beside the form: the site's own preview of this entry (the publish
3
+ // config's `preview` path with ?preview), at desktop or phone width. It follows the
4
+ // typing: the unsaved values go to the server (POST /api/cms/_preview, for this editor's
5
+ // ?preview requests only), then the page is told — `{ type: 'cms:preview', entity, id,
6
+ // locale, data }` — and refetches its content (plugins/cmsLivePreview.client.ts).
7
+ // Reloaded after every save; the unsaved values are dropped when the editor closes.
8
+ const props = defineProps<{ url: string; entity: string; id: string; locale: string | null; data: Record<string, any>; version: string | null; sheet?: boolean }>()
9
+ const emit = defineEmits<{ close: [] }>()
10
+ const { t } = useCmsI18n()
11
+
12
+ const frame = ref<HTMLIFrameElement | null>(null)
13
+ const width = ref<'desktop' | 'phone'>('desktop')
14
+ const reloads = ref(0)
15
+ // A save made a new version: show what is stored now.
16
+ watch(() => props.version, () => { reloads.value++ })
17
+
18
+ const target = computed(() => {
19
+ try {
20
+ return new URL(props.url, location.origin).origin
21
+ }
22
+ catch {
23
+ return location.origin
24
+ }
25
+ })
26
+ // Ask the site first (same site only): a missing page or an error is explained here
27
+ // instead of the browser's empty "refused to connect" frame.
28
+ const problem = ref<null | { status: number }>(null)
29
+ let probeSeq = 0
30
+ async function probe() {
31
+ const my = ++probeSeq
32
+ problem.value = null
33
+ if (target.value !== location.origin) return
34
+ try {
35
+ const res = await fetch(props.url, { credentials: 'same-origin', headers: { accept: 'text/html' } })
36
+ if (my === probeSeq && !res.ok) problem.value = { status: res.status }
37
+ }
38
+ catch { /* offline or blocked: let the frame try */ }
39
+ }
40
+ watch([() => props.url, reloads], probe)
41
+ const path = computed(() => {
42
+ try {
43
+ return new URL(props.url, location.origin).pathname
44
+ }
45
+ catch {
46
+ return props.url
47
+ }
48
+ })
49
+
50
+ let timer: ReturnType<typeof setTimeout> | null = null
51
+ let last = ''
52
+ let sending: Promise<unknown> = Promise.resolve()
53
+ const draftBody = (data: Record<string, any>) => ({ entity: props.entity, id: props.id, locale: props.locale, data })
54
+ async function post(force = false) {
55
+ // A plain copy of the field values (reactive proxies cannot be posted).
56
+ const data = JSON.parse(JSON.stringify(props.data ?? {}))
57
+ const json = JSON.stringify(data)
58
+ if (json !== last || force) {
59
+ last = json
60
+ // One at a time, in order: the page must never refetch before its values arrived.
61
+ sending = sending.then(() => $fetch('/api/cms/_preview', { method: 'POST', body: draftBody(data) }).catch(() => {}))
62
+ await sending
63
+ }
64
+ frame.value?.contentWindow?.postMessage({ type: 'cms:preview', entity: props.entity, id: props.id, locale: props.locale, data }, target.value)
65
+ }
66
+ watch(() => props.data, () => {
67
+ if (timer) clearTimeout(timer)
68
+ timer = setTimeout(() => post(), 250)
69
+ }, { deep: true })
70
+ // Closed or left: forget the unsaved values, so a later preview shows what is saved.
71
+ function clearDraft() {
72
+ try {
73
+ fetch('/api/cms/_preview', {
74
+ method: 'POST', keepalive: true, credentials: 'same-origin',
75
+ headers: { 'content-type': 'application/json' },
76
+ body: JSON.stringify({ entity: props.entity, id: props.id, locale: props.locale, clear: true }),
77
+ }).catch(() => {})
78
+ }
79
+ catch { /* leaving anyway */ }
80
+ }
81
+ onMounted(() => {
82
+ void probe()
83
+ void post(true)
84
+ // Leaving the page altogether (reload, another address) skips unmounting.
85
+ window.addEventListener('pagehide', clearDraft)
86
+ })
87
+ onBeforeUnmount(() => {
88
+ if (timer) clearTimeout(timer)
89
+ window.removeEventListener('pagehide', clearDraft)
90
+ clearDraft()
91
+ })
92
+ </script>
93
+
94
+ <template>
95
+ <section class="cms-preview" :class="sheet ? 'cms-preview--sheet flex-1 min-h-0' : ''" :aria-label="t('editor.previewPanel')">
96
+ <div class="flex items-center justify-between gap-2 pb-2">
97
+ <div class="flex items-center gap-1">
98
+ <span class="text-xs text-muted mr-2 max-sm:hidden">{{ t('editor.previewHint') }}</span>
99
+ <UButton
100
+ size="xs" variant="ghost" :color="width === 'desktop' ? 'primary' : 'neutral'" icon="i-lucide-monitor"
101
+ :aria-label="t('editor.previewDesktop')" :aria-pressed="width === 'desktop'" @click="width = 'desktop'"
102
+ />
103
+ <UButton
104
+ size="xs" variant="ghost" :color="width === 'phone' ? 'primary' : 'neutral'" icon="i-lucide-smartphone"
105
+ :aria-label="t('editor.previewPhone')" :aria-pressed="width === 'phone'" @click="width = 'phone'"
106
+ />
107
+ </div>
108
+ <div class="flex items-center gap-1">
109
+ <UButton size="xs" variant="ghost" color="neutral" icon="i-lucide-rotate-cw" :aria-label="t('editor.previewReload')" @click="reloads++" />
110
+ <UButton size="xs" variant="ghost" color="neutral" icon="i-lucide-external-link" :to="url" target="_blank" :aria-label="t('editor.preview')" />
111
+ <UButton size="xs" variant="ghost" color="neutral" icon="i-lucide-x" :aria-label="t('common.close')" @click="emit('close')" />
112
+ </div>
113
+ </div>
114
+ <div v-if="problem" class="cms-preview__stage grid place-items-center p-6">
115
+ <div class="max-w-sm text-center">
116
+ <UIcon :name="problem.status === 404 ? 'i-lucide-file-question' : 'i-lucide-triangle-alert'" class="size-8 text-dimmed" />
117
+ <p class="mt-3 text-sm font-medium text-highlighted">{{ problem.status === 404 ? t('editor.previewMissingTitle') : t('editor.previewErrorTitle') }}</p>
118
+ <p class="mt-1 text-sm text-muted text-pretty">
119
+ {{ problem.status === 404 ? t('editor.previewMissingBody', { path }) : t('editor.previewErrorBody', { status: problem.status }) }}
120
+ </p>
121
+ <UButton class="mt-4" size="sm" color="neutral" variant="outline" icon="i-lucide-rotate-cw" @click="reloads++">{{ t('editor.previewReload') }}</UButton>
122
+ </div>
123
+ </div>
124
+ <div v-else class="cms-preview__stage">
125
+ <iframe
126
+ :key="reloads" ref="frame" :src="url" :title="t('editor.previewPanel')"
127
+ class="cms-preview__frame" :class="width === 'phone' ? 'cms-preview__frame--phone' : ''" @load="post()"
128
+ />
129
+ </div>
130
+ </section>
131
+ </template>
@@ -0,0 +1,102 @@
1
+ <script setup lang="ts">
2
+ // The step before something goes on the website: what is ready, what is missing
3
+ // (each with the way to fix it), and when — now or at a chosen time. Warnings say
4
+ // what visitors will see and never block publishing. A required field left empty
5
+ // does block it (the save would be refused): it is listed first, with a way to it.
6
+ export interface CmsReviewCheck {
7
+ ok: boolean
8
+ /** Not ok and stops publishing (a required field is empty). */
9
+ blocking?: boolean
10
+ title: string
11
+ description?: string
12
+ action?: { label: string; onClick: () => void }
13
+ }
14
+ const props = defineProps<{
15
+ checks: CmsReviewCheck[]
16
+ /** The publish-date field, when this content can be scheduled. */
17
+ dateField?: any
18
+ entity: string
19
+ busy?: boolean
20
+ }>()
21
+ const open = defineModel<boolean>('open', { default: false })
22
+ /** The publish date (scheduling edits it in place). */
23
+ const date = defineModel<any>('date')
24
+ const emit = defineEmits<{ publish: [when: 'now' | 'schedule'] }>()
25
+ const { t } = useCmsI18n()
26
+
27
+ const when = ref<'now' | 'schedule'>('now')
28
+ watch(open, (v) => {
29
+ if (v) when.value = date.value && new Date(date.value).getTime() > Date.now() ? 'schedule' : 'now'
30
+ })
31
+ const scheduleInvalid = computed(() => when.value === 'schedule' && !(date.value && new Date(date.value).getTime() > Date.now()))
32
+ const warnings = computed(() => props.checks.filter((c) => !c.ok).length)
33
+ const blocked = computed(() => props.checks.some((c) => !c.ok && c.blocking))
34
+ const bird = cmsCharacter('bird')
35
+ </script>
36
+
37
+ <template>
38
+ <UModal
39
+ v-model:open="open" fullscreen :title="t('review.title')" :description="t('review.subtitle')"
40
+ :ui="{ header: 'hidden', body: 'p-0 sm:p-0', content: 'bg-(--cms-page-bg)' }"
41
+ >
42
+ <template #body>
43
+ <div class="flex h-14 items-center justify-between border-b border-default px-3 sm:px-6">
44
+ <UButton color="neutral" variant="ghost" icon="i-lucide-chevron-left" class="-ml-1.5" @click="open = false">{{ t('review.back') }}</UButton>
45
+ </div>
46
+ <div class="mx-auto w-full max-w-2xl px-4 py-8 sm:py-12">
47
+ <div class="flex items-start justify-between gap-6">
48
+ <div>
49
+ <h2 class="cms-display text-[1.75rem] sm:text-3xl leading-tight text-highlighted">{{ t('review.title') }}</h2>
50
+ <p class="cms-display text-[1.75rem] sm:text-3xl leading-tight text-muted">{{ t('review.subtitle') }}</p>
51
+ </div>
52
+ <img :src="bird.url" alt="" class="h-14 sm:h-18 w-auto shrink-0 select-none" draggable="false">
53
+ </div>
54
+
55
+ <ul class="cms-card mt-7 divide-y divide-(--ui-border-muted)">
56
+ <li v-for="(c, i) in checks" :key="i" class="flex items-center gap-3.5 px-4 py-3.5">
57
+ <span
58
+ class="grid size-7 shrink-0 place-items-center rounded-full"
59
+ :class="c.ok ? 'bg-success/10 text-success' : c.blocking ? 'bg-error/10 text-error' : 'bg-warning/10 text-warning'"
60
+ >
61
+ <UIcon :name="c.ok ? 'i-lucide-check' : c.blocking ? 'i-lucide-circle-x' : 'i-lucide-circle-alert'" class="size-4" />
62
+ </span>
63
+ <div class="min-w-0 flex-1">
64
+ <p class="text-sm font-medium text-highlighted">{{ c.title }}</p>
65
+ <p v-if="c.description" class="text-sm text-muted text-pretty break-words">{{ c.description }}</p>
66
+ </div>
67
+ <UButton v-if="c.action" color="neutral" variant="outline" size="sm" class="shrink-0" @click="c.action.onClick">{{ c.action.label }}</UButton>
68
+ </li>
69
+ </ul>
70
+
71
+ <template v-if="dateField">
72
+ <h3 class="cms-label mt-8 mb-2.5">{{ t('review.when') }}</h3>
73
+ <div class="grid gap-2.5 sm:grid-cols-2" role="radiogroup" :aria-label="t('review.when')">
74
+ <button
75
+ v-for="opt in (['now', 'schedule'] as const)" :key="opt" type="button" role="radio" :aria-checked="when === opt"
76
+ class="flex items-start gap-3 rounded-xl border p-3.5 text-left transition-colors"
77
+ :class="when === opt ? 'border-(--ui-primary) ring-1 ring-(--ui-primary)' : 'border-default hover:border-accented'"
78
+ @click="when = opt"
79
+ >
80
+ <span class="mt-0.5 size-4 shrink-0 rounded-full border" :class="when === opt ? 'border-[5px] border-(--ui-primary)' : 'border-accented'" />
81
+ <span>
82
+ <span class="block text-sm font-medium text-highlighted">{{ opt === 'now' ? t('review.now') : t('review.schedule') }}</span>
83
+ <span class="block text-sm text-muted">{{ opt === 'now' ? t('review.nowHint') : t('review.scheduleHint') }}</span>
84
+ </span>
85
+ </button>
86
+ </div>
87
+ <div v-if="when === 'schedule'" class="mt-4 max-w-xs">
88
+ <CmsField v-model="date" :field="dateField" :entity="entity" placement="main" id-prefix="review-" />
89
+ </div>
90
+ </template>
91
+
92
+ <div class="mt-8 flex flex-col-reverse gap-3 sm:flex-row sm:items-center sm:justify-between">
93
+ <p class="text-sm" :class="blocked ? 'text-error' : 'text-muted'" :role="blocked ? 'status' : undefined">{{ blocked ? t('review.requiredFirst') : warnings ? t('review.warningsDontBlock') : t('review.allGood') }}</p>
94
+ <UButton
95
+ size="lg" :loading="busy" :disabled="scheduleInvalid || blocked" class="justify-center"
96
+ :icon="when === 'schedule' ? 'i-lucide-clock' : undefined" @click="emit('publish', when)"
97
+ >{{ when === 'schedule' ? t('review.scheduleAction') : t('review.publishAction') }}</UButton>
98
+ </div>
99
+ </div>
100
+ </template>
101
+ </UModal>
102
+ </template>