@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.
- package/CHANGELOG.md +17 -0
- package/LICENSE +21 -0
- package/README.md +93 -2
- package/design-tokens/kodacms.tokens.json +1360 -0
- package/dist/apple-touch-icon.png +0 -0
- package/dist/assets/AuditView-DCgrAjma.js +1 -0
- package/dist/assets/CollectionView-CY3zK1CE.js +1 -0
- package/dist/assets/CustomComponent-B1mxHHd0.js +1 -0
- package/dist/assets/CustomPageView-BTsy9MC8.js +1 -0
- package/dist/assets/DashboardView-ujWhLuS2.js +1 -0
- package/dist/assets/DeleteDocumentsDialog-D1nx27UG.js +1 -0
- package/dist/assets/DocumentHistoryView-Ko633-Dy.js +1 -0
- package/dist/assets/DocumentView-CPEjwzzo.js +1 -0
- package/dist/assets/GlobalHistoryView-CbwdeYpn.js +1 -0
- package/dist/assets/GlobalView-DcTGexxK.js +1 -0
- package/dist/assets/KAlert-DoR81cyQ.js +1 -0
- package/dist/assets/KCard-DNom764U.js +1 -0
- package/dist/assets/KDropdownMenu-BECk5S9K.js +1 -0
- package/dist/assets/KField-CvINPmYu.js +1 -0
- package/dist/assets/KPagination-DQOzrRaf.js +1 -0
- package/dist/assets/KPasswordInput-EPBXvtXG.js +1 -0
- package/dist/assets/KSeparator-DEbXnpDV.js +1 -0
- package/dist/assets/KTableRow-Dpp2Lk2V.js +1 -0
- package/dist/assets/KTabs-b95D7hep.js +1 -0
- package/dist/assets/KTextarea-CCveuS_I.js +1 -0
- package/dist/assets/Label-m9Ig3v9B.js +1 -0
- package/dist/assets/ListFooter-qYmCWY4R.js +1 -0
- package/dist/assets/LoadError-BRccywgs.js +1 -0
- package/dist/assets/LoginView-DvTtEJxp.js +1 -0
- package/dist/assets/NoAccessView-Bg69btHE.js +1 -0
- package/dist/assets/NotFoundView-qhJ2ixSH.js +1 -0
- package/dist/assets/PageHeader-B3riLtJg.js +1 -0
- package/dist/assets/PopoverAnchor-BwL6g4vt.js +1 -0
- package/dist/assets/PopoverContentImpl-Dq0cbuHV.js +1 -0
- package/dist/assets/PopoverContentModal-BEl8rmbI.js +1 -0
- package/dist/assets/PopoverContentNonModal-D5osgtpx.js +1 -0
- package/dist/assets/RoleView-D9732bW6.js +1 -0
- package/dist/assets/RolesView-Du4NUhQJ.js +1 -0
- package/dist/assets/TooltipContentHoverable-C18vbtIU.js +1 -0
- package/dist/assets/TooltipContentImpl-CCpG79EA.js +1 -0
- package/dist/assets/TooltipContentImpl-DQFjU6ri.js +1 -0
- package/dist/assets/UploadQueueItem-BbG5x7WM.js +6 -0
- package/dist/assets/UserView-iFK1eFT9.js +1 -0
- package/dist/assets/UsersView-B6fCtC-4.js +1 -0
- package/dist/assets/columns-DmJOzXV9.js +1 -0
- package/dist/assets/ellipsis-BNwYKZMS.js +1 -0
- package/dist/assets/error-text-1F8qU3pC.js +1 -0
- package/dist/assets/eye-DyBObYiE.js +1 -0
- package/dist/assets/eye-off-Bd_6erac.js +1 -0
- package/dist/assets/form-layout-Dk2JVUC0.js +1 -0
- package/dist/assets/globals-BMIQQR5f.js +1 -0
- package/dist/assets/index-CGdQZeTs.css +2 -0
- package/dist/assets/index-a4P44W6e.js +14 -0
- package/dist/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2 +0 -0
- package/dist/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2 +0 -0
- package/dist/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2 +0 -0
- package/dist/assets/inter-greek-wght-normal-CkhJZR-_.woff2 +0 -0
- package/dist/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2 +0 -0
- package/dist/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
- package/dist/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2 +0 -0
- package/dist/assets/jetbrains-mono-cyrillic-ext-wght-normal-EocZY2iu.woff2 +0 -0
- package/dist/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
- package/dist/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
- package/dist/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
- package/dist/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
- package/dist/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
- package/dist/assets/list-query-DcmvyLSO.js +1 -0
- package/dist/assets/rolldown-runtime-P3Pd_6ND.js +1 -0
- package/dist/assets/select-options-osOjd-zR.js +1 -0
- package/dist/assets/useAuditState-D6n8HXQ2.js +1 -0
- package/dist/assets/useDebounced-BVo96C1E.js +1 -0
- package/dist/assets/useHistoryLocale-BWBBUuQi.js +1 -0
- package/dist/assets/useListState-CTgxjU_g.js +1 -0
- package/dist/assets/useLocaleDocument-DkvwSG3X.js +1 -0
- package/dist/assets/usePageHeader-wYdFq9cQ.js +1 -0
- package/dist/assets/useRoleDelete-DFwroHOv.js +1 -0
- package/dist/assets/useSaveShortcut-DFNu_TAL.js +1 -0
- package/dist/assets/useUserDelete-83wa7pqC.js +1 -0
- package/dist/assets/useUsersAccess-1yVnzExk.js +1 -0
- package/dist/assets/users-NiowxtJB.js +1 -0
- package/dist/assets/validate-CEcXMakk.js +1 -0
- package/dist/favicon.svg +12 -0
- package/dist/index.html +16 -0
- package/dist/koda-components.json +4 -0
- package/index.html +15 -0
- package/package.json +68 -4
- package/public/apple-touch-icon.png +0 -0
- package/public/favicon.svg +12 -0
- package/src/App.vue +17 -0
- package/src/api/access.ts +110 -0
- package/src/api/admin-config.ts +318 -0
- package/src/api/admin-fields.ts +557 -0
- package/src/api/admin-layout.ts +191 -0
- package/src/api/api-error.ts +78 -0
- package/src/api/audit.ts +170 -0
- package/src/api/client.ts +153 -0
- package/src/api/documents.ts +470 -0
- package/src/api/drafts.ts +115 -0
- package/src/api/error-text.ts +11 -0
- package/src/api/globals.ts +133 -0
- package/src/api/http.ts +24 -0
- package/src/api/locale.ts +48 -0
- package/src/api/permissions.ts +194 -0
- package/src/api/relations.ts +86 -0
- package/src/api/roles.ts +170 -0
- package/src/api/scopes.ts +91 -0
- package/src/api/search-query.ts +33 -0
- package/src/api/search.ts +39 -0
- package/src/api/types.ts +39 -0
- package/src/api/upload.ts +146 -0
- package/src/api/users.ts +88 -0
- package/src/api/versions.ts +206 -0
- package/src/api/where-query.ts +79 -0
- package/src/audit/AuditActionBadge.vue +13 -0
- package/src/audit/AuditActor.vue +34 -0
- package/src/audit/AuditCard.vue +68 -0
- package/src/audit/AuditDrawer.vue +86 -0
- package/src/audit/AuditDrawerActions.vue +70 -0
- package/src/audit/AuditEntryBody.vue +74 -0
- package/src/audit/AuditEntryChanges.vue +88 -0
- package/src/audit/AuditEntryFacts.vue +47 -0
- package/src/audit/AuditFilterBar.vue +55 -0
- package/src/audit/AuditFilterControls.vue +148 -0
- package/src/audit/AuditFiltersDrawer.vue +46 -0
- package/src/audit/AuditHistory.vue +136 -0
- package/src/audit/AuditList.vue +183 -0
- package/src/audit/AuditListStates.vue +70 -0
- package/src/audit/AuditRestoredVersion.vue +66 -0
- package/src/audit/AuditSearch.vue +40 -0
- package/src/audit/AuditTable.vue +116 -0
- package/src/audit/HistoryTabs.vue +48 -0
- package/src/audit/audit-changes.ts +161 -0
- package/src/audit/audit-filters.ts +152 -0
- package/src/audit/audit-view.ts +372 -0
- package/src/audit/useAuditContext.ts +23 -0
- package/src/audit/useAuditFilterOptions.ts +67 -0
- package/src/audit/useAuditState.ts +82 -0
- package/src/brand/KodaMark.vue +42 -0
- package/src/composables/useAccessView.ts +120 -0
- package/src/composables/useDebounced.ts +15 -0
- package/src/composables/usePageHeader.ts +20 -0
- package/src/composables/useSessionCacheReset.ts +23 -0
- package/src/composables/useTheme.ts +79 -0
- package/src/composables/useUsersAccess.ts +13 -0
- package/src/custom/CustomComponent.vue +103 -0
- package/src/custom/CustomComponentNotice.vue +71 -0
- package/src/custom/CustomInserts.vue +36 -0
- package/src/custom/component-name.ts +18 -0
- package/src/custom/error-info.ts +22 -0
- package/src/custom/form-context.ts +44 -0
- package/src/custom/list-context.ts +44 -0
- package/src/custom/place.ts +126 -0
- package/src/custom/registry.ts +101 -0
- package/src/custom/useCustomComponent.ts +136 -0
- package/src/custom/useFormZones.ts +65 -0
- package/src/custom/useListZones.ts +38 -0
- package/src/custom/user-components.ts +20 -0
- package/src/custom/zone-components.ts +53 -0
- package/src/documents/DocumentForm.vue +168 -0
- package/src/documents/DocumentList.vue +190 -0
- package/src/documents/cells/CheckboxCell.vue +16 -0
- package/src/documents/cells/DateCell.vue +26 -0
- package/src/documents/cells/FallbackCell.vue +23 -0
- package/src/documents/cells/FileSizeCell.vue +14 -0
- package/src/documents/cells/IdCell.vue +14 -0
- package/src/documents/cells/MimeCell.vue +15 -0
- package/src/documents/cells/NumberCell.vue +13 -0
- package/src/documents/cells/RelationshipCell.vue +33 -0
- package/src/documents/cells/RowsCell.vue +21 -0
- package/src/documents/cells/SelectCell.vue +23 -0
- package/src/documents/cells/StatusCell.vue +18 -0
- package/src/documents/cells/TextCell.vue +16 -0
- package/src/documents/cells/ThumbnailCell.vue +31 -0
- package/src/documents/cells/UploadCell.vue +53 -0
- package/src/documents/cells/UploadCellThumb.vue +27 -0
- package/src/documents/cells/cell-props.ts +12 -0
- package/src/documents/cells/registry.ts +44 -0
- package/src/documents/cells/select-options.ts +18 -0
- package/src/documents/drafts/DraftActions.vue +62 -0
- package/src/documents/drafts/DraftStatus.vue +100 -0
- package/src/documents/drafts/StatusBadge.vue +23 -0
- package/src/documents/drafts/UnpublishDialog.vue +25 -0
- package/src/documents/drafts/useAutosave.ts +88 -0
- package/src/documents/drafts/useDrafts.ts +73 -0
- package/src/documents/fields/CheckboxControl.vue +13 -0
- package/src/documents/fields/DateControl.vue +22 -0
- package/src/documents/fields/FieldControl.vue +55 -0
- package/src/documents/fields/FieldDescription.vue +34 -0
- package/src/documents/fields/FieldRenderer.vue +92 -0
- package/src/documents/fields/GroupChildren.vue +28 -0
- package/src/documents/fields/GroupErrors.vue +49 -0
- package/src/documents/fields/GroupFields.vue +87 -0
- package/src/documents/fields/JsonControl.vue +20 -0
- package/src/documents/fields/NumberControl.vue +20 -0
- package/src/documents/fields/ReadOnlyControl.vue +18 -0
- package/src/documents/fields/SelectControl.vue +46 -0
- package/src/documents/fields/TextControl.vue +37 -0
- package/src/documents/fields/TextareaControl.vue +18 -0
- package/src/documents/fields/ValueField.vue +87 -0
- package/src/documents/fields/field-control.ts +10 -0
- package/src/documents/fields/registry.ts +56 -0
- package/src/documents/fields/relation/JoinControl.vue +41 -0
- package/src/documents/fields/relation/RelationshipControl.vue +57 -0
- package/src/documents/fields/relation/useRelationPicker.ts +96 -0
- package/src/documents/fields/rows/ArrayFields.vue +72 -0
- package/src/documents/fields/rows/BlocksFields.vue +90 -0
- package/src/documents/fields/rows/RowCard.vue +81 -0
- package/src/documents/fields/rows/RowFields.vue +32 -0
- package/src/documents/fields/rows/RowsFieldset.vue +51 -0
- package/src/documents/fields/rows/row-title.ts +29 -0
- package/src/documents/fields/rows/useRows.ts +32 -0
- package/src/documents/fields/upload/MediaGrid.vue +61 -0
- package/src/documents/fields/upload/MediaLibrary.vue +131 -0
- package/src/documents/fields/upload/MediaPickerDialog.vue +54 -0
- package/src/documents/fields/upload/MediaTile.vue +69 -0
- package/src/documents/fields/upload/MediaUploadArea.vue +60 -0
- package/src/documents/fields/upload/UploadControl.vue +157 -0
- package/src/documents/fields/upload/UploadValueItem.vue +108 -0
- package/src/documents/fields/upload/upload-field.ts +77 -0
- package/src/documents/fields/upload/useFieldUploads.ts +60 -0
- package/src/documents/fields/upload/useMediaLibrary.ts +77 -0
- package/src/documents/fields/useCustomFieldModel.ts +32 -0
- package/src/documents/fields/useFieldLocale.ts +38 -0
- package/src/documents/form/DocumentFields.vue +28 -0
- package/src/documents/form/DocumentHeader.vue +50 -0
- package/src/documents/form/DocumentMeta.vue +99 -0
- package/src/documents/form/UnsavedChangesDialog.vue +27 -0
- package/src/documents/form/created-by.ts +12 -0
- package/src/documents/form/field-errors.ts +29 -0
- package/src/documents/form/field-value.ts +229 -0
- package/src/documents/form/focus-first-error.ts +43 -0
- package/src/documents/form/form-conditions.ts +106 -0
- package/src/documents/form/form-layout.ts +245 -0
- package/src/documents/form/form-values.ts +265 -0
- package/src/documents/form/layout/LayoutBlock.vue +32 -0
- package/src/documents/form/layout/LayoutItems.vue +43 -0
- package/src/documents/form/layout/LayoutLeaf.vue +33 -0
- package/src/documents/form/layout/LayoutRow.vue +60 -0
- package/src/documents/form/layout/LayoutSection.vue +73 -0
- package/src/documents/form/layout/LayoutStack.vue +20 -0
- package/src/documents/form/layout/LayoutTabs.vue +74 -0
- package/src/documents/form/relation-value.ts +160 -0
- package/src/documents/form/rows.ts +24 -0
- package/src/documents/form/save-messages.ts +65 -0
- package/src/documents/form/useDocumentDelete.ts +38 -0
- package/src/documents/form/useDocumentEditor.ts +167 -0
- package/src/documents/form/useDocumentForm.ts +37 -0
- package/src/documents/form/useDocumentRights.ts +45 -0
- package/src/documents/form/useDocumentSubmit.ts +128 -0
- package/src/documents/form/useFieldsForm.ts +238 -0
- package/src/documents/form/useFormLayout.ts +21 -0
- package/src/documents/form/useFormTabs.ts +54 -0
- package/src/documents/form/useLeaveGuard.ts +69 -0
- package/src/documents/form/useSaveShortcut.ts +13 -0
- package/src/documents/form/validate.ts +220 -0
- package/src/documents/list/CellConflictMessage.vue +24 -0
- package/src/documents/list/CellEditor.vue +155 -0
- package/src/documents/list/CellRelationEditor.vue +62 -0
- package/src/documents/list/DeleteDocumentsDialog.vue +42 -0
- package/src/documents/list/DocumentActions.vue +68 -0
- package/src/documents/list/DocumentCard.vue +84 -0
- package/src/documents/list/DocumentCards.vue +31 -0
- package/src/documents/list/DocumentRow.vue +86 -0
- package/src/documents/list/DocumentTable.vue +104 -0
- package/src/documents/list/InlineCell.vue +151 -0
- package/src/documents/list/InlineCheckboxCell.vue +99 -0
- package/src/documents/list/ListCell.vue +39 -0
- package/src/documents/list/ListCellValue.vue +59 -0
- package/src/documents/list/ListFooter.vue +50 -0
- package/src/documents/list/ListSearch.vue +44 -0
- package/src/documents/list/ListStates.vue +73 -0
- package/src/documents/list/ListToolbar.vue +37 -0
- package/src/documents/list/SelectionBar.vue +30 -0
- package/src/documents/list/cell-failure.ts +91 -0
- package/src/documents/list/cell-save.ts +129 -0
- package/src/documents/list/columns.ts +157 -0
- package/src/documents/list/inline-cells.ts +61 -0
- package/src/documents/list/inline-edit-context.ts +14 -0
- package/src/documents/list/inline-edit.ts +302 -0
- package/src/documents/list/list-query.ts +46 -0
- package/src/documents/list/row-overlay.ts +45 -0
- package/src/documents/list/sort.ts +32 -0
- package/src/documents/list/useCellEditorKeys.ts +78 -0
- package/src/documents/list/useCellEditorModel.ts +33 -0
- package/src/documents/list/useCellPopup.ts +94 -0
- package/src/documents/list/useDeleteFlow.ts +42 -0
- package/src/documents/list/useDocumentListData.ts +97 -0
- package/src/documents/list/useInlineEdit.ts +143 -0
- package/src/documents/list/useListInlineEdit.ts +68 -0
- package/src/documents/list/useListNotices.ts +58 -0
- package/src/documents/list/useListState.ts +67 -0
- package/src/documents/list/useRowPublish.ts +150 -0
- package/src/documents/upload/BulkUpload.vue +58 -0
- package/src/documents/upload/DocumentFileCard.vue +106 -0
- package/src/documents/upload/FileActions.vue +57 -0
- package/src/documents/upload/FileDetails.vue +40 -0
- package/src/documents/upload/UploadProgressRow.vue +29 -0
- package/src/documents/upload/UploadQueueItem.vue +150 -0
- package/src/documents/upload/UploadQueueSummary.vue +70 -0
- package/src/documents/upload/file-actions.ts +35 -0
- package/src/documents/upload/upload-logic.ts +209 -0
- package/src/documents/upload/upload-queue.ts +220 -0
- package/src/documents/upload/useDocumentFile.ts +93 -0
- package/src/documents/upload/useFileBlob.ts +132 -0
- package/src/documents/upload/useShownFile.ts +77 -0
- package/src/documents/versions/DiffOmitted.vue +34 -0
- package/src/documents/versions/DiffTree.vue +76 -0
- package/src/documents/versions/DiffValue.vue +101 -0
- package/src/documents/versions/HistoryLink.vue +17 -0
- package/src/documents/versions/RestoreVersionDialog.vue +58 -0
- package/src/documents/versions/VersionCard.vue +111 -0
- package/src/documents/versions/VersionHistory.vue +127 -0
- package/src/documents/versions/VersionSnapshot.vue +145 -0
- package/src/documents/versions/diff-view.ts +153 -0
- package/src/documents/versions/text-diff.ts +66 -0
- package/src/documents/versions/useRestoreFlow.ts +55 -0
- package/src/env.d.ts +17 -0
- package/src/format.ts +58 -0
- package/src/globals/GlobalForm.vue +139 -0
- package/src/globals/GlobalHeader.vue +39 -0
- package/src/globals/GlobalMeta.vue +67 -0
- package/src/globals/useGlobalEditor.ts +118 -0
- package/src/globals/useGlobalForm.ts +32 -0
- package/src/globals/useGlobalSubmit.ts +75 -0
- package/src/layout/AppBarMobile.vue +42 -0
- package/src/layout/AppLayout.vue +40 -0
- package/src/layout/AppTopbar.vue +28 -0
- package/src/layout/LoadError.vue +19 -0
- package/src/layout/MobileNavDrawer.vue +45 -0
- package/src/layout/PageHeader.vue +19 -0
- package/src/layout/ThemeToggle.vue +28 -0
- package/src/layout/palette/AppCommandPalette.vue +32 -0
- package/src/layout/palette/palette-actions.ts +54 -0
- package/src/layout/palette/palette-commands.ts +156 -0
- package/src/layout/palette/palette-documents.ts +73 -0
- package/src/layout/palette/palette-groups.ts +90 -0
- package/src/layout/palette/palette-hotkey.ts +39 -0
- package/src/layout/palette/recent-documents.ts +123 -0
- package/src/layout/palette/useCommandPalette.ts +75 -0
- package/src/layout/palette/useDocumentSearch.ts +88 -0
- package/src/layout/palette/useRememberDocument.ts +30 -0
- package/src/layout/sidebar/SidebarAdmin.vue +50 -0
- package/src/layout/sidebar/SidebarBrand.vue +14 -0
- package/src/layout/sidebar/SidebarCollections.vue +55 -0
- package/src/layout/sidebar/SidebarGlobals.vue +23 -0
- package/src/layout/sidebar/SidebarGroup.vue +14 -0
- package/src/layout/sidebar/SidebarItem.vue +47 -0
- package/src/layout/sidebar/SidebarNav.vue +37 -0
- package/src/layout/sidebar/SidebarUser.vue +43 -0
- package/src/layout/sidebar/SidebarViews.vue +26 -0
- package/src/layout/sidebar/view-icons.ts +112 -0
- package/src/localization/FallbackHint.vue +41 -0
- package/src/localization/LocaleNotice.vue +42 -0
- package/src/localization/LocaleSwitcher.vue +40 -0
- package/src/localization/fallback-value.ts +76 -0
- package/src/localization/list-locale.ts +37 -0
- package/src/localization/locale-form.ts +64 -0
- package/src/localization/locale.ts +286 -0
- package/src/localization/useContentLocale.ts +47 -0
- package/src/localization/useHistoryLocale.ts +30 -0
- package/src/localization/useListFallbacks.ts +49 -0
- package/src/localization/useLocaleDocument.ts +116 -0
- package/src/main.ts +21 -0
- package/src/public/__snapshots__/public-api.spec.ts.snap +456 -0
- package/src/public/composables/useApi.ts +155 -0
- package/src/public/composables/useCell.ts +38 -0
- package/src/public/composables/useCurrentUser.ts +16 -0
- package/src/public/composables/useDocument.ts +108 -0
- package/src/public/composables/useField.ts +136 -0
- package/src/public/composables/useList.ts +38 -0
- package/src/public/composables/useLocale.ts +29 -0
- package/src/public/composables/useToast.ts +19 -0
- package/src/public/index.ts +59 -0
- package/src/public/types.ts +183 -0
- package/src/public/ui.ts +85 -0
- package/src/roles/CopyRoleDialog.vue +32 -0
- package/src/roles/DeleteRoleDialog.vue +26 -0
- package/src/roles/MatrixFlags.vue +77 -0
- package/src/roles/MatrixTable.vue +101 -0
- package/src/roles/PermissionMatrix.vue +112 -0
- package/src/roles/RoleActions.vue +47 -0
- package/src/roles/RoleCard.vue +54 -0
- package/src/roles/RoleForm.vue +150 -0
- package/src/roles/RoleFormFields.vue +43 -0
- package/src/roles/RoleList.vue +77 -0
- package/src/roles/RoleMeta.vue +74 -0
- package/src/roles/RoleTable.vue +74 -0
- package/src/roles/role-form.ts +135 -0
- package/src/roles/role-matrix.ts +284 -0
- package/src/roles/useRoleCopy.ts +61 -0
- package/src/roles/useRoleDelete.ts +39 -0
- package/src/roles/useRoleForm.ts +122 -0
- package/src/router/guards.ts +57 -0
- package/src/router/index.ts +160 -0
- package/src/router/redirect.ts +9 -0
- package/src/runtime/runtime-config.ts +32 -0
- package/src/stores/auth.ts +205 -0
- package/src/stores/shell.ts +24 -0
- package/src/stores/uploads.ts +81 -0
- package/src/styles/main.css +40 -0
- package/src/styles/motion.css +328 -0
- package/src/styles/tokens.css +347 -0
- package/src/ui/KAlert.vue +80 -0
- package/src/ui/KAvatar.vue +43 -0
- package/src/ui/KBadge.vue +56 -0
- package/src/ui/KBreadcrumbs.vue +56 -0
- package/src/ui/KButton.vue +136 -0
- package/src/ui/KCalendar.vue +79 -0
- package/src/ui/KCard.vue +106 -0
- package/src/ui/KCellMessage.vue +57 -0
- package/src/ui/KCellTextarea.vue +92 -0
- package/src/ui/KCheckbox.vue +87 -0
- package/src/ui/KCollapsible.vue +100 -0
- package/src/ui/KCombobox.vue +173 -0
- package/src/ui/KComboboxOptions.vue +68 -0
- package/src/ui/KCommandItem.vue +53 -0
- package/src/ui/KCommandPalette.vue +215 -0
- package/src/ui/KDatePicker.vue +165 -0
- package/src/ui/KDrawer.vue +108 -0
- package/src/ui/KDropdownMenu.vue +60 -0
- package/src/ui/KDropzone.vue +163 -0
- package/src/ui/KEmptyState.vue +68 -0
- package/src/ui/KField.vue +103 -0
- package/src/ui/KInput.vue +89 -0
- package/src/ui/KKbd.vue +24 -0
- package/src/ui/KModal.vue +92 -0
- package/src/ui/KMultiSelect.vue +141 -0
- package/src/ui/KPagination.vue +65 -0
- package/src/ui/KPasswordInput.vue +33 -0
- package/src/ui/KPopover.vue +110 -0
- package/src/ui/KProgress.vue +61 -0
- package/src/ui/KRadioGroup.vue +90 -0
- package/src/ui/KSearchTrigger.vue +51 -0
- package/src/ui/KSegmented.vue +104 -0
- package/src/ui/KSelect.vue +124 -0
- package/src/ui/KSeparator.vue +33 -0
- package/src/ui/KSkeleton.vue +35 -0
- package/src/ui/KSpinner.vue +17 -0
- package/src/ui/KSwitch.vue +65 -0
- package/src/ui/KTab.vue +65 -0
- package/src/ui/KTabList.vue +18 -0
- package/src/ui/KTabPanel.vue +18 -0
- package/src/ui/KTable.vue +43 -0
- package/src/ui/KTableBody.vue +9 -0
- package/src/ui/KTableCell.vue +228 -0
- package/src/ui/KTableHeader.vue +39 -0
- package/src/ui/KTableHeaderCell.vue +94 -0
- package/src/ui/KTableRow.vue +49 -0
- package/src/ui/KTabs.vue +24 -0
- package/src/ui/KTag.vue +29 -0
- package/src/ui/KTextarea.vue +50 -0
- package/src/ui/KThumbnail.vue +100 -0
- package/src/ui/KToaster.vue +70 -0
- package/src/ui/KTooltip.vue +55 -0
- package/src/ui/command-palette.ts +41 -0
- package/src/ui/control-classes.ts +48 -0
- package/src/ui/cx.ts +6 -0
- package/src/ui/date-value.ts +48 -0
- package/src/ui/field-context.ts +61 -0
- package/src/ui/index.ts +88 -0
- package/src/ui/options.ts +6 -0
- package/src/ui/pagination.ts +38 -0
- package/src/ui/shortcut.ts +104 -0
- package/src/ui/table-grid.ts +277 -0
- package/src/ui/toast.ts +59 -0
- package/src/ui/useFileDrop.ts +70 -0
- package/src/users/DeleteUserDialog.vue +26 -0
- package/src/users/UserActions.vue +46 -0
- package/src/users/UserCard.vue +44 -0
- package/src/users/UserForm.vue +134 -0
- package/src/users/UserFormFields.vue +93 -0
- package/src/users/UserList.vue +107 -0
- package/src/users/UserMeta.vue +70 -0
- package/src/users/UserRoleBadge.vue +10 -0
- package/src/users/UserTable.vue +84 -0
- package/src/users/useRoleOptions.ts +50 -0
- package/src/users/useUserDelete.ts +39 -0
- package/src/users/useUserForm.ts +74 -0
- package/src/users/user-columns.ts +12 -0
- package/src/users/user-form.ts +167 -0
- package/src/views/AuditView.vue +57 -0
- package/src/views/CollectionView.vue +103 -0
- package/src/views/CustomPageView.vue +53 -0
- package/src/views/DashboardView.vue +91 -0
- package/src/views/DocumentHistoryView.vue +158 -0
- package/src/views/DocumentView.vue +173 -0
- package/src/views/GlobalHistoryView.vue +136 -0
- package/src/views/GlobalView.vue +115 -0
- package/src/views/LoginView.vue +41 -0
- package/src/views/NoAccessView.vue +34 -0
- package/src/views/NotFoundView.vue +27 -0
- package/src/views/RoleView.vue +93 -0
- package/src/views/RolesView.vue +66 -0
- package/src/views/UserView.vue +68 -0
- package/src/views/UsersView.vue +59 -0
- package/src/views/dashboard/CollectionCard.vue +21 -0
- package/src/views/dashboard/DashboardCardTitle.vue +18 -0
- package/src/views/dashboard/DashboardWidgets.vue +35 -0
- package/src/views/dashboard/GlobalCard.vue +24 -0
- package/src/views/login/LoginForm.vue +93 -0
- package/src/views/login/login-errors.ts +42 -0
- package/tsconfig.components.json +26 -0
- 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
|
+
}
|
package/src/public/ui.ts
ADDED
|
@@ -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>
|