@rebasepro/cms 0.24.0 → 0.24.1-canary.g19596ef

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (816) hide show
  1. package/README.md +3 -1
  2. package/dist/collection_editor/CollectionEditorDialogsContext.js +10 -0
  3. package/dist/collection_editor/CollectionEditorDialogsContext.js.map +1 -0
  4. package/dist/collection_editor/ConfigControllerProvider.js +274 -0
  5. package/dist/collection_editor/ConfigControllerProvider.js.map +1 -0
  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.js +130 -0
  12. package/dist/collection_editor/liveSchemaClient.js.map +1 -0
  13. package/dist/collection_editor/relation_kinds.js +74 -0
  14. package/dist/collection_editor/relation_kinds.js.map +1 -0
  15. package/dist/collection_editor/serializable_types.d.ts +4 -1
  16. package/dist/collection_editor/serializable_utils.js +504 -0
  17. package/dist/collection_editor/serializable_utils.js.map +1 -0
  18. package/dist/collection_editor/ui/EditorCollectionAction.js +37 -0
  19. package/dist/collection_editor/ui/EditorCollectionAction.js.map +1 -0
  20. package/dist/collection_editor/ui/MissingReferenceWidget.js +39 -0
  21. package/dist/collection_editor/ui/MissingReferenceWidget.js.map +1 -0
  22. package/dist/collection_editor/ui/collection_editor/AICollectionGeneratorPopover.js +160 -0
  23. package/dist/collection_editor/ui/collection_editor/AICollectionGeneratorPopover.js.map +1 -0
  24. package/dist/collection_editor/ui/collection_editor/AIModifiedPathsContext.js +61 -0
  25. package/dist/collection_editor/ui/collection_editor/AIModifiedPathsContext.js.map +1 -0
  26. package/dist/collection_editor/ui/collection_editor/CollectionEditorDialog.js +731 -0
  27. package/dist/collection_editor/ui/collection_editor/CollectionEditorDialog.js.map +1 -0
  28. package/dist/collection_editor/ui/collection_editor/CollectionEditorWelcomeView.js +220 -0
  29. package/dist/collection_editor/ui/collection_editor/CollectionEditorWelcomeView.js.map +1 -0
  30. package/dist/collection_editor/ui/collection_editor/CollectionJsonImportDialog.js +160 -0
  31. package/dist/collection_editor/ui/collection_editor/CollectionJsonImportDialog.js.map +1 -0
  32. package/dist/collection_editor/ui/collection_editor/CollectionPropertiesEditorForm.js +394 -0
  33. package/dist/collection_editor/ui/collection_editor/CollectionPropertiesEditorForm.js.map +1 -0
  34. package/dist/collection_editor/ui/collection_editor/CollectionRLSTab.js +616 -0
  35. package/dist/collection_editor/ui/collection_editor/CollectionRLSTab.js.map +1 -0
  36. package/dist/collection_editor/ui/collection_editor/CollectionStudioView.js +68 -0
  37. package/dist/collection_editor/ui/collection_editor/CollectionStudioView.js.map +1 -0
  38. package/dist/collection_editor/ui/collection_editor/CollectionYupValidation.js +11 -0
  39. package/dist/collection_editor/ui/collection_editor/CollectionYupValidation.js.map +1 -0
  40. package/dist/collection_editor/ui/collection_editor/CollectionsStudioView.js +148 -0
  41. package/dist/collection_editor/ui/collection_editor/CollectionsStudioView.js.map +1 -0
  42. package/dist/collection_editor/ui/collection_editor/DisplaySettingsForm.js +244 -0
  43. package/dist/collection_editor/ui/collection_editor/DisplaySettingsForm.js.map +1 -0
  44. package/dist/collection_editor/ui/collection_editor/EnumForm.js +222 -0
  45. package/dist/collection_editor/ui/collection_editor/EnumForm.js.map +1 -0
  46. package/dist/collection_editor/ui/collection_editor/GeneralSettingsForm.js +204 -0
  47. package/dist/collection_editor/ui/collection_editor/GeneralSettingsForm.js.map +1 -0
  48. package/dist/collection_editor/ui/collection_editor/GetCodeDialog.js +108 -0
  49. package/dist/collection_editor/ui/collection_editor/GetCodeDialog.js.map +1 -0
  50. package/dist/collection_editor/ui/collection_editor/KanbanConfigSection.js +163 -0
  51. package/dist/collection_editor/ui/collection_editor/KanbanConfigSection.js.map +1 -0
  52. package/dist/collection_editor/ui/collection_editor/LayoutModeSwitch.js +59 -0
  53. package/dist/collection_editor/ui/collection_editor/LayoutModeSwitch.js.map +1 -0
  54. package/dist/collection_editor/ui/collection_editor/PropertyEditView.js +640 -0
  55. package/dist/collection_editor/ui/collection_editor/PropertyEditView.js.map +1 -0
  56. package/dist/collection_editor/ui/collection_editor/PropertyFieldPreview.js +141 -0
  57. package/dist/collection_editor/ui/collection_editor/PropertyFieldPreview.js.map +1 -0
  58. package/dist/collection_editor/ui/collection_editor/PropertyTree.js +210 -0
  59. package/dist/collection_editor/ui/collection_editor/PropertyTree.js.map +1 -0
  60. package/dist/collection_editor/ui/collection_editor/RouterCollectionStudioView.js +31 -0
  61. package/dist/collection_editor/ui/collection_editor/RouterCollectionStudioView.js.map +1 -0
  62. package/dist/collection_editor/ui/collection_editor/RouterCollectionsStudioView.js +25 -0
  63. package/dist/collection_editor/ui/collection_editor/RouterCollectionsStudioView.js.map +1 -0
  64. package/dist/{SchemaChangeDialog-CcFSXvkK.js → collection_editor/ui/collection_editor/SchemaChangeDialog.js} +42 -59
  65. package/dist/collection_editor/ui/collection_editor/SchemaChangeDialog.js.map +1 -0
  66. package/dist/collection_editor/ui/collection_editor/SwitchControl.js +24 -0
  67. package/dist/collection_editor/ui/collection_editor/SwitchControl.js.map +1 -0
  68. package/dist/collection_editor/ui/collection_editor/ViewModeSwitch.js +66 -0
  69. package/dist/collection_editor/ui/collection_editor/ViewModeSwitch.js.map +1 -0
  70. package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.js +61 -0
  71. package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.js.map +1 -0
  72. package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportMapping.js +188 -0
  73. package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportMapping.js.map +1 -0
  74. package/dist/collection_editor/ui/collection_editor/import/clean_import_data.d.ts +12 -0
  75. package/dist/collection_editor/ui/collection_editor/import/clean_import_data.js +74 -0
  76. package/dist/collection_editor/ui/collection_editor/import/clean_import_data.js.map +1 -0
  77. package/dist/collection_editor/ui/collection_editor/properties/BlockPropertyField.js +100 -0
  78. package/dist/collection_editor/ui/collection_editor/properties/BlockPropertyField.js.map +1 -0
  79. package/dist/collection_editor/ui/collection_editor/properties/BooleanPropertyField.js +34 -0
  80. package/dist/collection_editor/ui/collection_editor/properties/BooleanPropertyField.js.map +1 -0
  81. package/dist/collection_editor/ui/collection_editor/properties/CommonPropertyFields.js +75 -0
  82. package/dist/collection_editor/ui/collection_editor/properties/CommonPropertyFields.js.map +1 -0
  83. package/dist/collection_editor/ui/collection_editor/properties/DateTimePropertyField.js +338 -0
  84. package/dist/collection_editor/ui/collection_editor/properties/DateTimePropertyField.js.map +1 -0
  85. package/dist/collection_editor/ui/collection_editor/properties/EnumPropertyField.js +83 -0
  86. package/dist/collection_editor/ui/collection_editor/properties/EnumPropertyField.js.map +1 -0
  87. package/dist/collection_editor/ui/collection_editor/properties/KeyValuePropertyField.js +15 -0
  88. package/dist/collection_editor/ui/collection_editor/properties/KeyValuePropertyField.js.map +1 -0
  89. package/dist/collection_editor/ui/collection_editor/properties/MapPropertyField.js +121 -0
  90. package/dist/collection_editor/ui/collection_editor/properties/MapPropertyField.js.map +1 -0
  91. package/dist/collection_editor/ui/collection_editor/properties/MarkdownPropertyField.js +127 -0
  92. package/dist/collection_editor/ui/collection_editor/properties/MarkdownPropertyField.js.map +1 -0
  93. package/dist/collection_editor/ui/collection_editor/properties/NumberPropertyField.js +151 -0
  94. package/dist/collection_editor/ui/collection_editor/properties/NumberPropertyField.js.map +1 -0
  95. package/dist/collection_editor/ui/collection_editor/properties/ReferencePropertyField.js +77 -0
  96. package/dist/collection_editor/ui/collection_editor/properties/ReferencePropertyField.js.map +1 -0
  97. package/dist/collection_editor/ui/collection_editor/properties/RelationPropertyField.js +254 -0
  98. package/dist/collection_editor/ui/collection_editor/properties/RelationPropertyField.js.map +1 -0
  99. package/dist/collection_editor/ui/collection_editor/properties/RepeatPropertyField.js +71 -0
  100. package/dist/collection_editor/ui/collection_editor/properties/RepeatPropertyField.js.map +1 -0
  101. package/dist/collection_editor/ui/collection_editor/properties/StoragePropertyField.js +356 -0
  102. package/dist/collection_editor/ui/collection_editor/properties/StoragePropertyField.js.map +1 -0
  103. package/dist/collection_editor/ui/collection_editor/properties/StringPropertyField.js +173 -0
  104. package/dist/collection_editor/ui/collection_editor/properties/StringPropertyField.js.map +1 -0
  105. package/dist/collection_editor/ui/collection_editor/properties/UrlPropertyField.js +79 -0
  106. package/dist/collection_editor/ui/collection_editor/properties/UrlPropertyField.js.map +1 -0
  107. package/dist/collection_editor/ui/collection_editor/properties/VectorPropertyField.js +34 -0
  108. package/dist/collection_editor/ui/collection_editor/properties/VectorPropertyField.js.map +1 -0
  109. package/dist/collection_editor/ui/collection_editor/properties/advanced/AdvancedPropertyValidation.js +47 -0
  110. package/dist/collection_editor/ui/collection_editor/properties/advanced/AdvancedPropertyValidation.js.map +1 -0
  111. package/dist/collection_editor/ui/collection_editor/properties/validation/ArrayPropertyValidation.js +47 -0
  112. package/dist/collection_editor/ui/collection_editor/properties/validation/ArrayPropertyValidation.js.map +1 -0
  113. package/dist/collection_editor/ui/collection_editor/properties/validation/GeneralPropertyValidation.js +62 -0
  114. package/dist/collection_editor/ui/collection_editor/properties/validation/GeneralPropertyValidation.js.map +1 -0
  115. package/dist/collection_editor/ui/collection_editor/properties/validation/NumberPropertyValidation.js +119 -0
  116. package/dist/collection_editor/ui/collection_editor/properties/validation/NumberPropertyValidation.js.map +1 -0
  117. package/dist/collection_editor/ui/collection_editor/properties/validation/StringPropertyValidation.d.ts +10 -0
  118. package/dist/collection_editor/ui/collection_editor/properties/validation/StringPropertyValidation.js +178 -0
  119. package/dist/collection_editor/ui/collection_editor/properties/validation/StringPropertyValidation.js.map +1 -0
  120. package/dist/collection_editor/ui/collection_editor/properties/validation/ValidationPanel.js +23 -0
  121. package/dist/collection_editor/ui/collection_editor/properties/validation/ValidationPanel.js.map +1 -0
  122. package/dist/collection_editor/ui/collection_editor/templates/blog_template.js +116 -0
  123. package/dist/collection_editor/ui/collection_editor/templates/blog_template.js.map +1 -0
  124. package/dist/collection_editor/ui/collection_editor/templates/pages_template.js +182 -0
  125. package/dist/collection_editor/ui/collection_editor/templates/pages_template.js.map +1 -0
  126. package/dist/collection_editor/ui/collection_editor/templates/products_template.js +87 -0
  127. package/dist/collection_editor/ui/collection_editor/templates/products_template.js.map +1 -0
  128. package/dist/collection_editor/ui/collection_editor/templates/users_template.js +46 -0
  129. package/dist/collection_editor/ui/collection_editor/templates/users_template.js.map +1 -0
  130. package/dist/collection_editor/ui/collection_editor/util.js +20 -0
  131. package/dist/collection_editor/ui/collection_editor/util.js.map +1 -0
  132. package/dist/collection_editor/ui/collection_editor/utils/strings.js +2 -0
  133. package/dist/collection_editor/ui/collection_editor/utils/supported_fields.js +37 -0
  134. package/dist/collection_editor/ui/collection_editor/utils/supported_fields.js.map +1 -0
  135. package/dist/collection_editor/ui/collection_editor/utils/update_property_for_widget.js +192 -0
  136. package/dist/collection_editor/ui/collection_editor/utils/update_property_for_widget.js.map +1 -0
  137. package/dist/collection_editor/useCollectionEditorController.js +12 -0
  138. package/dist/collection_editor/useCollectionEditorController.js.map +1 -0
  139. package/dist/collection_editor/useCollectionsConfigController.js +12 -0
  140. package/dist/collection_editor/useCollectionsConfigController.js.map +1 -0
  141. package/dist/collection_editor/useJsonCollectionsConfigController.js +191 -0
  142. package/dist/collection_editor/useJsonCollectionsConfigController.js.map +1 -0
  143. package/dist/collection_editor/useLiveSchemaEditing.js +214 -0
  144. package/dist/collection_editor/useLiveSchemaEditing.js.map +1 -0
  145. package/dist/collection_editor/useLocalCollectionsConfigController.js +228 -0
  146. package/dist/collection_editor/useLocalCollectionsConfigController.js.map +1 -0
  147. package/dist/collection_editor/useSafeSnackbarController.js +13 -0
  148. package/dist/collection_editor/useSafeSnackbarController.js.map +1 -0
  149. package/dist/collection_editor/validateCollectionJson.js +289 -0
  150. package/dist/collection_editor/validateCollectionJson.js.map +1 -0
  151. package/dist/collection_editor_ui.js +7 -33
  152. package/dist/components/AdditionalFieldValue.js +60 -0
  153. package/dist/components/AdditionalFieldValue.js.map +1 -0
  154. package/dist/components/AdminModeSyncer.js +41 -0
  155. package/dist/components/AdminModeSyncer.js.map +1 -0
  156. package/dist/components/ArrayContainer.d.ts +8 -2
  157. package/dist/components/ArrayContainer.js +363 -0
  158. package/dist/components/ArrayContainer.js.map +1 -0
  159. package/dist/components/ClearFilterSortButton.js +33 -0
  160. package/dist/components/ClearFilterSortButton.js.map +1 -0
  161. package/dist/components/CollectionEditorDialogs.js +49 -0
  162. package/dist/components/CollectionEditorDialogs.js.map +1 -0
  163. package/dist/components/CollectionPanel.d.ts +26 -5
  164. package/dist/components/CollectionPanel.js +142 -0
  165. package/dist/components/CollectionPanel.js.map +1 -0
  166. package/dist/components/CollectionTableBinding/CollectionRowActions.js +165 -0
  167. package/dist/components/CollectionTableBinding/CollectionRowActions.js.map +1 -0
  168. package/dist/components/CollectionTableBinding/CollectionTableBinding.js +329 -0
  169. package/dist/components/CollectionTableBinding/CollectionTableBinding.js.map +1 -0
  170. package/dist/components/CollectionTableBinding/PropertyTableCell.js +311 -0
  171. package/dist/components/CollectionTableBinding/PropertyTableCell.js.map +1 -0
  172. package/dist/components/CollectionTableBinding/column_utils.js +85 -0
  173. package/dist/components/CollectionTableBinding/column_utils.js.map +1 -0
  174. package/dist/components/CollectionTableBinding/fields/CompactEntityCellField.js +45 -0
  175. package/dist/components/CollectionTableBinding/fields/CompactEntityCellField.js.map +1 -0
  176. package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.js +66 -0
  177. package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.js.map +1 -0
  178. package/dist/components/CollectionTableBinding/fields/TableReferenceField.js +86 -0
  179. package/dist/components/CollectionTableBinding/fields/TableReferenceField.js.map +1 -0
  180. package/dist/components/CollectionTableBinding/fields/TableRelationField.js +93 -0
  181. package/dist/components/CollectionTableBinding/fields/TableRelationField.js.map +1 -0
  182. package/dist/components/CollectionTableBinding/fields/TableRelationSelectorField.js +33 -0
  183. package/dist/components/CollectionTableBinding/fields/TableRelationSelectorField.js.map +1 -0
  184. package/dist/components/CollectionTableBinding/fields/TableStorageUpload.js +171 -0
  185. package/dist/components/CollectionTableBinding/fields/TableStorageUpload.js.map +1 -0
  186. package/dist/components/CollectionTableBinding/fields/VirtualTableSelect.js +91 -0
  187. package/dist/components/CollectionTableBinding/fields/VirtualTableSelect.js.map +1 -0
  188. package/dist/components/CollectionTableBinding/fields/VirtualTableUserSelect.js +36 -0
  189. package/dist/components/CollectionTableBinding/fields/VirtualTableUserSelect.js.map +1 -0
  190. package/dist/components/CollectionTableBinding/index.js +6 -0
  191. package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.js +50 -0
  192. package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.js.map +1 -0
  193. package/dist/components/CollectionTableBinding/internal/EntityTableCell.d.ts +2 -0
  194. package/dist/components/CollectionTableBinding/internal/EntityTableCell.js +223 -0
  195. package/dist/components/CollectionTableBinding/internal/EntityTableCell.js.map +1 -0
  196. package/dist/components/CollectionTableBinding/internal/EntityTableCellActions.js +58 -0
  197. package/dist/components/CollectionTableBinding/internal/EntityTableCellActions.js.map +1 -0
  198. package/dist/components/CollectionTableBinding/internal/TableCellOpener.js +53 -0
  199. package/dist/components/CollectionTableBinding/internal/TableCellOpener.js.map +1 -0
  200. package/dist/components/CollectionTableBinding/internal/common.js +40 -0
  201. package/dist/components/CollectionTableBinding/internal/common.js.map +1 -0
  202. package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js +270 -0
  203. package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js.map +1 -0
  204. package/dist/components/CollectionTableBinding/internal/popup_field/useDraggable.js +68 -0
  205. package/dist/components/CollectionTableBinding/internal/popup_field/useDraggable.js.map +1 -0
  206. package/dist/components/CollectionTableBinding/internal/popup_field/useWindowSize.js +24 -0
  207. package/dist/components/CollectionTableBinding/internal/popup_field/useWindowSize.js.map +1 -0
  208. package/dist/components/CollectionTableBinding/table_bindings.js +306 -0
  209. package/dist/components/CollectionTableBinding/table_bindings.js.map +1 -0
  210. package/dist/components/CollectionViewBinding/BoardCardBinding.js +160 -0
  211. package/dist/components/CollectionViewBinding/BoardCardBinding.js.map +1 -0
  212. package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.js +471 -0
  213. package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.js.map +1 -0
  214. package/dist/components/CollectionViewBinding/CollectionCardViewBinding.js +108 -0
  215. package/dist/components/CollectionViewBinding/CollectionCardViewBinding.js.map +1 -0
  216. package/dist/components/CollectionViewBinding/CollectionListViewBinding.js +988 -0
  217. package/dist/components/CollectionViewBinding/CollectionListViewBinding.js.map +1 -0
  218. package/dist/components/CollectionViewBinding/CollectionViewActions.js +146 -0
  219. package/dist/components/CollectionViewBinding/CollectionViewActions.js.map +1 -0
  220. package/dist/components/CollectionViewBinding/CollectionViewBinding.js +1209 -0
  221. package/dist/components/CollectionViewBinding/CollectionViewBinding.js.map +1 -0
  222. package/dist/components/CollectionViewBinding/CollectionViewStartActions.js +133 -0
  223. package/dist/components/CollectionViewBinding/CollectionViewStartActions.js.map +1 -0
  224. package/dist/components/CollectionViewBinding/EntityCardBinding.js +133 -0
  225. package/dist/components/CollectionViewBinding/EntityCardBinding.js.map +1 -0
  226. package/dist/components/CollectionViewBinding/FilterPresetsButton.js +203 -0
  227. package/dist/components/CollectionViewBinding/FilterPresetsButton.js.map +1 -0
  228. package/dist/components/CollectionViewBinding/FiltersDialog.js +148 -0
  229. package/dist/components/CollectionViewBinding/FiltersDialog.js.map +1 -0
  230. package/dist/components/CollectionViewBinding/SearchExplanation.js +86 -0
  231. package/dist/components/CollectionViewBinding/SearchExplanation.js.map +1 -0
  232. package/dist/components/CollectionViewBinding/SearchHighlight.js +262 -0
  233. package/dist/components/CollectionViewBinding/SearchHighlight.js.map +1 -0
  234. package/dist/components/CollectionViewBinding/SlotValue.js +117 -0
  235. package/dist/components/CollectionViewBinding/SlotValue.js.map +1 -0
  236. package/dist/components/CollectionViewBinding/SortButton.js +214 -0
  237. package/dist/components/CollectionViewBinding/SortButton.js.map +1 -0
  238. package/dist/components/CollectionViewBinding/SplitListCloseButton.js +41 -0
  239. package/dist/components/CollectionViewBinding/SplitListCloseButton.js.map +1 -0
  240. package/dist/components/CollectionViewBinding/SplitListShowButton.js +29 -0
  241. package/dist/components/CollectionViewBinding/SplitListShowButton.js.map +1 -0
  242. package/dist/components/CollectionViewBinding/SplitListView.js +311 -0
  243. package/dist/components/CollectionViewBinding/SplitListView.js.map +1 -0
  244. package/dist/components/CollectionViewBinding/SplitViewContext.js +21 -0
  245. package/dist/components/CollectionViewBinding/SplitViewContext.js.map +1 -0
  246. package/dist/components/CollectionViewBinding/ViewModeToggle.js +150 -0
  247. package/dist/components/CollectionViewBinding/ViewModeToggle.js.map +1 -0
  248. package/dist/components/CollectionViewBinding/hooks/useCollectionInlineEditor.js +49 -0
  249. package/dist/components/CollectionViewBinding/hooks/useCollectionInlineEditor.js.map +1 -0
  250. package/dist/components/CollectionViewBinding/hooks/useKanbanDragAndDrop.js +122 -0
  251. package/dist/components/CollectionViewBinding/hooks/useKanbanDragAndDrop.js.map +1 -0
  252. package/dist/components/CollectionViewBinding/useBoardDataController.js +530 -0
  253. package/dist/components/CollectionViewBinding/useBoardDataController.js.map +1 -0
  254. package/dist/components/CollectionViewBinding/usePreviewSlots.d.ts +4 -1
  255. package/dist/components/CollectionViewBinding/usePreviewSlots.js +384 -0
  256. package/dist/components/CollectionViewBinding/usePreviewSlots.js.map +1 -0
  257. package/dist/components/CollectionViewBinding/useSelectionController.js +104 -0
  258. package/dist/components/CollectionViewBinding/useSelectionController.js.map +1 -0
  259. package/dist/components/CollectionViewBinding/utils.js +21 -0
  260. package/dist/components/CollectionViewBinding/utils.js.map +1 -0
  261. package/dist/components/CollectionsProvider.d.ts +44 -0
  262. package/dist/components/CollectionsProvider.js +137 -0
  263. package/dist/components/CollectionsProvider.js.map +1 -0
  264. package/dist/components/CollectionsScopeContext.d.ts +18 -0
  265. package/dist/components/CollectionsScopeContext.js +25 -0
  266. package/dist/components/CollectionsScopeContext.js.map +1 -0
  267. package/dist/components/DefaultAppBar.js +179 -0
  268. package/dist/components/DefaultAppBar.js.map +1 -0
  269. package/dist/components/DefaultDrawer.js +364 -0
  270. package/dist/components/DefaultDrawer.js.map +1 -0
  271. package/dist/components/DeleteEntityDialog.js +256 -0
  272. package/dist/components/DeleteEntityDialog.js.map +1 -0
  273. package/dist/components/DetailViewBinding.js +504 -0
  274. package/dist/components/DetailViewBinding.js.map +1 -0
  275. package/dist/components/DrawerNavigationGroup.js +74 -0
  276. package/dist/components/DrawerNavigationGroup.js.map +1 -0
  277. package/dist/components/DrawerNavigationItem.d.ts +8 -0
  278. package/dist/components/DrawerNavigationItem.js +45 -0
  279. package/dist/components/DrawerNavigationItem.js.map +1 -0
  280. package/dist/components/EditFormActions.js +210 -0
  281. package/dist/components/EditFormActions.js.map +1 -0
  282. package/dist/components/EditViewBinding.js +802 -0
  283. package/dist/components/EditViewBinding.js.map +1 -0
  284. package/dist/components/EntityDisplayHeader.js +139 -0
  285. package/dist/components/EntityDisplayHeader.js.map +1 -0
  286. package/dist/components/EntityFormPanel.d.ts +58 -0
  287. package/dist/components/EntityFormPanel.js +126 -0
  288. package/dist/components/EntityFormPanel.js.map +1 -0
  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.js +27 -0
  320. package/dist/components/NavigationLoadingErrorView.js.map +1 -0
  321. package/dist/components/PickerTrigger.js +27 -0
  322. package/dist/components/PickerTrigger.js.map +1 -0
  323. package/dist/components/PropertyCollectionView.js +215 -0
  324. package/dist/components/PropertyCollectionView.js.map +1 -0
  325. package/dist/components/PropertyConfigBadge.js +19 -0
  326. package/dist/components/PropertyConfigBadge.js.map +1 -0
  327. package/dist/components/PropertyKeyHint.js +58 -0
  328. package/dist/components/PropertyKeyHint.js.map +1 -0
  329. package/dist/components/RebaseAuthGate.js +35 -0
  330. package/dist/components/RebaseAuthGate.js.map +1 -0
  331. package/dist/components/RebaseCMS.js +44 -0
  332. package/dist/components/RebaseCMS.js.map +1 -0
  333. package/dist/components/RebaseLayout.js +59 -0
  334. package/dist/components/RebaseLayout.js.map +1 -0
  335. package/dist/components/RebaseNavigation.js +215 -0
  336. package/dist/components/RebaseNavigation.js.map +1 -0
  337. package/dist/components/RebaseRouteDefs.js +96 -0
  338. package/dist/components/RebaseRouteDefs.js.map +1 -0
  339. package/dist/components/RebaseShell.js +50 -0
  340. package/dist/components/RebaseShell.js.map +1 -0
  341. package/dist/components/ReferenceTable/SelectionTableBinding.js +224 -0
  342. package/dist/components/ReferenceTable/SelectionTableBinding.js.map +1 -0
  343. package/dist/components/ReferenceWidget.js +100 -0
  344. package/dist/components/ReferenceWidget.js.map +1 -0
  345. package/dist/components/RelationSelector.js +625 -0
  346. package/dist/components/RelationSelector.js.map +1 -0
  347. package/dist/components/SearchIconsView.js +52 -0
  348. package/dist/components/SearchIconsView.js.map +1 -0
  349. package/dist/components/SelectableTable/SelectableTable.d.ts +1 -1
  350. package/dist/components/SelectableTable/SelectableTable.js +158 -0
  351. package/dist/components/SelectableTable/SelectableTable.js.map +1 -0
  352. package/dist/components/SelectableTable/SelectableTableContext.js +8 -0
  353. package/dist/components/SelectableTable/SelectableTableContext.js.map +1 -0
  354. package/dist/components/SelectableTable/SelectionStore.js +29 -0
  355. package/dist/components/SelectableTable/SelectionStore.js.map +1 -0
  356. package/dist/components/SelectableTable/filters/BooleanFilterField.js +28 -0
  357. package/dist/components/SelectableTable/filters/BooleanFilterField.js.map +1 -0
  358. package/dist/components/SelectableTable/filters/DateTimeFilterField.d.ts +2 -1
  359. package/dist/components/SelectableTable/filters/DateTimeFilterField.js +93 -0
  360. package/dist/components/SelectableTable/filters/DateTimeFilterField.js.map +1 -0
  361. package/dist/components/SelectableTable/filters/FilterFieldBinding.js +132 -0
  362. package/dist/components/SelectableTable/filters/FilterFieldBinding.js.map +1 -0
  363. package/dist/components/SelectableTable/filters/ReferenceFilterField.js +157 -0
  364. package/dist/components/SelectableTable/filters/ReferenceFilterField.js.map +1 -0
  365. package/dist/components/SelectableTable/filters/RelationFilterField.js +169 -0
  366. package/dist/components/SelectableTable/filters/RelationFilterField.js.map +1 -0
  367. package/dist/components/SelectableTable/filters/StringNumberFilterField.js +181 -0
  368. package/dist/components/SelectableTable/filters/StringNumberFilterField.js.map +1 -0
  369. package/dist/components/SelectableTable/filters/null_filter.js +36 -0
  370. package/dist/components/SelectableTable/filters/null_filter.js.map +1 -0
  371. package/dist/components/SideDialogs.js +149 -0
  372. package/dist/components/SideDialogs.js.map +1 -0
  373. package/dist/components/SidePanelBinding.js +287 -0
  374. package/dist/components/SidePanelBinding.js.map +1 -0
  375. package/dist/components/SidePanelProvider.js +69 -0
  376. package/dist/components/SidePanelProvider.js.map +1 -0
  377. package/dist/components/UserSelector.d.ts +2 -0
  378. package/dist/components/UserSelector.js +418 -0
  379. package/dist/components/UserSelector.js.map +1 -0
  380. package/dist/components/admin/CreationResultDialog.js +118 -0
  381. package/dist/components/admin/CreationResultDialog.js.map +1 -0
  382. package/dist/components/app/AppBar.js +14 -0
  383. package/dist/components/app/AppBar.js.map +1 -0
  384. package/dist/components/app/Drawer.js +26 -0
  385. package/dist/components/app/Drawer.js.map +1 -0
  386. package/dist/components/app/Scaffold.js +229 -0
  387. package/dist/components/app/Scaffold.js.map +1 -0
  388. package/dist/components/app/useApp.js +24 -0
  389. package/dist/components/app/useApp.js.map +1 -0
  390. package/dist/components/common/ActionMenuLabel.js +30 -0
  391. package/dist/components/common/ActionMenuLabel.js.map +1 -0
  392. package/dist/components/common/default_entity_actions.js +590 -0
  393. package/dist/components/common/default_entity_actions.js.map +1 -0
  394. package/dist/components/drawer_expansion.d.ts +25 -0
  395. package/dist/components/drawer_expansion.js +44 -0
  396. package/dist/components/drawer_expansion.js.map +1 -0
  397. package/dist/components/field_configs.d.ts +2 -2
  398. package/dist/components/field_configs.js +431 -0
  399. package/dist/components/field_configs.js.map +1 -0
  400. package/dist/components/field_ids.d.ts +11 -0
  401. package/dist/components/field_ids.js +58 -0
  402. package/dist/components/field_ids.js.map +1 -0
  403. package/dist/components/history/EntityHistoryEntry.js +151 -0
  404. package/dist/components/history/EntityHistoryEntry.js.map +1 -0
  405. package/dist/components/history/EntityHistoryView.js +157 -0
  406. package/dist/components/history/EntityHistoryView.js.map +1 -0
  407. package/dist/components/history/UserChip.js +21 -0
  408. package/dist/components/history/UserChip.js.map +1 -0
  409. package/dist/components/history/index.js +4 -0
  410. package/dist/components/index.d.ts +2 -0
  411. package/dist/components/lazy_record_views.d.ts +10 -0
  412. package/dist/components/lazy_record_views.js +57 -0
  413. package/dist/components/lazy_record_views.js.map +1 -0
  414. package/dist/contexts/BreacrumbsContext.js +28 -0
  415. package/dist/contexts/BreacrumbsContext.js.map +1 -0
  416. package/dist/contexts/EditorAIControllerContext.d.ts +18 -0
  417. package/dist/contexts/EditorAIControllerContext.js +29 -0
  418. package/dist/contexts/EditorAIControllerContext.js.map +1 -0
  419. package/dist/contexts/SideDialogsControllerContext.js +7 -0
  420. package/dist/contexts/SideDialogsControllerContext.js.map +1 -0
  421. package/dist/data_export/export/BasicExportAction.js +151 -0
  422. package/dist/data_export/export/BasicExportAction.js.map +1 -0
  423. package/dist/data_export/export/ExportCollectionAction.js +297 -0
  424. package/dist/data_export/export/ExportCollectionAction.js.map +1 -0
  425. package/dist/data_export/export/additional_fields.js +40 -0
  426. package/dist/data_export/export/additional_fields.js.map +1 -0
  427. package/dist/data_export/export/export.d.ts +35 -0
  428. package/dist/data_export/export/export.js +400 -0
  429. package/dist/data_export/export/export.js.map +1 -0
  430. package/dist/data_export/export/fetch_export_data.d.ts +17 -7
  431. package/dist/data_export/export/fetch_export_data.js +67 -0
  432. package/dist/data_export/export/fetch_export_data.js.map +1 -0
  433. package/dist/data_export/export/index.d.ts +4 -2
  434. package/dist/data_export/export/index.js +5 -0
  435. package/dist/data_import/components/DataNewPropertiesMapping.js +207 -0
  436. package/dist/data_import/components/DataNewPropertiesMapping.js.map +1 -0
  437. package/dist/data_import/components/ImportConversionProblems.js +89 -0
  438. package/dist/data_import/components/ImportConversionProblems.js.map +1 -0
  439. package/dist/data_import/components/ImportFileUpload.js +43 -0
  440. package/dist/data_import/components/ImportFileUpload.js.map +1 -0
  441. package/dist/data_import/components/ImportNewPropertyFieldPreview.js +42 -0
  442. package/dist/data_import/components/ImportNewPropertyFieldPreview.js.map +1 -0
  443. package/dist/data_import/components/ImportSaveInProgress.js +105 -0
  444. package/dist/data_import/components/ImportSaveInProgress.js.map +1 -0
  445. package/dist/data_import/hooks/useImportConfig.js +34 -0
  446. package/dist/data_import/hooks/useImportConfig.js.map +1 -0
  447. package/dist/{import-DjQoRrIU.js → data_import/import/ImportCollectionAction.js} +53 -43
  448. package/dist/data_import/import/ImportCollectionAction.js.map +1 -0
  449. package/dist/data_import/import/index.js +2 -0
  450. package/dist/data_import/utils/csv.js +146 -0
  451. package/dist/data_import/utils/csv.js.map +1 -0
  452. package/dist/data_import/utils/data.js +366 -0
  453. package/dist/data_import/utils/data.js.map +1 -0
  454. package/dist/data_import/utils/file_headers.js +32 -0
  455. package/dist/data_import/utils/file_headers.js.map +1 -0
  456. package/dist/data_import/utils/file_to_json.js +149 -0
  457. package/dist/data_import/utils/file_to_json.js.map +1 -0
  458. package/dist/data_import/utils/get_import_inference_type.js +14 -0
  459. package/dist/data_import/utils/get_import_inference_type.js.map +1 -0
  460. package/dist/data_import/utils/id_column.js +27 -0
  461. package/dist/data_import/utils/id_column.js.map +1 -0
  462. package/dist/data_import/utils/import_columns.js +92 -0
  463. package/dist/data_import/utils/import_columns.js.map +1 -0
  464. package/dist/data_import/utils/save_entities.d.ts +33 -4
  465. package/dist/data_import/utils/save_entities.js +244 -0
  466. package/dist/data_import/utils/save_entities.js.map +1 -0
  467. package/dist/data_import/utils/transforms.js +83 -0
  468. package/dist/data_import/utils/transforms.js.map +1 -0
  469. package/dist/editor/components/SlashCommandMenu.js +497 -0
  470. package/dist/editor/components/SlashCommandMenu.js.map +1 -0
  471. package/dist/editor/components/editor-bubble-item.js +24 -0
  472. package/dist/editor/components/editor-bubble-item.js.map +1 -0
  473. package/dist/editor/components/editor-bubble.js +97 -0
  474. package/dist/editor/components/editor-bubble.js.map +1 -0
  475. package/dist/editor/components/image-bubble.js +148 -0
  476. package/dist/editor/components/image-bubble.js.map +1 -0
  477. package/dist/editor/components/table-bubble.js +406 -0
  478. package/dist/editor/components/table-bubble.js.map +1 -0
  479. package/dist/editor/editor.js +423 -0
  480. package/dist/editor/editor.js.map +1 -0
  481. package/dist/editor/extensions/HighlightDecorationExtension.js +74 -0
  482. package/dist/editor/extensions/HighlightDecorationExtension.js.map +1 -0
  483. package/dist/editor/extensions/Image.d.ts +7 -1
  484. package/dist/editor/extensions/Image.js +160 -0
  485. package/dist/editor/extensions/Image.js.map +1 -0
  486. package/dist/editor/extensions/TextLoadingDecorationExtension.js +82 -0
  487. package/dist/editor/extensions/TextLoadingDecorationExtension.js.map +1 -0
  488. package/dist/editor/extensions/clipboard.js +63 -0
  489. package/dist/editor/extensions/clipboard.js.map +1 -0
  490. package/dist/editor/extensions/drag-and-drop.js +354 -0
  491. package/dist/editor/extensions/drag-and-drop.js.map +1 -0
  492. package/dist/editor/hooks/useProseMirror.js +101 -0
  493. package/dist/editor/hooks/useProseMirror.js.map +1 -0
  494. package/dist/editor/hooks/useProseMirrorContext.js +11 -0
  495. package/dist/editor/hooks/useProseMirrorContext.js.map +1 -0
  496. package/dist/editor/markdown.js +154 -0
  497. package/dist/editor/markdown.js.map +1 -0
  498. package/dist/editor/nodeViews/ImageComponent.js +35 -0
  499. package/dist/editor/nodeViews/ImageComponent.js.map +1 -0
  500. package/dist/editor/nodeViews/ReactNodeView.js +57 -0
  501. package/dist/editor/nodeViews/ReactNodeView.js.map +1 -0
  502. package/dist/editor/nodeViews/TaskItemComponent.js +29 -0
  503. package/dist/editor/nodeViews/TaskItemComponent.js.map +1 -0
  504. package/dist/editor/nodeViews/index.js +21 -0
  505. package/dist/editor/nodeViews/index.js.map +1 -0
  506. package/dist/editor/plugins/index.js +54 -0
  507. package/dist/editor/plugins/index.js.map +1 -0
  508. package/dist/editor/plugins/inputrules.js +54 -0
  509. package/dist/editor/plugins/inputrules.js.map +1 -0
  510. package/dist/editor/plugins/placeholderPlugin.js +38 -0
  511. package/dist/editor/plugins/placeholderPlugin.js.map +1 -0
  512. package/dist/editor/plugins/slashCommandPlugin.js +40 -0
  513. package/dist/editor/plugins/slashCommandPlugin.js.map +1 -0
  514. package/dist/editor/sanitize-html.js +190 -0
  515. package/dist/editor/sanitize-html.js.map +1 -0
  516. package/dist/{markdown-CCqp8ibf.js → editor/schema.js} +2 -159
  517. package/dist/editor/schema.js.map +1 -0
  518. package/dist/editor/selectors/link-selector.js +118 -0
  519. package/dist/editor/selectors/link-selector.js.map +1 -0
  520. package/dist/editor/selectors/node-selector.js +118 -0
  521. package/dist/editor/selectors/node-selector.js.map +1 -0
  522. package/dist/editor/selectors/text-buttons.js +71 -0
  523. package/dist/editor/selectors/text-buttons.js.map +1 -0
  524. package/dist/editor/utils/prosemirror-utils.js +92 -0
  525. package/dist/editor/utils/prosemirror-utils.js.map +1 -0
  526. package/dist/editor/utils/remove_classes.js +16 -0
  527. package/dist/editor/utils/remove_classes.js.map +1 -0
  528. package/dist/editor.js +1 -3147
  529. package/dist/form/EntityForm.js +734 -0
  530. package/dist/form/EntityForm.js.map +1 -0
  531. package/dist/form/EntityFormActions.js +101 -0
  532. package/dist/form/EntityFormActions.js.map +1 -0
  533. package/dist/form/EntityFormBinding.js +256 -0
  534. package/dist/form/EntityFormBinding.js.map +1 -0
  535. package/dist/form/PropertyFieldBinding.js +298 -0
  536. package/dist/form/PropertyFieldBinding.js.map +1 -0
  537. package/dist/form/components/ErrorFocus.js +33 -0
  538. package/dist/form/components/ErrorFocus.js.map +1 -0
  539. package/dist/form/components/FieldBlock.js +118 -0
  540. package/dist/form/components/FieldBlock.js.map +1 -0
  541. package/dist/form/components/FieldHelperText.js +56 -0
  542. package/dist/form/components/FieldHelperText.js.map +1 -0
  543. package/dist/form/components/FormRail.js +118 -0
  544. package/dist/form/components/FormRail.js.map +1 -0
  545. package/dist/form/components/FormSections.js +63 -0
  546. package/dist/form/components/FormSections.js.map +1 -0
  547. package/dist/form/components/LabelWithIcon.js +29 -0
  548. package/dist/form/components/LabelWithIcon.js.map +1 -0
  549. package/dist/form/components/LocalChangesMenu.js +127 -0
  550. package/dist/form/components/LocalChangesMenu.js.map +1 -0
  551. package/dist/form/components/StorageItemPreview.js +46 -0
  552. package/dist/form/components/StorageItemPreview.js.map +1 -0
  553. package/dist/form/components/StorageUploadProgress.js +84 -0
  554. package/dist/form/components/StorageUploadProgress.js.map +1 -0
  555. package/dist/form/components/useRailVisible.js +43 -0
  556. package/dist/form/components/useRailVisible.js.map +1 -0
  557. package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.js +84 -0
  558. package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.js.map +1 -0
  559. package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.js +125 -0
  560. package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.js.map +1 -0
  561. package/dist/form/field_bindings/BinaryFieldBinding.js +135 -0
  562. package/dist/form/field_bindings/BinaryFieldBinding.js.map +1 -0
  563. package/dist/form/field_bindings/BlockFieldBinding.js +164 -0
  564. package/dist/form/field_bindings/BlockFieldBinding.js.map +1 -0
  565. package/dist/form/field_bindings/DateTimeFieldBinding.js +47 -0
  566. package/dist/form/field_bindings/DateTimeFieldBinding.js.map +1 -0
  567. package/dist/form/field_bindings/GeopointFieldBinding.js +148 -0
  568. package/dist/form/field_bindings/GeopointFieldBinding.js.map +1 -0
  569. package/dist/form/field_bindings/KeyValueFieldBinding.js +450 -0
  570. package/dist/form/field_bindings/KeyValueFieldBinding.js.map +1 -0
  571. package/dist/form/field_bindings/MapFieldBinding.js +77 -0
  572. package/dist/form/field_bindings/MapFieldBinding.js.map +1 -0
  573. package/dist/form/field_bindings/MarkdownEditorFieldBinding.js +215 -0
  574. package/dist/form/field_bindings/MarkdownEditorFieldBinding.js.map +1 -0
  575. package/dist/form/field_bindings/MultiSelectFieldBinding.js +88 -0
  576. package/dist/form/field_bindings/MultiSelectFieldBinding.js.map +1 -0
  577. package/dist/form/field_bindings/MultipleRelationFieldBinding.js +118 -0
  578. package/dist/form/field_bindings/MultipleRelationFieldBinding.js.map +1 -0
  579. package/dist/form/field_bindings/ReadOnlyFieldBinding.js +52 -0
  580. package/dist/form/field_bindings/ReadOnlyFieldBinding.js.map +1 -0
  581. package/dist/form/field_bindings/ReferenceFieldBinding.js +99 -0
  582. package/dist/form/field_bindings/ReferenceFieldBinding.js.map +1 -0
  583. package/dist/form/field_bindings/RelationFieldBinding.js +135 -0
  584. package/dist/form/field_bindings/RelationFieldBinding.js.map +1 -0
  585. package/dist/form/field_bindings/RepeatFieldBinding.js +103 -0
  586. package/dist/form/field_bindings/RepeatFieldBinding.js.map +1 -0
  587. package/dist/form/field_bindings/SelectFieldBinding.js +80 -0
  588. package/dist/form/field_bindings/SelectFieldBinding.js.map +1 -0
  589. package/dist/form/field_bindings/StorageUploadFieldBinding.js +266 -0
  590. package/dist/form/field_bindings/StorageUploadFieldBinding.js.map +1 -0
  591. package/dist/form/field_bindings/SwitchFieldBinding.js +41 -0
  592. package/dist/form/field_bindings/SwitchFieldBinding.js.map +1 -0
  593. package/dist/form/field_bindings/TextFieldBinding.js +114 -0
  594. package/dist/form/field_bindings/TextFieldBinding.js.map +1 -0
  595. package/dist/form/field_bindings/UserSelectFieldBinding.js +48 -0
  596. package/dist/form/field_bindings/UserSelectFieldBinding.js.map +1 -0
  597. package/dist/form/field_bindings/VectorFieldBinding.js +147 -0
  598. package/dist/form/field_bindings/VectorFieldBinding.js.map +1 -0
  599. package/dist/form/form_keyboard_scope.d.ts +26 -0
  600. package/dist/form/form_keyboard_scope.js +39 -0
  601. package/dist/form/form_keyboard_scope.js.map +1 -0
  602. package/dist/form/form_uploads.d.ts +24 -0
  603. package/dist/form/form_uploads.js +31 -0
  604. package/dist/form/form_uploads.js.map +1 -0
  605. package/dist/form/form_utils.d.ts +24 -0
  606. package/dist/form/form_utils.js +280 -0
  607. package/dist/form/form_utils.js.map +1 -0
  608. package/dist/form/resolve_cell_property.d.ts +32 -0
  609. package/dist/form/resolve_cell_property.js +80 -0
  610. package/dist/form/resolve_cell_property.js.map +1 -0
  611. package/dist/form/resolve_form_properties.d.ts +2 -1
  612. package/dist/form/resolve_form_properties.js +78 -0
  613. package/dist/form/resolve_form_properties.js.map +1 -0
  614. package/dist/form/useClearRestoreValue.js +27 -0
  615. package/dist/form/useClearRestoreValue.js.map +1 -0
  616. package/dist/form/useUndoableDiscard.js +36 -0
  617. package/dist/form/useUndoableDiscard.js.map +1 -0
  618. package/dist/form/validation.d.ts +20 -0
  619. package/dist/form/validation.js +416 -0
  620. package/dist/form/validation.js.map +1 -0
  621. package/dist/hooks/navigation/contexts/CollectionRegistryContext.js +22 -0
  622. package/dist/hooks/navigation/contexts/CollectionRegistryContext.js.map +1 -0
  623. package/dist/hooks/navigation/contexts/NavigationStateContext.js +15 -0
  624. package/dist/hooks/navigation/contexts/NavigationStateContext.js.map +1 -0
  625. package/dist/hooks/navigation/contexts/UrlContext.js +22 -0
  626. package/dist/hooks/navigation/contexts/UrlContext.js.map +1 -0
  627. package/dist/hooks/navigation/useAsyncResolver.js +68 -0
  628. package/dist/hooks/navigation/useAsyncResolver.js.map +1 -0
  629. package/dist/hooks/navigation/useBuildCollectionRegistryController.js +141 -0
  630. package/dist/hooks/navigation/useBuildCollectionRegistryController.js.map +1 -0
  631. package/dist/hooks/navigation/useBuildNavigationStateController.js +77 -0
  632. package/dist/hooks/navigation/useBuildNavigationStateController.js.map +1 -0
  633. package/dist/hooks/navigation/useBuildUrlController.js +57 -0
  634. package/dist/hooks/navigation/useBuildUrlController.js.map +1 -0
  635. package/dist/hooks/navigation/useNavigationResolution.js +177 -0
  636. package/dist/hooks/navigation/useNavigationResolution.js.map +1 -0
  637. package/dist/hooks/navigation/useResolvedCollections.js +56 -0
  638. package/dist/hooks/navigation/useResolvedCollections.js.map +1 -0
  639. package/dist/hooks/navigation/useResolvedViews.js +94 -0
  640. package/dist/hooks/navigation/useResolvedViews.js.map +1 -0
  641. package/dist/hooks/navigation/useTopLevelNavigation.js +162 -0
  642. package/dist/hooks/navigation/useTopLevelNavigation.js.map +1 -0
  643. package/dist/hooks/navigation/utils.js +125 -0
  644. package/dist/hooks/navigation/utils.js.map +1 -0
  645. package/dist/hooks/useAdminContext.js +45 -0
  646. package/dist/hooks/useAdminContext.js.map +1 -0
  647. package/dist/hooks/useBreadcrumbsController.js +17 -0
  648. package/dist/hooks/useBreadcrumbsController.js.map +1 -0
  649. package/dist/hooks/useBuildSideDialogsController.js +96 -0
  650. package/dist/hooks/useBuildSideDialogsController.js.map +1 -0
  651. package/dist/hooks/useBuildSidePanel.js +221 -0
  652. package/dist/hooks/useBuildSidePanel.js.map +1 -0
  653. package/dist/hooks/useChildViewSource.js +41 -0
  654. package/dist/hooks/useChildViewSource.js.map +1 -0
  655. package/dist/hooks/useEntityDisplay.js +136 -0
  656. package/dist/hooks/useEntityDisplay.js.map +1 -0
  657. package/dist/hooks/useEntityDisplayTitle.js +34 -0
  658. package/dist/hooks/useEntityDisplayTitle.js.map +1 -0
  659. package/dist/hooks/useHistory.js +137 -0
  660. package/dist/hooks/useHistory.js.map +1 -0
  661. package/dist/hooks/useRecordActions.js +108 -0
  662. package/dist/hooks/useRecordActions.js.map +1 -0
  663. package/dist/hooks/useReferencePaths.js +32 -0
  664. package/dist/hooks/useReferencePaths.js.map +1 -0
  665. package/dist/hooks/useResolvedNavigationFrom.js +83 -0
  666. package/dist/hooks/useResolvedNavigationFrom.js.map +1 -0
  667. package/dist/hooks/useResolvedUsers.js +109 -0
  668. package/dist/hooks/useResolvedUsers.js.map +1 -0
  669. package/dist/hooks/useSelectionDialog.js +53 -0
  670. package/dist/hooks/useSelectionDialog.js.map +1 -0
  671. package/dist/hooks/useSideDialogsController.js +8 -0
  672. package/dist/hooks/useSideDialogsController.js.map +1 -0
  673. package/dist/hooks/useSidePanel.js +15 -0
  674. package/dist/hooks/useSidePanel.js.map +1 -0
  675. package/dist/hooks/useStorageReferenceResolver.d.ts +4 -2
  676. package/dist/hooks/useStorageReferenceResolver.js +49 -0
  677. package/dist/hooks/useStorageReferenceResolver.js.map +1 -0
  678. package/dist/index.d.ts +3 -2
  679. package/dist/index.js +151 -3867
  680. package/dist/preview/PropertyPreview.js +260 -0
  681. package/dist/preview/PropertyPreview.js.map +1 -0
  682. package/dist/preview/compact_text.js +52 -0
  683. package/dist/preview/compact_text.js.map +1 -0
  684. package/dist/preview/components/ArrayEnumPreview.js +24 -0
  685. package/dist/preview/components/ArrayEnumPreview.js.map +1 -0
  686. package/dist/preview/components/BooleanPreview.js +25 -0
  687. package/dist/preview/components/BooleanPreview.js.map +1 -0
  688. package/dist/preview/components/DatePreview.d.ts +3 -2
  689. package/dist/preview/components/DatePreview.js +87 -0
  690. package/dist/preview/components/DatePreview.js.map +1 -0
  691. package/dist/preview/components/EmptyValue.js +13 -0
  692. package/dist/preview/components/EmptyValue.js.map +1 -0
  693. package/dist/preview/components/EnumValuesChip.js +26 -0
  694. package/dist/preview/components/EnumValuesChip.js.map +1 -0
  695. package/dist/preview/components/ImagePreview.d.ts +7 -1
  696. package/dist/preview/components/ImagePreview.js +112 -0
  697. package/dist/preview/components/ImagePreview.js.map +1 -0
  698. package/dist/preview/components/InlineEntityListPreview.js +31 -0
  699. package/dist/preview/components/InlineEntityListPreview.js.map +1 -0
  700. package/dist/preview/components/ReferencePreview.js +162 -0
  701. package/dist/preview/components/ReferencePreview.js.map +1 -0
  702. package/dist/preview/components/RelationPreview.js +196 -0
  703. package/dist/preview/components/RelationPreview.js.map +1 -0
  704. package/dist/preview/components/StorageMarkdown.d.ts +2 -1
  705. package/dist/preview/components/StorageMarkdown.js +49 -0
  706. package/dist/preview/components/StorageMarkdown.js.map +1 -0
  707. package/dist/preview/components/StorageThumbnail.js +183 -0
  708. package/dist/preview/components/StorageThumbnail.js.map +1 -0
  709. package/dist/preview/components/UrlComponentPreview.d.ts +3 -1
  710. package/dist/preview/components/UrlComponentPreview.js +88 -0
  711. package/dist/preview/components/UrlComponentPreview.js.map +1 -0
  712. package/dist/preview/components/UserPreview.js +30 -0
  713. package/dist/preview/components/UserPreview.js.map +1 -0
  714. package/dist/preview/components/date_fns_locales.js +124 -0
  715. package/dist/preview/components/date_fns_locales.js.map +1 -0
  716. package/dist/preview/components/storageRenditions.d.ts +10 -0
  717. package/dist/preview/components/storageRenditions.js +95 -0
  718. package/dist/preview/components/storageRenditions.js.map +1 -0
  719. package/dist/preview/property_previews/ArrayOfMapsPreview.js +44 -0
  720. package/dist/preview/property_previews/ArrayOfMapsPreview.js.map +1 -0
  721. package/dist/preview/property_previews/ArrayOfReferencesPreview.js +48 -0
  722. package/dist/preview/property_previews/ArrayOfReferencesPreview.js.map +1 -0
  723. package/dist/preview/property_previews/ArrayOfRelationsPreview.js +50 -0
  724. package/dist/preview/property_previews/ArrayOfRelationsPreview.js.map +1 -0
  725. package/dist/preview/property_previews/ArrayOfStorageComponentsPreview.js +30 -0
  726. package/dist/preview/property_previews/ArrayOfStorageComponentsPreview.js.map +1 -0
  727. package/dist/preview/property_previews/ArrayOfStringsPreview.js +42 -0
  728. package/dist/preview/property_previews/ArrayOfStringsPreview.js.map +1 -0
  729. package/dist/preview/property_previews/ArrayOneOfPreview.js +47 -0
  730. package/dist/preview/property_previews/ArrayOneOfPreview.js.map +1 -0
  731. package/dist/preview/property_previews/ArrayPropertyEnumPreview.js +25 -0
  732. package/dist/preview/property_previews/ArrayPropertyEnumPreview.js.map +1 -0
  733. package/dist/preview/property_previews/ArrayPropertyPreview.js +48 -0
  734. package/dist/preview/property_previews/ArrayPropertyPreview.js.map +1 -0
  735. package/dist/preview/property_previews/MapPropertyPreview.js +137 -0
  736. package/dist/preview/property_previews/MapPropertyPreview.js.map +1 -0
  737. package/dist/preview/property_previews/NumberPropertyPreview.js +34 -0
  738. package/dist/preview/property_previews/NumberPropertyPreview.js.map +1 -0
  739. package/dist/preview/property_previews/SkeletonPropertyComponent.js +151 -0
  740. package/dist/preview/property_previews/SkeletonPropertyComponent.js.map +1 -0
  741. package/dist/preview/property_previews/StringPropertyPreview.js +49 -0
  742. package/dist/preview/property_previews/StringPropertyPreview.js.map +1 -0
  743. package/dist/preview/util.d.ts +4 -3
  744. package/dist/{util-D7ebttKT.js → preview/util.js} +8 -5
  745. package/dist/preview/util.js.map +1 -0
  746. package/dist/routes/CustomViewRoute.js +26 -0
  747. package/dist/routes/CustomViewRoute.js.map +1 -0
  748. package/dist/routes/RebaseRoute.js +311 -0
  749. package/dist/routes/RebaseRoute.js.map +1 -0
  750. package/dist/selection/SelectionMenu.js +90 -0
  751. package/dist/selection/SelectionMenu.js.map +1 -0
  752. package/dist/selection/resolve_selection.js +79 -0
  753. package/dist/selection/resolve_selection.js.map +1 -0
  754. package/dist/util/caller_scopes.js +25 -0
  755. package/dist/util/caller_scopes.js.map +1 -0
  756. package/dist/util/collection_open_mode.d.ts +20 -0
  757. package/dist/util/collection_open_mode.js +32 -0
  758. package/dist/util/collection_open_mode.js.map +1 -0
  759. package/dist/util/dataControllerAdapter.js +65 -0
  760. package/dist/util/dataControllerAdapter.js.map +1 -0
  761. package/dist/util/entity_actions.d.ts +5 -0
  762. package/dist/util/entity_actions.js +77 -0
  763. package/dist/util/entity_actions.js.map +1 -0
  764. package/dist/util/entity_pages.d.ts +37 -3
  765. package/dist/util/entity_pages.js +71 -0
  766. package/dist/util/entity_pages.js.map +1 -0
  767. package/dist/util/find_entities_by_ids.d.ts +23 -0
  768. package/dist/util/find_entities_by_ids.js +55 -0
  769. package/dist/util/find_entities_by_ids.js.map +1 -0
  770. package/dist/util/fit_inline_actions.js +40 -0
  771. package/dist/util/fit_inline_actions.js.map +1 -0
  772. package/dist/util/format_collection_date.d.ts +29 -0
  773. package/dist/util/format_collection_date.js +60 -0
  774. package/dist/util/format_collection_date.js.map +1 -0
  775. package/dist/util/map_with_concurrency.js +46 -0
  776. package/dist/util/map_with_concurrency.js.map +1 -0
  777. package/dist/util/navigation_utils.js +45 -0
  778. package/dist/util/navigation_utils.js.map +1 -0
  779. package/dist/util/number_format.js +33 -0
  780. package/dist/util/number_format.js.map +1 -0
  781. package/dist/util/previews.js +71 -0
  782. package/dist/util/previews.js.map +1 -0
  783. package/dist/util/propertyConfigMapper.js +83 -0
  784. package/dist/util/propertyConfigMapper.js.map +1 -0
  785. package/dist/util/property_utils.js +141 -0
  786. package/dist/util/property_utils.js.map +1 -0
  787. package/dist/util/resolutions.js +55 -0
  788. package/dist/util/resolutions.js.map +1 -0
  789. package/dist/util/view_constants.js +35 -0
  790. package/dist/util/view_constants.js.map +1 -0
  791. package/dist/util/view_mode.js +112 -0
  792. package/dist/util/view_mode.js.map +1 -0
  793. package/package.json +13 -9
  794. package/dist/CollectionEditorDialog-p5-I-Apu.js +0 -3669
  795. package/dist/CollectionEditorDialog-p5-I-Apu.js.map +0 -1
  796. package/dist/JsonPreviewBinding-v0w3H0fp.js.map +0 -1
  797. package/dist/PropertyEditView-DDB_X-00.js +0 -3837
  798. package/dist/PropertyEditView-DDB_X-00.js.map +0 -1
  799. package/dist/RouterCollectionsStudioView-SGBV4CMg.js +0 -212
  800. package/dist/RouterCollectionsStudioView-SGBV4CMg.js.map +0 -1
  801. package/dist/SchemaChangeDialog-CcFSXvkK.js.map +0 -1
  802. package/dist/collection_editor/ui/CollectionViewHeaderAction.d.ts +0 -13
  803. package/dist/collection_editor/ui/PropertyAddColumnComponent.d.ts +0 -8
  804. package/dist/collection_editor_ui.js.map +0 -1
  805. package/dist/editor.js.map +0 -1
  806. package/dist/export-DCHuPD1a.js +0 -520
  807. package/dist/export-DCHuPD1a.js.map +0 -1
  808. package/dist/history-CBd6SBRs.js +0 -314
  809. package/dist/history-CBd6SBRs.js.map +0 -1
  810. package/dist/import-DjQoRrIU.js.map +0 -1
  811. package/dist/index.js.map +0 -1
  812. package/dist/markdown-CCqp8ibf.js.map +0 -1
  813. package/dist/rolldown-runtime-D7D4PA-g.js +0 -13
  814. package/dist/util-BRvKFMLa.js +0 -27773
  815. package/dist/util-BRvKFMLa.js.map +0 -1
  816. package/dist/util-D7ebttKT.js.map +0 -1
