@rebasepro/cms 0.28.1 → 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
|
@@ -27,8 +27,9 @@ export interface CollectionTableToolbarProps {
|
|
|
27
27
|
*
|
|
28
28
|
* Decided by the toolbar's own width, not the window's: a relation tab beside
|
|
29
29
|
* the split list is a narrow toolbar in a wide window, and its labelled
|
|
30
|
-
* controls overflowed the left group and were drawn over the search bar.
|
|
31
|
-
*
|
|
30
|
+
* controls overflowed the left group and were drawn over the search bar. And
|
|
31
|
+
* by the collection view's: a view narrower than its large layout draws its
|
|
32
|
+
* controls icon-only, as a phone does. `true` outside a toolbar.
|
|
32
33
|
*/
|
|
33
34
|
export declare function useToolbarLabels(): boolean;
|
|
34
35
|
export declare function CollectionTableToolbar({ actions, actionsStart, loading, onTextSearch, title, viewModeToggle, initialSearchText, compact }: CollectionTableToolbarProps): React.JSX.Element;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { useCollectionLargeLayout } from "../../CollectionViewBinding/useCollectionLargeLayout.js";
|
|
1
2
|
import React, { useContext, useLayoutEffect, useRef, useState } from "react";
|
|
2
3
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
4
|
import { CircularProgress, SearchBar, cls } from "@rebasepro/ui";
|
|
4
|
-
import {
|
|
5
|
+
import { useTranslation } from "@rebasepro/app";
|
|
5
6
|
//#region src/components/CollectionTableBinding/internal/CollectionTableToolbar.tsx
|
|
6
7
|
var ToolbarLabelsContext = React.createContext(true);
|
|
7
8
|
/**
|
|
@@ -10,8 +11,9 @@ var ToolbarLabelsContext = React.createContext(true);
|
|
|
10
11
|
*
|
|
11
12
|
* Decided by the toolbar's own width, not the window's: a relation tab beside
|
|
12
13
|
* the split list is a narrow toolbar in a wide window, and its labelled
|
|
13
|
-
* controls overflowed the left group and were drawn over the search bar.
|
|
14
|
-
*
|
|
14
|
+
* controls overflowed the left group and were drawn over the search bar. And
|
|
15
|
+
* by the collection view's: a view narrower than its large layout draws its
|
|
16
|
+
* controls icon-only, as a phone does. `true` outside a toolbar.
|
|
15
17
|
*/
|
|
16
18
|
function useToolbarLabels() {
|
|
17
19
|
return useContext(ToolbarLabelsContext);
|
|
@@ -54,7 +56,7 @@ function useLabelsFit(container, row) {
|
|
|
54
56
|
return labelled;
|
|
55
57
|
}
|
|
56
58
|
function CollectionTableToolbar({ actions, actionsStart, loading, onTextSearch, title, viewModeToggle, initialSearchText, compact = false }) {
|
|
57
|
-
const largeLayout =
|
|
59
|
+
const largeLayout = useCollectionLargeLayout();
|
|
58
60
|
const { t } = useTranslation();
|
|
59
61
|
const containerRef = useRef(null);
|
|
60
62
|
const rowRef = useRef(null);
|
|
@@ -67,11 +69,11 @@ function CollectionTableToolbar({ actions, actionsStart, loading, onTextSearch,
|
|
|
67
69
|
className: cls("no-scrollbar min-h-[52px] overflow-x-auto bg-surface-sheet flex w-full"),
|
|
68
70
|
children: /* @__PURE__ */ jsx("div", {
|
|
69
71
|
ref: rowRef,
|
|
70
|
-
className: "px-2
|
|
72
|
+
className: "px-2 @3xl/collection:px-4 flex flex-row justify-between items-center min-w-full w-max",
|
|
71
73
|
children: /* @__PURE__ */ jsxs(ToolbarLabelsContext.Provider, {
|
|
72
|
-
value: labelled,
|
|
74
|
+
value: labelled && largeLayout,
|
|
73
75
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
74
|
-
className: "flex items-center gap-1
|
|
76
|
+
className: "flex items-center gap-1 @3xl/collection:mr-4 mr-2",
|
|
75
77
|
children: [
|
|
76
78
|
!compact && viewModeToggle,
|
|
77
79
|
title && /* @__PURE__ */ jsx("div", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CollectionTableToolbar.js","names":[],"sources":["../../../../src/components/CollectionTableBinding/internal/CollectionTableToolbar.tsx"],"sourcesContent":["import React, { useContext, useLayoutEffect, useRef, useState } from \"react\";\n\nimport { CircularProgress, cls, SearchBar } from \"@rebasepro/ui\";\nimport {
|
|
1
|
+
{"version":3,"file":"CollectionTableToolbar.js","names":[],"sources":["../../../../src/components/CollectionTableBinding/internal/CollectionTableToolbar.tsx"],"sourcesContent":["import React, { useContext, useLayoutEffect, useRef, useState } from \"react\";\n\nimport { CircularProgress, cls, SearchBar } from \"@rebasepro/ui\";\nimport { useTranslation } from \"@rebasepro/app\";\nimport { useCollectionLargeLayout } from \"../../CollectionViewBinding/useCollectionLargeLayout\";\n\nexport interface CollectionTableToolbarProps {\n loading: boolean;\n actionsStart?: React.ReactNode;\n actions?: React.ReactNode;\n /**\n * View mode toggle button, positioned left of the search bar.\n */\n viewModeToggle?: React.ReactNode;\n title?: React.ReactNode,\n onTextSearch?: (searchString?: string) => void;\n /**\n * Initial search string to pre-populate the search bar (e.g. from URL params).\n */\n initialSearchText?: string;\n /**\n * When true the toolbar is in \"compact\" mode for the split-view left panel.\n * - Search bar, loading spinner, and view-mode toggle are hidden.\n * - Secondary actions remain inline (displayed horizontally).\n * - Only `actionsStart` (filters) and the add button (last child of `actions`) remain visible.\n */\n compact?: boolean;\n}\n\nconst ToolbarLabelsContext = React.createContext(true);\n\n/**\n * Whether the toolbar this control sits in has room for its controls' labels\n * (\"Filters\", \"Add existing\", \"Add Tag\"), or wants their icon-only forms.\n *\n * Decided by the toolbar's own width, not the window's: a relation tab beside\n * the split list is a narrow toolbar in a wide window, and its labelled\n * controls overflowed the left group and were drawn over the search bar. And\n * by the collection view's: a view narrower than its large layout draws its\n * controls icon-only, as a phone does. `true` outside a toolbar.\n */\nexport function useToolbarLabels(): boolean {\n return useContext(ToolbarLabelsContext);\n}\n\n/**\n * Whether `row` — the toolbar's controls at their natural width — fits in\n * `container`. Once it has not, the width the labelled controls needed is kept,\n * and the labels come back only when the container has that much room again:\n * measured on the icon-only row, they would always seem to fit.\n */\nfunction useLabelsFit(\n container: React.RefObject<HTMLDivElement | null>,\n row: React.RefObject<HTMLDivElement | null>\n): boolean {\n const [labelled, setLabelled] = useState(true);\n const labelledRef = useRef(true);\n const labelledWidth = useRef<number | undefined>(undefined);\n\n useLayoutEffect(() => {\n const containerElement = container.current;\n const rowElement = row.current;\n if (!containerElement || !rowElement || typeof ResizeObserver === \"undefined\") return undefined;\n\n const measure = () => {\n const available = containerElement.clientWidth;\n let next = labelledRef.current;\n if (labelledRef.current) {\n const needed = rowElement.scrollWidth;\n if (needed > available + 1) {\n labelledWidth.current = needed;\n next = false;\n }\n } else if (labelledWidth.current !== undefined && available >= labelledWidth.current) {\n next = true;\n }\n if (next !== labelledRef.current) {\n labelledRef.current = next;\n setLabelled(next);\n }\n };\n\n // The container for the room there is, the row for what the controls\n // take — a selection count appearing widens the row, not the toolbar.\n const observer = new ResizeObserver(measure);\n observer.observe(containerElement);\n observer.observe(rowElement);\n measure();\n return () => observer.disconnect();\n }, [container, row]);\n\n return labelled;\n}\n\nexport function CollectionTableToolbar({\n actions,\n actionsStart,\n loading,\n onTextSearch,\n title,\n viewModeToggle,\n initialSearchText,\n compact = false\n}: CollectionTableToolbarProps) {\n\n const largeLayout = useCollectionLargeLayout();\n const { t } = useTranslation();\n\n const containerRef = useRef<HTMLDivElement>(null);\n const rowRef = useRef<HTMLDivElement>(null);\n const labelled = useLabelsFit(containerRef, rowRef);\n\n // Split actions into \"primary\" (add button = last child) and \"secondary\" (everything else)\n const actionChildren = React.Children.toArray(actions);\n const addButton = actionChildren.length > 0 ? actionChildren[actionChildren.length - 1] : null;\n const secondaryActions = actionChildren.slice(0, -1);\n\n return (\n <div\n ref={containerRef}\n className={cls(\"no-scrollbar min-h-[52px] overflow-x-auto bg-surface-sheet flex w-full\")}>\n\n {/* At least as wide as the toolbar, and never narrower than its\n controls: the two groups cannot be squeezed into each other.\n When even the icon-only controls do not fit, the toolbar\n scrolls. */}\n <div\n ref={rowRef}\n className={\"px-2 @3xl/collection:px-4 flex flex-row justify-between items-center min-w-full w-max\"}>\n\n <ToolbarLabelsContext.Provider value={labelled && largeLayout}>\n\n <div className=\"flex items-center gap-1 @3xl/collection:mr-4 mr-2\">\n\n {/* View toggle — hidden in compact */}\n {!compact && viewModeToggle}\n\n {title && <div className={\"flex items-center\"}>\n {title}\n </div>}\n\n {actionsStart}\n\n </div>\n\n <div className=\"flex items-center gap-1\">\n\n {/* Loading spinner — hidden in compact */}\n {largeLayout && !compact && loading && (\n <div className=\"mr-4\">\n <CircularProgress size={\"smallest\"}/>\n </div>\n )}\n\n {/* Search bar — hidden in compact */}\n {!compact && onTextSearch &&\n <SearchBar\n key={\"search-bar\"}\n size={\"small\"}\n placeholder={t(\"search\")}\n onTextSearch={onTextSearch}\n expandable={true}\n initialValue={initialSearchText}/>}\n\n {/* Secondary actions — always inline */}\n <div className=\"flex items-center gap-1\">\n {secondaryActions}\n </div>\n\n {/* Add button — always visible */}\n {addButton}\n\n </div>\n\n </ToolbarLabelsContext.Provider>\n\n </div>\n\n </div>\n );\n}\n"],"mappings":";;;;;;AA6BA,IAAM,uBAAuB,MAAM,cAAc,IAAI;;;;;;;;;;;AAYrD,SAAgB,mBAA4B;CACxC,OAAO,WAAW,oBAAoB;AAC1C;;;;;;;AAQA,SAAS,aACL,WACA,KACO;CACP,MAAM,CAAC,UAAU,eAAe,SAAS,IAAI;CAC7C,MAAM,cAAc,OAAO,IAAI;CAC/B,MAAM,gBAAgB,OAA2B,KAAA,CAAS;CAE1D,sBAAsB;EAClB,MAAM,mBAAmB,UAAU;EACnC,MAAM,aAAa,IAAI;EACvB,IAAI,CAAC,oBAAoB,CAAC,cAAc,OAAO,mBAAmB,aAAa,OAAO,KAAA;EAEtF,MAAM,gBAAgB;GAClB,MAAM,YAAY,iBAAiB;GACnC,IAAI,OAAO,YAAY;GACvB,IAAI,YAAY,SAAS;IACrB,MAAM,SAAS,WAAW;IAC1B,IAAI,SAAS,YAAY,GAAG;KACxB,cAAc,UAAU;KACxB,OAAO;IACX;GACJ,OAAO,IAAI,cAAc,YAAY,KAAA,KAAa,aAAa,cAAc,SACzE,OAAO;GAEX,IAAI,SAAS,YAAY,SAAS;IAC9B,YAAY,UAAU;IACtB,YAAY,IAAI;GACpB;EACJ;EAIA,MAAM,WAAW,IAAI,eAAe,OAAO;EAC3C,SAAS,QAAQ,gBAAgB;EACjC,SAAS,QAAQ,UAAU;EAC3B,QAAQ;EACR,aAAa,SAAS,WAAW;CACrC,GAAG,CAAC,WAAW,GAAG,CAAC;CAEnB,OAAO;AACX;AAEA,SAAgB,uBAAuB,EACnC,SACA,cACA,SACA,cACA,OACA,gBACA,mBACA,UAAU,SACkB;CAE5B,MAAM,cAAc,yBAAyB;CAC7C,MAAM,EAAE,MAAM,eAAe;CAE7B,MAAM,eAAe,OAAuB,IAAI;CAChD,MAAM,SAAS,OAAuB,IAAI;CAC1C,MAAM,WAAW,aAAa,cAAc,MAAM;CAGlD,MAAM,iBAAiB,MAAM,SAAS,QAAQ,OAAO;CACrD,MAAM,YAAY,eAAe,SAAS,IAAI,eAAe,eAAe,SAAS,KAAK;CAC1F,MAAM,mBAAmB,eAAe,MAAM,GAAG,EAAE;CAEnD,OACI,oBAAC,OAAD;EACI,KAAK;EACL,WAAW,IAAI,wEAAwE;YAMvF,oBAAC,OAAD;GACI,KAAK;GACL,WAAW;aAEX,qBAAC,qBAAqB,UAAtB;IAA+B,OAAO,YAAY;cAAlD,CAEI,qBAAC,OAAD;KAAK,WAAU;eAAf;MAGK,CAAC,WAAW;MAEZ,SAAS,oBAAC,OAAD;OAAK,WAAW;iBACrB;MACA,CAAA;MAEJ;KAEA;QAEL,qBAAC,OAAD;KAAK,WAAU;eAAf;MAGK,eAAe,CAAC,WAAW,WACxB,oBAAC,OAAD;OAAK,WAAU;iBACX,oBAAC,kBAAD,EAAkB,MAAM,WAAY,CAAA;MACnC,CAAA;MAIR,CAAC,WAAW,gBACT,oBAAC,WAAD;OAEI,MAAM;OACN,aAAa,EAAE,QAAQ;OACT;OACd,YAAY;OACZ,cAAc;MAAmB,GAL5B,YAK4B;MAGzC,oBAAC,OAAD;OAAK,WAAU;iBACV;MACA,CAAA;MAGJ;KAEA;MAEsB;;EAE9B,CAAA;CAEJ,CAAA;AAEb"}
|
|
@@ -1,5 +1,29 @@
|
|
|
1
|
-
import type { Property } from "@rebasepro/types";
|
|
1
|
+
import type { DateProperty, Property } from "@rebasepro/types";
|
|
2
2
|
import type { AdminCollection } from "@rebasepro/cms-types";
|
|
3
|
+
import { DatePreviewFormatOptions } from "../../../preview/components/DatePreview.js";
|
|
4
|
+
/**
|
|
5
|
+
* What a date cell is formatted with, beyond the property itself: the admin's
|
|
6
|
+
* locale and format. Without it a column is sized for the defaults.
|
|
7
|
+
*/
|
|
8
|
+
export type DateColumnFormatting = Pick<DatePreviewFormatOptions, "locale" | "dateTimeFormat" | "dateFnsLocale"> & {
|
|
9
|
+
/**
|
|
10
|
+
* Whether the cell is the date input (inline editing on, property not
|
|
11
|
+
* read-only) rather than the formatted preview. The input draws the
|
|
12
|
+
* browser's short numeric form, whatever the admin's format says.
|
|
13
|
+
*/
|
|
14
|
+
editable?: boolean;
|
|
15
|
+
};
|
|
3
16
|
export declare function getTableCellAlignment(property: Property): "right" | "left" | "center";
|
|
4
|
-
export declare function getTablePropertyColumnWidth(property: Property): number;
|
|
17
|
+
export declare function getTablePropertyColumnWidth(property: Property, dateFormatting?: DateColumnFormatting): number;
|
|
18
|
+
/**
|
|
19
|
+
* A date column wide enough for its widest value on one line.
|
|
20
|
+
*
|
|
21
|
+
* It used to be a flat 200px, and the default format — "November 06, 2026,
|
|
22
|
+
* 23:32:05", 27 mono characters at 8.4px — needs 227px before the cell's own
|
|
23
|
+
* padding. Every date wrapped after its year, and at the text sizes (xs–m) the
|
|
24
|
+
* row has room for one line, so what showed was the bottom of one line and
|
|
25
|
+
* the top of the next. The width now comes from formatting real dates exactly
|
|
26
|
+
* as the cell will (`formatDatePreview`), in the admin's locale and format.
|
|
27
|
+
*/
|
|
28
|
+
export declare function getDateColumnWidth(property: DateProperty, formatting?: DateColumnFormatting): number;
|
|
5
29
|
export declare function getSubcollectionColumnId(collection: AdminCollection): string;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { getDatePropertyMode, getDatePropertyTimezone } from "../../../preview/util.js";
|
|
2
|
+
import { formatDatePreview } from "../../../preview/components/DatePreview.js";
|
|
1
3
|
//#region src/components/CollectionTableBinding/internal/common.tsx
|
|
2
4
|
function getTableCellAlignment(property) {
|
|
3
5
|
if (property.type === "boolean") return "center";
|
|
@@ -7,7 +9,7 @@ function getTableCellAlignment(property) {
|
|
|
7
9
|
} else if (property.type === "date") return "right";
|
|
8
10
|
else return "left";
|
|
9
11
|
}
|
|
10
|
-
function getTablePropertyColumnWidth(property) {
|
|
12
|
+
function getTablePropertyColumnWidth(property, dateFormatting) {
|
|
11
13
|
if (property.admin?.columnWidth) return property.admin?.columnWidth;
|
|
12
14
|
if (property.type === "string") if (property.admin?.urlPreview) return 280;
|
|
13
15
|
else if (property.storage) return 160;
|
|
@@ -19,22 +21,104 @@ function getTablePropertyColumnWidth(property) {
|
|
|
19
21
|
else if (property.type === "array") {
|
|
20
22
|
const arrayProperty = property;
|
|
21
23
|
if (arrayProperty.of) if (Array.isArray(property.of)) return 300;
|
|
22
|
-
else return getTablePropertyColumnWidth(arrayProperty.of);
|
|
24
|
+
else return getTablePropertyColumnWidth(arrayProperty.of, dateFormatting);
|
|
23
25
|
else return 300;
|
|
24
26
|
} else if (property.type === "number") {
|
|
25
27
|
if (property.enum) return 200;
|
|
26
28
|
return 140;
|
|
27
29
|
} else if (property.type === "map") return 360;
|
|
28
|
-
else if (property.type === "date") return
|
|
30
|
+
else if (property.type === "date") return getDateColumnWidth(property, dateFormatting);
|
|
29
31
|
else if (property.type === "reference") return 220;
|
|
30
32
|
else if (property.type === "relation") return 280;
|
|
31
33
|
else if (property.type === "boolean") return 140;
|
|
32
34
|
else return 200;
|
|
33
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* What a table cell spends around its content at the roomiest size: the 4px
|
|
38
|
+
* border plus `p-4` (l and xl), on both sides. Sized for the roomiest so a
|
|
39
|
+
* column fits at every size without changing width when the size does.
|
|
40
|
+
*/
|
|
41
|
+
var CELL_CHROME_WIDTH = 40;
|
|
42
|
+
/** An editable cell's native input: `dd/mm/yyyy, --:--` and the picker. */
|
|
43
|
+
var EDITABLE_DATE_COLUMN_WIDTH = 200;
|
|
44
|
+
/** Never narrower than this: the header's title, sort and filter need room too. */
|
|
45
|
+
var MIN_DATE_COLUMN_WIDTH = 140;
|
|
46
|
+
/** A row's text (`text-sm`) and the zone after a zoned date (`text-xs`). */
|
|
47
|
+
var CELL_FONT_SIZE = 14;
|
|
48
|
+
var ZONE_FONT_SIZE = 12;
|
|
49
|
+
/** `gap-1` between a zoned date and its zone. */
|
|
50
|
+
var ZONE_GAP = 4;
|
|
51
|
+
/** Every mono face in `--font-mono` advances 0.6em per character. */
|
|
52
|
+
var MONO_ADVANCE = .6;
|
|
53
|
+
var measureContext;
|
|
54
|
+
/**
|
|
55
|
+
* The width of `text` in the mono tier, as the browser will draw it.
|
|
56
|
+
*
|
|
57
|
+
* Measured, not counted, where a canvas exists: a locale's month names may be
|
|
58
|
+
* in a script the mono face does not cover, and the fallback face it lands in
|
|
59
|
+
* is not 0.6em wide. Counted elsewhere (tests, SSR).
|
|
60
|
+
*/
|
|
61
|
+
function measureMonoText(text, fontSize) {
|
|
62
|
+
if (measureContext === void 0) measureContext = typeof document !== "undefined" ? document.createElement("canvas").getContext("2d") : null;
|
|
63
|
+
if (!measureContext) return text.length * fontSize * MONO_ADVANCE;
|
|
64
|
+
const family = getComputedStyle(document.documentElement).getPropertyValue("--font-mono").trim() || "monospace";
|
|
65
|
+
measureContext.font = `${fontSize}px ${family}`;
|
|
66
|
+
return measureContext.measureText(text).width;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Dates covering every month and weekday, at a two-digit day and the
|
|
70
|
+
* two-digit hours of both clocks (23:58, 11:58 PM): the widest a format can
|
|
71
|
+
* get is the widest of these, whatever its locale names the months and days.
|
|
72
|
+
*/
|
|
73
|
+
var WIDEST_DATE_SAMPLES = Array.from({ length: 84 }, (_, i) => new Date(2026, Math.floor(i / 7), 22 + i % 7, 23, 58, 58));
|
|
74
|
+
var dateColumnWidths = /* @__PURE__ */ new Map();
|
|
75
|
+
/**
|
|
76
|
+
* A date column wide enough for its widest value on one line.
|
|
77
|
+
*
|
|
78
|
+
* It used to be a flat 200px, and the default format — "November 06, 2026,
|
|
79
|
+
* 23:32:05", 27 mono characters at 8.4px — needs 227px before the cell's own
|
|
80
|
+
* padding. Every date wrapped after its year, and at the text sizes (xs–m) the
|
|
81
|
+
* row has room for one line, so what showed was the bottom of one line and
|
|
82
|
+
* the top of the next. The width now comes from formatting real dates exactly
|
|
83
|
+
* as the cell will (`formatDatePreview`), in the admin's locale and format.
|
|
84
|
+
*/
|
|
85
|
+
function getDateColumnWidth(property, formatting) {
|
|
86
|
+
if (formatting?.editable) return EDITABLE_DATE_COLUMN_WIDTH;
|
|
87
|
+
const options = {
|
|
88
|
+
locale: formatting?.locale,
|
|
89
|
+
dateTimeFormat: formatting?.dateTimeFormat,
|
|
90
|
+
dateFnsLocale: formatting?.dateFnsLocale,
|
|
91
|
+
mode: getDatePropertyMode(property),
|
|
92
|
+
timezone: getDatePropertyTimezone(property)
|
|
93
|
+
};
|
|
94
|
+
const key = [
|
|
95
|
+
options.mode,
|
|
96
|
+
options.timezone,
|
|
97
|
+
options.locale,
|
|
98
|
+
options.dateTimeFormat,
|
|
99
|
+
options.dateFnsLocale?.code
|
|
100
|
+
].join("|");
|
|
101
|
+
const cached = dateColumnWidths.get(key);
|
|
102
|
+
if (cached !== void 0) return cached;
|
|
103
|
+
let widest = 0;
|
|
104
|
+
try {
|
|
105
|
+
for (const date of WIDEST_DATE_SAMPLES) {
|
|
106
|
+
const { text, zone } = formatDatePreview(date, options);
|
|
107
|
+
const width = measureMonoText(text, CELL_FONT_SIZE) + (zone ? ZONE_GAP + measureMonoText(`(${zone})`, ZONE_FONT_SIZE) : 0);
|
|
108
|
+
widest = Math.max(widest, width);
|
|
109
|
+
}
|
|
110
|
+
} catch (error) {
|
|
111
|
+
console.warn("Could not measure a date column", error);
|
|
112
|
+
return 200;
|
|
113
|
+
}
|
|
114
|
+
const width = Math.max(MIN_DATE_COLUMN_WIDTH, Math.ceil((widest + 1 + CELL_CHROME_WIDTH) / 4) * 4);
|
|
115
|
+
dateColumnWidths.set(key, width);
|
|
116
|
+
return width;
|
|
117
|
+
}
|
|
34
118
|
function getSubcollectionColumnId(collection) {
|
|
35
119
|
return `subcollection:${collection.slug}`;
|
|
36
120
|
}
|
|
37
121
|
//#endregion
|
|
38
|
-
export { getSubcollectionColumnId, getTableCellAlignment, getTablePropertyColumnWidth };
|
|
122
|
+
export { getDateColumnWidth, getSubcollectionColumnId, getTableCellAlignment, getTablePropertyColumnWidth };
|
|
39
123
|
|
|
40
124
|
//# sourceMappingURL=common.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","names":[],"sources":["../../../../src/components/CollectionTableBinding/internal/common.tsx"],"sourcesContent":["\nimport type { ArrayProperty, Property } from \"@rebasepro/types\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\n\nexport function getTableCellAlignment(property: Property): \"right\" | \"left\" | \"center\" {\n if (property.type === \"boolean\") {\n return \"center\";\n } else if (property.type === \"number\") {\n if (property.enum)\n return \"left\";\n return \"right\";\n } else if (property.type === \"date\") {\n return \"right\";\n } else {\n return \"left\";\n }\n}\n\nexport function getTablePropertyColumnWidth(property: Property): number {\n\n if (property.admin?.columnWidth) {\n return property.admin?.columnWidth;\n }\n\n if (property.type === \"string\") {\n if (property.admin?.urlPreview) {\n return 280;\n } else if (property.storage) {\n return 160;\n } else if (property.enum) {\n return 200;\n } else if (property.admin?.multiline) {\n return 300;\n } else if (property.admin?.markdown) {\n return 300;\n } else if (property.email) {\n return 200;\n } else {\n return 200;\n }\n } else if (property.type === \"array\") {\n const arrayProperty = property as ArrayProperty;\n if (arrayProperty.of) {\n if (Array.isArray(property.of)) {\n return 300;\n } else {\n return getTablePropertyColumnWidth(arrayProperty.of as Property);\n }\n } else {\n return 300;\n }\n } else if (property.type === \"number\") {\n if (property.enum) {\n return 200;\n }\n return 140;\n } else if (property.type === \"map\") {\n return 360;\n } else if (property.type === \"date\") {\n return
|
|
1
|
+
{"version":3,"file":"common.js","names":[],"sources":["../../../../src/components/CollectionTableBinding/internal/common.tsx"],"sourcesContent":["\nimport type { ArrayProperty, DateProperty, Property } from \"@rebasepro/types\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\nimport { DatePreviewFormatOptions, formatDatePreview } from \"../../../preview/components/DatePreview\";\nimport { getDatePropertyMode, getDatePropertyTimezone } from \"../../../preview/util\";\n\n/**\n * What a date cell is formatted with, beyond the property itself: the admin's\n * locale and format. Without it a column is sized for the defaults.\n */\nexport type DateColumnFormatting = Pick<DatePreviewFormatOptions, \"locale\" | \"dateTimeFormat\" | \"dateFnsLocale\"> & {\n /**\n * Whether the cell is the date input (inline editing on, property not\n * read-only) rather than the formatted preview. The input draws the\n * browser's short numeric form, whatever the admin's format says.\n */\n editable?: boolean;\n};\n\nexport function getTableCellAlignment(property: Property): \"right\" | \"left\" | \"center\" {\n if (property.type === \"boolean\") {\n return \"center\";\n } else if (property.type === \"number\") {\n if (property.enum)\n return \"left\";\n return \"right\";\n } else if (property.type === \"date\") {\n return \"right\";\n } else {\n return \"left\";\n }\n}\n\nexport function getTablePropertyColumnWidth(property: Property, dateFormatting?: DateColumnFormatting): number {\n\n if (property.admin?.columnWidth) {\n return property.admin?.columnWidth;\n }\n\n if (property.type === \"string\") {\n if (property.admin?.urlPreview) {\n return 280;\n } else if (property.storage) {\n return 160;\n } else if (property.enum) {\n return 200;\n } else if (property.admin?.multiline) {\n return 300;\n } else if (property.admin?.markdown) {\n return 300;\n } else if (property.email) {\n return 200;\n } else {\n return 200;\n }\n } else if (property.type === \"array\") {\n const arrayProperty = property as ArrayProperty;\n if (arrayProperty.of) {\n if (Array.isArray(property.of)) {\n return 300;\n } else {\n return getTablePropertyColumnWidth(arrayProperty.of as Property, dateFormatting);\n }\n } else {\n return 300;\n }\n } else if (property.type === \"number\") {\n if (property.enum) {\n return 200;\n }\n return 140;\n } else if (property.type === \"map\") {\n return 360;\n } else if (property.type === \"date\") {\n return getDateColumnWidth(property, dateFormatting);\n } else if (property.type === \"reference\") {\n return 220;\n } else if (property.type === \"relation\") {\n return 280;\n } else if (property.type === \"boolean\") {\n return 140;\n } else {\n return 200;\n }\n}\n\n/**\n * What a table cell spends around its content at the roomiest size: the 4px\n * border plus `p-4` (l and xl), on both sides. Sized for the roomiest so a\n * column fits at every size without changing width when the size does.\n */\nconst CELL_CHROME_WIDTH = 2 * (4 + 16);\n/** An editable cell's native input: `dd/mm/yyyy, --:--` and the picker. */\nconst EDITABLE_DATE_COLUMN_WIDTH = 200;\n/** Never narrower than this: the header's title, sort and filter need room too. */\nconst MIN_DATE_COLUMN_WIDTH = 140;\n/** A row's text (`text-sm`) and the zone after a zoned date (`text-xs`). */\nconst CELL_FONT_SIZE = 14;\nconst ZONE_FONT_SIZE = 12;\n/** `gap-1` between a zoned date and its zone. */\nconst ZONE_GAP = 4;\n/** Every mono face in `--font-mono` advances 0.6em per character. */\nconst MONO_ADVANCE = 0.6;\n\nlet measureContext: CanvasRenderingContext2D | null | undefined;\n\n/**\n * The width of `text` in the mono tier, as the browser will draw it.\n *\n * Measured, not counted, where a canvas exists: a locale's month names may be\n * in a script the mono face does not cover, and the fallback face it lands in\n * is not 0.6em wide. Counted elsewhere (tests, SSR).\n */\nfunction measureMonoText(text: string, fontSize: number): number {\n if (measureContext === undefined) {\n measureContext = typeof document !== \"undefined\"\n ? document.createElement(\"canvas\").getContext(\"2d\")\n : null;\n }\n if (!measureContext) return text.length * fontSize * MONO_ADVANCE;\n const family = getComputedStyle(document.documentElement).getPropertyValue(\"--font-mono\").trim() || \"monospace\";\n measureContext.font = `${fontSize}px ${family}`;\n return measureContext.measureText(text).width;\n}\n\n/**\n * Dates covering every month and weekday, at a two-digit day and the\n * two-digit hours of both clocks (23:58, 11:58 PM): the widest a format can\n * get is the widest of these, whatever its locale names the months and days.\n */\nconst WIDEST_DATE_SAMPLES: Date[] = Array.from({ length: 12 * 7 }, (_, i) =>\n new Date(2026, Math.floor(i / 7), 22 + i % 7, 23, 58, 58));\n\nconst dateColumnWidths = new Map<string, number>();\n\n/**\n * A date column wide enough for its widest value on one line.\n *\n * It used to be a flat 200px, and the default format — \"November 06, 2026,\n * 23:32:05\", 27 mono characters at 8.4px — needs 227px before the cell's own\n * padding. Every date wrapped after its year, and at the text sizes (xs–m) the\n * row has room for one line, so what showed was the bottom of one line and\n * the top of the next. The width now comes from formatting real dates exactly\n * as the cell will (`formatDatePreview`), in the admin's locale and format.\n */\nexport function getDateColumnWidth(property: DateProperty, formatting?: DateColumnFormatting): number {\n if (formatting?.editable) return EDITABLE_DATE_COLUMN_WIDTH;\n const options: DatePreviewFormatOptions = {\n locale: formatting?.locale,\n dateTimeFormat: formatting?.dateTimeFormat,\n dateFnsLocale: formatting?.dateFnsLocale,\n mode: getDatePropertyMode(property),\n timezone: getDatePropertyTimezone(property)\n };\n const key = [options.mode, options.timezone, options.locale, options.dateTimeFormat, options.dateFnsLocale?.code].join(\"|\");\n const cached = dateColumnWidths.get(key);\n if (cached !== undefined) return cached;\n\n let widest = 0;\n try {\n for (const date of WIDEST_DATE_SAMPLES) {\n const { text, zone } = formatDatePreview(date, options);\n const width = measureMonoText(text, CELL_FONT_SIZE)\n + (zone ? ZONE_GAP + measureMonoText(`(${zone})`, ZONE_FONT_SIZE) : 0);\n widest = Math.max(widest, width);\n }\n } catch (error) {\n // An unknown timezone or a malformed format throws here exactly as it\n // does in the cell, which reports it; the column keeps its old width.\n console.warn(\"Could not measure a date column\", error);\n return 200;\n }\n\n // Rounded up to the 4px grid, with a pixel of slack for subpixel glyphs.\n const width = Math.max(MIN_DATE_COLUMN_WIDTH, Math.ceil((widest + 1 + CELL_CHROME_WIDTH) / 4) * 4);\n dateColumnWidths.set(key, width);\n return width;\n}\n\nexport function getSubcollectionColumnId(collection: AdminCollection) {\n return `subcollection:${collection.slug}`;\n}\n"],"mappings":";;;AAmBA,SAAgB,sBAAsB,UAAiD;CACnF,IAAI,SAAS,SAAS,WAClB,OAAO;MACJ,IAAI,SAAS,SAAS,UAAU;EACnC,IAAI,SAAS,MACT,OAAO;EACX,OAAO;CACX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/B,OAAO;AACX;AAEA,SAAgB,yBAAyB,YAA6B;CAClE,OAAO,iBAAiB,WAAW;AACvC"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { getPropertyInPath as getPropertyInPath$1 } from "../../../../util/property_utils.js";
|
|
2
2
|
import { applyValueTransforms, getEntitySchema } from "../../../../form/validation.js";
|
|
3
3
|
import { PropertyFieldBinding } from "../../../../form/PropertyFieldBinding.js";
|
|
4
|
+
import { cellValidationProperties } from "../../../../form/resolve_cell_property.js";
|
|
4
5
|
import { zodToFormErrors } from "../../../../form/form_utils.js";
|
|
5
6
|
import { useDraggable } from "./useDraggable.js";
|
|
6
|
-
import { cellValidationProperties } from "../../../../form/resolve_cell_property.js";
|
|
7
7
|
import { useWindowSize } from "./useWindowSize.js";
|
|
8
8
|
import React, { useCallback, useEffect, useLayoutEffect, useState } from "react";
|
|
9
9
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
10
10
|
import { Button, DialogActions, IconButton, Portal, Typography, XIcon } from "@rebasepro/ui";
|
|
11
11
|
import { hasEntityId } from "@rebasepro/common";
|
|
12
|
-
import { PluginProviderStack, isDisabled, isReadOnly, useAuthController, useCustomizationController, useData, useRebaseContext, useTranslation } from "@rebasepro/app";
|
|
12
|
+
import { PluginProviderStack, isDisabled, isReadOnly, rowOfEntity, useAuthController, useCustomizationController, useData, useRebaseContext, useTranslation } from "@rebasepro/app";
|
|
13
13
|
import { Formex, getIn, useCreateFormex } from "@rebasepro/forms";
|
|
14
14
|
//#region src/components/CollectionTableBinding/internal/popup_field/PopupFormField.tsx
|
|
15
15
|
function PopupFormField(props) {
|
|
@@ -165,7 +165,8 @@ function PopupFormFieldInternal({ tableKey, entityId, customFieldValidator, prop
|
|
|
165
165
|
const disabled = isSubmitting;
|
|
166
166
|
const formContext = {
|
|
167
167
|
collection,
|
|
168
|
-
entityId,
|
|
168
|
+
id: entityId,
|
|
169
|
+
row: entity ? rowOfEntity(entity, collection) : void 0,
|
|
169
170
|
values,
|
|
170
171
|
path,
|
|
171
172
|
setFieldValue,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PopupFormField.js","names":[],"sources":["../../../../../src/components/CollectionTableBinding/internal/popup_field/PopupFormField.tsx"],"sourcesContent":["import type { Properties } from \"@rebasepro/types\";\nimport { hasEntityId } from \"@rebasepro/common\";\n\nimport type { FormContext, PropertyFieldBindingProps } from \"../../../../types/fields\";\nimport type { Property } from \"@rebasepro/types\";\nimport React, { useCallback, useEffect, useLayoutEffect, useState } from \"react\";\n\nimport { Button, DialogActions, IconButton, Portal, Typography, XIcon } from \"@rebasepro/ui\";\n\nimport { Entity, EntityValues } from \"@rebasepro/types\";\nimport { PluginProviderStack, useTranslation } from \"@rebasepro/app\";\nimport { Formex, FormexController, getIn, useCreateFormex } from \"@rebasepro/forms\";\nimport { useDraggable } from \"./useDraggable\";\nimport { applyValueTransforms, CustomFieldValidator, getEntitySchema } from \"../../../../form/validation\";\nimport { cellValidationProperties } from \"../../../../form/resolve_cell_property\";\nimport { useWindowSize } from \"./useWindowSize\";\nimport { getPropertyInPath } from \"../../../../util/property_utils\";\nimport { PropertyFieldBinding, zodToFormErrors } from \"../../../../form\";\nimport { useAuthController, useCustomizationController, useData, useRebaseContext } from \"@rebasepro/app\";\nimport type { OnCellValueChangeParams } from \"@rebasepro/app\";\nimport { isDisabled, isReadOnly } from \"@rebasepro/app\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\n\ninterface PopupFormFieldProps<M extends Record<string, unknown>> {\n customFieldValidator?: CustomFieldValidator;\n path: string;\n entityId: string | number;\n tableKey: string;\n propertyKey?: Extract<keyof M, string>;\n // `AdminCollection<M>`, not `<any>`: the admin block's key-shaped fields\n // (titleProperty, sort, propertiesOrder) are typed against M, and\n // `AdminCollection<any>` collapses them to `string` — which then fails to\n // flow into the `FormContext<M>` built below.\n collection?: AdminCollection<M>;\n cellRect?: DOMRect;\n open: boolean;\n onClose: () => void;\n container: HTMLElement | null;\n /**\n * Callback when the value of a cell has been edited\n * @param params\n */\n onCellValueChange?: (params: OnCellValueChangeParams<any, any>) => Promise<void> | void;\n}\n\nexport function PopupFormField<M extends Record<string, unknown>>(props: PopupFormFieldProps<M>) {\n if (!props.open) return null;\n return <PopupFormFieldLoading {...props}/>;\n\n}\n\nexport function PopupFormFieldLoading<M extends Record<string, unknown>>({\n tableKey,\n entityId,\n customFieldValidator,\n propertyKey,\n collection: inputCollection,\n path,\n cellRect,\n open,\n onClose,\n onCellValueChange,\n container\n}: PopupFormFieldProps<M>) {\n const dataClient = useData();\n const [entity, setEntity] = useState<Entity<M> | undefined>(undefined);\n useEffect(() => {\n if (hasEntityId(entityId) && inputCollection) {\n dataClient.collection(path).findById(entityId).then((result) => setEntity(result as Entity<M> | undefined));\n }\n }, [entityId, inputCollection, dataClient, path]);\n\n if (!entity) return null;\n return <PopupFormFieldInternal {...{\n tableKey,\n entityId,\n customFieldValidator,\n propertyKey,\n collection: inputCollection,\n path,\n cellRect,\n open,\n onClose,\n onCellValueChange,\n container\n }} entity={entity}/>;\n}\n\nexport function PopupFormFieldInternal<M extends Record<string, unknown>>({\n tableKey,\n entityId,\n customFieldValidator,\n propertyKey,\n collection,\n path,\n cellRect,\n open,\n onClose,\n onCellValueChange,\n container,\n entity\n}: PopupFormFieldProps<M> & {\n entity?: Entity<M>\n}) {\n const { t } = useTranslation();\n\n const rebaseContext = useRebaseContext();\n const authController = useAuthController();\n const customizationController = useCustomizationController();\n\n const [savingError, setSavingError] = React.useState<any>();\n const [popupLocation, setPopupLocation] = useState<{\n x: number,\n y: number\n }>();\n\n const windowSize = useWindowSize();\n\n const draggableRef = React.useRef<HTMLDivElement>(null);\n const innerRef = React.useRef<HTMLDivElement>(null);\n\n const initialPositionSet = React.useRef<boolean>(false);\n\n const getInitialLocation = useCallback(() => {\n if (!cellRect) throw Error(\"getInitialLocation error\");\n\n return {\n x: cellRect.left < windowSize.width - cellRect.right\n ? cellRect.x + cellRect.width / 2\n : cellRect.x - cellRect.width / 2,\n y: cellRect.top < windowSize.height - cellRect.bottom\n ? cellRect.y + cellRect.height / 2\n : cellRect.y - cellRect.height / 2\n };\n }, [cellRect, windowSize.height, windowSize.width]);\n\n const normalizePosition = useCallback((\n pos: { x: number, y: number },\n draggableBoundingRect: DOMRect,\n currentWindowSize: { width: number, height: number }\n ) => {\n if (!draggableBoundingRect || draggableBoundingRect.width === 0 || draggableBoundingRect.height === 0) {\n return pos;\n }\n return {\n x: Math.max(0, Math.min(pos.x, currentWindowSize.width - draggableBoundingRect.width)),\n y: Math.max(0, Math.min(pos.y, currentWindowSize.height - draggableBoundingRect.height))\n };\n }, []);\n\n const updatePopupLocation = useCallback((newPositionCandidate?: {\n x: number,\n y: number\n }) => {\n const draggableBoundingRect = draggableRef.current?.getBoundingClientRect();\n if (!cellRect || !draggableBoundingRect || draggableBoundingRect.width === 0 || draggableBoundingRect.height === 0) {\n return;\n }\n const basePosition = newPositionCandidate ?? getInitialLocation();\n const newNormalizedPosition = normalizePosition(basePosition, draggableBoundingRect, windowSize);\n\n if (!popupLocation || newNormalizedPosition.x !== popupLocation.x || newNormalizedPosition.y !== popupLocation.y) {\n setPopupLocation(newNormalizedPosition);\n }\n }, [cellRect, getInitialLocation, normalizePosition, popupLocation, windowSize]);\n\n useDraggable({\n containerRef: draggableRef,\n innerRef,\n x: popupLocation?.x,\n y: popupLocation?.y,\n onMove: updatePopupLocation\n });\n\n useEffect(\n () => {\n initialPositionSet.current = false;\n },\n [propertyKey, entity]\n );\n\n useLayoutEffect(\n () => {\n if (!cellRect || initialPositionSet.current) return;\n // Ensure draggableRef is available and has dimensions before initial positioning\n const draggableBoundingRect = draggableRef.current?.getBoundingClientRect();\n if (!draggableBoundingRect || draggableBoundingRect.width === 0 || draggableBoundingRect.height === 0) {\n // If not ready, perhaps wait or log. For now, just return.\n // This might need a retry mechanism or ensure content is rendered first.\n return;\n }\n updatePopupLocation();\n initialPositionSet.current = true;\n },\n [cellRect, updatePopupLocation] // Removed initialPositionSet.current from deps as it's a ref\n );\n\n useLayoutEffect(\n () => {\n updatePopupLocation(popupLocation);\n },\n [windowSize, cellRect, updatePopupLocation, popupLocation]\n );\n\n // Built per validation, from the properties resolved against the values\n // the popup holds: a `conditions` rule or a `dynamicProps` validation\n // depends on them, as it does in the record form.\n const validationSchemaFor = (values: Partial<M>) => {\n if (!collection || !hasEntityId(entityId) || !propertyKey) return undefined;\n return getEntitySchema(\n entityId,\n cellValidationProperties<M>(collection.properties, propertyKey as string, values, entity?.values, entityId, {\n path,\n authController,\n propertyConfigs: customizationController.propertyConfigs\n }),\n customFieldValidator);\n };\n\n const adaptResize = useCallback(() => {\n // When the popup resizes, we want to re-evaluate its position\n // based on its current location and new dimensions.\n return updatePopupLocation(popupLocation);\n }, [popupLocation, updatePopupLocation]);\n\n // Setup ResizeObserver\n useEffect(() => {\n const element = draggableRef.current;\n if (!element) return;\n\n const observer = new ResizeObserver(() => {\n adaptResize();\n });\n\n observer.observe(element);\n\n return () => {\n observer.unobserve(element);\n observer.disconnect();\n };\n }, [adaptResize, draggableRef]);\n\n const saveValue = async (values: M) => {\n setSavingError(null);\n if (collection && entity && onCellValueChange && propertyKey) {\n // Written the way the form writes it: with the string transforms\n // the properties declare (`trim`, `lowercase`, `uppercase`) applied.\n const writtenValues = applyValueTransforms(values, collection.properties);\n return onCellValueChange({\n // By path: a spread map's child is `address.street`, which is\n // nested in the form values, not a key of them.\n value: getIn(writtenValues, propertyKey as string),\n propertyKey: propertyKey as string,\n data: entity,\n setError: setSavingError,\n onValueUpdated: () => {\n }\n });\n }\n return Promise.resolve();\n };\n\n const formex = useCreateFormex<M>({\n initialValues: (entity?.values ?? {}) as EntityValues<M>,\n validation: async (values) => {\n const validationSchema = validationSchemaFor(values);\n if (!validationSchema) return {};\n const result = await validationSchema.safeParseAsync(values);\n if (result.success) return {};\n return zodToFormErrors(result.error) as Record<string, string>;\n },\n validateOnInitialRender: true,\n onSubmit: (values, actions) => {\n saveValue(values)\n .then(() => {\n formex.resetForm({\n values: values\n })\n onClose();\n })\n .finally(() => actions.setSubmitting(false));\n }\n });\n\n const {\n values,\n isSubmitting,\n setFieldValue,\n handleSubmit\n } = formex;\n\n const disabled = isSubmitting;\n\n const formContext: FormContext<M> = {\n collection: collection,\n entityId,\n values,\n path,\n setFieldValue,\n save: saveValue,\n submit: handleSubmit,\n formex,\n status: \"existing\",\n openEntityMode: \"side_panel\",\n disabled: false\n };\n\n const property: Property | undefined = propertyKey && getPropertyInPath(collection?.properties ?? {} as Properties, propertyKey as string);\n const fieldProps: PropertyFieldBindingProps<M> | undefined = propertyKey && property\n ? {\n propertyKey: propertyKey as string,\n disabled: isSubmitting || isReadOnly(property) || isDisabled(property),\n property,\n includeDescription: false,\n underlyingValueHasChanged: false,\n context: formContext,\n partOfArray: false,\n minimalistView: true,\n autoFocus: open\n }\n : undefined;\n\n let internalForm = <>\n <div\n key={`popup_form_${tableKey}_${entityId}_${propertyKey}`}\n className=\"w-[700px] max-w-full max-h-[85vh]\">\n <form\n onSubmit={handleSubmit}\n noValidate>\n\n <div\n className=\"mb-1 p-4 flex flex-col relative\">\n <div\n ref={innerRef}\n className=\"cursor-auto\"\n style={{ cursor: \"auto !important\" }}>\n {fieldProps &&\n <PropertyFieldBinding {...fieldProps}/>}\n </div>\n </div>\n\n <DialogActions>\n <Button\n variant=\"filled\"\n color=\"primary\"\n type=\"submit\"\n disabled={disabled}\n >\n Save\n </Button>\n </DialogActions>\n\n </form>\n\n </div>\n\n </>;\n\n const plugins = customizationController.plugins;\n if (plugins && plugins.length > 0) {\n internalForm = (\n <PluginProviderStack\n plugins={plugins}\n scope=\"form\"\n scopeProps={{\n status: \"existing\",\n path,\n collection,\n entity,\n context: rebaseContext,\n currentEntityId: entityId,\n formContext\n }}>\n {internalForm}\n </PluginProviderStack>\n );\n }\n const form = <div\n className={`text-surface-900 dark:text-white overflow-auto rounded-xs rounded-md bg-surface-card ${!open ? \"hidden\" : \"\"} cursor-grab max-w-[100vw]`}>\n\n {internalForm}\n\n {savingError &&\n <Typography color={\"error\"}>\n {savingError.message}\n </Typography>\n }\n </div>;\n\n const draggable = (\n <div\n key={`draggable_${propertyKey as string}_${entityId}_${open}`}\n style={{\n boxShadow: \"0 0 0 2px rgba(128,128,128,0.2)\"\n }}\n className={`inline-block fixed z-20 shadow-outline rounded-md bg-surface-card ${!open ? \"invisible\" : \"visible\"\n } cursor-grab overflow-visible`}\n ref={draggableRef}>\n\n {/* ElementResizeListener removed from here */}\n\n <div\n className=\"overflow-hidden\">\n\n {form}\n\n <div\n className=\"absolute -top-3.5 -right-3.5 bg-surface-500 rounded-full\"\n style={{\n width: \"32px\",\n height: \"32px\"\n }}>\n <IconButton aria-label={t(\"close\")}\n size={\"small\"}\n onClick={(event) => {\n event.stopPropagation();\n onClose();\n }}>\n <XIcon className=\"text-white\"/>\n </IconButton>\n </div>\n </div>\n\n </div>\n );\n\n return (\n <Portal.Root asChild\n container={container}>\n <Formex value={formex as FormexController<Record<string, unknown>>}>\n {draggable}\n </Formex>\n </Portal.Root>\n );\n\n}\n"],"mappings":";;;;;;;;;;;;;;AA6CA,SAAgB,eAAkD,OAA+B;CAC7F,IAAI,CAAC,MAAM,MAAM,OAAO;CACxB,OAAO,oBAAC,uBAAD,EAAuB,GAAI,MAAO,CAAA;AAE7C;AAEA,SAAgB,sBAAyD,EACrE,UACA,UACA,sBACA,aACA,YAAY,iBACZ,MACA,UACA,MACA,SACA,mBACA,aACuB;CACvB,MAAM,aAAa,QAAQ;CAC3B,MAAM,CAAC,QAAQ,aAAa,SAAgC,KAAA,CAAS;CACrE,gBAAgB;EACZ,IAAI,YAAY,QAAQ,KAAK,iBACzB,WAAW,WAAW,IAAI,CAAC,CAAC,SAAS,QAAQ,CAAC,CAAC,MAAM,WAAW,UAAU,MAA+B,CAAC;CAElH,GAAG;EAAC;EAAU;EAAiB;EAAY;CAAI,CAAC;CAEhD,IAAI,CAAC,QAAQ,OAAO;CACpB,OAAO,oBAAC,wBAAD;EAC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MAAM,gBAAgB;MACtB,QAAQ;KACZ;eACA,oBAAC,OAAD,EAAO,WAAU,aAAa,CAAA;IACtB,CAAA;GACX,CAAA,CACJ;;CAEJ,GAhCI,aAAa,YAAsB,GAAG,SAAS,GAAG,MAgCtD;CAGT,OACI,oBAAC,OAAO,MAAR;EAAa,SAAA;EACE;YACX,oBAAC,QAAD;GAAQ,OAAO;aACV;EACG,CAAA;CACC,CAAA;AAGrB"}
|
|
1
|
+
{"version":3,"file":"PopupFormField.js","names":[],"sources":["../../../../../src/components/CollectionTableBinding/internal/popup_field/PopupFormField.tsx"],"sourcesContent":["import type { Properties } from \"@rebasepro/types\";\nimport { hasEntityId } from \"@rebasepro/common\";\n\nimport type { FormContext, PropertyFieldBindingProps } from \"../../../../types/fields\";\nimport type { Property } from \"@rebasepro/types\";\nimport React, { useCallback, useEffect, useLayoutEffect, useState } from \"react\";\n\nimport { Button, DialogActions, IconButton, Portal, Typography, XIcon } from \"@rebasepro/ui\";\n\nimport { Entity, EntityValues } from \"@rebasepro/types\";\nimport { PluginProviderStack, useTranslation } from \"@rebasepro/app\";\nimport { Formex, FormexController, getIn, useCreateFormex } from \"@rebasepro/forms\";\nimport { useDraggable } from \"./useDraggable\";\nimport { applyValueTransforms, CustomFieldValidator, getEntitySchema } from \"../../../../form/validation\";\nimport { cellValidationProperties } from \"../../../../form/resolve_cell_property\";\nimport { useWindowSize } from \"./useWindowSize\";\nimport { getPropertyInPath } from \"../../../../util/property_utils\";\nimport { PropertyFieldBinding, zodToFormErrors } from \"../../../../form\";\nimport { useAuthController, useCustomizationController, useData, useRebaseContext } from \"@rebasepro/app\";\nimport type { OnCellValueChangeParams } from \"@rebasepro/app\";\nimport { isDisabled, isReadOnly } from \"@rebasepro/app\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\nimport { rowOfEntity } from \"@rebasepro/app\";\n\ninterface PopupFormFieldProps<M extends Record<string, unknown>> {\n customFieldValidator?: CustomFieldValidator;\n path: string;\n entityId: string | number;\n tableKey: string;\n propertyKey?: Extract<keyof M, string>;\n // `AdminCollection<M>`, not `<any>`: the admin block's key-shaped fields\n // (titleProperty, sort, propertiesOrder) are typed against M, and\n // `AdminCollection<any>` collapses them to `string` — which then fails to\n // flow into the `FormContext<M>` built below.\n collection?: AdminCollection<M>;\n cellRect?: DOMRect;\n open: boolean;\n onClose: () => void;\n container: HTMLElement | null;\n /**\n * Callback when the value of a cell has been edited\n * @param params\n */\n onCellValueChange?: (params: OnCellValueChangeParams<any, any>) => Promise<void> | void;\n}\n\nexport function PopupFormField<M extends Record<string, unknown>>(props: PopupFormFieldProps<M>) {\n if (!props.open) return null;\n return <PopupFormFieldLoading {...props}/>;\n\n}\n\nexport function PopupFormFieldLoading<M extends Record<string, unknown>>({\n tableKey,\n entityId,\n customFieldValidator,\n propertyKey,\n collection: inputCollection,\n path,\n cellRect,\n open,\n onClose,\n onCellValueChange,\n container\n}: PopupFormFieldProps<M>) {\n const dataClient = useData();\n const [entity, setEntity] = useState<Entity<M> | undefined>(undefined);\n useEffect(() => {\n if (hasEntityId(entityId) && inputCollection) {\n dataClient.collection(path).findById(entityId).then((result) => setEntity(result as Entity<M> | undefined));\n }\n }, [entityId, inputCollection, dataClient, path]);\n\n if (!entity) return null;\n return <PopupFormFieldInternal {...{\n tableKey,\n entityId,\n customFieldValidator,\n propertyKey,\n collection: inputCollection,\n path,\n cellRect,\n open,\n onClose,\n onCellValueChange,\n container\n }} entity={entity}/>;\n}\n\nexport function PopupFormFieldInternal<M extends Record<string, unknown>>({\n tableKey,\n entityId,\n customFieldValidator,\n propertyKey,\n collection,\n path,\n cellRect,\n open,\n onClose,\n onCellValueChange,\n container,\n entity\n}: PopupFormFieldProps<M> & {\n entity?: Entity<M>\n}) {\n const { t } = useTranslation();\n\n const rebaseContext = useRebaseContext();\n const authController = useAuthController();\n const customizationController = useCustomizationController();\n\n const [savingError, setSavingError] = React.useState<any>();\n const [popupLocation, setPopupLocation] = useState<{\n x: number,\n y: number\n }>();\n\n const windowSize = useWindowSize();\n\n const draggableRef = React.useRef<HTMLDivElement>(null);\n const innerRef = React.useRef<HTMLDivElement>(null);\n\n const initialPositionSet = React.useRef<boolean>(false);\n\n const getInitialLocation = useCallback(() => {\n if (!cellRect) throw Error(\"getInitialLocation error\");\n\n return {\n x: cellRect.left < windowSize.width - cellRect.right\n ? cellRect.x + cellRect.width / 2\n : cellRect.x - cellRect.width / 2,\n y: cellRect.top < windowSize.height - cellRect.bottom\n ? cellRect.y + cellRect.height / 2\n : cellRect.y - cellRect.height / 2\n };\n }, [cellRect, windowSize.height, windowSize.width]);\n\n const normalizePosition = useCallback((\n pos: { x: number, y: number },\n draggableBoundingRect: DOMRect,\n currentWindowSize: { width: number, height: number }\n ) => {\n if (!draggableBoundingRect || draggableBoundingRect.width === 0 || draggableBoundingRect.height === 0) {\n return pos;\n }\n return {\n x: Math.max(0, Math.min(pos.x, currentWindowSize.width - draggableBoundingRect.width)),\n y: Math.max(0, Math.min(pos.y, currentWindowSize.height - draggableBoundingRect.height))\n };\n }, []);\n\n const updatePopupLocation = useCallback((newPositionCandidate?: {\n x: number,\n y: number\n }) => {\n const draggableBoundingRect = draggableRef.current?.getBoundingClientRect();\n if (!cellRect || !draggableBoundingRect || draggableBoundingRect.width === 0 || draggableBoundingRect.height === 0) {\n return;\n }\n const basePosition = newPositionCandidate ?? getInitialLocation();\n const newNormalizedPosition = normalizePosition(basePosition, draggableBoundingRect, windowSize);\n\n if (!popupLocation || newNormalizedPosition.x !== popupLocation.x || newNormalizedPosition.y !== popupLocation.y) {\n setPopupLocation(newNormalizedPosition);\n }\n }, [cellRect, getInitialLocation, normalizePosition, popupLocation, windowSize]);\n\n useDraggable({\n containerRef: draggableRef,\n innerRef,\n x: popupLocation?.x,\n y: popupLocation?.y,\n onMove: updatePopupLocation\n });\n\n useEffect(\n () => {\n initialPositionSet.current = false;\n },\n [propertyKey, entity]\n );\n\n useLayoutEffect(\n () => {\n if (!cellRect || initialPositionSet.current) return;\n // Ensure draggableRef is available and has dimensions before initial positioning\n const draggableBoundingRect = draggableRef.current?.getBoundingClientRect();\n if (!draggableBoundingRect || draggableBoundingRect.width === 0 || draggableBoundingRect.height === 0) {\n // If not ready, perhaps wait or log. For now, just return.\n // This might need a retry mechanism or ensure content is rendered first.\n return;\n }\n updatePopupLocation();\n initialPositionSet.current = true;\n },\n [cellRect, updatePopupLocation] // Removed initialPositionSet.current from deps as it's a ref\n );\n\n useLayoutEffect(\n () => {\n updatePopupLocation(popupLocation);\n },\n [windowSize, cellRect, updatePopupLocation, popupLocation]\n );\n\n // Built per validation, from the properties resolved against the values\n // the popup holds: a `conditions` rule or a `dynamicProps` validation\n // depends on them, as it does in the record form.\n const validationSchemaFor = (values: Partial<M>) => {\n if (!collection || !hasEntityId(entityId) || !propertyKey) return undefined;\n return getEntitySchema(\n entityId,\n cellValidationProperties<M>(collection.properties, propertyKey as string, values, entity?.values, entityId, {\n path,\n authController,\n propertyConfigs: customizationController.propertyConfigs\n }),\n customFieldValidator);\n };\n\n const adaptResize = useCallback(() => {\n // When the popup resizes, we want to re-evaluate its position\n // based on its current location and new dimensions.\n return updatePopupLocation(popupLocation);\n }, [popupLocation, updatePopupLocation]);\n\n // Setup ResizeObserver\n useEffect(() => {\n const element = draggableRef.current;\n if (!element) return;\n\n const observer = new ResizeObserver(() => {\n adaptResize();\n });\n\n observer.observe(element);\n\n return () => {\n observer.unobserve(element);\n observer.disconnect();\n };\n }, [adaptResize, draggableRef]);\n\n const saveValue = async (values: M) => {\n setSavingError(null);\n if (collection && entity && onCellValueChange && propertyKey) {\n // Written the way the form writes it: with the string transforms\n // the properties declare (`trim`, `lowercase`, `uppercase`) applied.\n const writtenValues = applyValueTransforms(values, collection.properties);\n return onCellValueChange({\n // By path: a spread map's child is `address.street`, which is\n // nested in the form values, not a key of them.\n value: getIn(writtenValues, propertyKey as string),\n propertyKey: propertyKey as string,\n data: entity,\n setError: setSavingError,\n onValueUpdated: () => {\n }\n });\n }\n return Promise.resolve();\n };\n\n const formex = useCreateFormex<M>({\n initialValues: (entity?.values ?? {}) as EntityValues<M>,\n validation: async (values) => {\n const validationSchema = validationSchemaFor(values);\n if (!validationSchema) return {};\n const result = await validationSchema.safeParseAsync(values);\n if (result.success) return {};\n return zodToFormErrors(result.error) as Record<string, string>;\n },\n validateOnInitialRender: true,\n onSubmit: (values, actions) => {\n saveValue(values)\n .then(() => {\n formex.resetForm({\n values: values\n })\n onClose();\n })\n .finally(() => actions.setSubmitting(false));\n }\n });\n\n const {\n values,\n isSubmitting,\n setFieldValue,\n handleSubmit\n } = formex;\n\n const disabled = isSubmitting;\n\n const formContext: FormContext<M> = {\n collection: collection,\n id: entityId,\n row: entity ? rowOfEntity(entity, collection) : undefined,\n values,\n path,\n setFieldValue,\n save: saveValue,\n submit: handleSubmit,\n formex,\n status: \"existing\",\n openEntityMode: \"side_panel\",\n disabled: false\n };\n\n const property: Property | undefined = propertyKey && getPropertyInPath(collection?.properties ?? {} as Properties, propertyKey as string);\n const fieldProps: PropertyFieldBindingProps<M> | undefined = propertyKey && property\n ? {\n propertyKey: propertyKey as string,\n disabled: isSubmitting || isReadOnly(property) || isDisabled(property),\n property,\n includeDescription: false,\n underlyingValueHasChanged: false,\n context: formContext,\n partOfArray: false,\n minimalistView: true,\n autoFocus: open\n }\n : undefined;\n\n let internalForm = <>\n <div\n key={`popup_form_${tableKey}_${entityId}_${propertyKey}`}\n className=\"w-[700px] max-w-full max-h-[85vh]\">\n <form\n onSubmit={handleSubmit}\n noValidate>\n\n <div\n className=\"mb-1 p-4 flex flex-col relative\">\n <div\n ref={innerRef}\n className=\"cursor-auto\"\n style={{ cursor: \"auto !important\" }}>\n {fieldProps &&\n <PropertyFieldBinding {...fieldProps}/>}\n </div>\n </div>\n\n <DialogActions>\n <Button\n variant=\"filled\"\n color=\"primary\"\n type=\"submit\"\n disabled={disabled}\n >\n Save\n </Button>\n </DialogActions>\n\n </form>\n\n </div>\n\n </>;\n\n const plugins = customizationController.plugins;\n if (plugins && plugins.length > 0) {\n internalForm = (\n <PluginProviderStack\n plugins={plugins}\n scope=\"form\"\n scopeProps={{\n status: \"existing\",\n path,\n collection,\n entity,\n context: rebaseContext,\n currentEntityId: entityId,\n formContext\n }}>\n {internalForm}\n </PluginProviderStack>\n );\n }\n const form = <div\n className={`text-surface-900 dark:text-white overflow-auto rounded-xs rounded-md bg-surface-card ${!open ? \"hidden\" : \"\"} cursor-grab max-w-[100vw]`}>\n\n {internalForm}\n\n {savingError &&\n <Typography color={\"error\"}>\n {savingError.message}\n </Typography>\n }\n </div>;\n\n const draggable = (\n <div\n key={`draggable_${propertyKey as string}_${entityId}_${open}`}\n style={{\n boxShadow: \"0 0 0 2px rgba(128,128,128,0.2)\"\n }}\n className={`inline-block fixed z-20 shadow-outline rounded-md bg-surface-card ${!open ? \"invisible\" : \"visible\"\n } cursor-grab overflow-visible`}\n ref={draggableRef}>\n\n {/* ElementResizeListener removed from here */}\n\n <div\n className=\"overflow-hidden\">\n\n {form}\n\n <div\n className=\"absolute -top-3.5 -right-3.5 bg-surface-500 rounded-full\"\n style={{\n width: \"32px\",\n height: \"32px\"\n }}>\n <IconButton aria-label={t(\"close\")}\n size={\"small\"}\n onClick={(event) => {\n event.stopPropagation();\n onClose();\n }}>\n <XIcon className=\"text-white\"/>\n </IconButton>\n </div>\n </div>\n\n </div>\n );\n\n return (\n <Portal.Root asChild\n container={container}>\n <Formex value={formex as FormexController<Record<string, unknown>>}>\n {draggable}\n </Formex>\n </Portal.Root>\n );\n\n}\n"],"mappings":";;;;;;;;;;;;;;AA8CA,SAAgB,eAAkD,OAA+B;CAC7F,IAAI,CAAC,MAAM,MAAM,OAAO;CACxB,OAAO,oBAAC,uBAAD,EAAuB,GAAI,MAAO,CAAA;AAE7C;AAEA,SAAgB,sBAAyD,EACrE,UACA,UACA,sBACA,aACA,YAAY,iBACZ,MACA,UACA,MACA,SACA,mBACA,aACuB;CACvB,MAAM,aAAa,QAAQ;CAC3B,MAAM,CAAC,QAAQ,a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;aACd,YAAY;EACL,CAAA,CAEf;;CAEL,MAAM,YACF,oBAAC,OAAD;EAEI,OAAO,EACH,WAAW,kCACf;EACA,WAAW,qEAAqE,CAAC,OAAO,cAAc,UACjG;EACL,KAAK;YAIL,qBAAC,OAAD;GACI,WAAU;aADd,CAGK,MAED,oBAAC,OAAD;IACI,WAAU;IACV,OAAO;KACH,OAAO;KACP,QAAQ;IACZ;cACA,oBAAC,YAAD;KAAY,cAAY,EAAE,OAAO;KAC7B,MAAM;KACN,UAAU,UAAU;MAChB,MAAM,gBAAgB;MACtB,QAAQ;KACZ;eACA,oBAAC,OAAD,EAAO,WAAU,aAAa,CAAA;IACtB,CAAA;GACX,CAAA,CACJ;;CAEJ,GAhCI,aAAa,YAAsB,GAAG,SAAS,GAAG,MAgCtD;CAGT,OACI,oBAAC,OAAO,MAAR;EAAa,SAAA;EACE;YACX,oBAAC,QAAD;GAAQ,OAAO;aACV;EACG,CAAA;CACC,CAAA;AAGrB"}
|
|
@@ -8,6 +8,11 @@ export type BoardCardBindingProps<M extends Record<string, unknown> = Record<str
|
|
|
8
8
|
selected?: boolean;
|
|
9
9
|
onSelectionChange?: (entity: Entity<M>, selected: boolean) => void;
|
|
10
10
|
selectionEnabled?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Draws the record's actions beside the card's title — the collection's
|
|
13
|
+
* `entityActions` with Copy and Delete, placed as a table row places them.
|
|
14
|
+
*/
|
|
15
|
+
renderActions?: (entity: Entity<M>) => React.ReactNode;
|
|
11
16
|
};
|
|
12
17
|
/**
|
|
13
18
|
* Compact card component for displaying a entity in a Kanban board.
|
|
@@ -17,7 +22,7 @@ export type BoardCardBindingProps<M extends Record<string, unknown> = Record<str
|
|
|
17
22
|
* revealed on card hover or when the card is selected. This keeps the card
|
|
18
23
|
* layout clean while providing intuitive selection affordance.
|
|
19
24
|
*/
|
|
20
|
-
declare function BoardCardBindingInner<M extends Record<string, unknown> = Record<string, unknown>>({ item, isDragging, isGroupedOver, style, collection, onClick, selected, onSelectionChange, selectionEnabled }: BoardCardBindingProps<M>): React.JSX.Element;
|
|
25
|
+
declare function BoardCardBindingInner<M extends Record<string, unknown> = Record<string, unknown>>({ item, isDragging, isGroupedOver, style, collection, onClick, selected, onSelectionChange, selectionEnabled, renderActions }: BoardCardBindingProps<M>): React.JSX.Element;
|
|
21
26
|
export declare const BoardCardBinding: typeof BoardCardBindingInner;
|
|
22
27
|
/**
|
|
23
28
|
* Wrapper component that adapts BoardCardBinding to BoardItemViewProps interface
|
|
@@ -27,5 +32,6 @@ export declare function createBoardCardBindingComponent<M extends Record<string,
|
|
|
27
32
|
isEntitySelected?: (entity: Entity<M>) => boolean;
|
|
28
33
|
onSelectionChange?: (entity: Entity<M>, selected: boolean) => void;
|
|
29
34
|
selectionEnabled?: boolean;
|
|
35
|
+
renderActions?: (entity: Entity<M>) => React.ReactNode;
|
|
30
36
|
}): React.ComponentType<BoardItemViewProps<Entity<M>>>;
|
|
31
37
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StorageMarkdown } from "../../preview/components/StorageMarkdown.js";
|
|
2
|
-
import { useCollectionSlotKeys, useEntitySlots } from "./usePreviewSlots.js";
|
|
2
|
+
import { useCollectionSlotKeys, useEntitySlots, useImagePlace } from "./usePreviewSlots.js";
|
|
3
3
|
import { SlotValue, TagChips } from "./SlotValue.js";
|
|
4
4
|
import { memo, useCallback, useMemo } from "react";
|
|
5
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -14,10 +14,12 @@ import { IconForView, useAuthController, useCustomizationController, useTranslat
|
|
|
14
14
|
* revealed on card hover or when the card is selected. This keeps the card
|
|
15
15
|
* layout clean while providing intuitive selection affordance.
|
|
16
16
|
*/
|
|
17
|
-
function BoardCardBindingInner({ item, isDragging, isGroupedOver, style, collection, onClick, selected, onSelectionChange, selectionEnabled = false }) {
|
|
17
|
+
function BoardCardBindingInner({ item, isDragging, isGroupedOver, style, collection, onClick, selected, onSelectionChange, selectionEnabled = false, renderActions }) {
|
|
18
18
|
const { t } = useTranslation();
|
|
19
19
|
const entity = item.data;
|
|
20
|
-
const
|
|
20
|
+
const slotKeys = useCollectionSlotKeys(collection, useAuthController(), useCustomizationController().propertyConfigs);
|
|
21
|
+
const slots = useEntitySlots(entity, collection, slotKeys);
|
|
22
|
+
const imagePlace = useImagePlace(slotKeys.imageKey);
|
|
21
23
|
const handleClick = useCallback((e) => {
|
|
22
24
|
if ((e.metaKey || e.ctrlKey) && selectionEnabled) {
|
|
23
25
|
e.preventDefault();
|
|
@@ -69,10 +71,10 @@ function BoardCardBindingInner({ item, isDragging, isGroupedOver, style, collect
|
|
|
69
71
|
onClick: handleClick,
|
|
70
72
|
children: /* @__PURE__ */ jsxs("div", {
|
|
71
73
|
className: cardClassName,
|
|
72
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
74
|
+
children: [(imagePlace || selectionEnabled) && /* @__PURE__ */ jsxs("div", {
|
|
73
75
|
className: "relative w-10 h-10 rounded-md shrink-0 mr-2",
|
|
74
76
|
onClick: handleThumbnailClick,
|
|
75
|
-
children: [slots.image ? /* @__PURE__ */ jsx("div", {
|
|
77
|
+
children: [!imagePlace ? null : slots.image ? /* @__PURE__ */ jsx("div", {
|
|
76
78
|
className: cls("w-10 h-10 rounded-md overflow-hidden transition-opacity duration-200", selectionEnabled && "group-hover/card:opacity-30", selected && "opacity-0"),
|
|
77
79
|
children: /* @__PURE__ */ jsx(SlotValue, {
|
|
78
80
|
slot: slots.image,
|
|
@@ -102,15 +104,18 @@ function BoardCardBindingInner({ item, isDragging, isGroupedOver, style, collect
|
|
|
102
104
|
}), /* @__PURE__ */ jsxs("div", {
|
|
103
105
|
className: "flex-1 min-w-0",
|
|
104
106
|
children: [
|
|
105
|
-
/* @__PURE__ */
|
|
106
|
-
className: "
|
|
107
|
-
children:
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
107
|
+
/* @__PURE__ */ jsxs("div", {
|
|
108
|
+
className: "flex items-start gap-1",
|
|
109
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
110
|
+
className: "flex-1 min-w-0 line-clamp-2 text-sm font-medium",
|
|
111
|
+
children: slots.title ? /* @__PURE__ */ jsx(SlotValue, {
|
|
112
|
+
slot: slots.title,
|
|
113
|
+
size: "small"
|
|
114
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
115
|
+
className: "text-surface-500",
|
|
116
|
+
children: entity.id
|
|
117
|
+
})
|
|
118
|
+
}), renderActions?.(entity)]
|
|
114
119
|
}),
|
|
115
120
|
slots.subtitle ? /* @__PURE__ */ jsx("div", {
|
|
116
121
|
className: "text-xs text-surface-500 mt-1 line-clamp-3 opacity-80",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BoardCardBinding.js","names":[],"sources":["../../../src/components/CollectionViewBinding/BoardCardBinding.tsx"],"sourcesContent":["\nimport React, { memo, useCallback, useMemo } from \"react\";\nimport { Entity } from \"@rebasepro/types\";\nimport { Checkbox, Chip, cls, defaultBorderMixin } from \"@rebasepro/ui\";\nimport { StorageMarkdown } from \"../../preview/components/StorageMarkdown\";\nimport { PropertyPreview } from \"../../preview\";\nimport { useAuthController, useCustomizationController, useTranslation } from \"@rebasepro/app\";\nimport { IconForView } from \"@rebasepro/app\";\nimport { BoardItemViewProps } from \"@rebasepro/ui\";\nimport { useCollectionSlotKeys, useEntitySlots } from \"./usePreviewSlots\";\nimport { SlotValue, TagChips } from \"./SlotValue\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\n\nexport type BoardCardBindingProps<M extends Record<string, unknown> = Record<string, unknown>> = BoardItemViewProps<Entity<M>> & {\n collection: AdminCollection<M>;\n onClick?: (entity: Entity<M>) => void;\n selected?: boolean;\n onSelectionChange?: (entity: Entity<M>, selected: boolean) => void;\n selectionEnabled?: boolean;\n};\n\n/**\n * Compact card component for displaying a entity in a Kanban board.\n * Uses the shared slot system for consistent preview rendering.\n *\n * Selection UX: The checkbox overlays on top of the image/icon thumbnail area,\n * revealed on card hover or when the card is selected. This keeps the card\n * layout clean while providing intuitive selection affordance.\n */\nfunction BoardCardBindingInner<M extends Record<string, unknown> = Record<string, unknown>>({\n item,\n isDragging,\n isGroupedOver,\n style,\n collection,\n onClick,\n selected,\n onSelectionChange,\n selectionEnabled = false\n}: BoardCardBindingProps<M>) {\n const { t } = useTranslation();\n const entity = item.data;\n const authController = useAuthController();\n const customizationController = useCustomizationController();\n\n const slotKeys = useCollectionSlotKeys(\n collection as AdminCollection<Record<string, unknown>>,\n authController,\n customizationController.propertyConfigs\n );\n\n const slots = useEntitySlots(\n entity as Entity<Record<string, unknown>>,\n collection as AdminCollection<Record<string, unknown>>,\n slotKeys\n );\n\n const handleClick = useCallback((e: React.MouseEvent) => {\n // Cmd+click (Mac) or Ctrl+click (Windows) toggles selection\n if ((e.metaKey || e.ctrlKey) && selectionEnabled) {\n e.preventDefault();\n e.stopPropagation();\n onSelectionChange?.(entity, !selected);\n return;\n }\n if (onClick) {\n e.stopPropagation();\n onClick(entity);\n }\n }, [entity, onClick, onSelectionChange, selected, selectionEnabled]);\n\n const handleThumbnailClick = useCallback((e: React.MouseEvent) => {\n if (!selectionEnabled) return;\n e.stopPropagation();\n e.preventDefault();\n onSelectionChange?.(entity, !selected);\n }, [entity, onSelectionChange, selected, selectionEnabled]);\n\n const handleSelectionChange = useCallback((checked: boolean) => {\n onSelectionChange?.(entity, checked);\n }, [entity, onSelectionChange]);\n\n // Memoize className computations\n const backgroundColor = useMemo((): string => {\n if (isDragging) {\n return \"bg-surface-raised\";\n }\n if (isGroupedOver) {\n return \"bg-surface-raised\";\n }\n return \"bg-surface-card hover:bg-surface-hover\";\n }, [isDragging, isGroupedOver]);\n\n const borderColor = useMemo((): string =>\n isDragging ? \"ring-2 ring-primary\" : \"\", [isDragging]);\n\n // Memoize the card className — use CSS group for hover-reveal of checkbox\n const cardClassName = useMemo(() => cls(\n \"group/card p-2 flex items-start border rounded-lg cursor-pointer transition-all duration-200\",\n defaultBorderMixin,\n borderColor,\n backgroundColor,\n selected\n ? \"ring-2 ring-primary bg-primary/[0.03] dark:bg-primary/[0.06]\"\n : \"hover:shadow-sm\"\n ), [borderColor, backgroundColor, selected]);\n\n return (\n <div\n style={style}\n className=\"py-1\"\n data-is-dragging={isDragging}\n data-testid={item.id}\n onClick={handleClick}\n >\n <div className={cardClassName}>\n {/* Thumbnail area with selection overlay */}\n <div\n className=\"relative w-10 h-10 rounded-md shrink-0 mr-2\"\n onClick={handleThumbnailClick}\n >\n {/* Image or fallback icon */}\n {slots.image ? (\n <div className={cls(\n \"w-10 h-10 rounded-md overflow-hidden transition-opacity duration-200\",\n selectionEnabled && \"group-hover/card:opacity-30\",\n selected && \"opacity-0\"\n )}>\n <SlotValue slot={slots.image} size=\"small\" fill={true}/>\n </div>\n ) : (\n <div className={cls(\n \"w-10 h-10 rounded-md bg-surface-raised flex items-center justify-center transition-opacity duration-200\",\n selectionEnabled && \"group-hover/card:opacity-30\",\n selected && \"opacity-0\"\n )}>\n <IconForView\n collectionOrView={collection}\n color=\"disabled\"\n size=\"small\"\n />\n </div>\n )}\n\n {/* Selection checkbox overlay — always in the DOM, visibility controlled by CSS */}\n <div className={cls(\n \"absolute inset-0 flex items-center justify-center rounded-md transition-[opacity,background-color] duration-200\",\n !selectionEnabled && \"invisible pointer-events-none\",\n selectionEnabled && (selected\n ? \"opacity-100 bg-primary/10 dark:bg-primary/20\"\n : \"opacity-0 group-hover/card:opacity-100\")\n )}>\n <div className={cls(\n \"transition-transform duration-200\",\n selected\n ? \"scale-100\"\n : \"scale-75 group-hover/card:scale-100\"\n )}>\n <Checkbox\n aria-label={t(\"select_row\", { id: String(entity.id) })}\n checked={selected ?? false}\n onCheckedChange={handleSelectionChange}\n size=\"small\"\n padding={false}\n />\n </div>\n </div>\n </div>\n\n {/* Content */}\n <div className=\"flex-1 min-w-0\">\n {/* Title slot */}\n <div className=\"line-clamp-2 text-sm font-medium\">\n {slots.title ? (\n <SlotValue slot={slots.title} size=\"small\"/>\n ) : (\n <span className=\"text-surface-500\">{entity.id}</span>\n )}\n </div>\n {/* Subtitle / Description */}\n {slots.subtitle ? (\n <div className=\"text-xs text-surface-500 mt-1 line-clamp-3 opacity-80\">\n {typeof slots.subtitle.value === \"string\" ? (\n <StorageMarkdown source={slots.subtitle.value} size=\"small\" />\n ) : (\n <SlotValue slot={slots.subtitle} size=\"small\"/>\n )}\n </div>\n ) : (\n <div className=\"text-xs text-surface-500 font-mono truncate mt-1\">\n {entity.id}\n </div>\n )}\n {/* Relation chips slot */}\n {slots.relations.length > 0 && (\n <div className=\"flex items-center gap-1 mt-1 overflow-hidden max-w-full flex-wrap\">\n {slots.relations.map((rel) => (\n rel.items.map((item) => (\n <Chip\n key={`${rel.propertyKey}-${item.id}`}\n size=\"smallest\"\n colorScheme={rel.colorScheme}\n className=\"!text-[10px] !leading-tight !py-0 shrink-0 max-w-[90px] truncate\"\n >\n {item.displayName}\n </Chip>\n ))\n ))}\n {slots.relations.some(r => r.totalCount > r.items.length) && (\n <span className=\"text-[10px] text-surface-400 dark:text-surface-500 shrink-0\">\n +{slots.relations.reduce((acc, r) => acc + Math.max(0, r.totalCount - r.items.length), 0)}\n </span>\n )}\n </div>\n )}\n\n {/* Tags slot */}\n {slots.tags && (\n <div className=\"flex items-center gap-1 mt-1 flex-wrap\">\n <TagChips slot={slots.tags} max={3}/>\n </div>\n )}\n\n {/* Date slot — a board card is a list row without the image, and\n the row shows it. The status is deliberately not repeated\n here: on a board grouped by it, the column header is already\n saying it. */}\n {slots.date && (\n <div className=\"text-[10px] text-surface-500 dark:text-surface-400 mt-1\">\n {slots.date.formatted}\n </div>\n )}\n </div>\n </div>\n </div>\n );\n}\n\n// Memoized to prevent unnecessary re-renders when other cards in the board change\nexport const BoardCardBinding = memo(BoardCardBindingInner) as typeof BoardCardBindingInner;\n\n/**\n * Wrapper component that adapts BoardCardBinding to BoardItemViewProps interface\n */\nexport function createBoardCardBindingComponent<M extends Record<string, unknown>>(\n collection: AdminCollection<M>,\n options: {\n onClick?: (entity: Entity<M>) => void;\n isEntitySelected?: (entity: Entity<M>) => boolean;\n onSelectionChange?: (entity: Entity<M>, selected: boolean) => void;\n selectionEnabled?: boolean;\n }\n): React.ComponentType<BoardItemViewProps<Entity<M>>> {\n return function BoardCardBindingWrapper(props: BoardItemViewProps<Entity<M>>) {\n return (\n <BoardCardBinding\n {...props}\n collection={collection}\n onClick={options.onClick}\n selected={options.isEntitySelected?.(props.item.data)}\n onSelectionChange={options.onSelectionChange}\n selectionEnabled={options.selectionEnabled}\n />\n );\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA6BA,SAAS,sBAAmF,EACxF,MACA,YACA,eACA,OACA,YACA,SACA,UACA,mBACA,mBAAmB,SACM;CACzB,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,SAAS,KAAK;CAUpB,MAAM,QAAQ,eACV,QACA,YARa,sBACb,YAJmB,kBAKnB,GAJ4B,2BAK5B,CAAA,CAAwB,eAMxB,CACJ;CAEA,MAAM,cAAc,aAAa,MAAwB;EAErD,KAAK,EAAE,WAAW,EAAE,YAAY,kBAAkB;GAC9C,EAAE,eAAe;GACjB,EAAE,gBAAgB;GAClB,oBAAoB,QAAQ,CAAC,QAAQ;GACrC;EACJ;EACA,IAAI,SAAS;GACT,EAAE,gBAAgB;GAClB,QAAQ,MAAM;EAClB;CACJ,GAAG;EAAC;EAAQ;EAAS;EAAmB;EAAU;CAAgB,CAAC;CAEnE,MAAM,uBAAuB,aAAa,MAAwB;EAC9D,IAAI,CAAC,kBAAkB;EACvB,EAAE,gBAAgB;EAClB,EAAE,eAAe;EACjB,oBAAoB,QAAQ,CAAC,QAAQ;CACzC,GAAG;EAAC;EAAQ;EAAmB;EAAU;CAAgB,CAAC;CAE1D,MAAM,wBAAwB,aAAa,YAAqB;EAC5D,oBAAoB,QAAQ,OAAO;CACvC,GAAG,CAAC,QAAQ,iBAAiB,CAAC;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MAAK;MAAQ,CAAA,IAE3C,oBAAC,QAAD;OAAM,WAAU;iBAAoB,OAAO;MAAS,CAAA;KAEvD,CAAA;KAEJ,MAAM,WACH,oBAAC,OAAD;MAAK,WAAU;gBACV,OAAO,MAAM,SAAS,UAAU,WAC7B,oBAAC,iBAAD;OAAiB,QAAQ,MAAM,SAAS;OAAO,MAAK;MAAS,CAAA,IAE7D,oBAAC,WAAD;OAAW,MAAM,MAAM;OAAU,MAAK;MAAQ,CAAA;KAEjD,CAAA,IAEL,oBAAC,OAAD;MAAK,WAAU;gBACV,OAAO;KACP,CAAA;KAGR,MAAM,UAAU,SAAS,KACtB,qBAAC,OAAD;MAAK,WAAU;gBAAf,CACK,MAAM,UAAU,KAAK,QAClB,IAAI,MAAM,KAAK,SACX,oBAAC,MAAD;OAEI,MAAK;OACL,aAAa,IAAI;OACjB,WAAU;iBAET,KAAK;MACJ,GANG,GAAG,IAAI,YAAY,GAAG,KAAK,IAM9B,CACT,CACJ,GACA,MAAM,UAAU,MAAK,MAAK,EAAE,aAAa,EAAE,MAAM,MAAM,KACpD,qBAAC,QAAD;OAAM,WAAU;iBAAhB,CAA8E,KACxE,MAAM,UAAU,QAAQ,KAAK,MAAM,MAAM,KAAK,IAAI,GAAG,EAAE,aAAa,EAAE,MAAM,MAAM,GAAG,CAAC,CACtF;QAET;;KAIR,MAAM,QACH,oBAAC,OAAD;MAAK,WAAU;gBACX,oBAAC,UAAD;OAAU,MAAM,MAAM;OAAM,KAAK;MAAG,CAAA;KACnC,CAAA;KAOR,MAAM,QACH,oBAAC,OAAD;MAAK,WAAU;gBACV,MAAM,KAAK;KACX,CAAA;IAER;KACJ;;CACJ,CAAA;AAEb;AAGA,IAAa,mBAAmB,KAAK,qBAAqB"}
|
|
1
|
+
{"version":3,"file":"BoardCardBinding.js","names":[],"sources":["../../../src/components/CollectionViewBinding/BoardCardBinding.tsx"],"sourcesContent":["\nimport React, { memo, useCallback, useMemo } from \"react\";\nimport { Entity } from \"@rebasepro/types\";\nimport { Checkbox, Chip, cls, defaultBorderMixin } from \"@rebasepro/ui\";\nimport { StorageMarkdown } from \"../../preview/components/StorageMarkdown\";\nimport { PropertyPreview } from \"../../preview\";\nimport { useAuthController, useCustomizationController, useTranslation } from \"@rebasepro/app\";\nimport { IconForView } from \"@rebasepro/app\";\nimport { BoardItemViewProps } from \"@rebasepro/ui\";\nimport { useCollectionSlotKeys, useEntitySlots, useImagePlace } from \"./usePreviewSlots\";\nimport { SlotValue, TagChips } from \"./SlotValue\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\n\nexport type BoardCardBindingProps<M extends Record<string, unknown> = Record<string, unknown>> = BoardItemViewProps<Entity<M>> & {\n collection: AdminCollection<M>;\n onClick?: (entity: Entity<M>) => void;\n selected?: boolean;\n onSelectionChange?: (entity: Entity<M>, selected: boolean) => void;\n selectionEnabled?: boolean;\n /**\n * Draws the record's actions beside the card's title — the collection's\n * `entityActions` with Copy and Delete, placed as a table row places them.\n */\n renderActions?: (entity: Entity<M>) => React.ReactNode;\n};\n\n/**\n * Compact card component for displaying a entity in a Kanban board.\n * Uses the shared slot system for consistent preview rendering.\n *\n * Selection UX: The checkbox overlays on top of the image/icon thumbnail area,\n * revealed on card hover or when the card is selected. This keeps the card\n * layout clean while providing intuitive selection affordance.\n */\nfunction BoardCardBindingInner<M extends Record<string, unknown> = Record<string, unknown>>({\n item,\n isDragging,\n isGroupedOver,\n style,\n collection,\n onClick,\n selected,\n onSelectionChange,\n selectionEnabled = false,\n renderActions\n}: BoardCardBindingProps<M>) {\n const { t } = useTranslation();\n const entity = item.data;\n const authController = useAuthController();\n const customizationController = useCustomizationController();\n\n const slotKeys = useCollectionSlotKeys(\n collection as AdminCollection<Record<string, unknown>>,\n authController,\n customizationController.propertyConfigs\n );\n\n const slots = useEntitySlots(\n entity as Entity<Record<string, unknown>>,\n collection as AdminCollection<Record<string, unknown>>,\n slotKeys\n );\n const imagePlace = useImagePlace(slotKeys.imageKey);\n\n const handleClick = useCallback((e: React.MouseEvent) => {\n // Cmd+click (Mac) or Ctrl+click (Windows) toggles selection\n if ((e.metaKey || e.ctrlKey) && selectionEnabled) {\n e.preventDefault();\n e.stopPropagation();\n onSelectionChange?.(entity, !selected);\n return;\n }\n if (onClick) {\n e.stopPropagation();\n onClick(entity);\n }\n }, [entity, onClick, onSelectionChange, selected, selectionEnabled]);\n\n const handleThumbnailClick = useCallback((e: React.MouseEvent) => {\n if (!selectionEnabled) return;\n e.stopPropagation();\n e.preventDefault();\n onSelectionChange?.(entity, !selected);\n }, [entity, onSelectionChange, selected, selectionEnabled]);\n\n const handleSelectionChange = useCallback((checked: boolean) => {\n onSelectionChange?.(entity, checked);\n }, [entity, onSelectionChange]);\n\n // Memoize className computations\n const backgroundColor = useMemo((): string => {\n if (isDragging) {\n return \"bg-surface-raised\";\n }\n if (isGroupedOver) {\n return \"bg-surface-raised\";\n }\n return \"bg-surface-card hover:bg-surface-hover\";\n }, [isDragging, isGroupedOver]);\n\n const borderColor = useMemo((): string =>\n isDragging ? \"ring-2 ring-primary\" : \"\", [isDragging]);\n\n // Memoize the card className — use CSS group for hover-reveal of checkbox\n const cardClassName = useMemo(() => cls(\n \"group/card p-2 flex items-start border rounded-lg cursor-pointer transition-all duration-200\",\n defaultBorderMixin,\n borderColor,\n backgroundColor,\n selected\n ? \"ring-2 ring-primary bg-primary/[0.03] dark:bg-primary/[0.06]\"\n : \"hover:shadow-sm\"\n ), [borderColor, backgroundColor, selected]);\n\n return (\n <div\n style={style}\n className=\"py-1\"\n data-is-dragging={isDragging}\n data-testid={item.id}\n onClick={handleClick}\n >\n <div className={cardClassName}>\n {/* Thumbnail area with selection overlay. Where `fields` leaves\n every image out it holds only the checkbox, and with no\n selection it is not drawn. */}\n {(imagePlace || selectionEnabled) && <div\n className=\"relative w-10 h-10 rounded-md shrink-0 mr-2\"\n onClick={handleThumbnailClick}\n >\n {/* Image or fallback icon */}\n {!imagePlace ? null : slots.image ? (\n <div className={cls(\n \"w-10 h-10 rounded-md overflow-hidden transition-opacity duration-200\",\n selectionEnabled && \"group-hover/card:opacity-30\",\n selected && \"opacity-0\"\n )}>\n <SlotValue slot={slots.image} size=\"small\" fill={true}/>\n </div>\n ) : (\n <div className={cls(\n \"w-10 h-10 rounded-md bg-surface-raised flex items-center justify-center transition-opacity duration-200\",\n selectionEnabled && \"group-hover/card:opacity-30\",\n selected && \"opacity-0\"\n )}>\n <IconForView\n collectionOrView={collection}\n color=\"disabled\"\n size=\"small\"\n />\n </div>\n )}\n\n {/* Selection checkbox overlay — always in the DOM, visibility controlled by CSS */}\n <div className={cls(\n \"absolute inset-0 flex items-center justify-center rounded-md transition-[opacity,background-color] duration-200\",\n !selectionEnabled && \"invisible pointer-events-none\",\n selectionEnabled && (selected\n ? \"opacity-100 bg-primary/10 dark:bg-primary/20\"\n : \"opacity-0 group-hover/card:opacity-100\")\n )}>\n <div className={cls(\n \"transition-transform duration-200\",\n selected\n ? \"scale-100\"\n : \"scale-75 group-hover/card:scale-100\"\n )}>\n <Checkbox\n aria-label={t(\"select_row\", { id: String(entity.id) })}\n checked={selected ?? false}\n onCheckedChange={handleSelectionChange}\n size=\"small\"\n padding={false}\n />\n </div>\n </div>\n </div>}\n\n {/* Content */}\n <div className=\"flex-1 min-w-0\">\n {/* Title slot, and the record's actions beside it */}\n <div className=\"flex items-start gap-1\">\n <div className=\"flex-1 min-w-0 line-clamp-2 text-sm font-medium\">\n {slots.title ? (\n <SlotValue slot={slots.title} size=\"small\"/>\n ) : (\n <span className=\"text-surface-500\">{entity.id}</span>\n )}\n </div>\n {renderActions?.(entity)}\n </div>\n {/* Subtitle / Description */}\n {slots.subtitle ? (\n <div className=\"text-xs text-surface-500 mt-1 line-clamp-3 opacity-80\">\n {typeof slots.subtitle.value === \"string\" ? (\n <StorageMarkdown source={slots.subtitle.value} size=\"small\" />\n ) : (\n <SlotValue slot={slots.subtitle} size=\"small\"/>\n )}\n </div>\n ) : (\n <div className=\"text-xs text-surface-500 font-mono truncate mt-1\">\n {entity.id}\n </div>\n )}\n {/* Relation chips slot */}\n {slots.relations.length > 0 && (\n <div className=\"flex items-center gap-1 mt-1 overflow-hidden max-w-full flex-wrap\">\n {slots.relations.map((rel) => (\n rel.items.map((item) => (\n <Chip\n key={`${rel.propertyKey}-${item.id}`}\n size=\"smallest\"\n colorScheme={rel.colorScheme}\n className=\"!text-[10px] !leading-tight !py-0 shrink-0 max-w-[90px] truncate\"\n >\n {item.displayName}\n </Chip>\n ))\n ))}\n {slots.relations.some(r => r.totalCount > r.items.length) && (\n <span className=\"text-[10px] text-surface-400 dark:text-surface-500 shrink-0\">\n +{slots.relations.reduce((acc, r) => acc + Math.max(0, r.totalCount - r.items.length), 0)}\n </span>\n )}\n </div>\n )}\n\n {/* Tags slot */}\n {slots.tags && (\n <div className=\"flex items-center gap-1 mt-1 flex-wrap\">\n <TagChips slot={slots.tags} max={3}/>\n </div>\n )}\n\n {/* Date slot — a board card is a list row without the image, and\n the row shows it. The status is deliberately not repeated\n here: on a board grouped by it, the column header is already\n saying it. */}\n {slots.date && (\n <div className=\"text-[10px] text-surface-500 dark:text-surface-400 mt-1\">\n {slots.date.formatted}\n </div>\n )}\n </div>\n </div>\n </div>\n );\n}\n\n// Memoized to prevent unnecessary re-renders when other cards in the board change\nexport const BoardCardBinding = memo(BoardCardBindingInner) as typeof BoardCardBindingInner;\n\n/**\n * Wrapper component that adapts BoardCardBinding to BoardItemViewProps interface\n */\nexport function createBoardCardBindingComponent<M extends Record<string, unknown>>(\n collection: AdminCollection<M>,\n options: {\n onClick?: (entity: Entity<M>) => void;\n isEntitySelected?: (entity: Entity<M>) => boolean;\n onSelectionChange?: (entity: Entity<M>, selected: boolean) => void;\n selectionEnabled?: boolean;\n renderActions?: (entity: Entity<M>) => React.ReactNode;\n }\n): React.ComponentType<BoardItemViewProps<Entity<M>>> {\n return function BoardCardBindingWrapper(props: BoardItemViewProps<Entity<M>>) {\n return (\n <BoardCardBinding\n {...props}\n collection={collection}\n onClick={options.onClick}\n selected={options.isEntitySelected?.(props.item.data)}\n onSelectionChange={options.onSelectionChange}\n selectionEnabled={options.selectionEnabled}\n renderActions={options.renderActions}\n />\n );\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAkCA,SAAS,sBAAmF,EACxF,MACA,YACA,eACA,OACA,YACA,SACA,UACA,mBACA,mBAAmB,OACnB,iBACyB;CACzB,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,SAAS,KAAK;CAIpB,MAAM,WAAW,sBACb,YAJmB,kBAKnB,GAJ4B,2BAK5B,CAAA,CAAwB,eAC5B;CAEA,MAAM,QAAQ,eACV,QACA,YACA,QACJ;CACA,MAAM,aAAa,cAAc,SAAS,QAAQ;CAElD,MAAM,cAAc,aAAa,MAAwB;EAErD,KAAK,EAAE,WAAW,EAAE,YAAY,kBAAkB;GAC9C,EAAE,eAAe;GACjB,EAAE,gBAAgB;GAClB,oBAAoB,QAAQ,CAAC,QAAQ;GACrC;EACJ;EACA,IAAI,SAAS;GACT,EAAE,gBAAgB;GAClB,QAAQ,MAAM;EAClB;CACJ,GAAG;EAAC;EAAQ;EAAS;EAAmB;EAAU;CAAgB,CAAC;CAEnE,MAAM,uBAAuB,aAAa,MAAwB;EAC9D,IAAI,CAAC,kBAAkB;EACvB,EAAE,gBAAgB;EAClB,EAAE,eAAe;EACjB,oBAAoB,QAAQ,CAAC,QAAQ;CACzC,GAAG;EAAC;EAAQ;EAAmB;EAAU;CAAgB,CAAC;CAE1D,MAAM,wBAAwB,aAAa,YAAqB;EAC5D,oBAAoB,QAAQ,OAAO;CACvC,GAAG,CAAC,QAAQ,iBAAiB,CAAC;CAG9B,MAAM,kBAAkB,cAAsB;EAC1C,IAAI,YACA,OAAO;EAEX,IAAI,eACA,OAAO;EAEX,OAAO;CACX,GAAG,CAAC,YAAY,aAAa,CAAC;CAE9B,MAAM,cAAc,cAChB,aAAa,wBAAwB,IAAI,CAAC,UAAU,CAAC;CAGzD,MAAM,gBAAgB,cAAc,IAChC,g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