@rebasepro/cms 0.28.2 → 0.29.0-canary.g0e3a0e7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/collection_editor/_cms_internals.d.ts +0 -1
- package/dist/collection_editor/ui/EditorCollectionAction.d.ts +2 -2
- package/dist/collection_editor/ui/EditorCollectionAction.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.js +2 -2
- package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/MarkdownPropertyField.js +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/MarkdownPropertyField.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/StoragePropertyField.js +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/StoragePropertyField.js.map +1 -1
- package/dist/components/AdditionalFieldValue.d.ts +9 -3
- package/dist/components/AdditionalFieldValue.js +7 -4
- package/dist/components/AdditionalFieldValue.js.map +1 -1
- package/dist/components/CollectionPanel.d.ts +117 -18
- package/dist/components/CollectionPanel.js +115 -37
- package/dist/components/CollectionPanel.js.map +1 -1
- package/dist/components/CollectionTableBinding/CollectionRowActions.d.ts +5 -5
- package/dist/components/CollectionTableBinding/CollectionRowActions.js +16 -12
- package/dist/components/CollectionTableBinding/CollectionRowActions.js.map +1 -1
- package/dist/components/CollectionTableBinding/CollectionTableBinding.js +33 -8
- package/dist/components/CollectionTableBinding/CollectionTableBinding.js.map +1 -1
- package/dist/components/CollectionTableBinding/CollectionTableBindingProps.d.ts +8 -3
- package/dist/components/CollectionTableBinding/PropertyTableCell.js +2 -2
- package/dist/components/CollectionTableBinding/PropertyTableCell.js.map +1 -1
- package/dist/components/CollectionTableBinding/column_utils.d.ts +9 -1
- package/dist/components/CollectionTableBinding/column_utils.js +6 -3
- package/dist/components/CollectionTableBinding/column_utils.js.map +1 -1
- package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.js +2 -2
- package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.js.map +1 -1
- package/dist/components/CollectionTableBinding/fields/TableReferenceField.js +2 -2
- package/dist/components/CollectionTableBinding/fields/TableReferenceField.js.map +1 -1
- package/dist/components/CollectionTableBinding/fields/TableRelationField.js +2 -2
- package/dist/components/CollectionTableBinding/fields/TableRelationField.js.map +1 -1
- package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.d.ts +3 -2
- package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.js +9 -7
- package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.js.map +1 -1
- package/dist/components/CollectionTableBinding/internal/common.d.ts +26 -2
- package/dist/components/CollectionTableBinding/internal/common.js +88 -4
- package/dist/components/CollectionTableBinding/internal/common.js.map +1 -1
- package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js +4 -3
- package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js.map +1 -1
- package/dist/components/CollectionViewBinding/BoardCardBinding.d.ts +7 -1
- package/dist/components/CollectionViewBinding/BoardCardBinding.js +19 -14
- package/dist/components/CollectionViewBinding/BoardCardBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionAddButton.d.ts +28 -0
- package/dist/components/CollectionViewBinding/CollectionAddButton.js +50 -0
- package/dist/components/CollectionViewBinding/CollectionAddButton.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.d.ts +11 -3
- package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.js +9 -4
- package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionCardViewBinding.d.ts +5 -3
- package/dist/components/CollectionViewBinding/CollectionCardViewBinding.js +5 -3
- package/dist/components/CollectionViewBinding/CollectionCardViewBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionEntityActions.d.ts +29 -0
- package/dist/components/CollectionViewBinding/CollectionEntityActions.js +112 -0
- package/dist/components/CollectionViewBinding/CollectionEntityActions.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionListViewBinding.d.ts +2 -2
- package/dist/components/CollectionViewBinding/CollectionListViewBinding.js +58 -16
- package/dist/components/CollectionViewBinding/CollectionListViewBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionToolbar.d.ts +57 -0
- package/dist/components/CollectionViewBinding/CollectionToolbar.js +146 -0
- package/dist/components/CollectionViewBinding/CollectionToolbar.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionViewActions.d.ts +2 -2
- package/dist/components/CollectionViewBinding/CollectionViewActions.js +22 -26
- package/dist/components/CollectionViewBinding/CollectionViewActions.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionViewBinding.d.ts +58 -22
- package/dist/components/CollectionViewBinding/CollectionViewBinding.js +81 -1089
- package/dist/components/CollectionViewBinding/CollectionViewBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionViewContent.d.ts +9 -0
- package/dist/components/CollectionViewBinding/CollectionViewContent.js +152 -0
- package/dist/components/CollectionViewBinding/CollectionViewContent.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionViewDialogs.d.ts +9 -0
- package/dist/components/CollectionViewBinding/CollectionViewDialogs.js +38 -0
- package/dist/components/CollectionViewBinding/CollectionViewDialogs.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionViewFrame.d.ts +13 -0
- package/dist/components/CollectionViewBinding/CollectionViewFrame.js +32 -0
- package/dist/components/CollectionViewBinding/CollectionViewFrame.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionViewScope.d.ts +14 -0
- package/dist/components/CollectionViewBinding/CollectionViewScope.js +22 -0
- package/dist/components/CollectionViewBinding/CollectionViewScope.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionViewStartActions.d.ts +2 -2
- package/dist/components/CollectionViewBinding/CollectionViewStartActions.js +39 -67
- package/dist/components/CollectionViewBinding/CollectionViewStartActions.js.map +1 -1
- package/dist/components/CollectionViewBinding/CustomViewHost.d.ts +28 -0
- package/dist/components/CollectionViewBinding/CustomViewHost.js +54 -0
- package/dist/components/CollectionViewBinding/CustomViewHost.js.map +1 -0
- package/dist/components/CollectionViewBinding/EntitiesCount.d.ts +24 -0
- package/dist/components/CollectionViewBinding/EntitiesCount.js +69 -0
- package/dist/components/CollectionViewBinding/EntitiesCount.js.map +1 -0
- package/dist/components/CollectionViewBinding/EntityCardBinding.d.ts +7 -1
- package/dist/components/CollectionViewBinding/EntityCardBinding.js +34 -23
- package/dist/components/CollectionViewBinding/EntityCardBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/EntityIdHeaderWidget.d.ts +17 -0
- package/dist/components/CollectionViewBinding/EntityIdHeaderWidget.js +107 -0
- package/dist/components/CollectionViewBinding/EntityIdHeaderWidget.js.map +1 -0
- package/dist/components/CollectionViewBinding/FiltersButton.d.ts +15 -0
- package/dist/components/CollectionViewBinding/FiltersButton.js +49 -0
- package/dist/components/CollectionViewBinding/FiltersButton.js.map +1 -0
- package/dist/components/CollectionViewBinding/PluginColumnSlots.d.ts +35 -0
- package/dist/components/CollectionViewBinding/PluginColumnSlots.js +45 -0
- package/dist/components/CollectionViewBinding/PluginColumnSlots.js.map +1 -0
- package/dist/components/CollectionViewBinding/RowActions.d.ts +40 -0
- package/dist/components/CollectionViewBinding/RowActions.js +60 -0
- package/dist/components/CollectionViewBinding/RowActions.js.map +1 -0
- package/dist/components/CollectionViewBinding/SplitListView.d.ts +7 -4
- package/dist/components/CollectionViewBinding/SplitListView.js +20 -21
- package/dist/components/CollectionViewBinding/SplitListView.js.map +1 -1
- package/dist/components/CollectionViewBinding/builtin_action_props.d.ts +13 -0
- package/dist/components/CollectionViewBinding/fields.d.ts +22 -0
- package/dist/components/CollectionViewBinding/fields.js +47 -0
- package/dist/components/CollectionViewBinding/fields.js.map +1 -0
- package/dist/components/CollectionViewBinding/useBoardDataController.js +6 -7
- package/dist/components/CollectionViewBinding/useBoardDataController.js.map +1 -1
- package/dist/components/CollectionViewBinding/useCollectionLargeLayout.d.ts +19 -0
- package/dist/components/CollectionViewBinding/useCollectionLargeLayout.js +28 -0
- package/dist/components/CollectionViewBinding/useCollectionLargeLayout.js.map +1 -0
- package/dist/components/CollectionViewBinding/useCollectionViewState.d.ts +125 -0
- package/dist/components/CollectionViewBinding/useCollectionViewState.js +844 -0
- package/dist/components/CollectionViewBinding/useCollectionViewState.js.map +1 -0
- package/dist/components/CollectionViewBinding/usePreviewSlots.d.ts +20 -0
- package/dist/components/CollectionViewBinding/usePreviewSlots.js +23 -2
- package/dist/components/CollectionViewBinding/usePreviewSlots.js.map +1 -1
- package/dist/components/CollectionViewBinding/useSelectionController.d.ts +21 -3
- package/dist/components/CollectionViewBinding/useSelectionController.js +37 -6
- package/dist/components/CollectionViewBinding/useSelectionController.js.map +1 -1
- package/dist/components/CollectionsProvider.d.ts +3 -3
- package/dist/components/CollectionsProvider.js +4 -4
- package/dist/components/CollectionsProvider.js.map +1 -1
- package/dist/components/CollectionsScopeContext.d.ts +1 -1
- package/dist/components/CollectionsScopeContext.js +1 -1
- package/dist/components/CollectionsScopeContext.js.map +1 -1
- package/dist/components/DeleteEntityDialog.d.ts +1 -1
- package/dist/components/DeleteEntityDialog.js +2 -2
- package/dist/components/DeleteEntityDialog.js.map +1 -1
- package/dist/components/DetailViewBinding.js +32 -68
- package/dist/components/DetailViewBinding.js.map +1 -1
- package/dist/components/EditFormActions.js +5 -4
- package/dist/components/EditFormActions.js.map +1 -1
- package/dist/components/EditViewBinding.d.ts +2 -2
- package/dist/components/EditViewBinding.js +25 -15
- package/dist/components/EditViewBinding.js.map +1 -1
- package/dist/components/EntityDisplayHeader.js +8 -5
- package/dist/components/EntityDisplayHeader.js.map +1 -1
- package/dist/components/EntityPreviewBinding.js +1 -1
- package/dist/components/EntityPreviewBinding.js.map +1 -1
- package/dist/components/EntityViewBinding.d.ts +8 -1
- package/dist/components/EntityViewBinding.js +43 -14
- package/dist/components/EntityViewBinding.js.map +1 -1
- package/dist/components/EntityViewBody.d.ts +40 -0
- package/dist/components/EntityViewBody.js +90 -0
- package/dist/components/EntityViewBody.js.map +1 -0
- package/dist/components/FieldValue.d.ts +50 -0
- package/dist/components/FieldValue.js +81 -0
- package/dist/components/FieldValue.js.map +1 -0
- package/dist/components/InlineEntityPreview.js +1 -1
- package/dist/components/InlineEntityPreview.js.map +1 -1
- package/dist/components/PanelNotFound.d.ts +5 -0
- package/dist/components/PanelNotFound.js +21 -0
- package/dist/components/PanelNotFound.js.map +1 -0
- package/dist/components/RebaseCMS.d.ts +1 -1
- package/dist/components/RebaseCMS.js +11 -3
- package/dist/components/RebaseCMS.js.map +1 -1
- package/dist/components/RebaseNavigation.js +9 -3
- package/dist/components/RebaseNavigation.js.map +1 -1
- package/dist/components/RebaseShell.js +10 -5
- package/dist/components/RebaseShell.js.map +1 -1
- package/dist/components/RecordDetail.d.ts +61 -0
- package/dist/components/RecordDetail.js +123 -0
- package/dist/components/RecordDetail.js.map +1 -0
- package/dist/components/RecordForm.d.ts +126 -0
- package/dist/components/{EntityFormPanel.js → RecordForm.js} +64 -36
- package/dist/components/RecordForm.js.map +1 -0
- package/dist/components/ReferenceTable/SelectionTableBinding.d.ts +47 -17
- package/dist/components/ReferenceTable/SelectionTableBinding.js +89 -53
- package/dist/components/ReferenceTable/SelectionTableBinding.js.map +1 -1
- package/dist/components/ReferenceWidget.d.ts +5 -3
- package/dist/components/ReferenceWidget.js +10 -7
- package/dist/components/ReferenceWidget.js.map +1 -1
- package/dist/components/RelationSelector.js +4 -4
- package/dist/components/RelationSelector.js.map +1 -1
- package/dist/components/SelectableTable/SelectableTable.js +2 -3
- package/dist/components/SelectableTable/SelectableTable.js.map +1 -1
- package/dist/components/SelectableTable/SelectionStore.d.ts +1 -1
- package/dist/components/SelectableTable/SelectionStore.js +1 -1
- package/dist/components/SelectableTable/SelectionStore.js.map +1 -1
- package/dist/components/SelectableTable/filters/ReferenceFilterField.js +2 -2
- package/dist/components/SelectableTable/filters/ReferenceFilterField.js.map +1 -1
- package/dist/components/SidePanelBinding.js +13 -12
- package/dist/components/SidePanelBinding.js.map +1 -1
- package/dist/components/collection_prop.d.ts +18 -0
- package/dist/components/collection_prop.js +23 -0
- package/dist/components/collection_prop.js.map +1 -0
- package/dist/components/common/default_entity_actions.js +54 -54
- package/dist/components/common/default_entity_actions.js.map +1 -1
- package/dist/components/history/EntityHistoryView.d.ts +4 -1
- package/dist/components/history/EntityHistoryView.js +1 -1
- package/dist/components/history/EntityHistoryView.js.map +1 -1
- package/dist/components/history/LastEditedByFormAction.d.ts +1 -1
- package/dist/components/index.d.ts +4 -2
- package/dist/data_export/export/ExportCollectionAction.d.ts +3 -2
- package/dist/data_export/export/ExportCollectionAction.js +4 -3
- package/dist/data_export/export/ExportCollectionAction.js.map +1 -1
- package/dist/data_export/export/additional_fields.d.ts +6 -3
- package/dist/data_export/export/additional_fields.js +8 -4
- package/dist/data_export/export/additional_fields.js.map +1 -1
- package/dist/data_import/import/ImportCollectionAction.js +2 -2
- package/dist/data_import/import/ImportCollectionAction.js.map +1 -1
- package/dist/form/EntityForm.d.ts +1 -1
- package/dist/form/EntityForm.js +252 -150
- package/dist/form/EntityForm.js.map +1 -1
- package/dist/form/EntityFormActions.js +3 -2
- package/dist/form/EntityFormActions.js.map +1 -1
- package/dist/form/EntityFormBinding.d.ts +1 -1
- package/dist/form/EntityFormBinding.js +22 -11
- package/dist/form/EntityFormBinding.js.map +1 -1
- package/dist/form/FormField.d.ts +36 -0
- package/dist/form/FormField.js +41 -0
- package/dist/form/FormField.js.map +1 -0
- package/dist/form/FormFieldsContext.d.ts +69 -0
- package/dist/form/FormFieldsContext.js +143 -0
- package/dist/form/FormFieldsContext.js.map +1 -0
- package/dist/form/PropertyFieldBinding.js +4 -4
- package/dist/form/PropertyFieldBinding.js.map +1 -1
- package/dist/form/collection_showing.d.ts +8 -0
- package/dist/form/collection_showing.js +29 -0
- package/dist/form/collection_showing.js.map +1 -0
- package/dist/form/components/ErrorFocus.js +2 -1
- package/dist/form/components/ErrorFocus.js.map +1 -1
- package/dist/form/components/FieldBlock.js +3 -1
- package/dist/form/components/FieldBlock.js.map +1 -1
- package/dist/form/components/FormRail.d.ts +5 -1
- package/dist/form/components/FormRail.js +5 -1
- package/dist/form/components/FormRail.js.map +1 -1
- package/dist/form/components/FormSections.d.ts +5 -1
- package/dist/form/components/FormSections.js +11 -4
- package/dist/form/components/FormSections.js.map +1 -1
- package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.js +2 -2
- package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/MarkdownEditorFieldBinding.js +1 -1
- package/dist/form/field_bindings/MarkdownEditorFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/MultipleRelationFieldBinding.js +2 -2
- package/dist/form/field_bindings/MultipleRelationFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/ReadOnlyFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/ReferenceFieldBinding.js +2 -2
- package/dist/form/field_bindings/ReferenceFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/RelationFieldBinding.js +2 -2
- package/dist/form/field_bindings/RelationFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/StorageUploadFieldBinding.js +1 -1
- package/dist/form/field_bindings/StorageUploadFieldBinding.js.map +1 -1
- package/dist/form/form_dom_ids.d.ts +25 -0
- package/dist/form/form_dom_ids.js +42 -0
- package/dist/form/form_dom_ids.js.map +1 -0
- package/dist/form/index.d.ts +3 -1
- package/dist/form/resolve_cell_property.d.ts +5 -0
- package/dist/form/resolve_cell_property.js +22 -1
- package/dist/form/resolve_cell_property.js.map +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/navigation/useBuildNavigationStateController.d.ts +2 -2
- package/dist/hooks/navigation/useBuildNavigationStateController.js.map +1 -1
- package/dist/hooks/navigation/useNavigationResolution.d.ts +3 -3
- package/dist/hooks/navigation/useNavigationResolution.js.map +1 -1
- package/dist/hooks/navigation/useResolvedCollections.d.ts +2 -2
- package/dist/hooks/navigation/useResolvedCollections.js.map +1 -1
- package/dist/hooks/navigation/useResolvedViews.d.ts +2 -2
- package/dist/hooks/navigation/useResolvedViews.js.map +1 -1
- package/dist/hooks/useBuildSidePanel.js +9 -9
- package/dist/hooks/useBuildSidePanel.js.map +1 -1
- package/dist/hooks/useEntityDisplay.js +6 -4
- package/dist/hooks/useEntityDisplay.js.map +1 -1
- package/dist/hooks/useRecordActions.js +2 -2
- package/dist/hooks/useRecordActions.js.map +1 -1
- package/dist/hooks/useSelectionDialog.d.ts +20 -7
- package/dist/hooks/useSelectionDialog.js +29 -8
- package/dist/hooks/useSelectionDialog.js.map +1 -1
- package/dist/index.d.ts +8 -3
- package/dist/index.js +15 -9
- package/dist/mcp-view.d.ts +9 -0
- package/dist/mcp-view.js +2 -0
- package/dist/mcp_view/app_modules.d.ts +29 -0
- package/dist/mcp_view/app_modules.js +163 -0
- package/dist/mcp_view/app_modules.js.map +1 -0
- package/dist/mcp_view/bridge.d.ts +90 -0
- package/dist/mcp_view/bridge.js +205 -0
- package/dist/mcp_view/bridge.js.map +1 -0
- package/dist/mcp_view/code_app.d.ts +65 -0
- package/dist/mcp_view/code_app.js +139 -0
- package/dist/mcp_view/code_app.js.map +1 -0
- package/dist/mcp_view/index.d.ts +48 -0
- package/dist/mcp_view/index.js +235 -0
- package/dist/mcp_view/index.js.map +1 -0
- package/dist/mcp_view/payload.d.ts +78 -0
- package/dist/mcp_view/payload.js +155 -0
- package/dist/mcp_view/payload.js.map +1 -0
- package/dist/mcp_view/screen.d.ts +28 -0
- package/dist/mcp_view/screen.js +223 -0
- package/dist/mcp_view/screen.js.map +1 -0
- package/dist/mcp_view/storage_source.d.ts +14 -0
- package/dist/mcp_view/storage_source.js +29 -0
- package/dist/mcp_view/storage_source.js.map +1 -0
- package/dist/mcp_view/store.d.ts +9 -0
- package/dist/mcp_view/store.js +27 -0
- package/dist/mcp_view/store.js.map +1 -0
- package/dist/mcp_view/tool_driver.d.ts +135 -0
- package/dist/mcp_view/tool_driver.js +527 -0
- package/dist/mcp_view/tool_driver.js.map +1 -0
- package/dist/preview/components/DatePreview.d.ts +34 -1
- package/dist/preview/components/DatePreview.js +72 -37
- package/dist/preview/components/DatePreview.js.map +1 -1
- package/dist/routes/RebaseRoute.js +1 -1
- package/dist/routes/RebaseRoute.js.map +1 -1
- package/dist/selection/SelectionMenu.d.ts +5 -3
- package/dist/selection/SelectionMenu.js +16 -9
- package/dist/selection/SelectionMenu.js.map +1 -1
- package/dist/selection/index.d.ts +2 -1
- package/dist/selection/resolve_selection.d.ts +61 -7
- package/dist/selection/resolve_selection.js +93 -11
- package/dist/selection/resolve_selection.js.map +1 -1
- package/dist/types/components/EntityFormProps.d.ts +60 -10
- package/dist/types/fields.d.ts +2 -65
- package/dist/util/dataControllerAdapter.d.ts +8 -0
- package/dist/util/dataControllerAdapter.js +11 -0
- package/dist/util/dataControllerAdapter.js.map +1 -1
- package/dist/util/navigation_utils.d.ts +5 -4
- package/dist/util/navigation_utils.js +6 -6
- package/dist/util/navigation_utils.js.map +1 -1
- package/dist/util/propertyConfigMapper.d.ts +8 -0
- package/dist/util/propertyConfigMapper.js +16 -2
- package/dist/util/propertyConfigMapper.js.map +1 -1
- package/package.json +15 -9
- package/recipes/README.md +79 -26
- package/recipes/approval-queue.tsx +79 -0
- package/recipes/bulk-set-status.tsx +23 -17
- package/recipes/calendar-view.tsx +28 -23
- package/recipes/master-detail.tsx +75 -0
- package/recipes/my-preferences.tsx +3 -3
- package/recipes/orders-dashboard.tsx +58 -84
- package/recipes/site-settings.tsx +4 -4
- package/dist/components/EntityFormPanel.d.ts +0 -63
- package/dist/components/EntityFormPanel.js.map +0 -1
package/README.md
CHANGED
|
@@ -37,7 +37,7 @@ of it resolves too: Node has supported `require(esm)` since 22.12.
|
|
|
37
37
|
| `SideDialogs` | Stacked side-panel dialog system |
|
|
38
38
|
| `AdminModeSyncer` | Syncs the admin mode (`"cms"` \| `"studio"`) with the current route |
|
|
39
39
|
| `CollectionPanel` | Standalone collection browser panel — by slug, or with the collection as a value (`collection={postsCollection}`), anywhere under `<Rebase>` and a router |
|
|
40
|
-
| `
|
|
40
|
+
| `RecordForm` | One record's form, loaded by `id` (or new without one) and saved through `<Rebase>`'s data layer, with `onSaved` and `onClose` |
|
|
41
41
|
| `CollectionsProvider` | The minimal scope for those two in a page of your own app: a registry of the collections you pass, and the side panels records open in. No `RebaseCMS`, `RebaseNavigation` or `RebaseShell` needed; any React Router router |
|
|
42
42
|
|
|
43
43
|
### Entity & Collection Views
|
|
@@ -73,8 +73,8 @@ of it resolves too: Node has supported `require(esm)` since 22.12.
|
|
|
73
73
|
|---|---|
|
|
74
74
|
| `useApp` | Access the app-level context (navigation, mode, config) |
|
|
75
75
|
| `useSidePanel` | Open/close entity side panels programmatically |
|
|
76
|
-
| `useSelectionDialog` |
|
|
77
|
-
| `useSelectionController` |
|
|
76
|
+
| `useSelectionDialog` | Open a dialog that picks rows from a collection, handing them back as the server sends them |
|
|
77
|
+
| `useSelectionController` | A selection of a collection's rows you hold, by id, for `admin.selectionController` |
|
|
78
78
|
| `useHistory` | Entity change history and version revert |
|
|
79
79
|
| `useBreadcrumbsController` | Breadcrumb navigation state |
|
|
80
80
|
| `useAdminContext` | Access the admin-level context |
|
|
@@ -15,7 +15,6 @@ export { CollectionTableBinding } from "../components/CollectionTableBinding/ind
|
|
|
15
15
|
export { VirtualTableInput } from "@rebasepro/ui";
|
|
16
16
|
export { ArrayContainer } from "../components/ArrayContainer.js";
|
|
17
17
|
export type { ArrayEntryParams } from "../components/ArrayContainer.js";
|
|
18
|
-
export { useSelectionController } from "../components/CollectionViewBinding/useSelectionController.js";
|
|
19
18
|
export { ImportFileUpload } from "../data_import/components/ImportFileUpload.js";
|
|
20
19
|
export { ImportSaveInProgress } from "../data_import/components/ImportSaveInProgress.js";
|
|
21
20
|
export { useImportConfig } from "../data_import/hooks/useImportConfig.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function EditorCollectionAction({ path, parentCollectionSlugs, parentEntityIds, collection, tableController }:
|
|
1
|
+
import type { BuiltInCollectionActionProps } from "../../components/CollectionViewBinding/builtin_action_props.js";
|
|
2
|
+
export declare function EditorCollectionAction({ path, parentCollectionSlugs, parentEntityIds, collection, tableController }: BuiltInCollectionActionProps): import("react").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditorCollectionAction.js","names":[],"sources":["../../../src/collection_editor/ui/EditorCollectionAction.tsx"],"sourcesContent":["import { useCollectionRegistryController } from \"../_cms_internals\";\nimport { useAuthController, useTranslation } from \"@rebasepro/app\";\n\nimport {
|
|
1
|
+
{"version":3,"file":"EditorCollectionAction.js","names":[],"sources":["../../../src/collection_editor/ui/EditorCollectionAction.tsx"],"sourcesContent":["import { useCollectionRegistryController } from \"../_cms_internals\";\nimport { useAuthController, useTranslation } from \"@rebasepro/app\";\n\nimport { AdminCollection } from \"@rebasepro/cms-types\";\nimport type { BuiltInCollectionActionProps } from \"../../components/CollectionViewBinding/builtin_action_props\";\nimport { IconButton, SettingsIcon, Tooltip } from \"@rebasepro/ui\";\n\nimport { useCollectionEditorController } from \"../useCollectionEditorController\";\n\nexport function EditorCollectionAction({\n path,\n parentCollectionSlugs, parentEntityIds,\n collection,\n tableController\n}: BuiltInCollectionActionProps) {\n\n const authController = useAuthController();\n const collectionRegistry = useCollectionRegistryController();\n const collectionEditorController = useCollectionEditorController();\n const { t } = useTranslation();\n\n const parentCollection = parentCollectionSlugs.length > 0 ? collectionRegistry.getCollection(parentCollectionSlugs[parentCollectionSlugs.length - 1]) : undefined;\n\n const canEditCollection = !collectionEditorController.configController?.readOnly;\n\n const tooltipTitle = collectionEditorController.configController?.readOnly\n ? (collectionEditorController.configController.readOnlyReason || t(\"studio_editor_collection_disabled\"))\n : (canEditCollection ? t(\"studio_editor_collection_edit\") : t(\"studio_editor_collection_no_permission\"));\n\n const editorButton = <Tooltip\n asChild={true}\n title={tooltipTitle}>\n <IconButton aria-label={tooltipTitle}\n size={\"small\"}\n disabled={!canEditCollection}\n onClick={canEditCollection\n ? () => collectionEditorController?.editCollection({\n id: collection.slug,\n path,\n parentCollectionSlugs,\nparentEntityIds,\n parentCollection: parentCollection as AdminCollection,\n existingEntities: tableController?.data ?? []\n })\n : undefined}>\n <SettingsIcon/>\n </IconButton>\n </Tooltip>;\n\n return <>\n {editorButton}\n </>\n\n}\n"],"mappings":";;;;;;AASA,SAAgB,uBAAuB,EACnC,MACA,uBAAuB,iBACvB,YACA,mBAC6B;CAEN,kBAAkB;CACzC,MAAM,qBAAqB,gCAAgC;CAC3D,MAAM,6BAA6B,8BAA8B;CACjE,MAAM,EAAE,MAAM,eAAe;CAE7B,MAAM,mBAAmB,sBAAsB,SAAS,IAAI,mBAAmB,cAAc,sBAAsB,sBAAsB,SAAS,EAAE,IAAI,KAAA;CAExJ,MAAM,oBAAoB,CAAC,2BAA2B,kBAAkB;CAExE,MAAM,eAAe,2BAA2B,kBAAkB,WAC3D,2BAA2B,iBAAiB,kBAAkB,EAAE,mCAAmC,IACnG,oBAAoB,EAAE,+BAA+B,IAAI,EAAE,wCAAwC;CAsB1G,OAAO,oBAAA,UAAA,EAAA,UApBc,oBAAC,SAAD;EACjB,SAAS;EACT,OAAO;YACP,oBAAC,YAAD;GAAY,cAAY;GACpB,MAAM;GACN,UAAU,CAAC;GACX,SAAS,0BACG,4BAA4B,eAAe;IAC/C,IAAI,WAAW;IACf;IACA;IACpB;IACsC;IAClB,kBAAkB,iBAAiB,QAAQ,CAAC;GAChD,CAAC,IACC,KAAA;aACN,oBAAC,cAAD,CAAc,CAAA;EACN,CAAA;CACP,CAGJ,EACH,CAAA;AAEN"}
|
package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useCollectionRegistryController } from "../../../../hooks/navigation/contexts/CollectionRegistryContext.js";
|
|
2
2
|
import { CollectionTableBinding } from "../../../../components/CollectionTableBinding/CollectionTableBinding.js";
|
|
3
|
-
import {
|
|
3
|
+
import { useEntitySelectionController } from "../../../../components/CollectionViewBinding/useSelectionController.js";
|
|
4
4
|
import { convertImportData } from "../../../../data_import/utils/data.js";
|
|
5
5
|
import { ImportConversionProblems } from "../../../../data_import/components/ImportConversionProblems.js";
|
|
6
6
|
import { useEffect, useState } from "react";
|
|
@@ -21,7 +21,7 @@ function CollectionEditorImportDataPreview({ importConfig, properties, propertie
|
|
|
21
21
|
useEffect(() => {
|
|
22
22
|
loadEntities().finally(() => setLoading(false));
|
|
23
23
|
}, []);
|
|
24
|
-
const selectionController =
|
|
24
|
+
const selectionController = useEntitySelectionController();
|
|
25
25
|
if (loading) return /* @__PURE__ */ jsx(CircularProgressCenter, {});
|
|
26
26
|
return /* @__PURE__ */ jsxs("div", {
|
|
27
27
|
className: "flex flex-col h-full w-full",
|
package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CollectionEditorImportDataPreview.js","names":[],"sources":["../../../../../src/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.tsx"],"sourcesContent":["import { useCollectionRegistryController } from \"../../../_cms_internals\";\nimport { convertImportData, ImportConfig, ImportConversionProblems } from \"../../../_cms_internals\";\nimport type { ImportConversionProblem } from \"../../../../data_import/utils/data\";\nimport { useAuthController } from \"@rebasepro/app\";\nimport { CollectionTableBinding } from \"../../../../components/CollectionTableBinding/CollectionTableBinding\";\nimport {
|
|
1
|
+
{"version":3,"file":"CollectionEditorImportDataPreview.js","names":[],"sources":["../../../../../src/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.tsx"],"sourcesContent":["import { useCollectionRegistryController } from \"../../../_cms_internals\";\nimport { convertImportData, ImportConfig, ImportConversionProblems } from \"../../../_cms_internals\";\nimport type { ImportConversionProblem } from \"../../../../data_import/utils/data\";\nimport { useAuthController } from \"@rebasepro/app\";\nimport { CollectionTableBinding } from \"../../../../components/CollectionTableBinding/CollectionTableBinding\";\nimport { useEntitySelectionController } from \"../../../../components/CollectionViewBinding/useSelectionController\";\nimport { CircularProgressCenter } from \"@rebasepro/ui\";\nimport { Properties } from \"@rebasepro/types\";\nimport { useEffect, useState } from \"react\";\nimport { Typography } from \"@rebasepro/ui\";\n\nexport function CollectionEditorImportDataPreview({\n importConfig,\n properties,\n propertiesOrder\n}: {\n importConfig: ImportConfig,\n properties: Properties,\n propertiesOrder: string[]\n}) {\n\n const authController = useAuthController();\n const registry = useCollectionRegistryController();\n const [loading, setLoading] = useState<boolean>(false);\n const [problems, setProblems] = useState<ImportConversionProblem[]>([]);\n\n async function loadEntities() {\n const converted = convertImportData(authController,\n registry,\n importConfig.importData,\n importConfig.idColumn,\n importConfig.headersMapping,\n properties,\n \"TEMP_PATH\",\n importConfig.defaultValues);\n importConfig.setEntities(converted.entities);\n setProblems(converted.problems);\n }\n\n useEffect(() => {\n loadEntities().finally(() => setLoading(false));\n }, []);\n\n const selectionController = useEntitySelectionController();\n if (loading)\n return <CircularProgressCenter/>\n\n return <div className={\"flex flex-col h-full w-full\"}>\n <ImportConversionProblems problems={problems}/>\n <div className={\"flex-1 min-h-0\"}>\n <CollectionTableBinding\n title={<div>\n <Typography variant={\"subtitle2\"}>Imported data preview</Typography>\n <Typography variant={\"caption\"}>Entities with the same id will be overwritten</Typography>\n </div>}\n tableController={{\n data: importConfig.entities,\n dataLoading: false,\n noMoreToLoad: false\n }}\n endAdornment={<div className={\"h-12\"}/>}\n filterable={false}\n sortable={false}\n selectionController={selectionController}\n displayedColumnIds={propertiesOrder.map(p => ({\n key: p,\n disabled: false\n }))}\n openEntityMode={\"side_panel\"}\n properties={properties}\n enablePopupIcon={false}/>\n </div>\n </div>;\n\n}\n"],"mappings":";;;;;;;;;;AAWA,SAAgB,kCAAkC,EAC9C,cACA,YACA,mBAKD;CAEC,MAAM,iBAAiB,kBAAkB;CACzC,MAAM,WAAW,gCAAgC;CACjD,MAAM,CAAC,SAAS,cAAc,SAAkB,KAAK;CACrD,MAAM,CAAC,UAAU,eAAe,SAAoC,CAAC,CAAC;CAEtE,eAAe,eAAe;EAC1B,MAAM,YAAY,kBAAkB,gBAChC,UACA,aAAa,YACb,aAAa,UACb,aAAa,gBACb,YACA,aACA,aAAa,aAAa;EAC9B,aAAa,YAAY,UAAU,QAAQ;EAC3C,YAAY,UAAU,QAAQ;CAClC;CAEA,gBAAgB;EACZ,aAAa,CAAC,CAAC,cAAc,WAAW,KAAK,CAAC;CAClD,GAAG,CAAC,CAAC;CAEL,MAAM,sBAAsB,6BAA6B;CACzD,IAAI,SACA,OAAO,oBAAC,wBAAD,CAAwB,CAAA;CAEnC,OAAO,qBAAC,OAAD;EAAK,WAAW;YAAhB,CACH,oBAAC,0BAAD,EAAoC,SAAU,CAAA,GAC9C,oBAAC,OAAD;GAAK,WAAW;aACZ,oBAAC,wBAAD;IACI,OAAO,qBAAC,OAAD,EAAA,UAAA,CACH,oBAAC,YAAD;KAAY,SAAS;eAAa;IAAiC,CAAA,GACnE,oBAAC,YAAD;KAAY,SAAS;eAAW;IAAyD,CAAA,CACxF,EAAA,CAAA;IACL,iBAAiB;KACb,MAAM,aAAa;KACnB,aAAa;KACb,cAAc;IAClB;IACA,cAAc,oBAAC,OAAD,EAAK,WAAW,OAAQ,CAAA;IACtC,YAAY;IACZ,UAAU;IACW;IACrB,oBAAoB,gBAAgB,KAAI,OAAM;KAC1C,KAAK;KACL,UAAU;IACd,EAAE;IACF,gBAAgB;IACJ;IACZ,iBAAiB;GAAO,CAAA;EAC3B,CAAA,CACJ;;AAET"}
|
|
@@ -75,7 +75,7 @@ function MarkdownPropertyField({ disabled, showErrors }) {
|
|
|
75
75
|
/* @__PURE__ */ jsx("li", { children: "{file} - Full name of the uploaded file" }),
|
|
76
76
|
/* @__PURE__ */ jsx("li", { children: "{file.name} - Name of the uploaded file without extension" }),
|
|
77
77
|
/* @__PURE__ */ jsx("li", { children: "{file.ext} - Extension of the uploaded file" }),
|
|
78
|
-
/* @__PURE__ */ jsx("li", { children: "{
|
|
78
|
+
/* @__PURE__ */ jsx("li", { children: "{id} - ID of the entity" }),
|
|
79
79
|
/* @__PURE__ */ jsx("li", { children: "{propertyKey} - ID of this field" }),
|
|
80
80
|
/* @__PURE__ */ jsx("li", { children: "{path} - Path of this entity" }),
|
|
81
81
|
/* @__PURE__ */ jsx("li", { children: "{rand} - Random value used to avoid name collisions" })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownPropertyField.js","names":[],"sources":["../../../../../src/collection_editor/ui/collection_editor/properties/MarkdownPropertyField.tsx"],"sourcesContent":["\nimport React from \"react\";\nimport { StringPropertyValidation } from \"./validation/StringPropertyValidation\";\nimport { ValidationPanel } from \"./validation/ValidationPanel\";\nimport { Field, getIn, useFormex } from \"@rebasepro/forms\";\nimport { useTranslation } from \"@rebasepro/app\";\n\nimport {\n DebouncedTextField,\n ExpandablePanel,\n TextField,\n Typography,\n UploadCloudIcon\n} from \"@rebasepro/ui\";\n\nexport function MarkdownPropertyField({\n disabled,\n showErrors\n}: {\n disabled: boolean;\n showErrors: boolean;\n}) {\n\n const {\n values,\n setFieldValue\n } = useFormex();\n const { t } = useTranslation();\n\n const baseStoragePath = \"storage\";\n\n const metadata = `${baseStoragePath}.metadata`;\n const fileName = `${baseStoragePath}.fileName`;\n const maxSize = `${baseStoragePath}.maxSize`;\n const storagePath = `${baseStoragePath}.storagePath`;\n\n const fileNameValue = (getIn(values, fileName) as string | undefined) ?? \"{rand}_{file}\";\n const storagePathValue = (getIn(values, storagePath) as string | undefined) ?? \"/\";\n const maxSizeValue = getIn(values, maxSize);\n\n const hasFilenameCallback = typeof fileNameValue === \"function\";\n const hasStoragePathCallback = typeof storagePathValue === \"function\";\n\n return (\n <>\n <div className={\"col-span-12\"}>\n\n <ValidationPanel>\n\n <StringPropertyValidation disabled={disabled}\n length={true}\n lowercase={true}\n max={true}\n min={true}\n trim={true}\n uppercase={true}\n showErrors={showErrors}/>\n\n </ValidationPanel>\n\n </div>\n\n <div className={\"col-span-12\"}>\n <ExpandablePanel\n title={\n <div className=\"flex flex-row text-surface-500\">\n <UploadCloudIcon/>\n <Typography variant={\"subtitle2\"}\n className=\"ml-4\">\n File upload config\n </Typography>\n </div>\n }>\n\n <div className={\"grid grid-cols-12 gap-2 p-4\"}>\n\n <div className={\"col-span-12\"}>\n <Field name={fileName}\n as={DebouncedTextField}\n label={t(\"storage_file_name\")}\n size={\"small\"}\n disabled={hasFilenameCallback || disabled}\n value={hasFilenameCallback ? \"-\" : fileNameValue}\n />\n </div>\n <div className={\"col-span-12\"}>\n <Field name={storagePath}\n as={DebouncedTextField}\n label={t(\"storage_path\")}\n disabled={hasStoragePathCallback || disabled}\n size={\"small\"}\n value={hasStoragePathCallback ? \"-\" : storagePathValue}\n />\n <Typography variant={\"caption\"} className={\"ml-3.5 mt-1 mb-2\"}>\n <p>You can use the following placeholders in\n the file name\n and storage path values:</p>\n <ul>\n <li>{\"{file} - Full name of the uploaded file\"}</li>\n <li>{\"{file.name} - Name of the uploaded file without extension\"}</li>\n <li>{\"{file.ext} - Extension of the uploaded file\"}</li>\n <li>{\"{
|
|
1
|
+
{"version":3,"file":"MarkdownPropertyField.js","names":[],"sources":["../../../../../src/collection_editor/ui/collection_editor/properties/MarkdownPropertyField.tsx"],"sourcesContent":["\nimport React from \"react\";\nimport { StringPropertyValidation } from \"./validation/StringPropertyValidation\";\nimport { ValidationPanel } from \"./validation/ValidationPanel\";\nimport { Field, getIn, useFormex } from \"@rebasepro/forms\";\nimport { useTranslation } from \"@rebasepro/app\";\n\nimport {\n DebouncedTextField,\n ExpandablePanel,\n TextField,\n Typography,\n UploadCloudIcon\n} from \"@rebasepro/ui\";\n\nexport function MarkdownPropertyField({\n disabled,\n showErrors\n}: {\n disabled: boolean;\n showErrors: boolean;\n}) {\n\n const {\n values,\n setFieldValue\n } = useFormex();\n const { t } = useTranslation();\n\n const baseStoragePath = \"storage\";\n\n const metadata = `${baseStoragePath}.metadata`;\n const fileName = `${baseStoragePath}.fileName`;\n const maxSize = `${baseStoragePath}.maxSize`;\n const storagePath = `${baseStoragePath}.storagePath`;\n\n const fileNameValue = (getIn(values, fileName) as string | undefined) ?? \"{rand}_{file}\";\n const storagePathValue = (getIn(values, storagePath) as string | undefined) ?? \"/\";\n const maxSizeValue = getIn(values, maxSize);\n\n const hasFilenameCallback = typeof fileNameValue === \"function\";\n const hasStoragePathCallback = typeof storagePathValue === \"function\";\n\n return (\n <>\n <div className={\"col-span-12\"}>\n\n <ValidationPanel>\n\n <StringPropertyValidation disabled={disabled}\n length={true}\n lowercase={true}\n max={true}\n min={true}\n trim={true}\n uppercase={true}\n showErrors={showErrors}/>\n\n </ValidationPanel>\n\n </div>\n\n <div className={\"col-span-12\"}>\n <ExpandablePanel\n title={\n <div className=\"flex flex-row text-surface-500\">\n <UploadCloudIcon/>\n <Typography variant={\"subtitle2\"}\n className=\"ml-4\">\n File upload config\n </Typography>\n </div>\n }>\n\n <div className={\"grid grid-cols-12 gap-2 p-4\"}>\n\n <div className={\"col-span-12\"}>\n <Field name={fileName}\n as={DebouncedTextField}\n label={t(\"storage_file_name\")}\n size={\"small\"}\n disabled={hasFilenameCallback || disabled}\n value={hasFilenameCallback ? \"-\" : fileNameValue}\n />\n </div>\n <div className={\"col-span-12\"}>\n <Field name={storagePath}\n as={DebouncedTextField}\n label={t(\"storage_path\")}\n disabled={hasStoragePathCallback || disabled}\n size={\"small\"}\n value={hasStoragePathCallback ? \"-\" : storagePathValue}\n />\n <Typography variant={\"caption\"} className={\"ml-3.5 mt-1 mb-2\"}>\n <p>You can use the following placeholders in\n the file name\n and storage path values:</p>\n <ul>\n <li>{\"{file} - Full name of the uploaded file\"}</li>\n <li>{\"{file.name} - Name of the uploaded file without extension\"}</li>\n <li>{\"{file.ext} - Extension of the uploaded file\"}</li>\n <li>{\"{id} - ID of the entity\"}</li>\n <li>{\"{propertyKey} - ID of this field\"}</li>\n <li>{\"{path} - Path of this entity\"}</li>\n <li>{\"{rand} - Random value used to avoid name collisions\"}</li>\n </ul>\n </Typography>\n\n <Typography variant={\"caption\"} className={\"ml-3.5 mt-1 mb-2\"}>\n When using Markdown, the URL of the uploaded files are always saved in the text value\n (not\n the path).\n </Typography>\n </div>\n\n <div className={\"col-span-12\"}>\n <DebouncedTextField name={maxSize}\n type={\"number\"}\n label={t(\"storage_max_size\")}\n size={\"small\"}\n value={maxSizeValue !== undefined && maxSizeValue !== null ? maxSizeValue.toString() : \"\"}\n onChange={(e) => {\n const value = e.target.value;\n if (value === \"\") setFieldValue(maxSize, undefined);\n else setFieldValue(maxSize, parseInt(value));\n }}\n />\n </div>\n\n </div>\n </ExpandablePanel>\n </div>\n\n <div className={\"col-span-12\"}>\n\n <TextField name={\"defaultValue\"}\n disabled={disabled}\n onChange={(e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n setFieldValue(\"defaultValue\", e.target.value === \"\" ? undefined : e.target.value);\n }}\n label={t(\"default_value\")}\n value={(getIn(values, \"defaultValue\") as string | undefined) ?? \"\"}/>\n\n </div>\n </>\n );\n}\n"],"mappings":";;;;;;;;AAeA,SAAgB,sBAAsB,EAClC,UACA,cAID;CAEC,MAAM,EACF,QACA,kBACA,UAAU;CACd,MAAM,EAAE,MAAM,eAAe;CAE7B,MAAM,kBAAkB;CAGxB,MAAM,WAAW,GAAG,gBAAgB;CACpC,MAAM,UAAU,GAAG,gBAAgB;CACnC,MAAM,cAAc,GAAG,gBAAgB;CAEvC,MAAM,gBAAiB,MAAM,QAAQ,QAAQ,KAA4B;CACzE,MAAM,mBAAoB,MAAM,QAAQ,WAAW,KAA4B;CAC/E,MAAM,eAAe,MAAM,QAAQ,OAAO;CAE1C,MAAM,sBAAsB,OAAO,kBAAkB;CACrD,MAAM,yBAAyB,OAAO,qBAAqB;CAE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AAD,EAAA,UAAK,sDAA0D,CAAA;SAC/D,EAAA,CAAA,CACI;;QAEZ,oBAAC,YAAD;SAAY,SAAS;SAAW,WAAW;mBAAoB;QAInD,CAAA;OACX;;MAEL,oBAAC,OAAD;OAAK,WAAW;iBACZ,oBAAC,oBAAD;QAAoB,MAAM;QACtB,MAAM;QACN,OAAO,EAAE,kBAAkB;QAC3B,MAAM;QACN,OAAO,iBAAiB,KAAA,KAAa,iBAAiB,OAAO,aAAa,SAAS,IAAI;QACvF,WAAW,MAAM;SACb,MAAM,QAAQ,EAAE,OAAO;SACvB,IAAI,UAAU,IAAI,cAAc,SAAS,KAAA,CAAS;cAC7C,cAAc,SAAS,SAAS,KAAK,CAAC;QAC/C;OACH,CAAA;MACA,CAAA;KAEJ;;GACQ,CAAA;EAChB,CAAA;EAEL,oBAAC,OAAD;GAAK,WAAW;aAEZ,oBAAC,WAAD;IAAW,MAAM;IACH;IACV,WAAW,MAAiE;KACxE,cAAc,gBAAgB,EAAE,OAAO,UAAU,KAAK,KAAA,IAAY,EAAE,OAAO,KAAK;IACpF;IACA,OAAO,EAAE,eAAe;IACxB,OAAQ,MAAM,QAAQ,cAAc,KAA4B;GAAI,CAAA;EAEvE,CAAA;CACP,EAAA,CAAA;AAEV"}
|
|
@@ -150,7 +150,7 @@ function StoragePropertyField({ multiple, existing, disabled }) {
|
|
|
150
150
|
/* @__PURE__ */ jsx("li", { children: "{file} - Full name of the uploaded file" }),
|
|
151
151
|
/* @__PURE__ */ jsx("li", { children: "{file.name} - Name of the uploaded file without extension" }),
|
|
152
152
|
/* @__PURE__ */ jsx("li", { children: "{file.ext} - Extension of the uploaded file" }),
|
|
153
|
-
/* @__PURE__ */ jsx("li", { children: "{
|
|
153
|
+
/* @__PURE__ */ jsx("li", { children: "{id} - ID of the entity" }),
|
|
154
154
|
/* @__PURE__ */ jsx("li", { children: "{propertyKey} - ID of this field" }),
|
|
155
155
|
/* @__PURE__ */ jsx("li", { children: "{path} - Path of this entity" }),
|
|
156
156
|
/* @__PURE__ */ jsx("li", { children: "{rand} - Random value used to avoid name collisions" })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StoragePropertyField.js","names":[],"sources":["../../../../../src/collection_editor/ui/collection_editor/properties/StoragePropertyField.tsx"],"sourcesContent":["\nimport React from \"react\";\nimport {\n Button,\n DebouncedTextField,\n ExpandablePanel,\n MultiSelect,\n MultiSelectItem,\n Select,\n SelectItem,\n Typography,\n UploadCloudIcon\n} from \"@rebasepro/ui\";\n\nimport { Field, FormexFieldProps, getIn, useFormex } from \"@rebasepro/forms\";\nimport { useStorageSources, useTranslation } from \"@rebasepro/app\";\nimport { DEFAULT_STORAGE_SOURCE_KEY } from \"@rebasepro/types\";\nimport { GeneralPropertyValidation } from \"./validation/GeneralPropertyValidation\";\nimport { ArrayPropertyValidation } from \"./validation/ArrayPropertyValidation\";\nimport { ValidationPanel } from \"./validation/ValidationPanel\";\nimport { SwitchControl } from \"../SwitchControl\";\n\nconst fileTypes: Record<string, string> = {\n \"image/*\": \"Images\",\n \"video/*\": \"Videos\",\n \"audio/*\": \"Audio files\",\n \"application/*\": \"Files (pdf, zip, csv, excel...)\",\n \"text/*\": \"Text files\"\n}\n\nexport function StoragePropertyField({\n multiple,\n existing,\n disabled\n}: {\n multiple: boolean;\n existing: boolean;\n disabled: boolean;\n}) {\n\n const {\n values,\n setFieldValue\n } = useFormex();\n const { t } = useTranslation();\n const storageSources = useStorageSources();\n\n const baseStoragePath = multiple ? \"of.storage\" : \"storage\";\n const acceptedFiles = `${baseStoragePath}.acceptedFiles`;\n const storageSource = `${baseStoragePath}.storageSource`;\n\n const metadata = `${baseStoragePath}.metadata`;\n const fileName = `${baseStoragePath}.fileName`;\n const maxSize = `${baseStoragePath}.maxSize`;\n const storagePath = `${baseStoragePath}.storagePath`;\n const storeUrl = `${baseStoragePath}.storeUrl`;\n const includeBucketUrl = `${baseStoragePath}.includeBucketUrl`;\n\n // Image resize config paths\n const imageResize = `${baseStoragePath}.imageResize`;\n const imageResizeMaxWidth = `${imageResize}.maxWidth`;\n const imageResizeMaxHeight = `${imageResize}.maxHeight`;\n const imageResizeMode = `${imageResize}.mode`;\n const imageResizeFormat = `${imageResize}.format`;\n const imageResizeQuality = `${imageResize}.quality`;\n\n const fileNameValue = (getIn(values, fileName) as string | undefined) ?? \"{rand}_{file}\";\n const storagePathValue = (getIn(values, storagePath) as string | undefined) ?? \"/\";\n const maxSizeValue = getIn(values, maxSize) as number | undefined;\n\n // Image resize values\n const imageResizeMaxWidthValue = getIn(values, imageResizeMaxWidth) as number | undefined;\n const imageResizeMaxHeightValue = getIn(values, imageResizeMaxHeight) as number | undefined;\n const imageResizeModeValue = (getIn(values, imageResizeMode) as string | undefined) ?? \"cover\";\n const imageResizeFormatValue = (getIn(values, imageResizeFormat) as string | undefined) ?? \"original\";\n const imageResizeQualityValue = getIn(values, imageResizeQuality) as number | undefined;\n\n const storedValue = getIn(values, acceptedFiles);\n const fileTypesValue: string[] | undefined = Array.isArray(storedValue) ? storedValue : undefined;\n const allFileTypesSelected = !fileTypesValue || fileTypesValue.length === 0;\n\n // Available storage backends (from `<Rebase storageSources={...}>`).\n const sourceKeys = Object.keys(storageSources.sources)\n .filter((key) => key !== DEFAULT_STORAGE_SOURCE_KEY);\n const storageSourceValue = (getIn(values, storageSource) as string | undefined) ?? DEFAULT_STORAGE_SOURCE_KEY;\n\n const handleTypesChange = (value: string[]) => {\n if (!value) setFieldValue(acceptedFiles, undefined);\n else setFieldValue(acceptedFiles, value);\n };\n\n const hasFilenameCallback = typeof fileNameValue === \"function\";\n const hasStoragePathCallback = typeof storagePathValue === \"function\";\n\n return (\n <>\n\n <div className={\"col-span-12\"}>\n\n <ExpandablePanel\n title={\n <div className=\"flex flex-row text-surface-500 text-text-secondary dark:text-text-secondary-dark\">\n <UploadCloudIcon/>\n <Typography variant={\"subtitle2\"}\n className=\"ml-4\">\n File upload config\n </Typography>\n </div>\n }>\n\n <div className={\"grid grid-cols-12 gap-2 p-4\"}>\n\n {sourceKeys.length > 0 && (\n <div className={\"col-span-12\"}>\n <Select\n className={\"w-full\"}\n disabled={disabled}\n name={storageSource}\n value={storageSourceValue}\n onValueChange={(value) =>\n setFieldValue(storageSource, !value || value === DEFAULT_STORAGE_SOURCE_KEY ? undefined : value)}\n label={\"Storage backend\"}\n renderValue={(key) => {\n const label = storageSources.registry[key]?.label;\n return label ?? (key === DEFAULT_STORAGE_SOURCE_KEY ? \"Default\" : key);\n }}>\n <SelectItem value={DEFAULT_STORAGE_SOURCE_KEY}>\n Default\n </SelectItem>\n {sourceKeys.map((key) => (\n <SelectItem key={key} value={key}>\n {storageSources.registry[key]?.label ?? key}\n </SelectItem>\n ))}\n </Select>\n </div>\n )}\n\n <div className={\"col-span-12\"}>\n\n <MultiSelect\n className={\"w-full\"}\n placeholder={\"All file types allowed\"}\n disabled={disabled}\n value={fileTypesValue ?? []}\n onValueChange={handleTypesChange}\n label={allFileTypesSelected ? undefined : \"Allowed file types\"}\n renderValues={(selected: string[]) => {\n if (!selected || selected.length === 0) return \"All file types allowed\";\n return selected.map((v: string) => fileTypes[v])\n .filter((v: string) => Boolean(v))\n .join(\", \");\n }}>\n\n {Object.entries(fileTypes).map(([value, label]) => (\n <MultiSelectItem key={value} value={value} className={\"flex items-center gap-2\"}>\n {/*<Checkbox*/}\n {/* checked={allFileTypesSelected || fileTypesValue.indexOf(value) > -1}/>*/}\n <div className={\"grow\"}>\n {label}\n </div>\n <Button size={\"small\"}\n variant={\"text\"}\n onClick={(e: React.MouseEvent) => {\n e.preventDefault();\n e.stopPropagation();\n return setFieldValue(acceptedFiles, [value]);\n }}>\n Only\n </Button>\n </MultiSelectItem>\n ))}\n\n </MultiSelect>\n </div>\n\n <div className={\"col-span-12\"}>\n <Field name={fileName}\n as={DebouncedTextField}\n label={t(\"storage_file_name\")}\n size={\"small\"}\n disabled={hasFilenameCallback || disabled}\n value={hasFilenameCallback ? \"-\" : fileNameValue}\n />\n </div>\n <div className={\"col-span-12\"}>\n <Field name={storagePath}\n as={DebouncedTextField}\n label={t(\"storage_path\")}\n disabled={hasStoragePathCallback || disabled}\n size={\"small\"}\n value={hasStoragePathCallback ? \"-\" : storagePathValue}\n />\n <Typography variant={\"caption\"} className={\"ml-3.5 mt-1 mb-2\"}>\n <p>You can use the following placeholders in\n the file name\n and storage path values:</p>\n <ul>\n <li>{\"{file} - Full name of the uploaded file\"}</li>\n <li>{\"{file.name} - Name of the uploaded file without extension\"}</li>\n <li>{\"{file.ext} - Extension of the uploaded file\"}</li>\n <li>{\"{entityId} - ID of the entity\"}</li>\n <li>{\"{propertyKey} - ID of this field\"}</li>\n <li>{\"{path} - Path of this entity\"}</li>\n <li>{\"{rand} - Random value used to avoid name collisions\"}</li>\n </ul>\n </Typography>\n\n <Field name={includeBucketUrl}\n type=\"checkbox\">\n {({\n field,\n form\n }: FormexFieldProps) => {\n return <SwitchControl\n label={t(\"storage_include_bucket_url\")}\n disabled={existing || disabled}\n form={form}\n field={field}/>;\n }}\n </Field>\n\n <Typography variant={\"caption\"} className={\"ml-3.5 mt-1 mb-2\"}>\n Turn this setting on if you want to save a fully-qualified storage URL\n (e.g. <code>s3://my-bucket/path/to/file</code>) instead of just the storage path.\n You can only change this prop upon creation.\n </Typography>\n\n <Field name={storeUrl}\n type=\"checkbox\">\n {({\n field,\n form\n }: FormexFieldProps) => {\n return <SwitchControl\n label={t(\"storage_save_url\")}\n disabled={existing || disabled}\n form={form}\n field={field}/>;\n }}\n </Field>\n\n <Typography variant={\"caption\"} className={\"ml-3.5 mt-1 mb-2\"}>\n Turn this setting on, if you prefer to save\n the download\n URL of the uploaded file instead of the\n storage path.\n You can only change this prop upon creation.\n </Typography>\n </div>\n\n <div className={\"col-span-12\"}>\n <DebouncedTextField name={maxSize}\n type={\"number\"}\n label={t(\"storage_max_size\")}\n size={\"small\"}\n value={maxSizeValue !== undefined && maxSizeValue !== null ? maxSizeValue.toString() : \"\"}\n onChange={(e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n const value = e.target.value;\n if (value === \"\") setFieldValue(maxSize, undefined);\n else setFieldValue(maxSize, parseInt(value));\n }}\n />\n </div>\n\n <div className={\"col-span-12 mt-4\"}>\n <Typography variant={\"subtitle2\"}\n color={\"secondary\"}\n className={\"mb-2 block\"}>\n Image Resize Configuration\n </Typography>\n <Typography variant={\"caption\"} className={\"mb-2 block text-xs\"}>\n Automatically resize and optimize images before upload (JPEG, PNG, WebP only)\n </Typography>\n </div>\n\n <div className={\"col-span-6\"}>\n <DebouncedTextField\n name={imageResizeMaxWidth}\n type={\"number\"}\n label={t(\"storage_max_width\")}\n size={\"small\"}\n disabled={disabled}\n value={imageResizeMaxWidthValue !== undefined && imageResizeMaxWidthValue !== null ? imageResizeMaxWidthValue.toString() : \"\"}\n onChange={(e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n const value = e.target.value;\n if (value === \"\") setFieldValue(imageResizeMaxWidth, undefined);\n else setFieldValue(imageResizeMaxWidth, parseInt(value));\n }}\n />\n </div>\n\n <div className={\"col-span-6\"}>\n <DebouncedTextField\n name={imageResizeMaxHeight}\n type={\"number\"}\n label={t(\"storage_max_height\")}\n size={\"small\"}\n disabled={disabled}\n value={imageResizeMaxHeightValue !== undefined && imageResizeMaxHeightValue !== null ? imageResizeMaxHeightValue.toString() : \"\"}\n onChange={(e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n const value = e.target.value;\n if (value === \"\") setFieldValue(imageResizeMaxHeight, undefined);\n else setFieldValue(imageResizeMaxHeight, parseInt(value));\n }}\n />\n </div>\n\n <div className={\"col-span-6\"}>\n <Select\n disabled={disabled}\n name={imageResizeMode}\n fullWidth\n size={\"medium\"}\n value={imageResizeModeValue || \"cover\"}\n onValueChange={(value) => setFieldValue(imageResizeMode, value || \"cover\")}\n label={t(\"storage_resize_mode\")}\n renderValue={(selected) => {\n if (!selected) return \"Cover\";\n return selected === \"contain\" ? \"Contain (fit within bounds)\" : \"Cover (fill bounds, may crop)\";\n }}>\n <SelectItem value=\"contain\">\n Contain (fit within bounds)\n </SelectItem>\n <SelectItem value=\"cover\">\n Cover (fill bounds, may crop)\n </SelectItem>\n </Select>\n </div>\n\n <div className={\"col-span-6\"}>\n <Select\n disabled={disabled}\n size={\"medium\"}\n fullWidth\n name={imageResizeFormat}\n value={imageResizeFormatValue || \"original\"}\n onValueChange={(value) => setFieldValue(imageResizeFormat, value || \"original\")}\n label={t(\"storage_output_format\")}\n renderValue={(selected) => {\n if (!selected) return \"Original\";\n return selected.charAt(0).toUpperCase() + selected.slice(1);\n }}>\n <SelectItem value=\"original\">\n Original (keep same format)\n </SelectItem>\n <SelectItem value=\"jpeg\">\n JPEG\n </SelectItem>\n <SelectItem value=\"png\">\n PNG\n </SelectItem>\n <SelectItem value=\"webp\">\n WebP (best compression)\n </SelectItem>\n </Select>\n </div>\n\n <div className={\"col-span-12\"}>\n <DebouncedTextField\n name={imageResizeQuality}\n type={\"number\"}\n label={t(\"storage_quality\")}\n size={\"small\"}\n disabled={disabled}\n value={imageResizeQualityValue !== undefined && imageResizeQualityValue !== null ? imageResizeQualityValue.toString() : \"\"}\n onChange={(e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n const value = e.target.value;\n if (value === \"\") setFieldValue(imageResizeQuality, undefined);\n else {\n const numValue = parseInt(value);\n if (numValue >= 0 && numValue <= 100) {\n setFieldValue(imageResizeQuality, numValue);\n }\n }\n }}\n />\n <Typography variant={\"caption\"} className={\"ml-3.5 mt-1 mb-2\"}>\n Higher quality = larger file size. Recommended: 80-90 for photos, 90-100 for graphics\n </Typography>\n </div>\n\n </div>\n </ExpandablePanel>\n\n </div>\n\n <div className={\"col-span-12\"}>\n\n <ValidationPanel>\n {!multiple && <div className={\"grid grid-cols-12 gap-2\"}>\n <GeneralPropertyValidation disabled={disabled}/>\n </div>}\n {multiple && <div className={\"col-span-12\"}>\n <ArrayPropertyValidation disabled={disabled}/>\n </div>}\n </Validation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"file":"StoragePropertyField.js","names":[],"sources":["../../../../../src/collection_editor/ui/collection_editor/properties/StoragePropertyField.tsx"],"sourcesContent":["\nimport React from \"react\";\nimport {\n Button,\n DebouncedTextField,\n ExpandablePanel,\n MultiSelect,\n MultiSelectItem,\n Select,\n SelectItem,\n Typography,\n UploadCloudIcon\n} from \"@rebasepro/ui\";\n\nimport { Field, FormexFieldProps, getIn, useFormex } from \"@rebasepro/forms\";\nimport { useStorageSources, useTranslation } from \"@rebasepro/app\";\nimport { DEFAULT_STORAGE_SOURCE_KEY } from \"@rebasepro/types\";\nimport { GeneralPropertyValidation } from \"./validation/GeneralPropertyValidation\";\nimport { ArrayPropertyValidation } from \"./validation/ArrayPropertyValidation\";\nimport { ValidationPanel } from \"./validation/ValidationPanel\";\nimport { SwitchControl } from \"../SwitchControl\";\n\nconst fileTypes: Record<string, string> = {\n \"image/*\": \"Images\",\n \"video/*\": \"Videos\",\n \"audio/*\": \"Audio files\",\n \"application/*\": \"Files (pdf, zip, csv, excel...)\",\n \"text/*\": \"Text files\"\n}\n\nexport function StoragePropertyField({\n multiple,\n existing,\n disabled\n}: {\n multiple: boolean;\n existing: boolean;\n disabled: boolean;\n}) {\n\n const {\n values,\n setFieldValue\n } = useFormex();\n const { t } = useTranslation();\n const storageSources = useStorageSources();\n\n const baseStoragePath = multiple ? \"of.storage\" : \"storage\";\n const acceptedFiles = `${baseStoragePath}.acceptedFiles`;\n const storageSource = `${baseStoragePath}.storageSource`;\n\n const metadata = `${baseStoragePath}.metadata`;\n const fileName = `${baseStoragePath}.fileName`;\n const maxSize = `${baseStoragePath}.maxSize`;\n const storagePath = `${baseStoragePath}.storagePath`;\n const storeUrl = `${baseStoragePath}.storeUrl`;\n const includeBucketUrl = `${baseStoragePath}.includeBucketUrl`;\n\n // Image resize config paths\n const imageResize = `${baseStoragePath}.imageResize`;\n const imageResizeMaxWidth = `${imageResize}.maxWidth`;\n const imageResizeMaxHeight = `${imageResize}.maxHeight`;\n const imageResizeMode = `${imageResize}.mode`;\n const imageResizeFormat = `${imageResize}.format`;\n const imageResizeQuality = `${imageResize}.quality`;\n\n const fileNameValue = (getIn(values, fileName) as string | undefined) ?? \"{rand}_{file}\";\n const storagePathValue = (getIn(values, storagePath) as string | undefined) ?? \"/\";\n const maxSizeValue = getIn(values, maxSize) as number | undefined;\n\n // Image resize values\n const imageResizeMaxWidthValue = getIn(values, imageResizeMaxWidth) as number | undefined;\n const imageResizeMaxHeightValue = getIn(values, imageResizeMaxHeight) as number | undefined;\n const imageResizeModeValue = (getIn(values, imageResizeMode) as string | undefined) ?? \"cover\";\n const imageResizeFormatValue = (getIn(values, imageResizeFormat) as string | undefined) ?? \"original\";\n const imageResizeQualityValue = getIn(values, imageResizeQuality) as number | undefined;\n\n const storedValue = getIn(values, acceptedFiles);\n const fileTypesValue: string[] | undefined = Array.isArray(storedValue) ? storedValue : undefined;\n const allFileTypesSelected = !fileTypesValue || fileTypesValue.length === 0;\n\n // Available storage backends (from `<Rebase storageSources={...}>`).\n const sourceKeys = Object.keys(storageSources.sources)\n .filter((key) => key !== DEFAULT_STORAGE_SOURCE_KEY);\n const storageSourceValue = (getIn(values, storageSource) as string | undefined) ?? DEFAULT_STORAGE_SOURCE_KEY;\n\n const handleTypesChange = (value: string[]) => {\n if (!value) setFieldValue(acceptedFiles, undefined);\n else setFieldValue(acceptedFiles, value);\n };\n\n const hasFilenameCallback = typeof fileNameValue === \"function\";\n const hasStoragePathCallback = typeof storagePathValue === \"function\";\n\n return (\n <>\n\n <div className={\"col-span-12\"}>\n\n <ExpandablePanel\n title={\n <div className=\"flex flex-row text-surface-500 text-text-secondary dark:text-text-secondary-dark\">\n <UploadCloudIcon/>\n <Typography variant={\"subtitle2\"}\n className=\"ml-4\">\n File upload config\n </Typography>\n </div>\n }>\n\n <div className={\"grid grid-cols-12 gap-2 p-4\"}>\n\n {sourceKeys.length > 0 && (\n <div className={\"col-span-12\"}>\n <Select\n className={\"w-full\"}\n disabled={disabled}\n name={storageSource}\n value={storageSourceValue}\n onValueChange={(value) =>\n setFieldValue(storageSource, !value || value === DEFAULT_STORAGE_SOURCE_KEY ? undefined : value)}\n label={\"Storage backend\"}\n renderValue={(key) => {\n const label = storageSources.registry[key]?.label;\n return label ?? (key === DEFAULT_STORAGE_SOURCE_KEY ? \"Default\" : key);\n }}>\n <SelectItem value={DEFAULT_STORAGE_SOURCE_KEY}>\n Default\n </SelectItem>\n {sourceKeys.map((key) => (\n <SelectItem key={key} value={key}>\n {storageSources.registry[key]?.label ?? key}\n </SelectItem>\n ))}\n </Select>\n </div>\n )}\n\n <div className={\"col-span-12\"}>\n\n <MultiSelect\n className={\"w-full\"}\n placeholder={\"All file types allowed\"}\n disabled={disabled}\n value={fileTypesValue ?? []}\n onValueChange={handleTypesChange}\n label={allFileTypesSelected ? undefined : \"Allowed file types\"}\n renderValues={(selected: string[]) => {\n if (!selected || selected.length === 0) return \"All file types allowed\";\n return selected.map((v: string) => fileTypes[v])\n .filter((v: string) => Boolean(v))\n .join(\", \");\n }}>\n\n {Object.entries(fileTypes).map(([value, label]) => (\n <MultiSelectItem key={value} value={value} className={\"flex items-center gap-2\"}>\n {/*<Checkbox*/}\n {/* checked={allFileTypesSelected || fileTypesValue.indexOf(value) > -1}/>*/}\n <div className={\"grow\"}>\n {label}\n </div>\n <Button size={\"small\"}\n variant={\"text\"}\n onClick={(e: React.MouseEvent) => {\n e.preventDefault();\n e.stopPropagation();\n return setFieldValue(acceptedFiles, [value]);\n }}>\n Only\n </Button>\n </MultiSelectItem>\n ))}\n\n </MultiSelect>\n </div>\n\n <div className={\"col-span-12\"}>\n <Field name={fileName}\n as={DebouncedTextField}\n label={t(\"storage_file_name\")}\n size={\"small\"}\n disabled={hasFilenameCallback || disabled}\n value={hasFilenameCallback ? \"-\" : fileNameValue}\n />\n </div>\n <div className={\"col-span-12\"}>\n <Field name={storagePath}\n as={DebouncedTextField}\n label={t(\"storage_path\")}\n disabled={hasStoragePathCallback || disabled}\n size={\"small\"}\n value={hasStoragePathCallback ? \"-\" : storagePathValue}\n />\n <Typography variant={\"caption\"} className={\"ml-3.5 mt-1 mb-2\"}>\n <p>You can use the following placeholders in\n the file name\n and storage path values:</p>\n <ul>\n <li>{\"{file} - Full name of the uploaded file\"}</li>\n <li>{\"{file.name} - Name of the uploaded file without extension\"}</li>\n <li>{\"{file.ext} - Extension of the uploaded file\"}</li>\n <li>{\"{id} - ID of the entity\"}</li>\n <li>{\"{propertyKey} - ID of this field\"}</li>\n <li>{\"{path} - Path of this entity\"}</li>\n <li>{\"{rand} - Random value used to avoid name collisions\"}</li>\n </ul>\n </Typography>\n\n <Field name={includeBucketUrl}\n type=\"checkbox\">\n {({\n field,\n form\n }: FormexFieldProps) => {\n return <SwitchControl\n label={t(\"storage_include_bucket_url\")}\n disabled={existing || disabled}\n form={form}\n field={field}/>;\n }}\n </Field>\n\n <Typography variant={\"caption\"} className={\"ml-3.5 mt-1 mb-2\"}>\n Turn this setting on if you want to save a fully-qualified storage URL\n (e.g. <code>s3://my-bucket/path/to/file</code>) instead of just the storage path.\n You can only change this prop upon creation.\n </Typography>\n\n <Field name={storeUrl}\n type=\"checkbox\">\n {({\n field,\n form\n }: FormexFieldProps) => {\n return <SwitchControl\n label={t(\"storage_save_url\")}\n disabled={existing || disabled}\n form={form}\n field={field}/>;\n }}\n </Field>\n\n <Typography variant={\"caption\"} className={\"ml-3.5 mt-1 mb-2\"}>\n Turn this setting on, if you prefer to save\n the download\n URL of the uploaded file instead of the\n storage path.\n You can only change this prop upon creation.\n </Typography>\n </div>\n\n <div className={\"col-span-12\"}>\n <DebouncedTextField name={maxSize}\n type={\"number\"}\n label={t(\"storage_max_size\")}\n size={\"small\"}\n value={maxSizeValue !== undefined && maxSizeValue !== null ? maxSizeValue.toString() : \"\"}\n onChange={(e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n const value = e.target.value;\n if (value === \"\") setFieldValue(maxSize, undefined);\n else setFieldValue(maxSize, parseInt(value));\n }}\n />\n </div>\n\n <div className={\"col-span-12 mt-4\"}>\n <Typography variant={\"subtitle2\"}\n color={\"secondary\"}\n className={\"mb-2 block\"}>\n Image Resize Configuration\n </Typography>\n <Typography variant={\"caption\"} className={\"mb-2 block text-xs\"}>\n Automatically resize and optimize images before upload (JPEG, PNG, WebP only)\n </Typography>\n </div>\n\n <div className={\"col-span-6\"}>\n <DebouncedTextField\n name={imageResizeMaxWidth}\n type={\"number\"}\n label={t(\"storage_max_width\")}\n size={\"small\"}\n disabled={disabled}\n value={imageResizeMaxWidthValue !== undefined && imageResizeMaxWidthValue !== null ? imageResizeMaxWidthValue.toString() : \"\"}\n onChange={(e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n const value = e.target.value;\n if (value === \"\") setFieldValue(imageResizeMaxWidth, undefined);\n else setFieldValue(imageResizeMaxWidth, parseInt(value));\n }}\n />\n </div>\n\n <div className={\"col-span-6\"}>\n <DebouncedTextField\n name={imageResizeMaxHeight}\n type={\"number\"}\n label={t(\"storage_max_height\")}\n size={\"small\"}\n disabled={disabled}\n value={imageResizeMaxHeightValue !== undefined && imageResizeMaxHeightValue !== null ? imageResizeMaxHeightValue.toString() : \"\"}\n onChange={(e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n const value = e.target.value;\n if (value === \"\") setFieldValue(imageResizeMaxHeight, undefined);\n else setFieldValue(imageResizeMaxHeight, parseInt(value));\n }}\n />\n </div>\n\n <div className={\"col-span-6\"}>\n <Select\n disabled={disabled}\n name={imageResizeMode}\n fullWidth\n size={\"medium\"}\n value={imageResizeModeValue || \"cover\"}\n onValueChange={(value) => setFieldValue(imageResizeMode, value || \"cover\")}\n label={t(\"storage_resize_mode\")}\n renderValue={(selected) => {\n if (!selected) return \"Cover\";\n return selected === \"contain\" ? \"Contain (fit within bounds)\" : \"Cover (fill bounds, may crop)\";\n }}>\n <SelectItem value=\"contain\">\n Contain (fit within bounds)\n </SelectItem>\n <SelectItem value=\"cover\">\n Cover (fill bounds, may crop)\n </SelectItem>\n </Select>\n </div>\n\n <div className={\"col-span-6\"}>\n <Select\n disabled={disabled}\n size={\"medium\"}\n fullWidth\n name={imageResizeFormat}\n value={imageResizeFormatValue || \"original\"}\n onValueChange={(value) => setFieldValue(imageResizeFormat, value || \"original\")}\n label={t(\"storage_output_format\")}\n renderValue={(selected) => {\n if (!selected) return \"Original\";\n return selected.charAt(0).toUpperCase() + selected.slice(1);\n }}>\n <SelectItem value=\"original\">\n Original (keep same format)\n </SelectItem>\n <SelectItem value=\"jpeg\">\n JPEG\n </SelectItem>\n <SelectItem value=\"png\">\n PNG\n </SelectItem>\n <SelectItem value=\"webp\">\n WebP (best compression)\n </SelectItem>\n </Select>\n </div>\n\n <div className={\"col-span-12\"}>\n <DebouncedTextField\n name={imageResizeQuality}\n type={\"number\"}\n label={t(\"storage_quality\")}\n size={\"small\"}\n disabled={disabled}\n value={imageResizeQualityValue !== undefined && imageResizeQualityValue !== null ? imageResizeQualityValue.toString() : \"\"}\n onChange={(e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n const value = e.target.value;\n if (value === \"\") setFieldValue(imageResizeQuality, undefined);\n else {\n const numValue = parseInt(value);\n if (numValue >= 0 && numValue <= 100) {\n setFieldValue(imageResizeQuality, numValue);\n }\n }\n }}\n />\n <Typography variant={\"caption\"} className={\"ml-3.5 mt-1 mb-2\"}>\n Higher quality = larger file size. Recommended: 80-90 for photos, 90-100 for graphics\n </Typography>\n </div>\n\n </div>\n </ExpandablePanel>\n\n </div>\n\n <div className={\"col-span-12\"}>\n\n <ValidationPanel>\n {!multiple && <div className={\"grid grid-cols-12 gap-2\"}>\n <GeneralPropertyValidation disabled={disabled}/>\n </div>}\n {multiple && <div className={\"col-span-12\"}>\n <ArrayPropertyValidation disabled={disabled}/>\n </div>}\n </ValidationPanel>\n\n </div>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;AAsBA,IAAM,YAAoC;CACtC,WAAW;CACX,WAAW;CACX,WAAW;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
3
2
|
import React from "react";
|
|
4
3
|
export interface AdditionalFieldValueProps<M extends Record<string, unknown>> {
|
|
5
4
|
field: AdditionalFieldDelegate<M>;
|
|
6
|
-
|
|
5
|
+
/**
|
|
6
|
+
* The record as the server sends the row — what `field.value` is handed.
|
|
7
|
+
* Keep it the same object while the record is unchanged: a new one runs
|
|
8
|
+
* `value` again.
|
|
9
|
+
*/
|
|
10
|
+
row: Record<string, unknown>;
|
|
11
|
+
/** The record's id, handed to `field.value` beside the row. */
|
|
12
|
+
id: string;
|
|
7
13
|
context: RebaseContext;
|
|
8
14
|
}
|
|
9
15
|
/**
|
|
@@ -22,4 +28,4 @@ export interface AdditionalFieldValueProps<M extends Record<string, unknown>> {
|
|
|
22
28
|
* the form and the read-only record), which is why the bug reached all three.
|
|
23
29
|
* Now there is one.
|
|
24
30
|
*/
|
|
25
|
-
export declare function AdditionalFieldValue<M extends Record<string, unknown>>({ field,
|
|
31
|
+
export declare function AdditionalFieldValue<M extends Record<string, unknown>>({ field, row, id, context }: AdditionalFieldValueProps<M>): React.JSX.Element;
|
|
@@ -17,17 +17,19 @@ import { Fragment, jsx } from "react/jsx-runtime";
|
|
|
17
17
|
* the form and the read-only record), which is why the bug reached all three.
|
|
18
18
|
* Now there is one.
|
|
19
19
|
*/
|
|
20
|
-
function AdditionalFieldValue({ field,
|
|
20
|
+
function AdditionalFieldValue({ field, row, id, context }) {
|
|
21
21
|
const [resolved, setResolved] = useState(() => {
|
|
22
22
|
const value = field.value?.({
|
|
23
|
-
|
|
23
|
+
row,
|
|
24
|
+
id,
|
|
24
25
|
context
|
|
25
26
|
});
|
|
26
27
|
return isPromise(value) ? void 0 : value;
|
|
27
28
|
});
|
|
28
29
|
useEffect(() => {
|
|
29
30
|
const value = field.value?.({
|
|
30
|
-
|
|
31
|
+
row,
|
|
32
|
+
id,
|
|
31
33
|
context
|
|
32
34
|
});
|
|
33
35
|
if (!isPromise(value)) {
|
|
@@ -46,7 +48,8 @@ function AdditionalFieldValue({ field, entity, context }) {
|
|
|
46
48
|
};
|
|
47
49
|
}, [
|
|
48
50
|
field,
|
|
49
|
-
|
|
51
|
+
row,
|
|
52
|
+
id,
|
|
50
53
|
context
|
|
51
54
|
]);
|
|
52
55
|
return /* @__PURE__ */ jsx(Fragment, { children: resolved === void 0 || resolved === null ? null : String(resolved) });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AdditionalFieldValue.js","names":[],"sources":["../../src/components/AdditionalFieldValue.tsx"],"sourcesContent":["import type { AdditionalFieldDelegate, RebaseContext } from \"@rebasepro/cms-types\";\nimport
|
|
1
|
+
{"version":3,"file":"AdditionalFieldValue.js","names":[],"sources":["../../src/components/AdditionalFieldValue.tsx"],"sourcesContent":["import type { AdditionalFieldDelegate, RebaseContext } from \"@rebasepro/cms-types\";\nimport React, { useEffect, useState } from \"react\";\n\nexport interface AdditionalFieldValueProps<M extends Record<string, unknown>> {\n field: AdditionalFieldDelegate<M>;\n /**\n * The record as the server sends the row — what `field.value` is handed.\n * Keep it the same object while the record is unchanged: a new one runs\n * `value` again.\n */\n row: Record<string, unknown>;\n /** The record's id, handed to `field.value` beside the row. */\n id: string;\n context: RebaseContext;\n}\n\n/**\n * Renders an `additionalFields` entry that supplies a `value` rather than a\n * `Builder`.\n *\n * `value` is typed `string | number | Promise<string | number>`, and the promise\n * arm has been part of that type from the start — the CSV export awaits it\n * correctly. Every *renderer* called `.toString()` on the result instead, so an\n * async value drew the literal text `[object Promise]` in the cell: a shape the\n * type promised, that worked in one of its two consumers, and failed silently in\n * the other. That is what made the obvious port of a FireCMS column — one that\n * fetches a title from a subcollection — look supported and not be.\n *\n * Three call sites had the same three lines copied between them (the table cell,\n * the form and the read-only record), which is why the bug reached all three.\n * Now there is one.\n */\nexport function AdditionalFieldValue<M extends Record<string, unknown>>({\n field,\n row,\n id,\n context\n}: AdditionalFieldValueProps<M>) {\n\n const [resolved, setResolved] = useState<string | number | undefined>(() => {\n const value = field.value?.({ row, id, context });\n // A synchronous value is available on the first render, so it never\n // flashes empty on its way in.\n return isPromise(value) ? undefined : value;\n });\n\n useEffect(() => {\n const value = field.value?.({ row, id, context });\n if (!isPromise(value)) {\n setResolved(value);\n return;\n }\n\n // The row may scroll out, or the record change, before this lands.\n let live = true;\n value.then(\n result => {\n if (live) setResolved(result);\n },\n error => {\n if (live) setResolved(undefined);\n console.warn(`[rebase] Additional field \"${field.key}\" failed to resolve:`, error);\n }\n );\n return () => {\n live = false;\n };\n }, [field, row, id, context]);\n\n return <>{resolved === undefined || resolved === null ? null : String(resolved)}</>;\n}\n\nfunction isPromise(value: unknown): value is Promise<string | number | undefined> {\n return typeof (value as Promise<unknown> | undefined)?.then === \"function\";\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAgCA,SAAgB,qBAAwD,EACpE,OACA,KACA,IACA,WAC6B;CAE7B,MAAM,CAAC,UAAU,eAAe,eAA4C;EACxE,MAAM,QAAQ,MAAM,QAAQ;GAAE;GAAK;GAAI;EAAQ,CAAC;EAGhD,OAAO,UAAU,KAAK,IAAI,KAAA,IAAY;CAC1C,CAAC;CAED,gBAAgB;EACZ,MAAM,QAAQ,MAAM,QAAQ;GAAE;GAAK;GAAI;EAAQ,CAAC;EAChD,IAAI,CAAC,UAAU,KAAK,GAAG;GACnB,YAAY,KAAK;GACjB;EACJ;EAGA,IAAI,OAAO;EACX,MAAM,MACF,WAAU;GACN,IAAI,MAAM,YAAY,MAAM;EAChC,IACA,UAAS;GACL,IAAI,MAAM,YAAY,KAAA,CAAS;GAC/B,QAAQ,KAAK,8BAA8B,MAAM,IAAI,uBAAuB,KAAK;EACrF,CACJ;EACA,aAAa;GACT,OAAO;EACX;CACJ,GAAG;EAAC;EAAO;EAAK;EAAI;CAAO,CAAC;CAE5B,OAAO,oBAAA,UAAA,EAAA,UAAG,aAAa,KAAA,KAAa,aAAa,OAAO,OAAO,OAAO,QAAQ,EAAI,CAAA;AACtF;AAEA,SAAS,UAAU,OAA+D;CAC9E,OAAO,OAAQ,OAAwC,SAAS;AACpE"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { ViewMode, AdminCollection } from "@rebasepro/cms-types";
|
|
2
|
+
import type { FilterValues } from "@rebasepro/types";
|
|
2
3
|
import React from "react";
|
|
4
|
+
import { type RowActionsRenderer } from "./CollectionViewBinding/RowActions.js";
|
|
3
5
|
/**
|
|
4
6
|
* Props for the {@link CollectionPanel} component.
|
|
5
7
|
*
|
|
@@ -7,31 +9,35 @@ import React from "react";
|
|
|
7
9
|
* designed for embedding collection views inside custom pages (home pages,
|
|
8
10
|
* dashboards, entity detail views, etc.).
|
|
9
11
|
*
|
|
10
|
-
* Name the collection
|
|
11
|
-
* {@link CollectionsProvider} above
|
|
12
|
-
* `collection`. All other props are optional overrides that take precedence
|
|
12
|
+
* Name the collection — `collection="orders"`, one registered with
|
|
13
|
+
* `<RebaseCMS>` or a {@link CollectionsProvider} above — or hand it over as a
|
|
14
|
+
* value, `collection={ordersCollection}`. All other props are optional overrides that take precedence
|
|
13
15
|
* over the collection's default configuration.
|
|
14
16
|
*
|
|
15
17
|
* @group Components
|
|
16
18
|
*/
|
|
17
19
|
export type CollectionPanelProps = CollectionPanelOptions & ({
|
|
18
20
|
/**
|
|
19
|
-
* The collection
|
|
20
|
-
*
|
|
21
|
+
* The collection to display: its name (`"orders"`), registered with
|
|
22
|
+
* `<RebaseCMS>` or a {@link CollectionsProvider} above, or the collection
|
|
23
|
+
* as a value — a `defineCollection` config or a resolved collection.
|
|
24
|
+
* Handed over as a value where no CMS navigation is mounted above, the
|
|
25
|
+
* panel brings its own {@link CollectionsProvider} for it, so it works
|
|
26
|
+
* anywhere under `<Rebase>` and a router.
|
|
21
27
|
*/
|
|
22
|
-
|
|
23
|
-
/** The collection itself, when it is not registered. */
|
|
24
|
-
collection?: AdminCollection;
|
|
25
|
-
} | {
|
|
28
|
+
collection: AdminCollection | string;
|
|
26
29
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* the panel brings its own {@link CollectionsProvider} for it, so it
|
|
30
|
-
* works anywhere under `<Rebase>` and a router.
|
|
30
|
+
* Where the rows live, where that is not the collection's name: a
|
|
31
|
+
* subcollection's full path, `posts/p1/comments`.
|
|
31
32
|
*/
|
|
32
|
-
collection: AdminCollection;
|
|
33
|
-
/** Defaults to `collection.slug`. */
|
|
34
33
|
path?: string;
|
|
34
|
+
} | {
|
|
35
|
+
/**
|
|
36
|
+
* @deprecated Name the collection with `collection`:
|
|
37
|
+
* `<CollectionPanel collection="orders"/>`. It warns once.
|
|
38
|
+
*/
|
|
39
|
+
path: string;
|
|
40
|
+
collection?: undefined;
|
|
35
41
|
});
|
|
36
42
|
/**
|
|
37
43
|
* The display options of a {@link CollectionPanel}.
|
|
@@ -46,17 +52,47 @@ export type CollectionPanelOptions = {
|
|
|
46
52
|
*/
|
|
47
53
|
title?: string | false;
|
|
48
54
|
/**
|
|
49
|
-
*
|
|
55
|
+
* The view mode the panel opens in, over the collection's default, the
|
|
56
|
+
* one in the URL and the one the person last picked. They can still
|
|
57
|
+
* switch.
|
|
50
58
|
*/
|
|
51
59
|
viewMode?: ViewMode;
|
|
52
60
|
/**
|
|
53
|
-
*
|
|
61
|
+
* @deprecated Use {@link orderBy}: `orderBy="field:desc"`. It warns once.
|
|
54
62
|
*/
|
|
55
63
|
sort?: [string, "asc" | "desc"];
|
|
64
|
+
/**
|
|
65
|
+
* The order the rows open in, as `"field:desc"` or `["field", "desc"]`.
|
|
66
|
+
* The person can still sort by another column.
|
|
67
|
+
*/
|
|
68
|
+
orderBy?: `${string}:asc` | `${string}:desc` | readonly [string, "asc" | "desc"];
|
|
69
|
+
/**
|
|
70
|
+
* Your own JSX on every row, card and kanban card — an "Approve" button,
|
|
71
|
+
* a "Ship" — handed the row as the server sends it and its id:
|
|
72
|
+
*
|
|
73
|
+
* ```tsx
|
|
74
|
+
* <CollectionPanel collection="orders" rowActions={(row, id) =>
|
|
75
|
+
* <Button size="small" onClick={() => update("orders", id, { status: "shipped" })}>Ship</Button>}/>
|
|
76
|
+
* ```
|
|
77
|
+
*
|
|
78
|
+
* In the table it is the last column; on a list row, a card and a kanban
|
|
79
|
+
* card it sits beside the collection's own actions. A click on it does
|
|
80
|
+
* not open the record.
|
|
81
|
+
*/
|
|
82
|
+
rowActions?: RowActionsRenderer;
|
|
56
83
|
/**
|
|
57
84
|
* Maximum number of entities to display.
|
|
58
85
|
*/
|
|
59
86
|
limit?: number;
|
|
87
|
+
/**
|
|
88
|
+
* Which rows the panel holds, as `useRows`' `where` takes it:
|
|
89
|
+
* `{ status: ["==", "pending"] }`. The person's own filters on other
|
|
90
|
+
* fields combine with it (AND); these fields cannot be changed or
|
|
91
|
+
* cleared from the toolbar. It follows the prop, so a tab bar or a chart
|
|
92
|
+
* click can drive it from state. Over the collection's `fixedFilter`,
|
|
93
|
+
* field by field.
|
|
94
|
+
*/
|
|
95
|
+
where?: FilterValues<string>;
|
|
60
96
|
/**
|
|
61
97
|
* Whether to sync filter/sort state with URL query params.
|
|
62
98
|
* Defaults to `false` (embedded panels shouldn't hijack the URL).
|
|
@@ -66,6 +102,13 @@ export type CollectionPanelOptions = {
|
|
|
66
102
|
* Override the entity open mode when clicking a entity.
|
|
67
103
|
*/
|
|
68
104
|
openEntityMode?: "side_panel" | "full_screen" | "split" | "dialog";
|
|
105
|
+
/**
|
|
106
|
+
* The ids of the rows drawn as selected — the one a page shows beside
|
|
107
|
+
* the list, say. `[]` draws none. Without it the panel highlights the
|
|
108
|
+
* row last opened. Compared as strings, so an integer key's `5` and
|
|
109
|
+
* `"5"` are one row.
|
|
110
|
+
*/
|
|
111
|
+
highlightedIds?: (string | number)[];
|
|
69
112
|
/**
|
|
70
113
|
* Additional CSS class name for the container.
|
|
71
114
|
*/
|
|
@@ -75,5 +118,61 @@ export type CollectionPanelOptions = {
|
|
|
75
118
|
* `enabledViews`, `entityActions`, `defaultFilter`, etc.).
|
|
76
119
|
*/
|
|
77
120
|
collectionOverrides?: Partial<AdminCollection>;
|
|
121
|
+
/**
|
|
122
|
+
* The properties the panel shows, in this order; the ones it leaves out
|
|
123
|
+
* are not drawn.
|
|
124
|
+
*
|
|
125
|
+
* - Table: the columns.
|
|
126
|
+
* - List, cards, kanban cards: what the row's or card's places — title,
|
|
127
|
+
* image, subtitle, status, date, relation chips, the list's columns —
|
|
128
|
+
* are filled from, earlier ones first. A place none of them fills
|
|
129
|
+
* stays empty.
|
|
130
|
+
*
|
|
131
|
+
* For this panel it wins over `propertiesOrder`, the column order the
|
|
132
|
+
* user saved, `listProperties` and what the cards infer. Column widths
|
|
133
|
+
* the user drags still persist; the order is yours, so columns are not
|
|
134
|
+
* dragged. A property hidden from collections stays hidden, and a
|
|
135
|
+
* custom view is handed the whole collection.
|
|
136
|
+
*/
|
|
137
|
+
fields?: string[];
|
|
138
|
+
/**
|
|
139
|
+
* The toolbar above the rows.
|
|
140
|
+
*
|
|
141
|
+
* - `"full"`, the default: the collection page's own toolbar.
|
|
142
|
+
* - `"compact"`: the view-mode switch, search, and New where the person
|
|
143
|
+
* may create.
|
|
144
|
+
* - `"none"`: no toolbar.
|
|
145
|
+
*
|
|
146
|
+
* Or compose one from its pieces:
|
|
147
|
+
*
|
|
148
|
+
* ```tsx
|
|
149
|
+
* <CollectionPanel collection="orders" toolbar={
|
|
150
|
+
* <CollectionToolbar
|
|
151
|
+
* start={<CollectionFiltersButton/>}
|
|
152
|
+
* end={<><CollectionSearchBar/><CollectionAddButton/></>}/>
|
|
153
|
+
* }/>
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
toolbar?: "full" | "compact" | "none" | React.ReactElement;
|
|
157
|
+
/**
|
|
158
|
+
* Called with the row and its id when one is clicked, instead of the
|
|
159
|
+
* panel opening it. Without it the record opens as `openEntityMode` says.
|
|
160
|
+
*
|
|
161
|
+
* The row is the one the server sends — the shape `useRows`, `useRow`
|
|
162
|
+
* and `FieldValue` take: ISO date strings (`YYYY-MM-DD` for a date-only
|
|
163
|
+
* column), and a belongsTo relation as its foreign key, under that key's
|
|
164
|
+
* own name. It is exactly the record's columns; the id is the string the
|
|
165
|
+
* admin addresses the record by — its primary key, a composite one's
|
|
166
|
+
* parts joined by `:::` — which `highlightedIds` and
|
|
167
|
+
* `useSidePanel().open` take.
|
|
168
|
+
*
|
|
169
|
+
* ```tsx
|
|
170
|
+
* const [selectedId, setSelectedId] = useState<string>();
|
|
171
|
+
* <CollectionPanel collection="orders"
|
|
172
|
+
* onRowClick={(row, id) => setSelectedId(id)}
|
|
173
|
+
* highlightedIds={selectedId ? [selectedId] : []}/>
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
onRowClick?: (row: Record<string, unknown>, id: string) => void;
|
|
78
177
|
};
|
|
79
|
-
export declare function CollectionPanel(
|
|
178
|
+
export declare function CollectionPanel(rawProps: CollectionPanelProps): React.JSX.Element;
|