@rebasepro/cms 0.23.0 → 0.24.1-canary.g19596ef

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