@rebasepro/admin 0.0.1-canary.eae7889 → 0.0.1-canary.eb08332

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.
Files changed (716) hide show
  1. package/LICENSE +21 -6
  2. package/README.md +139 -0
  3. package/dist/CollectionEditorDialog-DKGlYDPc.js +3630 -0
  4. package/dist/CollectionEditorDialog-DKGlYDPc.js.map +1 -0
  5. package/dist/PropertyEditView-h0N-AMCY.js +3808 -0
  6. package/dist/PropertyEditView-h0N-AMCY.js.map +1 -0
  7. package/dist/RouterCollectionsStudioView-DdEStpFk.js +192 -0
  8. package/dist/RouterCollectionsStudioView-DdEStpFk.js.map +1 -0
  9. package/dist/collection_editor/ConfigControllerProvider.d.ts +2 -11
  10. package/dist/collection_editor/_cms_internals.d.ts +4 -4
  11. package/dist/collection_editor/api/generateCollectionApi.d.ts +10 -9
  12. package/dist/collection_editor/extensibility_types.d.ts +135 -0
  13. package/dist/collection_editor/index.d.ts +6 -1
  14. package/dist/collection_editor/pgColumnToProperty.d.ts +3 -3
  15. package/dist/collection_editor/serializable_types.d.ts +370 -0
  16. package/dist/collection_editor/serializable_utils.d.ts +50 -0
  17. package/dist/collection_editor/types/collection_editor_controller.d.ts +11 -10
  18. package/dist/collection_editor/types/collection_inference.d.ts +2 -2
  19. package/dist/collection_editor/types/config_controller.d.ts +21 -14
  20. package/dist/collection_editor/ui/AddKanbanColumnAction.d.ts +7 -5
  21. package/dist/collection_editor/ui/CollectionViewHeaderAction.d.ts +7 -5
  22. package/dist/collection_editor/ui/EditorCollectionAction.d.ts +1 -1
  23. package/dist/collection_editor/ui/EditorCollectionActionStart.d.ts +1 -1
  24. package/dist/collection_editor/ui/EditorEntityAction.d.ts +1 -1
  25. package/dist/collection_editor/ui/HomePageEditorCollectionAction.d.ts +1 -1
  26. package/dist/collection_editor/ui/KanbanSetupAction.d.ts +7 -5
  27. package/dist/collection_editor/ui/MissingReferenceWidget.d.ts +1 -1
  28. package/dist/collection_editor/ui/NewCollectionButton.d.ts +1 -1
  29. package/dist/collection_editor/ui/NewCollectionCard.d.ts +1 -1
  30. package/dist/collection_editor/ui/PropertyAddColumnComponent.d.ts +6 -5
  31. package/dist/collection_editor/ui/collection_editor/AICollectionGeneratorPopover.d.ts +4 -4
  32. package/dist/collection_editor/ui/collection_editor/AIModifiedPathsContext.d.ts +1 -1
  33. package/dist/collection_editor/ui/collection_editor/CollectionDetailsForm.d.ts +7 -7
  34. package/dist/collection_editor/ui/collection_editor/CollectionEditorDialog.d.ts +10 -11
  35. package/dist/collection_editor/ui/collection_editor/CollectionEditorWelcomeView.d.ts +4 -4
  36. package/dist/collection_editor/ui/collection_editor/CollectionJsonImportDialog.d.ts +4 -3
  37. package/dist/collection_editor/ui/collection_editor/CollectionPropertiesEditorForm.d.ts +17 -7
  38. package/dist/collection_editor/ui/collection_editor/CollectionRLSTab.d.ts +2 -1
  39. package/dist/collection_editor/ui/collection_editor/CollectionRelationsTab.d.ts +2 -1
  40. package/dist/collection_editor/ui/collection_editor/CollectionStudioView.d.ts +14 -1
  41. package/dist/collection_editor/ui/collection_editor/CollectionYupValidation.d.ts +1 -9
  42. package/dist/collection_editor/ui/collection_editor/CollectionsStudioView.d.ts +25 -2
  43. package/dist/collection_editor/ui/collection_editor/DisplaySettingsForm.d.ts +4 -2
  44. package/dist/collection_editor/ui/collection_editor/EntityActionsEditTab.d.ts +4 -3
  45. package/dist/collection_editor/ui/collection_editor/EntityActionsSelectDialog.d.ts +2 -1
  46. package/dist/collection_editor/ui/collection_editor/EntityCustomViewsSelectDialog.d.ts +2 -1
  47. package/dist/collection_editor/ui/collection_editor/EnumForm.d.ts +2 -1
  48. package/dist/collection_editor/ui/collection_editor/GeneralSettingsForm.d.ts +8 -4
  49. package/dist/collection_editor/ui/collection_editor/GetCodeDialog.d.ts +4 -3
  50. package/dist/collection_editor/ui/collection_editor/KanbanConfigSection.d.ts +2 -1
  51. package/dist/collection_editor/ui/collection_editor/LayoutModeSwitch.d.ts +3 -3
  52. package/dist/collection_editor/ui/collection_editor/PropertyEditView.d.ts +17 -5
  53. package/dist/collection_editor/ui/collection_editor/PropertyFieldPreview.d.ts +2 -2
  54. package/dist/collection_editor/ui/collection_editor/PropertyTree.d.ts +2 -2
  55. package/dist/collection_editor/ui/collection_editor/RouterCollectionStudioView.d.ts +15 -0
  56. package/dist/collection_editor/ui/collection_editor/RouterCollectionsStudioView.d.ts +14 -0
  57. package/dist/collection_editor/ui/collection_editor/SubcollectionsEditTab.d.ts +8 -6
  58. package/dist/collection_editor/ui/collection_editor/SwitchControl.d.ts +3 -2
  59. package/dist/collection_editor/ui/collection_editor/ViewModeSwitch.d.ts +1 -1
  60. package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.d.ts +1 -1
  61. package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportMapping.d.ts +3 -2
  62. package/dist/collection_editor/ui/collection_editor/properties/BlockPropertyField.d.ts +2 -1
  63. package/dist/collection_editor/ui/collection_editor/properties/BooleanPropertyField.d.ts +2 -1
  64. package/dist/collection_editor/ui/collection_editor/properties/DateTimePropertyField.d.ts +2 -1
  65. package/dist/collection_editor/ui/collection_editor/properties/EnumPropertyField.d.ts +2 -1
  66. package/dist/collection_editor/ui/collection_editor/properties/KeyValuePropertyField.d.ts +2 -1
  67. package/dist/collection_editor/ui/collection_editor/properties/MapPropertyField.d.ts +2 -1
  68. package/dist/collection_editor/ui/collection_editor/properties/MarkdownPropertyField.d.ts +2 -1
  69. package/dist/collection_editor/ui/collection_editor/properties/NumberPropertyField.d.ts +2 -1
  70. package/dist/collection_editor/ui/collection_editor/properties/ReferencePropertyField.d.ts +3 -2
  71. package/dist/collection_editor/ui/collection_editor/properties/RelationPropertyField.d.ts +3 -8
  72. package/dist/collection_editor/ui/collection_editor/properties/RepeatPropertyField.d.ts +2 -1
  73. package/dist/collection_editor/ui/collection_editor/properties/StoragePropertyField.d.ts +2 -1
  74. package/dist/collection_editor/ui/collection_editor/properties/StringPropertyField.d.ts +2 -1
  75. package/dist/collection_editor/ui/collection_editor/properties/UrlPropertyField.d.ts +2 -1
  76. package/dist/collection_editor/ui/collection_editor/properties/VectorPropertyField.d.ts +4 -0
  77. package/dist/collection_editor/ui/collection_editor/properties/advanced/AdvancedPropertyValidation.d.ts +2 -1
  78. package/dist/collection_editor/ui/collection_editor/properties/conditions/ConditionsEditor.d.ts +2 -1
  79. package/dist/collection_editor/ui/collection_editor/properties/conditions/ConditionsPanel.d.ts +1 -1
  80. package/dist/collection_editor/ui/collection_editor/properties/conditions/EnumConditionsEditor.d.ts +2 -1
  81. package/dist/collection_editor/ui/collection_editor/properties/validation/ArrayPropertyValidation.d.ts +2 -1
  82. package/dist/collection_editor/ui/collection_editor/properties/validation/GeneralPropertyValidation.d.ts +2 -1
  83. package/dist/collection_editor/ui/collection_editor/properties/validation/NumberPropertyValidation.d.ts +2 -1
  84. package/dist/collection_editor/ui/collection_editor/properties/validation/StringPropertyValidation.d.ts +2 -1
  85. package/dist/collection_editor/ui/collection_editor/properties/validation/ValidationPanel.d.ts +1 -1
  86. package/dist/collection_editor/ui/collection_editor/templates/blog_template.d.ts +2 -2
  87. package/dist/collection_editor/ui/collection_editor/templates/pages_template.d.ts +2 -2
  88. package/dist/collection_editor/ui/collection_editor/templates/products_template.d.ts +2 -2
  89. package/dist/collection_editor/ui/collection_editor/templates/users_template.d.ts +2 -2
  90. package/dist/collection_editor/useJsonCollectionsConfigController.d.ts +37 -0
  91. package/dist/collection_editor/useLocalCollectionsConfigController.d.ts +2 -2
  92. package/dist/collection_editor/useSafeSnackbarController.d.ts +2 -0
  93. package/dist/collection_editor/validateCollectionJson.d.ts +2 -2
  94. package/dist/collection_editor_ui.d.ts +4 -0
  95. package/dist/collection_editor_ui.js +33 -11
  96. package/dist/collection_editor_ui.js.map +1 -1
  97. package/dist/components/ArrayContainer.d.ts +5 -5
  98. package/dist/components/ClearFilterSortButton.d.ts +1 -1
  99. package/dist/components/CollectionEditorDialogs.d.ts +2 -1
  100. package/dist/components/CollectionPanel.d.ts +58 -0
  101. package/dist/components/{EntityCollectionTable/EntityCollectionRowActions.d.ts → CollectionTableBinding/CollectionRowActions.d.ts} +5 -5
  102. package/dist/components/CollectionTableBinding/CollectionTableBinding.d.ts +28 -0
  103. package/dist/components/{EntityCollectionTable/EntityCollectionTableProps.d.ts → CollectionTableBinding/CollectionTableBindingProps.d.ts} +4 -4
  104. package/dist/components/{EntityCollectionTable → CollectionTableBinding}/column_utils.d.ts +2 -2
  105. package/dist/components/{EntityCollectionTable → CollectionTableBinding}/fields/TableMultipleRelationField.d.ts +6 -6
  106. package/dist/components/{EntityCollectionTable → CollectionTableBinding}/fields/TableReferenceField.d.ts +6 -6
  107. package/dist/components/{EntityCollectionTable → CollectionTableBinding}/fields/TableRelationField.d.ts +6 -6
  108. package/dist/components/{EntityCollectionTable → CollectionTableBinding}/fields/TableRelationSelectorField.d.ts +3 -2
  109. package/dist/components/{EntityCollectionTable → CollectionTableBinding}/fields/TableStorageUpload.d.ts +4 -4
  110. package/dist/components/{EntityCollectionTable → CollectionTableBinding}/fields/VirtualTableSelect.d.ts +1 -1
  111. package/dist/components/{EntityCollectionTable → CollectionTableBinding}/fields/VirtualTableUserSelect.d.ts +1 -1
  112. package/dist/components/CollectionTableBinding/index.d.ts +6 -0
  113. package/dist/components/{EntityCollectionTable → CollectionTableBinding}/internal/CollectionTableToolbar.d.ts +5 -1
  114. package/dist/components/{EntityCollectionTable → CollectionTableBinding}/internal/EntityTableCell.d.ts +3 -3
  115. package/dist/components/{EntityCollectionTable → CollectionTableBinding}/internal/EntityTableCellActions.d.ts +1 -1
  116. package/dist/components/{EntityCollectionTable → CollectionTableBinding}/internal/common.d.ts +2 -2
  117. package/dist/components/{EntityCollectionTable → CollectionTableBinding}/internal/popup_field/PopupFormField.d.ts +7 -6
  118. package/dist/components/{EntityCollectionTable → CollectionTableBinding}/table_bindings.d.ts +4 -3
  119. package/dist/components/CollectionViewBinding/BoardCardBinding.d.ts +31 -0
  120. package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.d.ts +22 -0
  121. package/dist/components/{EntityCollectionView/EntityCollectionCardView.d.ts → CollectionViewBinding/CollectionCardViewBinding.d.ts} +5 -5
  122. package/dist/components/CollectionViewBinding/CollectionListViewBinding.d.ts +50 -0
  123. package/dist/components/CollectionViewBinding/CollectionViewActions.d.ts +20 -0
  124. package/dist/components/CollectionViewBinding/CollectionViewBinding.d.ts +41 -0
  125. package/dist/components/CollectionViewBinding/CollectionViewStartActions.d.ts +21 -0
  126. package/dist/components/CollectionViewBinding/EntityCardBinding.d.ts +21 -0
  127. package/dist/components/CollectionViewBinding/FilterPresetsButton.d.ts +22 -0
  128. package/dist/components/{EntityCollectionView → CollectionViewBinding}/FiltersDialog.d.ts +3 -2
  129. package/dist/components/{EntityCollectionView → CollectionViewBinding}/SplitListView.d.ts +6 -5
  130. package/dist/components/{EntityCollectionView → CollectionViewBinding}/ViewModeToggle.d.ts +2 -1
  131. package/dist/components/{EntityCollectionView → CollectionViewBinding}/hooks/useCollectionInlineEditor.d.ts +3 -3
  132. package/dist/components/{EntityCollectionView → CollectionViewBinding}/hooks/useKanbanDragAndDrop.d.ts +7 -6
  133. package/dist/components/{EntityCollectionView → CollectionViewBinding}/useBoardDataController.d.ts +2 -2
  134. package/dist/components/{EntityCollectionView/useEntityPreviewSlots.d.ts → CollectionViewBinding/usePreviewSlots.d.ts} +5 -5
  135. package/dist/components/DefaultAppBar.d.ts +18 -1
  136. package/dist/components/DefaultDrawer.d.ts +53 -5
  137. package/dist/components/DeleteEntityDialog.d.ts +6 -5
  138. package/dist/components/DetailViewBinding.d.ts +28 -0
  139. package/dist/components/DrawerNavigationGroup.d.ts +1 -1
  140. package/dist/components/DrawerNavigationItem.d.ts +1 -1
  141. package/dist/components/EditFormActions.d.ts +3 -0
  142. package/dist/components/EditViewBinding.d.ts +58 -0
  143. package/dist/components/{EntityPreview.d.ts → EntityPreviewBinding.d.ts} +14 -14
  144. package/dist/components/EntityViewBinding.d.ts +13 -0
  145. package/dist/components/FieldCaption.d.ts +1 -1
  146. package/dist/components/HomePage/ContentHomePage.d.ts +1 -1
  147. package/dist/components/HomePage/FavouritesView.d.ts +1 -1
  148. package/dist/components/HomePage/HomePageDnD.d.ts +7 -7
  149. package/dist/components/HomePage/NavigationCard.d.ts +1 -1
  150. package/dist/components/HomePage/NavigationCardBinding.d.ts +2 -1
  151. package/dist/components/HomePage/NavigationGroup.d.ts +2 -2
  152. package/dist/components/HomePage/RenameGroupDialog.d.ts +2 -1
  153. package/dist/components/HomePage/SmallNavigationCard.d.ts +1 -1
  154. package/dist/components/JsonPreviewBinding.d.ts +4 -0
  155. package/dist/components/PropertyCollectionView.d.ts +3 -2
  156. package/dist/components/PropertyIdCopyTooltip.d.ts +3 -3
  157. package/dist/components/{RebaseCMS.d.ts → RebaseAdmin.d.ts} +2 -2
  158. package/dist/components/RebaseAuthGate.d.ts +1 -1
  159. package/dist/components/RebaseLayout.d.ts +6 -5
  160. package/dist/components/RebaseNavigation.d.ts +2 -2
  161. package/dist/components/RebaseRouteDefs.d.ts +2 -2
  162. package/dist/components/RebaseShell.d.ts +2 -1
  163. package/dist/components/ReferenceTable/{EntitySelectionTable.d.ts → SelectionTableBinding.d.ts} +6 -6
  164. package/dist/components/ReferenceWidget.d.ts +3 -2
  165. package/dist/components/RelationSelector.d.ts +1 -1
  166. package/dist/components/SearchIconsView.d.ts +2 -1
  167. package/dist/components/SelectableTable/SelectableTable.d.ts +11 -11
  168. package/dist/components/SelectableTable/SelectableTableContext.d.ts +3 -3
  169. package/dist/components/SelectableTable/SelectionStore.d.ts +16 -22
  170. package/dist/components/SelectableTable/filters/BooleanFilterField.d.ts +9 -3
  171. package/dist/components/SelectableTable/filters/DateTimeFilterField.d.ts +10 -3
  172. package/dist/components/SelectableTable/filters/FilterFieldBinding.d.ts +40 -0
  173. package/dist/components/SelectableTable/filters/ReferenceFilterField.d.ts +10 -3
  174. package/dist/components/SelectableTable/filters/RelationFilterField.d.ts +8 -1
  175. package/dist/components/SelectableTable/filters/StringNumberFilterField.d.ts +10 -3
  176. package/dist/components/SideDialogs.d.ts +2 -2
  177. package/dist/components/SidePanelBinding.d.ts +11 -0
  178. package/dist/components/{SideEntityProvider.d.ts → SidePanelProvider.d.ts} +8 -8
  179. package/dist/components/admin/CreationResultDialog.d.ts +6 -0
  180. package/dist/components/admin/index.d.ts +1 -3
  181. package/dist/components/app/AppBar.d.ts +1 -1
  182. package/dist/components/app/Drawer.d.ts +9 -2
  183. package/dist/components/common/default_entity_actions.d.ts +8 -1
  184. package/dist/components/field_configs.d.ts +1 -1
  185. package/dist/components/history/EntityHistoryEntry.d.ts +3 -3
  186. package/dist/components/history/EntityHistoryView.d.ts +1 -1
  187. package/dist/components/history/LastEditedByFormAction.d.ts +2 -1
  188. package/dist/components/history/LastEditedByIndicator.d.ts +4 -3
  189. package/dist/components/history/UserChip.d.ts +1 -1
  190. package/dist/components/index.d.ts +16 -13
  191. package/dist/contexts/SidePanelControllerContext.d.ts +3 -0
  192. package/dist/data_export/export/BasicExportAction.d.ts +2 -1
  193. package/dist/data_export/export/ExportCollectionAction.d.ts +4 -4
  194. package/dist/data_export/export/export.d.ts +3 -3
  195. package/dist/data_import/components/DataNewPropertiesMapping.d.ts +1 -1
  196. package/dist/data_import/components/ImportFileUpload.d.ts +1 -1
  197. package/dist/data_import/components/ImportNewPropertyFieldPreview.d.ts +2 -1
  198. package/dist/data_import/components/ImportSaveInProgress.d.ts +3 -3
  199. package/dist/data_import/import/ImportCollectionAction.d.ts +4 -3
  200. package/dist/data_import/utils/data.d.ts +1 -1
  201. package/dist/data_import/utils/file_headers.d.ts +6 -1
  202. package/dist/data_import/utils/file_to_json.d.ts +1 -11
  203. package/dist/data_import/utils/transforms.d.ts +11 -0
  204. package/dist/editor/components/SlashCommandMenu.d.ts +2 -1
  205. package/dist/editor/components/editor-bubble.d.ts +5 -1
  206. package/dist/editor/components/image-bubble.d.ts +5 -1
  207. package/dist/editor/components/index.d.ts +3 -3
  208. package/dist/editor/components/table-bubble.d.ts +5 -1
  209. package/dist/editor/editor.d.ts +4 -4
  210. package/dist/editor/nodeViews/ReactNodeView.d.ts +4 -1
  211. package/dist/editor/selectors/color-selector.d.ts +1 -1
  212. package/dist/editor/selectors/link-selector.d.ts +1 -1
  213. package/dist/editor/selectors/node-selector.d.ts +1 -1
  214. package/dist/editor/selectors/text-buttons.d.ts +1 -1
  215. package/dist/editor/useProseMirror.d.ts +2 -2
  216. package/dist/editor/utils/remove_classes.d.ts +1 -1
  217. package/dist/editor.js +2625 -3569
  218. package/dist/editor.js.map +1 -1
  219. package/dist/form/EntityForm.d.ts +11 -9
  220. package/dist/form/EntityFormActions.d.ts +2 -1
  221. package/dist/form/EntityFormBinding.d.ts +27 -0
  222. package/dist/form/PropertyFieldBinding.d.ts +1 -1
  223. package/dist/form/components/FieldHelperText.d.ts +1 -1
  224. package/dist/form/components/FormEntry.d.ts +1 -1
  225. package/dist/form/components/FormLayout.d.ts +1 -1
  226. package/dist/form/components/LabelWithIconAndTooltip.d.ts +1 -1
  227. package/dist/form/components/LocalChangesMenu.d.ts +3 -2
  228. package/dist/form/components/StorageItemPreview.d.ts +2 -1
  229. package/dist/form/components/StorageUploadProgress.d.ts +10 -4
  230. package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.d.ts +2 -1
  231. package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.d.ts +2 -1
  232. package/dist/form/field_bindings/BlockFieldBinding.d.ts +2 -1
  233. package/dist/form/field_bindings/DateTimeFieldBinding.d.ts +2 -1
  234. package/dist/form/field_bindings/KeyValueFieldBinding.d.ts +2 -1
  235. package/dist/form/field_bindings/MapFieldBinding.d.ts +2 -1
  236. package/dist/form/field_bindings/MarkdownEditorFieldBinding.d.ts +4 -3
  237. package/dist/form/field_bindings/MultiSelectFieldBinding.d.ts +2 -1
  238. package/dist/form/field_bindings/MultipleRelationFieldBinding.d.ts +2 -1
  239. package/dist/form/field_bindings/ReadOnlyFieldBinding.d.ts +2 -1
  240. package/dist/form/field_bindings/ReferenceFieldBinding.d.ts +2 -1
  241. package/dist/form/field_bindings/RelationFieldBinding.d.ts +2 -1
  242. package/dist/form/field_bindings/RepeatFieldBinding.d.ts +2 -1
  243. package/dist/form/field_bindings/SelectFieldBinding.d.ts +2 -1
  244. package/dist/form/field_bindings/StorageUploadFieldBinding.d.ts +5 -4
  245. package/dist/form/field_bindings/SwitchFieldBinding.d.ts +2 -1
  246. package/dist/form/field_bindings/TextFieldBinding.d.ts +2 -1
  247. package/dist/form/field_bindings/UserSelectFieldBinding.d.ts +2 -1
  248. package/dist/form/field_bindings/VectorFieldBinding.d.ts +12 -0
  249. package/dist/form/form_utils.d.ts +8 -0
  250. package/dist/form/index.d.ts +6 -2
  251. package/dist/form/validation.d.ts +3 -3
  252. package/dist/history-C0FdqGNz.js +311 -0
  253. package/dist/history-C0FdqGNz.js.map +1 -0
  254. package/dist/hooks/index.d.ts +4 -4
  255. package/dist/hooks/navigation/contexts/CollectionRegistryContext.d.ts +2 -2
  256. package/dist/hooks/navigation/useAsyncResolver.d.ts +26 -0
  257. package/dist/hooks/navigation/useBuildCollectionRegistryController.d.ts +2 -0
  258. package/dist/hooks/navigation/useBuildNavigationStateController.d.ts +6 -8
  259. package/dist/hooks/navigation/useNavigationResolution.d.ts +6 -7
  260. package/dist/hooks/navigation/useResolvedCollections.d.ts +11 -7
  261. package/dist/hooks/navigation/useResolvedViews.d.ts +2 -5
  262. package/dist/hooks/navigation/useTopLevelNavigation.d.ts +3 -3
  263. package/dist/hooks/navigation/utils.d.ts +5 -5
  264. package/dist/hooks/useBreadcrumbsController.d.ts +2 -32
  265. package/dist/hooks/useBuildSidePanel.d.ts +6 -0
  266. package/dist/hooks/useCMSContext.d.ts +2 -2
  267. package/dist/hooks/{useEntityHistory.d.ts → useHistory.d.ts} +2 -2
  268. package/dist/hooks/useResolvedNavigationFrom.d.ts +3 -3
  269. package/dist/hooks/{useEntitySelectionDialog.d.ts → useSelectionDialog.d.ts} +2 -2
  270. package/dist/hooks/useSideDialogsController.d.ts +1 -1
  271. package/dist/hooks/useSidePanel.d.ts +11 -0
  272. package/dist/index.d.ts +6 -3
  273. package/dist/index.js +2 -799
  274. package/dist/markdown-CklalUUk.js +526 -0
  275. package/dist/markdown-CklalUUk.js.map +1 -0
  276. package/dist/preview/components/ArrayEnumPreview.d.ts +2 -1
  277. package/dist/preview/components/EmptyValue.d.ts +2 -1
  278. package/dist/preview/components/EnumValuesChip.d.ts +1 -1
  279. package/dist/preview/components/ImagePreview.d.ts +2 -1
  280. package/dist/preview/components/ReferencePreview.d.ts +2 -1
  281. package/dist/preview/components/RelationPreview.d.ts +2 -1
  282. package/dist/preview/components/StorageThumbnail.d.ts +3 -1
  283. package/dist/preview/components/UrlComponentPreview.d.ts +1 -0
  284. package/dist/preview/components/UserPreview.d.ts +6 -3
  285. package/dist/preview/property_previews/ArrayOfMapsPreview.d.ts +2 -1
  286. package/dist/preview/property_previews/ArrayOfReferencesPreview.d.ts +1 -1
  287. package/dist/preview/property_previews/ArrayOfRelationsPreview.d.ts +1 -1
  288. package/dist/preview/property_previews/ArrayOfStorageComponentsPreview.d.ts +2 -1
  289. package/dist/preview/property_previews/ArrayOfStringsPreview.d.ts +2 -1
  290. package/dist/preview/property_previews/ArrayOneOfPreview.d.ts +2 -1
  291. package/dist/preview/property_previews/ArrayPropertyEnumPreview.d.ts +1 -1
  292. package/dist/preview/property_previews/ArrayPropertyPreview.d.ts +2 -1
  293. package/dist/preview/property_previews/MapPropertyPreview.d.ts +3 -2
  294. package/dist/preview/property_previews/SkeletonPropertyComponent.d.ts +5 -4
  295. package/dist/rolldown-runtime-D7D4PA-g.js +13 -0
  296. package/dist/routes/CustomViewRoute.d.ts +2 -1
  297. package/dist/routes/RebaseRoute.d.ts +1 -1
  298. package/dist/src-DLAFyeZI.js +24222 -0
  299. package/dist/src-DLAFyeZI.js.map +1 -0
  300. package/dist/types/components/EntityFormActionsProps.d.ts +4 -4
  301. package/dist/types/components/EntityFormProps.d.ts +65 -5
  302. package/dist/types/components/PropertyPreviewProps.d.ts +6 -1
  303. package/dist/types/components/formex.d.ts +1 -40
  304. package/dist/types/fields.d.ts +23 -12
  305. package/dist/util/dataControllerAdapter.d.ts +27 -0
  306. package/dist/util/navigation_utils.d.ts +16 -6
  307. package/dist/util/previews.d.ts +8 -3
  308. package/dist/util/propertyConfigMapper.d.ts +17 -0
  309. package/dist/util/property_utils.d.ts +3 -3
  310. package/dist/util/resolutions.d.ts +1 -2
  311. package/dist/util/view_constants.d.ts +6 -0
  312. package/package.json +56 -55
  313. package/src/collection_editor/ConfigControllerProvider.tsx +37 -53
  314. package/src/collection_editor/_cms_internals.ts +4 -4
  315. package/src/collection_editor/api/generateCollectionApi.ts +10 -9
  316. package/src/collection_editor/extensibility_types.ts +168 -0
  317. package/src/collection_editor/index.ts +47 -3
  318. package/src/collection_editor/pgColumnToProperty.ts +23 -6
  319. package/src/collection_editor/serializable_types.ts +474 -0
  320. package/src/collection_editor/serializable_utils.ts +576 -0
  321. package/src/collection_editor/types/collection_editor_controller.tsx +8 -11
  322. package/src/collection_editor/types/collection_inference.ts +2 -2
  323. package/src/collection_editor/types/config_controller.tsx +14 -14
  324. package/src/collection_editor/ui/AddKanbanColumnAction.tsx +21 -9
  325. package/src/collection_editor/ui/CollectionViewHeaderAction.tsx +8 -8
  326. package/src/collection_editor/ui/EditorCollectionAction.tsx +9 -14
  327. package/src/collection_editor/ui/EditorCollectionActionStart.tsx +13 -18
  328. package/src/collection_editor/ui/EditorEntityAction.tsx +9 -14
  329. package/src/collection_editor/ui/HomePageEditorCollectionAction.tsx +13 -19
  330. package/src/collection_editor/ui/KanbanSetupAction.tsx +8 -6
  331. package/src/collection_editor/ui/MissingReferenceWidget.tsx +5 -3
  332. package/src/collection_editor/ui/NewCollectionButton.tsx +4 -4
  333. package/src/collection_editor/ui/NewCollectionCard.tsx +8 -13
  334. package/src/collection_editor/ui/PropertyAddColumnComponent.tsx +11 -16
  335. package/src/collection_editor/ui/collection_editor/AICollectionGeneratorPopover.tsx +20 -12
  336. package/src/collection_editor/ui/collection_editor/CollectionDetailsForm.tsx +29 -59
  337. package/src/collection_editor/ui/collection_editor/CollectionEditorDialog.tsx +213 -135
  338. package/src/collection_editor/ui/collection_editor/CollectionEditorWelcomeView.tsx +21 -7
  339. package/src/collection_editor/ui/collection_editor/CollectionJsonImportDialog.tsx +29 -23
  340. package/src/collection_editor/ui/collection_editor/CollectionPropertiesEditorForm.tsx +142 -112
  341. package/src/collection_editor/ui/collection_editor/CollectionRLSTab.tsx +49 -12
  342. package/src/collection_editor/ui/collection_editor/CollectionRelationsTab.tsx +29 -10
  343. package/src/collection_editor/ui/collection_editor/CollectionStudioView.tsx +26 -23
  344. package/src/collection_editor/ui/collection_editor/CollectionsStudioView.tsx +104 -37
  345. package/src/collection_editor/ui/collection_editor/DisplaySettingsForm.tsx +26 -14
  346. package/src/collection_editor/ui/collection_editor/EntityActionsEditTab.tsx +21 -8
  347. package/src/collection_editor/ui/collection_editor/EntityActionsSelectDialog.tsx +1 -1
  348. package/src/collection_editor/ui/collection_editor/EntityCustomViewsSelectDialog.tsx +1 -1
  349. package/src/collection_editor/ui/collection_editor/EnumForm.tsx +20 -5
  350. package/src/collection_editor/ui/collection_editor/GeneralSettingsForm.tsx +45 -12
  351. package/src/collection_editor/ui/collection_editor/GetCodeDialog.tsx +10 -12
  352. package/src/collection_editor/ui/collection_editor/KanbanConfigSection.tsx +5 -6
  353. package/src/collection_editor/ui/collection_editor/LayoutModeSwitch.tsx +17 -5
  354. package/src/collection_editor/ui/collection_editor/PropertyEditView.tsx +190 -27
  355. package/src/collection_editor/ui/collection_editor/PropertyFieldPreview.tsx +58 -49
  356. package/src/collection_editor/ui/collection_editor/PropertyTree.tsx +17 -4
  357. package/src/collection_editor/ui/collection_editor/RouterCollectionStudioView.tsx +44 -0
  358. package/src/collection_editor/ui/collection_editor/RouterCollectionsStudioView.tsx +41 -0
  359. package/src/collection_editor/ui/collection_editor/SubcollectionsEditTab.tsx +27 -13
  360. package/src/collection_editor/ui/collection_editor/SwitchControl.tsx +1 -1
  361. package/src/collection_editor/ui/collection_editor/ViewModeSwitch.tsx +9 -2
  362. package/src/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.tsx +4 -4
  363. package/src/collection_editor/ui/collection_editor/import/CollectionEditorImportMapping.tsx +4 -4
  364. package/src/collection_editor/ui/collection_editor/properties/BlockPropertyField.tsx +5 -6
  365. package/src/collection_editor/ui/collection_editor/properties/BooleanPropertyField.tsx +1 -1
  366. package/src/collection_editor/ui/collection_editor/properties/CommonPropertyFields.tsx +5 -5
  367. package/src/collection_editor/ui/collection_editor/properties/DateTimePropertyField.tsx +10 -10
  368. package/src/collection_editor/ui/collection_editor/properties/EnumPropertyField.tsx +10 -9
  369. package/src/collection_editor/ui/collection_editor/properties/MapPropertyField.tsx +7 -8
  370. package/src/collection_editor/ui/collection_editor/properties/MarkdownPropertyField.tsx +17 -10
  371. package/src/collection_editor/ui/collection_editor/properties/NumberPropertyField.tsx +7 -7
  372. package/src/collection_editor/ui/collection_editor/properties/ReferencePropertyField.tsx +19 -53
  373. package/src/collection_editor/ui/collection_editor/properties/RelationPropertyField.tsx +43 -60
  374. package/src/collection_editor/ui/collection_editor/properties/RepeatPropertyField.tsx +3 -3
  375. package/src/collection_editor/ui/collection_editor/properties/StoragePropertyField.tsx +56 -13
  376. package/src/collection_editor/ui/collection_editor/properties/StringPropertyField.tsx +7 -7
  377. package/src/collection_editor/ui/collection_editor/properties/UrlPropertyField.tsx +4 -3
  378. package/src/collection_editor/ui/collection_editor/properties/VectorPropertyField.tsx +34 -0
  379. package/src/collection_editor/ui/collection_editor/properties/advanced/AdvancedPropertyValidation.tsx +5 -6
  380. package/src/collection_editor/ui/collection_editor/properties/conditions/ConditionsEditor.tsx +18 -9
  381. package/src/collection_editor/ui/collection_editor/properties/conditions/ConditionsPanel.tsx +1 -2
  382. package/src/collection_editor/ui/collection_editor/properties/conditions/EnumConditionsEditor.tsx +17 -5
  383. package/src/collection_editor/ui/collection_editor/properties/conditions/property_paths.ts +1 -1
  384. package/src/collection_editor/ui/collection_editor/properties/validation/ArrayPropertyValidation.tsx +4 -4
  385. package/src/collection_editor/ui/collection_editor/properties/validation/GeneralPropertyValidation.tsx +3 -3
  386. package/src/collection_editor/ui/collection_editor/properties/validation/NumberPropertyValidation.tsx +6 -9
  387. package/src/collection_editor/ui/collection_editor/properties/validation/StringPropertyValidation.tsx +6 -6
  388. package/src/collection_editor/ui/collection_editor/properties/validation/ValidationPanel.tsx +1 -2
  389. package/src/collection_editor/ui/collection_editor/templates/blog_template.ts +3 -3
  390. package/src/collection_editor/ui/collection_editor/templates/pages_template.ts +3 -3
  391. package/src/collection_editor/ui/collection_editor/templates/products_template.ts +4 -4
  392. package/src/collection_editor/ui/collection_editor/templates/users_template.ts +2 -2
  393. package/src/collection_editor/ui/collection_editor/utils/supported_fields.tsx +0 -1
  394. package/src/collection_editor/ui/collection_editor/utils/update_property_for_widget.ts +7 -29
  395. package/src/collection_editor/useJsonCollectionsConfigController.tsx +286 -0
  396. package/src/collection_editor/useLocalCollectionsConfigController.tsx +11 -8
  397. package/src/collection_editor/useSafeSnackbarController.ts +9 -0
  398. package/src/collection_editor/validateCollectionJson.ts +111 -24
  399. package/src/collection_editor_ui.ts +6 -0
  400. package/src/components/AdminModeSyncer.tsx +2 -2
  401. package/src/components/ArrayContainer.tsx +28 -24
  402. package/src/components/ClearFilterSortButton.tsx +2 -3
  403. package/src/components/CollectionEditorDialogs.tsx +1 -1
  404. package/src/components/CollectionPanel.tsx +178 -0
  405. package/src/components/{EntityCollectionTable/EntityCollectionRowActions.tsx → CollectionTableBinding/CollectionRowActions.tsx} +26 -16
  406. package/src/components/{EntityCollectionTable/EntityCollectionTable.tsx → CollectionTableBinding/CollectionTableBinding.tsx} +34 -31
  407. package/src/components/{EntityCollectionTable/EntityCollectionTableProps.tsx → CollectionTableBinding/CollectionTableBindingProps.tsx} +4 -4
  408. package/src/components/{EntityCollectionTable → CollectionTableBinding}/PropertyTableCell.tsx +14 -12
  409. package/src/components/{EntityCollectionTable → CollectionTableBinding}/column_utils.tsx +4 -4
  410. package/src/components/{EntityCollectionTable → CollectionTableBinding}/fields/TableMultipleRelationField.tsx +13 -13
  411. package/src/components/{EntityCollectionTable → CollectionTableBinding}/fields/TableReferenceField.tsx +39 -19
  412. package/src/components/{EntityCollectionTable → CollectionTableBinding}/fields/TableRelationField.tsx +14 -14
  413. package/src/components/{EntityCollectionTable → CollectionTableBinding}/fields/TableRelationSelectorField.tsx +3 -3
  414. package/src/components/{EntityCollectionTable → CollectionTableBinding}/fields/TableStorageUpload.tsx +29 -27
  415. package/src/components/{EntityCollectionTable → CollectionTableBinding}/fields/VirtualTableSelect.tsx +0 -1
  416. package/src/components/CollectionTableBinding/index.tsx +14 -0
  417. package/src/components/{EntityCollectionTable → CollectionTableBinding}/internal/CollectionTableToolbar.tsx +22 -28
  418. package/src/components/{EntityCollectionTable → CollectionTableBinding}/internal/EntityTableCell.tsx +8 -9
  419. package/src/components/{EntityCollectionTable → CollectionTableBinding}/internal/EntityTableCellActions.tsx +2 -3
  420. package/src/components/{EntityCollectionTable → CollectionTableBinding}/internal/common.tsx +7 -7
  421. package/src/components/{EntityCollectionTable → CollectionTableBinding}/internal/popup_field/PopupFormField.tsx +12 -13
  422. package/src/components/{EntityCollectionTable → CollectionTableBinding}/internal/popup_field/useDraggable.tsx +5 -2
  423. package/src/components/{EntityCollectionTable → CollectionTableBinding}/table_bindings.tsx +101 -104
  424. package/src/components/{EntityCollectionView/EntityBoardCard.tsx → CollectionViewBinding/BoardCardBinding.tsx} +39 -40
  425. package/src/components/{EntityCollectionView/EntityCollectionBoardView.tsx → CollectionViewBinding/CollectionBoardViewBinding.tsx} +88 -52
  426. package/src/components/CollectionViewBinding/CollectionCardViewBinding.tsx +157 -0
  427. package/src/components/{EntityCollectionView/EntityCollectionListView.tsx → CollectionViewBinding/CollectionListViewBinding.tsx} +234 -151
  428. package/src/components/{EntityCollectionView/EntityCollectionViewActions.tsx → CollectionViewBinding/CollectionViewActions.tsx} +36 -26
  429. package/src/components/{EntityCollectionView/EntityCollectionView.tsx → CollectionViewBinding/CollectionViewBinding.tsx} +392 -213
  430. package/src/components/{EntityCollectionView/EntityCollectionViewStartActions.tsx → CollectionViewBinding/CollectionViewStartActions.tsx} +42 -23
  431. package/src/components/{EntityCollectionView/EntityCard.tsx → CollectionViewBinding/EntityCardBinding.tsx} +14 -14
  432. package/src/components/CollectionViewBinding/FilterPresetsButton.tsx +294 -0
  433. package/src/components/{EntityCollectionView → CollectionViewBinding}/FiltersDialog.tsx +37 -79
  434. package/src/components/{EntityCollectionView → CollectionViewBinding}/SplitListView.tsx +97 -30
  435. package/src/components/{EntityCollectionView → CollectionViewBinding}/ViewModeToggle.tsx +20 -8
  436. package/src/components/{EntityCollectionView → CollectionViewBinding}/hooks/useCollectionInlineEditor.ts +9 -8
  437. package/src/components/{EntityCollectionView → CollectionViewBinding}/hooks/useKanbanDragAndDrop.ts +17 -16
  438. package/src/components/{EntityCollectionView → CollectionViewBinding}/useBoardDataController.tsx +118 -70
  439. package/src/components/{EntityCollectionView/useEntityPreviewSlots.ts → CollectionViewBinding/usePreviewSlots.ts} +136 -48
  440. package/src/components/DefaultAppBar.tsx +73 -41
  441. package/src/components/DefaultDrawer.tsx +317 -85
  442. package/src/components/DeleteEntityDialog.tsx +7 -7
  443. package/src/components/DetailViewBinding.tsx +670 -0
  444. package/src/components/DrawerNavigationGroup.tsx +11 -11
  445. package/src/components/DrawerNavigationItem.tsx +6 -6
  446. package/src/components/{EntityEditViewFormActions.tsx → EditFormActions.tsx} +78 -59
  447. package/src/components/EditViewBinding.tsx +761 -0
  448. package/src/components/{EntityPreview.tsx → EntityPreviewBinding.tsx} +53 -39
  449. package/src/components/{EntityView.tsx → EntityViewBinding.tsx} +8 -9
  450. package/src/components/HomePage/ContentHomePage.tsx +35 -17
  451. package/src/components/HomePage/FavouritesView.tsx +2 -3
  452. package/src/components/HomePage/HomePageDnD.tsx +3 -2
  453. package/src/components/HomePage/NavigationCard.tsx +9 -16
  454. package/src/components/HomePage/NavigationCardBinding.tsx +6 -7
  455. package/src/components/HomePage/NavigationGroup.tsx +4 -5
  456. package/src/components/HomePage/RenameGroupDialog.tsx +1 -1
  457. package/src/components/HomePage/SmallNavigationCard.tsx +0 -5
  458. package/src/components/{EntityJsonPreview.tsx → JsonPreviewBinding.tsx} +2 -2
  459. package/src/components/PropertyCollectionView.tsx +2 -1
  460. package/src/components/PropertyIdCopyTooltip.tsx +2 -3
  461. package/src/components/{RebaseCMS.tsx → RebaseAdmin.tsx} +8 -6
  462. package/src/components/RebaseAuthGate.tsx +5 -3
  463. package/src/components/RebaseLayout.tsx +10 -9
  464. package/src/components/RebaseNavigation.tsx +107 -31
  465. package/src/components/RebaseRouteDefs.tsx +10 -13
  466. package/src/components/RebaseShell.tsx +18 -14
  467. package/src/components/ReferenceTable/{EntitySelectionTable.tsx → SelectionTableBinding.tsx} +40 -33
  468. package/src/components/ReferenceWidget.tsx +7 -7
  469. package/src/components/RelationSelector.tsx +82 -24
  470. package/src/components/SearchIconsView.tsx +13 -12
  471. package/src/components/SelectableTable/SelectableTable.tsx +68 -115
  472. package/src/components/SelectableTable/SelectableTableContext.tsx +4 -3
  473. package/src/components/SelectableTable/SelectionStore.ts +20 -44
  474. package/src/components/SelectableTable/filters/BooleanFilterField.tsx +13 -5
  475. package/src/components/SelectableTable/filters/DateTimeFilterField.tsx +37 -16
  476. package/src/components/SelectableTable/filters/FilterFieldBinding.tsx +187 -0
  477. package/src/components/SelectableTable/filters/ReferenceFilterField.tsx +27 -13
  478. package/src/components/SelectableTable/filters/RelationFilterField.tsx +17 -3
  479. package/src/components/SelectableTable/filters/StringNumberFilterField.tsx +95 -35
  480. package/src/components/SideDialogs.tsx +58 -40
  481. package/src/components/SidePanelBinding.tsx +261 -0
  482. package/src/components/{SideEntityProvider.tsx → SidePanelProvider.tsx} +17 -16
  483. package/src/components/UserSelector.tsx +123 -9
  484. package/src/components/admin/CreationResultDialog.tsx +138 -0
  485. package/src/components/admin/index.ts +1 -3
  486. package/src/components/app/Drawer.tsx +9 -1
  487. package/src/components/app/Scaffold.tsx +16 -9
  488. package/src/components/common/default_entity_actions.tsx +270 -29
  489. package/src/components/field_configs.tsx +68 -46
  490. package/src/components/history/EntityHistoryEntry.tsx +4 -5
  491. package/src/components/history/EntityHistoryView.tsx +18 -8
  492. package/src/components/history/LastEditedByIndicator.tsx +4 -4
  493. package/src/components/index.ts +20 -17
  494. package/src/contexts/BreacrumbsContext.tsx +15 -6
  495. package/src/contexts/SidePanelControllerContext.tsx +5 -0
  496. package/src/data_export/export/BasicExportAction.tsx +42 -43
  497. package/src/data_export/export/ExportCollectionAction.tsx +55 -54
  498. package/src/data_export/export/export.ts +17 -17
  499. package/src/data_import/components/DataNewPropertiesMapping.tsx +17 -4
  500. package/src/data_import/components/ImportFileUpload.tsx +2 -3
  501. package/src/data_import/components/ImportNewPropertyFieldPreview.tsx +2 -3
  502. package/src/data_import/components/ImportSaveInProgress.tsx +4 -4
  503. package/src/data_import/import/ImportCollectionAction.tsx +26 -13
  504. package/src/data_import/utils/data.ts +26 -8
  505. package/src/data_import/utils/file_headers.ts +13 -89
  506. package/src/data_import/utils/file_to_json.ts +43 -68
  507. package/src/data_import/utils/get_properties_mapping.ts +1 -1
  508. package/src/data_import/utils/transforms.ts +47 -0
  509. package/src/editor/components/SlashCommandMenu.tsx +17 -2
  510. package/src/editor/components/editor-bubble-item.tsx +1 -1
  511. package/src/editor/components/editor-bubble.tsx +32 -9
  512. package/src/editor/components/image-bubble.tsx +28 -12
  513. package/src/editor/components/index.ts +3 -3
  514. package/src/editor/components/table-bubble.tsx +80 -18
  515. package/src/editor/editor.tsx +34 -15
  516. package/src/editor/extensions/HighlightDecorationExtension.ts +3 -2
  517. package/src/editor/extensions/Image/index.ts +3 -3
  518. package/src/editor/extensions/Image.ts +3 -3
  519. package/src/editor/extensions/clipboard.ts +2 -2
  520. package/src/editor/markdown-it-plugins.d.ts +24 -0
  521. package/src/editor/markdown.ts +2 -3
  522. package/src/editor/nodeViews/ReactNodeView.tsx +1 -1
  523. package/src/editor/nodeViews/TaskItemComponent.tsx +9 -8
  524. package/src/editor/schema.ts +135 -59
  525. package/src/editor/selectors/ai-selector.tsx +0 -1
  526. package/src/editor/selectors/color-selector.tsx +1 -2
  527. package/src/editor/selectors/link-selector.tsx +9 -7
  528. package/src/editor/selectors/node-selector.tsx +17 -3
  529. package/src/editor/selectors/text-buttons.tsx +1 -2
  530. package/src/editor/useProseMirror.ts +2 -2
  531. package/src/editor/utils/prosemirror-utils.ts +1 -1
  532. package/src/editor/utils/remove_classes.ts +6 -5
  533. package/src/form/EntityForm.tsx +222 -442
  534. package/src/form/EntityFormActions.tsx +49 -55
  535. package/src/form/EntityFormBinding.tsx +323 -0
  536. package/src/form/PropertyFieldBinding.tsx +81 -84
  537. package/src/form/components/ErrorFocus.tsx +1 -1
  538. package/src/form/components/FieldHelperText.tsx +6 -7
  539. package/src/form/components/FormLayout.tsx +1 -1
  540. package/src/form/components/LocalChangesMenu.tsx +20 -5
  541. package/src/form/components/StorageItemPreview.tsx +2 -3
  542. package/src/form/components/StorageUploadProgress.tsx +14 -7
  543. package/src/form/field_bindings/ArrayCustomShapedFieldBinding.tsx +5 -5
  544. package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +12 -13
  545. package/src/form/field_bindings/BlockFieldBinding.tsx +59 -58
  546. package/src/form/field_bindings/DateTimeFieldBinding.tsx +2 -2
  547. package/src/form/field_bindings/KeyValueFieldBinding.tsx +319 -303
  548. package/src/form/field_bindings/MapFieldBinding.tsx +14 -56
  549. package/src/form/field_bindings/MarkdownEditorFieldBinding.tsx +28 -10
  550. package/src/form/field_bindings/MultiSelectFieldBinding.tsx +3 -4
  551. package/src/form/field_bindings/MultipleRelationFieldBinding.tsx +11 -12
  552. package/src/form/field_bindings/ReadOnlyFieldBinding.tsx +9 -2
  553. package/src/form/field_bindings/ReferenceFieldBinding.tsx +17 -15
  554. package/src/form/field_bindings/RelationFieldBinding.tsx +157 -156
  555. package/src/form/field_bindings/RepeatFieldBinding.tsx +8 -8
  556. package/src/form/field_bindings/SelectFieldBinding.tsx +3 -4
  557. package/src/form/field_bindings/StorageUploadFieldBinding.tsx +107 -103
  558. package/src/form/field_bindings/SwitchFieldBinding.tsx +17 -17
  559. package/src/form/field_bindings/TextFieldBinding.tsx +90 -78
  560. package/src/form/field_bindings/UserSelectFieldBinding.tsx +18 -18
  561. package/src/form/field_bindings/VectorFieldBinding.tsx +202 -0
  562. package/src/form/form_utils.ts +163 -0
  563. package/src/form/index.tsx +15 -6
  564. package/src/form/useClearRestoreValue.tsx +1 -1
  565. package/src/form/validation.ts +104 -50
  566. package/src/hooks/index.ts +4 -4
  567. package/src/hooks/navigation/contexts/CollectionRegistryContext.tsx +5 -4
  568. package/src/hooks/navigation/contexts/NavigationStateContext.tsx +2 -2
  569. package/src/hooks/navigation/contexts/UrlContext.tsx +1 -2
  570. package/src/hooks/navigation/useAsyncResolver.ts +100 -0
  571. package/src/hooks/navigation/useBuildCollectionRegistryController.tsx +40 -21
  572. package/src/hooks/navigation/useBuildNavigationStateController.tsx +21 -22
  573. package/src/hooks/navigation/useNavigationResolution.ts +193 -21
  574. package/src/hooks/navigation/useResolvedCollections.ts +45 -77
  575. package/src/hooks/navigation/useResolvedViews.tsx +44 -123
  576. package/src/hooks/navigation/useTopLevelNavigation.ts +22 -18
  577. package/src/hooks/navigation/utils.ts +12 -9
  578. package/src/hooks/useBreadcrumbsController.tsx +2 -34
  579. package/src/hooks/{useBuildSideEntityController.tsx → useBuildSidePanel.tsx} +63 -24
  580. package/src/hooks/useCMSContext.tsx +7 -7
  581. package/src/hooks/{useEntityHistory.ts → useHistory.ts} +9 -4
  582. package/src/hooks/useResolvedNavigationFrom.tsx +8 -5
  583. package/src/hooks/{useEntitySelectionDialog.tsx → useSelectionDialog.tsx} +7 -7
  584. package/src/hooks/useSideDialogsController.tsx +1 -1
  585. package/src/hooks/useSidePanel.tsx +13 -0
  586. package/src/index.ts +34 -20
  587. package/src/preview/PropertyPreview.tsx +34 -41
  588. package/src/preview/components/DatePreview.tsx +1 -1
  589. package/src/preview/components/EnumValuesChip.tsx +1 -1
  590. package/src/preview/components/ImagePreview.tsx +4 -3
  591. package/src/preview/components/ReferencePreview.tsx +69 -18
  592. package/src/preview/components/RelationPreview.tsx +107 -18
  593. package/src/preview/components/StorageThumbnail.tsx +28 -8
  594. package/src/preview/components/UrlComponentPreview.tsx +12 -4
  595. package/src/preview/components/UserPreview.tsx +6 -15
  596. package/src/preview/property_previews/ArrayOfMapsPreview.tsx +5 -5
  597. package/src/preview/property_previews/ArrayOfReferencesPreview.tsx +5 -5
  598. package/src/preview/property_previews/ArrayOfRelationsPreview.tsx +4 -4
  599. package/src/preview/property_previews/ArrayOfStorageComponentsPreview.tsx +4 -4
  600. package/src/preview/property_previews/ArrayOfStringsPreview.tsx +3 -2
  601. package/src/preview/property_previews/ArrayOneOfPreview.tsx +7 -9
  602. package/src/preview/property_previews/ArrayPropertyEnumPreview.tsx +1 -1
  603. package/src/preview/property_previews/ArrayPropertyPreview.tsx +4 -4
  604. package/src/preview/property_previews/MapPropertyPreview.tsx +4 -3
  605. package/src/preview/property_previews/NumberPropertyPreview.tsx +5 -3
  606. package/src/preview/property_previews/SkeletonPropertyComponent.tsx +24 -25
  607. package/src/preview/property_previews/StringPropertyPreview.tsx +13 -11
  608. package/src/routes/CustomViewRoute.tsx +14 -6
  609. package/src/routes/RebaseRoute.tsx +112 -36
  610. package/src/types/components/EntityFormActionsProps.tsx +4 -4
  611. package/src/types/components/EntityFormProps.tsx +75 -5
  612. package/src/types/components/PropertyPreviewProps.tsx +6 -1
  613. package/src/types/components/formex.tsx +1 -45
  614. package/src/types/fields.tsx +26 -15
  615. package/src/util/dataControllerAdapter.ts +87 -0
  616. package/src/util/navigation_utils.ts +43 -13
  617. package/src/util/previews.ts +149 -13
  618. package/src/util/propertyConfigMapper.ts +134 -0
  619. package/src/util/property_utils.tsx +24 -9
  620. package/src/util/resolutions.ts +4 -8
  621. package/src/util/view_constants.ts +6 -0
  622. package/dist/CollectionEditorDialog-B2M9lCyL.js +0 -4720
  623. package/dist/CollectionEditorDialog-B2M9lCyL.js.map +0 -1
  624. package/dist/CollectionsStudioView-WG6soyfs.js +0 -218
  625. package/dist/CollectionsStudioView-WG6soyfs.js.map +0 -1
  626. package/dist/ContentHomePage-CDF_a6Lp.js +0 -1786
  627. package/dist/ContentHomePage-CDF_a6Lp.js.map +0 -1
  628. package/dist/ExportCollectionAction-Dc0VOWMN.js +0 -439
  629. package/dist/ExportCollectionAction-Dc0VOWMN.js.map +0 -1
  630. package/dist/ImportCollectionAction-DpCagAOy.js +0 -686
  631. package/dist/ImportCollectionAction-DpCagAOy.js.map +0 -1
  632. package/dist/PropertyEditView-DS67DxoT.js +0 -8138
  633. package/dist/PropertyEditView-DS67DxoT.js.map +0 -1
  634. package/dist/RoleChip-QtUFXeTp.js +0 -67
  635. package/dist/RoleChip-QtUFXeTp.js.map +0 -1
  636. package/dist/RolesView-CIuYBimF.js +0 -424
  637. package/dist/RolesView-CIuYBimF.js.map +0 -1
  638. package/dist/UsersView-B5zelXnH.js +0 -493
  639. package/dist/UsersView-B5zelXnH.js.map +0 -1
  640. package/dist/collection_editor/types/config_permissions.d.ts +0 -19
  641. package/dist/components/EntityCollectionTable/EntityCollectionTable.d.ts +0 -27
  642. package/dist/components/EntityCollectionTable/fields/VirtualTableDateField.d.ts +0 -12
  643. package/dist/components/EntityCollectionTable/fields/VirtualTableInput.d.ts +0 -9
  644. package/dist/components/EntityCollectionTable/fields/VirtualTableNumberInput.d.ts +0 -8
  645. package/dist/components/EntityCollectionTable/fields/VirtualTableSwitch.d.ts +0 -7
  646. package/dist/components/EntityCollectionTable/index.d.ts +0 -6
  647. package/dist/components/EntityCollectionView/Board.d.ts +0 -2
  648. package/dist/components/EntityCollectionView/BoardColumn.d.ts +0 -42
  649. package/dist/components/EntityCollectionView/BoardColumnTitle.d.ts +0 -9
  650. package/dist/components/EntityCollectionView/BoardSortableList.d.ts +0 -14
  651. package/dist/components/EntityCollectionView/EntityBoardCard.d.ts +0 -31
  652. package/dist/components/EntityCollectionView/EntityCard.d.ts +0 -20
  653. package/dist/components/EntityCollectionView/EntityCollectionBoardView.d.ts +0 -21
  654. package/dist/components/EntityCollectionView/EntityCollectionListView.d.ts +0 -34
  655. package/dist/components/EntityCollectionView/EntityCollectionView.d.ts +0 -64
  656. package/dist/components/EntityCollectionView/EntityCollectionViewActions.d.ts +0 -18
  657. package/dist/components/EntityCollectionView/EntityCollectionViewStartActions.d.ts +0 -18
  658. package/dist/components/EntityCollectionView/board_types.d.ts +0 -105
  659. package/dist/components/EntityEditView.d.ts +0 -49
  660. package/dist/components/EntityEditViewFormActions.d.ts +0 -2
  661. package/dist/components/EntityJsonPreview.d.ts +0 -3
  662. package/dist/components/EntitySidePanel.d.ts +0 -10
  663. package/dist/components/EntityView.d.ts +0 -12
  664. package/dist/components/admin/RoleChip.d.ts +0 -4
  665. package/dist/components/admin/RolesView.d.ts +0 -4
  666. package/dist/components/admin/UsersView.d.ts +0 -4
  667. package/dist/contexts/SideEntityControllerContext.d.ts +0 -3
  668. package/dist/form/field_bindings/ReferenceAsStringFieldBinding.d.ts +0 -10
  669. package/dist/hooks/navigation/useNavigationRegistry.d.ts +0 -11
  670. package/dist/hooks/navigation/useNavigationURLs.d.ts +0 -11
  671. package/dist/hooks/useBuildSideEntityController.d.ts +0 -6
  672. package/dist/hooks/useSideEntityController.d.ts +0 -11
  673. package/dist/index-CBhrgpR7.js +0 -12
  674. package/dist/index-CBhrgpR7.js.map +0 -1
  675. package/dist/index-CHxgwt6E.js +0 -456
  676. package/dist/index-CHxgwt6E.js.map +0 -1
  677. package/dist/index-Dey5WJpO.js +0 -8
  678. package/dist/index-Dey5WJpO.js.map +0 -1
  679. package/dist/index.js.map +0 -1
  680. package/dist/markdown-z2Ir7Cgo.js +0 -618
  681. package/dist/markdown-z2Ir7Cgo.js.map +0 -1
  682. package/dist/useEntityHistory-Dcj4zhGj.js +0 -121
  683. package/dist/useEntityHistory-Dcj4zhGj.js.map +0 -1
  684. package/dist/util-BQ82ySL3.js +0 -27720
  685. package/dist/util-BQ82ySL3.js.map +0 -1
  686. package/src/collection_editor/types/config_permissions.ts +0 -20
  687. package/src/components/EntityCollectionTable/fields/VirtualTableDateField.tsx +0 -39
  688. package/src/components/EntityCollectionTable/fields/VirtualTableInput.tsx +0 -90
  689. package/src/components/EntityCollectionTable/fields/VirtualTableNumberInput.tsx +0 -80
  690. package/src/components/EntityCollectionTable/fields/VirtualTableSwitch.tsx +0 -32
  691. package/src/components/EntityCollectionTable/index.tsx +0 -14
  692. package/src/components/EntityCollectionView/Board.tsx +0 -474
  693. package/src/components/EntityCollectionView/BoardColumn.tsx +0 -158
  694. package/src/components/EntityCollectionView/BoardColumnTitle.tsx +0 -45
  695. package/src/components/EntityCollectionView/BoardSortableList.tsx +0 -177
  696. package/src/components/EntityCollectionView/EntityCollectionCardView.tsx +0 -267
  697. package/src/components/EntityCollectionView/board_types.ts +0 -113
  698. package/src/components/EntityEditView.tsx +0 -632
  699. package/src/components/EntitySidePanel.tsx +0 -160
  700. package/src/components/admin/RoleChip.tsx +0 -23
  701. package/src/components/admin/RolesView.tsx +0 -419
  702. package/src/components/admin/UsersView.tsx +0 -782
  703. package/src/contexts/SideEntityControllerContext.tsx +0 -5
  704. package/src/form/field_bindings/ReferenceAsStringFieldBinding.tsx +0 -141
  705. package/src/hooks/navigation/useNavigationRegistry.ts +0 -153
  706. package/src/hooks/navigation/useNavigationURLs.ts +0 -56
  707. package/src/hooks/useSideEntityController.tsx +0 -13
  708. /package/dist/components/{EntityCollectionTable → CollectionTableBinding}/PropertyTableCell.d.ts +0 -0
  709. /package/dist/components/{EntityCollectionTable → CollectionTableBinding}/internal/popup_field/useDraggable.d.ts +0 -0
  710. /package/dist/components/{EntityCollectionTable → CollectionTableBinding}/internal/popup_field/useWindowSize.d.ts +0 -0
  711. /package/dist/components/{EntityCollectionView → CollectionViewBinding}/useSelectionController.d.ts +0 -0
  712. /package/dist/components/{EntityCollectionView → CollectionViewBinding}/utils.d.ts +0 -0
  713. /package/src/components/{EntityCollectionTable → CollectionTableBinding}/fields/VirtualTableUserSelect.tsx +0 -0
  714. /package/src/components/{EntityCollectionTable → CollectionTableBinding}/internal/popup_field/useWindowSize.tsx +0 -0
  715. /package/src/components/{EntityCollectionView → CollectionViewBinding}/useSelectionController.tsx +0 -0
  716. /package/src/components/{EntityCollectionView → CollectionViewBinding}/utils.ts +0 -0
