@xleddyl/nuxt-cms 0.9.4 → 0.10.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 (431) hide show
  1. package/README.md +1 -1
  2. package/dist/module.d.mts +20 -1
  3. package/dist/module.json +1 -1
  4. package/dist/module.mjs +1037 -148
  5. package/dist/runtime/app/blocks/CmsBlocks.d.vue.ts +1 -1
  6. package/dist/runtime/app/blocks/CmsBlocks.vue +57 -9
  7. package/dist/runtime/app/blocks/CmsBlocks.vue.d.ts +1 -1
  8. package/dist/runtime/app/blocks/CmsField.d.ts +24 -0
  9. package/dist/runtime/app/blocks/CmsField.js +16 -0
  10. package/dist/runtime/app/blocks/node.d.ts +37 -0
  11. package/dist/runtime/app/blocks/node.js +17 -0
  12. package/dist/runtime/app/blocks/resolve.d.ts +18 -0
  13. package/dist/runtime/app/blocks/resolve.js +34 -0
  14. package/dist/runtime/app/components/cms/BlockPicker.d.vue.ts +22 -0
  15. package/dist/runtime/app/components/cms/BlockPicker.vue +87 -0
  16. package/dist/runtime/app/components/cms/BlockPicker.vue.d.ts +22 -0
  17. package/dist/runtime/app/components/cms/BlockPickerPopover.d.vue.ts +38 -0
  18. package/dist/runtime/app/components/cms/BlockPickerPopover.vue +44 -0
  19. package/dist/runtime/app/components/cms/BlockPickerPopover.vue.d.ts +38 -0
  20. package/dist/runtime/app/components/cms/BlockTree.d.vue.ts +29 -0
  21. package/dist/runtime/app/components/cms/BlockTree.vue +322 -0
  22. package/dist/runtime/app/components/cms/BlockTree.vue.d.ts +29 -0
  23. package/dist/runtime/app/components/cms/BlocksField.vue +569 -218
  24. package/dist/runtime/app/components/cms/BrandMark.vue +7 -13
  25. package/dist/runtime/app/components/cms/ConfirmGroups.vue +15 -13
  26. package/dist/runtime/app/components/cms/{BlockPalette.vue.d.ts → EditorHistory.d.vue.ts} +6 -5
  27. package/dist/runtime/app/components/cms/EditorHistory.vue +34 -0
  28. package/dist/runtime/app/components/cms/{BlockPalette.d.vue.ts → EditorHistory.vue.d.ts} +6 -5
  29. package/dist/runtime/app/components/cms/EntryDrawer.d.vue.ts +11 -5
  30. package/dist/runtime/app/components/cms/EntryDrawer.vue +183 -152
  31. package/dist/runtime/app/components/cms/EntryDrawer.vue.d.ts +11 -5
  32. package/dist/runtime/app/components/cms/EntryForm.d.vue.ts +16 -4
  33. package/dist/runtime/app/components/cms/EntryForm.vue +106 -146
  34. package/dist/runtime/app/components/cms/EntryForm.vue.d.ts +16 -4
  35. package/dist/runtime/app/components/cms/FieldInput.vue +10 -2
  36. package/dist/runtime/app/components/cms/FormSections.d.vue.ts +22 -0
  37. package/dist/runtime/app/components/cms/FormSections.vue +71 -0
  38. package/dist/runtime/app/components/cms/FormSections.vue.d.ts +22 -0
  39. package/dist/runtime/app/components/cms/ImportModal.vue +46 -58
  40. package/dist/runtime/app/components/cms/LinkField.d.vue.ts +16 -0
  41. package/dist/runtime/app/components/cms/LinkField.vue +250 -0
  42. package/dist/runtime/app/components/cms/LinkField.vue.d.ts +16 -0
  43. package/dist/runtime/app/components/cms/ListFilters.vue +10 -12
  44. package/dist/runtime/app/components/cms/LocaleSwitch.d.vue.ts +2 -1
  45. package/dist/runtime/app/components/cms/LocaleSwitch.vue +29 -5
  46. package/dist/runtime/app/components/cms/LocaleSwitch.vue.d.ts +2 -1
  47. package/dist/runtime/app/components/cms/MediaDetail.d.vue.ts +2 -0
  48. package/dist/runtime/app/components/cms/MediaDetail.vue +112 -83
  49. package/dist/runtime/app/components/cms/MediaDetail.vue.d.ts +2 -0
  50. package/dist/runtime/app/components/cms/MediaField.vue +35 -25
  51. package/dist/runtime/app/components/cms/MediaFolderPicker.vue +26 -71
  52. package/dist/runtime/app/components/cms/MediaGallery.d.vue.ts +1 -0
  53. package/dist/runtime/app/components/cms/MediaGallery.vue +442 -419
  54. package/dist/runtime/app/components/cms/MediaGallery.vue.d.ts +1 -0
  55. package/dist/runtime/app/components/cms/MediaThumb.vue +9 -25
  56. package/dist/runtime/app/components/cms/MediaUpload.vue +1 -1
  57. package/dist/runtime/app/components/cms/{BlockOutline.d.vue.ts → NestedBlockList.d.vue.ts} +5 -5
  58. package/dist/runtime/app/components/cms/NestedBlockList.vue +87 -0
  59. package/dist/runtime/app/components/cms/{BlockOutline.vue.d.ts → NestedBlockList.vue.d.ts} +5 -5
  60. package/dist/runtime/app/components/cms/PoweredBy.vue +12 -5
  61. package/dist/runtime/app/components/cms/PresetModal.d.vue.ts +18 -0
  62. package/dist/runtime/app/components/cms/PresetModal.vue +70 -0
  63. package/dist/runtime/app/components/cms/PresetModal.vue.d.ts +18 -0
  64. package/dist/runtime/app/components/cms/RelationField.vue +2 -8
  65. package/dist/runtime/app/components/cms/SettingsAccount.vue +60 -71
  66. package/dist/runtime/app/components/cms/SettingsColumns.vue +47 -69
  67. package/dist/runtime/app/components/cms/SettingsEmptyAdd.d.vue.ts +13 -0
  68. package/dist/runtime/app/components/cms/SettingsEmptyAdd.vue +21 -0
  69. package/dist/runtime/app/components/cms/SettingsEmptyAdd.vue.d.ts +13 -0
  70. package/dist/runtime/app/components/cms/SettingsEntries.d.vue.ts +13 -0
  71. package/dist/runtime/app/components/cms/SettingsEntries.vue +50 -0
  72. package/dist/runtime/app/components/cms/SettingsEntries.vue.d.ts +13 -0
  73. package/dist/runtime/app/components/cms/SettingsEntry.d.vue.ts +1 -10
  74. package/dist/runtime/app/components/cms/SettingsEntry.vue +11 -95
  75. package/dist/runtime/app/components/cms/SettingsEntry.vue.d.ts +1 -10
  76. package/dist/runtime/app/components/cms/SettingsEntryActions.d.vue.ts +7 -0
  77. package/dist/runtime/app/components/cms/SettingsEntryActions.vue +42 -0
  78. package/dist/runtime/app/components/cms/SettingsEntryActions.vue.d.ts +7 -0
  79. package/dist/runtime/app/components/cms/SettingsEntryTabs.d.vue.ts +7 -0
  80. package/dist/runtime/app/components/cms/SettingsEntryTabs.vue +21 -0
  81. package/dist/runtime/app/components/cms/SettingsEntryTabs.vue.d.ts +7 -0
  82. package/dist/runtime/app/components/cms/SettingsFormAction.d.vue.ts +3 -0
  83. package/dist/runtime/app/components/cms/SettingsFormAction.vue +17 -0
  84. package/dist/runtime/app/components/cms/SettingsFormAction.vue.d.ts +3 -0
  85. package/dist/runtime/app/components/cms/SettingsLayout.vue +18 -14
  86. package/dist/runtime/app/components/cms/SettingsPresetForm.d.vue.ts +11 -0
  87. package/dist/runtime/app/components/cms/SettingsPresetForm.vue +60 -0
  88. package/dist/runtime/app/components/cms/SettingsPresetForm.vue.d.ts +11 -0
  89. package/dist/runtime/app/components/cms/SettingsPresets.d.vue.ts +13 -0
  90. package/dist/runtime/app/components/cms/SettingsPresets.vue +65 -0
  91. package/dist/runtime/app/components/cms/SettingsPresets.vue.d.ts +13 -0
  92. package/dist/runtime/app/components/cms/SettingsRecordActions.d.vue.ts +32 -0
  93. package/dist/runtime/app/components/cms/SettingsRecordActions.vue +45 -0
  94. package/dist/runtime/app/components/cms/SettingsRecordActions.vue.d.ts +32 -0
  95. package/dist/runtime/app/components/cms/SettingsRedirectActions.d.vue.ts +3 -0
  96. package/dist/runtime/app/components/cms/SettingsRedirectActions.vue +59 -0
  97. package/dist/runtime/app/components/cms/SettingsRedirectActions.vue.d.ts +3 -0
  98. package/dist/runtime/app/components/cms/SettingsRedirectForm.d.vue.ts +11 -0
  99. package/dist/runtime/app/components/cms/SettingsRedirectForm.vue +77 -0
  100. package/dist/runtime/app/components/cms/SettingsRedirectForm.vue.d.ts +11 -0
  101. package/dist/runtime/app/components/cms/SettingsRedirects.d.vue.ts +13 -0
  102. package/dist/runtime/app/components/cms/SettingsRedirects.vue +117 -0
  103. package/dist/runtime/app/components/cms/SettingsRedirects.vue.d.ts +13 -0
  104. package/dist/runtime/app/components/cms/SettingsSecretCard.d.vue.ts +17 -0
  105. package/dist/runtime/app/components/cms/SettingsSecretCard.vue +43 -0
  106. package/dist/runtime/app/components/cms/SettingsSecretCard.vue.d.ts +17 -0
  107. package/dist/runtime/app/components/cms/SettingsSite.d.vue.ts +3 -0
  108. package/dist/runtime/app/components/cms/SettingsSite.vue +140 -0
  109. package/dist/runtime/app/components/cms/SettingsSite.vue.d.ts +3 -0
  110. package/dist/runtime/app/components/cms/SettingsUserCreate.d.vue.ts +8 -0
  111. package/dist/runtime/app/components/cms/SettingsUserCreate.vue +82 -0
  112. package/dist/runtime/app/components/cms/SettingsUserCreate.vue.d.ts +8 -0
  113. package/dist/runtime/app/components/cms/SettingsUserDetail.d.vue.ts +11 -0
  114. package/dist/runtime/app/components/cms/SettingsUserDetail.vue +179 -0
  115. package/dist/runtime/app/components/cms/SettingsUserDetail.vue.d.ts +11 -0
  116. package/dist/runtime/app/components/cms/SettingsUsers.d.vue.ts +9 -6
  117. package/dist/runtime/app/components/cms/SettingsUsers.vue +88 -234
  118. package/dist/runtime/app/components/cms/SettingsUsers.vue.d.ts +9 -6
  119. package/dist/runtime/app/components/cms/SharePreview.d.vue.ts +18 -0
  120. package/dist/runtime/app/components/cms/SharePreview.vue +219 -0
  121. package/dist/runtime/app/components/cms/SharePreview.vue.d.ts +18 -0
  122. package/dist/runtime/app/components/cms/SlugField.vue +5 -3
  123. package/dist/runtime/app/components/cms/StatusBadge.vue +9 -8
  124. package/dist/runtime/app/components/cms/TranslationBadges.d.vue.ts +7 -0
  125. package/dist/runtime/app/components/cms/TranslationBadges.vue +45 -0
  126. package/dist/runtime/app/components/cms/TranslationBadges.vue.d.ts +7 -0
  127. package/dist/runtime/app/components/cms/TranslationMenu.d.vue.ts +17 -0
  128. package/dist/runtime/app/components/cms/TranslationMenu.vue +28 -0
  129. package/dist/runtime/app/components/cms/TranslationMenu.vue.d.ts +17 -0
  130. package/dist/runtime/app/components/cms/VisualEditor.d.vue.ts +22 -4
  131. package/dist/runtime/app/components/cms/VisualEditor.vue +1152 -335
  132. package/dist/runtime/app/components/cms/VisualEditor.vue.d.ts +22 -4
  133. package/dist/runtime/app/components/cms/WelcomeModal.vue +32 -50
  134. package/dist/runtime/app/composables/cms-clipboard.d.ts +8 -0
  135. package/dist/runtime/app/composables/cms-clipboard.js +38 -0
  136. package/dist/runtime/app/composables/cms-confirm.d.ts +6 -8
  137. package/dist/runtime/app/composables/cms-confirm.js +5 -7
  138. package/dist/runtime/app/composables/cms-entry-disabled.d.ts +5 -1
  139. package/dist/runtime/app/composables/cms-entry-disabled.js +7 -0
  140. package/dist/runtime/app/composables/cms-entry-form.d.ts +15 -0
  141. package/dist/runtime/app/composables/cms-entry-form.js +40 -0
  142. package/dist/runtime/app/composables/cms-entry-settings.d.ts +30 -0
  143. package/dist/runtime/app/composables/cms-entry-settings.js +122 -0
  144. package/dist/runtime/app/composables/cms-entry.d.ts +5 -1
  145. package/dist/runtime/app/composables/cms-entry.js +36 -11
  146. package/dist/runtime/app/composables/cms-history.d.ts +10 -0
  147. package/dist/runtime/app/composables/cms-history.js +24 -0
  148. package/dist/runtime/app/composables/cms-link-targets.d.ts +10 -0
  149. package/dist/runtime/app/composables/cms-link-targets.js +40 -0
  150. package/dist/runtime/app/composables/cms-link-usage.d.ts +1 -0
  151. package/dist/runtime/app/composables/cms-link-usage.js +45 -0
  152. package/dist/runtime/app/composables/cms-media-library.d.ts +19 -9
  153. package/dist/runtime/app/composables/cms-media-library.js +31 -13
  154. package/dist/runtime/app/composables/cms-media-uploader.js +6 -20
  155. package/dist/runtime/app/composables/cms-permissions.d.ts +18 -0
  156. package/dist/runtime/app/composables/cms-permissions.js +54 -0
  157. package/dist/runtime/app/composables/cms-presets.d.ts +11 -0
  158. package/dist/runtime/app/composables/cms-presets.js +40 -0
  159. package/dist/runtime/app/composables/cms-preview-mode.d.ts +4 -0
  160. package/dist/runtime/app/composables/cms-preview-mode.js +8 -0
  161. package/dist/runtime/app/composables/cms-query.d.ts +3 -0
  162. package/dist/runtime/app/composables/cms-query.js +45 -20
  163. package/dist/runtime/app/composables/cms-record-list.d.ts +31 -0
  164. package/dist/runtime/app/composables/cms-record-list.js +75 -0
  165. package/dist/runtime/app/composables/cms-route.d.ts +6 -0
  166. package/dist/runtime/app/composables/cms-route.js +36 -0
  167. package/dist/runtime/app/composables/cms-runtime.d.ts +1 -0
  168. package/dist/runtime/app/composables/cms-save-handoff.d.ts +4 -0
  169. package/dist/runtime/app/composables/cms-save-handoff.js +19 -0
  170. package/dist/runtime/app/composables/cms-seo.d.ts +12 -0
  171. package/dist/runtime/app/composables/cms-seo.js +69 -0
  172. package/dist/runtime/app/composables/cms-settings-form.d.ts +13 -0
  173. package/dist/runtime/app/composables/cms-settings-form.js +29 -0
  174. package/dist/runtime/app/composables/cms-settings-sections.d.ts +26 -0
  175. package/dist/runtime/app/composables/cms-settings-sections.js +181 -0
  176. package/dist/runtime/app/composables/cms-settings-stores.d.ts +52 -0
  177. package/dist/runtime/app/composables/cms-settings-stores.js +156 -0
  178. package/dist/runtime/app/composables/cms-settings.d.ts +3 -3
  179. package/dist/runtime/app/composables/cms-settings.js +14 -8
  180. package/dist/runtime/app/composables/cms-site-disabled.d.ts +7 -0
  181. package/dist/runtime/app/composables/cms-site-disabled.js +8 -0
  182. package/dist/runtime/app/composables/cms-site.d.ts +7 -0
  183. package/dist/runtime/app/composables/cms-site.js +22 -0
  184. package/dist/runtime/app/composables/cms-toast.d.ts +2 -8
  185. package/dist/runtime/app/composables/cms-toast.js +3 -9
  186. package/dist/runtime/app/composables/cms-translation-actions.d.ts +15 -0
  187. package/dist/runtime/app/composables/cms-translation-actions.js +108 -0
  188. package/dist/runtime/app/css-url.d.ts +4 -0
  189. package/dist/runtime/app/image/CmsImage.d.vue.ts +89 -0
  190. package/dist/runtime/app/image/CmsImage.vue +91 -0
  191. package/dist/runtime/app/image/CmsImage.vue.d.ts +89 -0
  192. package/dist/runtime/app/layouts/cms-admin.d.vue.ts +2 -2
  193. package/dist/runtime/app/layouts/cms-admin.vue +98 -76
  194. package/dist/runtime/app/layouts/cms-admin.vue.d.ts +2 -2
  195. package/dist/runtime/app/layouts/cms-editor.vue +7 -2
  196. package/dist/runtime/app/links/CmsLink.d.vue.ts +18 -0
  197. package/dist/runtime/app/links/CmsLink.vue +18 -0
  198. package/dist/runtime/app/links/CmsLink.vue.d.ts +18 -0
  199. package/dist/runtime/app/middleware/cms-auth.js +13 -1
  200. package/dist/runtime/app/pages/admin-collection.vue +473 -297
  201. package/dist/runtime/app/pages/admin-content.vue +190 -53
  202. package/dist/runtime/app/pages/admin-entry.vue +79 -75
  203. package/dist/runtime/app/pages/admin-index.vue +18 -5
  204. package/dist/runtime/app/pages/admin-login.vue +1 -1
  205. package/dist/runtime/app/pages/admin-logout.vue +1 -1
  206. package/dist/runtime/app/pages/admin-media.vue +3 -3
  207. package/dist/runtime/app/pages/admin-preview.vue +112 -24
  208. package/dist/runtime/app/plugins/cms-field.d.ts +2 -0
  209. package/dist/runtime/app/plugins/cms-field.js +8 -0
  210. package/dist/runtime/app/plugins/cms-preview-banner.client.d.ts +2 -0
  211. package/dist/runtime/app/plugins/cms-preview-banner.client.js +19 -0
  212. package/dist/runtime/app/plugins/cms-preview.d.ts +2 -0
  213. package/dist/runtime/app/plugins/cms-preview.js +27 -0
  214. package/dist/runtime/app/preview/CmsPreviewBanner.d.vue.ts +7 -0
  215. package/dist/runtime/app/preview/CmsPreviewBanner.vue +63 -0
  216. package/dist/runtime/app/preview/CmsPreviewBanner.vue.d.ts +7 -0
  217. package/dist/runtime/app/preview/PreviewOverlay.d.vue.ts +17 -3
  218. package/dist/runtime/app/preview/PreviewOverlay.vue +629 -166
  219. package/dist/runtime/app/preview/PreviewOverlay.vue.d.ts +17 -3
  220. package/dist/runtime/app/preview/field-marker.d.ts +12 -0
  221. package/dist/runtime/app/preview/field-marker.js +20 -0
  222. package/dist/runtime/app/preview/inline-text.d.ts +15 -0
  223. package/dist/runtime/app/preview/inline-text.js +158 -0
  224. package/dist/runtime/app/utils/block-editor.d.ts +22 -0
  225. package/dist/runtime/app/utils/block-editor.js +12 -0
  226. package/dist/runtime/app/utils/keyboard.d.ts +6 -0
  227. package/dist/runtime/app/utils/keyboard.js +52 -0
  228. package/dist/runtime/app/utils/redirects.d.ts +6 -0
  229. package/dist/runtime/app/utils/redirects.js +7 -0
  230. package/dist/runtime/app/utils/ui.d.ts +8 -0
  231. package/dist/runtime/app/utils/ui.js +15 -1
  232. package/dist/runtime/app/utils/users.d.ts +15 -0
  233. package/dist/runtime/app/utils/users.js +14 -0
  234. package/dist/runtime/assets/cms.css +1 -1
  235. package/dist/runtime/generate.js +16 -2
  236. package/dist/runtime/server/api/collection-export.get.js +3 -2
  237. package/dist/runtime/server/api/collection-import.post.js +39 -11
  238. package/dist/runtime/server/api/collection.get.js +27 -9
  239. package/dist/runtime/server/api/collection.post.js +28 -11
  240. package/dist/runtime/server/api/collection.put.js +35 -13
  241. package/dist/runtime/server/api/item.delete.js +19 -7
  242. package/dist/runtime/server/api/item.get.js +3 -2
  243. package/dist/runtime/server/api/item.put.js +52 -18
  244. package/dist/runtime/server/api/link-usage.post.d.ts +5 -0
  245. package/dist/runtime/server/api/link-usage.post.js +21 -0
  246. package/dist/runtime/server/api/media-delete.post.js +4 -2
  247. package/dist/runtime/server/api/media-download.get.js +2 -2
  248. package/dist/runtime/server/api/media-folder.delete.js +8 -2
  249. package/dist/runtime/server/api/media-folder.patch.js +10 -2
  250. package/dist/runtime/server/api/media-folder.post.js +4 -2
  251. package/dist/runtime/server/api/media-move.post.js +7 -4
  252. package/dist/runtime/server/api/media-presign.post.js +2 -2
  253. package/dist/runtime/server/api/media-upload.put.js +2 -2
  254. package/dist/runtime/server/api/media-usage.post.d.ts +2 -4
  255. package/dist/runtime/server/api/media-usage.post.js +13 -9
  256. package/dist/runtime/server/api/media.delete.js +4 -2
  257. package/dist/runtime/server/api/media.get.js +22 -7
  258. package/dist/runtime/server/api/media.post.js +4 -2
  259. package/dist/runtime/server/api/media.put.js +33 -16
  260. package/dist/runtime/server/api/preset.delete.d.ts +4 -0
  261. package/dist/runtime/server/api/preset.delete.js +9 -0
  262. package/dist/runtime/server/api/preset.put.d.ts +3 -0
  263. package/dist/runtime/server/api/preset.put.js +23 -0
  264. package/dist/runtime/server/api/presets-field.get.d.ts +3 -0
  265. package/dist/runtime/server/api/presets-field.get.js +13 -0
  266. package/dist/runtime/server/api/presets-field.post.d.ts +3 -0
  267. package/dist/runtime/server/api/presets-field.post.js +36 -0
  268. package/dist/runtime/server/api/presets.get.d.ts +3 -0
  269. package/dist/runtime/server/api/presets.get.js +7 -0
  270. package/dist/runtime/server/api/preview-link.delete.d.ts +4 -0
  271. package/dist/runtime/server/api/preview-link.delete.js +15 -0
  272. package/dist/runtime/server/api/preview-links.get.d.ts +3 -0
  273. package/dist/runtime/server/api/preview-links.get.js +10 -0
  274. package/dist/runtime/server/api/preview-links.post.d.ts +3 -0
  275. package/dist/runtime/server/api/preview-links.post.js +17 -0
  276. package/dist/runtime/server/api/preview.get.d.ts +3 -0
  277. package/dist/runtime/server/api/preview.get.js +7 -0
  278. package/dist/runtime/server/api/redirect.delete.d.ts +4 -0
  279. package/dist/runtime/server/api/redirect.delete.js +10 -0
  280. package/dist/runtime/server/api/redirect.put.d.ts +3 -0
  281. package/dist/runtime/server/api/redirect.put.js +8 -0
  282. package/dist/runtime/server/api/redirects-import.post.d.ts +3 -0
  283. package/dist/runtime/server/api/redirects-import.post.js +13 -0
  284. package/dist/runtime/server/api/redirects.get.d.ts +3 -0
  285. package/dist/runtime/server/api/redirects.get.js +7 -0
  286. package/dist/runtime/server/api/redirects.post.d.ts +3 -0
  287. package/dist/runtime/server/api/redirects.post.js +7 -0
  288. package/dist/runtime/server/api/search.get.js +8 -3
  289. package/dist/runtime/server/api/settings.delete.js +2 -2
  290. package/dist/runtime/server/api/settings.get.js +4 -2
  291. package/dist/runtime/server/api/settings.put.js +2 -2
  292. package/dist/runtime/server/api/site.get.d.ts +3 -0
  293. package/dist/runtime/server/api/site.get.js +7 -0
  294. package/dist/runtime/server/api/site.put.d.ts +3 -0
  295. package/dist/runtime/server/api/site.put.js +16 -0
  296. package/dist/runtime/server/api/tags.get.js +3 -2
  297. package/dist/runtime/server/api/user.delete.js +8 -2
  298. package/dist/runtime/server/api/user.put.js +14 -4
  299. package/dist/runtime/server/api/users.get.js +2 -2
  300. package/dist/runtime/server/api/users.post.js +8 -4
  301. package/dist/runtime/server/middleware/hidden-site.d.ts +2 -0
  302. package/dist/runtime/server/middleware/hidden-site.js +8 -0
  303. package/dist/runtime/server/middleware/preview-links.d.ts +2 -0
  304. package/dist/runtime/server/middleware/preview-links.js +6 -0
  305. package/dist/runtime/server/middleware/redirects.d.ts +2 -0
  306. package/dist/runtime/server/middleware/redirects.js +18 -0
  307. package/dist/runtime/server/plugins/session-validate.js +4 -1
  308. package/dist/runtime/server/plugins/webhooks.d.ts +3 -0
  309. package/dist/runtime/server/plugins/webhooks.js +27 -0
  310. package/dist/runtime/server/routes/graphql.js +5 -3
  311. package/dist/runtime/server/routes/robots.d.ts +2 -0
  312. package/dist/runtime/server/routes/robots.js +16 -0
  313. package/dist/runtime/server/routes/sitemap.d.ts +2 -0
  314. package/dist/runtime/server/routes/sitemap.js +67 -0
  315. package/dist/runtime/server/utils/cached-value.d.ts +5 -0
  316. package/dist/runtime/server/utils/cached-value.js +24 -0
  317. package/dist/runtime/server/utils/content-routes.d.ts +5 -0
  318. package/dist/runtime/server/utils/content-routes.js +29 -0
  319. package/dist/runtime/server/utils/field-rules.d.ts +19 -0
  320. package/dist/runtime/server/utils/field-rules.js +72 -0
  321. package/dist/runtime/server/utils/graphql.d.ts +3 -1
  322. package/dist/runtime/server/utils/graphql.js +143 -28
  323. package/dist/runtime/server/utils/hooks.d.ts +14 -0
  324. package/dist/runtime/server/utils/hooks.js +71 -0
  325. package/dist/runtime/server/utils/import.d.ts +7 -2
  326. package/dist/runtime/server/utils/import.js +108 -14
  327. package/dist/runtime/server/utils/link-usage.d.ts +4 -0
  328. package/dist/runtime/server/utils/link-usage.js +28 -0
  329. package/dist/runtime/server/utils/media-references.d.ts +6 -1
  330. package/dist/runtime/server/utils/media-references.js +49 -20
  331. package/dist/runtime/server/utils/media-usage.d.ts +2 -0
  332. package/dist/runtime/server/utils/media-usage.js +5 -3
  333. package/dist/runtime/server/utils/page-rows.d.ts +2 -0
  334. package/dist/runtime/server/utils/page-rows.js +42 -29
  335. package/dist/runtime/server/utils/permissions.d.ts +14 -0
  336. package/dist/runtime/server/utils/permissions.js +43 -0
  337. package/dist/runtime/server/utils/presets.d.ts +18 -0
  338. package/dist/runtime/server/utils/presets.js +68 -0
  339. package/dist/runtime/server/utils/preview-links.d.ts +207 -0
  340. package/dist/runtime/server/utils/preview-links.js +161 -0
  341. package/dist/runtime/server/utils/redirects.d.ts +31 -0
  342. package/dist/runtime/server/utils/redirects.js +240 -0
  343. package/dist/runtime/server/utils/registry.js +4 -1
  344. package/dist/runtime/server/utils/relations.d.ts +8 -0
  345. package/dist/runtime/server/utils/relations.js +25 -6
  346. package/dist/runtime/server/utils/require-admin.d.ts +0 -1
  347. package/dist/runtime/server/utils/require-admin.js +4 -8
  348. package/dist/runtime/server/utils/search.d.ts +1 -0
  349. package/dist/runtime/server/utils/search.js +44 -19
  350. package/dist/runtime/server/utils/site.d.ts +23 -0
  351. package/dist/runtime/server/utils/site.js +79 -0
  352. package/dist/runtime/server/utils/sitemap.d.ts +12 -0
  353. package/dist/runtime/server/utils/sitemap.js +109 -0
  354. package/dist/runtime/server/utils/user-management.d.ts +4 -0
  355. package/dist/runtime/server/utils/user-management.js +20 -0
  356. package/dist/runtime/server/utils/users.d.ts +1 -1
  357. package/dist/runtime/server/utils/users.js +1 -1
  358. package/dist/runtime/server/utils/visibility.d.ts +1 -0
  359. package/dist/runtime/server/utils/visibility.js +6 -1
  360. package/dist/runtime/server/utils/webhooks.d.ts +24 -0
  361. package/dist/runtime/server/utils/webhooks.js +90 -0
  362. package/dist/runtime/shared/block-paths.d.ts +66 -0
  363. package/dist/runtime/shared/block-paths.js +310 -0
  364. package/dist/runtime/shared/block-picker.d.ts +18 -0
  365. package/dist/runtime/shared/block-picker.js +31 -0
  366. package/dist/runtime/shared/block-signature.d.ts +4 -0
  367. package/dist/runtime/shared/block-signature.js +46 -0
  368. package/dist/runtime/shared/clipboard.d.ts +31 -0
  369. package/dist/runtime/shared/clipboard.js +206 -0
  370. package/dist/runtime/shared/conditions.d.ts +36 -0
  371. package/dist/runtime/shared/conditions.js +100 -0
  372. package/dist/runtime/shared/content-routes.d.ts +42 -0
  373. package/dist/runtime/shared/content-routes.js +237 -0
  374. package/dist/runtime/shared/duplicate.js +2 -1
  375. package/dist/runtime/shared/editor-layout.d.ts +18 -0
  376. package/dist/runtime/shared/editor-layout.js +9 -0
  377. package/dist/runtime/shared/field-options.d.ts +21 -0
  378. package/dist/runtime/shared/field-options.js +90 -0
  379. package/dist/runtime/shared/graphql-sdl.d.ts +1 -0
  380. package/dist/runtime/shared/graphql-sdl.js +50 -26
  381. package/dist/runtime/shared/history.d.ts +27 -0
  382. package/dist/runtime/shared/history.js +123 -0
  383. package/dist/runtime/shared/hooks.d.ts +45 -0
  384. package/dist/runtime/shared/hooks.js +28 -0
  385. package/dist/runtime/shared/index.d.ts +90 -21
  386. package/dist/runtime/shared/index.js +121 -37
  387. package/dist/runtime/shared/inline-text.d.ts +38 -0
  388. package/dist/runtime/shared/inline-text.js +85 -0
  389. package/dist/runtime/shared/layout.d.ts +2 -1
  390. package/dist/runtime/shared/layout.js +3 -0
  391. package/dist/runtime/shared/links.d.ts +48 -0
  392. package/dist/runtime/shared/links.js +155 -0
  393. package/dist/runtime/shared/list-filters.d.ts +2 -0
  394. package/dist/runtime/shared/list-filters.js +2 -0
  395. package/dist/runtime/shared/media-focal.d.ts +30 -0
  396. package/dist/runtime/shared/media-focal.js +52 -0
  397. package/dist/runtime/shared/migrations-dir.d.ts +14 -0
  398. package/dist/runtime/shared/migrations-dir.js +48 -2
  399. package/dist/runtime/shared/presets.d.ts +67 -0
  400. package/dist/runtime/shared/presets.js +127 -0
  401. package/dist/runtime/shared/preview-links.d.ts +64 -0
  402. package/dist/runtime/shared/preview-links.js +54 -0
  403. package/dist/runtime/shared/preview.d.ts +124 -21
  404. package/dist/runtime/shared/preview.js +419 -81
  405. package/dist/runtime/shared/redirects.d.ts +75 -0
  406. package/dist/runtime/shared/redirects.js +230 -0
  407. package/dist/runtime/shared/roles.d.ts +57 -0
  408. package/dist/runtime/shared/roles.js +293 -0
  409. package/dist/runtime/shared/save-state.d.ts +8 -0
  410. package/dist/runtime/shared/save-state.js +15 -0
  411. package/dist/runtime/shared/search.d.ts +16 -1
  412. package/dist/runtime/shared/search.js +41 -7
  413. package/dist/runtime/shared/seo.d.ts +167 -0
  414. package/dist/runtime/shared/seo.js +335 -0
  415. package/dist/runtime/shared/transfer.js +2 -1
  416. package/dist/runtime/shared/translations.d.ts +29 -0
  417. package/dist/runtime/shared/translations.js +123 -0
  418. package/dist/runtime/shared/users.d.ts +1 -1
  419. package/dist/runtime/shared/validation.d.ts +23 -1
  420. package/dist/runtime/shared/validation.js +214 -64
  421. package/dist/runtime/webhooks.d.ts +33 -0
  422. package/dist/runtime/webhooks.js +57 -0
  423. package/dist/types.d.mts +5 -1
  424. package/package.json +6 -2
  425. package/dist/runtime/app/components/cms/BlockOutline.vue +0 -88
  426. package/dist/runtime/app/components/cms/BlockPalette.vue +0 -31
  427. package/dist/runtime/app/components/cms/SettingsModal.d.vue.ts +0 -12
  428. package/dist/runtime/app/components/cms/SettingsModal.vue +0 -126
  429. package/dist/runtime/app/components/cms/SettingsModal.vue.d.ts +0 -12
  430. package/dist/runtime/app/composables/cms-field-focus.d.ts +0 -4
  431. package/dist/runtime/app/composables/cms-field-focus.js +0 -20
