@rebasepro/cms 0.30.1 → 0.31.0-canary.g902a0ce
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 +8 -8
- package/dist/collection_editor/ConfigControllerProvider.js +25 -22
- package/dist/collection_editor/ConfigControllerProvider.js.map +1 -1
- package/dist/collection_editor/firestore_callee.d.ts +10 -0
- package/dist/collection_editor/firestore_callee.js +15 -0
- package/dist/collection_editor/firestore_callee.js.map +1 -0
- package/dist/collection_editor/firestore_edit.d.ts +62 -0
- package/dist/collection_editor/firestore_edit.js +339 -0
- package/dist/collection_editor/firestore_edit.js.map +1 -0
- package/dist/collection_editor/index.d.ts +2 -3
- package/dist/collection_editor/liveSchemaClient.d.ts +44 -22
- package/dist/collection_editor/liveSchemaClient.js +9 -3
- package/dist/collection_editor/liveSchemaClient.js.map +1 -1
- package/dist/collection_editor/property_column.d.ts +86 -0
- package/dist/collection_editor/property_column.js +719 -0
- package/dist/collection_editor/property_column.js.map +1 -0
- package/dist/collection_editor/serializable_types.d.ts +2 -24
- package/dist/collection_editor/serializable_utils.d.ts +1 -1
- package/dist/collection_editor/serializable_utils.js +2 -1
- package/dist/collection_editor/serializable_utils.js.map +1 -1
- package/dist/collection_editor/split_edit.d.ts +106 -0
- package/dist/collection_editor/split_edit.js +564 -0
- package/dist/collection_editor/split_edit.js.map +1 -0
- package/dist/collection_editor/split_edit_error.d.ts +25 -0
- package/dist/collection_editor/split_edit_error.js +35 -0
- package/dist/collection_editor/split_edit_error.js.map +1 -0
- package/dist/collection_editor/types/collection_editor_controller.d.ts +1 -1
- package/dist/collection_editor/types/config_controller.d.ts +67 -1
- package/dist/collection_editor/ui/collection_editor/CollectionEditorDialog.d.ts +6 -5
- package/dist/collection_editor/ui/collection_editor/CollectionEditorDialog.js +44 -12
- package/dist/collection_editor/ui/collection_editor/CollectionEditorDialog.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/CollectionPropertiesEditorForm.js +18 -3
- package/dist/collection_editor/ui/collection_editor/CollectionPropertiesEditorForm.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/CollectionRLSTab.js +94 -55
- package/dist/collection_editor/ui/collection_editor/CollectionRLSTab.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/CollectionRelationsTab.d.ts +2 -1
- package/dist/collection_editor/ui/collection_editor/DisplaySettingsForm.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/EnumForm.d.ts +1 -1
- package/dist/collection_editor/ui/collection_editor/EnumForm.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/GeneralSettingsForm.js +3 -3
- package/dist/collection_editor/ui/collection_editor/GeneralSettingsForm.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/KanbanConfigSection.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/PropertyEditView.d.ts +2 -3
- package/dist/collection_editor/ui/collection_editor/PropertyEditView.js +1 -1
- package/dist/collection_editor/ui/collection_editor/PropertyEditView.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/PropertyFieldPreview.d.ts +1 -1
- package/dist/collection_editor/ui/collection_editor/PropertyFieldPreview.js +1 -1
- package/dist/collection_editor/ui/collection_editor/PropertyFieldPreview.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/PropertyTree.d.ts +7 -4
- package/dist/collection_editor/ui/collection_editor/PropertyTree.js +15 -5
- package/dist/collection_editor/ui/collection_editor/PropertyTree.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/SchemaChangeDialog.js +1 -1
- package/dist/collection_editor/ui/collection_editor/SchemaChangeDialog.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/SchemaEditRefusalView.d.ts +20 -0
- package/dist/collection_editor/ui/collection_editor/SchemaEditRefusalView.js +74 -0
- package/dist/collection_editor/ui/collection_editor/SchemaEditRefusalView.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.d.ts +1 -1
- package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportMapping.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/import/clean_import_data.d.ts +1 -1
- package/dist/collection_editor/ui/collection_editor/import/clean_import_data.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/BlockPropertyField.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/DateTimePropertyField.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/EnumPropertyField.js +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/EnumPropertyField.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/MapPropertyField.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/ReferencePropertyField.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/RelationPropertyField.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/RepeatPropertyField.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/conditions/ConditionsEditor.d.ts +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/conditions/EnumConditionsEditor.d.ts +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/conditions/property_paths.d.ts +1 -1
- package/dist/collection_editor/ui/collection_editor/rlsRuleForm.d.ts +34 -0
- package/dist/collection_editor/ui/collection_editor/rlsRuleForm.js +50 -0
- package/dist/collection_editor/ui/collection_editor/rlsRuleForm.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/utils/update_property_for_widget.d.ts +1 -2
- package/dist/collection_editor/ui/collection_editor/utils/update_property_for_widget.js.map +1 -1
- package/dist/collection_editor/useDetachRulesConfirmation.d.ts +16 -0
- package/dist/collection_editor/useDetachRulesConfirmation.js +48 -0
- package/dist/collection_editor/useDetachRulesConfirmation.js.map +1 -0
- package/dist/collection_editor/useLiveSchemaEditing.d.ts +2 -2
- package/dist/collection_editor/useLiveSchemaEditing.js +1 -1
- package/dist/collection_editor/useLiveSchemaEditing.js.map +1 -1
- package/dist/collection_editor/useLocalCollectionsConfigController.d.ts +54 -10
- package/dist/collection_editor/useLocalCollectionsConfigController.js +394 -122
- package/dist/collection_editor/useLocalCollectionsConfigController.js.map +1 -1
- package/dist/collection_editor/validateCollectionJson.js.map +1 -1
- package/dist/components/CollectionPanel.d.ts +10 -9
- package/dist/components/CollectionPanel.js +5 -2
- package/dist/components/CollectionPanel.js.map +1 -1
- package/dist/components/CollectionTableBinding/CollectionRowActions.d.ts +1 -2
- package/dist/components/CollectionTableBinding/CollectionRowActions.js.map +1 -1
- package/dist/components/CollectionTableBinding/CollectionTableBinding.js.map +1 -1
- package/dist/components/CollectionTableBinding/CollectionTableBindingProps.d.ts +3 -5
- package/dist/components/CollectionTableBinding/PropertyTableCell.d.ts +2 -2
- package/dist/components/CollectionTableBinding/PropertyTableCell.js.map +1 -1
- package/dist/components/CollectionTableBinding/column_utils.d.ts +1 -1
- package/dist/components/CollectionTableBinding/column_utils.js.map +1 -1
- package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.d.ts +2 -2
- package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.js +1 -2
- package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.js.map +1 -1
- package/dist/components/CollectionTableBinding/fields/TableReferenceField.d.ts +2 -2
- 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.d.ts +2 -2
- package/dist/components/CollectionTableBinding/fields/TableRelationField.js +1 -2
- package/dist/components/CollectionTableBinding/fields/TableRelationField.js.map +1 -1
- package/dist/components/CollectionTableBinding/fields/TableRelationSelectorField.d.ts +2 -1
- package/dist/components/CollectionTableBinding/fields/TableRelationSelectorField.js.map +1 -1
- package/dist/components/CollectionTableBinding/fields/TableStorageUpload.d.ts +2 -2
- package/dist/components/CollectionTableBinding/fields/TableStorageUpload.js.map +1 -1
- package/dist/components/CollectionTableBinding/fields/VirtualTableSelect.d.ts +1 -1
- package/dist/components/CollectionTableBinding/fields/VirtualTableSelect.js +1 -1
- package/dist/components/CollectionTableBinding/fields/VirtualTableSelect.js.map +1 -1
- package/dist/components/CollectionTableBinding/internal/common.d.ts +1 -2
- package/dist/components/CollectionTableBinding/internal/common.js.map +1 -1
- package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.d.ts +1 -1
- package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js +2 -2
- package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js.map +1 -1
- package/dist/components/CollectionTableBinding/table_bindings.d.ts +2 -2
- package/dist/components/CollectionTableBinding/table_bindings.js.map +1 -1
- package/dist/components/CollectionViewBinding/BoardCardBinding.d.ts +1 -1
- package/dist/components/CollectionViewBinding/BoardCardBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.d.ts +1 -2
- package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.js +9 -5
- package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionCardViewBinding.d.ts +1 -2
- package/dist/components/CollectionViewBinding/CollectionCardViewBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionEntityActions.d.ts +1 -1
- package/dist/components/CollectionViewBinding/CollectionEntityActions.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionListViewBinding.d.ts +1 -2
- package/dist/components/CollectionViewBinding/CollectionListViewBinding.js +1 -1
- package/dist/components/CollectionViewBinding/CollectionListViewBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionToolbar.js +1 -1
- package/dist/components/CollectionViewBinding/CollectionToolbar.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionViewActions.js +2 -4
- package/dist/components/CollectionViewBinding/CollectionViewActions.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionViewBinding.d.ts +6 -6
- package/dist/components/CollectionViewBinding/CollectionViewBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionViewContent.js +1 -2
- package/dist/components/CollectionViewBinding/CollectionViewContent.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionViewStartActions.d.ts +1 -1
- package/dist/components/CollectionViewBinding/CollectionViewStartActions.js.map +1 -1
- package/dist/components/CollectionViewBinding/CustomViewHost.d.ts +1 -2
- package/dist/components/CollectionViewBinding/CustomViewHost.js.map +1 -1
- package/dist/components/CollectionViewBinding/EntitiesCount.js +3 -3
- package/dist/components/CollectionViewBinding/EntitiesCount.js.map +1 -1
- package/dist/components/CollectionViewBinding/EntityCardBinding.d.ts +1 -2
- package/dist/components/CollectionViewBinding/EntityCardBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/EntityIdHeaderWidget.js +1 -1
- package/dist/components/CollectionViewBinding/EntityIdHeaderWidget.js.map +1 -1
- package/dist/components/CollectionViewBinding/FilterPresetsButton.d.ts +1 -2
- package/dist/components/CollectionViewBinding/FilterPresetsButton.js +1 -1
- package/dist/components/CollectionViewBinding/FilterPresetsButton.js.map +1 -1
- package/dist/components/CollectionViewBinding/FiltersButton.d.ts +1 -2
- package/dist/components/CollectionViewBinding/FiltersButton.js.map +1 -1
- package/dist/components/CollectionViewBinding/FiltersDialog.d.ts +1 -1
- package/dist/components/CollectionViewBinding/FiltersDialog.js.map +1 -1
- package/dist/components/CollectionViewBinding/PluginColumnSlots.d.ts +1 -2
- package/dist/components/CollectionViewBinding/PluginColumnSlots.js.map +1 -1
- package/dist/components/CollectionViewBinding/RowActions.d.ts +1 -2
- package/dist/components/CollectionViewBinding/RowActions.js.map +1 -1
- package/dist/components/CollectionViewBinding/SortButton.d.ts +1 -1
- package/dist/components/CollectionViewBinding/SortButton.js.map +1 -1
- package/dist/components/CollectionViewBinding/SplitListView.d.ts +1 -2
- package/dist/components/CollectionViewBinding/SplitListView.js.map +1 -1
- package/dist/components/CollectionViewBinding/hooks/useCollectionInlineEditor.d.ts +1 -2
- package/dist/components/CollectionViewBinding/hooks/useCollectionInlineEditor.js +1 -1
- package/dist/components/CollectionViewBinding/hooks/useCollectionInlineEditor.js.map +1 -1
- package/dist/components/CollectionViewBinding/hooks/useKanbanDragAndDrop.d.ts +1 -2
- package/dist/components/CollectionViewBinding/hooks/useKanbanDragAndDrop.js.map +1 -1
- package/dist/components/CollectionViewBinding/useBoardDataController.d.ts +2 -1
- package/dist/components/CollectionViewBinding/useBoardDataController.js +3 -3
- package/dist/components/CollectionViewBinding/useBoardDataController.js.map +1 -1
- package/dist/components/CollectionViewBinding/useCollectionViewState.d.ts +2 -4
- package/dist/components/CollectionViewBinding/useCollectionViewState.js +14 -19
- package/dist/components/CollectionViewBinding/useCollectionViewState.js.map +1 -1
- package/dist/components/CollectionViewBinding/usePreviewSlots.d.ts +1 -3
- package/dist/components/CollectionViewBinding/usePreviewSlots.js.map +1 -1
- package/dist/components/CollectionViewBinding/useSelectionController.d.ts +1 -2
- package/dist/components/CollectionViewBinding/useSelectionController.js.map +1 -1
- package/dist/components/CollectionsProvider.d.ts +23 -8
- package/dist/components/CollectionsProvider.js +23 -7
- package/dist/components/CollectionsProvider.js.map +1 -1
- package/dist/components/DefaultDrawer.js +1 -1
- package/dist/components/DeleteEntityDialog.d.ts +1 -1
- package/dist/components/DeleteEntityDialog.js +1 -1
- package/dist/components/DeleteEntityDialog.js.map +1 -1
- package/dist/components/DetailViewBinding.js +3 -3
- package/dist/components/DetailViewBinding.js.map +1 -1
- package/dist/components/EditFormActions.js.map +1 -1
- package/dist/components/EditViewBinding.d.ts +2 -1
- package/dist/components/EditViewBinding.js +6 -6
- package/dist/components/EditViewBinding.js.map +1 -1
- package/dist/components/EntityDisplayHeader.d.ts +1 -2
- package/dist/components/EntityDisplayHeader.js.map +1 -1
- package/dist/components/EntityInspector.d.ts +1 -2
- package/dist/components/EntityInspector.js.map +1 -1
- package/dist/components/EntityPreviewBinding.d.ts +1 -1
- package/dist/components/EntityPreviewBinding.js +1 -1
- package/dist/components/EntityPreviewBinding.js.map +1 -1
- package/dist/components/EntityViewBinding.d.ts +1 -1
- package/dist/components/EntityViewBinding.js.map +1 -1
- package/dist/components/EntityViewBody.d.ts +1 -1
- package/dist/components/EntityViewBody.js +3 -4
- package/dist/components/EntityViewBody.js.map +1 -1
- package/dist/components/FieldValue.js +2 -2
- package/dist/components/FieldValue.js.map +1 -1
- package/dist/components/HomePage/ContentHomePage.js +12 -3
- package/dist/components/HomePage/ContentHomePage.js.map +1 -1
- package/dist/components/InlineEntityPreview.d.ts +1 -1
- package/dist/components/InlineEntityPreview.js.map +1 -1
- package/dist/components/PropertyCollectionView.d.ts +2 -2
- package/dist/components/PropertyCollectionView.js.map +1 -1
- package/dist/components/PropertyConfigBadge.js.map +1 -1
- package/dist/components/RebaseCMS.d.ts +22 -3
- package/dist/components/RebaseCMS.js +32 -14
- package/dist/components/RebaseCMS.js.map +1 -1
- package/dist/components/RebaseNavigation.js +106 -31
- package/dist/components/RebaseNavigation.js.map +1 -1
- package/dist/components/RecordDetail.js +4 -1
- package/dist/components/RecordDetail.js.map +1 -1
- package/dist/components/RecordForm.d.ts +5 -5
- package/dist/components/RecordForm.js +5 -2
- package/dist/components/RecordForm.js.map +1 -1
- package/dist/components/ReferenceTable/SelectionTableBinding.d.ts +2 -2
- package/dist/components/ReferenceTable/SelectionTableBinding.js +1 -1
- package/dist/components/ReferenceTable/SelectionTableBinding.js.map +1 -1
- package/dist/components/ReferenceWidget.d.ts +2 -1
- package/dist/components/ReferenceWidget.js +2 -2
- package/dist/components/ReferenceWidget.js.map +1 -1
- package/dist/components/RelationSelector.d.ts +2 -1
- package/dist/components/RelationSelector.js +2 -3
- package/dist/components/RelationSelector.js.map +1 -1
- package/dist/components/SelectableTable/SelectableTable.d.ts +2 -2
- package/dist/components/SelectableTable/SelectableTable.js.map +1 -1
- package/dist/components/SelectableTable/filters/FilterFieldBinding.d.ts +2 -1
- package/dist/components/SelectableTable/filters/FilterFieldBinding.js +3 -3
- package/dist/components/SelectableTable/filters/FilterFieldBinding.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/SelectableTable/filters/RelationFilterField.d.ts +1 -1
- package/dist/components/SelectableTable/filters/RelationFilterField.js +1 -1
- package/dist/components/SelectableTable/filters/RelationFilterField.js.map +1 -1
- package/dist/components/SelectableTable/filters/StringNumberFilterField.d.ts +1 -1
- package/dist/components/SelectableTable/filters/StringNumberFilterField.js.map +1 -1
- package/dist/components/SelectableTable/filters/null_filter.d.ts +1 -3
- package/dist/components/SelectableTable/filters/null_filter.js.map +1 -1
- package/dist/components/SidePanelBinding.js +1 -1
- package/dist/components/SidePanelBinding.js.map +1 -1
- package/dist/components/field_configs.d.ts +1 -2
- package/dist/components/field_configs.js.map +1 -1
- package/dist/components/field_ids.d.ts +1 -1
- package/dist/components/field_ids.js +1 -1
- package/dist/components/field_ids.js.map +1 -1
- package/dist/components/history/EntityHistoryEntry.js.map +1 -1
- package/dist/components/history/EntityHistoryView.d.ts +1 -2
- package/dist/components/history/EntityHistoryView.js +1 -1
- package/dist/components/history/EntityHistoryView.js.map +1 -1
- package/dist/data_export/export/BasicExportAction.d.ts +1 -1
- package/dist/data_export/export/BasicExportAction.js.map +1 -1
- package/dist/data_export/export/ExportCollectionAction.js +2 -2
- package/dist/data_export/export/ExportCollectionAction.js.map +1 -1
- package/dist/data_export/export/additional_fields.d.ts +1 -1
- package/dist/data_export/export/additional_fields.js.map +1 -1
- package/dist/data_export/export/export.d.ts +1 -1
- package/dist/data_export/export/export.js +1 -1
- package/dist/data_export/export/export.js.map +1 -1
- package/dist/data_export/export/fetch_export_data.d.ts +3 -2
- package/dist/data_export/export/fetch_export_data.js.map +1 -1
- package/dist/data_import/components/DataNewPropertiesMapping.d.ts +1 -1
- package/dist/data_import/components/DataNewPropertiesMapping.js.map +1 -1
- package/dist/data_import/components/ImportNewPropertyFieldPreview.d.ts +1 -1
- package/dist/data_import/components/ImportNewPropertyFieldPreview.js.map +1 -1
- package/dist/data_import/hooks/useImportConfig.js.map +1 -1
- package/dist/data_import/import/ImportCollectionAction.d.ts +2 -2
- package/dist/data_import/import/ImportCollectionAction.js.map +1 -1
- package/dist/data_import/types/column_mapping.d.ts +1 -1
- package/dist/data_import/utils/data.d.ts +1 -2
- package/dist/data_import/utils/data.js +1 -2
- package/dist/data_import/utils/data.js.map +1 -1
- package/dist/data_import/utils/get_import_inference_type.d.ts +1 -1
- package/dist/data_import/utils/get_import_inference_type.js.map +1 -1
- package/dist/data_import/utils/id_column.d.ts +1 -1
- package/dist/data_import/utils/id_column.js.map +1 -1
- package/dist/data_import/utils/import_columns.d.ts +1 -1
- package/dist/data_import/utils/import_columns.js.map +1 -1
- package/dist/data_import/utils/save_entities.d.ts +3 -3
- package/dist/data_import/utils/save_entities.js +1 -1
- package/dist/data_import/utils/save_entities.js.map +1 -1
- package/dist/form/EntityForm.js +2 -1
- package/dist/form/EntityForm.js.map +1 -1
- package/dist/form/EntityFormActions.js.map +1 -1
- package/dist/form/EntityFormBinding.js +2 -2
- package/dist/form/EntityFormBinding.js.map +1 -1
- package/dist/form/FormFieldsContext.d.ts +1 -4
- package/dist/form/FormFieldsContext.js +1 -1
- package/dist/form/FormFieldsContext.js.map +1 -1
- package/dist/form/PropertyFieldBinding.js +6 -8
- package/dist/form/PropertyFieldBinding.js.map +1 -1
- package/dist/form/components/FieldBlock.d.ts +1 -2
- package/dist/form/components/FieldBlock.js.map +1 -1
- package/dist/form/components/FieldHelperText.d.ts +1 -1
- package/dist/form/components/FieldHelperText.js.map +1 -1
- package/dist/form/components/FormRail.d.ts +1 -1
- package/dist/form/components/FormRail.js.map +1 -1
- package/dist/form/components/LocalChangesMenu.d.ts +1 -1
- package/dist/form/components/LocalChangesMenu.js.map +1 -1
- package/dist/form/components/StorageItemPreview.d.ts +1 -1
- package/dist/form/components/StorageItemPreview.js.map +1 -1
- package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.js +1 -1
- package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.d.ts +2 -2
- package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.js +2 -2
- package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/BinaryFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/BinaryFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/BlockFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/BlockFieldBinding.js +1 -1
- package/dist/form/field_bindings/BlockFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/DateTimeFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/DateTimeFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/GeopointFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/GeopointFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/KeyValueFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/KeyValueFieldBinding.js +1 -2
- package/dist/form/field_bindings/KeyValueFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/MapFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/MapFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/MarkdownEditorFieldBinding.d.ts +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/MultiSelectFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/MultiSelectFieldBinding.js +1 -1
- package/dist/form/field_bindings/MultiSelectFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/MultipleRelationFieldBinding.d.ts +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.d.ts +1 -1
- package/dist/form/field_bindings/ReadOnlyFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/ReferenceFieldBinding.d.ts +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.d.ts +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/RepeatFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/RepeatFieldBinding.js +1 -1
- package/dist/form/field_bindings/RepeatFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/SelectFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/SelectFieldBinding.js +1 -1
- package/dist/form/field_bindings/SelectFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/StorageUploadFieldBinding.d.ts +2 -2
- package/dist/form/field_bindings/StorageUploadFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/SwitchFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/SwitchFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/TextFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/TextFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/UserSelectFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/UserSelectFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/VectorFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/VectorFieldBinding.js.map +1 -1
- package/dist/form/form_utils.d.ts +3 -3
- package/dist/form/form_utils.js +1 -2
- package/dist/form/form_utils.js.map +1 -1
- package/dist/form/label_placement.d.ts +1 -2
- package/dist/form/label_placement.js.map +1 -1
- package/dist/form/resolve_cell_property.d.ts +1 -2
- package/dist/form/resolve_cell_property.js +1 -1
- package/dist/form/resolve_cell_property.js.map +1 -1
- package/dist/form/resolve_form_properties.d.ts +2 -2
- package/dist/form/resolve_form_properties.js +1 -1
- package/dist/form/resolve_form_properties.js.map +1 -1
- package/dist/form/useClearRestoreValue.d.ts +1 -1
- package/dist/form/useClearRestoreValue.js.map +1 -1
- package/dist/form/validation.d.ts +2 -2
- package/dist/form/validation.js +1 -1
- package/dist/form/validation.js.map +1 -1
- package/dist/hooks/navigation/compose_collections.d.ts +59 -0
- package/dist/hooks/navigation/compose_collections.js +48 -0
- package/dist/hooks/navigation/compose_collections.js.map +1 -0
- package/dist/hooks/navigation/compose_collections_input.d.ts +8 -0
- package/dist/hooks/navigation/compose_collections_input.js +17 -0
- package/dist/hooks/navigation/compose_collections_input.js.map +1 -0
- package/dist/hooks/navigation/contexts/CollectionRegistryContext.d.ts +1 -1
- package/dist/hooks/navigation/contexts/CollectionRegistryContext.js.map +1 -1
- package/dist/hooks/navigation/registered_collection.d.ts +15 -0
- package/dist/hooks/navigation/registered_collection.js +20 -0
- package/dist/hooks/navigation/registered_collection.js.map +1 -0
- package/dist/hooks/navigation/ui_preferences.d.ts +47 -0
- package/dist/hooks/navigation/ui_preferences.js +179 -0
- package/dist/hooks/navigation/ui_preferences.js.map +1 -0
- package/dist/hooks/navigation/useAsyncResolver.d.ts +8 -1
- package/dist/hooks/navigation/useAsyncResolver.js +9 -3
- package/dist/hooks/navigation/useAsyncResolver.js.map +1 -1
- package/dist/hooks/navigation/useBuildCollectionRegistryController.d.ts +1 -3
- package/dist/hooks/navigation/useBuildCollectionRegistryController.js +3 -3
- package/dist/hooks/navigation/useBuildCollectionRegistryController.js.map +1 -1
- package/dist/hooks/navigation/useBuildNavigationStateController.d.ts +9 -5
- package/dist/hooks/navigation/useBuildNavigationStateController.js +2 -1
- package/dist/hooks/navigation/useBuildNavigationStateController.js.map +1 -1
- package/dist/hooks/navigation/useBuildUrlController.d.ts +1 -1
- package/dist/hooks/navigation/useBuildUrlController.js.map +1 -1
- package/dist/hooks/navigation/useNavigationResolution.js +1 -2
- package/dist/hooks/navigation/useNavigationResolution.js.map +1 -1
- package/dist/hooks/navigation/usePanelTables.d.ts +11 -0
- package/dist/hooks/navigation/usePanelTables.js +33 -0
- package/dist/hooks/navigation/usePanelTables.js.map +1 -0
- package/dist/hooks/navigation/useResolvedCollections.d.ts +8 -3
- package/dist/hooks/navigation/useResolvedCollections.js +3 -2
- package/dist/hooks/navigation/useResolvedCollections.js.map +1 -1
- package/dist/hooks/navigation/useResolvedViews.d.ts +1 -2
- package/dist/hooks/navigation/useResolvedViews.js.map +1 -1
- package/dist/hooks/navigation/useTopLevelNavigation.d.ts +1 -2
- package/dist/hooks/navigation/useTopLevelNavigation.js.map +1 -1
- package/dist/hooks/navigation/user_preferences_overlay.d.ts +21 -0
- package/dist/hooks/navigation/user_preferences_overlay.js +101 -0
- package/dist/hooks/navigation/user_preferences_overlay.js.map +1 -0
- package/dist/hooks/navigation/utils.js +1 -1
- package/dist/hooks/navigation/utils.js.map +1 -1
- package/dist/hooks/useAdminContext.d.ts +1 -2
- package/dist/hooks/useAdminContext.js.map +1 -1
- package/dist/hooks/useBuildSidePanel.d.ts +1 -2
- package/dist/hooks/useBuildSidePanel.js +2 -1
- package/dist/hooks/useBuildSidePanel.js.map +1 -1
- package/dist/hooks/useChildViewSource.d.ts +1 -1
- package/dist/hooks/useChildViewSource.js +1 -1
- package/dist/hooks/useChildViewSource.js.map +1 -1
- package/dist/hooks/useEntityDisplay.d.ts +1 -2
- package/dist/hooks/useEntityDisplay.js +1 -1
- package/dist/hooks/useEntityDisplay.js.map +1 -1
- package/dist/hooks/useEntityDisplayTitle.d.ts +2 -2
- package/dist/hooks/useEntityDisplayTitle.js.map +1 -1
- package/dist/hooks/useHistory.js +1 -1
- package/dist/hooks/useHistory.js.map +1 -1
- package/dist/hooks/useRecordActions.d.ts +1 -2
- package/dist/hooks/useRecordActions.js.map +1 -1
- package/dist/hooks/useReferencePaths.d.ts +21 -7
- package/dist/hooks/useReferencePaths.js +23 -6
- package/dist/hooks/useReferencePaths.js.map +1 -1
- package/dist/hooks/useResolvedNavigationFrom.d.ts +3 -3
- package/dist/hooks/useResolvedNavigationFrom.js +1 -1
- package/dist/hooks/useResolvedNavigationFrom.js.map +1 -1
- package/dist/index.d.ts +11 -0
- package/dist/index.js +8 -2
- package/dist/mcp_view/app_modules.d.ts +2 -2
- package/dist/mcp_view/app_modules.js +4 -4
- package/dist/mcp_view/app_modules.js.map +1 -1
- package/dist/mcp_view/index.d.ts +16 -19
- package/dist/mcp_view/index.js +43 -62
- package/dist/mcp_view/index.js.map +1 -1
- package/dist/mcp_view/payload.d.ts +54 -18
- package/dist/mcp_view/payload.js +49 -24
- package/dist/mcp_view/payload.js.map +1 -1
- package/dist/mcp_view/screen.js +11 -11
- package/dist/mcp_view/screen.js.map +1 -1
- package/dist/mcp_view/tool_driver.d.ts +5 -34
- package/dist/mcp_view/tool_driver.js +17 -16
- package/dist/mcp_view/tool_driver.js.map +1 -1
- package/dist/mcp_view/write_review.d.ts +1 -2
- package/dist/mcp_view/write_review.js +1 -1
- package/dist/mcp_view/write_review.js.map +1 -1
- package/dist/preview/PropertyPreview.d.ts +1 -1
- package/dist/preview/PropertyPreview.js +4 -3
- package/dist/preview/PropertyPreview.js.map +1 -1
- package/dist/preview/components/ArrayEnumPreview.d.ts +1 -1
- package/dist/preview/components/ArrayEnumPreview.js.map +1 -1
- package/dist/preview/components/BooleanPreview.d.ts +1 -1
- package/dist/preview/components/BooleanPreview.js.map +1 -1
- package/dist/preview/components/EnumValuesChip.d.ts +1 -1
- package/dist/preview/components/EnumValuesChip.js +1 -1
- package/dist/preview/components/EnumValuesChip.js.map +1 -1
- package/dist/preview/components/ReferencePreview.d.ts +1 -1
- package/dist/preview/components/ReferencePreview.js.map +1 -1
- package/dist/preview/components/RelationPreview.d.ts +1 -1
- package/dist/preview/components/RelationPreview.js.map +1 -1
- package/dist/preview/components/StorageThumbnail.js +2 -1
- package/dist/preview/components/StorageThumbnail.js.map +1 -1
- package/dist/preview/components/UserPreview.d.ts +1 -1
- package/dist/preview/components/UserPreview.js.map +1 -1
- package/dist/preview/property_previews/ArrayOfMapsPreview.d.ts +1 -1
- package/dist/preview/property_previews/ArrayOfMapsPreview.js.map +1 -1
- package/dist/preview/property_previews/ArrayOfReferencesPreview.d.ts +1 -1
- package/dist/preview/property_previews/ArrayOfReferencesPreview.js.map +1 -1
- package/dist/preview/property_previews/ArrayOfRelationsPreview.d.ts +1 -1
- package/dist/preview/property_previews/ArrayOfRelationsPreview.js +2 -1
- package/dist/preview/property_previews/ArrayOfRelationsPreview.js.map +1 -1
- package/dist/preview/property_previews/ArrayOfStorageComponentsPreview.d.ts +1 -1
- package/dist/preview/property_previews/ArrayOfStorageComponentsPreview.js.map +1 -1
- package/dist/preview/property_previews/ArrayOfStringsPreview.d.ts +1 -1
- package/dist/preview/property_previews/ArrayOfStringsPreview.js.map +1 -1
- package/dist/preview/property_previews/ArrayOneOfPreview.d.ts +1 -1
- package/dist/preview/property_previews/ArrayOneOfPreview.js +1 -1
- package/dist/preview/property_previews/ArrayOneOfPreview.js.map +1 -1
- package/dist/preview/property_previews/ArrayPropertyEnumPreview.d.ts +1 -1
- package/dist/preview/property_previews/ArrayPropertyEnumPreview.js +1 -1
- package/dist/preview/property_previews/ArrayPropertyEnumPreview.js.map +1 -1
- package/dist/preview/property_previews/ArrayPropertyPreview.d.ts +1 -1
- package/dist/preview/property_previews/ArrayPropertyPreview.js +1 -1
- package/dist/preview/property_previews/ArrayPropertyPreview.js.map +1 -1
- package/dist/preview/property_previews/MapPropertyPreview.d.ts +1 -1
- package/dist/preview/property_previews/MapPropertyPreview.js.map +1 -1
- package/dist/preview/property_previews/NumberPropertyPreview.d.ts +1 -1
- package/dist/preview/property_previews/NumberPropertyPreview.js +1 -1
- package/dist/preview/property_previews/NumberPropertyPreview.js.map +1 -1
- package/dist/preview/property_previews/SkeletonPropertyComponent.d.ts +1 -1
- package/dist/preview/property_previews/SkeletonPropertyComponent.js.map +1 -1
- package/dist/preview/property_previews/StringPropertyPreview.d.ts +1 -1
- package/dist/preview/property_previews/StringPropertyPreview.js.map +1 -1
- package/dist/preview/util.d.ts +1 -1
- package/dist/preview/util.js.map +1 -1
- package/dist/routes/RebaseRoute.js +2 -2
- package/dist/routes/RebaseRoute.js.map +1 -1
- package/dist/saved_apps/SavedAppsView.d.ts +1 -1
- package/dist/saved_apps/SavedAppsView.js +1 -1
- package/dist/saved_apps/SavedAppsView.js.map +1 -1
- package/dist/selection/SelectionMenu.d.ts +1 -1
- package/dist/selection/SelectionMenu.js.map +1 -1
- package/dist/selection/resolve_selection.d.ts +3 -3
- package/dist/selection/resolve_selection.js +3 -2
- package/dist/selection/resolve_selection.js.map +1 -1
- package/dist/tables/apply_customization.d.ts +65 -0
- package/dist/tables/apply_customization.js +644 -0
- package/dist/tables/apply_customization.js.map +1 -0
- package/dist/tables/column_property.d.ts +64 -0
- package/dist/tables/column_property.js +549 -0
- package/dist/tables/column_property.js.map +1 -0
- package/dist/tables/customize_table.d.ts +39 -0
- package/dist/tables/customize_table.js +247 -0
- package/dist/tables/customize_table.js.map +1 -0
- package/dist/tables/index.d.ts +12 -0
- package/dist/tables/labels.d.ts +18 -0
- package/dist/tables/labels.js +18 -0
- package/dist/tables/labels.js.map +1 -0
- package/dist/tables/project_table.d.ts +79 -0
- package/dist/tables/project_table.js +148 -0
- package/dist/tables/project_table.js.map +1 -0
- package/dist/tables/relations.d.ts +47 -0
- package/dist/tables/relations.js +112 -0
- package/dist/tables/relations.js.map +1 -0
- package/dist/tables/rls.d.ts +39 -0
- package/dist/tables/rls.js +111 -0
- package/dist/tables/rls.js.map +1 -0
- package/dist/tables/update_record.d.ts +32 -0
- package/dist/tables/update_record.js +40 -0
- package/dist/tables/update_record.js.map +1 -0
- package/dist/types/components/EntityFormActionsProps.d.ts +1 -1
- package/dist/types/components/PropertyPreviewProps.d.ts +2 -2
- package/dist/types/fields.d.ts +2 -2
- package/dist/util/dataControllerAdapter.js.map +1 -1
- package/dist/util/entity_pages.d.ts +2 -1
- package/dist/util/entity_pages.js.map +1 -1
- package/dist/util/find_entities_by_ids.d.ts +2 -2
- package/dist/util/find_entities_by_ids.js +1 -1
- package/dist/util/find_entities_by_ids.js.map +1 -1
- package/dist/util/format_collection_date.d.ts +1 -1
- package/dist/util/format_collection_date.js.map +1 -1
- package/dist/util/identity.d.ts +8 -0
- package/dist/util/identity.js +16 -0
- package/dist/util/identity.js.map +1 -0
- package/dist/util/navigation_utils.js +1 -1
- package/dist/util/navigation_utils.js.map +1 -1
- package/dist/util/previews.js +1 -1
- package/dist/util/previews.js.map +1 -1
- package/dist/util/propertyConfigMapper.d.ts +1 -1
- package/dist/util/propertyConfigMapper.js.map +1 -1
- package/dist/util/property_utils.d.ts +1 -3
- package/dist/util/property_utils.js +1 -1
- package/dist/util/property_utils.js.map +1 -1
- package/dist/util/relations.d.ts +18 -0
- package/dist/util/relations.js +32 -0
- package/dist/util/relations.js.map +1 -0
- package/package.json +12 -10
- package/recipes/README.md +4 -4
- package/recipes/my-preferences.tsx +34 -26
- package/recipes/site-settings.tsx +34 -27
- package/dist/collection_editor/collection_wire.d.ts +0 -13
- package/dist/collection_editor/collection_wire.js +0 -49
- package/dist/collection_editor/collection_wire.js.map +0 -1
- package/dist/collection_editor/useJsonCollectionsConfigController.d.ts +0 -37
- package/dist/collection_editor/useJsonCollectionsConfigController.js +0 -191
- package/dist/collection_editor/useJsonCollectionsConfigController.js.map +0 -1
|
@@ -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.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,oBACA,WACA,WACA,OACA,gBACA,UAAU,cACV,cACA,SACA,eACqD;CACrD,MAAM,EAAE,MAAM,eAAe;CAEN,kBAAkB;CACzC,MAAM,WAAW,gBAAgB;CACjC,MAAM,YAAY,aAAa;CAC/B,MAAM,cAAc,aAAa;CACjC,MAAM,uBAAuB,iBAAiB;CAC9C,MAAM,UAAU,SAAS;CACzB,MAAM,iBAAiB,kBAAkB;CAIzC,MAAM,mBAA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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"}
|
|
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/cms-types\";\nimport { getIconForProperty } from \"../../util/property_utils\";\nimport type { FieldProps } from \"../../types/fields\";\nimport type { ArrayProperty, StringProperty } from \"@rebasepro/cms-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/cms-types\";\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,EAA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AOL,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"}
|
|
@@ -5,7 +5,7 @@ import { LabelWithIcon } from "../components/LabelWithIcon.js";
|
|
|
5
5
|
import { useCallback } from "react";
|
|
6
6
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
import { MultiSelect, MultiSelectItem, XIcon, iconSize } from "@rebasepro/ui";
|
|
8
|
-
import { enumToObjectEntries, getLabelOrConfigFrom } from "@rebasepro/
|
|
8
|
+
import { enumToObjectEntries, getLabelOrConfigFrom } from "@rebasepro/cms-types";
|
|
9
9
|
//#region src/form/field_bindings/MultiSelectFieldBinding.tsx
|
|
10
10
|
/**
|
|
11
11
|
* This fields renders a dropdown with multiple selection.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiSelectFieldBinding.js","names":[],"sources":["../../../src/form/field_bindings/MultiSelectFieldBinding.tsx"],"sourcesContent":["import type { FieldProps } from \"../../types/fields\";\nimport type { ArrayProperty, Property } from \"@rebasepro/types\";\nimport React, { useCallback } from \"react\";\n\n;\nimport { FieldHelperText } from \"../components/FieldHelperText\";\nimport { LabelWithIcon } from \"../components/LabelWithIcon\";\nimport { EnumValuesChip } from \"../../preview\";\nimport { getIconForProperty } from \"../../util/property_utils\";\nimport {
|
|
1
|
+
{"version":3,"file":"MultiSelectFieldBinding.js","names":[],"sources":["../../../src/form/field_bindings/MultiSelectFieldBinding.tsx"],"sourcesContent":["import type { FieldProps } from \"../../types/fields\";\nimport type { ArrayProperty, Property } from \"@rebasepro/cms-types\";\nimport React, { useCallback } from \"react\";\n\n;\nimport { FieldHelperText } from \"../components/FieldHelperText\";\nimport { LabelWithIcon } from \"../components/LabelWithIcon\";\nimport { EnumValuesChip } from \"../../preview\";\nimport { getIconForProperty } from \"../../util/property_utils\";\nimport { getLabelOrConfigFrom, enumToObjectEntries } from \"@rebasepro/cms-types\";\nimport { iconSize, MultiSelect, MultiSelectItem, XIcon } from \"@rebasepro/ui\";\n\n/**\n * This fields renders a dropdown with multiple selection.\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 MultiSelectFieldBinding({\n propertyKey,\n value,\n setValue,\n error,\n showError,\n disabled,\n property,\n includeDescription,\n hideLabel,\n size = \"large\",\n autoFocus\n}: FieldProps<ArrayProperty, unknown, Record<string, unknown>>) {\n\n const of = property.of;\n if (!of) {\n throw Error(\"Using wrong component ArrayEnumSelect\");\n }\n\n if (Array.isArray(of)) {\n throw Error(\"Using array properties instead of single one in `of` in ArrayProperty\");\n }\n\n if (of.type !== \"string\" && of.type !== \"number\") {\n throw Error(\"Field misconfiguration: array field of type string or number\");\n }\n\n const enumValues = of.enum ? enumToObjectEntries(of.enum) : undefined;\n if (!enumValues) {\n console.error(property);\n throw Error(\"Field misconfiguration: array field of type string or number needs to have enumValues\");\n }\n\n const validValue = !!value && Array.isArray(value);\n\n const renderValue = useCallback((enumKey: string, list: boolean) => {\n const enumValue = enumKey !== undefined ? getLabelOrConfigFrom(enumValues, enumKey) : undefined;\n return <EnumValuesChip\n enumKey={enumKey}\n enumValues={enumValues}\n size={\"medium\"}\n key={enumKey}>\n {enumValue?.label ?? enumKey}\n {!list && <button\n className=\"ml-1 rounded-full\"\n onMouseDown={(e) => {\n e.preventDefault();\n e.stopPropagation();\n }}\n onClick={(e) => {\n e.preventDefault();\n e.stopPropagation();\n setValue((value ?? []).filter((v: string | number) => v !== enumKey));\n }}\n >\n <XIcon size={iconSize.smallest}/>\n </button>}\n </EnumValuesChip>;\n }, [enumValues, setValue, value]);\n\n return (\n <>\n <MultiSelect\n // No top margin: `className` lands on the box itself, not on\n // the label above it, so `mt-2` was 8px of gap between the\n // form's label and this control and none between the label and\n // the text field beside it. A binding renders a control, not a\n // labelled control — the top of what it renders is the top of\n // the box, or it will not line up with its neighbour.\n className={\"w-full\"}\n size={size}\n // Same reason as `SelectFieldBinding`: the label is an element,\n // so without this the name is whatever chips happen to be\n // selected — and nothing at all on an empty field.\n aria-label={property.name ?? propertyKey}\n value={validValue ? value.map((v) => v?.toString()) : []}\n disabled={disabled}\n modalPopover={true}\n label={hideLabel ? undefined : <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 onValueChange={(updatedValue: string[]) => {\n let newValue;\n if (of && (of as Property)?.type === \"number\") {\n newValue = updatedValue ? (updatedValue as string[]).map((e) => parseFloat(e)) : [];\n } else {\n newValue = updatedValue;\n }\n return setValue(newValue);\n }}>\n {enumValues.map((enumValue) => String(enumValue.id)).map((enumKey) => (\n <MultiSelectItem key={enumKey} value={enumKey}>\n {renderValue(enumKey, true)}\n </MultiSelectItem>))}\n </MultiSelect>\n\n <FieldHelperText includeDescription={includeDescription}\n showError={showError}\n error={error}\n disabled={disabled}\n property={property}/>\n\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAmBA,SAAgB,wBAAwB,EACpC,aACA,OACA,UACA,OACA,WACA,UACA,UACA,oBACA,WACA,OAAO,SACP,aAC4D;CAE5D,MAAM,KAAK,SAAS;CACpB,IAAI,CAAC,IACD,MAAM,MAAM,uCAAuC;CAGvD,IAAI,MAAM,QAAQ,EAAE,GAChB,MAAM,MAAM,uEAAuE;CAGvF,IAAI,GAAG,SAAS,YAAY,GAAG,S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C,IAAI,CAAC;QAElF,WAAW;GAEf,OAAO,SAAS,QAAQ;EAC5B;YACC,WAAW,KAAK,cAAc,OAAO,UAAU,EAAE,CAAC,CAAC,CAAC,KAAK,YACtD,oBAAC,iBAAD;GAA+B,OAAO;aACjC,YAAY,SAAS,IAAI;EACb,GAFK,OAEL,CAAE;CACd,CAAA,GAEb,oBAAC,iBAAD;EAAqC;EACtB;EACJ;EACG;EACA;CAAU,CAAA,CAE1B,EAAA,CAAA;AAEV"}
|
|
@@ -7,9 +7,9 @@ import { ArrayContainer } from "../../components/ArrayContainer.js";
|
|
|
7
7
|
import { useCallback } from "react";
|
|
8
8
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
import { Button, ExpandablePanel, PencilIcon, Typography, cls, fieldBackgroundMixin } from "@rebasepro/ui";
|
|
10
|
-
import { getRelationFrom, resolveRelationProperty } from "@rebasepro/
|
|
10
|
+
import { getCollectionDataPath, getRelationFrom, resolveRelationProperty } from "@rebasepro/cms-types";
|
|
11
11
|
import { ErrorView, useTranslation } from "@rebasepro/app";
|
|
12
|
-
import {
|
|
12
|
+
import { getDataSourceCapabilities } from "@rebasepro/types";
|
|
13
13
|
//#region src/form/field_bindings/MultipleRelationFieldBinding.tsx
|
|
14
14
|
/**
|
|
15
15
|
* This field allows selecting multiple references.
|
|
@@ -1 +1 @@
|
|
|
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 {
|
|
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/cms-types\";\nimport { 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, getCollectionDataPath, Entity } from \"@rebasepro/cms-types\";\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,MAAM,QAAQ,SAAS,IAAI,YAAY,CAAC;CACtD,MAAM,EAAE,MAAM,eAAe;CAE7B,IAAI,SAAS,SAAS,YAClB,MAAM,MAAM,gEAAgE;CAGhF,MAAM,mBAAmB,QAAQ;CACjC,MAAM,eAAe,mBAAmB,0BAA0B,iBAAiB,MAAM,IAAI,KAAA;CAY7F,IAAI,CAAC,oBAAoB,CAAC,cAAc,mBACpC,MAAM,MAAM,oFAAoF;CAGpG,MAAM,WADmB,wBAAwB,UAAU,kBAAkB,WAC5D;CACjB,IAAI,CAAC,UACD,MAAM,MACF,gEACJ;CAEJ,MAAM,oBAAoB,SAAS,MAAM,QAAQ,KAAK,IAAI,MAAM,KAAK,QAAQ,IAAI,EAAE,IAAI,CAAC;CACxF,MAAM,aAAa,SAAS,OAAO;CAEnC,MAAM,6BAA6B,aAAa,aAAgD;EAC5F,SAAS,SAAS,KAAI,MAAK,gBAAgB,CAAC,CAAC,CAAC;CAClD,GAAG,CAAC,QAAQ,CAAC;CAEb,MAAM,4BAA4B,yBAAyB;EACvD,aA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e;GAC5F,iBAAiB;GACjB,gBAAgB,UAAU,cAAc,aAAa,KAAK;EAC7D,CAAA,GAED,qBAAC,QAAD;GACI,WAAU;GACV,SAAQ;GACR,OAAM;GACN,UAAU,YAAY;GACtB,SAAS;aALb,CAMI,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,CAEI,oBAAC,iBAAD;EACI,gBAAgB;EAChB,gBAAgB,IAAI,0CAA0C,oBAAoB;EAC3E;YACN;CACY,CAAA,GAEjB,oBAAC,iBAAD;EAAqC;EACtB;EACJ;EACG;EACA;CAAU,CAAA,CAE1B,EAAA,CAAA;AAEV"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReadOnlyFieldBinding.js","names":[],"sources":["../../../src/form/field_bindings/ReadOnlyFieldBinding.tsx"],"sourcesContent":["import type { FieldProps } from \"../../types/fields\";\nimport type { Property } from \"@rebasepro/types\";\nimport React from \"react\";\n\nimport { PropertyPreview } from \"../../preview\";\nimport { FieldHelperText } from \"../components/FieldHelperText\";\nimport { LabelWithIcon } from \"../components/LabelWithIcon\";\nimport { cls, ErrorBoundary, InputLabel } from \"@rebasepro/ui\";\nimport { getIconForProperty } from \"../../util/property_utils\";\nimport { readOnlyLabelsInside } from \"../label_placement\";\n\n/**\n *\n * Simply render the non-editable preview of a field\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 ReadOnlyFieldBinding({\n propertyKey,\n value,\n error,\n showError,\n minimalistView,\n property,\n includeDescription,\n hideLabel,\n context,\n size = \"large\"\n}: FieldProps<Property>) {\n\n // if (!context.id)\n // throw new Error(\"ReadOnlyFieldBinding: Entity id is null\");\n\n const skipCardWrapper = property.type === \"relation\" || property.type === \"reference\";\n\n // No required marker on either label: the asterisk asks the person filling\n // the form for a value, and nobody fills this one in. `validation.required`\n // on a read-only field is about the column (NOT NULL), not about them.\n\n // A one-line value at the form's size is drawn like the one-line fields\n // around it: the same 64px box, the label shrunk into its top edge. It keeps\n // the outline and drops the fill — that is what says it cannot be edited.\n if (!minimalistView && !hideLabel && size === \"large\" && readOnlyLabelsInside(property)) {\n return (\n <>\n <div className={\"relative w-full min-h-[66px] rounded-lg border border-hairline-strong px-3 pt-8 pb-2 text-base\"}>\n {/* `left-0` is the box's padding edge, where a text field's\n label starts; left to its static position it would\n start after the `px-3`, 12px too far in. */}\n <InputLabel shrink\n className={\"pointer-events-none absolute top-1 left-0 text-text-secondary dark:text-text-secondary-dark\"}>\n <LabelWithIcon\n icon={getIconForProperty(property, \"small\")}\n title={property.name ?? propertyKey}/>\n </InputLabel>\n <div className={\"min-h-6 flex items-center overflow-x-auto no-scrollbar opacity-80\"}>\n <ErrorBoundary>\n <PropertyPreview propertyKey={propertyKey}\n value={value}\n property={property}\n hideLabel\n size={\"medium\"}/>\n </ErrorBoundary>\n </div>\n </div>\n\n <FieldHelperText includeDescription={includeDescription}\n showError={showError}\n error={error}\n property={property}/>\n </>\n );\n }\n\n return (\n\n <>\n\n {!minimalistView && !hideLabel && <LabelWithIcon\n propertyKey={propertyKey}\n icon={getIconForProperty(property, \"small\")}\n title={property.name ?? propertyKey}\n className={\"h-8 text-text-secondary dark:text-text-secondary-dark ml-3\"}/>\n }\n\n <div\n className={cls(\n \"w-full overflow-x-scroll no-scrollbar flex items-center\",\n skipCardWrapper\n ? \"\"\n // `px-3` is what `TextField` gives its input, so a\n // read-only value starts on the same vertical line as\n // the text beside it. It was `px-4 md:px-6`, which in a\n // one-column span spent a sixth of the box on empty\n // margin and pushed short values towards the middle.\n : cls(\"rounded-lg border border-hairline-strong px-3 text-sm opacity-80\", {\n // The height an editable field of the form's `size`\n // renders at — the kit's control height plus its 1px\n // hairline on each side — so a row holding one of\n // each has its baselines and bottom edges agree. This\n // was a fixed `min-h-12` (48px) with the page's 16px\n // text: 2px short of a `large` text field, 14px taller\n // than a `small` one, and a size above every input's\n // `text-sm` at either.\n \"min-h-[34px]\": size === \"small\",\n \"min-h-[42px]\": size === \"medium\",\n \"min-h-[50px]\": size === \"large\"\n })\n )}>\n\n <ErrorBoundary>\n {/* The field is labelled either just above by this\n component, or by the `FieldBlock` that asked for\n `hideLabel` — never by the preview. `BooleanPreview`\n prints the property name beside its checkbox, so a\n read-only boolean read as \"Procesado por LLM\" over a\n checkbox saying \"Procesado por LLM\", wrapped over two\n lines in a one-column span. */}\n <PropertyPreview propertyKey={propertyKey}\n value={value}\n property={property}\n hideLabel={hideLabel || !minimalistView}\n size={\"medium\"}/>\n </ErrorBoundary>\n\n </div>\n\n <FieldHelperText includeDescription={includeDescription}\n showError={showError}\n error={error}\n property={property}/>\n\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAmBA,SAAgB,qBAAqB,EACjC,aACA,OACA,OACA,WACA,gBACA,UACA,oBACA,WACA,SACA,OAAO,WACc;CAKrB,MAAM,kBAAkB,SAAS,SAAS,cAAc,SAAS,SAAS;CAS1E,IAAI,CAAC,kBAAkB,CAAC,aAAa,SAAS,WAAW,qBAAqB,QAAQ,GAClF,OACI,qBAAA,UAAA,EAAA,UAAA,CACI,qBAAC,OAAD;EAAK,WAAW;YAAhB,CAII,oBAAC,YAAD;GAAY,QAAA;GACR,WAAW;aACX,oBAAC,eAAD;IACI,MAAM,mBAAmB,UAAU,OAAO;IAC1C,OAAO,SAAS,QAAQ;GAAa,CAAA;EACjC,CAAA,GACZ,oBAAC,OAAD;GAAK,WAAW;aACZ,oBAAC,eAAD,EAAA,UACI,oBAAC,iBAAD;IAA8B;IACnB;IACG;IACV,WAAA;IACA,MAAM;GAAU,CAAA,EACT,CAAA;EACd,CAAA,CACJ;KAEL,oBAAC,iBAAD;EAAqC;EACtB;EACJ;EACG;CAAU,CAAA,CAC1B,EAAA,CAAA;CAIV,OAEI,qBAAA,UAAA,EAAA,UAAA;EAEK,CAAC,kBAAkB,CAAC,aAAa,oBAAC,eAAD;GACjB;GACb,MAAM,mBAAmB,UAAU,OAAO;GAC1C,OAAO,SAAS,QAAQ;GACxB,WAAW;EAA8D,CAAA;EAG7E,oBAAC,OAAD;GACI,WAAW,IACP,2DACA,kBACM,KAMA,IAAI,oEAAoE;IAStE,gBAAgB,SAAS;IACzB,gBAAgB,SAAS;IACzB,gBAAgB,SAAS;GAC7B,CAAC,CACT;aAEA,oBAAC,eAAD,EAAA,UAQI,oBAAC,iBAAD;IAA8B;IACnB;IACG;IACV,WAAW,aAAa,CAAC;IACzB,MAAM;GAAU,CAAA,EACT,CAAA;EAEd,CAAA;EAEL,oBAAC,iBAAD;GAAqC;GACtB;GACJ;GACG;EAAU,CAAA;CAE1B,EAAA,CAAA;AAEV"}
|
|
1
|
+
{"version":3,"file":"ReadOnlyFieldBinding.js","names":[],"sources":["../../../src/form/field_bindings/ReadOnlyFieldBinding.tsx"],"sourcesContent":["import type { FieldProps } from \"../../types/fields\";\nimport type { Property } from \"@rebasepro/cms-types\";\nimport React from \"react\";\n\nimport { PropertyPreview } from \"../../preview\";\nimport { FieldHelperText } from \"../components/FieldHelperText\";\nimport { LabelWithIcon } from \"../components/LabelWithIcon\";\nimport { cls, ErrorBoundary, InputLabel } from \"@rebasepro/ui\";\nimport { getIconForProperty } from \"../../util/property_utils\";\nimport { readOnlyLabelsInside } from \"../label_placement\";\n\n/**\n *\n * Simply render the non-editable preview of a field\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 ReadOnlyFieldBinding({\n propertyKey,\n value,\n error,\n showError,\n minimalistView,\n property,\n includeDescription,\n hideLabel,\n context,\n size = \"large\"\n}: FieldProps<Property>) {\n\n // if (!context.id)\n // throw new Error(\"ReadOnlyFieldBinding: Entity id is null\");\n\n const skipCardWrapper = property.type === \"relation\" || property.type === \"reference\";\n\n // No required marker on either label: the asterisk asks the person filling\n // the form for a value, and nobody fills this one in. `validation.required`\n // on a read-only field is about the column (NOT NULL), not about them.\n\n // A one-line value at the form's size is drawn like the one-line fields\n // around it: the same 64px box, the label shrunk into its top edge. It keeps\n // the outline and drops the fill — that is what says it cannot be edited.\n if (!minimalistView && !hideLabel && size === \"large\" && readOnlyLabelsInside(property)) {\n return (\n <>\n <div className={\"relative w-full min-h-[66px] rounded-lg border border-hairline-strong px-3 pt-8 pb-2 text-base\"}>\n {/* `left-0` is the box's padding edge, where a text field's\n label starts; left to its static position it would\n start after the `px-3`, 12px too far in. */}\n <InputLabel shrink\n className={\"pointer-events-none absolute top-1 left-0 text-text-secondary dark:text-text-secondary-dark\"}>\n <LabelWithIcon\n icon={getIconForProperty(property, \"small\")}\n title={property.name ?? propertyKey}/>\n </InputLabel>\n <div className={\"min-h-6 flex items-center overflow-x-auto no-scrollbar opacity-80\"}>\n <ErrorBoundary>\n <PropertyPreview propertyKey={propertyKey}\n value={value}\n property={property}\n hideLabel\n size={\"medium\"}/>\n </ErrorBoundary>\n </div>\n </div>\n\n <FieldHelperText includeDescription={includeDescription}\n showError={showError}\n error={error}\n property={property}/>\n </>\n );\n }\n\n return (\n\n <>\n\n {!minimalistView && !hideLabel && <LabelWithIcon\n propertyKey={propertyKey}\n icon={getIconForProperty(property, \"small\")}\n title={property.name ?? propertyKey}\n className={\"h-8 text-text-secondary dark:text-text-secondary-dark ml-3\"}/>\n }\n\n <div\n className={cls(\n \"w-full overflow-x-scroll no-scrollbar flex items-center\",\n skipCardWrapper\n ? \"\"\n // `px-3` is what `TextField` gives its input, so a\n // read-only value starts on the same vertical line as\n // the text beside it. It was `px-4 md:px-6`, which in a\n // one-column span spent a sixth of the box on empty\n // margin and pushed short values towards the middle.\n : cls(\"rounded-lg border border-hairline-strong px-3 text-sm opacity-80\", {\n // The height an editable field of the form's `size`\n // renders at — the kit's control height plus its 1px\n // hairline on each side — so a row holding one of\n // each has its baselines and bottom edges agree. This\n // was a fixed `min-h-12` (48px) with the page's 16px\n // text: 2px short of a `large` text field, 14px taller\n // than a `small` one, and a size above every input's\n // `text-sm` at either.\n \"min-h-[34px]\": size === \"small\",\n \"min-h-[42px]\": size === \"medium\",\n \"min-h-[50px]\": size === \"large\"\n })\n )}>\n\n <ErrorBoundary>\n {/* The field is labelled either just above by this\n component, or by the `FieldBlock` that asked for\n `hideLabel` — never by the preview. `BooleanPreview`\n prints the property name beside its checkbox, so a\n read-only boolean read as \"Procesado por LLM\" over a\n checkbox saying \"Procesado por LLM\", wrapped over two\n lines in a one-column span. */}\n <PropertyPreview propertyKey={propertyKey}\n value={value}\n property={property}\n hideLabel={hideLabel || !minimalistView}\n size={\"medium\"}/>\n </ErrorBoundary>\n\n </div>\n\n <FieldHelperText includeDescription={includeDescription}\n showError={showError}\n error={error}\n property={property}/>\n\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAmBA,SAAgB,qBAAqB,EACjC,aACA,OACA,OACA,WACA,gBACA,UACA,oBACA,WACA,SACA,OAAO,WACc;CAKrB,MAAM,kBAAkB,SAAS,SAAS,cAAc,SAAS,SAAS;CAS1E,IAAI,CAAC,kBAAkB,CAAC,aAAa,SAAS,WAAW,qBAAqB,QAAQ,GAClF,OACI,qBAAA,UAAA,EAAA,UAAA,CACI,qBAAC,OAAD;EAAK,WAAW;YAAhB,CAII,oBAAC,YAAD;GAAY,QAAA;GACR,WAAW;aACX,oBAAC,eAAD;IACI,MAAM,mBAAmB,UAAU,OAAO;IAC1C,OAAO,SAAS,QAAQ;GAAa,CAAA;EACjC,CAAA,GACZ,oBAAC,OAAD;GAAK,WAAW;aACZ,oBAAC,eAAD,EAAA,UACI,oBAAC,iBAAD;IAA8B;IACnB;IACG;IACV,WAAA;IACA,MAAM;GAAU,CAAA,EACT,CAAA;EACd,CAAA,CACJ;KAEL,oBAAC,iBAAD;EAAqC;EACtB;EACJ;EACG;CAAU,CAAA,CAC1B,EAAA,CAAA;CAIV,OAEI,qBAAA,UAAA,EAAA,UAAA;EAEK,CAAC,kBAAkB,CAAC,aAAa,oBAAC,eAAD;GACjB;GACb,MAAM,mBAAmB,UAAU,OAAO;GAC1C,OAAO,SAAS,QAAQ;GACxB,WAAW;EAA8D,CAAA;EAG7E,oBAAC,OAAD;GACI,WAAW,IACP,2DACA,kBACM,KAMA,IAAI,oEAAoE;IAStE,gBAAgB,SAAS;IACzB,gBAAgB,SAAS;IACzB,gBAAgB,SAAS;GAC7B,CAAC,CACT;aAEA,oBAAC,eAAD,EAAA,UAQI,oBAAC,iBAAD;IAA8B;IACnB;IACG;IACV,WAAW,aAAa,CAAC;IACzB,MAAM;GAAU,CAAA,EACT,CAAA;EAEd,CAAA;EAEL,oBAAC,iBAAD;GAAqC;GACtB;GACJ;GACG;EAAU,CAAA;CAE1B,EAAA,CAAA;AAEV"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { FieldProps } from "../../types/fields.js";
|
|
2
|
-
import type { ReferenceProperty } from "@rebasepro/types";
|
|
3
2
|
import React from "react";
|
|
3
|
+
import type { ReferenceProperty } from "@rebasepro/cms-types";
|
|
4
4
|
/**
|
|
5
5
|
* Field that opens a reference selection dialog.
|
|
6
6
|
*
|
|
@@ -29,8 +29,8 @@ function ReferenceFieldBindingInternal({ propertyKey, value, setValue, error, sh
|
|
|
29
29
|
const refValue = value;
|
|
30
30
|
const validValue = refValue && typeof refValue === "object" && "isEntityReference" in refValue && refValue.isEntityReference();
|
|
31
31
|
const collectionRegistryController = useCollectionRegistryController();
|
|
32
|
-
const {
|
|
33
|
-
const collectionPath =
|
|
32
|
+
const { targetPath, referenceTo } = useReferencePaths();
|
|
33
|
+
const collectionPath = targetPath(property.path);
|
|
34
34
|
const collection = useMemo(() => {
|
|
35
35
|
return collectionRegistryController.getCollection(collectionPath);
|
|
36
36
|
}, [collectionPath]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReferenceFieldBinding.js","names":[],"sources":["../../../src/form/field_bindings/ReferenceFieldBinding.tsx"],"sourcesContent":["import { useEntitySelectionDialog } from \"../../hooks/useSelectionDialog\";\n\nimport type { FieldProps } from \"../../types/fields\";\nimport
|
|
1
|
+
{"version":3,"file":"ReferenceFieldBinding.js","names":[],"sources":["../../../src/form/field_bindings/ReferenceFieldBinding.tsx"],"sourcesContent":["import { useEntitySelectionDialog } from \"../../hooks/useSelectionDialog\";\n\nimport type { FieldProps } from \"../../types/fields\";\nimport React, { useCallback, useMemo } from \"react\";\n\nimport { EntityReference, Entity } from \"@rebasepro/cms-types\";\nimport { ErrorView } from \"@rebasepro/app\";\nimport { ReadOnlyFieldBinding } from \"./ReadOnlyFieldBinding\";\nimport { FieldHelperText } from \"../components/FieldHelperText\";\nimport { LabelWithIcon } from \"../components/LabelWithIcon\";\nimport { EntityPreviewContainer } from \"../../components/EntityPreviewBinding\";\nimport { ReferencePreview } from \"../../preview\";\nimport { IconForView, useTranslation } from \"@rebasepro/app\";\nimport { getIconForProperty } from \"../../util/property_utils\";\nimport { cls } from \"@rebasepro/ui\";\nimport { useCollectionRegistryController } from \"../../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { useReferencePaths } from \"../../hooks/useReferencePaths\";\nimport type { AdminCollection, Property, ReferenceProperty } from \"@rebasepro/cms-types\";\n\n/**\n * Field that opens a reference selection dialog.\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 ReferenceFieldBinding(props: FieldProps<ReferenceProperty>) {\n\n if (typeof props.property.path !== \"string\") {\n return <ReadOnlyFieldBinding {...props as FieldProps<Property>}/>\n }\n\n return <ReferenceFieldBindingInternal {...props}/>;\n\n}\n\nfunction ReferenceFieldBindingInternal({\n propertyKey,\n value,\n setValue,\n error,\n showError,\n isSubmitting,\n disabled,\n minimalistView,\n touched,\n autoFocus,\n property,\n includeDescription,\n hideLabel,\n size = \"medium\"\n}: FieldProps<ReferenceProperty>) {\n if (!property.path) {\n throw new Error(\"Property path is required for ReferenceFieldBinding\");\n }\n\n const { t } = useTranslation();\n const refValue = value as EntityReference | null | undefined;\n\n const validValue = refValue && typeof refValue === \"object\" && \"isEntityReference\" in refValue && refValue.isEntityReference();\n\n const collectionRegistryController = useCollectionRegistryController();\n const { targetPath, referenceTo } = useReferencePaths();\n const collectionPath = targetPath(property.path);\n const collection: AdminCollection | undefined = useMemo(() => {\n return collectionRegistryController.getCollection(collectionPath);\n }, [collectionPath]);\n\n if (!collection) {\n throw Error(`Couldn't find the corresponding collection for the path: ${property.path}`);\n }\n\n const onSingleEntitySelected = useCallback((e: Entity<Record<string, unknown>> | null) => {\n const ref = e ? referenceTo(e) : null;\n setValue(ref);\n }, [setValue, propertyKey, referenceTo]);\n\n const referenceDialogController = useEntitySelectionDialog({\n multiselect: false,\n path: collectionPath,\n collection,\n onSingleEntitySelected,\n selectedEntityIds: validValue && refValue ? [refValue.id] : undefined,\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 return (\n <>\n {!minimalistView && !hideLabel && <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\n {!collection && <ErrorView\n error={\"The specified collection does not exist. Check console\"}/>}\n\n {collection && <>\n\n {refValue && <ReferencePreview\n disabled={!property.path}\n previewProperties={property.admin?.previewProperties}\n hover={!disabled}\n size={size}\n onClick={disabled || isSubmitting ? undefined : onEntryClick}\n reference={refValue}\n includeEntityLink={property.admin?.includeEntityLink}\n includeId={property.admin?.includeId}\n />}\n\n {!refValue && <div className=\"justify-center text-left\">\n <EntityPreviewContainer className={cls(\"px-6 h-12 text-sm font-medium flex items-center gap-6\",\n disabled || isSubmitting\n ? \"text-surface-accent-500\"\n : \"cursor-pointer text-surface-accent-700 dark:text-surface-accent-300 hover:bg-surface-hover group-hover:bg-surface-hover\")}\n onClick={disabled || isSubmitting ? undefined : onEntryClick}\n size={\"medium\"}>\n <IconForView collectionOrView={collection}\n className={\"text-surface-300 dark:text-surface-600\"}/>\n {t(\"edit_name\", { name: property.name ?? propertyKey }).toUpperCase()}\n </EntityPreviewContainer>\n </div>}\n </>}\n\n <FieldHelperText includeDescription={includeDescription}\n showError={showError}\n error={error}\n disabled={disabled}\n property={property}/>\n\n </>\n );\n\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA0BA,SAAgB,sBAAsB,OAAsC;CAExE,IAAI,OAAO,MAAM,SAAS,SAAS,UAC/B,OAAO,oBAAC,sBAAD,EAAsB,GAAI,MAA+B,CAAA;CAGpE,OAAO,oBAAC,+BAAD,EAA+B,GAAI,MAAO,CAAA;AAErD;AAEA,SAAS,8BAA8B,EACnC,aACA,OACA,UACA,OACA,WACA,cACA,UACA,gBACA,SACA,WACA,UACA,oBACA,WACA,OAAO,YACuB;CAC9B,IAAI,CAAC,SAAS,MACV,MAAM,IAAI,MAAM,qDAAqD;CAGzE,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,WAAW;CAEjB,MAAM,aAAa,YAAY,OAAO,aAAa,YAAY,uBAAuB,YAAY,SAAS,kBAAkB;CAE7H,MAAM,+BAA+B,gCAAgC;CACrE,MAAM,EAAE,YAAY,gBAAgB,kBAAkB;CACtD,MAAM,iBAAiB,WAAW,SAAS,IAAI;CAC/C,MAAM,aAA0C,cAAc;EAC1D,OAAO,6BAA6B,cAAc,cAAc;CACpE,GAAG,CAAC,cAAc,CAAC;CAEnB,IAAI,CAAC,YACD,MAAM,MAAM,4DAA4D,SAAS,MAAM;CAQ3F,MAAM,4BAA4B,yBAAyB;EACvD,aAAa;EACb,MAAM;EACN;EACA,wBAT2B,aAAa,MAA8C;GAEtF,SADY,IAAI,YAAY,CAAC,IAAI,IACrB;EAChB,GAAG;GAAC;GAAU;GAAa;EAAW,CAMlC;EACA,mBAAmB,cAAc,WAAW,CAAC,SAAS,EAAE,IAAI,KAAA;EAC5D,aAAa,SAAS,OAAO;CACjC,CACA;CAEA,MAAM,gBAAgB,MAA4B;EAC9C,EAAE,eAAe;EACjB,IAAI,YAAY,cAAc;EAC9B,0BAA0B,KAAK;CACnC;CAEA,OACI,qBAAA,UAAA,EAAA,UAAA;EACK,CAAC,kBAAkB,CAAC,aAAa,oBAAC,eAAD;GACjB;GACb,MAAM,mBAAmB,UAAU,OAAO;GAC1C,UAAU,SAAS,YAAY;GAC/B,OAAO,SAAS,QAAQ;GACxB,WAAW;EAAgE,CAAA;EAE9E,CAAC,cAAc,oBAAC,WAAD,EACZ,OAAO,yDAA0D,CAAA;EAEpE,cAAc,qBAAA,UAAA,EAAA,UAAA,CAEV,YAAY,oBAAC,kBAAD;GACT,UAAU,CAAC,SAAS;GACpB,mBAAmB,SAAS,OAAO;GACnC,OAAO,CAAC;GACF;GACN,SAAS,YAAY,eAAe,KAAA,IAAY;GAChD,WAAW;GACX,mBAAmB,SAAS,OAAO;GACnC,WAAW,SAAS,OAAO;EAC9B,CAAA,GAEA,CAAC,YAAY,oBAAC,OAAD;GAAK,WAAU;aACzB,qBAAC,wBAAD;IAAwB,WAAW,IAAI,yDACnC,YAAY,eACN,4BACA,yHAAyH;IAC/H,SAAS,YAAY,eAAe,KAAA,IAAY;IAChD,MAAM;cALV,CAMI,oBAAC,aAAD;KAAa,kBAAkB;KAC3B,WAAW;IAA0C,CAAA,GACxD,EAAE,aAAa,EAAE,MAAM,SAAS,QAAQ,YAAY,CAAC,CAAC,CAAC,YAAY,CAChD;;EACvB,CAAA,CACP,EAAA,CAAA;EAEF,oBAAC,iBAAD;GAAqC;GACtB;GACJ;GACG;GACA;EAAU,CAAA;CAE1B,EAAA,CAAA;AAGV"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { FieldProps } from "../../types/fields.js";
|
|
2
|
-
import type { RelationProperty } from "@rebasepro/types";
|
|
2
|
+
import type { RelationProperty } from "@rebasepro/cms-types";
|
|
3
3
|
import React from "react";
|
|
4
4
|
export declare function RelationFieldBinding(props: FieldProps<RelationProperty>): React.JSX.Element;
|
|
@@ -9,9 +9,9 @@ import { MultipleRelationFieldBinding } from "./MultipleRelationFieldBinding.js"
|
|
|
9
9
|
import { useCallback } from "react";
|
|
10
10
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
11
11
|
import { cls } from "@rebasepro/ui";
|
|
12
|
-
import { getRelationFrom, normalizeToEntityRelation, resolveRelationProperty } from "@rebasepro/
|
|
12
|
+
import { getCollectionDataPath, getRelationFrom, normalizeToEntityRelation, resolveRelationProperty } from "@rebasepro/cms-types";
|
|
13
13
|
import { ErrorView, IconForView, useTranslation } from "@rebasepro/app";
|
|
14
|
-
import {
|
|
14
|
+
import { getDataSourceCapabilities } from "@rebasepro/types";
|
|
15
15
|
//#region src/form/field_bindings/RelationFieldBinding.tsx
|
|
16
16
|
function RelationFieldBinding(props) {
|
|
17
17
|
const { property, propertyKey, context } = props;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RelationFieldBinding.js","names":[],"sources":["../../../src/form/field_bindings/RelationFieldBinding.tsx"],"sourcesContent":["import { useEntitySelectionDialog } from \"../../hooks/useSelectionDialog\";\nimport type { FieldProps } from \"../../types/fields\";\nimport type { RelationProperty } from \"@rebasepro/types\";\nimport { Entity, getCollectionDataPath, getDataSourceCapabilities, Relation } from \"@rebasepro/types\";\nimport React, { useCallback } from \"react\";\nimport { FieldHelperText } from \"../components/FieldHelperText\";\nimport { LabelWithIcon } from \"../components/LabelWithIcon\";\nimport { EntityPreviewContainer } from \"../../components/EntityPreviewBinding\";\nimport { ErrorView, IconForView, useTranslation } from \"@rebasepro/app\";\nimport { getIconForProperty } from \"../../util/property_utils\";\nimport { getRelationFrom, normalizeToEntityRelation, resolveRelationProperty } from \"@rebasepro/common\";\nimport { cls } from \"@rebasepro/ui\";\nimport { RelationPreview } from \"../../preview\";\nimport { RelationSelector } from \"../../components/RelationSelector\";\nimport { MultipleRelationFieldBinding } from \"./MultipleRelationFieldBinding\";\n\nexport function RelationFieldBinding(props: FieldProps<RelationProperty>) {\n const { property, propertyKey, context } = props;\n\n if (property.type !== \"relation\") {\n throw Error(\"RelationFieldBinding expected a property containing a relation\");\n }\n const collection = context.collection;\n const capabilities = collection ? getDataSourceCapabilities(collection.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 (!collection || !capabilities?.supportsRelations) {\n throw Error(\"RelationFieldBinding expected a collection whose engine supports relations\");\n }\n const resolvedProperty = resolveRelationProperty(property, collection, propertyKey);\n const relation = resolvedProperty;\n\n // A multi-hop `via` is read-only (`writable: false`): the server refuses a\n // write naming one (RELATION_NOT_WRITABLE), so its picker could only lead\n // to a failed save. Shown, not offered. A single-hop `via` is writable.\n const fieldProps = relation && !relation.writable ? { ...props, disabled: true } : props;\n\n const manyRelation = relation?.cardinality === \"many\";\n const widget = property.admin?.widget ?? \"select\";\n\n if (widget === \"select\" && relation) {\n return <RelationSelectorBinding {...fieldProps} relation={relation} manyRelation={manyRelation} />;\n }\n\n if (manyRelation) {\n return <MultipleRelationFieldBinding {...fieldProps} />;\n }\n\n return <SingleRelationFieldBinding {...fieldProps} relation={relation} />;\n}\n\nfunction RelationSelectorBinding({\n propertyKey,\n value,\n size,\n error,\n showError,\n disabled,\n isSubmitting,\n property,\n includeDescription,\n hideLabel,\n setValue,\n relation,\n manyRelation\n}: FieldProps<RelationProperty> & { relation: Relation; manyRelation: boolean }) {\n const normalizedSingle = (!manyRelation && value && !Array.isArray(value)) ? normalizeToEntityRelation(value) : null;\n const singleValue = normalizedSingle ?? null;\n const multipleValue = (manyRelation && Array.isArray(value)) ? value : [];\n\n // Passed straight through. Mapping the form's `large` onto the selector's\n // `medium` produced a 56px box next to 48px text fields — the labels lined\n // up and the boxes did not.\n const selectorSize = size;\n\n return (\n <div className=\"\">\n {!hideLabel && <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\n <RelationSelector\n relation={relation}\n value={manyRelation ? multipleValue : singleValue}\n onValueChange={(newVal) => {\n if (manyRelation) {\n setValue(Array.isArray(newVal) ? newVal : []);\n } else {\n setValue(!Array.isArray(newVal) ? (newVal ?? null) : null);\n }\n }}\n disabled={disabled || isSubmitting}\n fixedFilter={property.admin?.fixedFilter}\n size={selectorSize}\n />\n\n <FieldHelperText includeDescription={includeDescription}\n showError={showError}\n error={error}\n disabled={disabled}\n property={property}/>\n </div>\n );\n}\n\nfunction SingleRelationFieldBinding({\n propertyKey,\n value,\n size,\n error,\n showError,\n disabled,\n isSubmitting,\n property,\n includeDescription,\n hideLabel,\n setValue,\n relation\n}: FieldProps<RelationProperty> & { relation: Relation | undefined }) {\n const { t } = useTranslation();\n const normalizedValue = value && !Array.isArray(value) ? normalizeToEntityRelation(value) : null;\n const validValue = !!normalizedValue;\n\n const collection = relation?.target();\n\n if (!collection) {\n throw Error(`Couldn't find the corresponding collection for the relation: ${propertyKey}`);\n }\n\n const onSingleEntitySelected = useCallback((e: Entity<Record<string, unknown>> | null) => {\n setValue(e ? getRelationFrom(e) : null);\n }, [setValue]);\n\n const referenceDialogController = useEntitySelectionDialog({\n multiselect: false,\n path: getCollectionDataPath(collection),\n collection,\n onSingleEntitySelected,\n selectedEntityIds: validValue && normalizedValue ? [normalizedValue.id] : undefined,\n fixedFilter: property.admin?.fixedFilter\n });\n\n const onEntryClick = (e: React.SyntheticEvent) => {\n e.preventDefault();\n if (disabled || isSubmitting) return;\n referenceDialogController.open();\n };\n\n const usedRelation = Array.isArray(value) ? undefined : normalizedValue ?? undefined;\n\n return (\n <>\n {!hideLabel && <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\n {!collection && <ErrorView\n error={\"The specified collection does not exist. Check console\"}/>}\n\n {collection && <>\n\n {usedRelation && <RelationPreview\n disabled={!usedRelation}\n previewProperties={property.admin?.previewProperties}\n hover={!disabled}\n size={size}\n onClick={disabled || isSubmitting ? undefined : onEntryClick}\n relation={usedRelation}\n includeEntityLink={property.admin?.includeEntityLink}\n includeId={property.admin?.includeId}\n />}\n\n {!value && <div className=\"justify-center text-left\">\n <EntityPreviewContainer className={cls(\"px-6 h-12 text-sm font-medium flex items-center gap-6\",\n disabled || isSubmitting\n ? \"text-surface-accent-500\"\n : \"cursor-pointer text-surface-accent-700 dark:text-surface-accent-300 hover:bg-surface-hover group-hover:bg-surface-hover\")}\n onClick={disabled || isSubmitting ? undefined : onEntryClick}\n size={\"medium\"}>\n <IconForView collectionOrView={collection}\n className={\"text-surface-300 dark:text-surface-600\"}/>\n {t(\"edit_name\", { name: property.name ?? propertyKey }).toUpperCase()}\n </EntityPreviewContainer>\n </div>}\n </>}\n\n <FieldHelperText includeDescription={includeDescription}\n showError={showError}\n error={error}\n disabled={disabled}\n property={property}/>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAgBA,SAAgB,qBAAqB,OAAqC;CACtE,MAAM,EAAE,UAAU,aAAa,YAAY;CAE3C,IAAI,SAAS,SAAS,YAClB,MAAM,MAAM,gEAAgE;CAEhF,MAAM,aAAa,QAAQ;CAC3B,MAAM,eAAe,aAAa,0BAA0B,WAAW,MAAM,IAAI,KAAA;CAYjF,IAAI,CAAC,cAAc,CAAC,cAAc,mBAC9B,MAAM,MAAM,4EAA4E;CAG5F,MAAM,WADmB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AAD;GAAK,WAAU;aACtB,qBAAC,wBAAD;IAAwB,WAAW,IAAI,yDACnC,YAAY,eACN,4BACA,yHAAyH;IAC/H,SAAS,YAAY,eAAe,KAAA,IAAY;IAChD,MAAM;cALV,CAMI,oBAAC,aAAD;KAAa,kBAAkB;KAC3B,WAAW;IAA0C,CAAA,GACxD,EAAE,aAAa,EAAE,MAAM,SAAS,QAAQ,YAAY,CAAC,CAAC,CAAC,YAAY,CAChD;;EACvB,CAAA,CACP,EAAA,CAAA;EAEF,oBAAC,iBAAD;GAAqC;GACtB;GACJ;GACG;GACA;EAAU,CAAA;CAC1B,EAAA,CAAA;AAEV"}
|
|
1
|
+
{"version":3,"file":"RelationFieldBinding.js","names":[],"sources":["../../../src/form/field_bindings/RelationFieldBinding.tsx"],"sourcesContent":["import { useEntitySelectionDialog } from \"../../hooks/useSelectionDialog\";\nimport type { FieldProps } from \"../../types/fields\";\nimport type { RelationProperty } from \"@rebasepro/cms-types\";\nimport { getDataSourceCapabilities } from \"@rebasepro/types\";\nimport React, { useCallback } from \"react\";\nimport { FieldHelperText } from \"../components/FieldHelperText\";\nimport { LabelWithIcon } from \"../components/LabelWithIcon\";\nimport { EntityPreviewContainer } from \"../../components/EntityPreviewBinding\";\nimport { ErrorView, IconForView, useTranslation } from \"@rebasepro/app\";\nimport { getIconForProperty } from \"../../util/property_utils\";\nimport { getRelationFrom, resolveRelationProperty, getCollectionDataPath, Relation, normalizeToEntityRelation, Entity } from \"@rebasepro/cms-types\";\nimport { cls } from \"@rebasepro/ui\";\nimport { RelationPreview } from \"../../preview\";\nimport { RelationSelector } from \"../../components/RelationSelector\";\nimport { MultipleRelationFieldBinding } from \"./MultipleRelationFieldBinding\";\n\nexport function RelationFieldBinding(props: FieldProps<RelationProperty>) {\n const { property, propertyKey, context } = props;\n\n if (property.type !== \"relation\") {\n throw Error(\"RelationFieldBinding expected a property containing a relation\");\n }\n const collection = context.collection;\n const capabilities = collection ? getDataSourceCapabilities(collection.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 (!collection || !capabilities?.supportsRelations) {\n throw Error(\"RelationFieldBinding expected a collection whose engine supports relations\");\n }\n const resolvedProperty = resolveRelationProperty(property, collection, propertyKey);\n const relation = resolvedProperty;\n\n // A multi-hop `via` is read-only (`writable: false`): the server refuses a\n // write naming one (RELATION_NOT_WRITABLE), so its picker could only lead\n // to a failed save. Shown, not offered. A single-hop `via` is writable.\n const fieldProps = relation && !relation.writable ? { ...props, disabled: true } : props;\n\n const manyRelation = relation?.cardinality === \"many\";\n const widget = property.admin?.widget ?? \"select\";\n\n if (widget === \"select\" && relation) {\n return <RelationSelectorBinding {...fieldProps} relation={relation} manyRelation={manyRelation} />;\n }\n\n if (manyRelation) {\n return <MultipleRelationFieldBinding {...fieldProps} />;\n }\n\n return <SingleRelationFieldBinding {...fieldProps} relation={relation} />;\n}\n\nfunction RelationSelectorBinding({\n propertyKey,\n value,\n size,\n error,\n showError,\n disabled,\n isSubmitting,\n property,\n includeDescription,\n hideLabel,\n setValue,\n relation,\n manyRelation\n}: FieldProps<RelationProperty> & { relation: Relation; manyRelation: boolean }) {\n const normalizedSingle = (!manyRelation && value && !Array.isArray(value)) ? normalizeToEntityRelation(value) : null;\n const singleValue = normalizedSingle ?? null;\n const multipleValue = (manyRelation && Array.isArray(value)) ? value : [];\n\n // Passed straight through. Mapping the form's `large` onto the selector's\n // `medium` produced a 56px box next to 48px text fields — the labels lined\n // up and the boxes did not.\n const selectorSize = size;\n\n return (\n <div className=\"\">\n {!hideLabel && <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\n <RelationSelector\n relation={relation}\n value={manyRelation ? multipleValue : singleValue}\n onValueChange={(newVal) => {\n if (manyRelation) {\n setValue(Array.isArray(newVal) ? newVal : []);\n } else {\n setValue(!Array.isArray(newVal) ? (newVal ?? null) : null);\n }\n }}\n disabled={disabled || isSubmitting}\n fixedFilter={property.admin?.fixedFilter}\n size={selectorSize}\n />\n\n <FieldHelperText includeDescription={includeDescription}\n showError={showError}\n error={error}\n disabled={disabled}\n property={property}/>\n </div>\n );\n}\n\nfunction SingleRelationFieldBinding({\n propertyKey,\n value,\n size,\n error,\n showError,\n disabled,\n isSubmitting,\n property,\n includeDescription,\n hideLabel,\n setValue,\n relation\n}: FieldProps<RelationProperty> & { relation: Relation | undefined }) {\n const { t } = useTranslation();\n const normalizedValue = value && !Array.isArray(value) ? normalizeToEntityRelation(value) : null;\n const validValue = !!normalizedValue;\n\n const collection = relation?.target();\n\n if (!collection) {\n throw Error(`Couldn't find the corresponding collection for the relation: ${propertyKey}`);\n }\n\n const onSingleEntitySelected = useCallback((e: Entity<Record<string, unknown>> | null) => {\n setValue(e ? getRelationFrom(e) : null);\n }, [setValue]);\n\n const referenceDialogController = useEntitySelectionDialog({\n multiselect: false,\n path: getCollectionDataPath(collection),\n collection,\n onSingleEntitySelected,\n selectedEntityIds: validValue && normalizedValue ? [normalizedValue.id] : undefined,\n fixedFilter: property.admin?.fixedFilter\n });\n\n const onEntryClick = (e: React.SyntheticEvent) => {\n e.preventDefault();\n if (disabled || isSubmitting) return;\n referenceDialogController.open();\n };\n\n const usedRelation = Array.isArray(value) ? undefined : normalizedValue ?? undefined;\n\n return (\n <>\n {!hideLabel && <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\n {!collection && <ErrorView\n error={\"The specified collection does not exist. Check console\"}/>}\n\n {collection && <>\n\n {usedRelation && <RelationPreview\n disabled={!usedRelation}\n previewProperties={property.admin?.previewProperties}\n hover={!disabled}\n size={size}\n onClick={disabled || isSubmitting ? undefined : onEntryClick}\n relation={usedRelation}\n includeEntityLink={property.admin?.includeEntityLink}\n includeId={property.admin?.includeId}\n />}\n\n {!value && <div className=\"justify-center text-left\">\n <EntityPreviewContainer className={cls(\"px-6 h-12 text-sm font-medium flex items-center gap-6\",\n disabled || isSubmitting\n ? \"text-surface-accent-500\"\n : \"cursor-pointer text-surface-accent-700 dark:text-surface-accent-300 hover:bg-surface-hover group-hover:bg-surface-hover\")}\n onClick={disabled || isSubmitting ? undefined : onEntryClick}\n size={\"medium\"}>\n <IconForView collectionOrView={collection}\n className={\"text-surface-300 dark:text-surface-600\"}/>\n {t(\"edit_name\", { name: property.name ?? propertyKey }).toUpperCase()}\n </EntityPreviewContainer>\n </div>}\n </>}\n\n <FieldHelperText includeDescription={includeDescription}\n showError={showError}\n error={error}\n disabled={disabled}\n property={property}/>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAgBA,SAAgB,qBAAqB,OAAqC;CACtE,MAAM,EAAE,UAAU,aAAa,YAAY;CAE3C,IAAI,SAAS,SAAS,YAClB,MAAM,MAAM,gEAAgE;CAEhF,MAAM,aAAa,QAAQ;CAC3B,MAAM,eAAe,aAAa,0BAA0B,WAAW,MAAM,IAAI,KAAA;CAYjF,IAAI,CAAC,cAAc,CAAC,cAAc,mBAC9B,MAAM,MAAM,4EAA4E;CAG5F,MAAM,WADmB,wBAAwB,UAAU,YAAY,WACtD;CAKjB,MAAM,aAAa,YAAY,CAAC,SAAS,WAAW;EAAE,GAAG;EAAO,UAAU;CAAK,IAAI;CAEnF,MAAM,eAAe,UAAU,gBAAgB;CAG/C,KAFe,SAAS,OAAO,UAAU,cAE1B,YAAY,UACvB,OAAO,oBAAC,yBAAD;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AE,aAAa,EAAE,MAAM,SAAS,QAAQ,YAAY,CAAC,CAAC,CAAC,YAAY,CAChD;;EACvB,CAAA,CACP,EAAA,CAAA;EAEF,oBAAC,iBAAD;GAAqC;GACtB;GACJ;GACG;GACA;EAAU,CAAA;CAC1B,EAAA,CAAA;AAEV"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FieldProps } from "../../types/fields.js";
|
|
2
|
-
import type { ArrayProperty } from "@rebasepro/types";
|
|
2
|
+
import type { ArrayProperty } from "@rebasepro/cms-types";
|
|
3
3
|
import React from "react";
|
|
4
4
|
/**
|
|
5
5
|
* Generic array field that allows reordering and renders the child property
|
|
@@ -6,7 +6,7 @@ import { PropertyFieldBinding } from "../PropertyFieldBinding.js";
|
|
|
6
6
|
import { useState } from "react";
|
|
7
7
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
import { ErrorBoundary, ExpandablePanel, Typography } from "@rebasepro/ui";
|
|
9
|
-
import { getArrayResolvedProperties, getDefaultValueFor } from "@rebasepro/
|
|
9
|
+
import { getArrayResolvedProperties, getDefaultValueFor } from "@rebasepro/cms-types";
|
|
10
10
|
import { isDisabled, useAuthController, useTranslation } from "@rebasepro/app";
|
|
11
11
|
import { mergeDeep } from "@rebasepro/utils";
|
|
12
12
|
//#region src/form/field_bindings/RepeatFieldBinding.tsx
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RepeatFieldBinding.js","names":[],"sources":["../../../src/form/field_bindings/RepeatFieldBinding.tsx"],"sourcesContent":["import type { FieldProps, PropertyFieldBindingProps } from \"../../types/fields\";\nimport type { ArrayProperty } from \"@rebasepro/types\";\nimport React, { useState } from \"react\";\n;\nimport { FieldHelperText } from \"../components/FieldHelperText\";\nimport { LabelWithIcon } from \"../components/LabelWithIcon\";\nimport { ArrayContainer, ArrayEntryParams } from \"../../components/ArrayContainer\";\nimport { ErrorBoundary } from \"@rebasepro/ui\";\nimport { getArrayResolvedProperties, getDefaultValueFor } from \"@rebasepro/
|
|
1
|
+
{"version":3,"file":"RepeatFieldBinding.js","names":[],"sources":["../../../src/form/field_bindings/RepeatFieldBinding.tsx"],"sourcesContent":["import type { FieldProps, PropertyFieldBindingProps } from \"../../types/fields\";\nimport type { ArrayProperty } from \"@rebasepro/cms-types\";\nimport React, { useState } from \"react\";\n;\nimport { FieldHelperText } from \"../components/FieldHelperText\";\nimport { LabelWithIcon } from \"../components/LabelWithIcon\";\nimport { ArrayContainer, ArrayEntryParams } from \"../../components/ArrayContainer\";\nimport { ErrorBoundary } from \"@rebasepro/ui\";\nimport { getArrayResolvedProperties, getDefaultValueFor } from \"@rebasepro/cms-types\";\nimport { getIconForProperty } from \"../../util/property_utils\";\nimport { PropertyFieldBinding } from \"../PropertyFieldBinding\";\nimport { ExpandablePanel, Typography } from \"@rebasepro/ui\";\nimport { isDisabled, useAuthController, useTranslation } from \"@rebasepro/app\";\nimport { mergeDeep } from \"@rebasepro/utils\";\n\n/**\n * Generic array field that allows reordering and renders the child property\n * as nodes.\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 RepeatFieldBinding({\n propertyKey,\n value,\n error,\n showError,\n isSubmitting,\n setValue,\n setFieldValue,\n minimalistView: minimalistViewProp,\n property,\n includeDescription,\n underlyingValueHasChanged,\n context,\n disabled\n}: FieldProps<ArrayProperty>) {\n\n const authController = useAuthController();\n const { t } = useTranslation();\n if (property.type !== \"array\" || !property.of || Array.isArray(property.of)) {\n throw Error(\"RepeatFieldBinding misconfiguration. Property `type` is not `array`\");\n }\n\n const minimalistView = minimalistViewProp || property.admin?.minimalistView;\n\n if (!property.of)\n throw Error(\"RepeatFieldBinding misconfiguration. Property `of` not set\");\n\n const resolvedProperties = getArrayResolvedProperties({\n propertyValue: value,\n propertyKey,\n property,\n ignoreMissingFields: false,\n authController\n })\n\n const expanded = property.admin?.expanded === undefined ? true : property.admin?.expanded;\n const ofProperty = property.of;\n\n const [lastAddedId, setLastAddedId] = useState<number | undefined>();\n\n const buildEntry = ({\n index,\n internalId,\n storedProps,\n storeProps\n }: ArrayEntryParams) => {\n const childProperty = (resolvedProperties as Record<number, typeof ofProperty>)?.[index] ?? ofProperty;\n const fieldProps: PropertyFieldBindingProps = {\n propertyKey: `${propertyKey}.${index}`,\n disabled,\n property: storedProps ? mergeDeep(childProperty, storedProps) : childProperty,\n onPropertyChange: storeProps,\n includeDescription,\n underlyingValueHasChanged,\n context,\n partOfArray: true,\n minimalistView: false,\n // The panel header already names the field; repeating \"Locale\" on\n // every row of a three-item array is noise, and the label was what\n // made each row a 76px card around a two-character value.\n hideLabel: true,\n autoFocus: internalId === lastAddedId\n };\n return <ErrorBoundary>\n <PropertyFieldBinding {...fieldProps} index={index}/>\n </ErrorBoundary>;\n };\n\n const canAddElements = !isDisabled(property) && !isSubmitting && !disabled && (property.admin?.canAddElements || property.admin?.canAddElements === undefined);\n const sortable = property.admin?.sortable === undefined ? true : property.admin.sortable;\n const arrayContainer = <ArrayContainer droppableId={propertyKey}\n addLabel={property.name ? t(\"add_to_field\", { fieldName: property.name }) : t(\"add_entry\")}\n value={(value as unknown[]) ?? []}\n buildEntry={buildEntry}\n onInternalIdAdded={setLastAddedId}\n disabled={isSubmitting || isDisabled(property)}\n canAddElements={canAddElements}\n sortable={sortable}\n newDefaultEntry={getDefaultValueFor(property.of)}\n onValueChange={(value) => setFieldValue(propertyKey, value)}\n />;\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 return (\n\n <>\n\n {!minimalistView && <ExpandablePanel initiallyExpanded={expanded}\n innerClassName={\"px-2 md:px-4 pb-2 md:pb-4 pt-1 md:pt-2\"}\n title={title}>\n {arrayContainer}\n </ExpandablePanel>}\n\n {minimalistView && arrayContainer}\n\n <FieldHelperText includeDescription={includeDescription}\n showError={showError}\n error={error}\n disabled={disabled}\n property={property}/>\n\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuBA,SAAgB,mBAAmB,EAC/B,aACA,OACA,OACA,WACA,cACA,UACA,eACA,gBAAgB,oBAChB,UACA,oBACA,2BACA,SACA,YAC0B;CAE1B,MAAM,iBAAiB,kBAAkB;CACzC,MAAM,EAAE,MAAM,eAAe;CAC7B,IAAI,SAAS,SAAS,WAAW,CAAC,SAAS,MAAM,MAAM,QAAQ,SAAS,EAAE,GACtE,MAAM,MAAM,qEAAqE;CAGrF,MAAM,iBAAiB,sBAAsB,SAAS,OAAO;CAE7D,IAAI,CAAC,SAAS,IACV,MAAM,MAAM,4DAA4D;CAE5E,MAAM,qBAAqB,2BAA2B;EAClD,eAAe;EACf;EACA;EACA,qBAAqB;EACrB;CACJ,CAAC;CAED,MAAM,WAAW,SAAS,OAAO,aAAa,KAAA,IAAY,OAAO,SAAS,OAAO;CACjF,MAAM,aAAa,SAAS;CAE5B,MAAM,CAAC,aAAa,kBAAkB,SAA6B;CAEnE,MAAM,cAAc,EAChB,OACA,YACA,aACA,iBACoB;EACpB,MAAM,gBAAiB,qBAA2D,UAAU;EAiB5F,OAAO,oBAAC,eAAD,EAAA,UACH,oBAAC,sBAAD;GAhBA,aAAa,GAAG,YAAY,GAAG;GAC/B;GACA,UAAU,cAAc,UAAU,eAAe,WAAW,IAAI;GAChE,kBAAkB;GAClB;GACA;GACA;GACA,aAAa;GACb,gBAAgB;GAIhB,WAAW;GACX,WAAW,eAAe;GAGmB;EAAO,CAAA,EACzC,CAAA;CACnB;CAEA,MAAM,iBAAiB,CAAC,WAAW,QAAQ,KAAK,CAAC,gBAAgB,CAAC,aAAa,SAAS,OAAO,kBAAkB,SAAS,OAAO,mBAAmB,KAAA;CACpJ,MAAM,WAAW,SAAS,OAAO,aAAa,KAAA,IAAY,OAAO,SAAS,MAAM;CAChF,MAAM,iBAAiB,oBAAC,gBAAD;EAAgB,aAAa;EAChD,UAAU,SAAS,OAAO,EAAE,gBAAgB,EAAE,WAAW,SAAS,KAAK,CAAC,IAAI,EAAE,WAAW;EACzF,OAAQ,SAAuB,CAAC;EACpB;EACZ,mBAAmB;EACnB,UAAU,gBAAgB,WAAW,QAAQ;EAC7B;EACN;EACV,iBAAiB,mBAAmB,SAAS,EAAE;EAC/C,gBAAgB,UAAU,cAAc,aAAa,KAAK;CAC7D,CAAA;CAED,MAAM,QAAS,qBAAA,UAAA,EAAA,UAAA,CACX,oBAAC,eAAD;EACiB;EACb,MAAM,mBAAmB,UAAU,OAAO;EAC1C,UAAU,SAAS,YAAY;EAC/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,OAEI,qBAAA,UAAA,EAAA,UAAA;EAEK,CAAC,kBAAkB,oBAAC,iBAAD;GAAiB,mBAAmB;GACpD,gBAAgB;GACT;aACN;EACY,CAAA;EAEhB,kBAAkB;EAEnB,oBAAC,iBAAD;GAAqC;GACtB;GACJ;GACG;GACA;EAAU,CAAA;CAE1B,EAAA,CAAA;AAEV"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FieldProps } from "../../types/fields.js";
|
|
2
|
-
import type { NumberProperty, StringProperty } from "@rebasepro/types";
|
|
2
|
+
import type { NumberProperty, StringProperty } from "@rebasepro/cms-types";
|
|
3
3
|
import React from "react";
|
|
4
4
|
/**
|
|
5
5
|
* If `enumValues` are set in the string config, this field renders a select
|
|
@@ -5,7 +5,7 @@ import { LabelWithIcon } from "../components/LabelWithIcon.js";
|
|
|
5
5
|
import { useCallback, useId } from "react";
|
|
6
6
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
import { IconButton, InputLabel, Select, SelectItem, XIcon, cls } from "@rebasepro/ui";
|
|
8
|
-
import { resolveEnumValues } from "@rebasepro/
|
|
8
|
+
import { resolveEnumValues } from "@rebasepro/cms-types";
|
|
9
9
|
import { useTranslation } from "@rebasepro/app";
|
|
10
10
|
//#region src/form/field_bindings/SelectFieldBinding.tsx
|
|
11
11
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectFieldBinding.js","names":[],"sources":["../../../src/form/field_bindings/SelectFieldBinding.tsx"],"sourcesContent":["import { useTranslation } from \"@rebasepro/app\";\nimport type { FieldProps } from \"../../types/fields\";\nimport type { NumberProperty, StringProperty } from \"@rebasepro/types\";\nimport React, { useCallback, useId } from \"react\";\n\nimport { FieldHelperText } from \"../components/FieldHelperText\";\nimport { LabelWithIcon } from \"../components/LabelWithIcon\";\nimport { EnumValuesChip } from \"../../preview\";\nimport { getIconForProperty } from \"../../util/property_utils\";\nimport { cls, IconButton, InputLabel, Select, SelectItem, XIcon } from \"@rebasepro/ui\";\nimport { resolveEnumValues } from \"@rebasepro/
|
|
1
|
+
{"version":3,"file":"SelectFieldBinding.js","names":[],"sources":["../../../src/form/field_bindings/SelectFieldBinding.tsx"],"sourcesContent":["import { useTranslation } from \"@rebasepro/app\";\nimport type { FieldProps } from \"../../types/fields\";\nimport type { NumberProperty, StringProperty } from \"@rebasepro/cms-types\";\nimport React, { useCallback, useId } from \"react\";\n\nimport { FieldHelperText } from \"../components/FieldHelperText\";\nimport { LabelWithIcon } from \"../components/LabelWithIcon\";\nimport { EnumValuesChip } from \"../../preview\";\nimport { getIconForProperty } from \"../../util/property_utils\";\nimport { cls, IconButton, InputLabel, Select, SelectItem, XIcon } from \"@rebasepro/ui\";\nimport { resolveEnumValues } from \"@rebasepro/cms-types\";\n\n/**\n * If `enumValues` are set in the string config, this field renders a select\n * where each option is a colored chip.\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 SelectFieldBinding({\n propertyKey,\n value,\n setValue,\n error,\n showError,\n disabled,\n autoFocus,\n touched,\n property,\n includeDescription,\n hideLabel,\n size = \"large\"\n}: FieldProps<StringProperty | NumberProperty>) {\n const { t } = useTranslation();\n\n const enumValues = resolveEnumValues(property.enum ?? []);\n\n const handleClearClick = useCallback((e: React.MouseEvent) => {\n e.stopPropagation();\n e.preventDefault();\n setValue(null);\n }, [setValue]);\n\n const triggerId = useId();\n const hasValue = value !== undefined && value !== null && value !== \"\";\n\n // `undefined` rather than an empty element, as in the text field: the box\n // only makes room for a label when there is one to draw.\n const label = hideLabel\n ? undefined\n : <LabelWithIcon\n icon={getIconForProperty(property, \"small\")}\n required={property.validation?.required}\n title={property.name ?? propertyKey}/>;\n // Inside the box at the form's size; a smaller select has no room for a\n // label in its top edge, and keeps it above as the kit draws it.\n const labelInside = Boolean(label) && size === \"large\";\n\n return (\n <>\n {/* The label goes INSIDE the box, as a text field's does: the kit's\n own floating label, shrunk into the top edge once there is a\n value and resting in the middle while there is none. `Select`\n can only put a label above its box, so it is laid over the box\n here — `top-[5px] left-px` is where a TextField's label lands,\n 1px in from its border — and the value is pushed down under it.\n Same 64px as a text field, so two of them paired on a row line\n up. */}\n <div className={\"relative\"}>\n <Select\n id={triggerId}\n value={value !== undefined && value != null ? value.toString() : \"\"}\n // The visible label is an element (icon + tooltip), which the\n // control cannot read a name from, so it announced itself as\n // \"Select an option\" — the same name for every enum field in\n // every form. Named here, where the property is.\n aria-label={property.name ?? propertyKey}\n disabled={disabled}\n size={size}\n fullWidth={true}\n position=\"item-aligned\"\n inputClassName={cls(\"w-full\", labelInside && \"min-h-[64px] pl-3\")}\n label={label && !labelInside\n ? <LabelWithIcon\n icon={getIconForProperty(property, \"small\")}\n required={property.validation?.required}\n title={property.name ?? propertyKey}\n propertyKey={propertyKey}\n className={\"h-8 text-text-secondary dark:text-text-secondary-dark ml-3.5 my-0\"}/>\n : undefined}\n endAdornment={\n property.admin?.clearable && !disabled && <IconButton aria-label={t(\"clear\")}\n size=\"small\"\n onClick={handleClearClick}>\n <XIcon/>\n </IconButton>\n }\n onValueChange={(updatedValue: string) => {\n const newValue = updatedValue\n ? (property.type === \"number\" ? parseFloat(updatedValue) : updatedValue)\n : null;\n return setValue(newValue);\n }}\n renderValue={(enumKey: string) => {\n const chip = <EnumValuesChip\n enumKey={enumKey}\n enumValues={enumValues}\n size={size}/>;\n // Pushed down under the label inside the value slot,\n // not by padding the trigger: the chip lands on the line\n // a text field's value sits on beside it, and the\n // chevron stays centred in the box, where a text\n // field's buttons are.\n return labelInside ? <div className={\"pt-6\"}>{chip}</div> : chip;\n }}\n >\n {enumValues && enumValues.map((option) => {\n return <SelectItem\n key={option.id}\n value={String(option.id)}\n textValue={option.label}>\n <EnumValuesChip\n enumKey={String(option.id)}\n enumValues={enumValues}\n size={size}/>\n </SelectItem>\n })}\n </Select>\n {labelInside && (\n <InputLabel htmlFor={triggerId}\n shrink={hasValue}\n className={cls(\n \"pointer-events-none absolute top-[5px] left-px\",\n disabled\n ? \"text-text-disabled dark:text-text-disabled-dark\"\n : showError && error\n ? \"text-red-500 dark:text-red-600\"\n : \"text-text-secondary dark:text-text-secondary-dark\"\n )}>\n {label}\n </InputLabel>\n )}\n </div>\n\n <FieldHelperText includeDescription={includeDescription}\n showError={showError}\n error={error}\n disabled={disabled}\n property={property}/>\n\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAoBA,SAAgB,mBAAmB,EAC/B,aACA,OACA,UACA,OACA,WACA,UACA,WACA,SACA,UACA,oBACA,WACA,OAAO,WACqC;CAC5C,MAAM,EAAE,MAAM,eAAe;CAE7B,MAAM,aAAa,kBAAkB,SAAS,QAAQ,CAAC,CAAC;CAExD,MAAM,mBAAmB,aAAa,MAAwB;EAC1D,EAAE,gBAAgB;EAClB,EAAE,eAAe;EACjB,SAAS,IAAI;CACjB,GAAG,CAAC,QAAQ,CAAC;CAEb,MAAM,YAAY,MAAM;CAC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AAM,CAAA;IACR,GAPH,OAAO,EAOJ;GAChB,CAAC;EACG,CAAA,GACP,eACG,oBAAC,YAAD;GAAY,SAAS;GACjB,QAAQ;GACR,WAAW,IACP,kDACA,WACM,oDACA,aAAa,QACT,mCACA,mDACd;aACC;EACO,CAAA,CAEf;KAEL,oBAAC,iBAAD;EAAqC;EACtB;EACJ;EACG;EACA;CAAU,CAAA,CAE1B,EAAA,CAAA;AAEV"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { FieldProps } from "../../types/fields.js";
|
|
2
|
-
import type { ArrayProperty, StringProperty } from "@rebasepro/types";
|
|
2
|
+
import type { ArrayProperty, StringProperty } from "@rebasepro/cms-types";
|
|
3
3
|
import React from "react";
|
|
4
|
-
import { StorageConfig } from "@rebasepro/types";
|
|
4
|
+
import { StorageConfig } from "@rebasepro/cms-types";
|
|
5
5
|
import { StorageFieldItem } from "@rebasepro/app";
|
|
6
6
|
export declare function StorageUploadFieldBinding({ propertyKey, value, setValue, error, showError, autoFocus, minimalistView, property, includeDescription, hideLabel, context, isSubmitting }: FieldProps<StringProperty | ArrayProperty>): React.JSX.Element;
|
|
7
7
|
export interface StorageUploadProps {
|