@kodacms/admin 0.0.0-stage → 0.1.1

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 +13 -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,6 @@
1
+ /** Вариант выбора (select, radio). value — строка: так приходит из _config. */
2
+ export interface ChoiceOption {
3
+ label: string;
4
+ value: string;
5
+ disabled?: boolean;
6
+ }
@@ -0,0 +1,38 @@
1
+ /** Номера страниц для пагинации (Penpot: Pagination Item — Number / Ellipsis). */
2
+ export type PageItem =
3
+ { type: 'page'; page: number } | { type: 'ellipsis'; key: string };
4
+
5
+ /**
6
+ * Всегда первая и последняя, вокруг текущей — `siblings` с каждой стороны, пропуски — «…».
7
+ * 1 [2] 3 … 13 · 1 … 5 [6] 7 … 13 · 1 … 11 12 [13]
8
+ */
9
+ export function pageItems(
10
+ current: number,
11
+ total: number,
12
+ siblings = 1,
13
+ ): PageItem[] {
14
+ if (total <= 0) return [];
15
+ const pages = new Set<number>([1, total]);
16
+ for (let p = current - siblings; p <= current + siblings; p++)
17
+ if (p >= 1 && p <= total) pages.add(p);
18
+ // Пропуск в одну страницу показываем номером, а не «…»
19
+ const sorted = [...pages].sort((a, b) => a - b);
20
+ const items: PageItem[] = [];
21
+ sorted.forEach((page, i) => {
22
+ const prev = sorted[i - 1];
23
+ if (prev !== undefined && page - prev === 2)
24
+ items.push({ type: 'page', page: page - 1 });
25
+ else if (prev !== undefined && page - prev > 2)
26
+ items.push({ type: 'ellipsis', key: `gap-${prev}` });
27
+ items.push({ type: 'page', page });
28
+ });
29
+ return items;
30
+ }
31
+
32
+ /** «Показано 9–16 из 248». */
33
+ export function rangeLabel(page: number, limit: number, total: number): string {
34
+ if (total === 0) return 'Нет документов';
35
+ const from = (page - 1) * limit + 1;
36
+ const to = Math.min(page * limit, total);
37
+ return `Показано ${from}–${to} из ${total}`;
38
+ }
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Подпись сочетания клавиш для KKbd: `mod` — ⌘ на macOS и Ctrl на Windows/Linux.
3
+ * macOS — символы слитно («⇧⌘L», «⌘K»), остальные — слова через пробел («Ctrl Shift L»).
4
+ * Ключи — как в `aria-keyshortcuts` (`Meta`, `Control`, `Shift`, `Alt`, `Enter`, `Escape`,
5
+ * стрелки) или одна буква/цифра; `formatAriaShortcut` даёт значение для `aria-keyshortcuts`.
6
+ */
7
+ export type ShortcutKey = string;
8
+
9
+ const MAC: Record<string, string> = {
10
+ mod: '⌘',
11
+ meta: '⌘',
12
+ control: '⌃',
13
+ ctrl: '⌃',
14
+ shift: '⇧',
15
+ alt: '⌥',
16
+ enter: '↵',
17
+ escape: 'Esc',
18
+ esc: 'Esc',
19
+ arrowup: '↑',
20
+ arrowdown: '↓',
21
+ arrowleft: '←',
22
+ arrowright: '→',
23
+ backspace: '⌫',
24
+ };
25
+ const OTHER: Record<string, string> = {
26
+ mod: 'Ctrl',
27
+ meta: 'Win',
28
+ control: 'Ctrl',
29
+ ctrl: 'Ctrl',
30
+ shift: 'Shift',
31
+ alt: 'Alt',
32
+ enter: '↵',
33
+ escape: 'Esc',
34
+ esc: 'Esc',
35
+ arrowup: '↑',
36
+ arrowdown: '↓',
37
+ arrowleft: '←',
38
+ arrowright: '→',
39
+ backspace: 'Backspace',
40
+ };
41
+ /** Порядок модификаторов: macOS — ⌃⌥⇧⌘, остальные — Ctrl Alt Shift. */
42
+ const MAC_ORDER = ['control', 'ctrl', 'alt', 'shift', 'mod', 'meta'];
43
+ const OTHER_ORDER = ['mod', 'control', 'ctrl', 'meta', 'alt', 'shift'];
44
+
45
+ /** macOS / iOS по `navigator` (вне браузера — нет). */
46
+ export function isApplePlatform(
47
+ nav:
48
+ | { platform?: string; userAgent?: string }
49
+ | undefined = globalThis.navigator,
50
+ ): boolean {
51
+ if (!nav) return false;
52
+ return /Mac|iPhone|iPad|iPod/i.test(nav.platform || nav.userAgent || '');
53
+ }
54
+
55
+ function sortKeys(keys: ShortcutKey[], order: string[]): ShortcutKey[] {
56
+ const rank = (key: string) => {
57
+ const index = order.indexOf(key.toLowerCase());
58
+ return index === -1 ? order.length : index;
59
+ };
60
+ return [...keys].sort((a, b) => rank(a) - rank(b));
61
+ }
62
+
63
+ function keyLabel(key: ShortcutKey, map: Record<string, string>): string {
64
+ return map[key.toLowerCase()] ?? (key.length === 1 ? key.toUpperCase() : key);
65
+ }
66
+
67
+ /** Подпись сочетания: `['mod', 'k']` → «⌘K» (macOS) / «Ctrl K». */
68
+ export function formatShortcut(
69
+ keys: ShortcutKey[],
70
+ apple: boolean = isApplePlatform(),
71
+ ): string {
72
+ const sorted = sortKeys(keys, apple ? MAC_ORDER : OTHER_ORDER);
73
+ return sorted
74
+ .map((key) => keyLabel(key, apple ? MAC : OTHER))
75
+ .join(apple ? '' : ' ');
76
+ }
77
+
78
+ /** Значение `aria-keyshortcuts`: `['mod', 'k']` → «Meta+K» (macOS) / «Control+K». */
79
+ export function formatAriaShortcut(
80
+ keys: ShortcutKey[],
81
+ apple: boolean = isApplePlatform(),
82
+ ): string {
83
+ const ARIA: Record<string, string> = {
84
+ mod: apple ? 'Meta' : 'Control',
85
+ meta: 'Meta',
86
+ control: 'Control',
87
+ ctrl: 'Control',
88
+ shift: 'Shift',
89
+ alt: 'Alt',
90
+ enter: 'Enter',
91
+ esc: 'Escape',
92
+ escape: 'Escape',
93
+ arrowup: 'ArrowUp',
94
+ arrowdown: 'ArrowDown',
95
+ arrowleft: 'ArrowLeft',
96
+ arrowright: 'ArrowRight',
97
+ };
98
+ return sortKeys(keys, OTHER_ORDER)
99
+ .map(
100
+ (key) =>
101
+ ARIA[key.toLowerCase()] ?? (key.length === 1 ? key.toUpperCase() : key),
102
+ )
103
+ .join('+');
104
+ }
@@ -0,0 +1,277 @@
1
+ import {
2
+ inject,
3
+ onBeforeUnmount,
4
+ onMounted,
5
+ provide,
6
+ type InjectionKey,
7
+ type Ref,
8
+ } from 'vue';
9
+
10
+ /**
11
+ * Режим grid у KTable (WAI-ARIA Data Grid): одна остановка Tab на всю таблицу (roving tabindex),
12
+ * стрелки, Home/End (строка), Ctrl+Home/Ctrl+End (вся таблица), PageUp/PageDown (по 10 строк).
13
+ * Ячейки ищутся по DOM (строки thead/tbody/tfoot, ячейки td/th), шапка — тоже строка grid. Фокус в ячейке —
14
+ * на её единственный виджет (ссылка, чекбокс, кнопка меню, кнопка сортировки), иначе на саму
15
+ * ячейку. Ячейка с открытым редактором (`data-editing`) клавиши не отдаёт: Enter, Tab, Esc и
16
+ * стрелки внутри редактора — его.
17
+ */
18
+ export interface GridPosition {
19
+ row: number;
20
+ col: number;
21
+ }
22
+
23
+ export type GridKey =
24
+ | 'ArrowUp'
25
+ | 'ArrowDown'
26
+ | 'ArrowLeft'
27
+ | 'ArrowRight'
28
+ | 'Home'
29
+ | 'End'
30
+ | 'PageUp'
31
+ | 'PageDown';
32
+
33
+ const GRID_KEYS = new Set<string>([
34
+ 'ArrowUp',
35
+ 'ArrowDown',
36
+ 'ArrowLeft',
37
+ 'ArrowRight',
38
+ 'Home',
39
+ 'End',
40
+ 'PageUp',
41
+ 'PageDown',
42
+ ]);
43
+
44
+ export const GRID_PAGE_SIZE = 10;
45
+
46
+ export function isGridKey(key: string): key is GridKey {
47
+ return GRID_KEYS.has(key);
48
+ }
49
+
50
+ /**
51
+ * Следующая позиция в сетке; `colCount(row)` — число ячеек в строке (строки бывают разной длины).
52
+ * Края не зацикливаются. Колонка при переходе в короткую строку прижимается к последней ячейке.
53
+ */
54
+ export function nextGridPosition(
55
+ from: GridPosition,
56
+ key: GridKey,
57
+ rowCount: number,
58
+ colCount: (row: number) => number,
59
+ ctrl = false,
60
+ ): GridPosition {
61
+ const clampCol = (row: number, col: number) =>
62
+ Math.max(0, Math.min(col, colCount(row) - 1));
63
+ const toRow = (row: number) => {
64
+ const target = Math.max(0, Math.min(row, rowCount - 1));
65
+ return { row: target, col: clampCol(target, from.col) };
66
+ };
67
+ switch (key) {
68
+ case 'ArrowUp':
69
+ return toRow(from.row - 1);
70
+ case 'ArrowDown':
71
+ return toRow(from.row + 1);
72
+ case 'PageUp':
73
+ return toRow(from.row - GRID_PAGE_SIZE);
74
+ case 'PageDown':
75
+ return toRow(from.row + GRID_PAGE_SIZE);
76
+ case 'ArrowLeft':
77
+ return { row: from.row, col: clampCol(from.row, from.col - 1) };
78
+ case 'ArrowRight':
79
+ return { row: from.row, col: clampCol(from.row, from.col + 1) };
80
+ case 'Home':
81
+ return ctrl ? { row: 0, col: 0 } : { row: from.row, col: 0 };
82
+ case 'End': {
83
+ const row = ctrl ? rowCount - 1 : from.row;
84
+ return { row, col: colCount(row) - 1 };
85
+ }
86
+ }
87
+ }
88
+
89
+ /** Виджеты, которые получают фокус вместо ячейки (и которым roving снимает Tab). */
90
+ const FOCUSABLE =
91
+ 'a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not(td):not(th), [contenteditable="true"]';
92
+
93
+ export interface GridContext {
94
+ /** Перевести фокус на ячейку (или её виджет) и сделать её остановкой Tab. */
95
+ focusCell(cell: HTMLElement): void;
96
+ /** Сдвиг от ячейки: (1, 0) — вниз (Enter в редакторе), (0, 1) — вправо (Tab). */
97
+ move(from: HTMLElement, rowDelta: number, colDelta: number): void;
98
+ }
99
+
100
+ const GRID_CONTEXT: InjectionKey<GridContext | null> = Symbol('KTableGrid');
101
+
102
+ /** Контекст grid для частей таблицы; вне grid — null (обычная таблица). */
103
+ export function injectGridContext(): GridContext | null {
104
+ return inject(GRID_CONTEXT, null);
105
+ }
106
+
107
+ function cellOf(table: HTMLTableElement, node: EventTarget | null) {
108
+ if (!(node instanceof Element)) return null;
109
+ const cell = node.closest<HTMLTableCellElement>('td, th');
110
+ return cell && cell.closest('table') === table ? cell : null;
111
+ }
112
+
113
+ /** Строки таблицы по порядку (шапка, тело, подвал); вложенные таблицы не входят. */
114
+ function rowsOf(table: HTMLTableElement): HTMLTableRowElement[] {
115
+ return [
116
+ ...table.querySelectorAll<HTMLTableRowElement>(
117
+ ':scope > thead > tr, :scope > tbody > tr, :scope > tfoot > tr, :scope > tr',
118
+ ),
119
+ ];
120
+ }
121
+
122
+ function cellsOf(row: HTMLTableRowElement | undefined): HTMLTableCellElement[] {
123
+ if (!row) return [];
124
+ return [...row.children].filter(
125
+ (el): el is HTMLTableCellElement =>
126
+ el.tagName === 'TD' || el.tagName === 'TH',
127
+ );
128
+ }
129
+
130
+ function positionOf(
131
+ rows: HTMLTableRowElement[],
132
+ cell: HTMLTableCellElement,
133
+ ): GridPosition {
134
+ const row = cell.parentElement as HTMLTableRowElement;
135
+ return { row: rows.indexOf(row), col: cellsOf(row).indexOf(cell) };
136
+ }
137
+
138
+ /** Куда ставить фокус в ячейке: её единственный (первый) виджет или сама ячейка. */
139
+ export function focusTargetOf(cell: HTMLElement): HTMLElement {
140
+ return cell.querySelector<HTMLElement>(FOCUSABLE) ?? cell;
141
+ }
142
+
143
+ const isEditing = (cell: Element) => cell.hasAttribute('data-editing');
144
+
145
+ /**
146
+ * Подключить grid к таблице: provide контекста, roving tabindex, клавиатура. Активная ячейка
147
+ * по умолчанию — первая ячейка тела (нет строк — первая в шапке); после перерисовки (новые
148
+ * строки, другая страница) остановка Tab восстанавливается. Режим задаётся при создании таблицы.
149
+ */
150
+ export function useTableGrid(tableRef: Ref<HTMLTableElement | null>): void {
151
+ let active: HTMLTableCellElement | null = null;
152
+ let observer: MutationObserver | null = null;
153
+ let scheduled = false;
154
+
155
+ const table = () => tableRef.value;
156
+
157
+ function defaultCell(t: HTMLTableElement): HTMLTableCellElement | null {
158
+ const body = t.querySelector<HTMLTableRowElement>(':scope > tbody > tr');
159
+ return cellsOf(body ?? rowsOf(t)[0])[0] ?? null;
160
+ }
161
+
162
+ function cellAt(rows: HTMLTableRowElement[], pos: GridPosition) {
163
+ return cellsOf(rows[pos.row])[pos.col] ?? null;
164
+ }
165
+
166
+ /** Ровно одна остановка Tab: цель активной ячейки — 0, остальные ячейки и виджеты — −1. */
167
+ function sync(): void {
168
+ const t = table();
169
+ if (!t) return;
170
+ if (!active || !t.contains(active)) active = defaultCell(t);
171
+ for (const row of rowsOf(t)) {
172
+ for (const cell of cellsOf(row)) {
173
+ if (isEditing(cell)) continue;
174
+ const target = focusTargetOf(cell);
175
+ cell.tabIndex = cell === active && target === cell ? 0 : -1;
176
+ for (const widget of cell.querySelectorAll<HTMLElement>(FOCUSABLE)) {
177
+ widget.tabIndex = cell === active && widget === target ? 0 : -1;
178
+ }
179
+ }
180
+ }
181
+ }
182
+
183
+ function scheduleSync(): void {
184
+ if (scheduled) return;
185
+ scheduled = true;
186
+ queueMicrotask(() => {
187
+ scheduled = false;
188
+ sync();
189
+ });
190
+ }
191
+
192
+ function focusCell(cell: HTMLElement): void {
193
+ const t = table();
194
+ const target = t ? cellOf(t, cell) : null;
195
+ if (!target) return;
196
+ active = target;
197
+ sync();
198
+ focusTargetOf(target).focus();
199
+ }
200
+
201
+ function move(from: HTMLElement, rowDelta: number, colDelta: number): void {
202
+ const t = table();
203
+ const cell = t ? cellOf(t, from) : null;
204
+ if (!t || !cell) return;
205
+ const rows = rowsOf(t);
206
+ const pos = positionOf(rows, cell);
207
+ const row = Math.max(0, Math.min(pos.row + rowDelta, rows.length - 1));
208
+ const cells = cellsOf(rows[row]).length;
209
+ const next = cellAt(rows, {
210
+ row,
211
+ col: Math.max(0, Math.min(pos.col + colDelta, cells - 1)),
212
+ });
213
+ if (next) focusCell(next);
214
+ }
215
+
216
+ function onKeydown(event: KeyboardEvent): void {
217
+ const t = table();
218
+ if (!t || !isGridKey(event.key) || event.altKey) return;
219
+ const cell = cellOf(t, event.target);
220
+ if (!cell || isEditing(cell)) return;
221
+ const target = event.target as HTMLElement;
222
+ // Текстовое поле в ячейке без редактора — стрелки двигают курсор, не фокус
223
+ if (
224
+ target !== cell &&
225
+ (target.matches('input:not([type="checkbox"]), textarea, select') ||
226
+ target.isContentEditable)
227
+ )
228
+ return;
229
+ const rows = rowsOf(t);
230
+ const next = nextGridPosition(
231
+ positionOf(rows, cell),
232
+ event.key,
233
+ rows.length,
234
+ (row) => cellsOf(rows[row]).length,
235
+ event.ctrlKey || event.metaKey,
236
+ );
237
+ // Перехватываем раньше виджета: кнопка меню не открывается по ↓, страница не прокручивается
238
+ event.preventDefault();
239
+ event.stopPropagation();
240
+ const nextCell = cellAt(rows, next);
241
+ if (nextCell && nextCell !== cell) focusCell(nextCell);
242
+ }
243
+
244
+ function onFocusin(event: FocusEvent): void {
245
+ const t = table();
246
+ const cell = t ? cellOf(t, event.target) : null;
247
+ if (!cell || cell === active) return;
248
+ active = cell;
249
+ sync();
250
+ }
251
+
252
+ provide(GRID_CONTEXT, {
253
+ focusCell,
254
+ move,
255
+ });
256
+
257
+ onMounted(() => {
258
+ const t = tableRef.value;
259
+ if (!t) return;
260
+ t.addEventListener('keydown', onKeydown, true);
261
+ t.addEventListener('focusin', onFocusin);
262
+ observer = new MutationObserver(scheduleSync);
263
+ observer.observe(t, { childList: true, subtree: true });
264
+ sync();
265
+ });
266
+ onBeforeUnmount(() => {
267
+ const t = tableRef.value;
268
+ t?.removeEventListener('keydown', onKeydown, true);
269
+ t?.removeEventListener('focusin', onFocusin);
270
+ observer?.disconnect();
271
+ });
272
+ }
273
+
274
+ /** Для KTable: provide null вне grid, чтобы вложенная таблица не унаследовала grid внешней. */
275
+ export function provideNoGrid(): void {
276
+ provide(GRID_CONTEXT, null);
277
+ }
@@ -0,0 +1,59 @@
1
+ import { readonly, ref } from 'vue';
2
+
3
+ /** Penpot: Toast — Tone Info / Success / Warning / Danger. */
4
+ export type ToastTone = 'info' | 'success' | 'warning' | 'danger';
5
+
6
+ /** Кнопка действия в тосте (Penpot: Toast — Action): «Отменить», «Открыть»… Клик закрывает тост. */
7
+ export interface ToastAction {
8
+ label: string;
9
+ onClick: () => void;
10
+ }
11
+
12
+ export interface ToastMessage {
13
+ id: number;
14
+ tone: ToastTone;
15
+ title: string;
16
+ description?: string;
17
+ action?: ToastAction;
18
+ /** мс; danger по умолчанию висит дольше — ошибку надо успеть прочитать */
19
+ duration: number;
20
+ }
21
+
22
+ export type ToastInput = Omit<ToastMessage, 'id' | 'duration' | 'tone'> & {
23
+ duration?: number;
24
+ };
25
+
26
+ const DEFAULT_DURATION: Record<ToastTone, number> = {
27
+ info: 5000,
28
+ success: 4000,
29
+ warning: 7000,
30
+ danger: 10000,
31
+ };
32
+
33
+ const toasts = ref<ToastMessage[]>([]);
34
+ let nextId = 1;
35
+
36
+ function show(tone: ToastTone, input: ToastInput): number {
37
+ const id = nextId++;
38
+ toasts.value = [
39
+ ...toasts.value,
40
+ { ...input, id, tone, duration: input.duration ?? DEFAULT_DURATION[tone] },
41
+ ];
42
+ return id;
43
+ }
44
+
45
+ function dismiss(id: number): void {
46
+ toasts.value = toasts.value.filter((t) => t.id !== id);
47
+ }
48
+
49
+ /** Уведомления из любого места: `useToast().success({ title: 'Сохранено' })`. Показывает KToaster. */
50
+ export function useToast() {
51
+ return {
52
+ toasts: readonly(toasts),
53
+ info: (input: ToastInput) => show('info', input),
54
+ success: (input: ToastInput) => show('success', input),
55
+ warning: (input: ToastInput) => show('warning', input),
56
+ danger: (input: ToastInput) => show('danger', input),
57
+ dismiss,
58
+ };
59
+ }
@@ -0,0 +1,70 @@
1
+ import {
2
+ type MaybeRefOrGetter,
3
+ onMounted,
4
+ onUnmounted,
5
+ ref,
6
+ toValue,
7
+ } from 'vue';
8
+
9
+ const hasFiles = (event: DragEvent) =>
10
+ [...(event.dataTransfer?.types ?? [])].includes('Files');
11
+
12
+ /** Сколько зон на странице: слушатель окна один, снимается вместе с последней зоной. */
13
+ let mountedZones = 0;
14
+ function guardWindow(event: DragEvent): void {
15
+ // Иначе браузер откроет брошенный файл вместо админки (правки потеряются)
16
+ if (hasFiles(event)) event.preventDefault();
17
+ }
18
+
19
+ /**
20
+ * Перетаскивание файлов на зону: `dragging` для подсветки (dragenter/dragleave приходят и от
21
+ * дочерних элементов — считается вложенность), `onDrop(files)` — брошенные файлы. Пока зона
22
+ * на странице, бросок файла мимо неё не уводит со страницы.
23
+ */
24
+ export function useFileDrop(
25
+ disabled: MaybeRefOrGetter<boolean>,
26
+ onFiles: (files: FileList | undefined) => void,
27
+ ) {
28
+ const dragging = ref(false);
29
+ let depth = 0;
30
+
31
+ onMounted(() => {
32
+ mountedZones += 1;
33
+ if (mountedZones > 1) return;
34
+ window.addEventListener('dragover', guardWindow);
35
+ window.addEventListener('drop', guardWindow);
36
+ });
37
+ onUnmounted(() => {
38
+ mountedZones -= 1;
39
+ if (mountedZones > 0) return;
40
+ window.removeEventListener('dragover', guardWindow);
41
+ window.removeEventListener('drop', guardWindow);
42
+ });
43
+
44
+ const listeners = {
45
+ dragenter(event: DragEvent): void {
46
+ if (toValue(disabled) || !hasFiles(event)) return;
47
+ depth += 1;
48
+ dragging.value = true;
49
+ },
50
+ dragover(event: DragEvent): void {
51
+ if (toValue(disabled) || !hasFiles(event)) return;
52
+ // Без preventDefault браузер не даст бросить файл
53
+ event.preventDefault();
54
+ if (event.dataTransfer) event.dataTransfer.dropEffect = 'copy';
55
+ },
56
+ dragleave(): void {
57
+ depth = Math.max(0, depth - 1);
58
+ if (depth === 0) dragging.value = false;
59
+ },
60
+ drop(event: DragEvent): void {
61
+ depth = 0;
62
+ dragging.value = false;
63
+ if (toValue(disabled)) return;
64
+ event.preventDefault();
65
+ onFiles(event.dataTransfer?.files);
66
+ },
67
+ };
68
+
69
+ return { dragging, listeners };
70
+ }
@@ -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,46 @@
1
+ <script setup lang="ts">
2
+ import { Ellipsis, Pencil, Trash2 } from '@lucide/vue';
3
+ import { computed } from 'vue';
4
+ import { useRouter } from 'vue-router';
5
+ import type { PublicUser } from '../api/types.js';
6
+ import { KButton, KDropdownMenu, type MenuAction } from '../ui/index.js';
7
+
8
+ /** Меню «…» пользователя: открыть, удалить (не себя). */
9
+ const props = defineProps<{ user: PublicUser; self: boolean }>();
10
+ const emit = defineEmits<{ delete: [] }>();
11
+ const router = useRouter();
12
+
13
+ const actions = computed<MenuAction[]>(() => [
14
+ {
15
+ label: 'Открыть',
16
+ icon: Pencil,
17
+ onSelect: () =>
18
+ void router.push({ name: 'user', params: { id: props.user.id } }),
19
+ },
20
+ ...(props.self
21
+ ? []
22
+ : [
23
+ {
24
+ label: 'Удалить',
25
+ icon: Trash2,
26
+ tone: 'danger' as const,
27
+ onSelect: () => emit('delete'),
28
+ },
29
+ ]),
30
+ ]);
31
+ </script>
32
+
33
+ <template>
34
+ <KDropdownMenu :actions="actions">
35
+ <template #trigger>
36
+ <KButton
37
+ variant="ghost"
38
+ size="sm"
39
+ icon-only
40
+ :aria-label="`Действия: ${user.name}`"
41
+ >
42
+ <Ellipsis :size="16" />
43
+ </KButton>
44
+ </template>
45
+ </KDropdownMenu>
46
+ </template>
@@ -0,0 +1,44 @@
1
+ <script setup lang="ts">
2
+ import { RouterLink } from 'vue-router';
3
+ import type { PublicUser } from '../api/types.js';
4
+ import { KTooltip } from '../ui/index.js';
5
+ import UserActions from './UserActions.vue';
6
+ import UserRoleBadge from './UserRoleBadge.vue';
7
+
8
+ /**
9
+ * Карточка пользователя на мобильных: имя (обрезается — полный текст в KTooltip), email, роль,
10
+ * меню «…». Не KCard — по той же причине, что DocumentCard: в карточке-ссылке нельзя меню «…»,
11
+ * а заголовок статичной KCard — typo-heading-3.
12
+ */
13
+ defineProps<{ user: PublicUser; self: boolean }>();
14
+ defineEmits<{ delete: [] }>();
15
+ </script>
16
+
17
+ <template>
18
+ <article
19
+ class="flex flex-col gap-2 rounded-lg border border-border-default bg-bg-surface p-4"
20
+ >
21
+ <div class="flex items-start justify-between gap-2">
22
+ <KTooltip :content="user.name">
23
+ <RouterLink
24
+ :to="{ name: 'user', params: { id: user.id } }"
25
+ class="min-w-0 truncate rounded-sm typo-body-strong text-fg-default outline-none focus-visible:shadow-focus"
26
+ >
27
+ {{ user.name }}
28
+ </RouterLink>
29
+ </KTooltip>
30
+ <UserActions
31
+ :user="user"
32
+ :self="self"
33
+ class="-mt-1 -mr-1"
34
+ @delete="$emit('delete')"
35
+ />
36
+ </div>
37
+ <div
38
+ class="flex flex-wrap items-center justify-between gap-2 typo-caption text-fg-muted"
39
+ >
40
+ <span class="min-w-0 truncate">{{ user.email }}</span>
41
+ <UserRoleBadge :role-name="user.roleName" />
42
+ </div>
43
+ </article>
44
+ </template>