@kodacms/admin 0.0.0-stage → 0.1.2

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 (503) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/LICENSE +21 -0
  3. package/README.md +93 -2
  4. package/design-tokens/kodacms.tokens.json +1360 -0
  5. package/dist/apple-touch-icon.png +0 -0
  6. package/dist/assets/AuditView-DCgrAjma.js +1 -0
  7. package/dist/assets/CollectionView-CY3zK1CE.js +1 -0
  8. package/dist/assets/CustomComponent-B1mxHHd0.js +1 -0
  9. package/dist/assets/CustomPageView-BTsy9MC8.js +1 -0
  10. package/dist/assets/DashboardView-ujWhLuS2.js +1 -0
  11. package/dist/assets/DeleteDocumentsDialog-D1nx27UG.js +1 -0
  12. package/dist/assets/DocumentHistoryView-Ko633-Dy.js +1 -0
  13. package/dist/assets/DocumentView-CPEjwzzo.js +1 -0
  14. package/dist/assets/GlobalHistoryView-CbwdeYpn.js +1 -0
  15. package/dist/assets/GlobalView-DcTGexxK.js +1 -0
  16. package/dist/assets/KAlert-DoR81cyQ.js +1 -0
  17. package/dist/assets/KCard-DNom764U.js +1 -0
  18. package/dist/assets/KDropdownMenu-BECk5S9K.js +1 -0
  19. package/dist/assets/KField-CvINPmYu.js +1 -0
  20. package/dist/assets/KPagination-DQOzrRaf.js +1 -0
  21. package/dist/assets/KPasswordInput-EPBXvtXG.js +1 -0
  22. package/dist/assets/KSeparator-DEbXnpDV.js +1 -0
  23. package/dist/assets/KTableRow-Dpp2Lk2V.js +1 -0
  24. package/dist/assets/KTabs-b95D7hep.js +1 -0
  25. package/dist/assets/KTextarea-CCveuS_I.js +1 -0
  26. package/dist/assets/Label-m9Ig3v9B.js +1 -0
  27. package/dist/assets/ListFooter-qYmCWY4R.js +1 -0
  28. package/dist/assets/LoadError-BRccywgs.js +1 -0
  29. package/dist/assets/LoginView-DvTtEJxp.js +1 -0
  30. package/dist/assets/NoAccessView-Bg69btHE.js +1 -0
  31. package/dist/assets/NotFoundView-qhJ2ixSH.js +1 -0
  32. package/dist/assets/PageHeader-B3riLtJg.js +1 -0
  33. package/dist/assets/PopoverAnchor-BwL6g4vt.js +1 -0
  34. package/dist/assets/PopoverContentImpl-Dq0cbuHV.js +1 -0
  35. package/dist/assets/PopoverContentModal-BEl8rmbI.js +1 -0
  36. package/dist/assets/PopoverContentNonModal-D5osgtpx.js +1 -0
  37. package/dist/assets/RoleView-D9732bW6.js +1 -0
  38. package/dist/assets/RolesView-Du4NUhQJ.js +1 -0
  39. package/dist/assets/TooltipContentHoverable-C18vbtIU.js +1 -0
  40. package/dist/assets/TooltipContentImpl-CCpG79EA.js +1 -0
  41. package/dist/assets/TooltipContentImpl-DQFjU6ri.js +1 -0
  42. package/dist/assets/UploadQueueItem-BbG5x7WM.js +6 -0
  43. package/dist/assets/UserView-iFK1eFT9.js +1 -0
  44. package/dist/assets/UsersView-B6fCtC-4.js +1 -0
  45. package/dist/assets/columns-DmJOzXV9.js +1 -0
  46. package/dist/assets/ellipsis-BNwYKZMS.js +1 -0
  47. package/dist/assets/error-text-1F8qU3pC.js +1 -0
  48. package/dist/assets/eye-DyBObYiE.js +1 -0
  49. package/dist/assets/eye-off-Bd_6erac.js +1 -0
  50. package/dist/assets/form-layout-Dk2JVUC0.js +1 -0
  51. package/dist/assets/globals-BMIQQR5f.js +1 -0
  52. package/dist/assets/index-CGdQZeTs.css +2 -0
  53. package/dist/assets/index-a4P44W6e.js +14 -0
  54. package/dist/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2 +0 -0
  55. package/dist/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2 +0 -0
  56. package/dist/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2 +0 -0
  57. package/dist/assets/inter-greek-wght-normal-CkhJZR-_.woff2 +0 -0
  58. package/dist/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2 +0 -0
  59. package/dist/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
  60. package/dist/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2 +0 -0
  61. package/dist/assets/jetbrains-mono-cyrillic-ext-wght-normal-EocZY2iu.woff2 +0 -0
  62. package/dist/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
  63. package/dist/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
  64. package/dist/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
  65. package/dist/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
  66. package/dist/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
  67. package/dist/assets/list-query-DcmvyLSO.js +1 -0
  68. package/dist/assets/rolldown-runtime-P3Pd_6ND.js +1 -0
  69. package/dist/assets/select-options-osOjd-zR.js +1 -0
  70. package/dist/assets/useAuditState-D6n8HXQ2.js +1 -0
  71. package/dist/assets/useDebounced-BVo96C1E.js +1 -0
  72. package/dist/assets/useHistoryLocale-BWBBUuQi.js +1 -0
  73. package/dist/assets/useListState-CTgxjU_g.js +1 -0
  74. package/dist/assets/useLocaleDocument-DkvwSG3X.js +1 -0
  75. package/dist/assets/usePageHeader-wYdFq9cQ.js +1 -0
  76. package/dist/assets/useRoleDelete-DFwroHOv.js +1 -0
  77. package/dist/assets/useSaveShortcut-DFNu_TAL.js +1 -0
  78. package/dist/assets/useUserDelete-83wa7pqC.js +1 -0
  79. package/dist/assets/useUsersAccess-1yVnzExk.js +1 -0
  80. package/dist/assets/users-NiowxtJB.js +1 -0
  81. package/dist/assets/validate-CEcXMakk.js +1 -0
  82. package/dist/favicon.svg +12 -0
  83. package/dist/index.html +16 -0
  84. package/dist/koda-components.json +4 -0
  85. package/index.html +15 -0
  86. package/package.json +68 -4
  87. package/public/apple-touch-icon.png +0 -0
  88. package/public/favicon.svg +12 -0
  89. package/src/App.vue +17 -0
  90. package/src/api/access.ts +110 -0
  91. package/src/api/admin-config.ts +318 -0
  92. package/src/api/admin-fields.ts +557 -0
  93. package/src/api/admin-layout.ts +191 -0
  94. package/src/api/api-error.ts +78 -0
  95. package/src/api/audit.ts +170 -0
  96. package/src/api/client.ts +153 -0
  97. package/src/api/documents.ts +470 -0
  98. package/src/api/drafts.ts +115 -0
  99. package/src/api/error-text.ts +11 -0
  100. package/src/api/globals.ts +133 -0
  101. package/src/api/http.ts +24 -0
  102. package/src/api/locale.ts +48 -0
  103. package/src/api/permissions.ts +194 -0
  104. package/src/api/relations.ts +86 -0
  105. package/src/api/roles.ts +170 -0
  106. package/src/api/scopes.ts +91 -0
  107. package/src/api/search-query.ts +33 -0
  108. package/src/api/search.ts +39 -0
  109. package/src/api/types.ts +39 -0
  110. package/src/api/upload.ts +146 -0
  111. package/src/api/users.ts +88 -0
  112. package/src/api/versions.ts +206 -0
  113. package/src/api/where-query.ts +79 -0
  114. package/src/audit/AuditActionBadge.vue +13 -0
  115. package/src/audit/AuditActor.vue +34 -0
  116. package/src/audit/AuditCard.vue +68 -0
  117. package/src/audit/AuditDrawer.vue +86 -0
  118. package/src/audit/AuditDrawerActions.vue +70 -0
  119. package/src/audit/AuditEntryBody.vue +74 -0
  120. package/src/audit/AuditEntryChanges.vue +88 -0
  121. package/src/audit/AuditEntryFacts.vue +47 -0
  122. package/src/audit/AuditFilterBar.vue +55 -0
  123. package/src/audit/AuditFilterControls.vue +148 -0
  124. package/src/audit/AuditFiltersDrawer.vue +46 -0
  125. package/src/audit/AuditHistory.vue +136 -0
  126. package/src/audit/AuditList.vue +183 -0
  127. package/src/audit/AuditListStates.vue +70 -0
  128. package/src/audit/AuditRestoredVersion.vue +66 -0
  129. package/src/audit/AuditSearch.vue +40 -0
  130. package/src/audit/AuditTable.vue +116 -0
  131. package/src/audit/HistoryTabs.vue +48 -0
  132. package/src/audit/audit-changes.ts +161 -0
  133. package/src/audit/audit-filters.ts +152 -0
  134. package/src/audit/audit-view.ts +372 -0
  135. package/src/audit/useAuditContext.ts +23 -0
  136. package/src/audit/useAuditFilterOptions.ts +67 -0
  137. package/src/audit/useAuditState.ts +82 -0
  138. package/src/brand/KodaMark.vue +42 -0
  139. package/src/composables/useAccessView.ts +120 -0
  140. package/src/composables/useDebounced.ts +15 -0
  141. package/src/composables/usePageHeader.ts +20 -0
  142. package/src/composables/useSessionCacheReset.ts +23 -0
  143. package/src/composables/useTheme.ts +79 -0
  144. package/src/composables/useUsersAccess.ts +13 -0
  145. package/src/custom/CustomComponent.vue +103 -0
  146. package/src/custom/CustomComponentNotice.vue +71 -0
  147. package/src/custom/CustomInserts.vue +36 -0
  148. package/src/custom/component-name.ts +18 -0
  149. package/src/custom/error-info.ts +22 -0
  150. package/src/custom/form-context.ts +44 -0
  151. package/src/custom/list-context.ts +44 -0
  152. package/src/custom/place.ts +126 -0
  153. package/src/custom/registry.ts +101 -0
  154. package/src/custom/useCustomComponent.ts +136 -0
  155. package/src/custom/useFormZones.ts +65 -0
  156. package/src/custom/useListZones.ts +38 -0
  157. package/src/custom/user-components.ts +20 -0
  158. package/src/custom/zone-components.ts +53 -0
  159. package/src/documents/DocumentForm.vue +168 -0
  160. package/src/documents/DocumentList.vue +190 -0
  161. package/src/documents/cells/CheckboxCell.vue +16 -0
  162. package/src/documents/cells/DateCell.vue +26 -0
  163. package/src/documents/cells/FallbackCell.vue +23 -0
  164. package/src/documents/cells/FileSizeCell.vue +14 -0
  165. package/src/documents/cells/IdCell.vue +14 -0
  166. package/src/documents/cells/MimeCell.vue +15 -0
  167. package/src/documents/cells/NumberCell.vue +13 -0
  168. package/src/documents/cells/RelationshipCell.vue +33 -0
  169. package/src/documents/cells/RowsCell.vue +21 -0
  170. package/src/documents/cells/SelectCell.vue +23 -0
  171. package/src/documents/cells/StatusCell.vue +18 -0
  172. package/src/documents/cells/TextCell.vue +16 -0
  173. package/src/documents/cells/ThumbnailCell.vue +31 -0
  174. package/src/documents/cells/UploadCell.vue +53 -0
  175. package/src/documents/cells/UploadCellThumb.vue +27 -0
  176. package/src/documents/cells/cell-props.ts +12 -0
  177. package/src/documents/cells/registry.ts +44 -0
  178. package/src/documents/cells/select-options.ts +18 -0
  179. package/src/documents/drafts/DraftActions.vue +62 -0
  180. package/src/documents/drafts/DraftStatus.vue +100 -0
  181. package/src/documents/drafts/StatusBadge.vue +23 -0
  182. package/src/documents/drafts/UnpublishDialog.vue +25 -0
  183. package/src/documents/drafts/useAutosave.ts +88 -0
  184. package/src/documents/drafts/useDrafts.ts +73 -0
  185. package/src/documents/fields/CheckboxControl.vue +13 -0
  186. package/src/documents/fields/DateControl.vue +22 -0
  187. package/src/documents/fields/FieldControl.vue +55 -0
  188. package/src/documents/fields/FieldDescription.vue +34 -0
  189. package/src/documents/fields/FieldRenderer.vue +92 -0
  190. package/src/documents/fields/GroupChildren.vue +28 -0
  191. package/src/documents/fields/GroupErrors.vue +49 -0
  192. package/src/documents/fields/GroupFields.vue +87 -0
  193. package/src/documents/fields/JsonControl.vue +20 -0
  194. package/src/documents/fields/NumberControl.vue +20 -0
  195. package/src/documents/fields/ReadOnlyControl.vue +18 -0
  196. package/src/documents/fields/SelectControl.vue +46 -0
  197. package/src/documents/fields/TextControl.vue +37 -0
  198. package/src/documents/fields/TextareaControl.vue +18 -0
  199. package/src/documents/fields/ValueField.vue +87 -0
  200. package/src/documents/fields/field-control.ts +10 -0
  201. package/src/documents/fields/registry.ts +56 -0
  202. package/src/documents/fields/relation/JoinControl.vue +41 -0
  203. package/src/documents/fields/relation/RelationshipControl.vue +57 -0
  204. package/src/documents/fields/relation/useRelationPicker.ts +96 -0
  205. package/src/documents/fields/rows/ArrayFields.vue +72 -0
  206. package/src/documents/fields/rows/BlocksFields.vue +90 -0
  207. package/src/documents/fields/rows/RowCard.vue +81 -0
  208. package/src/documents/fields/rows/RowFields.vue +32 -0
  209. package/src/documents/fields/rows/RowsFieldset.vue +51 -0
  210. package/src/documents/fields/rows/row-title.ts +29 -0
  211. package/src/documents/fields/rows/useRows.ts +32 -0
  212. package/src/documents/fields/upload/MediaGrid.vue +61 -0
  213. package/src/documents/fields/upload/MediaLibrary.vue +131 -0
  214. package/src/documents/fields/upload/MediaPickerDialog.vue +54 -0
  215. package/src/documents/fields/upload/MediaTile.vue +69 -0
  216. package/src/documents/fields/upload/MediaUploadArea.vue +60 -0
  217. package/src/documents/fields/upload/UploadControl.vue +157 -0
  218. package/src/documents/fields/upload/UploadValueItem.vue +108 -0
  219. package/src/documents/fields/upload/upload-field.ts +77 -0
  220. package/src/documents/fields/upload/useFieldUploads.ts +60 -0
  221. package/src/documents/fields/upload/useMediaLibrary.ts +77 -0
  222. package/src/documents/fields/useCustomFieldModel.ts +32 -0
  223. package/src/documents/fields/useFieldLocale.ts +38 -0
  224. package/src/documents/form/DocumentFields.vue +28 -0
  225. package/src/documents/form/DocumentHeader.vue +50 -0
  226. package/src/documents/form/DocumentMeta.vue +99 -0
  227. package/src/documents/form/UnsavedChangesDialog.vue +27 -0
  228. package/src/documents/form/created-by.ts +12 -0
  229. package/src/documents/form/field-errors.ts +29 -0
  230. package/src/documents/form/field-value.ts +229 -0
  231. package/src/documents/form/focus-first-error.ts +43 -0
  232. package/src/documents/form/form-conditions.ts +106 -0
  233. package/src/documents/form/form-layout.ts +245 -0
  234. package/src/documents/form/form-values.ts +265 -0
  235. package/src/documents/form/layout/LayoutBlock.vue +32 -0
  236. package/src/documents/form/layout/LayoutItems.vue +43 -0
  237. package/src/documents/form/layout/LayoutLeaf.vue +33 -0
  238. package/src/documents/form/layout/LayoutRow.vue +60 -0
  239. package/src/documents/form/layout/LayoutSection.vue +73 -0
  240. package/src/documents/form/layout/LayoutStack.vue +20 -0
  241. package/src/documents/form/layout/LayoutTabs.vue +74 -0
  242. package/src/documents/form/relation-value.ts +160 -0
  243. package/src/documents/form/rows.ts +24 -0
  244. package/src/documents/form/save-messages.ts +65 -0
  245. package/src/documents/form/useDocumentDelete.ts +38 -0
  246. package/src/documents/form/useDocumentEditor.ts +167 -0
  247. package/src/documents/form/useDocumentForm.ts +37 -0
  248. package/src/documents/form/useDocumentRights.ts +45 -0
  249. package/src/documents/form/useDocumentSubmit.ts +128 -0
  250. package/src/documents/form/useFieldsForm.ts +238 -0
  251. package/src/documents/form/useFormLayout.ts +21 -0
  252. package/src/documents/form/useFormTabs.ts +54 -0
  253. package/src/documents/form/useLeaveGuard.ts +69 -0
  254. package/src/documents/form/useSaveShortcut.ts +13 -0
  255. package/src/documents/form/validate.ts +220 -0
  256. package/src/documents/list/CellConflictMessage.vue +24 -0
  257. package/src/documents/list/CellEditor.vue +155 -0
  258. package/src/documents/list/CellRelationEditor.vue +62 -0
  259. package/src/documents/list/DeleteDocumentsDialog.vue +42 -0
  260. package/src/documents/list/DocumentActions.vue +68 -0
  261. package/src/documents/list/DocumentCard.vue +84 -0
  262. package/src/documents/list/DocumentCards.vue +31 -0
  263. package/src/documents/list/DocumentRow.vue +86 -0
  264. package/src/documents/list/DocumentTable.vue +104 -0
  265. package/src/documents/list/InlineCell.vue +151 -0
  266. package/src/documents/list/InlineCheckboxCell.vue +99 -0
  267. package/src/documents/list/ListCell.vue +39 -0
  268. package/src/documents/list/ListCellValue.vue +59 -0
  269. package/src/documents/list/ListFooter.vue +50 -0
  270. package/src/documents/list/ListSearch.vue +44 -0
  271. package/src/documents/list/ListStates.vue +73 -0
  272. package/src/documents/list/ListToolbar.vue +37 -0
  273. package/src/documents/list/SelectionBar.vue +30 -0
  274. package/src/documents/list/cell-failure.ts +91 -0
  275. package/src/documents/list/cell-save.ts +129 -0
  276. package/src/documents/list/columns.ts +157 -0
  277. package/src/documents/list/inline-cells.ts +61 -0
  278. package/src/documents/list/inline-edit-context.ts +14 -0
  279. package/src/documents/list/inline-edit.ts +302 -0
  280. package/src/documents/list/list-query.ts +46 -0
  281. package/src/documents/list/row-overlay.ts +45 -0
  282. package/src/documents/list/sort.ts +32 -0
  283. package/src/documents/list/useCellEditorKeys.ts +78 -0
  284. package/src/documents/list/useCellEditorModel.ts +33 -0
  285. package/src/documents/list/useCellPopup.ts +94 -0
  286. package/src/documents/list/useDeleteFlow.ts +42 -0
  287. package/src/documents/list/useDocumentListData.ts +97 -0
  288. package/src/documents/list/useInlineEdit.ts +143 -0
  289. package/src/documents/list/useListInlineEdit.ts +68 -0
  290. package/src/documents/list/useListNotices.ts +58 -0
  291. package/src/documents/list/useListState.ts +67 -0
  292. package/src/documents/list/useRowPublish.ts +150 -0
  293. package/src/documents/upload/BulkUpload.vue +58 -0
  294. package/src/documents/upload/DocumentFileCard.vue +106 -0
  295. package/src/documents/upload/FileActions.vue +57 -0
  296. package/src/documents/upload/FileDetails.vue +40 -0
  297. package/src/documents/upload/UploadProgressRow.vue +29 -0
  298. package/src/documents/upload/UploadQueueItem.vue +150 -0
  299. package/src/documents/upload/UploadQueueSummary.vue +70 -0
  300. package/src/documents/upload/file-actions.ts +35 -0
  301. package/src/documents/upload/upload-logic.ts +209 -0
  302. package/src/documents/upload/upload-queue.ts +220 -0
  303. package/src/documents/upload/useDocumentFile.ts +93 -0
  304. package/src/documents/upload/useFileBlob.ts +132 -0
  305. package/src/documents/upload/useShownFile.ts +77 -0
  306. package/src/documents/versions/DiffOmitted.vue +34 -0
  307. package/src/documents/versions/DiffTree.vue +76 -0
  308. package/src/documents/versions/DiffValue.vue +101 -0
  309. package/src/documents/versions/HistoryLink.vue +17 -0
  310. package/src/documents/versions/RestoreVersionDialog.vue +58 -0
  311. package/src/documents/versions/VersionCard.vue +111 -0
  312. package/src/documents/versions/VersionHistory.vue +127 -0
  313. package/src/documents/versions/VersionSnapshot.vue +145 -0
  314. package/src/documents/versions/diff-view.ts +153 -0
  315. package/src/documents/versions/text-diff.ts +66 -0
  316. package/src/documents/versions/useRestoreFlow.ts +55 -0
  317. package/src/env.d.ts +17 -0
  318. package/src/format.ts +58 -0
  319. package/src/globals/GlobalForm.vue +139 -0
  320. package/src/globals/GlobalHeader.vue +39 -0
  321. package/src/globals/GlobalMeta.vue +67 -0
  322. package/src/globals/useGlobalEditor.ts +118 -0
  323. package/src/globals/useGlobalForm.ts +32 -0
  324. package/src/globals/useGlobalSubmit.ts +75 -0
  325. package/src/layout/AppBarMobile.vue +42 -0
  326. package/src/layout/AppLayout.vue +40 -0
  327. package/src/layout/AppTopbar.vue +28 -0
  328. package/src/layout/LoadError.vue +19 -0
  329. package/src/layout/MobileNavDrawer.vue +45 -0
  330. package/src/layout/PageHeader.vue +19 -0
  331. package/src/layout/ThemeToggle.vue +28 -0
  332. package/src/layout/palette/AppCommandPalette.vue +32 -0
  333. package/src/layout/palette/palette-actions.ts +54 -0
  334. package/src/layout/palette/palette-commands.ts +156 -0
  335. package/src/layout/palette/palette-documents.ts +73 -0
  336. package/src/layout/palette/palette-groups.ts +90 -0
  337. package/src/layout/palette/palette-hotkey.ts +39 -0
  338. package/src/layout/palette/recent-documents.ts +123 -0
  339. package/src/layout/palette/useCommandPalette.ts +75 -0
  340. package/src/layout/palette/useDocumentSearch.ts +88 -0
  341. package/src/layout/palette/useRememberDocument.ts +30 -0
  342. package/src/layout/sidebar/SidebarAdmin.vue +50 -0
  343. package/src/layout/sidebar/SidebarBrand.vue +14 -0
  344. package/src/layout/sidebar/SidebarCollections.vue +55 -0
  345. package/src/layout/sidebar/SidebarGlobals.vue +23 -0
  346. package/src/layout/sidebar/SidebarGroup.vue +14 -0
  347. package/src/layout/sidebar/SidebarItem.vue +47 -0
  348. package/src/layout/sidebar/SidebarNav.vue +37 -0
  349. package/src/layout/sidebar/SidebarUser.vue +43 -0
  350. package/src/layout/sidebar/SidebarViews.vue +26 -0
  351. package/src/layout/sidebar/view-icons.ts +112 -0
  352. package/src/localization/FallbackHint.vue +41 -0
  353. package/src/localization/LocaleNotice.vue +42 -0
  354. package/src/localization/LocaleSwitcher.vue +40 -0
  355. package/src/localization/fallback-value.ts +76 -0
  356. package/src/localization/list-locale.ts +37 -0
  357. package/src/localization/locale-form.ts +64 -0
  358. package/src/localization/locale.ts +286 -0
  359. package/src/localization/useContentLocale.ts +47 -0
  360. package/src/localization/useHistoryLocale.ts +30 -0
  361. package/src/localization/useListFallbacks.ts +49 -0
  362. package/src/localization/useLocaleDocument.ts +116 -0
  363. package/src/main.ts +21 -0
  364. package/src/public/__snapshots__/public-api.spec.ts.snap +456 -0
  365. package/src/public/composables/useApi.ts +155 -0
  366. package/src/public/composables/useCell.ts +38 -0
  367. package/src/public/composables/useCurrentUser.ts +16 -0
  368. package/src/public/composables/useDocument.ts +108 -0
  369. package/src/public/composables/useField.ts +136 -0
  370. package/src/public/composables/useList.ts +38 -0
  371. package/src/public/composables/useLocale.ts +29 -0
  372. package/src/public/composables/useToast.ts +19 -0
  373. package/src/public/index.ts +59 -0
  374. package/src/public/types.ts +183 -0
  375. package/src/public/ui.ts +85 -0
  376. package/src/roles/CopyRoleDialog.vue +32 -0
  377. package/src/roles/DeleteRoleDialog.vue +26 -0
  378. package/src/roles/MatrixFlags.vue +77 -0
  379. package/src/roles/MatrixTable.vue +101 -0
  380. package/src/roles/PermissionMatrix.vue +112 -0
  381. package/src/roles/RoleActions.vue +47 -0
  382. package/src/roles/RoleCard.vue +54 -0
  383. package/src/roles/RoleForm.vue +150 -0
  384. package/src/roles/RoleFormFields.vue +43 -0
  385. package/src/roles/RoleList.vue +77 -0
  386. package/src/roles/RoleMeta.vue +74 -0
  387. package/src/roles/RoleTable.vue +74 -0
  388. package/src/roles/role-form.ts +135 -0
  389. package/src/roles/role-matrix.ts +284 -0
  390. package/src/roles/useRoleCopy.ts +61 -0
  391. package/src/roles/useRoleDelete.ts +39 -0
  392. package/src/roles/useRoleForm.ts +122 -0
  393. package/src/router/guards.ts +57 -0
  394. package/src/router/index.ts +160 -0
  395. package/src/router/redirect.ts +9 -0
  396. package/src/runtime/runtime-config.ts +32 -0
  397. package/src/stores/auth.ts +205 -0
  398. package/src/stores/shell.ts +24 -0
  399. package/src/stores/uploads.ts +81 -0
  400. package/src/styles/main.css +40 -0
  401. package/src/styles/motion.css +328 -0
  402. package/src/styles/tokens.css +347 -0
  403. package/src/ui/KAlert.vue +80 -0
  404. package/src/ui/KAvatar.vue +43 -0
  405. package/src/ui/KBadge.vue +56 -0
  406. package/src/ui/KBreadcrumbs.vue +56 -0
  407. package/src/ui/KButton.vue +136 -0
  408. package/src/ui/KCalendar.vue +79 -0
  409. package/src/ui/KCard.vue +106 -0
  410. package/src/ui/KCellMessage.vue +57 -0
  411. package/src/ui/KCellTextarea.vue +92 -0
  412. package/src/ui/KCheckbox.vue +87 -0
  413. package/src/ui/KCollapsible.vue +100 -0
  414. package/src/ui/KCombobox.vue +173 -0
  415. package/src/ui/KComboboxOptions.vue +68 -0
  416. package/src/ui/KCommandItem.vue +53 -0
  417. package/src/ui/KCommandPalette.vue +215 -0
  418. package/src/ui/KDatePicker.vue +165 -0
  419. package/src/ui/KDrawer.vue +108 -0
  420. package/src/ui/KDropdownMenu.vue +60 -0
  421. package/src/ui/KDropzone.vue +163 -0
  422. package/src/ui/KEmptyState.vue +68 -0
  423. package/src/ui/KField.vue +103 -0
  424. package/src/ui/KInput.vue +89 -0
  425. package/src/ui/KKbd.vue +24 -0
  426. package/src/ui/KModal.vue +92 -0
  427. package/src/ui/KMultiSelect.vue +141 -0
  428. package/src/ui/KPagination.vue +65 -0
  429. package/src/ui/KPasswordInput.vue +33 -0
  430. package/src/ui/KPopover.vue +110 -0
  431. package/src/ui/KProgress.vue +61 -0
  432. package/src/ui/KRadioGroup.vue +90 -0
  433. package/src/ui/KSearchTrigger.vue +51 -0
  434. package/src/ui/KSegmented.vue +104 -0
  435. package/src/ui/KSelect.vue +124 -0
  436. package/src/ui/KSeparator.vue +33 -0
  437. package/src/ui/KSkeleton.vue +35 -0
  438. package/src/ui/KSpinner.vue +17 -0
  439. package/src/ui/KSwitch.vue +65 -0
  440. package/src/ui/KTab.vue +65 -0
  441. package/src/ui/KTabList.vue +18 -0
  442. package/src/ui/KTabPanel.vue +18 -0
  443. package/src/ui/KTable.vue +43 -0
  444. package/src/ui/KTableBody.vue +9 -0
  445. package/src/ui/KTableCell.vue +228 -0
  446. package/src/ui/KTableHeader.vue +39 -0
  447. package/src/ui/KTableHeaderCell.vue +94 -0
  448. package/src/ui/KTableRow.vue +49 -0
  449. package/src/ui/KTabs.vue +24 -0
  450. package/src/ui/KTag.vue +29 -0
  451. package/src/ui/KTextarea.vue +50 -0
  452. package/src/ui/KThumbnail.vue +100 -0
  453. package/src/ui/KToaster.vue +70 -0
  454. package/src/ui/KTooltip.vue +55 -0
  455. package/src/ui/command-palette.ts +41 -0
  456. package/src/ui/control-classes.ts +48 -0
  457. package/src/ui/cx.ts +6 -0
  458. package/src/ui/date-value.ts +48 -0
  459. package/src/ui/field-context.ts +61 -0
  460. package/src/ui/index.ts +88 -0
  461. package/src/ui/options.ts +6 -0
  462. package/src/ui/pagination.ts +38 -0
  463. package/src/ui/shortcut.ts +104 -0
  464. package/src/ui/table-grid.ts +277 -0
  465. package/src/ui/toast.ts +59 -0
  466. package/src/ui/useFileDrop.ts +70 -0
  467. package/src/users/DeleteUserDialog.vue +26 -0
  468. package/src/users/UserActions.vue +46 -0
  469. package/src/users/UserCard.vue +44 -0
  470. package/src/users/UserForm.vue +134 -0
  471. package/src/users/UserFormFields.vue +93 -0
  472. package/src/users/UserList.vue +107 -0
  473. package/src/users/UserMeta.vue +70 -0
  474. package/src/users/UserRoleBadge.vue +10 -0
  475. package/src/users/UserTable.vue +84 -0
  476. package/src/users/useRoleOptions.ts +50 -0
  477. package/src/users/useUserDelete.ts +39 -0
  478. package/src/users/useUserForm.ts +74 -0
  479. package/src/users/user-columns.ts +12 -0
  480. package/src/users/user-form.ts +167 -0
  481. package/src/views/AuditView.vue +57 -0
  482. package/src/views/CollectionView.vue +103 -0
  483. package/src/views/CustomPageView.vue +53 -0
  484. package/src/views/DashboardView.vue +91 -0
  485. package/src/views/DocumentHistoryView.vue +158 -0
  486. package/src/views/DocumentView.vue +173 -0
  487. package/src/views/GlobalHistoryView.vue +136 -0
  488. package/src/views/GlobalView.vue +115 -0
  489. package/src/views/LoginView.vue +41 -0
  490. package/src/views/NoAccessView.vue +34 -0
  491. package/src/views/NotFoundView.vue +27 -0
  492. package/src/views/RoleView.vue +93 -0
  493. package/src/views/RolesView.vue +66 -0
  494. package/src/views/UserView.vue +68 -0
  495. package/src/views/UsersView.vue +59 -0
  496. package/src/views/dashboard/CollectionCard.vue +21 -0
  497. package/src/views/dashboard/DashboardCardTitle.vue +18 -0
  498. package/src/views/dashboard/DashboardWidgets.vue +35 -0
  499. package/src/views/dashboard/GlobalCard.vue +24 -0
  500. package/src/views/login/LoginForm.vue +93 -0
  501. package/src/views/login/login-errors.ts +42 -0
  502. package/tsconfig.components.json +26 -0
  503. package/vite/koda-admin.ts +274 -0
