@rebasepro/cms 0.28.2 → 0.29.0-canary.g0e3a0e7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/collection_editor/_cms_internals.d.ts +0 -1
- package/dist/collection_editor/ui/EditorCollectionAction.d.ts +2 -2
- package/dist/collection_editor/ui/EditorCollectionAction.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.js +2 -2
- package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/MarkdownPropertyField.js +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/MarkdownPropertyField.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/StoragePropertyField.js +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/StoragePropertyField.js.map +1 -1
- package/dist/components/AdditionalFieldValue.d.ts +9 -3
- package/dist/components/AdditionalFieldValue.js +7 -4
- package/dist/components/AdditionalFieldValue.js.map +1 -1
- package/dist/components/CollectionPanel.d.ts +117 -18
- package/dist/components/CollectionPanel.js +115 -37
- package/dist/components/CollectionPanel.js.map +1 -1
- package/dist/components/CollectionTableBinding/CollectionRowActions.d.ts +5 -5
- package/dist/components/CollectionTableBinding/CollectionRowActions.js +16 -12
- package/dist/components/CollectionTableBinding/CollectionRowActions.js.map +1 -1
- package/dist/components/CollectionTableBinding/CollectionTableBinding.js +33 -8
- package/dist/components/CollectionTableBinding/CollectionTableBinding.js.map +1 -1
- package/dist/components/CollectionTableBinding/CollectionTableBindingProps.d.ts +8 -3
- package/dist/components/CollectionTableBinding/PropertyTableCell.js +2 -2
- package/dist/components/CollectionTableBinding/PropertyTableCell.js.map +1 -1
- package/dist/components/CollectionTableBinding/column_utils.d.ts +9 -1
- package/dist/components/CollectionTableBinding/column_utils.js +6 -3
- package/dist/components/CollectionTableBinding/column_utils.js.map +1 -1
- package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.js +2 -2
- package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.js.map +1 -1
- package/dist/components/CollectionTableBinding/fields/TableReferenceField.js +2 -2
- package/dist/components/CollectionTableBinding/fields/TableReferenceField.js.map +1 -1
- package/dist/components/CollectionTableBinding/fields/TableRelationField.js +2 -2
- package/dist/components/CollectionTableBinding/fields/TableRelationField.js.map +1 -1
- package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.d.ts +3 -2
- package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.js +9 -7
- package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.js.map +1 -1
- package/dist/components/CollectionTableBinding/internal/common.d.ts +26 -2
- package/dist/components/CollectionTableBinding/internal/common.js +88 -4
- package/dist/components/CollectionTableBinding/internal/common.js.map +1 -1
- package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js +4 -3
- package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js.map +1 -1
- package/dist/components/CollectionViewBinding/BoardCardBinding.d.ts +7 -1
- package/dist/components/CollectionViewBinding/BoardCardBinding.js +19 -14
- package/dist/components/CollectionViewBinding/BoardCardBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionAddButton.d.ts +28 -0
- package/dist/components/CollectionViewBinding/CollectionAddButton.js +50 -0
- package/dist/components/CollectionViewBinding/CollectionAddButton.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.d.ts +11 -3
- package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.js +9 -4
- package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionCardViewBinding.d.ts +5 -3
- package/dist/components/CollectionViewBinding/CollectionCardViewBinding.js +5 -3
- package/dist/components/CollectionViewBinding/CollectionCardViewBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionEntityActions.d.ts +29 -0
- package/dist/components/CollectionViewBinding/CollectionEntityActions.js +112 -0
- package/dist/components/CollectionViewBinding/CollectionEntityActions.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionListViewBinding.d.ts +2 -2
- package/dist/components/CollectionViewBinding/CollectionListViewBinding.js +58 -16
- package/dist/components/CollectionViewBinding/CollectionListViewBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionToolbar.d.ts +57 -0
- package/dist/components/CollectionViewBinding/CollectionToolbar.js +146 -0
- package/dist/components/CollectionViewBinding/CollectionToolbar.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionViewActions.d.ts +2 -2
- package/dist/components/CollectionViewBinding/CollectionViewActions.js +22 -26
- package/dist/components/CollectionViewBinding/CollectionViewActions.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionViewBinding.d.ts +58 -22
- package/dist/components/CollectionViewBinding/CollectionViewBinding.js +81 -1089
- package/dist/components/CollectionViewBinding/CollectionViewBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionViewContent.d.ts +9 -0
- package/dist/components/CollectionViewBinding/CollectionViewContent.js +152 -0
- package/dist/components/CollectionViewBinding/CollectionViewContent.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionViewDialogs.d.ts +9 -0
- package/dist/components/CollectionViewBinding/CollectionViewDialogs.js +38 -0
- package/dist/components/CollectionViewBinding/CollectionViewDialogs.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionViewFrame.d.ts +13 -0
- package/dist/components/CollectionViewBinding/CollectionViewFrame.js +32 -0
- package/dist/components/CollectionViewBinding/CollectionViewFrame.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionViewScope.d.ts +14 -0
- package/dist/components/CollectionViewBinding/CollectionViewScope.js +22 -0
- package/dist/components/CollectionViewBinding/CollectionViewScope.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionViewStartActions.d.ts +2 -2
- package/dist/components/CollectionViewBinding/CollectionViewStartActions.js +39 -67
- package/dist/components/CollectionViewBinding/CollectionViewStartActions.js.map +1 -1
- package/dist/components/CollectionViewBinding/CustomViewHost.d.ts +28 -0
- package/dist/components/CollectionViewBinding/CustomViewHost.js +54 -0
- package/dist/components/CollectionViewBinding/CustomViewHost.js.map +1 -0
- package/dist/components/CollectionViewBinding/EntitiesCount.d.ts +24 -0
- package/dist/components/CollectionViewBinding/EntitiesCount.js +69 -0
- package/dist/components/CollectionViewBinding/EntitiesCount.js.map +1 -0
- package/dist/components/CollectionViewBinding/EntityCardBinding.d.ts +7 -1
- package/dist/components/CollectionViewBinding/EntityCardBinding.js +34 -23
- package/dist/components/CollectionViewBinding/EntityCardBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/EntityIdHeaderWidget.d.ts +17 -0
- package/dist/components/CollectionViewBinding/EntityIdHeaderWidget.js +107 -0
- package/dist/components/CollectionViewBinding/EntityIdHeaderWidget.js.map +1 -0
- package/dist/components/CollectionViewBinding/FiltersButton.d.ts +15 -0
- package/dist/components/CollectionViewBinding/FiltersButton.js +49 -0
- package/dist/components/CollectionViewBinding/FiltersButton.js.map +1 -0
- package/dist/components/CollectionViewBinding/PluginColumnSlots.d.ts +35 -0
- package/dist/components/CollectionViewBinding/PluginColumnSlots.js +45 -0
- package/dist/components/CollectionViewBinding/PluginColumnSlots.js.map +1 -0
- package/dist/components/CollectionViewBinding/RowActions.d.ts +40 -0
- package/dist/components/CollectionViewBinding/RowActions.js +60 -0
- package/dist/components/CollectionViewBinding/RowActions.js.map +1 -0
- package/dist/components/CollectionViewBinding/SplitListView.d.ts +7 -4
- package/dist/components/CollectionViewBinding/SplitListView.js +20 -21
- package/dist/components/CollectionViewBinding/SplitListView.js.map +1 -1
- package/dist/components/CollectionViewBinding/builtin_action_props.d.ts +13 -0
- package/dist/components/CollectionViewBinding/fields.d.ts +22 -0
- package/dist/components/CollectionViewBinding/fields.js +47 -0
- package/dist/components/CollectionViewBinding/fields.js.map +1 -0
- package/dist/components/CollectionViewBinding/useBoardDataController.js +6 -7
- package/dist/components/CollectionViewBinding/useBoardDataController.js.map +1 -1
- package/dist/components/CollectionViewBinding/useCollectionLargeLayout.d.ts +19 -0
- package/dist/components/CollectionViewBinding/useCollectionLargeLayout.js +28 -0
- package/dist/components/CollectionViewBinding/useCollectionLargeLayout.js.map +1 -0
- package/dist/components/CollectionViewBinding/useCollectionViewState.d.ts +125 -0
- package/dist/components/CollectionViewBinding/useCollectionViewState.js +844 -0
- package/dist/components/CollectionViewBinding/useCollectionViewState.js.map +1 -0
- package/dist/components/CollectionViewBinding/usePreviewSlots.d.ts +20 -0
- package/dist/components/CollectionViewBinding/usePreviewSlots.js +23 -2
- package/dist/components/CollectionViewBinding/usePreviewSlots.js.map +1 -1
- package/dist/components/CollectionViewBinding/useSelectionController.d.ts +21 -3
- package/dist/components/CollectionViewBinding/useSelectionController.js +37 -6
- package/dist/components/CollectionViewBinding/useSelectionController.js.map +1 -1
- package/dist/components/CollectionsProvider.d.ts +3 -3
- package/dist/components/CollectionsProvider.js +4 -4
- package/dist/components/CollectionsProvider.js.map +1 -1
- package/dist/components/CollectionsScopeContext.d.ts +1 -1
- package/dist/components/CollectionsScopeContext.js +1 -1
- package/dist/components/CollectionsScopeContext.js.map +1 -1
- package/dist/components/DeleteEntityDialog.d.ts +1 -1
- package/dist/components/DeleteEntityDialog.js +2 -2
- package/dist/components/DeleteEntityDialog.js.map +1 -1
- package/dist/components/DetailViewBinding.js +32 -68
- package/dist/components/DetailViewBinding.js.map +1 -1
- package/dist/components/EditFormActions.js +5 -4
- package/dist/components/EditFormActions.js.map +1 -1
- package/dist/components/EditViewBinding.d.ts +2 -2
- package/dist/components/EditViewBinding.js +25 -15
- package/dist/components/EditViewBinding.js.map +1 -1
- package/dist/components/EntityDisplayHeader.js +8 -5
- package/dist/components/EntityDisplayHeader.js.map +1 -1
- package/dist/components/EntityPreviewBinding.js +1 -1
- package/dist/components/EntityPreviewBinding.js.map +1 -1
- package/dist/components/EntityViewBinding.d.ts +8 -1
- package/dist/components/EntityViewBinding.js +43 -14
- package/dist/components/EntityViewBinding.js.map +1 -1
- package/dist/components/EntityViewBody.d.ts +40 -0
- package/dist/components/EntityViewBody.js +90 -0
- package/dist/components/EntityViewBody.js.map +1 -0
- package/dist/components/FieldValue.d.ts +50 -0
- package/dist/components/FieldValue.js +81 -0
- package/dist/components/FieldValue.js.map +1 -0
- package/dist/components/InlineEntityPreview.js +1 -1
- package/dist/components/InlineEntityPreview.js.map +1 -1
- package/dist/components/PanelNotFound.d.ts +5 -0
- package/dist/components/PanelNotFound.js +21 -0
- package/dist/components/PanelNotFound.js.map +1 -0
- package/dist/components/RebaseCMS.d.ts +1 -1
- package/dist/components/RebaseCMS.js +11 -3
- package/dist/components/RebaseCMS.js.map +1 -1
- package/dist/components/RebaseNavigation.js +9 -3
- package/dist/components/RebaseNavigation.js.map +1 -1
- package/dist/components/RebaseShell.js +10 -5
- package/dist/components/RebaseShell.js.map +1 -1
- package/dist/components/RecordDetail.d.ts +61 -0
- package/dist/components/RecordDetail.js +123 -0
- package/dist/components/RecordDetail.js.map +1 -0
- package/dist/components/RecordForm.d.ts +126 -0
- package/dist/components/{EntityFormPanel.js → RecordForm.js} +64 -36
- package/dist/components/RecordForm.js.map +1 -0
- package/dist/components/ReferenceTable/SelectionTableBinding.d.ts +47 -17
- package/dist/components/ReferenceTable/SelectionTableBinding.js +89 -53
- package/dist/components/ReferenceTable/SelectionTableBinding.js.map +1 -1
- package/dist/components/ReferenceWidget.d.ts +5 -3
- package/dist/components/ReferenceWidget.js +10 -7
- package/dist/components/ReferenceWidget.js.map +1 -1
- package/dist/components/RelationSelector.js +4 -4
- package/dist/components/RelationSelector.js.map +1 -1
- package/dist/components/SelectableTable/SelectableTable.js +2 -3
- package/dist/components/SelectableTable/SelectableTable.js.map +1 -1
- package/dist/components/SelectableTable/SelectionStore.d.ts +1 -1
- package/dist/components/SelectableTable/SelectionStore.js +1 -1
- package/dist/components/SelectableTable/SelectionStore.js.map +1 -1
- package/dist/components/SelectableTable/filters/ReferenceFilterField.js +2 -2
- package/dist/components/SelectableTable/filters/ReferenceFilterField.js.map +1 -1
- package/dist/components/SidePanelBinding.js +13 -12
- package/dist/components/SidePanelBinding.js.map +1 -1
- package/dist/components/collection_prop.d.ts +18 -0
- package/dist/components/collection_prop.js +23 -0
- package/dist/components/collection_prop.js.map +1 -0
- package/dist/components/common/default_entity_actions.js +54 -54
- package/dist/components/common/default_entity_actions.js.map +1 -1
- package/dist/components/history/EntityHistoryView.d.ts +4 -1
- package/dist/components/history/EntityHistoryView.js +1 -1
- package/dist/components/history/EntityHistoryView.js.map +1 -1
- package/dist/components/history/LastEditedByFormAction.d.ts +1 -1
- package/dist/components/index.d.ts +4 -2
- package/dist/data_export/export/ExportCollectionAction.d.ts +3 -2
- package/dist/data_export/export/ExportCollectionAction.js +4 -3
- package/dist/data_export/export/ExportCollectionAction.js.map +1 -1
- package/dist/data_export/export/additional_fields.d.ts +6 -3
- package/dist/data_export/export/additional_fields.js +8 -4
- package/dist/data_export/export/additional_fields.js.map +1 -1
- package/dist/data_import/import/ImportCollectionAction.js +2 -2
- package/dist/data_import/import/ImportCollectionAction.js.map +1 -1
- package/dist/form/EntityForm.d.ts +1 -1
- package/dist/form/EntityForm.js +252 -150
- package/dist/form/EntityForm.js.map +1 -1
- package/dist/form/EntityFormActions.js +3 -2
- package/dist/form/EntityFormActions.js.map +1 -1
- package/dist/form/EntityFormBinding.d.ts +1 -1
- package/dist/form/EntityFormBinding.js +22 -11
- package/dist/form/EntityFormBinding.js.map +1 -1
- package/dist/form/FormField.d.ts +36 -0
- package/dist/form/FormField.js +41 -0
- package/dist/form/FormField.js.map +1 -0
- package/dist/form/FormFieldsContext.d.ts +69 -0
- package/dist/form/FormFieldsContext.js +143 -0
- package/dist/form/FormFieldsContext.js.map +1 -0
- package/dist/form/PropertyFieldBinding.js +4 -4
- package/dist/form/PropertyFieldBinding.js.map +1 -1
- package/dist/form/collection_showing.d.ts +8 -0
- package/dist/form/collection_showing.js +29 -0
- package/dist/form/collection_showing.js.map +1 -0
- package/dist/form/components/ErrorFocus.js +2 -1
- package/dist/form/components/ErrorFocus.js.map +1 -1
- package/dist/form/components/FieldBlock.js +3 -1
- package/dist/form/components/FieldBlock.js.map +1 -1
- package/dist/form/components/FormRail.d.ts +5 -1
- package/dist/form/components/FormRail.js +5 -1
- package/dist/form/components/FormRail.js.map +1 -1
- package/dist/form/components/FormSections.d.ts +5 -1
- package/dist/form/components/FormSections.js +11 -4
- package/dist/form/components/FormSections.js.map +1 -1
- package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.js +2 -2
- package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/MarkdownEditorFieldBinding.js +1 -1
- package/dist/form/field_bindings/MarkdownEditorFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/MultipleRelationFieldBinding.js +2 -2
- package/dist/form/field_bindings/MultipleRelationFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/ReadOnlyFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/ReferenceFieldBinding.js +2 -2
- package/dist/form/field_bindings/ReferenceFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/RelationFieldBinding.js +2 -2
- package/dist/form/field_bindings/RelationFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/StorageUploadFieldBinding.js +1 -1
- package/dist/form/field_bindings/StorageUploadFieldBinding.js.map +1 -1
- package/dist/form/form_dom_ids.d.ts +25 -0
- package/dist/form/form_dom_ids.js +42 -0
- package/dist/form/form_dom_ids.js.map +1 -0
- package/dist/form/index.d.ts +3 -1
- package/dist/form/resolve_cell_property.d.ts +5 -0
- package/dist/form/resolve_cell_property.js +22 -1
- package/dist/form/resolve_cell_property.js.map +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/navigation/useBuildNavigationStateController.d.ts +2 -2
- package/dist/hooks/navigation/useBuildNavigationStateController.js.map +1 -1
- package/dist/hooks/navigation/useNavigationResolution.d.ts +3 -3
- package/dist/hooks/navigation/useNavigationResolution.js.map +1 -1
- package/dist/hooks/navigation/useResolvedCollections.d.ts +2 -2
- package/dist/hooks/navigation/useResolvedCollections.js.map +1 -1
- package/dist/hooks/navigation/useResolvedViews.d.ts +2 -2
- package/dist/hooks/navigation/useResolvedViews.js.map +1 -1
- package/dist/hooks/useBuildSidePanel.js +9 -9
- package/dist/hooks/useBuildSidePanel.js.map +1 -1
- package/dist/hooks/useEntityDisplay.js +6 -4
- package/dist/hooks/useEntityDisplay.js.map +1 -1
- package/dist/hooks/useRecordActions.js +2 -2
- package/dist/hooks/useRecordActions.js.map +1 -1
- package/dist/hooks/useSelectionDialog.d.ts +20 -7
- package/dist/hooks/useSelectionDialog.js +29 -8
- package/dist/hooks/useSelectionDialog.js.map +1 -1
- package/dist/index.d.ts +8 -3
- package/dist/index.js +15 -9
- package/dist/mcp-view.d.ts +9 -0
- package/dist/mcp-view.js +2 -0
- package/dist/mcp_view/app_modules.d.ts +29 -0
- package/dist/mcp_view/app_modules.js +163 -0
- package/dist/mcp_view/app_modules.js.map +1 -0
- package/dist/mcp_view/bridge.d.ts +90 -0
- package/dist/mcp_view/bridge.js +205 -0
- package/dist/mcp_view/bridge.js.map +1 -0
- package/dist/mcp_view/code_app.d.ts +65 -0
- package/dist/mcp_view/code_app.js +139 -0
- package/dist/mcp_view/code_app.js.map +1 -0
- package/dist/mcp_view/index.d.ts +48 -0
- package/dist/mcp_view/index.js +235 -0
- package/dist/mcp_view/index.js.map +1 -0
- package/dist/mcp_view/payload.d.ts +78 -0
- package/dist/mcp_view/payload.js +155 -0
- package/dist/mcp_view/payload.js.map +1 -0
- package/dist/mcp_view/screen.d.ts +28 -0
- package/dist/mcp_view/screen.js +223 -0
- package/dist/mcp_view/screen.js.map +1 -0
- package/dist/mcp_view/storage_source.d.ts +14 -0
- package/dist/mcp_view/storage_source.js +29 -0
- package/dist/mcp_view/storage_source.js.map +1 -0
- package/dist/mcp_view/store.d.ts +9 -0
- package/dist/mcp_view/store.js +27 -0
- package/dist/mcp_view/store.js.map +1 -0
- package/dist/mcp_view/tool_driver.d.ts +135 -0
- package/dist/mcp_view/tool_driver.js +527 -0
- package/dist/mcp_view/tool_driver.js.map +1 -0
- package/dist/preview/components/DatePreview.d.ts +34 -1
- package/dist/preview/components/DatePreview.js +72 -37
- package/dist/preview/components/DatePreview.js.map +1 -1
- package/dist/routes/RebaseRoute.js +1 -1
- package/dist/routes/RebaseRoute.js.map +1 -1
- package/dist/selection/SelectionMenu.d.ts +5 -3
- package/dist/selection/SelectionMenu.js +16 -9
- package/dist/selection/SelectionMenu.js.map +1 -1
- package/dist/selection/index.d.ts +2 -1
- package/dist/selection/resolve_selection.d.ts +61 -7
- package/dist/selection/resolve_selection.js +93 -11
- package/dist/selection/resolve_selection.js.map +1 -1
- package/dist/types/components/EntityFormProps.d.ts +60 -10
- package/dist/types/fields.d.ts +2 -65
- package/dist/util/dataControllerAdapter.d.ts +8 -0
- package/dist/util/dataControllerAdapter.js +11 -0
- package/dist/util/dataControllerAdapter.js.map +1 -1
- package/dist/util/navigation_utils.d.ts +5 -4
- package/dist/util/navigation_utils.js +6 -6
- package/dist/util/navigation_utils.js.map +1 -1
- package/dist/util/propertyConfigMapper.d.ts +8 -0
- package/dist/util/propertyConfigMapper.js +16 -2
- package/dist/util/propertyConfigMapper.js.map +1 -1
- package/package.json +15 -9
- package/recipes/README.md +79 -26
- package/recipes/approval-queue.tsx +79 -0
- package/recipes/bulk-set-status.tsx +23 -17
- package/recipes/calendar-view.tsx +28 -23
- package/recipes/master-detail.tsx +75 -0
- package/recipes/my-preferences.tsx +3 -3
- package/recipes/orders-dashboard.tsx +58 -84
- package/recipes/site-settings.tsx +4 -4
- package/dist/components/EntityFormPanel.d.ts +0 -63
- package/dist/components/EntityFormPanel.js.map +0 -1
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { CollectionTableToolbar, useToolbarLabels } from "../CollectionTableBinding/internal/CollectionTableToolbar.js";
|
|
2
|
+
import { useCollectionViewScope } from "./CollectionViewScope.js";
|
|
3
|
+
import { EMPTY_ARRAY } from "./PluginColumnSlots.js";
|
|
4
|
+
import { FiltersButton } from "./FiltersButton.js";
|
|
5
|
+
import { CollectionViewStartActions } from "./CollectionViewStartActions.js";
|
|
6
|
+
import { ViewModeToggle } from "./ViewModeToggle.js";
|
|
7
|
+
import React from "react";
|
|
8
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
9
|
+
import { SearchBar } from "@rebasepro/ui";
|
|
10
|
+
import { useTranslation } from "@rebasepro/app";
|
|
11
|
+
import { getCollectionDataPath } from "@rebasepro/types";
|
|
12
|
+
//#region src/components/CollectionViewBinding/CollectionToolbar.tsx
|
|
13
|
+
/**
|
|
14
|
+
* The view-mode switcher of the collection view it is drawn in, with the
|
|
15
|
+
* size and kanban-column choices of the active view.
|
|
16
|
+
*
|
|
17
|
+
* @group Collection components
|
|
18
|
+
*/
|
|
19
|
+
function CollectionViewModeToggle() {
|
|
20
|
+
const { viewMode, onViewModeChange, enabledViews, resolvedCustomViews, activeCustomView, customViewSize, setCustomViewSize, listSize, tableSize, cardSize, setCardSize, onListSizeChanged, onTableSizeChanged, viewModePopoverOpen, setViewModePopoverOpen, kanbanPropertyOptions, selectedKanbanProperty, onKanbanPropertyChange } = useCollectionViewScope("CollectionViewModeToggle");
|
|
21
|
+
return /* @__PURE__ */ jsx(ViewModeToggle, {
|
|
22
|
+
viewMode,
|
|
23
|
+
onViewModeChange,
|
|
24
|
+
enabledViews,
|
|
25
|
+
customViews: resolvedCustomViews,
|
|
26
|
+
size: activeCustomView ? activeCustomView.sizeable ? customViewSize : void 0 : viewMode === "list" ? listSize : viewMode === "table" ? tableSize : viewMode === "cards" ? cardSize : void 0,
|
|
27
|
+
onSizeChanged: activeCustomView ? activeCustomView.sizeable ? setCustomViewSize : void 0 : viewMode === "list" ? onListSizeChanged : viewMode === "table" ? onTableSizeChanged : viewMode === "cards" ? setCardSize : void 0,
|
|
28
|
+
open: viewModePopoverOpen,
|
|
29
|
+
onOpenChange: setViewModePopoverOpen,
|
|
30
|
+
kanbanPropertyOptions,
|
|
31
|
+
selectedKanbanProperty,
|
|
32
|
+
onKanbanPropertyChange
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The search box of the collection view it is drawn in.
|
|
37
|
+
*
|
|
38
|
+
* @group Collection components
|
|
39
|
+
*/
|
|
40
|
+
function CollectionSearchBar() {
|
|
41
|
+
const { tableController } = useCollectionViewScope("CollectionSearchBar");
|
|
42
|
+
const { t } = useTranslation();
|
|
43
|
+
if (!tableController.setSearchString) return null;
|
|
44
|
+
return /* @__PURE__ */ jsx(SearchBar, {
|
|
45
|
+
size: "small",
|
|
46
|
+
placeholder: t("search"),
|
|
47
|
+
onTextSearch: tableController.setSearchString,
|
|
48
|
+
expandable: true,
|
|
49
|
+
initialValue: tableController.searchString
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The filters button of the collection view it is drawn in, with the count
|
|
54
|
+
* of filters set, and the dialog it opens.
|
|
55
|
+
*
|
|
56
|
+
* @group Collection components
|
|
57
|
+
*/
|
|
58
|
+
function CollectionFiltersButton() {
|
|
59
|
+
const { tableController, resolvedCollection, collection, isCompact } = useCollectionViewScope("CollectionFiltersButton");
|
|
60
|
+
const toolbarLabels = useToolbarLabels();
|
|
61
|
+
return /* @__PURE__ */ jsx(FiltersButton, {
|
|
62
|
+
tableController,
|
|
63
|
+
properties: resolvedCollection.properties,
|
|
64
|
+
fixedFilter: collection.fixedFilter,
|
|
65
|
+
iconOnly: isCompact || !toolbarLabels
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* The toolbar of the collection view it is drawn in — the default
|
|
70
|
+
* `toolbar` of a `CollectionPanel`.
|
|
71
|
+
*
|
|
72
|
+
* Without props: the view-mode switcher, selection, filters, sort and count
|
|
73
|
+
* on the left; search, the `Collection.Actions` override with the
|
|
74
|
+
* `collection.toolbar` and `collection.actions` contributions, and the add
|
|
75
|
+
* button on the right. With `start` or `end`: the same bar, holding only
|
|
76
|
+
* those — compose them from `CollectionViewModeToggle`,
|
|
77
|
+
* `CollectionFiltersButton`, `CollectionSearchBar` and `CollectionAddButton`.
|
|
78
|
+
*
|
|
79
|
+
* @group Collection components
|
|
80
|
+
*/
|
|
81
|
+
function CollectionToolbar({ start, end }) {
|
|
82
|
+
const { collection, path, parentCollectionSlugs, parentEntityIds, tableController, usedSelectionController, resolvedCollection, viewMode, isCompact, activeSelectionEnabled, liveSelectionQuery, docsCount, openNewDocument, onNewClick, onMultipleDeleteClick, isLinkedChildView, linkedTargetSlug, selectionDialog, pluginToolbarWidgets, ResolvedCollectionActions } = useCollectionViewScope("CollectionToolbar");
|
|
83
|
+
if (start !== void 0 || end !== void 0) return /* @__PURE__ */ jsx(CollectionTableToolbar, {
|
|
84
|
+
loading: tableController.dataLoading,
|
|
85
|
+
actionsStart: start,
|
|
86
|
+
actions: end
|
|
87
|
+
});
|
|
88
|
+
return /* @__PURE__ */ jsx(CollectionTableToolbar, {
|
|
89
|
+
compact: isCompact,
|
|
90
|
+
loading: tableController.dataLoading,
|
|
91
|
+
onTextSearch: tableController.setSearchString,
|
|
92
|
+
initialSearchText: tableController.searchString,
|
|
93
|
+
viewModeToggle: /* @__PURE__ */ jsx(CollectionViewModeToggle, {}),
|
|
94
|
+
actionsStart: /* @__PURE__ */ jsx(CollectionViewStartActions, {
|
|
95
|
+
parentCollectionSlugs: parentCollectionSlugs ?? EMPTY_ARRAY,
|
|
96
|
+
parentEntityIds: parentEntityIds ?? EMPTY_ARRAY,
|
|
97
|
+
collection,
|
|
98
|
+
tableController,
|
|
99
|
+
path,
|
|
100
|
+
relativePath: getCollectionDataPath(collection),
|
|
101
|
+
selectionController: usedSelectionController,
|
|
102
|
+
collectionEntitiesCount: docsCount ?? void 0,
|
|
103
|
+
resolvedProperties: resolvedCollection.properties,
|
|
104
|
+
viewMode,
|
|
105
|
+
selectionEnabled: activeSelectionEnabled,
|
|
106
|
+
selectionQuery: liveSelectionQuery,
|
|
107
|
+
entitiesCount: docsCount,
|
|
108
|
+
openNewDocument,
|
|
109
|
+
compact: isCompact
|
|
110
|
+
}),
|
|
111
|
+
actions: /* @__PURE__ */ jsx(ResolvedCollectionActions, {
|
|
112
|
+
parentCollectionSlugs: parentCollectionSlugs ?? EMPTY_ARRAY,
|
|
113
|
+
parentEntityIds: parentEntityIds ?? EMPTY_ARRAY,
|
|
114
|
+
collection,
|
|
115
|
+
tableController,
|
|
116
|
+
onMultipleDeleteClick,
|
|
117
|
+
removeUnlinks: isLinkedChildView,
|
|
118
|
+
onNewClick,
|
|
119
|
+
onAddExistingClick: linkedTargetSlug ? selectionDialog.open : void 0,
|
|
120
|
+
openNewDocument,
|
|
121
|
+
path,
|
|
122
|
+
relativePath: getCollectionDataPath(collection),
|
|
123
|
+
selectionController: usedSelectionController,
|
|
124
|
+
selectionEnabled: activeSelectionEnabled,
|
|
125
|
+
collectionEntitiesCount: docsCount ?? void 0,
|
|
126
|
+
compact: isCompact,
|
|
127
|
+
children: pluginToolbarWidgets
|
|
128
|
+
})
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
/** The default toolbar, as the element a view draws when it is given none. */
|
|
132
|
+
var DEFAULT_TOOLBAR = /* @__PURE__ */ jsx(CollectionToolbar, {});
|
|
133
|
+
/** The toolbar a view was given: the default, a composition, or `null`. */
|
|
134
|
+
var CollectionToolbarSlotContext = React.createContext(DEFAULT_TOOLBAR);
|
|
135
|
+
/**
|
|
136
|
+
* Draws the view's toolbar. One element for the life of the view, so the
|
|
137
|
+
* toolbar keeps its place in the tree — and the view-mode popover stays open —
|
|
138
|
+
* whichever view is shown below it.
|
|
139
|
+
*/
|
|
140
|
+
function CollectionToolbarSlot() {
|
|
141
|
+
return /* @__PURE__ */ jsx(Fragment, { children: React.useContext(CollectionToolbarSlotContext) });
|
|
142
|
+
}
|
|
143
|
+
//#endregion
|
|
144
|
+
export { CollectionFiltersButton, CollectionSearchBar, CollectionToolbar, CollectionToolbarSlot, CollectionToolbarSlotContext, CollectionViewModeToggle, DEFAULT_TOOLBAR };
|
|
145
|
+
|
|
146
|
+
//# sourceMappingURL=CollectionToolbar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CollectionToolbar.js","names":[],"sources":["../../../src/components/CollectionViewBinding/CollectionToolbar.tsx"],"sourcesContent":["import React from \"react\";\nimport { getCollectionDataPath } from \"@rebasepro/types\";\nimport { useTranslation } from \"@rebasepro/app\";\nimport { SearchBar } from \"@rebasepro/ui\";\nimport { CollectionTableToolbar, useToolbarLabels } from \"../CollectionTableBinding/internal/CollectionTableToolbar\";\nimport { FiltersButton } from \"./FiltersButton\";\nimport { CollectionViewStartActions } from \"./CollectionViewStartActions\";\nimport { ViewModeToggle } from \"./ViewModeToggle\";\nimport { EMPTY_ARRAY } from \"./PluginColumnSlots\";\nimport { useCollectionViewScope } from \"./CollectionViewScope\";\n\n/**\n * The view-mode switcher of the collection view it is drawn in, with the\n * size and kanban-column choices of the active view.\n *\n * @group Collection components\n */\nexport function CollectionViewModeToggle() {\n const scope = useCollectionViewScope(\"CollectionViewModeToggle\");\n const {\n viewMode,\n onViewModeChange,\n enabledViews,\n resolvedCustomViews,\n activeCustomView,\n customViewSize,\n setCustomViewSize,\n listSize,\n tableSize,\n cardSize,\n setCardSize,\n onListSizeChanged,\n onTableSizeChanged,\n viewModePopoverOpen,\n setViewModePopoverOpen,\n kanbanPropertyOptions,\n selectedKanbanProperty,\n onKanbanPropertyChange\n } = scope;\n return (\n <ViewModeToggle\n viewMode={viewMode}\n onViewModeChange={onViewModeChange}\n enabledViews={enabledViews}\n customViews={resolvedCustomViews}\n size={activeCustomView ? (activeCustomView.sizeable ? customViewSize : undefined) : viewMode === \"list\" ? listSize : viewMode === \"table\" ? tableSize : viewMode === \"cards\" ? cardSize : undefined}\n onSizeChanged={activeCustomView ? (activeCustomView.sizeable ? setCustomViewSize : undefined) : viewMode === \"list\" ? onListSizeChanged : viewMode === \"table\" ? onTableSizeChanged : viewMode === \"cards\" ? setCardSize : undefined}\n open={viewModePopoverOpen}\n onOpenChange={setViewModePopoverOpen}\n kanbanPropertyOptions={kanbanPropertyOptions}\n selectedKanbanProperty={selectedKanbanProperty}\n onKanbanPropertyChange={onKanbanPropertyChange}\n />\n );\n}\n\n/**\n * The search box of the collection view it is drawn in.\n *\n * @group Collection components\n */\nexport function CollectionSearchBar() {\n const { tableController } = useCollectionViewScope(\"CollectionSearchBar\");\n const { t } = useTranslation();\n if (!tableController.setSearchString) return null;\n return (\n <SearchBar\n size={\"small\"}\n placeholder={t(\"search\")}\n onTextSearch={tableController.setSearchString}\n expandable={true}\n initialValue={tableController.searchString}/>\n );\n}\n\n/**\n * The filters button of the collection view it is drawn in, with the count\n * of filters set, and the dialog it opens.\n *\n * @group Collection components\n */\nexport function CollectionFiltersButton() {\n const { tableController, resolvedCollection, collection, isCompact } = useCollectionViewScope(\"CollectionFiltersButton\");\n const toolbarLabels = useToolbarLabels();\n return (\n <FiltersButton\n tableController={tableController}\n properties={resolvedCollection.properties}\n fixedFilter={collection.fixedFilter}\n iconOnly={isCompact || !toolbarLabels}/>\n );\n}\n\n/**\n * @group Collection components\n */\nexport type CollectionToolbarProps = {\n /**\n * The leading group. With neither `start` nor `end`, the toolbar draws\n * its full set of pieces.\n */\n start?: React.ReactNode;\n /** The trailing group. */\n end?: React.ReactNode;\n};\n\n/**\n * The toolbar of the collection view it is drawn in — the default\n * `toolbar` of a `CollectionPanel`.\n *\n * Without props: the view-mode switcher, selection, filters, sort and count\n * on the left; search, the `Collection.Actions` override with the\n * `collection.toolbar` and `collection.actions` contributions, and the add\n * button on the right. With `start` or `end`: the same bar, holding only\n * those — compose them from `CollectionViewModeToggle`,\n * `CollectionFiltersButton`, `CollectionSearchBar` and `CollectionAddButton`.\n *\n * @group Collection components\n */\nexport function CollectionToolbar({ start, end }: CollectionToolbarProps) {\n const scope = useCollectionViewScope(\"CollectionToolbar\");\n const {\n collection,\n path,\n parentCollectionSlugs,\n parentEntityIds,\n tableController,\n usedSelectionController,\n resolvedCollection,\n viewMode,\n isCompact,\n activeSelectionEnabled,\n liveSelectionQuery,\n docsCount,\n openNewDocument,\n onNewClick,\n onMultipleDeleteClick,\n isLinkedChildView,\n linkedTargetSlug,\n selectionDialog,\n pluginToolbarWidgets,\n ResolvedCollectionActions\n } = scope;\n\n if (start !== undefined || end !== undefined) {\n return (\n <CollectionTableToolbar\n loading={tableController.dataLoading}\n actionsStart={start}\n actions={end}/>\n );\n }\n\n return (\n <CollectionTableToolbar\n compact={isCompact}\n loading={tableController.dataLoading}\n onTextSearch={tableController.setSearchString}\n initialSearchText={tableController.searchString}\n viewModeToggle={<CollectionViewModeToggle/>}\n actionsStart={<CollectionViewStartActions\n parentCollectionSlugs={parentCollectionSlugs ?? EMPTY_ARRAY} parentEntityIds={parentEntityIds ?? EMPTY_ARRAY}\n collection={collection}\n tableController={tableController}\n path={path}\n relativePath={getCollectionDataPath(collection)}\n selectionController={usedSelectionController}\n collectionEntitiesCount={docsCount ?? undefined}\n resolvedProperties={resolvedCollection.properties}\n viewMode={viewMode}\n selectionEnabled={activeSelectionEnabled}\n selectionQuery={liveSelectionQuery}\n entitiesCount={docsCount}\n openNewDocument={openNewDocument}\n compact={isCompact}/>}\n actions={\n <ResolvedCollectionActions\n parentCollectionSlugs={parentCollectionSlugs ?? EMPTY_ARRAY} parentEntityIds={parentEntityIds ?? EMPTY_ARRAY}\n collection={collection}\n tableController={tableController}\n onMultipleDeleteClick={onMultipleDeleteClick}\n removeUnlinks={isLinkedChildView}\n onNewClick={onNewClick}\n onAddExistingClick={linkedTargetSlug ? selectionDialog.open : undefined}\n openNewDocument={openNewDocument}\n path={path}\n relativePath={getCollectionDataPath(collection)}\n selectionController={usedSelectionController}\n selectionEnabled={activeSelectionEnabled}\n collectionEntitiesCount={docsCount ?? undefined}\n compact={isCompact}\n >\n {pluginToolbarWidgets}\n </ResolvedCollectionActions>\n }\n />\n );\n}\n\n/** The default toolbar, as the element a view draws when it is given none. */\nexport const DEFAULT_TOOLBAR = <CollectionToolbar/>;\n\n/** The toolbar a view was given: the default, a composition, or `null`. */\nexport const CollectionToolbarSlotContext = React.createContext<React.ReactNode>(DEFAULT_TOOLBAR);\n\n/**\n * Draws the view's toolbar. One element for the life of the view, so the\n * toolbar keeps its place in the tree — and the view-mode popover stays open —\n * whichever view is shown below it.\n */\nexport function CollectionToolbarSlot() {\n return <>{React.useContext(CollectionToolbarSlotContext)}</>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiBA,SAAgB,2BAA2B;CAEvC,MAAM,EACF,UACA,kBACA,cACA,qBACA,kBACA,gBACA,mBACA,UACA,WACA,UACA,aACA,mBACA,oBACA,qBACA,wBACA,uBACA,wBACA,2BAnBU,uBAAuB,0BAoBjC;CACJ,OACI,oBAAC,gBAAD;EACc;EACQ;EACJ;EACd,aAAa;EACb,MAAM,mBAAoB,iBAAiB,WAAW,iBAAiB,KAAA,IAAa,aAAa,SAAS,WAAW,aAAa,UAAU,YAAY,aAAa,UAAU,WAAW,KAAA;EAC1L,eAAe,mBAAoB,iBAAiB,WAAW,oBAAoB,KAAA,IAAa,aAAa,SAAS,oBAAoB,aAAa,UAAU,qBAAqB,aAAa,UAAU,cAAc,KAAA;EAC3N,MAAM;EACN,cAAc;EACS;EACC;EACA;CAC3B,CAAA;AAET;;;;;;AAOA,SAAgB,sBAAsB;CAClC,MAAM,EAAE,oBAAoB,uBAAuB,qBAAqB;CACxE,MAAM,EAAE,MAAM,eAAe;CAC7B,IAAI,CAAC,gBAAgB,iBAAiB,OAAO;CAC7C,OACI,oBAAC,WAAD;EACI,MAAM;EACN,aAAa,EAAE,QAAQ;EACvB,cAAc,gBAAgB;EAC9B,YAAY;EACZ,cAAc,gBAAgB;CAAc,CAAA;AAExD;;;;;;;AAQA,SAAgB,0BAA0B;CACtC,MAAM,EAAE,iBAAiB,oBAAoB,YAAY,cAA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D,IAAa,+BAA+B,MAAM,cAA+B,eAAe;;;;;;AAOhG,SAAgB,wBAAwB;CACpC,OAAO,oBAAA,UAAA,EAAA,UAAG,MAAM,WAAW,4BAA4B,EAAI,CAAA;AAC/D"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { EntityTableController,
|
|
2
|
+
import { EntityTableController, EntitySelectionController, AdminCollection } from "@rebasepro/cms-types";
|
|
3
3
|
export type CollectionViewActionsProps<M extends Record<string, unknown>> = {
|
|
4
4
|
collection: AdminCollection<M>;
|
|
5
5
|
path: string;
|
|
@@ -19,7 +19,7 @@ export type CollectionViewActionsProps<M extends Record<string, unknown>> = {
|
|
|
19
19
|
* them unlinks them from this record and deletes nothing. The bin says so.
|
|
20
20
|
*/
|
|
21
21
|
removeUnlinks?: boolean;
|
|
22
|
-
selectionController:
|
|
22
|
+
selectionController: EntitySelectionController<M>;
|
|
23
23
|
tableController: EntityTableController<M>;
|
|
24
24
|
collectionEntitiesCount?: number;
|
|
25
25
|
compact?: boolean;
|
|
@@ -2,41 +2,30 @@ import { useAdminContext } from "../../hooks/useAdminContext.js";
|
|
|
2
2
|
import { useToolbarLabels } from "../CollectionTableBinding/internal/CollectionTableToolbar.js";
|
|
3
3
|
import { useCollectionEditorController } from "../../collection_editor/useCollectionEditorController.js";
|
|
4
4
|
import { EditorCollectionAction } from "../../collection_editor/ui/EditorCollectionAction.js";
|
|
5
|
+
import { CollectionAddButton } from "./CollectionAddButton.js";
|
|
5
6
|
import React, { Suspense } from "react";
|
|
6
7
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
-
import { Button, ErrorBoundary, IconButton, Link2Icon, MoreVerticalIcon,
|
|
8
|
-
import { resolveComponentRef,
|
|
8
|
+
import { Button, ErrorBoundary, IconButton, Link2Icon, MoreVerticalIcon, Popover, Tooltip, Trash2Icon, Unlink2Icon, iconSize, lazyChunk } from "@rebasepro/ui";
|
|
9
|
+
import { resolveComponentRef, selectionControllerOf, tableControllerOf, usePermissions, useSlot, useTranslation } from "@rebasepro/app";
|
|
9
10
|
import { toArray } from "@rebasepro/utils";
|
|
10
11
|
//#region src/components/CollectionViewBinding/CollectionViewActions.tsx
|
|
11
12
|
var ImportCollectionAction = lazyChunk(() => import("../../data_import/import/index.js").then((m) => ({ default: m.ImportCollectionAction })));
|
|
12
13
|
var ExportCollectionAction = lazyChunk(() => import("../../data_export/export/index.js").then((m) => ({ default: m.ExportCollectionAction })));
|
|
13
14
|
function CollectionViewActions({ collection, relativePath, parentCollectionSlugs, parentEntityIds, onNewClick, onAddExistingClick, onMultipleDeleteClick, removeUnlinks, selectionEnabled, path, selectionController, tableController, collectionEntitiesCount, compact, children, openNewDocument }) {
|
|
14
15
|
const context = useAdminContext();
|
|
15
|
-
const {
|
|
16
|
-
const largeLayout = useLargeLayout();
|
|
16
|
+
const { canDelete } = usePermissions();
|
|
17
17
|
const toolbarLabels = useToolbarLabels();
|
|
18
|
-
const labelled =
|
|
18
|
+
const labelled = !compact && toolbarLabels;
|
|
19
19
|
const { t } = useTranslation();
|
|
20
20
|
const collectionEditorController = useCollectionEditorController();
|
|
21
21
|
const hasCollectionEditor = Boolean(collectionEditorController?.editCollection);
|
|
22
22
|
const { selectedCount, hasSelection } = selectionController;
|
|
23
|
-
const addButton =
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
startIcon: /* @__PURE__ */ jsx(PlusIcon, { size: iconSize.small }),
|
|
27
|
-
size: "small",
|
|
28
|
-
variant: "filled",
|
|
29
|
-
color: "primary",
|
|
30
|
-
children: t("add_specific", { name: collection.singularName ?? collection.name })
|
|
31
|
-
}) : /* @__PURE__ */ jsx(IconButton, {
|
|
32
|
-
id: `add_entity_${path}`,
|
|
23
|
+
const addButton = onNewClick && /* @__PURE__ */ jsx(CollectionAddButton, {
|
|
24
|
+
collection,
|
|
25
|
+
path,
|
|
33
26
|
onClick: onNewClick,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
size: "small",
|
|
37
|
-
"aria-label": t("add_specific", { name: collection.singularName ?? collection.name }),
|
|
38
|
-
children: /* @__PURE__ */ jsx(PlusIcon, { size: iconSize.small })
|
|
39
|
-
}));
|
|
27
|
+
compact: Boolean(compact)
|
|
28
|
+
});
|
|
40
29
|
const linkButton = onAddExistingClick && (labelled ? /* @__PURE__ */ jsx(Button, {
|
|
41
30
|
id: `link_entity_${path}`,
|
|
42
31
|
onClick: onAddExistingClick,
|
|
@@ -61,8 +50,10 @@ function CollectionViewActions({ collection, relativePath, parentCollectionSlugs
|
|
|
61
50
|
let multipleDeleteButton;
|
|
62
51
|
if (hasSelection) {
|
|
63
52
|
const RemoveIcon = removeUnlinks ? Unlink2Icon : Trash2Icon;
|
|
53
|
+
const actionLabel = removeUnlinks ? t("remove_from_record") : t("delete_selected");
|
|
64
54
|
const button = labelled ? /* @__PURE__ */ jsxs(Button, {
|
|
65
55
|
variant: "text",
|
|
56
|
+
"aria-label": `${actionLabel} (${countLabel})`,
|
|
66
57
|
disabled: !multipleDeleteEnabled,
|
|
67
58
|
startIcon: /* @__PURE__ */ jsx(RemoveIcon, {
|
|
68
59
|
size: iconSize.small,
|
|
@@ -70,14 +61,14 @@ function CollectionViewActions({ collection, relativePath, parentCollectionSlugs
|
|
|
70
61
|
}),
|
|
71
62
|
onClick: onMultipleDeleteClick,
|
|
72
63
|
color: "neutral",
|
|
73
|
-
className: "
|
|
64
|
+
className: "@5xl/collection:min-w-20",
|
|
74
65
|
children: [
|
|
75
66
|
"(",
|
|
76
67
|
countLabel,
|
|
77
68
|
")"
|
|
78
69
|
]
|
|
79
70
|
}) : /* @__PURE__ */ jsx(IconButton, {
|
|
80
|
-
"aria-label":
|
|
71
|
+
"aria-label": actionLabel,
|
|
81
72
|
size: "small",
|
|
82
73
|
disabled: !multipleDeleteEnabled,
|
|
83
74
|
onClick: onMultipleDeleteClick,
|
|
@@ -88,7 +79,7 @@ function CollectionViewActions({ collection, relativePath, parentCollectionSlugs
|
|
|
88
79
|
children: button
|
|
89
80
|
});
|
|
90
81
|
}
|
|
91
|
-
const
|
|
82
|
+
const builtInActionProps = {
|
|
92
83
|
path,
|
|
93
84
|
relativePath,
|
|
94
85
|
parentCollectionSlugs,
|
|
@@ -100,6 +91,11 @@ function CollectionViewActions({ collection, relativePath, parentCollectionSlugs
|
|
|
100
91
|
collectionEntitiesCount,
|
|
101
92
|
openNewDocument
|
|
102
93
|
};
|
|
94
|
+
const actionProps = {
|
|
95
|
+
...builtInActionProps,
|
|
96
|
+
selectionController: selectionControllerOf(selectionController, collection, path),
|
|
97
|
+
tableController: tableControllerOf(tableController, collection)
|
|
98
|
+
};
|
|
103
99
|
const secondaryActions = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
104
100
|
children,
|
|
105
101
|
/* @__PURE__ */ jsxs(ErrorBoundary, { children: [toArray(collection.Actions).map((actionRef, i) => {
|
|
@@ -116,9 +112,9 @@ function CollectionViewActions({ collection, relativePath, parentCollectionSlugs
|
|
|
116
112
|
}) }),
|
|
117
113
|
collection.exportable !== false && /* @__PURE__ */ jsx(ErrorBoundary, { children: /* @__PURE__ */ jsx(Suspense, {
|
|
118
114
|
fallback: null,
|
|
119
|
-
children: /* @__PURE__ */ jsx(ExportCollectionAction, { ...
|
|
115
|
+
children: /* @__PURE__ */ jsx(ExportCollectionAction, { ...builtInActionProps })
|
|
120
116
|
}) }),
|
|
121
|
-
hasCollectionEditor && /* @__PURE__ */ jsx(ErrorBoundary, { children: /* @__PURE__ */ jsx(EditorCollectionAction, { ...
|
|
117
|
+
hasCollectionEditor && /* @__PURE__ */ jsx(ErrorBoundary, { children: /* @__PURE__ */ jsx(EditorCollectionAction, { ...builtInActionProps }) })
|
|
122
118
|
] });
|
|
123
119
|
const [overflowOpen, setOverflowOpen] = React.useState(false);
|
|
124
120
|
return /* @__PURE__ */ jsxs("div", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CollectionViewActions.js","names":[],"sources":["../../../src/components/CollectionViewBinding/CollectionViewActions.tsx"],"sourcesContent":["\n\nimport React, { Suspense } from \"react\";\n\nimport { useLargeLayout, useTranslation, useSlot, resolveComponentRef } from \"@rebasepro/app\";\nimport { CollectionActionsProps, EntityTableController, SelectionController, AdminCollection } from \"@rebasepro/cms-types\";\nimport { Button, IconButton, Tooltip, Popover, iconSize, lazyChunk } from \"@rebasepro/ui\";\nimport { ErrorBoundary, Link2Icon, MoreVerticalIcon, PlusIcon, Trash2Icon, Unlink2Icon } from \"@rebasepro/ui\";\nimport { usePermissions } from \"@rebasepro/app\";\nimport { toArray } from \"@rebasepro/utils\";\n// Lazy-load import/export — pulls in exceljs only on demand\nconst ImportCollectionAction = lazyChunk(() => import(\"../../data_import/import\").then(m => ({ default: m.ImportCollectionAction })));\nconst ExportCollectionAction = lazyChunk(() => import(\"../../data_export/export\").then(m => ({ default: m.ExportCollectionAction })));\nimport { EditorCollectionAction } from \"../../collection_editor/ui/EditorCollectionAction\";\nimport { useCollectionEditorController } from \"../../collection_editor/useCollectionEditorController\";\nimport { useAdminContext } from \"../../hooks/useAdminContext\";\nimport { useToolbarLabels } from \"../CollectionTableBinding/internal/CollectionTableToolbar\";\n\nexport type CollectionViewActionsProps<M extends Record<string, unknown>> = {\n collection: AdminCollection<M>;\n path: string;\n relativePath: string;\n parentCollectionSlugs: string[], parentEntityIds: string[];\n selectionEnabled: boolean;\n onNewClick: () => void;\n /**\n * Attach a row that already exists to this parent. Only supplied for a\n * junction-backed tab, where the parent owns the link rather than the row.\n */\n onAddExistingClick?: () => void;\n onMultipleDeleteClick: () => void;\n /**\n * The rows are shared with other records through a junction, so removing\n * them unlinks them from this record and deletes nothing. The bin says so.\n */\n removeUnlinks?: boolean;\n selectionController: SelectionController<M>;\n tableController: EntityTableController<M>;\n collectionEntitiesCount?: number;\n compact?: boolean;\n children?: React.ReactNode;\n openNewDocument: (defaultValues?: Record<string, unknown>) => void;\n}\n\nexport function CollectionViewActions<M extends Record<string, unknown>>({\n collection,\n relativePath,\n parentCollectionSlugs, parentEntityIds,\n onNewClick,\n onAddExistingClick,\n onMultipleDeleteClick,\n removeUnlinks,\n selectionEnabled,\n path,\n selectionController,\n tableController,\n collectionEntitiesCount,\n compact,\n children,\n openNewDocument\n}: CollectionViewActionsProps<M>) {\n const context = useAdminContext();\n\n const { canCreate, canDelete } = usePermissions();\n\n const largeLayout = useLargeLayout();\n const toolbarLabels = useToolbarLabels();\n // Labelled controls on a wide layout whose toolbar has room for them;\n // their icon-only forms otherwise.\n const labelled = largeLayout && !compact && toolbarLabels;\n const { t } = useTranslation();\n\n // Check if the collection editor context is available (ConfigControllerProvider present)\n const collectionEditorController = useCollectionEditorController();\n const hasCollectionEditor = Boolean(collectionEditorController?.editCollection);\n\n const { selectedCount, hasSelection } = selectionController;\n\n const addButton = canCreate(collection, path) &&\n onNewClick && (labelled\n ? <Button\n id={`add_entity_${path}`}\n onClick={onNewClick}\n startIcon={<PlusIcon size={iconSize.small}/>}\n size=\"small\"\n variant=\"filled\"\n color=\"primary\">\n {t(\"add_specific\", { name: collection.singularName ?? collection.name })}\n </Button>\n // In the compact split-list toolbar the add action is the one filled\n // control: a rounded square, so it reads as a button and not a badge.\n : <IconButton\n id={`add_entity_${path}`}\n onClick={onNewClick}\n variant=\"filled\"\n shape=\"square\"\n size=\"small\"\n aria-label={t(\"add_specific\", { name: collection.singularName ?? collection.name })}\n >\n <PlusIcon size={iconSize.small}/>\n </IconButton>);\n\n // On a junction-backed tab, creating a row is only half of what \"add\" means:\n // the far more common act is attaching one that already exists. There was no\n // way to do that at all — the junction row was only ever written alongside an\n // insert — so a shared vocabulary could only ever grow.\n const linkButton = onAddExistingClick && (labelled\n ? <Button\n id={`link_entity_${path}`}\n onClick={onAddExistingClick}\n startIcon={<Link2Icon size={iconSize.small}/>}\n size=\"small\"\n variant=\"outlined\"\n color=\"neutral\">\n {t(\"add_existing\")}\n </Button>\n : <Tooltip title={t(\"add_existing\")}>\n <Button\n id={`link_entity_${path}`}\n onClick={onAddExistingClick}\n variant=\"outlined\"\n color=\"neutral\"\n size=\"small\">\n <Link2Icon size={iconSize.small}/>\n </Button>\n </Tooltip>);\n\n const multipleDeleteEnabled = canDelete(collection, path, null);\n\n // Only once something is selected. A permanently-disabled bin sat in every\n // collection toolbar — and in the split view, where the toolbar is a narrow\n // strip above the list, it was a third of the visible controls doing\n // nothing. It appears the moment you tick a row, which is when you want it.\n\n // `undefined` is \"every matching row, and nobody knows how many\" — a full\n // selection against an accessor with no `count`. Rendering it as 0 would\n // say the opposite of what is true.\n const countLabel = selectedCount === undefined ? \"…\" : selectedCount.toLocaleString();\n\n let multipleDeleteButton: React.ReactNode | undefined;\n if (hasSelection) {\n const RemoveIcon = removeUnlinks ? Unlink2Icon : Trash2Icon;\n const button = labelled\n // `min-w`, not `w`. A fixed 80px was enough for the one- and\n // two-digit counts you could reach by ticking rows; \"select all\n // matching\" put six digits in here, and a flex child over its width\n // compresses — so the bin itself was what gave way, shrinking to a\n // sliver beside the number. The width is a floor now, so the\n // control still holds its place in the toolbar when the count is\n // short, and `shrink-0` means the icon can never be the thing that\n // gives.\n ? <Button\n variant={\"text\"}\n disabled={!multipleDeleteEnabled}\n startIcon={<RemoveIcon size={iconSize.small} className={\"shrink-0\"}/>}\n onClick={onMultipleDeleteClick}\n color={\"neutral\"}\n className=\"lg:min-w-20\"\n >\n ({countLabel})\n </Button>\n : <IconButton aria-label={t(\"delete_selected\")}\n size={\"small\"}\n disabled={!multipleDeleteEnabled}\n onClick={onMultipleDeleteClick}>\n <RemoveIcon size={iconSize.small}/>\n </IconButton>;\n multipleDeleteButton =\n <Tooltip\n title={multipleDeleteEnabled\n ? (removeUnlinks ? t(\"remove_from_record\") : t(\"delete\"))\n : t(\"delete_not_allowed\")}>\n {button}\n </Tooltip>\n }\n\n const actionProps: CollectionActionsProps<M> = {\n path,\n relativePath,\n parentCollectionSlugs,\nparentEntityIds,\n collection,\n selectionController,\n context,\n tableController,\n collectionEntitiesCount,\n openNewDocument\n };\n\n const actions = toArray(collection.Actions)\n .map((actionRef, i) => {\n const Action = resolveComponentRef(actionRef);\n if (!Action) return null;\n return (\n <ErrorBoundary key={`actions_${i}`}>\n <Suspense fallback={null}>\n <Action {...actionProps}/>\n </Suspense>\n </ErrorBoundary>\n );\n });\n\n const pluginActions = useSlot(\"collection.actions\", actionProps as CollectionActionsProps);\n\n const secondaryActions = (\n <>\n {children}\n <ErrorBoundary>\n {actions}\n {pluginActions}\n </ErrorBoundary>\n <ErrorBoundary>\n <Suspense fallback={null}>\n <ImportCollectionAction {...(actionProps as CollectionActionsProps)}/>\n </Suspense>\n </ErrorBoundary>\n {collection.exportable !== false && (\n <ErrorBoundary>\n <Suspense fallback={null}>\n <ExportCollectionAction {...(actionProps as CollectionActionsProps)}/>\n </Suspense>\n </ErrorBoundary>\n )}\n {hasCollectionEditor && (\n <ErrorBoundary>\n <EditorCollectionAction {...(actionProps as CollectionActionsProps)}/>\n </ErrorBoundary>\n )}\n </>\n );\n\n const [overflowOpen, setOverflowOpen] = React.useState(false);\n\n return (\n <div className=\"flex items-center gap-1\">\n {!compact ? (\n secondaryActions\n ) : (\n <Popover\n open={overflowOpen}\n onOpenChange={setOverflowOpen}\n trigger={\n <IconButton aria-label={t(\"more_actions\")} size=\"small\">\n <MoreVerticalIcon size={iconSize.smallest}/>\n </IconButton>\n }>\n <div className=\"flex flex-row items-center gap-1 p-2\">\n {secondaryActions}\n </div>\n </Popover>\n )}\n {multipleDeleteButton}\n {linkButton}\n {addButton}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;AAWA,IAAM,yBAAyB,gBAAgB,OAAO,oCAA2B,CAAC,MAAK,OAAM,EAAE,SAAS,EAAE,uBAAuB,EAAE,CAAC;AACpI,IAAM,yBAAyB,gBAAgB,OAAO,oCAA2B,CAAC,MAAK,OAAM,EAAE,SAAS,EAAE,uBAAuB,EAAE,CAAC;AAgCpI,SAAgB,sBAAyD,EACrE,YACA,cACA,uBAAuB,iBACvB,YACA,oBACA,uBACA,eAC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oBAAC,eAAD,EAAA,UACI,oBAAC,UAAD;GAAU,UAAU;aAChB,oBAAC,wBAAD,EAAwB,GAAK,YAAwC,CAAA;EAC/D,CAAA,EACC,CAAA;EAElB,uBACG,oBAAC,eAAD,EAAA,UACI,oBAAC,wBAAD,EAAwB,GAAK,YAAwC,CAAA,EAC1D,CAAA;CAErB,EAAA,CAAA;CAGN,MAAM,CAAC,cAAc,mBAAmB,MAAM,SAAS,KAAK;CAE5D,OACI,qBAAC,OAAD;EAAK,WAAU;YAAf;GACK,CAAC,UACE,mBAEA,oBAAC,SAAD;IACI,MAAM;IACN,cAAc;IACd,SACI,oBAAC,YAAD;KAAY,cAAY,EAAE,cAAc;KAAG,MAAK;eAC5C,oBAAC,kBAAD,EAAkB,MAAM,SAAS,SAAU,CAAA;IACnC,CAAA;cAEhB,oBAAC,OAAD;KAAK,WAAU;eACV;IACA,CAAA;GACA,CAAA;GAEZ;GACA;GACA;EACA;;AAEb"}
|
|
1
|
+
{"version":3,"file":"CollectionViewActions.js","names":[],"sources":["../../../src/components/CollectionViewBinding/CollectionViewActions.tsx"],"sourcesContent":["\n\nimport React, { Suspense } from \"react\";\n\nimport { useTranslation, useSlot, resolveComponentRef } from \"@rebasepro/app\";\nimport { CollectionActionsProps, EntityTableController, EntitySelectionController, AdminCollection } from \"@rebasepro/cms-types\";\nimport { Button, IconButton, Tooltip, Popover, iconSize, lazyChunk } from \"@rebasepro/ui\";\nimport { ErrorBoundary, Link2Icon, MoreVerticalIcon, Trash2Icon, Unlink2Icon } from \"@rebasepro/ui\";\nimport { usePermissions } from \"@rebasepro/app\";\nimport { toArray } from \"@rebasepro/utils\";\n// Lazy-load import/export — pulls in exceljs only on demand\nconst ImportCollectionAction = lazyChunk(() => import(\"../../data_import/import\").then(m => ({ default: m.ImportCollectionAction })));\nconst ExportCollectionAction = lazyChunk(() => import(\"../../data_export/export\").then(m => ({ default: m.ExportCollectionAction })));\nimport { EditorCollectionAction } from \"../../collection_editor/ui/EditorCollectionAction\";\nimport { useCollectionEditorController } from \"../../collection_editor/useCollectionEditorController\";\nimport { useAdminContext } from \"../../hooks/useAdminContext\";\nimport { useToolbarLabels } from \"../CollectionTableBinding/internal/CollectionTableToolbar\";\nimport { CollectionAddButton } from \"./CollectionAddButton\";\nimport { selectionControllerOf, tableControllerOf } from \"@rebasepro/app\";\n\nexport type CollectionViewActionsProps<M extends Record<string, unknown>> = {\n collection: AdminCollection<M>;\n path: string;\n relativePath: string;\n parentCollectionSlugs: string[], parentEntityIds: string[];\n selectionEnabled: boolean;\n onNewClick: () => void;\n /**\n * Attach a row that already exists to this parent. Only supplied for a\n * junction-backed tab, where the parent owns the link rather than the row.\n */\n onAddExistingClick?: () => void;\n onMultipleDeleteClick: () => void;\n /**\n * The rows are shared with other records through a junction, so removing\n * them unlinks them from this record and deletes nothing. The bin says so.\n */\n removeUnlinks?: boolean;\n selectionController: EntitySelectionController<M>;\n tableController: EntityTableController<M>;\n collectionEntitiesCount?: number;\n compact?: boolean;\n children?: React.ReactNode;\n openNewDocument: (defaultValues?: Record<string, unknown>) => void;\n}\n\nexport function CollectionViewActions<M extends Record<string, unknown>>({\n collection,\n relativePath,\n parentCollectionSlugs, parentEntityIds,\n onNewClick,\n onAddExistingClick,\n onMultipleDeleteClick,\n removeUnlinks,\n selectionEnabled,\n path,\n selectionController,\n tableController,\n collectionEntitiesCount,\n compact,\n children,\n openNewDocument\n}: CollectionViewActionsProps<M>) {\n const context = useAdminContext();\n\n const { canDelete } = usePermissions();\n\n const toolbarLabels = useToolbarLabels();\n // Labelled controls where the toolbar has room for them — a wide view\n // and labels that fit; their icon-only forms otherwise.\n const labelled = !compact && toolbarLabels;\n const { t } = useTranslation();\n\n // Check if the collection editor context is available (ConfigControllerProvider present)\n const collectionEditorController = useCollectionEditorController();\n const hasCollectionEditor = Boolean(collectionEditorController?.editCollection);\n\n const { selectedCount, hasSelection } = selectionController;\n\n const addButton = onNewClick &&\n <CollectionAddButton collection={collection} path={path} onClick={onNewClick} compact={Boolean(compact)}/>;\n\n // On a junction-backed tab, creating a row is only half of what \"add\" means:\n // the far more common act is attaching one that already exists. There was no\n // way to do that at all — the junction row was only ever written alongside an\n // insert — so a shared vocabulary could only ever grow.\n const linkButton = onAddExistingClick && (labelled\n ? <Button\n id={`link_entity_${path}`}\n onClick={onAddExistingClick}\n startIcon={<Link2Icon size={iconSize.small}/>}\n size=\"small\"\n variant=\"outlined\"\n color=\"neutral\">\n {t(\"add_existing\")}\n </Button>\n : <Tooltip title={t(\"add_existing\")}>\n <Button\n id={`link_entity_${path}`}\n onClick={onAddExistingClick}\n variant=\"outlined\"\n color=\"neutral\"\n size=\"small\">\n <Link2Icon size={iconSize.small}/>\n </Button>\n </Tooltip>);\n\n const multipleDeleteEnabled = canDelete(collection, path, null);\n\n // Only once something is selected. A permanently-disabled bin sat in every\n // collection toolbar — and in the split view, where the toolbar is a narrow\n // strip above the list, it was a third of the visible controls doing\n // nothing. It appears the moment you tick a row, which is when you want it.\n\n // `undefined` is \"every matching row, and nobody knows how many\" — a full\n // selection against an accessor with no `count`. Rendering it as 0 would\n // say the opposite of what is true.\n const countLabel = selectedCount === undefined ? \"…\" : selectedCount.toLocaleString();\n\n let multipleDeleteButton: React.ReactNode | undefined;\n if (hasSelection) {\n const RemoveIcon = removeUnlinks ? Unlink2Icon : Trash2Icon;\n // What the button does, in both forms. The labelled one's only text is\n // the count, so without it a screen reader announced \"(1)\".\n const actionLabel = removeUnlinks ? t(\"remove_from_record\") : t(\"delete_selected\");\n const button = labelled\n // `min-w`, not `w`. A fixed 80px was enough for the one- and\n // two-digit counts you could reach by ticking rows; \"select all\n // matching\" put six digits in here, and a flex child over its width\n // compresses — so the bin itself was what gave way, shrinking to a\n // sliver beside the number. The width is a floor now, so the\n // control still holds its place in the toolbar when the count is\n // short, and `shrink-0` means the icon can never be the thing that\n // gives.\n ? <Button\n variant={\"text\"}\n aria-label={`${actionLabel} (${countLabel})`}\n disabled={!multipleDeleteEnabled}\n startIcon={<RemoveIcon size={iconSize.small} className={\"shrink-0\"}/>}\n onClick={onMultipleDeleteClick}\n color={\"neutral\"}\n className=\"@5xl/collection:min-w-20\"\n >\n ({countLabel})\n </Button>\n : <IconButton aria-label={actionLabel}\n size={\"small\"}\n disabled={!multipleDeleteEnabled}\n onClick={onMultipleDeleteClick}>\n <RemoveIcon size={iconSize.small}/>\n </IconButton>;\n multipleDeleteButton =\n <Tooltip\n title={multipleDeleteEnabled\n ? (removeUnlinks ? t(\"remove_from_record\") : t(\"delete\"))\n : t(\"delete_not_allowed\")}>\n {button}\n </Tooltip>\n }\n\n // The admin's own actions read the records; an app's are handed rows.\n const builtInActionProps = {\n path,\n relativePath,\n parentCollectionSlugs,\n parentEntityIds,\n collection,\n selectionController,\n context,\n tableController,\n collectionEntitiesCount,\n openNewDocument\n };\n const actionProps: CollectionActionsProps<M> = {\n ...builtInActionProps,\n selectionController: selectionControllerOf(selectionController, collection, path),\n tableController: tableControllerOf(tableController, collection)\n };\n\n const actions = toArray(collection.Actions)\n .map((actionRef, i) => {\n const Action = resolveComponentRef(actionRef);\n if (!Action) return null;\n return (\n <ErrorBoundary key={`actions_${i}`}>\n <Suspense fallback={null}>\n <Action {...actionProps}/>\n </Suspense>\n </ErrorBoundary>\n );\n });\n\n const pluginActions = useSlot(\"collection.actions\", actionProps as CollectionActionsProps);\n\n const secondaryActions = (\n <>\n {children}\n <ErrorBoundary>\n {actions}\n {pluginActions}\n </ErrorBoundary>\n <ErrorBoundary>\n <Suspense fallback={null}>\n <ImportCollectionAction {...(actionProps as CollectionActionsProps)}/>\n </Suspense>\n </ErrorBoundary>\n {collection.exportable !== false && (\n <ErrorBoundary>\n <Suspense fallback={null}>\n <ExportCollectionAction {...builtInActionProps}/>\n </Suspense>\n </ErrorBoundary>\n )}\n {hasCollectionEditor && (\n <ErrorBoundary>\n <EditorCollectionAction {...builtInActionProps}/>\n </ErrorBoundary>\n )}\n </>\n );\n\n const [overflowOpen, setOverflowOpen] = React.useState(false);\n\n return (\n <div className=\"flex items-center gap-1\">\n {!compact ? (\n secondaryActions\n ) : (\n <Popover\n open={overflowOpen}\n onOpenChange={setOverflowOpen}\n trigger={\n <IconButton aria-label={t(\"more_actions\")} size=\"small\">\n <MoreVerticalIcon size={iconSize.smallest}/>\n </IconButton>\n }>\n <div className=\"flex flex-row items-center gap-1 p-2\">\n {secondaryActions}\n </div>\n </Popover>\n )}\n {multipleDeleteButton}\n {linkButton}\n {addButton}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;AAWA,IAAM,yBAAyB,gBAAgB,OAAO,oCAA2B,CAAC,MAAK,OAAM,EAAE,SAAS,EAAE,uBAAuB,EAAE,CAAC;AACpI,IAAM,yBAAyB,gBAAgB,OAAO,oCAA2B,CAAC,MAAK,OAAM,EAAE,SAAS,EAAE,uBAAuB,EAAE,CAAC;AAkCpI,SAAgB,sBAAyD,EACrE,YACA,cACA,uBAAuB,iBACvB,YACA,oBACA,uBACA,eACA,kBACA,MACA,qBACA,iBACA,yBACA,SACA,UACA,mBAC8B;CAC9B,MAAM,UAAU,gBAAgB;CAEhC,MAAM,EAAE,cAAc,eAAe;CAErC,MAAM,gBAAgB,iBAAiB;CAGvC,MAAM,WAAW,CAAC,WAAW;CAC7B,MAAM,EAAE,MAAM,eAAe;CAG7B,MAAM,6BAA6B,8BAA8B;CACjE,MAAM,sBAAsB,QAAQ,4BAA4B,cAAc;CAE9E,MAAM,EAAE,eAAe,iBAAiB;CAExC,MAAM,YAAY,cACd,oBAAC,qBAAD;EAAiC;EAAkB;EAAM,SAAS;EAAY,SAAS,QAAQ,OAAO;CAAG,CAAA;CAM7G,MAAM,aAAa,uBAAuB,WACpC,oBAAC,QAAD;EACE,IAAI,eAAe;EACnB,SAAS;EACT,WAAW,oBAAC,WAAD,EAAW,MAAM,SAAS,MAAO,CAAA;EAC5C,MAAK;EACL,SAAQ;EACR,OAAM;YACL,EAAE,cAAc;CACb,CAAA,IACN,oBAAC,SAAD;EAAS,OAAO,EAAE,cAAc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AS;GAC5C,IAAI,CAAC,QAAQ,OAAO;GACpB,OACI,oBAAC,eAAD,EAAA,UACI,oBAAC,UAAD;IAAU,UAAU;cAChB,oBAAC,QAAD,EAAQ,GAAI,YAAa,CAAA;GACnB,CAAA,EACC,GAJK,WAAW,GAIhB;EAEvB,CAQS,GANS,QAAQ,sBAAsB,WAOvC,CACU,EAAA,CAAA;EACf,oBAAC,eAAD,EAAA,UACI,oBAAC,UAAD;GAAU,UAAU;aAChB,oBAAC,wBAAD,EAAwB,GAAK,YAAwC,CAAA;EAC/D,CAAA,EACC,CAAA;EACd,WAAW,eAAe,SACvB,oBAAC,eAAD,EAAA,UACI,oBAAC,UAAD;GAAU,UAAU;aAChB,oBAAC,wBAAD,EAAwB,GAAI,mBAAoB,CAAA;EAC1C,CAAA,EACC,CAAA;EAElB,uBACG,oBAAC,eAAD,EAAA,UACI,oBAAC,wBAAD,EAAwB,GAAI,mBAAoB,CAAA,EACrC,CAAA;CAErB,EAAA,CAAA;CAGN,MAAM,CAAC,cAAc,mBAAmB,MAAM,SAAS,KAAK;CAE5D,OACI,qBAAC,OAAD;EAAK,WAAU;YAAf;GACK,CAAC,UACE,mBAEA,oBAAC,SAAD;IACI,MAAM;IACN,cAAc;IACd,SACI,oBAAC,YAAD;KAAY,cAAY,EAAE,cAAc;KAAG,MAAK;eAC5C,oBAAC,kBAAD,EAAkB,MAAM,SAAS,SAAU,CAAA;IACnC,CAAA;cAEhB,oBAAC,OAAD;KAAK,WAAU;eACV;IACA,CAAA;GACA,CAAA;GAEZ;GACA;GACA;EACA;;AAEb"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { AdminCollection } from "@rebasepro/cms-types";
|
|
3
|
-
import { FilterValues } from "@rebasepro/types";
|
|
1
|
+
import type { AdminCollection, ViewMode } from "@rebasepro/cms-types";
|
|
4
2
|
import React from "react";
|
|
3
|
+
export { EntitiesCount } from "./EntitiesCount.js";
|
|
5
4
|
/**
|
|
6
5
|
* @group Components
|
|
7
6
|
*/
|
|
@@ -42,26 +41,63 @@ export type CollectionViewBindingProps<M extends Record<string, unknown>> = {
|
|
|
42
41
|
* in the entity detail panel. Used by the router to pass the subcollection from the URL.
|
|
43
42
|
*/
|
|
44
43
|
selectedTab?: string;
|
|
45
|
-
} & AdminCollection<M>;
|
|
46
|
-
export declare const CollectionViewBinding: React.FunctionComponent<CollectionViewBindingProps<any>>;
|
|
47
|
-
export declare function EntitiesCount({ path, collection, filter, sortBy, searchString, onCountChange, refreshKey }: {
|
|
48
|
-
path: string;
|
|
49
|
-
collection: AdminCollection;
|
|
50
|
-
filter?: FilterValues<any>;
|
|
51
|
-
sortBy?: OrderByTuple[];
|
|
52
44
|
/**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
45
|
+
* What this view changes about the collection it draws — a fixed filter,
|
|
46
|
+
* a default view mode, a sort — applied over the registered collection.
|
|
47
|
+
*
|
|
48
|
+
* The collection's own props are not that: where the path is registered
|
|
49
|
+
* the view draws the registry's copy, which carries the user's saved
|
|
50
|
+
* overrides and the plugins' changes, and the props are only its fallback.
|
|
51
|
+
* `CollectionPanel`'s `viewMode`, `sort`, `limit` and `collectionOverrides`
|
|
52
|
+
* arrive here; spread onto the props, they were dropped for every
|
|
53
|
+
* registered collection.
|
|
54
|
+
*/
|
|
55
|
+
collectionOverrides?: Partial<AdminCollection<M>>;
|
|
56
|
+
/**
|
|
57
|
+
* The ids of the rows drawn as selected, where the caller decides which
|
|
58
|
+
* they are — a page that shows the opened row beside the list. `[]`
|
|
59
|
+
* draws none. Without it the view highlights the row last opened, by
|
|
60
|
+
* itself.
|
|
61
|
+
*/
|
|
62
|
+
highlightedIds?: (string | number)[];
|
|
63
|
+
/**
|
|
64
|
+
* The properties this view shows, in this order; the ones it leaves out
|
|
65
|
+
* are not drawn. In the table they are the columns. In the list, on a card
|
|
66
|
+
* and on a kanban card they are what the row's or card's places — title,
|
|
67
|
+
* image, subtitle, status, date, relation chips, the list's columns — are
|
|
68
|
+
* filled from, earlier ones first; a place none of them fills stays empty.
|
|
69
|
+
*
|
|
70
|
+
* Over `propertiesOrder`, the order the user saved, `listProperties` and
|
|
71
|
+
* what the cards infer, for this view only. Column widths the user drags
|
|
72
|
+
* still persist; the column order is the caller's, so columns are not
|
|
73
|
+
* dragged. A property hidden from collections stays hidden, and a custom
|
|
74
|
+
* view is handed the whole collection.
|
|
75
|
+
*/
|
|
76
|
+
fields?: string[];
|
|
77
|
+
/**
|
|
78
|
+
* The mode this view opens in, over the one in the URL and the one the
|
|
79
|
+
* person last picked. They can still switch.
|
|
80
|
+
*/
|
|
81
|
+
viewMode?: ViewMode;
|
|
82
|
+
/**
|
|
83
|
+
* The title the list view draws above its rows; `false` draws none.
|
|
84
|
+
* Defaults to the collection's name.
|
|
58
85
|
*/
|
|
59
|
-
|
|
60
|
-
onCountChange?: (count: number | null | undefined) => void;
|
|
86
|
+
title?: string | false;
|
|
61
87
|
/**
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
88
|
+
* The toolbar drawn above the rows. Defaults to the full toolbar —
|
|
89
|
+
* `<CollectionToolbar/>`; `null` draws none. Compose a smaller one from
|
|
90
|
+
* its pieces: `CollectionSearchBar`, `CollectionFiltersButton`,
|
|
91
|
+
* `CollectionViewModeToggle`, `CollectionAddButton`.
|
|
65
92
|
*/
|
|
66
|
-
|
|
67
|
-
|
|
93
|
+
toolbar?: React.ReactNode;
|
|
94
|
+
/**
|
|
95
|
+
* Called with the row and its id when one is clicked, instead of the
|
|
96
|
+
* view opening it. Without it the record opens as the collection's
|
|
97
|
+
* `openEntityMode` says. The row is the server's, as `useRows` returns
|
|
98
|
+
* it; the id is the string `highlightedIds` and `useSidePanel().open`
|
|
99
|
+
* take.
|
|
100
|
+
*/
|
|
101
|
+
onRowClick?: (row: Record<string, unknown>, id: string) => void;
|
|
102
|
+
} & AdminCollection<M>;
|
|
103
|
+
export declare const CollectionViewBinding: React.FunctionComponent<CollectionViewBindingProps<any>>;
|