@rebasepro/cms 0.23.0 → 0.24.1-canary.g56af4a4

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