@@ -0,0 +1,3808 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
2
+ import { Bt as getFieldId, Ft as PropertyConfigBadge, It as DEFAULT_FIELD_CONFIGS, Wn as useCollectionRegistryController, _ as toSerializableProperty, a as namespaceToPropertiesPath, fn as FieldCaption, h as toSerializableCollectionConfig, i as namespaceToPropertiesOrderPath, n as getFullIdPath, r as idToPropertiesPath, t as getFullId, tn as ArrayContainer, zt as getFieldConfig } from "./src-DLAFyeZI.js";
3
+ import React, { createContext, useCallback, useContext, useDeferredValue, useEffect, useMemo, useRef, useState } from "react";
4
+ import { deepEqual } from "fast-equals";
5
+ import { AlertTriangleIcon, ArrowDownToLineIcon, ArrowUpToLineIcon, Badge, BooleanSwitchWithLabel, Button, Card, CheckSquareIcon, CircularProgress, DebouncedTextField, Dialog, DialogActions, DialogContent, DialogTitle, ErrorBoundary, ExpandablePanel, FileSearchIcon, FunctionSquareIcon, IconButton, InfoLabel, ListIcon, Menu, MenuItem, MinusCircleIcon, MoreVerticalIcon, MultiSelect, MultiSelectItem, Paper, PlusIcon, RefreshCcwIcon, Select, SelectItem, SettingsIcon, TextField, Tooltip, Trash2Icon, Typography, UploadCloudIcon, cls, defaultBorderMixin, iconSize } from "@rebasepro/ui";
6
+ import { isPropertyBuilder, resolveEnumValues } from "@rebasepro/common";
7
+ import { AIModifiedIndicator, ConfirmationDialog, IconForView, useCustomizationController, useSnackbarController, useStorageSources, useTranslation } from "@rebasepro/app";
8
+ import { Field, Formex, getIn, useCreateFormex, useFormex } from "@rebasepro/forms";
9
+ import { isValidRegExp, mergeDeep, prettifyIdentifier, serializeRegExp, toSnakeCase } from "@rebasepro/utils";
10
+ import { DEFAULT_STORAGE_SOURCE_KEY } from "@rebasepro/types";
11
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
12
+ import { DndContext, KeyboardSensor, PointerSensor, closestCenter, useSensor, useSensors } from "@dnd-kit/core";
13
+ import { restrictToVerticalAxis } from "@dnd-kit/modifiers";
14
+ import { SortableContext, sortableKeyboardCoordinates, useSortable, verticalListSortingStrategy } from "@dnd-kit/sortable";
15
+ import { CSS } from "@dnd-kit/utilities";
16
+ import { extractEnumFromValues } from "@rebasepro/inference";
17
+ //#region src/collection_editor/useSafeSnackbarController.ts
18
+ function useSafeSnackbarController() {
19
+ try {
20
+ return useSnackbarController();
21
+ } catch {
22
+ return;
23
+ }
24
+ }
25
+ //#endregion
26
+ //#region src/collection_editor/ui/collection_editor/EnumForm.tsx
27
+ function EnumForm({ enumValues, onValuesChanged, onError, updateIds, disabled, allowDataInference, getData }) {
28
+ const formex = useCreateFormex({
29
+ initialValues: { enum: enumValues },
30
+ validateOnChange: true,
31
+ validation: (values) => {
32
+ const enumErrors = [];
33
+ let hasAnyError = false;
34
+ if (values.enum) values.enum.forEach((enumValue, index) => {
35
+ const fieldError = {};
36
+ if (!enumValue?.label) {
37
+ fieldError.label = "You must specify a label for this enum value entry";
38
+ hasAnyError = true;
39
+ }
40
+ if (!enumValue?.id) {
41
+ fieldError.id = "You must specify an ID for this enum value entry";
42
+ hasAnyError = true;
43
+ }
44
+ enumErrors[index] = fieldError;
45
+ });
46
+ const errors = hasAnyError ? { enum: enumErrors } : {};
47
+ onError?.(hasAnyError);
48
+ return errors;
49
+ }
50
+ });
51
+ const { values, errors } = formex;
52
+ useEffect(() => {
53
+ if (onValuesChanged) onValuesChanged(values.enum);
54
+ }, [values.enum]);
55
+ return /* @__PURE__ */ jsx(Formex, {
56
+ value: formex,
57
+ children: /* @__PURE__ */ jsx(EnumFormFields, {
58
+ enumValuesPath: "enum",
59
+ values,
60
+ errors,
61
+ shouldUpdateId: updateIds,
62
+ disabled,
63
+ allowDataInference,
64
+ getData
65
+ })
66
+ });
67
+ }
68
+ function EnumFormFields({ values, errors, disabled, enumValuesPath, shouldUpdateId, allowDataInference, getData }) {
69
+ const { setFieldValue } = useFormex();
70
+ const [lastInternalIdAdded, setLastInternalIdAdded] = React.useState();
71
+ const [editDialogIndex, setEditDialogIndex] = React.useState();
72
+ const [inferring, setInferring] = React.useState(false);
73
+ const inferredValues = React.useRef(/* @__PURE__ */ new Set()).current;
74
+ const buildEntry = ({ index, internalId }) => {
75
+ const justAdded = lastInternalIdAdded === internalId;
76
+ const entryError = errors?.enum?.[index];
77
+ return /* @__PURE__ */ jsx(EnumEntry, {
78
+ index,
79
+ disabled,
80
+ enumValuesPath,
81
+ autoFocus: justAdded,
82
+ entryError,
83
+ shouldUpdateId: shouldUpdateId || justAdded,
84
+ onDialogOpen: () => setEditDialogIndex(index),
85
+ inferredEntry: inferredValues.has(values.enum[index]?.id)
86
+ }, `${internalId}`);
87
+ };
88
+ const inferValues = async () => {
89
+ if (!getData) return;
90
+ setInferring(true);
91
+ getData?.().then((data) => {
92
+ if (!data) return;
93
+ const flatData = data.flat();
94
+ const fieldData = Array.from(new Set(flatData));
95
+ const currentEnumValues = values.enum;
96
+ const newEnumValues = extractEnumFromValues(fieldData).filter((enumValue) => {
97
+ if (!enumValue) return false;
98
+ return !currentEnumValues?.some((v) => v.id === enumValue.id);
99
+ });
100
+ newEnumValues.forEach((enumValue) => {
101
+ if (enumValue) inferredValues.add(enumValue.id);
102
+ });
103
+ setFieldValue(enumValuesPath, [...newEnumValues, ...currentEnumValues], true);
104
+ }).catch((e) => {
105
+ console.error(e);
106
+ }).finally(() => setInferring(false));
107
+ };
108
+ return /* @__PURE__ */ jsxs("div", {
109
+ className: "col-span-12",
110
+ children: [/* @__PURE__ */ jsxs("div", {
111
+ className: "ml-3.5 flex flex-row items-center",
112
+ children: [
113
+ /* @__PURE__ */ jsx(ListIcon, {}),
114
+ /* @__PURE__ */ jsx(Typography, {
115
+ variant: "subtitle2",
116
+ className: "ml-2 grow",
117
+ children: "Values"
118
+ }),
119
+ allowDataInference && /* @__PURE__ */ jsxs(Button, {
120
+ loading: inferring,
121
+ disabled: disabled || inferring,
122
+ variant: "text",
123
+ size: "small",
124
+ onClick: inferValues,
125
+ children: [inferring ? /* @__PURE__ */ jsx(CircularProgress, { size: "smallest" }) : /* @__PURE__ */ jsx(RefreshCcwIcon, {}), "Infer values from data"]
126
+ })
127
+ ]
128
+ }), /* @__PURE__ */ jsxs(Paper, {
129
+ className: "p-4 m-1",
130
+ children: [/* @__PURE__ */ jsx(ArrayContainer, {
131
+ droppableId: enumValuesPath,
132
+ addLabel: "Add enum value",
133
+ value: values.enum,
134
+ disabled,
135
+ size: "small",
136
+ buildEntry,
137
+ onInternalIdAdded: setLastInternalIdAdded,
138
+ canAddElements: true,
139
+ onValueChange: (value) => setFieldValue(enumValuesPath, value),
140
+ newDefaultEntry: {
141
+ id: "",
142
+ label: ""
143
+ }
144
+ }), /* @__PURE__ */ jsx(EnumEntryDialog, {
145
+ index: editDialogIndex,
146
+ open: editDialogIndex !== void 0,
147
+ enumValuesPath,
148
+ onClose: () => setEditDialogIndex(void 0)
149
+ })]
150
+ })]
151
+ });
152
+ }
153
+ var EnumEntry = React.memo(function EnumEntryInternal({ index, shouldUpdateId: updateId, enumValuesPath, autoFocus, onDialogOpen, disabled, inferredEntry, entryError }) {
154
+ const { values, handleChange, errors, setFieldValue, touched } = useFormex();
155
+ const shouldUpdateIdRef = React.useRef(!getIn(values, `${enumValuesPath}[${index}].id`));
156
+ const shouldUpdateId = updateId || shouldUpdateIdRef.current;
157
+ const idValue = getIn(values, `${enumValuesPath}[${index}].id`);
158
+ const labelValue = getIn(values, `${enumValuesPath}[${index}].label`);
159
+ const currentLabelRef = React.useRef(labelValue);
160
+ React.useEffect(() => {
161
+ if ((currentLabelRef.current === idValue || !idValue) && shouldUpdateId) setFieldValue(`${enumValuesPath}[${index}].id`, labelValue);
162
+ currentLabelRef.current = labelValue;
163
+ }, [labelValue]);
164
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
165
+ /* @__PURE__ */ jsxs("div", {
166
+ className: "flex w-full align-center justify-center",
167
+ children: [/* @__PURE__ */ jsx(Field, {
168
+ name: `${enumValuesPath}[${index}].label`,
169
+ as: DebouncedTextField,
170
+ className: "grow",
171
+ required: true,
172
+ disabled,
173
+ size: "small",
174
+ autoFocus,
175
+ autoComplete: "off",
176
+ endAdornment: inferredEntry && /* @__PURE__ */ jsx(RefreshCcwIcon, { size: iconSize.small }),
177
+ error: Boolean(entryError?.label)
178
+ }), !disabled && /* @__PURE__ */ jsx(Badge, {
179
+ color: "error",
180
+ invisible: !entryError?.id,
181
+ children: /* @__PURE__ */ jsx(IconButton, {
182
+ size: "small",
183
+ "aria-label": "edit",
184
+ className: "m-1",
185
+ onClick: () => onDialogOpen(),
186
+ children: /* @__PURE__ */ jsx(SettingsIcon, { size: iconSize.small })
187
+ })
188
+ })]
189
+ }),
190
+ entryError?.label && /* @__PURE__ */ jsx(Typography, {
191
+ variant: "caption",
192
+ className: "ml-3.5 text-red-500 dark:text-red-500",
193
+ children: entryError?.label
194
+ }),
195
+ entryError?.id && /* @__PURE__ */ jsx(Typography, {
196
+ variant: "caption",
197
+ className: "ml-3.5 text-red-500 dark:text-red-500",
198
+ children: entryError?.id
199
+ })
200
+ ] });
201
+ }, function areEqual(prevProps, nextProps) {
202
+ return prevProps.index === nextProps.index && prevProps.enumValuesPath === nextProps.enumValuesPath && prevProps.shouldUpdateId === nextProps.shouldUpdateId && prevProps.inferredEntry === nextProps.inferredEntry && deepEqual(prevProps.entryError, nextProps.entryError) && prevProps.autoFocus === nextProps.autoFocus;
203
+ });
204
+ function EnumEntryDialog({ index, open, onClose, enumValuesPath }) {
205
+ const { errors } = useFormex();
206
+ const idError = index !== void 0 ? getIn(errors, `${enumValuesPath}[${index}].id`) : void 0;
207
+ return /* @__PURE__ */ jsxs(Dialog, {
208
+ maxWidth: "md",
209
+ "aria-labelledby": "enum-edit-dialog",
210
+ open,
211
+ onOpenChange: (open) => !open ? onClose() : void 0,
212
+ children: [
213
+ /* @__PURE__ */ jsx(DialogTitle, {
214
+ hidden: true,
215
+ children: "Enum form dialog"
216
+ }),
217
+ /* @__PURE__ */ jsx(DialogContent, { children: index !== void 0 && /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(Field, {
218
+ name: `${enumValuesPath}[${index}].id`,
219
+ as: DebouncedTextField,
220
+ required: true,
221
+ label: "ID",
222
+ size: "small",
223
+ autoComplete: "off",
224
+ error: Boolean(idError)
225
+ }), /* @__PURE__ */ jsx(FieldCaption, {
226
+ error: Boolean(idError),
227
+ children: idError ?? "Value saved in the data source"
228
+ })] }) }),
229
+ /* @__PURE__ */ jsx(DialogActions, { children: /* @__PURE__ */ jsx(Button, {
230
+ autoFocus: true,
231
+ onClick: onClose,
232
+ children: "Ok"
233
+ }) })
234
+ ]
235
+ });
236
+ }
237
+ //#endregion
238
+ //#region src/collection_editor/ui/collection_editor/SwitchControl.tsx
239
+ function SwitchControl({ field, form, label, tooltip, disabled, size = "small", allowIndeterminate }) {
240
+ const formControlLabel = /* @__PURE__ */ jsx(BooleanSwitchWithLabel, {
241
+ label,
242
+ size,
243
+ position: "start",
244
+ value: field.value,
245
+ disabled,
246
+ allowIndeterminate,
247
+ onValueChange: (checked) => form.setFieldValue(field.name, checked)
248
+ });
249
+ if (tooltip) return /* @__PURE__ */ jsx(Tooltip, {
250
+ title: tooltip,
251
+ children: formControlLabel
252
+ });
253
+ return formControlLabel;
254
+ }
255
+ //#endregion
256
+ //#region src/collection_editor/ui/collection_editor/properties/validation/GeneralPropertyValidation.tsx
257
+ function GeneralPropertyValidation({ disabled }) {
258
+ const { values, handleChange } = useFormex();
259
+ const { t } = useTranslation();
260
+ const validationRequired = "validation.required";
261
+ const validationRequiredMessage = "validation.requiredMessage";
262
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
263
+ /* @__PURE__ */ jsx("div", {
264
+ className: "col-span-6",
265
+ children: /* @__PURE__ */ jsx(Field, {
266
+ name: validationRequired,
267
+ type: "checkbox",
268
+ children: ({ field, form }) => {
269
+ return /* @__PURE__ */ jsx(SwitchControl, {
270
+ disabled,
271
+ label: t("required"),
272
+ tooltip: t("required_tooltip"),
273
+ form,
274
+ field
275
+ });
276
+ }
277
+ })
278
+ }),
279
+ /* @__PURE__ */ jsx("div", {
280
+ className: "col-span-6",
281
+ children: /* @__PURE__ */ jsx(Field, {
282
+ name: "validation.unique",
283
+ type: "checkbox",
284
+ children: ({ field, form }) => {
285
+ return /* @__PURE__ */ jsx(SwitchControl, {
286
+ disabled,
287
+ label: t("unique"),
288
+ tooltip: t("unique_tooltip"),
289
+ form,
290
+ field
291
+ });
292
+ }
293
+ })
294
+ }),
295
+ getIn(values, validationRequired) && /* @__PURE__ */ jsx("div", {
296
+ className: "col-span-12",
297
+ children: /* @__PURE__ */ jsx(DebouncedTextField, {
298
+ disabled,
299
+ value: getIn(values, validationRequiredMessage),
300
+ label: t("required_message"),
301
+ name: validationRequiredMessage,
302
+ size: "small",
303
+ onChange: handleChange
304
+ })
305
+ })
306
+ ] });
307
+ }
308
+ //#endregion
309
+ //#region src/collection_editor/ui/collection_editor/properties/validation/StringPropertyValidation.tsx
310
+ function StringPropertyValidation({ length, lowercase, matches, max, min, trim, uppercase, disabled, showErrors }) {
311
+ const { values, handleChange, errors } = useFormex();
312
+ const { t } = useTranslation();
313
+ const validationLength = "validation.length";
314
+ const validationMin = "validation.min";
315
+ const validationMax = "validation.max";
316
+ const validationTrim = "validation.trim";
317
+ const validationMatches = "validation.matches";
318
+ const validationLowercase = "validation.lowercase";
319
+ const validationUppercase = "validation.uppercase";
320
+ const matchesError = getIn(errors, validationMatches);
321
+ const matchesValue = getIn(values, validationMatches);
322
+ const matchesStringValue = typeof matchesValue === "string" ? matchesValue : serializeRegExp(matchesValue);
323
+ return /* @__PURE__ */ jsxs("div", {
324
+ className: "grid grid-cols-12 gap-2",
325
+ children: [
326
+ /* @__PURE__ */ jsx(GeneralPropertyValidation, { disabled }),
327
+ /* @__PURE__ */ jsxs("div", {
328
+ className: "grid grid-cols-12 gap-2 col-span-12",
329
+ children: [
330
+ lowercase && /* @__PURE__ */ jsx("div", {
331
+ className: "col-span-4",
332
+ children: /* @__PURE__ */ jsx(Field, {
333
+ name: validationLowercase,
334
+ type: "checkbox",
335
+ children: ({ field, form }) => {
336
+ return /* @__PURE__ */ jsx(SwitchControl, {
337
+ label: t("lowercase"),
338
+ disabled,
339
+ form,
340
+ field
341
+ });
342
+ }
343
+ })
344
+ }),
345
+ uppercase && /* @__PURE__ */ jsx("div", {
346
+ className: "col-span-4",
347
+ children: /* @__PURE__ */ jsx(Field, {
348
+ name: validationUppercase,
349
+ type: "checkbox",
350
+ children: ({ field, form }) => {
351
+ return /* @__PURE__ */ jsx(SwitchControl, {
352
+ label: t("uppercase"),
353
+ disabled,
354
+ form,
355
+ field
356
+ });
357
+ }
358
+ })
359
+ }),
360
+ trim && /* @__PURE__ */ jsx("div", {
361
+ className: "col-span-4",
362
+ children: /* @__PURE__ */ jsx(Field, {
363
+ name: validationTrim,
364
+ type: "checkbox",
365
+ children: ({ field, form }) => {
366
+ return /* @__PURE__ */ jsx(SwitchControl, {
367
+ label: t("trim"),
368
+ disabled,
369
+ form,
370
+ field
371
+ });
372
+ }
373
+ })
374
+ })
375
+ ]
376
+ }),
377
+ /* @__PURE__ */ jsxs("div", {
378
+ className: "grid grid-cols-12 gap-2 col-span-12",
379
+ children: [
380
+ length && /* @__PURE__ */ jsx("div", {
381
+ className: "col-span-4",
382
+ children: /* @__PURE__ */ jsx(DebouncedTextField, {
383
+ value: getIn(values, validationLength),
384
+ label: t("exact_length"),
385
+ name: validationLength,
386
+ type: "number",
387
+ size: "small",
388
+ disabled,
389
+ onChange: handleChange
390
+ })
391
+ }),
392
+ min && /* @__PURE__ */ jsx("div", {
393
+ className: "col-span-4",
394
+ children: /* @__PURE__ */ jsx(DebouncedTextField, {
395
+ value: getIn(values, validationMin),
396
+ label: t("min_length"),
397
+ name: validationMin,
398
+ type: "number",
399
+ size: "small",
400
+ disabled,
401
+ onChange: handleChange
402
+ })
403
+ }),
404
+ max && /* @__PURE__ */ jsx("div", {
405
+ className: "col-span-4",
406
+ children: /* @__PURE__ */ jsx(DebouncedTextField, {
407
+ value: getIn(values, validationMax),
408
+ label: t("max_length"),
409
+ name: validationMax,
410
+ type: "number",
411
+ size: "small",
412
+ disabled,
413
+ onChange: handleChange
414
+ })
415
+ })
416
+ ]
417
+ }),
418
+ matches && /* @__PURE__ */ jsxs("div", {
419
+ className: "col-span-12",
420
+ children: [/* @__PURE__ */ jsx(Field, {
421
+ name: validationMatches,
422
+ as: DebouncedTextField,
423
+ label: t("matches_regex"),
424
+ size: "small",
425
+ disabled,
426
+ value: matchesStringValue,
427
+ error: Boolean(matchesError)
428
+ }), /* @__PURE__ */ jsx(FieldCaption, {
429
+ error: Boolean(matchesError),
430
+ children: matchesError ? t("not_valid_regexp") : t("regex_helper")
431
+ })]
432
+ })
433
+ ]
434
+ });
435
+ }
436
+ //#endregion
437
+ //#region src/collection_editor/ui/collection_editor/properties/validation/ArrayPropertyValidation.tsx
438
+ function ArrayPropertyValidation({ max = true, min = true, disabled }) {
439
+ const { values, handleChange } = useFormex();
440
+ const { t } = useTranslation();
441
+ const validationMin = "validation.min";
442
+ const validationMax = "validation.max";
443
+ return /* @__PURE__ */ jsxs("div", {
444
+ className: "grid grid-cols-12 gap-2",
445
+ children: [
446
+ /* @__PURE__ */ jsx(GeneralPropertyValidation, { disabled }),
447
+ min && /* @__PURE__ */ jsx("div", {
448
+ className: "col-span-6",
449
+ children: /* @__PURE__ */ jsx(DebouncedTextField, {
450
+ value: getIn(values, validationMin),
451
+ disabled,
452
+ label: t("min_length"),
453
+ name: validationMin,
454
+ type: "number",
455
+ size: "small",
456
+ onChange: handleChange
457
+ })
458
+ }),
459
+ max && /* @__PURE__ */ jsx("div", {
460
+ className: "col-span-6",
461
+ children: /* @__PURE__ */ jsx(DebouncedTextField, {
462
+ value: getIn(values, validationMax),
463
+ disabled,
464
+ label: t("max_length"),
465
+ name: validationMax,
466
+ type: "number",
467
+ size: "small",
468
+ onChange: handleChange
469
+ })
470
+ })
471
+ ]
472
+ });
473
+ }
474
+ //#endregion
475
+ //#region src/collection_editor/ui/collection_editor/properties/validation/ValidationPanel.tsx
476
+ function ValidationPanel({ children }) {
477
+ return /* @__PURE__ */ jsx(ExpandablePanel, {
478
+ initiallyExpanded: false,
479
+ asField: true,
480
+ innerClassName: "p-4",
481
+ title: /* @__PURE__ */ jsxs("div", {
482
+ className: "flex flex-row text-surface-500 text-text-secondary dark:text-text-secondary-dark",
483
+ children: [/* @__PURE__ */ jsx(CheckSquareIcon, {}), /* @__PURE__ */ jsx(Typography, {
484
+ variant: "subtitle2",
485
+ className: "ml-4",
486
+ children: "Validation"
487
+ })]
488
+ }),
489
+ children
490
+ });
491
+ }
492
+ //#endregion
493
+ //#region src/collection_editor/ui/collection_editor/properties/EnumPropertyField.tsx
494
+ function EnumPropertyField({ multiselect, updateIds, disabled, showErrors, allowDataInference, getData, propertyNamespace }) {
495
+ const { values, setFieldError, setFieldValue } = useFormex();
496
+ const snackbarContext = useSafeSnackbarController();
497
+ const { t } = useTranslation();
498
+ const enumValuesPath = multiselect ? "of.enum" : "enum";
499
+ const defaultValue = getIn(values, "defaultValue");
500
+ const valuesEnumValues = getIn(values, enumValuesPath);
501
+ const enumValues = useMemo(() => {
502
+ if (!valuesEnumValues || typeof valuesEnumValues === "boolean") return [];
503
+ return resolveEnumValues(valuesEnumValues) ?? [];
504
+ }, [valuesEnumValues]);
505
+ const onValuesChanged = (value) => {
506
+ if (!values) return;
507
+ setFieldValue(enumValuesPath, value);
508
+ if (!multiselect) {
509
+ const enumIds = value.filter((v) => Boolean(v?.id)).map((v) => v.id);
510
+ if (defaultValue && !enumIds.includes(defaultValue)) {
511
+ setFieldValue("defaultValue", void 0);
512
+ snackbarContext?.open({
513
+ type: "warning",
514
+ message: "Default value was cleared"
515
+ });
516
+ }
517
+ }
518
+ };
519
+ const fullPropertyPath = values.id ? propertyNamespace ? `${propertyNamespace}.${values.id}` : values.id : void 0;
520
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
521
+ /* @__PURE__ */ jsx("div", {
522
+ className: "col-span-12",
523
+ children: /* @__PURE__ */ jsx(EnumForm, {
524
+ enumValues,
525
+ updateIds,
526
+ disabled,
527
+ allowDataInference,
528
+ onError: (hasError) => {
529
+ setFieldError(enumValuesPath, hasError ? "This enum property is missing some values" : void 0);
530
+ },
531
+ getData: getData && fullPropertyPath ? () => getData().then((res) => res.map((entry) => getIn(entry, fullPropertyPath)).filter(Boolean)) : void 0,
532
+ onValuesChanged
533
+ })
534
+ }),
535
+ /* @__PURE__ */ jsx("div", {
536
+ className: "col-span-12",
537
+ children: /* @__PURE__ */ jsxs(ValidationPanel, { children: [!multiselect && /* @__PURE__ */ jsx(StringPropertyValidation, {
538
+ disabled,
539
+ showErrors
540
+ }), multiselect && /* @__PURE__ */ jsx(ArrayPropertyValidation, { disabled })] })
541
+ }),
542
+ !multiselect && /* @__PURE__ */ jsx("div", {
543
+ className: "col-span-12",
544
+ children: /* @__PURE__ */ jsx(Select, {
545
+ disabled,
546
+ position: "item-aligned",
547
+ fullWidth: true,
548
+ onValueChange: (value) => {
549
+ setFieldValue("defaultValue", value);
550
+ },
551
+ label: t("default_value"),
552
+ value: defaultValue?.toString() ?? "",
553
+ children: enumValues.filter((enumValue) => Boolean(enumValue?.id)).map((enumValue) => /* @__PURE__ */ jsx(SelectItem, {
554
+ value: enumValue.id?.toString(),
555
+ children: enumValue.label
556
+ }, enumValue.id))
557
+ })
558
+ })
559
+ ] });
560
+ }
561
+ //#endregion
562
+ //#region src/collection_editor/ui/collection_editor/properties/StoragePropertyField.tsx
563
+ var fileTypes = {
564
+ "image/*": "Images",
565
+ "video/*": "Videos",
566
+ "audio/*": "Audio files",
567
+ "application/*": "Files (pdf, zip, csv, excel...)",
568
+ "text/*": "Text files"
569
+ };
570
+ function StoragePropertyField({ multiple, existing, disabled }) {
571
+ const { values, setFieldValue } = useFormex();
572
+ const { t } = useTranslation();
573
+ const storageSources = useStorageSources();
574
+ const baseStoragePath = multiple ? "of.storage" : "storage";
575
+ const acceptedFiles = `${baseStoragePath}.acceptedFiles`;
576
+ const storageSource = `${baseStoragePath}.storageSource`;
577
+ `${baseStoragePath}`;
578
+ const fileName = `${baseStoragePath}.fileName`;
579
+ const maxSize = `${baseStoragePath}.maxSize`;
580
+ const storagePath = `${baseStoragePath}.storagePath`;
581
+ const storeUrl = `${baseStoragePath}.storeUrl`;
582
+ const includeBucketUrl = `${baseStoragePath}.includeBucketUrl`;
583
+ const imageResize = `${baseStoragePath}.imageResize`;
584
+ const imageResizeMaxWidth = `${imageResize}.maxWidth`;
585
+ const imageResizeMaxHeight = `${imageResize}.maxHeight`;
586
+ const imageResizeMode = `${imageResize}.mode`;
587
+ const imageResizeFormat = `${imageResize}.format`;
588
+ const imageResizeQuality = `${imageResize}.quality`;
589
+ const fileNameValue = getIn(values, fileName) ?? "{rand}_{file}";
590
+ const storagePathValue = getIn(values, storagePath) ?? "/";
591
+ const maxSizeValue = getIn(values, maxSize);
592
+ const imageResizeMaxWidthValue = getIn(values, imageResizeMaxWidth);
593
+ const imageResizeMaxHeightValue = getIn(values, imageResizeMaxHeight);
594
+ const imageResizeModeValue = getIn(values, imageResizeMode) ?? "cover";
595
+ const imageResizeFormatValue = getIn(values, imageResizeFormat) ?? "original";
596
+ const imageResizeQualityValue = getIn(values, imageResizeQuality);
597
+ const storedValue = getIn(values, acceptedFiles);
598
+ const fileTypesValue = Array.isArray(storedValue) ? storedValue : void 0;
599
+ const allFileTypesSelected = !fileTypesValue || fileTypesValue.length === 0;
600
+ const sourceKeys = Object.keys(storageSources.sources).filter((key) => key !== DEFAULT_STORAGE_SOURCE_KEY);
601
+ const storageSourceValue = getIn(values, storageSource) ?? DEFAULT_STORAGE_SOURCE_KEY;
602
+ const handleTypesChange = (value) => {
603
+ if (!value) setFieldValue(acceptedFiles, void 0);
604
+ else setFieldValue(acceptedFiles, value);
605
+ };
606
+ const hasFilenameCallback = typeof fileNameValue === "function";
607
+ const hasStoragePathCallback = typeof storagePathValue === "function";
608
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
609
+ className: "col-span-12",
610
+ children: /* @__PURE__ */ jsx(ExpandablePanel, {
611
+ title: /* @__PURE__ */ jsxs("div", {
612
+ className: "flex flex-row text-surface-500 text-text-secondary dark:text-text-secondary-dark",
613
+ children: [/* @__PURE__ */ jsx(UploadCloudIcon, {}), /* @__PURE__ */ jsx(Typography, {
614
+ variant: "subtitle2",
615
+ className: "ml-4",
616
+ children: "File upload config"
617
+ })]
618
+ }),
619
+ children: /* @__PURE__ */ jsxs("div", {
620
+ className: "grid grid-cols-12 gap-2 p-4",
621
+ children: [
622
+ sourceKeys.length > 0 && /* @__PURE__ */ jsx("div", {
623
+ className: "col-span-12",
624
+ children: /* @__PURE__ */ jsxs(Select, {
625
+ className: "w-full",
626
+ disabled,
627
+ name: storageSource,
628
+ value: storageSourceValue,
629
+ onValueChange: (value) => setFieldValue(storageSource, !value || value === DEFAULT_STORAGE_SOURCE_KEY ? void 0 : value),
630
+ label: "Storage backend",
631
+ renderValue: (key) => {
632
+ return storageSources.registry[key]?.label ?? (key === DEFAULT_STORAGE_SOURCE_KEY ? "Default" : key);
633
+ },
634
+ children: [/* @__PURE__ */ jsx(SelectItem, {
635
+ value: DEFAULT_STORAGE_SOURCE_KEY,
636
+ children: "Default"
637
+ }), sourceKeys.map((key) => /* @__PURE__ */ jsx(SelectItem, {
638
+ value: key,
639
+ children: storageSources.registry[key]?.label ?? key
640
+ }, key))]
641
+ })
642
+ }),
643
+ /* @__PURE__ */ jsx("div", {
644
+ className: "col-span-12",
645
+ children: /* @__PURE__ */ jsx(MultiSelect, {
646
+ className: "w-full",
647
+ placeholder: "All file types allowed",
648
+ disabled,
649
+ name: acceptedFiles,
650
+ value: fileTypesValue ?? [],
651
+ onValueChange: handleTypesChange,
652
+ label: allFileTypesSelected ? void 0 : "Allowed file types",
653
+ renderValues: (selected) => {
654
+ if (!selected || selected.length === 0) return "All file types allowed";
655
+ return selected.map((v) => fileTypes[v]).filter((v) => Boolean(v)).join(", ");
656
+ },
657
+ children: Object.entries(fileTypes).map(([value, label]) => /* @__PURE__ */ jsxs(MultiSelectItem, {
658
+ value,
659
+ className: "flex items-center gap-2",
660
+ children: [/* @__PURE__ */ jsx("div", {
661
+ className: "grow",
662
+ children: label
663
+ }), /* @__PURE__ */ jsx(Button, {
664
+ size: "small",
665
+ variant: "text",
666
+ onClick: (e) => {
667
+ e.preventDefault();
668
+ e.stopPropagation();
669
+ return setFieldValue(acceptedFiles, [value]);
670
+ },
671
+ children: "Only"
672
+ })]
673
+ }, value))
674
+ })
675
+ }),
676
+ /* @__PURE__ */ jsx("div", {
677
+ className: "col-span-12",
678
+ children: /* @__PURE__ */ jsx(Field, {
679
+ name: fileName,
680
+ as: DebouncedTextField,
681
+ label: t("storage_file_name"),
682
+ size: "small",
683
+ disabled: hasFilenameCallback || disabled,
684
+ value: hasFilenameCallback ? "-" : fileNameValue
685
+ })
686
+ }),
687
+ /* @__PURE__ */ jsxs("div", {
688
+ className: "col-span-12",
689
+ children: [
690
+ /* @__PURE__ */ jsx(Field, {
691
+ name: storagePath,
692
+ as: DebouncedTextField,
693
+ label: t("storage_path"),
694
+ disabled: hasStoragePathCallback || disabled,
695
+ size: "small",
696
+ value: hasStoragePathCallback ? "-" : storagePathValue
697
+ }),
698
+ /* @__PURE__ */ jsxs(Typography, {
699
+ variant: "caption",
700
+ className: "ml-3.5 mt-1 mb-2",
701
+ children: [/* @__PURE__ */ jsx("p", { children: "You can use the following placeholders in the file name and storage path values:" }), /* @__PURE__ */ jsxs("ul", { children: [
702
+ /* @__PURE__ */ jsx("li", { children: "{file} - Full name of the uploaded file" }),
703
+ /* @__PURE__ */ jsx("li", { children: "{file.name} - Name of the uploaded file without extension" }),
704
+ /* @__PURE__ */ jsx("li", { children: "{file.ext} - Extension of the uploaded file" }),
705
+ /* @__PURE__ */ jsx("li", { children: "{entityId} - ID of the entity" }),
706
+ /* @__PURE__ */ jsx("li", { children: "{propertyKey} - ID of this field" }),
707
+ /* @__PURE__ */ jsx("li", { children: "{path} - Path of this entity" }),
708
+ /* @__PURE__ */ jsx("li", { children: "{rand} - Random value used to avoid name collisions" })
709
+ ] })]
710
+ }),
711
+ /* @__PURE__ */ jsx(Field, {
712
+ name: includeBucketUrl,
713
+ type: "checkbox",
714
+ children: ({ field, form }) => {
715
+ return /* @__PURE__ */ jsx(SwitchControl, {
716
+ label: t("storage_include_bucket_url"),
717
+ disabled: existing || disabled,
718
+ form,
719
+ field
720
+ });
721
+ }
722
+ }),
723
+ /* @__PURE__ */ jsxs(Typography, {
724
+ variant: "caption",
725
+ className: "ml-3.5 mt-1 mb-2",
726
+ children: [
727
+ "Turn this setting on if you want to save a fully-qualified storage URL (e.g. ",
728
+ /* @__PURE__ */ jsx("code", { children: "s3://my-bucket/path/to/file" }),
729
+ ") instead of just the storage path. You can only change this prop upon creation."
730
+ ]
731
+ }),
732
+ /* @__PURE__ */ jsx(Field, {
733
+ name: storeUrl,
734
+ type: "checkbox",
735
+ children: ({ field, form }) => {
736
+ return /* @__PURE__ */ jsx(SwitchControl, {
737
+ label: t("storage_save_url"),
738
+ disabled: existing || disabled,
739
+ form,
740
+ field
741
+ });
742
+ }
743
+ }),
744
+ /* @__PURE__ */ jsx(Typography, {
745
+ variant: "caption",
746
+ className: "ml-3.5 mt-1 mb-2",
747
+ children: "Turn this setting on, if you prefer to save the download URL of the uploaded file instead of the storage path. You can only change this prop upon creation."
748
+ })
749
+ ]
750
+ }),
751
+ /* @__PURE__ */ jsx("div", {
752
+ className: "col-span-12",
753
+ children: /* @__PURE__ */ jsx(DebouncedTextField, {
754
+ name: maxSize,
755
+ type: "number",
756
+ label: t("storage_max_size"),
757
+ size: "small",
758
+ value: maxSizeValue !== void 0 && maxSizeValue !== null ? maxSizeValue.toString() : "",
759
+ onChange: (e) => {
760
+ const value = e.target.value;
761
+ if (value === "") setFieldValue(maxSize, void 0);
762
+ else setFieldValue(maxSize, parseInt(value));
763
+ }
764
+ })
765
+ }),
766
+ /* @__PURE__ */ jsxs("div", {
767
+ className: "col-span-12 mt-4",
768
+ children: [/* @__PURE__ */ jsx(Typography, {
769
+ variant: "subtitle2",
770
+ color: "secondary",
771
+ className: "mb-2 block",
772
+ children: "Image Resize Configuration"
773
+ }), /* @__PURE__ */ jsx(Typography, {
774
+ variant: "caption",
775
+ className: "mb-2 block text-xs",
776
+ children: "Automatically resize and optimize images before upload (JPEG, PNG, WebP only)"
777
+ })]
778
+ }),
779
+ /* @__PURE__ */ jsx("div", {
780
+ className: "col-span-6",
781
+ children: /* @__PURE__ */ jsx(DebouncedTextField, {
782
+ name: imageResizeMaxWidth,
783
+ type: "number",
784
+ label: t("storage_max_width"),
785
+ size: "small",
786
+ disabled,
787
+ value: imageResizeMaxWidthValue !== void 0 && imageResizeMaxWidthValue !== null ? imageResizeMaxWidthValue.toString() : "",
788
+ onChange: (e) => {
789
+ const value = e.target.value;
790
+ if (value === "") setFieldValue(imageResizeMaxWidth, void 0);
791
+ else setFieldValue(imageResizeMaxWidth, parseInt(value));
792
+ }
793
+ })
794
+ }),
795
+ /* @__PURE__ */ jsx("div", {
796
+ className: "col-span-6",
797
+ children: /* @__PURE__ */ jsx(DebouncedTextField, {
798
+ name: imageResizeMaxHeight,
799
+ type: "number",
800
+ label: t("storage_max_height"),
801
+ size: "small",
802
+ disabled,
803
+ value: imageResizeMaxHeightValue !== void 0 && imageResizeMaxHeightValue !== null ? imageResizeMaxHeightValue.toString() : "",
804
+ onChange: (e) => {
805
+ const value = e.target.value;
806
+ if (value === "") setFieldValue(imageResizeMaxHeight, void 0);
807
+ else setFieldValue(imageResizeMaxHeight, parseInt(value));
808
+ }
809
+ })
810
+ }),
811
+ /* @__PURE__ */ jsx("div", {
812
+ className: "col-span-6",
813
+ children: /* @__PURE__ */ jsxs(Select, {
814
+ disabled,
815
+ name: imageResizeMode,
816
+ fullWidth: true,
817
+ size: "medium",
818
+ value: imageResizeModeValue || "cover",
819
+ onValueChange: (value) => setFieldValue(imageResizeMode, value || "cover"),
820
+ label: t("storage_resize_mode"),
821
+ renderValue: (selected) => {
822
+ if (!selected) return "Cover";
823
+ return selected === "contain" ? "Contain (fit within bounds)" : "Cover (fill bounds, may crop)";
824
+ },
825
+ children: [/* @__PURE__ */ jsx(SelectItem, {
826
+ value: "contain",
827
+ children: "Contain (fit within bounds)"
828
+ }), /* @__PURE__ */ jsx(SelectItem, {
829
+ value: "cover",
830
+ children: "Cover (fill bounds, may crop)"
831
+ })]
832
+ })
833
+ }),
834
+ /* @__PURE__ */ jsx("div", {
835
+ className: "col-span-6",
836
+ children: /* @__PURE__ */ jsxs(Select, {
837
+ disabled,
838
+ size: "medium",
839
+ fullWidth: true,
840
+ name: imageResizeFormat,
841
+ value: imageResizeFormatValue || "original",
842
+ onValueChange: (value) => setFieldValue(imageResizeFormat, value || "original"),
843
+ label: t("storage_output_format"),
844
+ renderValue: (selected) => {
845
+ if (!selected) return "Original";
846
+ return selected.charAt(0).toUpperCase() + selected.slice(1);
847
+ },
848
+ children: [
849
+ /* @__PURE__ */ jsx(SelectItem, {
850
+ value: "original",
851
+ children: "Original (keep same format)"
852
+ }),
853
+ /* @__PURE__ */ jsx(SelectItem, {
854
+ value: "jpeg",
855
+ children: "JPEG"
856
+ }),
857
+ /* @__PURE__ */ jsx(SelectItem, {
858
+ value: "png",
859
+ children: "PNG"
860
+ }),
861
+ /* @__PURE__ */ jsx(SelectItem, {
862
+ value: "webp",
863
+ children: "WebP (best compression)"
864
+ })
865
+ ]
866
+ })
867
+ }),
868
+ /* @__PURE__ */ jsxs("div", {
869
+ className: "col-span-12",
870
+ children: [/* @__PURE__ */ jsx(DebouncedTextField, {
871
+ name: imageResizeQuality,
872
+ type: "number",
873
+ label: t("storage_quality"),
874
+ size: "small",
875
+ disabled,
876
+ value: imageResizeQualityValue !== void 0 && imageResizeQualityValue !== null ? imageResizeQualityValue.toString() : "",
877
+ onChange: (e) => {
878
+ const value = e.target.value;
879
+ if (value === "") setFieldValue(imageResizeQuality, void 0);
880
+ else {
881
+ const numValue = parseInt(value);
882
+ if (numValue >= 0 && numValue <= 100) setFieldValue(imageResizeQuality, numValue);
883
+ }
884
+ }
885
+ }), /* @__PURE__ */ jsx(Typography, {
886
+ variant: "caption",
887
+ className: "ml-3.5 mt-1 mb-2",
888
+ children: "Higher quality = larger file size. Recommended: 80-90 for photos, 90-100 for graphics"
889
+ })]
890
+ })
891
+ ]
892
+ })
893
+ })
894
+ }), /* @__PURE__ */ jsx("div", {
895
+ className: "col-span-12",
896
+ children: /* @__PURE__ */ jsxs(ValidationPanel, { children: [!multiple && /* @__PURE__ */ jsx("div", {
897
+ className: "grid grid-cols-12 gap-2",
898
+ children: /* @__PURE__ */ jsx(GeneralPropertyValidation, { disabled })
899
+ }), multiple && /* @__PURE__ */ jsx("div", {
900
+ className: "col-span-12",
901
+ children: /* @__PURE__ */ jsx(ArrayPropertyValidation, { disabled })
902
+ })] })
903
+ })] });
904
+ }
905
+ //#endregion
906
+ //#region src/collection_editor/ui/collection_editor/PropertyFieldPreview.tsx
907
+ function PropertyFieldPreview({ property, propertyKey, onClick, hasError, includeName, includeEditButton, selected }) {
908
+ const { propertyConfigs } = useCustomizationController();
909
+ const propertyConfig = getFieldConfig(property, propertyConfigs);
910
+ return /* @__PURE__ */ jsx(ErrorBoundary, { children: /* @__PURE__ */ jsx("div", {
911
+ onClick,
912
+ className: onClick ? "cursor-pointer" : "",
913
+ children: /* @__PURE__ */ jsxs("div", {
914
+ className: cls("w-full flex flex-row gap-3 items-center px-3 py-2 rounded-lg transition-all duration-200 border bg-white dark:bg-surface-900 shadow-xs", (hasError ? "border-red-500 dark:border-red-500 border-red-500/100 dark:border-red-500/100 ring-0 dark:ring-0" : selected ? "border-primary" : "") || "border-surface-200 dark:border-surface-700", selected ? "bg-primary/10 text-primary dark:bg-primary/20 dark:text-primary-light ring-1 ring-inset ring-primary border-primary/30" : "hover:bg-surface-50 dark:hover:bg-surface-700"),
915
+ children: [
916
+ /* @__PURE__ */ jsx(PropertyConfigBadge, {
917
+ propertyConfig,
918
+ size: "small"
919
+ }),
920
+ /* @__PURE__ */ jsxs("div", {
921
+ className: "flex-1 flex flex-col min-w-0 mr-16",
922
+ children: [includeName && /* @__PURE__ */ jsxs(ErrorBoundary, { children: [/* @__PURE__ */ jsxs("div", {
923
+ className: "flex items-center gap-2 min-w-0",
924
+ children: [/* @__PURE__ */ jsx(Typography, {
925
+ variant: "body2",
926
+ component: "span",
927
+ className: "truncate font-medium",
928
+ children: property.name || propertyKey || "\xA0"
929
+ }), propertyConfig?.name && /* @__PURE__ */ jsx(Typography, {
930
+ variant: "caption",
931
+ component: "span",
932
+ className: "text-text-secondary dark:text-text-secondary-dark shrink-0",
933
+ children: propertyConfig.name
934
+ })]
935
+ }), /* @__PURE__ */ jsxs("div", {
936
+ className: "flex items-center gap-1.5 mt-0.5 min-w-0",
937
+ children: [propertyKey && /* @__PURE__ */ jsx(Typography, {
938
+ variant: "caption",
939
+ component: "span",
940
+ color: "secondary",
941
+ className: "font-mono truncate",
942
+ children: propertyKey
943
+ }), /* @__PURE__ */ jsx(ErrorBoundary, { children: /* @__PURE__ */ jsxs(Typography, {
944
+ variant: "caption",
945
+ component: "span",
946
+ className: "shrink-0 text-text-disabled dark:text-text-disabled-dark font-mono",
947
+ children: ["· ", "columnType" in property ? property.columnType ?? property.type : property.type]
948
+ }) })]
949
+ })] }), !includeName && /* @__PURE__ */ jsx("div", {
950
+ className: "flex flex-row items-center gap-2",
951
+ children: /* @__PURE__ */ jsx(ErrorBoundary, { children: /* @__PURE__ */ jsx(Typography, {
952
+ variant: "caption",
953
+ component: "span",
954
+ className: "text-text-secondary dark:text-text-secondary-dark font-medium",
955
+ children: propertyConfig?.name
956
+ }) })
957
+ })]
958
+ }),
959
+ includeEditButton && /* @__PURE__ */ jsx(Typography, {
960
+ variant: "button",
961
+ children: "EDIT"
962
+ })
963
+ ]
964
+ })
965
+ }) });
966
+ }
967
+ function NonEditablePropertyPreview({ name, selected, onClick, property }) {
968
+ const { propertyConfigs } = useCustomizationController();
969
+ const propertyConfig = !isPropertyBuilder(property) && property ? getFieldConfig(property, propertyConfigs) : void 0;
970
+ return /* @__PURE__ */ jsx("div", {
971
+ onClick,
972
+ className: onClick ? "cursor-pointer" : "",
973
+ children: /* @__PURE__ */ jsxs("div", {
974
+ className: cls("w-full flex flex-row gap-3 items-center px-3 py-2 rounded-lg transition-all duration-200 border bg-white dark:bg-surface-900 border-surface-200 dark:border-surface-700 shadow-xs", selected ? "bg-primary/10 text-primary dark:bg-primary/20 dark:text-primary-light ring-1 ring-inset ring-primary border-primary/30" : "hover:bg-surface-50 dark:hover:bg-surface-700"),
975
+ children: [/* @__PURE__ */ jsxs("div", {
976
+ className: "relative shrink-0",
977
+ children: [
978
+ propertyConfig && /* @__PURE__ */ jsx(PropertyConfigBadge, {
979
+ propertyConfig,
980
+ size: "small"
981
+ }),
982
+ !propertyConfig && /* @__PURE__ */ jsx("div", {
983
+ className: "h-8 w-8 flex items-center justify-center rounded-full shadow-2xs text-white bg-surface-500",
984
+ children: /* @__PURE__ */ jsx(FunctionSquareIcon, {
985
+ className: "text-inherit",
986
+ size: iconSize.small
987
+ })
988
+ }),
989
+ /* @__PURE__ */ jsx(MinusCircleIcon, {
990
+ className: "text-surface-accent-400 absolute -right-2 -top-2 bg-surface-50 dark:bg-surface-900 rounded-full",
991
+ size: iconSize.small
992
+ })
993
+ ]
994
+ }), /* @__PURE__ */ jsxs("div", {
995
+ className: "flex-1 flex flex-col min-w-0 mr-16",
996
+ children: [/* @__PURE__ */ jsxs("div", {
997
+ className: "flex items-center gap-2 min-w-0",
998
+ children: [/* @__PURE__ */ jsx(Typography, {
999
+ variant: "label",
1000
+ component: "span",
1001
+ className: "truncate",
1002
+ children: property?.name ? property.name : name
1003
+ }), propertyConfig && /* @__PURE__ */ jsx(Typography, {
1004
+ variant: "caption",
1005
+ component: "span",
1006
+ className: "text-text-secondary dark:text-text-secondary-dark shrink-0",
1007
+ children: propertyConfig?.name
1008
+ })]
1009
+ }), /* @__PURE__ */ jsxs("div", {
1010
+ className: "flex flex-row items-center gap-1.5 mt-0.5 min-w-0",
1011
+ children: [
1012
+ /* @__PURE__ */ jsx(Typography, {
1013
+ variant: "caption",
1014
+ component: "span",
1015
+ color: "secondary",
1016
+ className: "font-mono truncate",
1017
+ children: name
1018
+ }),
1019
+ property && isPropertyBuilder(property) && /* @__PURE__ */ jsx(ErrorBoundary, { children: /* @__PURE__ */ jsx(Typography, {
1020
+ variant: "caption",
1021
+ component: "span",
1022
+ className: "text-text-disabled dark:text-text-disabled-dark",
1023
+ children: "· Defined in code"
1024
+ }) }),
1025
+ !property && /* @__PURE__ */ jsx(ErrorBoundary, { children: /* @__PURE__ */ jsx(Typography, {
1026
+ variant: "caption",
1027
+ component: "span",
1028
+ className: "text-text-disabled dark:text-text-disabled-dark",
1029
+ children: "· Additional field"
1030
+ }) })
1031
+ ]
1032
+ })]
1033
+ })]
1034
+ })
1035
+ });
1036
+ }
1037
+ //#endregion
1038
+ //#region src/collection_editor/ui/collection_editor/AIModifiedPathsContext.tsx
1039
+ var AIModifiedPathsContext = createContext(null);
1040
+ function AIModifiedPathsProvider({ children }) {
1041
+ const [modifiedPaths, setModifiedPaths] = useState(/* @__PURE__ */ new Set());
1042
+ const [generationCounter, setGenerationCounter] = useState(0);
1043
+ const addModifiedPaths = useCallback((operations) => {
1044
+ setModifiedPaths((prev) => {
1045
+ const newSet = new Set(prev);
1046
+ operations.forEach((op) => {
1047
+ newSet.add(op.path);
1048
+ const parts = op.path.split(".");
1049
+ if (parts[0] === "properties" && parts.length >= 2) newSet.add(`properties.${parts[1]}`);
1050
+ });
1051
+ return newSet;
1052
+ });
1053
+ setGenerationCounter((prev) => prev + 1);
1054
+ }, []);
1055
+ const clearPath = useCallback((path) => {
1056
+ setModifiedPaths((prev) => {
1057
+ const newSet = new Set(prev);
1058
+ for (const p of newSet) if (p === path || p.startsWith(path + ".")) newSet.delete(p);
1059
+ return newSet;
1060
+ });
1061
+ }, []);
1062
+ const clearAllPaths = useCallback(() => {
1063
+ setModifiedPaths(/* @__PURE__ */ new Set());
1064
+ }, []);
1065
+ const isPathModified = useCallback((path) => {
1066
+ if (modifiedPaths.has(path)) return true;
1067
+ for (const p of modifiedPaths) if (p.startsWith(path + ".")) return true;
1068
+ return false;
1069
+ }, [modifiedPaths]);
1070
+ const contextValue = useMemo(() => ({
1071
+ modifiedPaths,
1072
+ generationCounter,
1073
+ addModifiedPaths,
1074
+ clearPath,
1075
+ clearAllPaths,
1076
+ isPathModified
1077
+ }), [
1078
+ modifiedPaths,
1079
+ generationCounter,
1080
+ addModifiedPaths,
1081
+ clearPath,
1082
+ clearAllPaths,
1083
+ isPathModified
1084
+ ]);
1085
+ return /* @__PURE__ */ jsx(AIModifiedPathsContext.Provider, {
1086
+ value: contextValue,
1087
+ children
1088
+ });
1089
+ }
1090
+ function useAIModifiedPaths() {
1091
+ return useContext(AIModifiedPathsContext);
1092
+ }
1093
+ //#endregion
1094
+ //#region src/collection_editor/ui/collection_editor/PropertyTree.tsx
1095
+ var PropertyTree = React.memo(function PropertyTree({ namespace, selectedPropertyKey, onPropertyClick, properties, propertiesOrder: propertiesOrderProp, additionalFields, errors, onPropertyMove, onPropertyRemove, className, inferredPropertyKeys }) {
1096
+ const propertyKeys = Object.keys(properties);
1097
+ const filteredOrder = (propertiesOrderProp ?? propertyKeys).filter((key) => !key.includes(".") && properties[key]);
1098
+ const missingKeys = propertyKeys.filter((key) => !filteredOrder.includes(key));
1099
+ const propertiesOrder = [...filteredOrder, ...missingKeys];
1100
+ const sensors = useSensors(useSensor(PointerSensor, { activationConstraint: { distance: 5 } }), useSensor(KeyboardSensor, { coordinateGetter: sortableKeyboardCoordinates }));
1101
+ const handleDragEnd = (event) => {
1102
+ const { active, over } = event;
1103
+ if (!over || active.id === over.id) return;
1104
+ const activeId = String(active.id);
1105
+ const overId = String(over.id);
1106
+ const activeKey = activeId.includes(".") ? activeId.split(".").pop() : activeId;
1107
+ const overKey = overId.includes(".") ? overId.split(".").pop() : overId;
1108
+ if (!activeKey || !overKey) return;
1109
+ const oldIndex = propertiesOrder.indexOf(activeKey);
1110
+ const newIndex = propertiesOrder.indexOf(overKey);
1111
+ if (oldIndex !== -1 && newIndex !== -1) {
1112
+ const newPropertiesOrder = [...propertiesOrder];
1113
+ const [removed] = newPropertiesOrder.splice(oldIndex, 1);
1114
+ newPropertiesOrder.splice(newIndex, 0, removed);
1115
+ if (onPropertyMove) onPropertyMove(newPropertiesOrder, namespace);
1116
+ }
1117
+ };
1118
+ const items = propertiesOrder.map((key) => getFullId(key, namespace));
1119
+ return /* @__PURE__ */ jsx(DndContext, {
1120
+ sensors,
1121
+ collisionDetection: closestCenter,
1122
+ onDragEnd: handleDragEnd,
1123
+ modifiers: [restrictToVerticalAxis],
1124
+ children: /* @__PURE__ */ jsx(SortableContext, {
1125
+ items,
1126
+ strategy: verticalListSortingStrategy,
1127
+ children: /* @__PURE__ */ jsx("div", {
1128
+ className: cls("flex flex-col gap-0.5", className),
1129
+ children: propertiesOrder && propertiesOrder.map((propertyKey, index) => {
1130
+ const property = properties[propertyKey];
1131
+ const additionalField = additionalFields?.find((field) => field.key === propertyKey);
1132
+ if (!property && !additionalField) {
1133
+ console.warn(`Property ${propertyKey} not found in properties or additionalFields`);
1134
+ return null;
1135
+ }
1136
+ const id = getFullId(propertyKey, namespace);
1137
+ return /* @__PURE__ */ jsx(PropertyTreeEntry, {
1138
+ id,
1139
+ propertyKey,
1140
+ property,
1141
+ additionalField,
1142
+ errors,
1143
+ namespace,
1144
+ propertiesOrder,
1145
+ inferredPropertyKeys,
1146
+ onPropertyMove,
1147
+ onPropertyRemove,
1148
+ onPropertyClick,
1149
+ selectedPropertyKey
1150
+ }, id);
1151
+ }).filter(Boolean)
1152
+ })
1153
+ })
1154
+ });
1155
+ }, deepEqual);
1156
+ function PropertyTreeEntry({ id, propertyKey, namespace, property, additionalField, selectedPropertyKey, errors, propertiesOrder, onPropertyClick, onPropertyMove, onPropertyRemove, inferredPropertyKeys }) {
1157
+ const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({ id });
1158
+ const style = {
1159
+ transform: CSS.Translate.toString(transform),
1160
+ transition,
1161
+ zIndex: isDragging ? 10 : void 0,
1162
+ position: "relative"
1163
+ };
1164
+ const isPropertyInferred = inferredPropertyKeys?.includes(namespace ? `${namespace}.${propertyKey}` : propertyKey);
1165
+ const fullId = id;
1166
+ const hasError = getFullIdPath(propertyKey, namespace) in errors;
1167
+ let subtree;
1168
+ if (typeof property === "object") {
1169
+ if (property.type === "map" && property.properties) subtree = /* @__PURE__ */ jsx(PropertyTree, {
1170
+ selectedPropertyKey,
1171
+ namespace: fullId,
1172
+ properties: property.properties,
1173
+ propertiesOrder: property.propertiesOrder,
1174
+ errors,
1175
+ onPropertyClick,
1176
+ onPropertyMove,
1177
+ onPropertyRemove,
1178
+ inferredPropertyKeys
1179
+ });
1180
+ }
1181
+ const selected = selectedPropertyKey === fullId;
1182
+ const editable = property && !isPropertyBuilder(property);
1183
+ const isAIModified = useAIModifiedPaths()?.isPathModified(`properties.${propertyKey}`) ?? false;
1184
+ return /* @__PURE__ */ jsx("div", {
1185
+ ref: setNodeRef,
1186
+ style,
1187
+ className: "relative cursor-grab",
1188
+ ...attributes,
1189
+ ...listeners,
1190
+ children: /* @__PURE__ */ jsxs("div", {
1191
+ className: "relative",
1192
+ children: [
1193
+ subtree && /* @__PURE__ */ jsx("div", {
1194
+ className: "absolute border-l " + defaultBorderMixin,
1195
+ style: {
1196
+ left: "24px",
1197
+ top: "40px",
1198
+ bottom: "16px"
1199
+ }
1200
+ }),
1201
+ /* @__PURE__ */ jsx("div", { children: !isPropertyBuilder(property) && !additionalField && editable ? /* @__PURE__ */ jsx(PropertyFieldPreview, {
1202
+ property,
1203
+ propertyKey,
1204
+ onClick: onPropertyClick ? () => onPropertyClick(propertyKey, namespace) : void 0,
1205
+ includeName: true,
1206
+ selected,
1207
+ hasError
1208
+ }) : /* @__PURE__ */ jsx(NonEditablePropertyPreview, {
1209
+ name: propertyKey,
1210
+ property,
1211
+ onClick: onPropertyClick ? () => onPropertyClick(propertyKey, namespace) : void 0,
1212
+ selected
1213
+ }) }),
1214
+ /* @__PURE__ */ jsxs("div", {
1215
+ className: "absolute top-1/2 -translate-y-1/2 right-2 flex flex-row items-center gap-1",
1216
+ children: [
1217
+ isAIModified && /* @__PURE__ */ jsx(AIModifiedIndicator, {}),
1218
+ isPropertyInferred && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Tooltip, {
1219
+ title: "Inferred property",
1220
+ asChild: true,
1221
+ children: /* @__PURE__ */ jsx(IconButton, {
1222
+ size: "smallest",
1223
+ disabled: true,
1224
+ children: /* @__PURE__ */ jsx(FileSearchIcon, { size: iconSize.smallest })
1225
+ })
1226
+ }), onPropertyRemove && /* @__PURE__ */ jsx(Tooltip, {
1227
+ title: "Remove inferred property",
1228
+ asChild: true,
1229
+ children: /* @__PURE__ */ jsx(IconButton, {
1230
+ size: "smallest",
1231
+ color: "inherit",
1232
+ onClick: (e) => {
1233
+ e.stopPropagation();
1234
+ onPropertyRemove(propertyKey, namespace);
1235
+ },
1236
+ children: /* @__PURE__ */ jsx(Trash2Icon, { size: iconSize.smallest })
1237
+ })
1238
+ })] }),
1239
+ /* @__PURE__ */ jsxs(Menu, {
1240
+ trigger: /* @__PURE__ */ jsx(IconButton, {
1241
+ size: "smallest",
1242
+ children: /* @__PURE__ */ jsx(MoreVerticalIcon, { size: iconSize.smallest })
1243
+ }),
1244
+ children: [
1245
+ /* @__PURE__ */ jsxs(MenuItem, {
1246
+ dense: true,
1247
+ onClick: () => {
1248
+ if (propertiesOrder.indexOf(propertyKey) > 0) {
1249
+ const newOrder = propertiesOrder.filter((k) => k !== propertyKey);
1250
+ newOrder.unshift(propertyKey);
1251
+ onPropertyMove?.(newOrder, namespace);
1252
+ }
1253
+ },
1254
+ children: [/* @__PURE__ */ jsx(ArrowUpToLineIcon, { size: iconSize.smallest }), "Move to top"]
1255
+ }),
1256
+ /* @__PURE__ */ jsxs(MenuItem, {
1257
+ dense: true,
1258
+ onClick: () => {
1259
+ if (propertiesOrder.indexOf(propertyKey) < propertiesOrder.length - 1) {
1260
+ const newOrder = propertiesOrder.filter((k) => k !== propertyKey);
1261
+ newOrder.push(propertyKey);
1262
+ onPropertyMove?.(newOrder, namespace);
1263
+ }
1264
+ },
1265
+ children: [/* @__PURE__ */ jsx(ArrowDownToLineIcon, { size: iconSize.smallest }), "Move to bottom"]
1266
+ }),
1267
+ /* @__PURE__ */ jsxs(MenuItem, {
1268
+ dense: true,
1269
+ onClick: () => onPropertyRemove?.(propertyKey, namespace),
1270
+ children: [/* @__PURE__ */ jsx(Trash2Icon, { size: iconSize.smallest }), "Delete"]
1271
+ })
1272
+ ]
1273
+ })
1274
+ ]
1275
+ }),
1276
+ subtree && /* @__PURE__ */ jsx("div", {
1277
+ className: "ml-12",
1278
+ children: subtree
1279
+ })
1280
+ ]
1281
+ })
1282
+ });
1283
+ }
1284
+ //#endregion
1285
+ //#region src/collection_editor/ui/collection_editor/properties/MapPropertyField.tsx
1286
+ function MapPropertyField({ disabled, getData, allowDataInference, propertyConfigs }) {
1287
+ const { values, setFieldValue } = useFormex();
1288
+ const { t } = useTranslation();
1289
+ const [propertyDialogOpen, setPropertyDialogOpen] = useState(false);
1290
+ const [selectedPropertyKey, setSelectedPropertyKey] = useState();
1291
+ const [selectedPropertyNamespace, setSelectedPropertyNamespace] = useState();
1292
+ const propertiesOrder = values.propertiesOrder ?? Object.keys(values.properties ?? {});
1293
+ const onPropertyCreated = ({ id, property }) => {
1294
+ if (!id) throw Error();
1295
+ setFieldValue("properties", {
1296
+ ...values.properties ?? {},
1297
+ [id]: property
1298
+ }, false);
1299
+ const currentPropertiesOrder = values.propertiesOrder ?? Object.keys(values.properties ?? {});
1300
+ setFieldValue("propertiesOrder", currentPropertiesOrder.includes(id) ? currentPropertiesOrder : [...currentPropertiesOrder, id], false);
1301
+ setPropertyDialogOpen(false);
1302
+ };
1303
+ const deleteProperty = (propertyKey, namespace) => {
1304
+ const fullId = propertyKey ? getFullId(propertyKey, namespace) : void 0;
1305
+ if (!fullId) throw Error("collection editor miss config");
1306
+ const propertiesPath = idToPropertiesPath(fullId);
1307
+ const propertiesOrderPath = namespaceToPropertiesOrderPath(namespace);
1308
+ const currentPropertiesOrder = getIn(values, propertiesOrderPath) ?? Object.keys(getIn(values, namespaceToPropertiesPath(namespace)) ?? {});
1309
+ setFieldValue(propertiesPath, void 0, false);
1310
+ setFieldValue(propertiesOrderPath, currentPropertiesOrder.filter((p) => p !== propertyKey), false);
1311
+ setPropertyDialogOpen(false);
1312
+ setSelectedPropertyKey(void 0);
1313
+ setSelectedPropertyNamespace(void 0);
1314
+ };
1315
+ const selectedPropertyFullId = selectedPropertyKey ? getFullId(selectedPropertyKey, selectedPropertyNamespace) : void 0;
1316
+ const selectedProperty = selectedPropertyFullId ? getIn(values.properties, selectedPropertyFullId.replaceAll(".", ".properties.")) : void 0;
1317
+ const empty = !propertiesOrder || propertiesOrder.length < 1;
1318
+ const onPropertyMove = (propertiesOrder, namespace) => {
1319
+ setFieldValue(namespaceToPropertiesOrderPath(namespace), propertiesOrder, false);
1320
+ };
1321
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1322
+ /* @__PURE__ */ jsxs("div", {
1323
+ className: "col-span-12",
1324
+ children: [/* @__PURE__ */ jsxs("div", {
1325
+ className: "flex justify-between items-end my-4",
1326
+ children: [/* @__PURE__ */ jsx(Typography, {
1327
+ variant: "subtitle2",
1328
+ children: t("properties_in_this_group")
1329
+ }), /* @__PURE__ */ jsxs(Button, {
1330
+ onClick: () => setPropertyDialogOpen(true),
1331
+ startIcon: /* @__PURE__ */ jsx(PlusIcon, {}),
1332
+ children: ["Add property to ", values.name ?? "this group"]
1333
+ })]
1334
+ }), /* @__PURE__ */ jsxs(Paper, {
1335
+ className: "p-2 pl-8",
1336
+ children: [/* @__PURE__ */ jsx(PropertyTree, {
1337
+ properties: values.properties ?? {},
1338
+ propertiesOrder,
1339
+ errors: {},
1340
+ onPropertyClick: (propertyKey, namespace) => {
1341
+ setSelectedPropertyKey(propertyKey);
1342
+ setSelectedPropertyNamespace(namespace);
1343
+ setPropertyDialogOpen(true);
1344
+ },
1345
+ onPropertyMove
1346
+ }), empty && /* @__PURE__ */ jsx(Typography, {
1347
+ variant: "label",
1348
+ className: "h-full flex items-center justify-center p-4",
1349
+ children: "Add the first property to this group"
1350
+ })]
1351
+ })]
1352
+ }),
1353
+ /* @__PURE__ */ jsxs("div", {
1354
+ className: "col-span-12",
1355
+ children: [/* @__PURE__ */ jsx(BooleanSwitchWithLabel, {
1356
+ position: "start",
1357
+ size: "medium",
1358
+ label: t("spread_children_as_columns"),
1359
+ onValueChange: (v) => setFieldValue("ui.spreadChildren", v),
1360
+ value: values.ui?.spreadChildren ?? false
1361
+ }), /* @__PURE__ */ jsx(FieldCaption, { children: "Set this flag to true if you want to display the children of this group as individual columns. This will only work for top level groups." })]
1362
+ }),
1363
+ /* @__PURE__ */ jsx(PropertyFormDialog, {
1364
+ inArray: false,
1365
+ forceShowErrors: false,
1366
+ open: propertyDialogOpen,
1367
+ allowDataInference,
1368
+ onCancel: () => {
1369
+ setPropertyDialogOpen(false);
1370
+ setSelectedPropertyKey(void 0);
1371
+ setSelectedPropertyNamespace(void 0);
1372
+ },
1373
+ onOkClicked: () => {
1374
+ setPropertyDialogOpen(false);
1375
+ setSelectedPropertyKey(void 0);
1376
+ setSelectedPropertyNamespace(void 0);
1377
+ },
1378
+ getData,
1379
+ onDelete: deleteProperty,
1380
+ propertyKey: selectedPropertyKey,
1381
+ propertyNamespace: selectedPropertyNamespace,
1382
+ property: selectedProperty,
1383
+ existingProperty: Boolean(selectedPropertyKey),
1384
+ autoUpdateId: !selectedPropertyKey,
1385
+ autoOpenTypeSelect: !selectedPropertyKey,
1386
+ onPropertyChanged: onPropertyCreated,
1387
+ existingPropertyKeys: selectedPropertyKey ? void 0 : propertiesOrder,
1388
+ propertyConfigs
1389
+ })
1390
+ ] });
1391
+ }
1392
+ //#endregion
1393
+ //#region src/collection_editor/ui/collection_editor/properties/RepeatPropertyField.tsx
1394
+ function RepeatPropertyField({ showErrors, existing, disabled, getData, allowDataInference, propertyConfigs }) {
1395
+ const { values, handleChange, errors, setFieldValue, touched } = useFormex();
1396
+ const [propertyDialogOpen, setPropertyDialogOpen] = useState(false);
1397
+ const ofProperty = getIn(values, "of");
1398
+ const ofPropertyError = getIn(touched, "of") && getIn(errors, "of");
1399
+ const onPropertyChanged = ({ id, property, namespace }) => {
1400
+ setFieldValue("of", property);
1401
+ };
1402
+ const widget = ofProperty && getFieldConfig(ofProperty, propertyConfigs);
1403
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("div", {
1404
+ className: "col-span-12",
1405
+ children: [/* @__PURE__ */ jsx(Typography, {
1406
+ variant: "subtitle2",
1407
+ children: "Repeat component"
1408
+ }), /* @__PURE__ */ jsx(Field, {
1409
+ name: "of",
1410
+ value: ofProperty,
1411
+ children: ({}) => /* @__PURE__ */ jsxs(Paper, {
1412
+ className: "p-2 mt-4",
1413
+ children: [
1414
+ ofProperty && /* @__PURE__ */ jsx(PropertyFieldPreview, {
1415
+ property: ofProperty,
1416
+ onClick: disabled ? void 0 : () => setPropertyDialogOpen(true),
1417
+ includeName: false,
1418
+ includeEditButton: true,
1419
+ selected: false,
1420
+ hasError: false
1421
+ }),
1422
+ !disabled && !ofProperty && /* @__PURE__ */ jsxs(Button, {
1423
+ variant: "text",
1424
+ color: ofPropertyError ? "error" : "primary",
1425
+ onClick: () => setPropertyDialogOpen(true),
1426
+ children: ["Edit ", `${widget ? widget.name : "repeat component"}`]
1427
+ }),
1428
+ /* @__PURE__ */ jsx(PropertyFormDialog, {
1429
+ inArray: true,
1430
+ open: propertyDialogOpen,
1431
+ existingProperty: existing,
1432
+ getData,
1433
+ autoUpdateId: !existing,
1434
+ autoOpenTypeSelect: !existing,
1435
+ onOkClicked: () => setPropertyDialogOpen(false),
1436
+ allowDataInference,
1437
+ property: ofProperty,
1438
+ includeIdAndName: false,
1439
+ onPropertyChanged,
1440
+ forceShowErrors: showErrors,
1441
+ propertyConfigs
1442
+ })
1443
+ ]
1444
+ })
1445
+ })]
1446
+ }), /* @__PURE__ */ jsx("div", {
1447
+ className: "col-span-12",
1448
+ children: /* @__PURE__ */ jsx(ValidationPanel, { children: /* @__PURE__ */ jsx(ArrayPropertyValidation, { disabled }) })
1449
+ })] });
1450
+ }
1451
+ //#endregion
1452
+ //#region src/collection_editor/ui/collection_editor/properties/CommonPropertyFields.tsx
1453
+ var CommonPropertyFields = React.forwardRef(function CommonPropertyFields({ showErrors, disabledId, disabled, autoUpdateId, isNewProperty }, ref) {
1454
+ const { errors, values, setFieldValue, setFieldTouched, touched, validate } = useFormex();
1455
+ const { t } = useTranslation();
1456
+ const name = "name";
1457
+ const nameError = showErrors && getIn(errors, name);
1458
+ const id = "id";
1459
+ const idError = showErrors && getIn(errors, id);
1460
+ const description = "description";
1461
+ const descriptionError = showErrors && getIn(errors, description);
1462
+ return /* @__PURE__ */ jsxs("div", {
1463
+ className: "flex flex-col gap-2 col-span-12",
1464
+ children: [
1465
+ /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(Field, {
1466
+ name,
1467
+ inputRef: ref,
1468
+ as: DebouncedTextField,
1469
+ value: values[name],
1470
+ onChange: (e) => {
1471
+ const newNameValue = e.target.value;
1472
+ if (!getIn(touched, id) && autoUpdateId) setFieldValue(id, newNameValue ? toSnakeCase(newNameValue) : "", false);
1473
+ setFieldValue(name, newNameValue, true);
1474
+ setFieldTouched(name, true);
1475
+ },
1476
+ style: { fontSize: 20 },
1477
+ placeholder: t("field_name"),
1478
+ required: true,
1479
+ disabled,
1480
+ error: Boolean(nameError)
1481
+ }), /* @__PURE__ */ jsx(FieldCaption, {
1482
+ error: Boolean(nameError),
1483
+ children: nameError
1484
+ })] }),
1485
+ /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(DebouncedTextField, {
1486
+ name: id,
1487
+ label: "ID",
1488
+ value: values[id],
1489
+ onChange: (e) => {
1490
+ const newIdValue = e.target.value;
1491
+ if (!getIn(touched, name) && autoUpdateId) setFieldValue(name, newIdValue ? prettifyIdentifier(newIdValue) : "");
1492
+ setFieldValue(id, newIdValue, true);
1493
+ setFieldTouched(id, true);
1494
+ },
1495
+ disabled: disabledId || disabled,
1496
+ required: true,
1497
+ size: "small",
1498
+ error: Boolean(idError)
1499
+ }), /* @__PURE__ */ jsx(FieldCaption, {
1500
+ error: Boolean(idError),
1501
+ children: idError
1502
+ })] }),
1503
+ /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(Field, {
1504
+ name: description,
1505
+ as: DebouncedTextField,
1506
+ label: t("description"),
1507
+ disabled,
1508
+ error: Boolean(descriptionError)
1509
+ }), /* @__PURE__ */ jsx(FieldCaption, {
1510
+ error: Boolean(descriptionError),
1511
+ children: descriptionError
1512
+ })] })
1513
+ ]
1514
+ });
1515
+ });
1516
+ //#endregion
1517
+ //#region src/collection_editor/ui/collection_editor/properties/StringPropertyField.tsx
1518
+ function StringPropertyField({ widgetId, disabled, showErrors }) {
1519
+ const { values, setFieldValue, touched, errors } = useFormex();
1520
+ const { t } = useTranslation();
1521
+ const columnTypePath = "columnType";
1522
+ const columnTypeValue = getIn(values, columnTypePath);
1523
+ const columnTypeError = getIn(touched, columnTypePath) && getIn(errors, columnTypePath);
1524
+ const isIdPath = "isId";
1525
+ const isIdValue = getIn(values, isIdPath);
1526
+ const isIdError = getIn(touched, isIdPath) && getIn(errors, isIdPath);
1527
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1528
+ /* @__PURE__ */ jsx("div", {
1529
+ className: "col-span-12",
1530
+ children: /* @__PURE__ */ jsxs(ValidationPanel, { children: [
1531
+ widgetId === "text_field" && /* @__PURE__ */ jsx(StringPropertyValidation, {
1532
+ disabled,
1533
+ length: true,
1534
+ lowercase: true,
1535
+ matches: true,
1536
+ max: true,
1537
+ min: true,
1538
+ trim: true,
1539
+ uppercase: true,
1540
+ showErrors
1541
+ }),
1542
+ widgetId === "user_select" && /* @__PURE__ */ jsx(StringPropertyValidation, {
1543
+ disabled,
1544
+ showErrors
1545
+ }),
1546
+ widgetId === "multiline" && /* @__PURE__ */ jsx(StringPropertyValidation, {
1547
+ disabled,
1548
+ length: true,
1549
+ lowercase: true,
1550
+ max: true,
1551
+ min: true,
1552
+ trim: true,
1553
+ uppercase: true,
1554
+ showErrors
1555
+ }),
1556
+ widgetId === "email" && /* @__PURE__ */ jsx(StringPropertyValidation, {
1557
+ disabled,
1558
+ max: true,
1559
+ min: true,
1560
+ trim: true,
1561
+ showErrors
1562
+ })
1563
+ ] })
1564
+ }),
1565
+ /* @__PURE__ */ jsxs("div", {
1566
+ className: "col-span-12",
1567
+ children: [/* @__PURE__ */ jsxs(Select, {
1568
+ name: columnTypePath,
1569
+ disabled: disabled || Boolean(isIdValue),
1570
+ fullWidth: true,
1571
+ value: isIdValue === "uuid" ? "uuid" : columnTypeValue ?? "_default_",
1572
+ onValueChange: (v) => setFieldValue(columnTypePath, v === "_default_" ? void 0 : v),
1573
+ renderValue: (v) => {
1574
+ if (isIdValue === "uuid") return "uuid (forced by Primary Key)";
1575
+ switch (v) {
1576
+ case "text": return "text (unlimited)";
1577
+ case "char": return "char (fixed length)";
1578
+ case "varchar": return "varchar (variable length)";
1579
+ case "_default_": return "Default (varchar)";
1580
+ default: return "Default (varchar)";
1581
+ }
1582
+ },
1583
+ error: Boolean(columnTypeError),
1584
+ label: t("db_column_type"),
1585
+ children: [
1586
+ isIdValue === "uuid" && /* @__PURE__ */ jsx(SelectItem, {
1587
+ value: "uuid",
1588
+ children: " uuid (forced by Primary Key) "
1589
+ }),
1590
+ /* @__PURE__ */ jsx(SelectItem, {
1591
+ value: "_default_",
1592
+ children: " Default (varchar) "
1593
+ }),
1594
+ /* @__PURE__ */ jsx(SelectItem, {
1595
+ value: "varchar",
1596
+ children: " varchar (variable length) "
1597
+ }),
1598
+ /* @__PURE__ */ jsx(SelectItem, {
1599
+ value: "text",
1600
+ children: " text (unlimited) "
1601
+ }),
1602
+ /* @__PURE__ */ jsx(SelectItem, {
1603
+ value: "char",
1604
+ children: " char (fixed length) "
1605
+ })
1606
+ ]
1607
+ }), /* @__PURE__ */ jsx(FieldCaption, {
1608
+ error: Boolean(columnTypeError),
1609
+ children: columnTypeError ?? "Optional database override for this string field."
1610
+ })]
1611
+ }),
1612
+ /* @__PURE__ */ jsxs("div", {
1613
+ className: "col-span-12",
1614
+ children: [/* @__PURE__ */ jsxs(Select, {
1615
+ name: isIdPath,
1616
+ disabled,
1617
+ fullWidth: true,
1618
+ value: isIdValue === true ? "true" : isIdValue === false ? "false" : isIdValue ?? "_default_",
1619
+ onValueChange: (v) => {
1620
+ if (v === "_default_" || v === "false") setFieldValue(isIdPath, void 0);
1621
+ else if (v === "true") setFieldValue(isIdPath, true);
1622
+ else setFieldValue(isIdPath, v);
1623
+ },
1624
+ renderValue: (v) => {
1625
+ switch (v) {
1626
+ case "true": return "Yes (Auto-generated UUID/String)";
1627
+ case "manual": return "Yes (Manual input)";
1628
+ case "uuid": return "Yes (UUID)";
1629
+ case "cuid": return "Yes (CUID)";
1630
+ case "false":
1631
+ case "_default_": return "No";
1632
+ default: return `Yes (${v})`;
1633
+ }
1634
+ },
1635
+ error: Boolean(isIdError),
1636
+ label: t("primary_key_unique_id"),
1637
+ children: [
1638
+ /* @__PURE__ */ jsx(SelectItem, {
1639
+ value: "_default_",
1640
+ children: " No "
1641
+ }),
1642
+ /* @__PURE__ */ jsx(SelectItem, {
1643
+ value: "manual",
1644
+ children: " Yes (Manual input) "
1645
+ }),
1646
+ /* @__PURE__ */ jsx(SelectItem, {
1647
+ value: "true",
1648
+ children: " Yes (Auto-generated UUID/String) "
1649
+ }),
1650
+ /* @__PURE__ */ jsx(SelectItem, {
1651
+ value: "uuid",
1652
+ children: " Yes (UUID) "
1653
+ }),
1654
+ /* @__PURE__ */ jsx(SelectItem, {
1655
+ value: "cuid",
1656
+ children: " Yes (CUID) "
1657
+ })
1658
+ ]
1659
+ }), /* @__PURE__ */ jsx(FieldCaption, {
1660
+ error: Boolean(isIdError),
1661
+ children: isIdError ?? "Set as Primary Key and configure ID generation strategy."
1662
+ })]
1663
+ }),
1664
+ /* @__PURE__ */ jsx("div", {
1665
+ className: "col-span-12",
1666
+ children: /* @__PURE__ */ jsx(TextField, {
1667
+ name: "defaultValue",
1668
+ disabled,
1669
+ onChange: (e) => {
1670
+ setFieldValue("defaultValue", e.target.value === "" ? void 0 : e.target.value);
1671
+ },
1672
+ label: t("default_value"),
1673
+ value: getIn(values, "defaultValue") ?? ""
1674
+ })
1675
+ })
1676
+ ] });
1677
+ }
1678
+ //#endregion
1679
+ //#region src/collection_editor/ui/collection_editor/properties/BooleanPropertyField.tsx
1680
+ function BooleanPropertyField({ disabled }) {
1681
+ const { values } = useFormex();
1682
+ const defaultValue = getIn(values, "defaultValue");
1683
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
1684
+ className: "col-span-12",
1685
+ children: /* @__PURE__ */ jsx(ValidationPanel, { children: /* @__PURE__ */ jsx(GeneralPropertyValidation, { disabled }) })
1686
+ }), /* @__PURE__ */ jsx("div", {
1687
+ className: "col-span-12",
1688
+ children: /* @__PURE__ */ jsx(Field, {
1689
+ name: "defaultValue",
1690
+ children: ({ field, form }) => {
1691
+ return /* @__PURE__ */ jsx(SwitchControl, {
1692
+ size: "medium",
1693
+ label: defaultValue === null || defaultValue === void 0 ? "Default value not set" : "Default value is " + defaultValue.toString(),
1694
+ disabled,
1695
+ allowIndeterminate: true,
1696
+ field,
1697
+ form
1698
+ });
1699
+ }
1700
+ })
1701
+ })] });
1702
+ }
1703
+ //#endregion
1704
+ //#region src/collection_editor/ui/collection_editor/properties/BlockPropertyField.tsx
1705
+ function BlockPropertyField({ disabled, getData, allowDataInference, propertyConfigs }) {
1706
+ const { values, setFieldValue } = useFormex();
1707
+ const [propertyDialogOpen, setPropertyDialogOpen] = useState(false);
1708
+ const [selectedPropertyKey, setSelectedPropertyKey] = useState();
1709
+ const [selectedPropertyNamespace, setSelectedPropertyNamespace] = useState();
1710
+ const onPropertyChanged = ({ id, namespace, property }) => {
1711
+ if (!id) throw Error();
1712
+ setFieldValue("oneOf." + getFullIdPath(id, namespace), property, false);
1713
+ const currentPropertiesOrder = values.oneOf?.propertiesOrder ?? Object.keys(values.oneOf?.properties ?? {});
1714
+ const newPropertiesOrder = currentPropertiesOrder.includes(id) ? currentPropertiesOrder : [...currentPropertiesOrder, id];
1715
+ setFieldValue("oneOf." + namespaceToPropertiesOrderPath(namespace), newPropertiesOrder, false);
1716
+ setPropertyDialogOpen(false);
1717
+ };
1718
+ const selectedPropertyFullId = selectedPropertyKey ? getFullId(selectedPropertyKey, selectedPropertyNamespace) : void 0;
1719
+ const selectedProperty = selectedPropertyFullId ? getIn(values.oneOf?.properties, selectedPropertyFullId.replaceAll(".", ".properties.")) : void 0;
1720
+ const deleteProperty = (propertyKey, namespace) => {
1721
+ const fullId = propertyKey ? getFullId(propertyKey, namespace) : void 0;
1722
+ if (!fullId) throw Error("collection editor miss config");
1723
+ setFieldValue(`oneOf.${idToPropertiesPath(fullId)}`, void 0, false);
1724
+ const propertiesOrderPath = `oneOf.${namespaceToPropertiesOrderPath(namespace)}`;
1725
+ setFieldValue(propertiesOrderPath, (getIn(values, propertiesOrderPath) ?? Object.keys(getIn(values, namespaceToPropertiesPath(namespace)) ?? {})).filter((p) => p !== propertyKey), false);
1726
+ setPropertyDialogOpen(false);
1727
+ setSelectedPropertyKey(void 0);
1728
+ setSelectedPropertyNamespace(void 0);
1729
+ };
1730
+ const addChildButton = /* @__PURE__ */ jsxs(Button, {
1731
+ autoFocus: true,
1732
+ onClick: () => setPropertyDialogOpen(true),
1733
+ startIcon: /* @__PURE__ */ jsx(PlusIcon, {}),
1734
+ children: ["Add property to ", values.name ?? "this block"]
1735
+ });
1736
+ const onPropertyMove = (propertiesOrder, namespace) => {
1737
+ setFieldValue(`oneOf.${namespaceToPropertiesOrderPath(namespace)}`, propertiesOrder, false);
1738
+ };
1739
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("div", {
1740
+ className: "col-span-12",
1741
+ children: [/* @__PURE__ */ jsxs("div", {
1742
+ className: "flex justify-between items-end mt-8 mb-4",
1743
+ children: [/* @__PURE__ */ jsx(Typography, {
1744
+ variant: "subtitle2",
1745
+ children: "Properties in this block"
1746
+ }), addChildButton]
1747
+ }), /* @__PURE__ */ jsxs(Paper, {
1748
+ className: "p-2 pl-8",
1749
+ children: [/* @__PURE__ */ jsx(PropertyTree, {
1750
+ properties: values.oneOf?.properties ?? {},
1751
+ propertiesOrder: values.oneOf?.propertiesOrder,
1752
+ errors: {},
1753
+ onPropertyClick: disabled ? void 0 : (propertyKey, namespace) => {
1754
+ setSelectedPropertyKey(propertyKey);
1755
+ setSelectedPropertyNamespace(namespace);
1756
+ setPropertyDialogOpen(true);
1757
+ },
1758
+ onPropertyMove: disabled ? void 0 : onPropertyMove
1759
+ }), !disabled && values.oneOf?.propertiesOrder?.length === 0 && /* @__PURE__ */ jsx("div", {
1760
+ className: "h-full flex items-center justify-center p-4",
1761
+ children: "Add the first property to this block"
1762
+ })]
1763
+ })]
1764
+ }), !disabled && /* @__PURE__ */ jsx(PropertyFormDialog, {
1765
+ inArray: false,
1766
+ forceShowErrors: false,
1767
+ open: propertyDialogOpen,
1768
+ getData,
1769
+ allowDataInference,
1770
+ onCancel: () => {
1771
+ setPropertyDialogOpen(false);
1772
+ setSelectedPropertyKey(void 0);
1773
+ setSelectedPropertyNamespace(void 0);
1774
+ },
1775
+ onOkClicked: () => {
1776
+ setPropertyDialogOpen(false);
1777
+ setSelectedPropertyKey(void 0);
1778
+ setSelectedPropertyNamespace(void 0);
1779
+ },
1780
+ onDelete: deleteProperty,
1781
+ propertyKey: selectedPropertyKey,
1782
+ propertyNamespace: selectedPropertyNamespace,
1783
+ property: selectedProperty,
1784
+ existingProperty: Boolean(selectedPropertyKey),
1785
+ autoUpdateId: !selectedPropertyKey,
1786
+ autoOpenTypeSelect: !selectedPropertyKey,
1787
+ onPropertyChanged,
1788
+ existingPropertyKeys: selectedPropertyKey ? void 0 : values.oneOf?.propertiesOrder,
1789
+ propertyConfigs
1790
+ })] });
1791
+ }
1792
+ //#endregion
1793
+ //#region src/collection_editor/ui/collection_editor/properties/validation/NumberPropertyValidation.tsx
1794
+ function NumberPropertyValidation({ disabled }) {
1795
+ const { values, handleChange } = useFormex();
1796
+ const { t } = useTranslation();
1797
+ const validationMin = "validation.min";
1798
+ const validationMax = "validation.max";
1799
+ const validationLessThan = "validation.lessThan";
1800
+ const validationMoreThan = "validation.moreThan";
1801
+ return /* @__PURE__ */ jsxs("div", {
1802
+ className: "grid grid-cols-12 gap-2",
1803
+ children: [
1804
+ /* @__PURE__ */ jsx(GeneralPropertyValidation, { disabled }),
1805
+ /* @__PURE__ */ jsx("div", {
1806
+ className: "col-span-6",
1807
+ children: /* @__PURE__ */ jsx(DebouncedTextField, {
1808
+ value: getIn(values, validationMin),
1809
+ label: t("min_value"),
1810
+ name: validationMin,
1811
+ type: "number",
1812
+ size: "small",
1813
+ disabled,
1814
+ onChange: handleChange
1815
+ })
1816
+ }),
1817
+ /* @__PURE__ */ jsx("div", {
1818
+ className: "col-span-6",
1819
+ children: /* @__PURE__ */ jsx(DebouncedTextField, {
1820
+ value: getIn(values, validationMax),
1821
+ label: t("max_value"),
1822
+ name: validationMax,
1823
+ type: "number",
1824
+ size: "small",
1825
+ disabled,
1826
+ onChange: handleChange
1827
+ })
1828
+ }),
1829
+ /* @__PURE__ */ jsx("div", {
1830
+ className: "col-span-6",
1831
+ children: /* @__PURE__ */ jsx(DebouncedTextField, {
1832
+ value: getIn(values, validationLessThan),
1833
+ label: t("less_than"),
1834
+ name: validationLessThan,
1835
+ type: "number",
1836
+ size: "small",
1837
+ disabled,
1838
+ onChange: handleChange
1839
+ })
1840
+ }),
1841
+ /* @__PURE__ */ jsx("div", {
1842
+ className: "col-span-6",
1843
+ children: /* @__PURE__ */ jsx(DebouncedTextField, {
1844
+ value: getIn(values, validationMoreThan),
1845
+ label: t("more_than"),
1846
+ name: validationMoreThan,
1847
+ type: "number",
1848
+ size: "small",
1849
+ disabled,
1850
+ onChange: handleChange
1851
+ })
1852
+ }),
1853
+ /* @__PURE__ */ jsx("div", {
1854
+ className: "col-span-4",
1855
+ children: /* @__PURE__ */ jsx(Field, {
1856
+ name: "validation.positive",
1857
+ type: "checkbox",
1858
+ children: ({ field, form }) => {
1859
+ return /* @__PURE__ */ jsx(SwitchControl, {
1860
+ label: t("positive_value"),
1861
+ disabled,
1862
+ form,
1863
+ field
1864
+ });
1865
+ }
1866
+ })
1867
+ }),
1868
+ /* @__PURE__ */ jsx("div", {
1869
+ className: "col-span-4",
1870
+ children: /* @__PURE__ */ jsx(Field, {
1871
+ name: "validation.negative",
1872
+ type: "checkbox",
1873
+ children: ({ field, form }) => {
1874
+ return /* @__PURE__ */ jsx(SwitchControl, {
1875
+ label: t("negative_value"),
1876
+ disabled,
1877
+ form,
1878
+ field
1879
+ });
1880
+ }
1881
+ })
1882
+ }),
1883
+ /* @__PURE__ */ jsx("div", {
1884
+ className: "col-span-4",
1885
+ children: /* @__PURE__ */ jsx(Field, {
1886
+ name: "validation.integer",
1887
+ type: "checkbox",
1888
+ children: ({ field, form }) => {
1889
+ return /* @__PURE__ */ jsx(SwitchControl, {
1890
+ label: t("integer_value"),
1891
+ disabled,
1892
+ form,
1893
+ field
1894
+ });
1895
+ }
1896
+ })
1897
+ })
1898
+ ]
1899
+ });
1900
+ }
1901
+ //#endregion
1902
+ //#region src/collection_editor/ui/collection_editor/properties/NumberPropertyField.tsx
1903
+ function NumberPropertyField({ disabled }) {
1904
+ const { values, setFieldValue, touched, errors } = useFormex();
1905
+ const { t } = useTranslation();
1906
+ const columnTypePath = "columnType";
1907
+ const columnTypeValue = getIn(values, columnTypePath);
1908
+ const columnTypeError = getIn(touched, columnTypePath) && getIn(errors, columnTypePath);
1909
+ const isIdPath = "isId";
1910
+ const isIdValue = getIn(values, isIdPath);
1911
+ const isIdError = getIn(touched, isIdPath) && getIn(errors, isIdPath);
1912
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1913
+ /* @__PURE__ */ jsx("div", {
1914
+ className: "col-span-12",
1915
+ children: /* @__PURE__ */ jsx(ValidationPanel, { children: /* @__PURE__ */ jsx(NumberPropertyValidation, { disabled }) })
1916
+ }),
1917
+ /* @__PURE__ */ jsxs("div", {
1918
+ className: "col-span-12",
1919
+ children: [/* @__PURE__ */ jsxs(Select, {
1920
+ name: columnTypePath,
1921
+ disabled: disabled || Boolean(isIdValue),
1922
+ fullWidth: true,
1923
+ value: columnTypeValue ?? "_default_",
1924
+ onValueChange: (v) => setFieldValue(columnTypePath, v === "_default_" ? void 0 : v),
1925
+ renderValue: (v) => {
1926
+ switch (v) {
1927
+ case "integer": return "integer";
1928
+ case "real": return "real (float4)";
1929
+ case "double precision": return "double precision (float8)";
1930
+ case "numeric": return "numeric / decimal";
1931
+ case "bigint": return "bigint";
1932
+ case "serial": return "serial";
1933
+ case "bigserial": return "bigserial";
1934
+ case "_default_": return "Default (integer/numeric)";
1935
+ default: return "Default (integer/numeric)";
1936
+ }
1937
+ },
1938
+ error: Boolean(columnTypeError),
1939
+ label: t("db_column_type"),
1940
+ children: [
1941
+ /* @__PURE__ */ jsx(SelectItem, {
1942
+ value: "_default_",
1943
+ children: " Default (integer/numeric) "
1944
+ }),
1945
+ /* @__PURE__ */ jsx(SelectItem, {
1946
+ value: "integer",
1947
+ children: " integer "
1948
+ }),
1949
+ /* @__PURE__ */ jsx(SelectItem, {
1950
+ value: "real",
1951
+ children: " real (float4) "
1952
+ }),
1953
+ /* @__PURE__ */ jsx(SelectItem, {
1954
+ value: "double precision",
1955
+ children: " double precision (float8) "
1956
+ }),
1957
+ /* @__PURE__ */ jsx(SelectItem, {
1958
+ value: "numeric",
1959
+ children: " numeric / decimal "
1960
+ }),
1961
+ /* @__PURE__ */ jsx(SelectItem, {
1962
+ value: "bigint",
1963
+ children: " bigint "
1964
+ }),
1965
+ /* @__PURE__ */ jsx(SelectItem, {
1966
+ value: "serial",
1967
+ children: " serial "
1968
+ }),
1969
+ /* @__PURE__ */ jsx(SelectItem, {
1970
+ value: "bigserial",
1971
+ children: " bigserial "
1972
+ })
1973
+ ]
1974
+ }), /* @__PURE__ */ jsx(FieldCaption, {
1975
+ error: Boolean(columnTypeError),
1976
+ children: columnTypeError ?? "Optional database override for this number field."
1977
+ })]
1978
+ }),
1979
+ /* @__PURE__ */ jsxs("div", {
1980
+ className: "col-span-12",
1981
+ children: [/* @__PURE__ */ jsxs(Select, {
1982
+ name: isIdPath,
1983
+ disabled,
1984
+ fullWidth: true,
1985
+ value: isIdValue === true ? "true" : isIdValue === false ? "false" : isIdValue ?? "_default_",
1986
+ onValueChange: (v) => {
1987
+ if (v === "_default_" || v === "false") setFieldValue(isIdPath, void 0);
1988
+ else if (v === "true") setFieldValue(isIdPath, true);
1989
+ else setFieldValue(isIdPath, v);
1990
+ },
1991
+ renderValue: (v) => {
1992
+ switch (v) {
1993
+ case "true": return "Yes (Auto-increment/identity)";
1994
+ case "increment": return "Yes (Increment)";
1995
+ case "manual": return "Yes (Manual input)";
1996
+ case "false":
1997
+ case "_default_": return "No";
1998
+ default: return `Yes (${v})`;
1999
+ }
2000
+ },
2001
+ error: Boolean(isIdError),
2002
+ label: t("primary_key_unique_id"),
2003
+ children: [
2004
+ /* @__PURE__ */ jsx(SelectItem, {
2005
+ value: "_default_",
2006
+ children: " No "
2007
+ }),
2008
+ /* @__PURE__ */ jsx(SelectItem, {
2009
+ value: "manual",
2010
+ children: " Yes (Manual input) "
2011
+ }),
2012
+ /* @__PURE__ */ jsx(SelectItem, {
2013
+ value: "true",
2014
+ children: " Yes (Auto-increment/identity) "
2015
+ }),
2016
+ /* @__PURE__ */ jsx(SelectItem, {
2017
+ value: "increment",
2018
+ children: " Yes (Increment) "
2019
+ })
2020
+ ]
2021
+ }), /* @__PURE__ */ jsx(FieldCaption, {
2022
+ error: Boolean(isIdError),
2023
+ children: isIdError ?? "Set as Primary Key and configure ID generation strategy."
2024
+ })]
2025
+ }),
2026
+ /* @__PURE__ */ jsx("div", {
2027
+ className: "col-span-12",
2028
+ children: /* @__PURE__ */ jsx(TextField, {
2029
+ name: "defaultValue",
2030
+ disabled,
2031
+ type: "number",
2032
+ onChange: (e) => {
2033
+ setFieldValue("defaultValue", e.target.value === "" ? void 0 : parseFloat(e.target.value));
2034
+ },
2035
+ label: t("default_value"),
2036
+ value: getIn(values, "defaultValue") ?? ""
2037
+ })
2038
+ })
2039
+ ] });
2040
+ }
2041
+ //#endregion
2042
+ //#region src/collection_editor/ui/collection_editor/properties/ReferencePropertyField.tsx
2043
+ function ReferencePropertyField({ existing, multiple, disabled, showErrors, asString }) {
2044
+ const { values, errors, setFieldValue } = useFormex();
2045
+ if (!useCollectionRegistryController().initialised) return /* @__PURE__ */ jsx("div", {
2046
+ className: "col-span-12",
2047
+ children: /* @__PURE__ */ jsx(CircularProgress, {})
2048
+ });
2049
+ const pathPath = asString ? "reference.slug" : multiple ? "of.slug" : "path";
2050
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("div", {
2051
+ className: "col-span-12",
2052
+ children: /* @__PURE__ */ jsx(Field, {
2053
+ name: pathPath,
2054
+ pathPath,
2055
+ type: "select",
2056
+ disabled,
2057
+ value: getIn(values, pathPath),
2058
+ error: showErrors && getIn(errors, pathPath),
2059
+ setFieldValue,
2060
+ as: CollectionsSelect
2061
+ })
2062
+ }) });
2063
+ }
2064
+ function CollectionsSelect({ disabled, pathPath, value, setFieldValue, error, ...props }) {
2065
+ const collectionRegistry = useCollectionRegistryController();
2066
+ const { t } = useTranslation();
2067
+ if (!collectionRegistry.initialised) return /* @__PURE__ */ jsx("div", {
2068
+ className: "col-span-12",
2069
+ children: /* @__PURE__ */ jsx(CircularProgress, {})
2070
+ });
2071
+ const collections = collectionRegistry.collections ?? [];
2072
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(Select, {
2073
+ error: Boolean(error),
2074
+ disabled,
2075
+ value: value ?? "",
2076
+ position: "item-aligned",
2077
+ name: pathPath,
2078
+ fullWidth: true,
2079
+ onChange: (e) => setFieldValue(pathPath, e.target.value),
2080
+ label: t("target_collection"),
2081
+ renderValue: (selected) => {
2082
+ const selectedCollection = collections.find((collection) => collection.slug === selected);
2083
+ if (!selectedCollection) return null;
2084
+ return /* @__PURE__ */ jsxs("div", {
2085
+ className: "flex flex-row",
2086
+ children: [/* @__PURE__ */ jsx(IconForView, { collectionOrView: selectedCollection }), /* @__PURE__ */ jsx(Typography, {
2087
+ variant: "subtitle2",
2088
+ className: "ml-4",
2089
+ children: selectedCollection?.name.toUpperCase()
2090
+ })]
2091
+ });
2092
+ },
2093
+ ...props,
2094
+ children: collections.map((collection) => {
2095
+ return /* @__PURE__ */ jsx(SelectItem, {
2096
+ value: collection.slug,
2097
+ children: /* @__PURE__ */ jsxs("div", {
2098
+ className: "flex flex-row",
2099
+ children: [/* @__PURE__ */ jsx(IconForView, { collectionOrView: collection }), /* @__PURE__ */ jsx(Typography, {
2100
+ variant: "subtitle2",
2101
+ className: "ml-4",
2102
+ children: collection?.name.toUpperCase()
2103
+ })]
2104
+ })
2105
+ }, collection.slug);
2106
+ })
2107
+ }) });
2108
+ }
2109
+ //#endregion
2110
+ //#region src/collection_editor/ui/collection_editor/properties/DateTimePropertyField.tsx
2111
+ var TIMEZONES = [
2112
+ {
2113
+ value: "UTC",
2114
+ label: "UTC (Coordinated Universal Time)"
2115
+ },
2116
+ {
2117
+ value: "America/New_York",
2118
+ label: "New York (US Eastern)"
2119
+ },
2120
+ {
2121
+ value: "America/Chicago",
2122
+ label: "Chicago (US Central)"
2123
+ },
2124
+ {
2125
+ value: "America/Denver",
2126
+ label: "Denver (US Mountain)"
2127
+ },
2128
+ {
2129
+ value: "America/Los_Angeles",
2130
+ label: "Los Angeles (US Pacific)"
2131
+ },
2132
+ {
2133
+ value: "America/Anchorage",
2134
+ label: "Anchorage (Alaska)"
2135
+ },
2136
+ {
2137
+ value: "America/Toronto",
2138
+ label: "Toronto (Canada Eastern)"
2139
+ },
2140
+ {
2141
+ value: "America/Vancouver",
2142
+ label: "Vancouver (Canada Pacific)"
2143
+ },
2144
+ {
2145
+ value: "America/Mexico_City",
2146
+ label: "Mexico City"
2147
+ },
2148
+ {
2149
+ value: "America/Sao_Paulo",
2150
+ label: "São Paulo (Brazil)"
2151
+ },
2152
+ {
2153
+ value: "America/Buenos_Aires",
2154
+ label: "Buenos Aires (Argentina)"
2155
+ },
2156
+ {
2157
+ value: "Europe/London",
2158
+ label: "London (UK)"
2159
+ },
2160
+ {
2161
+ value: "Europe/Paris",
2162
+ label: "Paris (France)"
2163
+ },
2164
+ {
2165
+ value: "Europe/Berlin",
2166
+ label: "Berlin (Germany)"
2167
+ },
2168
+ {
2169
+ value: "Europe/Madrid",
2170
+ label: "Madrid (Spain)"
2171
+ },
2172
+ {
2173
+ value: "Europe/Rome",
2174
+ label: "Rome (Italy)"
2175
+ },
2176
+ {
2177
+ value: "Europe/Amsterdam",
2178
+ label: "Amsterdam (Netherlands)"
2179
+ },
2180
+ {
2181
+ value: "Europe/Brussels",
2182
+ label: "Brussels (Belgium)"
2183
+ },
2184
+ {
2185
+ value: "Europe/Zurich",
2186
+ label: "Zurich (Switzerland)"
2187
+ },
2188
+ {
2189
+ value: "Europe/Stockholm",
2190
+ label: "Stockholm (Sweden)"
2191
+ },
2192
+ {
2193
+ value: "Europe/Vienna",
2194
+ label: "Vienna (Austria)"
2195
+ },
2196
+ {
2197
+ value: "Europe/Warsaw",
2198
+ label: "Warsaw (Poland)"
2199
+ },
2200
+ {
2201
+ value: "Europe/Prague",
2202
+ label: "Prague (Czech Republic)"
2203
+ },
2204
+ {
2205
+ value: "Europe/Athens",
2206
+ label: "Athens (Greece)"
2207
+ },
2208
+ {
2209
+ value: "Europe/Moscow",
2210
+ label: "Moscow (Russia)"
2211
+ },
2212
+ {
2213
+ value: "Europe/Istanbul",
2214
+ label: "Istanbul (Turkey)"
2215
+ },
2216
+ {
2217
+ value: "Asia/Dubai",
2218
+ label: "Dubai (UAE)"
2219
+ },
2220
+ {
2221
+ value: "Asia/Kolkata",
2222
+ label: "Mumbai / Delhi (India)"
2223
+ },
2224
+ {
2225
+ value: "Asia/Bangkok",
2226
+ label: "Bangkok (Thailand)"
2227
+ },
2228
+ {
2229
+ value: "Asia/Singapore",
2230
+ label: "Singapore"
2231
+ },
2232
+ {
2233
+ value: "Asia/Hong_Kong",
2234
+ label: "Hong Kong"
2235
+ },
2236
+ {
2237
+ value: "Asia/Shanghai",
2238
+ label: "Shanghai (China)"
2239
+ },
2240
+ {
2241
+ value: "Asia/Tokyo",
2242
+ label: "Tokyo (Japan)"
2243
+ },
2244
+ {
2245
+ value: "Asia/Seoul",
2246
+ label: "Seoul (South Korea)"
2247
+ },
2248
+ {
2249
+ value: "Asia/Jakarta",
2250
+ label: "Jakarta (Indonesia)"
2251
+ },
2252
+ {
2253
+ value: "Australia/Sydney",
2254
+ label: "Sydney (Australia Eastern)"
2255
+ },
2256
+ {
2257
+ value: "Australia/Melbourne",
2258
+ label: "Melbourne (Australia)"
2259
+ },
2260
+ {
2261
+ value: "Australia/Brisbane",
2262
+ label: "Brisbane (Australia)"
2263
+ },
2264
+ {
2265
+ value: "Australia/Perth",
2266
+ label: "Perth (Australia Western)"
2267
+ },
2268
+ {
2269
+ value: "Pacific/Auckland",
2270
+ label: "Auckland (New Zealand)"
2271
+ },
2272
+ {
2273
+ value: "Africa/Cairo",
2274
+ label: "Cairo (Egypt)"
2275
+ },
2276
+ {
2277
+ value: "Africa/Johannesburg",
2278
+ label: "Johannesburg (South Africa)"
2279
+ },
2280
+ {
2281
+ value: "Africa/Lagos",
2282
+ label: "Lagos (Nigeria)"
2283
+ }
2284
+ ];
2285
+ function DateTimePropertyField({ disabled }) {
2286
+ const { values, errors, touched, setFieldValue } = useFormex();
2287
+ const { t } = useTranslation();
2288
+ const modePath = "mode";
2289
+ const modeValue = getIn(values, modePath);
2290
+ const modeError = getIn(touched, modePath) && getIn(errors, modePath);
2291
+ const autoValuePath = "autoValue";
2292
+ const autoValueValue = getIn(values, autoValuePath);
2293
+ const autoValueError = getIn(touched, autoValuePath) && getIn(errors, autoValuePath);
2294
+ const timezonePath = "timezone";
2295
+ const timezoneValue = getIn(values, timezonePath);
2296
+ const timezoneError = getIn(touched, timezonePath) && getIn(errors, timezonePath);
2297
+ const columnTypePath = "columnType";
2298
+ const columnTypeValue = getIn(values, columnTypePath);
2299
+ const columnTypeError = getIn(touched, columnTypePath) && getIn(errors, columnTypePath);
2300
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
2301
+ /* @__PURE__ */ jsxs("div", {
2302
+ className: "flex flex-col col-span-12 gap-2",
2303
+ children: [
2304
+ /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsxs(Select, {
2305
+ name: modePath,
2306
+ value: modeValue ?? "date",
2307
+ error: Boolean(modeError),
2308
+ onValueChange: (v) => setFieldValue(modePath, v),
2309
+ label: t("mode"),
2310
+ fullWidth: true,
2311
+ renderValue: (v) => {
2312
+ switch (v) {
2313
+ case "date_time": return "Date/Time";
2314
+ case "date": return "Date";
2315
+ default: return "";
2316
+ }
2317
+ },
2318
+ disabled,
2319
+ children: [/* @__PURE__ */ jsx(SelectItem, {
2320
+ value: "date_time",
2321
+ children: " Date/Time "
2322
+ }), /* @__PURE__ */ jsx(SelectItem, {
2323
+ value: "date",
2324
+ children: " Date "
2325
+ })]
2326
+ }), /* @__PURE__ */ jsx(FieldCaption, {
2327
+ error: Boolean(modeError),
2328
+ children: modeError
2329
+ })] }),
2330
+ /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsxs(Select, {
2331
+ name: autoValuePath,
2332
+ disabled,
2333
+ fullWidth: true,
2334
+ value: autoValueValue ?? "",
2335
+ onValueChange: (v) => setFieldValue(autoValuePath, v === "none" ? null : v),
2336
+ renderValue: (v) => {
2337
+ switch (v) {
2338
+ case "on_create": return "On create";
2339
+ case "on_update": return "On any update";
2340
+ default: return "None";
2341
+ }
2342
+ },
2343
+ error: Boolean(autoValueError),
2344
+ label: t("datetime_automatic_value"),
2345
+ children: [
2346
+ /* @__PURE__ */ jsx(SelectItem, {
2347
+ value: "none",
2348
+ children: " None "
2349
+ }),
2350
+ /* @__PURE__ */ jsx(SelectItem, {
2351
+ value: "on_create",
2352
+ children: " On create "
2353
+ }),
2354
+ /* @__PURE__ */ jsx(SelectItem, {
2355
+ value: "on_update",
2356
+ children: " On any update "
2357
+ })
2358
+ ]
2359
+ }), /* @__PURE__ */ jsx(FieldCaption, {
2360
+ error: Boolean(autoValueError),
2361
+ children: autoValueError ?? "Update this field automatically when creating or updating the entity"
2362
+ })] }),
2363
+ /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsxs(Select, {
2364
+ name: timezonePath,
2365
+ disabled,
2366
+ fullWidth: true,
2367
+ value: timezoneValue ?? "__local__",
2368
+ onValueChange: (v) => setFieldValue(timezonePath, v === "__local__" ? void 0 : v),
2369
+ renderValue: (v) => {
2370
+ if (!v || v === "__local__") return "Local timezone";
2371
+ return TIMEZONES.find((t) => t.value === v)?.label ?? v;
2372
+ },
2373
+ error: Boolean(timezoneError),
2374
+ label: t("timezone"),
2375
+ children: [/* @__PURE__ */ jsx(SelectItem, {
2376
+ value: "__local__",
2377
+ children: " Local timezone "
2378
+ }), TIMEZONES.map((tz) => /* @__PURE__ */ jsx(SelectItem, {
2379
+ value: tz.value,
2380
+ children: tz.label
2381
+ }, tz.value))]
2382
+ }), /* @__PURE__ */ jsx(FieldCaption, {
2383
+ error: Boolean(timezoneError),
2384
+ children: timezoneError ?? "Timezone for displaying and inputting dates. Values are always stored in UTC."
2385
+ })] })
2386
+ ]
2387
+ }),
2388
+ /* @__PURE__ */ jsxs("div", {
2389
+ className: "col-span-12",
2390
+ children: [/* @__PURE__ */ jsxs(Select, {
2391
+ name: columnTypePath,
2392
+ disabled,
2393
+ fullWidth: true,
2394
+ value: columnTypeValue ?? "_default_",
2395
+ onValueChange: (v) => setFieldValue(columnTypePath, v === "_default_" ? void 0 : v),
2396
+ renderValue: (v) => {
2397
+ switch (v) {
2398
+ case "timestamp": return "timestamp (with timezone)";
2399
+ case "date": return "date";
2400
+ case "time": return "time";
2401
+ case "_default_": return "Default (timestamp)";
2402
+ default: return "Default (timestamp)";
2403
+ }
2404
+ },
2405
+ error: Boolean(columnTypeError),
2406
+ label: t("db_column_type"),
2407
+ children: [
2408
+ /* @__PURE__ */ jsx(SelectItem, {
2409
+ value: "_default_",
2410
+ children: " Default (timestamp) "
2411
+ }),
2412
+ /* @__PURE__ */ jsx(SelectItem, {
2413
+ value: "timestamp",
2414
+ children: " timestamp (with timezone) "
2415
+ }),
2416
+ /* @__PURE__ */ jsx(SelectItem, {
2417
+ value: "date",
2418
+ children: " date "
2419
+ }),
2420
+ /* @__PURE__ */ jsx(SelectItem, {
2421
+ value: "time",
2422
+ children: " time "
2423
+ })
2424
+ ]
2425
+ }), /* @__PURE__ */ jsx(FieldCaption, {
2426
+ error: Boolean(columnTypeError),
2427
+ children: columnTypeError ?? "Optional database override for this date field."
2428
+ })]
2429
+ }),
2430
+ /* @__PURE__ */ jsx("div", {
2431
+ className: "col-span-12",
2432
+ children: /* @__PURE__ */ jsx(ValidationPanel, { children: /* @__PURE__ */ jsx(GeneralPropertyValidation, { disabled }) })
2433
+ })
2434
+ ] });
2435
+ }
2436
+ //#endregion
2437
+ //#region src/collection_editor/ui/collection_editor/properties/advanced/AdvancedPropertyValidation.tsx
2438
+ function AdvancedPropertyValidation({ disabled }) {
2439
+ return /* @__PURE__ */ jsxs("div", {
2440
+ className: "grid grid-cols-12 gap-2",
2441
+ children: [/* @__PURE__ */ jsx("div", {
2442
+ className: "col-span-12",
2443
+ children: /* @__PURE__ */ jsx(Field, {
2444
+ type: "checkbox",
2445
+ name: "ui.hideFromCollection",
2446
+ children: ({ field, form }) => {
2447
+ return /* @__PURE__ */ jsx(SwitchControl, {
2448
+ label: "Hide from collection",
2449
+ size: "small",
2450
+ disabled,
2451
+ form,
2452
+ tooltip: "Hide this field from the collection view. It will still be visible in the form view",
2453
+ field
2454
+ });
2455
+ }
2456
+ })
2457
+ }), /* @__PURE__ */ jsx("div", {
2458
+ className: "col-span-12",
2459
+ children: /* @__PURE__ */ jsx(Field, {
2460
+ name: "ui.readOnly",
2461
+ type: "checkbox",
2462
+ children: ({ field, form }) => {
2463
+ return /* @__PURE__ */ jsx(SwitchControl, {
2464
+ label: "Read only",
2465
+ size: "small",
2466
+ disabled,
2467
+ tooltip: "Is this a read only field. Display only as a preview",
2468
+ form,
2469
+ field
2470
+ });
2471
+ }
2472
+ })
2473
+ })]
2474
+ });
2475
+ }
2476
+ //#endregion
2477
+ //#region src/collection_editor/ui/collection_editor/properties/VectorPropertyField.tsx
2478
+ function VectorPropertyField({ disabled }) {
2479
+ const { values, setFieldValue, touched, errors } = useFormex();
2480
+ const dimensionsPath = "dimensions";
2481
+ const dimensionsValue = getIn(values, dimensionsPath);
2482
+ const dimensionsError = getIn(touched, dimensionsPath) && getIn(errors, dimensionsPath);
2483
+ return /* @__PURE__ */ jsxs("div", {
2484
+ className: "col-span-12",
2485
+ children: [/* @__PURE__ */ jsx(TextField, {
2486
+ name: dimensionsPath,
2487
+ disabled,
2488
+ type: "number",
2489
+ onChange: (e) => {
2490
+ const parsedVal = parseInt(e.target.value);
2491
+ setFieldValue(dimensionsPath, isNaN(parsedVal) ? void 0 : parsedVal);
2492
+ },
2493
+ label: "Vector Dimensions",
2494
+ value: dimensionsValue ?? "",
2495
+ error: Boolean(dimensionsError)
2496
+ }), /* @__PURE__ */ jsx(FieldCaption, {
2497
+ error: Boolean(dimensionsError),
2498
+ children: dimensionsError ?? "The dimension size of the vector embeddings (e.g., 1536 for OpenAI text-embedding-3-small)."
2499
+ })]
2500
+ });
2501
+ }
2502
+ //#endregion
2503
+ //#region src/collection_editor/ui/collection_editor/properties/KeyValuePropertyField.tsx
2504
+ function KeyValuePropertyField({ disabled }) {
2505
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("div", {
2506
+ className: "col-span-12",
2507
+ children: /* @__PURE__ */ jsx(ValidationPanel, { children: /* @__PURE__ */ jsx(GeneralPropertyValidation, { disabled }) })
2508
+ }) });
2509
+ }
2510
+ //#endregion
2511
+ //#region src/collection_editor/ui/collection_editor/properties/RelationPropertyField.tsx
2512
+ var ON_ACTION_OPTIONS = [
2513
+ "cascade",
2514
+ "restrict",
2515
+ "no action",
2516
+ "set null",
2517
+ "set default"
2518
+ ];
2519
+ function getTargetSlug(target) {
2520
+ if (!target) return "";
2521
+ if (typeof target === "string") return target;
2522
+ try {
2523
+ const resolved = target();
2524
+ if (typeof resolved === "string") return resolved;
2525
+ if (resolved && typeof resolved === "object" && "slug" in resolved && typeof resolved.slug === "string") return resolved.slug;
2526
+ return "";
2527
+ } catch {
2528
+ return "";
2529
+ }
2530
+ }
2531
+ /**
2532
+ * Property editor form for `type: "relation"` properties.
2533
+ *
2534
+ * This component edits the `RelationProperty` fields on the property itself (target, relationName, etc.)
2535
+ */
2536
+ function RelationPropertyField({ disabled, showErrors }) {
2537
+ const { values, errors, setFieldValue } = useFormex();
2538
+ const collectionRegistry = useCollectionRegistryController();
2539
+ const relationName = values.relationName ?? "";
2540
+ const targetSlug = getTargetSlug(values.target);
2541
+ const cardinality = values.cardinality ?? "one";
2542
+ const direction = values.direction ?? "owning";
2543
+ const localKey = values.localKey ?? "";
2544
+ const foreignKeyOnTarget = values.foreignKeyOnTarget ?? "";
2545
+ const through = values.through;
2546
+ const throughTable = through?.table ?? "";
2547
+ const throughSourceColumn = through?.sourceColumn ?? "";
2548
+ const throughTargetColumn = through?.targetColumn ?? "";
2549
+ const onUpdate = values.onUpdate ?? "no action";
2550
+ const onDelete = values.onDelete ?? "no action";
2551
+ const showThrough = cardinality === "many" && direction === "owning";
2552
+ const showLocalKey = direction === "owning" && cardinality === "one";
2553
+ const showForeignKey = direction === "inverse";
2554
+ const updateThrough = useCallback((patch) => {
2555
+ setFieldValue("through", {
2556
+ ...values.through ?? {
2557
+ table: "",
2558
+ sourceColumn: "",
2559
+ targetColumn: ""
2560
+ },
2561
+ ...patch
2562
+ });
2563
+ }, [values.through, setFieldValue]);
2564
+ useEffect(() => {
2565
+ if (targetSlug && !relationName) setFieldValue("relationName", targetSlug);
2566
+ }, [
2567
+ targetSlug,
2568
+ relationName,
2569
+ setFieldValue
2570
+ ]);
2571
+ collectionRegistry?.collections;
2572
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
2573
+ /* @__PURE__ */ jsxs("div", {
2574
+ className: "col-span-12",
2575
+ children: [/* @__PURE__ */ jsx(CollectionsSelect, {
2576
+ disabled,
2577
+ pathPath: "target",
2578
+ value: targetSlug,
2579
+ setFieldValue: (_, value) => {
2580
+ setFieldValue("target", value);
2581
+ if (!relationName || relationName === targetSlug) setFieldValue("relationName", value);
2582
+ },
2583
+ error: showErrors && !targetSlug ? "You must select a target collection" : void 0
2584
+ }), /* @__PURE__ */ jsx(FieldCaption, {
2585
+ error: showErrors && !targetSlug,
2586
+ children: showErrors && !targetSlug ? "You must select a target collection" : "The collection this relation points to"
2587
+ })]
2588
+ }),
2589
+ /* @__PURE__ */ jsxs("div", {
2590
+ className: "col-span-12",
2591
+ children: [/* @__PURE__ */ jsx(TextField, {
2592
+ value: relationName,
2593
+ onChange: (e) => setFieldValue("relationName", e.target.value),
2594
+ label: "Relation name",
2595
+ disabled,
2596
+ error: showErrors && !relationName
2597
+ }), /* @__PURE__ */ jsx(FieldCaption, {
2598
+ error: showErrors && !relationName,
2599
+ children: showErrors && !relationName ? "Required" : "Identifier for this relation (used to link the property to the relation config)"
2600
+ })]
2601
+ }),
2602
+ /* @__PURE__ */ jsxs("div", {
2603
+ className: "col-span-12 sm:col-span-6",
2604
+ children: [/* @__PURE__ */ jsxs(Select, {
2605
+ value: cardinality,
2606
+ onValueChange: (v) => setFieldValue("cardinality", v),
2607
+ label: "Cardinality",
2608
+ disabled,
2609
+ fullWidth: true,
2610
+ renderValue: (v) => v === "one" ? "One (has-one)" : "Many (has-many)",
2611
+ children: [/* @__PURE__ */ jsx(SelectItem, {
2612
+ value: "one",
2613
+ children: /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(Typography, {
2614
+ variant: "body2",
2615
+ children: "One (has-one)"
2616
+ }), /* @__PURE__ */ jsx(Typography, {
2617
+ variant: "caption",
2618
+ color: "secondary",
2619
+ children: "This property references a single record"
2620
+ })] })
2621
+ }), /* @__PURE__ */ jsx(SelectItem, {
2622
+ value: "many",
2623
+ children: /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(Typography, {
2624
+ variant: "body2",
2625
+ children: "Many (has-many)"
2626
+ }), /* @__PURE__ */ jsx(Typography, {
2627
+ variant: "caption",
2628
+ color: "secondary",
2629
+ children: "This property references multiple records"
2630
+ })] })
2631
+ })]
2632
+ }), /* @__PURE__ */ jsx(FieldCaption, { children: "Whether the relation returns one or multiple records" })]
2633
+ }),
2634
+ /* @__PURE__ */ jsxs("div", {
2635
+ className: "col-span-12 sm:col-span-6",
2636
+ children: [/* @__PURE__ */ jsxs(Select, {
2637
+ value: direction,
2638
+ onValueChange: (v) => setFieldValue("direction", v),
2639
+ label: "Direction",
2640
+ disabled,
2641
+ fullWidth: true,
2642
+ renderValue: (v) => v === "owning" ? "Owning" : "Inverse",
2643
+ children: [/* @__PURE__ */ jsx(SelectItem, {
2644
+ value: "owning",
2645
+ children: /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(Typography, {
2646
+ variant: "body2",
2647
+ children: "Owning"
2648
+ }), /* @__PURE__ */ jsx(Typography, {
2649
+ variant: "caption",
2650
+ color: "secondary",
2651
+ children: "This table stores the foreign key (or owns the junction table)"
2652
+ })] })
2653
+ }), /* @__PURE__ */ jsx(SelectItem, {
2654
+ value: "inverse",
2655
+ children: /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(Typography, {
2656
+ variant: "body2",
2657
+ children: "Inverse"
2658
+ }), /* @__PURE__ */ jsx(Typography, {
2659
+ variant: "caption",
2660
+ color: "secondary",
2661
+ children: "The target table stores the foreign key pointing back here"
2662
+ })] })
2663
+ })]
2664
+ }), /* @__PURE__ */ jsx(FieldCaption, { children: "Which side of the relation owns the persistence" })]
2665
+ }),
2666
+ showLocalKey && /* @__PURE__ */ jsxs("div", {
2667
+ className: "col-span-12",
2668
+ children: [/* @__PURE__ */ jsx(TextField, {
2669
+ value: localKey,
2670
+ onChange: (e) => setFieldValue("localKey", e.target.value),
2671
+ label: "Local key (foreign key column on this table)",
2672
+ disabled,
2673
+ placeholder: "e.g. author_id"
2674
+ }), /* @__PURE__ */ jsx(FieldCaption, { children: "Column on this table that references the target's primary key" })]
2675
+ }),
2676
+ showForeignKey && /* @__PURE__ */ jsxs("div", {
2677
+ className: "col-span-12",
2678
+ children: [/* @__PURE__ */ jsx(TextField, {
2679
+ value: foreignKeyOnTarget,
2680
+ onChange: (e) => setFieldValue("foreignKeyOnTarget", e.target.value),
2681
+ label: "Foreign key on target table",
2682
+ disabled,
2683
+ placeholder: "e.g. post_id"
2684
+ }), /* @__PURE__ */ jsx(FieldCaption, { children: "Column on the target table that references this table's primary key" })]
2685
+ }),
2686
+ showThrough && /* @__PURE__ */ jsxs("div", {
2687
+ className: "col-span-12",
2688
+ children: [/* @__PURE__ */ jsx(Typography, {
2689
+ variant: "label",
2690
+ className: "mb-2",
2691
+ children: "Junction table (many-to-many)"
2692
+ }), /* @__PURE__ */ jsxs("div", {
2693
+ className: "grid grid-cols-12 gap-4",
2694
+ children: [
2695
+ /* @__PURE__ */ jsxs("div", {
2696
+ className: "col-span-12",
2697
+ children: [/* @__PURE__ */ jsx(TextField, {
2698
+ value: throughTable,
2699
+ onChange: (e) => updateThrough({ table: e.target.value }),
2700
+ label: "Junction table name",
2701
+ disabled,
2702
+ placeholder: "e.g. user_roles"
2703
+ }), /* @__PURE__ */ jsx(FieldCaption, { children: "Name of the intermediate table that connects both collections" })]
2704
+ }),
2705
+ /* @__PURE__ */ jsxs("div", {
2706
+ className: "col-span-12 sm:col-span-6",
2707
+ children: [/* @__PURE__ */ jsx(TextField, {
2708
+ value: throughSourceColumn,
2709
+ onChange: (e) => updateThrough({ sourceColumn: e.target.value }),
2710
+ label: "Source column",
2711
+ disabled,
2712
+ placeholder: "e.g. user_id"
2713
+ }), /* @__PURE__ */ jsx(FieldCaption, { children: "Column in the junction table referencing this table" })]
2714
+ }),
2715
+ /* @__PURE__ */ jsxs("div", {
2716
+ className: "col-span-12 sm:col-span-6",
2717
+ children: [/* @__PURE__ */ jsx(TextField, {
2718
+ value: throughTargetColumn,
2719
+ onChange: (e) => updateThrough({ targetColumn: e.target.value }),
2720
+ label: "Target column",
2721
+ disabled,
2722
+ placeholder: "e.g. role_id"
2723
+ }), /* @__PURE__ */ jsx(FieldCaption, { children: "Column in the junction table referencing the target table" })]
2724
+ })
2725
+ ]
2726
+ })]
2727
+ }),
2728
+ /* @__PURE__ */ jsxs("div", {
2729
+ className: "col-span-12 sm:col-span-6",
2730
+ children: [/* @__PURE__ */ jsx(Select, {
2731
+ value: onUpdate,
2732
+ onValueChange: (v) => setFieldValue("onUpdate", v),
2733
+ label: "On update",
2734
+ disabled,
2735
+ fullWidth: true,
2736
+ renderValue: (v) => String(v),
2737
+ children: ON_ACTION_OPTIONS.map((action) => /* @__PURE__ */ jsx(SelectItem, {
2738
+ value: action,
2739
+ children: action
2740
+ }, action))
2741
+ }), /* @__PURE__ */ jsx(FieldCaption, { children: "Action when the referenced record is updated" })]
2742
+ }),
2743
+ /* @__PURE__ */ jsxs("div", {
2744
+ className: "col-span-12 sm:col-span-6",
2745
+ children: [/* @__PURE__ */ jsx(Select, {
2746
+ value: onDelete,
2747
+ onValueChange: (v) => setFieldValue("onDelete", v),
2748
+ label: "On delete",
2749
+ disabled,
2750
+ fullWidth: true,
2751
+ renderValue: (v) => String(v),
2752
+ children: ON_ACTION_OPTIONS.map((action) => /* @__PURE__ */ jsx(SelectItem, {
2753
+ value: action,
2754
+ children: action
2755
+ }, action))
2756
+ }), /* @__PURE__ */ jsx(FieldCaption, { children: "Action when the referenced record is deleted" })]
2757
+ })
2758
+ ] });
2759
+ }
2760
+ //#endregion
2761
+ //#region src/collection_editor/ui/collection_editor/utils/update_property_for_widget.ts
2762
+ function updatePropertyFromWidget(propertyData, selectedWidgetId, propertyConfigs) {
2763
+ let updatedProperty;
2764
+ if (selectedWidgetId === "text_field") updatedProperty = mergeDeep(propertyData, {
2765
+ type: "string",
2766
+ propertyConfig: "text_field",
2767
+ storage: void 0,
2768
+ ui: {
2769
+ multiline: void 0,
2770
+ markdown: void 0,
2771
+ url: void 0
2772
+ },
2773
+ email: void 0,
2774
+ enum: void 0,
2775
+ userSelect: void 0
2776
+ });
2777
+ else if (selectedWidgetId === "user_select") updatedProperty = mergeDeep(propertyData, {
2778
+ type: "string",
2779
+ propertyConfig: "user_select",
2780
+ storage: void 0,
2781
+ ui: {
2782
+ multiline: void 0,
2783
+ markdown: void 0,
2784
+ url: void 0
2785
+ },
2786
+ email: void 0,
2787
+ enum: void 0,
2788
+ userSelect: true
2789
+ });
2790
+ else if (selectedWidgetId === "multiline") updatedProperty = mergeDeep(propertyData, {
2791
+ type: "string",
2792
+ propertyConfig: "multiline",
2793
+ ui: {
2794
+ multiline: true,
2795
+ markdown: void 0,
2796
+ url: void 0
2797
+ },
2798
+ storage: void 0,
2799
+ email: void 0,
2800
+ enum: void 0,
2801
+ userSelect: void 0
2802
+ });
2803
+ else if (selectedWidgetId === "markdown") updatedProperty = mergeDeep(propertyData, {
2804
+ type: "string",
2805
+ propertyConfig: "markdown",
2806
+ storage: void 0,
2807
+ ui: {
2808
+ multiline: void 0,
2809
+ markdown: true,
2810
+ url: void 0
2811
+ },
2812
+ email: void 0,
2813
+ userSelect: void 0
2814
+ });
2815
+ else if (selectedWidgetId === "url") updatedProperty = mergeDeep(propertyData, {
2816
+ type: "string",
2817
+ propertyConfig: "url",
2818
+ storage: void 0,
2819
+ ui: {
2820
+ multiline: void 0,
2821
+ markdown: void 0,
2822
+ url: true
2823
+ },
2824
+ email: void 0,
2825
+ enum: void 0,
2826
+ userSelect: void 0
2827
+ });
2828
+ else if (selectedWidgetId === "email") updatedProperty = mergeDeep(propertyData, {
2829
+ type: "string",
2830
+ propertyConfig: "email",
2831
+ storage: void 0,
2832
+ ui: {
2833
+ multiline: void 0,
2834
+ markdown: void 0,
2835
+ url: void 0
2836
+ },
2837
+ email: true,
2838
+ enum: void 0,
2839
+ userSelect: void 0
2840
+ });
2841
+ else if (selectedWidgetId === "select") updatedProperty = mergeDeep(propertyData, {
2842
+ type: "string",
2843
+ propertyConfig: "select",
2844
+ storage: void 0,
2845
+ ui: {
2846
+ multiline: void 0,
2847
+ markdown: void 0,
2848
+ url: void 0
2849
+ },
2850
+ email: void 0,
2851
+ enum: propertyData.enum ?? [],
2852
+ userSelect: void 0
2853
+ });
2854
+ else if (selectedWidgetId === "multi_select") updatedProperty = mergeDeep(propertyData, {
2855
+ type: "array",
2856
+ propertyConfig: "multi_select",
2857
+ of: {
2858
+ type: "string",
2859
+ enum: propertyData.of?.enum ?? []
2860
+ }
2861
+ });
2862
+ else if (selectedWidgetId === "number_input") updatedProperty = mergeDeep(propertyData, {
2863
+ type: "number",
2864
+ propertyConfig: "number_input",
2865
+ enum: void 0
2866
+ });
2867
+ else if (selectedWidgetId === "number_select") updatedProperty = mergeDeep(propertyData, {
2868
+ type: "number",
2869
+ propertyConfig: "number_select",
2870
+ enum: propertyData.enum ?? []
2871
+ });
2872
+ else if (selectedWidgetId === "multi_number_select") updatedProperty = mergeDeep(propertyData, {
2873
+ type: "array",
2874
+ propertyConfig: "multi_number_select",
2875
+ of: {
2876
+ type: "number",
2877
+ enum: propertyData.of?.enum ?? []
2878
+ }
2879
+ });
2880
+ else if (selectedWidgetId === "file_upload") updatedProperty = mergeDeep(propertyData, {
2881
+ type: "string",
2882
+ propertyConfig: "file_upload",
2883
+ storage: { storagePath: "/" }
2884
+ });
2885
+ else if (selectedWidgetId === "multi_file_upload") updatedProperty = mergeDeep(propertyData, {
2886
+ type: "array",
2887
+ propertyConfig: "multi_file_upload",
2888
+ of: {
2889
+ type: "string",
2890
+ storage: propertyData.of?.storage ?? { storagePath: "/" }
2891
+ }
2892
+ });
2893
+ else if (selectedWidgetId === "group") updatedProperty = mergeDeep(propertyData, {
2894
+ type: "map",
2895
+ propertyConfig: "group",
2896
+ keyValue: false,
2897
+ properties: propertyData.properties ?? {}
2898
+ });
2899
+ else if (selectedWidgetId === "key_value") updatedProperty = mergeDeep(propertyData, {
2900
+ type: "map",
2901
+ propertyConfig: "key_value",
2902
+ keyValue: true,
2903
+ properties: void 0
2904
+ });
2905
+ else if (selectedWidgetId === "reference") updatedProperty = mergeDeep(propertyData, {
2906
+ type: "reference",
2907
+ propertyConfig: "reference"
2908
+ });
2909
+ else if (selectedWidgetId === "multi_references") updatedProperty = mergeDeep(propertyData, {
2910
+ type: "array",
2911
+ propertyConfig: "multi_references",
2912
+ of: { type: "reference" }
2913
+ });
2914
+ else if (selectedWidgetId === "switch") updatedProperty = mergeDeep(propertyData, {
2915
+ type: "boolean",
2916
+ propertyConfig: "switch"
2917
+ });
2918
+ else if (selectedWidgetId === "date_time") updatedProperty = mergeDeep(propertyData, {
2919
+ type: "date",
2920
+ propertyConfig: "date_time",
2921
+ mode: "date_time"
2922
+ });
2923
+ else if (selectedWidgetId === "relation") updatedProperty = mergeDeep(propertyData, {
2924
+ type: "relation",
2925
+ propertyConfig: "relation",
2926
+ relationName: propertyData.relationName ?? ""
2927
+ });
2928
+ else if (selectedWidgetId === "repeat") updatedProperty = mergeDeep(propertyData, {
2929
+ type: "array",
2930
+ propertyConfig: "repeat"
2931
+ });
2932
+ else if (selectedWidgetId === "block") updatedProperty = mergeDeep(propertyData, {
2933
+ type: "array",
2934
+ propertyConfig: "block",
2935
+ oneOf: { properties: {} }
2936
+ });
2937
+ else if (selectedWidgetId && propertyConfigs[selectedWidgetId]) updatedProperty = {
2938
+ ...propertyConfigs[selectedWidgetId].property,
2939
+ propertyConfig: selectedWidgetId
2940
+ };
2941
+ return updatedProperty;
2942
+ }
2943
+ //#endregion
2944
+ //#region src/collection_editor/ui/collection_editor/properties/UrlPropertyField.tsx
2945
+ function UrlPropertyField({ disabled, showErrors }) {
2946
+ const { values, setFieldValue } = useFormex();
2947
+ const urlRawValue = getIn(values, "url");
2948
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
2949
+ /* @__PURE__ */ jsx("div", {
2950
+ className: "col-span-12",
2951
+ children: /* @__PURE__ */ jsxs(Select, {
2952
+ disabled,
2953
+ position: "item-aligned",
2954
+ fullWidth: true,
2955
+ onValueChange: (value) => {
2956
+ if (value === "[NONE]") setFieldValue("url", true);
2957
+ else setFieldValue("url", value);
2958
+ },
2959
+ label: "Preview type",
2960
+ renderValue: (value) => {
2961
+ switch (value) {
2962
+ case "image": return "Image";
2963
+ case "video": return "Video";
2964
+ case "audio": return "Audio";
2965
+ default: return "Display URL";
2966
+ }
2967
+ },
2968
+ value: (typeof urlRawValue === "string" ? urlRawValue : "[NONE]") ?? "[NONE]",
2969
+ children: [
2970
+ /* @__PURE__ */ jsx(SelectItem, {
2971
+ value: "[NONE]",
2972
+ children: "Display URL"
2973
+ }),
2974
+ /* @__PURE__ */ jsx(SelectItem, {
2975
+ value: "image",
2976
+ children: "Image"
2977
+ }),
2978
+ /* @__PURE__ */ jsx(SelectItem, {
2979
+ value: "video",
2980
+ children: "Video"
2981
+ }),
2982
+ /* @__PURE__ */ jsx(SelectItem, {
2983
+ value: "audio",
2984
+ children: "Audio"
2985
+ })
2986
+ ]
2987
+ })
2988
+ }),
2989
+ /* @__PURE__ */ jsx("div", {
2990
+ className: "col-span-12",
2991
+ children: /* @__PURE__ */ jsx(ValidationPanel, { children: /* @__PURE__ */ jsx(StringPropertyValidation, {
2992
+ disabled,
2993
+ max: true,
2994
+ min: true,
2995
+ trim: true,
2996
+ showErrors
2997
+ }) })
2998
+ }),
2999
+ /* @__PURE__ */ jsx("div", {
3000
+ className: "col-span-12",
3001
+ children: /* @__PURE__ */ jsx(TextField, {
3002
+ name: "defaultValue",
3003
+ disabled,
3004
+ onChange: (e) => {
3005
+ setFieldValue("defaultValue", e.target.value === "" ? void 0 : e.target.value);
3006
+ },
3007
+ label: "Default value",
3008
+ value: getIn(values, "defaultValue") ?? ""
3009
+ })
3010
+ })
3011
+ ] });
3012
+ }
3013
+ //#endregion
3014
+ //#region src/collection_editor/ui/collection_editor/utils/supported_fields.tsx
3015
+ var supportedFieldsIds = [
3016
+ "text_field",
3017
+ "multiline",
3018
+ "markdown",
3019
+ "url",
3020
+ "email",
3021
+ "user_select",
3022
+ "select",
3023
+ "multi_select",
3024
+ "number_input",
3025
+ "number_select",
3026
+ "multi_number_select",
3027
+ "file_upload",
3028
+ "multi_file_upload",
3029
+ "reference",
3030
+ "multi_references",
3031
+ "relation",
3032
+ "switch",
3033
+ "date_time",
3034
+ "group",
3035
+ "key_value",
3036
+ "repeat",
3037
+ "block"
3038
+ ];
3039
+ var supportedFields = Object.entries(DEFAULT_FIELD_CONFIGS).filter(([id]) => supportedFieldsIds.includes(id)).map(([id, config]) => ({ [id]: config })).reduce((a, b) => ({
3040
+ ...a,
3041
+ ...b
3042
+ }), {});
3043
+ //#endregion
3044
+ //#region src/collection_editor/ui/collection_editor/properties/MarkdownPropertyField.tsx
3045
+ function MarkdownPropertyField({ disabled, showErrors }) {
3046
+ const { values, setFieldValue } = useFormex();
3047
+ const { t } = useTranslation();
3048
+ const baseStoragePath = "storage";
3049
+ const fileName = `${baseStoragePath}.fileName`;
3050
+ const maxSize = `${baseStoragePath}.maxSize`;
3051
+ const storagePath = `${baseStoragePath}.storagePath`;
3052
+ const fileNameValue = getIn(values, fileName) ?? "{rand}_{file}";
3053
+ const storagePathValue = getIn(values, storagePath) ?? "/";
3054
+ const maxSizeValue = getIn(values, maxSize);
3055
+ const markdownValue = getIn(values, "markdown");
3056
+ const isMarkdownObject = typeof markdownValue === "object" && markdownValue !== null;
3057
+ const htmlValue = isMarkdownObject ? markdownValue.html ?? true : true;
3058
+ const transformPastedTextValue = isMarkdownObject ? markdownValue.transformPastedText ?? false : false;
3059
+ const hasFilenameCallback = typeof fileNameValue === "function";
3060
+ const hasStoragePathCallback = typeof storagePathValue === "function";
3061
+ const updateMarkdownConfig = useCallback((key, value) => {
3062
+ const currentMarkdown = getIn(values, "markdown");
3063
+ if (typeof currentMarkdown === "object" && currentMarkdown !== null) setFieldValue(`markdown.${key}`, value);
3064
+ else setFieldValue("markdown", {
3065
+ html: true,
3066
+ transformPastedText: false,
3067
+ [key]: value
3068
+ });
3069
+ }, [values, setFieldValue]);
3070
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
3071
+ /* @__PURE__ */ jsx("div", {
3072
+ className: "col-span-12",
3073
+ children: /* @__PURE__ */ jsx(ValidationPanel, { children: /* @__PURE__ */ jsx(StringPropertyValidation, {
3074
+ disabled,
3075
+ length: true,
3076
+ lowercase: true,
3077
+ max: true,
3078
+ min: true,
3079
+ trim: true,
3080
+ uppercase: true,
3081
+ showErrors
3082
+ }) })
3083
+ }),
3084
+ /* @__PURE__ */ jsx("div", {
3085
+ className: "col-span-12",
3086
+ children: /* @__PURE__ */ jsx(ExpandablePanel, {
3087
+ title: /* @__PURE__ */ jsxs("div", {
3088
+ className: "flex flex-row text-surface-500",
3089
+ children: [/* @__PURE__ */ jsx(SettingsIcon, {}), /* @__PURE__ */ jsx(Typography, {
3090
+ variant: "subtitle2",
3091
+ className: "ml-4",
3092
+ children: "Paste behavior"
3093
+ })]
3094
+ }),
3095
+ children: /* @__PURE__ */ jsxs("div", {
3096
+ className: "flex flex-col gap-2 p-4",
3097
+ children: [
3098
+ /* @__PURE__ */ jsx(BooleanSwitchWithLabel, {
3099
+ size: "small",
3100
+ disabled,
3101
+ value: !htmlValue,
3102
+ onValueChange: (value) => updateMarkdownConfig("html", !value),
3103
+ label: t("markdown_strip_html")
3104
+ }),
3105
+ /* @__PURE__ */ jsx(Typography, {
3106
+ variant: "caption",
3107
+ className: "ml-3.5 mt-1 mb-2",
3108
+ children: "Remove HTML tags and inline styles when pasting content from external sources"
3109
+ }),
3110
+ /* @__PURE__ */ jsx(BooleanSwitchWithLabel, {
3111
+ size: "small",
3112
+ disabled,
3113
+ value: transformPastedTextValue,
3114
+ onValueChange: (value) => updateMarkdownConfig("transformPastedText", value),
3115
+ label: t("markdown_convert_pasted")
3116
+ }),
3117
+ /* @__PURE__ */ jsx(Typography, {
3118
+ variant: "caption",
3119
+ className: "ml-3.5 mt-1 mb-2",
3120
+ children: "Convert rich text (from Google Docs, Word, etc.) to clean markdown format"
3121
+ })
3122
+ ]
3123
+ })
3124
+ })
3125
+ }),
3126
+ /* @__PURE__ */ jsx("div", {
3127
+ className: "col-span-12",
3128
+ children: /* @__PURE__ */ jsx(ExpandablePanel, {
3129
+ title: /* @__PURE__ */ jsxs("div", {
3130
+ className: "flex flex-row text-surface-500",
3131
+ children: [/* @__PURE__ */ jsx(UploadCloudIcon, {}), /* @__PURE__ */ jsx(Typography, {
3132
+ variant: "subtitle2",
3133
+ className: "ml-4",
3134
+ children: "File upload config"
3135
+ })]
3136
+ }),
3137
+ children: /* @__PURE__ */ jsxs("div", {
3138
+ className: "grid grid-cols-12 gap-2 p-4",
3139
+ children: [
3140
+ /* @__PURE__ */ jsx("div", {
3141
+ className: "col-span-12",
3142
+ children: /* @__PURE__ */ jsx(Field, {
3143
+ name: fileName,
3144
+ as: DebouncedTextField,
3145
+ label: t("storage_file_name"),
3146
+ size: "small",
3147
+ disabled: hasFilenameCallback || disabled,
3148
+ value: hasFilenameCallback ? "-" : fileNameValue
3149
+ })
3150
+ }),
3151
+ /* @__PURE__ */ jsxs("div", {
3152
+ className: "col-span-12",
3153
+ children: [
3154
+ /* @__PURE__ */ jsx(Field, {
3155
+ name: storagePath,
3156
+ as: DebouncedTextField,
3157
+ label: t("storage_path"),
3158
+ disabled: hasStoragePathCallback || disabled,
3159
+ size: "small",
3160
+ value: hasStoragePathCallback ? "-" : storagePathValue
3161
+ }),
3162
+ /* @__PURE__ */ jsxs(Typography, {
3163
+ variant: "caption",
3164
+ className: "ml-3.5 mt-1 mb-2",
3165
+ children: [/* @__PURE__ */ jsx("p", { children: "You can use the following placeholders in the file name and storage path values:" }), /* @__PURE__ */ jsxs("ul", { children: [
3166
+ /* @__PURE__ */ jsx("li", { children: "{file} - Full name of the uploaded file" }),
3167
+ /* @__PURE__ */ jsx("li", { children: "{file.name} - Name of the uploaded file without extension" }),
3168
+ /* @__PURE__ */ jsx("li", { children: "{file.ext} - Extension of the uploaded file" }),
3169
+ /* @__PURE__ */ jsx("li", { children: "{entityId} - ID of the entity" }),
3170
+ /* @__PURE__ */ jsx("li", { children: "{propertyKey} - ID of this field" }),
3171
+ /* @__PURE__ */ jsx("li", { children: "{path} - Path of this entity" }),
3172
+ /* @__PURE__ */ jsx("li", { children: "{rand} - Random value used to avoid name collisions" })
3173
+ ] })]
3174
+ }),
3175
+ /* @__PURE__ */ jsx(Typography, {
3176
+ variant: "caption",
3177
+ className: "ml-3.5 mt-1 mb-2",
3178
+ children: "When using Markdown, the URL of the uploaded files are always saved in the text value (not the path)."
3179
+ })
3180
+ ]
3181
+ }),
3182
+ /* @__PURE__ */ jsx("div", {
3183
+ className: "col-span-12",
3184
+ children: /* @__PURE__ */ jsx(DebouncedTextField, {
3185
+ name: maxSize,
3186
+ type: "number",
3187
+ label: t("storage_max_size"),
3188
+ size: "small",
3189
+ value: maxSizeValue !== void 0 && maxSizeValue !== null ? maxSizeValue.toString() : "",
3190
+ onChange: (e) => {
3191
+ const value = e.target.value;
3192
+ if (value === "") setFieldValue(maxSize, void 0);
3193
+ else setFieldValue(maxSize, parseInt(value));
3194
+ }
3195
+ })
3196
+ })
3197
+ ]
3198
+ })
3199
+ })
3200
+ }),
3201
+ /* @__PURE__ */ jsx("div", {
3202
+ className: "col-span-12",
3203
+ children: /* @__PURE__ */ jsx(TextField, {
3204
+ name: "defaultValue",
3205
+ disabled,
3206
+ onChange: (e) => {
3207
+ setFieldValue("defaultValue", e.target.value === "" ? void 0 : e.target.value);
3208
+ },
3209
+ label: t("default_value"),
3210
+ value: getIn(values, "defaultValue") ?? ""
3211
+ })
3212
+ })
3213
+ ] });
3214
+ }
3215
+ //#endregion
3216
+ //#region src/collection_editor/ui/collection_editor/PropertyEditView.tsx
3217
+ var PropertyEditView_exports = /* @__PURE__ */ __exportAll({
3218
+ PropertyForm: () => PropertyForm,
3219
+ PropertyFormDialog: () => PropertyFormDialog,
3220
+ WidgetSelectViewItem: () => WidgetSelectViewItem
3221
+ });
3222
+ var PropertyForm = React.memo(function PropertyForm(props) {
3223
+ const { includeIdAndName = true, autoOpenTypeSelect, existingProperty, autoUpdateId, inArray, propertyKey, existingPropertyKeys, propertyNamespace, property, onPropertyChanged, onPropertyChangedImmediate = true, onDismiss, onDelete, onError, initialErrors, forceShowErrors, allowDataInference, getController, getData, propertyConfigs, propertyTypePresets, hiddenPropertyTypes, renderExtraPropertyFields, collectionValues } = props;
3224
+ const initialValue = {
3225
+ id: "",
3226
+ name: ""
3227
+ };
3228
+ const disabled = Boolean(property && isPropertyBuilder(property));
3229
+ const lastSubmittedProperty = useRef(property ? {
3230
+ id: propertyKey,
3231
+ previousId: propertyKey,
3232
+ property
3233
+ } : void 0);
3234
+ const doOnPropertyChanged = ({ id, property }) => {
3235
+ const params = {
3236
+ id,
3237
+ previousId: lastSubmittedProperty.current?.id,
3238
+ property,
3239
+ namespace: propertyNamespace
3240
+ };
3241
+ lastSubmittedProperty.current = params;
3242
+ onPropertyChanged?.(params);
3243
+ };
3244
+ const formexController = useCreateFormex({
3245
+ debugId: "PROPERTY_FORM",
3246
+ initialValues: property ? {
3247
+ id: propertyKey,
3248
+ ...property
3249
+ } : initialValue,
3250
+ initialErrors,
3251
+ validateOnChange: true,
3252
+ validateOnInitialRender: true,
3253
+ onSubmit: (newPropertyWithId, controller) => {
3254
+ const { id, ...property } = newPropertyWithId;
3255
+ doOnPropertyChanged({
3256
+ id,
3257
+ property
3258
+ });
3259
+ if (!existingProperty) controller.resetForm({ values: initialValue });
3260
+ },
3261
+ validation: (values) => {
3262
+ const errors = {};
3263
+ if (includeIdAndName) {
3264
+ if (!values.name) errors.name = "Required";
3265
+ else {
3266
+ const nameError = validateName(values.name);
3267
+ if (nameError) errors.name = nameError;
3268
+ }
3269
+ if (!values.id) errors.id = "Required";
3270
+ else {
3271
+ const idError = validateId(values.id, existingPropertyKeys);
3272
+ if (idError) errors.id = idError;
3273
+ }
3274
+ }
3275
+ if (values.type === "string") {
3276
+ if (values.validation?.matches && !isValidRegExp(values.validation?.matches.toString())) errors.validation = { matches: "Invalid regular expression" };
3277
+ }
3278
+ if (values.type === "reference" && !values.path) errors.slug = "You must specify a target collection for the field";
3279
+ if (values.type === "vector" && (!values.dimensions || isNaN(Number(values.dimensions)) || Number(values.dimensions) <= 0)) errors.dimensions = "Vector dimensions must be a positive number";
3280
+ if (values.propertyConfig === "repeat") {
3281
+ if (!("of" in values) || !values.of) errors.of = "You need to specify a repeat field";
3282
+ }
3283
+ if (values.propertyConfig === "block") {
3284
+ if (!("oneOf" in values) || !values.oneOf) errors.oneOf = "You need to specify the properties of this block";
3285
+ }
3286
+ return errors;
3287
+ }
3288
+ });
3289
+ useEffect(() => {
3290
+ getController?.(formexController);
3291
+ }, [formexController, getController]);
3292
+ return /* @__PURE__ */ jsx(Formex, {
3293
+ value: formexController,
3294
+ children: /* @__PURE__ */ jsx(PropertyEditFormFields, {
3295
+ onPropertyChanged: onPropertyChangedImmediate ? doOnPropertyChanged : void 0,
3296
+ onDelete,
3297
+ includeIdAndTitle: includeIdAndName,
3298
+ propertyNamespace,
3299
+ onError,
3300
+ onDismiss,
3301
+ showErrors: forceShowErrors || formexController.submitCount > 0,
3302
+ existing: existingProperty,
3303
+ autoUpdateId,
3304
+ inArray,
3305
+ autoOpenTypeSelect,
3306
+ disabled,
3307
+ getData,
3308
+ allowDataInference,
3309
+ propertyConfigs,
3310
+ propertyTypePresets,
3311
+ hiddenPropertyTypes,
3312
+ renderExtraPropertyFields,
3313
+ collectionValues,
3314
+ ...formexController
3315
+ })
3316
+ });
3317
+ }, (a, b) => a.getData === b.getData && a.propertyKey === b.propertyKey && a.propertyNamespace === b.propertyNamespace && a.includeIdAndName === b.includeIdAndName && a.autoOpenTypeSelect === b.autoOpenTypeSelect && a.autoUpdateId === b.autoUpdateId && a.existingPropertyKeys === b.existingPropertyKeys && a.existingProperty === b.existingProperty);
3318
+ function PropertyFormDialog({ open, onCancel, onOkClicked, onPropertyChanged, getData, ...formProps }) {
3319
+ const formexRef = useRef(void 0);
3320
+ const getController = (helpers) => {
3321
+ formexRef.current = helpers;
3322
+ };
3323
+ return /* @__PURE__ */ jsx(Dialog, {
3324
+ open: open ?? false,
3325
+ maxWidth: "xl",
3326
+ fullWidth: true,
3327
+ children: /* @__PURE__ */ jsxs("form", {
3328
+ noValidate: true,
3329
+ autoComplete: "off",
3330
+ onSubmit: (e) => {
3331
+ e.preventDefault();
3332
+ e.stopPropagation();
3333
+ formexRef.current?.handleSubmit(e);
3334
+ },
3335
+ children: [
3336
+ /* @__PURE__ */ jsx(DialogTitle, {
3337
+ hidden: true,
3338
+ children: "Property edit view"
3339
+ }),
3340
+ /* @__PURE__ */ jsx(DialogContent, { children: /* @__PURE__ */ jsx(PropertyForm, {
3341
+ ...formProps,
3342
+ onDismiss: onCancel,
3343
+ onPropertyChanged: (params) => {
3344
+ onPropertyChanged?.(params);
3345
+ onOkClicked?.();
3346
+ },
3347
+ onPropertyChangedImmediate: false,
3348
+ getController,
3349
+ getData
3350
+ }) }),
3351
+ /* @__PURE__ */ jsxs(DialogActions, { children: [onCancel && /* @__PURE__ */ jsx(Button, {
3352
+ variant: "text",
3353
+ onClick: () => {
3354
+ onCancel();
3355
+ formexRef.current?.resetForm();
3356
+ },
3357
+ children: "Cancel"
3358
+ }), /* @__PURE__ */ jsx(Button, {
3359
+ type: "submit",
3360
+ children: "Ok"
3361
+ })] })
3362
+ ]
3363
+ })
3364
+ });
3365
+ }
3366
+ function PropertyEditFormFields({ values, errors, setValues, existing, autoUpdateId = false, autoOpenTypeSelect, includeIdAndTitle, onPropertyChanged, onDelete, propertyNamespace, onDismiss, onError, showErrors, disabled, inArray, getData, allowDataInference, propertyConfigs, propertyTypePresets, hiddenPropertyTypes, renderExtraPropertyFields, collectionValues }) {
3367
+ const [selectOpen, setSelectOpen] = useState(autoOpenTypeSelect);
3368
+ const [deleteDialogOpen, setDeleteDialogOpen] = useState(false);
3369
+ const [selectedFieldConfigId, setSelectedFieldConfigId] = useState(values?.type ? getFieldId(values) : void 0);
3370
+ const deferredValues = useDeferredValue(values);
3371
+ const nameFieldRef = useRef(null);
3372
+ const lastSubmittedProperty = useRef(values);
3373
+ const selectedWidgetError = showErrors && getIn(errors, "selectedWidget");
3374
+ useEffect(() => {
3375
+ if (onPropertyChanged) {
3376
+ if (!includeIdAndTitle || deferredValues.id) {
3377
+ const { id, ...property } = deferredValues;
3378
+ if (!deepEqual(deferredValues, lastSubmittedProperty.current)) {
3379
+ onPropertyChanged({
3380
+ id,
3381
+ property,
3382
+ namespace: propertyNamespace
3383
+ });
3384
+ lastSubmittedProperty.current = deferredValues;
3385
+ }
3386
+ }
3387
+ }
3388
+ }, [
3389
+ deferredValues,
3390
+ includeIdAndTitle,
3391
+ propertyNamespace
3392
+ ]);
3393
+ useEffect(() => {
3394
+ if (values?.id && onError) onError(values?.id, propertyNamespace, errors);
3395
+ }, [
3396
+ errors,
3397
+ propertyNamespace,
3398
+ values?.id
3399
+ ]);
3400
+ const onWidgetSelectChanged = (newSelectedWidgetId) => {
3401
+ setSelectedFieldConfigId(newSelectedWidgetId);
3402
+ setValues(updatePropertyFromWidget(values, newSelectedWidgetId, propertyConfigs));
3403
+ setTimeout(() => {
3404
+ nameFieldRef.current?.focus();
3405
+ }, 0);
3406
+ };
3407
+ const onPresetSelected = useCallback((preset) => {
3408
+ const widgetId = {
3409
+ "string": "text_field",
3410
+ "number": "number_input",
3411
+ "boolean": "switch",
3412
+ "date": "date_time",
3413
+ "reference": "reference",
3414
+ "relation": "relation",
3415
+ "map": "group",
3416
+ "array": "repeat",
3417
+ "vector": "vector_input",
3418
+ "geopoint": "text_field",
3419
+ "binary": "text_field"
3420
+ }[preset.baseType] || "text_field";
3421
+ setSelectedFieldConfigId(widgetId);
3422
+ setValues({
3423
+ ...updatePropertyFromWidget(values, widgetId, propertyConfigs),
3424
+ ...preset.defaults,
3425
+ propertyConfig: widgetId
3426
+ });
3427
+ }, [
3428
+ values,
3429
+ propertyConfigs,
3430
+ setValues
3431
+ ]);
3432
+ let childComponent;
3433
+ if (selectedFieldConfigId === "text_field" || selectedFieldConfigId === "multiline" || selectedFieldConfigId === "user_select" || selectedFieldConfigId === "email") childComponent = /* @__PURE__ */ jsx(StringPropertyField, {
3434
+ widgetId: selectedFieldConfigId,
3435
+ disabled,
3436
+ showErrors
3437
+ });
3438
+ else if (selectedFieldConfigId === "url") childComponent = /* @__PURE__ */ jsx(UrlPropertyField, {
3439
+ disabled,
3440
+ showErrors
3441
+ });
3442
+ else if (selectedFieldConfigId === "markdown") childComponent = /* @__PURE__ */ jsx(MarkdownPropertyField, {
3443
+ disabled,
3444
+ showErrors
3445
+ });
3446
+ else if (selectedFieldConfigId === "select" || selectedFieldConfigId === "number_select") childComponent = /* @__PURE__ */ jsx(EnumPropertyField, {
3447
+ multiselect: false,
3448
+ allowDataInference,
3449
+ updateIds: !existing,
3450
+ disabled,
3451
+ getData,
3452
+ propertyNamespace,
3453
+ showErrors
3454
+ });
3455
+ else if (selectedFieldConfigId === "multi_select" || selectedFieldConfigId === "multi_number_select") childComponent = /* @__PURE__ */ jsx(EnumPropertyField, {
3456
+ multiselect: true,
3457
+ updateIds: !existing,
3458
+ disabled,
3459
+ allowDataInference,
3460
+ getData,
3461
+ propertyNamespace,
3462
+ showErrors
3463
+ });
3464
+ else if (selectedFieldConfigId === "file_upload") childComponent = /* @__PURE__ */ jsx(StoragePropertyField, {
3465
+ existing,
3466
+ multiple: false,
3467
+ disabled
3468
+ });
3469
+ else if (selectedFieldConfigId === "multi_file_upload") childComponent = /* @__PURE__ */ jsx(StoragePropertyField, {
3470
+ existing,
3471
+ multiple: true,
3472
+ disabled
3473
+ });
3474
+ else if (selectedFieldConfigId === "switch") childComponent = /* @__PURE__ */ jsx(BooleanPropertyField, { disabled });
3475
+ else if (selectedFieldConfigId === "number_input") childComponent = /* @__PURE__ */ jsx(NumberPropertyField, { disabled });
3476
+ else if (selectedFieldConfigId === "group") childComponent = /* @__PURE__ */ jsx(MapPropertyField, {
3477
+ disabled,
3478
+ getData,
3479
+ allowDataInference,
3480
+ propertyConfigs
3481
+ });
3482
+ else if (selectedFieldConfigId === "block") childComponent = /* @__PURE__ */ jsx(BlockPropertyField, {
3483
+ disabled,
3484
+ getData,
3485
+ allowDataInference,
3486
+ propertyConfigs
3487
+ });
3488
+ else if (selectedFieldConfigId === "reference") childComponent = /* @__PURE__ */ jsx(ReferencePropertyField, {
3489
+ showErrors,
3490
+ existing,
3491
+ multiple: false,
3492
+ disabled
3493
+ });
3494
+ else if (selectedFieldConfigId === "date_time") childComponent = /* @__PURE__ */ jsx(DateTimePropertyField, { disabled });
3495
+ else if (selectedFieldConfigId === "multi_references") childComponent = /* @__PURE__ */ jsx(ReferencePropertyField, {
3496
+ showErrors,
3497
+ existing,
3498
+ multiple: true,
3499
+ disabled
3500
+ });
3501
+ else if (selectedFieldConfigId === "repeat") childComponent = /* @__PURE__ */ jsx(RepeatPropertyField, {
3502
+ showErrors,
3503
+ existing,
3504
+ getData,
3505
+ allowDataInference,
3506
+ disabled,
3507
+ propertyConfigs
3508
+ });
3509
+ else if (selectedFieldConfigId === "key_value") childComponent = /* @__PURE__ */ jsx(KeyValuePropertyField, { disabled });
3510
+ else if (selectedFieldConfigId === "relation") childComponent = /* @__PURE__ */ jsx(RelationPropertyField, {
3511
+ showErrors,
3512
+ disabled
3513
+ });
3514
+ else if (selectedFieldConfigId === "vector_input") childComponent = /* @__PURE__ */ jsx(VectorPropertyField, { disabled });
3515
+ else childComponent = null;
3516
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
3517
+ disabled && /* @__PURE__ */ jsxs(InfoLabel, {
3518
+ mode: "warn",
3519
+ children: [/* @__PURE__ */ jsx(Typography, { children: "This property can't be edited" }), /* @__PURE__ */ jsx(Typography, {
3520
+ variant: "caption",
3521
+ children: "You may not have permission to edit it or it is defined in code and cannot be modified."
3522
+ })]
3523
+ }),
3524
+ /* @__PURE__ */ jsxs("div", {
3525
+ className: "flex mt-2 items-start justify-between",
3526
+ children: [/* @__PURE__ */ jsxs("div", {
3527
+ className: "w-full flex flex-col gap-2",
3528
+ children: [/* @__PURE__ */ jsx(WidgetSelectView, {
3529
+ initialProperty: values,
3530
+ value: selectedFieldConfigId,
3531
+ onValueChange: (value) => onWidgetSelectChanged(value),
3532
+ open: selectOpen,
3533
+ onOpenChange: (open, hasValue) => {
3534
+ if (!hasValue) onDismiss?.();
3535
+ setSelectOpen(open);
3536
+ },
3537
+ disabled,
3538
+ showError: Boolean(selectedWidgetError),
3539
+ existing,
3540
+ propertyConfigs,
3541
+ inArray,
3542
+ propertyTypePresets,
3543
+ hiddenPropertyTypes,
3544
+ onPresetSelected
3545
+ }), !!selectedWidgetError && /* @__PURE__ */ jsx(Typography, {
3546
+ variant: "caption",
3547
+ className: "ml-3.5",
3548
+ color: "error",
3549
+ children: "Required"
3550
+ })]
3551
+ }), onDelete && values?.id && /* @__PURE__ */ jsx(IconButton, {
3552
+ variant: "ghost",
3553
+ className: "mt-1 shrink-0",
3554
+ disabled,
3555
+ onClick: () => setDeleteDialogOpen(true),
3556
+ children: /* @__PURE__ */ jsx(Trash2Icon, { size: iconSize.small })
3557
+ })]
3558
+ }),
3559
+ /* @__PURE__ */ jsxs("div", {
3560
+ className: "grid grid-cols-12 gap-y-8 mt-6 mb-8",
3561
+ children: [
3562
+ includeIdAndTitle && /* @__PURE__ */ jsx(CommonPropertyFields, {
3563
+ showErrors,
3564
+ disabledId: existing,
3565
+ isNewProperty: !existing,
3566
+ disabled,
3567
+ autoUpdateId,
3568
+ ref: nameFieldRef
3569
+ }),
3570
+ childComponent,
3571
+ renderExtraPropertyFields && collectionValues && /* @__PURE__ */ jsx("div", {
3572
+ className: "col-span-12 mt-4 px-2",
3573
+ children: renderExtraPropertyFields({
3574
+ metadata: values.metadata ?? {},
3575
+ onMetadataChange: (key, value) => {
3576
+ const currentMetadata = values.metadata ?? {};
3577
+ setValues({
3578
+ ...values,
3579
+ metadata: {
3580
+ ...currentMetadata,
3581
+ [key]: value
3582
+ }
3583
+ });
3584
+ },
3585
+ property: toSerializableProperty(values),
3586
+ collection: toSerializableCollectionConfig(collectionValues)
3587
+ })
3588
+ }),
3589
+ /* @__PURE__ */ jsx("div", {
3590
+ className: "col-span-12",
3591
+ children: /* @__PURE__ */ jsx(AdvancedPropertyValidation, { disabled })
3592
+ })
3593
+ ]
3594
+ }),
3595
+ onDelete && /* @__PURE__ */ jsx(ConfirmationDialog, {
3596
+ open: deleteDialogOpen,
3597
+ onAccept: () => onDelete(values?.id, propertyNamespace),
3598
+ onCancel: () => setDeleteDialogOpen(false),
3599
+ title: /* @__PURE__ */ jsx("div", { children: "Delete this property?" }),
3600
+ body: /* @__PURE__ */ jsxs("div", { children: [
3601
+ " This will ",
3602
+ /* @__PURE__ */ jsx("b", { children: "not delete any data" }),
3603
+ ", only modify the collection."
3604
+ ] })
3605
+ })
3606
+ ] });
3607
+ }
3608
+ var idRegEx = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
3609
+ function validateId(value, existingPropertyKeys) {
3610
+ let error;
3611
+ if (!value) error = "You must specify an id for the field";
3612
+ if (value && !value.match(idRegEx)) error = "The id can only contain letters, numbers and underscores (_), and not start with a number";
3613
+ if (value && existingPropertyKeys && existingPropertyKeys.includes(value)) error = "There is another field with this ID already";
3614
+ return error;
3615
+ }
3616
+ function validateName(value) {
3617
+ let error;
3618
+ if (!value) error = "You must specify a title for the field";
3619
+ return error;
3620
+ }
3621
+ var WIDGET_TYPE_MAP = {
3622
+ text_field: "Text",
3623
+ multiline: "Text",
3624
+ markdown: "Text",
3625
+ url: "Text",
3626
+ email: "Text",
3627
+ switch: "Boolean",
3628
+ user_select: "Users",
3629
+ select: "Select",
3630
+ multi_select: "Select",
3631
+ number_input: "Number",
3632
+ number_select: "Select",
3633
+ multi_number_select: "Select",
3634
+ file_upload: "File",
3635
+ multi_file_upload: "File",
3636
+ relation: "Relation",
3637
+ reference: "Reference",
3638
+ multi_references: "Reference",
3639
+ date_time: "Date",
3640
+ group: "Group",
3641
+ key_value: "Group",
3642
+ repeat: "Array",
3643
+ custom_array: "Array",
3644
+ block: "Group",
3645
+ vector_input: "Number"
3646
+ };
3647
+ var WIDGET_BASE_TYPE_MAP = {
3648
+ text_field: "string",
3649
+ multiline: "string",
3650
+ markdown: "string",
3651
+ url: "string",
3652
+ email: "string",
3653
+ select: "string",
3654
+ multi_select: "string",
3655
+ file_upload: "string",
3656
+ multi_file_upload: "string",
3657
+ user_select: "string",
3658
+ number_input: "number",
3659
+ number_select: "number",
3660
+ multi_number_select: "number",
3661
+ switch: "boolean",
3662
+ date_time: "date",
3663
+ reference: "reference",
3664
+ multi_references: "reference",
3665
+ relation: "relation",
3666
+ group: "map",
3667
+ key_value: "map",
3668
+ block: "map",
3669
+ repeat: "array",
3670
+ custom_array: "array",
3671
+ vector_input: "vector"
3672
+ };
3673
+ function WidgetSelectView({ initialProperty, value, onValueChange, open, onOpenChange, disabled, showError, existing, propertyConfigs, inArray, propertyTypePresets, hiddenPropertyTypes, onPresetSelected }) {
3674
+ const allSupportedFields = Object.entries(supportedFields).concat(Object.entries(propertyConfigs));
3675
+ const filteredFields = hiddenPropertyTypes && !propertyTypePresets ? allSupportedFields.filter(([key]) => {
3676
+ const baseType = WIDGET_BASE_TYPE_MAP[key];
3677
+ return !baseType || !hiddenPropertyTypes.includes(baseType);
3678
+ }) : allSupportedFields;
3679
+ const displayedWidgets = (inArray ? filteredFields.filter(([_, propertyConfig]) => !isPropertyBuilder(propertyConfig.property) && propertyConfig.property?.type !== "array") : filteredFields).map(([key, propertyConfig]) => ({ [key]: propertyConfig })).reduce((a, b) => {
3680
+ return {
3681
+ ...a,
3682
+ ...b
3683
+ };
3684
+ }, {});
3685
+ const activePreset = useMemo(() => {
3686
+ if (!propertyTypePresets || !initialProperty) return void 0;
3687
+ return propertyTypePresets.find((p) => p.detect?.(toSerializableProperty(initialProperty)));
3688
+ }, [propertyTypePresets, initialProperty]);
3689
+ const key = value;
3690
+ const propertyConfig = key ? DEFAULT_FIELD_CONFIGS[key] ?? propertyConfigs[key] : void 0;
3691
+ const baseProperty = propertyConfig?.property;
3692
+ const baseFieldConfig = baseProperty && !isPropertyBuilder(baseProperty) ? getFieldConfig(baseProperty, propertyConfigs) : void 0;
3693
+ const computedFieldConfig = baseFieldConfig && propertyConfig ? mergeDeep(baseFieldConfig, propertyConfig) : propertyConfig;
3694
+ const groups = [...new Set(Object.keys(displayedWidgets).map((key) => {
3695
+ const group = WIDGET_TYPE_MAP[key];
3696
+ if (group) return group;
3697
+ return "Custom/Other";
3698
+ }))];
3699
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("div", {
3700
+ onClick: () => {
3701
+ if (!disabled) onOpenChange(!open, Boolean(value));
3702
+ },
3703
+ className: cls("select-none rounded-md text-sm py-2 px-1 transition-colors duration-200", !disabled && "hover:bg-surface-50 dark:hover:bg-surface-800 cursor-pointer", "relative flex items-center mb-2"),
3704
+ children: [!value && /* @__PURE__ */ jsx("em", { children: "Select a property widget" }), value && computedFieldConfig && /* @__PURE__ */ jsxs("div", {
3705
+ className: cls("flex items-center"),
3706
+ children: [/* @__PURE__ */ jsx("div", {
3707
+ className: "mr-4",
3708
+ children: /* @__PURE__ */ jsx(PropertyConfigBadge, { propertyConfig: computedFieldConfig })
3709
+ }), /* @__PURE__ */ jsxs("div", {
3710
+ className: "flex flex-col items-start text-left",
3711
+ children: [/* @__PURE__ */ jsx("div", {
3712
+ className: "font-semibold text-text-primary dark:text-text-primary-dark tracking-tight",
3713
+ children: computedFieldConfig.name
3714
+ }), /* @__PURE__ */ jsx(Typography, {
3715
+ variant: "caption",
3716
+ className: "text-text-secondary dark:text-text-secondary-dark mt-0.5",
3717
+ children: computedFieldConfig.description
3718
+ })]
3719
+ })]
3720
+ })]
3721
+ }), /* @__PURE__ */ jsxs(Dialog, {
3722
+ open,
3723
+ onOpenChange: (open) => onOpenChange(open, Boolean(value)),
3724
+ maxWidth: "4xl",
3725
+ children: [/* @__PURE__ */ jsx(DialogTitle, { children: propertyTypePresets ? "Select a property type" : "Select a property widget" }), /* @__PURE__ */ jsx(DialogContent, { children: propertyTypePresets ? /* @__PURE__ */ jsx("div", {
3726
+ className: "grid grid-cols-1 md:grid-cols-2 gap-x-4 gap-y-2 mt-4",
3727
+ children: propertyTypePresets.map((preset) => /* @__PURE__ */ jsx(Card, {
3728
+ onClick: () => {
3729
+ onPresetSelected?.(preset);
3730
+ onOpenChange(false, true);
3731
+ },
3732
+ className: cls("flex flex-row items-center px-4 py-2 m-1", activePreset?.id === preset.id && "ring-2 ring-primary"),
3733
+ children: /* @__PURE__ */ jsxs("div", {
3734
+ className: cls("flex flex-row items-center text-base min-h-[48px]"),
3735
+ children: [preset.icon && /* @__PURE__ */ jsx("div", {
3736
+ className: "mr-4 text-2xl",
3737
+ children: typeof preset.icon === "string" ? preset.icon : preset.icon
3738
+ }), /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Typography, {
3739
+ variant: "label",
3740
+ children: preset.label
3741
+ }) })]
3742
+ })
3743
+ }, preset.id))
3744
+ }) : /* @__PURE__ */ jsx("div", { children: groups.map((group) => {
3745
+ return /* @__PURE__ */ jsxs("div", {
3746
+ className: "mt-4",
3747
+ children: [/* @__PURE__ */ jsx(Typography, {
3748
+ variant: "label",
3749
+ children: group
3750
+ }), /* @__PURE__ */ jsx("div", {
3751
+ className: "grid grid-cols-1 md:grid-cols-2 gap-x-4 gap-y-2 mt-4",
3752
+ children: Object.entries(displayedWidgets).map(([key, propertyConfig]) => {
3753
+ if (WIDGET_TYPE_MAP[key] === group) return /* @__PURE__ */ jsx(WidgetSelectViewItem, {
3754
+ initialProperty,
3755
+ onClick: () => {
3756
+ onValueChange(key);
3757
+ onOpenChange(false, true);
3758
+ },
3759
+ propertyConfig,
3760
+ existing
3761
+ }, key);
3762
+ return null;
3763
+ })
3764
+ })]
3765
+ }, group);
3766
+ }) }) })]
3767
+ })] });
3768
+ }
3769
+ function WidgetSelectViewItem({ onClick, initialProperty, propertyConfig, existing }) {
3770
+ const baseProperty = propertyConfig.property;
3771
+ const shouldWarnChangingtype = existing && !isPropertyBuilder(baseProperty) && baseProperty.type !== initialProperty?.type;
3772
+ return /* @__PURE__ */ jsx(Card, {
3773
+ onClick,
3774
+ className: "flex flex-row items-center px-4 py-2 m-1",
3775
+ children: /* @__PURE__ */ jsxs("div", {
3776
+ className: cls("flex flex-row items-center text-base min-h-[48px]"),
3777
+ children: [/* @__PURE__ */ jsx("div", {
3778
+ className: "mr-8",
3779
+ children: /* @__PURE__ */ jsx(PropertyConfigBadge, {
3780
+ propertyConfig,
3781
+ disabled: shouldWarnChangingtype
3782
+ })
3783
+ }), /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsxs("div", {
3784
+ className: "flex flex-row gap-2 items-center",
3785
+ children: [shouldWarnChangingtype && /* @__PURE__ */ jsx(Tooltip, {
3786
+ title: "This widget uses a different data type than the initially selected widget. This can cause errors with existing data.",
3787
+ children: /* @__PURE__ */ jsx(AlertTriangleIcon, {
3788
+ size: iconSize.smallest,
3789
+ className: "w-4"
3790
+ })
3791
+ }), /* @__PURE__ */ jsx(Typography, {
3792
+ variant: "label",
3793
+ color: shouldWarnChangingtype ? "secondary" : void 0,
3794
+ children: propertyConfig.name
3795
+ })]
3796
+ }), /* @__PURE__ */ jsx(Typography, {
3797
+ variant: "caption",
3798
+ color: "secondary",
3799
+ className: "max-w-sm",
3800
+ children: propertyConfig.description
3801
+ })] })]
3802
+ })
3803
+ });
3804
+ }
3805
+ //#endregion
3806
+ export { updatePropertyFromWidget as a, useAIModifiedPaths as c, supportedFields as i, useSafeSnackbarController as l, PropertyForm as n, PropertyTree as o, PropertyFormDialog as r, AIModifiedPathsProvider as s, PropertyEditView_exports as t };
3807
+
3808
+ //# sourceMappingURL=PropertyEditView-h0N-AMCY.js.map