@@ -1,268 +1,122 @@
1
1
  <template>
2
- <KAlert
2
+ <CmsSettingsUserCreate v-if="isNew" @created="onCreated" />
3
+ <CmsSettingsUserDetail
4
+ v-else-if="page && current"
5
+ :key="current.id"
6
+ :account="current"
7
+ @updated="store.upsert"
8
+ />
9
+ <KSkeletonForm v-else-if="page && !store.loaded.value" :fields="3" />
10
+ <KRecordList
11
+ v-else
12
+ :items="items"
13
+ :loading="!store.loaded.value"
14
+ avatar
15
+ label="Users"
16
+ :empty-icon="cmsIcon('users')"
17
+ empty-text="No users yet"
18
+ empty-description="Add a user to give someone access to the panel."
19
+ @row-click="(item2) => open(item2.account)"
20
+ >
21
+ <template #leading="{ item }">
22
+ <KAvatar :name="item.title" decorative />
23
+ </template>
24
+ <template #action="{ item }">
25
+ <KButton
26
+ :icon="cmsIcon(canManageUser(item.account) ? 'pencil' : 'eye')"
27
+ variant="ghost"
28
+ tone="neutral"
29
+ size="sm"
30
+ square
31
+ :aria-label="canManageUser(item.account) ? 'Edit' : 'View'"
32
+ @click="open(item.account)"
33
+ />
34
+ </template>
35
+ <template #empty-actions>
36
+ <CmsSettingsEmptyAdd
37
+ label="Add user"
38
+ new-label="New user"
39
+ icon="user-plus"
40
+ @open="emit('open', $event)"
41
+ />
42
+ </template>
43
+ </KRecordList>
44
+ <KModal
3
45
  v-if="created"
