@open-mercato/documents 0.6.8-develop.7016.1.4ed7b1e49d
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/README.md +88 -0
- package/build.mjs +23 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +7 -0
- package/dist/modules/documents/acl.js +15 -0
- package/dist/modules/documents/acl.js.map +7 -0
- package/dist/modules/documents/api/[id]/archive/route.js +116 -0
- package/dist/modules/documents/api/[id]/archive/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/attachments/[attachmentId]/route.js +155 -0
- package/dist/modules/documents/api/[id]/attachments/[attachmentId]/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/attachments/route.js +153 -0
- package/dist/modules/documents/api/[id]/attachments/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/collab-token/route.js +180 -0
- package/dist/modules/documents/api/[id]/collab-token/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/comments/access-check/route.js +86 -0
- package/dist/modules/documents/api/[id]/comments/access-check/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/comments/route.js +387 -0
- package/dist/modules/documents/api/[id]/comments/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/content/route.js +143 -0
- package/dist/modules/documents/api/[id]/content/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/duplicate/route.js +200 -0
- package/dist/modules/documents/api/[id]/duplicate/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/export/route.js +421 -0
- package/dist/modules/documents/api/[id]/export/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/favorite/route.js +96 -0
- package/dist/modules/documents/api/[id]/favorite/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/links/[linkId]/route.js +85 -0
- package/dist/modules/documents/api/[id]/links/[linkId]/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/links/route.js +257 -0
- package/dist/modules/documents/api/[id]/links/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/principals/route.js +299 -0
- package/dist/modules/documents/api/[id]/principals/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/route.js +246 -0
- package/dist/modules/documents/api/[id]/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/shares/route.js +335 -0
- package/dist/modules/documents/api/[id]/shares/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/unarchive/route.js +39 -0
- package/dist/modules/documents/api/[id]/unarchive/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/versions/[versionId]/restore/route.js +133 -0
- package/dist/modules/documents/api/[id]/versions/[versionId]/restore/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/versions/[versionId]/route.js +93 -0
- package/dist/modules/documents/api/[id]/versions/[versionId]/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/versions/route.js +193 -0
- package/dist/modules/documents/api/[id]/versions/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/watch/route.js +97 -0
- package/dist/modules/documents/api/[id]/watch/route.js.map +7 -0
- package/dist/modules/documents/api/_commands.js +34 -0
- package/dist/modules/documents/api/_commands.js.map +7 -0
- package/dist/modules/documents/api/_shared.js +490 -0
- package/dist/modules/documents/api/_shared.js.map +7 -0
- package/dist/modules/documents/api/folders/route.js +256 -0
- package/dist/modules/documents/api/folders/route.js.map +7 -0
- package/dist/modules/documents/api/instantiate/route.js +108 -0
- package/dist/modules/documents/api/instantiate/route.js.map +7 -0
- package/dist/modules/documents/api/route.js +322 -0
- package/dist/modules/documents/api/route.js.map +7 -0
- package/dist/modules/documents/api/templates/[templateId]/preview/route.js +94 -0
- package/dist/modules/documents/api/templates/[templateId]/preview/route.js.map +7 -0
- package/dist/modules/documents/api/templates/[templateId]/route.js +82 -0
- package/dist/modules/documents/api/templates/[templateId]/route.js.map +7 -0
- package/dist/modules/documents/api/templates/route.js +344 -0
- package/dist/modules/documents/api/templates/route.js.map +7 -0
- package/dist/modules/documents/backend/documents/DocumentsPageClient.js +160 -0
- package/dist/modules/documents/backend/documents/DocumentsPageClient.js.map +7 -0
- package/dist/modules/documents/backend/documents/DocumentsTable.js +143 -0
- package/dist/modules/documents/backend/documents/DocumentsTable.js.map +7 -0
- package/dist/modules/documents/backend/documents/FolderDialog.js +55 -0
- package/dist/modules/documents/backend/documents/FolderDialog.js.map +7 -0
- package/dist/modules/documents/backend/documents/FolderTree.js +40 -0
- package/dist/modules/documents/backend/documents/FolderTree.js.map +7 -0
- package/dist/modules/documents/backend/documents/MoveDocumentDialog.js +64 -0
- package/dist/modules/documents/backend/documents/MoveDocumentDialog.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/CommentAnchorNavigation.js +77 -0
- package/dist/modules/documents/backend/documents/[id]/CommentAnchorNavigation.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/CommentComposer.js +126 -0
- package/dist/modules/documents/backend/documents/[id]/CommentComposer.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/CommentThreadList.js +88 -0
- package/dist/modules/documents/backend/documents/[id]/CommentThreadList.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/CommentsRail.js +123 -0
- package/dist/modules/documents/backend/documents/[id]/CommentsRail.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/DocumentCanvas.js +91 -0
- package/dist/modules/documents/backend/documents/[id]/DocumentCanvas.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/DocumentEditorErrorBoundary.js +27 -0
- package/dist/modules/documents/backend/documents/[id]/DocumentEditorErrorBoundary.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/DocumentEditorIsland.js +50 -0
- package/dist/modules/documents/backend/documents/[id]/DocumentEditorIsland.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/DocumentEditorSurface.js +168 -0
- package/dist/modules/documents/backend/documents/[id]/DocumentEditorSurface.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/DocumentNavigator.js +129 -0
- package/dist/modules/documents/backend/documents/[id]/DocumentNavigator.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/DocumentPageClient.js +429 -0
- package/dist/modules/documents/backend/documents/[id]/DocumentPageClient.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/EditorColorTools.js +68 -0
- package/dist/modules/documents/backend/documents/[id]/EditorColorTools.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/EditorStatusPresence.js +69 -0
- package/dist/modules/documents/backend/documents/[id]/EditorStatusPresence.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/EditorToolbar.js +151 -0
- package/dist/modules/documents/backend/documents/[id]/EditorToolbar.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/ExportMenu.js +121 -0
- package/dist/modules/documents/backend/documents/[id]/ExportMenu.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/MentionPicker.js +114 -0
- package/dist/modules/documents/backend/documents/[id]/MentionPicker.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/OutlinePane.js +70 -0
- package/dist/modules/documents/backend/documents/[id]/OutlinePane.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/RecordFieldsDialog.js +157 -0
- package/dist/modules/documents/backend/documents/[id]/RecordFieldsDialog.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/RelatedRecordsPanel.js +266 -0
- package/dist/modules/documents/backend/documents/[id]/RelatedRecordsPanel.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/VersionHistoryPanel.js +227 -0
- package/dist/modules/documents/backend/documents/[id]/VersionHistoryPanel.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/VersionPreviewDialog.js +157 -0
- package/dist/modules/documents/backend/documents/[id]/VersionPreviewDialog.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/commentTypes.js +150 -0
- package/dist/modules/documents/backend/documents/[id]/commentTypes.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/componentCapabilities.js +13 -0
- package/dist/modules/documents/backend/documents/[id]/componentCapabilities.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/documentPagination.js +295 -0
- package/dist/modules/documents/backend/documents/[id]/documentPagination.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/editorPresenceStyles.js +81 -0
- package/dist/modules/documents/backend/documents/[id]/editorPresenceStyles.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/editorTypes.js +52 -0
- package/dist/modules/documents/backend/documents/[id]/editorTypes.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/page.js +10 -0
- package/dist/modules/documents/backend/documents/[id]/page.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/page.meta.js +16 -0
- package/dist/modules/documents/backend/documents/[id]/page.meta.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/relatedRecordModel.js +38 -0
- package/dist/modules/documents/backend/documents/[id]/relatedRecordModel.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/restoreVersion.js +33 -0
- package/dist/modules/documents/backend/documents/[id]/restoreVersion.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/useDocumentCollaboration.js +392 -0
- package/dist/modules/documents/backend/documents/[id]/useDocumentCollaboration.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/useDocumentComments.js +253 -0
- package/dist/modules/documents/backend/documents/[id]/useDocumentComments.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/useDocumentEditor.js +149 -0
- package/dist/modules/documents/backend/documents/[id]/useDocumentEditor.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/useDocumentTitle.js +82 -0
- package/dist/modules/documents/backend/documents/[id]/useDocumentTitle.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/useEditorInsertions.js +144 -0
- package/dist/modules/documents/backend/documents/[id]/useEditorInsertions.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/useFallbackContentPersistence.js +237 -0
- package/dist/modules/documents/backend/documents/[id]/useFallbackContentPersistence.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/useMentionPicker.js +216 -0
- package/dist/modules/documents/backend/documents/[id]/useMentionPicker.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/versionHistoryModel.js +25 -0
- package/dist/modules/documents/backend/documents/[id]/versionHistoryModel.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/EntityPicker.js +156 -0
- package/dist/modules/documents/backend/documents/components/EntityPicker.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/EntityPickerResults.js +46 -0
- package/dist/modules/documents/backend/documents/components/EntityPickerResults.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/NewFromTemplateDialog.js +127 -0
- package/dist/modules/documents/backend/documents/components/NewFromTemplateDialog.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/PrincipalPicker.js +84 -0
- package/dist/modules/documents/backend/documents/components/PrincipalPicker.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/ShareDialog.js +77 -0
- package/dist/modules/documents/backend/documents/components/ShareDialog.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/ShareDialogAddForm.js +93 -0
- package/dist/modules/documents/backend/documents/components/ShareDialogAddForm.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/ShareDialogList.js +82 -0
- package/dist/modules/documents/backend/documents/components/ShareDialogList.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/TemplateBodyEditor.js +96 -0
- package/dist/modules/documents/backend/documents/components/TemplateBodyEditor.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/TemplateEditorDialog.js +169 -0
- package/dist/modules/documents/backend/documents/components/TemplateEditorDialog.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/TemplatePreview.js +38 -0
- package/dist/modules/documents/backend/documents/components/TemplatePreview.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/TemplateSlotFields.js +69 -0
- package/dist/modules/documents/backend/documents/components/TemplateSlotFields.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/TemplateSlotsEditor.js +71 -0
- package/dist/modules/documents/backend/documents/components/TemplateSlotsEditor.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/principalPickerModel.js +63 -0
- package/dist/modules/documents/backend/documents/components/principalPickerModel.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/shareDialogModel.js +68 -0
- package/dist/modules/documents/backend/documents/components/shareDialogModel.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/templateUi.js +89 -0
- package/dist/modules/documents/backend/documents/components/templateUi.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/useAvailableEntityRegistry.js +30 -0
- package/dist/modules/documents/backend/documents/components/useAvailableEntityRegistry.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/useEntitySearch.js +191 -0
- package/dist/modules/documents/backend/documents/components/useEntitySearch.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/usePrincipalPicker.js +221 -0
- package/dist/modules/documents/backend/documents/components/usePrincipalPicker.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/useShareDialog.js +236 -0
- package/dist/modules/documents/backend/documents/components/useShareDialog.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/useTemplateDetail.js +49 -0
- package/dist/modules/documents/backend/documents/components/useTemplateDetail.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/useTemplateInstantiation.js +234 -0
- package/dist/modules/documents/backend/documents/components/useTemplateInstantiation.js.map +7 -0
- package/dist/modules/documents/backend/documents/documentUi.js +106 -0
- package/dist/modules/documents/backend/documents/documentUi.js.map +7 -0
- package/dist/modules/documents/backend/documents/documentsListTypes.js +132 -0
- package/dist/modules/documents/backend/documents/documentsListTypes.js.map +7 -0
- package/dist/modules/documents/backend/documents/page.js +9 -0
- package/dist/modules/documents/backend/documents/page.js.map +7 -0
- package/dist/modules/documents/backend/documents/page.meta.js +26 -0
- package/dist/modules/documents/backend/documents/page.meta.js.map +7 -0
- package/dist/modules/documents/backend/documents/templates/TemplatesPageClient.js +91 -0
- package/dist/modules/documents/backend/documents/templates/TemplatesPageClient.js.map +7 -0
- package/dist/modules/documents/backend/documents/templates/TemplatesTable.js +58 -0
- package/dist/modules/documents/backend/documents/templates/TemplatesTable.js.map +7 -0
- package/dist/modules/documents/backend/documents/templates/page.js +9 -0
- package/dist/modules/documents/backend/documents/templates/page.js.map +7 -0
- package/dist/modules/documents/backend/documents/templates/page.meta.js +34 -0
- package/dist/modules/documents/backend/documents/templates/page.meta.js.map +7 -0
- package/dist/modules/documents/backend/documents/templates/useTemplatesPage.js +139 -0
- package/dist/modules/documents/backend/documents/templates/useTemplatesPage.js.map +7 -0
- package/dist/modules/documents/backend/documents/useDocumentsList.js +314 -0
- package/dist/modules/documents/backend/documents/useDocumentsList.js.map +7 -0
- package/dist/modules/documents/ce.js +8 -0
- package/dist/modules/documents/ce.js.map +7 -0
- package/dist/modules/documents/commands/aggregate.js +99 -0
- package/dist/modules/documents/commands/aggregate.js.map +7 -0
- package/dist/modules/documents/commands/attachments.js +252 -0
- package/dist/modules/documents/commands/attachments.js.map +7 -0
- package/dist/modules/documents/commands/comments.js +782 -0
- package/dist/modules/documents/commands/comments.js.map +7 -0
- package/dist/modules/documents/commands/content.js +238 -0
- package/dist/modules/documents/commands/content.js.map +7 -0
- package/dist/modules/documents/commands/document-crud.js +505 -0
- package/dist/modules/documents/commands/document-crud.js.map +7 -0
- package/dist/modules/documents/commands/documents.js +473 -0
- package/dist/modules/documents/commands/documents.js.map +7 -0
- package/dist/modules/documents/commands/duplicate.js +640 -0
- package/dist/modules/documents/commands/duplicate.js.map +7 -0
- package/dist/modules/documents/commands/favorites.js +150 -0
- package/dist/modules/documents/commands/favorites.js.map +7 -0
- package/dist/modules/documents/commands/folders.js +420 -0
- package/dist/modules/documents/commands/folders.js.map +7 -0
- package/dist/modules/documents/commands/index.js +64 -0
- package/dist/modules/documents/commands/index.js.map +7 -0
- package/dist/modules/documents/commands/interceptors.js +300 -0
- package/dist/modules/documents/commands/interceptors.js.map +7 -0
- package/dist/modules/documents/commands/lifecycle.js +249 -0
- package/dist/modules/documents/commands/lifecycle.js.map +7 -0
- package/dist/modules/documents/commands/links.js +410 -0
- package/dist/modules/documents/commands/links.js.map +7 -0
- package/dist/modules/documents/commands/mutation-helpers.js +42 -0
- package/dist/modules/documents/commands/mutation-helpers.js.map +7 -0
- package/dist/modules/documents/commands/projection-types.js +1 -0
- package/dist/modules/documents/commands/projection-types.js.map +7 -0
- package/dist/modules/documents/commands/shared.js +143 -0
- package/dist/modules/documents/commands/shared.js.map +7 -0
- package/dist/modules/documents/commands/shares.js +527 -0
- package/dist/modules/documents/commands/shares.js.map +7 -0
- package/dist/modules/documents/commands/side-effects.js +103 -0
- package/dist/modules/documents/commands/side-effects.js.map +7 -0
- package/dist/modules/documents/commands/templates.js +461 -0
- package/dist/modules/documents/commands/templates.js.map +7 -0
- package/dist/modules/documents/commands/versions.js +432 -0
- package/dist/modules/documents/commands/versions.js.map +7 -0
- package/dist/modules/documents/commands/watchers.js +164 -0
- package/dist/modules/documents/commands/watchers.js.map +7 -0
- package/dist/modules/documents/data/entities.js +653 -0
- package/dist/modules/documents/data/entities.js.map +7 -0
- package/dist/modules/documents/data/extensions.js +44 -0
- package/dist/modules/documents/data/extensions.js.map +7 -0
- package/dist/modules/documents/data/validators.js +219 -0
- package/dist/modules/documents/data/validators.js.map +7 -0
- package/dist/modules/documents/di.js +35 -0
- package/dist/modules/documents/di.js.map +7 -0
- package/dist/modules/documents/encryption.js +12 -0
- package/dist/modules/documents/encryption.js.map +7 -0
- package/dist/modules/documents/events.js +27 -0
- package/dist/modules/documents/events.js.map +7 -0
- package/dist/modules/documents/index.js +19 -0
- package/dist/modules/documents/index.js.map +7 -0
- package/dist/modules/documents/lib/attachmentServicePort.js +30 -0
- package/dist/modules/documents/lib/attachmentServicePort.js.map +7 -0
- package/dist/modules/documents/lib/capabilities.js +32 -0
- package/dist/modules/documents/lib/capabilities.js.map +7 -0
- package/dist/modules/documents/lib/collabCloseEvents.js +17 -0
- package/dist/modules/documents/lib/collabCloseEvents.js.map +7 -0
- package/dist/modules/documents/lib/collabEndpoint.js +22 -0
- package/dist/modules/documents/lib/collabEndpoint.js.map +7 -0
- package/dist/modules/documents/lib/collabMaterializer.js +107 -0
- package/dist/modules/documents/lib/collabMaterializer.js.map +7 -0
- package/dist/modules/documents/lib/collabToken.js +120 -0
- package/dist/modules/documents/lib/collabToken.js.map +7 -0
- package/dist/modules/documents/lib/collaborationAwareness.js +68 -0
- package/dist/modules/documents/lib/collaborationAwareness.js.map +7 -0
- package/dist/modules/documents/lib/commentAnchors.js +15 -0
- package/dist/modules/documents/lib/commentAnchors.js.map +7 -0
- package/dist/modules/documents/lib/constants.js +25 -0
- package/dist/modules/documents/lib/constants.js.map +7 -0
- package/dist/modules/documents/lib/contentService.js +248 -0
- package/dist/modules/documents/lib/contentService.js.map +7 -0
- package/dist/modules/documents/lib/displayLabels.js +23 -0
- package/dist/modules/documents/lib/displayLabels.js.map +7 -0
- package/dist/modules/documents/lib/docxRenderer.js +601 -0
- package/dist/modules/documents/lib/docxRenderer.js.map +7 -0
- package/dist/modules/documents/lib/duplicateContent.js +22 -0
- package/dist/modules/documents/lib/duplicateContent.js.map +7 -0
- package/dist/modules/documents/lib/editorConfig.js +287 -0
- package/dist/modules/documents/lib/editorConfig.js.map +7 -0
- package/dist/modules/documents/lib/entityLinks.js +148 -0
- package/dist/modules/documents/lib/entityLinks.js.map +7 -0
- package/dist/modules/documents/lib/entityRegistry.js +258 -0
- package/dist/modules/documents/lib/entityRegistry.js.map +7 -0
- package/dist/modules/documents/lib/entityRegistry.server.js +189 -0
- package/dist/modules/documents/lib/entityRegistry.server.js.map +7 -0
- package/dist/modules/documents/lib/entityRegistryAvailability.server.js +9 -0
- package/dist/modules/documents/lib/entityRegistryAvailability.server.js.map +7 -0
- package/dist/modules/documents/lib/entitySuggestion.js +50 -0
- package/dist/modules/documents/lib/entitySuggestion.js.map +7 -0
- package/dist/modules/documents/lib/favorites.js +22 -0
- package/dist/modules/documents/lib/favorites.js.map +7 -0
- package/dist/modules/documents/lib/folderHierarchySerialization.js +19 -0
- package/dist/modules/documents/lib/folderHierarchySerialization.js.map +7 -0
- package/dist/modules/documents/lib/historyLimits.js +100 -0
- package/dist/modules/documents/lib/historyLimits.js.map +7 -0
- package/dist/modules/documents/lib/historyPolicy.js +14 -0
- package/dist/modules/documents/lib/historyPolicy.js.map +7 -0
- package/dist/modules/documents/lib/organizationAccess.js +17 -0
- package/dist/modules/documents/lib/organizationAccess.js.map +7 -0
- package/dist/modules/documents/lib/pdfHtml.js +62 -0
- package/dist/modules/documents/lib/pdfHtml.js.map +7 -0
- package/dist/modules/documents/lib/pdfRenderer.js +284 -0
- package/dist/modules/documents/lib/pdfRenderer.js.map +7 -0
- package/dist/modules/documents/lib/permissions.js +222 -0
- package/dist/modules/documents/lib/permissions.js.map +7 -0
- package/dist/modules/documents/lib/platformServices.js +35 -0
- package/dist/modules/documents/lib/platformServices.js.map +7 -0
- package/dist/modules/documents/lib/recordFieldInsertion.js +58 -0
- package/dist/modules/documents/lib/recordFieldInsertion.js.map +7 -0
- package/dist/modules/documents/lib/requestBody.js +80 -0
- package/dist/modules/documents/lib/requestBody.js.map +7 -0
- package/dist/modules/documents/lib/resourceLimits.js +62 -0
- package/dist/modules/documents/lib/resourceLimits.js.map +7 -0
- package/dist/modules/documents/lib/shareCounts.js +25 -0
- package/dist/modules/documents/lib/shareCounts.js.map +7 -0
- package/dist/modules/documents/lib/templateFill.js +84 -0
- package/dist/modules/documents/lib/templateFill.js.map +7 -0
- package/dist/modules/documents/lib/templateInstantiation.js +147 -0
- package/dist/modules/documents/lib/templateInstantiation.js.map +7 -0
- package/dist/modules/documents/lib/templatePreviewDigest.js +82 -0
- package/dist/modules/documents/lib/templatePreviewDigest.js.map +7 -0
- package/dist/modules/documents/lib/templateSeeds.js +201 -0
- package/dist/modules/documents/lib/templateSeeds.js.map +7 -0
- package/dist/modules/documents/lib/userLabels.js +37 -0
- package/dist/modules/documents/lib/userLabels.js.map +7 -0
- package/dist/modules/documents/lib/versionContent.js +131 -0
- package/dist/modules/documents/lib/versionContent.js.map +7 -0
- package/dist/modules/documents/lib/versionLabels.js +12 -0
- package/dist/modules/documents/lib/versionLabels.js.map +7 -0
- package/dist/modules/documents/lib/versioning.js +14 -0
- package/dist/modules/documents/lib/versioning.js.map +7 -0
- package/dist/modules/documents/lib/visibility.js +422 -0
- package/dist/modules/documents/lib/visibility.js.map +7 -0
- package/dist/modules/documents/lib/watchers.js +106 -0
- package/dist/modules/documents/lib/watchers.js.map +7 -0
- package/dist/modules/documents/migrations/Migration20260708163836_documents.js +44 -0
- package/dist/modules/documents/migrations/Migration20260708163836_documents.js.map +7 -0
- package/dist/modules/documents/migrations/Migration20260709164720_documents.js +17 -0
- package/dist/modules/documents/migrations/Migration20260709164720_documents.js.map +7 -0
- package/dist/modules/documents/migrations/Migration20260710002318_documents.js +32 -0
- package/dist/modules/documents/migrations/Migration20260710002318_documents.js.map +7 -0
- package/dist/modules/documents/migrations/Migration20260710071003_documents.js +13 -0
- package/dist/modules/documents/migrations/Migration20260710071003_documents.js.map +7 -0
- package/dist/modules/documents/migrations/Migration20260712120000_documents.js +13 -0
- package/dist/modules/documents/migrations/Migration20260712120000_documents.js.map +7 -0
- package/dist/modules/documents/migrations/Migration20260712183000_documents.js +14 -0
- package/dist/modules/documents/migrations/Migration20260712183000_documents.js.map +7 -0
- package/dist/modules/documents/migrations/Migration20260713092156_documents.js +29 -0
- package/dist/modules/documents/migrations/Migration20260713092156_documents.js.map +7 -0
- package/dist/modules/documents/migrations/Migration20260717000000_documents.js +37 -0
- package/dist/modules/documents/migrations/Migration20260717000000_documents.js.map +7 -0
- package/dist/modules/documents/notifications.js +47 -0
- package/dist/modules/documents/notifications.js.map +7 -0
- package/dist/modules/documents/search.js +101 -0
- package/dist/modules/documents/search.js.map +7 -0
- package/dist/modules/documents/setup.js +19 -0
- package/dist/modules/documents/setup.js.map +7 -0
- package/dist/modules/documents/widgets/injection/related-documents/LinkDocumentDialog.js +214 -0
- package/dist/modules/documents/widgets/injection/related-documents/LinkDocumentDialog.js.map +7 -0
- package/dist/modules/documents/widgets/injection/related-documents/context.js +84 -0
- package/dist/modules/documents/widgets/injection/related-documents/context.js.map +7 -0
- package/dist/modules/documents/widgets/injection/related-documents/useRelatedDocuments.js +98 -0
- package/dist/modules/documents/widgets/injection/related-documents/useRelatedDocuments.js.map +7 -0
- package/dist/modules/documents/widgets/injection/related-documents/widget.client.js +83 -0
- package/dist/modules/documents/widgets/injection/related-documents/widget.client.js.map +7 -0
- package/dist/modules/documents/widgets/injection/related-documents/widget.js +19 -0
- package/dist/modules/documents/widgets/injection/related-documents/widget.js.map +7 -0
- package/dist/modules/documents/widgets/injection-table.js +21 -0
- package/dist/modules/documents/widgets/injection-table.js.map +7 -0
- package/dist/server/documents-collab-server.js +2260 -0
- package/dist/server/documents-collab-server.js.map +7 -0
- package/generated/entities/document/index.ts +12 -0
- package/generated/entities/document_attachment/index.ts +9 -0
- package/generated/entities/document_comment/index.ts +14 -0
- package/generated/entities/document_content/index.ts +11 -0
- package/generated/entities/document_entity_link/index.ts +19 -0
- package/generated/entities/document_favorite/index.ts +7 -0
- package/generated/entities/document_folder/index.ts +9 -0
- package/generated/entities/document_share/index.ts +11 -0
- package/generated/entities/document_template/index.ts +13 -0
- package/generated/entities/document_version/index.ts +9 -0
- package/generated/entities/document_watcher/index.ts +7 -0
- package/generated/entities.ids.generated.ts +21 -0
- package/generated/entity-fields-registry.ts +151 -0
- package/jest.config.cjs +34 -0
- package/package.json +149 -0
- package/server/documents-collab-server.ts +3416 -0
- package/src/index.ts +1 -0
- package/src/modules/documents/acl.ts +11 -0
- package/src/modules/documents/api/[id]/archive/route.ts +132 -0
- package/src/modules/documents/api/[id]/attachments/[attachmentId]/route.ts +166 -0
- package/src/modules/documents/api/[id]/attachments/route.ts +173 -0
- package/src/modules/documents/api/[id]/collab-token/route.ts +203 -0
- package/src/modules/documents/api/[id]/comments/access-check/route.ts +96 -0
- package/src/modules/documents/api/[id]/comments/route.ts +442 -0
- package/src/modules/documents/api/[id]/content/route.ts +156 -0
- package/src/modules/documents/api/[id]/duplicate/route.ts +231 -0
- package/src/modules/documents/api/[id]/export/route.ts +535 -0
- package/src/modules/documents/api/[id]/favorite/route.ts +110 -0
- package/src/modules/documents/api/[id]/links/[linkId]/route.ts +92 -0
- package/src/modules/documents/api/[id]/links/route.ts +301 -0
- package/src/modules/documents/api/[id]/principals/route.ts +375 -0
- package/src/modules/documents/api/[id]/route.ts +267 -0
- package/src/modules/documents/api/[id]/shares/route.ts +372 -0
- package/src/modules/documents/api/[id]/unarchive/route.ts +42 -0
- package/src/modules/documents/api/[id]/versions/[versionId]/restore/route.ts +152 -0
- package/src/modules/documents/api/[id]/versions/[versionId]/route.ts +100 -0
- package/src/modules/documents/api/[id]/versions/route.ts +207 -0
- package/src/modules/documents/api/[id]/watch/route.ts +111 -0
- package/src/modules/documents/api/_commands.ts +53 -0
- package/src/modules/documents/api/_shared.ts +676 -0
- package/src/modules/documents/api/folders/route.ts +287 -0
- package/src/modules/documents/api/instantiate/route.ts +114 -0
- package/src/modules/documents/api/route.ts +362 -0
- package/src/modules/documents/api/templates/[templateId]/preview/route.ts +97 -0
- package/src/modules/documents/api/templates/[templateId]/route.ts +92 -0
- package/src/modules/documents/api/templates/route.ts +370 -0
- package/src/modules/documents/backend/documents/DocumentsPageClient.tsx +150 -0
- package/src/modules/documents/backend/documents/DocumentsTable.tsx +168 -0
- package/src/modules/documents/backend/documents/FolderDialog.tsx +62 -0
- package/src/modules/documents/backend/documents/FolderTree.tsx +72 -0
- package/src/modules/documents/backend/documents/MoveDocumentDialog.tsx +70 -0
- package/src/modules/documents/backend/documents/[id]/CommentAnchorNavigation.ts +88 -0
- package/src/modules/documents/backend/documents/[id]/CommentComposer.tsx +136 -0
- package/src/modules/documents/backend/documents/[id]/CommentThreadList.tsx +131 -0
- package/src/modules/documents/backend/documents/[id]/CommentsRail.tsx +138 -0
- package/src/modules/documents/backend/documents/[id]/DocumentCanvas.tsx +111 -0
- package/src/modules/documents/backend/documents/[id]/DocumentEditorErrorBoundary.tsx +39 -0
- package/src/modules/documents/backend/documents/[id]/DocumentEditorIsland.tsx +50 -0
- package/src/modules/documents/backend/documents/[id]/DocumentEditorSurface.tsx +162 -0
- package/src/modules/documents/backend/documents/[id]/DocumentNavigator.tsx +129 -0
- package/src/modules/documents/backend/documents/[id]/DocumentPageClient.tsx +463 -0
- package/src/modules/documents/backend/documents/[id]/EditorColorTools.tsx +71 -0
- package/src/modules/documents/backend/documents/[id]/EditorStatusPresence.tsx +78 -0
- package/src/modules/documents/backend/documents/[id]/EditorToolbar.tsx +108 -0
- package/src/modules/documents/backend/documents/[id]/ExportMenu.tsx +144 -0
- package/src/modules/documents/backend/documents/[id]/MentionPicker.tsx +137 -0
- package/src/modules/documents/backend/documents/[id]/OutlinePane.tsx +98 -0
- package/src/modules/documents/backend/documents/[id]/RecordFieldsDialog.tsx +185 -0
- package/src/modules/documents/backend/documents/[id]/RelatedRecordsPanel.tsx +320 -0
- package/src/modules/documents/backend/documents/[id]/VersionHistoryPanel.tsx +244 -0
- package/src/modules/documents/backend/documents/[id]/VersionPreviewDialog.tsx +197 -0
- package/src/modules/documents/backend/documents/[id]/commentTypes.ts +192 -0
- package/src/modules/documents/backend/documents/[id]/componentCapabilities.ts +17 -0
- package/src/modules/documents/backend/documents/[id]/documentPagination.ts +352 -0
- package/src/modules/documents/backend/documents/[id]/editorPresenceStyles.ts +77 -0
- package/src/modules/documents/backend/documents/[id]/editorTypes.ts +84 -0
- package/src/modules/documents/backend/documents/[id]/page.meta.ts +12 -0
- package/src/modules/documents/backend/documents/[id]/page.tsx +6 -0
- package/src/modules/documents/backend/documents/[id]/relatedRecordModel.ts +49 -0
- package/src/modules/documents/backend/documents/[id]/restoreVersion.ts +49 -0
- package/src/modules/documents/backend/documents/[id]/useDocumentCollaboration.ts +458 -0
- package/src/modules/documents/backend/documents/[id]/useDocumentComments.ts +286 -0
- package/src/modules/documents/backend/documents/[id]/useDocumentEditor.ts +157 -0
- package/src/modules/documents/backend/documents/[id]/useDocumentTitle.ts +77 -0
- package/src/modules/documents/backend/documents/[id]/useEditorInsertions.ts +147 -0
- package/src/modules/documents/backend/documents/[id]/useFallbackContentPersistence.ts +277 -0
- package/src/modules/documents/backend/documents/[id]/useMentionPicker.ts +259 -0
- package/src/modules/documents/backend/documents/[id]/versionHistoryModel.ts +29 -0
- package/src/modules/documents/backend/documents/components/EntityPicker.tsx +171 -0
- package/src/modules/documents/backend/documents/components/EntityPickerResults.tsx +64 -0
- package/src/modules/documents/backend/documents/components/NewFromTemplateDialog.tsx +136 -0
- package/src/modules/documents/backend/documents/components/PrincipalPicker.tsx +90 -0
- package/src/modules/documents/backend/documents/components/ShareDialog.tsx +88 -0
- package/src/modules/documents/backend/documents/components/ShareDialogAddForm.tsx +113 -0
- package/src/modules/documents/backend/documents/components/ShareDialogList.tsx +117 -0
- package/src/modules/documents/backend/documents/components/TemplateBodyEditor.tsx +96 -0
- package/src/modules/documents/backend/documents/components/TemplateEditorDialog.tsx +171 -0
- package/src/modules/documents/backend/documents/components/TemplatePreview.tsx +43 -0
- package/src/modules/documents/backend/documents/components/TemplateSlotFields.tsx +72 -0
- package/src/modules/documents/backend/documents/components/TemplateSlotsEditor.tsx +72 -0
- package/src/modules/documents/backend/documents/components/principalPickerModel.ts +86 -0
- package/src/modules/documents/backend/documents/components/shareDialogModel.ts +94 -0
- package/src/modules/documents/backend/documents/components/templateUi.ts +128 -0
- package/src/modules/documents/backend/documents/components/useAvailableEntityRegistry.ts +43 -0
- package/src/modules/documents/backend/documents/components/useEntitySearch.ts +197 -0
- package/src/modules/documents/backend/documents/components/usePrincipalPicker.ts +165 -0
- package/src/modules/documents/backend/documents/components/useShareDialog.ts +267 -0
- package/src/modules/documents/backend/documents/components/useTemplateDetail.ts +54 -0
- package/src/modules/documents/backend/documents/components/useTemplateInstantiation.ts +252 -0
- package/src/modules/documents/backend/documents/documentUi.ts +134 -0
- package/src/modules/documents/backend/documents/documentsListTypes.ts +163 -0
- package/src/modules/documents/backend/documents/page.meta.ts +24 -0
- package/src/modules/documents/backend/documents/page.tsx +5 -0
- package/src/modules/documents/backend/documents/templates/TemplatesPageClient.tsx +93 -0
- package/src/modules/documents/backend/documents/templates/TemplatesTable.tsx +71 -0
- package/src/modules/documents/backend/documents/templates/page.meta.ts +32 -0
- package/src/modules/documents/backend/documents/templates/page.tsx +5 -0
- package/src/modules/documents/backend/documents/templates/useTemplatesPage.tsx +148 -0
- package/src/modules/documents/backend/documents/useDocumentsList.tsx +305 -0
- package/src/modules/documents/ce.ts +6 -0
- package/src/modules/documents/commands/aggregate.ts +128 -0
- package/src/modules/documents/commands/attachments.ts +309 -0
- package/src/modules/documents/commands/comments.ts +966 -0
- package/src/modules/documents/commands/content.ts +294 -0
- package/src/modules/documents/commands/document-crud.ts +609 -0
- package/src/modules/documents/commands/documents.ts +581 -0
- package/src/modules/documents/commands/duplicate.ts +772 -0
- package/src/modules/documents/commands/favorites.ts +171 -0
- package/src/modules/documents/commands/folders.ts +506 -0
- package/src/modules/documents/commands/index.ts +33 -0
- package/src/modules/documents/commands/interceptors.ts +402 -0
- package/src/modules/documents/commands/lifecycle.ts +333 -0
- package/src/modules/documents/commands/links.ts +486 -0
- package/src/modules/documents/commands/mutation-helpers.ts +48 -0
- package/src/modules/documents/commands/projection-types.ts +77 -0
- package/src/modules/documents/commands/shared.ts +219 -0
- package/src/modules/documents/commands/shares.ts +612 -0
- package/src/modules/documents/commands/side-effects.ts +130 -0
- package/src/modules/documents/commands/templates.ts +522 -0
- package/src/modules/documents/commands/versions.ts +537 -0
- package/src/modules/documents/commands/watchers.ts +181 -0
- package/src/modules/documents/data/entities.ts +631 -0
- package/src/modules/documents/data/extensions.ts +42 -0
- package/src/modules/documents/data/validators.ts +248 -0
- package/src/modules/documents/di.ts +33 -0
- package/src/modules/documents/encryption.ts +14 -0
- package/src/modules/documents/events.ts +23 -0
- package/src/modules/documents/i18n/.hardcoded-allowlist.json +9 -0
- package/src/modules/documents/i18n/de.json +522 -0
- package/src/modules/documents/i18n/en.json +522 -0
- package/src/modules/documents/i18n/es.json +522 -0
- package/src/modules/documents/i18n/ko.json +522 -0
- package/src/modules/documents/i18n/pl.json +522 -0
- package/src/modules/documents/index.ts +17 -0
- package/src/modules/documents/lib/attachmentServicePort.ts +94 -0
- package/src/modules/documents/lib/capabilities.ts +57 -0
- package/src/modules/documents/lib/collabCloseEvents.ts +26 -0
- package/src/modules/documents/lib/collabEndpoint.ts +43 -0
- package/src/modules/documents/lib/collabMaterializer.ts +140 -0
- package/src/modules/documents/lib/collabToken.ts +170 -0
- package/src/modules/documents/lib/collaborationAwareness.ts +102 -0
- package/src/modules/documents/lib/commentAnchors.ts +19 -0
- package/src/modules/documents/lib/constants.ts +39 -0
- package/src/modules/documents/lib/contentService.ts +340 -0
- package/src/modules/documents/lib/displayLabels.ts +31 -0
- package/src/modules/documents/lib/docxRenderer.ts +685 -0
- package/src/modules/documents/lib/duplicateContent.ts +32 -0
- package/src/modules/documents/lib/editorConfig.ts +371 -0
- package/src/modules/documents/lib/entityLinks.ts +250 -0
- package/src/modules/documents/lib/entityRegistry.server.ts +267 -0
- package/src/modules/documents/lib/entityRegistry.ts +345 -0
- package/src/modules/documents/lib/entityRegistryAvailability.server.ts +19 -0
- package/src/modules/documents/lib/entitySuggestion.ts +61 -0
- package/src/modules/documents/lib/favorites.ts +35 -0
- package/src/modules/documents/lib/folderHierarchySerialization.ts +34 -0
- package/src/modules/documents/lib/historyLimits.ts +154 -0
- package/src/modules/documents/lib/historyPolicy.ts +7 -0
- package/src/modules/documents/lib/organizationAccess.ts +44 -0
- package/src/modules/documents/lib/pdfHtml.ts +65 -0
- package/src/modules/documents/lib/pdfRenderer.ts +367 -0
- package/src/modules/documents/lib/permissions.ts +299 -0
- package/src/modules/documents/lib/platformServices.ts +70 -0
- package/src/modules/documents/lib/recordFieldInsertion.ts +72 -0
- package/src/modules/documents/lib/requestBody.ts +97 -0
- package/src/modules/documents/lib/resourceLimits.ts +94 -0
- package/src/modules/documents/lib/shareCounts.ts +44 -0
- package/src/modules/documents/lib/templateFill.ts +138 -0
- package/src/modules/documents/lib/templateInstantiation.ts +206 -0
- package/src/modules/documents/lib/templatePreviewDigest.ts +122 -0
- package/src/modules/documents/lib/templateSeeds.ts +248 -0
- package/src/modules/documents/lib/userLabels.ts +58 -0
- package/src/modules/documents/lib/versionContent.ts +163 -0
- package/src/modules/documents/lib/versionLabels.ts +9 -0
- package/src/modules/documents/lib/versioning.ts +29 -0
- package/src/modules/documents/lib/visibility.ts +610 -0
- package/src/modules/documents/lib/watchers.ts +129 -0
- package/src/modules/documents/migrations/.snapshot-open-mercato.json +2892 -0
- package/src/modules/documents/migrations/Migration20260708163836_documents.ts +50 -0
- package/src/modules/documents/migrations/Migration20260709164720_documents.ts +19 -0
- package/src/modules/documents/migrations/Migration20260710002318_documents.ts +35 -0
- package/src/modules/documents/migrations/Migration20260710071003_documents.ts +13 -0
- package/src/modules/documents/migrations/Migration20260712120000_documents.ts +13 -0
- package/src/modules/documents/migrations/Migration20260712183000_documents.ts +12 -0
- package/src/modules/documents/migrations/Migration20260713092156_documents.ts +43 -0
- package/src/modules/documents/migrations/Migration20260717000000_documents.ts +40 -0
- package/src/modules/documents/notifications.ts +45 -0
- package/src/modules/documents/search.ts +118 -0
- package/src/modules/documents/setup.ts +19 -0
- package/src/modules/documents/widgets/injection/related-documents/LinkDocumentDialog.tsx +224 -0
- package/src/modules/documents/widgets/injection/related-documents/context.ts +101 -0
- package/src/modules/documents/widgets/injection/related-documents/useRelatedDocuments.ts +112 -0
- package/src/modules/documents/widgets/injection/related-documents/widget.client.tsx +76 -0
- package/src/modules/documents/widgets/injection/related-documents/widget.ts +19 -0
- package/src/modules/documents/widgets/injection-table.ts +20 -0
- package/tsconfig.json +9 -0
- package/watch.mjs +6 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
import { Search } from 'lucide-react'
|
|
5
|
+
import { Button } from '@open-mercato/ui/primitives/button'
|
|
6
|
+
import { LoadingMessage } from '@open-mercato/ui/backend/detail'
|
|
7
|
+
import {
|
|
8
|
+
Dialog,
|
|
9
|
+
DialogContent,
|
|
10
|
+
DialogDescription,
|
|
11
|
+
DialogFooter,
|
|
12
|
+
DialogHeader,
|
|
13
|
+
DialogTitle,
|
|
14
|
+
} from '@open-mercato/ui/primitives/dialog'
|
|
15
|
+
import { Input } from '@open-mercato/ui/primitives/input'
|
|
16
|
+
import { Label } from '@open-mercato/ui/primitives/label'
|
|
17
|
+
import { SegmentedControl, SegmentedControlItem } from '@open-mercato/ui/primitives/segmented-control'
|
|
18
|
+
import { useT } from '@open-mercato/shared/lib/i18n/context'
|
|
19
|
+
import type { DocumentEntityType } from '../../../lib/entityRegistry'
|
|
20
|
+
import { sanitizeDocumentsDisplayLabel } from '../../../lib/displayLabels'
|
|
21
|
+
import { EntityPickerResults } from './EntityPickerResults'
|
|
22
|
+
import { useEntitySearch, type EntitySearchItem } from './useEntitySearch'
|
|
23
|
+
|
|
24
|
+
export type EntityPickerSelection = {
|
|
25
|
+
type: DocumentEntityType
|
|
26
|
+
id: string
|
|
27
|
+
label: string
|
|
28
|
+
href: string
|
|
29
|
+
values: Record<string, string | null>
|
|
30
|
+
}
|
|
31
|
+
export type EntityPickerProps = {
|
|
32
|
+
open: boolean
|
|
33
|
+
onOpenChange: (open: boolean) => void
|
|
34
|
+
onPick: (pick: EntityPickerSelection) => void
|
|
35
|
+
typeFilter?: DocumentEntityType[]
|
|
36
|
+
excludeId?: string
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function EntityPicker({ open, onOpenChange, onPick, typeFilter, excludeId }: EntityPickerProps) {
|
|
40
|
+
const t = useT()
|
|
41
|
+
const inputId = `documents-entity-picker-${React.useId()}`
|
|
42
|
+
const listId = `${inputId}-results`
|
|
43
|
+
const search = useEntitySearch(open, typeFilter, excludeId)
|
|
44
|
+
|
|
45
|
+
const selectItem = React.useCallback((item: EntitySearchItem) => {
|
|
46
|
+
if (!search.activeEntry || !search.isResultCurrent()) return
|
|
47
|
+
const href = search.activeEntry.resolveHref(item)
|
|
48
|
+
const label = sanitizeDocumentsDisplayLabel(item.label)
|
|
49
|
+
if (!href || !label) return
|
|
50
|
+
const rawItem = item.rawItem ?? {}
|
|
51
|
+
const values = Object.fromEntries(search.activeEntry.tokenFields.map((field) => [
|
|
52
|
+
field.field,
|
|
53
|
+
sanitizeDocumentsDisplayLabel(field.extract(rawItem)),
|
|
54
|
+
]))
|
|
55
|
+
onPick({ type: search.activeEntry.type, id: item.id, label, href, values })
|
|
56
|
+
onOpenChange(false)
|
|
57
|
+
}, [onOpenChange, onPick, search.activeEntry, search.isResultCurrent])
|
|
58
|
+
|
|
59
|
+
const pickActiveItem = React.useCallback(() => {
|
|
60
|
+
const item = search.items[search.activeIndex]
|
|
61
|
+
if (item) selectItem(item)
|
|
62
|
+
}, [search.activeIndex, search.items, selectItem])
|
|
63
|
+
|
|
64
|
+
const handleSearchKeyDown = React.useCallback((event: React.KeyboardEvent<HTMLInputElement>) => {
|
|
65
|
+
if ((event.key === 'ArrowDown' || event.key === 'ArrowUp') && search.items.length === 0) {
|
|
66
|
+
event.preventDefault()
|
|
67
|
+
search.setActiveIndex(-1)
|
|
68
|
+
return
|
|
69
|
+
}
|
|
70
|
+
if (event.key === 'ArrowDown') {
|
|
71
|
+
event.preventDefault()
|
|
72
|
+
search.setActiveIndex((index) => Math.min(index + 1, search.items.length - 1))
|
|
73
|
+
return
|
|
74
|
+
}
|
|
75
|
+
if (event.key === 'ArrowUp') {
|
|
76
|
+
event.preventDefault()
|
|
77
|
+
search.setActiveIndex((index) => Math.max(index - 1, 0))
|
|
78
|
+
return
|
|
79
|
+
}
|
|
80
|
+
if (event.key === 'Enter') {
|
|
81
|
+
event.preventDefault()
|
|
82
|
+
pickActiveItem()
|
|
83
|
+
}
|
|
84
|
+
}, [pickActiveItem, search.items.length, search.setActiveIndex])
|
|
85
|
+
|
|
86
|
+
if (!open) return null
|
|
87
|
+
const hasQuery = search.searchValue.trim().length > 0
|
|
88
|
+
return (
|
|
89
|
+
<Dialog open={open} onOpenChange={onOpenChange}>
|
|
90
|
+
<DialogContent size="lg" onKeyDown={(event) => {
|
|
91
|
+
if (event.defaultPrevented) return
|
|
92
|
+
if (event.key === 'Escape') { event.preventDefault(); onOpenChange(false); return }
|
|
93
|
+
if ((event.metaKey || event.ctrlKey) && event.key === 'Enter') { event.preventDefault(); pickActiveItem(); return }
|
|
94
|
+
}}>
|
|
95
|
+
<DialogHeader>
|
|
96
|
+
<DialogTitle>{t('documents.entityPicker.title')}</DialogTitle>
|
|
97
|
+
<DialogDescription>{t('documents.entityPicker.description')}</DialogDescription>
|
|
98
|
+
</DialogHeader>
|
|
99
|
+
{!search.isRegistryReady ? (
|
|
100
|
+
<div role="status" aria-live="polite">
|
|
101
|
+
<LoadingMessage label={t('documents.entityPicker.loadingRegistry')} />
|
|
102
|
+
</div>
|
|
103
|
+
) : search.availableEntries.length > 0 ? (
|
|
104
|
+
<div className="space-y-4">
|
|
105
|
+
<SegmentedControl
|
|
106
|
+
value={search.activeEntry?.type}
|
|
107
|
+
onValueChange={(value) => {
|
|
108
|
+
const entry = search.availableEntries.find((candidate) => candidate.type === value)
|
|
109
|
+
if (!entry) return
|
|
110
|
+
search.setActiveType(entry.type)
|
|
111
|
+
search.setActiveIndex(-1)
|
|
112
|
+
}}
|
|
113
|
+
aria-label={t('documents.entityPicker.typeTabs')}
|
|
114
|
+
className="grid h-auto w-full grid-cols-2 gap-1 rounded-xl p-1 sm:grid-cols-4"
|
|
115
|
+
>
|
|
116
|
+
{search.availableEntries.map((entry) => (
|
|
117
|
+
<SegmentedControlItem
|
|
118
|
+
key={entry.type}
|
|
119
|
+
value={entry.type}
|
|
120
|
+
className="h-auto min-h-7 min-w-0 whitespace-normal px-2 py-1 text-center leading-tight"
|
|
121
|
+
>
|
|
122
|
+
{t(entry.labelKey)}
|
|
123
|
+
</SegmentedControlItem>
|
|
124
|
+
))}
|
|
125
|
+
</SegmentedControl>
|
|
126
|
+
<div className="space-y-2">
|
|
127
|
+
<Label htmlFor={inputId}>{t('documents.entityPicker.searchLabel')}</Label>
|
|
128
|
+
<Input
|
|
129
|
+
id={inputId}
|
|
130
|
+
value={search.searchValue}
|
|
131
|
+
onChange={(event) => search.setSearchValue(event.target.value)}
|
|
132
|
+
placeholder={t('documents.entityPicker.searchPlaceholder')}
|
|
133
|
+
leftIcon={<Search />}
|
|
134
|
+
role="combobox"
|
|
135
|
+
aria-expanded={hasQuery}
|
|
136
|
+
aria-controls={listId}
|
|
137
|
+
aria-autocomplete="list"
|
|
138
|
+
aria-activedescendant={search.activeIndex >= 0 && search.activeIndex < search.items.length ? `${listId}-option-${search.activeIndex}` : undefined}
|
|
139
|
+
onKeyDown={handleSearchKeyDown}
|
|
140
|
+
/>
|
|
141
|
+
</div>
|
|
142
|
+
<EntityPickerResults
|
|
143
|
+
listId={listId}
|
|
144
|
+
items={search.items}
|
|
145
|
+
activeIndex={search.activeIndex}
|
|
146
|
+
hasQuery={hasQuery}
|
|
147
|
+
isLoading={search.isLoading}
|
|
148
|
+
hasSearched={search.hasSearched}
|
|
149
|
+
hasError={search.hasError}
|
|
150
|
+
prompt={t('documents.entityPicker.prompt')}
|
|
151
|
+
loadingLabel={t('documents.entityPicker.loading')}
|
|
152
|
+
emptyLabel={t('documents.entityPicker.noMatches')}
|
|
153
|
+
errorLabel={t('documents.entityPicker.error.search')}
|
|
154
|
+
retryLabel={t('documents.actions.retry')}
|
|
155
|
+
onRetry={search.retry}
|
|
156
|
+
onActiveIndexChange={search.setActiveIndex}
|
|
157
|
+
onSelect={selectItem}
|
|
158
|
+
/>
|
|
159
|
+
</div>
|
|
160
|
+
) : (
|
|
161
|
+
<div className="rounded-md border border-border bg-muted/20 px-3 py-8 text-center text-sm text-muted-foreground">
|
|
162
|
+
{t(search.allEntries.length === 0 ? 'documents.entityPicker.empty' : 'documents.entityPicker.unavailable')}
|
|
163
|
+
</div>
|
|
164
|
+
)}
|
|
165
|
+
<DialogFooter><Button type="button" variant="outline" onClick={() => onOpenChange(false)}>{t('documents.actions.cancel')}</Button></DialogFooter>
|
|
166
|
+
</DialogContent>
|
|
167
|
+
</Dialog>
|
|
168
|
+
)
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export default EntityPicker
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import { Spinner } from '@open-mercato/ui/primitives/spinner'
|
|
4
|
+
import { Button } from '@open-mercato/ui/primitives/button'
|
|
5
|
+
import { ErrorMessage } from '@open-mercato/ui/backend/detail'
|
|
6
|
+
import { cn } from '@open-mercato/shared/lib/utils'
|
|
7
|
+
import type { EntitySearchItem } from './useEntitySearch'
|
|
8
|
+
|
|
9
|
+
type EntityPickerResultsProps = {
|
|
10
|
+
listId: string
|
|
11
|
+
items: EntitySearchItem[]
|
|
12
|
+
activeIndex: number
|
|
13
|
+
hasQuery: boolean
|
|
14
|
+
isLoading: boolean
|
|
15
|
+
hasSearched: boolean
|
|
16
|
+
hasError: boolean
|
|
17
|
+
prompt: string
|
|
18
|
+
loadingLabel: string
|
|
19
|
+
emptyLabel: string
|
|
20
|
+
errorLabel: string
|
|
21
|
+
retryLabel: string
|
|
22
|
+
onRetry: () => void
|
|
23
|
+
onActiveIndexChange: (index: number) => void
|
|
24
|
+
onSelect: (item: EntitySearchItem) => void
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function EntityPickerResults(props: EntityPickerResultsProps) {
|
|
28
|
+
return (
|
|
29
|
+
<div id={props.listId} role="listbox" className="min-h-56 max-h-80 overflow-y-auto rounded-md border border-border bg-popover p-1 text-popover-foreground">
|
|
30
|
+
{!props.hasQuery ? <div className="px-3 py-8 text-center text-sm text-muted-foreground">{props.prompt}</div> : null}
|
|
31
|
+
{props.hasQuery && props.isLoading ? (
|
|
32
|
+
<div className="flex items-center justify-center gap-2 px-3 py-8 text-sm text-muted-foreground"><Spinner className="size-4" /><span>{props.loadingLabel}</span></div>
|
|
33
|
+
) : null}
|
|
34
|
+
{props.hasQuery && !props.isLoading && props.hasSearched && props.items.length === 0 ? (
|
|
35
|
+
<div className="px-3 py-8 text-center text-sm text-muted-foreground">{props.emptyLabel}</div>
|
|
36
|
+
) : null}
|
|
37
|
+
{props.hasQuery && !props.isLoading && props.hasError ? (
|
|
38
|
+
<ErrorMessage
|
|
39
|
+
label={props.errorLabel}
|
|
40
|
+
action={<Button type="button" size="sm" variant="outline" onClick={props.onRetry}>{props.retryLabel}</Button>}
|
|
41
|
+
/>
|
|
42
|
+
) : null}
|
|
43
|
+
{!props.isLoading && !props.hasError && props.items.map((item, index) => (
|
|
44
|
+
<Button
|
|
45
|
+
id={`${props.listId}-option-${index}`}
|
|
46
|
+
key={item.id}
|
|
47
|
+
type="button"
|
|
48
|
+
variant="ghost"
|
|
49
|
+
role="option"
|
|
50
|
+
aria-selected={index === props.activeIndex}
|
|
51
|
+
className={cn('h-auto w-full justify-start px-3 py-2 text-left', index === props.activeIndex ? 'bg-accent text-accent-foreground' : null)}
|
|
52
|
+
onMouseDown={(event) => event.preventDefault()}
|
|
53
|
+
onMouseEnter={() => props.onActiveIndexChange(index)}
|
|
54
|
+
onClick={() => props.onSelect(item)}
|
|
55
|
+
>
|
|
56
|
+
<span className="min-w-0">
|
|
57
|
+
<span className="block truncate text-sm font-medium">{item.label}</span>
|
|
58
|
+
{item.subtitle ? <span className="block truncate text-xs text-muted-foreground">{item.subtitle}</span> : null}
|
|
59
|
+
</span>
|
|
60
|
+
</Button>
|
|
61
|
+
))}
|
|
62
|
+
</div>
|
|
63
|
+
)
|
|
64
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
import { Search } from 'lucide-react'
|
|
5
|
+
import { LoadingMessage, ErrorMessage } from '@open-mercato/ui/backend/detail'
|
|
6
|
+
import { Button } from '@open-mercato/ui/primitives/button'
|
|
7
|
+
import {
|
|
8
|
+
Dialog,
|
|
9
|
+
DialogContent,
|
|
10
|
+
DialogDescription,
|
|
11
|
+
DialogFooter,
|
|
12
|
+
DialogHeader,
|
|
13
|
+
DialogTitle,
|
|
14
|
+
} from '@open-mercato/ui/primitives/dialog'
|
|
15
|
+
import { Alert, AlertDescription } from '@open-mercato/ui/primitives/alert'
|
|
16
|
+
import { Input } from '@open-mercato/ui/primitives/input'
|
|
17
|
+
import { Label } from '@open-mercato/ui/primitives/label'
|
|
18
|
+
import { Radio, RadioGroup } from '@open-mercato/ui/primitives/radio'
|
|
19
|
+
import { Tag } from '@open-mercato/ui/primitives/tag'
|
|
20
|
+
import { useT } from '@open-mercato/shared/lib/i18n/context'
|
|
21
|
+
import { TemplatePreview } from './TemplatePreview'
|
|
22
|
+
import { TemplateSlotFields } from './TemplateSlotFields'
|
|
23
|
+
import { useTemplateInstantiation, type PresetTemplateContext } from './useTemplateInstantiation'
|
|
24
|
+
|
|
25
|
+
type NewFromTemplateDialogProps = {
|
|
26
|
+
open: boolean
|
|
27
|
+
folderId?: string | null
|
|
28
|
+
presetContext?: PresetTemplateContext
|
|
29
|
+
onOpenChange: (open: boolean) => void
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function NewFromTemplateDialog(props: NewFromTemplateDialogProps) {
|
|
33
|
+
const t = useT()
|
|
34
|
+
const titleInputId = React.useId()
|
|
35
|
+
const templateSearchId = React.useId()
|
|
36
|
+
const flow = useTemplateInstantiation(props)
|
|
37
|
+
const canCreate = Boolean(
|
|
38
|
+
flow.selectedTemplate && flow.preview && !flow.missingRequired &&
|
|
39
|
+
flow.preview.unresolvedTokens.length === 0 && !flow.isSubmitting,
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<Dialog open={props.open} onOpenChange={props.onOpenChange}>
|
|
44
|
+
<DialogContent size="xl" onKeyDown={(event) => {
|
|
45
|
+
if (event.key === 'Escape') props.onOpenChange(false)
|
|
46
|
+
if ((event.metaKey || event.ctrlKey) && event.key === 'Enter' && canCreate) {
|
|
47
|
+
event.preventDefault()
|
|
48
|
+
void flow.submit()
|
|
49
|
+
}
|
|
50
|
+
}}>
|
|
51
|
+
<DialogHeader>
|
|
52
|
+
<DialogTitle>{t('documents.templates.instantiate.title')}</DialogTitle>
|
|
53
|
+
<DialogDescription>{t('documents.templates.instantiate.description')}</DialogDescription>
|
|
54
|
+
</DialogHeader>
|
|
55
|
+
{flow.isLoading ? <LoadingMessage label={t('documents.templates.instantiate.loading')} /> : null}
|
|
56
|
+
{flow.loadError ? (
|
|
57
|
+
<ErrorMessage
|
|
58
|
+
label={flow.loadError}
|
|
59
|
+
action={<Button type="button" size="sm" variant="outline" onClick={flow.retryTemplates}>{t('documents.actions.retry')}</Button>}
|
|
60
|
+
/>
|
|
61
|
+
) : null}
|
|
62
|
+
{!flow.isLoading && !flow.loadError ? (
|
|
63
|
+
<div className="grid gap-6 lg:grid-cols-2">
|
|
64
|
+
<div className="space-y-5">
|
|
65
|
+
<div className="space-y-2">
|
|
66
|
+
<Label htmlFor={templateSearchId}>{t('documents.templates.search.label')}</Label>
|
|
67
|
+
<Input id={templateSearchId} value={flow.templateSearch} onChange={(event) => flow.setTemplateSearch(event.target.value)} leftIcon={<Search />} placeholder={t('documents.templates.list.searchPlaceholder')} />
|
|
68
|
+
</div>
|
|
69
|
+
<RadioGroup
|
|
70
|
+
className="max-h-48 overflow-y-auto"
|
|
71
|
+
value={flow.selectedTemplateId ?? ''}
|
|
72
|
+
onValueChange={flow.setSelectedTemplateId}
|
|
73
|
+
aria-label={t('documents.templates.instantiate.template')}
|
|
74
|
+
orientation="vertical"
|
|
75
|
+
>
|
|
76
|
+
{flow.templates.length === 0 ? (
|
|
77
|
+
<p className="rounded-md border border-border bg-muted/20 p-3 text-sm text-muted-foreground">{t('documents.templates.instantiate.empty')}</p>
|
|
78
|
+
) : null}
|
|
79
|
+
{flow.templates.map((template) => {
|
|
80
|
+
const compatible = props.presetContext
|
|
81
|
+
? template.contextSlots.some((slot) => slot.entityType === props.presetContext?.entityType)
|
|
82
|
+
: false
|
|
83
|
+
const optionId = `${templateSearchId}-${template.id}`
|
|
84
|
+
return (
|
|
85
|
+
<Label
|
|
86
|
+
key={template.id}
|
|
87
|
+
htmlFor={optionId}
|
|
88
|
+
className={`flex w-full cursor-pointer items-center justify-between gap-3 rounded-md border p-3 text-left font-normal transition-colors ${template.id === flow.selectedTemplateId ? 'border-accent-indigo bg-accent-indigo/5' : 'border-border bg-background hover:bg-muted/50'}`}
|
|
89
|
+
>
|
|
90
|
+
<span className="flex min-w-0 items-center gap-3">
|
|
91
|
+
<Radio id={optionId} value={template.id} />
|
|
92
|
+
<span className="min-w-0"><span className="block truncate font-medium">{template.name}</span>{template.description ? <span className="block truncate text-xs text-muted-foreground">{template.description}</span> : null}</span>
|
|
93
|
+
</span>
|
|
94
|
+
{compatible ? <Tag variant="info">{t('documents.templates.compatible')}</Tag> : null}
|
|
95
|
+
</Label>
|
|
96
|
+
)
|
|
97
|
+
})}
|
|
98
|
+
</RadioGroup>
|
|
99
|
+
{flow.selectedTemplate ? (
|
|
100
|
+
<>
|
|
101
|
+
<div className="space-y-2">
|
|
102
|
+
<Label htmlFor={titleInputId}>{t('documents.templates.instantiate.documentTitle')}</Label>
|
|
103
|
+
<Input id={titleInputId} value={flow.title} onChange={(event) => flow.setTitle(event.target.value)} placeholder={t('documents.templates.instantiate.documentTitlePlaceholder')} />
|
|
104
|
+
</div>
|
|
105
|
+
<TemplateSlotFields
|
|
106
|
+
slots={flow.selectedTemplate.contextSlots}
|
|
107
|
+
selections={flow.selections}
|
|
108
|
+
onSelectionChange={(slot, selection) => flow.setSelections((current) => ({ ...current, [slot]: selection }))}
|
|
109
|
+
/>
|
|
110
|
+
</>
|
|
111
|
+
) : null}
|
|
112
|
+
</div>
|
|
113
|
+
<div className="space-y-3">
|
|
114
|
+
<h3 className="text-sm font-semibold">{t('documents.templates.preview.title')}</h3>
|
|
115
|
+
{flow.previewError ? (
|
|
116
|
+
<Alert status="error">
|
|
117
|
+
<AlertDescription className="flex flex-wrap items-center justify-between gap-3">
|
|
118
|
+
<span>{flow.previewError}</span>
|
|
119
|
+
<Button type="button" size="sm" variant="outline" onClick={flow.retryPreview}>{t('documents.actions.retry')}</Button>
|
|
120
|
+
</AlertDescription>
|
|
121
|
+
</Alert>
|
|
122
|
+
) : null}
|
|
123
|
+
<TemplatePreview preview={flow.preview} isLoading={flow.isPreviewLoading} />
|
|
124
|
+
</div>
|
|
125
|
+
</div>
|
|
126
|
+
) : null}
|
|
127
|
+
<DialogFooter>
|
|
128
|
+
<Button type="button" variant="outline" onClick={() => props.onOpenChange(false)} disabled={flow.isSubmitting}>{t('documents.actions.cancel')}</Button>
|
|
129
|
+
<Button type="button" onClick={() => void flow.submit()} disabled={!canCreate}>{t('documents.templates.instantiate.actions.create')}</Button>
|
|
130
|
+
</DialogFooter>
|
|
131
|
+
</DialogContent>
|
|
132
|
+
</Dialog>
|
|
133
|
+
)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export default NewFromTemplateDialog
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
import { Search, X } from 'lucide-react'
|
|
5
|
+
import { Alert } from '@open-mercato/ui/primitives/alert'
|
|
6
|
+
import { Button } from '@open-mercato/ui/primitives/button'
|
|
7
|
+
import { IconButton } from '@open-mercato/ui/primitives/icon-button'
|
|
8
|
+
import { Input } from '@open-mercato/ui/primitives/input'
|
|
9
|
+
import { useT } from '@open-mercato/shared/lib/i18n/context'
|
|
10
|
+
import { cn } from '@open-mercato/shared/lib/utils'
|
|
11
|
+
import type { PrincipalType } from './principalPickerModel'
|
|
12
|
+
import { usePrincipalPicker } from './usePrincipalPicker'
|
|
13
|
+
|
|
14
|
+
type PrincipalPickerProps = {
|
|
15
|
+
documentId: string
|
|
16
|
+
principalType: PrincipalType
|
|
17
|
+
value: string | null
|
|
18
|
+
onChange: (id: string | null, label: string | null) => void
|
|
19
|
+
disabled?: boolean
|
|
20
|
+
id?: string
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function PrincipalPicker({ documentId, principalType, value, onChange, disabled = false, id }: PrincipalPickerProps) {
|
|
24
|
+
const t = useT()
|
|
25
|
+
const generatedId = React.useId()
|
|
26
|
+
const inputId = id ?? `documents-principal-picker-${generatedId}`
|
|
27
|
+
const listId = `${inputId}-list`
|
|
28
|
+
const containerRef = React.useRef<HTMLDivElement>(null)
|
|
29
|
+
const fallbackLabel = t(principalType === 'user' ? 'documents.users.unknown' : 'documents.roles.unknown')
|
|
30
|
+
const picker = usePrincipalPicker({ documentId, principalType, value, onChange, disabled, fallbackLabel })
|
|
31
|
+
const placeholder = t(principalType === 'user' ? 'documents.share.picker.searchUser' : 'documents.share.picker.searchRole')
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<div ref={containerRef} className="relative space-y-1" onKeyDown={picker.handleKeyDown} onBlur={(event) => {
|
|
35
|
+
if (event.relatedTarget instanceof Node && containerRef.current?.contains(event.relatedTarget)) return
|
|
36
|
+
picker.setOpen(false)
|
|
37
|
+
}}>
|
|
38
|
+
<div className="flex items-center gap-2">
|
|
39
|
+
<div className="min-w-0 flex-1">
|
|
40
|
+
<Input
|
|
41
|
+
id={inputId}
|
|
42
|
+
className="w-full"
|
|
43
|
+
value={picker.displayValue}
|
|
44
|
+
onChange={(event) => picker.changeSearch(event.target.value)}
|
|
45
|
+
onFocus={() => { if (!picker.selectedLabel && !picker.fetchError) picker.setOpen(true) }}
|
|
46
|
+
placeholder={placeholder}
|
|
47
|
+
disabled={disabled}
|
|
48
|
+
leftIcon={<Search />}
|
|
49
|
+
role="combobox"
|
|
50
|
+
aria-expanded={picker.open && !picker.fetchError}
|
|
51
|
+
aria-controls={listId}
|
|
52
|
+
aria-autocomplete="list"
|
|
53
|
+
aria-activedescendant={!picker.fetchError && picker.activeIndex >= 0 ? `${listId}-option-${picker.activeIndex}` : undefined}
|
|
54
|
+
/>
|
|
55
|
+
</div>
|
|
56
|
+
{picker.displayValue ? <IconButton type="button" variant="ghost" className="shrink-0" aria-label={t('documents.share.picker.clear')} onClick={picker.clear} disabled={disabled}><X aria-hidden="true" /></IconButton> : null}
|
|
57
|
+
</div>
|
|
58
|
+
{picker.fetchError ? <Alert status="error" size="sm" action={<Button type="button" size="sm" variant="outline" onMouseDown={(event) => event.preventDefault()} onClick={picker.retry} disabled={disabled || picker.loading}>{t('documents.share.picker.retry')}</Button>}>{t('documents.share.picker.error')}</Alert> : null}
|
|
59
|
+
{picker.open && !picker.fetchError ? (
|
|
60
|
+
<div id={listId} role="listbox" className="absolute z-popover mt-1 max-h-72 w-full overflow-y-auto rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-lg">
|
|
61
|
+
{picker.loading ? <div className="px-3 py-2 text-sm text-muted-foreground">{t('documents.share.picker.loading')}</div> : null}
|
|
62
|
+
{!picker.loading && picker.hasFetched && !picker.items.length ? <div className="px-3 py-2 text-sm text-muted-foreground">{t('documents.share.picker.noMatches')}</div> : null}
|
|
63
|
+
{!picker.loading && picker.items.length ? <div className="space-y-1">{picker.items.map((item, index) => (
|
|
64
|
+
<Button
|
|
65
|
+
id={`${listId}-option-${index}`}
|
|
66
|
+
key={item.id}
|
|
67
|
+
type="button"
|
|
68
|
+
variant="ghost"
|
|
69
|
+
role="option"
|
|
70
|
+
aria-selected={index === picker.activeIndex}
|
|
71
|
+
disabled={disabled}
|
|
72
|
+
className={cn('h-auto w-full justify-start px-3 py-2 text-left', index === picker.activeIndex && 'bg-accent text-accent-foreground')}
|
|
73
|
+
onMouseDown={(event) => event.preventDefault()}
|
|
74
|
+
onMouseEnter={() => picker.setActiveIndex(index)}
|
|
75
|
+
onClick={() => picker.selectOption(item)}
|
|
76
|
+
>
|
|
77
|
+
<span className="min-w-0"><span className="block truncate text-sm font-medium">{item.primary}</span>{item.secondary ? <span className="block truncate text-xs text-muted-foreground">{item.secondary}</span> : null}</span>
|
|
78
|
+
</Button>
|
|
79
|
+
))}</div> : null}
|
|
80
|
+
{!picker.loading && picker.hasFetched ? <div className="border-t border-border px-2 py-2">
|
|
81
|
+
{picker.total > 0 ? <p className="mb-2 text-xs text-muted-foreground">{t('documents.share.picker.showing', { count: picker.items.length, total: picker.total })}</p> : null}
|
|
82
|
+
{picker.page < picker.totalPages ? <Button type="button" size="sm" variant="outline" className="w-full" onMouseDown={(event) => event.preventDefault()} onClick={picker.loadMore} disabled={picker.loadingMore}>{picker.loadingMore ? t('documents.share.picker.loading') : t('documents.share.picker.loadMore')}</Button> : null}
|
|
83
|
+
</div> : null}
|
|
84
|
+
</div>
|
|
85
|
+
) : null}
|
|
86
|
+
</div>
|
|
87
|
+
)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export default PrincipalPicker
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import { useT } from '@open-mercato/shared/lib/i18n/context'
|
|
4
|
+
import { Button } from '@open-mercato/ui/primitives/button'
|
|
5
|
+
import {
|
|
6
|
+
Dialog,
|
|
7
|
+
DialogContent,
|
|
8
|
+
DialogDescription,
|
|
9
|
+
DialogFooter,
|
|
10
|
+
DialogHeader,
|
|
11
|
+
DialogTitle,
|
|
12
|
+
} from '@open-mercato/ui/primitives/dialog'
|
|
13
|
+
import { ShareDialogAddForm } from './ShareDialogAddForm'
|
|
14
|
+
import { ShareDialogList } from './ShareDialogList'
|
|
15
|
+
import { useShareDialog } from './useShareDialog'
|
|
16
|
+
|
|
17
|
+
type ShareDialogProps = {
|
|
18
|
+
documentId: string
|
|
19
|
+
open: boolean
|
|
20
|
+
onOpenChange: (open: boolean) => void
|
|
21
|
+
/**
|
|
22
|
+
* Explicit live share capability. Omission retains the pre-capability public
|
|
23
|
+
* component contract; new in-app callers must always pass the server value.
|
|
24
|
+
* Server authorization remains authoritative for every mutation.
|
|
25
|
+
* @default true
|
|
26
|
+
*/
|
|
27
|
+
canManage?: boolean
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function ShareDialog({
|
|
31
|
+
documentId,
|
|
32
|
+
open,
|
|
33
|
+
onOpenChange,
|
|
34
|
+
canManage = true,
|
|
35
|
+
}: ShareDialogProps) {
|
|
36
|
+
const t = useT()
|
|
37
|
+
const dialog = useShareDialog({ documentId, open, canManage })
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<Dialog open={open} onOpenChange={onOpenChange}>
|
|
41
|
+
<DialogContent
|
|
42
|
+
size="lg"
|
|
43
|
+
onKeyDown={(event) => {
|
|
44
|
+
if ((event.metaKey || event.ctrlKey) && event.key === 'Enter' && !dialog.isSubmitting) {
|
|
45
|
+
event.preventDefault()
|
|
46
|
+
void dialog.addShare()
|
|
47
|
+
}
|
|
48
|
+
}}
|
|
49
|
+
>
|
|
50
|
+
<DialogHeader>
|
|
51
|
+
<DialogTitle>{t('documents.share.dialog.title')}</DialogTitle>
|
|
52
|
+
<DialogDescription>{t('documents.share.dialog.description')}</DialogDescription>
|
|
53
|
+
</DialogHeader>
|
|
54
|
+
|
|
55
|
+
<div className="space-y-4">
|
|
56
|
+
<ShareDialogAddForm
|
|
57
|
+
documentId={documentId}
|
|
58
|
+
principalType={dialog.principalType}
|
|
59
|
+
principalId={dialog.principalId}
|
|
60
|
+
permission={dialog.permission}
|
|
61
|
+
canManage={canManage}
|
|
62
|
+
isSubmitting={dialog.isSubmitting}
|
|
63
|
+
onPrincipalTypeChange={dialog.changePrincipalType}
|
|
64
|
+
onPrincipalIdChange={dialog.setPrincipalId}
|
|
65
|
+
onPermissionChange={dialog.setPermission}
|
|
66
|
+
onSubmit={dialog.addShare}
|
|
67
|
+
/>
|
|
68
|
+
<ShareDialogList
|
|
69
|
+
shares={dialog.shares}
|
|
70
|
+
isLoading={dialog.isLoading}
|
|
71
|
+
error={dialog.error}
|
|
72
|
+
canManage={canManage}
|
|
73
|
+
pendingShareIds={dialog.pendingShareIds}
|
|
74
|
+
onRetry={() => void dialog.reload()}
|
|
75
|
+
onPermissionChange={dialog.changePermission}
|
|
76
|
+
onRemove={dialog.removeShare}
|
|
77
|
+
/>
|
|
78
|
+
</div>
|
|
79
|
+
|
|
80
|
+
<DialogFooter>
|
|
81
|
+
<Button type="button" variant="outline" onClick={() => onOpenChange(false)}>
|
|
82
|
+
{t('documents.actions.close')}
|
|
83
|
+
</Button>
|
|
84
|
+
</DialogFooter>
|
|
85
|
+
</DialogContent>
|
|
86
|
+
</Dialog>
|
|
87
|
+
)
|
|
88
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
import { useT } from '@open-mercato/shared/lib/i18n/context'
|
|
5
|
+
import { Button } from '@open-mercato/ui/primitives/button'
|
|
6
|
+
import { Label } from '@open-mercato/ui/primitives/label'
|
|
7
|
+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@open-mercato/ui/primitives/select'
|
|
8
|
+
import { PrincipalPicker } from './PrincipalPicker'
|
|
9
|
+
import {
|
|
10
|
+
PRINCIPAL_TYPES,
|
|
11
|
+
SHARE_PERMISSIONS,
|
|
12
|
+
readPermission,
|
|
13
|
+
readPrincipalType,
|
|
14
|
+
type DocumentSharePermission,
|
|
15
|
+
type DocumentSharePrincipalType,
|
|
16
|
+
} from './shareDialogModel'
|
|
17
|
+
|
|
18
|
+
type ShareDialogAddFormProps = {
|
|
19
|
+
documentId: string
|
|
20
|
+
principalType: DocumentSharePrincipalType
|
|
21
|
+
principalId: string
|
|
22
|
+
permission: DocumentSharePermission
|
|
23
|
+
canManage: boolean
|
|
24
|
+
isSubmitting: boolean
|
|
25
|
+
onPrincipalTypeChange: (value: DocumentSharePrincipalType) => void
|
|
26
|
+
onPrincipalIdChange: (value: string) => void
|
|
27
|
+
onPermissionChange: (value: DocumentSharePermission) => void
|
|
28
|
+
onSubmit: () => Promise<void>
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function ShareDialogAddForm({
|
|
32
|
+
documentId,
|
|
33
|
+
principalType,
|
|
34
|
+
principalId,
|
|
35
|
+
permission,
|
|
36
|
+
canManage,
|
|
37
|
+
isSubmitting,
|
|
38
|
+
onPrincipalTypeChange,
|
|
39
|
+
onPrincipalIdChange,
|
|
40
|
+
onPermissionChange,
|
|
41
|
+
onSubmit,
|
|
42
|
+
}: ShareDialogAddFormProps) {
|
|
43
|
+
const t = useT()
|
|
44
|
+
const principalInputId = React.useId()
|
|
45
|
+
const principalTypeInputId = React.useId()
|
|
46
|
+
const permissionInputId = React.useId()
|
|
47
|
+
const disabled = !canManage || isSubmitting
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<form
|
|
51
|
+
className="grid gap-3 rounded-lg border border-border bg-muted/20 p-4 md:grid-cols-3"
|
|
52
|
+
onSubmit={(event) => {
|
|
53
|
+
event.preventDefault()
|
|
54
|
+
void onSubmit()
|
|
55
|
+
}}
|
|
56
|
+
>
|
|
57
|
+
<div className="space-y-2">
|
|
58
|
+
<Label htmlFor={principalInputId}>{t('documents.share.dialog.principalSearch')}</Label>
|
|
59
|
+
<PrincipalPicker
|
|
60
|
+
documentId={documentId}
|
|
61
|
+
id={principalInputId}
|
|
62
|
+
principalType={principalType}
|
|
63
|
+
value={principalId || null}
|
|
64
|
+
onChange={(id) => onPrincipalIdChange(id ?? '')}
|
|
65
|
+
disabled={disabled}
|
|
66
|
+
/>
|
|
67
|
+
</div>
|
|
68
|
+
<div className="space-y-2">
|
|
69
|
+
<Label htmlFor={principalTypeInputId}>{t('documents.share.dialog.principalType')}</Label>
|
|
70
|
+
<Select
|
|
71
|
+
value={principalType}
|
|
72
|
+
onValueChange={(value) => onPrincipalTypeChange(readPrincipalType(value))}
|
|
73
|
+
disabled={disabled}
|
|
74
|
+
>
|
|
75
|
+
<SelectTrigger id={principalTypeInputId}>
|
|
76
|
+
<SelectValue />
|
|
77
|
+
</SelectTrigger>
|
|
78
|
+
<SelectContent>
|
|
79
|
+
{PRINCIPAL_TYPES.map((type) => (
|
|
80
|
+
<SelectItem key={type} value={type}>
|
|
81
|
+
{t(`documents.share.principalTypes.${type}`)}
|
|
82
|
+
</SelectItem>
|
|
83
|
+
))}
|
|
84
|
+
</SelectContent>
|
|
85
|
+
</Select>
|
|
86
|
+
</div>
|
|
87
|
+
<div className="space-y-2">
|
|
88
|
+
<Label htmlFor={permissionInputId}>{t('documents.share.dialog.permission')}</Label>
|
|
89
|
+
<Select
|
|
90
|
+
value={permission}
|
|
91
|
+
onValueChange={(value) => onPermissionChange(readPermission(value))}
|
|
92
|
+
disabled={disabled}
|
|
93
|
+
>
|
|
94
|
+
<SelectTrigger id={permissionInputId}>
|
|
95
|
+
<SelectValue />
|
|
96
|
+
</SelectTrigger>
|
|
97
|
+
<SelectContent>
|
|
98
|
+
{SHARE_PERMISSIONS.map((tier) => (
|
|
99
|
+
<SelectItem key={tier} value={tier}>
|
|
100
|
+
{t(`documents.permissions.${tier}`)}
|
|
101
|
+
</SelectItem>
|
|
102
|
+
))}
|
|
103
|
+
</SelectContent>
|
|
104
|
+
</Select>
|
|
105
|
+
</div>
|
|
106
|
+
<div className="md:col-span-3">
|
|
107
|
+
<Button type="submit" disabled={disabled || principalId.trim().length === 0}>
|
|
108
|
+
{t('documents.share.dialog.add')}
|
|
109
|
+
</Button>
|
|
110
|
+
</div>
|
|
111
|
+
</form>
|
|
112
|
+
)
|
|
113
|
+
}
|