@@ -0,0 +1,183 @@
1
+ import type { AdminField } from '../api/admin-fields.js';
2
+
3
+ /**
4
+ * Типы публичного API `@kodacms/admin` (M13). Документы — в формате API, как REST отдаёт их при
5
+ * `depth: 0`: даты — ISO-строки, связи — id (у полиморфной — `{ relationTo, value }`).
6
+ */
7
+
8
+ /**
9
+ * Документы коллекций по slug. Пустой здесь — дополняет `koda:generate`
10
+ * (`src/admin/generated/admin-types.d.ts`): `interface KodaAdminCollections { posts: PostsDoc }`.
11
+ */
12
+ // oxlint-disable-next-line typescript/no-empty-interface, typescript/no-empty-object-type
13
+ export interface KodaAdminCollections {}
14
+
15
+ /** Документы globals по slug — как KodaAdminCollections. */
16
+ // oxlint-disable-next-line typescript/no-empty-interface, typescript/no-empty-object-type
17
+ export interface KodaAdminGlobals {}
18
+
19
+ /** Документ без сгенерированных типов: поля — как пришли из API. */
20
+ export type JsonDocument = { id?: string } & Record<string, unknown>;
21
+
22
+ /** Slug коллекции; пока генератор ничего не записал — string. */
23
+ export type CollectionSlug = [keyof KodaAdminCollections] extends [never]
24
+ ? string
25
+ : Extract<keyof KodaAdminCollections, string>;
26
+
27
+ /** Slug global; пока генератор ничего не записал — string. */
28
+ export type GlobalSlug = [keyof KodaAdminGlobals] extends [never]
29
+ ? string
30
+ : Extract<keyof KodaAdminGlobals, string>;
31
+
32
+ /** Документ коллекции (или global) по slug; неизвестный slug — `JsonDocument`. */
33
+ export type DocOf<S extends string> = S extends keyof KodaAdminCollections
34
+ ? KodaAdminCollections[S]
35
+ : S extends keyof KodaAdminGlobals
36
+ ? KodaAdminGlobals[S]
37
+ : JsonDocument;
38
+
39
+ /** Документ global по slug. */
40
+ export type GlobalDocOf<S extends string> = S extends keyof KodaAdminGlobals
41
+ ? KodaAdminGlobals[S]
42
+ : JsonDocument;
43
+
44
+ /** Служебные поля документа: их ставит сервер, в create/update они не уходят. */
45
+ type SystemKeys = 'id' | 'createdAt' | 'updatedAt';
46
+
47
+ /** Строка array/blocks во вводе: id необязателен (новая строка — без id). */
48
+ type RowInput<R> = R extends { id: string }
49
+ ? Omit<R, 'id'> & { id?: string }
50
+ : R;
51
+ type InputValue<T> = T extends readonly (infer R)[] ? RowInput<R>[] : T;
52
+ type InputOf<D> = { [K in Exclude<keyof D, SystemKeys>]?: InputValue<D[K]> };
53
+
54
+ /**
55
+ * Данные для create/update: поля документа без служебных, все необязательные; у строк
56
+ * array/blocks id необязателен.
57
+ */
58
+ export type DataOf<S extends string> = InputOf<DocOf<S>>;
59
+
60
+ /** Данные для update global — как DataOf. */
61
+ export type GlobalDataOf<S extends string> = InputOf<GlobalDocOf<S>>;
62
+
63
+ type Depth = [never, 0, 1, 2, 3, 4, 5, 6];
64
+
65
+ /**
66
+ * Пути полей документа через точку: `title`, `seo.title`, строки — по индексу:
67
+ * `layout.${number}.heading`. Не глубже 6 уровней.
68
+ */
69
+ export type FieldPathIn<T, D extends number = 6> = [D] extends [never]
70
+ ? never
71
+ : T extends readonly (infer Row)[]
72
+ ? `${number}` | `${number}.${FieldPathIn<NonNullable<Row>, Depth[D]>}`
73
+ : T extends object
74
+ ? {
75
+ [K in keyof T & string]:
76
+ K | `${K}.${FieldPathIn<NonNullable<T[K]>, Depth[D]>}`;
77
+ }[keyof T & string]
78
+ : never;
79
+
80
+ /** Пути полей коллекции; без сгенерированных типов — любая строка. */
81
+ export type FieldPath<S extends string> = string extends keyof DocOf<S>
82
+ ? string
83
+ : FieldPathIn<DocOf<S>>;
84
+
85
+ /** Значение по пути в объекте; нет такого пути — unknown. */
86
+ export type ValueAt<
87
+ T,
88
+ P extends string,
89
+ > = P extends `${infer Head}.${infer Rest}`
90
+ ? ValueAt<StepInto<T, Head>, Rest>
91
+ : StepInto<T, P>;
92
+
93
+ type StepInto<T, K extends string> = T extends readonly (infer Row)[]
94
+ ? K extends `${number}`
95
+ ? Row
96
+ : unknown
97
+ : T extends null | undefined
98
+ ? never
99
+ : K extends keyof T
100
+ ? T[K]
101
+ : unknown;
102
+
103
+ /**
104
+ * Значение поля в формате API: `FieldValue<'posts', 'title'>` → `string | null`. Это же
105
+ * значение — в `v-model` своего `Field` и в `useField().value`.
106
+ */
107
+ export type FieldValue<
108
+ S extends string,
109
+ P extends string,
110
+ > = string extends keyof DocOf<S> ? unknown : ValueAt<DocOf<S>, P>;
111
+
112
+ /** Описание поля из `_config` (тип, подпись, опции, admin). */
113
+ export type { AdminField } from '../api/admin-fields.js';
114
+
115
+ /**
116
+ * Пропсы своего `Field` (дублируют `useField()`): `defineProps<FieldProps<'posts', 'title'>>()`
117
+ * + `defineEmits<FieldEmits<'posts', 'title'>>()`, или проще `defineModel()`.
118
+ */
119
+ export interface FieldProps<
120
+ S extends string = string,
121
+ P extends FieldPath<S> = FieldPath<S>,
122
+ > {
123
+ field: AdminField;
124
+ /** Путь поля в форме: `seo.title`. */
125
+ path: string;
126
+ disabled?: boolean;
127
+ modelValue: FieldValue<S, P>;
128
+ }
129
+
130
+ export interface FieldEmits<
131
+ S extends string = string,
132
+ P extends FieldPath<S> = FieldPath<S>,
133
+ > {
134
+ 'update:modelValue': [value: FieldValue<S, P>];
135
+ }
136
+
137
+ /** Пропсы своей ячейки списка (дублируют `useCell()`). */
138
+ export interface CellProps<
139
+ S extends string = string,
140
+ P extends FieldPath<S> = FieldPath<S>,
141
+ > {
142
+ value: FieldValue<S, P>;
143
+ doc: DocOf<S>;
144
+ field: AdminField;
145
+ }
146
+
147
+ /** Пропсы своей подписи под полем (`Description`): значение только для чтения. */
148
+ export interface DescriptionProps<
149
+ S extends string = string,
150
+ P extends FieldPath<S> = FieldPath<S>,
151
+ > {
152
+ field: AdminField;
153
+ path: string;
154
+ value: FieldValue<S, P>;
155
+ }
156
+
157
+ /** Пропсы вставок списка (`beforeList`, `actions.list`). */
158
+ export interface ListSlotProps<S extends string = string> {
159
+ collection: S;
160
+ }
161
+
162
+ /**
163
+ * Пропсы вставок формы (`beforeFields`, `afterFields`, `actions.document`): у документа
164
+ * коллекции — `collection` и `id` (новый — без id), у global — `global`.
165
+ */
166
+ export interface DocumentSlotProps<S extends string = string> {
167
+ collection?: S;
168
+ global?: string;
169
+ id?: string;
170
+ /** Сохранённый документ; новый — undefined. */
171
+ doc?: DocOf<S>;
172
+ }
173
+
174
+ /** Пропсы своей страницы (`admin.views`). */
175
+ export interface ViewProps {
176
+ /** Путь страницы в конфиге: `reports` → `/admin/reports`. */
177
+ path: string;
178
+ }
179
+
180
+ /** Пропсы виджета дашборда. */
181
+ export interface WidgetProps {
182
+ width: 'full' | 'half';
183
+ }
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Публичный UI-кит `@kodacms/admin/ui` для своих компонентов (M13): компоненты дизайн-системы
3
+ * (Penpot → Reka UI). Их пропсы — контракт; снимок экспортов — `public-api.spec.ts`. Цвета и
4
+ * отступы — классы токенов (`bg-bg-surface`, `text-fg-muted`, `typo-body`) или
5
+ * `var(--color-…)` в `<style scoped>`: палитра Tailwind по умолчанию выключена.
6
+ */
7
+ export { default as KAlert, type AlertTone } from '../ui/KAlert.vue';
8
+ export { default as KAvatar } from '../ui/KAvatar.vue';
9
+ export { default as KBadge, type BadgeTone } from '../ui/KBadge.vue';
10
+ export {
11
+ default as KButton,
12
+ type ButtonSize,
13
+ type ButtonVariant,
14
+ } from '../ui/KButton.vue';
15
+ export { default as KCard } from '../ui/KCard.vue';
16
+ export {
17
+ default as KCellMessage,
18
+ type CellMessageTone,
19
+ } from '../ui/KCellMessage.vue';
20
+ export { default as KCheckbox } from '../ui/KCheckbox.vue';
21
+ export { default as KCollapsible } from '../ui/KCollapsible.vue';
22
+ export { default as KCommandPalette } from '../ui/KCommandPalette.vue';
23
+ export type { CommandGroup, CommandItem } from '../ui/command-palette.js';
24
+ export { default as KDatePicker } from '../ui/KDatePicker.vue';
25
+ export { default as KDrawer, type DrawerSide } from '../ui/KDrawer.vue';
26
+ export {
27
+ default as KDropdownMenu,
28
+ type MenuAction,
29
+ } from '../ui/KDropdownMenu.vue';
30
+ export {
31
+ default as KEmptyState,
32
+ type EmptyStateKind,
33
+ } from '../ui/KEmptyState.vue';
34
+ export { default as KField } from '../ui/KField.vue';
35
+ export { default as KInput } from '../ui/KInput.vue';
36
+ export { default as KKbd } from '../ui/KKbd.vue';
37
+ export { default as KModal } from '../ui/KModal.vue';
38
+ export { default as KPagination } from '../ui/KPagination.vue';
39
+ export {
40
+ default as KPopover,
41
+ type PopoverAlign,
42
+ type PopoverSide,
43
+ type PopoverWidth,
44
+ } from '../ui/KPopover.vue';
45
+ export { default as KProgress, type ProgressTone } from '../ui/KProgress.vue';
46
+ export { default as KRadioGroup } from '../ui/KRadioGroup.vue';
47
+ export {
48
+ default as KSegmented,
49
+ type SegmentedOption,
50
+ } from '../ui/KSegmented.vue';
51
+ export { default as KSelect } from '../ui/KSelect.vue';
52
+ export {
53
+ default as KSeparator,
54
+ type SeparatorOrientation,
55
+ } from '../ui/KSeparator.vue';
56
+ export { default as KSkeleton, type SkeletonShape } from '../ui/KSkeleton.vue';
57
+ export { default as KSpinner } from '../ui/KSpinner.vue';
58
+ export { default as KSwitch } from '../ui/KSwitch.vue';
59
+ export { default as KTab } from '../ui/KTab.vue';
60
+ export { default as KTable } from '../ui/KTable.vue';
61
+ export { default as KTableBody } from '../ui/KTableBody.vue';
62
+ export {
63
+ default as KTableCell,
64
+ type TableCellEditEvent,
65
+ type TableCellState,
66
+ } from '../ui/KTableCell.vue';
67
+ export { default as KTableHeader } from '../ui/KTableHeader.vue';
68
+ export {
69
+ default as KTableHeaderCell,
70
+ type TableSortDirection,
71
+ } from '../ui/KTableHeaderCell.vue';
72
+ export { default as KTableRow } from '../ui/KTableRow.vue';
73
+ export { default as KTabList } from '../ui/KTabList.vue';
74
+ export { default as KTabPanel } from '../ui/KTabPanel.vue';
75
+ export { default as KTabs } from '../ui/KTabs.vue';
76
+ export { default as KTag } from '../ui/KTag.vue';
77
+ export { default as KTextarea } from '../ui/KTextarea.vue';
78
+ export {
79
+ default as KThumbnail,
80
+ type ThumbnailKind,
81
+ } from '../ui/KThumbnail.vue';
82
+ export { default as KTooltip, type TooltipSide } from '../ui/KTooltip.vue';
83
+ export type { ChoiceOption } from '../ui/options.js';
84
+ export { formatShortcut, type ShortcutKey } from '../ui/shortcut.js';
85
+ export { injectGridContext, type GridContext } from '../ui/table-grid.js';
@@ -0,0 +1,32 @@
1
+ <script setup lang="ts">
2
+ import { KButton, KField, KInput, KModal } from '../ui/index.js';
3
+
4
+ /** Копия роли: название новой роли; права копирует сервер. */
5
+ defineProps<{ source: string; error?: string; pending: boolean }>();
6
+ const open = defineModel<boolean>('open', { default: false });
7
+ const name = defineModel<string>('name', { required: true });
8
+ defineEmits<{ confirm: [] }>();
9
+ </script>
10
+
11
+ <template>
12
+ <KModal
13
+ v-model:open="open"
14
+ :title="`Копировать роль «${source}»`"
15
+ description="Новая роль получит те же права. Пользователи не переносятся."
16
+ initial-focus="input[name='copy-name']"
17
+ >
18
+ <form id="copy-role-form" novalidate @submit.prevent="$emit('confirm')">
19
+ <KField label="Название новой роли" :error="error" required>
20
+ <KInput v-model="name" name="copy-name" autocomplete="off" />
21
+ </KField>
22
+ </form>
23
+ <template #footer>
24
+ <KButton variant="secondary" :disabled="pending" @click="open = false"
25
+ >Отмена</KButton
26
+ >
27
+ <KButton type="submit" form="copy-role-form" :loading="pending"
28
+ >Копировать</KButton
29
+ >
30
+ </template>
31
+ </KModal>
32
+ </template>
@@ -0,0 +1,26 @@
1
+ <script setup lang="ts">
2
+ import { KButton, KModal } from '../ui/index.js';
3
+
4
+ /** Подтверждение удаления роли (Penpot: Modal / Danger). */
5
+ defineProps<{ name: string; pending: boolean }>();
6
+ const open = defineModel<boolean>('open', { default: false });
7
+ defineEmits<{ confirm: [] }>();
8
+ </script>
9
+
10
+ <template>
11
+ <KModal
12
+ v-model:open="open"
13
+ tone="danger"
14
+ :title="`Удалить роль «${name}»?`"
15
+ description="Роль и её права будут удалены без возможности восстановления. Роль, назначенную пользователям, удалить нельзя."
16
+ >
17
+ <template #footer>
18
+ <KButton variant="secondary" :disabled="pending" @click="open = false"
19
+ >Отмена</KButton
20
+ >
21
+ <KButton variant="danger" :loading="pending" @click="$emit('confirm')"
22
+ >Удалить</KButton
23
+ >
24
+ </template>
25
+ </KModal>
26
+ </template>
@@ -0,0 +1,77 @@
1
+ <script setup lang="ts">
2
+ import { computed } from 'vue';
3
+ import type { MatrixScope, MatrixSection } from '../api/roles.js';
4
+ import { KCheckbox } from '../ui/index.js';
5
+ import {
6
+ ACTION_LABELS,
7
+ groupFlags,
8
+ type MatrixValues,
9
+ SYSTEM_FLAG_HINTS,
10
+ } from './role-matrix.js';
11
+
12
+ /**
13
+ * Флаги: свои (permissions в конфиге) — одна галочка на флаг, по группам, справа ключ;
14
+ * `system` — встроенные флаги ядра (раздел «Система», M10.3): справа ресурс целиком
15
+ * (`system:audit`), под списком — пояснение, что даёт флаг.
16
+ */
17
+ const props = defineProps<{
18
+ section: MatrixSection;
19
+ values: MatrixValues;
20
+ readonly: boolean;
21
+ system?: boolean;
22
+ }>();
23
+ const emit = defineEmits<{
24
+ change: [resource: string, action: string, scope: MatrixScope];
25
+ }>();
26
+ const groups = computed(() => groupFlags(props.section.resources));
27
+ const ALLOW = 'allow';
28
+
29
+ function toggle(resource: string, checked: boolean | 'indeterminate'): void {
30
+ emit('change', resource, ALLOW, checked === true ? 'all' : 'none');
31
+ }
32
+ </script>
33
+
34
+ <template>
35
+ <div class="flex flex-col gap-5">
36
+ <section
37
+ v-for="group in groups"
38
+ :key="group.label ?? ''"
39
+ class="flex flex-col gap-2"
40
+ :aria-label="group.label ?? 'Флаги'"
41
+ >
42
+ <h3 v-if="group.label" class="typo-label text-fg-muted">
43
+ {{ group.label }}
44
+ </h3>
45
+ <ul class="flex flex-col rounded-md border border-border-default">
46
+ <li
47
+ v-for="flag in group.flags"
48
+ :key="flag.resource"
49
+ class="flex min-h-12 flex-wrap items-center justify-between gap-x-4 gap-y-1 border-b border-border-default px-3 py-2 last:border-b-0"
50
+ >
51
+ <KCheckbox
52
+ :model-value="values[flag.resource]?.[ALLOW] === 'all'"
53
+ :label="flag.label"
54
+ :disabled="readonly"
55
+ :aria-label="`${flag.label}: ${ACTION_LABELS.allow}`"
56
+ :data-cell="`${flag.resource}.${ALLOW}`"
57
+ @update:model-value="toggle(flag.resource, $event)"
58
+ />
59
+ <code class="typo-code text-fg-subtle">{{
60
+ system ? flag.resource : flag.slug
61
+ }}</code>
62
+ </li>
63
+ </ul>
64
+ <template v-if="system">
65
+ <p
66
+ v-for="flag in group.flags.filter(
67
+ (f) => SYSTEM_FLAG_HINTS[f.resource],
68
+ )"
69
+ :key="flag.resource"
70
+ class="typo-caption text-fg-muted"
71
+ >
72
+ {{ SYSTEM_FLAG_HINTS[flag.resource] }}
73
+ </p>
74
+ </template>
75
+ </section>
76
+ </div>
77
+ </template>
@@ -0,0 +1,101 @@
1
+ <script setup lang="ts">
2
+ import { computed } from 'vue';
3
+ import type { MatrixScope, MatrixSection } from '../api/roles.js';
4
+ import {
5
+ KSelect,
6
+ KTable,
7
+ KTableBody,
8
+ KTableCell,
9
+ KTableHeader,
10
+ KTableHeaderCell,
11
+ KTableRow,
12
+ } from '../ui/index.js';
13
+ import {
14
+ actionLabel,
15
+ isActionLocked,
16
+ type MatrixValues,
17
+ scopeOptions,
18
+ sectionActions,
19
+ sectionLabel,
20
+ } from './role-matrix.js';
21
+
22
+ /**
23
+ * Таблица раздела (коллекции, globals): строки — сущности, колонки — действия; в ячейке —
24
+ * область («Все», «Свои», «Нет»), действия нет у сущности — «—». Прокрутка — внутри KTable.
25
+ * Сущность — заголовок строки (<th scope="row">): в ките нет такой ячейки, стили — как у KTableCell.
26
+ */
27
+ const props = defineProps<{
28
+ section: MatrixSection;
29
+ values: MatrixValues;
30
+ readonly: boolean;
31
+ }>();
32
+ const emit = defineEmits<{
33
+ change: [resource: string, action: string, scope: MatrixScope];
34
+ }>();
35
+ const columns = computed(() => sectionActions(props.section));
36
+ const hasPublish = computed(() => columns.value.includes('publish'));
37
+
38
+ const cellAction = (
39
+ resource: MatrixSection['resources'][number],
40
+ key: string,
41
+ ) => resource.actions.find((a) => a.action === key);
42
+ </script>
43
+
44
+ <template>
45
+ <div class="flex flex-col gap-2">
46
+ <KTable
47
+ :caption="`Права: ${sectionLabel(section.key)}`"
48
+ class="rounded-md border border-border-default"
49
+ >
50
+ <KTableHeader>
51
+ <KTableHeaderCell class="min-w-36">Сущность</KTableHeaderCell>
52
+ <KTableHeaderCell
53
+ v-for="column in columns"
54
+ :key="column"
55
+ class="min-w-28"
56
+ >
57
+ {{ actionLabel(column) }}
58
+ </KTableHeaderCell>
59
+ </KTableHeader>
60
+ <KTableBody>
61
+ <KTableRow
62
+ v-for="resource in section.resources"
63
+ :key="resource.resource"
64
+ >
65
+ <th
66
+ scope="row"
67
+ class="h-12 px-3 text-left typo-body-strong text-fg-default"
68
+ >
69
+ {{ resource.label }}
70
+ </th>
71
+ <KTableCell v-for="column in columns" :key="column">
72
+ <KSelect
73
+ v-if="cellAction(resource, column)"
74
+ size="sm"
75
+ :model-value="values[resource.resource]?.[column] ?? 'none'"
76
+ :options="scopeOptions(cellAction(resource, column)!)"
77
+ :disabled="
78
+ readonly || isActionLocked(values, resource.resource, column)
79
+ "
80
+ :aria-label="`${resource.label}: ${actionLabel(column)}`"
81
+ :data-cell="`${resource.resource}.${column}`"
82
+ @update:model-value="
83
+ emit('change', resource.resource, column, $event as MatrixScope)
84
+ "
85
+ />
86
+ <span
87
+ v-else
88
+ class="px-3 text-fg-subtle"
89
+ :aria-label="`${resource.label}: ${actionLabel(column)} — нет такого действия`"
90
+ >—</span
91
+ >
92
+ </KTableCell>
93
+ </KTableRow>
94
+ </KTableBody>
95
+ </KTable>
96
+ <p v-if="hasPublish" class="typo-caption text-fg-subtle">
97
+ «Публиковать» требует права «Редактировать»: без него публикация
98
+ недоступна.
99
+ </p>
100
+ </div>
101
+ </template>
@@ -0,0 +1,112 @@
1
+ <script setup lang="ts">
2
+ import { computed, ref } from 'vue';
3
+ import type {
4
+ MatrixScope,
5
+ MatrixSectionKey,
6
+ PermissionMatrix,
7
+ } from '../api/roles.js';
8
+ import {
9
+ KAlert,
10
+ KEmptyState,
11
+ KTab,
12
+ KTabList,
13
+ KTabPanel,
14
+ KTabs,
15
+ } from '../ui/index.js';
16
+ import MatrixFlags from './MatrixFlags.vue';
17
+ import MatrixTable from './MatrixTable.vue';
18
+ import {
19
+ grantedCount,
20
+ type MatrixValues,
21
+ SECTION_EMPTY,
22
+ sectionLabel,
23
+ setMatrixValue,
24
+ } from './role-matrix.js';
25
+
26
+ /**
27
+ * Матрица прав (как «Настройка доступа» в МоёмСкладе): разделы — вкладки KTabs (счётчик —
28
+ * сколько сущностей раздела с правами), в панели — таблица раздела или галочки флагов (свои
29
+ * флаги и раздел «Система» — встроенные флаги ядра, M10.3).
30
+ * Ошибки сервера по матрице — над ней. Значения живут в v-model, поэтому панели неактивных
31
+ * вкладок можно размонтировать.
32
+ */
33
+ const props = defineProps<{
34
+ matrix: PermissionMatrix;
35
+ errors: string[];
36
+ readonly?: boolean;
37
+ }>();
38
+ const values = defineModel<MatrixValues>({ required: true });
39
+ const active = ref<MatrixSectionKey>(
40
+ props.matrix.sections[0]?.key ?? 'collections',
41
+ );
42
+
43
+ const tabs = computed(() =>
44
+ props.matrix.sections.map((section) => ({
45
+ key: section.key,
46
+ label: sectionLabel(section.key),
47
+ count: grantedCount(section, values.value),
48
+ })),
49
+ );
50
+
51
+ function change(resource: string, action: string, scope: MatrixScope): void {
52
+ values.value = setMatrixValue(values.value, resource, action, scope);
53
+ }
54
+ </script>
55
+
56
+ <template>
57
+ <div class="flex flex-col gap-4">
58
+ <KAlert
59
+ v-if="errors.length > 0"
60
+ tone="danger"
61
+ title="Сервер не принял права"
62
+ >
63
+ <span v-for="message in errors" :key="message" class="block">{{
64
+ message
65
+ }}</span>
66
+ </KAlert>
67
+ <KTabs
68
+ :model-value="active"
69
+ @update:model-value="active = $event as MatrixSectionKey"
70
+ >
71
+ <KTabList aria-label="Разделы прав">
72
+ <KTab
73
+ v-for="tab in tabs"
74
+ :key="tab.key"
75
+ :value="tab.key"
76
+ :count="tab.count"
77
+ >
78
+ {{ tab.label }}
79
+ </KTab>
80
+ </KTabList>
81
+ <KTabPanel
82
+ v-for="section in matrix.sections"
83
+ :key="section.key"
84
+ :value="section.key"
85
+ class="min-w-0"
86
+ >
87
+ <KEmptyState
88
+ v-if="section.resources.length === 0"
89
+ framed
90
+ :heading-level="3"
91
+ :title="SECTION_EMPTY[section.key].title"
92
+ :description="SECTION_EMPTY[section.key].description"
93
+ />
94
+ <MatrixFlags
95
+ v-else-if="section.key === 'custom' || section.key === 'system'"
96
+ :section="section"
97
+ :values="values"
98
+ :readonly="readonly ?? false"
99
+ :system="section.key === 'system'"
100
+ @change="change"
101
+ />
102
+ <MatrixTable
103
+ v-else
104
+ :section="section"
105
+ :values="values"
106
+ :readonly="readonly ?? false"
107
+ @change="change"
108
+ />
109
+ </KTabPanel>
110
+ </KTabs>
111
+ </div>
112
+ </template>
@@ -0,0 +1,47 @@
1
+ <script setup lang="ts">
2
+ import { Copy, Ellipsis, Pencil, Trash2 } from '@lucide/vue';
3
+ import { computed } from 'vue';
4
+ import { useRouter } from 'vue-router';
5
+ import type { RoleSummary } from '../api/roles.js';
6
+ import { KButton, KDropdownMenu, type MenuAction } from '../ui/index.js';
7
+
8
+ /** Меню «…» роли: открыть; у обычной роли — копировать и удалить (системную — нельзя). */
9
+ const props = defineProps<{ role: RoleSummary }>();
10
+ const emit = defineEmits<{ copy: []; delete: [] }>();
11
+ const router = useRouter();
12
+
13
+ const actions = computed<MenuAction[]>(() => [
14
+ {
15
+ label: 'Открыть',
16
+ icon: Pencil,
17
+ onSelect: () =>
18
+ void router.push({ name: 'role', params: { id: props.role.id } }),
19
+ },
20
+ ...(props.role.isSystem
21
+ ? []
22
+ : [
23
+ { label: 'Копировать', icon: Copy, onSelect: () => emit('copy') },
24
+ {
25
+ label: 'Удалить',
26
+ icon: Trash2,
27
+ tone: 'danger' as const,
28
+ onSelect: () => emit('delete'),
29
+ },
30
+ ]),
31
+ ]);
32
+ </script>
33
+
34
+ <template>
35
+ <KDropdownMenu :actions="actions">
36
+ <template #trigger>
37
+ <KButton
38
+ variant="ghost"
39
+ size="sm"
40
+ icon-only
41
+ :aria-label="`Действия: ${role.name}`"
42
+ >
43
+ <Ellipsis :size="16" />
44
+ </KButton>
45
+ </template>
46
+ </KDropdownMenu>
47
+ </template>