@rebasepro/cms 0.23.0 → 0.24.1-canary.g19596ef
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/collection_editor/CollectionEditorDialogsContext.js +10 -0
- package/dist/collection_editor/CollectionEditorDialogsContext.js.map +1 -0
- package/dist/collection_editor/ConfigControllerProvider.js +274 -0
- package/dist/collection_editor/ConfigControllerProvider.js.map +1 -0
- package/dist/collection_editor/_cms_internals.d.ts +2 -1
- package/dist/collection_editor/api/generateCollectionApi.js +64 -0
- package/dist/collection_editor/api/generateCollectionApi.js.map +1 -0
- package/dist/collection_editor/collection_wire.d.ts +13 -0
- package/dist/collection_editor/collection_wire.js +49 -0
- package/dist/collection_editor/collection_wire.js.map +1 -0
- package/dist/collection_editor/liveSchemaClient.d.ts +38 -18
- package/dist/collection_editor/liveSchemaClient.js +130 -0
- package/dist/collection_editor/liveSchemaClient.js.map +1 -0
- package/dist/collection_editor/relation_kinds.js +74 -0
- package/dist/collection_editor/relation_kinds.js.map +1 -0
- package/dist/collection_editor/serializable_types.d.ts +6 -1
- package/dist/collection_editor/serializable_utils.js +504 -0
- package/dist/collection_editor/serializable_utils.js.map +1 -0
- package/dist/collection_editor/types/config_controller.d.ts +11 -0
- package/dist/collection_editor/ui/EditorCollectionAction.js +37 -0
- package/dist/collection_editor/ui/EditorCollectionAction.js.map +1 -0
- package/dist/collection_editor/ui/MissingReferenceWidget.js +39 -0
- package/dist/collection_editor/ui/MissingReferenceWidget.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/AICollectionGeneratorPopover.js +160 -0
- package/dist/collection_editor/ui/collection_editor/AICollectionGeneratorPopover.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/AIModifiedPathsContext.js +61 -0
- package/dist/collection_editor/ui/collection_editor/AIModifiedPathsContext.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/CollectionEditorDialog.js +731 -0
- package/dist/collection_editor/ui/collection_editor/CollectionEditorDialog.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/CollectionEditorWelcomeView.js +220 -0
- package/dist/collection_editor/ui/collection_editor/CollectionEditorWelcomeView.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/CollectionJsonImportDialog.js +160 -0
- package/dist/collection_editor/ui/collection_editor/CollectionJsonImportDialog.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/CollectionPropertiesEditorForm.js +394 -0
- package/dist/collection_editor/ui/collection_editor/CollectionPropertiesEditorForm.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/CollectionRLSTab.js +616 -0
- package/dist/collection_editor/ui/collection_editor/CollectionRLSTab.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/CollectionStudioView.js +68 -0
- package/dist/collection_editor/ui/collection_editor/CollectionStudioView.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/CollectionYupValidation.js +11 -0
- package/dist/collection_editor/ui/collection_editor/CollectionYupValidation.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/CollectionsStudioView.js +148 -0
- package/dist/collection_editor/ui/collection_editor/CollectionsStudioView.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/DisplaySettingsForm.js +244 -0
- package/dist/collection_editor/ui/collection_editor/DisplaySettingsForm.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/EnumForm.js +222 -0
- package/dist/collection_editor/ui/collection_editor/EnumForm.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/GeneralSettingsForm.js +204 -0
- package/dist/collection_editor/ui/collection_editor/GeneralSettingsForm.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/GetCodeDialog.js +108 -0
- package/dist/collection_editor/ui/collection_editor/GetCodeDialog.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/KanbanConfigSection.js +163 -0
- package/dist/collection_editor/ui/collection_editor/KanbanConfigSection.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/LayoutModeSwitch.js +59 -0
- package/dist/collection_editor/ui/collection_editor/LayoutModeSwitch.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/PropertyEditView.js +640 -0
- package/dist/collection_editor/ui/collection_editor/PropertyEditView.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/PropertyFieldPreview.js +141 -0
- package/dist/collection_editor/ui/collection_editor/PropertyFieldPreview.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/PropertyTree.js +210 -0
- package/dist/collection_editor/ui/collection_editor/PropertyTree.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/RouterCollectionStudioView.js +31 -0
- package/dist/collection_editor/ui/collection_editor/RouterCollectionStudioView.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/RouterCollectionsStudioView.js +25 -0
- package/dist/collection_editor/ui/collection_editor/RouterCollectionsStudioView.js.map +1 -0
- package/dist/{SchemaChangeDialog-BeP0A4MJ.js → collection_editor/ui/collection_editor/SchemaChangeDialog.js} +73 -69
- package/dist/collection_editor/ui/collection_editor/SchemaChangeDialog.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/SwitchControl.js +24 -0
- package/dist/collection_editor/ui/collection_editor/SwitchControl.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/ViewModeSwitch.js +66 -0
- package/dist/collection_editor/ui/collection_editor/ViewModeSwitch.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.js +61 -0
- package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportMapping.js +188 -0
- package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportMapping.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/import/clean_import_data.d.ts +12 -0
- package/dist/collection_editor/ui/collection_editor/import/clean_import_data.js +74 -0
- package/dist/collection_editor/ui/collection_editor/import/clean_import_data.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/BlockPropertyField.js +100 -0
- package/dist/collection_editor/ui/collection_editor/properties/BlockPropertyField.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/BooleanPropertyField.js +34 -0
- package/dist/collection_editor/ui/collection_editor/properties/BooleanPropertyField.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/CommonPropertyFields.js +75 -0
- package/dist/collection_editor/ui/collection_editor/properties/CommonPropertyFields.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/DateTimePropertyField.js +338 -0
- package/dist/collection_editor/ui/collection_editor/properties/DateTimePropertyField.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/EnumPropertyField.js +83 -0
- package/dist/collection_editor/ui/collection_editor/properties/EnumPropertyField.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/KeyValuePropertyField.js +15 -0
- package/dist/collection_editor/ui/collection_editor/properties/KeyValuePropertyField.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/MapPropertyField.js +121 -0
- package/dist/collection_editor/ui/collection_editor/properties/MapPropertyField.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/MarkdownPropertyField.js +127 -0
- package/dist/collection_editor/ui/collection_editor/properties/MarkdownPropertyField.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/NumberPropertyField.js +151 -0
- package/dist/collection_editor/ui/collection_editor/properties/NumberPropertyField.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/ReferencePropertyField.js +77 -0
- package/dist/collection_editor/ui/collection_editor/properties/ReferencePropertyField.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/RelationPropertyField.js +254 -0
- package/dist/collection_editor/ui/collection_editor/properties/RelationPropertyField.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/RepeatPropertyField.js +71 -0
- package/dist/collection_editor/ui/collection_editor/properties/RepeatPropertyField.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/StoragePropertyField.js +356 -0
- package/dist/collection_editor/ui/collection_editor/properties/StoragePropertyField.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/StringPropertyField.js +173 -0
- package/dist/collection_editor/ui/collection_editor/properties/StringPropertyField.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/UrlPropertyField.js +79 -0
- package/dist/collection_editor/ui/collection_editor/properties/UrlPropertyField.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/VectorPropertyField.js +34 -0
- package/dist/collection_editor/ui/collection_editor/properties/VectorPropertyField.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/advanced/AdvancedPropertyValidation.js +47 -0
- package/dist/collection_editor/ui/collection_editor/properties/advanced/AdvancedPropertyValidation.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/validation/ArrayPropertyValidation.js +47 -0
- package/dist/collection_editor/ui/collection_editor/properties/validation/ArrayPropertyValidation.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/validation/GeneralPropertyValidation.js +62 -0
- package/dist/collection_editor/ui/collection_editor/properties/validation/GeneralPropertyValidation.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/validation/NumberPropertyValidation.js +119 -0
- package/dist/collection_editor/ui/collection_editor/properties/validation/NumberPropertyValidation.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/validation/StringPropertyValidation.d.ts +10 -0
- package/dist/collection_editor/ui/collection_editor/properties/validation/StringPropertyValidation.js +178 -0
- package/dist/collection_editor/ui/collection_editor/properties/validation/StringPropertyValidation.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/validation/ValidationPanel.js +23 -0
- package/dist/collection_editor/ui/collection_editor/properties/validation/ValidationPanel.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/templates/blog_template.js +116 -0
- package/dist/collection_editor/ui/collection_editor/templates/blog_template.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/templates/pages_template.js +182 -0
- package/dist/collection_editor/ui/collection_editor/templates/pages_template.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/templates/products_template.js +87 -0
- package/dist/collection_editor/ui/collection_editor/templates/products_template.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/templates/users_template.js +46 -0
- package/dist/collection_editor/ui/collection_editor/templates/users_template.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/util.js +20 -0
- package/dist/collection_editor/ui/collection_editor/util.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/utils/strings.js +2 -0
- package/dist/collection_editor/ui/collection_editor/utils/supported_fields.js +37 -0
- package/dist/collection_editor/ui/collection_editor/utils/supported_fields.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/utils/update_property_for_widget.js +192 -0
- package/dist/collection_editor/ui/collection_editor/utils/update_property_for_widget.js.map +1 -0
- package/dist/collection_editor/useCollectionEditorController.js +12 -0
- package/dist/collection_editor/useCollectionEditorController.js.map +1 -0
- package/dist/collection_editor/useCollectionsConfigController.js +12 -0
- package/dist/collection_editor/useCollectionsConfigController.js.map +1 -0
- package/dist/collection_editor/useJsonCollectionsConfigController.js +191 -0
- package/dist/collection_editor/useJsonCollectionsConfigController.js.map +1 -0
- package/dist/collection_editor/useLiveSchemaEditing.d.ts +5 -5
- package/dist/collection_editor/useLiveSchemaEditing.js +214 -0
- package/dist/collection_editor/useLiveSchemaEditing.js.map +1 -0
- package/dist/collection_editor/useLocalCollectionsConfigController.d.ts +7 -0
- package/dist/collection_editor/useLocalCollectionsConfigController.js +228 -0
- package/dist/collection_editor/useLocalCollectionsConfigController.js.map +1 -0
- package/dist/collection_editor/useSafeSnackbarController.js +13 -0
- package/dist/collection_editor/useSafeSnackbarController.js.map +1 -0
- package/dist/collection_editor/validateCollectionJson.js +289 -0
- package/dist/collection_editor/validateCollectionJson.js.map +1 -0
- package/dist/collection_editor_ui.js +7 -33
- package/dist/components/AdditionalFieldValue.js +60 -0
- package/dist/components/AdditionalFieldValue.js.map +1 -0
- package/dist/components/AdminModeSyncer.js +41 -0
- package/dist/components/AdminModeSyncer.js.map +1 -0
- package/dist/components/ArrayContainer.d.ts +8 -2
- package/dist/components/ArrayContainer.js +363 -0
- package/dist/components/ArrayContainer.js.map +1 -0
- package/dist/components/ClearFilterSortButton.d.ts +7 -1
- package/dist/components/ClearFilterSortButton.js +33 -0
- package/dist/components/ClearFilterSortButton.js.map +1 -0
- package/dist/components/CollectionEditorDialogs.js +49 -0
- package/dist/components/CollectionEditorDialogs.js.map +1 -0
- package/dist/components/CollectionPanel.d.ts +26 -5
- package/dist/components/CollectionPanel.js +142 -0
- package/dist/components/CollectionPanel.js.map +1 -0
- package/dist/components/CollectionTableBinding/CollectionRowActions.js +165 -0
- package/dist/components/CollectionTableBinding/CollectionRowActions.js.map +1 -0
- package/dist/components/CollectionTableBinding/CollectionTableBinding.js +329 -0
- package/dist/components/CollectionTableBinding/CollectionTableBinding.js.map +1 -0
- package/dist/components/CollectionTableBinding/PropertyTableCell.js +311 -0
- package/dist/components/CollectionTableBinding/PropertyTableCell.js.map +1 -0
- package/dist/components/CollectionTableBinding/column_utils.js +85 -0
- package/dist/components/CollectionTableBinding/column_utils.js.map +1 -0
- package/dist/components/CollectionTableBinding/fields/CompactEntityCellField.js +45 -0
- package/dist/components/CollectionTableBinding/fields/CompactEntityCellField.js.map +1 -0
- package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.js +66 -0
- package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.js.map +1 -0
- package/dist/components/CollectionTableBinding/fields/TableReferenceField.js +86 -0
- package/dist/components/CollectionTableBinding/fields/TableReferenceField.js.map +1 -0
- package/dist/components/CollectionTableBinding/fields/TableRelationField.js +93 -0
- package/dist/components/CollectionTableBinding/fields/TableRelationField.js.map +1 -0
- package/dist/components/CollectionTableBinding/fields/TableRelationSelectorField.js +33 -0
- package/dist/components/CollectionTableBinding/fields/TableRelationSelectorField.js.map +1 -0
- package/dist/components/CollectionTableBinding/fields/TableStorageUpload.js +171 -0
- package/dist/components/CollectionTableBinding/fields/TableStorageUpload.js.map +1 -0
- package/dist/components/CollectionTableBinding/fields/VirtualTableSelect.js +91 -0
- package/dist/components/CollectionTableBinding/fields/VirtualTableSelect.js.map +1 -0
- package/dist/components/CollectionTableBinding/fields/VirtualTableUserSelect.js +36 -0
- package/dist/components/CollectionTableBinding/fields/VirtualTableUserSelect.js.map +1 -0
- package/dist/components/CollectionTableBinding/index.js +6 -0
- package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.js +50 -0
- package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.js.map +1 -0
- package/dist/components/CollectionTableBinding/internal/EntityTableCell.d.ts +2 -0
- package/dist/components/CollectionTableBinding/internal/EntityTableCell.js +223 -0
- package/dist/components/CollectionTableBinding/internal/EntityTableCell.js.map +1 -0
- package/dist/components/CollectionTableBinding/internal/EntityTableCellActions.js +58 -0
- package/dist/components/CollectionTableBinding/internal/EntityTableCellActions.js.map +1 -0
- package/dist/components/CollectionTableBinding/internal/TableCellOpener.js +53 -0
- package/dist/components/CollectionTableBinding/internal/TableCellOpener.js.map +1 -0
- package/dist/components/CollectionTableBinding/internal/common.js +40 -0
- package/dist/components/CollectionTableBinding/internal/common.js.map +1 -0
- package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js +270 -0
- package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js.map +1 -0
- package/dist/components/CollectionTableBinding/internal/popup_field/useDraggable.js +68 -0
- package/dist/components/CollectionTableBinding/internal/popup_field/useDraggable.js.map +1 -0
- package/dist/components/CollectionTableBinding/internal/popup_field/useWindowSize.js +24 -0
- package/dist/components/CollectionTableBinding/internal/popup_field/useWindowSize.js.map +1 -0
- package/dist/components/CollectionTableBinding/table_bindings.js +306 -0
- package/dist/components/CollectionTableBinding/table_bindings.js.map +1 -0
- package/dist/components/CollectionViewBinding/BoardCardBinding.js +160 -0
- package/dist/components/CollectionViewBinding/BoardCardBinding.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.js +471 -0
- package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionCardViewBinding.js +108 -0
- package/dist/components/CollectionViewBinding/CollectionCardViewBinding.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionListViewBinding.js +988 -0
- package/dist/components/CollectionViewBinding/CollectionListViewBinding.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionViewActions.d.ts +6 -1
- package/dist/components/CollectionViewBinding/CollectionViewActions.js +146 -0
- package/dist/components/CollectionViewBinding/CollectionViewActions.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionViewBinding.d.ts +5 -2
- package/dist/components/CollectionViewBinding/CollectionViewBinding.js +1209 -0
- package/dist/components/CollectionViewBinding/CollectionViewBinding.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionViewStartActions.js +133 -0
- package/dist/components/CollectionViewBinding/CollectionViewStartActions.js.map +1 -0
- package/dist/components/CollectionViewBinding/EntityCardBinding.js +133 -0
- package/dist/components/CollectionViewBinding/EntityCardBinding.js.map +1 -0
- package/dist/components/CollectionViewBinding/FilterPresetsButton.js +203 -0
- package/dist/components/CollectionViewBinding/FilterPresetsButton.js.map +1 -0
- package/dist/components/CollectionViewBinding/FiltersDialog.d.ts +5 -0
- package/dist/components/CollectionViewBinding/FiltersDialog.js +148 -0
- package/dist/components/CollectionViewBinding/FiltersDialog.js.map +1 -0
- package/dist/components/CollectionViewBinding/SearchExplanation.js +86 -0
- package/dist/components/CollectionViewBinding/SearchExplanation.js.map +1 -0
- package/dist/components/CollectionViewBinding/SearchHighlight.js +262 -0
- package/dist/components/CollectionViewBinding/SearchHighlight.js.map +1 -0
- package/dist/components/CollectionViewBinding/SlotValue.js +117 -0
- package/dist/components/CollectionViewBinding/SlotValue.js.map +1 -0
- package/dist/components/CollectionViewBinding/SortButton.js +214 -0
- package/dist/components/CollectionViewBinding/SortButton.js.map +1 -0
- package/dist/components/CollectionViewBinding/SplitListCloseButton.js +41 -0
- package/dist/components/CollectionViewBinding/SplitListCloseButton.js.map +1 -0
- package/dist/components/CollectionViewBinding/SplitListShowButton.js +29 -0
- package/dist/components/CollectionViewBinding/SplitListShowButton.js.map +1 -0
- package/dist/components/CollectionViewBinding/SplitListView.js +311 -0
- package/dist/components/CollectionViewBinding/SplitListView.js.map +1 -0
- package/dist/components/CollectionViewBinding/SplitViewContext.js +21 -0
- package/dist/components/CollectionViewBinding/SplitViewContext.js.map +1 -0
- package/dist/components/CollectionViewBinding/ViewModeToggle.js +150 -0
- package/dist/components/CollectionViewBinding/ViewModeToggle.js.map +1 -0
- package/dist/components/CollectionViewBinding/hooks/useCollectionInlineEditor.js +49 -0
- package/dist/components/CollectionViewBinding/hooks/useCollectionInlineEditor.js.map +1 -0
- package/dist/components/CollectionViewBinding/hooks/useKanbanDragAndDrop.js +122 -0
- package/dist/components/CollectionViewBinding/hooks/useKanbanDragAndDrop.js.map +1 -0
- package/dist/components/CollectionViewBinding/useBoardDataController.js +530 -0
- package/dist/components/CollectionViewBinding/useBoardDataController.js.map +1 -0
- package/dist/components/CollectionViewBinding/usePreviewSlots.d.ts +4 -1
- package/dist/components/CollectionViewBinding/usePreviewSlots.js +384 -0
- package/dist/components/CollectionViewBinding/usePreviewSlots.js.map +1 -0
- package/dist/components/CollectionViewBinding/useSelectionController.js +104 -0
- package/dist/components/CollectionViewBinding/useSelectionController.js.map +1 -0
- package/dist/components/CollectionViewBinding/utils.js +21 -0
- package/dist/components/CollectionViewBinding/utils.js.map +1 -0
- package/dist/components/CollectionsProvider.d.ts +44 -0
- package/dist/components/CollectionsProvider.js +137 -0
- package/dist/components/CollectionsProvider.js.map +1 -0
- package/dist/components/CollectionsScopeContext.d.ts +18 -0
- package/dist/components/CollectionsScopeContext.js +25 -0
- package/dist/components/CollectionsScopeContext.js.map +1 -0
- package/dist/components/DefaultAppBar.js +179 -0
- package/dist/components/DefaultAppBar.js.map +1 -0
- package/dist/components/DefaultDrawer.js +364 -0
- package/dist/components/DefaultDrawer.js.map +1 -0
- package/dist/components/DeleteEntityDialog.js +256 -0
- package/dist/components/DeleteEntityDialog.js.map +1 -0
- package/dist/components/DetailViewBinding.js +504 -0
- package/dist/components/DetailViewBinding.js.map +1 -0
- package/dist/components/DrawerNavigationGroup.js +74 -0
- package/dist/components/DrawerNavigationGroup.js.map +1 -0
- package/dist/components/DrawerNavigationItem.d.ts +8 -0
- package/dist/components/DrawerNavigationItem.js +45 -0
- package/dist/components/DrawerNavigationItem.js.map +1 -0
- package/dist/components/EditFormActions.js +210 -0
- package/dist/components/EditFormActions.js.map +1 -0
- package/dist/components/EditViewBinding.d.ts +7 -1
- package/dist/components/EditViewBinding.js +802 -0
- package/dist/components/EditViewBinding.js.map +1 -0
- package/dist/components/EntityDisplayHeader.js +139 -0
- package/dist/components/EntityDisplayHeader.js.map +1 -0
- package/dist/components/EntityFormPanel.d.ts +58 -0
- package/dist/components/EntityFormPanel.js +126 -0
- package/dist/components/EntityFormPanel.js.map +1 -0
- package/dist/components/EntityIdentityBar.d.ts +29 -4
- package/dist/components/EntityIdentityBar.js +364 -0
- package/dist/components/EntityIdentityBar.js.map +1 -0
- package/dist/components/EntityInspector.js +96 -0
- package/dist/components/EntityInspector.js.map +1 -0
- package/dist/components/EntityPreviewBinding.js +282 -0
- package/dist/components/EntityPreviewBinding.js.map +1 -0
- package/dist/components/EntityPreviewNesting.js +53 -0
- package/dist/components/EntityPreviewNesting.js.map +1 -0
- package/dist/components/EntityViewBinding.js +246 -0
- package/dist/components/EntityViewBinding.js.map +1 -0
- package/dist/components/FieldCaption.js +17 -0
- package/dist/components/FieldCaption.js.map +1 -0
- package/dist/components/HomePage/ContentHomePage.js +326 -0
- package/dist/components/HomePage/ContentHomePage.js.map +1 -0
- package/dist/components/HomePage/FavouritesView.js +44 -0
- package/dist/components/HomePage/FavouritesView.js.map +1 -0
- package/dist/components/HomePage/HomePageDnD.js +436 -0
- package/dist/components/HomePage/HomePageDnD.js.map +1 -0
- package/dist/components/HomePage/NavigationCard.js +59 -0
- package/dist/components/HomePage/NavigationCard.js.map +1 -0
- package/dist/components/HomePage/NavigationCardBinding.js +70 -0
- package/dist/components/HomePage/NavigationCardBinding.js.map +1 -0
- package/dist/components/HomePage/NavigationGroup.js +98 -0
- package/dist/components/HomePage/NavigationGroup.js.map +1 -0
- package/dist/components/HomePage/RenameGroupDialog.js +89 -0
- package/dist/components/HomePage/RenameGroupDialog.js.map +1 -0
- package/dist/components/InlineEntityPreview.js +116 -0
- package/dist/components/InlineEntityPreview.js.map +1 -0
- package/dist/{JsonPreviewBinding-v0w3H0fp.js → components/JsonPreviewBinding.js} +2 -2
- package/dist/components/JsonPreviewBinding.js.map +1 -0
- package/dist/components/NavigationLoadingErrorView.d.ts +16 -0
- package/dist/components/NavigationLoadingErrorView.js +27 -0
- package/dist/components/NavigationLoadingErrorView.js.map +1 -0
- package/dist/components/PickerTrigger.js +27 -0
- package/dist/components/PickerTrigger.js.map +1 -0
- package/dist/components/PropertyCollectionView.js +215 -0
- package/dist/components/PropertyCollectionView.js.map +1 -0
- package/dist/components/PropertyConfigBadge.js +19 -0
- package/dist/components/PropertyConfigBadge.js.map +1 -0
- package/dist/components/PropertyKeyHint.js +58 -0
- package/dist/components/PropertyKeyHint.js.map +1 -0
- package/dist/components/RebaseAuthGate.js +35 -0
- package/dist/components/RebaseAuthGate.js.map +1 -0
- package/dist/components/RebaseCMS.js +44 -0
- package/dist/components/RebaseCMS.js.map +1 -0
- package/dist/components/RebaseLayout.js +59 -0
- package/dist/components/RebaseLayout.js.map +1 -0
- package/dist/components/RebaseNavigation.js +215 -0
- package/dist/components/RebaseNavigation.js.map +1 -0
- package/dist/components/RebaseRouteDefs.js +96 -0
- package/dist/components/RebaseRouteDefs.js.map +1 -0
- package/dist/components/RebaseShell.js +50 -0
- package/dist/components/RebaseShell.js.map +1 -0
- package/dist/components/ReferenceTable/SelectionTableBinding.js +224 -0
- package/dist/components/ReferenceTable/SelectionTableBinding.js.map +1 -0
- package/dist/components/ReferenceWidget.js +100 -0
- package/dist/components/ReferenceWidget.js.map +1 -0
- package/dist/components/RelationSelector.js +625 -0
- package/dist/components/RelationSelector.js.map +1 -0
- package/dist/components/SearchIconsView.js +52 -0
- package/dist/components/SearchIconsView.js.map +1 -0
- package/dist/components/SelectableTable/SelectableTable.d.ts +1 -1
- package/dist/components/SelectableTable/SelectableTable.js +158 -0
- package/dist/components/SelectableTable/SelectableTable.js.map +1 -0
- package/dist/components/SelectableTable/SelectableTableContext.js +8 -0
- package/dist/components/SelectableTable/SelectableTableContext.js.map +1 -0
- package/dist/components/SelectableTable/SelectionStore.js +29 -0
- package/dist/components/SelectableTable/SelectionStore.js.map +1 -0
- package/dist/components/SelectableTable/filters/BooleanFilterField.js +28 -0
- package/dist/components/SelectableTable/filters/BooleanFilterField.js.map +1 -0
- package/dist/components/SelectableTable/filters/DateTimeFilterField.d.ts +2 -1
- package/dist/components/SelectableTable/filters/DateTimeFilterField.js +93 -0
- package/dist/components/SelectableTable/filters/DateTimeFilterField.js.map +1 -0
- package/dist/components/SelectableTable/filters/FilterFieldBinding.js +132 -0
- package/dist/components/SelectableTable/filters/FilterFieldBinding.js.map +1 -0
- package/dist/components/SelectableTable/filters/ReferenceFilterField.js +157 -0
- package/dist/components/SelectableTable/filters/ReferenceFilterField.js.map +1 -0
- package/dist/components/SelectableTable/filters/RelationFilterField.js +169 -0
- package/dist/components/SelectableTable/filters/RelationFilterField.js.map +1 -0
- package/dist/components/SelectableTable/filters/StringNumberFilterField.js +181 -0
- package/dist/components/SelectableTable/filters/StringNumberFilterField.js.map +1 -0
- package/dist/components/SelectableTable/filters/null_filter.js +36 -0
- package/dist/components/SelectableTable/filters/null_filter.js.map +1 -0
- package/dist/components/SideDialogs.js +149 -0
- package/dist/components/SideDialogs.js.map +1 -0
- package/dist/components/SidePanelBinding.js +287 -0
- package/dist/components/SidePanelBinding.js.map +1 -0
- package/dist/components/SidePanelProvider.js +69 -0
- package/dist/components/SidePanelProvider.js.map +1 -0
- package/dist/components/UserSelector.d.ts +2 -0
- package/dist/components/UserSelector.js +418 -0
- package/dist/components/UserSelector.js.map +1 -0
- package/dist/components/admin/CreationResultDialog.js +118 -0
- package/dist/components/admin/CreationResultDialog.js.map +1 -0
- package/dist/components/app/AppBar.js +14 -0
- package/dist/components/app/AppBar.js.map +1 -0
- package/dist/components/app/Drawer.js +26 -0
- package/dist/components/app/Drawer.js.map +1 -0
- package/dist/components/app/Scaffold.js +229 -0
- package/dist/components/app/Scaffold.js.map +1 -0
- package/dist/components/app/useApp.js +24 -0
- package/dist/components/app/useApp.js.map +1 -0
- package/dist/components/common/ActionMenuLabel.d.ts +15 -0
- package/dist/components/common/ActionMenuLabel.js +30 -0
- package/dist/components/common/ActionMenuLabel.js.map +1 -0
- package/dist/components/common/default_entity_actions.d.ts +37 -0
- package/dist/components/common/default_entity_actions.js +590 -0
- package/dist/components/common/default_entity_actions.js.map +1 -0
- package/dist/components/drawer_expansion.d.ts +25 -0
- package/dist/components/drawer_expansion.js +44 -0
- package/dist/components/drawer_expansion.js.map +1 -0
- package/dist/components/field_configs.d.ts +2 -2
- package/dist/components/field_configs.js +431 -0
- package/dist/components/field_configs.js.map +1 -0
- package/dist/components/field_ids.d.ts +11 -0
- package/dist/components/field_ids.js +58 -0
- package/dist/components/field_ids.js.map +1 -0
- package/dist/components/history/EntityHistoryEntry.js +151 -0
- package/dist/components/history/EntityHistoryEntry.js.map +1 -0
- package/dist/components/history/EntityHistoryView.js +157 -0
- package/dist/components/history/EntityHistoryView.js.map +1 -0
- package/dist/components/history/UserChip.js +21 -0
- package/dist/components/history/UserChip.js.map +1 -0
- package/dist/components/history/index.js +4 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/lazy_record_views.d.ts +10 -0
- package/dist/components/lazy_record_views.js +57 -0
- package/dist/components/lazy_record_views.js.map +1 -0
- package/dist/contexts/BreacrumbsContext.js +28 -0
- package/dist/contexts/BreacrumbsContext.js.map +1 -0
- package/dist/contexts/EditorAIControllerContext.d.ts +18 -0
- package/dist/contexts/EditorAIControllerContext.js +29 -0
- package/dist/contexts/EditorAIControllerContext.js.map +1 -0
- package/dist/contexts/SideDialogsControllerContext.js +7 -0
- package/dist/contexts/SideDialogsControllerContext.js.map +1 -0
- package/dist/data_export/export/BasicExportAction.js +151 -0
- package/dist/data_export/export/BasicExportAction.js.map +1 -0
- package/dist/data_export/export/ExportCollectionAction.js +297 -0
- package/dist/data_export/export/ExportCollectionAction.js.map +1 -0
- package/dist/data_export/export/additional_fields.js +40 -0
- package/dist/data_export/export/additional_fields.js.map +1 -0
- package/dist/data_export/export/export.d.ts +35 -0
- package/dist/data_export/export/export.js +400 -0
- package/dist/data_export/export/export.js.map +1 -0
- package/dist/data_export/export/fetch_export_data.d.ts +17 -7
- package/dist/data_export/export/fetch_export_data.js +67 -0
- package/dist/data_export/export/fetch_export_data.js.map +1 -0
- package/dist/data_export/export/index.d.ts +4 -2
- package/dist/data_export/export/index.js +5 -0
- package/dist/data_import/components/DataNewPropertiesMapping.js +207 -0
- package/dist/data_import/components/DataNewPropertiesMapping.js.map +1 -0
- package/dist/data_import/components/ImportConversionProblems.d.ts +11 -0
- package/dist/data_import/components/ImportConversionProblems.js +89 -0
- package/dist/data_import/components/ImportConversionProblems.js.map +1 -0
- package/dist/data_import/components/ImportFileUpload.js +43 -0
- package/dist/data_import/components/ImportFileUpload.js.map +1 -0
- package/dist/data_import/components/ImportNewPropertyFieldPreview.js +42 -0
- package/dist/data_import/components/ImportNewPropertyFieldPreview.js.map +1 -0
- package/dist/data_import/components/ImportSaveInProgress.js +105 -0
- package/dist/data_import/components/ImportSaveInProgress.js.map +1 -0
- package/dist/data_import/components/index.d.ts +1 -0
- package/dist/data_import/hooks/useImportConfig.js +34 -0
- package/dist/data_import/hooks/useImportConfig.js.map +1 -0
- package/dist/{import-TCgkTVlS.js → data_import/import/ImportCollectionAction.js} +84 -92
- package/dist/data_import/import/ImportCollectionAction.js.map +1 -0
- package/dist/data_import/import/index.js +2 -0
- package/dist/data_import/utils/csv.js +146 -0
- package/dist/data_import/utils/csv.js.map +1 -0
- package/dist/data_import/utils/data.d.ts +81 -4
- package/dist/data_import/utils/data.js +366 -0
- package/dist/data_import/utils/data.js.map +1 -0
- package/dist/data_import/utils/file_headers.js +32 -0
- package/dist/data_import/utils/file_headers.js.map +1 -0
- package/dist/data_import/utils/file_to_json.js +149 -0
- package/dist/data_import/utils/file_to_json.js.map +1 -0
- package/dist/data_import/utils/get_import_inference_type.js +14 -0
- package/dist/data_import/utils/get_import_inference_type.js.map +1 -0
- package/dist/data_import/utils/id_column.js +27 -0
- package/dist/data_import/utils/id_column.js.map +1 -0
- package/dist/data_import/utils/import_columns.d.ts +48 -0
- package/dist/data_import/utils/import_columns.js +92 -0
- package/dist/data_import/utils/import_columns.js.map +1 -0
- package/dist/data_import/utils/save_entities.d.ts +33 -4
- package/dist/data_import/utils/save_entities.js +244 -0
- package/dist/data_import/utils/save_entities.js.map +1 -0
- package/dist/data_import/utils/transforms.js +83 -0
- package/dist/data_import/utils/transforms.js.map +1 -0
- package/dist/editor/components/SlashCommandMenu.js +497 -0
- package/dist/editor/components/SlashCommandMenu.js.map +1 -0
- package/dist/editor/components/editor-bubble-item.js +24 -0
- package/dist/editor/components/editor-bubble-item.js.map +1 -0
- package/dist/editor/components/editor-bubble.js +97 -0
- package/dist/editor/components/editor-bubble.js.map +1 -0
- package/dist/editor/components/image-bubble.js +148 -0
- package/dist/editor/components/image-bubble.js.map +1 -0
- package/dist/editor/components/table-bubble.js +406 -0
- package/dist/editor/components/table-bubble.js.map +1 -0
- package/dist/editor/editor.d.ts +7 -1
- package/dist/editor/editor.js +423 -0
- package/dist/editor/editor.js.map +1 -0
- package/dist/editor/extensions/HighlightDecorationExtension.js +74 -0
- package/dist/editor/extensions/HighlightDecorationExtension.js.map +1 -0
- package/dist/editor/extensions/Image.d.ts +28 -1
- package/dist/editor/extensions/Image.js +160 -0
- package/dist/editor/extensions/Image.js.map +1 -0
- package/dist/editor/extensions/TextLoadingDecorationExtension.js +82 -0
- package/dist/editor/extensions/TextLoadingDecorationExtension.js.map +1 -0
- package/dist/editor/extensions/clipboard.js +63 -0
- package/dist/editor/extensions/clipboard.js.map +1 -0
- package/dist/editor/extensions/drag-and-drop.js +354 -0
- package/dist/editor/extensions/drag-and-drop.js.map +1 -0
- package/dist/editor/hooks/useProseMirror.d.ts +4 -1
- package/dist/editor/hooks/useProseMirror.js +101 -0
- package/dist/editor/hooks/useProseMirror.js.map +1 -0
- package/dist/editor/hooks/useProseMirrorContext.js +11 -0
- package/dist/editor/hooks/useProseMirrorContext.js.map +1 -0
- package/dist/editor/markdown.js +154 -0
- package/dist/editor/markdown.js.map +1 -0
- package/dist/editor/nodeViews/ImageComponent.js +35 -0
- package/dist/editor/nodeViews/ImageComponent.js.map +1 -0
- package/dist/editor/nodeViews/ReactNodeView.js +57 -0
- package/dist/editor/nodeViews/ReactNodeView.js.map +1 -0
- package/dist/editor/nodeViews/TaskItemComponent.js +29 -0
- package/dist/editor/nodeViews/TaskItemComponent.js.map +1 -0
- package/dist/editor/nodeViews/index.js +21 -0
- package/dist/editor/nodeViews/index.js.map +1 -0
- package/dist/editor/plugins/index.js +54 -0
- package/dist/editor/plugins/index.js.map +1 -0
- package/dist/editor/plugins/inputrules.js +54 -0
- package/dist/editor/plugins/inputrules.js.map +1 -0
- package/dist/editor/plugins/placeholderPlugin.js +38 -0
- package/dist/editor/plugins/placeholderPlugin.js.map +1 -0
- package/dist/editor/plugins/slashCommandPlugin.js +40 -0
- package/dist/editor/plugins/slashCommandPlugin.js.map +1 -0
- package/dist/editor/sanitize-html.js +190 -0
- package/dist/editor/sanitize-html.js.map +1 -0
- package/dist/{markdown-CCqp8ibf.js → editor/schema.js} +2 -159
- package/dist/editor/schema.js.map +1 -0
- package/dist/editor/selectors/link-selector.js +118 -0
- package/dist/editor/selectors/link-selector.js.map +1 -0
- package/dist/editor/selectors/node-selector.js +118 -0
- package/dist/editor/selectors/node-selector.js.map +1 -0
- package/dist/editor/selectors/text-buttons.js +71 -0
- package/dist/editor/selectors/text-buttons.js.map +1 -0
- package/dist/editor/utils/prosemirror-utils.js +92 -0
- package/dist/editor/utils/prosemirror-utils.js.map +1 -0
- package/dist/editor/utils/remove_classes.js +16 -0
- package/dist/editor/utils/remove_classes.js.map +1 -0
- package/dist/editor.js +1 -3085
- package/dist/form/EntityForm.js +734 -0
- package/dist/form/EntityForm.js.map +1 -0
- package/dist/form/EntityFormActions.js +101 -0
- package/dist/form/EntityFormActions.js.map +1 -0
- package/dist/form/EntityFormBinding.js +256 -0
- package/dist/form/EntityFormBinding.js.map +1 -0
- package/dist/form/PropertyFieldBinding.js +298 -0
- package/dist/form/PropertyFieldBinding.js.map +1 -0
- package/dist/form/components/ErrorFocus.js +33 -0
- package/dist/form/components/ErrorFocus.js.map +1 -0
- package/dist/form/components/FieldBlock.js +118 -0
- package/dist/form/components/FieldBlock.js.map +1 -0
- package/dist/form/components/FieldHelperText.js +56 -0
- package/dist/form/components/FieldHelperText.js.map +1 -0
- package/dist/form/components/FormRail.js +118 -0
- package/dist/form/components/FormRail.js.map +1 -0
- package/dist/form/components/FormSections.js +63 -0
- package/dist/form/components/FormSections.js.map +1 -0
- package/dist/form/components/LabelWithIcon.js +29 -0
- package/dist/form/components/LabelWithIcon.js.map +1 -0
- package/dist/form/components/LocalChangesMenu.js +127 -0
- package/dist/form/components/LocalChangesMenu.js.map +1 -0
- package/dist/form/components/StorageItemPreview.js +46 -0
- package/dist/form/components/StorageItemPreview.js.map +1 -0
- package/dist/form/components/StorageUploadProgress.js +84 -0
- package/dist/form/components/StorageUploadProgress.js.map +1 -0
- package/dist/form/components/useRailVisible.js +43 -0
- package/dist/form/components/useRailVisible.js.map +1 -0
- package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.js +84 -0
- package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.js +125 -0
- package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/BinaryFieldBinding.js +135 -0
- package/dist/form/field_bindings/BinaryFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/BlockFieldBinding.js +164 -0
- package/dist/form/field_bindings/BlockFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/DateTimeFieldBinding.js +47 -0
- package/dist/form/field_bindings/DateTimeFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/GeopointFieldBinding.js +148 -0
- package/dist/form/field_bindings/GeopointFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/KeyValueFieldBinding.js +450 -0
- package/dist/form/field_bindings/KeyValueFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/MapFieldBinding.js +77 -0
- package/dist/form/field_bindings/MapFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/MarkdownEditorFieldBinding.js +215 -0
- package/dist/form/field_bindings/MarkdownEditorFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/MultiSelectFieldBinding.js +88 -0
- package/dist/form/field_bindings/MultiSelectFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/MultipleRelationFieldBinding.js +118 -0
- package/dist/form/field_bindings/MultipleRelationFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/ReadOnlyFieldBinding.js +52 -0
- package/dist/form/field_bindings/ReadOnlyFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/ReferenceFieldBinding.js +99 -0
- package/dist/form/field_bindings/ReferenceFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/RelationFieldBinding.js +135 -0
- package/dist/form/field_bindings/RelationFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/RepeatFieldBinding.js +103 -0
- package/dist/form/field_bindings/RepeatFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/SelectFieldBinding.js +80 -0
- package/dist/form/field_bindings/SelectFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/StorageUploadFieldBinding.js +266 -0
- package/dist/form/field_bindings/StorageUploadFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/SwitchFieldBinding.js +41 -0
- package/dist/form/field_bindings/SwitchFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/TextFieldBinding.js +114 -0
- package/dist/form/field_bindings/TextFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/UserSelectFieldBinding.js +48 -0
- package/dist/form/field_bindings/UserSelectFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/VectorFieldBinding.js +147 -0
- package/dist/form/field_bindings/VectorFieldBinding.js.map +1 -0
- package/dist/form/form_keyboard_scope.d.ts +26 -0
- package/dist/form/form_keyboard_scope.js +39 -0
- package/dist/form/form_keyboard_scope.js.map +1 -0
- package/dist/form/form_uploads.d.ts +24 -0
- package/dist/form/form_uploads.js +31 -0
- package/dist/form/form_uploads.js.map +1 -0
- package/dist/form/form_utils.d.ts +48 -0
- package/dist/form/form_utils.js +280 -0
- package/dist/form/form_utils.js.map +1 -0
- package/dist/form/resolve_cell_property.d.ts +32 -0
- package/dist/form/resolve_cell_property.js +80 -0
- package/dist/form/resolve_cell_property.js.map +1 -0
- package/dist/form/resolve_form_properties.d.ts +27 -0
- package/dist/form/resolve_form_properties.js +78 -0
- package/dist/form/resolve_form_properties.js.map +1 -0
- package/dist/form/useClearRestoreValue.js +27 -0
- package/dist/form/useClearRestoreValue.js.map +1 -0
- package/dist/form/useUndoableDiscard.js +36 -0
- package/dist/form/useUndoableDiscard.js.map +1 -0
- package/dist/form/validation.d.ts +20 -0
- package/dist/form/validation.js +416 -0
- package/dist/form/validation.js.map +1 -0
- package/dist/hooks/navigation/contexts/CollectionRegistryContext.js +22 -0
- package/dist/hooks/navigation/contexts/CollectionRegistryContext.js.map +1 -0
- package/dist/hooks/navigation/contexts/NavigationStateContext.js +15 -0
- package/dist/hooks/navigation/contexts/NavigationStateContext.js.map +1 -0
- package/dist/hooks/navigation/contexts/UrlContext.js +22 -0
- package/dist/hooks/navigation/contexts/UrlContext.js.map +1 -0
- package/dist/hooks/navigation/useAsyncResolver.js +68 -0
- package/dist/hooks/navigation/useAsyncResolver.js.map +1 -0
- package/dist/hooks/navigation/useBuildCollectionRegistryController.js +141 -0
- package/dist/hooks/navigation/useBuildCollectionRegistryController.js.map +1 -0
- package/dist/hooks/navigation/useBuildNavigationStateController.js +77 -0
- package/dist/hooks/navigation/useBuildNavigationStateController.js.map +1 -0
- package/dist/hooks/navigation/useBuildUrlController.js +57 -0
- package/dist/hooks/navigation/useBuildUrlController.js.map +1 -0
- package/dist/hooks/navigation/useNavigationResolution.js +177 -0
- package/dist/hooks/navigation/useNavigationResolution.js.map +1 -0
- package/dist/hooks/navigation/useResolvedCollections.js +56 -0
- package/dist/hooks/navigation/useResolvedCollections.js.map +1 -0
- package/dist/hooks/navigation/useResolvedViews.js +94 -0
- package/dist/hooks/navigation/useResolvedViews.js.map +1 -0
- package/dist/hooks/navigation/useTopLevelNavigation.js +162 -0
- package/dist/hooks/navigation/useTopLevelNavigation.js.map +1 -0
- package/dist/hooks/navigation/utils.js +125 -0
- package/dist/hooks/navigation/utils.js.map +1 -0
- package/dist/hooks/useAdminContext.js +45 -0
- package/dist/hooks/useAdminContext.js.map +1 -0
- package/dist/hooks/useBreadcrumbsController.js +17 -0
- package/dist/hooks/useBreadcrumbsController.js.map +1 -0
- package/dist/hooks/useBuildSideDialogsController.js +96 -0
- package/dist/hooks/useBuildSideDialogsController.js.map +1 -0
- package/dist/hooks/useBuildSidePanel.js +221 -0
- package/dist/hooks/useBuildSidePanel.js.map +1 -0
- package/dist/hooks/useChildViewSource.js +41 -0
- package/dist/hooks/useChildViewSource.js.map +1 -0
- package/dist/hooks/useEntityDisplay.js +136 -0
- package/dist/hooks/useEntityDisplay.js.map +1 -0
- package/dist/hooks/useEntityDisplayTitle.js +34 -0
- package/dist/hooks/useEntityDisplayTitle.js.map +1 -0
- package/dist/hooks/useHistory.js +137 -0
- package/dist/hooks/useHistory.js.map +1 -0
- package/dist/hooks/useRecordActions.d.ts +28 -6
- package/dist/hooks/useRecordActions.js +108 -0
- package/dist/hooks/useRecordActions.js.map +1 -0
- package/dist/hooks/useReferencePaths.d.ts +21 -0
- package/dist/hooks/useReferencePaths.js +32 -0
- package/dist/hooks/useReferencePaths.js.map +1 -0
- package/dist/hooks/useResolvedNavigationFrom.js +83 -0
- package/dist/hooks/useResolvedNavigationFrom.js.map +1 -0
- package/dist/hooks/useResolvedUsers.js +109 -0
- package/dist/hooks/useResolvedUsers.js.map +1 -0
- package/dist/hooks/useSelectionDialog.js +53 -0
- package/dist/hooks/useSelectionDialog.js.map +1 -0
- package/dist/hooks/useSideDialogsController.js +8 -0
- package/dist/hooks/useSideDialogsController.js.map +1 -0
- package/dist/hooks/useSidePanel.js +15 -0
- package/dist/hooks/useSidePanel.js.map +1 -0
- package/dist/hooks/useStorageReferenceResolver.d.ts +25 -0
- package/dist/hooks/useStorageReferenceResolver.js +49 -0
- package/dist/hooks/useStorageReferenceResolver.js.map +1 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +151 -3793
- package/dist/preview/PropertyPreview.js +260 -0
- package/dist/preview/PropertyPreview.js.map +1 -0
- package/dist/preview/compact_text.js +52 -0
- package/dist/preview/compact_text.js.map +1 -0
- package/dist/preview/components/ArrayEnumPreview.js +24 -0
- package/dist/preview/components/ArrayEnumPreview.js.map +1 -0
- package/dist/preview/components/BooleanPreview.js +25 -0
- package/dist/preview/components/BooleanPreview.js.map +1 -0
- package/dist/preview/components/DatePreview.d.ts +3 -2
- package/dist/preview/components/DatePreview.js +87 -0
- package/dist/preview/components/DatePreview.js.map +1 -0
- package/dist/preview/components/EmptyValue.js +13 -0
- package/dist/preview/components/EmptyValue.js.map +1 -0
- package/dist/preview/components/EnumValuesChip.js +26 -0
- package/dist/preview/components/EnumValuesChip.js.map +1 -0
- package/dist/preview/components/ImagePreview.d.ts +7 -1
- package/dist/preview/components/ImagePreview.js +112 -0
- package/dist/preview/components/ImagePreview.js.map +1 -0
- package/dist/preview/components/InlineEntityListPreview.js +31 -0
- package/dist/preview/components/InlineEntityListPreview.js.map +1 -0
- package/dist/preview/components/ReferencePreview.js +162 -0
- package/dist/preview/components/ReferencePreview.js.map +1 -0
- package/dist/preview/components/RelationPreview.js +196 -0
- package/dist/preview/components/RelationPreview.js.map +1 -0
- package/dist/preview/components/StorageMarkdown.d.ts +11 -0
- package/dist/preview/components/StorageMarkdown.js +49 -0
- package/dist/preview/components/StorageMarkdown.js.map +1 -0
- package/dist/preview/components/StorageThumbnail.js +183 -0
- package/dist/preview/components/StorageThumbnail.js.map +1 -0
- package/dist/preview/components/UrlComponentPreview.d.ts +3 -1
- package/dist/preview/components/UrlComponentPreview.js +88 -0
- package/dist/preview/components/UrlComponentPreview.js.map +1 -0
- package/dist/preview/components/UserPreview.js +30 -0
- package/dist/preview/components/UserPreview.js.map +1 -0
- package/dist/preview/components/date_fns_locales.js +124 -0
- package/dist/preview/components/date_fns_locales.js.map +1 -0
- package/dist/preview/components/storageRenditions.d.ts +10 -0
- package/dist/preview/components/storageRenditions.js +95 -0
- package/dist/preview/components/storageRenditions.js.map +1 -0
- package/dist/preview/property_previews/ArrayOfMapsPreview.js +44 -0
- package/dist/preview/property_previews/ArrayOfMapsPreview.js.map +1 -0
- package/dist/preview/property_previews/ArrayOfReferencesPreview.js +48 -0
- package/dist/preview/property_previews/ArrayOfReferencesPreview.js.map +1 -0
- package/dist/preview/property_previews/ArrayOfRelationsPreview.js +50 -0
- package/dist/preview/property_previews/ArrayOfRelationsPreview.js.map +1 -0
- package/dist/preview/property_previews/ArrayOfStorageComponentsPreview.js +30 -0
- package/dist/preview/property_previews/ArrayOfStorageComponentsPreview.js.map +1 -0
- package/dist/preview/property_previews/ArrayOfStringsPreview.js +42 -0
- package/dist/preview/property_previews/ArrayOfStringsPreview.js.map +1 -0
- package/dist/preview/property_previews/ArrayOneOfPreview.js +47 -0
- package/dist/preview/property_previews/ArrayOneOfPreview.js.map +1 -0
- package/dist/preview/property_previews/ArrayPropertyEnumPreview.js +25 -0
- package/dist/preview/property_previews/ArrayPropertyEnumPreview.js.map +1 -0
- package/dist/preview/property_previews/ArrayPropertyPreview.js +48 -0
- package/dist/preview/property_previews/ArrayPropertyPreview.js.map +1 -0
- package/dist/preview/property_previews/MapPropertyPreview.js +137 -0
- package/dist/preview/property_previews/MapPropertyPreview.js.map +1 -0
- package/dist/preview/property_previews/NumberPropertyPreview.js +34 -0
- package/dist/preview/property_previews/NumberPropertyPreview.js.map +1 -0
- package/dist/preview/property_previews/SkeletonPropertyComponent.js +151 -0
- package/dist/preview/property_previews/SkeletonPropertyComponent.js.map +1 -0
- package/dist/preview/property_previews/StringPropertyPreview.js +49 -0
- package/dist/preview/property_previews/StringPropertyPreview.js.map +1 -0
- package/dist/preview/util.d.ts +8 -3
- package/dist/{util-CC0ozHoD.js → preview/util.js} +13 -6
- package/dist/preview/util.js.map +1 -0
- package/dist/routes/CustomViewRoute.js +26 -0
- package/dist/routes/CustomViewRoute.js.map +1 -0
- package/dist/routes/RebaseRoute.js +311 -0
- package/dist/routes/RebaseRoute.js.map +1 -0
- package/dist/selection/SelectionMenu.js +90 -0
- package/dist/selection/SelectionMenu.js.map +1 -0
- package/dist/selection/resolve_selection.js +79 -0
- package/dist/selection/resolve_selection.js.map +1 -0
- package/dist/util/caller_scopes.d.ts +15 -0
- package/dist/util/caller_scopes.js +25 -0
- package/dist/util/caller_scopes.js.map +1 -0
- package/dist/util/collection_open_mode.d.ts +20 -0
- package/dist/util/collection_open_mode.js +32 -0
- package/dist/util/collection_open_mode.js.map +1 -0
- package/dist/util/dataControllerAdapter.js +65 -0
- package/dist/util/dataControllerAdapter.js.map +1 -0
- package/dist/util/entity_actions.d.ts +42 -1
- package/dist/util/entity_actions.js +77 -0
- package/dist/util/entity_actions.js.map +1 -0
- package/dist/util/entity_pages.d.ts +37 -3
- package/dist/util/entity_pages.js +71 -0
- package/dist/util/entity_pages.js.map +1 -0
- package/dist/util/find_entities_by_ids.d.ts +23 -0
- package/dist/util/find_entities_by_ids.js +55 -0
- package/dist/util/find_entities_by_ids.js.map +1 -0
- package/dist/util/fit_inline_actions.d.ts +20 -0
- package/dist/util/fit_inline_actions.js +40 -0
- package/dist/util/fit_inline_actions.js.map +1 -0
- package/dist/util/format_collection_date.d.ts +29 -0
- package/dist/util/format_collection_date.js +60 -0
- package/dist/util/format_collection_date.js.map +1 -0
- package/dist/util/map_with_concurrency.js +46 -0
- package/dist/util/map_with_concurrency.js.map +1 -0
- package/dist/util/navigation_utils.js +45 -0
- package/dist/util/navigation_utils.js.map +1 -0
- package/dist/util/number_format.js +33 -0
- package/dist/util/number_format.js.map +1 -0
- package/dist/util/previews.js +71 -0
- package/dist/util/previews.js.map +1 -0
- package/dist/util/propertyConfigMapper.js +83 -0
- package/dist/util/propertyConfigMapper.js.map +1 -0
- package/dist/util/property_utils.js +141 -0
- package/dist/util/property_utils.js.map +1 -0
- package/dist/util/resolutions.js +55 -0
- package/dist/util/resolutions.js.map +1 -0
- package/dist/util/view_constants.js +35 -0
- package/dist/util/view_constants.js.map +1 -0
- package/dist/util/view_mode.js +112 -0
- package/dist/util/view_mode.js.map +1 -0
- package/package.json +13 -9
- package/dist/CollectionEditorDialog-DLHCka00.js +0 -3630
- package/dist/CollectionEditorDialog-DLHCka00.js.map +0 -1
- package/dist/JsonPreviewBinding-v0w3H0fp.js.map +0 -1
- package/dist/PropertyEditView-_pu5hzZn.js +0 -3837
- package/dist/PropertyEditView-_pu5hzZn.js.map +0 -1
- package/dist/RouterCollectionsStudioView-ChPNl_uU.js +0 -212
- package/dist/RouterCollectionsStudioView-ChPNl_uU.js.map +0 -1
- package/dist/SchemaChangeDialog-BeP0A4MJ.js.map +0 -1
- package/dist/collection_editor/ui/CollectionViewHeaderAction.d.ts +0 -13
- package/dist/collection_editor/ui/PropertyAddColumnComponent.d.ts +0 -8
- package/dist/collection_editor_ui.js.map +0 -1
- package/dist/editor.js.map +0 -1
- package/dist/export-4bJWdlDK.js +0 -520
- package/dist/export-4bJWdlDK.js.map +0 -1
- package/dist/history-BElrZ5Rw.js +0 -313
- package/dist/history-BElrZ5Rw.js.map +0 -1
- package/dist/import-TCgkTVlS.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/markdown-CCqp8ibf.js.map +0 -1
- package/dist/rolldown-runtime-D7D4PA-g.js +0 -13
- package/dist/util-CC0ozHoD.js.map +0 -1
- package/dist/util-DybQBkug.js +0 -26390
- package/dist/util-DybQBkug.js.map +0 -1
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import { ReadOnlyFieldBinding } from "./field_bindings/ReadOnlyFieldBinding.js";
|
|
2
|
+
import { resolveFormProperty } from "./resolve_form_properties.js";
|
|
3
|
+
import { useClearRestoreValue } from "./useClearRestoreValue.js";
|
|
4
|
+
import { getFieldId } from "../components/field_ids.js";
|
|
5
|
+
import { getFieldConfig } from "../components/field_configs.js";
|
|
6
|
+
import React, { Suspense, useCallback, useRef } from "react";
|
|
7
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { deepEqual } from "fast-equals";
|
|
9
|
+
import { ErrorBoundary, Typography } from "@rebasepro/ui";
|
|
10
|
+
import { isPropertyBuilder, resolveProperty } from "@rebasepro/common";
|
|
11
|
+
import { isDisabled, isHidden, isReadOnly, resolveComponentRef, useAuthController, useCustomizationController, useRebaseContext, useSlot, useTranslation } from "@rebasepro/app";
|
|
12
|
+
import { getIn, useFormexGetter, useFormexSelector } from "@rebasepro/forms";
|
|
13
|
+
//#region src/form/PropertyFieldBinding.tsx
|
|
14
|
+
/**
|
|
15
|
+
* This component renders a form field creating the corresponding configuration
|
|
16
|
+
* from a property. For example if bound to a string property, it will generate
|
|
17
|
+
* a text field.
|
|
18
|
+
*
|
|
19
|
+
* You can use it when you are creating a custom field, and need to
|
|
20
|
+
* render additional fields mapped to properties. This is useful if you
|
|
21
|
+
* need to build a complex property mapping, like an array where each index
|
|
22
|
+
* is a different property.
|
|
23
|
+
*
|
|
24
|
+
* Please note that if you build a custom field in a component, the
|
|
25
|
+
* **validation** passed in the property will have no effect. You need to set
|
|
26
|
+
* the validation in the `AdminCollection` definition.
|
|
27
|
+
*
|
|
28
|
+
* @param propertyKey You can use nested names such as `address.street` or `friends[2]`
|
|
29
|
+
* @param property
|
|
30
|
+
* @param context
|
|
31
|
+
* @param includeDescription
|
|
32
|
+
* @param underlyingValueHasChanged
|
|
33
|
+
* @param disabled
|
|
34
|
+
* @param tableMode
|
|
35
|
+
* @param partOfArray
|
|
36
|
+
* @param autoFocus
|
|
37
|
+
* @group Form custom fields
|
|
38
|
+
*/
|
|
39
|
+
var PropertyFieldBinding = React.memo(PropertyFieldBindingInternal, (a, b) => sameProps(a, b, DEEP_COMPARED_BINDING_PROPS));
|
|
40
|
+
/**
|
|
41
|
+
* Props compared by value rather than identity: a property is re-resolved
|
|
42
|
+
* (`dynamicProps`, enums, a parent's `mergeDeep`) into a new object on every
|
|
43
|
+
* render of whatever holds it, and an error for an array or map is a new
|
|
44
|
+
* sub-object of the errors map whenever anything is validated.
|
|
45
|
+
*/
|
|
46
|
+
var DEEP_COMPARED_BINDING_PROPS = /* @__PURE__ */ new Set(["property"]);
|
|
47
|
+
var DEEP_COMPARED_FIELD_PROPS = /* @__PURE__ */ new Set([
|
|
48
|
+
"property",
|
|
49
|
+
"error",
|
|
50
|
+
"customProps"
|
|
51
|
+
]);
|
|
52
|
+
function sameProps(a, b, deep) {
|
|
53
|
+
const keys = /* @__PURE__ */ new Set([...Object.keys(a), ...Object.keys(b)]);
|
|
54
|
+
for (const key of keys) {
|
|
55
|
+
if (Object.is(a[key], b[key])) continue;
|
|
56
|
+
if (deep.has(key) && deepEqual(a[key], b[key])) continue;
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
function PropertyFieldBindingInternal({ propertyKey, property, context, includeDescription, hideLabel, underlyingValueHasChanged, disabled: disabledProp, partOfArray, partOfBlock, minimalistView, autoFocus, index, size, onPropertyChange }) {
|
|
62
|
+
const authController = useAuthController();
|
|
63
|
+
const customizationController = useCustomizationController();
|
|
64
|
+
const alwaysRender = shouldPropertyReRender(property, customizationController.plugins, customizationController.propertyConfigs);
|
|
65
|
+
const slice = useFormexSelector(useCallback((formex) => ({
|
|
66
|
+
formex: alwaysRender ? formex : void 0,
|
|
67
|
+
value: getIn(formex.values, propertyKey),
|
|
68
|
+
error: getIn(formex.errors, propertyKey),
|
|
69
|
+
touched: getIn(formex.touched, propertyKey),
|
|
70
|
+
submitted: formex.submitCount > 0,
|
|
71
|
+
isSubmitting: formex.isSubmitting
|
|
72
|
+
}), [propertyKey, alwaysRender]), sameSlice);
|
|
73
|
+
const getFormex = useFormexGetter();
|
|
74
|
+
const values = (slice.formex ?? getFormex()).values;
|
|
75
|
+
let Component;
|
|
76
|
+
const resolvedProperty = resolveFormProperty({
|
|
77
|
+
propertyKey,
|
|
78
|
+
property,
|
|
79
|
+
values,
|
|
80
|
+
path: context.path,
|
|
81
|
+
entityId: context.entityId,
|
|
82
|
+
propertyConfigs: customizationController.propertyConfigs,
|
|
83
|
+
index,
|
|
84
|
+
authController
|
|
85
|
+
});
|
|
86
|
+
const readOnly = resolvedProperty ? isReadOnly(resolvedProperty) : true;
|
|
87
|
+
const disabled = disabledProp || readOnly || (resolvedProperty ? isDisabled(resolvedProperty) : false) || context.disabled;
|
|
88
|
+
if (resolvedProperty === null || isHidden(resolvedProperty)) return /* @__PURE__ */ jsx(Fragment, {});
|
|
89
|
+
else if (readOnly) Component = ReadOnlyFieldBinding;
|
|
90
|
+
else if (resolvedProperty.admin?.Field) {
|
|
91
|
+
const resolved = resolveComponentRef(resolvedProperty.admin.Field);
|
|
92
|
+
if (resolved) Component = resolved;
|
|
93
|
+
} else {
|
|
94
|
+
const propertyConfig = getFieldConfig(resolvedProperty, customizationController.propertyConfigs);
|
|
95
|
+
if (!propertyConfig) throw new Error(`INTERNAL: Could not find field config for property ${propertyKey}`);
|
|
96
|
+
Component = resolveComponentRef(resolveProperty({
|
|
97
|
+
propertyKey,
|
|
98
|
+
property: propertyConfig.property,
|
|
99
|
+
values,
|
|
100
|
+
path: context.path,
|
|
101
|
+
entityId: context.entityId,
|
|
102
|
+
propertyConfigs: customizationController.propertyConfigs,
|
|
103
|
+
index,
|
|
104
|
+
authController
|
|
105
|
+
})?.admin?.Field);
|
|
106
|
+
}
|
|
107
|
+
if (!Component) {
|
|
108
|
+
console.warn(`No field component found for property ${propertyKey}`);
|
|
109
|
+
console.warn("Property:", property);
|
|
110
|
+
return /* @__PURE__ */ jsx("div", {
|
|
111
|
+
className: "w-full",
|
|
112
|
+
children: `Currently the field ${resolvedProperty.type} is not supported`
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
return /* @__PURE__ */ jsx(FieldInternal, {
|
|
116
|
+
Component,
|
|
117
|
+
alwaysRender,
|
|
118
|
+
componentProps: {
|
|
119
|
+
propertyKey,
|
|
120
|
+
property: resolvedProperty,
|
|
121
|
+
includeDescription,
|
|
122
|
+
hideLabel,
|
|
123
|
+
underlyingValueHasChanged,
|
|
124
|
+
context,
|
|
125
|
+
disabled,
|
|
126
|
+
partOfArray,
|
|
127
|
+
partOfBlock,
|
|
128
|
+
minimalistView,
|
|
129
|
+
autoFocus,
|
|
130
|
+
size,
|
|
131
|
+
onPropertyChange
|
|
132
|
+
},
|
|
133
|
+
slice,
|
|
134
|
+
getFormex
|
|
135
|
+
}, propertyKey);
|
|
136
|
+
}
|
|
137
|
+
function sameSlice(a, b) {
|
|
138
|
+
return a.formex === b.formex && Object.is(a.value, b.value) && a.touched === b.touched && a.submitted === b.submitted && a.isSubmitting === b.isSubmitting && (Object.is(a.error, b.error) || deepEqual(a.error, b.error));
|
|
139
|
+
}
|
|
140
|
+
function FieldInternal({ Component, alwaysRender, componentProps: { propertyKey, property, includeDescription, hideLabel, underlyingValueHasChanged, partOfArray, partOfBlock, minimalistView, autoFocus, context, disabled, size, onPropertyChange }, slice, getFormex }) {
|
|
141
|
+
const { plugins } = useCustomizationController();
|
|
142
|
+
const { t } = useTranslation();
|
|
143
|
+
const rebaseContext = useRebaseContext();
|
|
144
|
+
const fieldSlotProps = React.useMemo(() => ({
|
|
145
|
+
propertyKey,
|
|
146
|
+
property,
|
|
147
|
+
path: context.path ?? "",
|
|
148
|
+
entityId: context.entityId,
|
|
149
|
+
collection: context.collection,
|
|
150
|
+
context: rebaseContext
|
|
151
|
+
}), [
|
|
152
|
+
propertyKey,
|
|
153
|
+
property,
|
|
154
|
+
context.path,
|
|
155
|
+
context.entityId,
|
|
156
|
+
context.collection,
|
|
157
|
+
rebaseContext
|
|
158
|
+
]);
|
|
159
|
+
const beforeField = useSlot("entity.field.before", fieldSlotProps);
|
|
160
|
+
const afterField = useSlot("entity.field.after", fieldSlotProps);
|
|
161
|
+
const customFieldProps = property.admin?.customProps;
|
|
162
|
+
const { value, error, touched, isSubmitting } = slice;
|
|
163
|
+
const showError = Boolean(error && (slice.submitted || property.validation?.unique) && (!Array.isArray(error) || !!error.filter((e) => !!e).length));
|
|
164
|
+
const UsedComponent = useWrappedComponent({
|
|
165
|
+
path: context.path,
|
|
166
|
+
collection: context.collection,
|
|
167
|
+
propertyKey,
|
|
168
|
+
property,
|
|
169
|
+
Component,
|
|
170
|
+
plugins
|
|
171
|
+
}) ?? Component;
|
|
172
|
+
const setValue = useCallback((value, shouldValidate) => {
|
|
173
|
+
const formex = getFormex();
|
|
174
|
+
formex.setFieldTouched(propertyKey, true, false);
|
|
175
|
+
formex.setFieldValue(propertyKey, value, shouldValidate);
|
|
176
|
+
}, [getFormex, propertyKey]);
|
|
177
|
+
const setFieldValue = useCallback((otherPropertyKey, value, shouldValidate) => {
|
|
178
|
+
const formex = getFormex();
|
|
179
|
+
formex.setFieldTouched(propertyKey, true, false);
|
|
180
|
+
formex.setFieldValue(otherPropertyKey, value, shouldValidate);
|
|
181
|
+
}, [getFormex, propertyKey]);
|
|
182
|
+
useClearRestoreValue({
|
|
183
|
+
property,
|
|
184
|
+
value,
|
|
185
|
+
setValue
|
|
186
|
+
});
|
|
187
|
+
const onPropertyChangeRef = useRef(onPropertyChange);
|
|
188
|
+
onPropertyChangeRef.current = onPropertyChange;
|
|
189
|
+
const stableOnPropertyChange = useCallback((changed) => onPropertyChangeRef.current?.(changed), []);
|
|
190
|
+
return /* @__PURE__ */ jsxs(ErrorBoundary, { children: [
|
|
191
|
+
beforeField,
|
|
192
|
+
/* @__PURE__ */ jsx(Suspense, {
|
|
193
|
+
fallback: null,
|
|
194
|
+
children: /* @__PURE__ */ jsx(MemoisedField, {
|
|
195
|
+
Component: UsedComponent,
|
|
196
|
+
alwaysRender,
|
|
197
|
+
fieldProps: {
|
|
198
|
+
propertyKey,
|
|
199
|
+
value,
|
|
200
|
+
setValue,
|
|
201
|
+
setFieldValue,
|
|
202
|
+
error,
|
|
203
|
+
touched,
|
|
204
|
+
showError,
|
|
205
|
+
isSubmitting,
|
|
206
|
+
includeDescription: includeDescription ?? true,
|
|
207
|
+
hideLabel: hideLabel ?? false,
|
|
208
|
+
property,
|
|
209
|
+
disabled: disabled ?? false,
|
|
210
|
+
underlyingValueHasChanged: underlyingValueHasChanged ?? false,
|
|
211
|
+
partOfArray: partOfArray ?? false,
|
|
212
|
+
partOfBlock: partOfBlock ?? false,
|
|
213
|
+
minimalistView: minimalistView ?? false,
|
|
214
|
+
autoFocus: autoFocus ?? false,
|
|
215
|
+
customProps: customFieldProps,
|
|
216
|
+
context,
|
|
217
|
+
size,
|
|
218
|
+
onPropertyChange: onPropertyChange ? stableOnPropertyChange : void 0
|
|
219
|
+
}
|
|
220
|
+
})
|
|
221
|
+
}),
|
|
222
|
+
afterField,
|
|
223
|
+
underlyingValueHasChanged && !isSubmitting && /* @__PURE__ */ jsx(Typography, {
|
|
224
|
+
variant: "caption",
|
|
225
|
+
className: "ml-3.5",
|
|
226
|
+
children: t("value_updated_elsewhere")
|
|
227
|
+
})
|
|
228
|
+
] });
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* The field's own component, rendered again only when its own slice of the
|
|
232
|
+
* form changed — value, error, touched, the flags — or when the context it
|
|
233
|
+
* draws the record from did (see `fieldContext` in `EntityForm`). Every field
|
|
234
|
+
* of the form used to re-render on every keystroke anywhere in it.
|
|
235
|
+
*
|
|
236
|
+
* A field that may read *another* field's value while rendering cannot know
|
|
237
|
+
* when to re-render from its own props, so those always do: see
|
|
238
|
+
* {@link shouldPropertyReRender}.
|
|
239
|
+
*/
|
|
240
|
+
var MemoisedField = React.memo(function MemoisedField({ Component, fieldProps }) {
|
|
241
|
+
return /* @__PURE__ */ jsx(Component, { ...fieldProps });
|
|
242
|
+
}, (prev, next) => !next.alwaysRender && prev.Component === next.Component && sameProps(prev.fieldProps, next.fieldProps, DEEP_COMPARED_FIELD_PROPS));
|
|
243
|
+
/**
|
|
244
|
+
* Whether a field has to re-render on every change to the form, because what
|
|
245
|
+
* it draws can depend on values other than its own:
|
|
246
|
+
* - a plugin `fieldBuilder` wraps it in a component of the plugin's;
|
|
247
|
+
* - a custom `admin.Field` gets the whole form through `context`;
|
|
248
|
+
* - `dynamicProps` and `conditions` are functions of every value;
|
|
249
|
+
* - a storage path or file name given as a function is built from the values
|
|
250
|
+
* the binding holds;
|
|
251
|
+
* - a custom `propertyConfig` whose property says any of the above, since the
|
|
252
|
+
* field is resolved through it.
|
|
253
|
+
* Inside maps, arrays and blocks too, since their bindings render the children.
|
|
254
|
+
*/
|
|
255
|
+
var shouldPropertyReRender = (property, plugins, propertyConfigs) => {
|
|
256
|
+
if (!property) return false;
|
|
257
|
+
if (plugins?.some((plugin) => plugin.fieldBuilder)) return true;
|
|
258
|
+
const recurse = (child) => shouldPropertyReRender(child, plugins, propertyConfigs);
|
|
259
|
+
if (isPropertyBuilder(property) || property.conditions || property.admin?.Field) return true;
|
|
260
|
+
const storage = "storage" in property ? property.storage : void 0;
|
|
261
|
+
if (storage && (typeof storage.storagePath === "function" || typeof storage.fileName === "function")) return true;
|
|
262
|
+
const configProperty = property.propertyConfig ? propertyConfigs?.[property.propertyConfig]?.property : void 0;
|
|
263
|
+
if (configProperty && configProperty !== property && recurse(configProperty)) return true;
|
|
264
|
+
if (property.type === "map" && property.properties) return Object.values(property.properties).some(recurse);
|
|
265
|
+
if (property.type === "array") {
|
|
266
|
+
if (Array.isArray(property.of)) return property.of.some(recurse);
|
|
267
|
+
if (property.of && recurse(property.of)) return true;
|
|
268
|
+
if (property.oneOf?.properties) return Object.values(property.oneOf.properties).some(recurse);
|
|
269
|
+
}
|
|
270
|
+
return false;
|
|
271
|
+
};
|
|
272
|
+
function useWrappedComponent({ path, collection, propertyKey, property, Component, plugins }) {
|
|
273
|
+
return useRef((() => {
|
|
274
|
+
let Wrapped = null;
|
|
275
|
+
if (plugins) plugins.forEach((plugin) => {
|
|
276
|
+
const fieldId = getFieldId(property);
|
|
277
|
+
if (fieldId && plugin.fieldBuilder) {
|
|
278
|
+
const params = {
|
|
279
|
+
fieldConfigId: fieldId,
|
|
280
|
+
propertyKey,
|
|
281
|
+
property,
|
|
282
|
+
Field: Wrapped ?? Component,
|
|
283
|
+
plugin,
|
|
284
|
+
path,
|
|
285
|
+
collection
|
|
286
|
+
};
|
|
287
|
+
const enabled = plugin.fieldBuilder.enabled?.(params);
|
|
288
|
+
if (enabled === void 0 || enabled) Wrapped = plugin.fieldBuilder.wrap(params) ?? Wrapped;
|
|
289
|
+
}
|
|
290
|
+
if (!fieldId) console.warn("INTERNAL: Field id not found for property", property);
|
|
291
|
+
});
|
|
292
|
+
return Wrapped;
|
|
293
|
+
})()).current;
|
|
294
|
+
}
|
|
295
|
+
//#endregion
|
|
296
|
+
export { PropertyFieldBinding };
|
|
297
|
+
|
|
298
|
+
//# sourceMappingURL=PropertyFieldBinding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PropertyFieldBinding.js","names":[],"sources":["../../src/form/PropertyFieldBinding.tsx"],"sourcesContent":["\nimport type { FieldProps as CoreFieldProps, AdminCollection } from \"@rebasepro/cms-types\";\nimport type { FieldProps, PropertyFieldBindingProps } from \"../types/fields\";\nimport type { Property } from \"@rebasepro/types\";\nimport type { RebasePlugin, PluginFieldBuilderParams, PropertyConfig } from \"@rebasepro/cms-types\";\nimport React, { ComponentType, ReactElement, Suspense, useCallback, useRef } from \"react\";\nimport { deepEqual as equal } from \"fast-equals\"\n\nimport { resolveComponentRef } from \"@rebasepro/app\";\n\nimport { FormexController, getIn, useFormexGetter, useFormexSelector } from \"@rebasepro/forms\";\n\n;\nimport { ReadOnlyFieldBinding } from \"./field_bindings/ReadOnlyFieldBinding\";\nimport { resolveFormProperty } from \"./resolve_form_properties\";\nimport { useClearRestoreValue } from \"./useClearRestoreValue\";\n\nimport { isPropertyBuilder, resolveProperty } from \"@rebasepro/common\";\nimport { isDisabled, isHidden, isReadOnly } from \"@rebasepro/app\";\nimport { useAuthController, useCustomizationController, useRebaseContext, useSlot, useTranslation } from \"@rebasepro/app\";\nimport { Typography } from \"@rebasepro/ui\";\nimport { getFieldConfig, getFieldId } from \"../components/field_configs\";\nimport { ErrorBoundary } from \"@rebasepro/ui\";\n\n/**\n * This component renders a form field creating the corresponding configuration\n * from a property. For example if bound to a string property, it will generate\n * a text field.\n *\n * You can use it when you are creating a custom field, and need to\n * render additional fields mapped to properties. This is useful if you\n * need to build a complex property mapping, like an array where each index\n * is a different property.\n *\n * Please note that if you build a custom field in a component, the\n * **validation** passed in the property will have no effect. You need to set\n * the validation in the `AdminCollection` definition.\n *\n * @param propertyKey You can use nested names such as `address.street` or `friends[2]`\n * @param property\n * @param context\n * @param includeDescription\n * @param underlyingValueHasChanged\n * @param disabled\n * @param tableMode\n * @param partOfArray\n * @param autoFocus\n * @group Form custom fields\n */\nexport const PropertyFieldBinding = React.memo(PropertyFieldBindingInternal,\n (a: PropertyFieldBindingProps<Record<string, unknown>>, b: PropertyFieldBindingProps<Record<string, unknown>>) =>\n sameProps(a as unknown as Record<string, unknown>, b as unknown as Record<string, unknown>, DEEP_COMPARED_BINDING_PROPS)\n) as typeof PropertyFieldBindingInternal;\n\n/**\n * Props compared by value rather than identity: a property is re-resolved\n * (`dynamicProps`, enums, a parent's `mergeDeep`) into a new object on every\n * render of whatever holds it, and an error for an array or map is a new\n * sub-object of the errors map whenever anything is validated.\n */\nconst DEEP_COMPARED_BINDING_PROPS = new Set([\"property\"]);\nconst DEEP_COMPARED_FIELD_PROPS = new Set([\"property\", \"error\", \"customProps\"]);\n\nfunction sameProps(a: Record<string, unknown>, b: Record<string, unknown>, deep: Set<string>): boolean {\n const keys = new Set([...Object.keys(a), ...Object.keys(b)]);\n for (const key of keys) {\n if (Object.is(a[key], b[key])) continue;\n if (deep.has(key) && equal(a[key], b[key])) continue;\n return false;\n }\n return true;\n}\n\nfunction PropertyFieldBindingInternal<M extends Record<string, unknown> = Record<string, unknown>>\n({\n propertyKey,\n property,\n context,\n includeDescription,\n hideLabel,\n underlyingValueHasChanged,\n disabled: disabledProp,\n partOfArray,\n partOfBlock,\n minimalistView,\n autoFocus,\n index,\n size,\n onPropertyChange\n }: PropertyFieldBindingProps<M>): ReactElement<PropertyFieldBindingProps<M>> {\n\n const authController = useAuthController();\n const customizationController = useCustomizationController();\n // Decided on the property as declared: once resolved, a builder or a rule\n // no longer says it was one.\n const alwaysRender = shouldPropertyReRender(property as Property, customizationController.plugins, customizationController.propertyConfigs);\n\n // This field's own slice of the form, so a change anywhere else does not\n // reach it. Through the form's context — which `Field` read — every field\n // of a record form re-rendered on every keystroke anywhere in it: all 500\n // items of an array nobody was typing into. A field that reads the rest of\n // the form while rendering takes the whole controller, and with it every\n // change, as it always has.\n const selectSlice = useCallback((formex: FormexController<Record<string, unknown>>): FieldSlice => ({\n formex: alwaysRender ? formex : undefined,\n value: getIn(formex.values, propertyKey),\n error: getIn(formex.errors, propertyKey) as FieldSlice[\"error\"],\n touched: getIn(formex.touched, propertyKey) as boolean | undefined,\n submitted: formex.submitCount > 0,\n isSubmitting: formex.isSubmitting\n }), [propertyKey, alwaysRender]);\n const slice = useFormexSelector(selectSlice, sameSlice);\n const getFormex = useFormexGetter<Record<string, unknown>>();\n // What the property is resolved against. Read, not subscribed to, for a\n // field that is not `alwaysRender`: nothing it declares reads the values.\n const values = (slice.formex ?? getFormex()).values;\n\n let Component: ComponentType<FieldProps<Property, any, any>> | undefined;\n // `dynamicProps` and `conditions` both, as the save judges it.\n const resolvedProperty = resolveFormProperty({\n propertyKey,\n property: property,\n values,\n path: context.path,\n entityId: context.entityId,\n propertyConfigs: customizationController.propertyConfigs,\n index,\n authController\n }) as Property | null;\n\n const readOnly = resolvedProperty ? isReadOnly(resolvedProperty) : true;\n const disabled = disabledProp || readOnly || (resolvedProperty ? isDisabled(resolvedProperty) : false) || context.disabled;\n\n if (resolvedProperty === null || isHidden(resolvedProperty)) {\n return <></>;\n } else if (readOnly) {\n Component = ReadOnlyFieldBinding;\n } else if (resolvedProperty.admin?.Field) {\n const resolved = resolveComponentRef(resolvedProperty.admin.Field);\n if (resolved) {\n Component = resolved as ComponentType<FieldProps<Property, any, any>>;\n }\n } else {\n const propertyConfig = getFieldConfig(resolvedProperty, customizationController.propertyConfigs);\n if (!propertyConfig) {\n throw new Error(`INTERNAL: Could not find field config for property ${propertyKey}`);\n }\n const configProperty = resolveProperty({\n propertyKey,\n property: propertyConfig.property as Property,\n values,\n path: context.path,\n entityId: context.entityId,\n propertyConfigs: customizationController.propertyConfigs,\n index,\n authController\n }) as Property | null;\n Component = resolveComponentRef(configProperty?.admin?.Field) as ComponentType<FieldProps<Property, any, any>> | undefined;\n }\n if (!Component) {\n console.warn(`No field component found for property ${propertyKey}`);\n console.warn(\"Property:\", property);\n return (\n <div className={\"w-full\"}>\n {`Currently the field ${resolvedProperty.type} is not supported`}\n </div>\n );\n }\n\n const componentProps: ResolvedPropertyFieldBindingProps<M> = {\n propertyKey,\n property: resolvedProperty,\n includeDescription,\n hideLabel,\n underlyingValueHasChanged,\n context,\n disabled,\n partOfArray,\n partOfBlock,\n minimalistView,\n autoFocus,\n size,\n onPropertyChange\n };\n\n // Keyed on the path, as the `Field` it replaces was: an array item that\n // moves to another index is a new field there.\n return <FieldInternal\n key={propertyKey}\n Component={Component as ComponentType<FieldProps<Property, any, any>>}\n alwaysRender={alwaysRender}\n componentProps={componentProps}\n slice={slice}\n getFormex={getFormex}/>;\n\n}\n\n/**\n * What one field reads from the form. `formex` is set only for a field that\n * re-renders on every change (see {@link shouldPropertyReRender}).\n */\ntype FieldSlice = {\n formex: FormexController<Record<string, unknown>> | undefined;\n value: unknown;\n error: string | string[] | Record<string, unknown> | undefined;\n touched: boolean | undefined;\n submitted: boolean;\n isSubmitting: boolean;\n};\n\nfunction sameSlice(a: FieldSlice, b: FieldSlice): boolean {\n return a.formex === b.formex &&\n Object.is(a.value, b.value) &&\n a.touched === b.touched &&\n a.submitted === b.submitted &&\n a.isSubmitting === b.isSubmitting &&\n // An array's or a map's error is a sub-object of the errors map, new\n // whenever anything is validated.\n (Object.is(a.error, b.error) || equal(a.error, b.error));\n}\n\ntype ResolvedPropertyFieldBindingProps<M extends Record<string, unknown> = Record<string, unknown>> =\n Omit<PropertyFieldBindingProps<M>, \"property\">\n & {\n property: Property\n};\n\nfunction FieldInternal<CustomProps, M extends Record<string, unknown>>\n({\n Component,\n alwaysRender,\n componentProps: {\n propertyKey,\n property,\n includeDescription,\n hideLabel,\n underlyingValueHasChanged,\n partOfArray,\n partOfBlock,\n minimalistView,\n autoFocus,\n context,\n disabled,\n size,\n onPropertyChange\n },\n slice,\n getFormex\n }:\n {\n Component: ComponentType<FieldProps<Property, any, any>>,\n alwaysRender: boolean,\n componentProps: ResolvedPropertyFieldBindingProps<M>,\n slice: FieldSlice,\n getFormex: () => FormexController<Record<string, unknown>>\n }) {\n\n const { plugins } = useCustomizationController();\n const { t } = useTranslation();\n\n // This is the one component every form field goes through, which is why the\n // two field slots render here rather than in each field binding: a slot\n // honoured by the string field and not by the date field is worse than one\n // that never renders at all.\n const rebaseContext = useRebaseContext();\n const fieldSlotProps = React.useMemo(() => ({\n propertyKey,\n property,\n path: context.path ?? \"\",\n entityId: context.entityId,\n collection: context.collection,\n context: rebaseContext\n }), [propertyKey, property, context.path, context.entityId, context.collection, rebaseContext]);\n const beforeField = useSlot(\"entity.field.before\", fieldSlotProps);\n const afterField = useSlot(\"entity.field.after\", fieldSlotProps);\n\n const customFieldProps: unknown = property.admin?.customProps;\n const { value, error, touched, isSubmitting } = slice;\n\n const showError = Boolean(error &&\n (slice.submitted || property.validation?.unique) &&\n (!Array.isArray(error) || !!error.filter((e: unknown) => !!e).length));\n\n const WrappedComponent: ComponentType<FieldProps<Property, any, any>> | null = useWrappedComponent<unknown, any>({\n path: context.path,\n collection: context.collection,\n propertyKey: propertyKey,\n property: property,\n Component: Component as ComponentType<FieldProps<Property, unknown, M>>,\n plugins: plugins\n });\n const UsedComponent: ComponentType<FieldProps<Property, any, any>> = WrappedComponent ?? Component;\n\n // Read the controller when called, not when rendered: this component\n // re-renders with its own slice only, and the form moves on without it.\n const setValue = useCallback((value: unknown | null, shouldValidate?: boolean) => {\n const formex = getFormex();\n formex.setFieldTouched(propertyKey, true, false);\n formex.setFieldValue(propertyKey, value, shouldValidate);\n }, [getFormex, propertyKey]);\n\n const setFieldValue = useCallback((otherPropertyKey: string, value: unknown | null, shouldValidate?: boolean) => {\n const formex = getFormex();\n formex.setFieldTouched(propertyKey, true, false);\n formex.setFieldValue(otherPropertyKey, value, shouldValidate);\n }, [getFormex, propertyKey]);\n\n // `disabled: { clearOnDisabled: true }`, for every field: called here and\n // not in each binding, where six of them never did and a disabled relation\n // kept its value and saved it.\n useClearRestoreValue({ property: property as Property, value, setValue });\n\n // A parent that builds `onPropertyChange` inline (an array item's\n // `storeProps`, a map's wrapper) would otherwise hand every child a new\n // function on each of its renders, and every child would re-render for it.\n const onPropertyChangeRef = useRef(onPropertyChange);\n onPropertyChangeRef.current = onPropertyChange;\n const stableOnPropertyChange = useCallback((changed: Partial<Property>) => onPropertyChangeRef.current?.(changed), []);\n\n const cmsFieldProps: FieldProps<Property, CustomProps, M> = {\n propertyKey,\n value,\n setValue,\n setFieldValue,\n error: error as string | undefined,\n touched,\n showError,\n isSubmitting,\n includeDescription: includeDescription ?? true,\n hideLabel: hideLabel ?? false,\n property: property as Property,\n disabled: disabled ?? false,\n underlyingValueHasChanged: underlyingValueHasChanged ?? false,\n partOfArray: partOfArray ?? false,\n partOfBlock: partOfBlock ?? false,\n minimalistView: minimalistView ?? false,\n autoFocus: autoFocus ?? false,\n customProps: customFieldProps as CustomProps,\n context,\n size,\n onPropertyChange: onPropertyChange ? stableOnPropertyChange : undefined\n };\n\n return (\n <ErrorBoundary>\n {beforeField}\n\n <Suspense fallback={null}>\n <MemoisedField Component={UsedComponent}\n alwaysRender={alwaysRender}\n fieldProps={cmsFieldProps as FieldProps<Property, any, any>}/>\n </Suspense>\n\n {afterField}\n\n {underlyingValueHasChanged && !isSubmitting &&\n <Typography variant={\"caption\"} className={\"ml-3.5\"}>\n {t(\"value_updated_elsewhere\")}\n </Typography>}\n\n </ErrorBoundary>);\n\n}\n\ntype MemoisedFieldProps = {\n Component: ComponentType<FieldProps<Property, any, any>>,\n alwaysRender: boolean,\n fieldProps: FieldProps<Property, any, any>\n};\n\n/**\n * The field's own component, rendered again only when its own slice of the\n * form changed — value, error, touched, the flags — or when the context it\n * draws the record from did (see `fieldContext` in `EntityForm`). Every field\n * of the form used to re-render on every keystroke anywhere in it.\n *\n * A field that may read *another* field's value while rendering cannot know\n * when to re-render from its own props, so those always do: see\n * {@link shouldPropertyReRender}.\n */\nconst MemoisedField = React.memo(\n function MemoisedField({ Component, fieldProps }: MemoisedFieldProps) {\n return <Component {...fieldProps}/>;\n },\n (prev: MemoisedFieldProps, next: MemoisedFieldProps) =>\n !next.alwaysRender &&\n prev.Component === next.Component &&\n sameProps(prev.fieldProps as unknown as Record<string, unknown>, next.fieldProps as unknown as Record<string, unknown>, DEEP_COMPARED_FIELD_PROPS)\n);\n\n/**\n * Whether a field has to re-render on every change to the form, because what\n * it draws can depend on values other than its own:\n * - a plugin `fieldBuilder` wraps it in a component of the plugin's;\n * - a custom `admin.Field` gets the whole form through `context`;\n * - `dynamicProps` and `conditions` are functions of every value;\n * - a storage path or file name given as a function is built from the values\n * the binding holds;\n * - a custom `propertyConfig` whose property says any of the above, since the\n * field is resolved through it.\n * Inside maps, arrays and blocks too, since their bindings render the children.\n */\nconst shouldPropertyReRender = (property: Property | undefined, plugins?: RebasePlugin[], propertyConfigs?: Record<string, PropertyConfig>): boolean => {\n if (!property) return false;\n if (plugins?.some((plugin) => plugin.fieldBuilder)) {\n return true;\n }\n const recurse = (child: unknown) => shouldPropertyReRender(child as Property, plugins, propertyConfigs);\n if (isPropertyBuilder(property) || property.conditions || property.admin?.Field) {\n return true;\n }\n const storage = \"storage\" in property ? property.storage : undefined;\n if (storage && (typeof storage.storagePath === \"function\" || typeof storage.fileName === \"function\")) {\n return true;\n }\n const configProperty = property.propertyConfig ? propertyConfigs?.[property.propertyConfig]?.property : undefined;\n if (configProperty && configProperty !== property && recurse(configProperty)) {\n return true;\n }\n if (property.type === \"map\" && property.properties) {\n return Object.values(property.properties).some(recurse);\n }\n if (property.type === \"array\") {\n if (Array.isArray(property.of)) {\n return property.of.some(recurse);\n }\n if (property.of && recurse(property.of)) {\n return true;\n }\n if (property.oneOf?.properties) {\n return Object.values(property.oneOf.properties).some(recurse);\n }\n }\n return false;\n}\n\ninterface UseWrappedComponentParams<M extends Record<string, unknown> = Record<string, unknown>> {\n path?: string,\n collection?: AdminCollection<M>,\n propertyKey: string,\n property: Property,\n Component: ComponentType<FieldProps<Property, unknown, M>>,\n plugins?: RebasePlugin[]\n}\n\nfunction useWrappedComponent<T, M extends Record<string, unknown> = Record<string, unknown>>(\n {\n path,\n collection,\n propertyKey,\n property,\n Component,\n plugins\n }: UseWrappedComponentParams<M>\n): ComponentType<FieldProps<Property, unknown, M>> | null {\n\n // A fold, in plugin order: each plugin's `wrap` is handed the field as the\n // plugins before it left it, so every wrapper renders — the first plugin's\n // closest to the field, the last one's outermost. A plugin that returns\n // null, or is not `enabled` for this field, passes it on unchanged.\n const wrapperRef = useRef<ComponentType<FieldProps<Property, unknown, M>> | null>((() => {\n let Wrapped: ComponentType<FieldProps<Property, unknown, M>> | null = null;\n if (plugins) {\n plugins.forEach((plugin) => {\n const fieldId = getFieldId(property);\n if (fieldId && plugin.fieldBuilder) {\n const params: PluginFieldBuilderParams = {\n fieldConfigId: fieldId,\n propertyKey,\n property,\n Field: (Wrapped ?? Component) as ComponentType<CoreFieldProps<Property, unknown, Record<string, unknown>>>,\n plugin,\n path,\n collection: collection as AdminCollection | undefined\n };\n const enabled = plugin.fieldBuilder.enabled?.(params);\n if (enabled === undefined || enabled)\n Wrapped = (plugin.fieldBuilder.wrap(params) as ComponentType<FieldProps<Property, unknown, M>> | null) ?? Wrapped;\n }\n if (!fieldId) {\n console.warn(\"INTERNAL: Field id not found for property\", property);\n }\n });\n }\n return Wrapped;\n })());\n\n return wrapperRef.current;\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useEffect, useRef } from "react";
|
|
2
|
+
import { useFormex } from "@rebasepro/forms";
|
|
3
|
+
//#region src/form/components/ErrorFocus.tsx
|
|
4
|
+
var ErrorFocus = ({ containerRef }) => {
|
|
5
|
+
const { isValidating, errors, version } = useFormex();
|
|
6
|
+
const prevVersion = useRef(version);
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
if (version === prevVersion.current) return;
|
|
9
|
+
const keys = Object.keys(errors);
|
|
10
|
+
if (!isValidating && keys.length > 0) {
|
|
11
|
+
const errorElement = containerRef?.current?.querySelector(`#form_field_${keys[0]}`);
|
|
12
|
+
if (errorElement) {
|
|
13
|
+
errorElement.scrollIntoView({
|
|
14
|
+
behavior: "smooth",
|
|
15
|
+
block: "center"
|
|
16
|
+
});
|
|
17
|
+
const input = errorElement.querySelector("input");
|
|
18
|
+
if (input) input.focus();
|
|
19
|
+
}
|
|
20
|
+
prevVersion.current = version;
|
|
21
|
+
}
|
|
22
|
+
}, [
|
|
23
|
+
isValidating,
|
|
24
|
+
errors,
|
|
25
|
+
containerRef,
|
|
26
|
+
version
|
|
27
|
+
]);
|
|
28
|
+
return null;
|
|
29
|
+
};
|
|
30
|
+
//#endregion
|
|
31
|
+
export { ErrorFocus };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=ErrorFocus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorFocus.js","names":[],"sources":["../../../src/form/components/ErrorFocus.tsx"],"sourcesContent":["import React, { useEffect, useRef } from \"react\";\nimport { useFormex } from \"@rebasepro/forms\";\n\nexport const ErrorFocus = ({ containerRef }:\n {\n containerRef?: React.RefObject<HTMLDivElement | null>\n }) => {\n const {\n isValidating,\n errors,\n version\n } = useFormex();\n\n const prevVersion = useRef(version);\n\n useEffect(() => {\n\n if (version === prevVersion.current) {\n return;\n }\n\n const keys = Object.keys(errors);\n\n // Whenever there are errors and the form has been submitted and is not validating\n if (!isValidating && keys.length > 0) {\n const errorElement = containerRef?.current?.querySelector<HTMLDivElement>(\n `#form_field_${keys[0]}`\n );\n\n if (errorElement) {\n errorElement.scrollIntoView({\n behavior: \"smooth\",\n block: \"center\"\n });\n const input = errorElement.querySelector(\"input\");\n if (input) input.focus();\n }\n prevVersion.current = version;\n }\n }, [isValidating, errors, containerRef, version]);\n\n // This component does not render anything by itself.\n return null;\n};\n"],"mappings":";;;AAGA,IAAa,cAAc,EAAE,mBAGnB;CACN,MAAM,EACF,cACA,QACA,YACA,UAAU;CAEd,MAAM,cAAc,OAAO,OAAO;CAElC,gBAAgB;EAEZ,IAAI,YAAY,YAAY,SACxB;EAGJ,MAAM,OAAO,OAAO,KAAK,MAAM;EAG/B,IAAI,CAAC,gBAAgB,KAAK,SAAS,GAAG;GAClC,MAAM,eAAe,cAAc,SAAS,cACxC,eAAe,KAAK,IACxB;GAEA,IAAI,cAAc;IACd,aAAa,eAAe;KACxB,UAAU;KACV,OAAO;IACX,CAAC;IACD,MAAM,QAAQ,aAAa,cAAc,OAAO;IAChD,IAAI,OAAO,MAAM,MAAM;GAC3B;GACA,YAAY,UAAU;EAC1B;CACJ,GAAG;EAAC;EAAc;EAAQ;EAAc;CAAO,CAAC;CAGhD,OAAO;AACX"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { getIconForProperty } from "../../util/property_utils.js";
|
|
2
|
+
import { PropertyKeyHint } from "../../components/PropertyKeyHint.js";
|
|
3
|
+
import "react";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { ErrorBoundary, Typography, cls } from "@rebasepro/ui";
|
|
6
|
+
//#region src/form/components/FieldBlock.tsx
|
|
7
|
+
/**
|
|
8
|
+
* Grid placement for a span.
|
|
9
|
+
*
|
|
10
|
+
* Written out as literal class strings rather than composed, because Tailwind
|
|
11
|
+
* scans source text: a template literal would produce classes that exist at
|
|
12
|
+
* runtime and were never generated into the stylesheet.
|
|
13
|
+
*
|
|
14
|
+
* Below the column breakpoint every field takes the single available column, so
|
|
15
|
+
* the side panel, the dialog and mobile all get a plain stack.
|
|
16
|
+
*
|
|
17
|
+
* Lives here rather than in the form, because the read-only rendering of a
|
|
18
|
+
* record places its fields on the same grid — a record that changes shape when
|
|
19
|
+
* you press Edit is the bug this whole layout exists to avoid.
|
|
20
|
+
*/
|
|
21
|
+
function spanClass(span) {
|
|
22
|
+
switch (span) {
|
|
23
|
+
case 1: return "@2xl/col:col-span-1";
|
|
24
|
+
case 2: return "@2xl/col:col-span-2";
|
|
25
|
+
case 3: return "@2xl/col:col-span-3";
|
|
26
|
+
case 4: return "@2xl/col:col-span-4";
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Does this property's editor supply its own heading?
|
|
31
|
+
*
|
|
32
|
+
* Arrays, maps, `oneOf` blocks and key-value editors render as a collapsible
|
|
33
|
+
* panel whose header *is* the label — hiding it would leave a panel you cannot
|
|
34
|
+
* identify or, worse, cannot expand. Those keep their own; everything else gets
|
|
35
|
+
* its label from {@link FieldBlock}, which is what makes a text field and a
|
|
36
|
+
* select finally agree on where a label goes.
|
|
37
|
+
*
|
|
38
|
+
* Exported because the layout resolver's span rules and this rule have to stay
|
|
39
|
+
* in step: the self-labelling types are exactly the ones that take a full row.
|
|
40
|
+
*/
|
|
41
|
+
function isSelfLabellingProperty(property) {
|
|
42
|
+
if (!property) return false;
|
|
43
|
+
switch (property.type) {
|
|
44
|
+
case "map": return !property.admin?.spreadChildren;
|
|
45
|
+
case "array": {
|
|
46
|
+
if (property.oneOf) return true;
|
|
47
|
+
if (Array.isArray(property.of) || !property.of) return true;
|
|
48
|
+
const of = property.of;
|
|
49
|
+
if (of.type === "string" && (of.enum || of.storage)) return false;
|
|
50
|
+
if (of.type === "number" && of.enum) return false;
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
default: return false;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The type icon in a field label, in px.
|
|
58
|
+
*
|
|
59
|
+
* Matched to the label's 13px rather than taken from `iconSize.smallest` (16),
|
|
60
|
+
* which is sized for buttons. Exported so the surfaces that draw a label
|
|
61
|
+
* themselves — the additional-field cards, the rail — can stay in step.
|
|
62
|
+
*/
|
|
63
|
+
var LABEL_ICON_SIZE = 14;
|
|
64
|
+
/**
|
|
65
|
+
* One field's worth of the form grid: label, control, description.
|
|
66
|
+
*
|
|
67
|
+
* The same block frames the read-only rendering of a record, so a field sits in
|
|
68
|
+
* the same place, at the same width, under the same label whether or not you are
|
|
69
|
+
* editing it — see {@link EntityViewBinding}.
|
|
70
|
+
*
|
|
71
|
+
* The label is one size down from the control it names (13px against the body's
|
|
72
|
+
* 14) with its icon matched to it at 14px. Labels are scaffolding: you read them
|
|
73
|
+
* to find the value, then read the value. Setting them at body size made a
|
|
74
|
+
* column of records scan as a column of field names with data attached.
|
|
75
|
+
*/
|
|
76
|
+
function FieldBlock({ propertyKey, property, showLabel, mode = "edit", label, icon, children }) {
|
|
77
|
+
const reading = mode === "read";
|
|
78
|
+
const description = property?.description?.trim();
|
|
79
|
+
const required = Boolean(property?.validation?.required);
|
|
80
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
81
|
+
id: `form_field_${propertyKey}`,
|
|
82
|
+
className: "relative flex flex-col min-w-0",
|
|
83
|
+
children: [
|
|
84
|
+
showLabel && /* @__PURE__ */ jsxs("div", {
|
|
85
|
+
className: cls("group/label flex items-center gap-1.5 min-w-0 font-medium leading-tight mb-1.5", "text-[13px] text-text-primary dark:text-text-primary-dark"),
|
|
86
|
+
children: [
|
|
87
|
+
(property || icon) && /* @__PURE__ */ jsx("span", {
|
|
88
|
+
className: "shrink-0 text-text-disabled dark:text-text-disabled-dark",
|
|
89
|
+
children: property ? getIconForProperty(property, 14) : icon
|
|
90
|
+
}),
|
|
91
|
+
/* @__PURE__ */ jsx("span", {
|
|
92
|
+
className: "truncate",
|
|
93
|
+
children: property?.name ?? label ?? propertyKey
|
|
94
|
+
}),
|
|
95
|
+
required && /* @__PURE__ */ jsx("span", {
|
|
96
|
+
className: "text-red-500 dark:text-red-500 -ml-1",
|
|
97
|
+
children: "*"
|
|
98
|
+
}),
|
|
99
|
+
property && /* @__PURE__ */ jsx(PropertyKeyHint, { propertyKey })
|
|
100
|
+
]
|
|
101
|
+
}),
|
|
102
|
+
/* @__PURE__ */ jsx("div", {
|
|
103
|
+
className: "min-w-0",
|
|
104
|
+
children: /* @__PURE__ */ jsx(ErrorBoundary, { children })
|
|
105
|
+
}),
|
|
106
|
+
showLabel && description && !reading && /* @__PURE__ */ jsx(Typography, {
|
|
107
|
+
variant: "caption",
|
|
108
|
+
color: "disabled",
|
|
109
|
+
className: "mt-1.5 ml-0.5 leading-snug",
|
|
110
|
+
children: description
|
|
111
|
+
})
|
|
112
|
+
]
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
//#endregion
|
|
116
|
+
export { FieldBlock, LABEL_ICON_SIZE, isSelfLabellingProperty, spanClass };
|
|
117
|
+
|
|
118
|
+
//# sourceMappingURL=FieldBlock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FieldBlock.js","names":[],"sources":["../../../src/form/components/FieldBlock.tsx"],"sourcesContent":["import type { Property } from \"@rebasepro/types\";\nimport type { PropertySpan } from \"@rebasepro/cms-types\";\nimport React from \"react\";\nimport { cls, ErrorBoundary, Typography } from \"@rebasepro/ui\";\nimport { getIconForProperty } from \"../../util/property_utils\";\nimport { PropertyKeyHint } from \"../../components/PropertyKeyHint\";\n\n/**\n * Grid placement for a span.\n *\n * Written out as literal class strings rather than composed, because Tailwind\n * scans source text: a template literal would produce classes that exist at\n * runtime and were never generated into the stylesheet.\n *\n * Below the column breakpoint every field takes the single available column, so\n * the side panel, the dialog and mobile all get a plain stack.\n *\n * Lives here rather than in the form, because the read-only rendering of a\n * record places its fields on the same grid — a record that changes shape when\n * you press Edit is the bug this whole layout exists to avoid.\n */\nexport function spanClass(span: PropertySpan): string {\n switch (span) {\n case 1: return \"@2xl/col:col-span-1\";\n case 2: return \"@2xl/col:col-span-2\";\n case 3: return \"@2xl/col:col-span-3\";\n case 4: return \"@2xl/col:col-span-4\";\n }\n}\n\n/**\n * Does this property's editor supply its own heading?\n *\n * Arrays, maps, `oneOf` blocks and key-value editors render as a collapsible\n * panel whose header *is* the label — hiding it would leave a panel you cannot\n * identify or, worse, cannot expand. Those keep their own; everything else gets\n * its label from {@link FieldBlock}, which is what makes a text field and a\n * select finally agree on where a label goes.\n *\n * Exported because the layout resolver's span rules and this rule have to stay\n * in step: the self-labelling types are exactly the ones that take a full row.\n */\nexport function isSelfLabellingProperty(property: Property | undefined): boolean {\n if (!property) return false;\n switch (property.type) {\n case \"map\":\n // `spreadChildren` inlines the children into the parent grid, so\n // there is no panel and therefore no header to reuse as the label.\n return !property.admin?.spreadChildren;\n case \"array\": {\n // Most arrays render as an expandable panel whose header is the\n // label — `repeat`, `block`, `custom_array`, `multi_references`.\n // The exceptions are the ones that resolve to an inline control:\n // an enum array is a multi-select and a storage array is a\n // dropzone, and both take their label from the form.\n //\n // This mirrors `getFieldConfig`'s array branch. Getting it backwards\n // is visible: an array of plain strings is a `repeat` panel, and\n // treating it as inline printed \"Available Locales\" twice, once\n // from the form and once from the panel's own header.\n if (property.oneOf) return true;\n if (Array.isArray(property.of) || !property.of) return true;\n const of = property.of;\n if (of.type === \"string\" && (of.enum || of.storage)) return false;\n if (of.type === \"number\" && of.enum) return false;\n return true;\n }\n default:\n return false;\n }\n}\n\n/**\n * The type icon in a field label, in px.\n *\n * Matched to the label's 13px rather than taken from `iconSize.smallest` (16),\n * which is sized for buttons. Exported so the surfaces that draw a label\n * themselves — the additional-field cards, the rail — can stay in step.\n */\nexport const LABEL_ICON_SIZE = 14;\n\nexport interface FieldBlockProps {\n propertyKey: string;\n property?: Property;\n /** Rendered by the form rather than by the field, unless self-labelling. */\n showLabel: boolean;\n /**\n * Which of the two renderings this block frames.\n *\n * The **label is identical in both** — same size, same weight, same colour,\n * same type icon, same required marker. A field is the same field whether or\n * not you are editing it, and a record whose labels restyle themselves under\n * Edit reads as two different screens.\n *\n * What `\"read\"` drops is the *description*, which is not part of the label:\n * it is input help. \"Sum of all line items before tax and shipping\" under a\n * number that is visibly a sum tells a reader nothing, and a line of it\n * under every field is what a record has instead of room.\n */\n mode?: \"edit\" | \"read\";\n /**\n * Label text, when there is no property to take it from.\n *\n * For additional fields, which are columns a collection computes rather\n * than stores. They go on the same grid as the properties and so have to\n * carry the same label — drawing their own is how they ended up a size out\n * and a couple of pixels off from the field beside them.\n */\n label?: string;\n /** Type icon, when there is no property to derive one from. */\n icon?: React.ReactNode;\n children: React.ReactNode;\n}\n\n/**\n * One field's worth of the form grid: label, control, description.\n *\n * The same block frames the read-only rendering of a record, so a field sits in\n * the same place, at the same width, under the same label whether or not you are\n * editing it — see {@link EntityViewBinding}.\n *\n * The label is one size down from the control it names (13px against the body's\n * 14) with its icon matched to it at 14px. Labels are scaffolding: you read them\n * to find the value, then read the value. Setting them at body size made a\n * column of records scan as a column of field names with data attached.\n */\nexport function FieldBlock({\n propertyKey,\n property,\n showLabel,\n mode = \"edit\",\n label,\n icon,\n children\n}: FieldBlockProps) {\n\n const reading = mode === \"read\";\n const description = property?.description?.trim();\n const required = Boolean(property?.validation?.required);\n\n return (\n // Top-aligned: with the description below the control, every label is a\n // single line, so the controls line up on their own. (Bottom-aligning\n // was only needed while the description sat between label and control.)\n <div\n id={`form_field_${propertyKey}`}\n className={\"relative flex flex-col min-w-0\"}>\n\n {showLabel && (\n <div className={cls(\n \"group/label flex items-center gap-1.5 min-w-0 font-medium leading-tight mb-1.5\",\n // Primary, not secondary: the label names the field and the\n // reference sets its labels in the primary ink; the type icon\n // beside it stays muted so the name carries the row.\n \"text-[13px] text-text-primary dark:text-text-primary-dark\"\n )}>\n {/* Small and quiet: enough to tell a number from a\n relation at a glance, not enough to compete with the\n field name. Matched to the label's 13px rather than\n left at the 16px `smallest` token, which put the\n heaviest mark on the row on the least important\n thing in it. */}\n {(property || icon) && (\n <span className={\"shrink-0 text-text-disabled dark:text-text-disabled-dark\"}>\n {property ? getIconForProperty(property, LABEL_ICON_SIZE) : icon}\n </span>\n )}\n <span className={\"truncate\"}>{property?.name ?? label ?? propertyKey}</span>\n {required && <span className={\"text-red-500 dark:text-red-500 -ml-1\"}>*</span>}\n {/* In the row, not over it. This was a tooltip on the\n label and on the control, which opened whenever a\n field took focus and covered the label being read. */}\n {property && <PropertyKeyHint propertyKey={propertyKey}/>}\n </div>\n )}\n\n <div className={\"min-w-0\"}>\n <ErrorBoundary>\n {children}\n </ErrorBoundary>\n </div>\n\n {/* Under the control, where it reads as a note about the thing you\n just filled in rather than a subtitle of the next label. */}\n {showLabel && description && !reading && (\n <Typography variant={\"caption\"}\n color={\"disabled\"}\n className={\"mt-1.5 ml-0.5 leading-snug\"}>\n {description}\n </Typography>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAqBA,SAAgB,UAAU,MAA4B;CAClD,QAAQ,MAAR;EACI,KAAK,GAAG,OAAO;EACf,KAAK,GAAG,OAAO;EACf,KAAK,GAAG,OAAO;EACf,KAAK,GAAG,OAAO;CACnB;AACJ;;;;;;;;;;;;;AAcA,SAAgB,wBAAwB,UAAyC;CAC7E,IAAI,CAAC,UAAU,OAAO;CACtB,QAAQ,SAAS,MAAjB;EACI,KAAK,OAGD,OAAO,CAAC,SAAS,OAAO;EAC5B,KAAK,SAAS;GAWV,IAAI,SAAS,OAAO,OAAO;GAC3B,IAAI,MAAM,QAAQ,SAAS,EAAE,KAAK,CAAC,SAAS,IAAI,OAAO;GACvD,MAAM,KAAK,SAAS;GACpB,IAAI,GAAG,SAAS,aAAa,GAAG,QAAQ,GAAG,UAAU,OAAO;GAC5D,IAAI,GAAG,SAAS,YAAY,GAAG,MAAM,OAAO;GAC5C,OAAO;EACX;EACA,SACI,OAAO;CACf;AACJ;;;;;;;;AASA,IAAa,kBAAkB;;;;;;;;;;;;;AA+C/B,SAAgB,WAAW,EACvB,aACA,UACA,WACA,OAAO,QACP,OACA,MACA,YACgB;CAEhB,MAAM,UAAU,SAAS;CACzB,MAAM,cAAc,UAAU,aAAa,KAAK;CAChD,MAAM,WAAW,QAAQ,UAAU,YAAY,QAAQ;CAEvD,OAII,qBAAC,OAAD;EACI,IAAI,cAAc;EAClB,WAAW;YAFf;GAIK,aACG,qBAAC,OAAD;IAAK,WAAW,IACZ,kFAIA,2DACJ;cANA;MAaM,YAAY,SACV,oBAAC,QAAD;MAAM,WAAW;gBACZ,WAAW,mBAAmB,UAAA,EAAyB,IAAI;KAC1D,CAAA;KAEV,oBAAC,QAAD;MAAM,WAAW;gBAAa,UAAU,QAAQ,SAAS;KAAkB,CAAA;KAC1E,YAAY,oBAAC,QAAD;MAAM,WAAW;gBAAwC;KAAO,CAAA;KAI5E,YAAY,oBAAC,iBAAD,EAA8B,YAAa,CAAA;IACvD;;GAGT,oBAAC,OAAD;IAAK,WAAW;cACZ,oBAAC,eAAD,EACK,SACU,CAAA;GACd,CAAA;GAIJ,aAAa,eAAe,CAAC,WAC1B,oBAAC,YAAD;IAAY,SAAS;IACjB,OAAO;IACP,WAAW;cACV;GACO,CAAA;EAEf;;AAEb"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Typography } from "@rebasepro/ui";
|
|
3
|
+
//#region src/form/components/FieldHelperText.tsx
|
|
4
|
+
/**
|
|
5
|
+
* Normalize an error value to a displayable string.
|
|
6
|
+
* Handles cases where the error is an array (e.g. per-element validation
|
|
7
|
+
* errors from array fields) or an object (e.g. raw Zod issue objects).
|
|
8
|
+
*/
|
|
9
|
+
function normalizeError(error) {
|
|
10
|
+
if (error === void 0 || error === null) return void 0;
|
|
11
|
+
if (typeof error === "string") return error;
|
|
12
|
+
if (Array.isArray(error)) {
|
|
13
|
+
const firstError = error.find((e) => !!e);
|
|
14
|
+
if (!firstError) return void 0;
|
|
15
|
+
return normalizeError(firstError);
|
|
16
|
+
}
|
|
17
|
+
if (typeof error === "object") {
|
|
18
|
+
if ("message" in error) return String(error.message);
|
|
19
|
+
const messages = [];
|
|
20
|
+
const extractMessages = (obj) => {
|
|
21
|
+
for (const key in obj) if (typeof obj[key] === "string") messages.push(obj[key]);
|
|
22
|
+
else if (typeof obj[key] === "object" && obj[key] !== null) extractMessages(obj[key]);
|
|
23
|
+
};
|
|
24
|
+
extractMessages(error);
|
|
25
|
+
if (messages.length > 0) return Array.from(new Set(messages)).join(", ");
|
|
26
|
+
}
|
|
27
|
+
return String(error);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Component in charge of rendering the description of a field
|
|
31
|
+
* as well as the error message if any.
|
|
32
|
+
*/
|
|
33
|
+
function FieldHelperText({ error, showError, property, includeDescription = true, disabled }) {
|
|
34
|
+
const displayError = normalizeError(error);
|
|
35
|
+
const hasDescription = property.description !== void 0 && property.description.trim().length > 0;
|
|
36
|
+
if (!(showError && displayError) && (!includeDescription || !hasDescription)) return null;
|
|
37
|
+
if (showError && displayError) return /* @__PURE__ */ jsx(Typography, {
|
|
38
|
+
variant: "caption",
|
|
39
|
+
className: "ml-3.5 text-red-500 dark:text-red-500",
|
|
40
|
+
children: displayError
|
|
41
|
+
});
|
|
42
|
+
const disabledTooltip = typeof property.admin?.disabled === "object" ? property.admin?.disabled.disabledMessage : void 0;
|
|
43
|
+
return /* @__PURE__ */ jsx("div", {
|
|
44
|
+
className: "flex ml-3.5 mt-1",
|
|
45
|
+
children: /* @__PURE__ */ jsx(Typography, {
|
|
46
|
+
variant: "caption",
|
|
47
|
+
color: disabled ? "disabled" : "secondary",
|
|
48
|
+
className: "grow",
|
|
49
|
+
children: disabledTooltip || property.description
|
|
50
|
+
})
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
export { FieldHelperText };
|
|
55
|
+
|
|
56
|
+
//# sourceMappingURL=FieldHelperText.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FieldHelperText.js","names":[],"sources":["../../../src/form/components/FieldHelperText.tsx"],"sourcesContent":["import type { Property } from \"@rebasepro/types\";\nimport { IconButton, InfoIcon, Tooltip, Typography } from \"@rebasepro/ui\";\n\n/**\n * Normalize an error value to a displayable string.\n * Handles cases where the error is an array (e.g. per-element validation\n * errors from array fields) or an object (e.g. raw Zod issue objects).\n */\nfunction normalizeError(error: unknown): string | undefined {\n if (error === undefined || error === null) return undefined;\n if (typeof error === \"string\") return error;\n if (Array.isArray(error)) {\n // Find the first non-falsy element and extract its message\n const firstError = error.find((e) => !!e);\n if (!firstError) return undefined;\n return normalizeError(firstError);\n }\n if (typeof error === \"object\") {\n if (\"message\" in error) {\n return String((error as { message: unknown }).message);\n }\n\n // Extract all string values from the object (e.g., nested validation errors)\n const messages: string[] = [];\n const extractMessages = (obj: Record<string, unknown>) => {\n for (const key in obj) {\n if (typeof obj[key] === \"string\") {\n messages.push(obj[key] as string);\n } else if (typeof obj[key] === \"object\" && obj[key] !== null) {\n extractMessages(obj[key] as Record<string, unknown>);\n }\n }\n };\n extractMessages(error as Record<string, unknown>);\n if (messages.length > 0) {\n return Array.from(new Set(messages)).join(\", \");\n }\n }\n return String(error);\n}\n\n/**\n * Component in charge of rendering the description of a field\n * as well as the error message if any.\n */\nexport function FieldHelperText<T>({\n error,\n showError,\n property,\n includeDescription = true,\n disabled\n}: {\n error?: string,\n showError?: boolean,\n property: Property | Property,\n includeDescription?: boolean,\n disabled?: boolean,\n}\n) {\n\n const displayError = normalizeError(error);\n const hasDescription = property.description !== undefined && property.description.trim().length > 0;\n\n if (!(showError && displayError) && (!includeDescription || !hasDescription))\n return null;\n\n if (showError && displayError) {\n return <Typography variant={\"caption\"}\n className={\"ml-3.5 text-red-500 dark:text-red-500\"}>\n {displayError}\n </Typography>\n }\n\n const disabledTooltip: string | undefined = typeof property.admin?.disabled === \"object\" ? property.admin?.disabled.disabledMessage : undefined;\n\n return <div className={\"flex ml-3.5 mt-1\"}>\n <Typography variant={\"caption\"}\n color={disabled ? \"disabled\" : \"secondary\"}\n className={\"grow\"}>\n {disabledTooltip || property.description}\n </Typography>\n\n </div>\n}\n"],"mappings":";;;;;;;;AAQA,SAAS,eAAe,OAAoC;CACxD,IAAI,UAAU,KAAA,KAAa,UAAU,MAAM,OAAO,KAAA;CAClD,IAAI,OAAO,UAAU,UAAU,OAAO;CACtC,IAAI,MAAM,QAAQ,KAAK,GAAG;EAEtB,MAAM,aAAa,MAAM,MAAM,MAAM,CAAC,CAAC,CAAC;EACxC,IAAI,CAAC,YAAY,OAAO,KAAA;EACxB,OAAO,eAAe,UAAU;CACpC;CACA,IAAI,OAAO,UAAU,UAAU;EAC3B,IAAI,aAAa,OACb,OAAO,OAAQ,MAA+B,OAAO;EAIzD,MAAM,WAAqB,CAAC;EAC5B,MAAM,mBAAmB,QAAiC;GACtD,KAAK,MAAM,OAAO,KACd,IAAI,OAAO,IAAI,SAAS,UACpB,SAAS,KAAK,IAAI,IAAc;QAC7B,IAAI,OAAO,IAAI,SAAS,YAAY,IAAI,SAAS,MACpD,gBAAgB,IAAI,IAA+B;EAG/D;EACA,gBAAgB,KAAgC;EAChD,IAAI,SAAS,SAAS,GAClB,OAAO,MAAM,KAAK,IAAI,IAAI,QAAQ,CAAC,CAAC,CAAC,KAAK,IAAI;CAEtD;CACA,OAAO,OAAO,KAAK;AACvB;;;;;AAMA,SAAgB,gBAAmB,EAC/B,OACA,WACA,UACA,qBAAqB,MACrB,YAQF;CAEE,MAAM,eAAe,eAAe,KAAK;CACzC,MAAM,iBAAiB,SAAS,gBAAgB,KAAA,KAAa,SAAS,YAAY,KAAK,CAAC,CAAC,SAAS;CAElG,IAAI,EAAE,aAAa,kBAAkB,CAAC,sBAAsB,CAAC,iBACzD,OAAO;CAEX,IAAI,aAAa,cACb,OAAO,oBAAC,YAAD;EAAY,SAAS;EACxB,WAAW;YACV;CACO,CAAA;CAGhB,MAAM,kBAAsC,OAAO,SAAS,OAAO,aAAa,WAAW,SAAS,OAAO,SAAS,kBAAkB,KAAA;CAEtI,OAAO,oBAAC,OAAD;EAAK,WAAW;YACnB,oBAAC,YAAD;GAAY,SAAS;GACjB,OAAO,WAAW,aAAa;GAC/B,WAAW;aACV,mBAAmB,SAAS;EACrB,CAAA;CAEX,CAAA;AACT"}
|