4
- tone="accent"
5
- role="status"
6
- :icon="cmsIcon('key')"
7
- :title="created.title"
8
- class="cms-credentials-alert"
46
+ v-model:open="createdOpen"
47
+ size="sm"
48
+ title="User created"
49
+ description="Share these credentials with the user. The password does not show again."
9
50
  >
10
- <p>Share these credentials with the user. The password does not show again.</p>
11
51
  <KDescriptionList
12
52
  :items="[
13
53
  { key: 'email', label: 'Email', value: created.email },
14
54
  { key: 'password', label: 'Password', value: created.password }
15
55
  ]"
16
- :divided="false"
17
- class="cms-credentials-items"
18
56
  >
19
57
  <template #value-password="{ item }">
20
58
  <span class="k-mono">{{ item.value }}</span>
21
59
  </template>
22
60
  </KDescriptionList>
23
- <template #actions>
61
+ <template #footer>
24
62
  <KCopyButton
63
+ variant="soft"
64
+ tone="neutral"
25
65
  :value="`Email: ${created.email}
26
66
  Password: ${created.password}`"
27
67
  label="Copy credentials"
28
68
  copied-label="Copied"
29
69
  show-label
30
- variant="soft"
31
- tone="accent"
32
70
  />
33
- <KButton label="Done" size="sm" @click="created = null" />
71
+ <KButton variant="ghost" tone="neutral" @click="createdOpen = false">Done</KButton>
34
72
  </template>
35
- </KAlert>
36
-
37
- <KCard v-if="creating" variant="subtle" title="New user" class="cms-user-create">
38
- <KForm :form="draft">
39
- <KGrid :columns="2">
40
- <KFormField label="Email" name="email" required>
41
- <KInput
42
- v-model="draft.values.email"
43
- type="email"
44
- :icon="cmsIcon('envelope')"
45
- placeholder="name@example.com"
46
- autocomplete="off"
47
- />
48
- </KFormField>
49
- <KFormField label="Name" name="name">
50
- <KInput v-model="draft.values.name" placeholder="Optional" autocomplete="off" />
51
- </KFormField>
52
- </KGrid>
53
- <KFormField label="Password" name="password" required>
54
- <KPasswordInput
55
- v-model="draft.values.password"
56
- icon="key"
57
- autocomplete="new-password"
58
- :generate="generatePassword"
59
- copy
60
- />
61
- </KFormField>
62
- <KStack direction="row" justify="end" gap="sm">
63
- <KButton label="Cancel" variant="ghost" tone="neutral" size="sm" @click="cancel" />
64
- <KButton
65
- type="submit"
66
- label="Create user"
67
- size="sm"
68
- :disabled="
69
- !draft.values.email || (draft.values.password ?? '').length < MIN_PASSWORD_LENGTH
70
- "
71
- />
72
- </KStack>
73
- </KForm>
74
- </KCard>
75
-
76
- <KSpinner v-if="loading" />
77
-
78
- <ul v-else-if="users.length" class="cms-user-list">
79
- <li v-for="account in users" :key="account.id" class="cms-user-row">
80
- <div class="cms-user-main">
81
- <KAvatar :name="account.name || account.email" size="sm" decorative />
82
- <div class="cms-user-text">
83
- <span class="cms-user-name">{{ account.name || account.email }}</span>
84
- <span class="cms-user-meta">
85
- {{ account.name ? `${account.email} \xB7 ` : "" }}{{ lastLogin(account) }}
86
- </span>
87
- </div>
88
- <KStack direction="row" gap="none">
89
- <KButton
90
- :icon="cmsIcon('key')"
91
- variant="ghost"
92
- tone="neutral"
93
- size="sm"
94
- title="Set a new password"
95
- aria-label="Set a new password"
96
- @click="startReset(account)"
97
- />
98
- <KButton
99
- :icon="cmsIcon('trash')"
100
- variant="ghost"
101
- tone="danger"
102
- size="sm"
103
- title="Delete user"
104
- aria-label="Delete user"
105
- @click="remove(account)"
106
- />
107
- </KStack>
108
- </div>
109
- <KForm v-if="resetting === account.id" :form="reset" class="cms-user-reset">
110
- <KFormField label="New password" name="password">
111
- <KPasswordInput
112
- v-model="reset.values.password"
113
- icon="key"
114
- autocomplete="new-password"
115
- :generate="generatePassword"
116
- copy
117
- />
118
- </KFormField>
119
- <KStack direction="row" justify="end" gap="sm">
120
- <KButton
121
- label="Cancel"
122
- variant="ghost"
123
- tone="neutral"
124
- size="sm"
125
- @click="resetting = null"
126
- />
127
- <KButton
128
- type="submit"
129
- label="Set password"
130
- size="sm"
131
- :disabled="(reset.values.password ?? '').length < MIN_PASSWORD_LENGTH"
132
- />
133
- </KStack>
134
- </KForm>
135
- </li>
136
- </ul>
137
-
138
- <KEmptyState
139
- v-else-if="!creating"
140
- :icon="cmsIcon('users')"
141
- title="No users yet"
142
- description="Add a user to give someone access to the panel."
143
- />
73
+ </KModal>
144
74
  </template>
145
75
 
146
76
  <script setup>
147
- import { MIN_PASSWORD_LENGTH } from "#nuxt-cms";
148
77
  import {
149
- Alert as KAlert,
150
78
  Avatar as KAvatar,
151
79
  Button as KButton,
152
- Card as KCard,
153
80
  CopyButton as KCopyButton,
154
81
  DescriptionList as KDescriptionList,
155
- EmptyState as KEmptyState,
156
- Form as KForm,
157
- FormField as KFormField,
158
- Grid as KGrid,
159
- Input as KInput,
160
- PasswordInput as KPasswordInput,
161
- Spinner as KSpinner,
162
- Stack as KStack,
163
- useForm
82
+ Modal as KModal,
83
+ RecordList as KRecordList,
84
+ SkeletonForm as KSkeletonForm
164
85
  } from "@xleddyl/443-components-vue";
165
- import { onMounted, ref, watch } from "#imports";
166
- import { generatePassword } from "../../composables/cms-account";
167
- import { useCmsConfirm } from "../../composables/cms-confirm";
168
- import { useCmsToast } from "../../composables/cms-toast";
169
- import { cmsApi } from "../../utils/api";
170
- import { cmsIcon, errorMessage } from "../../utils/ui";
171
- const toast = useCmsToast();
172
- const confirmAction = useCmsConfirm();
173
- const creating = defineModel("creating", { type: Boolean, ...{ default: false } });
174
- const users = ref([]);
175
- const loading = ref(true);
176
- async function load() {
177
- try {
178
- users.value = await cmsApi("/api/cms/users");
179
- } catch (error) {
180
- toast.add({ title: "Could not load users", description: errorMessage(error), color: "error" });
181
- } finally {
182
- loading.value = false;
183
- }
184
- }
185
- onMounted(load);
186
- function lastLogin(account) {
187
- if (!account.lastLoginAt) return "Never signed in";
188
- return `Last sign-in ${new Date(account.lastLoginAt).toLocaleString(void 0, {
189
- dateStyle: "medium",
190
- timeStyle: "short"
191
- })}`;
192
- }
193
- const created = ref(null);
194
- const draft = useForm({
195
- schema: {
196
- email: { initial: () => "" },
197
- name: { initial: () => "" },
198
- password: { initial: () => "" }
199
- },
200
- onSubmit: create
201
- });
202
- watch(
203
- creating,
204
- (value) => {
205
- if (!value) return;
206
- created.value = null;
207
- draft.reset({ email: "", name: "", password: generatePassword() });
208
- },
209
- { immediate: true }
210
- );
211
- function cancel() {
212
- creating.value = false;
213
- }
214
- async function create() {
215
- const password = draft.values.password ?? "";
216
- try {
217
- const account = await cmsApi("/api/cms/users", {
218
- method: "POST",
219
- body: {
220
- email: String(draft.values.email ?? ""),
221
- name: draft.values.name ? String(draft.values.name) : null,
222
- password
223
- }
224
- });
225
- users.value = [...users.value, account];
226
- created.value = { title: "User created", email: account.email, password };
227
- creating.value = false;
228
- } catch (error) {
229
- draft.setError("", errorMessage(error) ?? "User not created.");
230
- }
231
- }
232
- const resetting = ref(null);
233
- const reset = useForm({
234
- schema: { password: { initial: () => "" } },
235
- onSubmit: () => {
236
- const account = users.value.find((candidate) => candidate.id === resetting.value);
237
- return account ? saveReset(account) : void 0;
238
- }
86
+ import { computed, onMounted, ref } from "#imports";
87
+ import { CMS_NEW_RECORD } from "../../composables/cms-route";
88
+ import { useCmsPermissions } from "../../composables/cms-permissions";
89
+ import { useCmsUsers } from "../../composables/cms-settings-stores";
90
+ import { cmsIcon } from "../../utils/ui";
91
+ import { lastSignIn, roleBadge } from "../../utils/users";
92
+ const props = defineProps({
93
+ page: { type: Object, required: false }
239
94
  });
240
- function startReset(account) {
241
- reset.reset({ password: generatePassword() });
242
- resetting.value = resetting.value === account.id ? null : account.id;
243
- }
244
- async function saveReset(account) {
245
- const password = reset.values.password ?? "";
246
- try {
247
- const updated = await cmsApi(`/api/cms/users/${account.id}`, {
248
- method: "PUT",
249
- body: { password }
250
- });
251
- users.value = users.value.map((u) => u.id === updated.id ? updated : u);
252
- created.value = { title: "Password changed", email: account.email, password };
253
- resetting.value = null;
254
- } catch (error) {
255
- toast.add({ title: "Password not changed", description: errorMessage(error), color: "error" });
256
- }
95
+ const emit = defineEmits(["open", "back"]);
96
+ const store = useCmsUsers();
97
+ const { canManageUser } = store;
98
+ const { roleOptions, roleLabel } = useCmsPermissions();
99
+ onMounted(store.load);
100
+ const isNew = computed(() => props.page?.id === CMS_NEW_RECORD);
101
+ const current = computed(() => store.find(props.page?.id));
102
+ const created = ref(null);
103
+ const createdOpen = ref(false);
104
+ function open(account) {
105
+ emit("open", { id: account.id, label: store.label(account) });
257
106
  }
258
- async function remove(account) {
259
- if (!await confirmAction(`Delete ${account.email}? They lose access to the panel.`)) return;
260
- try {
261
- await cmsApi(`/api/cms/users/${account.id}`, { method: "DELETE" });
262
- users.value = users.value.filter((u) => u.id !== account.id);
263
- toast.add({ title: "User deleted", color: "success" });
264
- } catch (error) {
265
- toast.add({ title: "User not deleted", description: errorMessage(error), color: "error" });
266
- }
107
+ function onCreated(account, password) {
108
+ store.upsert(account);
109
+ created.value = { email: account.email, password };
110
+ createdOpen.value = true;
111
+ emit("back");
267
112
  }
113
+ const items = computed(
114
+ () => store.items.value.map((account) => ({
115
+ id: account.id,
116
+ account,
117
+ title: account.name || account.email,
118
+ description: `${account.name ? `${account.email} \xB7 ` : ""}${lastSignIn(account)}`,
119
+ badge: roleBadge(account.role, roleOptions, roleLabel)
120
+ }))
121
+ );
268
122
  </script>
@@ -1,10 +1,13 @@
1
- type __VLS_ModelProps = {
2
- 'creating'?: boolean;
1
+ import type { SettingsModalPage } from '@xleddyl/443-components-vue';
2
+ type __VLS_Props = {
3
+ page?: SettingsModalPage;
3
4
  };
4
- declare const __VLS_export: import("vue").DefineComponent<__VLS_ModelProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
5
- "update:creating": (value: boolean) => any;
6
- }, string, import("vue").PublicProps, Readonly<__VLS_ModelProps> & Readonly<{
7
- "onUpdate:creating"?: ((value: boolean) => any) | undefined;
5
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
6
+ open: (page: SettingsModalPage) => any;
7
+ back: () => any;
8
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
9
+ onOpen?: ((page: SettingsModalPage) => any) | undefined;
10
+ onBack?: (() => any) | undefined;
8
11
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
9
12
  declare const _default: typeof __VLS_export;
10
13
  export default _default;
@@ -0,0 +1,18 @@
1
+ type __VLS_Props = {
2
+ entryName: string;
3
+ itemId: string;
4
+ dirty: boolean;
5
+ locale?: string;
6
+ save: () => Promise<boolean>;
7
+ };
8
+ type __VLS_ModelProps = {
9
+ 'open': boolean;
10
+ };
11
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
12
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
13
+ "update:open": (value: boolean) => any;
14
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
15
+ "onUpdate:open"?: ((value: boolean) => any) | undefined;
16
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
17
+ declare const _default: typeof __VLS_export;
18
+ export default _default;
@@ -0,0 +1,219 @@
1
+ <template>
2
+ <KModal
3
+ v-model:open="open"
4
+ title="Share preview"
5
+ description="Anyone with the link can see the saved version of this item on the site, even while it is a draft or scheduled. No account needed. Changes you save later show up in the link too; unsaved changes never do."
6
+ size="md"
7
+ >
8
+ <KStack gap="lg">
9
+ <KAlert
10
+ v-if="dirty"
11
+ tone="warning"
12
+ role="status"
13
+ title="Unsaved changes"
14
+ description="The link shows the last saved version. Save first to share your latest edits."
15
+ />
16
+
17
+ <KAlert
18
+ v-if="created"
19
+ tone="accent"
20
+ role="status"
21
+ :icon="cmsIcon('link')"
22
+ title="Link ready"
23
+ >
24
+ <KStack gap="sm">
25
+ <span>Copy it now: for security it is stored hashed and does not show again.</span>
26
+ <KInput :model-value="created" readonly aria-label="Preview link" class="k-mono" />
27
+ </KStack>
28
+ <template #actions>
29
+ <KCopyButton
30
+ :value="created"
31
+ label="Copy link"
32
+ copied-label="Copied"
33
+ show-label
34
+ variant="soft"
35
+ tone="accent"
36
+ />
37
+ <KButton label="Done" size="sm" @click="created = null" />
38
+ </template>
39
+ </KAlert>
40
+
41
+ <KStack gap="md">
42
+ <KGrid :columns="i18n.locales.length > 1 ? 2 : 1">
43
+ <KFormField label="Expires after">
44
+ <KSegmentedControl
45
+ v-model="duration"
46
+ :options="durationOptions"
47
+ size="sm"
48
+ required
49
+ />
50
+ </KFormField>
51
+ <KFormField v-if="i18n.locales.length > 1" label="Language">
52
+ <KSelect v-model="locale" :options="localeOptions" />
53
+ </KFormField>
54
+ </KGrid>
55
+ <KStack direction="row" justify="end" gap="sm">
56
+ <KButton
57
+ v-if="dirty"
58
+ label="Save and create link"
59
+ size="sm"
60
+ :loading="busy"
61
+ @click="saveAndCreate"
62
+ />
63
+ <KButton
64
+ :label="dirty ? 'Create link from saved version' : 'Create link'"
65
+ size="sm"
66
+ :variant="dirty ? 'soft' : 'solid'"
67
+ :tone="dirty ? 'neutral' : 'accent'"
68
+ :loading="busy"
69
+ @click="create"
70
+ />
71
+ </KStack>
72
+ </KStack>
73
+
74
+ <KStack gap="sm">
75
+ <span class="k-label">Active links</span>
76
+ <KRecordList
77
+ :items="linkItems"
78
+ :loading="loading"
79
+ :skeleton-rows="2"
80
+ label="Active links"
81
+ empty-text="No active links for this item."
82
+ empty-variant="hint"
83
+ >
84
+ <template #action="{ item }">
85
+ <KButton
86
+ label="Revoke"
87
+ variant="ghost"
88
+ tone="danger"
89
+ size="sm"
90
+ @click="revokeById(item.id)"
91
+ />
92
+ </template>
93
+ </KRecordList>
94
+ </KStack>
95
+ </KStack>
96
+ </KModal>
97
+ </template>
98
+
99
+ <script setup>
100
+ import { DEFAULT_PREVIEW_LINK_DURATION, PREVIEW_LINK_DURATIONS } from "#nuxt-cms";
101
+ import {
102
+ Alert as KAlert,
103
+ Button as KButton,
104
+ CopyButton as KCopyButton,
105
+ FormField as KFormField,
106
+ Grid as KGrid,
107
+ Input as KInput,
108
+ Modal as KModal,
109
+ RecordList as KRecordList,
110
+ SegmentedControl as KSegmentedControl,
111
+ Select as KSelect,
112
+ Stack as KStack,
113
+ toast
114
+ } from "@xleddyl/443-components-vue";
115
+ import { computed, ref, watch } from "#imports";
116
+ import { useCmsConfirm } from "../../composables/cms-confirm";
117
+ import { useCmsRuntime } from "../../composables/cms-runtime";
118
+ import { cmsApi } from "../../utils/api";
119
+ import { cmsIcon, errorMessage } from "../../utils/ui";
120
+ const props = defineProps({
121
+ entryName: { type: String, required: true },
122
+ itemId: { type: String, required: true },
123
+ dirty: { type: Boolean, required: true },
124
+ locale: { type: String, required: false },
125
+ save: { type: Function, required: true }
126
+ });
127
+ const open = defineModel("open", { type: Boolean, ...{ required: true } });
128
+ const { i18n } = useCmsRuntime();
129
+ const confirmAction = useCmsConfirm();
130
+ const durationOptions = PREVIEW_LINK_DURATIONS.map(({ value, label }) => ({ value, label }));
131
+ const localeOptions = i18n.locales.map((code) => ({ value: code, label: code.toUpperCase() }));
132
+ const duration = ref(DEFAULT_PREVIEW_LINK_DURATION);
133
+ const locale = ref(props.locale ?? i18n.defaultLocale);
134
+ const links = ref([]);
135
+ const loading = ref(false);
136
+ const busy = ref(false);
137
+ const created = ref(null);
138
+ const endpoint = () => `/api/cms/preview-links/${encodeURIComponent(props.entryName)}/${encodeURIComponent(
139
+ props.itemId
140
+ )}`;
141
+ function formatDate(value) {
142
+ return new Date(value).toLocaleString(void 0, { dateStyle: "medium", timeStyle: "short" });
143
+ }
144
+ async function load() {
145
+ loading.value = true;
146
+ try {
147
+ links.value = await cmsApi(endpoint());
148
+ } catch (error) {
149
+ links.value = [];
150
+ toast.error("Could not load the preview links", { description: errorMessage(error) });
151
+ } finally {
152
+ loading.value = false;
153
+ }
154
+ }
155
+ watch(open, (value) => {
156
+ if (!value) {
157
+ created.value = null;
158
+ return;
159
+ }
160
+ locale.value = props.locale ?? i18n.defaultLocale;
161
+ void load();
162
+ });
163
+ async function copy(url) {
164
+ try {
165
+ await navigator.clipboard.writeText(url);
166
+ toast.success("Link copied");
167
+ } catch {
168
+ toast.success("Link created", { description: "Copy it from the box." });
169
+ }
170
+ }
171
+ async function create() {
172
+ busy.value = true;
173
+ try {
174
+ const result = await cmsApi(endpoint(), {
175
+ method: "POST",
176
+ body: { duration: duration.value, locale: i18n.locales.length ? locale.value : null }
177
+ });
178
+ created.value = new URL(result.url, window.location.origin).href;
179
+ links.value = [...links.value, result.link].sort(
180
+ (a, b) => a.expiresAt.localeCompare(b.expiresAt)
181
+ );
182
+ await copy(created.value);
183
+ } catch (error) {
184
+ toast.error("Could not create the link", { description: errorMessage(error) });
185
+ } finally {
186
+ busy.value = false;
187
+ }
188
+ }
189
+ async function saveAndCreate() {
190
+ if (await props.save()) await create();
191
+ }
192
+ const linkItems = computed(
193
+ () => links.value.map((link) => ({
194
+ id: link.id,
195
+ title: link.path,
196
+ description: `Expires ${formatDate(link.expiresAt)}${link.createdBy ? ` \xB7 by ${link.createdBy}` : ""}`,
197
+ badge: i18n.locales.length > 1 && link.locale ? { label: link.locale } : void 0
198
+ }))
199
+ );
200
+ function revokeById(id) {
201
+ const link = links.value.find((item) => item.id === id);
202
+ if (link) void revoke(link);
203
+ }
204
+ async function revoke(link) {
205
+ if (!await confirmAction({
206
+ title: "Revoke this link?",
207
+ description: `The link to ${link.path} stops working right away.`,
208
+ confirmLabel: "Revoke"
209
+ }))
210
+ return;
211
+ try {
212
+ await cmsApi(`${endpoint()}/${encodeURIComponent(link.id)}`, { method: "DELETE" });
213
+ links.value = links.value.filter((item) => item.id !== link.id);
214
+ toast.success("Link revoked");
215
+ } catch (error) {
216
+ toast.error("Revoke failed", { description: errorMessage(error) });
217
+ }
218
+ }
219
+ </script>
@@ -0,0 +1,18 @@
1
+ type __VLS_Props = {
2
+ entryName: string;
3
+ itemId: string;
4
+ dirty: boolean;
5
+ locale?: string;
6
+ save: () => Promise<boolean>;
7
+ };
8
+ type __VLS_ModelProps = {
9
+ 'open': boolean;
10
+ };
11
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
12
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
13
+ "update:open": (value: boolean) => any;
14
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
15
+ "onUpdate:open"?: ((value: boolean) => any) | undefined;
16
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
17
+ declare const _default: typeof __VLS_export;
18
+ export default _default;
@@ -16,7 +16,7 @@
16
16
  variant="ghost"
17
17
  tone="neutral"
18
18
  aria-label="Regenerate slug"
19
- title="Regenerate slug"
19
+ :disabled="disabled"
20
20
  @click="regenerate"
21
21
  />
22
22
  </template>
@@ -24,22 +24,24 @@
24
24
  </template>
25
25
 
26
26
  <script setup>
27
- import { Button as KButton, Input as KInput } from "@xleddyl/443-components-vue";
27
+ import { Button as KButton, Input as KInput, useFieldControl } from "@xleddyl/443-components-vue";
28
28
  import { ref, watch } from "#imports";
29
29
  import { slugify } from "#nuxt-cms";
30
30
  const props = defineProps({
31
31
  source: { type: [String, null], required: false }
32
32
  });
33
33
  const model = defineModel({ type: [String, null], ...{ required: true } });
34
+ const { disabled } = useFieldControl();
34
35
  const touched = ref(!!model.value);
35
36
  watch(
36
37
  () => props.source,
37
38
  (value) => {
38
- if (touched.value) return;
39
+ if (touched.value || disabled.value) return;
39
40
  model.value = value ? slugify(value) : null;
40
41
  }
41
42
  );
42
43
  function regenerate() {
44
+ if (disabled.value) return;
43
45
  model.value = props.source ? slugify(props.source) : null;
44
46
  touched.value = false;
45
47
  }