@rebasepro/cms 0.30.1 → 0.31.0-canary.g59cd6fd
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":"EnumForm.js","names":[],"sources":["../../../../src/collection_editor/ui/collection_editor/EnumForm.tsx"],"sourcesContent":["\nimport { FieldCaption } from \"../../_cms_internals\";\nimport React, { useEffect } from \"react\";\nimport { useTranslation } from \"@rebasepro/app\";\nimport { deepEqual as equal } from \"fast-equals\"\n\n;\nimport { EnumValueConfig, EnumValues } from \"@rebasepro/types\";\nimport { ArrayContainer, ArrayEntryParams } from \"../../_cms_internals\";\nimport {\n Badge,\n Button,\n CircularProgress,\n DebouncedTextField,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n IconButton,\n iconSize,\n ListIcon,\n Paper,\n RefreshCcwIcon,\n SettingsIcon,\n Typography\n} from \"@rebasepro/ui\";\nimport { extractEnumFromValues } from \"@rebasepro/inference\";\nimport { Field, Formex, getIn, useCreateFormex, useFormex } from \"@rebasepro/forms\";\n\ntype EnumFormProps = {\n enumValues: EnumValueConfig[];\n onValuesChanged?: (enumValues: EnumValueConfig[]) => void;\n onError?: (error: boolean) => void;\n updateIds: boolean;\n disabled: boolean;\n allowDataInference?: boolean;\n getData?: () => Promise<string[]>;\n};\n\nexport function EnumForm({\n enumValues,\n onValuesChanged,\n onError,\n updateIds,\n disabled,\n allowDataInference,\n getData\n}: EnumFormProps) {\n\n const { t } = useTranslation();\n const formex = useCreateFormex<{\n enum: EnumValueConfig[]\n }>({\n initialValues: { enum: enumValues },\n validateOnChange: true,\n validation: (values) => {\n const enumErrors = enumValueErrors(values.enum ?? [], t);\n const hasAnyError = enumErrors.some(error => error.label !== undefined || error.id !== undefined);\n onError?.(hasAnyError);\n return (hasAnyError ? { enum: enumErrors } : {}) as Record<string, string>;\n }\n });\n\n const {\n values,\n errors\n } = formex;\n\n useEffect(() => {\n if (onValuesChanged) {\n onValuesChanged(values.enum);\n }\n }, [values.enum]);\n\n return <Formex value={formex as ReturnType<typeof useCreateFormex>}>\n <EnumFormFields enumValuesPath={\"enum\"}\n values={values}\n errors={errors}\n shouldUpdateId={updateIds}\n disabled={disabled}\n allowDataInference={allowDataInference}\n getData={getData}/>\n </Formex>\n\n}\n\n/** What is wrong with one enum value entry, if anything. */\nexport interface EnumFieldError { label?: string; id?: string; }\n\n/**\n * The errors of each enum value entry, by index: a missing label, a missing\n * id, or an id an earlier entry already has. An id names one value — two with\n * the same id store the same thing, and the panel cannot tell which label a\n * row means — compared as text, as the stored value and the select compare it.\n */\nexport function enumValueErrors(\n enumValues: EnumValueConfig[],\n t: (key: string, options?: Record<string, string>) => string\n): EnumFieldError[] {\n const seenIds = new Set<string>();\n return enumValues.map((enumValue) => {\n const fieldError: EnumFieldError = {};\n if (!enumValue?.label) {\n fieldError.label = \"You must specify a label for this enum value entry\";\n }\n if (!hasEnumId(enumValue)) {\n fieldError.id = \"You must specify an ID for this enum value entry\";\n } else if (seenIds.has(String(enumValue.id))) {\n fieldError.id = t(\"enum_id_duplicate\", { id: String(enumValue.id) });\n } else {\n seenIds.add(String(enumValue.id));\n }\n return fieldError;\n });\n}\n\n/**\n * Whether an enum value has its id. `0` is one: a number select's first\n * value is often `0`, and a truthiness check called it missing.\n */\nexport function hasEnumId(enumValue: EnumValueConfig | undefined): boolean {\n const id = enumValue?.id;\n return id !== undefined && id !== null && id !== \"\";\n}\n\ntype EnumFormFieldsProps = {\n values: {\n enum: EnumValueConfig[]\n };\n errors: { enum?: Array<{ label?: string; id?: string }> };\n enumValuesPath: string;\n shouldUpdateId: boolean;\n disabled: boolean;\n getData?: () => Promise<string[]>;\n allowDataInference?: boolean;\n};\n\n// const EnumFormFields = React.memo(\nfunction EnumFormFields({\n values,\n errors,\n disabled,\n enumValuesPath,\n shouldUpdateId,\n allowDataInference,\n getData\n}: EnumFormFieldsProps) {\n\n const {\n setFieldValue\n } = useFormex();\n\n const [lastInternalIdAdded, setLastInternalIdAdded] = React.useState<number | undefined>();\n const [editDialogIndex, setEditDialogIndex] = React.useState<number | undefined>();\n const [inferring, setInferring] = React.useState(false);\n\n const inferredValuesRef = React.useRef(new Set());\n const inferredValues = inferredValuesRef.current;\n\n const buildEntry = ({\n index,\n internalId\n }: ArrayEntryParams) => {\n const justAdded = lastInternalIdAdded === internalId;\n const entryError = errors?.enum?.[index];\n return <EnumEntry index={index}\n disabled={disabled}\n enumValuesPath={enumValuesPath}\n autoFocus={justAdded}\n entryError={entryError}\n shouldUpdateId={shouldUpdateId || justAdded}\n onDialogOpen={() => setEditDialogIndex(index)}\n inferredEntry={inferredValues.has(values.enum[index]?.id as string)}\n key={`${internalId}`}/>;\n };\n\n const inferValues = async () => {\n if (!getData)\n return;\n setInferring(true);\n getData?.().then((data) => {\n if (!data)\n return;\n\n const flatData = data.flat();\n\n const fieldData = Array.from(new Set(flatData));\n\n const currentEnumValues = values.enum;\n const foundEnumValues = extractEnumFromValues(fieldData);\n\n // add only new enum values\n const newEnumValues = foundEnumValues.filter((enumValue) => {\n if (!enumValue) return false;\n return !currentEnumValues?.some((v: EnumValueConfig) => v.id === enumValue.id);\n });\n\n newEnumValues.forEach((enumValue) => {\n if (enumValue) inferredValues.add(enumValue.id);\n });\n setFieldValue(enumValuesPath, [...newEnumValues, ...currentEnumValues], true);\n }).catch(e => {\n console.error(e);\n })\n .finally(() => setInferring(false));\n }\n\n return (\n <div className={\"col-span-12\"}>\n <div className=\"ml-3.5 flex flex-row items-center\">\n <ListIcon/>\n <Typography variant={\"subtitle2\"}\n className=\"ml-2 grow\">\n Values\n </Typography>\n {allowDataInference &&\n <Button\n disabled={disabled || inferring}\n variant={\"text\"}\n size={\"small\"}\n onClick={inferValues}>\n {inferring ? <CircularProgress size={\"smallest\"}/> : <RefreshCcwIcon/>}\n Infer values from data\n </Button>}\n </div>\n\n <Paper className=\"p-4 m-1\">\n\n <ArrayContainer droppableId={enumValuesPath}\n addLabel={\"Add enum value\"}\n value={values.enum}\n disabled={disabled}\n size={\"small\"}\n buildEntry={buildEntry}\n onInternalIdAdded={setLastInternalIdAdded}\n canAddElements={true}\n onValueChange={(value: EnumValueConfig[]) => setFieldValue(enumValuesPath, value)}\n newDefaultEntry={{\n id: \"\",\n label: \"\"\n }}/>\n\n <EnumEntryDialog index={editDialogIndex}\n open={editDialogIndex !== undefined}\n enumValuesPath={enumValuesPath}\n onClose={() => setEditDialogIndex(undefined)}/>\n </Paper>\n </div>\n );\n}\n\ntype EnumEntryProps = {\n index: number,\n enumValuesPath: string,\n shouldUpdateId: boolean,\n autoFocus: boolean,\n onDialogOpen: () => void;\n disabled: boolean;\n inferredEntry?: boolean;\n entryError?: { label?: string, id?: string }\n};\n\nconst EnumEntry = React.memo(\n function EnumEntryInternal({\n index,\n shouldUpdateId: updateId,\n enumValuesPath,\n autoFocus,\n onDialogOpen,\n disabled,\n inferredEntry,\n entryError\n }: EnumEntryProps) {\n\n const {\n values,\n handleChange,\n errors,\n setFieldValue,\n touched\n } = useFormex<EnumValues>();\n\n const shouldUpdateIdRef = React.useRef(!getIn(values, `${enumValuesPath}[${index}].id`));\n const shouldUpdateId = updateId || shouldUpdateIdRef.current;\n\n const idValue = getIn(values, `${enumValuesPath}[${index}].id`);\n const labelValue = getIn(values, `${enumValuesPath}[${index}].label`);\n\n const currentLabelRef = React.useRef(labelValue);\n\n React.useEffect(() => {\n if ((currentLabelRef.current === idValue || !idValue) && shouldUpdateId) {\n setFieldValue(`${enumValuesPath}[${index}].id`, labelValue);\n }\n currentLabelRef.current = labelValue;\n }, [labelValue]);\n\n return (\n <>\n <div className={\"flex w-full align-center justify-center\"}>\n <Field name={`${enumValuesPath}[${index}].label`}\n as={DebouncedTextField}\n className={\"grow\"}\n required\n disabled={disabled}\n size=\"small\"\n autoFocus={autoFocus}\n autoComplete=\"off\"\n endAdornment={inferredEntry && <RefreshCcwIcon size={iconSize.small}/>}\n error={Boolean(entryError?.label)}/>\n\n {!disabled &&\n <Badge color={\"error\"} invisible={!entryError?.id}>\n <IconButton\n size=\"small\"\n aria-label=\"edit\"\n className={\"m-1\"}\n onClick={() => onDialogOpen()}>\n <SettingsIcon size={iconSize.small}/>\n </IconButton>\n </Badge>}\n\n </div>\n\n {entryError?.label && <Typography variant={\"caption\"}\n className={\"ml-3.5 text-red-500 dark:text-red-500\"}>\n {entryError?.label}\n </Typography>}\n\n {entryError?.id && <Typography variant={\"caption\"}\n className={\"ml-3.5 text-red-500 dark:text-red-500\"}>\n {entryError?.id}\n </Typography>}\n\n </>);\n },\n function areEqual(prevProps: EnumEntryProps, nextProps: EnumEntryProps) {\n return prevProps.index === nextProps.index &&\n prevProps.enumValuesPath === nextProps.enumValuesPath &&\n prevProps.shouldUpdateId === nextProps.shouldUpdateId &&\n prevProps.inferredEntry === nextProps.inferredEntry &&\n equal(prevProps.entryError, nextProps.entryError) &&\n prevProps.autoFocus === nextProps.autoFocus;\n }\n);\n\nfunction EnumEntryDialog({\n index,\n open,\n onClose,\n enumValuesPath\n}: {\n index?: number;\n open: boolean;\n enumValuesPath: string;\n onClose: () => void;\n}) {\n\n const {\n errors\n } = useFormex<EnumValues>();\n\n const idError = index !== undefined ? getIn(errors, `${enumValuesPath}[${index}].id`) as string | undefined : undefined;\n return <Dialog\n maxWidth=\"md\"\n aria-labelledby=\"enum-edit-dialog\"\n open={open}\n onOpenChange={(open) => !open ? onClose() : undefined}\n >\n <DialogTitle hidden>Enum form dialog</DialogTitle>\n <DialogContent>\n {index !== undefined &&\n <div>\n <Field name={`${enumValuesPath}[${index}].id`}\n as={DebouncedTextField}\n required\n label={\"ID\"}\n size=\"small\"\n autoComplete=\"off\"\n error={Boolean(idError)}/>\n\n <FieldCaption error={Boolean(idError)}>\n {idError ?? \"Value saved in the data source\"}\n </FieldCaption>\n </div>}\n </DialogContent>\n\n <DialogActions>\n <Button\n autoFocus\n onClick={onClose}>\n Ok\n </Button>\n </DialogActions>\n\n </Dialog>\n}\n\n"],"mappings":";;;;;;;;;;AAuCA,SAAgB,SAAS,EACrB,YACA,iBACA,SACA,WACA,UACA,oBACA,WACc;CAEd,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,SAAS,gBAEZ;EACC,eAAe,EAAE,MAAM,WAAW;EAClC,kBAAkB;EAClB,aAAa,WAAW;GACpB,MAAM,aAAa,gBAAgB,OAAO,QAAQ,CAAC,GAAG,CAAC;GACvD,MAAM,cAAc,WAAW,MAAK,UAAS,MAAM,UAAU,KAAA,KAAa,MAAM,OAAO,KAAA,CAAS;GAChG,UAAU,WAAW;GACrB,OAAQ,cAAc,EAAE,MAAM,WAAW,IAAI,CAAC;EAClD;CACJ,CAAC;CAED,MAAM,EACF,QACA,WACA;CAEJ,gBAAgB;EACZ,IAAI,iBACA,gBAAgB,OAAO,IA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WAAA;IACA,SAAS;cAAS;GAEd,CAAA,EACG,CAAA;EAEX;;AACZ"}
|
|
1
|
+
{"version":3,"file":"EnumForm.js","names":[],"sources":["../../../../src/collection_editor/ui/collection_editor/EnumForm.tsx"],"sourcesContent":["\nimport { FieldCaption } from \"../../_cms_internals\";\nimport React, { useEffect } from \"react\";\nimport { useTranslation } from \"@rebasepro/app\";\nimport { deepEqual as equal } from \"fast-equals\"\n\n;\nimport { EnumValueConfig, EnumValues } from \"@rebasepro/cms-types\";\nimport { ArrayContainer, ArrayEntryParams } from \"../../_cms_internals\";\nimport {\n Badge,\n Button,\n CircularProgress,\n DebouncedTextField,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n IconButton,\n iconSize,\n ListIcon,\n Paper,\n RefreshCcwIcon,\n SettingsIcon,\n Typography\n} from \"@rebasepro/ui\";\nimport { extractEnumFromValues } from \"@rebasepro/inference\";\nimport { Field, Formex, getIn, useCreateFormex, useFormex } from \"@rebasepro/forms\";\n\ntype EnumFormProps = {\n enumValues: EnumValueConfig[];\n onValuesChanged?: (enumValues: EnumValueConfig[]) => void;\n onError?: (error: boolean) => void;\n updateIds: boolean;\n disabled: boolean;\n allowDataInference?: boolean;\n getData?: () => Promise<string[]>;\n};\n\nexport function EnumForm({\n enumValues,\n onValuesChanged,\n onError,\n updateIds,\n disabled,\n allowDataInference,\n getData\n}: EnumFormProps) {\n\n const { t } = useTranslation();\n const formex = useCreateFormex<{\n enum: EnumValueConfig[]\n }>({\n initialValues: { enum: enumValues },\n validateOnChange: true,\n validation: (values) => {\n const enumErrors = enumValueErrors(values.enum ?? [], t);\n const hasAnyError = enumErrors.some(error => error.label !== undefined || error.id !== undefined);\n onError?.(hasAnyError);\n return (hasAnyError ? { enum: enumErrors } : {}) as Record<string, string>;\n }\n });\n\n const {\n values,\n errors\n } = formex;\n\n useEffect(() => {\n if (onValuesChanged) {\n onValuesChanged(values.enum);\n }\n }, [values.enum]);\n\n return <Formex value={formex as ReturnType<typeof useCreateFormex>}>\n <EnumFormFields enumValuesPath={\"enum\"}\n values={values}\n errors={errors}\n shouldUpdateId={updateIds}\n disabled={disabled}\n allowDataInference={allowDataInference}\n getData={getData}/>\n </Formex>\n\n}\n\n/** What is wrong with one enum value entry, if anything. */\nexport interface EnumFieldError { label?: string; id?: string; }\n\n/**\n * The errors of each enum value entry, by index: a missing label, a missing\n * id, or an id an earlier entry already has. An id names one value — two with\n * the same id store the same thing, and the panel cannot tell which label a\n * row means — compared as text, as the stored value and the select compare it.\n */\nexport function enumValueErrors(\n enumValues: EnumValueConfig[],\n t: (key: string, options?: Record<string, string>) => string\n): EnumFieldError[] {\n const seenIds = new Set<string>();\n return enumValues.map((enumValue) => {\n const fieldError: EnumFieldError = {};\n if (!enumValue?.label) {\n fieldError.label = \"You must specify a label for this enum value entry\";\n }\n if (!hasEnumId(enumValue)) {\n fieldError.id = \"You must specify an ID for this enum value entry\";\n } else if (seenIds.has(String(enumValue.id))) {\n fieldError.id = t(\"enum_id_duplicate\", { id: String(enumValue.id) });\n } else {\n seenIds.add(String(enumValue.id));\n }\n return fieldError;\n });\n}\n\n/**\n * Whether an enum value has its id. `0` is one: a number select's first\n * value is often `0`, and a truthiness check called it missing.\n */\nexport function hasEnumId(enumValue: EnumValueConfig | undefined): boolean {\n const id = enumValue?.id;\n return id !== undefined && id !== null && id !== \"\";\n}\n\ntype EnumFormFieldsProps = {\n values: {\n enum: EnumValueConfig[]\n };\n errors: { enum?: Array<{ label?: string; id?: string }> };\n enumValuesPath: string;\n shouldUpdateId: boolean;\n disabled: boolean;\n getData?: () => Promise<string[]>;\n allowDataInference?: boolean;\n};\n\n// const EnumFormFields = React.memo(\nfunction EnumFormFields({\n values,\n errors,\n disabled,\n enumValuesPath,\n shouldUpdateId,\n allowDataInference,\n getData\n}: EnumFormFieldsProps) {\n\n const {\n setFieldValue\n } = useFormex();\n\n const [lastInternalIdAdded, setLastInternalIdAdded] = React.useState<number | undefined>();\n const [editDialogIndex, setEditDialogIndex] = React.useState<number | undefined>();\n const [inferring, setInferring] = React.useState(false);\n\n const inferredValuesRef = React.useRef(new Set());\n const inferredValues = inferredValuesRef.current;\n\n const buildEntry = ({\n index,\n internalId\n }: ArrayEntryParams) => {\n const justAdded = lastInternalIdAdded === internalId;\n const entryError = errors?.enum?.[index];\n return <EnumEntry index={index}\n disabled={disabled}\n enumValuesPath={enumValuesPath}\n autoFocus={justAdded}\n entryError={entryError}\n shouldUpdateId={shouldUpdateId || justAdded}\n onDialogOpen={() => setEditDialogIndex(index)}\n inferredEntry={inferredValues.has(values.enum[index]?.id as string)}\n key={`${internalId}`}/>;\n };\n\n const inferValues = async () => {\n if (!getData)\n return;\n setInferring(true);\n getData?.().then((data) => {\n if (!data)\n return;\n\n const flatData = data.flat();\n\n const fieldData = Array.from(new Set(flatData));\n\n const currentEnumValues = values.enum;\n const foundEnumValues = extractEnumFromValues(fieldData);\n\n // add only new enum values\n const newEnumValues = foundEnumValues.filter((enumValue) => {\n if (!enumValue) return false;\n return !currentEnumValues?.some((v: EnumValueConfig) => v.id === enumValue.id);\n });\n\n newEnumValues.forEach((enumValue) => {\n if (enumValue) inferredValues.add(enumValue.id);\n });\n setFieldValue(enumValuesPath, [...newEnumValues, ...currentEnumValues], true);\n }).catch(e => {\n console.error(e);\n })\n .finally(() => setInferring(false));\n }\n\n return (\n <div className={\"col-span-12\"}>\n <div className=\"ml-3.5 flex flex-row items-center\">\n <ListIcon/>\n <Typography variant={\"subtitle2\"}\n className=\"ml-2 grow\">\n Values\n </Typography>\n {allowDataInference &&\n <Button\n disabled={disabled || inferring}\n variant={\"text\"}\n size={\"small\"}\n onClick={inferValues}>\n {inferring ? <CircularProgress size={\"smallest\"}/> : <RefreshCcwIcon/>}\n Infer values from data\n </Button>}\n </div>\n\n <Paper className=\"p-4 m-1\">\n\n <ArrayContainer droppableId={enumValuesPath}\n addLabel={\"Add enum value\"}\n value={values.enum}\n disabled={disabled}\n size={\"small\"}\n buildEntry={buildEntry}\n onInternalIdAdded={setLastInternalIdAdded}\n canAddElements={true}\n onValueChange={(value: EnumValueConfig[]) => setFieldValue(enumValuesPath, value)}\n newDefaultEntry={{\n id: \"\",\n label: \"\"\n }}/>\n\n <EnumEntryDialog index={editDialogIndex}\n open={editDialogIndex !== undefined}\n enumValuesPath={enumValuesPath}\n onClose={() => setEditDialogIndex(undefined)}/>\n </Paper>\n </div>\n );\n}\n\ntype EnumEntryProps = {\n index: number,\n enumValuesPath: string,\n shouldUpdateId: boolean,\n autoFocus: boolean,\n onDialogOpen: () => void;\n disabled: boolean;\n inferredEntry?: boolean;\n entryError?: { label?: string, id?: string }\n};\n\nconst EnumEntry = React.memo(\n function EnumEntryInternal({\n index,\n shouldUpdateId: updateId,\n enumValuesPath,\n autoFocus,\n onDialogOpen,\n disabled,\n inferredEntry,\n entryError\n }: EnumEntryProps) {\n\n const {\n values,\n handleChange,\n errors,\n setFieldValue,\n touched\n } = useFormex<EnumValues>();\n\n const shouldUpdateIdRef = React.useRef(!getIn(values, `${enumValuesPath}[${index}].id`));\n const shouldUpdateId = updateId || shouldUpdateIdRef.current;\n\n const idValue = getIn(values, `${enumValuesPath}[${index}].id`);\n const labelValue = getIn(values, `${enumValuesPath}[${index}].label`);\n\n const currentLabelRef = React.useRef(labelValue);\n\n React.useEffect(() => {\n if ((currentLabelRef.current === idValue || !idValue) && shouldUpdateId) {\n setFieldValue(`${enumValuesPath}[${index}].id`, labelValue);\n }\n currentLabelRef.current = labelValue;\n }, [labelValue]);\n\n return (\n <>\n <div className={\"flex w-full align-center justify-center\"}>\n <Field name={`${enumValuesPath}[${index}].label`}\n as={DebouncedTextField}\n className={\"grow\"}\n required\n disabled={disabled}\n size=\"small\"\n autoFocus={autoFocus}\n autoComplete=\"off\"\n endAdornment={inferredEntry && <RefreshCcwIcon size={iconSize.small}/>}\n error={Boolean(entryError?.label)}/>\n\n {!disabled &&\n <Badge color={\"error\"} invisible={!entryError?.id}>\n <IconButton\n size=\"small\"\n aria-label=\"edit\"\n className={\"m-1\"}\n onClick={() => onDialogOpen()}>\n <SettingsIcon size={iconSize.small}/>\n </IconButton>\n </Badge>}\n\n </div>\n\n {entryError?.label && <Typography variant={\"caption\"}\n className={\"ml-3.5 text-red-500 dark:text-red-500\"}>\n {entryError?.label}\n </Typography>}\n\n {entryError?.id && <Typography variant={\"caption\"}\n className={\"ml-3.5 text-red-500 dark:text-red-500\"}>\n {entryError?.id}\n </Typography>}\n\n </>);\n },\n function areEqual(prevProps: EnumEntryProps, nextProps: EnumEntryProps) {\n return prevProps.index === nextProps.index &&\n prevProps.enumValuesPath === nextProps.enumValuesPath &&\n prevProps.shouldUpdateId === nextProps.shouldUpdateId &&\n prevProps.inferredEntry === nextProps.inferredEntry &&\n equal(prevProps.entryError, nextProps.entryError) &&\n prevProps.autoFocus === nextProps.autoFocus;\n }\n);\n\nfunction EnumEntryDialog({\n index,\n open,\n onClose,\n enumValuesPath\n}: {\n index?: number;\n open: boolean;\n enumValuesPath: string;\n onClose: () => void;\n}) {\n\n const {\n errors\n } = useFormex<EnumValues>();\n\n const idError = index !== undefined ? getIn(errors, `${enumValuesPath}[${index}].id`) as string | undefined : undefined;\n return <Dialog\n maxWidth=\"md\"\n aria-labelledby=\"enum-edit-dialog\"\n open={open}\n onOpenChange={(open) => !open ? onClose() : undefined}\n >\n <DialogTitle hidden>Enum form dialog</DialogTitle>\n <DialogContent>\n {index !== undefined &&\n <div>\n <Field name={`${enumValuesPath}[${index}].id`}\n as={DebouncedTextField}\n required\n label={\"ID\"}\n size=\"small\"\n autoComplete=\"off\"\n error={Boolean(idError)}/>\n\n <FieldCaption error={Boolean(idError)}>\n {idError ?? \"Value saved in the data source\"}\n </FieldCaption>\n </div>}\n </DialogContent>\n\n <DialogActions>\n <Button\n autoFocus\n onClick={onClose}>\n Ok\n </Button>\n </DialogActions>\n\n </Dialog>\n}\n\n"],"mappings":";;;;;;;;;;AAuCA,SAAgB,SAAS,EACrB,YACA,iBACA,SACA,WACA,UACA,oBACA,WACc;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YAJzC;GAMH,oBAAC,aAAD;IAAa,QAAA;cAAO;GAA6B,CAAA;GACjD,oBAAC,eAAD,EAAA,UACK,UAAU,KAAA,KACP,qBAAC,OAAD,EAAA,UAAA,CACI,oBAAC,OAAD;IAAO,MAAM,GAAG,eAAe,GAAG,MAAM;IACpC,IAAI;IACJ,UAAA;IACA,OAAO;IACP,MAAK;IACL,cAAa;IACb,OAAO,QAAQ,OAAO;GAAG,CAAA,GAE7B,oBAAC,cAAD;IAAc,OAAO,QAAQ,OAAO;cAC/B,WAAW;GACF,CAAA,CACb,EAAA,CAAA,EACE,CAAA;GAEf,oBAAC,eAAD,EAAA,UACI,oBAAC,QAAD;IACI,WAAA;IACA,SAAS;cAAS;GAEd,CAAA,EACG,CAAA;EAEX;;AACZ"}
|
|
@@ -43,7 +43,7 @@ function GeneralSettingsForm({ isNewCollection, existingPaths, existingIds, pare
|
|
|
43
43
|
}),
|
|
44
44
|
/* @__PURE__ */ jsx(DefaultDatabaseField, {
|
|
45
45
|
databaseId: values.databaseId,
|
|
46
|
-
disabled: configController?.readOnly,
|
|
46
|
+
disabled: configController?.readOnly || !isNewCollection,
|
|
47
47
|
onDatabaseIdUpdate: updateDatabaseId
|
|
48
48
|
}),
|
|
49
49
|
/* @__PURE__ */ jsx(Tooltip, {
|
|
@@ -96,7 +96,7 @@ function GeneralSettingsForm({ isNewCollection, existingPaths, existingIds, pare
|
|
|
96
96
|
error: showErrors && Boolean(errors.table)
|
|
97
97
|
}), /* @__PURE__ */ jsx(FieldCaption, {
|
|
98
98
|
error: touched.table && Boolean(errors.table),
|
|
99
|
-
children: touched.table && Boolean(errors.table) ? errors.table : isSubcollection ? "Relative path to the parent (no need to include the parent path)" : "PostgreSQL table name for this collection"
|
|
99
|
+
children: touched.table && Boolean(errors.table) ? errors.table : !isNewCollection ? t("schema_rename_is_a_migration") : isSubcollection ? "Relative path to the parent (no need to include the parent path)" : "PostgreSQL table name for this collection"
|
|
100
100
|
})]
|
|
101
101
|
}),
|
|
102
102
|
/* @__PURE__ */ jsxs("div", {
|
|
@@ -143,7 +143,7 @@ function GeneralSettingsForm({ isNewCollection, existingPaths, existingIds, pare
|
|
|
143
143
|
error: showErrors && Boolean(errors.slug)
|
|
144
144
|
}), /* @__PURE__ */ jsx(FieldCaption, {
|
|
145
145
|
error: touched.slug && Boolean(errors.slug),
|
|
146
|
-
children: touched.slug && Boolean(errors.slug) ? errors.slug : "This ID identifies this collection. Typically the same as the path."
|
|
146
|
+
children: touched.slug && Boolean(errors.slug) ? errors.slug : !isNewCollection ? t("schema_rename_is_a_migration") : "This ID identifies this collection. Typically the same as the path."
|
|
147
147
|
})]
|
|
148
148
|
})
|
|
149
149
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GeneralSettingsForm.js","names":[],"sources":["../../../../src/collection_editor/ui/collection_editor/GeneralSettingsForm.tsx"],"sourcesContent":["\nimport { IconForView, useTranslation } from \"@rebasepro/app\";\nimport { FieldCaption } from \"../../_cms_internals\";\nimport React, { useState } from \"react\";\n\nimport { SearchIconsView } from \"../../_cms_internals\";\n\nimport {\n BooleanSwitchWithLabel,\n Chip,\n cls,\n Container,\n DebouncedTextField,\n Dialog,\n ExpandablePanel,\n HistoryIcon,\n IconButton,\n iconSize,\n SearchIcon,\n Select,\n SelectItem,\n TextField,\n Tooltip,\n Typography\n} from \"@rebasepro/ui\";\nimport { Field, getIn, useFormex } from \"@rebasepro/forms\";\nimport { useCollectionsConfigController } from \"../../useCollectionsConfigController\";\nimport { singular, toSnakeCase } from \"@rebasepro/utils\";\nimport type { ExtraCollectionFieldsParams } from \"../../extensibility_types\";\nimport { toSerializableCollectionConfig } from \"../../serializable_utils\";\nimport type { AdminCollection, AdminPostgresCollection } from \"@rebasepro/cms-types\";\n\nexport function GeneralSettingsForm({\n isNewCollection,\n existingPaths,\n existingIds,\n parentCollection,\n renderExtraCollectionFields,\n standalone,\n}: {\n isNewCollection: boolean;\n existingPaths?: string[];\n existingIds?: string[];\n parentCollection?: AdminCollection;\n renderExtraCollectionFields?: (params: ExtraCollectionFieldsParams) => React.ReactNode;\n standalone?: boolean;\n}) {\n\n const {\n values,\n setFieldValue,\n handleChange,\n touched,\n errors,\n setFieldTouched,\n submitCount\n } = useFormex<AdminPostgresCollection>();\n const { t } = useTranslation();\n\n const [iconDialogOpen, setIconDialogOpen] = useState(false);\n\n const configControllerFromContext = useCollectionsConfigController();\n const configController = standalone ? { readOnly: false } : configControllerFromContext;\n\n const updateDatabaseId = (databaseId: string) => {\n setFieldValue(\"databaseId\", databaseId ?? undefined);\n }\n\n const updateName = (name: string) => {\n setFieldValue(\"name\", name);\n\n const pathTouched = getIn(touched, \"table\");\n if (!pathTouched && isNewCollection && name) {\n setFieldValue(\"table\", toSnakeCase(name));\n }\n\n const idTouched = getIn(touched, \"slug\");\n if (!idTouched && isNewCollection && name) {\n setFieldValue(\"slug\", toSnakeCase(name));\n }\n\n const singularNameTouched = getIn(touched, \"singularName\");\n if (!singularNameTouched && isNewCollection && name) {\n setFieldValue(\"singularName\", singular(name));\n }\n };\n\n const collectionIcon = <IconForView collectionOrView={values}/>;\n const isSubcollection = !!parentCollection;\n const showErrors = submitCount > 0;\n\n return (\n <div className={\"overflow-auto my-auto\"}>\n <Container maxWidth={\"4xl\"} className={\"flex flex-col gap-4 p-8 m-auto\"}>\n\n <div>\n <div className=\"flex flex-row gap-2 items-center\">\n <Typography variant={!isNewCollection ? \"h5\" : \"h4\"} className={\"flex-grow\"}>\n {isNewCollection ? \"New collection\" : `${values?.name} collection`}\n </Typography>\n <DefaultDatabaseField databaseId={values.databaseId}\n disabled={configController?.readOnly}\n onDatabaseIdUpdate={updateDatabaseId}/>\n\n <Tooltip title={t(\"change_icon\")}\n asChild={true}>\n <IconButton aria-label={t(\"change_icon\")}\n shape={\"square\"}\n disabled={configController?.readOnly}\n onClick={() => setIconDialogOpen(true)}>\n {collectionIcon}\n </IconButton>\n </Tooltip>\n </div>\n\n {parentCollection && <Chip colorScheme={\"teal\"}>\n <Typography variant={\"caption\"}>\n This is a subcollection of <b>{parentCollection.name}</b>\n </Typography>\n </Chip>}\n\n </div>\n\n <fieldset disabled={configController?.readOnly} className=\"contents\">\n <div className={\"grid grid-cols-12 gap-4\"}>\n\n {/* Name */}\n <div className={\"col-span-12\"}>\n <TextField\n value={values.name ?? \"\"}\n onChange={(e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => updateName(e.target.value)}\n label={\"Name\"}\n autoFocus={true}\n required\n error={showErrors && Boolean(errors.name)}/>\n <FieldCaption error={touched.name && Boolean(errors.name)}>\n {touched.name && Boolean(errors.name) ? errors.name : \"Name of this collection, usually a plural name (e.g. Products)\"}\n </FieldCaption>\n </div>\n\n {/* Table name — fixed once the collection exists, like its ID. The\n schema is only ever changed additively, so a new name\n here would create a new, empty table and leave every\n row in the old one. Moving a table is a migration. */}\n <div className={cls(\"col-span-12\")}>\n <Field name={\"table\"}\n as={DebouncedTextField}\n label={\"Table name\"}\n required\n disabled={!isNewCollection}\n error={showErrors && Boolean(errors.table)}/>\n\n <FieldCaption error={touched.table && Boolean(errors.table)}>\n {touched.table && Boolean(errors.table)\n ? errors.table\n : isSubcollection ? \"Relative path to the parent (no need to include the parent path)\" : \"PostgreSQL table name for this collection\"}\n </FieldCaption>\n </div>\n\n {/* Singular Name */}\n <div className={\"col-span-12\"}>\n <TextField\n error={showErrors && Boolean(errors.singularName)}\n name={\"singularName\"}\n aria-describedby={\"singularName-helper\"}\n onChange={(e) => {\n setFieldTouched(\"singularName\", true);\n return handleChange(e);\n }}\n value={values.singularName ?? \"\"}\n label={\"Singular name\"}/>\n <FieldCaption error={showErrors && Boolean(errors.singularName)}>\n {showErrors && Boolean(errors.singularName) ? errors.singularName : \"Optionally define a singular name for your entities\"}\n </FieldCaption>\n </div>\n\n {/* Description */}\n <div className={\"col-span-12\"}>\n <TextField\n error={showErrors && Boolean(errors.description)}\n name=\"description\"\n value={values.description ?? \"\"}\n onChange={handleChange}\n multiline\n minRows={2}\n aria-describedby=\"description-helper-text\"\n label=\"Description\"\n />\n <FieldCaption error={showErrors && Boolean(errors.description)}>\n {showErrors && Boolean(errors.description) ? errors.description : \"Description of the collection, you can use markdown\"}\n </FieldCaption>\n </div>\n\n {/* Collection ID */}\n <div className={\"col-span-12\"}>\n <DebouncedTextField\n name={\"slug\"}\n value={values.slug ?? \"\"}\n onChange={(e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => setFieldValue(\"slug\", e.target.value)}\n disabled={!isNewCollection}\n label={\"Collection ID\"}\n error={showErrors && Boolean(errors.slug)}/>\n <FieldCaption error={touched.slug && Boolean(errors.slug)}>\n {touched.slug && Boolean(errors.slug) ? errors.slug : \"This ID identifies this collection. Typically the same as the path.\"}\n </FieldCaption>\n </div>\n\n </div>\n\n {/* Advanced Settings */}\n {/* eslint-disable-next-line no-constant-condition */}\n {false ? <ExpandablePanel\n title={<Typography variant=\"subtitle2\">Advanced settings</Typography>}\n initiallyExpanded={false}\n className=\"mt-4\"\n innerClassName=\"p-4 flex flex-col gap-4\"\n >\n {/* HistoryIcon revisions */}\n <div>\n <BooleanSwitchWithLabel\n position={\"start\"}\n allowIndeterminate={true}\n label={<span className=\"flex items-center gap-2\"><HistoryIcon size={iconSize.smallest}/>{values.history === null || values.history === undefined ? \"Document history revisions enabled if enabled globally\" : (\n values.history ? \"Document history revisions ENABLED\" : \"Document history revisions NOT enabled\"\n )}</span>}\n onValueChange={(v) => setFieldValue(\"history\", v)}\n value={values.history ?? null}\n />\n <FieldCaption>\n When enabled, each document in this collection will have a history of changes.\n This is useful for auditing purposes. The data is stored in a subcollection of the document\n in your database, called <b>__history</b>.\n </FieldCaption>\n </div>\n\n </ExpandablePanel> : null}\n </fieldset>\n\n <div style={{ height: \"52px\" }}/>\n\n <Dialog\n open={iconDialogOpen}\n onOpenChange={setIconDialogOpen}\n maxWidth={\"xl\"}\n fullWidth\n >\n <div className={\"p-4 overflow-auto min-h-[200px]\"}>\n <SearchIconsView selectedIcon={typeof values.icon === \"string\" ? values.icon : undefined}\n onIconSelected={(icon: string) => {\n setIconDialogOpen(false);\n setFieldValue(\"icon\", icon);\n }}/>\n </div>\n </Dialog>\n\n {renderExtraCollectionFields && (\n <div className=\"mt-4\">\n {renderExtraCollectionFields({\n metadata: (values.metadata ?? {}) as Record<string, unknown>,\n onMetadataChange: (key: string, value: unknown) => {\n setFieldValue(`metadata.${key}`, value);\n },\n collection: toSerializableCollectionConfig(values),\n })}\n </div>\n )}\n\n </Container>\n </div>\n );\n}\n\nfunction DefaultDatabaseField({\n databaseId,\n disabled = false,\n onDatabaseIdUpdate\n}: { databaseId?: string, disabled?: boolean, onDatabaseIdUpdate: (databaseId: string) => void }) {\n\n const { t } = useTranslation();\n\n return <Tooltip title={t(\"database_id\")}\n side={\"top\"}\n align={\"start\"}>\n <TextField size={\"small\"}\n aria-label={t(\"database_id\")}\n invisible={true}\n inputClassName={\"text-end\"}\n disabled={disabled}\n value={databaseId ?? \"\"}\n onChange={(e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => onDatabaseIdUpdate(e.target.value)}\n placeholder={\"(default)\"}></TextField>\n </Tooltip>\n}\n"],"mappings":";;;;;;;;;;;AAgCA,SAAgB,oBAAoB,EAChC,iBACA,eACA,aACA,kBACA,6BACA,cAQD;CAEC,MAAM,EACF,QACA,eACA,cACA,SACA,QACA,iBACA,gBACA,UAAmC;CACvC,MAAM,EAAE,MAAM,eAAe;CAE7B,MAAM,CAAC,gBAAgB,qBAAqB,SAAS,KAAK;CAE1D,MAAM,8BAA8B,+BAA+B;CACnE,MAAM,mBAAmB,aAAa,EAAE,UAAU,MAAM,IAAI;CAE5D,MAAM,oBAAoB,eAAuB;EAC7C,cAAc,cAAc,cAAc,KAAA,CAAS;CACvD;CAEA,MAAM,cAAc,SAAiB;EACjC,cAAc,QAAQ,IAAI;EAG1B,IAAI,CADgB,MAAM,SAAS,OAC9B,KAAe,mBAAmB,MACnC,cAAc,SAAS,YAAY,IAAI,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AC3B,WAAW;GACX,gBAAgB;GACN;GACV,OAAO,cAAc;GACrB,WAAW,MAAiE,mBAAmB,EAAE,OAAO,KAAK;GAC7G,aAAa;EAAwB,CAAA;CACpC,CAAA;AACb"}
|
|
1
|
+
{"version":3,"file":"GeneralSettingsForm.js","names":[],"sources":["../../../../src/collection_editor/ui/collection_editor/GeneralSettingsForm.tsx"],"sourcesContent":["\nimport { IconForView, useTranslation } from \"@rebasepro/app\";\nimport { FieldCaption } from \"../../_cms_internals\";\nimport React, { useState } from \"react\";\n\nimport { SearchIconsView } from \"../../_cms_internals\";\n\nimport {\n BooleanSwitchWithLabel,\n Chip,\n cls,\n Container,\n DebouncedTextField,\n Dialog,\n ExpandablePanel,\n HistoryIcon,\n IconButton,\n iconSize,\n SearchIcon,\n Select,\n SelectItem,\n TextField,\n Tooltip,\n Typography\n} from \"@rebasepro/ui\";\nimport { Field, getIn, useFormex } from \"@rebasepro/forms\";\nimport { useCollectionsConfigController } from \"../../useCollectionsConfigController\";\nimport { singular, toSnakeCase } from \"@rebasepro/utils\";\nimport type { ExtraCollectionFieldsParams } from \"../../extensibility_types\";\nimport { toSerializableCollectionConfig } from \"../../serializable_utils\";\nimport type { AdminCollection, AdminPostgresCollection } from \"@rebasepro/cms-types\";\n\nexport function GeneralSettingsForm({\n isNewCollection,\n existingPaths,\n existingIds,\n parentCollection,\n renderExtraCollectionFields,\n standalone,\n}: {\n isNewCollection: boolean;\n existingPaths?: string[];\n existingIds?: string[];\n parentCollection?: AdminCollection;\n renderExtraCollectionFields?: (params: ExtraCollectionFieldsParams) => React.ReactNode;\n standalone?: boolean;\n}) {\n\n const {\n values,\n setFieldValue,\n handleChange,\n touched,\n errors,\n setFieldTouched,\n submitCount\n } = useFormex<AdminPostgresCollection>();\n const { t } = useTranslation();\n\n const [iconDialogOpen, setIconDialogOpen] = useState(false);\n\n const configControllerFromContext = useCollectionsConfigController();\n const configController = standalone ? { readOnly: false } : configControllerFromContext;\n\n const updateDatabaseId = (databaseId: string) => {\n setFieldValue(\"databaseId\", databaseId ?? undefined);\n }\n\n const updateName = (name: string) => {\n setFieldValue(\"name\", name);\n\n const pathTouched = getIn(touched, \"table\");\n if (!pathTouched && isNewCollection && name) {\n setFieldValue(\"table\", toSnakeCase(name));\n }\n\n const idTouched = getIn(touched, \"slug\");\n if (!idTouched && isNewCollection && name) {\n setFieldValue(\"slug\", toSnakeCase(name));\n }\n\n const singularNameTouched = getIn(touched, \"singularName\");\n if (!singularNameTouched && isNewCollection && name) {\n setFieldValue(\"singularName\", singular(name));\n }\n };\n\n const collectionIcon = <IconForView collectionOrView={values}/>;\n const isSubcollection = !!parentCollection;\n const showErrors = submitCount > 0;\n\n return (\n <div className={\"overflow-auto my-auto\"}>\n <Container maxWidth={\"4xl\"} className={\"flex flex-col gap-4 p-8 m-auto\"}>\n\n <div>\n <div className=\"flex flex-row gap-2 items-center\">\n <Typography variant={!isNewCollection ? \"h5\" : \"h4\"} className={\"flex-grow\"}>\n {isNewCollection ? \"New collection\" : `${values?.name} collection`}\n </Typography>\n <DefaultDatabaseField databaseId={values.databaseId}\n disabled={configController?.readOnly || !isNewCollection}\n onDatabaseIdUpdate={updateDatabaseId}/>\n\n <Tooltip title={t(\"change_icon\")}\n asChild={true}>\n <IconButton aria-label={t(\"change_icon\")}\n shape={\"square\"}\n disabled={configController?.readOnly}\n onClick={() => setIconDialogOpen(true)}>\n {collectionIcon}\n </IconButton>\n </Tooltip>\n </div>\n\n {parentCollection && <Chip colorScheme={\"teal\"}>\n <Typography variant={\"caption\"}>\n This is a subcollection of <b>{parentCollection.name}</b>\n </Typography>\n </Chip>}\n\n </div>\n\n <fieldset disabled={configController?.readOnly} className=\"contents\">\n <div className={\"grid grid-cols-12 gap-4\"}>\n\n {/* Name */}\n <div className={\"col-span-12\"}>\n <TextField\n value={values.name ?? \"\"}\n onChange={(e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => updateName(e.target.value)}\n label={\"Name\"}\n autoFocus={true}\n required\n error={showErrors && Boolean(errors.name)}/>\n <FieldCaption error={touched.name && Boolean(errors.name)}>\n {touched.name && Boolean(errors.name) ? errors.name : \"Name of this collection, usually a plural name (e.g. Products)\"}\n </FieldCaption>\n </div>\n\n {/* Table name — fixed once the collection exists, like its ID. The\n schema is only ever changed additively, so a new name\n here would create a new, empty table and leave every\n row in the old one. Moving a table is a migration. */}\n <div className={cls(\"col-span-12\")}>\n <Field name={\"table\"}\n as={DebouncedTextField}\n label={\"Table name\"}\n required\n disabled={!isNewCollection}\n error={showErrors && Boolean(errors.table)}/>\n\n <FieldCaption error={touched.table && Boolean(errors.table)}>\n {touched.table && Boolean(errors.table)\n ? errors.table\n : !isNewCollection ? t(\"schema_rename_is_a_migration\")\n : isSubcollection ? \"Relative path to the parent (no need to include the parent path)\" : \"PostgreSQL table name for this collection\"}\n </FieldCaption>\n </div>\n\n {/* Singular Name */}\n <div className={\"col-span-12\"}>\n <TextField\n error={showErrors && Boolean(errors.singularName)}\n name={\"singularName\"}\n aria-describedby={\"singularName-helper\"}\n onChange={(e) => {\n setFieldTouched(\"singularName\", true);\n return handleChange(e);\n }}\n value={values.singularName ?? \"\"}\n label={\"Singular name\"}/>\n <FieldCaption error={showErrors && Boolean(errors.singularName)}>\n {showErrors && Boolean(errors.singularName) ? errors.singularName : \"Optionally define a singular name for your entities\"}\n </FieldCaption>\n </div>\n\n {/* Description */}\n <div className={\"col-span-12\"}>\n <TextField\n error={showErrors && Boolean(errors.description)}\n name=\"description\"\n value={values.description ?? \"\"}\n onChange={handleChange}\n multiline\n minRows={2}\n aria-describedby=\"description-helper-text\"\n label=\"Description\"\n />\n <FieldCaption error={showErrors && Boolean(errors.description)}>\n {showErrors && Boolean(errors.description) ? errors.description : \"Description of the collection, you can use markdown\"}\n </FieldCaption>\n </div>\n\n {/* Collection ID */}\n <div className={\"col-span-12\"}>\n <DebouncedTextField\n name={\"slug\"}\n value={values.slug ?? \"\"}\n onChange={(e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => setFieldValue(\"slug\", e.target.value)}\n disabled={!isNewCollection}\n label={\"Collection ID\"}\n error={showErrors && Boolean(errors.slug)}/>\n <FieldCaption error={touched.slug && Boolean(errors.slug)}>\n {touched.slug && Boolean(errors.slug) ? errors.slug\n : !isNewCollection ? t(\"schema_rename_is_a_migration\")\n : \"This ID identifies this collection. Typically the same as the path.\"}\n </FieldCaption>\n </div>\n\n </div>\n\n {/* Advanced Settings */}\n {/* eslint-disable-next-line no-constant-condition */}\n {false ? <ExpandablePanel\n title={<Typography variant=\"subtitle2\">Advanced settings</Typography>}\n initiallyExpanded={false}\n className=\"mt-4\"\n innerClassName=\"p-4 flex flex-col gap-4\"\n >\n {/* HistoryIcon revisions */}\n <div>\n <BooleanSwitchWithLabel\n position={\"start\"}\n allowIndeterminate={true}\n label={<span className=\"flex items-center gap-2\"><HistoryIcon size={iconSize.smallest}/>{values.history === null || values.history === undefined ? \"Document history revisions enabled if enabled globally\" : (\n values.history ? \"Document history revisions ENABLED\" : \"Document history revisions NOT enabled\"\n )}</span>}\n onValueChange={(v) => setFieldValue(\"history\", v)}\n value={values.history ?? null}\n />\n <FieldCaption>\n When enabled, each document in this collection will have a history of changes.\n This is useful for auditing purposes. The data is stored in a subcollection of the document\n in your database, called <b>__history</b>.\n </FieldCaption>\n </div>\n\n </ExpandablePanel> : null}\n </fieldset>\n\n <div style={{ height: \"52px\" }}/>\n\n <Dialog\n open={iconDialogOpen}\n onOpenChange={setIconDialogOpen}\n maxWidth={\"xl\"}\n fullWidth\n >\n <div className={\"p-4 overflow-auto min-h-[200px]\"}>\n <SearchIconsView selectedIcon={typeof values.icon === \"string\" ? values.icon : undefined}\n onIconSelected={(icon: string) => {\n setIconDialogOpen(false);\n setFieldValue(\"icon\", icon);\n }}/>\n </div>\n </Dialog>\n\n {renderExtraCollectionFields && (\n <div className=\"mt-4\">\n {renderExtraCollectionFields({\n metadata: (values.metadata ?? {}) as Record<string, unknown>,\n onMetadataChange: (key: string, value: unknown) => {\n setFieldValue(`metadata.${key}`, value);\n },\n collection: toSerializableCollectionConfig(values),\n })}\n </div>\n )}\n\n </Container>\n </div>\n );\n}\n\nfunction DefaultDatabaseField({\n databaseId,\n disabled = false,\n onDatabaseIdUpdate\n}: { databaseId?: string, disabled?: boolean, onDatabaseIdUpdate: (databaseId: string) => void }) {\n\n const { t } = useTranslation();\n\n return <Tooltip title={t(\"database_id\")}\n side={\"top\"}\n align={\"start\"}>\n <TextField size={\"small\"}\n aria-label={t(\"database_id\")}\n invisible={true}\n inputClassName={\"text-end\"}\n disabled={disabled}\n value={databaseId ?? \"\"}\n onChange={(e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => onDatabaseIdUpdate(e.target.value)}\n placeholder={\"(default)\"}></TextField>\n </Tooltip>\n}\n"],"mappings":";;;;;;;;;;;AAgCA,SAAgB,oBAAoB,EAChC,iBACA,eACA,aACA,kBACA,6BACA,cAQD;CAEC,MAAM,EACF,QACA,eACA,cACA,SACA,QACA,iBACA,gBACA,UAAmC;CACvC,MAAM,EAAE,MAAM,eAAe;CAE7B,MAAM,CAAC,gBAAgB,qBAAqB,SAAS,KAAK;CAE1D,MAAM,8BAA8B,+BAA+B;CACnE,MAAM,mBAAmB,aAAa,EAAE,UAAU,MAAM,IAAI;CAE5D,MAAM,oBAAoB,eAAuB;EAC7C,cAAc,cAAc,cAAc,KAAA,CAAS;CACvD;CAEA,MAAM,cAAc,SAAiB;EACjC,cAAc,QAAQ,IAAI;EAG1B,IAAI,CADgB,MAAM,SAAS,OAC9B,KAAe,mBAAmB,MACnC,cAAc,SAAS,YAAY,IAAI,CAAC;EAI5C,IAAI,CADc,MAAM,SAAS,MAC5B,KAAa,mBAAmB,MACjC,cAAc,QAAQ,YAAY,IAAI,CAAC;EAI3C,IAAI,CADwB,MAAM,SAAS,cACtC,KAAuB,mBAAmB,MAC3C,cAAc,gBAAgB,SAAS,IAAI,CAAC;CAEpD;CAEA,MAAM,iBAAiB,oBAAC,aAAD,E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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KanbanConfigSection.js","names":[],"sources":["../../../../src/collection_editor/ui/collection_editor/KanbanConfigSection.tsx"],"sourcesContent":["\nimport { FieldCaption } from \"../../_cms_internals\";\nimport React, { useMemo, useRef, useState } from \"react\";\nimport { useAuthController, useCustomizationController, useTranslation } from \"@rebasepro/app\";\nimport { Property } from \"@rebasepro/types\";\nimport { PropertyConfigBadge } from \"../../../components/PropertyConfigBadge\";\nimport { getFieldConfig } from \"../../../components/field_configs\";\nimport { Button, IconButton, iconSize, Select, SelectItem, Typography, XIcon } from \"@rebasepro/ui\";\nimport { useFormex } from \"@rebasepro/forms\";\nimport { PropertyFormDialog } from \"./PropertyEditView\";\nimport { unslugify } from \"@rebasepro/utils\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\n\nexport function KanbanConfigSection({\n className,\n forceExpanded\n}: {\n className?: string;\n forceExpanded?: boolean;\n}) {\n const { t } = useTranslation();\n const authController = useAuthController();\n const customizationController = useCustomizationController();\n const { values, setFieldValue } = useFormex<AdminCollection>();\n const panelRef = useRef<HTMLDivElement>(null);\n const [columnPropertyDialogOpen, setColumnPropertyDialogOpen] = useState(false);\n\n // Get enum string properties (for columnProperty)\n const enumStringProperties = useMemo(() => {\n const result: { key: string; label: string; property: Property }[] = [];\n if (!values.properties) return result;\n\n Object.entries(values.properties).forEach(([key, prop]) => {\n if (prop && \"type\" in prop && prop.type === \"string\" && prop.enum) {\n result.push({\n key,\n label: (prop as Property).name || key,\n property: prop as Property\n });\n }\n });\n return result;\n }, [values.properties]);\n\n const kanbanConfig = values.kanban;\n\n // Check if columnProperty references a non-existent property\n const columnPropertyMissing = Boolean(kanbanConfig?.columnProperty) &&\n !enumStringProperties.some(p => p.key === kanbanConfig?.columnProperty);\n\n // Scroll to section when forceExpanded\n React.useEffect(() => {\n if (forceExpanded && panelRef.current) {\n setTimeout(() => {\n panelRef.current?.scrollIntoView({ behavior: \"smooth\",\nblock: \"center\" });\n }, 100);\n }\n }, [forceExpanded]);\n\n const showCreateButton = !kanbanConfig?.columnProperty || columnPropertyMissing;\n const dialogPropertyKey = columnPropertyMissing && kanbanConfig?.columnProperty\n ? kanbanConfig.columnProperty\n : \"status\";\n const dialogPropertyName = columnPropertyMissing && kanbanConfig?.columnProperty\n ? unslugify(kanbanConfig.columnProperty)\n : \"Status\";\n\n return (\n <div className={className} ref={panelRef}>\n <Select\n key={`column-select-${enumStringProperties.length}`}\n name=\"kanban.columnProperty\"\n label=\"Kanban Column Property\"\n fullWidth={true}\n position={\"item-aligned\"}\n disabled={enumStringProperties.length === 0}\n error={columnPropertyMissing}\n value={kanbanConfig?.columnProperty ?? \"\"}\n onValueChange={(v) => {\n if (v) {\n setFieldValue(\"kanban\", {\n ...kanbanConfig,\n columnProperty: v\n });\n } else {\n setFieldValue(\"kanban\", undefined);\n }\n }}\n renderValue={(value) => {\n if (columnPropertyMissing) {\n return <span className=\"text-red-500\">{value} (not found)</span>;\n }\n const prop = enumStringProperties.find(p => p.key === value);\n if (!prop) return \"Select a property\";\n const fieldConfig = getFieldConfig(prop.property, customizationController.propertyConfigs);\n return (\n <div className=\"flex items-center gap-2\">\n <PropertyConfigBadge propertyConfig={fieldConfig}/>\n <span>{prop.label}</span>\n </div>\n );\n }}\n endAdornment={kanbanConfig?.columnProperty ? (\n <IconButton aria-label={t(\"clear\")}\n size=\"small\"\n onClick={(e) => {\n e.stopPropagation();\n setFieldValue(\"kanban\", undefined);\n }}\n >\n <XIcon size={iconSize.smallest}/>\n </IconButton>\n ) : undefined}\n >\n {enumStringProperties.map((prop) => {\n const fieldConfig = getFieldConfig(prop.property, customizationController.propertyConfigs);\n return (\n <SelectItem key={prop.key} value={prop.key}>\n <div className=\"flex items-center gap-3\">\n <PropertyConfigBadge propertyConfig={fieldConfig}/>\n <div>\n <div>{prop.label}</div>\n <Typography variant=\"caption\" color=\"secondary\">\n {fieldConfig?.name || \"Enum\"}\n </Typography>\n </div>\n </div>\n </SelectItem>\n );\n })}\n </Select>\n <FieldCaption error={columnPropertyMissing}>\n {columnPropertyMissing\n ? `Property \"${kanbanConfig?.columnProperty}\" does not exist or is not an enum string property. Please select a valid property or clear the selection.`\n : enumStringProperties.length === 0\n ? \"No enum string properties found. Add a string property with enum to use Kanban view.\"\n : \"Select a string property with enum values to group entities into columns\"\n }\n </FieldCaption>\n\n {showCreateButton && (\n <>\n <Button\n variant=\"text\"\n size=\"small\"\n className=\"ml-3.5 mt-2\"\n onClick={() => setColumnPropertyDialogOpen(true)}\n >\n + Create "{dialogPropertyKey}" property\n </Button>\n <PropertyFormDialog\n open={columnPropertyDialogOpen}\n onCancel={() => setColumnPropertyDialogOpen(false)}\n property={{\n type: \"string\",\n name: dialogPropertyName,\n enum: [\n { id: \"todo\",\nlabel: \"To Do\" },\n { id: \"in_progress\",\nlabel: \"In Progress\" },\n { id: \"done\",\nlabel: \"Done\" }\n ]\n } as Property}\n propertyKey={dialogPropertyKey}\n existingProperty={false}\n autoOpenTypeSelect={false}\n autoUpdateId={false}\n inArray={false}\n allowDataInference={false}\n propertyConfigs={customizationController.propertyConfigs}\n\n existingPropertyKeys={Object.keys(values.properties ?? {})}\n onPropertyChanged={({ id, property }) => {\n const newProperties = {\n ...values.properties,\n [id!]: property\n };\n const newPropertiesOrder = [...(values.propertiesOrder ?? Object.keys(values.properties ?? {})), id];\n setFieldValue(\"properties\", newProperties);\n setFieldValue(\"propertiesOrder\", newPropertiesOrder);\n setFieldValue(\"kanban\", {\n ...kanbanConfig,\n columnProperty: id\n });\n setColumnPropertyDialogOpen(false);\n }}\n />\n </>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;AAaA,SAAgB,oBAAoB,EAChC,WACA,iBAID;CACC,MAAM,EAAE,MAAM,eAAe;CACN,kBAAkB;CACzC,MAAM,0BAA0B,2BAA2B;CAC3D,MAAM,EAAE,QAAQ,kBAAkB,UAA2B;CAC7D,MAAM,WAAW,OAAuB,IAAI;CAC5C,MAAM,CAAC,0BAA0B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IACN,gBAAgB,4BAA4B,KAAK;IACjD,UAAU;KACN,MAAM;KACN,MAAM;KACN,MAAM;MACF;OAAE,IAAI;OACtC,OAAO;MAAQ;MACiB;OAAE,IAAI;OACtC,OAAO;MAAc;MACW;OAAE,IAAI;OACtC,OAAO;MAAO;KACc;IACJ;IACA,aAAa;IACb,kBAAkB;IAClB,oBAAoB;IACpB,cAAc;IACd,SAAS;IACT,oBAAoB;IACpB,iBAAiB,wBAAwB;IAEzC,sBAAsB,OAAO,KAAK,OAAO,cAAc,CAAC,CAAC;IACzD,oBAAoB,EAAE,IAAI,eAAe;KACrC,MAAM,gBAAgB;MAClB,GAAG,OAAO;OACT,KAAM;KACX;KACA,MAAM,qBAAqB,CAAC,GAAI,OAAO,mBAAmB,OAAO,KAAK,OAAO,cAAc,CAAC,CAAC,GAAI,EAAE;KACnG,cAAc,cAAc,aAAa;KACzC,cAAc,mBAAmB,kBAAkB;KACnD,cAAc,UAAU;MACpB,GAAG;MACH,gBAAgB;KACpB,CAAC;KACD,4BAA4B,KAAK;IACrC;GACH,CAAA,CACH,EAAA,CAAA;EAEL;;AAEb"}
|
|
1
|
+
{"version":3,"file":"KanbanConfigSection.js","names":[],"sources":["../../../../src/collection_editor/ui/collection_editor/KanbanConfigSection.tsx"],"sourcesContent":["\nimport { FieldCaption } from \"../../_cms_internals\";\nimport React, { useMemo, useRef, useState } from \"react\";\nimport { useAuthController, useCustomizationController, useTranslation } from \"@rebasepro/app\";\nimport { Property } from \"@rebasepro/cms-types\";\nimport { PropertyConfigBadge } from \"../../../components/PropertyConfigBadge\";\nimport { getFieldConfig } from \"../../../components/field_configs\";\nimport { Button, IconButton, iconSize, Select, SelectItem, Typography, XIcon } from \"@rebasepro/ui\";\nimport { useFormex } from \"@rebasepro/forms\";\nimport { PropertyFormDialog } from \"./PropertyEditView\";\nimport { unslugify } from \"@rebasepro/utils\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\n\nexport function KanbanConfigSection({\n className,\n forceExpanded\n}: {\n className?: string;\n forceExpanded?: boolean;\n}) {\n const { t } = useTranslation();\n const authController = useAuthController();\n const customizationController = useCustomizationController();\n const { values, setFieldValue } = useFormex<AdminCollection>();\n const panelRef = useRef<HTMLDivElement>(null);\n const [columnPropertyDialogOpen, setColumnPropertyDialogOpen] = useState(false);\n\n // Get enum string properties (for columnProperty)\n const enumStringProperties = useMemo(() => {\n const result: { key: string; label: string; property: Property }[] = [];\n if (!values.properties) return result;\n\n Object.entries(values.properties).forEach(([key, prop]) => {\n if (prop && \"type\" in prop && prop.type === \"string\" && prop.enum) {\n result.push({\n key,\n label: (prop as Property).name || key,\n property: prop as Property\n });\n }\n });\n return result;\n }, [values.properties]);\n\n const kanbanConfig = values.kanban;\n\n // Check if columnProperty references a non-existent property\n const columnPropertyMissing = Boolean(kanbanConfig?.columnProperty) &&\n !enumStringProperties.some(p => p.key === kanbanConfig?.columnProperty);\n\n // Scroll to section when forceExpanded\n React.useEffect(() => {\n if (forceExpanded && panelRef.current) {\n setTimeout(() => {\n panelRef.current?.scrollIntoView({ behavior: \"smooth\",\nblock: \"center\" });\n }, 100);\n }\n }, [forceExpanded]);\n\n const showCreateButton = !kanbanConfig?.columnProperty || columnPropertyMissing;\n const dialogPropertyKey = columnPropertyMissing && kanbanConfig?.columnProperty\n ? kanbanConfig.columnProperty\n : \"status\";\n const dialogPropertyName = columnPropertyMissing && kanbanConfig?.columnProperty\n ? unslugify(kanbanConfig.columnProperty)\n : \"Status\";\n\n return (\n <div className={className} ref={panelRef}>\n <Select\n key={`column-select-${enumStringProperties.length}`}\n name=\"kanban.columnProperty\"\n label=\"Kanban Column Property\"\n fullWidth={true}\n position={\"item-aligned\"}\n disabled={enumStringProperties.length === 0}\n error={columnPropertyMissing}\n value={kanbanConfig?.columnProperty ?? \"\"}\n onValueChange={(v) => {\n if (v) {\n setFieldValue(\"kanban\", {\n ...kanbanConfig,\n columnProperty: v\n });\n } else {\n setFieldValue(\"kanban\", undefined);\n }\n }}\n renderValue={(value) => {\n if (columnPropertyMissing) {\n return <span className=\"text-red-500\">{value} (not found)</span>;\n }\n const prop = enumStringProperties.find(p => p.key === value);\n if (!prop) return \"Select a property\";\n const fieldConfig = getFieldConfig(prop.property, customizationController.propertyConfigs);\n return (\n <div className=\"flex items-center gap-2\">\n <PropertyConfigBadge propertyConfig={fieldConfig}/>\n <span>{prop.label}</span>\n </div>\n );\n }}\n endAdornment={kanbanConfig?.columnProperty ? (\n <IconButton aria-label={t(\"clear\")}\n size=\"small\"\n onClick={(e) => {\n e.stopPropagation();\n setFieldValue(\"kanban\", undefined);\n }}\n >\n <XIcon size={iconSize.smallest}/>\n </IconButton>\n ) : undefined}\n >\n {enumStringProperties.map((prop) => {\n const fieldConfig = getFieldConfig(prop.property, customizationController.propertyConfigs);\n return (\n <SelectItem key={prop.key} value={prop.key}>\n <div className=\"flex items-center gap-3\">\n <PropertyConfigBadge propertyConfig={fieldConfig}/>\n <div>\n <div>{prop.label}</div>\n <Typography variant=\"caption\" color=\"secondary\">\n {fieldConfig?.name || \"Enum\"}\n </Typography>\n </div>\n </div>\n </SelectItem>\n );\n })}\n </Select>\n <FieldCaption error={columnPropertyMissing}>\n {columnPropertyMissing\n ? `Property \"${kanbanConfig?.columnProperty}\" does not exist or is not an enum string property. Please select a valid property or clear the selection.`\n : enumStringProperties.length === 0\n ? \"No enum string properties found. Add a string property with enum to use Kanban view.\"\n : \"Select a string property with enum values to group entities into columns\"\n }\n </FieldCaption>\n\n {showCreateButton && (\n <>\n <Button\n variant=\"text\"\n size=\"small\"\n className=\"ml-3.5 mt-2\"\n onClick={() => setColumnPropertyDialogOpen(true)}\n >\n + Create "{dialogPropertyKey}" property\n </Button>\n <PropertyFormDialog\n open={columnPropertyDialogOpen}\n onCancel={() => setColumnPropertyDialogOpen(false)}\n property={{\n type: \"string\",\n name: dialogPropertyName,\n enum: [\n { id: \"todo\",\nlabel: \"To Do\" },\n { id: \"in_progress\",\nlabel: \"In Progress\" },\n { id: \"done\",\nlabel: \"Done\" }\n ]\n } as Property}\n propertyKey={dialogPropertyKey}\n existingProperty={false}\n autoOpenTypeSelect={false}\n autoUpdateId={false}\n inArray={false}\n allowDataInference={false}\n propertyConfigs={customizationController.propertyConfigs}\n\n existingPropertyKeys={Object.keys(values.properties ?? {})}\n onPropertyChanged={({ id, property }) => {\n const newProperties = {\n ...values.properties,\n [id!]: property\n };\n const newPropertiesOrder = [...(values.propertiesOrder ?? Object.keys(values.properties ?? {})), id];\n setFieldValue(\"properties\", newProperties);\n setFieldValue(\"propertiesOrder\", newPropertiesOrder);\n setFieldValue(\"kanban\", {\n ...kanbanConfig,\n columnProperty: id\n });\n setColumnPropertyDialogOpen(false);\n }}\n />\n </>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;AAaA,SAAgB,oBAAoB,EAChC,WACA,iBAID;CACC,MAAM,EAAE,MAAM,eAAe;CACN,kBAAkB;CACzC,MAAM,0BAA0B,2BAA2B;CAC3D,MAAM,EAAE,QAAQ,kBAAkB,UAA2B;CAC7D,MAAM,WAAW,OAAuB,IAAI;CAC5C,MAAM,CAAC,0BAA0B,+BAA+B,SAAS,KAAK;CAG9E,MAAM,uBAAuB,cAAc;EACvC,MAAM,SAA+D,CAAC;EACtE,IAAI,CAAC,OAAO,YAAY,OAAO;EAE/B,OAAO,QAAQ,OAAO,UAAU,CAAC,CAAC,SAAS,CAAC,KAAK,UAAU;GACvD,IAAI,QAAQ,UAAU,QAAQ,KAAK,SAAS,YAAY,KAAK,MACzD,OAAO,KAAK;IACR;IACA,OAAQ,KAAkB,QAAQ;IAClC,UAAU;GACd,CAAC;EAET,CAAC;EACD,OAAO;CACX,GAAG,CAAC,OAAO,UAAU,CAAC;CAEtB,MAAM,eAAe,OAAO;CAG5B,MAAM,wBAAwB,QAAQ,cAAc,cAAc,KAC9D,CAAC,qBAAqB,MAAK,MAAK,EAAE,QAAQ,cAAc,cAAc;CAG1E,MAAM,gBAAgB;EAClB,IAAI,iBAAiB,SAAS,SAC1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;KACzC,cAAc,mBAAmB,kBAAkB;KACnD,cAAc,UAAU;MACpB,GAAG;MACH,gBAAgB;KACpB,CAAC;KACD,4BAA4B,KAAK;IACrC;GACH,CAAA,CACH,EAAA,CAAA;EAEL;;AAEb"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { FormexController } from "@rebasepro/forms";
|
|
3
|
-
import { Property } from "@rebasepro/types";
|
|
4
|
-
import { PropertyConfig, AdminCollection } from "@rebasepro/cms-types";
|
|
3
|
+
import { PropertyConfig, AdminCollection, Property } from "@rebasepro/cms-types";
|
|
5
4
|
import type { PropertyTypePreset, PropertyType } from "../../extensibility_types.js";
|
|
6
5
|
import type { SerializableProperty, SerializableCollectionConfig } from "../../serializable_types.js";
|
|
7
6
|
export type PropertyWithId = Property & {
|
|
8
7
|
id?: string;
|
|
9
|
-
conditions?: import("@rebasepro/types").PropertyConditions;
|
|
8
|
+
conditions?: import("@rebasepro/cms-types").PropertyConditions;
|
|
10
9
|
};
|
|
11
10
|
export type OnPropertyChangedParams = {
|
|
12
11
|
id?: string;
|
|
@@ -25,7 +25,7 @@ import React, { useCallback, useDeferredValue, useEffect, useMemo, useRef, useSt
|
|
|
25
25
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
26
26
|
import { deepEqual } from "fast-equals";
|
|
27
27
|
import { AlertTriangleIcon, Button, Card, Dialog, DialogActions, DialogContent, DialogTitle, IconButton, InfoLabel, Tooltip, Trash2Icon, Typography, cls, iconSize } from "@rebasepro/ui";
|
|
28
|
-
import { isPropertyBuilder } from "@rebasepro/
|
|
28
|
+
import { isPropertyBuilder } from "@rebasepro/cms-types";
|
|
29
29
|
import { ConfirmationDialog, useTranslation } from "@rebasepro/app";
|
|
30
30
|
import { Formex, getIn, useCreateFormex } from "@rebasepro/forms";
|
|
31
31
|
import { isValidRegExp, mergeDeep } from "@rebasepro/utils";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PropertyEditView.js","names":[],"sources":["../../../../src/collection_editor/ui/collection_editor/PropertyEditView.tsx"],"sourcesContent":["\nimport React, { useCallback, useDeferredValue, useEffect, useMemo, useRef, useState } from \"react\";\nimport { deepEqual as equal } from \"fast-equals\"\n\nimport { Formex, FormexController, getIn, useCreateFormex } from \"@rebasepro/forms\";\nimport { ConfirmationDialog, useTranslation } from \"@rebasepro/app\";\nimport { DEFAULT_FIELD_CONFIGS, getFieldConfig, getFieldId } from \"../../../components/field_configs\";\nimport { PropertyConfigBadge } from \"../../../components/PropertyConfigBadge\";\nimport { Property } from \"@rebasepro/types\";\nimport { PropertyConfig, PropertyConfigId, AdminCollection } from \"@rebasepro/cms-types\";\nimport type { PropertyTypePreset, PropertyType } from \"../../extensibility_types\";\nimport { toSerializableProperty, toSerializableCollectionConfig } from \"../../serializable_utils\";\nimport type { SerializableProperty, SerializableCollectionConfig } from \"../../serializable_types\";\nimport { isPropertyBuilder } from \"@rebasepro/common\";\nimport {\n AlertTriangleIcon,\n Button,\n Card,\n cls,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n fieldBackgroundDisabledMixin,\n fieldBackgroundHoverMixin,\n fieldBackgroundMixin,\n IconButton,\n iconSize,\n InfoLabel,\n Tooltip,\n Trash2Icon,\n Typography\n} from \"@rebasepro/ui\";\nimport { EnumPropertyField } from \"./properties/EnumPropertyField\";\nimport { StoragePropertyField } from \"./properties/StoragePropertyField\";\nimport { MapPropertyField } from \"./properties/MapPropertyField\";\nimport { RepeatPropertyField } from \"./properties/RepeatPropertyField\";\nimport { CommonPropertyFields } from \"./properties/CommonPropertyFields\";\nimport { StringPropertyField } from \"./properties/StringPropertyField\";\nimport { BooleanPropertyField } from \"./properties/BooleanPropertyField\";\nimport { BlockPropertyField } from \"./properties/BlockPropertyField\";\nimport { NumberPropertyField } from \"./properties/NumberPropertyField\";\nimport { ReferencePropertyField } from \"./properties/ReferencePropertyField\";\nimport { DateTimePropertyField } from \"./properties/DateTimePropertyField\";\nimport { AdvancedPropertyValidation } from \"./properties/advanced/AdvancedPropertyValidation\";\nimport { VectorPropertyField } from \"./properties/VectorPropertyField\";\n\nimport { KeyValuePropertyField } from \"./properties/KeyValuePropertyField\";\nimport { RelationPropertyField } from \"./properties/RelationPropertyField\";\nimport { updatePropertyFromWidget } from \"./utils/update_property_for_widget\";\nimport { UrlPropertyField } from \"./properties/UrlPropertyField\";\nimport { supportedFields } from \"./utils/supported_fields\";\nimport { MarkdownPropertyField } from \"./properties/MarkdownPropertyField\";\nimport { isValidRegExp, mergeDeep } from \"@rebasepro/utils\";\n\nexport type PropertyWithId = Property & {\n id?: string;\n conditions?: import(\"@rebasepro/types\").PropertyConditions;\n};\n\nexport type OnPropertyChangedParams = {\n id?: string,\n property: Property,\n namespace?: string,\n previousId?: string\n};\n\nexport type PropertyFormProps = {\n includeIdAndName?: boolean;\n existingProperty: boolean;\n autoUpdateId?: boolean;\n autoOpenTypeSelect: boolean;\n inArray: boolean;\n propertyKey?: string;\n propertyNamespace?: string;\n property?: Property;\n onPropertyChanged?: (params: OnPropertyChangedParams) => void;\n onPropertyChangedImmediate?: boolean;\n onDismiss?: () => void;\n onDelete?: (id?: string, namespace?: string) => void;\n onError?: (id: string, namespace?: string, error?: Record<string, any>) => void;\n initialErrors?: Record<string, any>;\n existingPropertyKeys?: string[];\n forceShowErrors?: boolean;\n allowDataInference: boolean;\n getData?: () => Promise<object[]>;\n getController?: (formex: FormexController<PropertyWithId>) => void;\n propertyConfigs: Record<string, PropertyConfig>;\n propertyTypePresets?: PropertyTypePreset[];\n hiddenPropertyTypes?: PropertyType[];\n renderExtraPropertyFields?: (params: {\n metadata: Record<string, unknown>;\n onMetadataChange: (key: string, value: unknown) => void;\n property: SerializableProperty;\n collection: SerializableCollectionConfig;\n }) => React.ReactNode;\n collectionValues?: AdminCollection;\n\n};\n\nexport const PropertyForm = React.memo(\n function PropertyForm(props: PropertyFormProps) {\n\n const {\n includeIdAndName = true,\n autoOpenTypeSelect,\n existingProperty,\n autoUpdateId,\n inArray,\n propertyKey,\n existingPropertyKeys,\n propertyNamespace,\n property,\n onPropertyChanged,\n onPropertyChangedImmediate = true,\n onDismiss,\n onDelete,\n onError,\n initialErrors,\n forceShowErrors,\n allowDataInference,\n getController,\n getData,\n propertyConfigs,\n propertyTypePresets,\n hiddenPropertyTypes,\n renderExtraPropertyFields,\n collectionValues\n } = props;\n\n const initialValue: PropertyWithId = {\n id: \"\",\n name: \"\"\n } as PropertyWithId;\n\n const disabled = Boolean(property && isPropertyBuilder(property));\n\n const lastSubmittedProperty = useRef<OnPropertyChangedParams | undefined>(property ? {\n id: propertyKey,\n previousId: propertyKey,\n property\n } : undefined);\n\n const doOnPropertyChanged = ({\n id,\n property\n }: OnPropertyChangedParams) => {\n // A change of ID is a rename wherever this is applied as it is\n // typed: the property is written under the new key and the old one\n // is deleted. So an ID that is another property's, or not a valid\n // ID at all, is held back until it is one — applied, it would write\n // this property over the other, and the rename that followed would\n // start from a key this property never really had.\n if (includeIdAndName && id !== lastSubmittedProperty.current?.id && validateId(id, existingPropertyKeys)) {\n return;\n }\n const params = {\n id,\n previousId: lastSubmittedProperty.current?.id,\n property,\n namespace: propertyNamespace\n };\n lastSubmittedProperty.current = params;\n onPropertyChanged?.(params);\n };\n\n const formexController = useCreateFormex<PropertyWithId>({\n debugId: \"PROPERTY_FORM\",\n initialValues: property\n ? { id: propertyKey,\n...property } as PropertyWithId\n : initialValue,\n initialErrors,\n validateOnChange: true,\n validateOnInitialRender: true,\n onSubmit: (newPropertyWithId, controller) => {\n const {\n id,\n ...property\n } = newPropertyWithId;\n doOnPropertyChanged({\n id,\n property: property as Property\n });\n if (!existingProperty)\n controller.resetForm({ values: initialValue });\n },\n validation: (values) => {\n const errors: Record<string, any> = {};\n if (includeIdAndName) {\n if (!values.name) {\n errors.name = \"Required\";\n } else {\n const nameError = validateName(values.name);\n if (nameError)\n errors.name = nameError;\n }\n if (!values.id) {\n errors.id = \"Required\";\n } else {\n const idError = validateId(values.id, existingPropertyKeys);\n if (idError)\n errors.id = idError;\n }\n }\n\n if (values.type === \"string\") {\n if (values.validation?.matches && !isValidRegExp(values.validation?.matches.toString())) {\n errors.validation = {\n matches: \"Invalid regular expression\"\n }\n }\n }\n if (values.type === \"reference\" && !values.path) {\n errors.slug = \"You must specify a target collection for the field\";\n }\n if (values.type === \"vector\" && (!values.dimensions || isNaN(Number(values.dimensions)) || Number(values.dimensions) <= 0)) {\n errors.dimensions = \"Vector dimensions must be a positive number\";\n }\n if (values.propertyConfig === \"repeat\") {\n if (!(\"of\" in values) || !values.of) {\n errors.of = \"You need to specify a repeat field\";\n }\n }\n if (values.propertyConfig === \"block\") {\n if (!(\"oneOf\" in values) || !values.oneOf) {\n errors.oneOf = \"You need to specify the properties of this block\";\n }\n }\n return errors;\n }\n });\n\n useEffect(() => {\n getController?.(formexController);\n }, [formexController, getController]);\n\n return <Formex value={formexController}>\n <PropertyEditFormFields\n onPropertyChanged={onPropertyChangedImmediate\n ? doOnPropertyChanged\n : undefined}\n onDelete={onDelete}\n includeIdAndTitle={includeIdAndName}\n propertyNamespace={propertyNamespace}\n onError={onError}\n onDismiss={onDismiss}\n showErrors={forceShowErrors || formexController.submitCount > 0}\n existing={existingProperty}\n autoUpdateId={autoUpdateId}\n inArray={inArray}\n autoOpenTypeSelect={autoOpenTypeSelect}\n disabled={disabled}\n getData={getData}\n allowDataInference={allowDataInference}\n propertyConfigs={propertyConfigs}\n propertyTypePresets={propertyTypePresets}\n hiddenPropertyTypes={hiddenPropertyTypes}\n renderExtraPropertyFields={renderExtraPropertyFields}\n collectionValues={collectionValues}\n {...formexController}/>\n </Formex>;\n }, (a, b) =>\n a.getData === b.getData &&\n a.propertyKey === b.propertyKey &&\n a.propertyNamespace === b.propertyNamespace &&\n a.includeIdAndName === b.includeIdAndName &&\n a.autoOpenTypeSelect === b.autoOpenTypeSelect &&\n a.autoUpdateId === b.autoUpdateId &&\n a.existingPropertyKeys === b.existingPropertyKeys &&\n a.existingProperty === b.existingProperty\n);\n\nexport function PropertyFormDialog({\n open,\n onCancel,\n onOkClicked,\n onPropertyChanged,\n getData,\n ...formProps\n}: PropertyFormProps & {\n open?: boolean;\n onOkClicked?: () => void;\n onCancel?: () => void;\n}) {\n const formexRef = useRef<FormexController<PropertyWithId>>(undefined);\n const getController = (helpers: FormexController<PropertyWithId>) => {\n formexRef.current = helpers;\n };\n\n return <Dialog\n open={open ?? false}\n maxWidth={\"xl\"}\n fullWidth={true}\n >\n <form noValidate={true}\n autoComplete={\"off\"}\n onSubmit={(e) => {\n e.preventDefault();\n e.stopPropagation();\n formexRef.current?.handleSubmit(e)\n }}>\n <DialogTitle hidden>Property edit view</DialogTitle>\n <DialogContent>\n\n <PropertyForm {...formProps}\n onDismiss={onCancel}\n onPropertyChanged={(params) => {\n onPropertyChanged?.(params);\n onOkClicked?.();\n }}\n\n onPropertyChangedImmediate={false}\n getController={getController}\n getData={getData}\n />\n </DialogContent>\n\n <DialogActions>\n\n {onCancel && <Button\n variant={\"text\"}\n onClick={() => {\n onCancel();\n formexRef.current?.resetForm();\n }}>\n Cancel\n </Button>}\n\n <Button type={\"submit\"}>\n Ok\n </Button>\n </DialogActions>\n </form>\n </Dialog>;\n\n}\n\nfunction PropertyEditFormFields({\n values,\n errors,\n setValues,\n existing,\n autoUpdateId = false,\n autoOpenTypeSelect,\n includeIdAndTitle,\n onPropertyChanged,\n onDelete,\n propertyNamespace,\n onDismiss,\n onError,\n showErrors,\n disabled,\n inArray,\n getData,\n allowDataInference,\n propertyConfigs,\n propertyTypePresets,\n hiddenPropertyTypes,\n renderExtraPropertyFields,\n collectionValues\n}: {\n includeIdAndTitle?: boolean;\n existing: boolean;\n autoUpdateId?: boolean;\n autoOpenTypeSelect: boolean;\n propertyNamespace?: string;\n onDismiss?: () => void;\n onPropertyChanged?: (params: OnPropertyChangedParams) => void;\n onDelete?: (id?: string, namespace?: string) => void;\n onError?: (id: string, namespace?: string, error?: Record<string, any>) => void;\n showErrors: boolean;\n inArray: boolean;\n disabled: boolean;\n getData?: () => Promise<object[]>;\n allowDataInference: boolean;\n propertyConfigs: Record<string, PropertyConfig>;\n propertyTypePresets?: PropertyTypePreset[];\n hiddenPropertyTypes?: PropertyType[];\n renderExtraPropertyFields?: PropertyFormProps[\"renderExtraPropertyFields\"];\n collectionValues?: AdminCollection;\n\n} & FormexController<PropertyWithId>) {\n const { t } = useTranslation();\n\n const [selectOpen, setSelectOpen] = useState(autoOpenTypeSelect);\n const [deleteDialogOpen, setDeleteDialogOpen] = useState(false);\n const [selectedFieldConfigId, setSelectedFieldConfigId] = useState<string | undefined>(values?.type ? getFieldId(values) : undefined);\n\n const deferredValues = useDeferredValue(values);\n const nameFieldRef = useRef<HTMLInputElement>(null);\n\n const lastSubmittedProperty = useRef<object>(values);\n\n const selectedWidgetError = showErrors && getIn(errors, \"selectedWidget\");\n\n useEffect(() => {\n if (onPropertyChanged) {\n if ((!includeIdAndTitle || deferredValues.id)) {\n const {\n id,\n ...property\n } = deferredValues;\n if (!equal(deferredValues, lastSubmittedProperty.current)) {\n onPropertyChanged({\n id,\n property,\n namespace: propertyNamespace\n });\n lastSubmittedProperty.current = deferredValues;\n }\n }\n }\n }, [deferredValues, includeIdAndTitle, propertyNamespace]);\n\n useEffect(() => {\n if (values?.id && onError) {\n onError(values?.id, propertyNamespace, errors);\n }\n }, [errors, propertyNamespace, values?.id]);\n\n const onWidgetSelectChanged = (newSelectedWidgetId: PropertyConfigId) => {\n setSelectedFieldConfigId(newSelectedWidgetId);\n setValues(updatePropertyFromWidget(values, newSelectedWidgetId, propertyConfigs));\n // Ugly hack to autofocus the name field\n setTimeout(() => {\n nameFieldRef.current?.focus();\n }, 0);\n };\n\n const onPresetSelected = useCallback((preset: PropertyTypePreset) => {\n // Map baseType to the default widgetId\n const BASE_TYPE_TO_WIDGET: Record<string, string> = {\n \"string\": \"text_field\",\n \"number\": \"number_input\",\n \"boolean\": \"switch\",\n \"date\": \"date_time\",\n \"reference\": \"reference\",\n \"relation\": \"relation\",\n \"map\": \"group\",\n \"array\": \"repeat\",\n \"vector\": \"vector_input\",\n \"geopoint\": \"geopoint\",\n \"binary\": \"binary\"\n };\n const widgetId = BASE_TYPE_TO_WIDGET[preset.baseType] || \"text_field\";\n setSelectedFieldConfigId(widgetId);\n // Merge preset defaults into the property\n const updatedValues = updatePropertyFromWidget(values, widgetId, propertyConfigs);\n const mergedValues = { ...updatedValues,\n...preset.defaults,\npropertyConfig: widgetId };\n setValues(mergedValues as PropertyWithId);\n }, [values, propertyConfigs, setValues]);\n\n let childComponent;\n if (selectedFieldConfigId === \"text_field\" ||\n selectedFieldConfigId === \"multiline\" ||\n selectedFieldConfigId === \"user_select\" ||\n selectedFieldConfigId === \"email\") {\n childComponent =\n <StringPropertyField widgetId={selectedFieldConfigId}\n disabled={disabled}\n showErrors={showErrors}/>;\n } else if (selectedFieldConfigId === \"url\") {\n childComponent =\n <UrlPropertyField disabled={disabled}\n showErrors={showErrors}/>;\n } else if (selectedFieldConfigId === \"markdown\") {\n childComponent =\n <MarkdownPropertyField disabled={disabled}\n showErrors={showErrors}/>;\n } else if (selectedFieldConfigId === \"select\" ||\n selectedFieldConfigId === \"number_select\") {\n childComponent = <EnumPropertyField\n multiselect={false}\n allowDataInference={allowDataInference}\n updateIds={!existing}\n disabled={disabled}\n getData={getData}\n propertyNamespace={propertyNamespace}\n showErrors={showErrors}/>;\n } else if (selectedFieldConfigId === \"multi_select\" ||\n selectedFieldConfigId === \"multi_number_select\") {\n childComponent = <EnumPropertyField\n multiselect={true}\n updateIds={!existing}\n disabled={disabled}\n allowDataInference={allowDataInference}\n getData={getData}\n propertyNamespace={propertyNamespace}\n showErrors={showErrors}/>;\n } else if (selectedFieldConfigId === \"file_upload\") {\n childComponent =\n <StoragePropertyField existing={existing}\n multiple={false}\n disabled={disabled}/>;\n } else if (selectedFieldConfigId === \"multi_file_upload\") {\n childComponent =\n <StoragePropertyField existing={existing}\n multiple={true}\n disabled={disabled}/>;\n } else if (selectedFieldConfigId === \"switch\") {\n childComponent = <BooleanPropertyField disabled={disabled}/>;\n } else if (selectedFieldConfigId === \"number_input\") {\n childComponent = <NumberPropertyField disabled={disabled}/>;\n } else if (selectedFieldConfigId === \"group\") {\n childComponent =\n <MapPropertyField disabled={disabled} getData={getData} allowDataInference={allowDataInference}\n propertyConfigs={propertyConfigs}/>;\n } else if (selectedFieldConfigId === \"block\") {\n childComponent =\n <BlockPropertyField disabled={disabled} getData={getData} allowDataInference={allowDataInference}\n propertyConfigs={propertyConfigs}/>;\n } else if (selectedFieldConfigId === \"reference\") {\n childComponent =\n <ReferencePropertyField showErrors={showErrors}\n existing={existing}\n multiple={false}\n disabled={disabled}/>;\n } else if (selectedFieldConfigId === \"date_time\") {\n childComponent = <DateTimePropertyField disabled={disabled}/>;\n } else if (selectedFieldConfigId === \"multi_references\") {\n childComponent =\n <ReferencePropertyField showErrors={showErrors}\n existing={existing}\n multiple={true}\n disabled={disabled}/>;\n } else if (selectedFieldConfigId === \"repeat\") {\n childComponent =\n <RepeatPropertyField showErrors={showErrors}\n existing={existing}\n getData={getData}\n allowDataInference={allowDataInference}\n disabled={disabled}\n propertyConfigs={propertyConfigs}/>;\n } else if (selectedFieldConfigId === \"key_value\") {\n childComponent =\n <KeyValuePropertyField disabled={disabled}/>;\n } else if (selectedFieldConfigId === \"relation\") {\n childComponent =\n <RelationPropertyField\n showErrors={showErrors}\n disabled={disabled}/>;\n } else if (selectedFieldConfigId === \"vector_input\") {\n childComponent =\n <VectorPropertyField\n disabled={disabled}/>;\n } else if (selectedFieldConfigId === \"geopoint\" || selectedFieldConfigId === \"binary\") {\n // These two have nothing of their own to configure — a geopoint is a\n // latitude and a longitude, a binary value is base64 — so the shared\n // fields above are the whole editor. Said out loud, because a dialog\n // that just stops is indistinguishable from one that failed to load.\n childComponent = (\n <div className={\"col-span-12\"}>\n <Typography variant={\"body2\"} color={\"secondary\"}>\n {selectedFieldConfigId === \"geopoint\"\n ? \"A location is stored as a latitude and a longitude. There is nothing further to configure here.\"\n : \"Binary values are stored as base64. There is nothing further to configure here.\"}\n </Typography>\n </div>\n );\n } else {\n // No editor matched this widget. `geopoint` lands here every time: the\n // model defines the type, but the admin has no field binding for it, so\n // `getDefaultFieldId` falls off the end of its chain, logs to the\n // console and returns undefined.\n //\n // This used to render nothing — the dialog opened showing a name, a\n // description and no type-specific fields at all, which reads exactly\n // like a property that simply has no settings. Saying so out loud is\n // not support, but it is the difference between a gap and a bug.\n childComponent = (\n <div className={\"col-span-12\"}>\n <InfoLabel mode={\"warn\"}>\n {values?.type\n ? `Properties of type \"${values.type}\" have no editor in the admin panel yet. ` +\n \"The fields shown here are the ones every property shares — configure the rest in code.\"\n : \"This property has no type yet.\"}\n </InfoLabel>\n </div>\n );\n }\n\n return (\n <>\n {disabled && <InfoLabel mode={\"warn\"}>\n <Typography>This property can't be edited</Typography>\n <Typography variant={\"caption\"}>\n You may not have permission to\n edit it or it is defined in code and cannot be modified.\n </Typography>\n </InfoLabel>}\n\n <div className=\"flex mt-2 items-start justify-between\">\n <div className={\"w-full flex flex-col gap-2\"}>\n <WidgetSelectView\n initialProperty={values}\n value={selectedFieldConfigId as PropertyConfigId}\n onValueChange={(value) => onWidgetSelectChanged(value as PropertyConfigId)}\n open={selectOpen}\n onOpenChange={(open, hasValue) => {\n if (!hasValue) {\n onDismiss?.();\n }\n setSelectOpen(open);\n }}\n disabled={disabled}\n showError={Boolean(selectedWidgetError)}\n existing={existing}\n propertyConfigs={propertyConfigs}\n inArray={inArray}\n propertyTypePresets={propertyTypePresets}\n hiddenPropertyTypes={hiddenPropertyTypes}\n onPresetSelected={onPresetSelected}/>\n\n {!!selectedWidgetError &&\n <Typography variant=\"caption\"\n className={\"ml-3.5\"}\n color={\"error\"}>Required</Typography>}\n\n {/*<Typography variant=\"caption\" className={\"ml-3.5\"}>Define your own custom properties and*/}\n {/* components</Typography>*/}\n\n </div>\n\n {onDelete && values?.id &&\n <IconButton aria-label={t(\"delete\")}\n variant={\"ghost\"}\n className=\"mt-1 shrink-0\"\n disabled={disabled}\n onClick={() => setDeleteDialogOpen(true)}>\n <Trash2Icon size={iconSize.small}/>\n </IconButton>}\n </div>\n\n <div className={\"grid grid-cols-12 gap-y-8 mt-6 mb-8\"}>\n {includeIdAndTitle &&\n <CommonPropertyFields showErrors={showErrors}\n disabledId={existing}\n isNewProperty={!existing}\n disabled={disabled}\n autoUpdateId={autoUpdateId}\n ref={nameFieldRef}/>}\n\n {childComponent}\n\n {renderExtraPropertyFields && collectionValues && (\n <div className=\"col-span-12 mt-4 px-2\">\n {renderExtraPropertyFields({\n metadata: (values.metadata ?? {}),\n onMetadataChange: (key: string, value: unknown) => {\n const currentMetadata = (values.metadata ?? {});\n setValues({\n ...values,\n metadata: { ...currentMetadata,\n[key]: value }\n } as PropertyWithId);\n },\n property: toSerializableProperty(values as Property),\n collection: toSerializableCollectionConfig(collectionValues)\n })}\n </div>\n )}\n\n <div className={\"col-span-12\"}>\n <AdvancedPropertyValidation disabled={disabled}/>\n </div>\n </div>\n\n {onDelete &&\n <ConfirmationDialog open={deleteDialogOpen}\n onAccept={() => onDelete(values?.id, propertyNamespace)}\n onCancel={() => setDeleteDialogOpen(false)}\n title={<div>Delete this property?</div>}\n body={\n <div> This will <b>not delete any\n data</b>, only modify the\n collection.</div>\n }/>}\n\n </>\n );\n}\n\nconst idRegEx = /^[a-zA-Z_][a-zA-Z0-9_]*$/;\n\nfunction validateId(value?: string, existingPropertyKeys?: string[]) {\n\n let error;\n if (!value) {\n error = \"You must specify an id for the field\";\n }\n if (value && !value.match(idRegEx)) {\n error = \"The id can only contain letters, numbers and underscores (_), and not start with a number\";\n }\n if (value && existingPropertyKeys && existingPropertyKeys.includes(value)) {\n error = \"There is another field with this ID already\";\n }\n return error;\n}\n\nfunction validateName(value: string) {\n let error;\n if (!value) {\n error = \"You must specify a title for the field\";\n }\n return error;\n}\n\nconst WIDGET_TYPE_MAP: Record<PropertyConfigId, string> = {\n text_field: \"Text\",\n multiline: \"Text\",\n markdown: \"Text\",\n url: \"Text\",\n email: \"Text\",\n switch: \"Boolean\",\n user_select: \"Users\",\n select: \"Select\",\n multi_select: \"Select\",\n number_input: \"Number\",\n number_select: \"Select\",\n multi_number_select: \"Select\",\n file_upload: \"File\",\n multi_file_upload: \"File\",\n relation: \"Relation\",\n reference: \"Reference\",\n multi_references: \"Reference\",\n date_time: \"Date\",\n group: \"Group\",\n key_value: \"Group\",\n repeat: \"Array\",\n custom_array: \"Array\",\n block: \"Group\",\n vector_input: \"Number\",\n geopoint: \"Location\",\n binary: \"Binary\"\n};\n\nconst WIDGET_BASE_TYPE_MAP: Record<string, PropertyType> = {\n text_field: \"string\",\n multiline: \"string\",\n markdown: \"string\",\n url: \"string\",\n email: \"string\",\n select: \"string\",\n multi_select: \"string\",\n file_upload: \"string\",\n multi_file_upload: \"string\",\n user_select: \"string\",\n number_input: \"number\",\n number_select: \"number\",\n multi_number_select: \"number\",\n switch: \"boolean\",\n date_time: \"date\",\n reference: \"reference\",\n multi_references: \"reference\",\n relation: \"relation\",\n group: \"map\",\n key_value: \"map\",\n block: \"map\",\n repeat: \"array\",\n custom_array: \"array\",\n vector_input: \"vector\",\n geopoint: \"geopoint\",\n binary: \"binary\"\n};\n\nfunction WidgetSelectView({\n initialProperty,\n value,\n onValueChange,\n open,\n onOpenChange,\n disabled,\n showError,\n existing,\n propertyConfigs,\n inArray,\n propertyTypePresets,\n hiddenPropertyTypes,\n onPresetSelected\n}: {\n initialProperty?: PropertyWithId,\n value?: PropertyConfigId,\n onValueChange: (value: string) => void,\n showError: boolean,\n open: boolean,\n onOpenChange: (open: boolean, hasValue: boolean) => void,\n disabled: boolean,\n existing: boolean,\n propertyConfigs: Record<string, PropertyConfig>,\n inArray?: boolean,\n propertyTypePresets?: PropertyTypePreset[],\n hiddenPropertyTypes?: PropertyType[],\n onPresetSelected?: (preset: PropertyTypePreset) => void,\n}) {\n\n const allSupportedFields = Object.entries(supportedFields).concat(Object.entries(propertyConfigs));\n\n const filteredFields = hiddenPropertyTypes && !propertyTypePresets\n ? allSupportedFields.filter(([key]) => {\n const baseType = WIDGET_BASE_TYPE_MAP[key];\n return !baseType || !hiddenPropertyTypes.includes(baseType);\n })\n : allSupportedFields;\n\n const displayedWidgets = (inArray\n ? filteredFields.filter(([_, propertyConfig]) => !isPropertyBuilder(propertyConfig.property as Property) && (propertyConfig.property as Property)?.type !== \"array\")\n : filteredFields)\n .map(([key, propertyConfig]) => ({\n [key]: propertyConfig\n }))\n .reduce((a, b) => {\n return {\n ...a,\n ...b\n }\n }, {});\n\n const activePreset = useMemo(() => {\n if (!propertyTypePresets || !initialProperty) return undefined;\n return propertyTypePresets.find(p => p.detect?.(toSerializableProperty(initialProperty as Property)));\n }, [propertyTypePresets, initialProperty]);\n\n const key = value;\n const propertyConfig = key ? (DEFAULT_FIELD_CONFIGS[key] ?? propertyConfigs[key]) : undefined;\n const baseProperty = propertyConfig?.property;\n const baseFieldConfig = baseProperty && !isPropertyBuilder(baseProperty as Property) ? getFieldConfig(baseProperty as Property, propertyConfigs) : undefined;\n const computedFieldConfig = baseFieldConfig && propertyConfig ? mergeDeep(baseFieldConfig, propertyConfig) : propertyConfig;\n\n const groups: string[] = [...new Set(Object.keys(displayedWidgets).map(key => {\n const group = WIDGET_TYPE_MAP[key as PropertyConfigId];\n if (group) {\n return group;\n }\n return \"Custom/Other\"\n }))];\n\n return <>\n <div\n onClick={() => {\n if (!disabled) {\n onOpenChange(!open, Boolean(value));\n }\n }}\n className={cls(\n \"select-none rounded-md text-sm py-2 px-1 transition-colors duration-200\",\n !disabled && \"hover:bg-surface-hover cursor-pointer\",\n \"relative flex items-center mb-2\"\n )}>\n {!value && <em>Select a property widget</em>}\n {value && computedFieldConfig && <div\n className={cls(\n \"flex items-center\")}>\n <div className={\"mr-4\"}>\n <PropertyConfigBadge propertyConfig={computedFieldConfig}/>\n </div>\n <div className={\"flex flex-col items-start text-left\"}>\n <div className=\"font-semibold text-text-primary dark:text-text-primary-dark tracking-tight\">{computedFieldConfig.name}</div>\n <Typography variant={\"caption\"}\n className=\"text-text-secondary dark:text-text-secondary-dark mt-0.5\">\n {computedFieldConfig.description}\n </Typography>\n </div>\n </div>}\n </div>\n <Dialog open={open}\n onOpenChange={(open: boolean) => onOpenChange(open, Boolean(value))}\n maxWidth={\"4xl\"}>\n <DialogTitle>\n {propertyTypePresets ? \"Select a property type\" : \"Select a property widget\"}\n </DialogTitle>\n <DialogContent>\n {propertyTypePresets ? (\n <div className={\"grid grid-cols-1 md:grid-cols-2 gap-x-4 gap-y-2 mt-4\"}>\n {propertyTypePresets.map((preset) => (\n <Card\n key={preset.id}\n onClick={() => {\n onPresetSelected?.(preset);\n onOpenChange(false, true);\n }}\n className={cls(\n \"flex flex-row items-center px-4 py-2 m-1\",\n activePreset?.id === preset.id && \"ring-2 ring-primary\"\n )}>\n <div className={cls(\"flex flex-row items-center text-base min-h-[48px]\")}>\n {preset.icon && (\n <div className={\"mr-4 text-2xl\"}>\n {typeof preset.icon === \"string\" ? preset.icon : preset.icon}\n </div>\n )}\n <div>\n <Typography variant={\"label\"}>{preset.label}</Typography>\n </div>\n </div>\n </Card>\n ))}\n </div>\n ) : (\n <div>\n {groups.map(group => {\n return <div key={group} className={\"mt-4\"}>\n <Typography variant={\"label\"}>{group}</Typography>\n <div className={\"grid grid-cols-1 md:grid-cols-2 gap-x-4 gap-y-2 mt-4\"}>\n {Object.entries(displayedWidgets).map(([key, propertyConfig]) => {\n const groupKey = WIDGET_TYPE_MAP[key as PropertyConfigId];\n if (groupKey === group) {\n return <WidgetSelectViewItem\n key={key}\n initialProperty={initialProperty}\n onClick={() => {\n onValueChange(key);\n onOpenChange(false, true);\n }}\n propertyConfig={propertyConfig}\n existing={existing}/>;\n }\n return null;\n })}\n </div>\n </div>;\n })}\n {/*{displayedWidgets.map(([key, propertyConfig]) => {*/}\n {/* return <WidgetSelectViewItem*/}\n {/* key={key}*/}\n {/* initialProperty={initialProperty}*/}\n {/* onClick={() => {*/}\n {/* onValueChange(key);*/}\n {/* onOpenChange(false);*/}\n {/* }}*/}\n {/* propertyConfig={propertyConfig}*/}\n {/* existing={existing}/>;*/}\n {/*})}*/}\n </div>\n )}\n </DialogContent>\n </Dialog>\n </>;\n}\n\nexport interface PropertySelectItemProps {\n onClick?: () => void;\n initialProperty?: PropertyWithId;\n propertyConfig: PropertyConfig;\n existing: boolean;\n}\n\nexport function WidgetSelectViewItem({\n onClick,\n initialProperty,\n // optionDisabled,\n propertyConfig,\n existing\n}: PropertySelectItemProps) {\n const baseProperty = propertyConfig.property;\n const shouldWarnChangingtype = existing && !isPropertyBuilder(baseProperty as Property) && (baseProperty as Property).type !== initialProperty?.type;\n\n return <Card\n onClick={onClick}\n className={\"flex flex-row items-center px-4 py-2 m-1\"}>\n <div\n className={cls(\n \"flex flex-row items-center text-base min-h-[48px]\"\n )}>\n <div className={\"mr-8\"}>\n <PropertyConfigBadge propertyConfig={propertyConfig} disabled={shouldWarnChangingtype}/>\n </div>\n <div>\n <div className={\"flex flex-row gap-2 items-center\"}>\n {shouldWarnChangingtype && <Tooltip\n title={\"This widget uses a different data type than the initially selected widget. This can cause errors with existing data.\"}>\n <AlertTriangleIcon size={iconSize.smallest} className={\"w-4\"}/>\n </Tooltip>}\n <Typography\n variant={\"label\"}\n color={shouldWarnChangingtype ? \"secondary\" : undefined}>{propertyConfig.name}</Typography>\n </div>\n\n <Typography variant={\"caption\"}\n color={\"secondary\"}\n className={\"max-w-sm\"}>\n {propertyConfig.description}\n </Typography>\n\n </div>\n </div>\n </Card>\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoGA,IAAa,eAAe,MAAM,KAC9B,SAAS,aAAa,OAA0B;CAE5C,MAAM,EACF,mBAAmB,MACnB,oBACA,kBACA,cACA,SACA,aACA,sBACA,mBACA,UACA,mBACA,6BAA6B,MAC7B,WACA,UACA,SACA,eACA,iBACA,oBACA,eACA,SACA,iBACA,qBACA,qBACA,2BACA,qBACA;CAEJ,MA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B,OAAO;eACP,oBAAC,mBAAD;MAAmB,MAAM,SAAS;MAAU,WAAW;KAAO,CAAA;IACzD,CAAA,GACT,oBAAC,YAAD;KACI,SAAS;KACT,OAAO,yBAAyB,cAAc,KAAA;eAAY,eAAe;IAAiB,CAAA,CAC7F;OAEL,oBAAC,YAAD;IAAY,SAAS;IACjB,OAAO;IACP,WAAW;cACV,eAAe;GACR,CAAA,CAEX,EAAA,CAAA,CACJ;;CACH,CAAA;AACV"}
|
|
1
|
+
{"version":3,"file":"PropertyEditView.js","names":[],"sources":["../../../../src/collection_editor/ui/collection_editor/PropertyEditView.tsx"],"sourcesContent":["\nimport React, { useCallback, useDeferredValue, useEffect, useMemo, useRef, useState } from \"react\";\nimport { deepEqual as equal } from \"fast-equals\"\n\nimport { Formex, FormexController, getIn, useCreateFormex } from \"@rebasepro/forms\";\nimport { ConfirmationDialog, useTranslation } from \"@rebasepro/app\";\nimport { DEFAULT_FIELD_CONFIGS, getFieldConfig, getFieldId } from \"../../../components/field_configs\";\nimport { PropertyConfigBadge } from \"../../../components/PropertyConfigBadge\";\nimport { PropertyConfig, PropertyConfigId, AdminCollection, isPropertyBuilder, Property } from \"@rebasepro/cms-types\";\nimport type { PropertyTypePreset, PropertyType } from \"../../extensibility_types\";\nimport { toSerializableProperty, toSerializableCollectionConfig } from \"../../serializable_utils\";\nimport type { SerializableProperty, SerializableCollectionConfig } from \"../../serializable_types\";\nimport {\n AlertTriangleIcon,\n Button,\n Card,\n cls,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n fieldBackgroundDisabledMixin,\n fieldBackgroundHoverMixin,\n fieldBackgroundMixin,\n IconButton,\n iconSize,\n InfoLabel,\n Tooltip,\n Trash2Icon,\n Typography\n} from \"@rebasepro/ui\";\nimport { EnumPropertyField } from \"./properties/EnumPropertyField\";\nimport { StoragePropertyField } from \"./properties/StoragePropertyField\";\nimport { MapPropertyField } from \"./properties/MapPropertyField\";\nimport { RepeatPropertyField } from \"./properties/RepeatPropertyField\";\nimport { CommonPropertyFields } from \"./properties/CommonPropertyFields\";\nimport { StringPropertyField } from \"./properties/StringPropertyField\";\nimport { BooleanPropertyField } from \"./properties/BooleanPropertyField\";\nimport { BlockPropertyField } from \"./properties/BlockPropertyField\";\nimport { NumberPropertyField } from \"./properties/NumberPropertyField\";\nimport { ReferencePropertyField } from \"./properties/ReferencePropertyField\";\nimport { DateTimePropertyField } from \"./properties/DateTimePropertyField\";\nimport { AdvancedPropertyValidation } from \"./properties/advanced/AdvancedPropertyValidation\";\nimport { VectorPropertyField } from \"./properties/VectorPropertyField\";\n\nimport { KeyValuePropertyField } from \"./properties/KeyValuePropertyField\";\nimport { RelationPropertyField } from \"./properties/RelationPropertyField\";\nimport { updatePropertyFromWidget } from \"./utils/update_property_for_widget\";\nimport { UrlPropertyField } from \"./properties/UrlPropertyField\";\nimport { supportedFields } from \"./utils/supported_fields\";\nimport { MarkdownPropertyField } from \"./properties/MarkdownPropertyField\";\nimport { isValidRegExp, mergeDeep } from \"@rebasepro/utils\";\n\nexport type PropertyWithId = Property & {\n id?: string;\n conditions?: import(\"@rebasepro/cms-types\").PropertyConditions;\n};\n\nexport type OnPropertyChangedParams = {\n id?: string,\n property: Property,\n namespace?: string,\n previousId?: string\n};\n\nexport type PropertyFormProps = {\n includeIdAndName?: boolean;\n existingProperty: boolean;\n autoUpdateId?: boolean;\n autoOpenTypeSelect: boolean;\n inArray: boolean;\n propertyKey?: string;\n propertyNamespace?: string;\n property?: Property;\n onPropertyChanged?: (params: OnPropertyChangedParams) => void;\n onPropertyChangedImmediate?: boolean;\n onDismiss?: () => void;\n onDelete?: (id?: string, namespace?: string) => void;\n onError?: (id: string, namespace?: string, error?: Record<string, any>) => void;\n initialErrors?: Record<string, any>;\n existingPropertyKeys?: string[];\n forceShowErrors?: boolean;\n allowDataInference: boolean;\n getData?: () => Promise<object[]>;\n getController?: (formex: FormexController<PropertyWithId>) => void;\n propertyConfigs: Record<string, PropertyConfig>;\n propertyTypePresets?: PropertyTypePreset[];\n hiddenPropertyTypes?: PropertyType[];\n renderExtraPropertyFields?: (params: {\n metadata: Record<string, unknown>;\n onMetadataChange: (key: string, value: unknown) => void;\n property: SerializableProperty;\n collection: SerializableCollectionConfig;\n }) => React.ReactNode;\n collectionValues?: AdminCollection;\n\n};\n\nexport const PropertyForm = React.memo(\n function PropertyForm(props: PropertyFormProps) {\n\n const {\n includeIdAndName = true,\n autoOpenTypeSelect,\n existingProperty,\n autoUpdateId,\n inArray,\n propertyKey,\n existingPropertyKeys,\n propertyNamespace,\n property,\n onPropertyChanged,\n onPropertyChangedImmediate = true,\n onDismiss,\n onDelete,\n onError,\n initialErrors,\n forceShowErrors,\n allowDataInference,\n getController,\n getData,\n propertyConfigs,\n propertyTypePresets,\n hiddenPropertyTypes,\n renderExtraPropertyFields,\n collectionValues\n } = props;\n\n const initialValue: PropertyWithId = {\n id: \"\",\n name: \"\"\n } as PropertyWithId;\n\n const disabled = Boolean(property && isPropertyBuilder(property));\n\n const lastSubmittedProperty = useRef<OnPropertyChangedParams | undefined>(property ? {\n id: propertyKey,\n previousId: propertyKey,\n property\n } : undefined);\n\n const doOnPropertyChanged = ({\n id,\n property\n }: OnPropertyChangedParams) => {\n // A change of ID is a rename wherever this is applied as it is\n // typed: the property is written under the new key and the old one\n // is deleted. So an ID that is another property's, or not a valid\n // ID at all, is held back until it is one — applied, it would write\n // this property over the other, and the rename that followed would\n // start from a key this property never really had.\n if (includeIdAndName && id !== lastSubmittedProperty.current?.id && validateId(id, existingPropertyKeys)) {\n return;\n }\n const params = {\n id,\n previousId: lastSubmittedProperty.current?.id,\n property,\n namespace: propertyNamespace\n };\n lastSubmittedProperty.current = params;\n onPropertyChanged?.(params);\n };\n\n const formexController = useCreateFormex<PropertyWithId>({\n debugId: \"PROPERTY_FORM\",\n initialValues: property\n ? { id: propertyKey,\n...property } as PropertyWithId\n : initialValue,\n initialErrors,\n validateOnChange: true,\n validateOnInitialRender: true,\n onSubmit: (newPropertyWithId, controller) => {\n const {\n id,\n ...property\n } = newPropertyWithId;\n doOnPropertyChanged({\n id,\n property: property as Property\n });\n if (!existingProperty)\n controller.resetForm({ values: initialValue });\n },\n validation: (values) => {\n const errors: Record<string, any> = {};\n if (includeIdAndName) {\n if (!values.name) {\n errors.name = \"Required\";\n } else {\n const nameError = validateName(values.name);\n if (nameError)\n errors.name = nameError;\n }\n if (!values.id) {\n errors.id = \"Required\";\n } else {\n const idError = validateId(values.id, existingPropertyKeys);\n if (idError)\n errors.id = idError;\n }\n }\n\n if (values.type === \"string\") {\n if (values.validation?.matches && !isValidRegExp(values.validation?.matches.toString())) {\n errors.validation = {\n matches: \"Invalid regular expression\"\n }\n }\n }\n if (values.type === \"reference\" && !values.path) {\n errors.slug = \"You must specify a target collection for the field\";\n }\n if (values.type === \"vector\" && (!values.dimensions || isNaN(Number(values.dimensions)) || Number(values.dimensions) <= 0)) {\n errors.dimensions = \"Vector dimensions must be a positive number\";\n }\n if (values.propertyConfig === \"repeat\") {\n if (!(\"of\" in values) || !values.of) {\n errors.of = \"You need to specify a repeat field\";\n }\n }\n if (values.propertyConfig === \"block\") {\n if (!(\"oneOf\" in values) || !values.oneOf) {\n errors.oneOf = \"You need to specify the properties of this block\";\n }\n }\n return errors;\n }\n });\n\n useEffect(() => {\n getController?.(formexController);\n }, [formexController, getController]);\n\n return <Formex value={formexController}>\n <PropertyEditFormFields\n onPropertyChanged={onPropertyChangedImmediate\n ? doOnPropertyChanged\n : undefined}\n onDelete={onDelete}\n includeIdAndTitle={includeIdAndName}\n propertyNamespace={propertyNamespace}\n onError={onError}\n onDismiss={onDismiss}\n showErrors={forceShowErrors || formexController.submitCount > 0}\n existing={existingProperty}\n autoUpdateId={autoUpdateId}\n inArray={inArray}\n autoOpenTypeSelect={autoOpenTypeSelect}\n disabled={disabled}\n getData={getData}\n allowDataInference={allowDataInference}\n propertyConfigs={propertyConfigs}\n propertyTypePresets={propertyTypePresets}\n hiddenPropertyTypes={hiddenPropertyTypes}\n renderExtraPropertyFields={renderExtraPropertyFields}\n collectionValues={collectionValues}\n {...formexController}/>\n </Formex>;\n }, (a, b) =>\n a.getData === b.getData &&\n a.propertyKey === b.propertyKey &&\n a.propertyNamespace === b.propertyNamespace &&\n a.includeIdAndName === b.includeIdAndName &&\n a.autoOpenTypeSelect === b.autoOpenTypeSelect &&\n a.autoUpdateId === b.autoUpdateId &&\n a.existingPropertyKeys === b.existingPropertyKeys &&\n a.existingProperty === b.existingProperty\n);\n\nexport function PropertyFormDialog({\n open,\n onCancel,\n onOkClicked,\n onPropertyChanged,\n getData,\n ...formProps\n}: PropertyFormProps & {\n open?: boolean;\n onOkClicked?: () => void;\n onCancel?: () => void;\n}) {\n const formexRef = useRef<FormexController<PropertyWithId>>(undefined);\n const getController = (helpers: FormexController<PropertyWithId>) => {\n formexRef.current = helpers;\n };\n\n return <Dialog\n open={open ?? false}\n maxWidth={\"xl\"}\n fullWidth={true}\n >\n <form noValidate={true}\n autoComplete={\"off\"}\n onSubmit={(e) => {\n e.preventDefault();\n e.stopPropagation();\n formexRef.current?.handleSubmit(e)\n }}>\n <DialogTitle hidden>Property edit view</DialogTitle>\n <DialogContent>\n\n <PropertyForm {...formProps}\n onDismiss={onCancel}\n onPropertyChanged={(params) => {\n onPropertyChanged?.(params);\n onOkClicked?.();\n }}\n\n onPropertyChangedImmediate={false}\n getController={getController}\n getData={getData}\n />\n </DialogContent>\n\n <DialogActions>\n\n {onCancel && <Button\n variant={\"text\"}\n onClick={() => {\n onCancel();\n formexRef.current?.resetForm();\n }}>\n Cancel\n </Button>}\n\n <Button type={\"submit\"}>\n Ok\n </Button>\n </DialogActions>\n </form>\n </Dialog>;\n\n}\n\nfunction PropertyEditFormFields({\n values,\n errors,\n setValues,\n existing,\n autoUpdateId = false,\n autoOpenTypeSelect,\n includeIdAndTitle,\n onPropertyChanged,\n onDelete,\n propertyNamespace,\n onDismiss,\n onError,\n showErrors,\n disabled,\n inArray,\n getData,\n allowDataInference,\n propertyConfigs,\n propertyTypePresets,\n hiddenPropertyTypes,\n renderExtraPropertyFields,\n collectionValues\n}: {\n includeIdAndTitle?: boolean;\n existing: boolean;\n autoUpdateId?: boolean;\n autoOpenTypeSelect: boolean;\n propertyNamespace?: string;\n onDismiss?: () => void;\n onPropertyChanged?: (params: OnPropertyChangedParams) => void;\n onDelete?: (id?: string, namespace?: string) => void;\n onError?: (id: string, namespace?: string, error?: Record<string, any>) => void;\n showErrors: boolean;\n inArray: boolean;\n disabled: boolean;\n getData?: () => Promise<object[]>;\n allowDataInference: boolean;\n propertyConfigs: Record<string, PropertyConfig>;\n propertyTypePresets?: PropertyTypePreset[];\n hiddenPropertyTypes?: PropertyType[];\n renderExtraPropertyFields?: PropertyFormProps[\"renderExtraPropertyFields\"];\n collectionValues?: AdminCollection;\n\n} & FormexController<PropertyWithId>) {\n const { t } = useTranslation();\n\n const [selectOpen, setSelectOpen] = useState(autoOpenTypeSelect);\n const [deleteDialogOpen, setDeleteDialogOpen] = useState(false);\n const [selectedFieldConfigId, setSelectedFieldConfigId] = useState<string | undefined>(values?.type ? getFieldId(values) : undefined);\n\n const deferredValues = useDeferredValue(values);\n const nameFieldRef = useRef<HTMLInputElement>(null);\n\n const lastSubmittedProperty = useRef<object>(values);\n\n const selectedWidgetError = showErrors && getIn(errors, \"selectedWidget\");\n\n useEffect(() => {\n if (onPropertyChanged) {\n if ((!includeIdAndTitle || deferredValues.id)) {\n const {\n id,\n ...property\n } = deferredValues;\n if (!equal(deferredValues, lastSubmittedProperty.current)) {\n onPropertyChanged({\n id,\n property,\n namespace: propertyNamespace\n });\n lastSubmittedProperty.current = deferredValues;\n }\n }\n }\n }, [deferredValues, includeIdAndTitle, propertyNamespace]);\n\n useEffect(() => {\n if (values?.id && onError) {\n onError(values?.id, propertyNamespace, errors);\n }\n }, [errors, propertyNamespace, values?.id]);\n\n const onWidgetSelectChanged = (newSelectedWidgetId: PropertyConfigId) => {\n setSelectedFieldConfigId(newSelectedWidgetId);\n setValues(updatePropertyFromWidget(values, newSelectedWidgetId, propertyConfigs));\n // Ugly hack to autofocus the name field\n setTimeout(() => {\n nameFieldRef.current?.focus();\n }, 0);\n };\n\n const onPresetSelected = useCallback((preset: PropertyTypePreset) => {\n // Map baseType to the default widgetId\n const BASE_TYPE_TO_WIDGET: Record<string, string> = {\n \"string\": \"text_field\",\n \"number\": \"number_input\",\n \"boolean\": \"switch\",\n \"date\": \"date_time\",\n \"reference\": \"reference\",\n \"relation\": \"relation\",\n \"map\": \"group\",\n \"array\": \"repeat\",\n \"vector\": \"vector_input\",\n \"geopoint\": \"geopoint\",\n \"binary\": \"binary\"\n };\n const widgetId = BASE_TYPE_TO_WIDGET[preset.baseType] || \"text_field\";\n setSelectedFieldConfigId(widgetId);\n // Merge preset defaults into the property\n const updatedValues = updatePropertyFromWidget(values, widgetId, propertyConfigs);\n const mergedValues = { ...updatedValues,\n...preset.defaults,\npropertyConfig: widgetId };\n setValues(mergedValues as PropertyWithId);\n }, [values, propertyConfigs, setValues]);\n\n let childComponent;\n if (selectedFieldConfigId === \"text_field\" ||\n selectedFieldConfigId === \"multiline\" ||\n selectedFieldConfigId === \"user_select\" ||\n selectedFieldConfigId === \"email\") {\n childComponent =\n <StringPropertyField widgetId={selectedFieldConfigId}\n disabled={disabled}\n showErrors={showErrors}/>;\n } else if (selectedFieldConfigId === \"url\") {\n childComponent =\n <UrlPropertyField disabled={disabled}\n showErrors={showErrors}/>;\n } else if (selectedFieldConfigId === \"markdown\") {\n childComponent =\n <MarkdownPropertyField disabled={disabled}\n showErrors={showErrors}/>;\n } else if (selectedFieldConfigId === \"select\" ||\n selectedFieldConfigId === \"number_select\") {\n childComponent = <EnumPropertyField\n multiselect={false}\n allowDataInference={allowDataInference}\n updateIds={!existing}\n disabled={disabled}\n getData={getData}\n propertyNamespace={propertyNamespace}\n showErrors={showErrors}/>;\n } else if (selectedFieldConfigId === \"multi_select\" ||\n selectedFieldConfigId === \"multi_number_select\") {\n childComponent = <EnumPropertyField\n multiselect={true}\n updateIds={!existing}\n disabled={disabled}\n allowDataInference={allowDataInference}\n getData={getData}\n propertyNamespace={propertyNamespace}\n showErrors={showErrors}/>;\n } else if (selectedFieldConfigId === \"file_upload\") {\n childComponent =\n <StoragePropertyField existing={existing}\n multiple={false}\n disabled={disabled}/>;\n } else if (selectedFieldConfigId === \"multi_file_upload\") {\n childComponent =\n <StoragePropertyField existing={existing}\n multiple={true}\n disabled={disabled}/>;\n } else if (selectedFieldConfigId === \"switch\") {\n childComponent = <BooleanPropertyField disabled={disabled}/>;\n } else if (selectedFieldConfigId === \"number_input\") {\n childComponent = <NumberPropertyField disabled={disabled}/>;\n } else if (selectedFieldConfigId === \"group\") {\n childComponent =\n <MapPropertyField disabled={disabled} getData={getData} allowDataInference={allowDataInference}\n propertyConfigs={propertyConfigs}/>;\n } else if (selectedFieldConfigId === \"block\") {\n childComponent =\n <BlockPropertyField disabled={disabled} getData={getData} allowDataInference={allowDataInference}\n propertyConfigs={propertyConfigs}/>;\n } else if (selectedFieldConfigId === \"reference\") {\n childComponent =\n <ReferencePropertyField showErrors={showErrors}\n existing={existing}\n multiple={false}\n disabled={disabled}/>;\n } else if (selectedFieldConfigId === \"date_time\") {\n childComponent = <DateTimePropertyField disabled={disabled}/>;\n } else if (selectedFieldConfigId === \"multi_references\") {\n childComponent =\n <ReferencePropertyField showErrors={showErrors}\n existing={existing}\n multiple={true}\n disabled={disabled}/>;\n } else if (selectedFieldConfigId === \"repeat\") {\n childComponent =\n <RepeatPropertyField showErrors={showErrors}\n existing={existing}\n getData={getData}\n allowDataInference={allowDataInference}\n disabled={disabled}\n propertyConfigs={propertyConfigs}/>;\n } else if (selectedFieldConfigId === \"key_value\") {\n childComponent =\n <KeyValuePropertyField disabled={disabled}/>;\n } else if (selectedFieldConfigId === \"relation\") {\n childComponent =\n <RelationPropertyField\n showErrors={showErrors}\n disabled={disabled}/>;\n } else if (selectedFieldConfigId === \"vector_input\") {\n childComponent =\n <VectorPropertyField\n disabled={disabled}/>;\n } else if (selectedFieldConfigId === \"geopoint\" || selectedFieldConfigId === \"binary\") {\n // These two have nothing of their own to configure — a geopoint is a\n // latitude and a longitude, a binary value is base64 — so the shared\n // fields above are the whole editor. Said out loud, because a dialog\n // that just stops is indistinguishable from one that failed to load.\n childComponent = (\n <div className={\"col-span-12\"}>\n <Typography variant={\"body2\"} color={\"secondary\"}>\n {selectedFieldConfigId === \"geopoint\"\n ? \"A location is stored as a latitude and a longitude. There is nothing further to configure here.\"\n : \"Binary values are stored as base64. There is nothing further to configure here.\"}\n </Typography>\n </div>\n );\n } else {\n // No editor matched this widget. `geopoint` lands here every time: the\n // model defines the type, but the admin has no field binding for it, so\n // `getDefaultFieldId` falls off the end of its chain, logs to the\n // console and returns undefined.\n //\n // This used to render nothing — the dialog opened showing a name, a\n // description and no type-specific fields at all, which reads exactly\n // like a property that simply has no settings. Saying so out loud is\n // not support, but it is the difference between a gap and a bug.\n childComponent = (\n <div className={\"col-span-12\"}>\n <InfoLabel mode={\"warn\"}>\n {values?.type\n ? `Properties of type \"${values.type}\" have no editor in the admin panel yet. ` +\n \"The fields shown here are the ones every property shares — configure the rest in code.\"\n : \"This property has no type yet.\"}\n </InfoLabel>\n </div>\n );\n }\n\n return (\n <>\n {disabled && <InfoLabel mode={\"warn\"}>\n <Typography>This property can't be edited</Typography>\n <Typography variant={\"caption\"}>\n You may not have permission to\n edit it or it is defined in code and cannot be modified.\n </Typography>\n </InfoLabel>}\n\n <div className=\"flex mt-2 items-start justify-between\">\n <div className={\"w-full flex flex-col gap-2\"}>\n <WidgetSelectView\n initialProperty={values}\n value={selectedFieldConfigId as PropertyConfigId}\n onValueChange={(value) => onWidgetSelectChanged(value as PropertyConfigId)}\n open={selectOpen}\n onOpenChange={(open, hasValue) => {\n if (!hasValue) {\n onDismiss?.();\n }\n setSelectOpen(open);\n }}\n disabled={disabled}\n showError={Boolean(selectedWidgetError)}\n existing={existing}\n propertyConfigs={propertyConfigs}\n inArray={inArray}\n propertyTypePresets={propertyTypePresets}\n hiddenPropertyTypes={hiddenPropertyTypes}\n onPresetSelected={onPresetSelected}/>\n\n {!!selectedWidgetError &&\n <Typography variant=\"caption\"\n className={\"ml-3.5\"}\n color={\"error\"}>Required</Typography>}\n\n {/*<Typography variant=\"caption\" className={\"ml-3.5\"}>Define your own custom properties and*/}\n {/* components</Typography>*/}\n\n </div>\n\n {onDelete && values?.id &&\n <IconButton aria-label={t(\"delete\")}\n variant={\"ghost\"}\n className=\"mt-1 shrink-0\"\n disabled={disabled}\n onClick={() => setDeleteDialogOpen(true)}>\n <Trash2Icon size={iconSize.small}/>\n </IconButton>}\n </div>\n\n <div className={\"grid grid-cols-12 gap-y-8 mt-6 mb-8\"}>\n {includeIdAndTitle &&\n <CommonPropertyFields showErrors={showErrors}\n disabledId={existing}\n isNewProperty={!existing}\n disabled={disabled}\n autoUpdateId={autoUpdateId}\n ref={nameFieldRef}/>}\n\n {childComponent}\n\n {renderExtraPropertyFields && collectionValues && (\n <div className=\"col-span-12 mt-4 px-2\">\n {renderExtraPropertyFields({\n metadata: (values.metadata ?? {}),\n onMetadataChange: (key: string, value: unknown) => {\n const currentMetadata = (values.metadata ?? {});\n setValues({\n ...values,\n metadata: { ...currentMetadata,\n[key]: value }\n } as PropertyWithId);\n },\n property: toSerializableProperty(values as Property),\n collection: toSerializableCollectionConfig(collectionValues)\n })}\n </div>\n )}\n\n <div className={\"col-span-12\"}>\n <AdvancedPropertyValidation disabled={disabled}/>\n </div>\n </div>\n\n {onDelete &&\n <ConfirmationDialog open={deleteDialogOpen}\n onAccept={() => onDelete(values?.id, propertyNamespace)}\n onCancel={() => setDeleteDialogOpen(false)}\n title={<div>Delete this property?</div>}\n body={\n <div> This will <b>not delete any\n data</b>, only modify the\n collection.</div>\n }/>}\n\n </>\n );\n}\n\nconst idRegEx = /^[a-zA-Z_][a-zA-Z0-9_]*$/;\n\nfunction validateId(value?: string, existingPropertyKeys?: string[]) {\n\n let error;\n if (!value) {\n error = \"You must specify an id for the field\";\n }\n if (value && !value.match(idRegEx)) {\n error = \"The id can only contain letters, numbers and underscores (_), and not start with a number\";\n }\n if (value && existingPropertyKeys && existingPropertyKeys.includes(value)) {\n error = \"There is another field with this ID already\";\n }\n return error;\n}\n\nfunction validateName(value: string) {\n let error;\n if (!value) {\n error = \"You must specify a title for the field\";\n }\n return error;\n}\n\nconst WIDGET_TYPE_MAP: Record<PropertyConfigId, string> = {\n text_field: \"Text\",\n multiline: \"Text\",\n markdown: \"Text\",\n url: \"Text\",\n email: \"Text\",\n switch: \"Boolean\",\n user_select: \"Users\",\n select: \"Select\",\n multi_select: \"Select\",\n number_input: \"Number\",\n number_select: \"Select\",\n multi_number_select: \"Select\",\n file_upload: \"File\",\n multi_file_upload: \"File\",\n relation: \"Relation\",\n reference: \"Reference\",\n multi_references: \"Reference\",\n date_time: \"Date\",\n group: \"Group\",\n key_value: \"Group\",\n repeat: \"Array\",\n custom_array: \"Array\",\n block: \"Group\",\n vector_input: \"Number\",\n geopoint: \"Location\",\n binary: \"Binary\"\n};\n\nconst WIDGET_BASE_TYPE_MAP: Record<string, PropertyType> = {\n text_field: \"string\",\n multiline: \"string\",\n markdown: \"string\",\n url: \"string\",\n email: \"string\",\n select: \"string\",\n multi_select: \"string\",\n file_upload: \"string\",\n multi_file_upload: \"string\",\n user_select: \"string\",\n number_input: \"number\",\n number_select: \"number\",\n multi_number_select: \"number\",\n switch: \"boolean\",\n date_time: \"date\",\n reference: \"reference\",\n multi_references: \"reference\",\n relation: \"relation\",\n group: \"map\",\n key_value: \"map\",\n block: \"map\",\n repeat: \"array\",\n custom_array: \"array\",\n vector_input: \"vector\",\n geopoint: \"geopoint\",\n binary: \"binary\"\n};\n\nfunction WidgetSelectView({\n initialProperty,\n value,\n onValueChange,\n open,\n onOpenChange,\n disabled,\n showError,\n existing,\n propertyConfigs,\n inArray,\n propertyTypePresets,\n hiddenPropertyTypes,\n onPresetSelected\n}: {\n initialProperty?: PropertyWithId,\n value?: PropertyConfigId,\n onValueChange: (value: string) => void,\n showError: boolean,\n open: boolean,\n onOpenChange: (open: boolean, hasValue: boolean) => void,\n disabled: boolean,\n existing: boolean,\n propertyConfigs: Record<string, PropertyConfig>,\n inArray?: boolean,\n propertyTypePresets?: PropertyTypePreset[],\n hiddenPropertyTypes?: PropertyType[],\n onPresetSelected?: (preset: PropertyTypePreset) => void,\n}) {\n\n const allSupportedFields = Object.entries(supportedFields).concat(Object.entries(propertyConfigs));\n\n const filteredFields = hiddenPropertyTypes && !propertyTypePresets\n ? allSupportedFields.filter(([key]) => {\n const baseType = WIDGET_BASE_TYPE_MAP[key];\n return !baseType || !hiddenPropertyTypes.includes(baseType);\n })\n : allSupportedFields;\n\n const displayedWidgets = (inArray\n ? filteredFields.filter(([_, propertyConfig]) => !isPropertyBuilder(propertyConfig.property as Property) && (propertyConfig.property as Property)?.type !== \"array\")\n : filteredFields)\n .map(([key, propertyConfig]) => ({\n [key]: propertyConfig\n }))\n .reduce((a, b) => {\n return {\n ...a,\n ...b\n }\n }, {});\n\n const activePreset = useMemo(() => {\n if (!propertyTypePresets || !initialProperty) return undefined;\n return propertyTypePresets.find(p => p.detect?.(toSerializableProperty(initialProperty as Property)));\n }, [propertyTypePresets, initialProperty]);\n\n const key = value;\n const propertyConfig = key ? (DEFAULT_FIELD_CONFIGS[key] ?? propertyConfigs[key]) : undefined;\n const baseProperty = propertyConfig?.property;\n const baseFieldConfig = baseProperty && !isPropertyBuilder(baseProperty as Property) ? getFieldConfig(baseProperty as Property, propertyConfigs) : undefined;\n const computedFieldConfig = baseFieldConfig && propertyConfig ? mergeDeep(baseFieldConfig, propertyConfig) : propertyConfig;\n\n const groups: string[] = [...new Set(Object.keys(displayedWidgets).map(key => {\n const group = WIDGET_TYPE_MAP[key as PropertyConfigId];\n if (group) {\n return group;\n }\n return \"Custom/Other\"\n }))];\n\n return <>\n <div\n onClick={() => {\n if (!disabled) {\n onOpenChange(!open, Boolean(value));\n }\n }}\n className={cls(\n \"select-none rounded-md text-sm py-2 px-1 transition-colors duration-200\",\n !disabled && \"hover:bg-surface-hover cursor-pointer\",\n \"relative flex items-center mb-2\"\n )}>\n {!value && <em>Select a property widget</em>}\n {value && computedFieldConfig && <div\n className={cls(\n \"flex items-center\")}>\n <div className={\"mr-4\"}>\n <PropertyConfigBadge propertyConfig={computedFieldConfig}/>\n </div>\n <div className={\"flex flex-col items-start text-left\"}>\n <div className=\"font-semibold text-text-primary dark:text-text-primary-dark tracking-tight\">{computedFieldConfig.name}</div>\n <Typography variant={\"caption\"}\n className=\"text-text-secondary dark:text-text-secondary-dark mt-0.5\">\n {computedFieldConfig.description}\n </Typography>\n </div>\n </div>}\n </div>\n <Dialog open={open}\n onOpenChange={(open: boolean) => onOpenChange(open, Boolean(value))}\n maxWidth={\"4xl\"}>\n <DialogTitle>\n {propertyTypePresets ? \"Select a property type\" : \"Select a property widget\"}\n </DialogTitle>\n <DialogContent>\n {propertyTypePresets ? (\n <div className={\"grid grid-cols-1 md:grid-cols-2 gap-x-4 gap-y-2 mt-4\"}>\n {propertyTypePresets.map((preset) => (\n <Card\n key={preset.id}\n onClick={() => {\n onPresetSelected?.(preset);\n onOpenChange(false, true);\n }}\n className={cls(\n \"flex flex-row items-center px-4 py-2 m-1\",\n activePreset?.id === preset.id && \"ring-2 ring-primary\"\n )}>\n <div className={cls(\"flex flex-row items-center text-base min-h-[48px]\")}>\n {preset.icon && (\n <div className={\"mr-4 text-2xl\"}>\n {typeof preset.icon === \"string\" ? preset.icon : preset.icon}\n </div>\n )}\n <div>\n <Typography variant={\"label\"}>{preset.label}</Typography>\n </div>\n </div>\n </Card>\n ))}\n </div>\n ) : (\n <div>\n {groups.map(group => {\n return <div key={group} className={\"mt-4\"}>\n <Typography variant={\"label\"}>{group}</Typography>\n <div className={\"grid grid-cols-1 md:grid-cols-2 gap-x-4 gap-y-2 mt-4\"}>\n {Object.entries(displayedWidgets).map(([key, propertyConfig]) => {\n const groupKey = WIDGET_TYPE_MAP[key as PropertyConfigId];\n if (groupKey === group) {\n return <WidgetSelectViewItem\n key={key}\n initialProperty={initialProperty}\n onClick={() => {\n onValueChange(key);\n onOpenChange(false, true);\n }}\n propertyConfig={propertyConfig}\n existing={existing}/>;\n }\n return null;\n })}\n </div>\n </div>;\n })}\n {/*{displayedWidgets.map(([key, propertyConfig]) => {*/}\n {/* return <WidgetSelectViewItem*/}\n {/* key={key}*/}\n {/* initialProperty={initialProperty}*/}\n {/* onClick={() => {*/}\n {/* onValueChange(key);*/}\n {/* onOpenChange(false);*/}\n {/* }}*/}\n {/* propertyConfig={propertyConfig}*/}\n {/* existing={existing}/>;*/}\n {/*})}*/}\n </div>\n )}\n </DialogContent>\n </Dialog>\n </>;\n}\n\nexport interface PropertySelectItemProps {\n onClick?: () => void;\n initialProperty?: PropertyWithId;\n propertyConfig: PropertyConfig;\n existing: boolean;\n}\n\nexport function WidgetSelectViewItem({\n onClick,\n initialProperty,\n // optionDisabled,\n propertyConfig,\n existing\n}: PropertySelectItemProps) {\n const baseProperty = propertyConfig.property;\n const shouldWarnChangingtype = existing && !isPropertyBuilder(baseProperty as Property) && (baseProperty as Property).type !== initialProperty?.type;\n\n return <Card\n onClick={onClick}\n className={\"flex flex-row items-center px-4 py-2 m-1\"}>\n <div\n className={cls(\n \"flex flex-row items-center text-base min-h-[48px]\"\n )}>\n <div className={\"mr-8\"}>\n <PropertyConfigBadge propertyConfig={propertyConfig} disabled={shouldWarnChangingtype}/>\n </div>\n <div>\n <div className={\"flex flex-row gap-2 items-center\"}>\n {shouldWarnChangingtype && <Tooltip\n title={\"This widget uses a different data type than the initially selected widget. This can cause errors with existing data.\"}>\n <AlertTriangleIcon size={iconSize.smallest} className={\"w-4\"}/>\n </Tooltip>}\n <Typography\n variant={\"label\"}\n color={shouldWarnChangingtype ? \"secondary\" : undefined}>{propertyConfig.name}</Typography>\n </div>\n\n <Typography variant={\"caption\"}\n color={\"secondary\"}\n className={\"max-w-sm\"}>\n {propertyConfig.description}\n </Typography>\n\n </div>\n </div>\n </Card>\n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J,OAAO,oBAAC,MAAD;EACM;EACT,WAAW;YACX,qBAAC,OAAD;GACI,WAAW,IACP,mDACJ;aAHJ,CAII,oBAAC,OAAD;IAAK,WAAW;cACZ,oBAAC,qBAAD;KAAqC;KAAgB,UAAU;IAAwB,CAAA;GACtF,CAAA,GACL,qBAAC,OAAD,EAAA,UAAA,CACI,qBAAC,OAAD;IAAK,WAAW;cAAhB,CACK,0BAA0B,oBAAC,SAAD;KACvB,OAAO;eACP,oBAAC,mBAAD;MAAmB,MAAM,SAAS;MAAU,WAAW;KAAO,CAAA;IACzD,CAAA,GACT,oBAAC,YAAD;KACI,SAAS;KACT,OAAO,yBAAyB,cAAc,KAAA;eAAY,eAAe;IAAiB,CAAA,CAC7F;OAEL,oBAAC,YAAD;IAAY,SAAS;IACjB,OAAO;IACP,WAAW;cACV,eAAe;GACR,CAAA,CAEX,EAAA,CAAA,CACJ;;CACH,CAAA;AACV"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Property } from "@rebasepro/types";
|
|
1
|
+
import { Property } from "@rebasepro/cms-types";
|
|
2
2
|
export declare function PropertyFieldPreview({ property, propertyKey, onClick, hasError, includeName, includeEditButton, selected }: {
|
|
3
3
|
property: Property;
|
|
4
4
|
propertyKey?: string;
|
|
@@ -2,7 +2,7 @@ import { getFieldConfig } from "../../../components/field_configs.js";
|
|
|
2
2
|
import { PropertyConfigBadge } from "../../../components/PropertyConfigBadge.js";
|
|
3
3
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
4
|
import { ErrorBoundary, FunctionSquareIcon, MinusCircleIcon, Typography, cls, iconSize } from "@rebasepro/ui";
|
|
5
|
-
import { isPropertyBuilder } from "@rebasepro/
|
|
5
|
+
import { isPropertyBuilder } from "@rebasepro/cms-types";
|
|
6
6
|
import { useCustomizationController } from "@rebasepro/app";
|
|
7
7
|
//#region src/collection_editor/ui/collection_editor/PropertyFieldPreview.tsx
|
|
8
8
|
function PropertyFieldPreview({ property, propertyKey, onClick, hasError, includeName, includeEditButton, selected }) {
|