@@ -1,3669 +0,0 @@
1
- import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
2
- import { A as getFieldId, At as ImportNewPropertyFieldPreview, Bn as useUrlController, Dt as useCollectionEditorController, Ft as convertImportData, Hn as useNavigationStateController, Ht as getInferenceType, Mn as useSelectionController, Mt as guessIdColumn, Nt as ImportConversionProblems, Pn as CollectionTableBinding, S as isSchemaChangeCancelled, Ut as useImportConfig, Wt as ImportSaveInProgress, _ as useCollectionsConfigController, cn as SearchIconsView, ct as useSafeSnackbarController, i as namespaceToPropertiesOrderPath, jt as DataNewPropertiesMapping, k as getFieldConfig, l as validateCollectionJson, ln as FieldCaption, m as toSerializableCollectionConfig, n as getFullIdPath, o as CollectionGenerationApiError, qt as ImportFileUpload, r as idToPropertiesPath, sn as PropertyConfigBadge, t as getFullId, yr as useCollectionRegistryController } from "./util-BRvKFMLa.js";
3
- import { a as updatePropertyFromWidget, c as useAIModifiedPaths, i as supportedFields, n as PropertyForm, o as PropertyTree, r as PropertyFormDialog, s as AIModifiedPathsProvider } from "./PropertyEditView-DDB_X-00.js";
4
- import * as React$1 from "react";
5
- import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
6
- import { Alert, AppWindow, ArrowLeftIcon, BooleanSwitchWithLabel, Button, Card, CheckIcon, Chip, CircularProgress, CircularProgressCenter, CodeIcon, ColumnsIcon, Container, CopyIcon, DebouncedTextField, Dialog, DialogActions, DialogContent, DialogTitle, ErrorBoundary, FileIcon, FileSearchIcon, FileTextIcon, IconButton, KanbanIcon, KeyIcon, LayoutGridIcon, ListIcon, LoadingButton, Menu, MultiSelect, MultiSelectItem, PanelLeftIcon, Paper, PlusIcon, Select, SelectItem, ShoppingCartIcon, SquareIcon, Tab, TableIcon, Tabs, TextField, ToggleButtonGroup, Tooltip, Trash2Icon, Typography, UserIcon, XIcon, cls, coolIconKeys, defaultBorderMixin, iconSize } from "@rebasepro/ui";
7
- import { buildCollectionFromTableMetadata, getGeneratedPolicyNames, getSubcollections, getTableName, isPropertyBuilder, policyToSecurityRule } from "@rebasepro/common";
8
- import { AIIcon, ConfirmationDialog, ErrorView, IconForView, UnsavedChangesDialog, getIcon, removeInitialAndTrailingSlashes, useAuthController, useCustomizationController, useLargeLayout, useRebaseContext, useTranslation, useUnsavedChangesDialog } from "@rebasepro/app";
9
- import { Field, Formex, clone, getIn, useCreateFormex, useFormex } from "@rebasepro/forms";
10
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
11
- import { RLS_ROLES_SQL, RLS_UID_SQL, getDataSourceCapabilities, isPostgresCollectionConfig } from "@rebasepro/types";
12
- import { camelCase, getPolicyNamesForRule, isEmptyObject, mergeDeep, prettifyIdentifier, randomString, removeUndefined, singular, slugify, toSnakeCase, unslugify } from "@rebasepro/utils";
13
- import { z } from "zod";
14
- import { buildEntityPropertiesFromData, buildPropertyFromData } from "@rebasepro/inference";
15
- import JSON5 from "json5";
16
- import { Highlight, themes } from "prism-react-renderer";
17
- //#region src/collection_editor/ui/collection_editor/CollectionYupValidation.tsx
18
- var CollectionEditorSchema = z.object({
19
- slug: z.string().min(1, "Required"),
20
- name: z.string().min(1, "Required"),
21
- table: z.string().min(1, "Required")
22
- });
23
- //#endregion
24
- //#region src/collection_editor/ui/collection_editor/GeneralSettingsForm.tsx
25
- function GeneralSettingsForm({ isNewCollection, existingPaths, existingIds, parentCollection, renderExtraCollectionFields, standalone }) {
26
- const { values, setFieldValue, handleChange, touched, errors, setFieldTouched, submitCount } = useFormex();
27
- const { t } = useTranslation();
28
- const [iconDialogOpen, setIconDialogOpen] = useState(false);
29
- const configControllerFromContext = useCollectionsConfigController();
30
- const configController = standalone ? { readOnly: false } : configControllerFromContext;
31
- const updateDatabaseId = (databaseId) => {
32
- setFieldValue("databaseId", databaseId ?? void 0);
33
- };
34
- const updateName = (name) => {
35
- setFieldValue("name", name);
36
- if (!getIn(touched, "table") && isNewCollection && name) setFieldValue("table", toSnakeCase(name));
37
- if (!getIn(touched, "slug") && isNewCollection && name) setFieldValue("slug", toSnakeCase(name));
38
- if (!getIn(touched, "singularName") && isNewCollection && name) setFieldValue("singularName", singular(name));
39
- };
40
- const collectionIcon = /* @__PURE__ */ jsx(IconForView, { collectionOrView: values });
41
- const isSubcollection = !!parentCollection;
42
- const showErrors = submitCount > 0;
43
- return /* @__PURE__ */ jsx("div", {
44
- className: "overflow-auto my-auto",
45
- children: /* @__PURE__ */ jsxs(Container, {
46
- maxWidth: "4xl",
47
- className: "flex flex-col gap-4 p-8 m-auto",
48
- children: [
49
- /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsxs("div", {
50
- className: "flex flex-row gap-2 items-center",
51
- children: [
52
- /* @__PURE__ */ jsx(Typography, {
53
- variant: !isNewCollection ? "h5" : "h4",
54
- className: "flex-grow",
55
- children: isNewCollection ? "New collection" : `${values?.name} collection`
56
- }),
57
- /* @__PURE__ */ jsx(DefaultDatabaseField, {
58
- databaseId: values.databaseId,
59
- disabled: configController?.readOnly,
60
- onDatabaseIdUpdate: updateDatabaseId
61
- }),
62
- /* @__PURE__ */ jsx(Tooltip, {
63
- title: t("change_icon"),
64
- asChild: true,
65
- children: /* @__PURE__ */ jsx(IconButton, {
66
- "aria-label": t("change_icon"),
67
- shape: "square",
68
- disabled: configController?.readOnly,
69
- onClick: () => setIconDialogOpen(true),
70
- children: collectionIcon
71
- })
72
- })
73
- ]
74
- }), parentCollection && /* @__PURE__ */ jsx(Chip, {
75
- colorScheme: "teal",
76
- children: /* @__PURE__ */ jsxs(Typography, {
77
- variant: "caption",
78
- children: ["This is a subcollection of ", /* @__PURE__ */ jsx("b", { children: parentCollection.name })]
79
- })
80
- })] }),
81
- /* @__PURE__ */ jsxs("fieldset", {
82
- disabled: configController?.readOnly,
83
- className: "contents",
84
- children: [/* @__PURE__ */ jsxs("div", {
85
- className: "grid grid-cols-12 gap-4",
86
- children: [
87
- /* @__PURE__ */ jsxs("div", {
88
- className: "col-span-12",
89
- children: [/* @__PURE__ */ jsx(TextField, {
90
- value: values.name ?? "",
91
- onChange: (e) => updateName(e.target.value),
92
- label: "Name",
93
- autoFocus: true,
94
- required: true,
95
- error: showErrors && Boolean(errors.name)
96
- }), /* @__PURE__ */ jsx(FieldCaption, {
97
- error: touched.name && Boolean(errors.name),
98
- children: touched.name && Boolean(errors.name) ? errors.name : "Name of this collection, usually a plural name (e.g. Products)"
99
- })]
100
- }),
101
- /* @__PURE__ */ jsxs("div", {
102
- className: cls("col-span-12"),
103
- children: [/* @__PURE__ */ jsx(Field, {
104
- name: "table",
105
- as: DebouncedTextField,
106
- label: "Table name",
107
- required: true,
108
- disabled: !isNewCollection,
109
- error: showErrors && Boolean(errors.table)
110
- }), /* @__PURE__ */ jsx(FieldCaption, {
111
- error: touched.table && Boolean(errors.table),
112
- children: touched.table && Boolean(errors.table) ? errors.table : isSubcollection ? "Relative path to the parent (no need to include the parent path)" : "PostgreSQL table name for this collection"
113
- })]
114
- }),
115
- /* @__PURE__ */ jsxs("div", {
116
- className: "col-span-12",
117
- children: [/* @__PURE__ */ jsx(TextField, {
118
- error: showErrors && Boolean(errors.singularName),
119
- name: "singularName",
120
- "aria-describedby": "singularName-helper",
121
- onChange: (e) => {
122
- setFieldTouched("singularName", true);
123
- return handleChange(e);
124
- },
125
- value: values.singularName ?? "",
126
- label: "Singular name"
127
- }), /* @__PURE__ */ jsx(FieldCaption, {
128
- error: showErrors && Boolean(errors.singularName),
129
- children: showErrors && Boolean(errors.singularName) ? errors.singularName : "Optionally define a singular name for your entities"
130
- })]
131
- }),
132
- /* @__PURE__ */ jsxs("div", {
133
- className: "col-span-12",
134
- children: [/* @__PURE__ */ jsx(TextField, {
135
- error: showErrors && Boolean(errors.description),
136
- name: "description",
137
- value: values.description ?? "",
138
- onChange: handleChange,
139
- multiline: true,
140
- minRows: 2,
141
- "aria-describedby": "description-helper-text",
142
- label: "Description"
143
- }), /* @__PURE__ */ jsx(FieldCaption, {
144
- error: showErrors && Boolean(errors.description),
145
- children: showErrors && Boolean(errors.description) ? errors.description : "Description of the collection, you can use markdown"
146
- })]
147
- }),
148
- /* @__PURE__ */ jsxs("div", {
149
- className: "col-span-12",
150
- children: [/* @__PURE__ */ jsx(DebouncedTextField, {
151
- name: "slug",
152
- value: values.slug ?? "",
153
- onChange: (e) => setFieldValue("slug", e.target.value),
154
- disabled: !isNewCollection,
155
- label: "Collection ID",
156
- error: showErrors && Boolean(errors.slug)
157
- }), /* @__PURE__ */ jsx(FieldCaption, {
158
- error: touched.slug && Boolean(errors.slug),
159
- children: touched.slug && Boolean(errors.slug) ? errors.slug : "This ID identifies this collection. Typically the same as the path."
160
- })]
161
- })
162
- ]
163
- }), null]
164
- }),
165
- /* @__PURE__ */ jsx("div", { style: { height: "52px" } }),
166
- /* @__PURE__ */ jsx(Dialog, {
167
- open: iconDialogOpen,
168
- onOpenChange: setIconDialogOpen,
169
- maxWidth: "xl",
170
- fullWidth: true,
171
- children: /* @__PURE__ */ jsx("div", {
172
- className: "p-4 overflow-auto min-h-[200px]",
173
- children: /* @__PURE__ */ jsx(SearchIconsView, {
174
- selectedIcon: typeof values.icon === "string" ? values.icon : void 0,
175
- onIconSelected: (icon) => {
176
- setIconDialogOpen(false);
177
- setFieldValue("icon", icon);
178
- }
179
- })
180
- })
181
- }),
182
- renderExtraCollectionFields && /* @__PURE__ */ jsx("div", {
183
- className: "mt-4",
184
- children: renderExtraCollectionFields({
185
- metadata: values.metadata ?? {},
186
- onMetadataChange: (key, value) => {
187
- setFieldValue(`metadata.${key}`, value);
188
- },
189
- collection: toSerializableCollectionConfig(values)
190
- })
191
- })
192
- ]
193
- })
194
- });
195
- }
196
- function DefaultDatabaseField({ databaseId, disabled = false, onDatabaseIdUpdate }) {
197
- const { t } = useTranslation();
198
- return /* @__PURE__ */ jsx(Tooltip, {
199
- title: t("database_id"),
200
- side: "top",
201
- align: "start",
202
- children: /* @__PURE__ */ jsx(TextField, {
203
- size: "small",
204
- "aria-label": t("database_id"),
205
- invisible: true,
206
- inputClassName: "text-end",
207
- disabled,
208
- value: databaseId ?? "",
209
- onChange: (e) => onDatabaseIdUpdate(e.target.value),
210
- placeholder: "(default)"
211
- })
212
- });
213
- }
214
- //#endregion
215
- //#region src/collection_editor/ui/collection_editor/LayoutModeSwitch.tsx
216
- function LayoutModeSwitch({ value, onChange, className }) {
217
- return /* @__PURE__ */ jsxs("div", {
218
- className: cls(className),
219
- children: [
220
- /* @__PURE__ */ jsx(Typography, {
221
- variant: "label",
222
- color: "secondary",
223
- className: "ml-3.5",
224
- children: "Document view"
225
- }),
226
- /* @__PURE__ */ jsx("div", {
227
- className: "my-2",
228
- children: /* @__PURE__ */ jsx(ToggleButtonGroup, {
229
- value,
230
- onValueChange: onChange,
231
- options: [
232
- {
233
- value: "side_panel",
234
- label: "Side panel",
235
- icon: /* @__PURE__ */ jsx(ColumnsIcon, {})
236
- },
237
- {
238
- value: "full_screen",
239
- label: "Full screen",
240
- icon: /* @__PURE__ */ jsx(SquareIcon, {})
241
- },
242
- {
243
- value: "split",
244
- label: "Split view",
245
- icon: /* @__PURE__ */ jsx(PanelLeftIcon, {})
246
- },
247
- {
248
- value: "dialog",
249
- label: "Centered dialog",
250
- icon: /* @__PURE__ */ jsx(AppWindow, {})
251
- }
252
- ]
253
- })
254
- }),
255
- /* @__PURE__ */ jsx(Typography, {
256
- variant: "caption",
257
- color: "secondary",
258
- className: "ml-3.5",
259
- children: "Should documents be opened full screen, inline side dialog, or centered dialog"
260
- })
261
- ]
262
- });
263
- }
264
- //#endregion
265
- //#region src/collection_editor/ui/collection_editor/ViewModeSwitch.tsx
266
- function ViewModeSwitch({ value, onChange, className }) {
267
- const registeredViews = useCustomizationController().collectionViews ?? [];
268
- return /* @__PURE__ */ jsxs("div", {
269
- className: cls(className),
270
- children: [
271
- /* @__PURE__ */ jsx(Typography, {
272
- variant: "label",
273
- color: "secondary",
274
- className: "ml-3.5",
275
- children: "Default collection view"
276
- }),
277
- /* @__PURE__ */ jsx("div", {
278
- className: "my-2",
279
- children: /* @__PURE__ */ jsx(ToggleButtonGroup, {
280
- value,
281
- onValueChange: onChange,
282
- options: [
283
- {
284
- value: "list",
285
- label: "List",
286
- icon: /* @__PURE__ */ jsx(ListIcon, {})
287
- },
288
- {
289
- value: "table",
290
- label: "Table",
291
- icon: /* @__PURE__ */ jsx(TableIcon, {})
292
- },
293
- {
294
- value: "cards",
295
- label: "Cards",
296
- icon: /* @__PURE__ */ jsx(LayoutGridIcon, {})
297
- },
298
- {
299
- value: "kanban",
300
- label: "Kanban",
301
- icon: /* @__PURE__ */ jsx(KanbanIcon, {})
302
- },
303
- ...registeredViews.map((view) => ({
304
- value: view.key,
305
- label: view.name,
306
- icon: getIcon(view.icon) ?? /* @__PURE__ */ jsx(ListIcon, {})
307
- }))
308
- ]
309
- })
310
- }),
311
- /* @__PURE__ */ jsx(Typography, {
312
- variant: "caption",
313
- color: "secondary",
314
- className: "ml-3.5",
315
- children: "Choose how entities should be displayed by default"
316
- })
317
- ]
318
- });
319
- }
320
- //#endregion
321
- //#region src/collection_editor/ui/collection_editor/KanbanConfigSection.tsx
322
- function KanbanConfigSection({ className, forceExpanded }) {
323
- useAuthController();
324
- const customizationController = useCustomizationController();
325
- const { values, setFieldValue } = useFormex();
326
- const panelRef = useRef(null);
327
- const [columnPropertyDialogOpen, setColumnPropertyDialogOpen] = useState(false);
328
- const enumStringProperties = useMemo(() => {
329
- const result = [];
330
- if (!values.properties) return result;
331
- Object.entries(values.properties).forEach(([key, prop]) => {
332
- if (prop && "type" in prop && prop.type === "string" && prop.enum) result.push({
333
- key,
334
- label: prop.name || key,
335
- property: prop
336
- });
337
- });
338
- return result;
339
- }, [values.properties]);
340
- const kanbanConfig = values.kanban;
341
- const columnPropertyMissing = Boolean(kanbanConfig?.columnProperty) && !enumStringProperties.some((p) => p.key === kanbanConfig?.columnProperty);
342
- React.useEffect(() => {
343
- if (forceExpanded && panelRef.current) setTimeout(() => {
344
- panelRef.current?.scrollIntoView({
345
- behavior: "smooth",
346
- block: "center"
347
- });
348
- }, 100);
349
- }, [forceExpanded]);
350
- const showCreateButton = !kanbanConfig?.columnProperty || columnPropertyMissing;
351
- const dialogPropertyKey = columnPropertyMissing && kanbanConfig?.columnProperty ? kanbanConfig.columnProperty : "status";
352
- const dialogPropertyName = columnPropertyMissing && kanbanConfig?.columnProperty ? unslugify(kanbanConfig.columnProperty) : "Status";
353
- return /* @__PURE__ */ jsxs("div", {
354
- className,
355
- ref: panelRef,
356
- children: [
357
- /* @__PURE__ */ jsx(Select, {
358
- name: "kanban.columnProperty",
359
- label: "Kanban Column Property",
360
- fullWidth: true,
361
- position: "item-aligned",
362
- disabled: enumStringProperties.length === 0,
363
- error: columnPropertyMissing,
364
- value: kanbanConfig?.columnProperty ?? "",
365
- onValueChange: (v) => {
366
- if (v) setFieldValue("kanban", {
367
- ...kanbanConfig,
368
- columnProperty: v
369
- });
370
- else setFieldValue("kanban", void 0);
371
- },
372
- renderValue: (value) => {
373
- if (columnPropertyMissing) return /* @__PURE__ */ jsxs("span", {
374
- className: "text-red-500",
375
- children: [value, " (not found)"]
376
- });
377
- const prop = enumStringProperties.find((p) => p.key === value);
378
- if (!prop) return "Select a property";
379
- return /* @__PURE__ */ jsxs("div", {
380
- className: "flex items-center gap-2",
381
- children: [/* @__PURE__ */ jsx(PropertyConfigBadge, { propertyConfig: getFieldConfig(prop.property, customizationController.propertyConfigs) }), /* @__PURE__ */ jsx("span", { children: prop.label })]
382
- });
383
- },
384
- endAdornment: kanbanConfig?.columnProperty ? /* @__PURE__ */ jsx(IconButton, {
385
- size: "small",
386
- onClick: (e) => {
387
- e.stopPropagation();
388
- setFieldValue("kanban", void 0);
389
- },
390
- children: /* @__PURE__ */ jsx(XIcon, { size: iconSize.smallest })
391
- }) : void 0,
392
- children: enumStringProperties.map((prop) => {
393
- const fieldConfig = getFieldConfig(prop.property, customizationController.propertyConfigs);
394
- return /* @__PURE__ */ jsx(SelectItem, {
395
- value: prop.key,
396
- children: /* @__PURE__ */ jsxs("div", {
397
- className: "flex items-center gap-3",
398
- children: [/* @__PURE__ */ jsx(PropertyConfigBadge, { propertyConfig: fieldConfig }), /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("div", { children: prop.label }), /* @__PURE__ */ jsx(Typography, {
399
- variant: "caption",
400
- color: "secondary",
401
- children: fieldConfig?.name || "Enum"
402
- })] })]
403
- })
404
- }, prop.key);
405
- })
406
- }, `column-select-${enumStringProperties.length}`),
407
- /* @__PURE__ */ jsx(FieldCaption, {
408
- error: columnPropertyMissing,
409
- children: columnPropertyMissing ? `Property "${kanbanConfig?.columnProperty}" does not exist or is not an enum string property. Please select a valid property or clear the selection.` : enumStringProperties.length === 0 ? "No enum string properties found. Add a string property with enum to use Kanban view." : "Select a string property with enum values to group entities into columns"
410
- }),
411
- showCreateButton && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(Button, {
412
- variant: "text",
413
- size: "small",
414
- className: "ml-3.5 mt-2",
415
- onClick: () => setColumnPropertyDialogOpen(true),
416
- children: [
417
- "+ Create \"",
418
- dialogPropertyKey,
419
- "\" property"
420
- ]
421
- }), /* @__PURE__ */ jsx(PropertyFormDialog, {
422
- open: columnPropertyDialogOpen,
423
- onCancel: () => setColumnPropertyDialogOpen(false),
424
- property: {
425
- type: "string",
426
- name: dialogPropertyName,
427
- enum: [
428
- {
429
- id: "todo",
430
- label: "To Do"
431
- },
432
- {
433
- id: "in_progress",
434
- label: "In Progress"
435
- },
436
- {
437
- id: "done",
438
- label: "Done"
439
- }
440
- ]
441
- },
442
- propertyKey: dialogPropertyKey,
443
- existingProperty: false,
444
- autoOpenTypeSelect: false,
445
- autoUpdateId: false,
446
- inArray: false,
447
- allowDataInference: false,
448
- propertyConfigs: customizationController.propertyConfigs,
449
- existingPropertyKeys: Object.keys(values.properties ?? {}),
450
- onPropertyChanged: ({ id, property }) => {
451
- const newProperties = {
452
- ...values.properties,
453
- [id]: property
454
- };
455
- const newPropertiesOrder = [...values.propertiesOrder ?? Object.keys(values.properties ?? {}), id];
456
- setFieldValue("properties", newProperties);
457
- setFieldValue("propertiesOrder", newPropertiesOrder);
458
- setFieldValue("kanban", {
459
- ...kanbanConfig,
460
- columnProperty: id
461
- });
462
- setColumnPropertyDialogOpen(false);
463
- }
464
- })] })
465
- ]
466
- });
467
- }
468
- //#endregion
469
- //#region src/collection_editor/ui/collection_editor/DisplaySettingsForm.tsx
470
- function DisplaySettingsForm({ expandKanban, standalone }) {
471
- const { values, setFieldValue, handleChange, submitCount } = useFormex();
472
- const [orderPropertyDialogOpen, setOrderPropertyDialogOpen] = useState(false);
473
- const customizationController = useCustomizationController();
474
- const configControllerFromContext = useCollectionsConfigController();
475
- const configController = standalone ? { readOnly: false } : configControllerFromContext;
476
- const textProperties = useMemo(() => {
477
- const result = [];
478
- if (!values.properties) return result;
479
- Object.entries(values.properties).forEach(([key, prop]) => {
480
- if (prop && "type" in prop && prop.type === "string") result.push({
481
- key,
482
- label: prop.name || key,
483
- property: prop
484
- });
485
- });
486
- return result;
487
- }, [values.properties]);
488
- return /* @__PURE__ */ jsx("div", {
489
- className: "overflow-auto my-auto",
490
- children: /* @__PURE__ */ jsxs(Container, {
491
- maxWidth: "4xl",
492
- className: "flex flex-col gap-4 p-8 m-auto",
493
- children: [
494
- /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Typography, {
495
- variant: "h5",
496
- className: "flex-grow",
497
- children: "Display settings"
498
- }) }),
499
- /* @__PURE__ */ jsx("fieldset", {
500
- disabled: configController?.readOnly,
501
- className: "contents",
502
- children: /* @__PURE__ */ jsxs("div", {
503
- className: "grid grid-cols-12 gap-4",
504
- children: [
505
- /* @__PURE__ */ jsx(LayoutModeSwitch, {
506
- className: "col-span-12",
507
- value: values.openEntityMode ?? "side_panel",
508
- onChange: (value) => setFieldValue("openEntityMode", value)
509
- }),
510
- /* @__PURE__ */ jsx(ViewModeSwitch, {
511
- className: "col-span-12",
512
- value: values.defaultViewMode ?? "table",
513
- onChange: (value) => setFieldValue("defaultViewMode", value)
514
- }),
515
- /* @__PURE__ */ jsx(KanbanConfigSection, {
516
- className: "col-span-12",
517
- forceExpanded: expandKanban
518
- }),
519
- /* @__PURE__ */ jsxs("div", {
520
- className: "col-span-12 mt-4",
521
- children: [(() => {
522
- const orderPropertyMissing = Boolean(values.orderProperty) && !textProperties.some((p) => p.key === values.orderProperty);
523
- return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Select, {
524
- name: "orderProperty",
525
- label: "Order Property",
526
- fullWidth: true,
527
- position: "item-aligned",
528
- disabled: textProperties.length === 0,
529
- error: orderPropertyMissing,
530
- value: values.orderProperty ?? "",
531
- onValueChange: (v) => {
532
- setFieldValue("orderProperty", v || void 0);
533
- },
534
- renderValue: (value) => {
535
- if (orderPropertyMissing) return /* @__PURE__ */ jsxs("span", {
536
- className: "text-red-500",
537
- children: [value, " (not found)"]
538
- });
539
- const prop = textProperties.find((p) => p.key === value);
540
- if (!prop) return "Select a property";
541
- return /* @__PURE__ */ jsxs("div", {
542
- className: "flex items-center gap-2",
543
- children: [/* @__PURE__ */ jsx(PropertyConfigBadge, { propertyConfig: getFieldConfig(prop.property, customizationController?.propertyConfigs ?? {}) }), /* @__PURE__ */ jsx("span", { children: prop.label })]
544
- });
545
- },
546
- endAdornment: values.orderProperty ? /* @__PURE__ */ jsx(IconButton, {
547
- size: "small",
548
- onClick: (e) => {
549
- e.stopPropagation();
550
- setFieldValue("orderProperty", void 0);
551
- },
552
- children: /* @__PURE__ */ jsx(XIcon, { size: iconSize.smallest })
553
- }) : void 0,
554
- children: textProperties.map((prop) => {
555
- const fieldConfig = getFieldConfig(prop.property, customizationController?.propertyConfigs ?? {});
556
- return /* @__PURE__ */ jsx(SelectItem, {
557
- value: prop.key,
558
- children: /* @__PURE__ */ jsxs("div", {
559
- className: "flex items-center gap-3",
560
- children: [/* @__PURE__ */ jsx(PropertyConfigBadge, { propertyConfig: fieldConfig }), /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("div", { children: prop.label }), /* @__PURE__ */ jsx(Typography, {
561
- variant: "caption",
562
- color: "secondary",
563
- children: fieldConfig?.name || "Text"
564
- })] })]
565
- })
566
- }, prop.key);
567
- })
568
- }, `order-select-${textProperties.length}`), /* @__PURE__ */ jsx(FieldCaption, {
569
- error: orderPropertyMissing,
570
- children: orderPropertyMissing ? `Property "${values.orderProperty}" does not exist or is not a text property. Please select a valid property or clear the selection.` : textProperties.length === 0 ? "No text properties found. Add a text property to enable ordering." : "Select a text property to persist the order of items"
571
- })] });
572
- })(), (() => {
573
- const orderPropertyMissing = Boolean(values.orderProperty) && !textProperties.some((p) => p.key === values.orderProperty);
574
- const showCreateButton = !values.orderProperty || orderPropertyMissing;
575
- const dialogPropertyKey = orderPropertyMissing && values.orderProperty ? values.orderProperty : "__order";
576
- const dialogPropertyName = orderPropertyMissing && values.orderProperty ? unslugify(values.orderProperty) : "Order";
577
- if (!showCreateButton) return null;
578
- return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(Button, {
579
- variant: "text",
580
- size: "small",
581
- className: "ml-3.5 mt-2",
582
- onClick: () => setOrderPropertyDialogOpen(true),
583
- children: [
584
- "+ Create \"",
585
- dialogPropertyKey,
586
- "\" property"
587
- ]
588
- }), /* @__PURE__ */ jsx(PropertyFormDialog, {
589
- open: orderPropertyDialogOpen,
590
- onCancel: () => setOrderPropertyDialogOpen(false),
591
- property: {
592
- type: "string",
593
- name: dialogPropertyName,
594
- admin: {
595
- disabled: true,
596
- hideFromCollection: true
597
- }
598
- },
599
- propertyKey: dialogPropertyKey,
600
- existingProperty: false,
601
- autoOpenTypeSelect: false,
602
- autoUpdateId: false,
603
- inArray: false,
604
- allowDataInference: false,
605
- propertyConfigs: customizationController?.propertyConfigs ?? {},
606
- existingPropertyKeys: Object.keys(values.properties ?? {}),
607
- onPropertyChanged: ({ id, property }) => {
608
- const newProperties = {
609
- ...values.properties,
610
- [id]: property
611
- };
612
- const newPropertiesOrder = [...values.propertiesOrder ?? Object.keys(values.properties ?? {}), id];
613
- setFieldValue("properties", newProperties);
614
- setFieldValue("propertiesOrder", newPropertiesOrder);
615
- setFieldValue("orderProperty", id);
616
- setOrderPropertyDialogOpen(false);
617
- }
618
- })] });
619
- })()]
620
- }),
621
- /* @__PURE__ */ jsx("div", {
622
- className: "col-span-12",
623
- children: /* @__PURE__ */ jsx(Select, {
624
- name: "defaultSize",
625
- fullWidth: true,
626
- label: "Default row size",
627
- position: "item-aligned",
628
- onChange: handleChange,
629
- value: values.defaultSize ?? "",
630
- renderValue: (value) => value.toUpperCase(),
631
- children: [
632
- "xs",
633
- "s",
634
- "m",
635
- "l",
636
- "xl"
637
- ].map((value) => /* @__PURE__ */ jsx(SelectItem, {
638
- value,
639
- children: value.toUpperCase()
640
- }, `size-select-${value}`))
641
- })
642
- }),
643
- /* @__PURE__ */ jsxs("div", {
644
- className: "col-span-12",
645
- children: [/* @__PURE__ */ jsx(TextField, {
646
- name: "sideDialogWidth",
647
- type: "number",
648
- "aria-describedby": "sideDialogWidth-helper",
649
- onChange: (e) => {
650
- const value = e.target.value;
651
- if (!value) setFieldValue("sideDialogWidth", null);
652
- else if (!isNaN(Number(value))) setFieldValue("sideDialogWidth", Number(value));
653
- },
654
- endAdornment: /* @__PURE__ */ jsx(IconButton, {
655
- size: "small",
656
- onClick: () => {
657
- setFieldValue("sideDialogWidth", null);
658
- },
659
- disabled: !values.sideDialogWidth,
660
- children: /* @__PURE__ */ jsx(XIcon, { size: iconSize.small })
661
- }),
662
- value: values.sideDialogWidth ?? "",
663
- label: "Side dialog width"
664
- }), /* @__PURE__ */ jsx(FieldCaption, { children: "Optionally define the width (in pixels) of entities side dialog. Default is 768px" })]
665
- }),
666
- /* @__PURE__ */ jsxs("div", {
667
- className: "col-span-12",
668
- children: [/* @__PURE__ */ jsx(BooleanSwitchWithLabel, {
669
- position: "start",
670
- label: values.inlineEditing === void 0 || values.inlineEditing ? "Data can be edited directly in the table view" : "Data can be edited only in the form view",
671
- onValueChange: (v) => setFieldValue("inlineEditing", v),
672
- value: values.inlineEditing === void 0 ? true : values.inlineEditing
673
- }), /* @__PURE__ */ jsx(FieldCaption, { children: "Allow editing data directly in the table view, without opening the form view." })]
674
- }),
675
- /* @__PURE__ */ jsxs("div", {
676
- className: "col-span-12",
677
- children: [/* @__PURE__ */ jsx(BooleanSwitchWithLabel, {
678
- position: "start",
679
- label: values.includeJsonView === void 0 || values.includeJsonView ? "Include JSON view" : "Do not include JSON view",
680
- onValueChange: (v) => setFieldValue("includeJsonView", v),
681
- value: values.includeJsonView === void 0 ? true : values.includeJsonView
682
- }), /* @__PURE__ */ jsx(FieldCaption, { children: "Allows removing the form view JSON tab if you think it is confusing for your users." })]
683
- })
684
- ]
685
- })
686
- }),
687
- /* @__PURE__ */ jsx("div", { style: { height: "52px" } })
688
- ]
689
- })
690
- });
691
- }
692
- //#endregion
693
- //#region src/collection_editor/ui/collection_editor/GetCodeDialog.tsx
694
- function GetCodeDialog({ collection, onOpenChange, open }) {
695
- const snackbarController = useSafeSnackbarController();
696
- const code = collection ? "import { AdminCollection } from \"@rebasepro/app\";\n\nconst " + (collection?.name ? camelCase(collection.name) : "my") + "Collection:AdminCollection = " + JSON5.stringify(collectionToCode({ ...collection }), null, " ") : "No collection selected";
697
- return /* @__PURE__ */ jsxs(Dialog, {
698
- open,
699
- onOpenChange,
700
- maxWidth: "4xl",
701
- children: [
702
- /* @__PURE__ */ jsxs(DialogTitle, {
703
- variant: "h6",
704
- children: ["Code for ", collection.name]
705
- }),
706
- /* @__PURE__ */ jsxs(DialogContent, { children: [/* @__PURE__ */ jsxs(Typography, {
707
- variant: "body2",
708
- className: "my-4 mb-8",
709
- children: [
710
- "If you want to customise the collection in code, you can add this collection code to your admin app configuration. More info in the ",
711
- /* @__PURE__ */ jsx("a", {
712
- rel: "noopener noreferrer",
713
- href: "https://rebase.pro/docs/cloud/quickstart",
714
- children: "docs"
715
- }),
716
- "."
717
- ]
718
- }), /* @__PURE__ */ jsx(Highlight, {
719
- theme: themes.vsDark,
720
- code,
721
- language: "typescript",
722
- children: ({ className, style, tokens, getLineProps, getTokenProps }) => /* @__PURE__ */ jsx("pre", {
723
- style,
724
- className: "p-4 rounded-xs text-sm",
725
- children: tokens.map((line, i) => /* @__PURE__ */ jsx("div", {
726
- ...getLineProps({ line }),
727
- children: line.map((token, key) => /* @__PURE__ */ jsx("span", { ...getTokenProps({ token }) }, key))
728
- }, i))
729
- })
730
- })] }),
731
- /* @__PURE__ */ jsxs(DialogActions, { children: [/* @__PURE__ */ jsxs(Button, {
732
- variant: "text",
733
- size: "small",
734
- onClick: (e) => {
735
- e.stopPropagation();
736
- e.preventDefault();
737
- snackbarController?.open({
738
- type: "success",
739
- message: "Copied"
740
- });
741
- return navigator.clipboard.writeText(code);
742
- },
743
- children: [/* @__PURE__ */ jsx(CopyIcon, {}), "CopyIcon to clipboard"]
744
- }), /* @__PURE__ */ jsx(Button, {
745
- onClick: () => onOpenChange(false),
746
- children: "Close"
747
- })] })
748
- ]
749
- });
750
- }
751
- function collectionToCode(collection) {
752
- const propertyCleanup = (value) => {
753
- if (value === void 0 || value === null) return value;
754
- const valueCopy = clone(value);
755
- if (typeof valueCopy === "function") return valueCopy;
756
- if (Array.isArray(valueCopy)) return valueCopy.map((v) => propertyCleanup(v));
757
- if (typeof valueCopy === "object") {
758
- if (valueCopy === null) return valueCopy;
759
- const obj = valueCopy;
760
- Object.keys(obj).forEach((key) => {
761
- if (!isEmptyObject(obj)) {
762
- const childRes = propertyCleanup(obj[key]);
763
- if (childRes !== null && childRes !== void 0 && childRes !== false && !isEmptyObject(childRes)) obj[key] = childRes;
764
- else delete obj[key];
765
- }
766
- });
767
- delete obj.resolved;
768
- delete obj.propertiesOrder;
769
- delete obj.propertyConfig;
770
- }
771
- return valueCopy;
772
- };
773
- return {
774
- id: collection.slug,
775
- name: collection.name,
776
- singularName: collection.singularName,
777
- path: collection.slug,
778
- description: collection.description,
779
- icon: collection.icon,
780
- defaultFilter: collection.defaultFilter,
781
- sort: collection.sort,
782
- properties: Object.entries({ ...collection.properties ?? {} }).map(([key, value]) => ({ [key]: propertyCleanup(value) })).reduce((a, b) => ({
783
- ...a,
784
- ...b
785
- }), {})
786
- };
787
- }
788
- //#endregion
789
- //#region src/collection_editor/ui/collection_editor/CollectionPropertiesEditorForm.tsx
790
- function CollectionPropertiesEditorForm({ showErrors, isNewCollection, propertyErrorsRef, onPropertyError, setDirty, extraIcon, getUser, getData, doCollectionInference, propertyConfigs, propertyTypePresets, hiddenPropertyTypes, renderExtraPropertyFields, standalone }) {
791
- const { values, setFieldValue, setFieldError, setFieldTouched, errors, dirty } = useFormex();
792
- const snackbarController = useSafeSnackbarController();
793
- const { t } = useTranslation();
794
- const configControllerFromContext = useCollectionsConfigController();
795
- const configController = standalone ? { readOnly: false } : configControllerFromContext;
796
- const largeLayout = useLargeLayout();
797
- const asDialog = standalone ? false : !largeLayout;
798
- const [selectedPropertyIndex, setSelectedPropertyIndex] = useState();
799
- const [selectedPropertyKey, setSelectedPropertyKey] = useState();
800
- const [selectedPropertyNamespace, setSelectedPropertyNamespace] = useState();
801
- const selectedPropertyFullId = selectedPropertyKey ? getFullId(selectedPropertyKey, selectedPropertyNamespace) : void 0;
802
- const selectedProperty = selectedPropertyFullId ? getIn(values.properties, selectedPropertyFullId.replaceAll(".", ".properties.")) : void 0;
803
- const [codeDialogOpen, setCodeDialogOpen] = useState(false);
804
- const [inferringProperties, setInferringProperties] = useState(false);
805
- const [newPropertyDialogOpen, setNewPropertyDialogOpen] = useState(false);
806
- const [inferredPropertyKeys, setInferredPropertyKeys] = useState([]);
807
- const currentPropertiesOrderRef = React.useRef(values.propertiesOrder ? { "": values.propertiesOrder } : {});
808
- useEffect(() => {
809
- if (setDirty) setDirty(dirty);
810
- }, [dirty]);
811
- const inferPropertiesFromData = doCollectionInference ? () => {
812
- const inferenceFn = doCollectionInference;
813
- if (!inferenceFn || configController?.readOnly) return;
814
- setInferringProperties(true);
815
- console.debug("CollectionEditor: inferring properties from data", values);
816
- const promise = inferenceFn(values);
817
- if (!promise) {
818
- setInferringProperties(false);
819
- return;
820
- }
821
- promise.then((newCollection) => {
822
- if (!newCollection) {
823
- snackbarController?.open?.({
824
- type: "error",
825
- message: "Could not infer properties from data"
826
- });
827
- return;
828
- }
829
- const findNewPropertyKeys = (existingProps, newProps, namespace) => {
830
- if (!newProps) return [];
831
- const keys = [];
832
- for (const key of Object.keys(newProps)) {
833
- const fullKey = namespace ? `${namespace}.${key}` : key;
834
- const existingProp = existingProps?.[key];
835
- const newProp = newProps[key];
836
- if (!existingProp) keys.push(fullKey);
837
- else if (typeof newProp === "object" && "type" in newProp && newProp.type === "map" && newProp.properties) {
838
- const existingMapProps = typeof existingProp === "object" && "type" in existingProp && existingProp.type === "map" ? existingProp.properties : void 0;
839
- keys.push(...findNewPropertyKeys(existingMapProps, newProp.properties, fullKey));
840
- }
841
- }
842
- return keys;
843
- };
844
- const addNewPropertiesOnly = (existingProps, newProps) => {
845
- if (!newProps) return existingProps ?? {};
846
- if (!existingProps) return newProps;
847
- const result = { ...existingProps };
848
- for (const key of Object.keys(newProps)) {
849
- const existingProp = existingProps[key];
850
- const newProp = newProps[key];
851
- if (!existingProp) result[key] = newProp;
852
- else if (typeof existingProp === "object" && "type" in existingProp && existingProp.type === "map" && typeof newProp === "object" && "type" in newProp && newProp.type === "map" && newProp.properties) {
853
- const existingMapProps = existingProp.properties;
854
- if (existingMapProps) result[key] = {
855
- ...existingProp,
856
- properties: addNewPropertiesOnly(existingMapProps, newProp.properties)
857
- };
858
- }
859
- }
860
- return result;
861
- };
862
- const updatedProperties = addNewPropertiesOnly(values.properties ?? {}, newCollection.properties);
863
- const allNewPropertyKeys = findNewPropertyKeys(values.properties, newCollection.properties);
864
- const newTopLevelPropertyKeys = (newCollection.properties ? Object.keys(newCollection.properties) : []).filter((propertyKey) => !values.properties[propertyKey]);
865
- if (allNewPropertyKeys.length === 0) {
866
- snackbarController?.open?.({
867
- type: "info",
868
- message: "No new properties found in existing data"
869
- });
870
- return;
871
- }
872
- const allExistingKeys = values.propertiesOrder ?? Object.keys(values.properties ?? {});
873
- const updatedPropertiesOrder = [...newTopLevelPropertyKeys, ...allExistingKeys.filter((key) => !newTopLevelPropertyKeys.includes(key))];
874
- setFieldValue("properties", updatedProperties, false);
875
- updatePropertiesOrder(updatedPropertiesOrder);
876
- setInferredPropertyKeys(allNewPropertyKeys);
877
- snackbarController?.open?.({
878
- type: "success",
879
- message: `Added ${allNewPropertyKeys.length} new ${allNewPropertyKeys.length === 1 ? "property" : "properties"}`
880
- });
881
- }).finally(() => {
882
- setInferringProperties(false);
883
- });
884
- } : void 0;
885
- const getCurrentPropertiesOrder = (namespace) => {
886
- if (!namespace) return currentPropertiesOrderRef.current[""] ?? getIn(values, namespaceToPropertiesOrderPath());
887
- return currentPropertiesOrderRef.current[namespace] ?? getIn(values, namespaceToPropertiesOrderPath(namespace));
888
- };
889
- const updatePropertiesOrder = (newPropertiesOrder, namespace) => {
890
- const propertiesOrderPath = namespaceToPropertiesOrderPath(namespace);
891
- setFieldValue(propertiesOrderPath, newPropertiesOrder, false);
892
- currentPropertiesOrderRef.current[namespace ?? ""] = newPropertiesOrder;
893
- };
894
- const deleteProperty = (propertyKey, namespace) => {
895
- if (configController?.readOnly) return;
896
- const fullId = propertyKey ? getFullId(propertyKey, namespace) : void 0;
897
- if (!fullId) throw Error("collection editor miss config");
898
- setFieldValue(idToPropertiesPath(fullId), void 0, false);
899
- const currentPropertiesOrder = getCurrentPropertiesOrder(namespace);
900
- if (currentPropertiesOrder) {
901
- const newPropertiesOrder = currentPropertiesOrder.filter((p) => p !== propertyKey);
902
- updatePropertiesOrder(newPropertiesOrder, namespace);
903
- }
904
- setNewPropertyDialogOpen(false);
905
- setSelectedPropertyIndex(void 0);
906
- setSelectedPropertyKey(void 0);
907
- setSelectedPropertyNamespace(void 0);
908
- };
909
- const onPropertyMove = (propertiesOrder, namespace) => {
910
- if (configController?.readOnly) return;
911
- setFieldValue(namespaceToPropertiesOrderPath(namespace), propertiesOrder, false);
912
- };
913
- const onPropertyCreated = ({ id, property }) => {
914
- if (configController?.readOnly) return;
915
- if (!id) throw Error("Need to include an ID when creating a new property");
916
- setFieldValue("properties", {
917
- ...values.properties ?? {},
918
- [id]: property
919
- }, false);
920
- const newPropertiesOrder = [...values.propertiesOrder ?? Object.keys(values.properties), id];
921
- updatePropertiesOrder(newPropertiesOrder);
922
- setNewPropertyDialogOpen(false);
923
- if (largeLayout) {
924
- setSelectedPropertyIndex(newPropertiesOrder.indexOf(id));
925
- setSelectedPropertyKey(id);
926
- }
927
- setSelectedPropertyNamespace(void 0);
928
- };
929
- const onPropertyChanged = ({ id, property, previousId, namespace }) => {
930
- const fullId = id ? getFullId(id, namespace) : void 0;
931
- const propertyPath = fullId ? idToPropertiesPath(fullId) : void 0;
932
- if (previousId && previousId !== id) {
933
- const previousPropertyPath = idToPropertiesPath(getFullId(previousId, namespace));
934
- const newPropertiesOrder = getCurrentPropertiesOrder(namespace).map((p) => p === previousId ? id : p).filter((p) => p !== void 0);
935
- updatePropertiesOrder(newPropertiesOrder, namespace);
936
- if (id) {
937
- setSelectedPropertyIndex(newPropertiesOrder.indexOf(id));
938
- setSelectedPropertyKey(id);
939
- }
940
- setFieldValue(previousPropertyPath, void 0, false);
941
- setFieldTouched(previousPropertyPath, false, false);
942
- }
943
- if (propertyPath) {
944
- setFieldValue(propertyPath, property, false);
945
- setFieldTouched(propertyPath, true, false);
946
- }
947
- };
948
- const onPropertyErrorInternal = (id, namespace, error) => {
949
- const propertyPath = id ? getFullId(id, namespace) : void 0;
950
- console.debug("onPropertyErrorInternal", {
951
- id,
952
- namespace,
953
- error,
954
- propertyPath
955
- });
956
- if (propertyPath) {
957
- const hasError = error && Object.keys(error).length > 0;
958
- onPropertyError(id, namespace, hasError ? error : void 0);
959
- setFieldError(idToPropertiesPath(propertyPath), hasError ? "Property error" : void 0);
960
- }
961
- };
962
- const closePropertyDialog = () => {
963
- setSelectedPropertyIndex(void 0);
964
- setSelectedPropertyKey(void 0);
965
- };
966
- const initialErrors = selectedPropertyKey && propertyErrorsRef?.current?.properties ? propertyErrorsRef.current.properties[selectedPropertyKey] : void 0;
967
- const emptyCollection = (values?.propertiesOrder === void 0 || values.propertiesOrder.length === 0) && (!values?.properties || Object.keys(values.properties).length === 0);
968
- const usedPropertiesOrder = values.propertiesOrder ? values.propertiesOrder : Object.keys(values.properties);
969
- const selectedNamespaceOrder = getCurrentPropertiesOrder(selectedPropertyNamespace);
970
- const otherPropertyKeys = useMemo(() => (selectedNamespaceOrder ?? []).filter((key) => key !== selectedPropertyKey), [selectedNamespaceOrder, selectedPropertyKey]);
971
- const owner = useMemo(() => values.ownerId && getUser ? getUser(values.ownerId) : null, [getUser, values.ownerId]);
972
- const generationCounter = useAIModifiedPaths()?.generationCounter ?? 0;
973
- const onPropertyClick = (propertyKey, namespace) => {
974
- console.debug("CollectionEditor: onPropertyClick", {
975
- propertyKey,
976
- namespace
977
- });
978
- setSelectedPropertyIndex(usedPropertiesOrder.indexOf(propertyKey));
979
- setSelectedPropertyKey(propertyKey);
980
- setSelectedPropertyNamespace(namespace);
981
- };
982
- return /* @__PURE__ */ jsxs(Fragment, { children: [
983
- /* @__PURE__ */ jsxs("div", {
984
- className: "grid grid-cols-12 h-full min-h-0 bg-surface-sheet",
985
- children: [
986
- /* @__PURE__ */ jsxs("div", {
987
- className: cls("col-span-12 lg:col-span-5 h-full min-h-0 flex flex-col bg-surface-sheet", !asDialog && "border-r " + defaultBorderMixin),
988
- children: [/* @__PURE__ */ jsxs("div", {
989
- className: cls("flex items-center justify-between px-3 py-2 border-b min-h-[48px] shrink-0", defaultBorderMixin),
990
- children: [
991
- /* @__PURE__ */ jsx("div", {
992
- className: "flex-grow min-w-0 pr-2",
993
- children: /* @__PURE__ */ jsx(Field, {
994
- name: "name",
995
- as: DebouncedTextField,
996
- invisible: true,
997
- className: "-ml-1",
998
- inputClassName: "text-sm font-semibold truncate bg-transparent border-0 outline-none focus:ring-0",
999
- placeholder: "Collection name",
1000
- size: "small",
1001
- required: true,
1002
- error: Boolean(errors?.name)
1003
- })
1004
- }),
1005
- extraIcon && /* @__PURE__ */ jsx("div", {
1006
- className: "flex-shrink-0",
1007
- children: extraIcon
1008
- }),
1009
- /* @__PURE__ */ jsxs("div", {
1010
- className: "flex items-center gap-1.5 flex-shrink-0 ml-2",
1011
- children: [inferPropertiesFromData && /* @__PURE__ */ jsx(Tooltip, {
1012
- title: "Add new properties based on data",
1013
- asChild: true,
1014
- children: /* @__PURE__ */ jsx(IconButton, {
1015
- "aria-label": "Add new properties based on data",
1016
- size: "small",
1017
- disabled: inferringProperties,
1018
- onClick: inferPropertiesFromData,
1019
- children: inferringProperties ? /* @__PURE__ */ jsx(CircularProgress, { size: "smallest" }) : /* @__PURE__ */ jsx(FileSearchIcon, { size: iconSize.smallest })
1020
- })
1021
- }), /* @__PURE__ */ jsx(Tooltip, {
1022
- title: t("studio_property_add_column"),
1023
- asChild: true,
1024
- children: /* @__PURE__ */ jsx(IconButton, {
1025
- "aria-label": t("studio_property_add_column"),
1026
- size: "small",
1027
- disabled: configController?.readOnly,
1028
- onClick: () => setNewPropertyDialogOpen(true),
1029
- children: /* @__PURE__ */ jsx(PlusIcon, { size: iconSize.smallest })
1030
- })
1031
- })]
1032
- })
1033
- ]
1034
- }), /* @__PURE__ */ jsxs("div", {
1035
- className: "flex-grow overflow-y-auto p-3 space-y-3 bg-surface-sheet",
1036
- children: [
1037
- owner && /* @__PURE__ */ jsx("div", {
1038
- className: "px-1 py-0.5",
1039
- children: /* @__PURE__ */ jsxs(Typography, {
1040
- variant: "body2",
1041
- color: "secondary",
1042
- children: ["Created by ", owner.displayName]
1043
- })
1044
- }),
1045
- /* @__PURE__ */ jsx(ErrorBoundary, { children: /* @__PURE__ */ jsx(PropertyTree, {
1046
- inferredPropertyKeys,
1047
- selectedPropertyKey: selectedPropertyKey ? getFullId(selectedPropertyKey, selectedPropertyNamespace) : void 0,
1048
- properties: values.properties,
1049
- additionalFields: values.additionalFields,
1050
- propertiesOrder: usedPropertiesOrder,
1051
- onPropertyClick,
1052
- onPropertyMove,
1053
- onPropertyRemove: (isNewCollection || inferredPropertyKeys && inferredPropertyKeys.length > 0) && !configController?.readOnly ? deleteProperty : void 0,
1054
- errors
1055
- }) }),
1056
- /* @__PURE__ */ jsx(Button, {
1057
- className: "w-full",
1058
- variant: "outlined",
1059
- color: "neutral",
1060
- disabled: configController?.readOnly,
1061
- onClick: () => setNewPropertyDialogOpen(true),
1062
- startIcon: /* @__PURE__ */ jsx(PlusIcon, {}),
1063
- children: "Add new property"
1064
- })
1065
- ]
1066
- })]
1067
- }),
1068
- !asDialog && /* @__PURE__ */ jsx("div", {
1069
- className: "col-span-12 lg:col-span-7 p-4 md:py-8 md:px-4 h-full overflow-auto bg-surface-sheet",
1070
- children: /* @__PURE__ */ jsxs("div", {
1071
- className: "sticky top-8 min-h-full w-full flex flex-col justify-center",
1072
- children: [
1073
- selectedPropertyFullId && !!selectedProperty && !isPropertyBuilder(selectedProperty) && /* @__PURE__ */ jsx(PropertyForm, {
1074
- inArray: false,
1075
- existingProperty: !isNewCollection,
1076
- autoUpdateId: false,
1077
- allowDataInference: !isNewCollection,
1078
- autoOpenTypeSelect: false,
1079
- propertyKey: selectedPropertyKey,
1080
- propertyNamespace: selectedPropertyNamespace,
1081
- property: selectedProperty,
1082
- existingPropertyKeys: otherPropertyKeys,
1083
- onPropertyChanged,
1084
- onDelete: deleteProperty,
1085
- onError: onPropertyErrorInternal,
1086
- forceShowErrors: showErrors,
1087
- initialErrors,
1088
- getData,
1089
- propertyConfigs,
1090
- propertyTypePresets,
1091
- hiddenPropertyTypes,
1092
- renderExtraPropertyFields,
1093
- collectionValues: values
1094
- }, `edit_view_${selectedPropertyIndex}_${generationCounter}`),
1095
- !selectedProperty && /* @__PURE__ */ jsxs("div", {
1096
- className: "w-full flex flex-col items-center justify-center h-full gap-4",
1097
- children: [/* @__PURE__ */ jsx(Typography, {
1098
- variant: "label",
1099
- className: "",
1100
- children: emptyCollection ? "Now you can add your first property" : "Select a property to edit it"
1101
- }), /* @__PURE__ */ jsxs(Button, {
1102
- disabled: configController?.readOnly,
1103
- onClick: () => setNewPropertyDialogOpen(true),
1104
- children: [/* @__PURE__ */ jsx(PlusIcon, {}), "Add new property"]
1105
- })]
1106
- }),
1107
- !!selectedProperty && isPropertyBuilder(selectedProperty) && /* @__PURE__ */ jsx(Typography, {
1108
- variant: "label",
1109
- className: "flex items-center justify-center",
1110
- children: "This property is defined as a property builder in code"
1111
- })
1112
- ]
1113
- })
1114
- }),
1115
- asDialog && /* @__PURE__ */ jsx(PropertyFormDialog, {
1116
- inArray: false,
1117
- open: selectedPropertyIndex !== void 0,
1118
- autoUpdateId: !selectedProperty,
1119
- allowDataInference: !isNewCollection,
1120
- existingProperty: true,
1121
- autoOpenTypeSelect: false,
1122
- propertyKey: selectedPropertyKey,
1123
- propertyNamespace: selectedPropertyNamespace,
1124
- property: selectedProperty,
1125
- onPropertyChanged,
1126
- onDelete: deleteProperty,
1127
- onError: onPropertyErrorInternal,
1128
- forceShowErrors: showErrors,
1129
- initialErrors,
1130
- getData,
1131
- propertyConfigs,
1132
- propertyTypePresets,
1133
- hiddenPropertyTypes,
1134
- renderExtraPropertyFields,
1135
- collectionValues: values,
1136
- onCancel: closePropertyDialog,
1137
- onOkClicked: asDialog ? closePropertyDialog : void 0
1138
- }, `edit_view_${selectedPropertyIndex}_${generationCounter}`)
1139
- ]
1140
- }),
1141
- /* @__PURE__ */ jsx(PropertyFormDialog, {
1142
- inArray: false,
1143
- existingProperty: false,
1144
- autoOpenTypeSelect: true,
1145
- autoUpdateId: true,
1146
- forceShowErrors: showErrors,
1147
- open: newPropertyDialogOpen,
1148
- onCancel: () => setNewPropertyDialogOpen(false),
1149
- onPropertyChanged: onPropertyCreated,
1150
- getData,
1151
- allowDataInference: !isNewCollection,
1152
- propertyConfigs,
1153
- propertyTypePresets,
1154
- hiddenPropertyTypes,
1155
- renderExtraPropertyFields,
1156
- collectionValues: values,
1157
- existingPropertyKeys: values.propertiesOrder
1158
- }),
1159
- /* @__PURE__ */ jsx(ErrorBoundary, { children: /* @__PURE__ */ jsx(GetCodeDialog, {
1160
- collection: values,
1161
- open: codeDialogOpen,
1162
- onOpenChange: setCodeDialogOpen
1163
- }) })
1164
- ] });
1165
- }
1166
- //#endregion
1167
- //#region src/collection_editor/ui/collection_editor/CollectionJsonImportDialog.tsx
1168
- var EXAMPLE_JSON = `{
1169
- "id": "products",
1170
- "name": "Products",
1171
- "path": "products",
1172
- "icon": "shopping_cart",
1173
- "properties": {
1174
- "name": {
1175
- "type": "string",
1176
- "name": "Name",
1177
- "validation": { "required": true }
1178
- },
1179
- "price": {
1180
- "type": "number",
1181
- "name": "Price"
1182
- },
1183
- "available": {
1184
- "type": "boolean",
1185
- "name": "Available"
1186
- }
1187
- }
1188
- }`;
1189
- function CollectionJsonImportDialog({ open, onClose, onImport }) {
1190
- const [jsonValue, setJsonValue] = useState("");
1191
- const [errors, setErrors] = useState([]);
1192
- const [touched, setTouched] = useState(false);
1193
- const handleJsonChange = useCallback((e) => {
1194
- const value = e.target.value;
1195
- setJsonValue(value);
1196
- setTouched(true);
1197
- if (!value.trim()) {
1198
- setErrors([]);
1199
- return;
1200
- }
1201
- const result = validateCollectionJson(value);
1202
- setErrors(result.errors);
1203
- }, []);
1204
- const handleImport = useCallback(() => {
1205
- const result = validateCollectionJson(jsonValue);
1206
- if (result.valid && result.collection) {
1207
- onImport(result.collection);
1208
- setJsonValue("");
1209
- setErrors([]);
1210
- setTouched(false);
1211
- onClose();
1212
- }
1213
- }, [
1214
- jsonValue,
1215
- onImport,
1216
- onClose
1217
- ]);
1218
- const handleClose = useCallback(() => {
1219
- setJsonValue("");
1220
- setErrors([]);
1221
- setTouched(false);
1222
- onClose();
1223
- }, [onClose]);
1224
- const isValid = touched && jsonValue.trim() && errors.length === 0;
1225
- return /* @__PURE__ */ jsxs(Dialog, {
1226
- open,
1227
- onOpenChange: (open) => !open && handleClose(),
1228
- maxWidth: "2xl",
1229
- children: [
1230
- /* @__PURE__ */ jsxs(DialogTitle, {
1231
- className: "flex items-center gap-2",
1232
- children: [/* @__PURE__ */ jsx(CodeIcon, { size: iconSize.smallest }), "Import Collection from JSON"]
1233
- }),
1234
- /* @__PURE__ */ jsxs(DialogContent, {
1235
- className: "flex flex-col gap-4",
1236
- children: [
1237
- /* @__PURE__ */ jsxs(Typography, {
1238
- variant: "body2",
1239
- color: "secondary",
1240
- children: [
1241
- "Paste a JSON object representing your collection configuration. The JSON must include ",
1242
- /* @__PURE__ */ jsx("code", {
1243
- className: "bg-surface-raised px-1 rounded",
1244
- children: "id"
1245
- }),
1246
- ",",
1247
- /* @__PURE__ */ jsx("code", {
1248
- className: "bg-surface-raised px-1 rounded",
1249
- children: "name"
1250
- }),
1251
- ",",
1252
- /* @__PURE__ */ jsx("code", {
1253
- className: "bg-surface-raised px-1 rounded",
1254
- children: "path"
1255
- }),
1256
- ", and",
1257
- /* @__PURE__ */ jsx("code", {
1258
- className: "bg-surface-raised px-1 rounded",
1259
- children: "properties"
1260
- }),
1261
- "."
1262
- ]
1263
- }),
1264
- /* @__PURE__ */ jsx(TextField, {
1265
- multiline: true,
1266
- minRows: 12,
1267
- "aria-label": "Collection JSON",
1268
- value: jsonValue,
1269
- onChange: handleJsonChange,
1270
- placeholder: EXAMPLE_JSON,
1271
- error: errors.length > 0 && touched,
1272
- className: "w-full",
1273
- inputClassName: "font-mono text-sm resize-none overflow-y-auto h-[300px]"
1274
- }),
1275
- errors.length > 0 && touched && /* @__PURE__ */ jsxs(Alert, {
1276
- color: "error",
1277
- children: [/* @__PURE__ */ jsx(Typography, {
1278
- variant: "body2",
1279
- className: "font-medium mb-2",
1280
- children: "Validation errors:"
1281
- }), /* @__PURE__ */ jsx("ul", {
1282
- className: "list-disc list-inside space-y-1",
1283
- children: errors.map((error, index) => /* @__PURE__ */ jsx("li", {
1284
- className: "text-sm",
1285
- children: error.path ? /* @__PURE__ */ jsxs(Fragment, { children: [
1286
- /* @__PURE__ */ jsx("code", {
1287
- className: "bg-red-100 dark:bg-red-900/40 px-1 rounded",
1288
- children: error.path
1289
- }),
1290
- ": ",
1291
- error.message
1292
- ] }) : error.message
1293
- }, index))
1294
- })]
1295
- }),
1296
- isValid && /* @__PURE__ */ jsx(Alert, {
1297
- color: "success",
1298
- children: /* @__PURE__ */ jsx(Typography, {
1299
- variant: "body2",
1300
- children: "✓ JSON is valid and ready to import"
1301
- })
1302
- })
1303
- ]
1304
- }),
1305
- /* @__PURE__ */ jsxs(DialogActions, { children: [/* @__PURE__ */ jsx(Button, {
1306
- variant: "text",
1307
- onClick: handleClose,
1308
- children: "Cancel"
1309
- }), /* @__PURE__ */ jsx(Button, {
1310
- variant: "filled",
1311
- color: "primary",
1312
- onClick: handleImport,
1313
- disabled: !isValid,
1314
- children: "Import Collection"
1315
- })] })
1316
- ]
1317
- });
1318
- }
1319
- //#endregion
1320
- //#region src/collection_editor/ui/collection_editor/templates/products_template.ts
1321
- var productsCollectionTemplate = {
1322
- slug: "products",
1323
- table: "products",
1324
- name: "Products",
1325
- singularName: "Product",
1326
- icon: "ShoppingCart",
1327
- description: "List of the products currently sold in your shop",
1328
- properties: {
1329
- name: {
1330
- type: "string",
1331
- name: "Name",
1332
- description: "Name of this product",
1333
- validation: { required: true }
1334
- },
1335
- brand: {
1336
- type: "string",
1337
- name: "Brand",
1338
- validation: { required: true }
1339
- },
1340
- description: {
1341
- type: "string",
1342
- name: "Description",
1343
- description: "Description of this product, supports markdown",
1344
- admin: { markdown: true }
1345
- },
1346
- main_image: {
1347
- type: "string",
1348
- name: "Image",
1349
- storage: {
1350
- storagePath: "images",
1351
- acceptedFiles: ["image/*"]
1352
- },
1353
- description: "Upload field for images"
1354
- },
1355
- available: {
1356
- type: "boolean",
1357
- name: "Available",
1358
- admin: { columnWidth: 100 },
1359
- description: "Is this product available in the website"
1360
- },
1361
- price: {
1362
- type: "number",
1363
- name: "Price",
1364
- validation: {
1365
- requiredMessage: "You must set a positive price",
1366
- min: 0
1367
- }
1368
- },
1369
- images: {
1370
- type: "array",
1371
- name: "Images",
1372
- admin: { hideFromCollection: true },
1373
- of: {
1374
- type: "string",
1375
- storage: {
1376
- storagePath: "images",
1377
- acceptedFiles: ["image/*"]
1378
- }
1379
- }
1380
- },
1381
- related_products: {
1382
- type: "array",
1383
- name: "Related products",
1384
- description: "Products related to this one",
1385
- of: {
1386
- type: "reference",
1387
- path: "products"
1388
- }
1389
- },
1390
- metadata: {
1391
- name: "Metadata",
1392
- description: "This is an example of a map property",
1393
- type: "map",
1394
- keyValue: true
1395
- },
1396
- added_on: {
1397
- type: "date",
1398
- name: "Added on",
1399
- autoValue: "on_create"
1400
- }
1401
- }
1402
- };
1403
- //#endregion
1404
- //#region src/collection_editor/ui/collection_editor/templates/blog_template.ts
1405
- var blogCollectionTemplate = {
1406
- slug: "blog",
1407
- table: "blog",
1408
- name: "Blog",
1409
- singularName: "Blog entry",
1410
- icon: "FileText",
1411
- description: "A collection of blog entries",
1412
- defaultSize: "l",
1413
- properties: {
1414
- name: {
1415
- name: "Name",
1416
- validation: { required: true },
1417
- type: "string"
1418
- },
1419
- header_image: {
1420
- name: "Header image",
1421
- type: "string",
1422
- storage: {
1423
- storagePath: "images",
1424
- acceptedFiles: ["image/*"],
1425
- metadata: { cacheControl: "max-age=1000000" }
1426
- }
1427
- },
1428
- content: {
1429
- name: "Content",
1430
- description: "Content blocks for the blog entry",
1431
- validation: { required: true },
1432
- type: "array",
1433
- oneOf: {
1434
- typeField: "type",
1435
- valueField: "value",
1436
- properties: {
1437
- text: {
1438
- type: "string",
1439
- name: "Text",
1440
- admin: { markdown: true }
1441
- },
1442
- quote: {
1443
- type: "string",
1444
- name: "Quote",
1445
- admin: { multiline: true }
1446
- },
1447
- images: {
1448
- name: "Images",
1449
- type: "array",
1450
- of: {
1451
- type: "string",
1452
- storage: {
1453
- storagePath: "images",
1454
- acceptedFiles: ["image/*"],
1455
- metadata: { cacheControl: "max-age=1000000" }
1456
- }
1457
- },
1458
- description: "This fields allows uploading multiple images at once and reordering"
1459
- },
1460
- products: {
1461
- name: "Products",
1462
- type: "array",
1463
- of: {
1464
- type: "reference",
1465
- path: "products",
1466
- admin: { previewProperties: ["name", "main_image"] }
1467
- }
1468
- }
1469
- },
1470
- propertiesOrder: [
1471
- "text",
1472
- "quote",
1473
- "images",
1474
- "products"
1475
- ]
1476
- }
1477
- },
1478
- created_on: {
1479
- name: "Created on",
1480
- type: "date",
1481
- autoValue: "on_create"
1482
- },
1483
- status: {
1484
- name: "Status",
1485
- validation: { required: true },
1486
- type: "string",
1487
- enum: {
1488
- published: {
1489
- id: "published",
1490
- label: "Published"
1491
- },
1492
- draft: "Draft"
1493
- },
1494
- defaultValue: "draft"
1495
- },
1496
- publish_date: {
1497
- name: "Publish date",
1498
- type: "date",
1499
- admin: { clearable: true }
1500
- },
1501
- reviewed: {
1502
- name: "Reviewed",
1503
- type: "boolean"
1504
- },
1505
- tags: {
1506
- name: "Tags",
1507
- description: "Example of generic array",
1508
- type: "array",
1509
- of: {
1510
- type: "string",
1511
- admin: { previewAsTag: true }
1512
- }
1513
- }
1514
- }
1515
- };
1516
- //#endregion
1517
- //#region src/collection_editor/ui/collection_editor/templates/users_template.ts
1518
- var usersCollectionTemplate = {
1519
- slug: "users",
1520
- table: "users",
1521
- name: "Users",
1522
- singularName: "User",
1523
- description: "Registered users in the app/web",
1524
- icon: "User",
1525
- properties: {
1526
- displayName: {
1527
- name: "Display name",
1528
- type: "string"
1529
- },
1530
- email: {
1531
- name: "Email",
1532
- type: "string",
1533
- email: true
1534
- },
1535
- emailVerified: {
1536
- name: "Email verified",
1537
- type: "boolean"
1538
- },
1539
- phone: {
1540
- name: "Phone",
1541
- type: "string"
1542
- },
1543
- favourite_products: {
1544
- name: "Favourite products",
1545
- type: "array",
1546
- of: {
1547
- type: "reference",
1548
- path: "products"
1549
- }
1550
- },
1551
- photoURL: {
1552
- name: "Photo URL",
1553
- type: "string",
1554
- url: true,
1555
- admin: { urlPreview: "image" }
1556
- }
1557
- }
1558
- };
1559
- //#endregion
1560
- //#region src/collection_editor/ui/collection_editor/templates/pages_template.ts
1561
- var pagesCollectionTemplate = {
1562
- slug: "pages",
1563
- table: "pages",
1564
- name: "Pages",
1565
- singularName: "Page",
1566
- icon: "File",
1567
- description: "List of website pages that can be edited here",
1568
- properties: {
1569
- title: {
1570
- type: "string",
1571
- name: "Page Title",
1572
- validation: { required: true }
1573
- },
1574
- slug: {
1575
- type: "string",
1576
- name: "URL Slug",
1577
- validation: {
1578
- required: true,
1579
- unique: true,
1580
- matches: "^[a-z0-9]+(?:-[a-z0-9]+)*$",
1581
- matchesMessage: "Must be lowercase, alphanumeric, and hyphenated"
1582
- }
1583
- },
1584
- hero_section: {
1585
- type: "map",
1586
- name: "Hero Section",
1587
- properties: {
1588
- headline: {
1589
- type: "string",
1590
- name: "Headline",
1591
- validation: { required: true }
1592
- },
1593
- subhead: {
1594
- type: "string",
1595
- name: "Subheadline"
1596
- },
1597
- background_image: {
1598
- type: "string",
1599
- name: "Background Image",
1600
- storage: {
1601
- storagePath: "page_hero/images",
1602
- acceptedFiles: ["image/*"]
1603
- }
1604
- },
1605
- call_to_action: {
1606
- type: "string",
1607
- name: "Call to Action"
1608
- },
1609
- call_to_action_link: {
1610
- type: "string",
1611
- name: "CTA Link",
1612
- url: true
1613
- }
1614
- }
1615
- },
1616
- content: {
1617
- type: "array",
1618
- name: "Content",
1619
- oneOf: { properties: {
1620
- section: {
1621
- type: "map",
1622
- name: "Section",
1623
- properties: {
1624
- title: {
1625
- type: "string",
1626
- name: "Section Title",
1627
- validation: { required: true }
1628
- },
1629
- content: {
1630
- type: "string",
1631
- name: "Section Content",
1632
- admin: { markdown: true }
1633
- },
1634
- image: {
1635
- type: "string",
1636
- name: "Section Image",
1637
- storage: {
1638
- storagePath: "page_sections/images",
1639
- acceptedFiles: ["image/*"]
1640
- }
1641
- },
1642
- link: {
1643
- type: "string",
1644
- name: "Section Link",
1645
- url: true
1646
- }
1647
- }
1648
- },
1649
- image: {
1650
- type: "string",
1651
- name: "Image",
1652
- storage: {
1653
- storagePath: "page_sections/images",
1654
- acceptedFiles: ["image/*"]
1655
- }
1656
- },
1657
- slider: {
1658
- type: "array",
1659
- name: "Slider",
1660
- of: {
1661
- type: "map",
1662
- properties: {
1663
- title: {
1664
- type: "string",
1665
- name: "Title",
1666
- validation: { required: true }
1667
- },
1668
- image: {
1669
- type: "string",
1670
- storage: {
1671
- storagePath: "page_sections/images",
1672
- acceptedFiles: ["image/*"]
1673
- }
1674
- }
1675
- }
1676
- }
1677
- }
1678
- } }
1679
- },
1680
- sidebar: {
1681
- type: "map",
1682
- name: "Sidebar",
1683
- properties: {
1684
- title: {
1685
- type: "string",
1686
- name: "Sidebar Title",
1687
- validation: { required: false }
1688
- },
1689
- content: {
1690
- type: "string",
1691
- name: "Sidebar Content",
1692
- admin: { markdown: true }
1693
- }
1694
- }
1695
- },
1696
- seo_metadata: {
1697
- type: "map",
1698
- name: "SEO Metadata",
1699
- properties: {
1700
- meta_title: {
1701
- type: "string",
1702
- name: "Meta Title"
1703
- },
1704
- meta_description: {
1705
- type: "string",
1706
- name: "Meta Description"
1707
- },
1708
- focus_keywords: {
1709
- type: "array",
1710
- name: "Focus Keywords",
1711
- of: { type: "string" }
1712
- }
1713
- }
1714
- },
1715
- footer_override: {
1716
- type: "string",
1717
- name: "Footer Override",
1718
- admin: { markdown: true }
1719
- },
1720
- publish_date: {
1721
- type: "date",
1722
- name: "Publish Date",
1723
- validation: { required: true }
1724
- },
1725
- last_updated: {
1726
- type: "date",
1727
- name: "Last Updated",
1728
- autoValue: "on_update"
1729
- },
1730
- is_published: {
1731
- type: "boolean",
1732
- name: "Is Published",
1733
- admin: { columnWidth: 100 },
1734
- description: "Should this page be live on the site?"
1735
- }
1736
- }
1737
- };
1738
- //#endregion
1739
- //#region src/collection_editor/ui/collection_editor/AICollectionGeneratorPopover.tsx
1740
- function AICollectionGeneratorPopover({ existingCollection, onGenerated, generateCollection, trigger, size = "small", showLabel = true, onAnalyticsEvent }) {
1741
- const { t } = useTranslation();
1742
- const [menuOpen, setMenuOpen] = useState(false);
1743
- const [prompt, setPrompt] = useState("");
1744
- const [loading, setLoading] = useState(false);
1745
- const [error, setError] = useState(null);
1746
- const collectionRegistry = useCollectionRegistryController();
1747
- const configController = useCollectionsConfigController();
1748
- const snackbarController = useSafeSnackbarController();
1749
- const existingCollections = collectionRegistry.collections ?? [];
1750
- const handleGenerate = async () => {
1751
- if (!prompt.trim()) return;
1752
- setLoading(true);
1753
- setError(null);
1754
- const mode = existingCollection ? "modify" : "create";
1755
- onAnalyticsEvent?.("ai_collection_generate_start", { mode });
1756
- try {
1757
- const collectionsContext = existingCollections.map((c) => ({
1758
- slug: c.slug,
1759
- name: c.name,
1760
- properties: c.properties,
1761
- propertiesOrder: c.propertiesOrder
1762
- }));
1763
- const result = await generateCollection({
1764
- prompt: prompt.trim(),
1765
- existingCollections: collectionsContext.slice(0, 30),
1766
- ...existingCollection && { existingCollection: {
1767
- slug: existingCollection.slug,
1768
- name: existingCollection.name,
1769
- properties: existingCollection.properties,
1770
- propertiesOrder: existingCollection.propertiesOrder
1771
- } }
1772
- });
1773
- onGenerated(result.collection, result.operations);
1774
- setMenuOpen(false);
1775
- setPrompt("");
1776
- onAnalyticsEvent?.("ai_collection_generate_success", {
1777
- mode,
1778
- operationsCount: result.operations?.length
1779
- });
1780
- snackbarController?.open({
1781
- type: "success",
1782
- message: existingCollection ? "Collection updated with AI suggestions" : "Collection generated successfully"
1783
- });
1784
- } catch (e) {
1785
- console.error("Error generating collection:", e);
1786
- const errorMessage = e instanceof CollectionGenerationApiError ? e.message : "Failed to generate collection. Please try again.";
1787
- setError(errorMessage);
1788
- onAnalyticsEvent?.("ai_collection_generate_error", {
1789
- mode,
1790
- error: errorMessage
1791
- });
1792
- snackbarController?.open({
1793
- type: "error",
1794
- message: errorMessage
1795
- });
1796
- } finally {
1797
- setLoading(false);
1798
- }
1799
- };
1800
- const handleKeyDown = (e) => {
1801
- if (e.key === "Enter" && !e.shiftKey) {
1802
- e.preventDefault();
1803
- handleGenerate();
1804
- }
1805
- };
1806
- const tooltipTitle = configController?.readOnly ? configController.readOnlyReason || "Collection generation is disabled" : void 0;
1807
- const defaultTrigger = showLabel ? /* @__PURE__ */ jsx(Tooltip, {
1808
- title: tooltipTitle,
1809
- asChild: true,
1810
- children: /* @__PURE__ */ jsx(Button, {
1811
- variant: "text",
1812
- size,
1813
- disabled: loading || configController?.readOnly,
1814
- startIcon: loading ? /* @__PURE__ */ jsx(CircularProgress, { size: "smallest" }) : /* @__PURE__ */ jsx(AIIcon, { size: "small" }),
1815
- children: "AI Assist"
1816
- })
1817
- }) : /* @__PURE__ */ jsx(Tooltip, {
1818
- title: tooltipTitle,
1819
- asChild: true,
1820
- children: /* @__PURE__ */ jsx(IconButton, {
1821
- size,
1822
- disabled: loading || configController?.readOnly,
1823
- "aria-label": "AI Assist",
1824
- children: loading ? /* @__PURE__ */ jsx(CircularProgress, { size: "smallest" }) : /* @__PURE__ */ jsx(AIIcon, { size: "small" })
1825
- })
1826
- });
1827
- return /* @__PURE__ */ jsx(Menu, {
1828
- open: menuOpen,
1829
- onOpenChange: (open) => {
1830
- setMenuOpen(open);
1831
- if (!open) setError(null);
1832
- },
1833
- trigger: trigger ?? defaultTrigger,
1834
- children: /* @__PURE__ */ jsxs("div", {
1835
- className: "p-4 flex flex-col gap-3 min-w-[360px] max-w-[480px]",
1836
- children: [
1837
- /* @__PURE__ */ jsxs("div", {
1838
- className: "flex items-center gap-2",
1839
- children: [/* @__PURE__ */ jsx(AIIcon, { size: "small" }), /* @__PURE__ */ jsx(Typography, {
1840
- variant: "subtitle2",
1841
- children: existingCollection ? "Modify Collection with AI" : "Generate Collection with AI"
1842
- })]
1843
- }),
1844
- /* @__PURE__ */ jsx(Typography, {
1845
- variant: "caption",
1846
- color: "secondary",
1847
- children: existingCollection ? t("describe_changes_to_make") : t("describe_collection_to_create")
1848
- }),
1849
- /* @__PURE__ */ jsx(TextField, {
1850
- size: "small",
1851
- multiline: true,
1852
- autoFocus: true,
1853
- "aria-label": existingCollection ? t("describe_changes_to_make") : t("describe_collection_to_create"),
1854
- className: "w-full text-text-primary dark:text-text-primary-dark",
1855
- value: prompt,
1856
- onChange: (e) => setPrompt(e.target.value),
1857
- onKeyDown: handleKeyDown,
1858
- placeholder: existingCollection ? "e.g., Add a thumbnail image field with storage, make price required..." : "e.g., Create a products collection with name, price, description, and category...",
1859
- disabled: loading
1860
- }),
1861
- error && /* @__PURE__ */ jsx(Typography, {
1862
- variant: "caption",
1863
- className: "text-red-500",
1864
- children: error
1865
- }),
1866
- /* @__PURE__ */ jsxs("div", {
1867
- className: "flex justify-end gap-2",
1868
- children: [/* @__PURE__ */ jsx(Button, {
1869
- variant: "text",
1870
- size: "small",
1871
- onClick: () => setMenuOpen(false),
1872
- disabled: loading,
1873
- children: "Cancel"
1874
- }), /* @__PURE__ */ jsx(Button, {
1875
- variant: "filled",
1876
- size: "small",
1877
- onClick: handleGenerate,
1878
- disabled: !prompt.trim() || loading,
1879
- startIcon: loading ? /* @__PURE__ */ jsx(CircularProgress, { size: "smallest" }) : void 0,
1880
- children: loading ? "Generating..." : "Generate"
1881
- })]
1882
- })
1883
- ]
1884
- })
1885
- });
1886
- }
1887
- //#endregion
1888
- //#region src/collection_editor/ui/collection_editor/CollectionEditorWelcomeView.tsx
1889
- function CollectionEditorWelcomeView({ path, parentCollection, onContinue, existingCollectionPaths, generateCollection, onAnalyticsEvent, unmappedTables, onImportFromTable }) {
1890
- const { pathSuggestions } = useCollectionEditorController();
1891
- const filteredSuggestions = (pathSuggestions ?? []).filter((s) => !(existingCollectionPaths ?? []).find((c) => c.trim().toLowerCase() === s.trim().toLowerCase()));
1892
- const { values, setFieldValue, setValues, submitCount } = useFormex();
1893
- const [jsonImportOpen, setJsonImportOpen] = useState(false);
1894
- const [importingTable, setImportingTable] = useState(null);
1895
- const filteredUnmappedTables = (unmappedTables ?? []).filter((t) => !(existingCollectionPaths ?? []).find((c) => c.trim().toLowerCase() === t.trim().toLowerCase()));
1896
- return /* @__PURE__ */ jsx("div", {
1897
- className: "overflow-auto my-auto",
1898
- children: /* @__PURE__ */ jsxs(Container, {
1899
- maxWidth: "4xl",
1900
- className: "flex flex-col gap-4 p-8 m-auto",
1901
- children: [
1902
- /* @__PURE__ */ jsx("div", {
1903
- className: "flex flex-row py-2 pt-3 items-center",
1904
- children: /* @__PURE__ */ jsx(Typography, {
1905
- variant: "h4",
1906
- className: "grow",
1907
- children: "New collection"
1908
- })
1909
- }),
1910
- parentCollection && /* @__PURE__ */ jsx(Chip, {
1911
- colorScheme: "teal",
1912
- children: /* @__PURE__ */ jsxs(Typography, {
1913
- variant: "caption",
1914
- children: ["This is a subcollection of ", /* @__PURE__ */ jsx("b", { children: parentCollection.name })]
1915
- })
1916
- }),
1917
- filteredUnmappedTables.length > 0 && /* @__PURE__ */ jsxs("div", {
1918
- className: "my-2",
1919
- children: [/* @__PURE__ */ jsx(Typography, {
1920
- variant: "caption",
1921
- color: "secondary",
1922
- children: "● Import from an existing database table:"
1923
- }), /* @__PURE__ */ jsx("div", {
1924
- className: "flex flex-wrap gap-x-2 gap-y-1 items-center my-2 min-h-7",
1925
- children: filteredUnmappedTables.map((tableName) => /* @__PURE__ */ jsxs(Chip, {
1926
- colorScheme: "purple",
1927
- onClick: () => {
1928
- if (onImportFromTable) {
1929
- setImportingTable(tableName);
1930
- onImportFromTable(tableName);
1931
- } else {
1932
- setFieldValue("name", prettifyIdentifier(tableName));
1933
- setFieldValue("id", tableName);
1934
- setFieldValue("path", tableName);
1935
- onContinue();
1936
- }
1937
- },
1938
- size: "small",
1939
- children: [/* @__PURE__ */ jsx(TableIcon, { size: iconSize.smallest }), importingTable === tableName ? "Loading..." : tableName]
1940
- }, tableName))
1941
- })]
1942
- }),
1943
- (filteredSuggestions ?? []).length > 0 && /* @__PURE__ */ jsxs("div", {
1944
- className: "my-2",
1945
- children: [/* @__PURE__ */ jsx(Typography, {
1946
- variant: "caption",
1947
- color: "secondary",
1948
- children: "● Use one of the existing paths in your database:"
1949
- }), /* @__PURE__ */ jsx("div", {
1950
- className: "flex flex-wrap gap-x-2 gap-y-1 items-center my-2 min-h-7",
1951
- children: filteredSuggestions?.map((suggestion, index) => /* @__PURE__ */ jsx(Chip, {
1952
- colorScheme: "cyan",
1953
- onClick: () => {
1954
- setFieldValue("name", prettifyIdentifier(suggestion));
1955
- setFieldValue("id", suggestion);
1956
- setFieldValue("path", suggestion);
1957
- setFieldValue("properties", void 0);
1958
- onContinue();
1959
- },
1960
- size: "small",
1961
- children: suggestion
1962
- }, suggestion))
1963
- })]
1964
- }),
1965
- /* @__PURE__ */ jsxs("div", {
1966
- className: "flex flex-row gap-8",
1967
- children: [generateCollection && /* @__PURE__ */ jsxs("div", {
1968
- className: "my-2",
1969
- children: [/* @__PURE__ */ jsx(Typography, {
1970
- variant: "caption",
1971
- color: "secondary",
1972
- className: "mb-2",
1973
- children: "● Describe your collection to AI:"
1974
- }), /* @__PURE__ */ jsx(AICollectionGeneratorPopover, {
1975
- onGenerated: (generatedCollection) => {
1976
- setValues(generatedCollection);
1977
- onContinue();
1978
- },
1979
- generateCollection,
1980
- onAnalyticsEvent,
1981
- trigger: /* @__PURE__ */ jsx(Button, {
1982
- variant: "filled",
1983
- color: "neutral",
1984
- startIcon: /* @__PURE__ */ jsx(AIIcon, { size: "small" }),
1985
- children: "Generate with AI"
1986
- })
1987
- })]
1988
- }), /* @__PURE__ */ jsxs("div", {
1989
- className: "my-2",
1990
- children: [
1991
- /* @__PURE__ */ jsx(Typography, {
1992
- variant: "caption",
1993
- color: "secondary",
1994
- className: "mb-2",
1995
- children: "● Create from JSON configuration:"
1996
- }),
1997
- /* @__PURE__ */ jsx(Button, {
1998
- variant: "filled",
1999
- color: "neutral",
2000
- onClick: () => setJsonImportOpen(true),
2001
- startIcon: /* @__PURE__ */ jsx(CodeIcon, { size: iconSize.small }),
2002
- children: "Paste JSON Configuration"
2003
- }),
2004
- /* @__PURE__ */ jsx(CollectionJsonImportDialog, {
2005
- open: jsonImportOpen,
2006
- onClose: () => setJsonImportOpen(false),
2007
- onImport: (collection) => {
2008
- setValues(collection);
2009
- onContinue();
2010
- }
2011
- })
2012
- ]
2013
- })]
2014
- }),
2015
- !parentCollection && /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(Typography, {
2016
- variant: "caption",
2017
- color: "secondary",
2018
- className: "mb-2",
2019
- children: "● Create a collection from a file (csv, json, xls, xslx...)"
2020
- }), /* @__PURE__ */ jsx(ImportFileUpload, { onDataAdded: (data, propertiesOrder) => onContinue(data, propertiesOrder) })] }),
2021
- /* @__PURE__ */ jsxs("div", {
2022
- className: "my-2",
2023
- children: [/* @__PURE__ */ jsx(Typography, {
2024
- variant: "caption",
2025
- color: "secondary",
2026
- children: "● Select a template:"
2027
- }), /* @__PURE__ */ jsxs("div", {
2028
- className: "flex gap-2",
2029
- children: [
2030
- /* @__PURE__ */ jsx(TemplateButton, {
2031
- title: "Products",
2032
- subtitle: "A collection of products with images, prices and stock",
2033
- icon: /* @__PURE__ */ jsx(ShoppingCartIcon, { size: iconSize.small }),
2034
- onClick: () => {
2035
- setValues(productsCollectionTemplate);
2036
- onContinue();
2037
- }
2038
- }),
2039
- /* @__PURE__ */ jsx(TemplateButton, {
2040
- title: "Users",
2041
- subtitle: "A collection of users with emails, names and roles",
2042
- icon: /* @__PURE__ */ jsx(UserIcon, { size: iconSize.small }),
2043
- onClick: () => {
2044
- setValues(usersCollectionTemplate);
2045
- onContinue();
2046
- }
2047
- }),
2048
- /* @__PURE__ */ jsx(TemplateButton, {
2049
- title: "Blog posts",
2050
- subtitle: "A collection of blog posts with images, authors and complex content",
2051
- icon: /* @__PURE__ */ jsx(FileTextIcon, { size: iconSize.small }),
2052
- onClick: () => {
2053
- setValues(blogCollectionTemplate);
2054
- onContinue();
2055
- }
2056
- }),
2057
- /* @__PURE__ */ jsx(TemplateButton, {
2058
- title: "Pages",
2059
- subtitle: "A collection of pages with images, authors and complex content",
2060
- icon: /* @__PURE__ */ jsx(FileIcon, { size: iconSize.small }),
2061
- onClick: () => {
2062
- setValues(pagesCollectionTemplate);
2063
- onContinue();
2064
- }
2065
- })
2066
- ]
2067
- })]
2068
- })
2069
- ]
2070
- })
2071
- });
2072
- }
2073
- function TemplateButton({ title, subtitle, icon, onClick }) {
2074
- return /* @__PURE__ */ jsx(Tooltip, {
2075
- title: subtitle,
2076
- asChild: true,
2077
- children: /* @__PURE__ */ jsxs(Card, {
2078
- onClick,
2079
- className: cls("my-2 rounded-md border px-4 py-3 focus:outline-none transition ease-in-out duration-150 flex flex-row gap-4 items-center", "text-text-secondary dark:text-text-secondary-dark", "hover:border-primary-dark hover:text-primary-dark dark:hover:text-primary focus:ring-primary hover:ring-1 hover:ring-primary", "border-surface-400 dark:border-surface-600 "),
2080
- children: [icon, /* @__PURE__ */ jsx("div", {
2081
- className: "flex flex-col items-start",
2082
- children: /* @__PURE__ */ jsx(Typography, {
2083
- variant: "subtitle2",
2084
- children: title
2085
- })
2086
- })]
2087
- })
2088
- });
2089
- }
2090
- //#endregion
2091
- //#region src/collection_editor/ui/collection_editor/import/CollectionEditorImportMapping.tsx
2092
- function CollectionEditorImportMapping({ importConfig, propertyConfigs }) {
2093
- const { setFieldValue, setFieldTouched, values } = useFormex();
2094
- const [selectedProperty, setSelectedProperty] = useState(void 0);
2095
- const currentPropertiesOrderRef = React.useRef(values.propertiesOrder ? { "": values.propertiesOrder } : {});
2096
- const propertyKey = selectedProperty ? selectedProperty.id : void 0;
2097
- const property = selectedProperty || void 0;
2098
- const onPropertyChanged = ({ id, property, previousId, namespace }) => {
2099
- const fullId = id ? getFullId(id, namespace) : void 0;
2100
- const propertyPath = fullId ? idToPropertiesPath(fullId) : void 0;
2101
- const getCurrentPropertiesOrder = (namespace) => {
2102
- if (!namespace) return currentPropertiesOrderRef.current[""];
2103
- return currentPropertiesOrderRef.current[namespace] ?? getIn(values, namespaceToPropertiesOrderPath(namespace));
2104
- };
2105
- const updatePropertiesOrder = (newPropertiesOrder, namespace) => {
2106
- const propertiesOrderPath = namespaceToPropertiesOrderPath(namespace);
2107
- setFieldValue(propertiesOrderPath, newPropertiesOrder, false);
2108
- currentPropertiesOrderRef.current[namespace ?? ""] = newPropertiesOrder;
2109
- };
2110
- if (previousId && previousId !== id) {
2111
- const previousPropertyPath = idToPropertiesPath(getFullId(previousId, namespace));
2112
- updatePropertiesOrder(getCurrentPropertiesOrder(namespace).map((p) => p === previousId ? id : p).filter((p) => p !== void 0), namespace);
2113
- const newHeadersMapping = { ...importConfig.headersMapping };
2114
- Object.keys(newHeadersMapping).forEach((key) => {
2115
- if (newHeadersMapping[key] === previousId) newHeadersMapping[key] = id ?? "";
2116
- });
2117
- importConfig.setHeadersMapping(newHeadersMapping);
2118
- setFieldValue(previousPropertyPath, void 0, false);
2119
- setFieldTouched(previousPropertyPath, false, false);
2120
- }
2121
- if (propertyPath) {
2122
- setFieldValue(propertyPath, property, false);
2123
- setFieldTouched(propertyPath, true, false);
2124
- }
2125
- };
2126
- const onPropertyTypeChanged = async ({ id, importKey, property, namespace }) => {
2127
- const fullId = id ? getFullId(id, namespace) : void 0;
2128
- const propertyPath = fullId ? idToPropertiesPath(fullId) : void 0;
2129
- const inferredNewProperty = { ...buildPropertyFromData(importConfig.importData.map((d) => getIn(d, importKey)), property, getInferenceType) };
2130
- if (propertyPath) {
2131
- if (inferredNewProperty) setFieldValue(propertyPath, inferredNewProperty, false);
2132
- else setFieldValue(propertyPath, property, false);
2133
- setFieldTouched(propertyPath, true, false);
2134
- }
2135
- };
2136
- return /* @__PURE__ */ jsxs("div", {
2137
- className: "overflow-auto my-auto",
2138
- children: [
2139
- /* @__PURE__ */ jsxs(Container, {
2140
- maxWidth: "6xl",
2141
- className: "flex flex-col gap-4 p-8 m-auto",
2142
- children: [/* @__PURE__ */ jsx(Typography, {
2143
- variant: "h6",
2144
- className: "my-4 ml-3.5",
2145
- children: "Data property mapping"
2146
- }), /* @__PURE__ */ jsx(DataNewPropertiesMapping, {
2147
- importConfig,
2148
- destinationProperties: values.properties,
2149
- buildPropertyView: ({ property, propertyKey, importKey, isIdColumn }) => {
2150
- if (isIdColumn) return /* @__PURE__ */ jsx(Typography, { children: " This column will be used as ID" });
2151
- return /* @__PURE__ */ jsx(ImportNewPropertyFieldPreview, {
2152
- property,
2153
- propertyKey,
2154
- onPropertyNameChanged: (propertyKey, value) => setFieldValue(`properties.${propertyKey}.name`, value, false),
2155
- onEditClick: () => {
2156
- if (!propertyKey || !property) return;
2157
- setSelectedProperty({
2158
- ...property,
2159
- id: propertyKey
2160
- });
2161
- },
2162
- propertyTypeView: /* @__PURE__ */ jsx(PropertySelect, {
2163
- property,
2164
- disabled: false,
2165
- onPropertyChanged: (props) => onPropertyTypeChanged({
2166
- ...props,
2167
- importKey
2168
- }),
2169
- propertyKey,
2170
- propertyConfigs
2171
- })
2172
- });
2173
- }
2174
- })]
2175
- }),
2176
- /* @__PURE__ */ jsx(PropertyFormDialog, {
2177
- open: selectedProperty !== void 0,
2178
- propertyKey,
2179
- property,
2180
- inArray: false,
2181
- autoUpdateId: false,
2182
- onPropertyChanged,
2183
- allowDataInference: false,
2184
- onOkClicked: () => {
2185
- setSelectedProperty(void 0);
2186
- },
2187
- onCancel: () => {
2188
- setSelectedProperty(void 0);
2189
- },
2190
- autoOpenTypeSelect: false,
2191
- existingProperty: false,
2192
- propertyConfigs
2193
- }),
2194
- /* @__PURE__ */ jsx("div", { style: { height: "52px" } })
2195
- ]
2196
- });
2197
- }
2198
- function PropertySelect({ property, onPropertyChanged, propertyKey, propertyConfigs, disabled }) {
2199
- const fieldId = property ? getFieldId(property) : null;
2200
- const widget = property ? getFieldConfig(property, propertyConfigs) : null;
2201
- const [selectOpen, setSelectOpen] = useState(false);
2202
- return /* @__PURE__ */ jsx(Tooltip, {
2203
- title: property && widget ? `${widget?.name} - ${property.type}` : void 0,
2204
- open: selectOpen ? false : void 0,
2205
- children: /* @__PURE__ */ jsx(Select, {
2206
- open: selectOpen,
2207
- onOpenChange: setSelectOpen,
2208
- invisible: true,
2209
- className: "w-full",
2210
- disabled,
2211
- error: !widget,
2212
- fullWidth: true,
2213
- value: fieldId ?? "",
2214
- placeholder: "Select a property widget",
2215
- position: "item-aligned",
2216
- renderValue: (value) => {
2217
- if (!widget) return null;
2218
- return /* @__PURE__ */ jsx(PropertyConfigBadge, { propertyConfig: widget });
2219
- },
2220
- onValueChange: (newSelectedWidgetId) => {
2221
- const newProperty = updatePropertyFromWidget(property, newSelectedWidgetId, propertyConfigs);
2222
- if (!propertyKey) return;
2223
- onPropertyChanged({
2224
- id: propertyKey,
2225
- property: newProperty,
2226
- previousId: propertyKey,
2227
- namespace: void 0
2228
- });
2229
- },
2230
- children: Object.entries(supportedFields).map(([key, widget]) => {
2231
- return /* @__PURE__ */ jsx(ImportPropertySelectItem, {
2232
- value: key,
2233
- optionDisabled: false,
2234
- propertyConfig: widget,
2235
- existing: false
2236
- }, key);
2237
- })
2238
- })
2239
- });
2240
- }
2241
- function ImportPropertySelectItem({ value, optionDisabled, propertyConfig, existing }) {
2242
- return /* @__PURE__ */ jsx(SelectItem, {
2243
- value,
2244
- disabled: optionDisabled,
2245
- className: "flex flex-row items-center",
2246
- children: /* @__PURE__ */ jsxs("div", {
2247
- className: cls("flex flex-row items-center text-base min-h-[48px]", optionDisabled ? "w-full" : ""),
2248
- children: [/* @__PURE__ */ jsx("div", {
2249
- className: "mr-8",
2250
- children: /* @__PURE__ */ jsx(PropertyConfigBadge, { propertyConfig })
2251
- }), /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("div", { children: propertyConfig.name }), /* @__PURE__ */ jsx(Typography, {
2252
- variant: "caption",
2253
- color: "disabled",
2254
- className: "max-w-sm",
2255
- children: existing && optionDisabled ? "You can only switch to widgets that use the same data type" : propertyConfig.description
2256
- })] })]
2257
- })
2258
- });
2259
- }
2260
- //#endregion
2261
- //#region src/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.tsx
2262
- function CollectionEditorImportDataPreview({ importConfig, properties, propertiesOrder }) {
2263
- const authController = useAuthController();
2264
- const registry = useCollectionRegistryController();
2265
- const [loading, setLoading] = useState(false);
2266
- const [problems, setProblems] = useState([]);
2267
- async function loadEntities() {
2268
- const converted = convertImportData(authController, registry, importConfig.importData, importConfig.idColumn, importConfig.headersMapping, properties, "TEMP_PATH", importConfig.defaultValues);
2269
- importConfig.setEntities(converted.entities);
2270
- setProblems(converted.problems);
2271
- }
2272
- useEffect(() => {
2273
- loadEntities().finally(() => setLoading(false));
2274
- }, []);
2275
- const selectionController = useSelectionController();
2276
- if (loading) return /* @__PURE__ */ jsx(CircularProgressCenter, {});
2277
- return /* @__PURE__ */ jsxs("div", {
2278
- className: "flex flex-col h-full w-full",
2279
- children: [/* @__PURE__ */ jsx(ImportConversionProblems, { problems }), /* @__PURE__ */ jsx("div", {
2280
- className: "flex-1 min-h-0",
2281
- children: /* @__PURE__ */ jsx(CollectionTableBinding, {
2282
- title: /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(Typography, {
2283
- variant: "subtitle2",
2284
- children: "Imported data preview"
2285
- }), /* @__PURE__ */ jsx(Typography, {
2286
- variant: "caption",
2287
- children: "Entities with the same id will be overwritten"
2288
- })] }),
2289
- tableController: {
2290
- data: importConfig.entities,
2291
- dataLoading: false,
2292
- noMoreToLoad: false
2293
- },
2294
- endAdornment: /* @__PURE__ */ jsx("div", { className: "h-12" }),
2295
- filterable: false,
2296
- sortable: false,
2297
- selectionController,
2298
- displayedColumnIds: propertiesOrder.map((p) => ({
2299
- key: p,
2300
- disabled: false
2301
- })),
2302
- openEntityMode: "side_panel",
2303
- properties,
2304
- enablePopupIcon: false
2305
- })
2306
- })]
2307
- });
2308
- }
2309
- //#endregion
2310
- //#region src/collection_editor/ui/collection_editor/import/clean_import_data.ts
2311
- function cleanPropertiesFromImport(properties, parentSlug = "") {
2312
- const taken = /* @__PURE__ */ new Set();
2313
- const uniqueSlug = (key, index) => {
2314
- const base = slugify(key) || `column_${index + 1}`;
2315
- let slug = base;
2316
- for (let n = 2; taken.has(slug); n++) slug = `${base}_${n}`;
2317
- taken.add(slug);
2318
- return slug;
2319
- };
2320
- const result = Object.keys(properties).reduce((acc, key, index) => {
2321
- const property = properties[key];
2322
- const slug = uniqueSlug(key, index);
2323
- const fullSlug = parentSlug ? `${parentSlug}.${slug}` : slug;
2324
- if (property.type === "map" && property.properties) {
2325
- const slugifiedResult = cleanPropertiesFromImport(property.properties, fullSlug);
2326
- const childMapping = Object.fromEntries(Object.entries(slugifiedResult.headersMapping).map(([childKey, childSlug]) => [`${key}.${childKey}`, childSlug]));
2327
- return {
2328
- headersMapping: {
2329
- ...acc.headersMapping,
2330
- [key]: fullSlug,
2331
- ...childMapping
2332
- },
2333
- properties: {
2334
- ...acc.properties,
2335
- [slug]: {
2336
- ...property,
2337
- properties: slugifiedResult.properties,
2338
- propertiesOrder: Object.keys(slugifiedResult.properties)
2339
- }
2340
- }
2341
- };
2342
- }
2343
- const updatedProperties = {
2344
- ...acc.properties,
2345
- [slug]: property
2346
- };
2347
- return {
2348
- headersMapping: {
2349
- ...acc.headersMapping,
2350
- [key]: fullSlug
2351
- },
2352
- properties: updatedProperties
2353
- };
2354
- }, {
2355
- headersMapping: {},
2356
- properties: {}
2357
- });
2358
- return {
2359
- ...result,
2360
- idColumn: guessIdColumn(Object.keys(result.headersMapping), result.headersMapping, result.properties)
2361
- };
2362
- }
2363
- //#endregion
2364
- //#region src/collection_editor/ui/collection_editor/CollectionRLSTab.tsx
2365
- /**
2366
- * Validates and double-quotes a SQL identifier to prevent injection.
2367
- * Only allows safe Postgres identifiers (letters, digits, underscores).
2368
- * Throws if the identifier contains unsafe characters.
2369
- */
2370
- function sanitizeSqlIdentifier(name) {
2371
- if (!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(name)) throw new Error(`Invalid SQL identifier: "${name}". Only letters, digits, and underscores are allowed.`);
2372
- return `"${name}"`;
2373
- }
2374
- /**
2375
- * `pg_policies` reports the operation and the permissive flag in upper case;
2376
- * `SecurityRule` names them in lower case. These two used to be `.toLowerCase()`
2377
- * assigned straight into a `SecurityRule`, which typechecks only against a
2378
- * `string` field — and this file declared its own local `SecurityRule` with
2379
- * `operation?: string`, so it did. Against the real type it does not: an
2380
- * unrecognised `cmd` would have been written into the collection as a policy
2381
- * operation that compiles to nothing.
2382
- */
2383
- function toSecurityOperation(cmd) {
2384
- switch (cmd) {
2385
- case "SELECT": return "select";
2386
- case "INSERT": return "insert";
2387
- case "UPDATE": return "update";
2388
- case "DELETE": return "delete";
2389
- case "ALL": return "all";
2390
- default: return;
2391
- }
2392
- }
2393
- function toSecurityMode(permissive) {
2394
- if (!permissive) return void 0;
2395
- return permissive === "RESTRICTIVE" ? "restrictive" : "permissive";
2396
- }
2397
- /**
2398
- * Build a rule from what the inline editor saved. Its `roles` are application
2399
- * roles; a live policy's are its `TO` list, which `policyToSecurityRule` reads.
2400
- *
2401
- * The WITH CHECK is kept whether or not there is a USING: every INSERT-only
2402
- * policy has only a check, and a roles-only rule with no roles compiles to
2403
- * `WITH CHECK (false)`, which stops every insert.
2404
- */
2405
- function toSecurityRule(policy) {
2406
- return {
2407
- name: policy.policyname ?? "",
2408
- operation: toSecurityOperation(policy.cmd),
2409
- mode: toSecurityMode(policy.permissive),
2410
- roles: policy.roles ? [...policy.roles] : void 0,
2411
- ...policy.qual ? { using: policy.qual } : {},
2412
- ...policy.with_check ? { withCheck: policy.with_check } : {}
2413
- };
2414
- }
2415
- /**
2416
- * The rule with what the editor changed, and nothing else.
2417
- *
2418
- * The editor shows a rule as a policy — name, command, mode, application roles
2419
- * and raw USING / WITH CHECK — and has no field for `ownerField`, `access`, a
2420
- * structured `condition`, `operations` (it shows them as ALL) or `pgRoles`.
2421
- * The rule used to be rebuilt from the form, which dropped all of them:
2422
- * renaming an owner rule saved a roles-only rule with no roles, which compiles
2423
- * to `USING (false)`. So a field is only written when it differs from what the
2424
- * editor was opened with. A condition typed in replaces the rule's condition
2425
- * whole — the forms are exclusive.
2426
- *
2427
- * Studio's RLS editor does the same in `policyRules.ts`; there the editor's
2428
- * roles are the policy's `TO` list, `pgRoles`, and here they are `roles`.
2429
- */
2430
- function editedRule(rule, original, edited) {
2431
- const next = toSecurityRule(edited);
2432
- const result = { ...rule };
2433
- if ((edited.policyname ?? "") !== original.policyname) if (next.name) result.name = next.name;
2434
- else delete result.name;
2435
- if (edited.cmd !== original.cmd) {
2436
- delete result.operations;
2437
- result.operation = next.operation;
2438
- }
2439
- if (edited.permissive !== original.permissive) result.mode = next.mode;
2440
- if (!sameRoles(edited.roles, original.roles)) if (next.roles && next.roles.length > 0) result.roles = next.roles;
2441
- else delete result.roles;
2442
- if ((edited.qual || null) !== (original.qual || null) || (edited.with_check || null) !== (original.with_check || null)) {
2443
- delete result.ownerField;
2444
- delete result.access;
2445
- delete result.condition;
2446
- delete result.check;
2447
- delete result.using;
2448
- delete result.withCheck;
2449
- if (next.using) result.using = next.using;
2450
- if (next.withCheck) result.withCheck = next.withCheck;
2451
- }
2452
- return result;
2453
- }
2454
- function sameRoles(a, b) {
2455
- const left = [...a ?? []].sort();
2456
- const right = [...b ?? []].sort();
2457
- return left.length === right.length && left.every((role, i) => role === right[i]);
2458
- }
2459
- function CollectionRLSTab() {
2460
- const { values, setFieldValue } = useFormex();
2461
- const [editing, setEditing] = useState(null);
2462
- const { readOnly, readOnlyReason } = useCollectionsConfigController();
2463
- const readOnlyTitle = readOnlyReason || "This backend does not accept collection edits.";
2464
- const rules = values.securityRules || [];
2465
- const { databaseAdmin } = useRebaseContext();
2466
- const [dbPolicies, setDbPolicies] = useState([]);
2467
- const [isLoadingDb, setIsLoadingDb] = useState(false);
2468
- const tableName = getTableName(values);
2469
- const schemaName = isPostgresCollectionConfig(values) && values.schema ? values.schema : "public";
2470
- useEffect(() => {
2471
- const fetchLivePolicies = async () => {
2472
- if (!tableName || !databaseAdmin?.executeSql) return;
2473
- setIsLoadingDb(true);
2474
- try {
2475
- const rawTableName = sanitizeSqlIdentifier(tableName).slice(1, -1);
2476
- const sql = `
2477
- SELECT policyname, permissive, roles, cmd, qual, with_check
2478
- FROM pg_policies
2479
- WHERE schemaname = '${sanitizeSqlIdentifier(schemaName).slice(1, -1)}' AND tablename = '${rawTableName}';
2480
- `;
2481
- const result = await databaseAdmin.executeSql(sql);
2482
- const extractRows = (res) => {
2483
- if (res && typeof res === "object" && "rows" in res && Array.isArray(res.rows)) return res.rows;
2484
- if (Array.isArray(res)) return res;
2485
- return [];
2486
- };
2487
- const policies = extractRows(result).map((p) => {
2488
- let parsedRoles = [];
2489
- const r = p.roles || p.ROLES;
2490
- if (Array.isArray(r)) parsedRoles = r;
2491
- else if (typeof r === "string") parsedRoles = r.replace(/^{|}$/g, "").split(",").map((s) => s.trim());
2492
- return {
2493
- policyname: p.policyname || p.POLICYNAME || "",
2494
- tablename: tableName,
2495
- permissive: p.permissive || p.PERMISSIVE || "PERMISSIVE",
2496
- roles: parsedRoles,
2497
- cmd: p.cmd || p.CMD || "ALL",
2498
- qual: p.qual || p.QUAL || null,
2499
- with_check: p.with_check || p.WITH_CHECK || null
2500
- };
2501
- });
2502
- setDbPolicies(policies);
2503
- } catch (e) {
2504
- console.error("Failed to fetch DB policies", e);
2505
- } finally {
2506
- setIsLoadingDb(false);
2507
- }
2508
- };
2509
- fetchLivePolicies();
2510
- }, [
2511
- databaseAdmin,
2512
- tableName,
2513
- schemaName
2514
- ]);
2515
- /**
2516
- * Application roles available to `SecurityRule.roles`.
2517
- *
2518
- * Deliberately NOT `fetchAvailableRoles` — that returns native pg_roles
2519
- * (postgres, rebase_user, …), which can never satisfy an application-role
2520
- * condition.
2521
- */
2522
- const [availableRoles, setAvailableRoles] = useState([]);
2523
- const [rolesUnavailable, setRolesUnavailable] = useState(false);
2524
- useEffect(() => {
2525
- let mounted = true;
2526
- const fetchRoles = async () => {
2527
- if (!databaseAdmin?.fetchApplicationRoles) {
2528
- if (mounted) setRolesUnavailable(true);
2529
- return;
2530
- }
2531
- try {
2532
- const fetched = await databaseAdmin.fetchApplicationRoles();
2533
- if (mounted) {
2534
- setAvailableRoles(fetched);
2535
- setRolesUnavailable(false);
2536
- }
2537
- } catch (e) {
2538
- console.error("Failed to fetch application roles", e);
2539
- if (mounted) setRolesUnavailable(true);
2540
- }
2541
- };
2542
- fetchRoles();
2543
- return () => {
2544
- mounted = false;
2545
- };
2546
- }, [databaseAdmin]);
2547
- const generatedPolicyNames = useMemo(() => {
2548
- if (!tableName) return /* @__PURE__ */ new Set();
2549
- return getGeneratedPolicyNames(values);
2550
- }, [tableName, values]);
2551
- const unmappedPolicies = dbPolicies.filter((dp) => !generatedPolicyNames.has(dp.policyname));
2552
- const handleSave = (newPolicy) => {
2553
- if (!editing) return;
2554
- const newRules = editing === "new" ? [...rules, toSecurityRule(newPolicy)] : rules.map((r, i) => i === editing.index ? editedRule(r, editing.policy, newPolicy) : r);
2555
- setFieldValue("securityRules", newRules);
2556
- setEditing(null);
2557
- };
2558
- return /* @__PURE__ */ jsx("div", {
2559
- className: "overflow-auto my-auto",
2560
- children: /* @__PURE__ */ jsxs(Container, {
2561
- maxWidth: "4xl",
2562
- className: "flex flex-col gap-4 p-8 m-auto",
2563
- children: [/* @__PURE__ */ jsxs("div", {
2564
- className: "w-full flex flex-col",
2565
- children: [
2566
- /* @__PURE__ */ jsxs("div", {
2567
- className: "flex items-center justify-between mb-8",
2568
- children: [/* @__PURE__ */ jsx(Typography, {
2569
- variant: "h5",
2570
- children: "Row Level Security"
2571
- }), /* @__PURE__ */ jsx(Tooltip, {
2572
- title: readOnly ? readOnlyTitle : void 0,
2573
- children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Button, {
2574
- variant: "filled",
2575
- color: "neutral",
2576
- disabled: readOnly,
2577
- onClick: () => setEditing("new"),
2578
- children: "CREATE POLICY"
2579
- }) })
2580
- })]
2581
- }),
2582
- rules.length === 0 ? /* @__PURE__ */ jsx("div", {
2583
- className: "flex-grow flex items-center justify-center text-text-disabled py-12",
2584
- children: /* @__PURE__ */ jsx(Typography, {
2585
- variant: "body2",
2586
- children: "No RLS policies defined for this collection."
2587
- })
2588
- }) : /* @__PURE__ */ jsx("div", {
2589
- className: "flex flex-col gap-3",
2590
- children: rules.map((rule, index) => /* @__PURE__ */ jsxs(Paper, {
2591
- className: "p-4 border border-transparent hover:border-surface-200 dark:hover:border-surface-700 rounded-lg flex flex-col sm:flex-row sm:items-center justify-between gap-4 transition-colors bg-surface-card shadow-sm",
2592
- children: [/* @__PURE__ */ jsxs("div", {
2593
- className: "flex flex-col gap-1.5 min-w-0",
2594
- children: [/* @__PURE__ */ jsxs("div", {
2595
- className: "flex items-center gap-2",
2596
- children: [/* @__PURE__ */ jsx(KeyIcon, {
2597
- size: iconSize.smallest,
2598
- className: "text-text-disabled dark:text-text-disabled-dark shrink-0"
2599
- }), /* @__PURE__ */ jsx(Typography, {
2600
- variant: "subtitle2",
2601
- className: "truncate",
2602
- children: rule.name || (tableName ? getPolicyNamesForRule(rule, tableName).join(", ") : "Unnamed policy")
2603
- })]
2604
- }), /* @__PURE__ */ jsxs("div", {
2605
- className: "flex gap-2 text-xs pl-6 overflow-x-auto hide-scrollbar",
2606
- children: [/* @__PURE__ */ jsxs(Chip, {
2607
- size: "small",
2608
- className: "bg-surface-raised text-text-secondary border-none",
2609
- children: ["Action: ", rule.operation || "ALL"]
2610
- }), /* @__PURE__ */ jsxs(Chip, {
2611
- size: "small",
2612
- className: "bg-surface-raised text-text-secondary border-none",
2613
- children: ["Roles: ", Array.isArray(rule.roles) ? rule.roles.join(", ") : rule.roles]
2614
- })]
2615
- })]
2616
- }), /* @__PURE__ */ jsxs("div", {
2617
- className: "flex items-center gap-1 sm:gap-2 shrink-0",
2618
- children: [/* @__PURE__ */ jsx(Button, {
2619
- size: "small",
2620
- variant: "text",
2621
- disabled: readOnly,
2622
- onClick: () => setEditing({
2623
- index,
2624
- policy: {
2625
- policyname: rule.name ?? "",
2626
- tablename: tableName || "your_table",
2627
- permissive: (rule.mode || "permissive").toUpperCase(),
2628
- cmd: (rule.operation || "ALL").toUpperCase(),
2629
- roles: [...rule.roles ?? []],
2630
- qual: rule.using || null,
2631
- with_check: rule.withCheck || null
2632
- }
2633
- }),
2634
- children: "EDIT"
2635
- }), /* @__PURE__ */ jsx(IconButton, {
2636
- size: "small",
2637
- disabled: readOnly,
2638
- onClick: () => {
2639
- setFieldValue("securityRules", rules.filter((_r, i) => i !== index));
2640
- },
2641
- children: /* @__PURE__ */ jsx(Trash2Icon, {
2642
- size: iconSize.smallest,
2643
- className: "text-text-secondary dark:text-text-secondary-dark hover:text-red-500 dark:hover:text-red-500 transition-colors"
2644
- })
2645
- })]
2646
- })]
2647
- }, `${index}:${rule.name ?? ""}`))
2648
- }),
2649
- isLoadingDb && unmappedPolicies.length === 0 && /* @__PURE__ */ jsx("div", {
2650
- className: "flex justify-center mt-8",
2651
- children: /* @__PURE__ */ jsx(CircularProgress, { size: "small" })
2652
- }),
2653
- !isLoadingDb && unmappedPolicies.length > 0 && /* @__PURE__ */ jsxs("div", {
2654
- className: "mt-12 flex flex-col gap-4",
2655
- children: [
2656
- /* @__PURE__ */ jsx(Typography, {
2657
- variant: "h6",
2658
- className: "text-text-secondary",
2659
- children: "Unmapped Database Policies"
2660
- }),
2661
- /* @__PURE__ */ jsx(Typography, {
2662
- variant: "body2",
2663
- className: "text-text-secondary opacity-80 -mt-2",
2664
- children: "These policies exist in your Postgres database but are not mapped to this collection's codebase configuration."
2665
- }),
2666
- /* @__PURE__ */ jsx("div", {
2667
- className: "flex flex-col gap-3",
2668
- children: unmappedPolicies.map((dp) => /* @__PURE__ */ jsxs(Paper, {
2669
- className: "p-4 border border-orange-200 dark:border-orange-900/50 bg-orange-50/50 dark:bg-orange-900/10 rounded-lg flex flex-col sm:flex-row sm:items-center justify-between gap-4 transition-colors",
2670
- children: [/* @__PURE__ */ jsxs("div", {
2671
- className: "flex flex-col gap-1.5 min-w-0",
2672
- children: [/* @__PURE__ */ jsxs("div", {
2673
- className: "flex items-center gap-2",
2674
- children: [
2675
- /* @__PURE__ */ jsx(KeyIcon, {
2676
- size: iconSize.smallest,
2677
- className: "text-orange-500 shrink-0"
2678
- }),
2679
- /* @__PURE__ */ jsx(Typography, {
2680
- variant: "subtitle2",
2681
- className: "truncate",
2682
- children: dp.policyname
2683
- }),
2684
- /* @__PURE__ */ jsx(Tooltip, {
2685
- title: "This policy is live in the database but missing from your codebase schema.",
2686
- children: /* @__PURE__ */ jsx("div", {
2687
- className: "px-1.5 py-0.5 rounded text-[10px] uppercase bg-orange-500/10 text-orange-600 border border-orange-500/20 shrink-0",
2688
- children: "DB Only"
2689
- })
2690
- })
2691
- ]
2692
- }), /* @__PURE__ */ jsxs("div", {
2693
- className: "flex gap-2 text-xs pl-6 overflow-x-auto hide-scrollbar",
2694
- children: [/* @__PURE__ */ jsxs(Chip, {
2695
- size: "small",
2696
- className: "bg-surface-card text-text-secondary border-none",
2697
- children: ["Action: ", dp.cmd || "ALL"]
2698
- }), /* @__PURE__ */ jsxs(Chip, {
2699
- size: "small",
2700
- className: "bg-surface-card text-text-secondary border-none",
2701
- children: ["Roles: ", Array.isArray(dp.roles) ? dp.roles.join(", ") : dp.roles]
2702
- })]
2703
- })]
2704
- }), /* @__PURE__ */ jsx("div", {
2705
- className: "flex items-center gap-1 sm:gap-2 shrink-0",
2706
- children: /* @__PURE__ */ jsx(Tooltip, {
2707
- title: readOnly ? readOnlyTitle : void 0,
2708
- children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Button, {
2709
- size: "small",
2710
- variant: "outlined",
2711
- color: "primary",
2712
- disabled: readOnly,
2713
- onClick: () => {
2714
- const rule = policyToSecurityRule(dp);
2715
- setFieldValue("securityRules", [...rules, rule]);
2716
- },
2717
- children: "Import to codebase"
2718
- }) })
2719
- })
2720
- })]
2721
- }, dp.policyname))
2722
- })
2723
- ]
2724
- })
2725
- ]
2726
- }), /* @__PURE__ */ jsx(Dialog, {
2727
- open: !!editing,
2728
- onOpenChange: (open) => !open && setEditing(null),
2729
- maxWidth: "4xl",
2730
- children: editing && /* @__PURE__ */ jsx(InlinePolicyEditor, {
2731
- policy: editing === "new" ? void 0 : editing.policy,
2732
- table: tableName || "your_table",
2733
- schema: schemaName,
2734
- availableRoles,
2735
- rolesUnavailable,
2736
- onSave: handleSave,
2737
- onCancel: () => setEditing(null)
2738
- })
2739
- })]
2740
- })
2741
- });
2742
- }
2743
- var COMMAND_OPTIONS = [
2744
- "ALL",
2745
- "SELECT",
2746
- "INSERT",
2747
- "UPDATE",
2748
- "DELETE"
2749
- ];
2750
- function InlinePolicyEditor({ policy, table, schema, availableRoles, rolesUnavailable, onSave, onCancel }) {
2751
- const { t } = useTranslation();
2752
- const [name, setName] = useState(policy?.policyname || "");
2753
- const [behavior, setBehavior] = useState(policy?.permissive || "PERMISSIVE");
2754
- const [command, setCommand] = useState(policy?.cmd || "ALL");
2755
- const [roles, setRoles] = useState(policy?.roles ? Array.isArray(policy.roles) ? policy.roles : [policy.roles] : []);
2756
- const [customRole, setCustomRole] = useState("");
2757
- const [usingExpr, setUsingExpr] = useState(policy?.qual || "");
2758
- const [checkExpr, setCheckExpr] = useState(policy?.with_check || "");
2759
- const showCheck = command === "ALL" || command === "INSERT" || command === "UPDATE";
2760
- /**
2761
- * Roles offered in the dropdown: those in use in the project, plus any the
2762
- * rule already carries. The union matters — application roles are derived
2763
- * from what users hold, so a role that is referenced here but assigned to
2764
- * nobody would otherwise vanish from its own policy on the next save.
2765
- */
2766
- const roleOptions = useMemo(() => Array.from(/* @__PURE__ */ new Set([...availableRoles, ...roles])).sort(), [availableRoles, roles]);
2767
- const addCustomRole = () => {
2768
- const trimmed = customRole.trim();
2769
- if (!trimmed || roles.includes(trimmed)) {
2770
- setCustomRole("");
2771
- return;
2772
- }
2773
- setRoles([...roles, trimmed]);
2774
- setCustomRole("");
2775
- };
2776
- return /* @__PURE__ */ jsxs(Fragment, { children: [
2777
- /* @__PURE__ */ jsxs(DialogTitle, {
2778
- variant: "h6",
2779
- children: [policy ? "Edit Policy" : "Create Policy", /* @__PURE__ */ jsxs("div", {
2780
- className: "text-sm font-normal text-text-secondary dark:text-text-secondary-dark tracking-wide mt-1",
2781
- children: ["Define RLS rules for ", /* @__PURE__ */ jsxs("span", {
2782
- className: "font-mono text-primary bg-primary-bg px-1 py-0.5 rounded",
2783
- children: [
2784
- schema,
2785
- ".",
2786
- table
2787
- ]
2788
- })]
2789
- })]
2790
- }),
2791
- /* @__PURE__ */ jsx(DialogContent, {
2792
- className: "p-4 md:p-6 border-t dark:border-surface-700 bg-surface-sheet",
2793
- includeMargin: false,
2794
- children: /* @__PURE__ */ jsxs(Paper, {
2795
- className: cls("p-4 md:p-6 flex flex-col gap-6 bg-surface-card border-none sm:border-solid rounded-none sm:rounded-xl", defaultBorderMixin),
2796
- children: [
2797
- /* @__PURE__ */ jsxs("div", {
2798
- className: "grid grid-cols-1 md:grid-cols-2 gap-4",
2799
- children: [/* @__PURE__ */ jsxs("div", {
2800
- className: "flex flex-col gap-1.5",
2801
- children: [/* @__PURE__ */ jsx(Typography, {
2802
- variant: "caption",
2803
- className: "uppercase tracking-wider text-text-secondary",
2804
- children: t("studio_policy_name")
2805
- }), /* @__PURE__ */ jsx(TextField, {
2806
- "aria-label": t("studio_policy_name"),
2807
- value: name,
2808
- onChange: (e) => setName(e.target.value),
2809
- placeholder: "e.g. allow_read_all"
2810
- })]
2811
- }), /* @__PURE__ */ jsxs("div", {
2812
- className: "flex flex-col gap-1.5",
2813
- children: [/* @__PURE__ */ jsx(Typography, {
2814
- variant: "caption",
2815
- className: "uppercase tracking-wider text-text-secondary",
2816
- children: "Behavior"
2817
- }), /* @__PURE__ */ jsxs(Select, {
2818
- value: behavior,
2819
- onValueChange: (val) => setBehavior(val),
2820
- position: "item-aligned",
2821
- children: [/* @__PURE__ */ jsx(SelectItem, {
2822
- value: "PERMISSIVE",
2823
- children: "Permissive"
2824
- }), /* @__PURE__ */ jsx(SelectItem, {
2825
- value: "RESTRICTIVE",
2826
- children: "Restrictive"
2827
- })]
2828
- })]
2829
- })]
2830
- }),
2831
- /* @__PURE__ */ jsxs("div", {
2832
- className: "flex flex-col gap-1.5",
2833
- children: [/* @__PURE__ */ jsx(Typography, {
2834
- variant: "caption",
2835
- className: "uppercase tracking-wider text-text-secondary",
2836
- children: "Command"
2837
- }), /* @__PURE__ */ jsx("div", {
2838
- className: "flex flex-wrap gap-1.5",
2839
- children: COMMAND_OPTIONS.map((cmd) => /* @__PURE__ */ jsx(Button, {
2840
- size: "small",
2841
- variant: command === cmd ? "filled" : "text",
2842
- color: "neutral",
2843
- onClick: () => setCommand(cmd),
2844
- children: cmd
2845
- }, cmd))
2846
- })]
2847
- }),
2848
- /* @__PURE__ */ jsxs("div", {
2849
- className: "flex flex-col gap-1.5",
2850
- children: [
2851
- /* @__PURE__ */ jsx(Typography, {
2852
- variant: "caption",
2853
- className: "uppercase tracking-wider text-text-secondary",
2854
- children: "Application Roles"
2855
- }),
2856
- /* @__PURE__ */ jsxs(Typography, {
2857
- variant: "caption",
2858
- className: "text-text-secondary opacity-80 -mt-1",
2859
- children: [
2860
- "Roles held by users of this project, matched via ",
2861
- /* @__PURE__ */ jsx("span", {
2862
- className: "font-mono",
2863
- children: RLS_ROLES_SQL
2864
- }),
2865
- ". These are not PostgreSQL roles — leave empty to apply the policy to everyone."
2866
- ]
2867
- }),
2868
- roleOptions.length > 0 && /* @__PURE__ */ jsx(MultiSelect, {
2869
- size: "small",
2870
- value: roles,
2871
- onValueChange: setRoles,
2872
- placeholder: "Select roles",
2873
- children: roleOptions.map((r) => /* @__PURE__ */ jsx(MultiSelectItem, {
2874
- value: r,
2875
- children: r
2876
- }, r))
2877
- }),
2878
- rolesUnavailable && roleOptions.length === 0 && /* @__PURE__ */ jsx(Typography, {
2879
- variant: "caption",
2880
- className: "text-text-secondary opacity-80",
2881
- children: "Could not load the project's roles — enter them manually below."
2882
- }),
2883
- !rolesUnavailable && roleOptions.length === 0 && /* @__PURE__ */ jsx(Typography, {
2884
- variant: "caption",
2885
- className: "text-text-secondary opacity-80",
2886
- children: "No roles are assigned to any user yet — enter one manually below."
2887
- }),
2888
- /* @__PURE__ */ jsxs("div", {
2889
- className: "flex gap-2 items-center",
2890
- children: [/* @__PURE__ */ jsx(TextField, {
2891
- size: "small",
2892
- "aria-label": "Add a custom role",
2893
- value: customRole,
2894
- onChange: (e) => setCustomRole(e.target.value),
2895
- onKeyDown: (e) => {
2896
- if (e.key === "Enter") {
2897
- e.preventDefault();
2898
- addCustomRole();
2899
- }
2900
- },
2901
- placeholder: "Add a role not listed, e.g. editor"
2902
- }), /* @__PURE__ */ jsx(Button, {
2903
- size: "small",
2904
- variant: "outlined",
2905
- color: "neutral",
2906
- disabled: !customRole.trim(),
2907
- onClick: addCustomRole,
2908
- children: "Add"
2909
- })]
2910
- })
2911
- ]
2912
- }),
2913
- command !== "INSERT" && /* @__PURE__ */ jsxs("div", {
2914
- className: "flex flex-col gap-1.5",
2915
- children: [/* @__PURE__ */ jsx(Typography, {
2916
- variant: "caption",
2917
- className: "uppercase tracking-wider text-text-secondary",
2918
- children: t("studio_policy_using_expr")
2919
- }), /* @__PURE__ */ jsx(TextField, {
2920
- "aria-label": t("studio_policy_using_expr"),
2921
- value: usingExpr,
2922
- onChange: (e) => setUsingExpr(e.target.value),
2923
- placeholder: `e.g. ${RLS_UID_SQL} = uid`
2924
- })]
2925
- }),
2926
- showCheck && /* @__PURE__ */ jsxs("div", {
2927
- className: "flex flex-col gap-1.5",
2928
- children: [/* @__PURE__ */ jsx(Typography, {
2929
- variant: "caption",
2930
- className: "uppercase tracking-wider text-text-secondary",
2931
- children: t("studio_policy_check_expr")
2932
- }), /* @__PURE__ */ jsx(TextField, {
2933
- "aria-label": t("studio_policy_check_expr"),
2934
- value: checkExpr,
2935
- onChange: (e) => setCheckExpr(e.target.value),
2936
- placeholder: `e.g. ${RLS_UID_SQL} = uid`
2937
- })]
2938
- })
2939
- ]
2940
- })
2941
- }),
2942
- /* @__PURE__ */ jsxs(DialogActions, { children: [/* @__PURE__ */ jsx(Button, {
2943
- size: "small",
2944
- variant: "text",
2945
- color: "neutral",
2946
- onClick: onCancel,
2947
- children: "Cancel"
2948
- }), /* @__PURE__ */ jsx(Button, {
2949
- size: "small",
2950
- variant: "filled",
2951
- color: "primary",
2952
- disabled: !name,
2953
- onClick: () => onSave({
2954
- policyname: name,
2955
- permissive: behavior,
2956
- cmd: command,
2957
- roles,
2958
- qual: usingExpr,
2959
- with_check: showCheck ? checkExpr : null
2960
- }),
2961
- children: "Save"
2962
- })] })
2963
- ] });
2964
- }
2965
- //#endregion
2966
- //#region src/collection_editor/ui/collection_editor/CollectionEditorDialog.tsx
2967
- var CollectionEditorDialog_exports = /* @__PURE__ */ __exportAll({
2968
- CollectionEditor: () => CollectionEditor,
2969
- CollectionEditorDialog: () => CollectionEditorDialog
2970
- });
2971
- function CollectionEditorDialog(props) {
2972
- const open = props.open;
2973
- const [formDirty, setFormDirty] = React$1.useState(false);
2974
- const { dialogProps, triggerDialog } = useUnsavedChangesDialog(open && formDirty, () => props.handleClose(void 0));
2975
- const handleCancel = () => {
2976
- if (!formDirty) props.handleClose(void 0);
2977
- else triggerDialog();
2978
- };
2979
- useEffect(() => {
2980
- if (!open) setFormDirty(false);
2981
- }, [open]);
2982
- return /* @__PURE__ */ jsxs(Dialog, {
2983
- open,
2984
- fullWidth: true,
2985
- fullHeight: true,
2986
- scrollable: false,
2987
- maxWidth: "7xl",
2988
- className: "bg-surface-sheet",
2989
- onOpenChange: (open) => !open ? handleCancel() : void 0,
2990
- children: [/* @__PURE__ */ jsx(DialogTitle, {
2991
- hidden: true,
2992
- children: "Collection editor"
2993
- }), /* @__PURE__ */ jsxs(AIModifiedPathsProvider, { children: [open && /* @__PURE__ */ jsx(CollectionEditor, {
2994
- ...props,
2995
- handleCancel,
2996
- setFormDirty
2997
- }), /* @__PURE__ */ jsx(UnsavedChangesDialog, { ...dialogProps })] })]
2998
- });
2999
- }
3000
- function CollectionEditor(props) {
3001
- const { standalone } = props;
3002
- const customizationController = useCustomizationController();
3003
- const navigationState = useNavigationStateController();
3004
- const collectionRegistry = useCollectionRegistryController();
3005
- const authController = useAuthController();
3006
- const propertyConfigs = standalone ? customizationController?.propertyConfigs ?? {} : customizationController.propertyConfigs;
3007
- standalone ? navigationState?.topLevelNavigation : navigationState.topLevelNavigation;
3008
- const collections = standalone ? collectionRegistry?.collections ?? [] : collectionRegistry.collections;
3009
- const initialValuesProp = props.initialValues;
3010
- const copyFromProp = props.copyFrom;
3011
- const includeTemplates = !copyFromProp && !initialValuesProp?.slug && (props.parentCollectionSlugs ?? []).length === 0;
3012
- const collectionsInThisLevel = (props.parentCollection ? getSubcollections(props.parentCollection) : collections) ?? [];
3013
- const existingPaths = collectionsInThisLevel.map((col) => getTableName(col)?.trim().toLowerCase()).filter(Boolean);
3014
- const existingIds = collectionsInThisLevel.map((col) => col.slug?.trim().toLowerCase()).filter(Boolean);
3015
- const [collection, setCollection] = React$1.useState();
3016
- const [initialLoadingCompleted, setInitialLoadingCompleted] = React$1.useState(false);
3017
- useEffect(() => {
3018
- try {
3019
- const initialised = (standalone ? true : collectionRegistry?.initialised ?? true) && !props.configController?.loading;
3020
- const getRawCollection = standalone ? (() => void 0) : collectionRegistry.getRawCollection;
3021
- if (initialised) {
3022
- if (props.editedCollectionId) {
3023
- const collectionPath = [...props.parentCollectionSlugs ?? [], props.editedCollectionId].reduce((acc, segment, i) => i === 0 ? segment : `${acc}/fake_id/${segment}`, "");
3024
- const registryCol = getRawCollection ? getRawCollection(collectionPath) : void 0;
3025
- const configCol = props.configController?.collections?.find((c) => c.slug === props.editedCollectionId);
3026
- setCollection(registryCol ?? configCol);
3027
- } else setCollection(void 0);
3028
- setInitialLoadingCompleted(true);
3029
- }
3030
- } catch (e) {
3031
- console.error(e);
3032
- }
3033
- }, [
3034
- props.editedCollectionId,
3035
- props.parentCollectionSlugs,
3036
- props.parentEntityIds,
3037
- standalone,
3038
- collectionRegistry.initialised,
3039
- collectionRegistry.getRawCollection,
3040
- props.configController.collections,
3041
- props.configController.loading,
3042
- collections
3043
- ]);
3044
- const initialIcon = React$1.useMemo(() => coolIconKeys[Math.floor(Math.random() * coolIconKeys.length)], []);
3045
- const fallbackSlug = React$1.useMemo(() => randomString(16), []);
3046
- const initialCollection = React$1.useMemo(() => {
3047
- return collection ? {
3048
- ...collection,
3049
- slug: collection.slug ?? fallbackSlug
3050
- } : void 0;
3051
- }, [collection, fallbackSlug]);
3052
- const initialValues = React$1.useMemo(() => {
3053
- return initialCollection ? applyPropertyConfigs(initialCollection, propertyConfigs) : copyFromProp ? (() => {
3054
- const { subcollections: _sub, schema: _schema, auth: _auth, ...rest } = copyFromProp;
3055
- return {
3056
- ...rest,
3057
- name: "",
3058
- slug: fallbackSlug,
3059
- table: "",
3060
- ownerId: authController.user?.uid ?? ""
3061
- };
3062
- })() : {
3063
- slug: initialValuesProp?.slug ?? fallbackSlug,
3064
- table: initialValuesProp?.slug ?? "",
3065
- name: initialValuesProp?.name ?? "",
3066
- properties: {},
3067
- propertiesOrder: [],
3068
- icon: initialIcon,
3069
- ownerId: authController.user?.uid ?? ""
3070
- };
3071
- }, [
3072
- initialCollection,
3073
- propertyConfigs,
3074
- copyFromProp,
3075
- initialValuesProp,
3076
- fallbackSlug,
3077
- initialIcon,
3078
- authController.user?.uid
3079
- ]);
3080
- if (!initialLoadingCompleted) return /* @__PURE__ */ jsx(CircularProgressCenter, {});
3081
- if (!props.isNewCollection && (!(standalone ? true : collectionRegistry?.initialised ?? true) || !initialLoadingCompleted)) return /* @__PURE__ */ jsx(CircularProgressCenter, {});
3082
- return /* @__PURE__ */ jsx(CollectionEditorInternal, {
3083
- ...props,
3084
- initialValues,
3085
- existingPaths,
3086
- existingIds,
3087
- includeTemplates,
3088
- collection,
3089
- setCollection,
3090
- propertyConfigs
3091
- });
3092
- }
3093
- function CollectionEditorInternal({ isNewCollection, configController, editedCollectionId, parentCollectionSlugs, parentEntityIds, path, collectionInference, handleClose, extraView, handleCancel, setFormDirty, getUser, parentCollection, getData, existingPaths, existingIds, includeTemplates, collection, setCollection, initialValues, propertyConfigs, existingEntities, initialView: initialViewProp, expandKanban, generateCollection, onAnalyticsEvent, fullScreen, unmappedTables, onFetchTableMetadata, propertyTypePresets, hiddenPropertyTypes, renderExtraPropertyFields, renderExtraCollectionFields, visibleTabs, standalone }) {
3094
- /** Why the submit buttons below are dead, straight from the backend. */
3095
- const readOnlyTitle = configController?.readOnlyReason || "This backend does not accept collection edits.";
3096
- const importConfigRaw = useImportConfig();
3097
- const urlControllerRaw = useUrlController();
3098
- const collectionRegistryRaw = useCollectionRegistryController();
3099
- const snackbarControllerRaw = useSafeSnackbarController();
3100
- const importConfig = standalone ? void 0 : importConfigRaw;
3101
- const urlController = standalone ? {
3102
- basePath: "/",
3103
- baseCollectionPath: "/c",
3104
- urlPathToDataPath: () => "",
3105
- homeUrl: "/",
3106
- isUrlCollectionPath: () => false,
3107
- buildUrlCollectionPath: () => "",
3108
- buildAppUrlPath: () => "",
3109
- resolveDatabasePathsFrom: (p) => p,
3110
- navigate: () => {}
3111
- } : urlControllerRaw;
3112
- const collectionRegistryInternal = standalone ? { convertIdsToPaths: (ids) => ids } : collectionRegistryRaw;
3113
- const snackbarController = snackbarControllerRaw ?? {
3114
- open: () => {},
3115
- close: () => {}
3116
- };
3117
- const propertyErrorsRef = useRef({});
3118
- const [currentView, setCurrentView] = useState(isNewCollection ? includeTemplates ? "welcome" : "general" : initialViewProp ?? "properties");
3119
- useEffect(() => {
3120
- if (visibleTabs && !visibleTabs.includes(currentView)) setCurrentView(visibleTabs[0] || "general");
3121
- }, [visibleTabs, currentView]);
3122
- const [error, setError] = React$1.useState();
3123
- /**
3124
- * `baseline` is what the form was loaded with: the controller saves the
3125
- * difference between it and `updatedCollection`, so only what the person
3126
- * changed is written. Never for a new collection, which is saved whole.
3127
- */
3128
- const saveCollection = (updatedCollection, baseline) => {
3129
- const id = updatedCollection.slug;
3130
- return configController.saveCollection({
3131
- id,
3132
- collectionData: updatedCollection,
3133
- baseline: isNewCollection ? void 0 : baseline,
3134
- previousId: editedCollectionId,
3135
- parentCollectionSlugs
3136
- }).then(() => {
3137
- setError(void 0);
3138
- return true;
3139
- }).catch((e) => {
3140
- if (isSchemaChangeCancelled(e)) {
3141
- setError(void 0);
3142
- return false;
3143
- }
3144
- setError(e);
3145
- console.error(e);
3146
- snackbarController.open({
3147
- type: "error",
3148
- message: "Error persisting collection: " + (e.message ?? "Details in the console")
3149
- });
3150
- return false;
3151
- });
3152
- };
3153
- const setNextMode = () => {
3154
- if (currentView === "general") if (importConfig?.inUse) setCurrentView("import_data_saving");
3155
- else if (extraView) setCurrentView("extra_view");
3156
- else setCurrentView("properties");
3157
- else if (currentView === "welcome") setCurrentView("general");
3158
- else if (currentView === "import_data_mapping") setCurrentView("import_data_preview");
3159
- else if (currentView === "import_data_preview") setCurrentView("general");
3160
- else if (currentView === "extra_view") setCurrentView("properties");
3161
- else setCurrentView("general");
3162
- };
3163
- const doCollectionInference = collectionInference ? (collection) => {
3164
- if (!collectionInference) return void 0;
3165
- return collectionInference?.(collection.slug, parentPaths ?? [], collection.databaseId);
3166
- } : void 0;
3167
- const inferCollectionFromData = async (newCollection) => {
3168
- try {
3169
- if (!doCollectionInference) {
3170
- setCollection(newCollection);
3171
- return Promise.resolve(newCollection);
3172
- }
3173
- setCurrentView("loading");
3174
- const inferredCollection = await doCollectionInference?.(newCollection);
3175
- if (!inferredCollection) {
3176
- setCollection(newCollection);
3177
- return Promise.resolve(newCollection);
3178
- }
3179
- const values = { ...newCollection ?? {} };
3180
- if (Object.keys(inferredCollection.properties ?? {}).length > 0) {
3181
- values.properties = inferredCollection.properties;
3182
- values.propertiesOrder = inferredCollection.propertiesOrder;
3183
- }
3184
- if (!values.propertiesOrder) {
3185
- values.propertiesOrder = Object.keys(values.properties);
3186
- return values;
3187
- }
3188
- setCollection(values);
3189
- console.debug("Inferred collection", {
3190
- newCollection: newCollection ?? {},
3191
- values
3192
- });
3193
- return values;
3194
- } catch (e) {
3195
- console.error(e);
3196
- snackbarController.open({
3197
- type: "error",
3198
- message: "Error inferring collection: " + (e instanceof Error ? e.message : "Details in the console")
3199
- });
3200
- return newCollection;
3201
- }
3202
- };
3203
- const onSubmit = async (newCollectionState, formexController) => {
3204
- console.debug("Submitting collection", newCollectionState);
3205
- try {
3206
- if (!isNewCollection) {
3207
- if (await saveCollection(newCollectionState, formexController.initialValues)) {
3208
- aiModifiedPaths?.clearAllPaths();
3209
- formexController.resetForm({ values: newCollectionState });
3210
- handleClose(newCollectionState);
3211
- }
3212
- return;
3213
- }
3214
- if (currentView === "welcome") {
3215
- setNextMode();
3216
- formexController.resetForm({ values: newCollectionState });
3217
- } else if (currentView === "general") if (extraView || importConfig?.inUse) {
3218
- formexController.resetForm({ values: newCollectionState });
3219
- setNextMode();
3220
- } else if (isNewCollection) {
3221
- const values = await inferCollectionFromData(newCollectionState);
3222
- formexController.resetForm({
3223
- values: values ?? newCollectionState,
3224
- touched: {
3225
- path: true,
3226
- name: true
3227
- }
3228
- });
3229
- setNextMode();
3230
- } else {
3231
- formexController.resetForm({ values: newCollectionState });
3232
- setNextMode();
3233
- }
3234
- else if (currentView === "extra_view") {
3235
- setNextMode();
3236
- formexController.resetForm({ values: newCollectionState });
3237
- } else if (currentView === "import_data_mapping") setNextMode();
3238
- else if (currentView === "import_data_preview") setNextMode();
3239
- else if (currentView === "properties") {
3240
- if (await saveCollection(newCollectionState)) {
3241
- formexController.resetForm({ values: initialValues });
3242
- setNextMode();
3243
- handleClose(newCollectionState);
3244
- }
3245
- } else {
3246
- setNextMode();
3247
- formexController.resetForm({ values: newCollectionState });
3248
- }
3249
- } catch (e) {
3250
- snackbarController.open({
3251
- type: "error",
3252
- message: "Error persisting collection: " + (e instanceof Error ? e.message : "Details in the console")
3253
- });
3254
- console.error(e);
3255
- formexController.resetForm({ values: newCollectionState });
3256
- }
3257
- };
3258
- const validation = (col) => {
3259
- let errors = {};
3260
- const schema = (currentView === "properties" || currentView === "general") && CollectionEditorSchema;
3261
- if (schema) {
3262
- const result = schema.safeParse(col);
3263
- if (!result.success) result.error.issues.forEach((issue) => {
3264
- const path = issue.path.join(".");
3265
- if (path) errors[path] = issue.message;
3266
- });
3267
- }
3268
- if (currentView === "properties") errors = {
3269
- ...errors,
3270
- ...propertyErrorsRef.current
3271
- };
3272
- if (currentView === "general") {
3273
- const pathError = validatePath(getTableName(col), isNewCollection, existingPaths, col.slug);
3274
- if (pathError) errors.slug = pathError;
3275
- const idError = validateId(col.slug, isNewCollection, existingPaths, existingIds);
3276
- if (idError) errors.id = idError;
3277
- }
3278
- if (Object.keys(errors).length > 0) console.error("Formex validation blocked save:", errors, "Current view:", currentView);
3279
- return errors;
3280
- };
3281
- const formController = useCreateFormex({
3282
- initialValues,
3283
- onSubmit,
3284
- validation,
3285
- debugId: "COLLECTION_EDITOR"
3286
- });
3287
- const { values, setFieldValue, isSubmitting, dirty, submitCount } = formController;
3288
- const usedPath = getTableName(values);
3289
- const pathError = validatePath(usedPath, isNewCollection, existingPaths, values.slug);
3290
- const parentPaths = !pathError && parentCollectionSlugs ? collectionRegistryInternal.convertIdsToPaths(parentCollectionSlugs) : void 0;
3291
- const updatedFullPath = parentPaths && parentPaths.length > 0 ? [...parentPaths, usedPath].join("/fake_id/") : path?.includes("/") ? path.split("/").slice(0, -1).join("/") + "/" + usedPath : usedPath;
3292
- const resolvedPath = !pathError ? urlController.resolveDatabasePathsFrom(updatedFullPath) : void 0;
3293
- const getDataWithPath = resolvedPath && getData ? async () => {
3294
- const data = await getData(resolvedPath, parentPaths ?? []);
3295
- if (existingEntities) {
3296
- const existingData = existingEntities.map((e) => e.values);
3297
- data.push(...existingData);
3298
- }
3299
- return data;
3300
- } : void 0;
3301
- useEffect(() => {
3302
- setFormDirty(dirty);
3303
- }, [dirty]);
3304
- function onImportDataSet(data, propertiesOrder) {
3305
- importConfig?.setInUse(true);
3306
- buildEntityPropertiesFromData(data, getInferenceType).then((properties) => {
3307
- const res = cleanPropertiesFromImport(properties);
3308
- importConfig?.setIdColumn(res.idColumn);
3309
- importConfig?.setImportData(data);
3310
- importConfig?.setHeadersMapping(res.headersMapping);
3311
- const filteredHeadingsOrder = (propertiesOrder ?? []).filter((key) => res.headersMapping[key]) ?? Object.keys(res.properties);
3312
- importConfig?.setHeadingsOrder(filteredHeadingsOrder);
3313
- importConfig?.setOriginProperties(res.properties);
3314
- const mappedHeadings = (propertiesOrder ?? []).map((key) => res.headersMapping[key]).filter(Boolean) ?? Object.keys(res.properties);
3315
- setFieldValue("properties", res.properties);
3316
- setFieldValue("propertiesOrder", mappedHeadings);
3317
- });
3318
- }
3319
- const validValues = Boolean(values.name) && Boolean(values.slug);
3320
- const onImportMappingComplete = () => {
3321
- const updatedProperties = { ...values.properties };
3322
- if (importConfig?.idColumn) delete updatedProperties[importConfig.idColumn];
3323
- setFieldValue("properties", updatedProperties);
3324
- setNextMode();
3325
- };
3326
- const [deleteRequested, setDeleteRequested] = useState(false);
3327
- const deleteCollection = () => {
3328
- if (!collection) return;
3329
- configController?.deleteCollection({ id: collection.slug }).then(() => {
3330
- setDeleteRequested(false);
3331
- handleCancel();
3332
- snackbarController.open({
3333
- message: "Collection deleted",
3334
- type: "success"
3335
- });
3336
- }, (e) => {
3337
- setDeleteRequested(false);
3338
- if (isSchemaChangeCancelled(e)) return;
3339
- console.error(e);
3340
- snackbarController.open({
3341
- type: "error",
3342
- message: "Error deleting collection: " + (e instanceof Error ? e.message : String(e))
3343
- });
3344
- });
3345
- };
3346
- const onWelcomeScreenContinue = (importData, propertiesOrder) => {
3347
- if (importData) {
3348
- onImportDataSet(importData, propertiesOrder);
3349
- setCurrentView("import_data_mapping");
3350
- } else setCurrentView("general");
3351
- };
3352
- const aiModifiedPaths = useAIModifiedPaths();
3353
- const handleAIGenerated = (generatedCollection, operations) => {
3354
- formController.setValues(generatedCollection);
3355
- if (operations && aiModifiedPaths) aiModifiedPaths.addModifiedPaths(operations);
3356
- };
3357
- return /* @__PURE__ */ jsxs("div", {
3358
- className: "h-full w-full flex flex-col bg-surface-sheet",
3359
- children: [/* @__PURE__ */ jsx(Formex, {
3360
- value: formController,
3361
- children: /* @__PURE__ */ jsxs(Fragment, { children: [!isNewCollection && /* @__PURE__ */ jsxs("div", {
3362
- className: cls("px-4 py-2 w-full flex shrink-0 items-center justify-between gap-4 border-b", defaultBorderMixin),
3363
- children: [/* @__PURE__ */ jsx("div", {
3364
- className: "flex flex-1 items-center justify-end gap-4 min-w-0",
3365
- children: /* @__PURE__ */ jsxs(Tabs, {
3366
- value: currentView,
3367
- className: "bg-transparent !w-fit max-w-full",
3368
- onValueChange: (v) => setCurrentView(v),
3369
- children: [
3370
- (!visibleTabs || visibleTabs.includes("general")) && /* @__PURE__ */ jsx(Tab, {
3371
- value: "general",
3372
- children: "General"
3373
- }),
3374
- (!visibleTabs || visibleTabs.includes("display")) && /* @__PURE__ */ jsx(Tab, {
3375
- value: "display",
3376
- children: "Display"
3377
- }),
3378
- (!visibleTabs || visibleTabs.includes("properties")) && /* @__PURE__ */ jsx(Tab, {
3379
- value: "properties",
3380
- children: "Properties"
3381
- }),
3382
- (!visibleTabs || visibleTabs.includes("rls")) && getDataSourceCapabilities(values.engine).supportsRLS && /* @__PURE__ */ jsx(Tab, {
3383
- value: "rls",
3384
- children: "RLS"
3385
- })
3386
- ]
3387
- })
3388
- }), /* @__PURE__ */ jsxs("div", {
3389
- className: "flex items-center gap-4",
3390
- children: [generateCollection && /* @__PURE__ */ jsx(AICollectionGeneratorPopover, {
3391
- existingCollection: values,
3392
- onGenerated: handleAIGenerated,
3393
- generateCollection,
3394
- onAnalyticsEvent
3395
- }), fullScreen && !isNewCollection && /* @__PURE__ */ jsxs("div", {
3396
- className: "flex items-center gap-2",
3397
- children: [configController?.readOnly && /* @__PURE__ */ jsx(Typography, {
3398
- variant: "caption",
3399
- color: "secondary",
3400
- className: "max-w-[28rem] truncate",
3401
- title: readOnlyTitle,
3402
- children: readOnlyTitle
3403
- }), /* @__PURE__ */ jsx(Tooltip, {
3404
- title: configController?.readOnly ? readOnlyTitle : void 0,
3405
- children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(LoadingButton, {
3406
- variant: "filled",
3407
- color: "primary",
3408
- type: "submit",
3409
- onClick: () => formController.handleSubmit(),
3410
- disabled: !dirty || isSubmitting || configController?.readOnly,
3411
- loading: isSubmitting,
3412
- children: configController?.readOnly ? "Update (Read-only)" : "Update"
3413
- }) })
3414
- })]
3415
- })]
3416
- })]
3417
- }), /* @__PURE__ */ jsxs("form", {
3418
- noValidate: true,
3419
- onSubmit: formController.handleSubmit,
3420
- className: "flex-grow flex flex-col min-h-0 relative",
3421
- children: [/* @__PURE__ */ jsxs("div", {
3422
- className: "flex-grow flex flex-col min-h-0 relative w-full h-full bg-surface-sheet",
3423
- children: [
3424
- currentView === "loading" && /* @__PURE__ */ jsx(CircularProgressCenter, {}),
3425
- currentView === "extra_view" && usedPath && extraView?.View && /* @__PURE__ */ jsx(extraView.View, { path: usedPath }),
3426
- currentView === "welcome" && /* @__PURE__ */ jsx(CollectionEditorWelcomeView, {
3427
- path: usedPath,
3428
- onContinue: onWelcomeScreenContinue,
3429
- existingCollectionPaths: existingPaths,
3430
- parentCollection,
3431
- generateCollection,
3432
- onAnalyticsEvent,
3433
- unmappedTables,
3434
- onImportFromTable: onFetchTableMetadata ? async (tableName) => {
3435
- try {
3436
- const columns = await onFetchTableMetadata(tableName);
3437
- if (!columns) return;
3438
- const collectionData = buildCollectionFromTableMetadata(tableName, columns);
3439
- formController.setValues({
3440
- ...formController.values,
3441
- ...collectionData
3442
- });
3443
- onWelcomeScreenContinue();
3444
- } catch (e) {
3445
- console.error("Error importing table:", e);
3446
- snackbarController.open({
3447
- type: "error",
3448
- message: "Error importing table: " + (e instanceof Error ? e.message : "Unknown error")
3449
- });
3450
- }
3451
- } : void 0
3452
- }),
3453
- currentView === "import_data_mapping" && importConfig && /* @__PURE__ */ jsx(CollectionEditorImportMapping, {
3454
- importConfig,
3455
- propertyConfigs
3456
- }),
3457
- currentView === "import_data_preview" && importConfig && /* @__PURE__ */ jsx(CollectionEditorImportDataPreview, {
3458
- importConfig,
3459
- properties: values.properties,
3460
- propertiesOrder: values.propertiesOrder
3461
- }),
3462
- currentView === "import_data_saving" && importConfig && /* @__PURE__ */ jsx(ImportSaveInProgress, {
3463
- importConfig,
3464
- collection: values,
3465
- path: usedPath,
3466
- onImportSuccess: async (importedCollection) => {
3467
- snackbarController.open({
3468
- type: "info",
3469
- message: "Data imported successfully"
3470
- });
3471
- await saveCollection(values, formController.initialValues);
3472
- handleClose(importedCollection);
3473
- }
3474
- }),
3475
- currentView === "general" && /* @__PURE__ */ jsx(GeneralSettingsForm, {
3476
- isNewCollection,
3477
- existingPaths,
3478
- existingIds,
3479
- parentCollection,
3480
- renderExtraCollectionFields,
3481
- standalone
3482
- }),
3483
- currentView === "display" && /* @__PURE__ */ jsx(DisplaySettingsForm, {
3484
- expandKanban,
3485
- standalone
3486
- }),
3487
- currentView === "rls" && getDataSourceCapabilities(values.engine).supportsRLS && /* @__PURE__ */ jsx(CollectionRLSTab, {}),
3488
- currentView === "properties" && /* @__PURE__ */ jsx(CollectionPropertiesEditorForm, {
3489
- showErrors: submitCount > 0,
3490
- isNewCollection,
3491
- onPropertyError: (propertyKey, namespace, error) => {
3492
- const current = removeUndefined({
3493
- ...propertyErrorsRef.current,
3494
- [getFullIdPath(propertyKey, namespace)]: removeUndefined(error, true)
3495
- }, true);
3496
- propertyErrorsRef.current = current;
3497
- formController.validate();
3498
- },
3499
- getUser,
3500
- getData: getDataWithPath,
3501
- doCollectionInference,
3502
- propertyConfigs,
3503
- propertyTypePresets,
3504
- hiddenPropertyTypes,
3505
- renderExtraPropertyFields,
3506
- extraIcon: extraView?.icon && /* @__PURE__ */ jsx(IconButton, {
3507
- onClick: () => setCurrentView("extra_view"),
3508
- children: extraView.icon
3509
- }),
3510
- standalone
3511
- })
3512
- ]
3513
- }), (!fullScreen || isNewCollection || !!error) && /* @__PURE__ */ jsxs("div", {
3514
- className: "shrink-0 w-full p-4 sm:px-6 sm:py-4 border-t border-hairline flex items-center justify-between gap-4",
3515
- children: [
3516
- error && /* @__PURE__ */ jsx(ErrorView, { error }),
3517
- isNewCollection && includeTemplates && currentView === "import_data_mapping" && /* @__PURE__ */ jsx(Button, {
3518
- variant: "text",
3519
- type: "button",
3520
- onClick: () => {
3521
- importConfig?.setInUse(false);
3522
- return setCurrentView("welcome");
3523
- },
3524
- children: "Back"
3525
- }),
3526
- isNewCollection && includeTemplates && currentView === "import_data_preview" && /* @__PURE__ */ jsx(Button, {
3527
- variant: "text",
3528
- type: "button",
3529
- onClick: () => {
3530
- setCurrentView("import_data_mapping");
3531
- },
3532
- children: "Back"
3533
- }),
3534
- isNewCollection && includeTemplates && currentView === "general" && /* @__PURE__ */ jsx(Button, {
3535
- variant: "text",
3536
- type: "button",
3537
- onClick: () => setCurrentView("welcome"),
3538
- children: "Back"
3539
- }),
3540
- isNewCollection && currentView === "properties" && /* @__PURE__ */ jsxs(Button, {
3541
- variant: "text",
3542
- type: "button",
3543
- color: "neutral",
3544
- onClick: () => setCurrentView("general"),
3545
- children: [/* @__PURE__ */ jsx(ArrowLeftIcon, {}), "Back"]
3546
- }),
3547
- /* @__PURE__ */ jsxs("div", {
3548
- className: "flex items-center gap-2 ml-auto",
3549
- children: [
3550
- (!fullScreen || isNewCollection) && /* @__PURE__ */ jsx(Button, {
3551
- variant: "text",
3552
- color: "neutral",
3553
- onClick: () => {
3554
- handleCancel();
3555
- },
3556
- children: "Cancel"
3557
- }),
3558
- currentView === "welcome" && /* @__PURE__ */ jsx(Button, {
3559
- variant: "text",
3560
- onClick: () => onWelcomeScreenContinue(),
3561
- children: "Continue from scratch"
3562
- }),
3563
- isNewCollection && currentView === "import_data_mapping" && /* @__PURE__ */ jsx(Button, {
3564
- variant: "filled",
3565
- color: "primary",
3566
- onClick: onImportMappingComplete,
3567
- children: "Next"
3568
- }),
3569
- isNewCollection && currentView === "import_data_preview" && /* @__PURE__ */ jsx(Button, {
3570
- variant: "filled",
3571
- color: "primary",
3572
- onClick: () => {
3573
- setNextMode();
3574
- },
3575
- children: "Next"
3576
- }),
3577
- isNewCollection && (currentView === "general" || currentView === "properties") && /* @__PURE__ */ jsxs(LoadingButton, {
3578
- variant: "filled",
3579
- color: "primary",
3580
- type: "submit",
3581
- loading: isSubmitting,
3582
- disabled: isSubmitting || currentView === "general" && !validValues || configController?.readOnly,
3583
- startIcon: currentView === "properties" ? /* @__PURE__ */ jsx(CheckIcon, {}) : void 0,
3584
- children: [currentView === "general" && "Next", currentView === "properties" && "Create collection"]
3585
- }),
3586
- !isNewCollection && !fullScreen && /* @__PURE__ */ jsx(Tooltip, {
3587
- title: configController?.readOnly ? readOnlyTitle : void 0,
3588
- children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(LoadingButton, {
3589
- variant: "filled",
3590
- color: "primary",
3591
- type: "submit",
3592
- disabled: isSubmitting || configController?.readOnly,
3593
- loading: isSubmitting,
3594
- children: configController?.readOnly ? "Update collection (Read-only)" : "Update collection"
3595
- }) })
3596
- })
3597
- ]
3598
- })
3599
- ]
3600
- })]
3601
- })] })
3602
- }), /* @__PURE__ */ jsx(ConfirmationDialog, {
3603
- open: deleteRequested,
3604
- onAccept: deleteCollection,
3605
- onCancel: () => setDeleteRequested(false),
3606
- title: /* @__PURE__ */ jsx(Fragment, { children: "Delete this collection?" }),
3607
- body: /* @__PURE__ */ jsxs(Fragment, { children: [
3608
- "Deletes ",
3609
- /* @__PURE__ */ jsxs("code", { children: [collection?.slug, ".ts"] }),
3610
- " from your collections and its entry in",
3611
- " ",
3612
- /* @__PURE__ */ jsx("code", { children: "index.ts" }),
3613
- ", and commits that. The table and its rows stay in the database. Refused while another collection links to this one."
3614
- ] })
3615
- })]
3616
- });
3617
- }
3618
- function applyPropertyConfigs(collection, propertyConfigs) {
3619
- const { properties, ...rest } = collection;
3620
- const propertiesResult = {};
3621
- if (properties) Object.keys(properties).forEach((key) => {
3622
- const prop = properties[key];
3623
- if (prop == null) return;
3624
- propertiesResult[key] = applyPropertiesConfig(prop, propertyConfigs);
3625
- });
3626
- return {
3627
- ...rest,
3628
- properties: propertiesResult
3629
- };
3630
- }
3631
- function applyPropertiesConfig(property, propertyConfigs) {
3632
- let internalProperty = property;
3633
- if (propertyConfigs && internalProperty && typeof internalProperty === "object" && internalProperty.propertyConfig) {
3634
- const propertyConfig = propertyConfigs[internalProperty.propertyConfig];
3635
- if (propertyConfig && isPropertyBuilder(propertyConfig.property)) internalProperty = propertyConfig.property;
3636
- else {
3637
- if (propertyConfig) internalProperty = mergeDeep(propertyConfig.property, internalProperty);
3638
- if (!isPropertyBuilder(internalProperty) && internalProperty.type === "map" && internalProperty.properties) {
3639
- const properties = {};
3640
- Object.keys(internalProperty.properties).forEach((key) => {
3641
- properties[key] = applyPropertiesConfig(internalProperty.properties[key], propertyConfigs);
3642
- });
3643
- internalProperty = {
3644
- ...internalProperty,
3645
- properties
3646
- };
3647
- }
3648
- }
3649
- }
3650
- return internalProperty;
3651
- }
3652
- var validatePath = (value, isNewCollection, existingPaths, idValue) => {
3653
- let error;
3654
- if (!value) error = "You must specify a path in the database for this collection";
3655
- if (isNewCollection && existingPaths?.includes(value.trim().toLowerCase()) && !idValue) error = "There is already a collection with the specified path. If you want to have multiple collections referring to the same database path, make sure the have different ids";
3656
- if (removeInitialAndTrailingSlashes(value).split("/").length % 2 === 0) error = `Collection paths must have an odd number of segments: ${value}`;
3657
- return error;
3658
- };
3659
- var validateId = (value, isNewCollection, existingPaths, existingIds) => {
3660
- if (!value) return void 0;
3661
- let error;
3662
- if (isNewCollection && existingPaths?.includes(value.trim().toLowerCase())) error = "There is already a collection that uses this value as a path";
3663
- if (isNewCollection && existingIds?.includes(value.trim().toLowerCase())) error = "There is already a collection which uses this id";
3664
- return error;
3665
- };
3666
- //#endregion
3667
- export { CollectionEditorDialog as n, CollectionEditorDialog_exports as r, CollectionEditor as t };
3668
-
3669
- //# sourceMappingURL=CollectionEditorDialog-p5-I-Apu.js.map