@rebasepro/cms 0.24.0 → 0.24.1-canary.g56af4a4
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/dist/collection_editor/CollectionEditorDialogsContext.js +10 -0
- package/dist/collection_editor/CollectionEditorDialogsContext.js.map +1 -0
- package/dist/collection_editor/ConfigControllerProvider.js +274 -0
- package/dist/collection_editor/ConfigControllerProvider.js.map +1 -0
- package/dist/collection_editor/api/generateCollectionApi.js +64 -0
- package/dist/collection_editor/api/generateCollectionApi.js.map +1 -0
- package/dist/collection_editor/collection_wire.d.ts +13 -0
- package/dist/collection_editor/collection_wire.js +49 -0
- package/dist/collection_editor/collection_wire.js.map +1 -0
- package/dist/collection_editor/liveSchemaClient.js +130 -0
- package/dist/collection_editor/liveSchemaClient.js.map +1 -0
- package/dist/collection_editor/relation_kinds.js +74 -0
- package/dist/collection_editor/relation_kinds.js.map +1 -0
- package/dist/collection_editor/serializable_types.d.ts +4 -1
- package/dist/collection_editor/serializable_utils.js +504 -0
- package/dist/collection_editor/serializable_utils.js.map +1 -0
- package/dist/collection_editor/ui/EditorCollectionAction.js +37 -0
- package/dist/collection_editor/ui/EditorCollectionAction.js.map +1 -0
- package/dist/collection_editor/ui/MissingReferenceWidget.js +39 -0
- package/dist/collection_editor/ui/MissingReferenceWidget.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/AICollectionGeneratorPopover.js +160 -0
- package/dist/collection_editor/ui/collection_editor/AICollectionGeneratorPopover.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/AIModifiedPathsContext.js +61 -0
- package/dist/collection_editor/ui/collection_editor/AIModifiedPathsContext.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/CollectionEditorDialog.js +731 -0
- package/dist/collection_editor/ui/collection_editor/CollectionEditorDialog.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/CollectionEditorWelcomeView.js +220 -0
- package/dist/collection_editor/ui/collection_editor/CollectionEditorWelcomeView.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/CollectionJsonImportDialog.js +160 -0
- package/dist/collection_editor/ui/collection_editor/CollectionJsonImportDialog.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/CollectionPropertiesEditorForm.js +394 -0
- package/dist/collection_editor/ui/collection_editor/CollectionPropertiesEditorForm.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/CollectionRLSTab.js +616 -0
- package/dist/collection_editor/ui/collection_editor/CollectionRLSTab.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/CollectionStudioView.js +68 -0
- package/dist/collection_editor/ui/collection_editor/CollectionStudioView.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/CollectionYupValidation.js +11 -0
- package/dist/collection_editor/ui/collection_editor/CollectionYupValidation.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/CollectionsStudioView.js +148 -0
- package/dist/collection_editor/ui/collection_editor/CollectionsStudioView.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/DisplaySettingsForm.js +244 -0
- package/dist/collection_editor/ui/collection_editor/DisplaySettingsForm.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/EnumForm.js +222 -0
- package/dist/collection_editor/ui/collection_editor/EnumForm.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/GeneralSettingsForm.js +204 -0
- package/dist/collection_editor/ui/collection_editor/GeneralSettingsForm.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/GetCodeDialog.js +108 -0
- package/dist/collection_editor/ui/collection_editor/GetCodeDialog.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/KanbanConfigSection.js +163 -0
- package/dist/collection_editor/ui/collection_editor/KanbanConfigSection.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/LayoutModeSwitch.js +59 -0
- package/dist/collection_editor/ui/collection_editor/LayoutModeSwitch.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/PropertyEditView.js +640 -0
- package/dist/collection_editor/ui/collection_editor/PropertyEditView.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/PropertyFieldPreview.js +141 -0
- package/dist/collection_editor/ui/collection_editor/PropertyFieldPreview.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/PropertyTree.js +210 -0
- package/dist/collection_editor/ui/collection_editor/PropertyTree.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/RouterCollectionStudioView.js +31 -0
- package/dist/collection_editor/ui/collection_editor/RouterCollectionStudioView.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/RouterCollectionsStudioView.js +25 -0
- package/dist/collection_editor/ui/collection_editor/RouterCollectionsStudioView.js.map +1 -0
- package/dist/{SchemaChangeDialog-CcFSXvkK.js → collection_editor/ui/collection_editor/SchemaChangeDialog.js} +42 -59
- package/dist/collection_editor/ui/collection_editor/SchemaChangeDialog.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/SwitchControl.js +24 -0
- package/dist/collection_editor/ui/collection_editor/SwitchControl.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/ViewModeSwitch.js +66 -0
- package/dist/collection_editor/ui/collection_editor/ViewModeSwitch.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.js +61 -0
- package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportMapping.js +188 -0
- package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportMapping.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/import/clean_import_data.d.ts +12 -0
- package/dist/collection_editor/ui/collection_editor/import/clean_import_data.js +74 -0
- package/dist/collection_editor/ui/collection_editor/import/clean_import_data.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/BlockPropertyField.js +100 -0
- package/dist/collection_editor/ui/collection_editor/properties/BlockPropertyField.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/BooleanPropertyField.js +34 -0
- package/dist/collection_editor/ui/collection_editor/properties/BooleanPropertyField.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/CommonPropertyFields.js +75 -0
- package/dist/collection_editor/ui/collection_editor/properties/CommonPropertyFields.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/DateTimePropertyField.js +338 -0
- package/dist/collection_editor/ui/collection_editor/properties/DateTimePropertyField.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/EnumPropertyField.js +83 -0
- package/dist/collection_editor/ui/collection_editor/properties/EnumPropertyField.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/KeyValuePropertyField.js +15 -0
- package/dist/collection_editor/ui/collection_editor/properties/KeyValuePropertyField.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/MapPropertyField.js +121 -0
- package/dist/collection_editor/ui/collection_editor/properties/MapPropertyField.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/MarkdownPropertyField.js +127 -0
- package/dist/collection_editor/ui/collection_editor/properties/MarkdownPropertyField.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/NumberPropertyField.js +151 -0
- package/dist/collection_editor/ui/collection_editor/properties/NumberPropertyField.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/ReferencePropertyField.js +77 -0
- package/dist/collection_editor/ui/collection_editor/properties/ReferencePropertyField.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/RelationPropertyField.js +254 -0
- package/dist/collection_editor/ui/collection_editor/properties/RelationPropertyField.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/RepeatPropertyField.js +71 -0
- package/dist/collection_editor/ui/collection_editor/properties/RepeatPropertyField.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/StoragePropertyField.js +356 -0
- package/dist/collection_editor/ui/collection_editor/properties/StoragePropertyField.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/StringPropertyField.js +173 -0
- package/dist/collection_editor/ui/collection_editor/properties/StringPropertyField.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/UrlPropertyField.js +79 -0
- package/dist/collection_editor/ui/collection_editor/properties/UrlPropertyField.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/VectorPropertyField.js +34 -0
- package/dist/collection_editor/ui/collection_editor/properties/VectorPropertyField.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/advanced/AdvancedPropertyValidation.js +47 -0
- package/dist/collection_editor/ui/collection_editor/properties/advanced/AdvancedPropertyValidation.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/validation/ArrayPropertyValidation.js +47 -0
- package/dist/collection_editor/ui/collection_editor/properties/validation/ArrayPropertyValidation.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/validation/GeneralPropertyValidation.js +62 -0
- package/dist/collection_editor/ui/collection_editor/properties/validation/GeneralPropertyValidation.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/validation/NumberPropertyValidation.js +119 -0
- package/dist/collection_editor/ui/collection_editor/properties/validation/NumberPropertyValidation.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/validation/StringPropertyValidation.d.ts +10 -0
- package/dist/collection_editor/ui/collection_editor/properties/validation/StringPropertyValidation.js +178 -0
- package/dist/collection_editor/ui/collection_editor/properties/validation/StringPropertyValidation.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/validation/ValidationPanel.js +23 -0
- package/dist/collection_editor/ui/collection_editor/properties/validation/ValidationPanel.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/templates/blog_template.js +116 -0
- package/dist/collection_editor/ui/collection_editor/templates/blog_template.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/templates/pages_template.js +182 -0
- package/dist/collection_editor/ui/collection_editor/templates/pages_template.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/templates/products_template.js +87 -0
- package/dist/collection_editor/ui/collection_editor/templates/products_template.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/templates/users_template.js +46 -0
- package/dist/collection_editor/ui/collection_editor/templates/users_template.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/util.js +20 -0
- package/dist/collection_editor/ui/collection_editor/util.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/utils/strings.js +2 -0
- package/dist/collection_editor/ui/collection_editor/utils/supported_fields.js +37 -0
- package/dist/collection_editor/ui/collection_editor/utils/supported_fields.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/utils/update_property_for_widget.js +192 -0
- package/dist/collection_editor/ui/collection_editor/utils/update_property_for_widget.js.map +1 -0
- package/dist/collection_editor/useCollectionEditorController.js +12 -0
- package/dist/collection_editor/useCollectionEditorController.js.map +1 -0
- package/dist/collection_editor/useCollectionsConfigController.js +12 -0
- package/dist/collection_editor/useCollectionsConfigController.js.map +1 -0
- package/dist/collection_editor/useJsonCollectionsConfigController.js +191 -0
- package/dist/collection_editor/useJsonCollectionsConfigController.js.map +1 -0
- package/dist/collection_editor/useLiveSchemaEditing.js +214 -0
- package/dist/collection_editor/useLiveSchemaEditing.js.map +1 -0
- package/dist/collection_editor/useLocalCollectionsConfigController.js +228 -0
- package/dist/collection_editor/useLocalCollectionsConfigController.js.map +1 -0
- package/dist/collection_editor/useSafeSnackbarController.js +13 -0
- package/dist/collection_editor/useSafeSnackbarController.js.map +1 -0
- package/dist/collection_editor/validateCollectionJson.js +289 -0
- package/dist/collection_editor/validateCollectionJson.js.map +1 -0
- package/dist/collection_editor_ui.js +7 -33
- package/dist/components/AdditionalFieldValue.js +60 -0
- package/dist/components/AdditionalFieldValue.js.map +1 -0
- package/dist/components/AdminModeSyncer.js +41 -0
- package/dist/components/AdminModeSyncer.js.map +1 -0
- package/dist/components/ArrayContainer.d.ts +8 -2
- package/dist/components/ArrayContainer.js +363 -0
- package/dist/components/ArrayContainer.js.map +1 -0
- package/dist/components/ClearFilterSortButton.js +33 -0
- package/dist/components/ClearFilterSortButton.js.map +1 -0
- package/dist/components/CollectionEditorDialogs.js +49 -0
- package/dist/components/CollectionEditorDialogs.js.map +1 -0
- package/dist/components/CollectionPanel.js +95 -0
- package/dist/components/CollectionPanel.js.map +1 -0
- package/dist/components/CollectionTableBinding/CollectionRowActions.js +165 -0
- package/dist/components/CollectionTableBinding/CollectionRowActions.js.map +1 -0
- package/dist/components/CollectionTableBinding/CollectionTableBinding.js +329 -0
- package/dist/components/CollectionTableBinding/CollectionTableBinding.js.map +1 -0
- package/dist/components/CollectionTableBinding/PropertyTableCell.js +311 -0
- package/dist/components/CollectionTableBinding/PropertyTableCell.js.map +1 -0
- package/dist/components/CollectionTableBinding/column_utils.js +85 -0
- package/dist/components/CollectionTableBinding/column_utils.js.map +1 -0
- package/dist/components/CollectionTableBinding/fields/CompactEntityCellField.js +45 -0
- package/dist/components/CollectionTableBinding/fields/CompactEntityCellField.js.map +1 -0
- package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.js +66 -0
- package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.js.map +1 -0
- package/dist/components/CollectionTableBinding/fields/TableReferenceField.js +86 -0
- package/dist/components/CollectionTableBinding/fields/TableReferenceField.js.map +1 -0
- package/dist/components/CollectionTableBinding/fields/TableRelationField.js +93 -0
- package/dist/components/CollectionTableBinding/fields/TableRelationField.js.map +1 -0
- package/dist/components/CollectionTableBinding/fields/TableRelationSelectorField.js +33 -0
- package/dist/components/CollectionTableBinding/fields/TableRelationSelectorField.js.map +1 -0
- package/dist/components/CollectionTableBinding/fields/TableStorageUpload.js +171 -0
- package/dist/components/CollectionTableBinding/fields/TableStorageUpload.js.map +1 -0
- package/dist/components/CollectionTableBinding/fields/VirtualTableSelect.js +91 -0
- package/dist/components/CollectionTableBinding/fields/VirtualTableSelect.js.map +1 -0
- package/dist/components/CollectionTableBinding/fields/VirtualTableUserSelect.js +36 -0
- package/dist/components/CollectionTableBinding/fields/VirtualTableUserSelect.js.map +1 -0
- package/dist/components/CollectionTableBinding/index.js +6 -0
- package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.js +50 -0
- package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.js.map +1 -0
- package/dist/components/CollectionTableBinding/internal/EntityTableCell.d.ts +2 -0
- package/dist/components/CollectionTableBinding/internal/EntityTableCell.js +223 -0
- package/dist/components/CollectionTableBinding/internal/EntityTableCell.js.map +1 -0
- package/dist/components/CollectionTableBinding/internal/EntityTableCellActions.js +58 -0
- package/dist/components/CollectionTableBinding/internal/EntityTableCellActions.js.map +1 -0
- package/dist/components/CollectionTableBinding/internal/TableCellOpener.js +53 -0
- package/dist/components/CollectionTableBinding/internal/TableCellOpener.js.map +1 -0
- package/dist/components/CollectionTableBinding/internal/common.js +40 -0
- package/dist/components/CollectionTableBinding/internal/common.js.map +1 -0
- package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js +270 -0
- package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js.map +1 -0
- package/dist/components/CollectionTableBinding/internal/popup_field/useDraggable.js +68 -0
- package/dist/components/CollectionTableBinding/internal/popup_field/useDraggable.js.map +1 -0
- package/dist/components/CollectionTableBinding/internal/popup_field/useWindowSize.js +24 -0
- package/dist/components/CollectionTableBinding/internal/popup_field/useWindowSize.js.map +1 -0
- package/dist/components/CollectionTableBinding/table_bindings.js +306 -0
- package/dist/components/CollectionTableBinding/table_bindings.js.map +1 -0
- package/dist/components/CollectionViewBinding/BoardCardBinding.js +160 -0
- package/dist/components/CollectionViewBinding/BoardCardBinding.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.js +471 -0
- package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionCardViewBinding.js +108 -0
- package/dist/components/CollectionViewBinding/CollectionCardViewBinding.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionListViewBinding.js +988 -0
- package/dist/components/CollectionViewBinding/CollectionListViewBinding.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionViewActions.js +146 -0
- package/dist/components/CollectionViewBinding/CollectionViewActions.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionViewBinding.js +1209 -0
- package/dist/components/CollectionViewBinding/CollectionViewBinding.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionViewStartActions.js +133 -0
- package/dist/components/CollectionViewBinding/CollectionViewStartActions.js.map +1 -0
- package/dist/components/CollectionViewBinding/EntityCardBinding.js +133 -0
- package/dist/components/CollectionViewBinding/EntityCardBinding.js.map +1 -0
- package/dist/components/CollectionViewBinding/FilterPresetsButton.js +203 -0
- package/dist/components/CollectionViewBinding/FilterPresetsButton.js.map +1 -0
- package/dist/components/CollectionViewBinding/FiltersDialog.js +148 -0
- package/dist/components/CollectionViewBinding/FiltersDialog.js.map +1 -0
- package/dist/components/CollectionViewBinding/SearchExplanation.js +86 -0
- package/dist/components/CollectionViewBinding/SearchExplanation.js.map +1 -0
- package/dist/components/CollectionViewBinding/SearchHighlight.js +262 -0
- package/dist/components/CollectionViewBinding/SearchHighlight.js.map +1 -0
- package/dist/components/CollectionViewBinding/SlotValue.js +117 -0
- package/dist/components/CollectionViewBinding/SlotValue.js.map +1 -0
- package/dist/components/CollectionViewBinding/SortButton.js +214 -0
- package/dist/components/CollectionViewBinding/SortButton.js.map +1 -0
- package/dist/components/CollectionViewBinding/SplitListCloseButton.js +41 -0
- package/dist/components/CollectionViewBinding/SplitListCloseButton.js.map +1 -0
- package/dist/components/CollectionViewBinding/SplitListShowButton.js +29 -0
- package/dist/components/CollectionViewBinding/SplitListShowButton.js.map +1 -0
- package/dist/components/CollectionViewBinding/SplitListView.js +311 -0
- package/dist/components/CollectionViewBinding/SplitListView.js.map +1 -0
- package/dist/components/CollectionViewBinding/SplitViewContext.js +21 -0
- package/dist/components/CollectionViewBinding/SplitViewContext.js.map +1 -0
- package/dist/components/CollectionViewBinding/ViewModeToggle.js +150 -0
- package/dist/components/CollectionViewBinding/ViewModeToggle.js.map +1 -0
- package/dist/components/CollectionViewBinding/hooks/useCollectionInlineEditor.js +49 -0
- package/dist/components/CollectionViewBinding/hooks/useCollectionInlineEditor.js.map +1 -0
- package/dist/components/CollectionViewBinding/hooks/useKanbanDragAndDrop.js +122 -0
- package/dist/components/CollectionViewBinding/hooks/useKanbanDragAndDrop.js.map +1 -0
- package/dist/components/CollectionViewBinding/useBoardDataController.js +530 -0
- package/dist/components/CollectionViewBinding/useBoardDataController.js.map +1 -0
- package/dist/components/CollectionViewBinding/usePreviewSlots.d.ts +4 -1
- package/dist/components/CollectionViewBinding/usePreviewSlots.js +384 -0
- package/dist/components/CollectionViewBinding/usePreviewSlots.js.map +1 -0
- package/dist/components/CollectionViewBinding/useSelectionController.js +104 -0
- package/dist/components/CollectionViewBinding/useSelectionController.js.map +1 -0
- package/dist/components/CollectionViewBinding/utils.js +21 -0
- package/dist/components/CollectionViewBinding/utils.js.map +1 -0
- package/dist/components/DefaultAppBar.js +179 -0
- package/dist/components/DefaultAppBar.js.map +1 -0
- package/dist/components/DefaultDrawer.js +364 -0
- package/dist/components/DefaultDrawer.js.map +1 -0
- package/dist/components/DeleteEntityDialog.js +256 -0
- package/dist/components/DeleteEntityDialog.js.map +1 -0
- package/dist/components/DetailViewBinding.js +504 -0
- package/dist/components/DetailViewBinding.js.map +1 -0
- package/dist/components/DrawerNavigationGroup.js +74 -0
- package/dist/components/DrawerNavigationGroup.js.map +1 -0
- package/dist/components/DrawerNavigationItem.d.ts +8 -0
- package/dist/components/DrawerNavigationItem.js +45 -0
- package/dist/components/DrawerNavigationItem.js.map +1 -0
- package/dist/components/EditFormActions.js +210 -0
- package/dist/components/EditFormActions.js.map +1 -0
- package/dist/components/EditViewBinding.js +802 -0
- package/dist/components/EditViewBinding.js.map +1 -0
- package/dist/components/EntityDisplayHeader.js +139 -0
- package/dist/components/EntityDisplayHeader.js.map +1 -0
- package/dist/components/EntityIdentityBar.js +364 -0
- package/dist/components/EntityIdentityBar.js.map +1 -0
- package/dist/components/EntityInspector.js +96 -0
- package/dist/components/EntityInspector.js.map +1 -0
- package/dist/components/EntityPreviewBinding.js +282 -0
- package/dist/components/EntityPreviewBinding.js.map +1 -0
- package/dist/components/EntityPreviewNesting.js +53 -0
- package/dist/components/EntityPreviewNesting.js.map +1 -0
- package/dist/components/EntityViewBinding.js +246 -0
- package/dist/components/EntityViewBinding.js.map +1 -0
- package/dist/components/FieldCaption.js +17 -0
- package/dist/components/FieldCaption.js.map +1 -0
- package/dist/components/HomePage/ContentHomePage.js +326 -0
- package/dist/components/HomePage/ContentHomePage.js.map +1 -0
- package/dist/components/HomePage/FavouritesView.js +44 -0
- package/dist/components/HomePage/FavouritesView.js.map +1 -0
- package/dist/components/HomePage/HomePageDnD.js +436 -0
- package/dist/components/HomePage/HomePageDnD.js.map +1 -0
- package/dist/components/HomePage/NavigationCard.js +59 -0
- package/dist/components/HomePage/NavigationCard.js.map +1 -0
- package/dist/components/HomePage/NavigationCardBinding.js +70 -0
- package/dist/components/HomePage/NavigationCardBinding.js.map +1 -0
- package/dist/components/HomePage/NavigationGroup.js +98 -0
- package/dist/components/HomePage/NavigationGroup.js.map +1 -0
- package/dist/components/HomePage/RenameGroupDialog.js +89 -0
- package/dist/components/HomePage/RenameGroupDialog.js.map +1 -0
- package/dist/components/InlineEntityPreview.js +116 -0
- package/dist/components/InlineEntityPreview.js.map +1 -0
- package/dist/{JsonPreviewBinding-v0w3H0fp.js → components/JsonPreviewBinding.js} +2 -2
- package/dist/components/JsonPreviewBinding.js.map +1 -0
- package/dist/components/NavigationLoadingErrorView.js +27 -0
- package/dist/components/NavigationLoadingErrorView.js.map +1 -0
- package/dist/components/PickerTrigger.js +27 -0
- package/dist/components/PickerTrigger.js.map +1 -0
- package/dist/components/PropertyCollectionView.js +215 -0
- package/dist/components/PropertyCollectionView.js.map +1 -0
- package/dist/components/PropertyConfigBadge.js +19 -0
- package/dist/components/PropertyConfigBadge.js.map +1 -0
- package/dist/components/PropertyKeyHint.js +58 -0
- package/dist/components/PropertyKeyHint.js.map +1 -0
- package/dist/components/RebaseAuthGate.js +35 -0
- package/dist/components/RebaseAuthGate.js.map +1 -0
- package/dist/components/RebaseCMS.js +44 -0
- package/dist/components/RebaseCMS.js.map +1 -0
- package/dist/components/RebaseLayout.js +59 -0
- package/dist/components/RebaseLayout.js.map +1 -0
- package/dist/components/RebaseNavigation.js +211 -0
- package/dist/components/RebaseNavigation.js.map +1 -0
- package/dist/components/RebaseRouteDefs.js +96 -0
- package/dist/components/RebaseRouteDefs.js.map +1 -0
- package/dist/components/RebaseShell.js +50 -0
- package/dist/components/RebaseShell.js.map +1 -0
- package/dist/components/ReferenceTable/SelectionTableBinding.js +224 -0
- package/dist/components/ReferenceTable/SelectionTableBinding.js.map +1 -0
- package/dist/components/ReferenceWidget.js +100 -0
- package/dist/components/ReferenceWidget.js.map +1 -0
- package/dist/components/RelationSelector.js +625 -0
- package/dist/components/RelationSelector.js.map +1 -0
- package/dist/components/SearchIconsView.js +52 -0
- package/dist/components/SearchIconsView.js.map +1 -0
- package/dist/components/SelectableTable/SelectableTable.d.ts +1 -1
- package/dist/components/SelectableTable/SelectableTable.js +158 -0
- package/dist/components/SelectableTable/SelectableTable.js.map +1 -0
- package/dist/components/SelectableTable/SelectableTableContext.js +8 -0
- package/dist/components/SelectableTable/SelectableTableContext.js.map +1 -0
- package/dist/components/SelectableTable/SelectionStore.js +29 -0
- package/dist/components/SelectableTable/SelectionStore.js.map +1 -0
- package/dist/components/SelectableTable/filters/BooleanFilterField.js +28 -0
- package/dist/components/SelectableTable/filters/BooleanFilterField.js.map +1 -0
- package/dist/components/SelectableTable/filters/DateTimeFilterField.d.ts +2 -1
- package/dist/components/SelectableTable/filters/DateTimeFilterField.js +93 -0
- package/dist/components/SelectableTable/filters/DateTimeFilterField.js.map +1 -0
- package/dist/components/SelectableTable/filters/FilterFieldBinding.js +132 -0
- package/dist/components/SelectableTable/filters/FilterFieldBinding.js.map +1 -0
- package/dist/components/SelectableTable/filters/ReferenceFilterField.js +157 -0
- package/dist/components/SelectableTable/filters/ReferenceFilterField.js.map +1 -0
- package/dist/components/SelectableTable/filters/RelationFilterField.js +169 -0
- package/dist/components/SelectableTable/filters/RelationFilterField.js.map +1 -0
- package/dist/components/SelectableTable/filters/StringNumberFilterField.js +181 -0
- package/dist/components/SelectableTable/filters/StringNumberFilterField.js.map +1 -0
- package/dist/components/SelectableTable/filters/null_filter.js +36 -0
- package/dist/components/SelectableTable/filters/null_filter.js.map +1 -0
- package/dist/components/SideDialogs.js +149 -0
- package/dist/components/SideDialogs.js.map +1 -0
- package/dist/components/SidePanelBinding.js +287 -0
- package/dist/components/SidePanelBinding.js.map +1 -0
- package/dist/components/SidePanelProvider.js +69 -0
- package/dist/components/SidePanelProvider.js.map +1 -0
- package/dist/components/UserSelector.d.ts +2 -0
- package/dist/components/UserSelector.js +418 -0
- package/dist/components/UserSelector.js.map +1 -0
- package/dist/components/admin/CreationResultDialog.js +118 -0
- package/dist/components/admin/CreationResultDialog.js.map +1 -0
- package/dist/components/app/AppBar.js +14 -0
- package/dist/components/app/AppBar.js.map +1 -0
- package/dist/components/app/Drawer.js +26 -0
- package/dist/components/app/Drawer.js.map +1 -0
- package/dist/components/app/Scaffold.js +229 -0
- package/dist/components/app/Scaffold.js.map +1 -0
- package/dist/components/app/useApp.js +24 -0
- package/dist/components/app/useApp.js.map +1 -0
- package/dist/components/common/ActionMenuLabel.js +30 -0
- package/dist/components/common/ActionMenuLabel.js.map +1 -0
- package/dist/components/common/default_entity_actions.js +590 -0
- package/dist/components/common/default_entity_actions.js.map +1 -0
- package/dist/components/drawer_expansion.d.ts +25 -0
- package/dist/components/drawer_expansion.js +44 -0
- package/dist/components/drawer_expansion.js.map +1 -0
- package/dist/components/field_configs.d.ts +2 -2
- package/dist/components/field_configs.js +431 -0
- package/dist/components/field_configs.js.map +1 -0
- package/dist/components/field_ids.d.ts +11 -0
- package/dist/components/field_ids.js +58 -0
- package/dist/components/field_ids.js.map +1 -0
- package/dist/components/history/EntityHistoryEntry.js +151 -0
- package/dist/components/history/EntityHistoryEntry.js.map +1 -0
- package/dist/components/history/EntityHistoryView.js +157 -0
- package/dist/components/history/EntityHistoryView.js.map +1 -0
- package/dist/components/history/UserChip.js +21 -0
- package/dist/components/history/UserChip.js.map +1 -0
- package/dist/components/history/index.js +4 -0
- package/dist/components/lazy_record_views.d.ts +10 -0
- package/dist/components/lazy_record_views.js +57 -0
- package/dist/components/lazy_record_views.js.map +1 -0
- package/dist/contexts/BreacrumbsContext.js +28 -0
- package/dist/contexts/BreacrumbsContext.js.map +1 -0
- package/dist/contexts/EditorAIControllerContext.d.ts +18 -0
- package/dist/contexts/EditorAIControllerContext.js +29 -0
- package/dist/contexts/EditorAIControllerContext.js.map +1 -0
- package/dist/contexts/SideDialogsControllerContext.js +7 -0
- package/dist/contexts/SideDialogsControllerContext.js.map +1 -0
- package/dist/data_export/export/BasicExportAction.js +151 -0
- package/dist/data_export/export/BasicExportAction.js.map +1 -0
- package/dist/data_export/export/ExportCollectionAction.js +297 -0
- package/dist/data_export/export/ExportCollectionAction.js.map +1 -0
- package/dist/data_export/export/additional_fields.js +40 -0
- package/dist/data_export/export/additional_fields.js.map +1 -0
- package/dist/data_export/export/export.d.ts +35 -0
- package/dist/data_export/export/export.js +400 -0
- package/dist/data_export/export/export.js.map +1 -0
- package/dist/data_export/export/fetch_export_data.d.ts +17 -7
- package/dist/data_export/export/fetch_export_data.js +67 -0
- package/dist/data_export/export/fetch_export_data.js.map +1 -0
- package/dist/data_export/export/index.d.ts +4 -2
- package/dist/data_export/export/index.js +5 -0
- package/dist/data_import/components/DataNewPropertiesMapping.js +207 -0
- package/dist/data_import/components/DataNewPropertiesMapping.js.map +1 -0
- package/dist/data_import/components/ImportConversionProblems.js +89 -0
- package/dist/data_import/components/ImportConversionProblems.js.map +1 -0
- package/dist/data_import/components/ImportFileUpload.js +43 -0
- package/dist/data_import/components/ImportFileUpload.js.map +1 -0
- package/dist/data_import/components/ImportNewPropertyFieldPreview.js +42 -0
- package/dist/data_import/components/ImportNewPropertyFieldPreview.js.map +1 -0
- package/dist/data_import/components/ImportSaveInProgress.js +105 -0
- package/dist/data_import/components/ImportSaveInProgress.js.map +1 -0
- package/dist/data_import/hooks/useImportConfig.js +34 -0
- package/dist/data_import/hooks/useImportConfig.js.map +1 -0
- package/dist/{import-DjQoRrIU.js → data_import/import/ImportCollectionAction.js} +53 -43
- package/dist/data_import/import/ImportCollectionAction.js.map +1 -0
- package/dist/data_import/import/index.js +2 -0
- package/dist/data_import/utils/csv.js +146 -0
- package/dist/data_import/utils/csv.js.map +1 -0
- package/dist/data_import/utils/data.js +366 -0
- package/dist/data_import/utils/data.js.map +1 -0
- package/dist/data_import/utils/file_headers.js +32 -0
- package/dist/data_import/utils/file_headers.js.map +1 -0
- package/dist/data_import/utils/file_to_json.js +149 -0
- package/dist/data_import/utils/file_to_json.js.map +1 -0
- package/dist/data_import/utils/get_import_inference_type.js +14 -0
- package/dist/data_import/utils/get_import_inference_type.js.map +1 -0
- package/dist/data_import/utils/id_column.js +27 -0
- package/dist/data_import/utils/id_column.js.map +1 -0
- package/dist/data_import/utils/import_columns.js +92 -0
- package/dist/data_import/utils/import_columns.js.map +1 -0
- package/dist/data_import/utils/save_entities.d.ts +33 -4
- package/dist/data_import/utils/save_entities.js +244 -0
- package/dist/data_import/utils/save_entities.js.map +1 -0
- package/dist/data_import/utils/transforms.js +83 -0
- package/dist/data_import/utils/transforms.js.map +1 -0
- package/dist/editor/components/SlashCommandMenu.js +497 -0
- package/dist/editor/components/SlashCommandMenu.js.map +1 -0
- package/dist/editor/components/editor-bubble-item.js +24 -0
- package/dist/editor/components/editor-bubble-item.js.map +1 -0
- package/dist/editor/components/editor-bubble.js +97 -0
- package/dist/editor/components/editor-bubble.js.map +1 -0
- package/dist/editor/components/image-bubble.js +148 -0
- package/dist/editor/components/image-bubble.js.map +1 -0
- package/dist/editor/components/table-bubble.js +406 -0
- package/dist/editor/components/table-bubble.js.map +1 -0
- package/dist/editor/editor.js +423 -0
- package/dist/editor/editor.js.map +1 -0
- package/dist/editor/extensions/HighlightDecorationExtension.js +74 -0
- package/dist/editor/extensions/HighlightDecorationExtension.js.map +1 -0
- package/dist/editor/extensions/Image.d.ts +7 -1
- package/dist/editor/extensions/Image.js +160 -0
- package/dist/editor/extensions/Image.js.map +1 -0
- package/dist/editor/extensions/TextLoadingDecorationExtension.js +82 -0
- package/dist/editor/extensions/TextLoadingDecorationExtension.js.map +1 -0
- package/dist/editor/extensions/clipboard.js +63 -0
- package/dist/editor/extensions/clipboard.js.map +1 -0
- package/dist/editor/extensions/drag-and-drop.js +354 -0
- package/dist/editor/extensions/drag-and-drop.js.map +1 -0
- package/dist/editor/hooks/useProseMirror.js +101 -0
- package/dist/editor/hooks/useProseMirror.js.map +1 -0
- package/dist/editor/hooks/useProseMirrorContext.js +11 -0
- package/dist/editor/hooks/useProseMirrorContext.js.map +1 -0
- package/dist/editor/markdown.js +154 -0
- package/dist/editor/markdown.js.map +1 -0
- package/dist/editor/nodeViews/ImageComponent.js +35 -0
- package/dist/editor/nodeViews/ImageComponent.js.map +1 -0
- package/dist/editor/nodeViews/ReactNodeView.js +57 -0
- package/dist/editor/nodeViews/ReactNodeView.js.map +1 -0
- package/dist/editor/nodeViews/TaskItemComponent.js +29 -0
- package/dist/editor/nodeViews/TaskItemComponent.js.map +1 -0
- package/dist/editor/nodeViews/index.js +21 -0
- package/dist/editor/nodeViews/index.js.map +1 -0
- package/dist/editor/plugins/index.js +54 -0
- package/dist/editor/plugins/index.js.map +1 -0
- package/dist/editor/plugins/inputrules.js +54 -0
- package/dist/editor/plugins/inputrules.js.map +1 -0
- package/dist/editor/plugins/placeholderPlugin.js +38 -0
- package/dist/editor/plugins/placeholderPlugin.js.map +1 -0
- package/dist/editor/plugins/slashCommandPlugin.js +40 -0
- package/dist/editor/plugins/slashCommandPlugin.js.map +1 -0
- package/dist/editor/sanitize-html.js +190 -0
- package/dist/editor/sanitize-html.js.map +1 -0
- package/dist/{markdown-CCqp8ibf.js → editor/schema.js} +2 -159
- package/dist/editor/schema.js.map +1 -0
- package/dist/editor/selectors/link-selector.js +118 -0
- package/dist/editor/selectors/link-selector.js.map +1 -0
- package/dist/editor/selectors/node-selector.js +118 -0
- package/dist/editor/selectors/node-selector.js.map +1 -0
- package/dist/editor/selectors/text-buttons.js +71 -0
- package/dist/editor/selectors/text-buttons.js.map +1 -0
- package/dist/editor/utils/prosemirror-utils.js +92 -0
- package/dist/editor/utils/prosemirror-utils.js.map +1 -0
- package/dist/editor/utils/remove_classes.js +16 -0
- package/dist/editor/utils/remove_classes.js.map +1 -0
- package/dist/editor.js +1 -3147
- package/dist/form/EntityForm.js +734 -0
- package/dist/form/EntityForm.js.map +1 -0
- package/dist/form/EntityFormActions.js +101 -0
- package/dist/form/EntityFormActions.js.map +1 -0
- package/dist/form/EntityFormBinding.js +257 -0
- package/dist/form/EntityFormBinding.js.map +1 -0
- package/dist/form/PropertyFieldBinding.js +298 -0
- package/dist/form/PropertyFieldBinding.js.map +1 -0
- package/dist/form/components/ErrorFocus.js +33 -0
- package/dist/form/components/ErrorFocus.js.map +1 -0
- package/dist/form/components/FieldBlock.js +118 -0
- package/dist/form/components/FieldBlock.js.map +1 -0
- package/dist/form/components/FieldHelperText.js +56 -0
- package/dist/form/components/FieldHelperText.js.map +1 -0
- package/dist/form/components/FormRail.js +118 -0
- package/dist/form/components/FormRail.js.map +1 -0
- package/dist/form/components/FormSections.js +63 -0
- package/dist/form/components/FormSections.js.map +1 -0
- package/dist/form/components/LabelWithIcon.js +29 -0
- package/dist/form/components/LabelWithIcon.js.map +1 -0
- package/dist/form/components/LocalChangesMenu.js +127 -0
- package/dist/form/components/LocalChangesMenu.js.map +1 -0
- package/dist/form/components/StorageItemPreview.js +46 -0
- package/dist/form/components/StorageItemPreview.js.map +1 -0
- package/dist/form/components/StorageUploadProgress.js +84 -0
- package/dist/form/components/StorageUploadProgress.js.map +1 -0
- package/dist/form/components/useRailVisible.js +43 -0
- package/dist/form/components/useRailVisible.js.map +1 -0
- package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.js +84 -0
- package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.js +125 -0
- package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/BinaryFieldBinding.js +135 -0
- package/dist/form/field_bindings/BinaryFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/BlockFieldBinding.js +164 -0
- package/dist/form/field_bindings/BlockFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/DateTimeFieldBinding.js +47 -0
- package/dist/form/field_bindings/DateTimeFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/GeopointFieldBinding.js +148 -0
- package/dist/form/field_bindings/GeopointFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/KeyValueFieldBinding.js +450 -0
- package/dist/form/field_bindings/KeyValueFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/MapFieldBinding.js +77 -0
- package/dist/form/field_bindings/MapFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/MarkdownEditorFieldBinding.js +215 -0
- package/dist/form/field_bindings/MarkdownEditorFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/MultiSelectFieldBinding.js +88 -0
- package/dist/form/field_bindings/MultiSelectFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/MultipleRelationFieldBinding.js +118 -0
- package/dist/form/field_bindings/MultipleRelationFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/ReadOnlyFieldBinding.js +52 -0
- package/dist/form/field_bindings/ReadOnlyFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/ReferenceFieldBinding.js +99 -0
- package/dist/form/field_bindings/ReferenceFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/RelationFieldBinding.js +135 -0
- package/dist/form/field_bindings/RelationFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/RepeatFieldBinding.js +103 -0
- package/dist/form/field_bindings/RepeatFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/SelectFieldBinding.js +80 -0
- package/dist/form/field_bindings/SelectFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/StorageUploadFieldBinding.js +266 -0
- package/dist/form/field_bindings/StorageUploadFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/SwitchFieldBinding.js +41 -0
- package/dist/form/field_bindings/SwitchFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/TextFieldBinding.js +114 -0
- package/dist/form/field_bindings/TextFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/UserSelectFieldBinding.js +48 -0
- package/dist/form/field_bindings/UserSelectFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/VectorFieldBinding.js +147 -0
- package/dist/form/field_bindings/VectorFieldBinding.js.map +1 -0
- package/dist/form/form_keyboard_scope.d.ts +26 -0
- package/dist/form/form_keyboard_scope.js +39 -0
- package/dist/form/form_keyboard_scope.js.map +1 -0
- package/dist/form/form_uploads.d.ts +24 -0
- package/dist/form/form_uploads.js +31 -0
- package/dist/form/form_uploads.js.map +1 -0
- package/dist/form/form_utils.d.ts +24 -0
- package/dist/form/form_utils.js +280 -0
- package/dist/form/form_utils.js.map +1 -0
- package/dist/form/resolve_cell_property.d.ts +32 -0
- package/dist/form/resolve_cell_property.js +80 -0
- package/dist/form/resolve_cell_property.js.map +1 -0
- package/dist/form/resolve_form_properties.d.ts +2 -1
- package/dist/form/resolve_form_properties.js +78 -0
- package/dist/form/resolve_form_properties.js.map +1 -0
- package/dist/form/useClearRestoreValue.js +27 -0
- package/dist/form/useClearRestoreValue.js.map +1 -0
- package/dist/form/useUndoableDiscard.js +36 -0
- package/dist/form/useUndoableDiscard.js.map +1 -0
- package/dist/form/validation.d.ts +20 -0
- package/dist/form/validation.js +416 -0
- package/dist/form/validation.js.map +1 -0
- package/dist/hooks/navigation/contexts/CollectionRegistryContext.js +22 -0
- package/dist/hooks/navigation/contexts/CollectionRegistryContext.js.map +1 -0
- package/dist/hooks/navigation/contexts/NavigationStateContext.js +15 -0
- package/dist/hooks/navigation/contexts/NavigationStateContext.js.map +1 -0
- package/dist/hooks/navigation/contexts/UrlContext.js +22 -0
- package/dist/hooks/navigation/contexts/UrlContext.js.map +1 -0
- package/dist/hooks/navigation/useAsyncResolver.js +68 -0
- package/dist/hooks/navigation/useAsyncResolver.js.map +1 -0
- package/dist/hooks/navigation/useBuildCollectionRegistryController.js +141 -0
- package/dist/hooks/navigation/useBuildCollectionRegistryController.js.map +1 -0
- package/dist/hooks/navigation/useBuildNavigationStateController.js +77 -0
- package/dist/hooks/navigation/useBuildNavigationStateController.js.map +1 -0
- package/dist/hooks/navigation/useBuildUrlController.js +57 -0
- package/dist/hooks/navigation/useBuildUrlController.js.map +1 -0
- package/dist/hooks/navigation/useNavigationResolution.js +177 -0
- package/dist/hooks/navigation/useNavigationResolution.js.map +1 -0
- package/dist/hooks/navigation/useResolvedCollections.js +56 -0
- package/dist/hooks/navigation/useResolvedCollections.js.map +1 -0
- package/dist/hooks/navigation/useResolvedViews.js +94 -0
- package/dist/hooks/navigation/useResolvedViews.js.map +1 -0
- package/dist/hooks/navigation/useTopLevelNavigation.js +162 -0
- package/dist/hooks/navigation/useTopLevelNavigation.js.map +1 -0
- package/dist/hooks/navigation/utils.js +125 -0
- package/dist/hooks/navigation/utils.js.map +1 -0
- package/dist/hooks/useAdminContext.js +45 -0
- package/dist/hooks/useAdminContext.js.map +1 -0
- package/dist/hooks/useBreadcrumbsController.js +17 -0
- package/dist/hooks/useBreadcrumbsController.js.map +1 -0
- package/dist/hooks/useBuildSideDialogsController.js +96 -0
- package/dist/hooks/useBuildSideDialogsController.js.map +1 -0
- package/dist/hooks/useBuildSidePanel.js +208 -0
- package/dist/hooks/useBuildSidePanel.js.map +1 -0
- package/dist/hooks/useChildViewSource.js +41 -0
- package/dist/hooks/useChildViewSource.js.map +1 -0
- package/dist/hooks/useEntityDisplay.js +136 -0
- package/dist/hooks/useEntityDisplay.js.map +1 -0
- package/dist/hooks/useEntityDisplayTitle.js +34 -0
- package/dist/hooks/useEntityDisplayTitle.js.map +1 -0
- package/dist/hooks/useHistory.js +137 -0
- package/dist/hooks/useHistory.js.map +1 -0
- package/dist/hooks/useRecordActions.js +108 -0
- package/dist/hooks/useRecordActions.js.map +1 -0
- package/dist/hooks/useReferencePaths.js +32 -0
- package/dist/hooks/useReferencePaths.js.map +1 -0
- package/dist/hooks/useResolvedNavigationFrom.js +83 -0
- package/dist/hooks/useResolvedNavigationFrom.js.map +1 -0
- package/dist/hooks/useResolvedUsers.js +109 -0
- package/dist/hooks/useResolvedUsers.js.map +1 -0
- package/dist/hooks/useSelectionDialog.js +53 -0
- package/dist/hooks/useSelectionDialog.js.map +1 -0
- package/dist/hooks/useSideDialogsController.js +8 -0
- package/dist/hooks/useSideDialogsController.js.map +1 -0
- package/dist/hooks/useSidePanel.js +15 -0
- package/dist/hooks/useSidePanel.js.map +1 -0
- package/dist/hooks/useStorageReferenceResolver.d.ts +4 -2
- package/dist/hooks/useStorageReferenceResolver.js +49 -0
- package/dist/hooks/useStorageReferenceResolver.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +149 -3867
- package/dist/preview/PropertyPreview.js +260 -0
- package/dist/preview/PropertyPreview.js.map +1 -0
- package/dist/preview/compact_text.js +52 -0
- package/dist/preview/compact_text.js.map +1 -0
- package/dist/preview/components/ArrayEnumPreview.js +24 -0
- package/dist/preview/components/ArrayEnumPreview.js.map +1 -0
- package/dist/preview/components/BooleanPreview.js +25 -0
- package/dist/preview/components/BooleanPreview.js.map +1 -0
- package/dist/preview/components/DatePreview.d.ts +3 -2
- package/dist/preview/components/DatePreview.js +87 -0
- package/dist/preview/components/DatePreview.js.map +1 -0
- package/dist/preview/components/EmptyValue.js +13 -0
- package/dist/preview/components/EmptyValue.js.map +1 -0
- package/dist/preview/components/EnumValuesChip.js +26 -0
- package/dist/preview/components/EnumValuesChip.js.map +1 -0
- package/dist/preview/components/ImagePreview.d.ts +7 -1
- package/dist/preview/components/ImagePreview.js +112 -0
- package/dist/preview/components/ImagePreview.js.map +1 -0
- package/dist/preview/components/InlineEntityListPreview.js +31 -0
- package/dist/preview/components/InlineEntityListPreview.js.map +1 -0
- package/dist/preview/components/ReferencePreview.js +162 -0
- package/dist/preview/components/ReferencePreview.js.map +1 -0
- package/dist/preview/components/RelationPreview.js +196 -0
- package/dist/preview/components/RelationPreview.js.map +1 -0
- package/dist/preview/components/StorageMarkdown.d.ts +2 -1
- package/dist/preview/components/StorageMarkdown.js +49 -0
- package/dist/preview/components/StorageMarkdown.js.map +1 -0
- package/dist/preview/components/StorageThumbnail.js +183 -0
- package/dist/preview/components/StorageThumbnail.js.map +1 -0
- package/dist/preview/components/UrlComponentPreview.d.ts +3 -1
- package/dist/preview/components/UrlComponentPreview.js +88 -0
- package/dist/preview/components/UrlComponentPreview.js.map +1 -0
- package/dist/preview/components/UserPreview.js +30 -0
- package/dist/preview/components/UserPreview.js.map +1 -0
- package/dist/preview/components/date_fns_locales.js +124 -0
- package/dist/preview/components/date_fns_locales.js.map +1 -0
- package/dist/preview/components/storageRenditions.d.ts +10 -0
- package/dist/preview/components/storageRenditions.js +93 -0
- package/dist/preview/components/storageRenditions.js.map +1 -0
- package/dist/preview/property_previews/ArrayOfMapsPreview.js +44 -0
- package/dist/preview/property_previews/ArrayOfMapsPreview.js.map +1 -0
- package/dist/preview/property_previews/ArrayOfReferencesPreview.js +48 -0
- package/dist/preview/property_previews/ArrayOfReferencesPreview.js.map +1 -0
- package/dist/preview/property_previews/ArrayOfRelationsPreview.js +50 -0
- package/dist/preview/property_previews/ArrayOfRelationsPreview.js.map +1 -0
- package/dist/preview/property_previews/ArrayOfStorageComponentsPreview.js +30 -0
- package/dist/preview/property_previews/ArrayOfStorageComponentsPreview.js.map +1 -0
- package/dist/preview/property_previews/ArrayOfStringsPreview.js +42 -0
- package/dist/preview/property_previews/ArrayOfStringsPreview.js.map +1 -0
- package/dist/preview/property_previews/ArrayOneOfPreview.js +47 -0
- package/dist/preview/property_previews/ArrayOneOfPreview.js.map +1 -0
- package/dist/preview/property_previews/ArrayPropertyEnumPreview.js +25 -0
- package/dist/preview/property_previews/ArrayPropertyEnumPreview.js.map +1 -0
- package/dist/preview/property_previews/ArrayPropertyPreview.js +48 -0
- package/dist/preview/property_previews/ArrayPropertyPreview.js.map +1 -0
- package/dist/preview/property_previews/MapPropertyPreview.js +137 -0
- package/dist/preview/property_previews/MapPropertyPreview.js.map +1 -0
- package/dist/preview/property_previews/NumberPropertyPreview.js +34 -0
- package/dist/preview/property_previews/NumberPropertyPreview.js.map +1 -0
- package/dist/preview/property_previews/SkeletonPropertyComponent.js +151 -0
- package/dist/preview/property_previews/SkeletonPropertyComponent.js.map +1 -0
- package/dist/preview/property_previews/StringPropertyPreview.js +49 -0
- package/dist/preview/property_previews/StringPropertyPreview.js.map +1 -0
- package/dist/preview/util.d.ts +4 -3
- package/dist/{util-D7ebttKT.js → preview/util.js} +8 -5
- package/dist/preview/util.js.map +1 -0
- package/dist/routes/CustomViewRoute.js +26 -0
- package/dist/routes/CustomViewRoute.js.map +1 -0
- package/dist/routes/RebaseRoute.js +311 -0
- package/dist/routes/RebaseRoute.js.map +1 -0
- package/dist/selection/SelectionMenu.js +90 -0
- package/dist/selection/SelectionMenu.js.map +1 -0
- package/dist/selection/resolve_selection.js +79 -0
- package/dist/selection/resolve_selection.js.map +1 -0
- package/dist/util/caller_scopes.js +25 -0
- package/dist/util/caller_scopes.js.map +1 -0
- package/dist/util/collection_open_mode.d.ts +20 -0
- package/dist/util/collection_open_mode.js +32 -0
- package/dist/util/collection_open_mode.js.map +1 -0
- package/dist/util/dataControllerAdapter.js +65 -0
- package/dist/util/dataControllerAdapter.js.map +1 -0
- package/dist/util/entity_actions.d.ts +5 -0
- package/dist/util/entity_actions.js +77 -0
- package/dist/util/entity_actions.js.map +1 -0
- package/dist/util/entity_pages.d.ts +37 -3
- package/dist/util/entity_pages.js +71 -0
- package/dist/util/entity_pages.js.map +1 -0
- package/dist/util/find_entities_by_ids.d.ts +23 -0
- package/dist/util/find_entities_by_ids.js +55 -0
- package/dist/util/find_entities_by_ids.js.map +1 -0
- package/dist/util/fit_inline_actions.js +40 -0
- package/dist/util/fit_inline_actions.js.map +1 -0
- package/dist/util/format_collection_date.d.ts +29 -0
- package/dist/util/format_collection_date.js +60 -0
- package/dist/util/format_collection_date.js.map +1 -0
- package/dist/util/map_with_concurrency.js +46 -0
- package/dist/util/map_with_concurrency.js.map +1 -0
- package/dist/util/navigation_utils.js +44 -0
- package/dist/util/navigation_utils.js.map +1 -0
- package/dist/util/number_format.js +33 -0
- package/dist/util/number_format.js.map +1 -0
- package/dist/util/previews.js +71 -0
- package/dist/util/previews.js.map +1 -0
- package/dist/util/propertyConfigMapper.js +83 -0
- package/dist/util/propertyConfigMapper.js.map +1 -0
- package/dist/util/property_utils.js +141 -0
- package/dist/util/property_utils.js.map +1 -0
- package/dist/util/resolutions.js +55 -0
- package/dist/util/resolutions.js.map +1 -0
- package/dist/util/view_constants.js +35 -0
- package/dist/util/view_constants.js.map +1 -0
- package/dist/util/view_mode.js +112 -0
- package/dist/util/view_mode.js.map +1 -0
- package/package.json +13 -9
- package/dist/CollectionEditorDialog-p5-I-Apu.js +0 -3669
- package/dist/CollectionEditorDialog-p5-I-Apu.js.map +0 -1
- package/dist/JsonPreviewBinding-v0w3H0fp.js.map +0 -1
- package/dist/PropertyEditView-DDB_X-00.js +0 -3837
- package/dist/PropertyEditView-DDB_X-00.js.map +0 -1
- package/dist/RouterCollectionsStudioView-SGBV4CMg.js +0 -212
- package/dist/RouterCollectionsStudioView-SGBV4CMg.js.map +0 -1
- package/dist/SchemaChangeDialog-CcFSXvkK.js.map +0 -1
- package/dist/collection_editor/ui/CollectionViewHeaderAction.d.ts +0 -13
- package/dist/collection_editor/ui/PropertyAddColumnComponent.d.ts +0 -8
- package/dist/collection_editor_ui.js.map +0 -1
- package/dist/editor.js.map +0 -1
- package/dist/export-DCHuPD1a.js +0 -520
- package/dist/export-DCHuPD1a.js.map +0 -1
- package/dist/history-CBd6SBRs.js +0 -314
- package/dist/history-CBd6SBRs.js.map +0 -1
- package/dist/import-DjQoRrIU.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/markdown-CCqp8ibf.js.map +0 -1
- package/dist/rolldown-runtime-D7D4PA-g.js +0 -13
- package/dist/util-BRvKFMLa.js +0 -27773
- package/dist/util-BRvKFMLa.js.map +0 -1
- package/dist/util-D7ebttKT.js.map +0 -1
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
2
|
+
import { useApiBase, useApiConfig } from "@rebasepro/app";
|
|
3
|
+
//#region src/hooks/useHistory.ts
|
|
4
|
+
/**
|
|
5
|
+
* Hook to fetch entity history from the backend REST API.
|
|
6
|
+
* Replaces the old subcollection-based approach with a proper API call.
|
|
7
|
+
*/
|
|
8
|
+
function useHistory(params) {
|
|
9
|
+
const { slug, entityId, enabled = true, pageSize = 10, refreshToken } = params;
|
|
10
|
+
const apiConfig = useApiConfig();
|
|
11
|
+
const apiBase = useApiBase();
|
|
12
|
+
const [entries, setEntries] = useState([]);
|
|
13
|
+
const [total, setTotal] = useState(0);
|
|
14
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
15
|
+
const [hasMore, setHasMore] = useState(true);
|
|
16
|
+
const [error, setError] = useState();
|
|
17
|
+
const [offset, setOffset] = useState(0);
|
|
18
|
+
const [refreshTrigger, setRefreshTrigger] = useState(0);
|
|
19
|
+
const entityKey = `${slug}/${entityId}/${refreshToken ?? 0}`;
|
|
20
|
+
const currentEntityRef = useRef(void 0);
|
|
21
|
+
const fetchEntries = useCallback(async (currentOffset, signal) => {
|
|
22
|
+
if (!apiConfig?.apiUrl || !entityId || !enabled) return;
|
|
23
|
+
setIsLoading(true);
|
|
24
|
+
setError(void 0);
|
|
25
|
+
try {
|
|
26
|
+
const token = await apiConfig.getAuthToken?.();
|
|
27
|
+
const headers = { "Content-Type": "application/json" };
|
|
28
|
+
if (token) headers["Authorization"] = `Bearer ${token}`;
|
|
29
|
+
const url = `${apiBase}/data/${slug}/${entityId}/history?limit=${pageSize}&offset=${currentOffset}`;
|
|
30
|
+
const response = await fetch(url, {
|
|
31
|
+
headers,
|
|
32
|
+
signal
|
|
33
|
+
});
|
|
34
|
+
if (signal?.aborted) return;
|
|
35
|
+
if (currentEntityRef.current !== entityKey) return;
|
|
36
|
+
if (!response.ok) {
|
|
37
|
+
const errorData = await response.json().catch(() => ({ error: { message: response.statusText } }));
|
|
38
|
+
throw new Error(errorData.error?.message || `Failed to fetch history (${response.status})`);
|
|
39
|
+
}
|
|
40
|
+
const result = await response.json();
|
|
41
|
+
if (currentOffset === 0) setEntries(result.data);
|
|
42
|
+
else setEntries((prev) => [...prev, ...result.data]);
|
|
43
|
+
setTotal(result.meta.total);
|
|
44
|
+
setHasMore(result.meta.hasMore);
|
|
45
|
+
} catch (err) {
|
|
46
|
+
if (err instanceof DOMException && err.name === "AbortError") return;
|
|
47
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
48
|
+
} finally {
|
|
49
|
+
setIsLoading(false);
|
|
50
|
+
}
|
|
51
|
+
}, [
|
|
52
|
+
apiConfig,
|
|
53
|
+
apiBase,
|
|
54
|
+
slug,
|
|
55
|
+
entityId,
|
|
56
|
+
entityKey,
|
|
57
|
+
enabled,
|
|
58
|
+
pageSize
|
|
59
|
+
]);
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
const isNewEntity = currentEntityRef.current !== entityKey;
|
|
62
|
+
if (isNewEntity) {
|
|
63
|
+
currentEntityRef.current = entityKey;
|
|
64
|
+
setEntries([]);
|
|
65
|
+
setTotal(0);
|
|
66
|
+
setHasMore(true);
|
|
67
|
+
setOffset(0);
|
|
68
|
+
}
|
|
69
|
+
if (!enabled || !entityId) return;
|
|
70
|
+
const abortController = new AbortController();
|
|
71
|
+
fetchEntries(isNewEntity ? 0 : offset, abortController.signal);
|
|
72
|
+
return () => {
|
|
73
|
+
abortController.abort();
|
|
74
|
+
};
|
|
75
|
+
}, [
|
|
76
|
+
fetchEntries,
|
|
77
|
+
offset,
|
|
78
|
+
enabled,
|
|
79
|
+
entityId,
|
|
80
|
+
entityKey,
|
|
81
|
+
refreshTrigger
|
|
82
|
+
]);
|
|
83
|
+
const loadMore = useCallback(() => {
|
|
84
|
+
if (!isLoading && hasMore && entries.length < total) setOffset((prev) => prev + pageSize);
|
|
85
|
+
}, [
|
|
86
|
+
isLoading,
|
|
87
|
+
hasMore,
|
|
88
|
+
pageSize,
|
|
89
|
+
entries.length,
|
|
90
|
+
total
|
|
91
|
+
]);
|
|
92
|
+
const revert = useCallback(async (historyId) => {
|
|
93
|
+
if (!apiConfig?.apiUrl || !entityId) throw new Error("Cannot revert: missing API configuration or entity ID");
|
|
94
|
+
const token = await apiConfig.getAuthToken?.();
|
|
95
|
+
const headers = { "Content-Type": "application/json" };
|
|
96
|
+
if (token) headers["Authorization"] = `Bearer ${token}`;
|
|
97
|
+
const url = `${apiBase}/data/${slug}/${entityId}/history/${historyId}/revert`;
|
|
98
|
+
const response = await fetch(url, {
|
|
99
|
+
method: "POST",
|
|
100
|
+
headers
|
|
101
|
+
});
|
|
102
|
+
if (!response.ok) {
|
|
103
|
+
const errorData = await response.json().catch(() => ({ error: { message: response.statusText } }));
|
|
104
|
+
throw new Error(errorData.error?.message || `Failed to revert (${response.status})`);
|
|
105
|
+
}
|
|
106
|
+
const result = await response.json();
|
|
107
|
+
currentEntityRef.current = void 0;
|
|
108
|
+
setRefreshTrigger((prev) => prev + 1);
|
|
109
|
+
return result.data;
|
|
110
|
+
}, [
|
|
111
|
+
apiConfig,
|
|
112
|
+
apiBase,
|
|
113
|
+
slug,
|
|
114
|
+
entityId
|
|
115
|
+
]);
|
|
116
|
+
return useMemo(() => ({
|
|
117
|
+
entries,
|
|
118
|
+
total,
|
|
119
|
+
isLoading,
|
|
120
|
+
hasMore,
|
|
121
|
+
error,
|
|
122
|
+
loadMore,
|
|
123
|
+
revert
|
|
124
|
+
}), [
|
|
125
|
+
entries,
|
|
126
|
+
total,
|
|
127
|
+
isLoading,
|
|
128
|
+
hasMore,
|
|
129
|
+
error,
|
|
130
|
+
loadMore,
|
|
131
|
+
revert
|
|
132
|
+
]);
|
|
133
|
+
}
|
|
134
|
+
//#endregion
|
|
135
|
+
export { useHistory };
|
|
136
|
+
|
|
137
|
+
//# sourceMappingURL=useHistory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useHistory.js","names":[],"sources":["../../src/hooks/useHistory.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState, useMemo } from \"react\";\nimport { useApiBase, useApiConfig } from \"@rebasepro/app\";\nimport type { EntityHistoryEntry } from \"@rebasepro/types\";\n\n/**\n * What the history REST endpoint returns. The fourth declaration of this shape\n * — the two drivers had one each and disagreed on `updated_at` — now an alias\n * of the one in `@rebasepro/types`.\n */\nexport type HistoryEntryData = EntityHistoryEntry;\n\nexport interface UseEntityHistoryResult {\n entries: HistoryEntryData[];\n total: number;\n isLoading: boolean;\n hasMore: boolean;\n error?: Error;\n loadMore: () => void;\n revert: (historyId: string) => Promise<Record<string, unknown>>;\n}\n\n/**\n * Hook to fetch entity history from the backend REST API.\n * Replaces the old subcollection-based approach with a proper API call.\n */\nexport function useHistory(params: {\n slug: string;\n entityId: string | number | undefined;\n enabled?: boolean;\n pageSize?: number;\n /**\n * Bumped by the caller when the record is saved. A save is the one event\n * that adds a revision, and nothing else here would notice it: without\n * this the open panel keeps showing the list it fetched when it opened,\n * so the revision you just created never appears.\n */\n refreshToken?: number;\n}): UseEntityHistoryResult {\n const { slug, entityId, enabled = true, pageSize = 10, refreshToken } = params;\n const apiConfig = useApiConfig();\n const apiBase = useApiBase();\n\n const [entries, setEntries] = useState<HistoryEntryData[]>([]);\n const [total, setTotal] = useState(0);\n const [isLoading, setIsLoading] = useState(false);\n const [hasMore, setHasMore] = useState(true);\n const [error, setError] = useState<Error | undefined>();\n const [offset, setOffset] = useState(0);\n const [refreshTrigger, setRefreshTrigger] = useState(0);\n\n // Track the current entity identity so we can detect stale responses.\n // `refreshToken` is part of the identity on purpose: a save makes the list\n // we are holding a stale page of a longer list, which is the same problem\n // as having moved to a different record.\n const entityKey = `${slug}/${entityId}/${refreshToken ?? 0}`;\n const currentEntityRef = useRef<string | undefined>(undefined);\n\n const fetchEntries = useCallback(async (\n currentOffset: number,\n signal?: AbortSignal\n ) => {\n if (!apiConfig?.apiUrl || !entityId || !enabled) return;\n\n setIsLoading(true);\n setError(undefined);\n\n try {\n const token = await apiConfig.getAuthToken?.();\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\"\n };\n if (token) headers[\"Authorization\"] = `Bearer ${token}`;\n\n const url = `${apiBase}/data/${slug}/${entityId}/history?limit=${pageSize}&offset=${currentOffset}`;\n const response = await fetch(url, { headers,\nsignal });\n\n // Check if the request was aborted or the entity changed while in-flight\n if (signal?.aborted) return;\n if (currentEntityRef.current !== entityKey) return;\n\n if (!response.ok) {\n const errorData = await response.json().catch(() => ({ error: { message: response.statusText } }));\n throw new Error(errorData.error?.message || `Failed to fetch history (${response.status})`);\n }\n\n const result = await response.json();\n\n if (currentOffset === 0) {\n setEntries(result.data);\n } else {\n setEntries(prev => [...prev, ...result.data]);\n }\n\n setTotal(result.meta.total);\n setHasMore(result.meta.hasMore);\n } catch (err) {\n // Don't set error state for intentional aborts\n if (err instanceof DOMException && err.name === \"AbortError\") return;\n setError(err instanceof Error ? err : new Error(String(err)));\n } finally {\n setIsLoading(false);\n }\n }, [apiConfig, apiBase, slug, entityId, entityKey, enabled, pageSize]);\n\n // Single unified effect: reset state when entity changes, fetch when offset changes.\n // Uses AbortController to cancel stale requests on entity change or unmount.\n useEffect(() => {\n const isNewEntity = currentEntityRef.current !== entityKey;\n\n if (isNewEntity) {\n // Reset state for new entity\n currentEntityRef.current = entityKey;\n setEntries([]);\n setTotal(0);\n setHasMore(true);\n setOffset(0);\n }\n\n if (!enabled || !entityId) return;\n\n const abortController = new AbortController();\n // When entity changed, always fetch from offset 0\n const effectiveOffset = isNewEntity ? 0 : offset;\n fetchEntries(effectiveOffset, abortController.signal);\n\n return () => {\n abortController.abort();\n };\n }, [fetchEntries, offset, enabled, entityId, entityKey, refreshTrigger]);\n\n const loadMore = useCallback(() => {\n // `entries` already holds every page up to the current offset; adding\n // the offset to it counted those pages twice and stopped the scroll\n // short of the oldest revisions.\n if (!isLoading && hasMore && entries.length < total) {\n setOffset(prev => prev + pageSize);\n }\n }, [isLoading, hasMore, pageSize, entries.length, total]);\n\n const revert = useCallback(async (historyId: string): Promise<Record<string, unknown>> => {\n if (!apiConfig?.apiUrl || !entityId) {\n throw new Error(\"Cannot revert: missing API configuration or entity ID\");\n }\n\n const token = await apiConfig.getAuthToken?.();\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\"\n };\n if (token) headers[\"Authorization\"] = `Bearer ${token}`;\n\n const url = `${apiBase}/data/${slug}/${entityId}/history/${historyId}/revert`;\n const response = await fetch(url, { method: \"POST\",\nheaders });\n\n if (!response.ok) {\n const errorData = await response.json().catch(() => ({ error: { message: response.statusText } }));\n throw new Error(errorData.error?.message || `Failed to revert (${response.status})`);\n }\n\n const result = await response.json();\n\n // Refresh the history list after revert by resetting the entity ref\n // and triggering the effect.\n currentEntityRef.current = undefined;\n setRefreshTrigger(prev => prev + 1);\n\n // Return the reverted entity data so callers can update the form\n return result.data as Record<string, unknown>;\n }, [apiConfig, apiBase, slug, entityId]);\n\n return useMemo(() => ({\n entries,\n total,\n isLoading,\n hasMore,\n error,\n loadMore,\n revert\n }), [entries, total, isLoading, hasMore, error, loadMore, revert]);\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { useUrlController } from "./navigation/contexts/UrlContext.js";
|
|
2
|
+
import { entityActionName, mergeEntityActions, placeEntityActions, resolveEntityActionState } from "../util/entity_actions.js";
|
|
3
|
+
import { withListState } from "../util/view_mode.js";
|
|
4
|
+
import { copyEntityAction, deleteEntityAction, unlinkEntityAction } from "../components/common/default_entity_actions.js";
|
|
5
|
+
import { useSideDialogContext } from "../components/SideDialogs.js";
|
|
6
|
+
import { resolveEntityAction } from "../util/resolutions.js";
|
|
7
|
+
import { useChildViewSource } from "./useChildViewSource.js";
|
|
8
|
+
import { useCallback, useMemo } from "react";
|
|
9
|
+
import { getIcon, useCustomizationController, usePermissions, useSnackbarController, useTranslation } from "@rebasepro/app";
|
|
10
|
+
import { useNavigate } from "react-router";
|
|
11
|
+
//#region src/hooks/useRecordActions.tsx
|
|
12
|
+
/**
|
|
13
|
+
* The actions you can perform *on* a record — copy, delete, and whatever the
|
|
14
|
+
* collection adds — resolved against the current user's permissions, and
|
|
15
|
+
* placed for the record's identity bar: buttons for the ones declared
|
|
16
|
+
* `collapsed: false`, menu groups for the rest.
|
|
17
|
+
*
|
|
18
|
+
* Extracted from the form's footer so the identity bar can own them. They are
|
|
19
|
+
* not ways to leave the form, so they never belonged next to Save's footer;
|
|
20
|
+
* the bar carries them on the edit view and the read-only view alike.
|
|
21
|
+
*/
|
|
22
|
+
function useRecordActions({ collection, path, entity, clickProps }) {
|
|
23
|
+
const { canCreate, canDelete } = usePermissions();
|
|
24
|
+
const customizationController = useCustomizationController();
|
|
25
|
+
const snackbarController = useSnackbarController();
|
|
26
|
+
const { t } = useTranslation();
|
|
27
|
+
const childViewSource = useChildViewSource(path);
|
|
28
|
+
const isLinkedChildView = childViewSource?.kind === "relation" && childViewSource.mode === "linked";
|
|
29
|
+
const actions = useMemo(() => {
|
|
30
|
+
const customEntityActions = (collection.entityActions ?? []).map((action) => resolveEntityAction(action, customizationController.entityActions)).filter(Boolean);
|
|
31
|
+
const createEnabled = canCreate(collection, path);
|
|
32
|
+
const deleteEnabled = entity ? canDelete(collection, path, entity) : false;
|
|
33
|
+
const disableActions = collection.disableDefaultActions ?? [];
|
|
34
|
+
const defaults = [];
|
|
35
|
+
if (createEnabled && !disableActions.includes("copy")) defaults.push(copyEntityAction);
|
|
36
|
+
if (deleteEnabled && !disableActions.includes("delete")) defaults.push(isLinkedChildView ? unlinkEntityAction : deleteEntityAction);
|
|
37
|
+
return (customEntityActions.length ? mergeEntityActions(defaults, customEntityActions) : defaults).filter((a) => a.includeInForm === void 0 || a.includeInForm);
|
|
38
|
+
}, [
|
|
39
|
+
canCreate,
|
|
40
|
+
canDelete,
|
|
41
|
+
collection,
|
|
42
|
+
path,
|
|
43
|
+
customizationController.entityActions?.length,
|
|
44
|
+
entity,
|
|
45
|
+
collection.disableDefaultActions,
|
|
46
|
+
isLinkedChildView
|
|
47
|
+
]);
|
|
48
|
+
return useMemo(() => {
|
|
49
|
+
if (!clickProps?.entity || !actions.length) return void 0;
|
|
50
|
+
const report = (action, error) => {
|
|
51
|
+
console.error("Error executing action", action.key ?? action.name, error);
|
|
52
|
+
snackbarController.open({
|
|
53
|
+
type: "error",
|
|
54
|
+
message: `${entityActionName(action, t)}: ${error instanceof Error ? error.message : String(error)}`
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
return placeEntityActions(actions.map((action, index) => ({
|
|
58
|
+
key: action.key ?? `${action.name}_${index}`,
|
|
59
|
+
name: entityActionName(action, t),
|
|
60
|
+
icon: getIcon(action.icon, void 0, void 0, "smallest"),
|
|
61
|
+
collapsed: action.collapsed,
|
|
62
|
+
...resolveEntityActionState(action, clickProps),
|
|
63
|
+
run: () => {
|
|
64
|
+
try {
|
|
65
|
+
const result = action.onClick(clickProps);
|
|
66
|
+
if (result instanceof Promise) return result.catch((error) => report(action, error));
|
|
67
|
+
} catch (error) {
|
|
68
|
+
report(action, error);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
})));
|
|
72
|
+
}, [
|
|
73
|
+
actions,
|
|
74
|
+
clickProps,
|
|
75
|
+
snackbarController,
|
|
76
|
+
t
|
|
77
|
+
]);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* What a record's own actions mean by `navigateBack`: leave the record. The
|
|
81
|
+
* delete action calls it once the row is gone.
|
|
82
|
+
*
|
|
83
|
+
* It is not the edit view's `navigateBack` prop, which every layout wires to
|
|
84
|
+
* "leave the edit view for the record's detail view" — after a delete that is a
|
|
85
|
+
* record that no longer exists, and the split, the side panel and the dialog
|
|
86
|
+
* stayed open on it.
|
|
87
|
+
*/
|
|
88
|
+
function useLeaveRecord({ layout, path, onCloseRequest }) {
|
|
89
|
+
const sideDialogContext = useSideDialogContext();
|
|
90
|
+
const navigate = useNavigate();
|
|
91
|
+
const urlController = useUrlController();
|
|
92
|
+
return useCallback(() => {
|
|
93
|
+
if (layout === "side_panel" || layout === "dialog") sideDialogContext.close(true);
|
|
94
|
+
else if (onCloseRequest) onCloseRequest();
|
|
95
|
+
else navigate(withListState(urlController.buildUrlCollectionPath(path)), { replace: true });
|
|
96
|
+
}, [
|
|
97
|
+
layout,
|
|
98
|
+
sideDialogContext,
|
|
99
|
+
onCloseRequest,
|
|
100
|
+
navigate,
|
|
101
|
+
urlController,
|
|
102
|
+
path
|
|
103
|
+
]);
|
|
104
|
+
}
|
|
105
|
+
//#endregion
|
|
106
|
+
export { useLeaveRecord, useRecordActions };
|
|
107
|
+
|
|
108
|
+
//# sourceMappingURL=useRecordActions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRecordActions.js","names":[],"sources":["../../src/hooks/useRecordActions.tsx"],"sourcesContent":["import type { EntityAction, EntityActionClickProps, AdminCollection } from \"@rebasepro/cms-types\";\nimport type { Entity } from \"@rebasepro/types\";\nimport { useCallback, useMemo } from \"react\";\nimport { useNavigate } from \"react-router\";\nimport { getIcon, useCustomizationController, usePermissions, useSnackbarController, useTranslation } from \"@rebasepro/app\";\nimport { copyEntityAction, deleteEntityAction, unlinkEntityAction } from \"../components/common/default_entity_actions\";\nimport { entityActionName, mergeEntityActions, placeEntityActions, resolveEntityActionState, type PlacedEntityActions } from \"../util/entity_actions\";\nimport { resolveEntityAction } from \"../util/resolutions\";\nimport { useChildViewSource } from \"./useChildViewSource\";\nimport { useUrlController } from \"./navigation/contexts/UrlContext\";\nimport { withListState } from \"../util/view_mode\";\nimport type { RecordActionItem } from \"../components/EntityIdentityBar\";\nimport { useSideDialogContext } from \"../components/SideDialogs\";\n\nexport interface UseRecordActionsParams<M extends Record<string, unknown>> {\n collection: AdminCollection<M>;\n path: string;\n entity?: Entity<M>;\n /**\n * What every action is called with — and asked `isEnabled` with. Undefined\n * until there is a record to act on.\n */\n clickProps?: EntityActionClickProps<Record<string, unknown>>;\n}\n\n/**\n * The actions you can perform *on* a record — copy, delete, and whatever the\n * collection adds — resolved against the current user's permissions, and\n * placed for the record's identity bar: buttons for the ones declared\n * `collapsed: false`, menu groups for the rest.\n *\n * Extracted from the form's footer so the identity bar can own them. They are\n * not ways to leave the form, so they never belonged next to Save's footer;\n * the bar carries them on the edit view and the read-only view alike.\n */\nexport function useRecordActions<M extends Record<string, unknown>>({\n collection,\n path,\n entity,\n clickProps\n}: UseRecordActionsParams<M>): PlacedEntityActions<RecordActionItem> | undefined {\n\n const { canCreate, canDelete } = usePermissions();\n const customizationController = useCustomizationController();\n const snackbarController = useSnackbarController();\n const { t } = useTranslation();\n\n // Rows shared through a junction: the delete action here removes the link,\n // because that is what the server does for this path.\n const childViewSource = useChildViewSource(path);\n const isLinkedChildView = childViewSource?.kind === \"relation\" && childViewSource.mode === \"linked\";\n\n const actions = useMemo((): EntityAction[] => {\n const customEntityActions = (collection.entityActions ?? [])\n .map(action => resolveEntityAction(action, customizationController.entityActions))\n .filter(Boolean) as EntityAction[];\n\n const createEnabled = canCreate(collection, path);\n const deleteEnabled = entity ? canDelete(collection, path, entity) : false;\n const disableActions = collection.disableDefaultActions ?? [];\n\n const defaults: EntityAction[] = [];\n if (createEnabled && !disableActions.includes(\"copy\"))\n defaults.push(copyEntityAction);\n if (deleteEnabled && !disableActions.includes(\"delete\"))\n defaults.push(isLinkedChildView ? unlinkEntityAction : deleteEntityAction);\n\n const merged = customEntityActions.length\n ? mergeEntityActions(defaults, customEntityActions)\n : defaults;\n\n return merged.filter(a => a.includeInForm === undefined || a.includeInForm);\n }, [\n canCreate,\n canDelete,\n collection,\n path,\n customizationController.entityActions?.length,\n entity,\n collection.disableDefaultActions,\n isLinkedChildView\n ]);\n\n return useMemo(() => {\n if (!clickProps?.entity || !actions.length) return undefined;\n\n const report = (action: EntityAction, error: unknown) => {\n console.error(\"Error executing action\", action.key ?? action.name, error);\n snackbarController.open({\n type: \"error\",\n message: `${entityActionName(action, t)}: ${error instanceof Error ? error.message : String(error)}`\n });\n };\n\n const items = actions.map((action, index): RecordActionItem & Pick<EntityAction, \"collapsed\"> => ({\n key: action.key ?? `${action.name}_${index}`,\n name: entityActionName(action, t),\n icon: getIcon(action.icon, undefined, undefined, \"smallest\"),\n collapsed: action.collapsed,\n ...resolveEntityActionState(action, clickProps),\n // A failure reaches the user rather than the console alone, wherever\n // the action was clicked from. A promise is handed back only when the\n // action returned one, so a button shows a spinner for work that is\n // actually running and never flashes one for a synchronous call.\n run: () => {\n try {\n const result = action.onClick(clickProps);\n if (result instanceof Promise) return result.catch(error => report(action, error));\n } catch (error: unknown) {\n report(action, error);\n }\n return undefined;\n }\n }));\n\n return placeEntityActions(items);\n }, [actions, clickProps, snackbarController, t]);\n}\n\n/**\n * What a record's own actions mean by `navigateBack`: leave the record. The\n * delete action calls it once the row is gone.\n *\n * It is not the edit view's `navigateBack` prop, which every layout wires to\n * \"leave the edit view for the record's detail view\" — after a delete that is a\n * record that no longer exists, and the split, the side panel and the dialog\n * stayed open on it.\n */\nexport function useLeaveRecord({\n layout,\n path,\n onCloseRequest\n}: {\n layout: \"side_panel\" | \"full_screen\" | \"split\" | \"dialog\";\n path: string;\n onCloseRequest?: () => void;\n}): () => void {\n const sideDialogContext = useSideDialogContext();\n const navigate = useNavigate();\n const urlController = useUrlController();\n return useCallback(() => {\n if (layout === \"side_panel\" || layout === \"dialog\") {\n sideDialogContext.close(true);\n } else if (onCloseRequest) {\n onCloseRequest();\n } else {\n navigate(withListState(urlController.buildUrlCollectionPath(path)), { replace: true });\n }\n }, [layout, sideDialogContext, onCloseRequest, navigate, urlController, path]);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAmCA,SAAgB,iBAAoD,EAChE,YACA,MACA,QACA,cAC6E;CAE7E,MAAM,EAAE,WAAW,cAAc,eAAe;CAChD,MAAM,0BAA0B,2BAA2B;CAC3D,MAAM,qBAAqB,sBAAsB;CACjD,MAAM,EAAE,MAAM,eAAe;CAI7B,MAAM,kBAAkB,mBAAmB,IAAI;CAC/C,MAAM,oBAAoB,iBAAiB,SAAS,cAAc,gBAAgB,SAAS;CAE3F,MAAM,UAAU,cAA8B;EAC1C,MAAM,uBAAuB,WAAW,iBAAiB,CAAC,EAAA,CACrD,KAAI,WAAU,oBAAoB,QAAQ,wBAAwB,aAAa,CAAC,CAAC,CACjF,OAAO,OAAO;EAEnB,MAAM,gBAAgB,UAAU,YAAY,IAAI;EAChD,MAAM,gBAAgB,SAAS,UAAU,YAAY,MAAM,MAAM,IAAI;EACrE,MAAM,iBAAiB,WAAW,yBAAyB,CAAC;EAE5D,MAAM,WAA2B,CAAC;EAClC,IAAI,iBAAiB,CAAC,eAAe,SAAS,MAAM,GAChD,SAAS,KAAK,gBAAgB;EAClC,IAAI,iBAAiB,CAAC,eAAe,SAAS,QAAQ,GAClD,SAAS,KAAK,oBAAoB,qBAAqB,kBAAkB;EAM7E,QAJe,oBAAoB,SAC7B,mBAAmB,UAAU,mBAAmB,IAChD,SAAA,CAEQ,QAAO,MAAK,EAAE,kBAAkB,KAAA,KAAa,EAAE,aAAa;CAC9E,GAAG;EACC;EACA;EACA;EACA;EACA,wBAAwB,eAAe;EACvC;EACA,WAAW;EACX;CACJ,CAAC;CAED,OAAO,cAAc;EACjB,IAAI,CAAC,YAAY,UAAU,CAAC,QAAQ,QAAQ,OAAO,KAAA;EAEnD,MAAM,UAAU,QAAsB,UAAmB;GACrD,QAAQ,MAAM,0BAA0B,OAAO,OAAO,OAAO,MAAM,KAAK;GACxE,mBAAmB,KAAK;IACpB,MAAM;IACN,SAAS,GAAG,iBAAiB,QAAQ,CAAC,EAAE,IAAI,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;GACrG,CAAC;EACL;EAuBA,OAAO,mBArBO,QAAQ,KAAK,QAAQ,WAA+D;GAC9F,KAAK,OAAO,OAAO,GAAG,OAAO,KAAK,GAAG;GACrC,MAAM,iBAAiB,QAAQ,CAAC;GAChC,MAAM,QAAQ,OAAO,MAAM,KAAA,GAAW,KAAA,GAAW,UAAU;GAC3D,WAAW,OAAO;GAClB,GAAG,yBAAyB,QAAQ,UAAU;GAK9C,WAAW;IACP,IAAI;KACA,MAAM,SAAS,OAAO,QAAQ,UAAU;KACxC,IAAI,kBAAkB,SAAS,OAAO,OAAO,OAAM,UAAS,OAAO,QAAQ,KAAK,CAAC;IACrF,SAAS,OAAgB;KACrB,OAAO,QAAQ,KAAK;IACxB;GAEJ;EACJ,EAE0B,CAAK;CACnC,GAAG;EAAC;EAAS;EAAY;EAAoB;CAAC,CAAC;AACnD;;;;;;;;;;AAWA,SAAgB,eAAe,EAC3B,QACA,MACA,kBAKW;CACX,MAAM,oBAAoB,qBAAqB;CAC/C,MAAM,WAAW,YAAY;CAC7B,MAAM,gBAAgB,iBAAiB;CACvC,OAAO,kBAAkB;EACrB,IAAI,WAAW,gBAAgB,WAAW,UACtC,kBAAkB,MAAM,IAAI;OACzB,IAAI,gBACP,eAAe;OAEf,SAAS,cAAc,cAAc,uBAAuB,IAAI,CAAC,GAAG,EAAE,SAAS,KAAK,CAAC;CAE7F,GAAG;EAAC;EAAQ;EAAmB;EAAgB;EAAU;EAAe;CAAI,CAAC;AACjF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useCollectionRegistryController } from "./navigation/contexts/CollectionRegistryContext.js";
|
|
2
|
+
import { useCallback } from "react";
|
|
3
|
+
import { getReferenceFrom } from "@rebasepro/common";
|
|
4
|
+
import { useCollectionScope } from "@rebasepro/app";
|
|
5
|
+
//#region src/hooks/useReferencePaths.ts
|
|
6
|
+
/**
|
|
7
|
+
* Where a reference points, as stored and as the admin addresses it.
|
|
8
|
+
*
|
|
9
|
+
* The two differ for a Firestore or MongoDB collection that declares a `path`
|
|
10
|
+
* for its store: `slug: "fs_diagnosis", path: "diagnosis"`. A reference stores
|
|
11
|
+
* `diagnosis`, because that is where its driver finds the record. The admin
|
|
12
|
+
* lists, routes and fetches by `fs_diagnosis`, and `diagnosis` can be the slug
|
|
13
|
+
* of a Postgres collection beside it — which is what declaring the `path` was
|
|
14
|
+
* for. A reference property's own `path` may be written either way.
|
|
15
|
+
*
|
|
16
|
+
* A stored path is read in favour of the data source of the collection in
|
|
17
|
+
* scope: a reference is read from a record, and points into that record's
|
|
18
|
+
* store unless its `driver` says otherwise.
|
|
19
|
+
*/
|
|
20
|
+
function useReferencePaths() {
|
|
21
|
+
const collectionRegistry = useCollectionRegistryController();
|
|
22
|
+
const scope = useCollectionScope();
|
|
23
|
+
const scopeDriver = scope?.dataSource ?? scope?.engine;
|
|
24
|
+
return {
|
|
25
|
+
toCollectionPath: useCallback((path, driver) => collectionRegistry.resolveCollectionPath(path, driver ?? scopeDriver), [collectionRegistry, scopeDriver]),
|
|
26
|
+
referenceTo: useCallback((entity) => getReferenceFrom(entity, collectionRegistry.resolveDataPath(entity.path)), [collectionRegistry])
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { useReferencePaths };
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=useReferencePaths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useReferencePaths.js","names":[],"sources":["../../src/hooks/useReferencePaths.ts"],"sourcesContent":["import { useCallback } from \"react\";\nimport type { Entity, EntityReference } from \"@rebasepro/types\";\nimport { useCollectionScope } from \"@rebasepro/app\";\nimport { getReferenceFrom } from \"@rebasepro/common\";\nimport { useCollectionRegistryController } from \"./navigation/contexts/CollectionRegistryContext\";\n\n/**\n * Where a reference points, as stored and as the admin addresses it.\n *\n * The two differ for a Firestore or MongoDB collection that declares a `path`\n * for its store: `slug: \"fs_diagnosis\", path: \"diagnosis\"`. A reference stores\n * `diagnosis`, because that is where its driver finds the record. The admin\n * lists, routes and fetches by `fs_diagnosis`, and `diagnosis` can be the slug\n * of a Postgres collection beside it — which is what declaring the `path` was\n * for. A reference property's own `path` may be written either way.\n *\n * A stored path is read in favour of the data source of the collection in\n * scope: a reference is read from a record, and points into that record's\n * store unless its `driver` says otherwise.\n */\nexport function useReferencePaths(): {\n /** The path the admin addresses the target of a stored reference, or of a reference property's `path`, by. */\n toCollectionPath: (path: string, driver?: string) => string;\n /** A reference to `entity`, carrying the path its record is stored under. */\n referenceTo: (entity: Entity<Record<string, unknown>>) => EntityReference;\n} {\n const collectionRegistry = useCollectionRegistryController();\n const scope = useCollectionScope();\n const scopeDriver = scope?.dataSource ?? scope?.engine;\n\n const toCollectionPath = useCallback(\n (path: string, driver?: string) => collectionRegistry.resolveCollectionPath(path, driver ?? scopeDriver),\n [collectionRegistry, scopeDriver]);\n\n const referenceTo = useCallback(\n (entity: Entity<Record<string, unknown>>) => getReferenceFrom(entity, collectionRegistry.resolveDataPath(entity.path)),\n [collectionRegistry]);\n\n return { toCollectionPath, referenceTo };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAoBA,SAAgB,oBAKd;CACE,MAAM,qBAAqB,gCAAgC;CAC3D,MAAM,QAAQ,mBAAmB;CACjC,MAAM,cAAc,OAAO,cAAc,OAAO;CAUhD,OAAO;EAAE,kBARgB,aACpB,MAAc,WAAoB,mBAAmB,sBAAsB,MAAM,UAAU,WAAW,GACvG,CAAC,oBAAoB,WAAW,CAM3B;EAAkB,aAJP,aACf,WAA4C,iBAAiB,QAAQ,mBAAmB,gBAAgB,OAAO,IAAI,CAAC,GACrH,CAAC,kBAAkB,CAEI;CAAY;AAC3C"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { useAdminContext } from "./useAdminContext.js";
|
|
2
|
+
import { useEffect, useMemo, useState } from "react";
|
|
3
|
+
import { getNavigationEntriesFromPath } from "@rebasepro/app";
|
|
4
|
+
//#region src/hooks/useResolvedNavigationFrom.tsx
|
|
5
|
+
/**
|
|
6
|
+
* Use this function to retrieve an array of navigation entries (resolved
|
|
7
|
+
* collection, entity or entity custom_view) for the given path. You need to pass the app context
|
|
8
|
+
* that you receive in different callbacks, such as the save hooks.
|
|
9
|
+
*
|
|
10
|
+
* It will take into account the `navigation` provided at the `Rebase` level.
|
|
11
|
+
*
|
|
12
|
+
* @param path
|
|
13
|
+
* @param context
|
|
14
|
+
* @group Hooks and utilities
|
|
15
|
+
*/
|
|
16
|
+
function resolveNavigationFrom({ path, context }) {
|
|
17
|
+
const data = context.data;
|
|
18
|
+
const { navigationStateController, collectionRegistryController } = context;
|
|
19
|
+
if (!navigationStateController || !collectionRegistryController) throw Error("Calling resolveNavigationFrom, but main navigation has not yet been initialised");
|
|
20
|
+
const resultPromises = getNavigationEntriesFromPath({
|
|
21
|
+
path,
|
|
22
|
+
collections: collectionRegistryController.collections ?? []
|
|
23
|
+
}).map((entry) => {
|
|
24
|
+
if (entry.type === "collection") return Promise.resolve(entry);
|
|
25
|
+
else if (entry.type === "entity") {
|
|
26
|
+
if (!collectionRegistryController.getCollection(entry.slug)) throw Error(`No collection defined in the navigation for the entity with path ${entry.slug}`);
|
|
27
|
+
return data.collection(entry.slug).findById(entry.entityId).then((row) => {
|
|
28
|
+
if (!row) return void 0;
|
|
29
|
+
const entity = {
|
|
30
|
+
id: entry.entityId,
|
|
31
|
+
path: entry.slug,
|
|
32
|
+
values: row
|
|
33
|
+
};
|
|
34
|
+
return {
|
|
35
|
+
...entry,
|
|
36
|
+
entity
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
} else if (entry.type === "custom_view") return Promise.resolve(entry);
|
|
40
|
+
else throw Error("Unmapped element in useEntitiesFromPath");
|
|
41
|
+
}).filter((v) => Boolean(v));
|
|
42
|
+
return Promise.all(resultPromises);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Use this hook to retrieve an array of navigation entries (resolved
|
|
46
|
+
* collection or entity) for the given path. You can use this hook
|
|
47
|
+
* in any React component that lives under `Rebase`
|
|
48
|
+
* @group Hooks and utilities
|
|
49
|
+
*/
|
|
50
|
+
function useResolvedNavigationFrom({ path }) {
|
|
51
|
+
const context = useAdminContext();
|
|
52
|
+
const { navigationStateController, collectionRegistryController } = context;
|
|
53
|
+
const [data, setData] = useState();
|
|
54
|
+
const [dataLoading, setDataLoading] = useState(false);
|
|
55
|
+
const [dataLoadingError, setDataLoadingError] = useState();
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
if (navigationStateController && collectionRegistryController) {
|
|
58
|
+
setDataLoading(true);
|
|
59
|
+
setDataLoadingError(void 0);
|
|
60
|
+
resolveNavigationFrom({
|
|
61
|
+
path,
|
|
62
|
+
context
|
|
63
|
+
}).then(setData).catch((e) => setDataLoadingError(e)).finally(() => setDataLoading(false));
|
|
64
|
+
}
|
|
65
|
+
}, [path, context]);
|
|
66
|
+
return useMemo(() => {
|
|
67
|
+
if (!navigationStateController) return { dataLoading: true };
|
|
68
|
+
return {
|
|
69
|
+
data,
|
|
70
|
+
dataLoading,
|
|
71
|
+
dataLoadingError
|
|
72
|
+
};
|
|
73
|
+
}, [
|
|
74
|
+
navigationStateController,
|
|
75
|
+
data,
|
|
76
|
+
dataLoading,
|
|
77
|
+
dataLoadingError
|
|
78
|
+
]);
|
|
79
|
+
}
|
|
80
|
+
//#endregion
|
|
81
|
+
export { resolveNavigationFrom, useResolvedNavigationFrom };
|
|
82
|
+
|
|
83
|
+
//# sourceMappingURL=useResolvedNavigationFrom.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useResolvedNavigationFrom.js","names":[],"sources":["../../src/hooks/useResolvedNavigationFrom.tsx"],"sourcesContent":["\nimport type { EntityCustomView, AdminCollection } from \"@rebasepro/cms-types\";\nimport { Entity, User } from \"@rebasepro/types\";\nimport { RebaseContext } from \"@rebasepro/cms-types\";\nimport { useEffect, useState, useMemo } from \"react\";\nimport { getNavigationEntriesFromPath } from \"@rebasepro/app\";\nimport { useAdminContext } from \"./useAdminContext\";\n\n/**\n * @see resolveNavigationFrom\n * @group Hooks and utilities\n */\nexport type ResolvedNavigationEntry<M extends Record<string, unknown>> =\n | ResolvedNavigationEntity<M>\n | ResolvedNavigationCollection<M>\n | ResolvedNavigationEntityCustom<M>;\n\n/**\n * @see resolveNavigationFrom\n * @group Hooks and utilities\n */\nexport interface ResolvedNavigationEntity<M extends Record<string, unknown>> {\n type: \"entity\";\n entity: Entity<M>;\n entityId: string | number;\n path: string;\n parentCollection: AdminCollection<M>;\n}\n\n/**\n * @see resolveNavigationFrom\n * @group Hooks and utilities\n */\nexport interface ResolvedNavigationCollection<M extends Record<string, unknown>> {\n type: \"collection\";\n path: string;\n collection: AdminCollection<M>;\n}\n\n/**\n * @see resolveNavigationFrom\n * @group Hooks and utilities\n */\ninterface ResolvedNavigationEntityCustom<M extends Record<string, unknown>> {\n type: \"custom_view\";\n path: string;\n view: EntityCustomView<M>;\n}\n\n/**\n * Use this function to retrieve an array of navigation entries (resolved\n * collection, entity or entity custom_view) for the given path. You need to pass the app context\n * that you receive in different callbacks, such as the save hooks.\n *\n * It will take into account the `navigation` provided at the `Rebase` level.\n *\n * @param path\n * @param context\n * @group Hooks and utilities\n */\nexport function resolveNavigationFrom<M extends Record<string, unknown>, USER extends User>({\n path,\n context\n}: {\n path: string,\n context: RebaseContext<USER>\n}): Promise<ResolvedNavigationEntry<M>[]> {\n\n const data = context.data;\n const { navigationStateController, collectionRegistryController } = context;\n\n if (!navigationStateController || !collectionRegistryController) {\n throw Error(\"Calling resolveNavigationFrom, but main navigation has not yet been initialised\");\n }\n\n const navigationEntries = getNavigationEntriesFromPath({\n path,\n collections: collectionRegistryController.collections ?? []\n });\n\n const resultPromises: Promise<ResolvedNavigationEntry<any>>[] = navigationEntries\n .map((entry) => {\n if (entry.type === \"collection\") {\n return Promise.resolve(entry);\n } else if (entry.type === \"entity\") {\n const collection = collectionRegistryController.getCollection(entry.slug);\n if (!collection) {\n throw Error(`No collection defined in the navigation for the entity with path ${entry.slug}`);\n }\n // `context.data` is the flat SDK layer; re-wrap the row into the\n // Entity view-model the navigation entry expects. The address is\n // the one we just fetched by — reading it back off the row would\n // find nothing, since a row is only its columns.\n return data.collection(entry.slug).findById(entry.entityId)\n .then((row) => {\n if (!row) return undefined;\n const entity = { id: entry.entityId, path: entry.slug, values: row };\n return { ...entry,\nentity };\n });\n } else if (entry.type === \"custom_view\") {\n return Promise.resolve(entry);\n } else {\n throw Error(\"Unmapped element in useEntitiesFromPath\");\n }\n })\n .filter(v => Boolean(v)) as Promise<ResolvedNavigationEntry<any>>[];\n\n return Promise.all(resultPromises);\n}\n\n/**\n * @group Hooks and utilities\n */\nexport interface NavigationFromProps {\n path: string;\n}\n\n/**\n * @group Hooks and utilities\n */\nexport interface NavigationFrom<M extends Record<string, unknown>> {\n data?: ResolvedNavigationEntry<M>[]\n dataLoading: boolean,\n dataLoadingError?: Error\n}\n\n/**\n * Use this hook to retrieve an array of navigation entries (resolved\n * collection or entity) for the given path. You can use this hook\n * in any React component that lives under `Rebase`\n * @group Hooks and utilities\n */\nexport function useResolvedNavigationFrom<M extends Record<string, unknown>>(\n {\n path\n }: NavigationFromProps): NavigationFrom<M> {\n\n const context = useAdminContext();\n const { navigationStateController, collectionRegistryController } = context;\n\n const [data, setData] = useState<ResolvedNavigationEntry<M>[] | undefined>();\n const [dataLoading, setDataLoading] = useState<boolean>(false);\n const [dataLoadingError, setDataLoadingError] = useState<Error | undefined>();\n\n useEffect(() => {\n if (navigationStateController && collectionRegistryController) {\n setDataLoading(true);\n setDataLoadingError(undefined);\n resolveNavigationFrom<M, User>({ path,\ncontext })\n .then(setData)\n .catch((e) => setDataLoadingError(e))\n .finally(() => setDataLoading(false));\n }\n\n }, [path, context]);\n\n return useMemo(() => {\n if (!navigationStateController) {\n return { dataLoading: true };\n }\n return { data,\ndataLoading,\ndataLoadingError };\n }, [navigationStateController, data, dataLoading, dataLoadingError]);\n}\n"],"mappings":";;;;;;;;;;;;;;;AA4DA,SAAgB,sBAA4E,EACxF,MACA,WAIsC;CAEtC,MAAM,OAAO,QAAQ;CACrB,MAAM,EAAE,2BAA2B,iCAAiC;CAEpE,IAAI,CAAC,6BAA6B,CAAC,8BAC/B,MAAM,MAAM,iFAAiF;CAQjG,MAAM,iBALoB,6BAA6B;EACnD;EACA,aAAa,6BAA6B,eAAe,CAAC;CAC9D,CAEgE,CAAA,CAC3D,KAAK,UAAU;EACZ,IAAI,MAAM,SAAS,cACf,OAAO,QAAQ,QAAQ,KAAK;OACzB,IAAI,MAAM,SAAS,UAAU;GAEhC,IAAI,CADe,6BAA6B,cAAc,MAAM,IAC/D,GACD,MAAM,MAAM,oEAAoE,MAAM,MAAM;GAMhG,OAAO,KAAK,WAAW,MAAM,IAAI,CAAC,CAAC,SAAS,MAAM,QAAQ,CAAC,CACtD,MAAM,QAAQ;IACX,IAAI,CAAC,KAAK,OAAO,KAAA;IACjB,MAAM,SAAS;KAAE,IAAI,MAAM;KAAU,MAAM,MAAM;KAAM,QAAQ;IAAI;IACnE,OAAO;KAAE,GAAG;KACpC;IAAO;GACa,CAAC;EACT,OAAO,IAAI,MAAM,SAAS,eACtB,OAAO,QAAQ,QAAQ,KAAK;OAE5B,MAAM,MAAM,yCAAyC;CAE7D,CAAC,CAAC,CACD,QAAO,MAAK,QAAQ,CAAC,CAAC;CAE3B,OAAO,QAAQ,IAAI,cAAc;AACrC;;;;;;;AAwBA,SAAgB,0BACZ,EACI,QACuC;CAE3C,MAAM,UAAU,gBAAgB;CAChC,MAAM,EAAE,2BAA2B,iCAAiC;CAEpE,MAAM,CAAC,MAAM,WAAW,SAAmD;CAC3E,MAAM,CAAC,aAAa,kBAAkB,SAAkB,KAAK;CAC7D,MAAM,CAAC,kBAAkB,uBAAuB,SAA4B;CAE5E,gBAAgB;EACZ,IAAI,6BAA6B,8BAA8B;GAC3D,eAAe,IAAI;GACnB,oBAAoB,KAAA,CAAS;GAC7B,sBAA+B;IAAE;IAC7C;GAAQ,CAAC,CAAC,CACO,KAAK,OAAO,CAAC,CACb,OAAO,MAAM,oBAAoB,CAAC,CAAC,CAAC,CACpC,cAAc,eAAe,KAAK,CAAC;EAC5C;CAEJ,GAAG,CAAC,MAAM,OAAO,CAAC;CAElB,OAAO,cAAc;EACjB,IAAI,CAAC,2BACD,OAAO,EAAE,aAAa,KAAK;EAE/B,OAAO;GAAE;GACjB;GACA;EAAiB;CACb,GAAG;EAAC;EAA2B;EAAM;EAAa;CAAgB,CAAC;AACvE"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { apiBaseOf, useAuthController, useRebaseClient } from "@rebasepro/app";
|
|
3
|
+
//#region src/hooks/useResolvedUsers.ts
|
|
4
|
+
var caches = /* @__PURE__ */ new Map();
|
|
5
|
+
function getCache(baseUrl) {
|
|
6
|
+
let cache = caches.get(baseUrl);
|
|
7
|
+
if (!cache) {
|
|
8
|
+
cache = {
|
|
9
|
+
users: /* @__PURE__ */ new Map(),
|
|
10
|
+
pending: /* @__PURE__ */ new Map(),
|
|
11
|
+
queue: /* @__PURE__ */ new Set()
|
|
12
|
+
};
|
|
13
|
+
caches.set(baseUrl, cache);
|
|
14
|
+
}
|
|
15
|
+
return cache;
|
|
16
|
+
}
|
|
17
|
+
async function fetchUsers(apiBase, ids, token) {
|
|
18
|
+
const resolved = /* @__PURE__ */ new Map();
|
|
19
|
+
for (const id of ids) resolved.set(id, null);
|
|
20
|
+
const params = new URLSearchParams({ ids: ids.join(",") });
|
|
21
|
+
const response = await fetch(`${apiBase}/admin/users/pick?${params}`, { headers: token ? { Authorization: `Bearer ${token}` } : {} });
|
|
22
|
+
if (!response.ok) return resolved;
|
|
23
|
+
const data = await response.json();
|
|
24
|
+
const rows = data.users ?? data.data ?? [];
|
|
25
|
+
for (const row of rows) {
|
|
26
|
+
const uid = row.uid ?? row.id;
|
|
27
|
+
if (!uid) continue;
|
|
28
|
+
resolved.set(uid, {
|
|
29
|
+
uid,
|
|
30
|
+
email: row.email ?? "",
|
|
31
|
+
displayName: row.displayName ?? row.display_name ?? null,
|
|
32
|
+
photoURL: row.photoURL ?? row.photo_url ?? null,
|
|
33
|
+
providerId: "custom",
|
|
34
|
+
isAnonymous: false,
|
|
35
|
+
roles: row.roles ?? []
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return resolved;
|
|
39
|
+
}
|
|
40
|
+
function requestUser(baseUrl, uid, getAuthToken) {
|
|
41
|
+
const cache = getCache(baseUrl);
|
|
42
|
+
const existing = cache.pending.get(uid);
|
|
43
|
+
if (existing) return existing;
|
|
44
|
+
cache.queue.add(uid);
|
|
45
|
+
const promise = new Promise((resolve, reject) => {
|
|
46
|
+
if (cache.flush) clearTimeout(cache.flush);
|
|
47
|
+
cache.flush = setTimeout(async () => {
|
|
48
|
+
const ids = [...cache.queue];
|
|
49
|
+
cache.queue.clear();
|
|
50
|
+
cache.flush = void 0;
|
|
51
|
+
try {
|
|
52
|
+
const resolved = await fetchUsers(baseUrl, ids, await getAuthToken?.());
|
|
53
|
+
for (const id of ids) {
|
|
54
|
+
cache.users.set(id, resolved.get(id) ?? null);
|
|
55
|
+
cache.pending.delete(id);
|
|
56
|
+
}
|
|
57
|
+
resolve();
|
|
58
|
+
} catch (error) {
|
|
59
|
+
for (const id of ids) cache.pending.delete(id);
|
|
60
|
+
reject(error);
|
|
61
|
+
}
|
|
62
|
+
}, 0);
|
|
63
|
+
});
|
|
64
|
+
cache.pending.set(uid, promise);
|
|
65
|
+
return promise;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The auth user behind a `userSelect` value, or `null` while it is loading or
|
|
69
|
+
* when it cannot be resolved.
|
|
70
|
+
*/
|
|
71
|
+
function useResolvedUser(uid) {
|
|
72
|
+
const client = useRebaseClient();
|
|
73
|
+
const { getAuthToken } = useAuthController();
|
|
74
|
+
const baseUrl = apiBaseOf(client);
|
|
75
|
+
const [user, setUser] = useState(() => baseUrl && uid ? getCache(baseUrl).users.get(uid) ?? null : null);
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
if (!baseUrl || !uid) {
|
|
78
|
+
setUser(null);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const cache = getCache(baseUrl);
|
|
82
|
+
if (cache.users.has(uid)) {
|
|
83
|
+
setUser(cache.users.get(uid) ?? null);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
let active = true;
|
|
87
|
+
requestUser(baseUrl, uid, getAuthToken).then(() => {
|
|
88
|
+
if (active) setUser(getCache(baseUrl).users.get(uid) ?? null);
|
|
89
|
+
}).catch(() => {
|
|
90
|
+
if (active) setUser(null);
|
|
91
|
+
});
|
|
92
|
+
return () => {
|
|
93
|
+
active = false;
|
|
94
|
+
};
|
|
95
|
+
}, [
|
|
96
|
+
baseUrl,
|
|
97
|
+
uid,
|
|
98
|
+
getAuthToken
|
|
99
|
+
]);
|
|
100
|
+
return user;
|
|
101
|
+
}
|
|
102
|
+
/** Human-readable label for a resolved user. */
|
|
103
|
+
function getUserLabel(user) {
|
|
104
|
+
return user.displayName || user.email || user.uid;
|
|
105
|
+
}
|
|
106
|
+
//#endregion
|
|
107
|
+
export { getUserLabel, useResolvedUser };
|
|
108
|
+
|
|
109
|
+
//# sourceMappingURL=useResolvedUsers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useResolvedUsers.js","names":[],"sources":["../../src/hooks/useResolvedUsers.ts"],"sourcesContent":["import { useEffect, useState } from \"react\";\nimport type { User } from \"@rebasepro/types\";\nimport { apiBaseOf, useAuthController, useRebaseClient } from \"@rebasepro/app\";\n\n/**\n * Resolves the auth users behind `userSelect` values.\n *\n * A collection view can ask for dozens of ids at once — one per row — so\n * lookups are coalesced into a single `GET /api/admin/users/pick?ids=…` per tick and\n * cached per base URL. Ids that resolve to nothing are remembered too, so a\n * dangling reference is not retried on every render.\n */\n\ninterface UserCache {\n users: Map<string, User | null>;\n pending: Map<string, Promise<void>>;\n queue: Set<string>;\n flush?: ReturnType<typeof setTimeout>;\n}\n\nconst caches = new Map<string, UserCache>();\n\nfunction getCache(baseUrl: string): UserCache {\n let cache = caches.get(baseUrl);\n if (!cache) {\n cache = { users: new Map(),\npending: new Map(),\nqueue: new Set() };\n caches.set(baseUrl, cache);\n }\n return cache;\n}\n\nasync function fetchUsers(apiBase: string, ids: string[], token: string | undefined): Promise<Map<string, User | null>> {\n const resolved = new Map<string, User | null>();\n for (const id of ids) resolved.set(id, null);\n\n const params = new URLSearchParams({ ids: ids.join(\",\") });\n // The picker's read, as the selector uses: anyone who may fill in a\n // `userSelect` field may see who its value names.\n const response = await fetch(`${apiBase}/admin/users/pick?${params}`, {\n headers: token ? { Authorization: `Bearer ${token}` } : {}\n });\n if (!response.ok) {\n // A caller who may write no collection with a user field gets a 403\n // here. Treat it as \"unresolvable\" rather than an error: callers fall\n // back to showing the raw value.\n return resolved;\n }\n const data = await response.json();\n const rows: Record<string, unknown>[] = data.users ?? data.data ?? [];\n for (const row of rows) {\n const uid = (row.uid as string) ?? (row.id as string);\n if (!uid) continue;\n resolved.set(uid, {\n uid,\n email: (row.email as string) ?? \"\",\n displayName: (row.displayName as string) ?? (row.display_name as string) ?? null,\n photoURL: (row.photoURL as string) ?? (row.photo_url as string) ?? null,\n providerId: \"custom\",\n isAnonymous: false,\n roles: (row.roles as string[]) ?? []\n });\n }\n return resolved;\n}\n\nfunction requestUser(\n baseUrl: string,\n uid: string,\n getAuthToken: (() => Promise<string | undefined>) | undefined\n): Promise<void> {\n const cache = getCache(baseUrl);\n const existing = cache.pending.get(uid);\n if (existing) return existing;\n\n cache.queue.add(uid);\n\n const promise = new Promise<void>((resolve, reject) => {\n if (cache.flush) clearTimeout(cache.flush);\n cache.flush = setTimeout(async () => {\n const ids = [...cache.queue];\n cache.queue.clear();\n cache.flush = undefined;\n try {\n const token = await getAuthToken?.();\n const resolved = await fetchUsers(baseUrl, ids, token);\n for (const id of ids) {\n cache.users.set(id, resolved.get(id) ?? null);\n cache.pending.delete(id);\n }\n resolve();\n } catch (error) {\n for (const id of ids) cache.pending.delete(id);\n reject(error);\n }\n }, 0);\n });\n\n cache.pending.set(uid, promise);\n return promise;\n}\n\n/**\n * The auth user behind a `userSelect` value, or `null` while it is loading or\n * when it cannot be resolved.\n */\nexport function useResolvedUser(uid: string | undefined): User | null {\n const client = useRebaseClient<{ baseUrl?: string, apiPath?: string }>();\n const { getAuthToken } = useAuthController();\n /* The API prefix, not the bare origin: it keys the cache and is what a\n request is built from, and a backend with a non-default `basePath`\n serves neither at `/api`. */\n const baseUrl = apiBaseOf(client);\n\n const [user, setUser] = useState<User | null>(() =>\n (baseUrl && uid) ? getCache(baseUrl).users.get(uid) ?? null : null);\n\n useEffect(() => {\n if (!baseUrl || !uid) {\n setUser(null);\n return;\n }\n const cache = getCache(baseUrl);\n if (cache.users.has(uid)) {\n setUser(cache.users.get(uid) ?? null);\n return;\n }\n\n let active = true;\n requestUser(baseUrl, uid, getAuthToken)\n .then(() => {\n if (active) setUser(getCache(baseUrl).users.get(uid) ?? null);\n })\n .catch(() => {\n if (active) setUser(null);\n });\n return () => {\n active = false;\n };\n }, [baseUrl, uid, getAuthToken]);\n\n return user;\n}\n\n/** Human-readable label for a resolved user. */\nexport function getUserLabel(user: User): string {\n return user.displayName || user.email || user.uid;\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { useCollectionRegistryController } from "./navigation/contexts/CollectionRegistryContext.js";
|
|
2
|
+
import { useSideDialogsController } from "./useSideDialogsController.js";
|
|
3
|
+
import { SelectionTableBinding } from "../components/ReferenceTable/SelectionTableBinding.js";
|
|
4
|
+
import { useCallback, useMemo } from "react";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
//#region src/hooks/useSelectionDialog.tsx
|
|
7
|
+
/**
|
|
8
|
+
* This hook is used to open a side dialog that allows the selection
|
|
9
|
+
* of entities under a given path.
|
|
10
|
+
* You can use it in custom views for selecting entities.
|
|
11
|
+
* You need to specify the path of the target collection at least.
|
|
12
|
+
* If your collection is not defined in your top collection configuration
|
|
13
|
+
* (in your `Rebase` component), you need to specify explicitly.
|
|
14
|
+
* This is the same hook used internally when a reference property is defined.
|
|
15
|
+
* @group Hooks and utilities
|
|
16
|
+
*/
|
|
17
|
+
function useSelectionDialog(referenceDialogProps) {
|
|
18
|
+
const navigation = useCollectionRegistryController();
|
|
19
|
+
const sideDialogsController = useSideDialogsController();
|
|
20
|
+
const open = useCallback(() => {
|
|
21
|
+
if (referenceDialogProps.path) {
|
|
22
|
+
let usedCollection = referenceDialogProps.collection;
|
|
23
|
+
if (!usedCollection) usedCollection = navigation.getCollection(referenceDialogProps.path);
|
|
24
|
+
if (!usedCollection) throw Error("Not able to resolve the collection in useSelectionDialog. Make sure a collection is registered in path " + referenceDialogProps.path);
|
|
25
|
+
sideDialogsController.open({
|
|
26
|
+
key: `reference_${referenceDialogProps.path}`,
|
|
27
|
+
component: /* @__PURE__ */ jsx(SelectionTableBinding, {
|
|
28
|
+
collection: usedCollection,
|
|
29
|
+
...referenceDialogProps
|
|
30
|
+
}),
|
|
31
|
+
width: "90vw",
|
|
32
|
+
onClose: () => {
|
|
33
|
+
referenceDialogProps.onClose?.();
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
} else throw Error("useReferenceDialog: You are trying to open a reference dialog, but have not declared the `path`");
|
|
37
|
+
}, [
|
|
38
|
+
navigation,
|
|
39
|
+
referenceDialogProps,
|
|
40
|
+
sideDialogsController
|
|
41
|
+
]);
|
|
42
|
+
const close = useCallback(() => {
|
|
43
|
+
sideDialogsController.close();
|
|
44
|
+
}, [sideDialogsController]);
|
|
45
|
+
return useMemo(() => ({
|
|
46
|
+
open,
|
|
47
|
+
close
|
|
48
|
+
}), [open, close]);
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
export { useSelectionDialog };
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=useSelectionDialog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSelectionDialog.js","names":[],"sources":["../../src/hooks/useSelectionDialog.tsx"],"sourcesContent":["import { SelectionProps, SelectionTableBinding } from \"../components/ReferenceTable/SelectionTableBinding\";\n\nimport { useCallback, useMemo } from \"react\";\nimport { useSideDialogsController } from \"./useSideDialogsController\";\nimport { useCollectionRegistryController } from \"./navigation/contexts/CollectionRegistryContext\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\n\n/**\n * This hook is used to open a side dialog that allows the selection\n * of entities under a given path.\n * You can use it in custom views for selecting entities.\n * You need to specify the path of the target collection at least.\n * If your collection is not defined in your top collection configuration\n * (in your `Rebase` component), you need to specify explicitly.\n * This is the same hook used internally when a reference property is defined.\n * @group Hooks and utilities\n */\nexport function useSelectionDialog<M extends Record<string, unknown>>(referenceDialogProps: Omit<SelectionProps<M>, \"path\"> & {\n path?: string | false;\n onClose?: () => void;\n}): { open: () => void; close: () => void } {\n\n const navigation = useCollectionRegistryController();\n const sideDialogsController = useSideDialogsController();\n\n const open = useCallback(() => {\n if (referenceDialogProps.path) {\n let usedCollection = referenceDialogProps.collection;\n if (!usedCollection)\n usedCollection = navigation.getCollection(referenceDialogProps.path) as AdminCollection<M> | undefined;\n if (!usedCollection)\n throw Error(\"Not able to resolve the collection in useSelectionDialog. Make sure a collection is registered in path \" + referenceDialogProps.path);\n sideDialogsController.open({\n key: `reference_${referenceDialogProps.path}`,\n component:\n <SelectionTableBinding\n collection={usedCollection}\n {...referenceDialogProps as SelectionProps<M>}/>,\n width: \"90vw\",\n onClose: () => {\n referenceDialogProps.onClose?.();\n }\n });\n } else {\n throw Error(\"useReferenceDialog: You are trying to open a reference dialog, but have not declared the `path`\")\n }\n }, [navigation, referenceDialogProps, sideDialogsController]);\n\n const close = useCallback(() => {\n sideDialogsController.close();\n }, [sideDialogsController]);\n\n return useMemo(() => ({\n open,\n close\n }), [open, close]);\n\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAiBA,SAAgB,mBAAsD,sBAG1B;CAExC,MAAM,aAAa,gCAAgC;CACnD,MAAM,wBAAwB,yBAAyB;CAEvD,MAAM,OAAO,kBAAkB;EAC3B,IAAI,qBAAqB,MAAM;GAC3B,IAAI,iBAAiB,qBAAqB;GAC1C,IAAI,CAAC,gBACD,iBAAiB,WAAW,cAAc,qBAAqB,IAAI;GACvE,IAAI,CAAC,gBACD,MAAM,MAAM,4GAA4G,qBAAqB,IAAI;GACrJ,sBAAsB,KAAK;IACvB,KAAK,aAAa,qBAAqB;IACvC,WACI,oBAAC,uBAAD;KACI,YAAY;KACZ,GAAI;IAA2C,CAAA;IACvD,OAAO;IACP,eAAe;KACX,qBAAqB,UAAU;IACnC;GACJ,CAAC;EACL,OACI,MAAM,MAAM,iGAAiG;CAErH,GAAG;EAAC;EAAY;EAAsB;CAAqB,CAAC;CAE5D,MAAM,QAAQ,kBAAkB;EAC5B,sBAAsB,MAAM;CAChC,GAAG,CAAC,qBAAqB,CAAC;CAE1B,OAAO,eAAe;EAClB;EACA;CACJ,IAAI,CAAC,MAAM,KAAK,CAAC;AAErB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SideDialogsControllerContext } from "../contexts/SideDialogsControllerContext.js";
|
|
2
|
+
import { useContext } from "react";
|
|
3
|
+
//#region src/hooks/useSideDialogsController.tsx
|
|
4
|
+
var useSideDialogsController = () => useContext(SideDialogsControllerContext);
|
|
5
|
+
//#endregion
|
|
6
|
+
export { useSideDialogsController };
|
|
7
|
+
|
|
8
|
+
//# sourceMappingURL=useSideDialogsController.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSideDialogsController.js","names":[],"sources":["../../src/hooks/useSideDialogsController.tsx"],"sourcesContent":["import React from \"react\";\nimport { SideDialogsControllerContext } from \"../contexts/SideDialogsControllerContext\";\nimport { useContext } from \"react\";\n\n/**\n * Hook to retrieve the side dialogs' controller.\n *\n * This hook allows you to open and close side dialogs. This is the mechanism\n * used when open a side entity dialog, or when selecting a reference.\n *\n * If you want to open a side entity dialog, you can use the {@link useSidePanel}\n * hook.\n *\n * If you want to select a reference, you can use the {@link useReferenceDialog}\n *\n * Consider that in order to use this hook you need to have a parent\n * `Rebase`\n *\n * @group Hooks and utilities\n */\nimport { SideDialogPanelProps, SideDialogsController } from \"@rebasepro/cms-types\";\n\nexport type { SideDialogPanelProps, SideDialogsController };\n\nexport const useSideDialogsController = (): SideDialogsController => useContext(SideDialogsControllerContext);\n"],"mappings":";;;AAwBA,IAAa,iCAAwD,WAAW,4BAA4B"}
|