@rebasepro/cms 0.28.2 → 0.29.0
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 +255 -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 +54 -0
- package/dist/mcp_view/index.js +262 -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 +30 -0
- package/dist/mcp_view/screen.js +245 -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 +160 -0
- package/dist/mcp_view/tool_driver.js +575 -0
- package/dist/mcp_view/tool_driver.js.map +1 -0
- package/dist/preview/components/DatePreview.d.ts +34 -1
- package/dist/preview/components/DatePreview.js +72 -37
- package/dist/preview/components/DatePreview.js.map +1 -1
- package/dist/routes/RebaseRoute.js +1 -1
- package/dist/routes/RebaseRoute.js.map +1 -1
- package/dist/selection/SelectionMenu.d.ts +5 -3
- package/dist/selection/SelectionMenu.js +16 -9
- package/dist/selection/SelectionMenu.js.map +1 -1
- package/dist/selection/index.d.ts +2 -1
- package/dist/selection/resolve_selection.d.ts +61 -7
- package/dist/selection/resolve_selection.js +93 -11
- package/dist/selection/resolve_selection.js.map +1 -1
- package/dist/types/components/EntityFormProps.d.ts +60 -10
- package/dist/types/fields.d.ts +2 -65
- package/dist/util/dataControllerAdapter.d.ts +8 -0
- package/dist/util/dataControllerAdapter.js +11 -0
- package/dist/util/dataControllerAdapter.js.map +1 -1
- package/dist/util/navigation_utils.d.ts +5 -4
- package/dist/util/navigation_utils.js +6 -6
- package/dist/util/navigation_utils.js.map +1 -1
- package/dist/util/propertyConfigMapper.d.ts +8 -0
- package/dist/util/propertyConfigMapper.js +16 -2
- package/dist/util/propertyConfigMapper.js.map +1 -1
- package/package.json +15 -9
- package/recipes/README.md +79 -26
- package/recipes/approval-queue.tsx +79 -0
- package/recipes/bulk-set-status.tsx +23 -17
- package/recipes/calendar-view.tsx +28 -23
- package/recipes/master-detail.tsx +75 -0
- package/recipes/my-preferences.tsx +3 -3
- package/recipes/orders-dashboard.tsx +58 -84
- package/recipes/site-settings.tsx +4 -4
- package/dist/components/EntityFormPanel.d.ts +0 -63
- package/dist/components/EntityFormPanel.js.map +0 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AdminCollection } from "@rebasepro/cms-types";
|
|
2
|
+
/**
|
|
3
|
+
* The collection as a record showing only `fields` lays it out, in the form
|
|
4
|
+
* and in the read-only view alike: `fields` as its order, which
|
|
5
|
+
* `getFormFieldKeys` also restricts to, and each section and the rail holding
|
|
6
|
+
* only those fields, in that order. Sections follow their first field.
|
|
7
|
+
*/
|
|
8
|
+
export declare function collectionShowing<M extends Record<string, unknown>>(collection: AdminCollection<M>, fields: string[]): AdminCollection<M>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region src/form/collection_showing.ts
|
|
2
|
+
/**
|
|
3
|
+
* The collection as a record showing only `fields` lays it out, in the form
|
|
4
|
+
* and in the read-only view alike: `fields` as its order, which
|
|
5
|
+
* `getFormFieldKeys` also restricts to, and each section and the rail holding
|
|
6
|
+
* only those fields, in that order. Sections follow their first field.
|
|
7
|
+
*/
|
|
8
|
+
function collectionShowing(collection, fields) {
|
|
9
|
+
const rank = new Map(fields.map((key, index) => [key, index]));
|
|
10
|
+
const ranked = (keys) => keys.filter((key) => rank.has(key)).sort((a, b) => (rank.get(a) ?? 0) - (rank.get(b) ?? 0));
|
|
11
|
+
const form = collection.form;
|
|
12
|
+
const firstRank = (keys) => Math.min(...keys.map((key) => rank.get(key) ?? Infinity));
|
|
13
|
+
return {
|
|
14
|
+
...collection,
|
|
15
|
+
propertiesOrder: fields,
|
|
16
|
+
form: form && {
|
|
17
|
+
...form,
|
|
18
|
+
sidebar: form.sidebar && ranked(form.sidebar),
|
|
19
|
+
sections: form.sections && form.sections.map((section) => ({
|
|
20
|
+
...section,
|
|
21
|
+
properties: ranked(section.properties)
|
|
22
|
+
})).sort((a, b) => firstRank(a.properties) - firstRank(b.properties))
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { collectionShowing };
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=collection_showing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collection_showing.js","names":[],"sources":["../../src/form/collection_showing.ts"],"sourcesContent":["import type { AdminCollection } from \"@rebasepro/cms-types\";\n\n/**\n * The collection as a record showing only `fields` lays it out, in the form\n * and in the read-only view alike: `fields` as its order, which\n * `getFormFieldKeys` also restricts to, and each section and the rail holding\n * only those fields, in that order. Sections follow their first field.\n */\nexport function collectionShowing<M extends Record<string, unknown>>(collection: AdminCollection<M>, fields: string[]): AdminCollection<M> {\n const rank = new Map(fields.map((key, index) => [key, index] as const));\n const ranked = (keys: string[]) => keys\n .filter(key => rank.has(key))\n .sort((a, b) => (rank.get(a) ?? 0) - (rank.get(b) ?? 0));\n const form = collection.form;\n const firstRank = (keys: string[]) => Math.min(...keys.map(key => rank.get(key) ?? Infinity));\n return {\n ...collection,\n propertiesOrder: fields as AdminCollection<M>[\"propertiesOrder\"],\n form: form && {\n ...form,\n sidebar: form.sidebar && ranked(form.sidebar as string[]) as typeof form.sidebar,\n sections: form.sections && form.sections\n .map(section => ({ ...section, properties: ranked(section.properties as string[]) as typeof section.properties }))\n .sort((a, b) => firstRank(a.properties as string[]) - firstRank(b.properties as string[]))\n }\n };\n}\n"],"mappings":";;;;;;;AAQA,SAAgB,kBAAqD,YAAgC,QAAsC;CACvI,MAAM,OAAO,IAAI,IAAI,OAAO,KAAK,KAAK,UAAU,CAAC,KAAK,KAAK,CAAU,CAAC;CACtE,MAAM,UAAU,SAAmB,KAC9B,QAAO,QAAO,KAAK,IAAI,GAAG,CAAC,CAAC,CAC5B,MAAM,GAAG,OAAO,KAAK,IAAI,CAAC,KAAK,MAAM,KAAK,IAAI,CAAC,KAAK,EAAE;CAC3D,MAAM,OAAO,WAAW;CACxB,MAAM,aAAa,SAAmB,KAAK,IAAI,GAAG,KAAK,KAAI,QAAO,KAAK,IAAI,GAAG,KAAK,QAAQ,CAAC;CAC5F,OAAO;EACH,GAAG;EACH,iBAAiB;EACjB,MAAM,QAAQ;GACV,GAAG;GACH,SAAS,KAAK,WAAW,OAAO,KAAK,OAAmB;GACxD,UAAU,KAAK,YAAY,KAAK,SAC3B,KAAI,aAAY;IAAE,GAAG;IAAS,YAAY,OAAO,QAAQ,UAAsB;GAA+B,EAAE,CAAC,CACjH,MAAM,GAAG,MAAM,UAAU,EAAE,UAAsB,IAAI,UAAU,EAAE,UAAsB,CAAC;EACjG;CACJ;AACJ"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { fieldSelector } from "../form_dom_ids.js";
|
|
1
2
|
import { useEffect, useRef } from "react";
|
|
2
3
|
import { useFormex } from "@rebasepro/forms";
|
|
3
4
|
//#region src/form/components/ErrorFocus.tsx
|
|
@@ -8,7 +9,7 @@ var ErrorFocus = ({ containerRef }) => {
|
|
|
8
9
|
if (version === prevVersion.current) return;
|
|
9
10
|
const keys = Object.keys(errors);
|
|
10
11
|
if (!isValidating && keys.length > 0) {
|
|
11
|
-
const errorElement = containerRef?.current?.querySelector(
|
|
12
|
+
const errorElement = containerRef?.current?.querySelector(fieldSelector(keys[0]));
|
|
12
13
|
if (errorElement) {
|
|
13
14
|
errorElement.scrollIntoView({
|
|
14
15
|
behavior: "smooth",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorFocus.js","names":[],"sources":["../../../src/form/components/ErrorFocus.tsx"],"sourcesContent":["import React, { useEffect, useRef } from \"react\";\nimport { useFormex } from \"@rebasepro/forms\";\n\nexport const ErrorFocus = ({ containerRef }:\n {\n containerRef?: React.RefObject<HTMLDivElement | null>\n }) => {\n const {\n isValidating,\n errors,\n version\n } = useFormex();\n\n const prevVersion = useRef(version);\n\n useEffect(() => {\n\n if (version === prevVersion.current) {\n return;\n }\n\n const keys = Object.keys(errors);\n\n // Whenever there are errors and the form has been submitted and is not validating\n if (!isValidating && keys.length > 0) {\n const errorElement = containerRef?.current?.querySelector<HTMLDivElement>(\n
|
|
1
|
+
{"version":3,"file":"ErrorFocus.js","names":[],"sources":["../../../src/form/components/ErrorFocus.tsx"],"sourcesContent":["import React, { useEffect, useRef } from \"react\";\nimport { useFormex } from \"@rebasepro/forms\";\nimport { fieldSelector } from \"../form_dom_ids\";\n\nexport const ErrorFocus = ({ containerRef }:\n {\n containerRef?: React.RefObject<HTMLDivElement | null>\n }) => {\n const {\n isValidating,\n errors,\n version\n } = useFormex();\n\n const prevVersion = useRef(version);\n\n useEffect(() => {\n\n if (version === prevVersion.current) {\n return;\n }\n\n const keys = Object.keys(errors);\n\n // Whenever there are errors and the form has been submitted and is not validating\n if (!isValidating && keys.length > 0) {\n // By key inside this form's own container: another form on the\n // page holds a field of the same name.\n const errorElement = containerRef?.current?.querySelector<HTMLDivElement>(\n fieldSelector(keys[0])\n );\n\n if (errorElement) {\n errorElement.scrollIntoView({\n behavior: \"smooth\",\n block: \"center\"\n });\n const input = errorElement.querySelector(\"input\");\n if (input) input.focus();\n }\n prevVersion.current = version;\n }\n }, [isValidating, errors, containerRef, version]);\n\n // This component does not render anything by itself.\n return null;\n};\n"],"mappings":";;;;AAIA,IAAa,cAAc,EAAE,mBAGnB;CACN,MAAM,EACF,cACA,QACA,YACA,UAAU;CAEd,MAAM,cAAc,OAAO,OAAO;CAElC,gBAAgB;EAEZ,IAAI,YAAY,YAAY,SACxB;EAGJ,MAAM,OAAO,OAAO,KAAK,MAAM;EAG/B,IAAI,CAAC,gBAAgB,KAAK,SAAS,GAAG;GAGlC,MAAM,eAAe,cAAc,SAAS,cACxC,cAAc,KAAK,EAAE,CACzB;GAEA,IAAI,cAAc;IACd,aAAa,eAAe;KACxB,UAAU;KACV,OAAO;IACX,CAAC;IACD,MAAM,QAAQ,aAAa,cAAc,OAAO;IAChD,IAAI,OAAO,MAAM,MAAM;GAC3B;GACA,YAAY,UAAU;EAC1B;CACJ,GAAG;EAAC;EAAc;EAAQ;EAAc;CAAO,CAAC;CAGhD,OAAO;AACX"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getIconForProperty } from "../../util/property_utils.js";
|
|
2
2
|
import { PropertyKeyHint } from "../../components/PropertyKeyHint.js";
|
|
3
|
+
import { fieldDomId, useFormDomScope } from "../form_dom_ids.js";
|
|
3
4
|
import "react";
|
|
4
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
6
|
import { ErrorBoundary, Typography, cls } from "@rebasepro/ui";
|
|
@@ -80,7 +81,8 @@ function FieldBlock({ propertyKey, property, showLabel, labelInside = false, mod
|
|
|
80
81
|
const required = Boolean(property?.validation?.required) && !(property && isReadOnly(property));
|
|
81
82
|
const footed = labelInside && !reading;
|
|
82
83
|
return /* @__PURE__ */ jsxs("div", {
|
|
83
|
-
id:
|
|
84
|
+
id: fieldDomId(useFormDomScope(), propertyKey),
|
|
85
|
+
"data-form-field": propertyKey,
|
|
84
86
|
className: cls("relative flex flex-col min-w-0", footed && "group/label"),
|
|
85
87
|
children: [
|
|
86
88
|
showLabel && /* @__PURE__ */ jsxs("div", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldBlock.js","names":[],"sources":["../../../src/form/components/FieldBlock.tsx"],"sourcesContent":["import type { Property } from \"@rebasepro/types\";\nimport type { PropertySpan } from \"@rebasepro/cms-types\";\nimport React from \"react\";\nimport { cls, ErrorBoundary, Typography } from \"@rebasepro/ui\";\nimport { isReadOnly } from \"@rebasepro/app\";\nimport { getIconForProperty } from \"../../util/property_utils\";\nimport { PropertyKeyHint } from \"../../components/PropertyKeyHint\";\n\n/**\n * Grid placement for a span.\n *\n * Written out as literal class strings rather than composed, because Tailwind\n * scans source text: a template literal would produce classes that exist at\n * runtime and were never generated into the stylesheet.\n *\n * Below the column breakpoint every field takes the single available column, so\n * the side panel, the dialog and mobile all get a plain stack.\n *\n * Lives here rather than in the form, because the read-only rendering of a\n * record places its fields on the same grid — a record that changes shape when\n * you press Edit is the bug this whole layout exists to avoid.\n */\nexport function spanClass(span: PropertySpan): string {\n switch (span) {\n case 1: return \"@2xl/col:col-span-1\";\n case 2: return \"@2xl/col:col-span-2\";\n case 3: return \"@2xl/col:col-span-3\";\n case 4: return \"@2xl/col:col-span-4\";\n }\n}\n\n/**\n * Does this property's editor supply its own heading?\n *\n * Arrays, maps, `oneOf` blocks and key-value editors render as a collapsible\n * panel whose header *is* the label — hiding it would leave a panel you cannot\n * identify or, worse, cannot expand. Those keep their own; everything else gets\n * its label from {@link FieldBlock}, which is what makes a text field and a\n * select finally agree on where a label goes.\n *\n * Exported because the layout resolver's span rules and this rule have to stay\n * in step: the self-labelling types are exactly the ones that take a full row.\n */\nexport function isSelfLabellingProperty(property: Property | undefined): boolean {\n if (!property) return false;\n switch (property.type) {\n case \"map\":\n // `spreadChildren` inlines the children into the parent grid, so\n // there is no panel and therefore no header to reuse as the label.\n return !property.admin?.spreadChildren;\n case \"array\": {\n // Most arrays render as an expandable panel whose header is the\n // label — `repeat`, `block`, `custom_array`, `multi_references`.\n // The exceptions are the ones that resolve to an inline control:\n // an enum array is a multi-select and a storage array is a\n // dropzone, and both take their label from the form.\n //\n // This mirrors `getFieldConfig`'s array branch. Getting it backwards\n // is visible: an array of plain strings is a `repeat` panel, and\n // treating it as inline printed \"Available Locales\" twice, once\n // from the form and once from the panel's own header.\n if (property.oneOf) return true;\n if (Array.isArray(property.of) || !property.of) return true;\n const of = property.of;\n if (of.type === \"string\" && (of.enum || of.storage)) return false;\n if (of.type === \"number\" && of.enum) return false;\n return true;\n }\n default:\n return false;\n }\n}\n\n/**\n * The type icon in a field label, in px.\n *\n * Matched to the label's 13px rather than taken from `iconSize.smallest` (16),\n * which is sized for buttons. Exported so the surfaces that draw a label\n * themselves — the additional-field cards, the rail — can stay in step.\n */\nexport const LABEL_ICON_SIZE = 14;\n\nexport interface FieldBlockProps {\n propertyKey: string;\n property?: Property;\n /** Rendered by the form rather than by the field, unless self-labelling. */\n showLabel: boolean;\n /**\n * The control draws its label inside its own box — the one-line fields of a\n * record form (see `labelsInsideControl`). The block then draws no label\n * row, but it still owns what goes under the box: the description, indented\n * to the value inside the box, and the property's key, on that same line.\n */\n labelInside?: boolean;\n /**\n * Which of the two renderings this block frames.\n *\n * The **label is identical in both** — same size, same weight, same colour,\n * same type icon, same required marker. A field is the same field whether or\n * not you are editing it, and a record whose labels restyle themselves under\n * Edit reads as two different screens.\n *\n * What `\"read\"` drops is the *description*, which is not part of the label:\n * it is input help. \"Sum of all line items before tax and shipping\" under a\n * number that is visibly a sum tells a reader nothing, and a line of it\n * under every field is what a record has instead of room.\n */\n mode?: \"edit\" | \"read\";\n /**\n * Label text, when there is no property to take it from.\n *\n * For additional fields, which are columns a collection computes rather\n * than stores. They go on the same grid as the properties and so have to\n * carry the same label — drawing their own is how they ended up a size out\n * and a couple of pixels off from the field beside them.\n */\n label?: string;\n /** Type icon, when there is no property to derive one from. */\n icon?: React.ReactNode;\n children: React.ReactNode;\n}\n\n/**\n * One field's worth of the form grid: label, control, description.\n *\n * The same block frames the read-only rendering of a record, so a field sits in\n * the same place, at the same width, under the same label whether or not you are\n * editing it — see {@link EntityViewBinding}.\n *\n * The label is one size down from the control it names (13px against the body's\n * 14) with its icon matched to it at 14px. Labels are scaffolding: you read them\n * to find the value, then read the value. Setting them at body size made a\n * column of records scan as a column of field names with data attached.\n */\nexport function FieldBlock({\n propertyKey,\n property,\n showLabel,\n labelInside = false,\n mode = \"edit\",\n label,\n icon,\n children\n}: FieldBlockProps) {\n\n const reading = mode === \"read\";\n const description = property?.description?.trim();\n // Only where someone can supply the value: on a read-only field the marker\n // asks for input nobody can give, and `validation.required` there states\n // what the column holds, which the form need not shout about.\n const required = Boolean(property?.validation?.required) && !(property && isReadOnly(property));\n const footed = labelInside && !reading;\n\n return (\n // Top-aligned: with the description below the control, every label is a\n // single line, so the controls line up on their own. (Bottom-aligning\n // was only needed while the description sat between label and control.)\n <div\n id={`form_field_${propertyKey}`}\n // With the label inside the control there is no label row to hover\n // for the key; the whole field reveals it instead.\n className={cls(\"relative flex flex-col min-w-0\", footed && \"group/label\")}>\n\n {showLabel && (\n <div className={cls(\n \"group/label flex items-center gap-1.5 min-w-0 font-medium leading-tight mb-1.5\",\n // Primary, not secondary: the label names the field and the\n // reference sets its labels in the primary ink; the type icon\n // beside it stays muted so the name carries the row.\n \"text-[13px] text-text-primary dark:text-text-primary-dark\"\n )}>\n {/* Small and quiet: enough to tell a number from a\n relation at a glance, not enough to compete with the\n field name. Matched to the label's 13px rather than\n left at the 16px `smallest` token, which put the\n heaviest mark on the row on the least important\n thing in it. */}\n {(property || icon) && (\n <span className={\"shrink-0 text-text-disabled dark:text-text-disabled-dark\"}>\n {property ? getIconForProperty(property, LABEL_ICON_SIZE) : icon}\n </span>\n )}\n <span className={\"truncate\"}>{property?.name ?? label ?? propertyKey}</span>\n {required && <span className={\"text-red-500 dark:text-red-500 -ml-1\"}>*</span>}\n {/* In the row, not over it. This was a tooltip on the\n label and on the control, which opened whenever a\n field took focus and covered the label being read. */}\n {property && <PropertyKeyHint propertyKey={propertyKey}/>}\n </div>\n )}\n\n {/* `data-field-control` names the slot for anything measuring the\n control itself. A class cannot: the label row carries\n `min-w-0` too, and a selector for it measured the label. */}\n <div className={\"min-w-0\"} data-field-control={\"\"}>\n <ErrorBoundary>\n {children}\n </ErrorBoundary>\n </div>\n\n {/* Under the control, where it reads as a note about the thing you\n just filled in rather than a subtitle of the next label. */}\n {showLabel && description && !reading && (\n <Typography variant={\"caption\"}\n color={\"disabled\"}\n className={\"mt-1.5 ml-0.5 leading-snug\"}>\n {description}\n </Typography>\n )}\n\n {/* A label drawn inside the box: the description is indented to\n the value, as the binding's own error line is (`ml-3.5`), and\n the key sits at the end of that line. A field with no\n description has no line to put it on, so the key hangs in the\n row gap below the box rather than reserving a line under every\n field for something only a hover shows. */}\n {footed && (description || property) && (\n <div className={cls(\n \"flex items-start gap-2 min-w-0 ml-3.5\",\n description ? \"mt-1.5\" : \"absolute top-full right-0 mt-1\"\n )}>\n {description && (\n <Typography variant={\"caption\"}\n color={\"disabled\"}\n className={\"grow min-w-0 leading-snug\"}>\n {description}\n </Typography>\n )}\n {property && <PropertyKeyHint propertyKey={propertyKey}\n className={description ? \"ml-auto shrink-0\" : undefined}/>}\n </div>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;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;MAAM,WAAW;gBAAwC;KAAO,CAAA;KAI5E,YAAY,oBAAC,iBAAD,EAA8B,YAAa,CAAA;IACvD;;GAMT,oBAAC,OAAD;IAAK,WAAW;IAAW,sBAAoB;cAC3C,oBAAC,eAAD,EACK,SACU,CAAA;GACd,CAAA;GAIJ,aAAa,eAAe,CAAC,WAC1B,oBAAC,YAAD;IAAY,SAAS;IACjB,OAAO;IACP,WAAW;cACV;GACO,CAAA;GASf,WAAW,eAAe,aACvB,qBAAC,OAAD;IAAK,WAAW,IACZ,yCACA,cAAc,WAAW,gCAC7B;cAHA,CAIK,eACG,oBAAC,YAAD;KAAY,SAAS;KACjB,OAAO;KACP,WAAW;eACV;IACO,CAAA,GAEf,YAAY,oBAAC,iBAAD;KAA8B;KACvC,WAAW,cAAc,qBAAqB,KAAA;IAAW,CAAA,CAC5D;;EAER;;AAEb"}
|
|
1
|
+
{"version":3,"file":"FieldBlock.js","names":[],"sources":["../../../src/form/components/FieldBlock.tsx"],"sourcesContent":["import type { Property } from \"@rebasepro/types\";\nimport type { PropertySpan } from \"@rebasepro/cms-types\";\nimport React from \"react\";\nimport { cls, ErrorBoundary, Typography } from \"@rebasepro/ui\";\nimport { isReadOnly } from \"@rebasepro/app\";\nimport { getIconForProperty } from \"../../util/property_utils\";\nimport { PropertyKeyHint } from \"../../components/PropertyKeyHint\";\nimport { fieldDomId, useFormDomScope } from \"../form_dom_ids\";\n\n/**\n * Grid placement for a span.\n *\n * Written out as literal class strings rather than composed, because Tailwind\n * scans source text: a template literal would produce classes that exist at\n * runtime and were never generated into the stylesheet.\n *\n * Below the column breakpoint every field takes the single available column, so\n * the side panel, the dialog and mobile all get a plain stack.\n *\n * Lives here rather than in the form, because the read-only rendering of a\n * record places its fields on the same grid — a record that changes shape when\n * you press Edit is the bug this whole layout exists to avoid.\n */\nexport function spanClass(span: PropertySpan): string {\n switch (span) {\n case 1: return \"@2xl/col:col-span-1\";\n case 2: return \"@2xl/col:col-span-2\";\n case 3: return \"@2xl/col:col-span-3\";\n case 4: return \"@2xl/col:col-span-4\";\n }\n}\n\n/**\n * Does this property's editor supply its own heading?\n *\n * Arrays, maps, `oneOf` blocks and key-value editors render as a collapsible\n * panel whose header *is* the label — hiding it would leave a panel you cannot\n * identify or, worse, cannot expand. Those keep their own; everything else gets\n * its label from {@link FieldBlock}, which is what makes a text field and a\n * select finally agree on where a label goes.\n *\n * Exported because the layout resolver's span rules and this rule have to stay\n * in step: the self-labelling types are exactly the ones that take a full row.\n */\nexport function isSelfLabellingProperty(property: Property | undefined): boolean {\n if (!property) return false;\n switch (property.type) {\n case \"map\":\n // `spreadChildren` inlines the children into the parent grid, so\n // there is no panel and therefore no header to reuse as the label.\n return !property.admin?.spreadChildren;\n case \"array\": {\n // Most arrays render as an expandable panel whose header is the\n // label — `repeat`, `block`, `custom_array`, `multi_references`.\n // The exceptions are the ones that resolve to an inline control:\n // an enum array is a multi-select and a storage array is a\n // dropzone, and both take their label from the form.\n //\n // This mirrors `getFieldConfig`'s array branch. Getting it backwards\n // is visible: an array of plain strings is a `repeat` panel, and\n // treating it as inline printed \"Available Locales\" twice, once\n // from the form and once from the panel's own header.\n if (property.oneOf) return true;\n if (Array.isArray(property.of) || !property.of) return true;\n const of = property.of;\n if (of.type === \"string\" && (of.enum || of.storage)) return false;\n if (of.type === \"number\" && of.enum) return false;\n return true;\n }\n default:\n return false;\n }\n}\n\n/**\n * The type icon in a field label, in px.\n *\n * Matched to the label's 13px rather than taken from `iconSize.smallest` (16),\n * which is sized for buttons. Exported so the surfaces that draw a label\n * themselves — the additional-field cards, the rail — can stay in step.\n */\nexport const LABEL_ICON_SIZE = 14;\n\nexport interface FieldBlockProps {\n propertyKey: string;\n property?: Property;\n /** Rendered by the form rather than by the field, unless self-labelling. */\n showLabel: boolean;\n /**\n * The control draws its label inside its own box — the one-line fields of a\n * record form (see `labelsInsideControl`). The block then draws no label\n * row, but it still owns what goes under the box: the description, indented\n * to the value inside the box, and the property's key, on that same line.\n */\n labelInside?: boolean;\n /**\n * Which of the two renderings this block frames.\n *\n * The **label is identical in both** — same size, same weight, same colour,\n * same type icon, same required marker. A field is the same field whether or\n * not you are editing it, and a record whose labels restyle themselves under\n * Edit reads as two different screens.\n *\n * What `\"read\"` drops is the *description*, which is not part of the label:\n * it is input help. \"Sum of all line items before tax and shipping\" under a\n * number that is visibly a sum tells a reader nothing, and a line of it\n * under every field is what a record has instead of room.\n */\n mode?: \"edit\" | \"read\";\n /**\n * Label text, when there is no property to take it from.\n *\n * For additional fields, which are columns a collection computes rather\n * than stores. They go on the same grid as the properties and so have to\n * carry the same label — drawing their own is how they ended up a size out\n * and a couple of pixels off from the field beside them.\n */\n label?: string;\n /** Type icon, when there is no property to derive one from. */\n icon?: React.ReactNode;\n children: React.ReactNode;\n}\n\n/**\n * One field's worth of the form grid: label, control, description.\n *\n * The same block frames the read-only rendering of a record, so a field sits in\n * the same place, at the same width, under the same label whether or not you are\n * editing it — see {@link EntityViewBinding}.\n *\n * The label is one size down from the control it names (13px against the body's\n * 14) with its icon matched to it at 14px. Labels are scaffolding: you read them\n * to find the value, then read the value. Setting them at body size made a\n * column of records scan as a column of field names with data attached.\n */\nexport function FieldBlock({\n propertyKey,\n property,\n showLabel,\n labelInside = false,\n mode = \"edit\",\n label,\n icon,\n children\n}: FieldBlockProps) {\n\n const reading = mode === \"read\";\n const description = property?.description?.trim();\n // Only where someone can supply the value: on a read-only field the marker\n // asks for input nobody can give, and `validation.required` there states\n // what the column holds, which the form need not shout about.\n const required = Boolean(property?.validation?.required) && !(property && isReadOnly(property));\n const footed = labelInside && !reading;\n const domScope = useFormDomScope();\n\n return (\n // Top-aligned: with the description below the control, every label is a\n // single line, so the controls line up on their own. (Bottom-aligning\n // was only needed while the description sat between label and control.)\n <div\n id={fieldDomId(domScope, propertyKey)}\n data-form-field={propertyKey}\n // With the label inside the control there is no label row to hover\n // for the key; the whole field reveals it instead.\n className={cls(\"relative flex flex-col min-w-0\", footed && \"group/label\")}>\n\n {showLabel && (\n <div className={cls(\n \"group/label flex items-center gap-1.5 min-w-0 font-medium leading-tight mb-1.5\",\n // Primary, not secondary: the label names the field and the\n // reference sets its labels in the primary ink; the type icon\n // beside it stays muted so the name carries the row.\n \"text-[13px] text-text-primary dark:text-text-primary-dark\"\n )}>\n {/* Small and quiet: enough to tell a number from a\n relation at a glance, not enough to compete with the\n field name. Matched to the label's 13px rather than\n left at the 16px `smallest` token, which put the\n heaviest mark on the row on the least important\n thing in it. */}\n {(property || icon) && (\n <span className={\"shrink-0 text-text-disabled dark:text-text-disabled-dark\"}>\n {property ? getIconForProperty(property, LABEL_ICON_SIZE) : icon}\n </span>\n )}\n <span className={\"truncate\"}>{property?.name ?? label ?? propertyKey}</span>\n {required && <span className={\"text-red-500 dark:text-red-500 -ml-1\"}>*</span>}\n {/* In the row, not over it. This was a tooltip on the\n label and on the control, which opened whenever a\n field took focus and covered the label being read. */}\n {property && <PropertyKeyHint propertyKey={propertyKey}/>}\n </div>\n )}\n\n {/* `data-field-control` names the slot for anything measuring the\n control itself. A class cannot: the label row carries\n `min-w-0` too, and a selector for it measured the label. */}\n <div className={\"min-w-0\"} data-field-control={\"\"}>\n <ErrorBoundary>\n {children}\n </ErrorBoundary>\n </div>\n\n {/* Under the control, where it reads as a note about the thing you\n just filled in rather than a subtitle of the next label. */}\n {showLabel && description && !reading && (\n <Typography variant={\"caption\"}\n color={\"disabled\"}\n className={\"mt-1.5 ml-0.5 leading-snug\"}>\n {description}\n </Typography>\n )}\n\n {/* A label drawn inside the box: the description is indented to\n the value, as the binding's own error line is (`ml-3.5`), and\n the key sits at the end of that line. A field with no\n description has no line to put it on, so the key hangs in the\n row gap below the box rather than reserving a line under every\n field for something only a hover shows. */}\n {footed && (description || property) && (\n <div className={cls(\n \"flex items-start gap-2 min-w-0 ml-3.5\",\n description ? \"mt-1.5\" : \"absolute top-full right-0 mt-1\"\n )}>\n {description && (\n <Typography variant={\"caption\"}\n color={\"disabled\"}\n className={\"grow min-w-0 leading-snug\"}>\n {description}\n </Typography>\n )}\n {property && <PropertyKeyHint propertyKey={propertyKey}\n className={description ? \"ml-auto shrink-0\" : undefined}/>}\n </div>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuBA,SAAgB,UAAU,MAA4B;CAClD,QAAQ,MAAR;EACI,KAAK,GAAG,OAAO;EACf,KAAK,GAAG,OAAO;EACf,KAAK,GAAG,OAAO;EACf,KAAK,GAAG,OAAO;CACnB;AACJ;;;;;;;;;;;;;AAcA,SAAgB,wBAAwB,UAAyC;CAC7E,IAAI,CAAC,UAAU,OAAO;CACtB,QAAQ,SAAS,MAAjB;EACI,KAAK,OAGD,OAAO,CAAC,SAAS,OAAO;EAC5B,KAAK,SAAS;GAWV,IAAI,SAAS,OAAO,OAAO;GAC3B,IAAI,MAAM,QAAQ,SAAS,EAAE,KAAK,CAAC,SAAS,IAAI,OAAO;GACvD,MAAM,KAAK,SAAS;GACpB,IAAI,GAAG,SAAS,aAAa,GAAG,QAAQ,GAAG,UAAU,OAAO;GAC5D,IAAI,GAAG,SAAS,YAAY,GAAG,MAAM,OAAO;GAC5C,OAAO;EACX;EACA,SACI,OAAO;CACf;AACJ;;;;;;;;AASA,IAAa,kBAAkB;;;;;;;;;;;;;AAsD/B,SAAgB,WAAW,EACvB,aACA,UACA,WACA,cAAc,OACd,OAAO,QACP,OACA,MACA,YACgB;CAEhB,MAAM,UAAU,SAAS;CACzB,MAAM,cAAc,UAAU,aAAa,KAAK;CAIhD,MAAM,WAAW,QAAQ,UAAU,YAAY,QAAQ,KAAK,EAAE,YAAY,WAAW,QAAQ;CAC7F,MAAM,SAAS,eAAe,CAAC;CAG/B,OAII,qBAAC,OAAD;EACI,IAAI,WAPK,gBAOM,GAAU,WAAW;EACpC,mBAAiB;EAGjB,WAAW,IAAI,kCAAkC,UAAU,aAAa;YAL5E;GAOK,aACG,qBAAC,OAAD;IAAK,WAAW,IACZ,kFAIA,2DACJ;cANA;MAaM,YAAY,SACV,oBAAC,QAAD;MAAM,WAAW;gBACZ,WAAW,mBAAmB,UAAA,EAAyB,IAAI;KAC1D,CAAA;KAEV,oBAAC,QAAD;MAAM,WAAW;gBAAa,UAAU,QAAQ,SAAS;KAAkB,CAAA;KAC1E,YAAY,oBAAC,QAAD;MAAM,WAAW;gBAAwC;KAAO,CAAA;KAI5E,YAAY,oBAAC,iBAAD,EAA8B,YAAa,CAAA;IACvD;;GAMT,oBAAC,OAAD;IAAK,WAAW;IAAW,sBAAoB;cAC3C,oBAAC,eAAD,EACK,SACU,CAAA;GACd,CAAA;GAIJ,aAAa,eAAe,CAAC,WAC1B,oBAAC,YAAD;IAAY,SAAS;IACjB,OAAO;IACP,WAAW;cACV;GACO,CAAA;GASf,WAAW,eAAe,aACvB,qBAAC,OAAD;IAAK,WAAW,IACZ,yCACA,cAAc,WAAW,gCAC7B;cAHA,CAIK,eACG,oBAAC,YAAD;KAAY,SAAS;KACjB,OAAO;KACP,WAAW;eACV;IACO,CAAA,GAEf,YAAY,oBAAC,iBAAD;KAA8B;KACvC,WAAW,cAAc,qBAAqB,KAAA;IAAW,CAAA,CAC5D;;EAER;;AAEb"}
|
|
@@ -5,7 +5,11 @@ export interface FormRailProps {
|
|
|
5
5
|
fields: ResolvedFormField[];
|
|
6
6
|
showRecordMeta: boolean;
|
|
7
7
|
entity?: Entity<Record<string, unknown>>;
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Renders one field. Defaults to the enclosing record form's own, which
|
|
10
|
+
* applies every rule the form has for a field.
|
|
11
|
+
*/
|
|
12
|
+
renderField?: (field: ResolvedFormField) => React.ReactNode;
|
|
9
13
|
}
|
|
10
14
|
/**
|
|
11
15
|
* The metadata column beside the form.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useFormFieldsContext } from "../FormFieldsContext.js";
|
|
1
2
|
import React from "react";
|
|
2
3
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
4
|
import { CheckIcon, CopyIcon, IconButton, Tooltip, Typography, cls, iconSize } from "@rebasepro/ui";
|
|
@@ -11,12 +12,15 @@ import { CheckIcon, CopyIcon, IconButton, Tooltip, Typography, cls, iconSize } f
|
|
|
11
12
|
* visible while you scroll.
|
|
12
13
|
*/
|
|
13
14
|
function FormRail({ fields, showRecordMeta, entity, renderField }) {
|
|
15
|
+
const formFields = useFormFieldsContext();
|
|
16
|
+
const render = renderField ?? formFields?.renderField;
|
|
14
17
|
if (!fields.length && !showRecordMeta) return null;
|
|
18
|
+
if (fields.length > 0 && !render) throw new Error("FormRail needs `renderField` outside a record form");
|
|
15
19
|
return /* @__PURE__ */ jsxs("aside", {
|
|
16
20
|
className: cls("flex flex-col gap-6 shrink-0 w-76 @7xl/form:w-84 overflow-y-auto", "px-5 py-6 bg-surface-sheet"),
|
|
17
21
|
children: [fields.length > 0 && /* @__PURE__ */ jsx("div", {
|
|
18
22
|
className: "flex flex-col gap-5",
|
|
19
|
-
children: fields.map(
|
|
23
|
+
children: render && fields.map(render)
|
|
20
24
|
}), showRecordMeta && entity && /* @__PURE__ */ jsx(RecordMeta, { entity })]
|
|
21
25
|
});
|
|
22
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormRail.js","names":[],"sources":["../../../src/form/components/FormRail.tsx"],"sourcesContent":["import type { Entity } from \"@rebasepro/types\";\nimport type { ResolvedFormField } from \"@rebasepro/app\";\nimport React from \"react\";\nimport { CheckIcon, cls, CopyIcon, IconButton, iconSize, Tooltip, Typography } from \"@rebasepro/ui\";\n\nexport interface FormRailProps {\n fields: ResolvedFormField[];\n showRecordMeta: boolean;\n entity?: Entity<Record<string, unknown>>;\n renderField
|
|
1
|
+
{"version":3,"file":"FormRail.js","names":[],"sources":["../../../src/form/components/FormRail.tsx"],"sourcesContent":["import type { Entity } from \"@rebasepro/types\";\nimport type { ResolvedFormField } from \"@rebasepro/app\";\nimport React from \"react\";\nimport { CheckIcon, cls, CopyIcon, IconButton, iconSize, Tooltip, Typography } from \"@rebasepro/ui\";\nimport { useFormFieldsContext } from \"../FormFieldsContext\";\n\nexport interface FormRailProps {\n fields: ResolvedFormField[];\n showRecordMeta: boolean;\n entity?: Entity<Record<string, unknown>>;\n /**\n * Renders one field. Defaults to the enclosing record form's own, which\n * applies every rule the form has for a field.\n */\n renderField?: (field: ResolvedFormField) => React.ReactNode;\n}\n\n/**\n * The metadata column beside the form.\n *\n * This replaces a `w-80 2xl:w-96` rail that held a Save button and several\n * hundred pixels of nothing. It renders only when it has something to say, and\n * the actions it used to hold now live in the identity bar, where they stay\n * visible while you scroll.\n */\nexport function FormRail({\n fields,\n showRecordMeta,\n entity,\n renderField\n}: FormRailProps) {\n\n const formFields = useFormFieldsContext();\n const render = renderField ?? formFields?.renderField;\n\n if (!fields.length && !showRecordMeta) return null;\n if (fields.length > 0 && !render) throw new Error(\"FormRail needs `renderField` outside a record form\");\n\n return (\n <aside className={cls(\n // No responsive hiding here. The caller decides whether the rail is\n // shown, by measuring; a CSS `hidden` would leave the fields the\n // resolver moved in here unreachable rather than folding them back.\n //\n // `w-76` (304px), between the old 288 and a full `w-80`. The rail\n // holds real controls — a status select, a date picker — plus a\n // record block whose id is a 36-character UUID, so 288 left the\n // select tighter than the identical select in the column.\n //\n // 304 is the floor rather than the answer everywhere. It was chosen\n // against the *narrow* end, where 320 took more than it gave back —\n // past about 300px the extra went to the gap beside a chip. That\n // stops being true once the form is genuinely wide: `@7xl/form`\n // (1280px of form) is the same signal the column widens on, and by\n // then 32px is coming out of gutters, not out of the column.\n //\n // Container, not viewport, for the reason the whole rail is\n // measured rather than breakpointed: a side panel inside a large\n // window is not a wide form. Both surfaces that render a rail —\n // `EntityForm` and `EntityViewBinding` — name their form element\n // `@container/form`, so a panel that never gets that wide keeps 304.\n // No left rule: the rail is sheet beside the form's card, and that\n // step is the separation. Regions meet with a step, not a line.\n \"flex flex-col gap-6 shrink-0 w-76 @7xl/form:w-84 overflow-y-auto\",\n \"px-5 py-6 bg-surface-sheet\"\n )}>\n {fields.length > 0 && (\n <div className={\"flex flex-col gap-5\"}>\n {render && fields.map(render)}\n </div>\n )}\n\n {showRecordMeta && entity && <RecordMeta entity={entity}/>}\n </aside>\n );\n}\n\n/**\n * The record's id and audit timestamps.\n *\n * Exported because the rail is not the only place it renders. The rail is shown\n * only when it has been *measured* to fit, and every layout narrower than that —\n * the split pane, the side panel, the dialog — folds its contents back into the\n * column. The fields folded back but this block did not, so on three of the four\n * layouts a record simply had no id on screen: the only copy of it was the\n * truncated `e166a394…b422` chip in the identity bar.\n */\nexport function RecordMeta({ entity }: { entity: Entity<Record<string, unknown>> }) {\n\n const createdAt = pickDate(entity.values, [\"created_at\", \"createdAt\", \"created_on\"]);\n const updatedAt = pickDate(entity.values, [\"updated_at\", \"updatedAt\", \"modified_at\"]);\n\n return (\n <div className={\"flex flex-col gap-2.5\"}>\n <Typography variant={\"caption\"}\n className={\"text-xs font-semibold uppercase tracking-wider text-text-disabled dark:text-text-disabled-dark\"}>\n Record\n </Typography>\n\n <MetaRow label={\"ID\"} value={String(entity.id)} copyable/>\n {createdAt && <MetaRow label={\"Created\"} value={createdAt}/>}\n {updatedAt && <MetaRow label={\"Updated\"} value={updatedAt}/>}\n </div>\n );\n}\n\nfunction MetaRow({\n label,\n value,\n copyable\n}: {\n label: string;\n value: string;\n copyable?: boolean;\n}) {\n const [copied, setCopied] = React.useState(false);\n\n const copy = () => {\n navigator.clipboard?.writeText(value).then(() => {\n setCopied(true);\n setTimeout(() => setCopied(false), 1600);\n }, () => undefined);\n };\n\n return (\n <div className={\"flex items-baseline justify-between gap-3 min-w-0\"}>\n <span className={\"text-xs text-text-disabled dark:text-text-disabled-dark shrink-0\"}>\n {label}\n </span>\n <span className={\"flex items-center gap-1 min-w-0\"}>\n <span className={\"font-mono text-xs text-text-secondary dark:text-text-secondary-dark truncate\"}\n title={value}>\n {value}\n </span>\n {copyable && (\n <Tooltip title={copied ? \"Copied\" : \"Copy\"}>\n <IconButton aria-label={copied ? \"Copied\" : \"Copy\"} size={\"smallest\"} onClick={copy}>\n {copied ? <CheckIcon size={iconSize.smallest}/> : <CopyIcon size={iconSize.smallest}/>}\n </IconButton>\n </Tooltip>\n )}\n </span>\n </div>\n );\n}\n\n/**\n * Audit timestamps are a convention, not a contract — a collection may name them\n * anything or not have them at all — so this reads the values it recognises and\n * stays quiet otherwise rather than rendering an empty row.\n */\nfunction pickDate(values: Record<string, unknown> | undefined, keys: string[]): string | undefined {\n if (!values) return undefined;\n for (const key of keys) {\n const value = values[key];\n if (value instanceof Date) return value.toLocaleDateString();\n if (typeof value === \"string\" && value) {\n const parsed = new Date(value);\n if (!Number.isNaN(parsed.getTime())) return parsed.toLocaleDateString();\n }\n }\n return undefined;\n}\n"],"mappings":";;;;;;;;;;;;;AAyBA,SAAgB,SAAS,EACrB,QACA,gBACA,QACA,eACc;CAEd,MAAM,aAAa,qBAAqB;CACxC,MAAM,SAAS,eAAe,YAAY;CAE1C,IAAI,CAAC,OAAO,UAAU,CAAC,gBAAgB,OAAO;CAC9C,IAAI,OAAO,SAAS,KAAK,CAAC,QAAQ,MAAM,IAAI,MAAM,oDAAoD;CAEtG,OACI,qBAAC,SAAD;EAAO,WAAW,IAwBd,oEACA,4BACJ;YA1BA,CA2BK,OAAO,SAAS,KACb,oBAAC,OAAD;GAAK,WAAW;aACX,UAAU,OAAO,IAAI,MAAM;EAC3B,CAAA,GAGR,kBAAkB,UAAU,oBAAC,YAAD,EAAoB,OAAQ,CAAA,CACtD;;AAEf;;;;;;;;;;;AAYA,SAAgB,WAAW,EAAE,UAAuD;CAEhF,MAAM,YAAY,SAAS,OAAO,QAAQ;EAAC;EAAc;EAAa;CAAY,CAAC;CACnF,MAAM,YAAY,SAAS,OAAO,QAAQ;EAAC;EAAc;EAAa;CAAa,CAAC;CAEpF,OACI,qBAAC,OAAD;EAAK,WAAW;YAAhB;GACI,oBAAC,YAAD;IAAY,SAAS;IACjB,WAAW;cAAkG;GAErG,CAAA;GAEZ,oBAAC,SAAD;IAAS,OA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J"}
|
|
@@ -11,7 +11,11 @@ export interface FormSectionsProps {
|
|
|
11
11
|
* user cannot submit and cannot debug.
|
|
12
12
|
*/
|
|
13
13
|
errorKeys: ReadonlySet<string>;
|
|
14
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Renders one field. Defaults to the enclosing record form's own, which
|
|
16
|
+
* applies every rule the form has for a field.
|
|
17
|
+
*/
|
|
18
|
+
renderField?: (field: ResolvedFormField) => React.ReactNode;
|
|
15
19
|
/**
|
|
16
20
|
* Which rendering this is. `"read"` opens the gaps up rather than closing
|
|
17
21
|
* them: a control is a bordered 40px box that separates itself from the next
|
|
@@ -1,14 +1,21 @@
|
|
|
1
|
+
import { sectionDomId, useFormDomScope } from "../form_dom_ids.js";
|
|
2
|
+
import { useFormFieldsContext } from "../FormFieldsContext.js";
|
|
1
3
|
import "react";
|
|
2
4
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
5
|
import { ChevronDownIcon, cls, defaultBorderMixin, iconSize } from "@rebasepro/ui";
|
|
4
6
|
//#region src/form/components/FormSections.tsx
|
|
5
7
|
function FormSections({ sections, collapsed, onToggle, errorKeys, renderField, mode = "edit", renderSummaryField }) {
|
|
6
8
|
const reading = mode === "read";
|
|
9
|
+
const domScope = useFormDomScope();
|
|
10
|
+
const formFields = useFormFieldsContext();
|
|
11
|
+
const render = renderField ?? formFields?.renderField;
|
|
12
|
+
if (!render) throw new Error("FormSections needs `renderField` outside a record form");
|
|
7
13
|
return /* @__PURE__ */ jsx("div", {
|
|
8
14
|
className: cls("flex flex-col", reading ? "gap-10" : "gap-8"),
|
|
9
15
|
children: sections.map((section) => {
|
|
10
16
|
const hasError = section.fields.some((f) => errorKeys.has(f.key));
|
|
11
17
|
const isCollapsed = section.collapsible && collapsed.has(section.key) && !hasError;
|
|
18
|
+
const regionId = sectionDomId(domScope, section.key);
|
|
12
19
|
const summary = reading && section.readVariant === "summary" && Boolean(renderSummaryField);
|
|
13
20
|
return /* @__PURE__ */ jsxs("section", {
|
|
14
21
|
className: "min-w-0",
|
|
@@ -16,16 +23,16 @@ function FormSections({ sections, collapsed, onToggle, errorKeys, renderField, m
|
|
|
16
23
|
title: section.title,
|
|
17
24
|
collapsible: section.collapsible,
|
|
18
25
|
collapsed: isCollapsed,
|
|
19
|
-
controls:
|
|
26
|
+
controls: regionId,
|
|
20
27
|
onToggle: () => onToggle(section.key)
|
|
21
28
|
}), !isCollapsed && (summary ? /* @__PURE__ */ jsx("div", {
|
|
22
|
-
id:
|
|
29
|
+
id: regionId,
|
|
23
30
|
className: "flex flex-col min-w-0 @2xl:max-w-md @2xl:ml-auto",
|
|
24
31
|
children: section.fields.map((field, index) => renderSummaryField(field, index, section.fields.length))
|
|
25
32
|
}) : /* @__PURE__ */ jsx("div", {
|
|
26
|
-
id:
|
|
33
|
+
id: regionId,
|
|
27
34
|
className: cls("grid min-w-0", reading ? "gap-x-8 gap-y-7" : "gap-x-4 gap-y-6", "grid-cols-1 @2xl:grid-cols-4"),
|
|
28
|
-
children: section.fields.map(
|
|
35
|
+
children: section.fields.map(render)
|
|
29
36
|
}))]
|
|
30
37
|
}, section.key);
|
|
31
38
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormSections.js","names":[],"sources":["../../../src/form/components/FormSections.tsx"],"sourcesContent":["import type { ResolvedFormField, ResolvedFormSection } from \"@rebasepro/app\";\nimport React from \"react\";\nimport { ChevronDownIcon, cls, defaultBorderMixin, iconSize } from \"@rebasepro/ui\";\n\nexport interface FormSectionsProps {\n sections: ResolvedFormSection[];\n /** Section keys the user has collapsed. */\n collapsed: ReadonlySet<string>;\n onToggle: (key: string) => void;\n /**\n * Field keys currently showing a validation error. A section holding one is\n * forced open — an error that hides inside a collapsed group is a form the\n * user cannot submit and cannot debug.\n */\n errorKeys: ReadonlySet<string>;\n renderField
|
|
1
|
+
{"version":3,"file":"FormSections.js","names":[],"sources":["../../../src/form/components/FormSections.tsx"],"sourcesContent":["import type { ResolvedFormField, ResolvedFormSection } from \"@rebasepro/app\";\nimport React from \"react\";\nimport { ChevronDownIcon, cls, defaultBorderMixin, iconSize } from \"@rebasepro/ui\";\nimport { sectionDomId, useFormDomScope } from \"../form_dom_ids\";\nimport { useFormFieldsContext } from \"../FormFieldsContext\";\n\nexport interface FormSectionsProps {\n sections: ResolvedFormSection[];\n /** Section keys the user has collapsed. */\n collapsed: ReadonlySet<string>;\n onToggle: (key: string) => void;\n /**\n * Field keys currently showing a validation error. A section holding one is\n * forced open — an error that hides inside a collapsed group is a form the\n * user cannot submit and cannot debug.\n */\n errorKeys: ReadonlySet<string>;\n /**\n * Renders one field. Defaults to the enclosing record form's own, which\n * applies every rule the form has for a field.\n */\n renderField?: (field: ResolvedFormField) => React.ReactNode;\n /**\n * Which rendering this is. `\"read\"` opens the gaps up rather than closing\n * them: a control is a bordered 40px box that separates itself from the next\n * one, and a value is bare text that does not. The form can also afford\n * tighter rows because a description usually sits between them; with that\n * gone, the same numbers ran a record's values together into one block.\n */\n mode?: \"edit\" | \"read\";\n /**\n * Renders one field as a summary row, for a section that asked for\n * `readVariant: \"summary\"`. Only the read view supplies it; without it such\n * a section falls back to the grid rather than to nothing.\n */\n renderSummaryField?: (field: ResolvedFormField, index: number, total: number) => React.ReactNode;\n}\n\nexport function FormSections({\n sections,\n collapsed,\n onToggle,\n errorKeys,\n renderField,\n mode = \"edit\",\n renderSummaryField\n}: FormSectionsProps) {\n\n const reading = mode === \"read\";\n const domScope = useFormDomScope();\n const formFields = useFormFieldsContext();\n const render = renderField ?? formFields?.renderField;\n if (!render) throw new Error(\"FormSections needs `renderField` outside a record form\");\n\n return (\n <div className={cls(\"flex flex-col\", reading ? \"gap-10\" : \"gap-8\")}>\n {sections.map((section) => {\n\n const hasError = section.fields.some(f => errorKeys.has(f.key));\n const isCollapsed = section.collapsible && collapsed.has(section.key) && !hasError;\n const regionId = sectionDomId(domScope, section.key);\n const summary = reading\n && section.readVariant === \"summary\"\n && Boolean(renderSummaryField);\n\n return (\n <section key={section.key} className={\"min-w-0\"}>\n\n {section.title && (\n <Header\n title={section.title}\n collapsible={section.collapsible}\n collapsed={isCollapsed}\n controls={regionId}\n onToggle={() => onToggle(section.key)}/>\n )}\n\n {!isCollapsed && (summary\n ? <div id={regionId}\n className={\"flex flex-col min-w-0 @2xl:max-w-md @2xl:ml-auto\"}>\n {section.fields.map((field, index) =>\n renderSummaryField!(field, index, section.fields.length))}\n </div>\n // A container query, not a media query: the form is\n // rendered at four very different widths (full\n // screen, side panel, split pane, dialog) inside the\n // same viewport, so spans have to answer to the\n // column they are in, not to the window.\n : <div id={regionId}\n className={cls(\n \"grid min-w-0\",\n // 24px between rows of filled boxes: with no\n // edge on a field, the gap is what keeps two\n // rows from reading as one block. It also\n // holds a field's key hint, which hangs below\n // a box that has no description line.\n reading ? \"gap-x-8 gap-y-7\" : \"gap-x-4 gap-y-6\",\n \"grid-cols-1 @2xl:grid-cols-4\"\n )}>\n {section.fields.map(render)}\n </div>\n )}\n </section>\n );\n })}\n </div>\n );\n}\n\nfunction Header({\n title,\n collapsible,\n collapsed,\n controls,\n onToggle\n}: {\n title: string;\n collapsible: boolean;\n collapsed: boolean;\n /**\n * Id of the region this header shows and hides. Only referenced while that\n * region exists — a collapsed section unmounts its fields, and pointing\n * `aria-controls` at an id that is not in the document is its own defect.\n */\n controls: string;\n onToggle: () => void;\n}) {\n\n const content = (\n <>\n {collapsible && (\n <ChevronDownIcon\n size={iconSize.smallest}\n className={cls(\n \"text-text-disabled dark:text-text-disabled-dark transition-transform duration-150\",\n collapsed && \"-rotate-90\"\n )}/>\n )}\n <span className={\"text-xs font-semibold uppercase tracking-wider text-text-disabled dark:text-text-disabled-dark whitespace-nowrap\"}>\n {title}\n </span>\n <span className={cls(\"flex-1 border-t\", defaultBorderMixin)}/>\n </>\n );\n\n const className = \"flex items-center gap-2.5 w-full mb-3.5\";\n\n if (!collapsible) {\n return <div className={className}>{content}</div>;\n }\n\n return (\n <button type={\"button\"}\n onClick={onToggle}\n aria-expanded={!collapsed}\n aria-controls={collapsed ? undefined : controls}\n className={cls(className, \"text-left hover:opacity-80 transition-opacity\")}>\n {content}\n </button>\n );\n}\n"],"mappings":";;;;;;AAsCA,SAAgB,aAAa,EACzB,UACA,WACA,UACA,WACA,aACA,OAAO,QACP,sBACkB;CAElB,MAAM,UAAU,SAAS;CACzB,MAAM,WAAW,gBAAgB;CACjC,MAAM,aAAa,qBAAqB;CACxC,MAAM,SAAS,eAAe,YAAY;CAC1C,IAAI,CAAC,QAAQ,MAAM,IAAI,MAAM,wDAAwD;CAErF,OACI,oBAAC,OAAD;EAAK,WAAW,IAAI,iBAAiB,UAAU,WAAW,OAAO;YAC5D,SAAS,KAAK,YAAY;GAEvB,MAAM,WAAW,QAAQ,OAAO,MAAK,MAAK,UAAU,IAAI,EAAE,GAAG,CAAC;GAC9D,MAAM,cAAc,QAAQ,eAAe,UAAU,IAAI,QAAQ,GAAG,KAAK,CAAC;GAC1E,MAAM,WAAW,aAAa,UAAU,QAAQ,GAAG;GACnD,MAAM,UAAU,WACT,QAAQ,gBAAgB,aACxB,QAAQ,kBAAkB;GAEjC,OACI,qBAAC,WAAD;IAA2B,WAAW;cAAtC,CAEK,QAAQ,SACL,oBAAC,QAAD;KACI,OAAO,QAAQ;KACf,aAAa,QAAQ;KACrB,WAAW;KACX,UAAU;KACV,gBAAgB,SAAS,QAAQ,GAAG;IAAG,CAAA,GAG9C,CAAC,gBAAgB,UACZ,oBAAC,OAAD;KAAK,IAAI;KACP,WAAW;eACV,QAAQ,OAAO,KAAK,OAAO,UACxB,mBAAoB,OAAO,OAAO,QAAQ,OAAO,MAAM,CAAC;IAC3D,CAAA,IAMH,oBAAC,OAAD;KAAK,IAAI;KACP,WAAW,IACP,gBAMA,UAAU,oBAAoB,mBAC9B,8BACJ;eACC,QAAQ,OAAO,IAAI,MAAM;IACzB,CAAA,EAEJ;MApCK,QAAQ,GAoCb;EAEjB,CAAC;CACA,CAAA;AAEb;AAEA,SAAS,OAAO,EACZ,OACA,aACA,WACA,UACA,YAYD;CAEC,MAAM,UACF,qBAAA,UAAA,EAAA,UAAA;EACK,eACG,oBAAC,iBAAD;GACI,MAAM,SAAS;GACf,WAAW,IACP,qFACA,aAAa,YACjB;EAAG,CAAA;EAEX,oBAAC,QAAD;GAAM,WAAW;aACZ;EACC,CAAA;EACN,oBAAC,QAAD,EAAM,WAAW,IAAI,mBAAmB,kBAAkB,EAAG,CAAA;CAC/D,EAAA,CAAA;CAGN,MAAM,YAAY;CAElB,IAAI,CAAC,aACD,OAAO,oBAAC,OAAD;EAAgB;YAAY;CAAa,CAAA;CAGpD,OACI,oBAAC,UAAD;EAAQ,MAAM;EACV,SAAS;EACT,iBAAe,CAAC;EAChB,iBAAe,YAAY,KAAA,IAAY;EACvC,WAAW,IAAI,WAAW,+CAA+C;YACxE;CACG,CAAA;AAEhB"}
|
|
@@ -4,7 +4,7 @@ import { useReferencePaths } from "../../hooks/useReferencePaths.js";
|
|
|
4
4
|
import { ReferencePreview } from "../../preview/components/ReferencePreview.js";
|
|
5
5
|
import { FieldHelperText } from "../components/FieldHelperText.js";
|
|
6
6
|
import { LabelWithIcon } from "../components/LabelWithIcon.js";
|
|
7
|
-
import {
|
|
7
|
+
import { useEntitySelectionDialog } from "../../hooks/useSelectionDialog.js";
|
|
8
8
|
import { ArrayContainer } from "../../components/ArrayContainer.js";
|
|
9
9
|
import { useCallback, useMemo } from "react";
|
|
10
10
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -32,7 +32,7 @@ function ArrayOfReferencesFieldBinding({ propertyKey, value, error, showError, d
|
|
|
32
32
|
return collectionPath ? collectionRegistryController.getCollection(collectionPath) : void 0;
|
|
33
33
|
}, [collectionPath]);
|
|
34
34
|
if (!collection) throw Error(`Couldn't find the corresponding collection for the path: ${ofProperty.path}`);
|
|
35
|
-
const referenceDialogController =
|
|
35
|
+
const referenceDialogController = useEntitySelectionDialog({
|
|
36
36
|
multiselect: true,
|
|
37
37
|
path: collectionPath,
|
|
38
38
|
collection,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArrayOfReferencesFieldBinding.js","names":[],"sources":["../../../src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"ArrayOfReferencesFieldBinding.js","names":[],"sources":["../../../src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx"],"sourcesContent":["import { useEntitySelectionDialog } from \"../../hooks/useSelectionDialog\";\n\nimport type { FieldProps } from \"../../types/fields\";\nimport type { ArrayProperty, Property } from \"@rebasepro/types\";\nimport React, { useCallback, useMemo } from \"react\";\nimport { Entity, EntityReference } from \"@rebasepro/types\";\nimport { ReferencePreview } from \"../../preview\";\nimport { FieldHelperText } from \"../components/FieldHelperText\";\nimport { LabelWithIcon } from \"../components/LabelWithIcon\";\nimport { ArrayContainer, ArrayEntryParams } from \"../../components/ArrayContainer\";\nimport { getIconForProperty } from \"../../util/property_utils\";\n\nimport { useTranslation, ErrorView } from \"@rebasepro/app\";\nimport { Button, cls, ExpandablePanel, fieldBackgroundMixin, PencilIcon, Typography } from \"@rebasepro/ui\";\nimport { useCollectionRegistryController } from \"../../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { useReferencePaths } from \"../../hooks/useReferencePaths\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\n\ntype ArrayOfReferencesFieldProps = FieldProps<ArrayProperty, EntityReference[]>;\n\n/**\n * This field allows selecting multiple references.\n *\n * This is one of the internal components that get mapped natively inside forms\n * and tables to the specified properties.\n * @group Form fields\n */\nexport function ArrayOfReferencesFieldBinding({\n propertyKey,\n value,\n error,\n showError,\n disabled,\n isSubmitting,\n minimalistView: minimalistViewProp,\n property,\n includeDescription,\n setValue,\n setFieldValue\n}: ArrayOfReferencesFieldProps) {\n\n const minimalistView = minimalistViewProp || property.admin?.minimalistView;\n const { t } = useTranslation();\n\n const ofProperty = property.of as Property;\n if (ofProperty.type !== \"reference\") {\n throw Error(\"ArrayOfReferencesField expected a property containing references\");\n }\n\n const expanded = property.admin?.expanded === undefined ? true : property.admin?.expanded;\n const selectedEntityIds = value && Array.isArray(value) ? value.map((ref) => ref.id) : [];\n\n const collectionRegistryController = useCollectionRegistryController();\n const { toCollectionPath, referenceTo } = useReferencePaths();\n const collectionPath = ofProperty.path ? toCollectionPath(ofProperty.path) : undefined;\n const collection: AdminCollection | undefined = useMemo(() => {\n return collectionPath ? collectionRegistryController.getCollection(collectionPath) : undefined;\n }, [collectionPath]);\n\n if (!collection) {\n throw Error(`Couldn't find the corresponding collection for the path: ${ofProperty.path}`);\n }\n\n const onMultipleEntitiesSelected = useCallback((entities: Entity<Record<string, unknown>>[]) => {\n const refs = entities.map(e => referenceTo(e));\n setValue(refs);\n }, [setValue, referenceTo]);\n\n const referenceDialogController = useEntitySelectionDialog({\n multiselect: true,\n path: collectionPath,\n collection,\n onMultipleEntitiesSelected,\n selectedEntityIds,\n fixedFilter: ofProperty.admin?.fixedFilter\n }\n );\n\n const onEntryClick = (e: React.SyntheticEvent) => {\n e.preventDefault();\n if (disabled || isSubmitting) return;\n referenceDialogController.open();\n };\n\n const buildEntry = useCallback(({\n index,\n internalId,\n storedProps,\n storeProps\n }: ArrayEntryParams) => {\n const entryValue = value && value.length > index ? value[index] : undefined;\n if (!entryValue)\n return <div>Internal ERROR</div>;\n return (\n <ReferencePreview\n key={internalId}\n disabled={!ofProperty.path}\n previewProperties={ofProperty.admin?.previewProperties}\n size={\"medium\"}\n onClick={onEntryClick}\n hover={!disabled}\n reference={entryValue}\n includeId={ofProperty.admin?.includeId}\n includeEntityLink={ofProperty.admin?.includeEntityLink}\n />\n );\n }, [ofProperty.path, ofProperty.admin?.previewProperties, value, disabled, isSubmitting]);\n\n const title = (<>\n <LabelWithIcon\n propertyKey={propertyKey}\n icon={getIconForProperty(property, \"small\")}\n required={property.validation?.required}\n title={property.name ?? propertyKey}\n className={\"h-8 flex grow text-text-secondary dark:text-text-secondary-dark\"}/>\n {Array.isArray(value) && <Typography variant={\"caption\"} className={\"px-4\"}>({value.length})</Typography>}\n </>);\n\n const body = <>\n {!collection && <ErrorView\n error={\"The specified collection does not exist. Check console\"}/>}\n\n {collection && <div className={\"group\"}>\n\n <ArrayContainer droppableId={propertyKey}\n value={value}\n disabled={disabled || isSubmitting}\n buildEntry={buildEntry}\n canAddElements={false}\n addLabel={property.name ? t(\"add_reference_to\", { name: property.name }) : t(\"add_reference\")}\n newDefaultEntry={property.of && \"defaultValue\" in property.of ? property.of?.defaultValue : null}\n onValueChange={(value) => setFieldValue(propertyKey, value)}\n />\n\n <Button\n className=\"ml-3.5 my-4 justify-center text-left\"\n variant=\"text\"\n disabled={disabled || isSubmitting}\n onClick={onEntryClick}>\n <PencilIcon size={16}/>\n {t(\"edit_name\", { name: property.name ?? propertyKey })}\n </Button>\n </div>}\n </>;\n\n return (\n <>\n\n {!minimalistView &&\n <ExpandablePanel\n titleClassName={fieldBackgroundMixin}\n innerClassName={cls(\"px-2 md:px-4 pb-2 md:pb-4 pt-1 md:pt-2\", fieldBackgroundMixin)}\n initiallyExpanded={expanded}\n title={title}>\n {body}\n </ExpandablePanel>}\n\n {minimalistView && body}\n\n <FieldHelperText includeDescription={includeDescription}\n showError={showError}\n error={error}\n disabled={disabled}\n property={property}/>\n\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA2BA,SAAgB,8BAA8B,EAC1C,aACA,OACA,OACA,WACA,UACA,cACA,gBAAgB,oBAChB,UACA,oBACA,UACA,iBAC4B;CAE5B,MAAM,iBAAiB,sBAAsB,SAAS,OAAO;CAC7D,MAAM,EAAE,MAAM,eAAe;CAE7B,MAAM,aAAa,SAAS;CAC5B,IAAI,WAAW,SAAS,aACpB,MAAM,MAAM,kEAAkE;CAGlF,MAAM,WAAW,SAAS,OAAO,aAAa,KAAA,IAAY,OAAO,SAAS,OAAO;CACjF,MAAM,oBAAoB,SAAS,MAAM,QAAQ,KAAK,IAAI,MAAM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AC/B,OAAO,SAAS,QAAQ;EACxB,WAAW;CAAmE,CAAA,GACjF,MAAM,QAAQ,KAAK,KAAK,qBAAC,YAAD;EAAY,SAAS;EAAW,WAAW;YAA3C;GAAmD;GAAE,MAAM;GAAO;EAAa;GAC1G,EAAA,CAAA;CAEF,MAAM,OAAO,qBAAA,UAAA,EAAA,UAAA,CACR,CAAC,cAAc,oBAAC,WAAD,EACZ,OAAO,yDAA0D,CAAA,GAEpE,cAAc,qBAAC,OAAD;EAAK,WAAW;YAAhB,CAEX,oBAAC,gBAAD;GAAgB,aAAa;GAClB;GACP,UAAU,YAAY;GACV;GACZ,gBAAgB;GAChB,UAAU,SAAS,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,KAAK,CAAC,IAAI,EAAE,eAAe;GAC5F,iBAAiB,SAAS,MAAM,kBAAkB,SAAS,KAAK,SAAS,IAAI,eAAe;GAC5F,gBAAgB,UAAU,cAAc,aAAa,KAAK;EAC7D,CAAA,GAED,qBAAC,QAAD;GACI,WAAU;GACV,SAAQ;GACR,UAAU,YAAY;GACtB,SAAS;aAJb,CAKI,oBAAC,YAAD,EAAY,MAAM,GAAI,CAAA,GACrB,EAAE,aAAa,EAAE,MAAM,SAAS,QAAQ,YAAY,CAAC,CAClD;IACP;GACP,EAAA,CAAA;CAEF,OACI,qBAAA,UAAA,EAAA,UAAA;EAEK,CAAC,kBACE,oBAAC,iBAAD;GACI,gBAAgB;GAChB,gBAAgB,IAAI,0CAA0C,oBAAoB;GAClF,mBAAmB;GACZ;aACN;EACY,CAAA;EAEpB,kBAAkB;EAEnB,oBAAC,iBAAD;GAAqC;GACtB;GACJ;GACG;GACA;EAAU,CAAA;CAE1B,EAAA,CAAA;AAEV"}
|
|
@@ -69,7 +69,7 @@ function MarkdownEditorFieldBinding({ property, propertyKey, value, setValue, in
|
|
|
69
69
|
const resolveImageSrc = useImageSrcResolver();
|
|
70
70
|
const aiController = useProvidedEditorAIController();
|
|
71
71
|
const entityValues = context.values;
|
|
72
|
-
const entityId = context.
|
|
72
|
+
const entityId = context.id;
|
|
73
73
|
const path = context.path;
|
|
74
74
|
const [fieldVersion, setFieldVersion] = useState(0);
|
|
75
75
|
const internalValue = useRef(value);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownEditorFieldBinding.js","names":[],"sources":["../../../src/form/field_bindings/MarkdownEditorFieldBinding.tsx"],"sourcesContent":["import React, { Suspense, useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { resourceKeyOf, storageReference } from \"@rebasepro/types\";\nimport { FieldHelperText } from \"../components/FieldHelperText\";\nimport { LabelWithIcon } from \"../components/LabelWithIcon\";\nimport { useAuthController, useStorageSource, useTranslation } from \"@rebasepro/app\";\nimport { useStorageSources } from \"@rebasepro/app\";\nimport { resolveStorageSource } from \"@rebasepro/common\";\nimport { getIconForProperty } from \"../../util/property_utils\";\nimport type { FieldProps } from \"../../types/fields\";\nimport type { ArrayProperty, StringProperty } from \"@rebasepro/types\";\nimport {\n cls,\n fieldBackgroundDisabledMixin,\n fieldBackgroundHoverMixin,\n fieldBackgroundMixin,\n IconButton,\n lazyChunk,\n Skeleton,\n XIcon\n} from \"@rebasepro/ui\";\nimport type { RichTextEditorProps } from \"../../editor\";\nimport { resolveStorageFilenameString, resolveStoragePathString } from \"@rebasepro/common\";\nimport { randomString } from \"@rebasepro/utils\";\nimport { useImageSrcResolver } from \"../../hooks/useStorageReferenceResolver\";\nimport { useProvidedEditorAIController } from \"../../contexts/EditorAIControllerContext\";\n\n// Lazy-load ProseMirror editor + markdown parser/serializer (~300KB)\n// Only fetched when a markdown field is actually rendered.\nconst RichTextEditor = lazyChunk(() => import(\"../../editor\").then(m => ({ default: m.RichTextEditor })));\nconst loadMarkdownUtils = () => import(\"../../editor/markdown\");\nlet _markdownUtils: Awaited<ReturnType<typeof loadMarkdownUtils>> | null = null;\nconst getMarkdownUtils = async () => {\n if (!_markdownUtils) _markdownUtils = await loadMarkdownUtils();\n return _markdownUtils;\n};\n\ninterface MarkdownEditorFieldProps {\n highlight?: { from: number, to: number };\n editorProps?: Partial<RichTextEditorProps>\n}\n\n/**\n * Normalize markdown for comparison purposes: collapse whitespace,\n * normalize line endings, trim lines. This is NOT for display.\n */\nfunction normalizeMarkdown(md: string | null | undefined): string {\n if (!md) return \"\";\n return md\n .replace(/\\r\\n/g, \"\\n\")\n .replace(/\\n{3,}/g, \"\\n\\n\")\n .replace(/[ \\t]+$/gm, \"\")\n .trim();\n}\n\n/**\n * Compute the canonical form of a markdown string by doing a full\n * parse → serialize roundtrip through ProseMirror. This gives us\n * the exact output the editor will produce for a given input,\n * so we can compare against it to avoid false dirty states.\n *\n * Falls back to normalizeMarkdown if the ProseMirror module hasn't loaded yet.\n */\nfunction canonicalizeMarkdown(md: string | null | undefined): string {\n if (!md) return \"\";\n if (!_markdownUtils) return normalizeMarkdown(md);\n try {\n const doc = _markdownUtils.parser.parse(md);\n if (!doc) return normalizeMarkdown(md);\n return normalizeMarkdown(_markdownUtils.serializer.serialize(doc));\n } catch {\n return normalizeMarkdown(md);\n }\n}\n\nexport function MarkdownEditorFieldBinding({\n property,\n propertyKey,\n value,\n setValue,\n includeDescription,\n hideLabel,\n showError,\n error,\n minimalistView,\n disabled: disabledProp,\n isSubmitting,\n context,\n customProps\n}: FieldProps<StringProperty, MarkdownEditorFieldProps>) {\n const { t } = useTranslation();\n\n const authController = useAuthController();\n const disabled = disabledProp || isSubmitting;\n const highlight = customProps?.highlight;\n const editorProps = customProps?.editorProps;\n const defaultStorageSource = useStorageSource();\n const storage = property.storage;\n const storageSources = useStorageSources();\n\n // Resolve the correct storage source for this property.\n // Mirrors the resolution in useStorageUploadController.\n const storageSourceKey = storage?.storageSource === undefined ? undefined : resourceKeyOf(storage.storageSource);\n const storageSource = useMemo(() => resolveStorageSource({\n sourceKey: storageSourceKey,\n sources: storageSources.sources,\n defaultSource: defaultStorageSource,\n createSource: storageSources.createSource\n }), [storageSourceKey, storageSources.sources, storageSources.createSource, defaultStorageSource]);\n\n // How the editor shows an image the text names by reference.\n const resolveImageSrc = useImageSrcResolver();\n\n // The AI continuation a plugin gives the form's markdown fields, if any;\n // the field's own `editorProps.aiController`, spread below, wins.\n const aiController = useProvidedEditorAIController();\n\n const entityValues = context.values;\n const entityId = context.entityId;\n const path = context.path;\n\n const [fieldVersion, setFieldVersion] = useState(0);\n const internalValue = useRef<string | null>(value);\n\n // Eagerly load ProseMirror markdown utils when the field first mounts\n useEffect(() => {\n getMarkdownUtils().then(() => {\n // Update canonical ref with the proper round-tripped value now that ProseMirror is loaded\n canonicalRef.current = canonicalizeMarkdown(canonicalSourceRef.current);\n });\n }, []);\n\n // Compute the canonical (round-tripped) form of the initial value ONCE.\n // This is what ProseMirror will produce after parse → serialize, so any\n // future serialization that matches this canonical form is NOT a real change.\n const canonicalInitialValue = useMemo(\n () => canonicalizeMarkdown(value),\n\n [] // intentionally only on mount\n );\n // Track it in a ref so the callback always has the latest\n const canonicalRef = useRef(canonicalInitialValue);\n // The value the canonical form was computed from — what this field was\n // given, as opposed to what the user has typed into it since.\n const canonicalSourceRef = useRef<string | null>(value);\n\n const onContentChange = useCallback((content: string) => {\n const normalizedContent = normalizeMarkdown(content);\n\n // Compare against the canonical roundtripped form of the initial value.\n // This eliminates ALL false positives from parse→serialize normalization\n // differences (trailing nodes, bullet chars, whitespace, etc.).\n if (normalizedContent === canonicalRef.current) {\n // Back to the value this field was given — so the form holds that\n // value again, verbatim, and not whatever was typed on the way.\n if (value !== canonicalSourceRef.current) {\n internalValue.current = canonicalSourceRef.current;\n setValue(canonicalSourceRef.current);\n }\n return;\n }\n // Also compare against the current form value to avoid redundant updates\n if (normalizedContent === normalizeMarkdown(value)) {\n return;\n }\n // Emptied: NULL, as the plain text field writes. `\"\"` over a stored\n // value stopped `isNull` filters matching the row.\n const next = normalizedContent.trim() === \"\" ? null : content;\n internalValue.current = next;\n setValue(next);\n }, [setValue, value]);\n\n useEffect(() => {\n if (internalValue.current !== value) {\n internalValue.current = value;\n canonicalSourceRef.current = value;\n canonicalRef.current = canonicalizeMarkdown(value);\n setFieldVersion(v => v + 1);\n }\n }, [value]);\n\n const fileNameBuilder = useCallback(async (file: File) => {\n if (storage?.fileName) {\n const fileName = await resolveStorageFilenameString({\n input: storage.fileName,\n storage,\n values: entityValues,\n entityId,\n path,\n property: property,\n file,\n propertyKey\n });\n if (!fileName || fileName.length === 0) {\n throw Error(\"You need to return a valid filename\");\n }\n return fileName;\n }\n return randomString() + \"_\" + file.name;\n }, [entityId, entityValues, path, property, propertyKey, storage]);\n\n const storagePathBuilder = useCallback((file: File) => {\n if (!storage) return \"/\";\n return resolveStoragePathString({\n input: storage.storagePath,\n storage,\n values: entityValues,\n entityId,\n path,\n property,\n file,\n propertyKey\n }) ?? \"/\";\n }, [entityId, entityValues, path, property, propertyKey, storage]);\n\n const editor = <Suspense fallback={<Skeleton height={200} className=\"w-full rounded-md\"/>}>\n <RichTextEditor\n content={value}\n onMarkdownContentChange={onContentChange}\n version={context.formex.version + fieldVersion}\n highlight={highlight}\n disabled={disabled}\n handleImageUpload={async (file: File) => {\n const storagePath = storagePathBuilder(file);\n const fileName = await fileNameBuilder(file);\n const key = `${storagePath}/${fileName}`.replace(/^\\/+/, \"\").replace(/\\/+/g, \"/\");\n const collectionSlug = context.collection?.slug;\n const result = await storageSource.putObject({\n file,\n key,\n // The property's own `storage.public`, and which property this\n // is, so the server holds the image to its limits.\n ...(storage?.public ? { public: true } : {}),\n ...(collectionSlug ? { context: { collection: collectionSlug, property: propertyKey } } : {})\n });\n // The text keeps a reference to the object, never its URL. A\n // private object's URL carries a download token that expires in\n // minutes, and this text is saved — so the post showed a broken\n // image, in this panel and on every site that published it, five\n // minutes after the upload. Whoever renders the text asks for a\n // URL then (`resolveStorageReferences`).\n return storageReference(result.key, storageSourceKey);\n }}\n resolveImageSrc={resolveImageSrc}\n aiController={aiController}\n {...editorProps}\n />\n </Suspense>;\n\n if (minimalistView)\n return editor;\n\n return (\n <>\n {!hideLabel && <div className=\"flex items-center w-full\">\n <LabelWithIcon\n propertyKey={propertyKey}\n icon={getIconForProperty(property, \"small\")}\n required={property.validation?.required}\n title={property.name ?? propertyKey}\n className={\"h-8 text-text-secondary dark:text-text-secondary-dark ml-3.5\"}/>\n </div>}\n {/* `relative` so Clear can float inside the box. It used to sit in\n the label row, which meant a clearable field with its label\n lifted out by the form still drew a row of chrome above the box\n and started lower than the field beside it.\n Bottom-right, not top: the editor puts its own mode toggle at\n `top-2 right-2` and the two would sit on each other. */}\n <div\n className={cls(\"relative rounded-md\", fieldBackgroundMixin, disabled ? fieldBackgroundDisabledMixin : fieldBackgroundHoverMixin)}>\n {property.admin?.clearable && !disabled && (\n <IconButton aria-label={t(\"clear\")}\n size=\"small\"\n className=\"absolute bottom-1 right-1 z-10\"\n onClick={(e) => {\n e.stopPropagation();\n e.preventDefault();\n setValue(null);\n }}\n >\n <XIcon/>\n </IconButton>\n )}\n {editor}\n </div>\n <FieldHelperText includeDescription={includeDescription}\n showError={showError}\n error={error}\n property={property}/>\n </>\n\n );\n\n}\n"],"mappings":";;;;;;;;;;;;;AA4BA,IAAM,iBAAiB,gBAAgB,OAAO,kBAAe,CAAC,MAAK,OAAM,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;AACxG,IAAM,0BAA0B,OAAO;AACvC,IAAI,iBAAuE;AAC3E,IAAM,mBAAmB,YAAY;CACjC,IAAI,CAAC,gBAAgB,iBAAiB,MAAM,kBAAkB;CAC9D,OAAO;AACX;;;;;AAWA,SAAS,kBAAkB,IAAuC;CAC9D,IAAI,CAAC,IAAI,OAAO;CAChB,OAAO,GACF,QAAQ,SAAS,IAAI,CAAC,CACtB,QAAQ,WAAW,MAAM,CAAC,CAC1B,QAAQ,aAAa,EAAE,CAAC,CACxB,KAAK;AACd;;;;;;;;;AAUA,SAAS,qBAAqB,IAAuC;CACjE,IAAI,CAAC,IAAI,OAAO;CAChB,IAAI,CAAC,gBAAgB,OAAO,kBAAkB,EAAE;CAChD,I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ding.tsx"],"sourcesContent":["import React, { Suspense, useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { resourceKeyOf, storageReference } from \"@rebasepro/types\";\nimport { FieldHelperText } from \"../components/FieldHelperText\";\nimport { LabelWithIcon } from \"../components/LabelWithIcon\";\nimport { useAuthController, useStorageSource, useTranslation } from \"@rebasepro/app\";\nimport { useStorageSources } from \"@rebasepro/app\";\nimport { resolveStorageSource } from \"@rebasepro/common\";\nimport { getIconForProperty } from \"../../util/property_utils\";\nimport type { FieldProps } from \"../../types/fields\";\nimport type { ArrayProperty, StringProperty } from \"@rebasepro/types\";\nimport {\n cls,\n fieldBackgroundDisabledMixin,\n fieldBackgroundHoverMixin,\n fieldBackgroundMixin,\n IconButton,\n lazyChunk,\n Skeleton,\n XIcon\n} from \"@rebasepro/ui\";\nimport type { RichTextEditorProps } from \"../../editor\";\nimport { resolveStorageFilenameString, resolveStoragePathString } from \"@rebasepro/common\";\nimport { randomString } from \"@rebasepro/utils\";\nimport { useImageSrcResolver } from \"../../hooks/useStorageReferenceResolver\";\nimport { useProvidedEditorAIController } from \"../../contexts/EditorAIControllerContext\";\n\n// Lazy-load ProseMirror editor + markdown parser/serializer (~300KB)\n// Only fetched when a markdown field is actually rendered.\nconst RichTextEditor = lazyChunk(() => import(\"../../editor\").then(m => ({ default: m.RichTextEditor })));\nconst loadMarkdownUtils = () => import(\"../../editor/markdown\");\nlet _markdownUtils: Awaited<ReturnType<typeof loadMarkdownUtils>> | null = null;\nconst getMarkdownUtils = async () => {\n if (!_markdownUtils) _markdownUtils = await loadMarkdownUtils();\n return _markdownUtils;\n};\n\ninterface MarkdownEditorFieldProps {\n highlight?: { from: number, to: number };\n editorProps?: Partial<RichTextEditorProps>\n}\n\n/**\n * Normalize markdown for comparison purposes: collapse whitespace,\n * normalize line endings, trim lines. This is NOT for display.\n */\nfunction normalizeMarkdown(md: string | null | undefined): string {\n if (!md) return \"\";\n return md\n .replace(/\\r\\n/g, \"\\n\")\n .replace(/\\n{3,}/g, \"\\n\\n\")\n .replace(/[ \\t]+$/gm, \"\")\n .trim();\n}\n\n/**\n * Compute the canonical form of a markdown string by doing a full\n * parse → serialize roundtrip through ProseMirror. This gives us\n * the exact output the editor will produce for a given input,\n * so we can compare against it to avoid false dirty states.\n *\n * Falls back to normalizeMarkdown if the ProseMirror module hasn't loaded yet.\n */\nfunction canonicalizeMarkdown(md: string | null | undefined): string {\n if (!md) return \"\";\n if (!_markdownUtils) return normalizeMarkdown(md);\n try {\n const doc = _markdownUtils.parser.parse(md);\n if (!doc) return normalizeMarkdown(md);\n return normalizeMarkdown(_markdownUtils.serializer.serialize(doc));\n } catch {\n return normalizeMarkdown(md);\n }\n}\n\nexport function MarkdownEditorFieldBinding({\n property,\n propertyKey,\n value,\n setValue,\n includeDescription,\n hideLabel,\n showError,\n error,\n minimalistView,\n disabled: disabledProp,\n isSubmitting,\n context,\n customProps\n}: FieldProps<StringProperty, MarkdownEditorFieldProps>) {\n const { t } = useTranslation();\n\n const authController = useAuthController();\n const disabled = disabledProp || isSubmitting;\n const highlight = customProps?.highlight;\n const editorProps = customProps?.editorProps;\n const defaultStorageSource = useStorageSource();\n const storage = property.storage;\n const storageSources = useStorageSources();\n\n // Resolve the correct storage source for this property.\n // Mirrors the resolution in useStorageUploadController.\n const storageSourceKey = storage?.storageSource === undefined ? undefined : resourceKeyOf(storage.storageSource);\n const storageSource = useMemo(() => resolveStorageSource({\n sourceKey: storageSourceKey,\n sources: storageSources.sources,\n defaultSource: defaultStorageSource,\n createSource: storageSources.createSource\n }), [storageSourceKey, storageSources.sources, storageSources.createSource, defaultStorageSource]);\n\n // How the editor shows an image the text names by reference.\n const resolveImageSrc = useImageSrcResolver();\n\n // The AI continuation a plugin gives the form's markdown fields, if any;\n // the field's own `editorProps.aiController`, spread below, wins.\n const aiController = useProvidedEditorAIController();\n\n const entityValues = context.values;\n const entityId = context.id;\n const path = context.path;\n\n const [fieldVersion, setFieldVersion] = useState(0);\n const internalValue = useRef<string | null>(value);\n\n // Eagerly load ProseMirror markdown utils when the field first mounts\n useEffect(() => {\n getMarkdownUtils().then(() => {\n // Update canonical ref with the proper round-tripped value now that ProseMirror is loaded\n canonicalRef.current = canonicalizeMarkdown(canonicalSourceRef.current);\n });\n }, []);\n\n // Compute the canonical (round-tripped) form of the initial value ONCE.\n // This is what ProseMirror will produce after parse → serialize, so any\n // future serialization that matches this canonical form is NOT a real change.\n const canonicalInitialValue = useMemo(\n () => canonicalizeMarkdown(value),\n\n [] // intentionally only on mount\n );\n // Track it in a ref so the callback always has the latest\n const canonicalRef = useRef(canonicalInitialValue);\n // The value the canonical form was computed from — what this field was\n // given, as opposed to what the user has typed into it since.\n const canonicalSourceRef = useRef<string | null>(value);\n\n const onContentChange = useCallback((content: string) => {\n const normalizedContent = normalizeMarkdown(content);\n\n // Compare against the canonical roundtripped form of the initial value.\n // This eliminates ALL false positives from parse→serialize normalization\n // differences (trailing nodes, bullet chars, whitespace, etc.).\n if (normalizedContent === canonicalRef.current) {\n // Back to the value this field was given — so the form holds that\n // value again, verbatim, and not whatever was typed on the way.\n if (value !== canonicalSourceRef.current) {\n internalValue.current = canonicalSourceRef.current;\n setValue(canonicalSourceRef.current);\n }\n return;\n }\n // Also compare against the current form value to avoid redundant updates\n if (normalizedContent === normalizeMarkdown(value)) {\n return;\n }\n // Emptied: NULL, as the plain text field writes. `\"\"` over a stored\n // value stopped `isNull` filters matching the row.\n const next = normalizedContent.trim() === \"\" ? null : content;\n internalValue.current = next;\n setValue(next);\n }, [setValue, value]);\n\n useEffect(() => {\n if (internalValue.current !== value) {\n internalValue.current = value;\n canonicalSourceRef.current = value;\n canonicalRef.current = canonicalizeMarkdown(value);\n setFieldVersion(v => v + 1);\n }\n }, [value]);\n\n const fileNameBuilder = useCallback(async (file: File) => {\n if (storage?.fileName) {\n const fileName = await resolveStorageFilenameString({\n input: storage.fileName,\n storage,\n values: entityValues,\n entityId,\n path,\n property: property,\n file,\n propertyKey\n });\n if (!fileName || fileName.length === 0) {\n throw Error(\"You need to return a valid filename\");\n }\n return fileName;\n }\n return randomString() + \"_\" + file.name;\n }, [entityId, entityValues, path, property, propertyKey, storage]);\n\n const storagePathBuilder = useCallback((file: File) => {\n if (!storage) return \"/\";\n return resolveStoragePathString({\n input: storage.storagePath,\n storage,\n values: entityValues,\n entityId,\n path,\n property,\n file,\n propertyKey\n }) ?? \"/\";\n }, [entityId, entityValues, path, property, propertyKey, storage]);\n\n const editor = <Suspense fallback={<Skeleton height={200} className=\"w-full rounded-md\"/>}>\n <RichTextEditor\n content={value}\n onMarkdownContentChange={onContentChange}\n version={context.formex.version + fieldVersion}\n highlight={highlight}\n disabled={disabled}\n handleImageUpload={async (file: File) => {\n const storagePath = storagePathBuilder(file);\n const fileName = await fileNameBuilder(file);\n const key = `${storagePath}/${fileName}`.replace(/^\\/+/, \"\").replace(/\\/+/g, \"/\");\n const collectionSlug = context.collection?.slug;\n const result = await storageSource.putObject({\n file,\n key,\n // The property's own `storage.public`, and which property this\n // is, so the server holds the image to its limits.\n ...(storage?.public ? { public: true } : {}),\n ...(collectionSlug ? { context: { collection: collectionSlug, property: propertyKey } } : {})\n });\n // The text keeps a reference to the object, never its URL. A\n // private object's URL carries a download token that expires in\n // minutes, and this text is saved — so the post showed a broken\n // image, in this panel and on every site that published it, five\n // minutes after the upload. Whoever renders the text asks for a\n // URL then (`resolveStorageReferences`).\n return storageReference(result.key, storageSourceKey);\n }}\n resolveImageSrc={resolveImageSrc}\n aiController={aiController}\n {...editorProps}\n />\n </Suspense>;\n\n if (minimalistView)\n return editor;\n\n return (\n <>\n {!hideLabel && <div className=\"flex items-center w-full\">\n <LabelWithIcon\n propertyKey={propertyKey}\n icon={getIconForProperty(property, \"small\")}\n required={property.validation?.required}\n title={property.name ?? propertyKey}\n className={\"h-8 text-text-secondary dark:text-text-secondary-dark ml-3.5\"}/>\n </div>}\n {/* `relative` so Clear can float inside the box. It used to sit in\n the label row, which meant a clearable field with its label\n lifted out by the form still drew a row of chrome above the box\n and started lower than the field beside it.\n Bottom-right, not top: the editor puts its own mode toggle at\n `top-2 right-2` and the two would sit on each other. */}\n <div\n className={cls(\"relative rounded-md\", fieldBackgroundMixin, disabled ? fieldBackgroundDisabledMixin : fieldBackgroundHoverMixin)}>\n {property.admin?.clearable && !disabled && (\n <IconButton aria-label={t(\"clear\")}\n size=\"small\"\n className=\"absolute bottom-1 right-1 z-10\"\n onClick={(e) => {\n e.stopPropagation();\n e.preventDefault();\n setValue(null);\n }}\n >\n <XIcon/>\n </IconButton>\n )}\n {editor}\n </div>\n <FieldHelperText includeDescription={includeDescription}\n showError={showError}\n error={error}\n property={property}/>\n </>\n\n );\n\n}\n"],"mappings":";;;;;;;;;;;;;AA4BA,IAAM,iBAAiB,gBAAgB,OAAO,kBAAe,CAAC,MAAK,OAAM,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;AACxG,IAAM,0BAA0B,OAAO;AACvC,IAAI,iBAAuE;AAC3E,IAAM,mBAAmB,YAAY;CACjC,IAAI,CAAC,gBAAgB,iBAAiB,MAAM,kBAAkB;CAC9D,OAAO;AACX;;;;;AAWA,SAAS,kBAAkB,IAAuC;CAC9D,IAAI,CAAC,IAAI,OAAO;CAChB,OAAO,GACF,QAAQ,SAAS,IAAI,CAAC,CACtB,QAAQ,WAAW,MAAM,CAAC,CAC1B,QAAQ,aAAa,EAAE,CAAC,CACxB,KAAK;AACd;;;;;;;;;AAUA,SAAS,qBAAqB,IAAuC;CACjE,IAAI,CAAC,IAAI,OAAO;CAChB,IAAI,CAAC,gBAAgB,OAAO,kBAAkB,EAAE;CAChD,IAAI;EACA,MAAM,MAAM,eAAe,OAAO,MAAM,EAAE;EAC1C,IAAI,CAAC,KAAK,OAAO,kBAAkB,EAAE;EACrC,OAAO,kBAAkB,eAAe,WAAW,UAAU,GAAG,CAAC;CACrE,QAAQ;EACJ,OAAO,kBAAkB,EAAE;CAC/B;AACJ;AAEA,SAAgB,2BAA2B,EACvC,UACA,aACA,OACA,UACA,oB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H,cAAc,UAAU;KACzC;KACA;KAGA,GAAI,SAAS,SAAS,EAAE,QAAQ,KAAK,IAAI,CAAC;KAC1C,GAAI,iBAAiB,EAAE,SAAS;MAAE,YAAY;MAAgB,UAAU;KAAY,EAAE,IAAI,CAAC;IAC/F,CAAC,EAAA,CAO8B,KAAK,gBAAgB;GACxD;GACiB;GACH;GACd,GAAI;EACP,CAAA;CACS,CAAA;CAEV,IAAI,gBACA,OAAO;CAEX,OACI,qBAAA,UAAA,EAAA,UAAA;EACK,CAAC,aAAa,oBAAC,OAAD;GAAK,WAAU;aAC1B,oBAAC,eAAD;IACiB;IACb,MAAM,mBAAmB,UAAU,OAAO;IAC1C,UAAU,SAAS,YAAY;IAC/B,OAAO,SAAS,QAAQ;IACxB,WAAW;GAAgE,CAAA;EAC9E,CAAA;EAOL,qBAAC,OAAD;GACI,WAAW,IAAI,uBAAuB,sBAAsB,WAAW,+BAA+B,yBAAyB;aADnI,CAEK,SAAS,OAAO,aAAa,CAAC,YAC3B,oBAAC,YAAD;IAAY,cAAY,EAAE,OAAO;IAC7B,MAAK;IACL,WAAU;IACV,UAAU,MAAM;KACZ,EAAE,gBAAgB;KAClB,EAAE,eAAe;KACjB,SAAS,IAAI;IACjB;cAEA,oBAAC,OAAD,CAAO,CAAA;GACC,CAAA,GAEf,MACA;;EACL,oBAAC,iBAAD;GAAqC;GACtB;GACJ;GACG;EAAU,CAAA;CAC1B,EAAA,CAAA;AAIV"}
|
|
@@ -2,7 +2,7 @@ import { getIconForProperty } from "../../util/property_utils.js";
|
|
|
2
2
|
import { RelationPreview } from "../../preview/components/RelationPreview.js";
|
|
3
3
|
import { FieldHelperText } from "../components/FieldHelperText.js";
|
|
4
4
|
import { LabelWithIcon } from "../components/LabelWithIcon.js";
|
|
5
|
-
import {
|
|
5
|
+
import { useEntitySelectionDialog } from "../../hooks/useSelectionDialog.js";
|
|
6
6
|
import { ArrayContainer } from "../../components/ArrayContainer.js";
|
|
7
7
|
import { useCallback } from "react";
|
|
8
8
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -32,7 +32,7 @@ function MultipleRelationFieldBinding({ propertyKey, value: valueProp, error, sh
|
|
|
32
32
|
const onMultipleEntitiesSelected = useCallback((entities) => {
|
|
33
33
|
setValue(entities.map((e) => getRelationFrom(e)));
|
|
34
34
|
}, [setValue]);
|
|
35
|
-
const referenceDialogController =
|
|
35
|
+
const referenceDialogController = useEntitySelectionDialog({
|
|
36
36
|
multiselect: true,
|
|
37
37
|
path: getCollectionDataPath(collection),
|
|
38
38
|
collection,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultipleRelationFieldBinding.js","names":[],"sources":["../../../src/form/field_bindings/MultipleRelationFieldBinding.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"MultipleRelationFieldBinding.js","names":[],"sources":["../../../src/form/field_bindings/MultipleRelationFieldBinding.tsx"],"sourcesContent":["import { useEntitySelectionDialog } from \"../../hooks/useSelectionDialog\";\nimport type { FieldProps } from \"../../types/fields\";\nimport type { RelationProperty } from \"@rebasepro/types\";\nimport { Entity, getCollectionDataPath, getDataSourceCapabilities } from \"@rebasepro/types\";\nimport React, { useCallback } from \"react\";\nimport { FieldHelperText } from \"../components/FieldHelperText\";\nimport { LabelWithIcon } from \"../components/LabelWithIcon\";\nimport { ArrayContainer, ArrayEntryParams } from \"../../components/ArrayContainer\";\nimport { getIconForProperty } from \"../../util/property_utils\";\nimport { getRelationFrom, resolveRelationProperty } from \"@rebasepro/common\";\n\nimport { ErrorView, useTranslation } from \"@rebasepro/app\";\nimport { Button, cls, ExpandablePanel, fieldBackgroundMixin, PencilIcon, Typography } from \"@rebasepro/ui\";\nimport { RelationPreview } from \"../../preview\";\n\n/**\n * This field allows selecting multiple references.\n *\n * This is one of the internal components that get mapped natively inside forms\n * and tables to the specified properties.\n * @group Form fields\n */\nexport function MultipleRelationFieldBinding({\n propertyKey,\n value: valueProp,\n error,\n showError,\n disabled,\n isSubmitting,\n property,\n includeDescription,\n setValue,\n setFieldValue,\n context\n}: FieldProps<RelationProperty>) {\n\n const value = Array.isArray(valueProp) ? valueProp : [];\n const { t } = useTranslation();\n\n if (property.type !== \"relation\") {\n throw Error(\"RelationFieldBinding expected a property containing a relation\");\n }\n\n const parentCollection = context.collection;\n const capabilities = parentCollection ? getDataSourceCapabilities(parentCollection.engine) : undefined;\n // Only two things have to hold here: there is a collection, and its engine\n // has relations at all. Whether *this* property's relation can be resolved\n // is `resolveRelationProperty`'s question, and it answers it across all\n // three forms — a pre-stamped `resolvedRelation`, an inline `relation`, or\n // a lookup by name in the collection's `relations` array — with an error\n // naming the property and the collection when it cannot.\n //\n // This used to demand the `relations` array as well, which the inline form\n // does not produce. That is the documented way to declare a relation, so\n // every collection using it threw here and rendered the error boundary\n // instead of the field.\n if (!parentCollection || !capabilities?.supportsRelations) {\n throw Error(\"MultipleRelationFieldBinding expected a collection whose engine supports relations\");\n }\n const resolvedProperty = resolveRelationProperty(property, parentCollection, propertyKey)\n const relation = resolvedProperty;\n if (!relation)\n throw Error(\n \"Property relation is required for MultipleRelationFieldBinding\"\n )\n\n const selectedEntityIds = value && Array.isArray(value) ? value.map((ref) => ref.id) : [];\n const collection = relation.target();\n\n const onMultipleEntitiesSelected = useCallback((entities: Entity<Record<string, unknown>>[]) => {\n setValue(entities.map(e => getRelationFrom(e)));\n }, [setValue]);\n\n const referenceDialogController = useEntitySelectionDialog({\n multiselect: true,\n path: getCollectionDataPath(collection),\n collection,\n onMultipleEntitiesSelected,\n selectedEntityIds,\n fixedFilter: property.admin?.fixedFilter\n }\n );\n\n const onEntryClick = (e: React.SyntheticEvent) => {\n e.preventDefault();\n if (disabled || isSubmitting) return;\n referenceDialogController.open();\n };\n\n const buildEntry = useCallback(({\n index,\n internalId,\n storedProps,\n storeProps\n }: ArrayEntryParams) => {\n const entryValue = value && Array.isArray(value) && value.length > index ? value[index] : undefined;\n if (!entryValue)\n return <div>Internal ERROR</div>;\n return (\n <RelationPreview\n key={internalId}\n previewProperties={property.admin?.previewProperties}\n size={\"medium\"}\n onClick={onEntryClick}\n hover={!disabled}\n relation={entryValue}\n includeId={property.admin?.includeId}\n includeEntityLink={property.admin?.includeEntityLink}\n />\n );\n }, [relation, property.admin?.previewProperties, value, disabled, isSubmitting]);\n\n const title = (<>\n <LabelWithIcon\n propertyKey={propertyKey}\n icon={getIconForProperty(property, \"small\")}\n required={property.validation?.required}\n title={property.name ?? propertyKey}\n className={\"h-8 flex grow text-text-secondary dark:text-text-secondary-dark\"}/>\n {Array.isArray(value) && <Typography variant={\"caption\"} className={\"px-4\"}>({value.length})</Typography>}\n </>);\n\n const body = <>\n {!collection && <ErrorView\n error={\"The specified collection does not exist. Check console\"}/>}\n\n {collection && <div className={\"group\"}>\n\n <ArrayContainer droppableId={propertyKey}\n value={value}\n disabled={disabled || isSubmitting}\n buildEntry={buildEntry}\n canAddElements={false}\n addLabel={property.name ? t(\"add_reference_to\", { name: property.name }) : t(\"add_reference\")}\n newDefaultEntry={null}\n onValueChange={(value) => setFieldValue(propertyKey, value)}\n />\n\n <Button\n className=\"ml-3.5 my-4 justify-center text-left\"\n variant=\"text\"\n color=\"primary\"\n disabled={disabled || isSubmitting}\n onClick={onEntryClick}>\n <PencilIcon size={16}/>\n {t(\"edit_name\", { name: property.name ?? propertyKey })}\n </Button>\n </div>}\n </>;\n\n return (\n <>\n\n <ExpandablePanel\n titleClassName={fieldBackgroundMixin}\n innerClassName={cls(\"px-2 md:px-4 pb-2 md:pb-4 pt-1 md:pt-2\", fieldBackgroundMixin)}\n title={title}>\n {body}\n </ExpandablePanel>\n\n <FieldHelperText includeDescription={includeDescription}\n showError={showError}\n error={error}\n disabled={disabled}\n property={property}/>\n\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAsBA,SAAgB,6BAA6B,EACzC,aACA,OAAO,WACP,OACA,WACA,UACA,cACA,UACA,oBACA,UACA,eACA,WAC6B;CAE7B,MAAM,QAAQ,MA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