@rebasepro/cms 0.30.1 → 0.31.0-canary.g59cd6fd

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 (583) hide show
  1. package/README.md +8 -8
  2. package/dist/collection_editor/ConfigControllerProvider.js +25 -22
  3. package/dist/collection_editor/ConfigControllerProvider.js.map +1 -1
  4. package/dist/collection_editor/firestore_callee.d.ts +10 -0
  5. package/dist/collection_editor/firestore_callee.js +15 -0
  6. package/dist/collection_editor/firestore_callee.js.map +1 -0
  7. package/dist/collection_editor/firestore_edit.d.ts +62 -0
  8. package/dist/collection_editor/firestore_edit.js +339 -0
  9. package/dist/collection_editor/firestore_edit.js.map +1 -0
  10. package/dist/collection_editor/index.d.ts +2 -3
  11. package/dist/collection_editor/liveSchemaClient.d.ts +44 -22
  12. package/dist/collection_editor/liveSchemaClient.js +9 -3
  13. package/dist/collection_editor/liveSchemaClient.js.map +1 -1
  14. package/dist/collection_editor/property_column.d.ts +86 -0
  15. package/dist/collection_editor/property_column.js +719 -0
  16. package/dist/collection_editor/property_column.js.map +1 -0
  17. package/dist/collection_editor/serializable_types.d.ts +2 -24
  18. package/dist/collection_editor/serializable_utils.d.ts +1 -1
  19. package/dist/collection_editor/serializable_utils.js +2 -1
  20. package/dist/collection_editor/serializable_utils.js.map +1 -1
  21. package/dist/collection_editor/split_edit.d.ts +106 -0
  22. package/dist/collection_editor/split_edit.js +564 -0
  23. package/dist/collection_editor/split_edit.js.map +1 -0
  24. package/dist/collection_editor/split_edit_error.d.ts +25 -0
  25. package/dist/collection_editor/split_edit_error.js +35 -0
  26. package/dist/collection_editor/split_edit_error.js.map +1 -0
  27. package/dist/collection_editor/types/collection_editor_controller.d.ts +1 -1
  28. package/dist/collection_editor/types/config_controller.d.ts +67 -1
  29. package/dist/collection_editor/ui/collection_editor/CollectionEditorDialog.d.ts +6 -5
  30. package/dist/collection_editor/ui/collection_editor/CollectionEditorDialog.js +44 -12
  31. package/dist/collection_editor/ui/collection_editor/CollectionEditorDialog.js.map +1 -1
  32. package/dist/collection_editor/ui/collection_editor/CollectionPropertiesEditorForm.js +18 -3
  33. package/dist/collection_editor/ui/collection_editor/CollectionPropertiesEditorForm.js.map +1 -1
  34. package/dist/collection_editor/ui/collection_editor/CollectionRLSTab.js +94 -55
  35. package/dist/collection_editor/ui/collection_editor/CollectionRLSTab.js.map +1 -1
  36. package/dist/collection_editor/ui/collection_editor/CollectionRelationsTab.d.ts +2 -1
  37. package/dist/collection_editor/ui/collection_editor/DisplaySettingsForm.js.map +1 -1
  38. package/dist/collection_editor/ui/collection_editor/EnumForm.d.ts +1 -1
  39. package/dist/collection_editor/ui/collection_editor/EnumForm.js.map +1 -1
  40. package/dist/collection_editor/ui/collection_editor/GeneralSettingsForm.js +3 -3
  41. package/dist/collection_editor/ui/collection_editor/GeneralSettingsForm.js.map +1 -1
  42. package/dist/collection_editor/ui/collection_editor/KanbanConfigSection.js.map +1 -1
  43. package/dist/collection_editor/ui/collection_editor/PropertyEditView.d.ts +2 -3
  44. package/dist/collection_editor/ui/collection_editor/PropertyEditView.js +1 -1
  45. package/dist/collection_editor/ui/collection_editor/PropertyEditView.js.map +1 -1
  46. package/dist/collection_editor/ui/collection_editor/PropertyFieldPreview.d.ts +1 -1
  47. package/dist/collection_editor/ui/collection_editor/PropertyFieldPreview.js +1 -1
  48. package/dist/collection_editor/ui/collection_editor/PropertyFieldPreview.js.map +1 -1
  49. package/dist/collection_editor/ui/collection_editor/PropertyTree.d.ts +7 -4
  50. package/dist/collection_editor/ui/collection_editor/PropertyTree.js +15 -5
  51. package/dist/collection_editor/ui/collection_editor/PropertyTree.js.map +1 -1
  52. package/dist/collection_editor/ui/collection_editor/SchemaChangeDialog.js +1 -1
  53. package/dist/collection_editor/ui/collection_editor/SchemaChangeDialog.js.map +1 -1
  54. package/dist/collection_editor/ui/collection_editor/SchemaEditRefusalView.d.ts +20 -0
  55. package/dist/collection_editor/ui/collection_editor/SchemaEditRefusalView.js +74 -0
  56. package/dist/collection_editor/ui/collection_editor/SchemaEditRefusalView.js.map +1 -0
  57. package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.d.ts +1 -1
  58. package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.js.map +1 -1
  59. package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportMapping.js.map +1 -1
  60. package/dist/collection_editor/ui/collection_editor/import/clean_import_data.d.ts +1 -1
  61. package/dist/collection_editor/ui/collection_editor/import/clean_import_data.js.map +1 -1
  62. package/dist/collection_editor/ui/collection_editor/properties/BlockPropertyField.js.map +1 -1
  63. package/dist/collection_editor/ui/collection_editor/properties/DateTimePropertyField.js.map +1 -1
  64. package/dist/collection_editor/ui/collection_editor/properties/EnumPropertyField.js +1 -1
  65. package/dist/collection_editor/ui/collection_editor/properties/EnumPropertyField.js.map +1 -1
  66. package/dist/collection_editor/ui/collection_editor/properties/MapPropertyField.js.map +1 -1
  67. package/dist/collection_editor/ui/collection_editor/properties/ReferencePropertyField.js.map +1 -1
  68. package/dist/collection_editor/ui/collection_editor/properties/RelationPropertyField.js.map +1 -1
  69. package/dist/collection_editor/ui/collection_editor/properties/RepeatPropertyField.js.map +1 -1
  70. package/dist/collection_editor/ui/collection_editor/properties/conditions/ConditionsEditor.d.ts +1 -1
  71. package/dist/collection_editor/ui/collection_editor/properties/conditions/EnumConditionsEditor.d.ts +1 -1
  72. package/dist/collection_editor/ui/collection_editor/properties/conditions/property_paths.d.ts +1 -1
  73. package/dist/collection_editor/ui/collection_editor/rlsRuleForm.d.ts +34 -0
  74. package/dist/collection_editor/ui/collection_editor/rlsRuleForm.js +50 -0
  75. package/dist/collection_editor/ui/collection_editor/rlsRuleForm.js.map +1 -0
  76. package/dist/collection_editor/ui/collection_editor/utils/update_property_for_widget.d.ts +1 -2
  77. package/dist/collection_editor/ui/collection_editor/utils/update_property_for_widget.js.map +1 -1
  78. package/dist/collection_editor/useDetachRulesConfirmation.d.ts +16 -0
  79. package/dist/collection_editor/useDetachRulesConfirmation.js +48 -0
  80. package/dist/collection_editor/useDetachRulesConfirmation.js.map +1 -0
  81. package/dist/collection_editor/useLiveSchemaEditing.d.ts +2 -2
  82. package/dist/collection_editor/useLiveSchemaEditing.js +1 -1
  83. package/dist/collection_editor/useLiveSchemaEditing.js.map +1 -1
  84. package/dist/collection_editor/useLocalCollectionsConfigController.d.ts +54 -10
  85. package/dist/collection_editor/useLocalCollectionsConfigController.js +394 -122
  86. package/dist/collection_editor/useLocalCollectionsConfigController.js.map +1 -1
  87. package/dist/collection_editor/validateCollectionJson.js.map +1 -1
  88. package/dist/components/CollectionPanel.d.ts +10 -9
  89. package/dist/components/CollectionPanel.js +5 -2
  90. package/dist/components/CollectionPanel.js.map +1 -1
  91. package/dist/components/CollectionTableBinding/CollectionRowActions.d.ts +1 -2
  92. package/dist/components/CollectionTableBinding/CollectionRowActions.js.map +1 -1
  93. package/dist/components/CollectionTableBinding/CollectionTableBinding.js.map +1 -1
  94. package/dist/components/CollectionTableBinding/CollectionTableBindingProps.d.ts +3 -5
  95. package/dist/components/CollectionTableBinding/PropertyTableCell.d.ts +2 -2
  96. package/dist/components/CollectionTableBinding/PropertyTableCell.js.map +1 -1
  97. package/dist/components/CollectionTableBinding/column_utils.d.ts +1 -1
  98. package/dist/components/CollectionTableBinding/column_utils.js.map +1 -1
  99. package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.d.ts +2 -2
  100. package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.js +1 -2
  101. package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.js.map +1 -1
  102. package/dist/components/CollectionTableBinding/fields/TableReferenceField.d.ts +2 -2
  103. package/dist/components/CollectionTableBinding/fields/TableReferenceField.js +2 -2
  104. package/dist/components/CollectionTableBinding/fields/TableReferenceField.js.map +1 -1
  105. package/dist/components/CollectionTableBinding/fields/TableRelationField.d.ts +2 -2
  106. package/dist/components/CollectionTableBinding/fields/TableRelationField.js +1 -2
  107. package/dist/components/CollectionTableBinding/fields/TableRelationField.js.map +1 -1
  108. package/dist/components/CollectionTableBinding/fields/TableRelationSelectorField.d.ts +2 -1
  109. package/dist/components/CollectionTableBinding/fields/TableRelationSelectorField.js.map +1 -1
  110. package/dist/components/CollectionTableBinding/fields/TableStorageUpload.d.ts +2 -2
  111. package/dist/components/CollectionTableBinding/fields/TableStorageUpload.js.map +1 -1
  112. package/dist/components/CollectionTableBinding/fields/VirtualTableSelect.d.ts +1 -1
  113. package/dist/components/CollectionTableBinding/fields/VirtualTableSelect.js +1 -1
  114. package/dist/components/CollectionTableBinding/fields/VirtualTableSelect.js.map +1 -1
  115. package/dist/components/CollectionTableBinding/internal/common.d.ts +1 -2
  116. package/dist/components/CollectionTableBinding/internal/common.js.map +1 -1
  117. package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.d.ts +1 -1
  118. package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js +2 -2
  119. package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js.map +1 -1
  120. package/dist/components/CollectionTableBinding/table_bindings.d.ts +2 -2
  121. package/dist/components/CollectionTableBinding/table_bindings.js.map +1 -1
  122. package/dist/components/CollectionViewBinding/BoardCardBinding.d.ts +1 -1
  123. package/dist/components/CollectionViewBinding/BoardCardBinding.js.map +1 -1
  124. package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.d.ts +1 -2
  125. package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.js +9 -5
  126. package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.js.map +1 -1
  127. package/dist/components/CollectionViewBinding/CollectionCardViewBinding.d.ts +1 -2
  128. package/dist/components/CollectionViewBinding/CollectionCardViewBinding.js.map +1 -1
  129. package/dist/components/CollectionViewBinding/CollectionEntityActions.d.ts +1 -1
  130. package/dist/components/CollectionViewBinding/CollectionEntityActions.js.map +1 -1
  131. package/dist/components/CollectionViewBinding/CollectionListViewBinding.d.ts +1 -2
  132. package/dist/components/CollectionViewBinding/CollectionListViewBinding.js +1 -1
  133. package/dist/components/CollectionViewBinding/CollectionListViewBinding.js.map +1 -1
  134. package/dist/components/CollectionViewBinding/CollectionToolbar.js +1 -1
  135. package/dist/components/CollectionViewBinding/CollectionToolbar.js.map +1 -1
  136. package/dist/components/CollectionViewBinding/CollectionViewActions.js +2 -4
  137. package/dist/components/CollectionViewBinding/CollectionViewActions.js.map +1 -1
  138. package/dist/components/CollectionViewBinding/CollectionViewBinding.d.ts +6 -6
  139. package/dist/components/CollectionViewBinding/CollectionViewBinding.js.map +1 -1
  140. package/dist/components/CollectionViewBinding/CollectionViewContent.js +1 -2
  141. package/dist/components/CollectionViewBinding/CollectionViewContent.js.map +1 -1
  142. package/dist/components/CollectionViewBinding/CollectionViewStartActions.d.ts +1 -1
  143. package/dist/components/CollectionViewBinding/CollectionViewStartActions.js.map +1 -1
  144. package/dist/components/CollectionViewBinding/CustomViewHost.d.ts +1 -2
  145. package/dist/components/CollectionViewBinding/CustomViewHost.js.map +1 -1
  146. package/dist/components/CollectionViewBinding/EntitiesCount.js +3 -3
  147. package/dist/components/CollectionViewBinding/EntitiesCount.js.map +1 -1
  148. package/dist/components/CollectionViewBinding/EntityCardBinding.d.ts +1 -2
  149. package/dist/components/CollectionViewBinding/EntityCardBinding.js.map +1 -1
  150. package/dist/components/CollectionViewBinding/EntityIdHeaderWidget.js +1 -1
  151. package/dist/components/CollectionViewBinding/EntityIdHeaderWidget.js.map +1 -1
  152. package/dist/components/CollectionViewBinding/FilterPresetsButton.d.ts +1 -2
  153. package/dist/components/CollectionViewBinding/FilterPresetsButton.js +1 -1
  154. package/dist/components/CollectionViewBinding/FilterPresetsButton.js.map +1 -1
  155. package/dist/components/CollectionViewBinding/FiltersButton.d.ts +1 -2
  156. package/dist/components/CollectionViewBinding/FiltersButton.js.map +1 -1
  157. package/dist/components/CollectionViewBinding/FiltersDialog.d.ts +1 -1
  158. package/dist/components/CollectionViewBinding/FiltersDialog.js.map +1 -1
  159. package/dist/components/CollectionViewBinding/PluginColumnSlots.d.ts +1 -2
  160. package/dist/components/CollectionViewBinding/PluginColumnSlots.js.map +1 -1
  161. package/dist/components/CollectionViewBinding/RowActions.d.ts +1 -2
  162. package/dist/components/CollectionViewBinding/RowActions.js.map +1 -1
  163. package/dist/components/CollectionViewBinding/SortButton.d.ts +1 -1
  164. package/dist/components/CollectionViewBinding/SortButton.js.map +1 -1
  165. package/dist/components/CollectionViewBinding/SplitListView.d.ts +1 -2
  166. package/dist/components/CollectionViewBinding/SplitListView.js.map +1 -1
  167. package/dist/components/CollectionViewBinding/hooks/useCollectionInlineEditor.d.ts +1 -2
  168. package/dist/components/CollectionViewBinding/hooks/useCollectionInlineEditor.js +1 -1
  169. package/dist/components/CollectionViewBinding/hooks/useCollectionInlineEditor.js.map +1 -1
  170. package/dist/components/CollectionViewBinding/hooks/useKanbanDragAndDrop.d.ts +1 -2
  171. package/dist/components/CollectionViewBinding/hooks/useKanbanDragAndDrop.js.map +1 -1
  172. package/dist/components/CollectionViewBinding/useBoardDataController.d.ts +2 -1
  173. package/dist/components/CollectionViewBinding/useBoardDataController.js +3 -3
  174. package/dist/components/CollectionViewBinding/useBoardDataController.js.map +1 -1
  175. package/dist/components/CollectionViewBinding/useCollectionViewState.d.ts +2 -4
  176. package/dist/components/CollectionViewBinding/useCollectionViewState.js +14 -19
  177. package/dist/components/CollectionViewBinding/useCollectionViewState.js.map +1 -1
  178. package/dist/components/CollectionViewBinding/usePreviewSlots.d.ts +1 -3
  179. package/dist/components/CollectionViewBinding/usePreviewSlots.js.map +1 -1
  180. package/dist/components/CollectionViewBinding/useSelectionController.d.ts +1 -2
  181. package/dist/components/CollectionViewBinding/useSelectionController.js.map +1 -1
  182. package/dist/components/CollectionsProvider.d.ts +23 -8
  183. package/dist/components/CollectionsProvider.js +23 -7
  184. package/dist/components/CollectionsProvider.js.map +1 -1
  185. package/dist/components/DefaultDrawer.js +1 -1
  186. package/dist/components/DeleteEntityDialog.d.ts +1 -1
  187. package/dist/components/DeleteEntityDialog.js +1 -1
  188. package/dist/components/DeleteEntityDialog.js.map +1 -1
  189. package/dist/components/DetailViewBinding.js +3 -3
  190. package/dist/components/DetailViewBinding.js.map +1 -1
  191. package/dist/components/EditFormActions.js.map +1 -1
  192. package/dist/components/EditViewBinding.d.ts +2 -1
  193. package/dist/components/EditViewBinding.js +6 -6
  194. package/dist/components/EditViewBinding.js.map +1 -1
  195. package/dist/components/EntityDisplayHeader.d.ts +1 -2
  196. package/dist/components/EntityDisplayHeader.js.map +1 -1
  197. package/dist/components/EntityInspector.d.ts +1 -2
  198. package/dist/components/EntityInspector.js.map +1 -1
  199. package/dist/components/EntityPreviewBinding.d.ts +1 -1
  200. package/dist/components/EntityPreviewBinding.js +1 -1
  201. package/dist/components/EntityPreviewBinding.js.map +1 -1
  202. package/dist/components/EntityViewBinding.d.ts +1 -1
  203. package/dist/components/EntityViewBinding.js.map +1 -1
  204. package/dist/components/EntityViewBody.d.ts +1 -1
  205. package/dist/components/EntityViewBody.js +3 -4
  206. package/dist/components/EntityViewBody.js.map +1 -1
  207. package/dist/components/FieldValue.js +2 -2
  208. package/dist/components/FieldValue.js.map +1 -1
  209. package/dist/components/HomePage/ContentHomePage.js +12 -3
  210. package/dist/components/HomePage/ContentHomePage.js.map +1 -1
  211. package/dist/components/InlineEntityPreview.d.ts +1 -1
  212. package/dist/components/InlineEntityPreview.js.map +1 -1
  213. package/dist/components/PropertyCollectionView.d.ts +2 -2
  214. package/dist/components/PropertyCollectionView.js.map +1 -1
  215. package/dist/components/PropertyConfigBadge.js.map +1 -1
  216. package/dist/components/RebaseCMS.d.ts +22 -3
  217. package/dist/components/RebaseCMS.js +32 -14
  218. package/dist/components/RebaseCMS.js.map +1 -1
  219. package/dist/components/RebaseNavigation.js +106 -31
  220. package/dist/components/RebaseNavigation.js.map +1 -1
  221. package/dist/components/RecordDetail.js +4 -1
  222. package/dist/components/RecordDetail.js.map +1 -1
  223. package/dist/components/RecordForm.d.ts +5 -5
  224. package/dist/components/RecordForm.js +5 -2
  225. package/dist/components/RecordForm.js.map +1 -1
  226. package/dist/components/ReferenceTable/SelectionTableBinding.d.ts +2 -2
  227. package/dist/components/ReferenceTable/SelectionTableBinding.js +1 -1
  228. package/dist/components/ReferenceTable/SelectionTableBinding.js.map +1 -1
  229. package/dist/components/ReferenceWidget.d.ts +2 -1
  230. package/dist/components/ReferenceWidget.js +2 -2
  231. package/dist/components/ReferenceWidget.js.map +1 -1
  232. package/dist/components/RelationSelector.d.ts +2 -1
  233. package/dist/components/RelationSelector.js +2 -3
  234. package/dist/components/RelationSelector.js.map +1 -1
  235. package/dist/components/SelectableTable/SelectableTable.d.ts +2 -2
  236. package/dist/components/SelectableTable/SelectableTable.js.map +1 -1
  237. package/dist/components/SelectableTable/filters/FilterFieldBinding.d.ts +2 -1
  238. package/dist/components/SelectableTable/filters/FilterFieldBinding.js +3 -3
  239. package/dist/components/SelectableTable/filters/FilterFieldBinding.js.map +1 -1
  240. package/dist/components/SelectableTable/filters/ReferenceFilterField.js +2 -2
  241. package/dist/components/SelectableTable/filters/ReferenceFilterField.js.map +1 -1
  242. package/dist/components/SelectableTable/filters/RelationFilterField.d.ts +1 -1
  243. package/dist/components/SelectableTable/filters/RelationFilterField.js +1 -1
  244. package/dist/components/SelectableTable/filters/RelationFilterField.js.map +1 -1
  245. package/dist/components/SelectableTable/filters/StringNumberFilterField.d.ts +1 -1
  246. package/dist/components/SelectableTable/filters/StringNumberFilterField.js.map +1 -1
  247. package/dist/components/SelectableTable/filters/null_filter.d.ts +1 -3
  248. package/dist/components/SelectableTable/filters/null_filter.js.map +1 -1
  249. package/dist/components/SidePanelBinding.js +1 -1
  250. package/dist/components/SidePanelBinding.js.map +1 -1
  251. package/dist/components/field_configs.d.ts +1 -2
  252. package/dist/components/field_configs.js.map +1 -1
  253. package/dist/components/field_ids.d.ts +1 -1
  254. package/dist/components/field_ids.js +1 -1
  255. package/dist/components/field_ids.js.map +1 -1
  256. package/dist/components/history/EntityHistoryEntry.js.map +1 -1
  257. package/dist/components/history/EntityHistoryView.d.ts +1 -2
  258. package/dist/components/history/EntityHistoryView.js +1 -1
  259. package/dist/components/history/EntityHistoryView.js.map +1 -1
  260. package/dist/data_export/export/BasicExportAction.d.ts +1 -1
  261. package/dist/data_export/export/BasicExportAction.js.map +1 -1
  262. package/dist/data_export/export/ExportCollectionAction.js +2 -2
  263. package/dist/data_export/export/ExportCollectionAction.js.map +1 -1
  264. package/dist/data_export/export/additional_fields.d.ts +1 -1
  265. package/dist/data_export/export/additional_fields.js.map +1 -1
  266. package/dist/data_export/export/export.d.ts +1 -1
  267. package/dist/data_export/export/export.js +1 -1
  268. package/dist/data_export/export/export.js.map +1 -1
  269. package/dist/data_export/export/fetch_export_data.d.ts +3 -2
  270. package/dist/data_export/export/fetch_export_data.js.map +1 -1
  271. package/dist/data_import/components/DataNewPropertiesMapping.d.ts +1 -1
  272. package/dist/data_import/components/DataNewPropertiesMapping.js.map +1 -1
  273. package/dist/data_import/components/ImportNewPropertyFieldPreview.d.ts +1 -1
  274. package/dist/data_import/components/ImportNewPropertyFieldPreview.js.map +1 -1
  275. package/dist/data_import/hooks/useImportConfig.js.map +1 -1
  276. package/dist/data_import/import/ImportCollectionAction.d.ts +2 -2
  277. package/dist/data_import/import/ImportCollectionAction.js.map +1 -1
  278. package/dist/data_import/types/column_mapping.d.ts +1 -1
  279. package/dist/data_import/utils/data.d.ts +1 -2
  280. package/dist/data_import/utils/data.js +1 -2
  281. package/dist/data_import/utils/data.js.map +1 -1
  282. package/dist/data_import/utils/get_import_inference_type.d.ts +1 -1
  283. package/dist/data_import/utils/get_import_inference_type.js.map +1 -1
  284. package/dist/data_import/utils/id_column.d.ts +1 -1
  285. package/dist/data_import/utils/id_column.js.map +1 -1
  286. package/dist/data_import/utils/import_columns.d.ts +1 -1
  287. package/dist/data_import/utils/import_columns.js.map +1 -1
  288. package/dist/data_import/utils/save_entities.d.ts +3 -3
  289. package/dist/data_import/utils/save_entities.js +1 -1
  290. package/dist/data_import/utils/save_entities.js.map +1 -1
  291. package/dist/form/EntityForm.js +2 -1
  292. package/dist/form/EntityForm.js.map +1 -1
  293. package/dist/form/EntityFormActions.js.map +1 -1
  294. package/dist/form/EntityFormBinding.js +2 -2
  295. package/dist/form/EntityFormBinding.js.map +1 -1
  296. package/dist/form/FormFieldsContext.d.ts +1 -4
  297. package/dist/form/FormFieldsContext.js +1 -1
  298. package/dist/form/FormFieldsContext.js.map +1 -1
  299. package/dist/form/PropertyFieldBinding.js +6 -8
  300. package/dist/form/PropertyFieldBinding.js.map +1 -1
  301. package/dist/form/components/FieldBlock.d.ts +1 -2
  302. package/dist/form/components/FieldBlock.js.map +1 -1
  303. package/dist/form/components/FieldHelperText.d.ts +1 -1
  304. package/dist/form/components/FieldHelperText.js.map +1 -1
  305. package/dist/form/components/FormRail.d.ts +1 -1
  306. package/dist/form/components/FormRail.js.map +1 -1
  307. package/dist/form/components/LocalChangesMenu.d.ts +1 -1
  308. package/dist/form/components/LocalChangesMenu.js.map +1 -1
  309. package/dist/form/components/StorageItemPreview.d.ts +1 -1
  310. package/dist/form/components/StorageItemPreview.js.map +1 -1
  311. package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.d.ts +1 -1
  312. package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.js +1 -1
  313. package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.js.map +1 -1
  314. package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.d.ts +2 -2
  315. package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.js +2 -2
  316. package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.js.map +1 -1
  317. package/dist/form/field_bindings/BinaryFieldBinding.d.ts +1 -1
  318. package/dist/form/field_bindings/BinaryFieldBinding.js.map +1 -1
  319. package/dist/form/field_bindings/BlockFieldBinding.d.ts +1 -1
  320. package/dist/form/field_bindings/BlockFieldBinding.js +1 -1
  321. package/dist/form/field_bindings/BlockFieldBinding.js.map +1 -1
  322. package/dist/form/field_bindings/DateTimeFieldBinding.d.ts +1 -1
  323. package/dist/form/field_bindings/DateTimeFieldBinding.js.map +1 -1
  324. package/dist/form/field_bindings/GeopointFieldBinding.d.ts +1 -1
  325. package/dist/form/field_bindings/GeopointFieldBinding.js.map +1 -1
  326. package/dist/form/field_bindings/KeyValueFieldBinding.d.ts +1 -1
  327. package/dist/form/field_bindings/KeyValueFieldBinding.js +1 -2
  328. package/dist/form/field_bindings/KeyValueFieldBinding.js.map +1 -1
  329. package/dist/form/field_bindings/MapFieldBinding.d.ts +1 -1
  330. package/dist/form/field_bindings/MapFieldBinding.js.map +1 -1
  331. package/dist/form/field_bindings/MarkdownEditorFieldBinding.d.ts +1 -1
  332. package/dist/form/field_bindings/MarkdownEditorFieldBinding.js +1 -1
  333. package/dist/form/field_bindings/MarkdownEditorFieldBinding.js.map +1 -1
  334. package/dist/form/field_bindings/MultiSelectFieldBinding.d.ts +1 -1
  335. package/dist/form/field_bindings/MultiSelectFieldBinding.js +1 -1
  336. package/dist/form/field_bindings/MultiSelectFieldBinding.js.map +1 -1
  337. package/dist/form/field_bindings/MultipleRelationFieldBinding.d.ts +1 -1
  338. package/dist/form/field_bindings/MultipleRelationFieldBinding.js +2 -2
  339. package/dist/form/field_bindings/MultipleRelationFieldBinding.js.map +1 -1
  340. package/dist/form/field_bindings/ReadOnlyFieldBinding.d.ts +1 -1
  341. package/dist/form/field_bindings/ReadOnlyFieldBinding.js.map +1 -1
  342. package/dist/form/field_bindings/ReferenceFieldBinding.d.ts +1 -1
  343. package/dist/form/field_bindings/ReferenceFieldBinding.js +2 -2
  344. package/dist/form/field_bindings/ReferenceFieldBinding.js.map +1 -1
  345. package/dist/form/field_bindings/RelationFieldBinding.d.ts +1 -1
  346. package/dist/form/field_bindings/RelationFieldBinding.js +2 -2
  347. package/dist/form/field_bindings/RelationFieldBinding.js.map +1 -1
  348. package/dist/form/field_bindings/RepeatFieldBinding.d.ts +1 -1
  349. package/dist/form/field_bindings/RepeatFieldBinding.js +1 -1
  350. package/dist/form/field_bindings/RepeatFieldBinding.js.map +1 -1
  351. package/dist/form/field_bindings/SelectFieldBinding.d.ts +1 -1
  352. package/dist/form/field_bindings/SelectFieldBinding.js +1 -1
  353. package/dist/form/field_bindings/SelectFieldBinding.js.map +1 -1
  354. package/dist/form/field_bindings/StorageUploadFieldBinding.d.ts +2 -2
  355. package/dist/form/field_bindings/StorageUploadFieldBinding.js.map +1 -1
  356. package/dist/form/field_bindings/SwitchFieldBinding.d.ts +1 -1
  357. package/dist/form/field_bindings/SwitchFieldBinding.js.map +1 -1
  358. package/dist/form/field_bindings/TextFieldBinding.d.ts +1 -1
  359. package/dist/form/field_bindings/TextFieldBinding.js.map +1 -1
  360. package/dist/form/field_bindings/UserSelectFieldBinding.d.ts +1 -1
  361. package/dist/form/field_bindings/UserSelectFieldBinding.js.map +1 -1
  362. package/dist/form/field_bindings/VectorFieldBinding.d.ts +1 -1
  363. package/dist/form/field_bindings/VectorFieldBinding.js.map +1 -1
  364. package/dist/form/form_utils.d.ts +3 -3
  365. package/dist/form/form_utils.js +1 -2
  366. package/dist/form/form_utils.js.map +1 -1
  367. package/dist/form/label_placement.d.ts +1 -2
  368. package/dist/form/label_placement.js.map +1 -1
  369. package/dist/form/resolve_cell_property.d.ts +1 -2
  370. package/dist/form/resolve_cell_property.js +1 -1
  371. package/dist/form/resolve_cell_property.js.map +1 -1
  372. package/dist/form/resolve_form_properties.d.ts +2 -2
  373. package/dist/form/resolve_form_properties.js +1 -1
  374. package/dist/form/resolve_form_properties.js.map +1 -1
  375. package/dist/form/useClearRestoreValue.d.ts +1 -1
  376. package/dist/form/useClearRestoreValue.js.map +1 -1
  377. package/dist/form/validation.d.ts +2 -2
  378. package/dist/form/validation.js +1 -1
  379. package/dist/form/validation.js.map +1 -1
  380. package/dist/hooks/navigation/compose_collections.d.ts +59 -0
  381. package/dist/hooks/navigation/compose_collections.js +48 -0
  382. package/dist/hooks/navigation/compose_collections.js.map +1 -0
  383. package/dist/hooks/navigation/compose_collections_input.d.ts +8 -0
  384. package/dist/hooks/navigation/compose_collections_input.js +17 -0
  385. package/dist/hooks/navigation/compose_collections_input.js.map +1 -0
  386. package/dist/hooks/navigation/contexts/CollectionRegistryContext.d.ts +1 -1
  387. package/dist/hooks/navigation/contexts/CollectionRegistryContext.js.map +1 -1
  388. package/dist/hooks/navigation/registered_collection.d.ts +15 -0
  389. package/dist/hooks/navigation/registered_collection.js +20 -0
  390. package/dist/hooks/navigation/registered_collection.js.map +1 -0
  391. package/dist/hooks/navigation/ui_preferences.d.ts +47 -0
  392. package/dist/hooks/navigation/ui_preferences.js +179 -0
  393. package/dist/hooks/navigation/ui_preferences.js.map +1 -0
  394. package/dist/hooks/navigation/useAsyncResolver.d.ts +8 -1
  395. package/dist/hooks/navigation/useAsyncResolver.js +9 -3
  396. package/dist/hooks/navigation/useAsyncResolver.js.map +1 -1
  397. package/dist/hooks/navigation/useBuildCollectionRegistryController.d.ts +1 -3
  398. package/dist/hooks/navigation/useBuildCollectionRegistryController.js +3 -3
  399. package/dist/hooks/navigation/useBuildCollectionRegistryController.js.map +1 -1
  400. package/dist/hooks/navigation/useBuildNavigationStateController.d.ts +9 -5
  401. package/dist/hooks/navigation/useBuildNavigationStateController.js +2 -1
  402. package/dist/hooks/navigation/useBuildNavigationStateController.js.map +1 -1
  403. package/dist/hooks/navigation/useBuildUrlController.d.ts +1 -1
  404. package/dist/hooks/navigation/useBuildUrlController.js.map +1 -1
  405. package/dist/hooks/navigation/useNavigationResolution.js +1 -2
  406. package/dist/hooks/navigation/useNavigationResolution.js.map +1 -1
  407. package/dist/hooks/navigation/usePanelTables.d.ts +11 -0
  408. package/dist/hooks/navigation/usePanelTables.js +33 -0
  409. package/dist/hooks/navigation/usePanelTables.js.map +1 -0
  410. package/dist/hooks/navigation/useResolvedCollections.d.ts +8 -3
  411. package/dist/hooks/navigation/useResolvedCollections.js +3 -2
  412. package/dist/hooks/navigation/useResolvedCollections.js.map +1 -1
  413. package/dist/hooks/navigation/useResolvedViews.d.ts +1 -2
  414. package/dist/hooks/navigation/useResolvedViews.js.map +1 -1
  415. package/dist/hooks/navigation/useTopLevelNavigation.d.ts +1 -2
  416. package/dist/hooks/navigation/useTopLevelNavigation.js.map +1 -1
  417. package/dist/hooks/navigation/user_preferences_overlay.d.ts +21 -0
  418. package/dist/hooks/navigation/user_preferences_overlay.js +101 -0
  419. package/dist/hooks/navigation/user_preferences_overlay.js.map +1 -0
  420. package/dist/hooks/navigation/utils.js +1 -1
  421. package/dist/hooks/navigation/utils.js.map +1 -1
  422. package/dist/hooks/useAdminContext.d.ts +1 -2
  423. package/dist/hooks/useAdminContext.js.map +1 -1
  424. package/dist/hooks/useBuildSidePanel.d.ts +1 -2
  425. package/dist/hooks/useBuildSidePanel.js +2 -1
  426. package/dist/hooks/useBuildSidePanel.js.map +1 -1
  427. package/dist/hooks/useChildViewSource.d.ts +1 -1
  428. package/dist/hooks/useChildViewSource.js +1 -1
  429. package/dist/hooks/useChildViewSource.js.map +1 -1
  430. package/dist/hooks/useEntityDisplay.d.ts +1 -2
  431. package/dist/hooks/useEntityDisplay.js +1 -1
  432. package/dist/hooks/useEntityDisplay.js.map +1 -1
  433. package/dist/hooks/useEntityDisplayTitle.d.ts +2 -2
  434. package/dist/hooks/useEntityDisplayTitle.js.map +1 -1
  435. package/dist/hooks/useHistory.js +1 -1
  436. package/dist/hooks/useHistory.js.map +1 -1
  437. package/dist/hooks/useRecordActions.d.ts +1 -2
  438. package/dist/hooks/useRecordActions.js.map +1 -1
  439. package/dist/hooks/useReferencePaths.d.ts +21 -7
  440. package/dist/hooks/useReferencePaths.js +23 -6
  441. package/dist/hooks/useReferencePaths.js.map +1 -1
  442. package/dist/hooks/useResolvedNavigationFrom.d.ts +3 -3
  443. package/dist/hooks/useResolvedNavigationFrom.js +1 -1
  444. package/dist/hooks/useResolvedNavigationFrom.js.map +1 -1
  445. package/dist/index.d.ts +11 -0
  446. package/dist/index.js +8 -2
  447. package/dist/mcp_view/app_modules.d.ts +2 -2
  448. package/dist/mcp_view/app_modules.js +4 -4
  449. package/dist/mcp_view/app_modules.js.map +1 -1
  450. package/dist/mcp_view/index.d.ts +16 -19
  451. package/dist/mcp_view/index.js +43 -62
  452. package/dist/mcp_view/index.js.map +1 -1
  453. package/dist/mcp_view/payload.d.ts +54 -18
  454. package/dist/mcp_view/payload.js +49 -24
  455. package/dist/mcp_view/payload.js.map +1 -1
  456. package/dist/mcp_view/screen.js +11 -11
  457. package/dist/mcp_view/screen.js.map +1 -1
  458. package/dist/mcp_view/tool_driver.d.ts +5 -34
  459. package/dist/mcp_view/tool_driver.js +17 -16
  460. package/dist/mcp_view/tool_driver.js.map +1 -1
  461. package/dist/mcp_view/write_review.d.ts +1 -2
  462. package/dist/mcp_view/write_review.js +1 -1
  463. package/dist/mcp_view/write_review.js.map +1 -1
  464. package/dist/preview/PropertyPreview.d.ts +1 -1
  465. package/dist/preview/PropertyPreview.js +4 -3
  466. package/dist/preview/PropertyPreview.js.map +1 -1
  467. package/dist/preview/components/ArrayEnumPreview.d.ts +1 -1
  468. package/dist/preview/components/ArrayEnumPreview.js.map +1 -1
  469. package/dist/preview/components/BooleanPreview.d.ts +1 -1
  470. package/dist/preview/components/BooleanPreview.js.map +1 -1
  471. package/dist/preview/components/EnumValuesChip.d.ts +1 -1
  472. package/dist/preview/components/EnumValuesChip.js +1 -1
  473. package/dist/preview/components/EnumValuesChip.js.map +1 -1
  474. package/dist/preview/components/ReferencePreview.d.ts +1 -1
  475. package/dist/preview/components/ReferencePreview.js.map +1 -1
  476. package/dist/preview/components/RelationPreview.d.ts +1 -1
  477. package/dist/preview/components/RelationPreview.js.map +1 -1
  478. package/dist/preview/components/StorageThumbnail.js +2 -1
  479. package/dist/preview/components/StorageThumbnail.js.map +1 -1
  480. package/dist/preview/components/UserPreview.d.ts +1 -1
  481. package/dist/preview/components/UserPreview.js.map +1 -1
  482. package/dist/preview/property_previews/ArrayOfMapsPreview.d.ts +1 -1
  483. package/dist/preview/property_previews/ArrayOfMapsPreview.js.map +1 -1
  484. package/dist/preview/property_previews/ArrayOfReferencesPreview.d.ts +1 -1
  485. package/dist/preview/property_previews/ArrayOfReferencesPreview.js.map +1 -1
  486. package/dist/preview/property_previews/ArrayOfRelationsPreview.d.ts +1 -1
  487. package/dist/preview/property_previews/ArrayOfRelationsPreview.js +2 -1
  488. package/dist/preview/property_previews/ArrayOfRelationsPreview.js.map +1 -1
  489. package/dist/preview/property_previews/ArrayOfStorageComponentsPreview.d.ts +1 -1
  490. package/dist/preview/property_previews/ArrayOfStorageComponentsPreview.js.map +1 -1
  491. package/dist/preview/property_previews/ArrayOfStringsPreview.d.ts +1 -1
  492. package/dist/preview/property_previews/ArrayOfStringsPreview.js.map +1 -1
  493. package/dist/preview/property_previews/ArrayOneOfPreview.d.ts +1 -1
  494. package/dist/preview/property_previews/ArrayOneOfPreview.js +1 -1
  495. package/dist/preview/property_previews/ArrayOneOfPreview.js.map +1 -1
  496. package/dist/preview/property_previews/ArrayPropertyEnumPreview.d.ts +1 -1
  497. package/dist/preview/property_previews/ArrayPropertyEnumPreview.js +1 -1
  498. package/dist/preview/property_previews/ArrayPropertyEnumPreview.js.map +1 -1
  499. package/dist/preview/property_previews/ArrayPropertyPreview.d.ts +1 -1
  500. package/dist/preview/property_previews/ArrayPropertyPreview.js +1 -1
  501. package/dist/preview/property_previews/ArrayPropertyPreview.js.map +1 -1
  502. package/dist/preview/property_previews/MapPropertyPreview.d.ts +1 -1
  503. package/dist/preview/property_previews/MapPropertyPreview.js.map +1 -1
  504. package/dist/preview/property_previews/NumberPropertyPreview.d.ts +1 -1
  505. package/dist/preview/property_previews/NumberPropertyPreview.js +1 -1
  506. package/dist/preview/property_previews/NumberPropertyPreview.js.map +1 -1
  507. package/dist/preview/property_previews/SkeletonPropertyComponent.d.ts +1 -1
  508. package/dist/preview/property_previews/SkeletonPropertyComponent.js.map +1 -1
  509. package/dist/preview/property_previews/StringPropertyPreview.d.ts +1 -1
  510. package/dist/preview/property_previews/StringPropertyPreview.js.map +1 -1
  511. package/dist/preview/util.d.ts +1 -1
  512. package/dist/preview/util.js.map +1 -1
  513. package/dist/routes/RebaseRoute.js +2 -2
  514. package/dist/routes/RebaseRoute.js.map +1 -1
  515. package/dist/saved_apps/SavedAppsView.d.ts +1 -1
  516. package/dist/saved_apps/SavedAppsView.js +1 -1
  517. package/dist/saved_apps/SavedAppsView.js.map +1 -1
  518. package/dist/selection/SelectionMenu.d.ts +1 -1
  519. package/dist/selection/SelectionMenu.js.map +1 -1
  520. package/dist/selection/resolve_selection.d.ts +3 -3
  521. package/dist/selection/resolve_selection.js +3 -2
  522. package/dist/selection/resolve_selection.js.map +1 -1
  523. package/dist/tables/apply_customization.d.ts +65 -0
  524. package/dist/tables/apply_customization.js +644 -0
  525. package/dist/tables/apply_customization.js.map +1 -0
  526. package/dist/tables/column_property.d.ts +64 -0
  527. package/dist/tables/column_property.js +549 -0
  528. package/dist/tables/column_property.js.map +1 -0
  529. package/dist/tables/customize_table.d.ts +39 -0
  530. package/dist/tables/customize_table.js +247 -0
  531. package/dist/tables/customize_table.js.map +1 -0
  532. package/dist/tables/index.d.ts +12 -0
  533. package/dist/tables/labels.d.ts +18 -0
  534. package/dist/tables/labels.js +18 -0
  535. package/dist/tables/labels.js.map +1 -0
  536. package/dist/tables/project_table.d.ts +79 -0
  537. package/dist/tables/project_table.js +148 -0
  538. package/dist/tables/project_table.js.map +1 -0
  539. package/dist/tables/relations.d.ts +47 -0
  540. package/dist/tables/relations.js +112 -0
  541. package/dist/tables/relations.js.map +1 -0
  542. package/dist/tables/rls.d.ts +39 -0
  543. package/dist/tables/rls.js +111 -0
  544. package/dist/tables/rls.js.map +1 -0
  545. package/dist/tables/update_record.d.ts +32 -0
  546. package/dist/tables/update_record.js +40 -0
  547. package/dist/tables/update_record.js.map +1 -0
  548. package/dist/types/components/EntityFormActionsProps.d.ts +1 -1
  549. package/dist/types/components/PropertyPreviewProps.d.ts +2 -2
  550. package/dist/types/fields.d.ts +2 -2
  551. package/dist/util/dataControllerAdapter.js.map +1 -1
  552. package/dist/util/entity_pages.d.ts +2 -1
  553. package/dist/util/entity_pages.js.map +1 -1
  554. package/dist/util/find_entities_by_ids.d.ts +2 -2
  555. package/dist/util/find_entities_by_ids.js +1 -1
  556. package/dist/util/find_entities_by_ids.js.map +1 -1
  557. package/dist/util/format_collection_date.d.ts +1 -1
  558. package/dist/util/format_collection_date.js.map +1 -1
  559. package/dist/util/identity.d.ts +8 -0
  560. package/dist/util/identity.js +16 -0
  561. package/dist/util/identity.js.map +1 -0
  562. package/dist/util/navigation_utils.js +1 -1
  563. package/dist/util/navigation_utils.js.map +1 -1
  564. package/dist/util/previews.js +1 -1
  565. package/dist/util/previews.js.map +1 -1
  566. package/dist/util/propertyConfigMapper.d.ts +1 -1
  567. package/dist/util/propertyConfigMapper.js.map +1 -1
  568. package/dist/util/property_utils.d.ts +1 -3
  569. package/dist/util/property_utils.js +1 -1
  570. package/dist/util/property_utils.js.map +1 -1
  571. package/dist/util/relations.d.ts +18 -0
  572. package/dist/util/relations.js +32 -0
  573. package/dist/util/relations.js.map +1 -0
  574. package/package.json +12 -10
  575. package/recipes/README.md +4 -4
  576. package/recipes/my-preferences.tsx +34 -26
  577. package/recipes/site-settings.tsx +34 -27
  578. package/dist/collection_editor/collection_wire.d.ts +0 -13
  579. package/dist/collection_editor/collection_wire.js +0 -49
  580. package/dist/collection_editor/collection_wire.js.map +0 -1
  581. package/dist/collection_editor/useJsonCollectionsConfigController.d.ts +0 -37
  582. package/dist/collection_editor/useJsonCollectionsConfigController.js +0 -191
  583. package/dist/collection_editor/useJsonCollectionsConfigController.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"StorageUploadFieldBinding.js","names":[],"sources":["../../../src/form/field_bindings/StorageUploadFieldBinding.tsx"],"sourcesContent":["import type { FieldProps } from \"../../types/fields\";\nimport type { ArrayProperty, StringProperty } from \"@rebasepro/types\";\nimport React, { useCallback, useState } from \"react\";\n\nimport { StorageConfig } from \"@rebasepro/types\";\nimport type { PreviewSize } from \"../../types/components/PropertyPreviewProps\";\nimport { useDropzone } from \"react-dropzone\";\nimport { FieldHelperText } from \"../components/FieldHelperText\";\nimport { LabelWithIcon } from \"../components/LabelWithIcon\";\n\nimport { isDisabled, isReadOnly } from \"@rebasepro/app\";\nimport { getIconForProperty } from \"../../util/property_utils\";\nimport { useAuthController, useSnackbarController, useStorageSource, useTranslation } from \"@rebasepro/app\";\nimport { StorageSourceContext } from \"@rebasepro/app\";\nimport {\n closestCenter,\n DndContext,\n DragEndEvent,\n DragStartEvent,\n KeyboardSensor,\n PointerSensor,\n useSensor,\n useSensors\n} from \"@dnd-kit/core\";\nimport {\n horizontalListSortingStrategy,\n SortableContext,\n sortableKeyboardCoordinates,\n useSortable\n} from \"@dnd-kit/sortable\";\nimport { CSS } from \"@dnd-kit/utilities\";\nimport { StorageFieldItem, useStorageUploadController } from \"@rebasepro/app\";\nimport { StorageUploadProgress } from \"../components/StorageUploadProgress\";\nimport { StorageItemPreview } from \"../components/StorageItemPreview\";\nimport {\n cls,\n fieldBackgroundDisabledMixin,\n fieldBackgroundHoverMixin,\n fieldBackgroundMixin,\n Typography\n} from \"@rebasepro/ui\";\n\n// Height comes from the thumbnails now. It used to be a flat `min-h-[254px]`\n// on top of another 250px inside, so a field holding one small image\n// reserved close to 300px of the form for mostly empty space.\n// One fixed height for the whole zone — 126px of preview row, 34px of hint,\n// and the padding between. Pinned on the root rather than on the children\n// because the hint reflows once files exist (\"Drag to reorder\"), and any\n// content-driven height makes a filled field taller than the same field\n// empty. Extra thumbnails scroll horizontally instead of growing it.\nconst dropZoneClasses = \"box-border relative pt-[2px] h-[172px] items-center border border-transparent outline-none rounded-md duration-200 ease-[cubic-bezier(0.4,0,0.2,1)] focus:border-primary\";\nconst disabledClasses = fieldBackgroundDisabledMixin;\nconst nonActiveDropClasses = fieldBackgroundHoverMixin\nconst activeDropClasses = \"pt-0 border-2 border-solid\"\nconst acceptDropClasses = \"transition-colors duration-200 ease-[cubic-bezier(0,0,0.2,1)] border-2 border-solid border-green-500\"\nconst rejectDropClasses = \"transition-colors duration-200 ease-[cubic-bezier(0,0,0.2,1)] border-2 border-solid border-red-500\"\n\nexport function StorageUploadFieldBinding({\n propertyKey,\n value,\n setValue,\n error,\n showError,\n autoFocus,\n minimalistView,\n property,\n includeDescription,\n hideLabel,\n context,\n isSubmitting\n }: FieldProps<StringProperty | ArrayProperty>) {\n\n const authController = useAuthController();\n\n const storageSource = useStorageSource();\n const disabled = isReadOnly(property) || isDisabled(property) || isSubmitting || context.disabled;\n\n const {\n internalValue,\n setInternalValue,\n onFilesAdded,\n storage,\n onFileUploadComplete,\n storagePathBuilder,\n multipleFilesSupported,\n resolvedStorageSource\n } = useStorageUploadController({\n entityValues: context.values,\n entityId: context.id,\n path: context.path,\n collectionSlug: context.collection?.slug,\n property,\n propertyKey,\n value: value as string | string[] | null,\n storageSource,\n disabled: disabled ?? false,\n onChange: setValue\n });\n\n return (\n\n <>\n\n {!minimalistView && !hideLabel &&\n <LabelWithIcon\n propertyKey={propertyKey}\n icon={getIconForProperty(property, \"small\")}\n required={property.validation?.required}\n title={property.name ?? propertyKey}\n className={\"h-8 text-text-secondary dark:text-text-secondary-dark ml-3.5\"}/>}\n\n <StorageSourceContext.Provider value={resolvedStorageSource}>\n <StorageUpload\n value={internalValue}\n name={propertyKey}\n disabled={disabled ?? false}\n autoFocus={autoFocus ?? false}\n property={property}\n onChange={setValue}\n setInternalValue={setInternalValue}\n onFilesAdded={onFilesAdded}\n onFileUploadComplete={onFileUploadComplete}\n storagePathBuilder={storagePathBuilder}\n storage={storage}\n multipleFilesSupported={multipleFilesSupported}/>\n </StorageSourceContext.Provider>\n\n <FieldHelperText includeDescription={includeDescription}\n showError={showError}\n error={error}\n disabled={disabled}\n property={property}/>\n\n </>\n );\n}\n\ninterface SortableStorageItemProps {\n id: number;\n entry: StorageFieldItem;\n property: StringProperty;\n name: string;\n metadata?: Record<string, unknown>;\n storagePathBuilder: (file: File) => string;\n onFileUploadComplete: (uploadedPath: string, entry: StorageFieldItem, fileMetadata?: Record<string, unknown>) => Promise<void>;\n onClear: (clearedStoragePathOrDownloadUrl: string) => void;\n disabled: boolean;\n isSortable: boolean; // Kept for consistency, though dnd-kit handles sortability via context\n}\n\nfunction SortableStorageItem({\n id,\n entry,\n property,\n metadata,\n storagePathBuilder,\n onFileUploadComplete,\n onClear,\n disabled\n }: SortableStorageItemProps) {\n\n const {\n attributes,\n listeners,\n setNodeRef,\n transform,\n transition,\n isDragging\n } = useSortable({ id });\n\n const style: React.CSSProperties = {\n transform: CSS.Transform.toString(transform),\n transition,\n zIndex: isDragging ? 100 : undefined\n };\n\n const getImageSizeNumber = (previewSize: PreviewSize): number => {\n switch (previewSize) {\n case \"small\":\n return 40;\n case \"medium\":\n return 118;\n case \"large\":\n return 220;\n default:\n return 118;\n }\n };\n\n let child: React.ReactNode;\n if (entry.storagePathOrDownloadUrl) {\n child = (\n <StorageItemPreview\n name={`storage_preview_${entry.storagePathOrDownloadUrl}`}\n property={property}\n disabled={disabled}\n value={entry.storagePathOrDownloadUrl}\n onRemove={() => onClear(entry.storagePathOrDownloadUrl!)}\n size={entry.size as PreviewSize}/>\n );\n } else if (entry.file) {\n child = (\n <StorageUploadProgress\n entry={entry}\n metadata={metadata}\n storagePath={storagePathBuilder(entry.file)}\n onFileUploadComplete={onFileUploadComplete}\n imageSize={getImageSizeNumber(entry.size as PreviewSize)}\n simple={false}\n />\n );\n }\n\n return (\n <div\n ref={setNodeRef}\n style={style}\n {...attributes}\n {...listeners}\n // No vertical margin: the strip already pads itself, and `m-1` made\n // each item 8px taller than the row's content box — enough to make a\n // field holding one image scroll vertically behind a hidden\n // scrollbar. `shrink-0` keeps thumbnails square once there are more\n // of them than fit across.\n className={cls(\"rounded-md shrink-0\")}\n tabIndex={-1}\n >\n {child}\n </div>\n );\n}\n\nfunction FileDropComponent({\n storage,\n disabled,\n onFilesAdded,\n multipleFilesSupported,\n autoFocus,\n internalValue,\n property,\n onClear,\n metadata,\n storagePathBuilder,\n onFileUploadComplete,\n name,\n helpText,\n isDndItemDragging\n }: {\n storage: StorageConfig,\n disabled: boolean,\n onFilesAdded: (acceptedFiles: File[]) => Promise<void>,\n multipleFilesSupported: boolean,\n autoFocus: boolean,\n internalValue: StorageFieldItem[],\n property: StringProperty,\n onClear: (clearedStoragePathOrDownloadUrl: string) => void,\n metadata?: Record<string, unknown>,\n storagePathBuilder: (file: File) => string,\n onFileUploadComplete: (uploadedPath: string, entry: StorageFieldItem, fileMetadata?: Record<string, unknown>) => Promise<void>,\n name: string,\n helpText: string,\n isDndItemDragging?: boolean\n}) {\n\n const snackbarContext = useSnackbarController();\n\n const {\n getRootProps,\n getInputProps,\n isDragActive, // This is for files dragged from OS\n isDragAccept,\n isDragReject\n } = useDropzone({\n accept: storage.acceptedFiles ? storage.acceptedFiles.reduce((acc, ext) => ({\n ...acc,\n [ext]: []\n }), {}) : undefined,\n disabled: disabled || isDndItemDragging,\n // react-dropzone defaults to `multiple: true`, so a\n // `type: \"string\"` property with a storage config offered a picker\n // that took several files, uploaded the first, and never mentioned\n // the rest — one thumbnail, one 201, and the others gone without a\n // word. The field holds one path; the picker should ask for one.\n multiple: multipleFilesSupported,\n noDragEventsBubbling: true,\n maxSize: storage.maxSize,\n onDrop: onFilesAdded,\n onDropRejected: (fileRejections) => {\n for (const fileRejection of fileRejections) {\n for (const error of fileRejection.errors) {\n console.error(\"Error uploading file: \", error);\n if (error.code === \"file-too-large\") {\n snackbarContext.open({\n type: \"error\",\n message: `Error uploading file: File is larger than ${storage.maxSize} bytes`\n });\n } else if (error.code === \"file-invalid-type\") {\n snackbarContext.open({\n type: \"error\",\n message: \"Error uploading file: File type is not supported\"\n });\n }\n }\n }\n }\n }\n );\n\n return (\n <div\n {...getRootProps()}\n className={cls(\n fieldBackgroundMixin,\n disabled ? fieldBackgroundDisabledMixin : fieldBackgroundHoverMixin,\n disabled ? \"text-surface-accent-600 dark:text-surface-accent-500\" : \"\",\n dropZoneClasses,\n multipleFilesSupported && internalValue.length ? \"\" : \"flex\",\n {\n [nonActiveDropClasses]: !isDragActive,\n [activeDropClasses]: isDragActive, // OS file drag active\n [rejectDropClasses]: isDragReject, // OS file drag reject\n [acceptDropClasses]: isDragAccept, // OS file drag accept\n [disabledClasses]: disabled || isDndItemDragging // Visually disable if internal drag\n })}\n >\n <div\n className={cls(\"flex items-center gap-2 p-1 px-3 no-scrollbar\",\n // Horizontal only. `overflow-auto` scrolls both axes, so any\n // pixel of vertical overflow turned the field into a\n // scrollable box with nothing visible to scroll to.\n multipleFilesSupported && internalValue.length ? \"overflow-x-auto overflow-y-hidden\" : \"\",\n // A fixed height, not a minimum: the 118px preview overflowed\n // a `min-h`, so a field with a file stood taller than the same\n // field empty. 126px is the preview plus its padding.\n \"h-[126px]\"\n )}\n >\n <input\n autoFocus={autoFocus}\n {...getInputProps()}/>\n\n {internalValue.map((entry) => (\n <SortableStorageItem\n key={entry.id}\n id={entry.id}\n entry={entry}\n property={property}\n name={name}\n metadata={metadata}\n storagePathBuilder={storagePathBuilder}\n onFileUploadComplete={onFileUploadComplete}\n onClear={onClear}\n disabled={disabled}\n isSortable={multipleFilesSupported}\n />\n ))}\n\n {/* Placeholder for empty dropzone text is handled by the outer Typography */}\n </div>\n\n <div\n // Two lines' worth, fixed: the hint gains \"Drag to reorder\" once\n // the field holds something, and a reflow there put the filled\n // state 25px taller than the empty one.\n className=\"box-border mx-3 mb-2.5 h-[34px] flex items-center justify-center text-center\">\n <Typography align={\"center\"}\n variant={\"caption\"}\n className={disabled ? \"text-surface-accent-600 dark:text-surface-accent-500\" : \"\"}>\n {helpText}\n </Typography>\n </div>\n </div>\n );\n}\n\nexport interface StorageUploadProps {\n value: StorageFieldItem[];\n setInternalValue: (v: StorageFieldItem[]) => void;\n name: string;\n property: StringProperty | ArrayProperty;\n onChange: (value: string | string[] | null) => void;\n multipleFilesSupported: boolean;\n autoFocus: boolean;\n disabled: boolean;\n storage: StorageConfig;\n onFilesAdded: (acceptedFiles: File[]) => Promise<void>; // Updated from useStorageUploadController\n storagePathBuilder: (file: File) => string;\n onFileUploadComplete: (uploadedPath: string, entry: StorageFieldItem, fileMetadata?: Record<string, unknown>) => Promise<void>;\n}\n\nexport function StorageUpload({\n property,\n name,\n value, // This is internalValue from useStorageUploadController\n setInternalValue,\n onChange,\n multipleFilesSupported,\n onFileUploadComplete,\n disabled,\n onFilesAdded,\n autoFocus,\n storage,\n storagePathBuilder\n }: StorageUploadProps) {\n\n if (multipleFilesSupported) {\n const arrayProperty = property as ArrayProperty;\n if (arrayProperty.of) {\n if (Array.isArray(arrayProperty.of)) {\n throw Error(\"Storage field using array must be of data type string\");\n }\n if (arrayProperty.of.type !== \"string\") {\n throw Error(\"Storage field using array must be of data type string\");\n }\n } else {\n throw Error(\"Storage field using array must be of data type string\");\n }\n }\n\n const metadata: Record<string, unknown> | undefined = storage?.metadata;\n const [isDndItemDragging, setIsDndItemDragging] = useState(false);\n\n const moveItem = useCallback((fromIndex: number, toIndex: number) => {\n if (!multipleFilesSupported || fromIndex === toIndex) return;\n const newValue = [...value];\n const item = newValue[fromIndex];\n newValue.splice(fromIndex, 1);\n newValue.splice(toIndex, 0, item);\n setInternalValue(newValue);\n const fieldValue = newValue\n .filter(e => !!e.storagePathOrDownloadUrl)\n .map(e => e.storagePathOrDownloadUrl as string);\n onChange(fieldValue);\n }, [multipleFilesSupported, onChange, setInternalValue, value]);\n\n const sensors = useSensors(\n useSensor(PointerSensor, {\n activationConstraint: {\n distance: 5 // Start dragging after 5px movement\n }\n }),\n useSensor(KeyboardSensor, {\n coordinateGetter: sortableKeyboardCoordinates\n })\n );\n\n const handleDragStart = useCallback((event: DragStartEvent) => {\n setIsDndItemDragging(true);\n }, []);\n\n const handleDragEnd = useCallback((event: DragEndEvent) => {\n setIsDndItemDragging(false);\n const {\n active,\n over\n } = event;\n if (over && active.id !== over.id) {\n const oldIndex = value.findIndex(item => item.id === active.id);\n const newIndex = value.findIndex(item => item.id === over.id);\n if (oldIndex !== -1 && newIndex !== -1) {\n moveItem(oldIndex, newIndex);\n }\n }\n }, [value, moveItem]);\n\n const onClear = useCallback((clearedStoragePathOrDownloadUrl: string) => {\n let newValue: StorageFieldItem[];\n if (multipleFilesSupported) {\n newValue = value.filter(v => v.storagePathOrDownloadUrl !== clearedStoragePathOrDownloadUrl);\n onChange(newValue.filter(v => !!v.storagePathOrDownloadUrl).map(v => v.storagePathOrDownloadUrl as string));\n } else {\n newValue = [];\n onChange(null);\n }\n setInternalValue(newValue);\n }, [value, multipleFilesSupported, onChange, setInternalValue]);\n\n const { t } = useTranslation();\n const helpText = multipleFilesSupported\n ? t(\"drag_drop_multiple\")\n : t(\"drag_drop_single\");\n\n const renderProperty: StringProperty = multipleFilesSupported\n ? (property as ArrayProperty).of as StringProperty\n : property as StringProperty;\n\n const fileDropProps = {\n storage,\n disabled,\n onFilesAdded,\n multipleFilesSupported,\n autoFocus,\n internalValue: value, // Pass current internalValue\n property: renderProperty,\n onClear,\n metadata,\n storagePathBuilder,\n onFileUploadComplete,\n name,\n helpText,\n isDndItemDragging // Pass this down\n };\n\n if (multipleFilesSupported) {\n return (\n <DndContext\n sensors={sensors}\n collisionDetection={closestCenter}\n onDragStart={handleDragStart}\n onDragEnd={handleDragEnd}\n >\n <SortableContext items={(value ?? []).map(v => v.id)} strategy={horizontalListSortingStrategy}>\n <FileDropComponent {...fileDropProps}/>\n </SortableContext>\n </DndContext>\n );\n } else {\n // For single file, no D&D context is needed\n return <FileDropComponent {...fileDropProps} isDndItemDragging={false}/>;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAkDA,IAAM,kBAAkB;AACxB,IAAM,kBAAkB;AACxB,IAAM,uBAAuB;AAC7B,IAAM,oBAAoB;AAC1B,IAAM,oBAAoB;AAC1B,IAAM,oBAAoB;AAE1B,SAAgB,0BAA0B,EACI,aACA,OACA,UACA,OACA,WACA,WACA,gBACA,UACA,oBACA,W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;EACA;CACJ;CAEA,IAAI,wBACA,OACI,oBAAC,YAAD;EACa;EACT,oBAAoB;EACpB,aAAa;EACb,WAAW;YAEX,oBAAC,iBAAD;GAAiB,QAAQ,SAAS,CAAC,EAAA,CAAG,KAAI,MAAK,EAAE,EAAE;GAAG,UAAU;aAC5D,oBAAC,mBAAD,EAAmB,GAAI,cAAe,CAAA;EACzB,CAAA;CACT,CAAA;MAIhB,OAAO,oBAAC,mBAAD;EAAmB,GAAI;EAAe,mBAAmB;CAAO,CAAA;AAE/E"}
1
+ {"version":3,"file":"StorageUploadFieldBinding.js","names":[],"sources":["../../../src/form/field_bindings/StorageUploadFieldBinding.tsx"],"sourcesContent":["import type { FieldProps } from \"../../types/fields\";\nimport type { ArrayProperty, StringProperty } from \"@rebasepro/cms-types\";\nimport React, { useCallback, useState } from \"react\";\n\nimport { StorageConfig } from \"@rebasepro/cms-types\";\nimport type { PreviewSize } from \"../../types/components/PropertyPreviewProps\";\nimport { useDropzone } from \"react-dropzone\";\nimport { FieldHelperText } from \"../components/FieldHelperText\";\nimport { LabelWithIcon } from \"../components/LabelWithIcon\";\n\nimport { isDisabled, isReadOnly } from \"@rebasepro/app\";\nimport { getIconForProperty } from \"../../util/property_utils\";\nimport { useAuthController, useSnackbarController, useStorageSource, useTranslation } from \"@rebasepro/app\";\nimport { StorageSourceContext } from \"@rebasepro/app\";\nimport {\n closestCenter,\n DndContext,\n DragEndEvent,\n DragStartEvent,\n KeyboardSensor,\n PointerSensor,\n useSensor,\n useSensors\n} from \"@dnd-kit/core\";\nimport {\n horizontalListSortingStrategy,\n SortableContext,\n sortableKeyboardCoordinates,\n useSortable\n} from \"@dnd-kit/sortable\";\nimport { CSS } from \"@dnd-kit/utilities\";\nimport { StorageFieldItem, useStorageUploadController } from \"@rebasepro/app\";\nimport { StorageUploadProgress } from \"../components/StorageUploadProgress\";\nimport { StorageItemPreview } from \"../components/StorageItemPreview\";\nimport {\n cls,\n fieldBackgroundDisabledMixin,\n fieldBackgroundHoverMixin,\n fieldBackgroundMixin,\n Typography\n} from \"@rebasepro/ui\";\n\n// Height comes from the thumbnails now. It used to be a flat `min-h-[254px]`\n// on top of another 250px inside, so a field holding one small image\n// reserved close to 300px of the form for mostly empty space.\n// One fixed height for the whole zone — 126px of preview row, 34px of hint,\n// and the padding between. Pinned on the root rather than on the children\n// because the hint reflows once files exist (\"Drag to reorder\"), and any\n// content-driven height makes a filled field taller than the same field\n// empty. Extra thumbnails scroll horizontally instead of growing it.\nconst dropZoneClasses = \"box-border relative pt-[2px] h-[172px] items-center border border-transparent outline-none rounded-md duration-200 ease-[cubic-bezier(0.4,0,0.2,1)] focus:border-primary\";\nconst disabledClasses = fieldBackgroundDisabledMixin;\nconst nonActiveDropClasses = fieldBackgroundHoverMixin\nconst activeDropClasses = \"pt-0 border-2 border-solid\"\nconst acceptDropClasses = \"transition-colors duration-200 ease-[cubic-bezier(0,0,0.2,1)] border-2 border-solid border-green-500\"\nconst rejectDropClasses = \"transition-colors duration-200 ease-[cubic-bezier(0,0,0.2,1)] border-2 border-solid border-red-500\"\n\nexport function StorageUploadFieldBinding({\n propertyKey,\n value,\n setValue,\n error,\n showError,\n autoFocus,\n minimalistView,\n property,\n includeDescription,\n hideLabel,\n context,\n isSubmitting\n }: FieldProps<StringProperty | ArrayProperty>) {\n\n const authController = useAuthController();\n\n const storageSource = useStorageSource();\n const disabled = isReadOnly(property) || isDisabled(property) || isSubmitting || context.disabled;\n\n const {\n internalValue,\n setInternalValue,\n onFilesAdded,\n storage,\n onFileUploadComplete,\n storagePathBuilder,\n multipleFilesSupported,\n resolvedStorageSource\n } = useStorageUploadController({\n entityValues: context.values,\n entityId: context.id,\n path: context.path,\n collectionSlug: context.collection?.slug,\n property,\n propertyKey,\n value: value as string | string[] | null,\n storageSource,\n disabled: disabled ?? false,\n onChange: setValue\n });\n\n return (\n\n <>\n\n {!minimalistView && !hideLabel &&\n <LabelWithIcon\n propertyKey={propertyKey}\n icon={getIconForProperty(property, \"small\")}\n required={property.validation?.required}\n title={property.name ?? propertyKey}\n className={\"h-8 text-text-secondary dark:text-text-secondary-dark ml-3.5\"}/>}\n\n <StorageSourceContext.Provider value={resolvedStorageSource}>\n <StorageUpload\n value={internalValue}\n name={propertyKey}\n disabled={disabled ?? false}\n autoFocus={autoFocus ?? false}\n property={property}\n onChange={setValue}\n setInternalValue={setInternalValue}\n onFilesAdded={onFilesAdded}\n onFileUploadComplete={onFileUploadComplete}\n storagePathBuilder={storagePathBuilder}\n storage={storage}\n multipleFilesSupported={multipleFilesSupported}/>\n </StorageSourceContext.Provider>\n\n <FieldHelperText includeDescription={includeDescription}\n showError={showError}\n error={error}\n disabled={disabled}\n property={property}/>\n\n </>\n );\n}\n\ninterface SortableStorageItemProps {\n id: number;\n entry: StorageFieldItem;\n property: StringProperty;\n name: string;\n metadata?: Record<string, unknown>;\n storagePathBuilder: (file: File) => string;\n onFileUploadComplete: (uploadedPath: string, entry: StorageFieldItem, fileMetadata?: Record<string, unknown>) => Promise<void>;\n onClear: (clearedStoragePathOrDownloadUrl: string) => void;\n disabled: boolean;\n isSortable: boolean; // Kept for consistency, though dnd-kit handles sortability via context\n}\n\nfunction SortableStorageItem({\n id,\n entry,\n property,\n metadata,\n storagePathBuilder,\n onFileUploadComplete,\n onClear,\n disabled\n }: SortableStorageItemProps) {\n\n const {\n attributes,\n listeners,\n setNodeRef,\n transform,\n transition,\n isDragging\n } = useSortable({ id });\n\n const style: React.CSSProperties = {\n transform: CSS.Transform.toString(transform),\n transition,\n zIndex: isDragging ? 100 : undefined\n };\n\n const getImageSizeNumber = (previewSize: PreviewSize): number => {\n switch (previewSize) {\n case \"small\":\n return 40;\n case \"medium\":\n return 118;\n case \"large\":\n return 220;\n default:\n return 118;\n }\n };\n\n let child: React.ReactNode;\n if (entry.storagePathOrDownloadUrl) {\n child = (\n <StorageItemPreview\n name={`storage_preview_${entry.storagePathOrDownloadUrl}`}\n property={property}\n disabled={disabled}\n value={entry.storagePathOrDownloadUrl}\n onRemove={() => onClear(entry.storagePathOrDownloadUrl!)}\n size={entry.size as PreviewSize}/>\n );\n } else if (entry.file) {\n child = (\n <StorageUploadProgress\n entry={entry}\n metadata={metadata}\n storagePath={storagePathBuilder(entry.file)}\n onFileUploadComplete={onFileUploadComplete}\n imageSize={getImageSizeNumber(entry.size as PreviewSize)}\n simple={false}\n />\n );\n }\n\n return (\n <div\n ref={setNodeRef}\n style={style}\n {...attributes}\n {...listeners}\n // No vertical margin: the strip already pads itself, and `m-1` made\n // each item 8px taller than the row's content box — enough to make a\n // field holding one image scroll vertically behind a hidden\n // scrollbar. `shrink-0` keeps thumbnails square once there are more\n // of them than fit across.\n className={cls(\"rounded-md shrink-0\")}\n tabIndex={-1}\n >\n {child}\n </div>\n );\n}\n\nfunction FileDropComponent({\n storage,\n disabled,\n onFilesAdded,\n multipleFilesSupported,\n autoFocus,\n internalValue,\n property,\n onClear,\n metadata,\n storagePathBuilder,\n onFileUploadComplete,\n name,\n helpText,\n isDndItemDragging\n }: {\n storage: StorageConfig,\n disabled: boolean,\n onFilesAdded: (acceptedFiles: File[]) => Promise<void>,\n multipleFilesSupported: boolean,\n autoFocus: boolean,\n internalValue: StorageFieldItem[],\n property: StringProperty,\n onClear: (clearedStoragePathOrDownloadUrl: string) => void,\n metadata?: Record<string, unknown>,\n storagePathBuilder: (file: File) => string,\n onFileUploadComplete: (uploadedPath: string, entry: StorageFieldItem, fileMetadata?: Record<string, unknown>) => Promise<void>,\n name: string,\n helpText: string,\n isDndItemDragging?: boolean\n}) {\n\n const snackbarContext = useSnackbarController();\n\n const {\n getRootProps,\n getInputProps,\n isDragActive, // This is for files dragged from OS\n isDragAccept,\n isDragReject\n } = useDropzone({\n accept: storage.acceptedFiles ? storage.acceptedFiles.reduce((acc, ext) => ({\n ...acc,\n [ext]: []\n }), {}) : undefined,\n disabled: disabled || isDndItemDragging,\n // react-dropzone defaults to `multiple: true`, so a\n // `type: \"string\"` property with a storage config offered a picker\n // that took several files, uploaded the first, and never mentioned\n // the rest — one thumbnail, one 201, and the others gone without a\n // word. The field holds one path; the picker should ask for one.\n multiple: multipleFilesSupported,\n noDragEventsBubbling: true,\n maxSize: storage.maxSize,\n onDrop: onFilesAdded,\n onDropRejected: (fileRejections) => {\n for (const fileRejection of fileRejections) {\n for (const error of fileRejection.errors) {\n console.error(\"Error uploading file: \", error);\n if (error.code === \"file-too-large\") {\n snackbarContext.open({\n type: \"error\",\n message: `Error uploading file: File is larger than ${storage.maxSize} bytes`\n });\n } else if (error.code === \"file-invalid-type\") {\n snackbarContext.open({\n type: \"error\",\n message: \"Error uploading file: File type is not supported\"\n });\n }\n }\n }\n }\n }\n );\n\n return (\n <div\n {...getRootProps()}\n className={cls(\n fieldBackgroundMixin,\n disabled ? fieldBackgroundDisabledMixin : fieldBackgroundHoverMixin,\n disabled ? \"text-surface-accent-600 dark:text-surface-accent-500\" : \"\",\n dropZoneClasses,\n multipleFilesSupported && internalValue.length ? \"\" : \"flex\",\n {\n [nonActiveDropClasses]: !isDragActive,\n [activeDropClasses]: isDragActive, // OS file drag active\n [rejectDropClasses]: isDragReject, // OS file drag reject\n [acceptDropClasses]: isDragAccept, // OS file drag accept\n [disabledClasses]: disabled || isDndItemDragging // Visually disable if internal drag\n })}\n >\n <div\n className={cls(\"flex items-center gap-2 p-1 px-3 no-scrollbar\",\n // Horizontal only. `overflow-auto` scrolls both axes, so any\n // pixel of vertical overflow turned the field into a\n // scrollable box with nothing visible to scroll to.\n multipleFilesSupported && internalValue.length ? \"overflow-x-auto overflow-y-hidden\" : \"\",\n // A fixed height, not a minimum: the 118px preview overflowed\n // a `min-h`, so a field with a file stood taller than the same\n // field empty. 126px is the preview plus its padding.\n \"h-[126px]\"\n )}\n >\n <input\n autoFocus={autoFocus}\n {...getInputProps()}/>\n\n {internalValue.map((entry) => (\n <SortableStorageItem\n key={entry.id}\n id={entry.id}\n entry={entry}\n property={property}\n name={name}\n metadata={metadata}\n storagePathBuilder={storagePathBuilder}\n onFileUploadComplete={onFileUploadComplete}\n onClear={onClear}\n disabled={disabled}\n isSortable={multipleFilesSupported}\n />\n ))}\n\n {/* Placeholder for empty dropzone text is handled by the outer Typography */}\n </div>\n\n <div\n // Two lines' worth, fixed: the hint gains \"Drag to reorder\" once\n // the field holds something, and a reflow there put the filled\n // state 25px taller than the empty one.\n className=\"box-border mx-3 mb-2.5 h-[34px] flex items-center justify-center text-center\">\n <Typography align={\"center\"}\n variant={\"caption\"}\n className={disabled ? \"text-surface-accent-600 dark:text-surface-accent-500\" : \"\"}>\n {helpText}\n </Typography>\n </div>\n </div>\n );\n}\n\nexport interface StorageUploadProps {\n value: StorageFieldItem[];\n setInternalValue: (v: StorageFieldItem[]) => void;\n name: string;\n property: StringProperty | ArrayProperty;\n onChange: (value: string | string[] | null) => void;\n multipleFilesSupported: boolean;\n autoFocus: boolean;\n disabled: boolean;\n storage: StorageConfig;\n onFilesAdded: (acceptedFiles: File[]) => Promise<void>; // Updated from useStorageUploadController\n storagePathBuilder: (file: File) => string;\n onFileUploadComplete: (uploadedPath: string, entry: StorageFieldItem, fileMetadata?: Record<string, unknown>) => Promise<void>;\n}\n\nexport function StorageUpload({\n property,\n name,\n value, // This is internalValue from useStorageUploadController\n setInternalValue,\n onChange,\n multipleFilesSupported,\n onFileUploadComplete,\n disabled,\n onFilesAdded,\n autoFocus,\n storage,\n storagePathBuilder\n }: StorageUploadProps) {\n\n if (multipleFilesSupported) {\n const arrayProperty = property as ArrayProperty;\n if (arrayProperty.of) {\n if (Array.isArray(arrayProperty.of)) {\n throw Error(\"Storage field using array must be of data type string\");\n }\n if (arrayProperty.of.type !== \"string\") {\n throw Error(\"Storage field using array must be of data type string\");\n }\n } else {\n throw Error(\"Storage field using array must be of data type string\");\n }\n }\n\n const metadata: Record<string, unknown> | undefined = storage?.metadata;\n const [isDndItemDragging, setIsDndItemDragging] = useState(false);\n\n const moveItem = useCallback((fromIndex: number, toIndex: number) => {\n if (!multipleFilesSupported || fromIndex === toIndex) return;\n const newValue = [...value];\n const item = newValue[fromIndex];\n newValue.splice(fromIndex, 1);\n newValue.splice(toIndex, 0, item);\n setInternalValue(newValue);\n const fieldValue = newValue\n .filter(e => !!e.storagePathOrDownloadUrl)\n .map(e => e.storagePathOrDownloadUrl as string);\n onChange(fieldValue);\n }, [multipleFilesSupported, onChange, setInternalValue, value]);\n\n const sensors = useSensors(\n useSensor(PointerSensor, {\n activationConstraint: {\n distance: 5 // Start dragging after 5px movement\n }\n }),\n useSensor(KeyboardSensor, {\n coordinateGetter: sortableKeyboardCoordinates\n })\n );\n\n const handleDragStart = useCallback((event: DragStartEvent) => {\n setIsDndItemDragging(true);\n }, []);\n\n const handleDragEnd = useCallback((event: DragEndEvent) => {\n setIsDndItemDragging(false);\n const {\n active,\n over\n } = event;\n if (over && active.id !== over.id) {\n const oldIndex = value.findIndex(item => item.id === active.id);\n const newIndex = value.findIndex(item => item.id === over.id);\n if (oldIndex !== -1 && newIndex !== -1) {\n moveItem(oldIndex, newIndex);\n }\n }\n }, [value, moveItem]);\n\n const onClear = useCallback((clearedStoragePathOrDownloadUrl: string) => {\n let newValue: StorageFieldItem[];\n if (multipleFilesSupported) {\n newValue = value.filter(v => v.storagePathOrDownloadUrl !== clearedStoragePathOrDownloadUrl);\n onChange(newValue.filter(v => !!v.storagePathOrDownloadUrl).map(v => v.storagePathOrDownloadUrl as string));\n } else {\n newValue = [];\n onChange(null);\n }\n setInternalValue(newValue);\n }, [value, multipleFilesSupported, onChange, setInternalValue]);\n\n const { t } = useTranslation();\n const helpText = multipleFilesSupported\n ? t(\"drag_drop_multiple\")\n : t(\"drag_drop_single\");\n\n const renderProperty: StringProperty = multipleFilesSupported\n ? (property as ArrayProperty).of as StringProperty\n : property as StringProperty;\n\n const fileDropProps = {\n storage,\n disabled,\n onFilesAdded,\n multipleFilesSupported,\n autoFocus,\n internalValue: value, // Pass current internalValue\n property: renderProperty,\n onClear,\n metadata,\n storagePathBuilder,\n onFileUploadComplete,\n name,\n helpText,\n isDndItemDragging // Pass this down\n };\n\n if (multipleFilesSupported) {\n return (\n <DndContext\n sensors={sensors}\n collisionDetection={closestCenter}\n onDragStart={handleDragStart}\n onDragEnd={handleDragEnd}\n >\n <SortableContext items={(value ?? []).map(v => v.id)} strategy={horizontalListSortingStrategy}>\n <FileDropComponent {...fileDropProps}/>\n </SortableContext>\n </DndContext>\n );\n } else {\n // For single file, no D&D context is needed\n return <FileDropComponent {...fileDropProps} isDndItemDragging={false}/>;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAkDA,IAAM,kBAAkB;AACxB,IAAM,kBAAkB;AACxB,IAAM,uBAAuB;AAC7B,IAAM,oBAAoB;AAC1B,IAAM,oBAAoB;AAC1B,IAAM,oBAAoB;AAE1B,SAAgB,0BAA0B,EACI,aACA,OACA,UACA,OACA,WACA,WACA,gBACA,UACA,oBACA,WACA,SACA,gBAC2C;CAE9D,kBAAkB;CAEzC,MAAM,gBAAgB,iBAAiB;CACvC,MAAM,WAAW,WAAW,QAAQ,KAAK,WAAW,QAAQ,KAAK,gBAAgB,QAAQ;CAEzF,MAAM,EACF,eACA,kBACA,cACA,SACA,sBACA,oBACA,wBACA,0BACA,2BAA2B;EAC3B,cAAc,QAAQ;EACtB,UAAU,QAAQ;EAClB,MAAM,QAAQ;EACd,gBAAgB,QAAQ,YAAY;EACpC;EACA;EACO;EACP;EACA,UAAU,YAAY;EACtB,UAAU;CACd,CAAC;CAED,OAEI,qBAAA,UAAA,EAAA,UAAA;EAEK,CAAC,kBAAkB,CAAC,aACjB,oBAAC,eAAD;GACiB;GACb,MAAM,mBAAmB,UAAU,OAAO;GAC1C,UAAU,SAAS,YAAY;GAC/B,OAAO,SAAS,QAAQ;GACxB,WAAW;EAAgE,CAAA;EAEnF,oBAAC,qBAAqB,UAAtB;GAA+B,OAAO;aAClC,oBAAC,eAAD;IACI,OAAO;IACP,MAAM;IACN,UAAU,YAAY;IACtB,WAAW,aAAa;IACd;IACV,UAAU;IACQ;IACJ;IACQ;IACF;IACX;IACe;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AI;EACJ,IAAI,wBAAwB;GACxB,WAAW,MAAM,QAAO,MAAK,EAAE,6BAA6B,+BAA+B;GAC3F,SAAS,SAAS,QAAO,MAAK,CAAC,CAAC,EAAE,wBAAwB,CAAC,CAAC,KAAI,MAAK,EAAE,wBAAkC,CAAC;EAC9G,OAAO;GACH,WAAW,CAAC;GACZ,SAAS,IAAI;EACjB;EACA,iBAAiB,QAAQ;CAC7B,GAAG;EAAC;EAAO;EAAwB;EAAU;CAAgB,CAAC;CAE9D,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,WAAW,yBACX,EAAE,oBAAoB,IACtB,EAAE,kBAAkB;CAM1B,MAAM,gBAAgB;EAClB;EACA;EACA;EACA;EACA;EACA,eAAe;EACf,UAXmC,yBAChC,SAA2B,KAC5B;EAUF;EACA;EACA;EACA;EACA;EACA;EACA;CACJ;CAEA,IAAI,wBACA,OACI,oBAAC,YAAD;EACa;EACT,oBAAoB;EACpB,aAAa;EACb,WAAW;YAEX,oBAAC,iBAAD;GAAiB,QAAQ,SAAS,CAAC,EAAA,CAAG,KAAI,MAAK,EAAE,EAAE;GAAG,UAAU;aAC5D,oBAAC,mBAAD,EAAmB,GAAI,cAAe,CAAA;EACzB,CAAA;CACT,CAAA;MAIhB,OAAO,oBAAC,mBAAD;EAAmB,GAAI;EAAe,mBAAmB;CAAO,CAAA;AAE/E"}
@@ -1,5 +1,5 @@
1
1
  import type { FieldProps } from "../../types/fields.js";
2
- import type { BooleanProperty } from "@rebasepro/types";
2
+ import type { BooleanProperty } from "@rebasepro/cms-types";
3
3
  import React from "react";
4
4
  /**
5
5
  * Simple boolean switch biding to a boolean property.
@@ -1 +1 @@
1
- {"version":3,"file":"SwitchFieldBinding.js","names":[],"sources":["../../../src/form/field_bindings/SwitchFieldBinding.tsx"],"sourcesContent":["import type { FieldProps } from \"../../types/fields\";\nimport type { BooleanProperty } from \"@rebasepro/types\";\nimport React from \"react\";\n\n;\nimport { getIconForProperty } from \"../../util/property_utils\";\nimport { FieldHelperText } from \"../components/FieldHelperText\";\nimport { LabelWithIcon } from \"../components/LabelWithIcon\";\nimport { BooleanSwitchWithLabel } from \"@rebasepro/ui\";\n\n/**\n * Simple boolean switch biding to a boolean property.\n *\n * This is one of the internal components that get mapped natively inside forms\n * and tables to the specified properties.\n * @group Form fields\n */\nexport const SwitchFieldBinding = function SwitchFieldBinding({\n propertyKey,\n value,\n setValue,\n error,\n showError,\n autoFocus,\n disabled,\n size = \"large\",\n property,\n includeDescription,\n hideLabel\n }: FieldProps<BooleanProperty>) {\n\n return (\n <>\n\n <BooleanSwitchWithLabel\n value={value as boolean | null}\n onValueChange={(v) => setValue(v)}\n error={showError}\n // The control is `justify-between`, so with the label lifted\n // out the switch would drift to the far edge of an otherwise\n // empty box. Anchor it to the start instead.\n position={hideLabel ? \"start\" : undefined}\n label={hideLabel ? undefined : <LabelWithIcon\n icon={getIconForProperty(property, \"small\")}\n required={property.validation?.required}\n title={property.name ?? propertyKey}/>}\n // The entity form sets `hideLabel` for every field FieldBlock\n // labels, and FieldBlock's label is not tied to the control —\n // so the switch names itself, as the date field does.\n aria-label={hideLabel ? (property.name ?? propertyKey) : undefined}\n disabled={disabled}\n autoFocus={autoFocus}\n size={size}\n // With its label inside, a switch stands as tall as a text\n // field whose label is inside: 64px plus the field's 1px\n // (transparent) border top and bottom. Pairing puts switches\n // side by side, and the rail stacks them under selects.\n className={!hideLabel && size === \"large\" ? \"min-h-[66px]\" : undefined}\n />\n\n <FieldHelperText includeDescription={includeDescription}\n showError={showError}\n error={error}\n disabled={disabled}\n property={property}/>\n </>\n\n );\n};\n"],"mappings":";;;;;;;;;;;;;;AAiBA,IAAa,qBAAqB,SAAS,mBAAmB,EACI,aACA,OACA,UACA,OACA,WACA,WACA,UACA,OAAO,SACP,UACA,oBACA,aAC4B;CAE1F,OACI,qBAAA,UAAA,EAAA,UAAA,CAEI,oBAAC,wBAAD;EACW;EACP,gBAAgB,MAAM,SAAS,CAAC;EAChC,OAAO;EAIP,UAAU,YAAY,UAAU,KAAA;EAChC,OAAO,YAAY,KAAA,IAAY,oBAAC,eAAD;GAC3B,MAAM,mBAAmB,UAAU,OAAO;GAC1C,UAAU,SAAS,YAAY;GAC/B,OAAO,SAAS,QAAQ;EAAa,CAAA;EAIzC,cAAY,YAAa,SAAS,QAAQ,cAAe,KAAA;EAC/C;EACC;EACL;EAKN,WAAW,CAAC,aAAa,SAAS,UAAU,iBAAiB,KAAA;CAChE,CAAA,GAED,oBAAC,iBAAD;EAAqC;EACT;EACJ;EACG;EACA;CAAU,CAAA,CACvC,EAAA,CAAA;AAGV"}
1
+ {"version":3,"file":"SwitchFieldBinding.js","names":[],"sources":["../../../src/form/field_bindings/SwitchFieldBinding.tsx"],"sourcesContent":["import type { FieldProps } from \"../../types/fields\";\nimport type { BooleanProperty } from \"@rebasepro/cms-types\";\nimport React from \"react\";\n\n;\nimport { getIconForProperty } from \"../../util/property_utils\";\nimport { FieldHelperText } from \"../components/FieldHelperText\";\nimport { LabelWithIcon } from \"../components/LabelWithIcon\";\nimport { BooleanSwitchWithLabel } from \"@rebasepro/ui\";\n\n/**\n * Simple boolean switch biding to a boolean property.\n *\n * This is one of the internal components that get mapped natively inside forms\n * and tables to the specified properties.\n * @group Form fields\n */\nexport const SwitchFieldBinding = function SwitchFieldBinding({\n propertyKey,\n value,\n setValue,\n error,\n showError,\n autoFocus,\n disabled,\n size = \"large\",\n property,\n includeDescription,\n hideLabel\n }: FieldProps<BooleanProperty>) {\n\n return (\n <>\n\n <BooleanSwitchWithLabel\n value={value as boolean | null}\n onValueChange={(v) => setValue(v)}\n error={showError}\n // The control is `justify-between`, so with the label lifted\n // out the switch would drift to the far edge of an otherwise\n // empty box. Anchor it to the start instead.\n position={hideLabel ? \"start\" : undefined}\n label={hideLabel ? undefined : <LabelWithIcon\n icon={getIconForProperty(property, \"small\")}\n required={property.validation?.required}\n title={property.name ?? propertyKey}/>}\n // The entity form sets `hideLabel` for every field FieldBlock\n // labels, and FieldBlock's label is not tied to the control —\n // so the switch names itself, as the date field does.\n aria-label={hideLabel ? (property.name ?? propertyKey) : undefined}\n disabled={disabled}\n autoFocus={autoFocus}\n size={size}\n // With its label inside, a switch stands as tall as a text\n // field whose label is inside: 64px plus the field's 1px\n // (transparent) border top and bottom. Pairing puts switches\n // side by side, and the rail stacks them under selects.\n className={!hideLabel && size === \"large\" ? \"min-h-[66px]\" : undefined}\n />\n\n <FieldHelperText includeDescription={includeDescription}\n showError={showError}\n error={error}\n disabled={disabled}\n property={property}/>\n </>\n\n );\n};\n"],"mappings":";;;;;;;;;;;;;;AAiBA,IAAa,qBAAqB,SAAS,mBAAmB,EACI,aACA,OACA,UACA,OACA,WACA,WACA,UACA,OAAO,SACP,UACA,oBACA,aAC4B;CAE1F,OACI,qBAAA,UAAA,EAAA,UAAA,CAEI,oBAAC,wBAAD;EACW;EACP,gBAAgB,MAAM,SAAS,CAAC;EAChC,OAAO;EAIP,UAAU,YAAY,UAAU,KAAA;EAChC,OAAO,YAAY,KAAA,IAAY,oBAAC,eAAD;GAC3B,MAAM,mBAAmB,UAAU,OAAO;GAC1C,UAAU,SAAS,YAAY;GAC/B,OAAO,SAAS,QAAQ;EAAa,CAAA;EAIzC,cAAY,YAAa,SAAS,QAAQ,cAAe,KAAA;EAC/C;EACC;EACL;EAKN,WAAW,CAAC,aAAa,SAAS,UAAU,iBAAiB,KAAA;CAChE,CAAA,GAED,oBAAC,iBAAD;EAAqC;EACT;EACJ;EACG;EACA;CAAU,CAAA,CACvC,EAAA,CAAA;AAGV"}
@@ -1,5 +1,5 @@
1
1
  import type { FieldProps } from "../../types/fields.js";
2
- import type { NumberProperty, StringProperty } from "@rebasepro/types";
2
+ import type { NumberProperty, StringProperty } from "@rebasepro/cms-types";
3
3
  import React from "react";
4
4
  /**
5
5
  * Generic text field.
@@ -1 +1 @@
1
- {"version":3,"file":"TextFieldBinding.js","names":[],"sources":["../../../src/form/field_bindings/TextFieldBinding.tsx"],"sourcesContent":["import { useTranslation } from \"@rebasepro/app\";\nimport type { FieldProps } from \"../../types/fields\";\nimport type { NumberProperty, StringProperty } from \"@rebasepro/types\";\nimport React, { useCallback } from \"react\";\n\nimport {\n cls,\n Collapse,\n fieldBackgroundHoverMixin,\n fieldBackgroundMixin,\n IconButton,\n InputLabel,\n TextareaAutosize,\n TextField,\n XIcon\n} from \"@rebasepro/ui\";\nimport { PreviewType } from \"@rebasepro/cms-types\";\nimport { FieldHelperText } from \"../components/FieldHelperText\";\nimport { LabelWithIcon } from \"../components/LabelWithIcon\";\nimport { PropertyPreview } from \"../../preview\";\nimport { getIconForProperty } from \"../../util/property_utils\";\n\n/**\n * Generic text field.\n * This is one of the internal components that get mapped natively inside forms\n * and tables to the specified properties.\n * @group Form fields\n */\nexport function TextFieldBinding<T extends string | number>({\n propertyKey,\n value,\n setValue,\n error,\n showError,\n disabled,\n autoFocus,\n property,\n includeDescription,\n hideLabel,\n size = \"large\"\n }: FieldProps<StringProperty | NumberProperty>) {\n const { t } = useTranslation();\n\n let multiline: boolean | undefined;\n let url: boolean | PreviewType | undefined;\n if (property.type === \"string\") {\n multiline = property.admin?.multiline;\n // `url: true` alone earns the preview. A form field holding a URL that\n // renders as plain text is one you have to select and copy to follow,\n // and the property has already said what it is.\n url = property.admin?.urlPreview ?? property.url;\n }\n\n const displayValue = (value !== undefined && value !== null) ? String(value) : \"\";\n // A number goes to the input as a number. React leaves a number input\n // alone while its text reads as the value (`\"1.0\" == 1`); handed `\"1\"`, it\n // compares strings and rewrites `\"1.0\"` to `\"1\"` as the zero is typed, so\n // `1.05` could not be entered.\n const inputValue: string | number = typeof value === \"number\" ? value : displayValue;\n\n const handleClearClick = useCallback((e: React.MouseEvent) => {\n e.stopPropagation();\n e.preventDefault();\n setValue(null);\n }, [setValue]);\n\n const onChange = (event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n if (inputType === \"number\") {\n const numberValue = event.target.value ? parseFloat(event.target.value) : undefined;\n if (numberValue !== undefined && Number.isNaN(numberValue)) {\n setValue(null);\n } else if (numberValue !== undefined && numberValue !== null) {\n setValue(numberValue as T);\n } else {\n setValue(null);\n }\n } else {\n // Emptied is NULL. Writing `\"\"` over a NULL the user only typed\n // into and deleted made `isNull` filters stop matching the row,\n // and collided on an optional unique column; `required` already\n // reads `\"\"` as missing.\n setValue(event.target.value === \"\" ? null : event.target.value as T);\n }\n };\n\n const isMultiline = Boolean(multiline);\n\n let inputType: \"number\" | \"email\" | \"url\" | undefined = undefined;\n if (property.type === \"number\") {\n inputType = \"number\";\n } else if (property.type === \"string\") {\n if (property.email) inputType = \"email\";\n else if (property.admin?.urlPreview || property.url) inputType = \"url\";\n }\n\n // `undefined` rather than an empty element: TextField and the multiline box\n // both reserve a label row whenever `label` is truthy, so a null-rendering\n // element would leave the gap behind without the text.\n const label = hideLabel\n ? undefined\n : (\n <LabelWithIcon\n icon={getIconForProperty(property, \"small\")}\n required={property.validation?.required || property.isId === true}\n title={property.name ?? propertyKey}/>\n );\n\n // A value under a label inside the box is set at 16px, the FireCMS field:\n // the 64px box is sized for a 24px line. Everywhere a text field stands\n // without its label — a table cell, a dense dialog — it keeps the kit's 14.\n const valueText = label && size === \"large\" ? \"text-base\" : undefined;\n\n // The control needs a name of its own in two cases, and between them they\n // cover every text field in an entity form:\n //\n // - `hideLabel`, which the form sets for anything FieldBlock labels for it\n // (`hideLabel: !selfLabelling`). FieldBlock draws the name in a <span>\n // inside a <div> — not a <label>, and pointing at nothing — so suppressing\n // the field's own label left the input with no accessible name at all and\n // a screen reader fell back to reading its value back to you.\n // - the multiline branch below, which never associated anything: its label\n // is a decorative absolutely-positioned <div>, so it is unnamed whether or\n // not the form also drew one.\n //\n // The single-line TextField is already handled by the kit when a label is\n // present — it wires `aria-labelledby` — so it only needs this as a fallback.\n const accessibleName = property.name ?? propertyKey;\n return (<>\n {isMultiline ? (\n <div className={cls(\n \"rounded-lg relative max-w-full min-h-[64px]\",\n fieldBackgroundMixin,\n fieldBackgroundHoverMixin,\n showError && error ? \"border border-red-500 dark:border-red-600\" : \"\"\n )}>\n {/* The single-line field's shrunk label, at the same spot:\n this was its own 14px label pinned to the top, a size up\n from the label of the field above it. Always shrunk —\n the box is tall, and a label resting in its middle would\n sit on the text. */}\n {label && <InputLabel shrink\n className={cls(\n \"pointer-events-none absolute top-1\",\n showError && error\n ? \"text-red-500 dark:text-red-600\"\n : \"text-text-secondary dark:text-text-secondary-dark\"\n )}>\n {label}\n </InputLabel>}\n <TextareaAutosize\n value={displayValue}\n onChange={onChange}\n autoFocus={autoFocus}\n disabled={disabled}\n aria-label={accessibleName}\n className={cls(\n \"rounded-md resize-none w-full outline-none text-sm bg-transparent min-h-[64px] px-3\",\n valueText,\n label ? \"pt-8 pb-2\" : \"py-2\",\n disabled && \"outline-none opacity-50 text-surface-accent-600 dark:text-surface-accent-500\",\n showError && error ? \"text-red-500 dark:text-red-600\" : \"\"\n )}\n />\n {property.admin?.clearable && (\n <div\n className=\"flex flex-row justify-center items-center absolute h-full right-0 top-0 mr-4\">\n <IconButton aria-label={t(\"clear\")} onClick={handleClearClick}>\n <XIcon/>\n </IconButton>\n </div>\n )}\n </div>\n ) : (\n <TextField\n size={size}\n value={inputValue}\n onChange={onChange}\n autoFocus={autoFocus}\n label={label}\n aria-label={label ? undefined : accessibleName}\n type={inputType}\n disabled={disabled}\n endAdornment={\n property.admin?.clearable && <IconButton aria-label={t(\"clear\")}\n onClick={handleClearClick}>\n <XIcon/>\n </IconButton>\n }\n error={showError ? !!error : undefined}\n inputClassName={cls(valueText, error && \"text-red-500 dark:text-red-600\")}/>\n )}\n <FieldHelperText includeDescription={includeDescription}\n showError={showError}\n error={error}\n disabled={disabled}\n property={property}/>\n\n {url && <Collapse\n className=\"mt-1 ml-1\"\n in={Boolean(value)}>\n <PropertyPreview\n value={value}\n property={property}\n size={size}/>\n </Collapse>}\n\n </>\n );\n\n}\n"],"mappings":";;;;;;;;;;;;;;;AA4BA,SAAgB,iBAA4C,EACI,aACA,OACA,UACA,OACA,W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,qBAAA,UAAA,EAAA,UAAA;EACC,cACG,qBAAC,OAAD;GAAK,WAAW,IACZ,+CACA,sBACA,2BACA,aAAa,QAAQ,8CAA8C,EACvE;aALA;IAWK,SAAS,oBAAC,YAAD;KAAY,QAAA;KAClB,WAAW,IACP,sCACA,aAAa,QACP,mCACA,mDACV;eACC;IACO,CAAA;IACZ,oBAAC,kBAAD;KACI,OAAO;KACG;KACC;KACD;KACV,cAAY;KACZ,WAAW,IACP,uFACA,WACA,QAAQ,cAAc,QACtB,YAAY,gFACZ,aAAa,QAAQ,mCAAmC,EAC5D;IACH,CAAA;IACA,SAAS,OAAO,aACb,oBAAC,OAAD;KACI,WAAU;eACV,oBAAC,YAAD;MAAY,cAAY,EAAE,OAAO;MAAG,SAAS;gBACzC,oBAAC,OAAD,CAAO,CAAA;KACC,CAAA;IACX,CAAA;GAER;OAEL,oBAAC,WAAD;GACU;GACN,OAAO;GACG;GACC;GACJ;GACP,cAAY,QAAQ,KAAA,IAAY;GAChC,MAAM;GACI;GACV,cACI,SAAS,OAAO,aAAa,oBAAC,YAAD;IAAY,cAAY,EAAE,OAAO;IAC1D,SAAS;cACT,oBAAC,OAAD,CAAO,CAAA;GACC,CAAA;GAEhB,OAAO,YAAY,CAAC,CAAC,QAAQ,KAAA;GAC7B,gBAAgB,IAAI,WAAW,SAAS,gCAAgC;EAAG,CAAA;EAEnF,oBAAC,iBAAD;GAAqC;GACT;GACJ;GACG;GACA;EAAU,CAAA;EAEpC,OAAO,oBAAC,UAAD;GACJ,WAAU;GACV,IAAI,QAAQ,KAAK;aACjB,oBAAC,iBAAD;IACW;IACG;IACJ;GAAM,CAAA;EACV,CAAA;CAEZ,EAAA,CAAA;AAGV"}
1
+ {"version":3,"file":"TextFieldBinding.js","names":[],"sources":["../../../src/form/field_bindings/TextFieldBinding.tsx"],"sourcesContent":["import { useTranslation } from \"@rebasepro/app\";\nimport type { FieldProps } from \"../../types/fields\";\nimport type { NumberProperty, StringProperty } from \"@rebasepro/cms-types\";\nimport React, { useCallback } from \"react\";\n\nimport {\n cls,\n Collapse,\n fieldBackgroundHoverMixin,\n fieldBackgroundMixin,\n IconButton,\n InputLabel,\n TextareaAutosize,\n TextField,\n XIcon\n} from \"@rebasepro/ui\";\nimport { PreviewType } from \"@rebasepro/cms-types\";\nimport { FieldHelperText } from \"../components/FieldHelperText\";\nimport { LabelWithIcon } from \"../components/LabelWithIcon\";\nimport { PropertyPreview } from \"../../preview\";\nimport { getIconForProperty } from \"../../util/property_utils\";\n\n/**\n * Generic text field.\n * This is one of the internal components that get mapped natively inside forms\n * and tables to the specified properties.\n * @group Form fields\n */\nexport function TextFieldBinding<T extends string | number>({\n propertyKey,\n value,\n setValue,\n error,\n showError,\n disabled,\n autoFocus,\n property,\n includeDescription,\n hideLabel,\n size = \"large\"\n }: FieldProps<StringProperty | NumberProperty>) {\n const { t } = useTranslation();\n\n let multiline: boolean | undefined;\n let url: boolean | PreviewType | undefined;\n if (property.type === \"string\") {\n multiline = property.admin?.multiline;\n // `url: true` alone earns the preview. A form field holding a URL that\n // renders as plain text is one you have to select and copy to follow,\n // and the property has already said what it is.\n url = property.admin?.urlPreview ?? property.url;\n }\n\n const displayValue = (value !== undefined && value !== null) ? String(value) : \"\";\n // A number goes to the input as a number. React leaves a number input\n // alone while its text reads as the value (`\"1.0\" == 1`); handed `\"1\"`, it\n // compares strings and rewrites `\"1.0\"` to `\"1\"` as the zero is typed, so\n // `1.05` could not be entered.\n const inputValue: string | number = typeof value === \"number\" ? value : displayValue;\n\n const handleClearClick = useCallback((e: React.MouseEvent) => {\n e.stopPropagation();\n e.preventDefault();\n setValue(null);\n }, [setValue]);\n\n const onChange = (event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n if (inputType === \"number\") {\n const numberValue = event.target.value ? parseFloat(event.target.value) : undefined;\n if (numberValue !== undefined && Number.isNaN(numberValue)) {\n setValue(null);\n } else if (numberValue !== undefined && numberValue !== null) {\n setValue(numberValue as T);\n } else {\n setValue(null);\n }\n } else {\n // Emptied is NULL. Writing `\"\"` over a NULL the user only typed\n // into and deleted made `isNull` filters stop matching the row,\n // and collided on an optional unique column; `required` already\n // reads `\"\"` as missing.\n setValue(event.target.value === \"\" ? null : event.target.value as T);\n }\n };\n\n const isMultiline = Boolean(multiline);\n\n let inputType: \"number\" | \"email\" | \"url\" | undefined = undefined;\n if (property.type === \"number\") {\n inputType = \"number\";\n } else if (property.type === \"string\") {\n if (property.email) inputType = \"email\";\n else if (property.admin?.urlPreview || property.url) inputType = \"url\";\n }\n\n // `undefined` rather than an empty element: TextField and the multiline box\n // both reserve a label row whenever `label` is truthy, so a null-rendering\n // element would leave the gap behind without the text.\n const label = hideLabel\n ? undefined\n : (\n <LabelWithIcon\n icon={getIconForProperty(property, \"small\")}\n required={property.validation?.required || property.isId === true}\n title={property.name ?? propertyKey}/>\n );\n\n // A value under a label inside the box is set at 16px, the FireCMS field:\n // the 64px box is sized for a 24px line. Everywhere a text field stands\n // without its label — a table cell, a dense dialog — it keeps the kit's 14.\n const valueText = label && size === \"large\" ? \"text-base\" : undefined;\n\n // The control needs a name of its own in two cases, and between them they\n // cover every text field in an entity form:\n //\n // - `hideLabel`, which the form sets for anything FieldBlock labels for it\n // (`hideLabel: !selfLabelling`). FieldBlock draws the name in a <span>\n // inside a <div> — not a <label>, and pointing at nothing — so suppressing\n // the field's own label left the input with no accessible name at all and\n // a screen reader fell back to reading its value back to you.\n // - the multiline branch below, which never associated anything: its label\n // is a decorative absolutely-positioned <div>, so it is unnamed whether or\n // not the form also drew one.\n //\n // The single-line TextField is already handled by the kit when a label is\n // present — it wires `aria-labelledby` — so it only needs this as a fallback.\n const accessibleName = property.name ?? propertyKey;\n return (<>\n {isMultiline ? (\n <div className={cls(\n \"rounded-lg relative max-w-full min-h-[64px]\",\n fieldBackgroundMixin,\n fieldBackgroundHoverMixin,\n showError && error ? \"border border-red-500 dark:border-red-600\" : \"\"\n )}>\n {/* The single-line field's shrunk label, at the same spot:\n this was its own 14px label pinned to the top, a size up\n from the label of the field above it. Always shrunk —\n the box is tall, and a label resting in its middle would\n sit on the text. */}\n {label && <InputLabel shrink\n className={cls(\n \"pointer-events-none absolute top-1\",\n showError && error\n ? \"text-red-500 dark:text-red-600\"\n : \"text-text-secondary dark:text-text-secondary-dark\"\n )}>\n {label}\n </InputLabel>}\n <TextareaAutosize\n value={displayValue}\n onChange={onChange}\n autoFocus={autoFocus}\n disabled={disabled}\n aria-label={accessibleName}\n className={cls(\n \"rounded-md resize-none w-full outline-none text-sm bg-transparent min-h-[64px] px-3\",\n valueText,\n label ? \"pt-8 pb-2\" : \"py-2\",\n disabled && \"outline-none opacity-50 text-surface-accent-600 dark:text-surface-accent-500\",\n showError && error ? \"text-red-500 dark:text-red-600\" : \"\"\n )}\n />\n {property.admin?.clearable && (\n <div\n className=\"flex flex-row justify-center items-center absolute h-full right-0 top-0 mr-4\">\n <IconButton aria-label={t(\"clear\")} onClick={handleClearClick}>\n <XIcon/>\n </IconButton>\n </div>\n )}\n </div>\n ) : (\n <TextField\n size={size}\n value={inputValue}\n onChange={onChange}\n autoFocus={autoFocus}\n label={label}\n aria-label={label ? undefined : accessibleName}\n type={inputType}\n disabled={disabled}\n endAdornment={\n property.admin?.clearable && <IconButton aria-label={t(\"clear\")}\n onClick={handleClearClick}>\n <XIcon/>\n </IconButton>\n }\n error={showError ? !!error : undefined}\n inputClassName={cls(valueText, error && \"text-red-500 dark:text-red-600\")}/>\n )}\n <FieldHelperText includeDescription={includeDescription}\n showError={showError}\n error={error}\n disabled={disabled}\n property={property}/>\n\n {url && <Collapse\n className=\"mt-1 ml-1\"\n in={Boolean(value)}>\n <PropertyPreview\n value={value}\n property={property}\n size={size}/>\n </Collapse>}\n\n </>\n );\n\n}\n"],"mappings":";;;;;;;;;;;;;;;AA4BA,SAAgB,iBAA4C,EACI,aACA,OACA,UACA,OACA,WACA,UACA,WACA,UACA,oBACA,WACA,OAAO,WACqC;CACxG,MAAM,EAAE,MAAM,eAAe;CA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sBACA,2BACA,aAAa,QAAQ,8CAA8C,EACvE;aALA;IAWK,SAAS,oBAAC,YAAD;KAAY,QAAA;KAClB,WAAW,IACP,sCACA,aAAa,QACP,mCACA,mDACV;eACC;IACO,CAAA;IACZ,oBAAC,kBAAD;KACI,OAAO;KACG;KACC;KACD;KACV,cAAY;KACZ,WAAW,IACP,uFACA,WACA,QAAQ,cAAc,QACtB,YAAY,gFACZ,aAAa,QAAQ,mCAAmC,EAC5D;IACH,CAAA;IACA,SAAS,OAAO,aACb,oBAAC,OAAD;KACI,WAAU;eACV,oBAAC,YAAD;MAAY,cAAY,EAAE,OAAO;MAAG,SAAS;gBACzC,oBAAC,OAAD,CAAO,CAAA;KACC,CAAA;IACX,CAAA;GAER;OAEL,oBAAC,WAAD;GACU;GACN,OAAO;GACG;GACC;GACJ;GACP,cAAY,QAAQ,KAAA,IAAY;GAChC,MAAM;GACI;GACV,cACI,SAAS,OAAO,aAAa,oBAAC,YAAD;IAAY,cAAY,EAAE,OAAO;IAC1D,SAAS;cACT,oBAAC,OAAD,CAAO,CAAA;GACC,CAAA;GAEhB,OAAO,YAAY,CAAC,CAAC,QAAQ,KAAA;GAC7B,gBAAgB,IAAI,WAAW,SAAS,gCAAgC;EAAG,CAAA;EAEnF,oBAAC,iBAAD;GAAqC;GACT;GACJ;GACG;GACA;EAAU,CAAA;EAEpC,OAAO,oBAAC,UAAD;GACJ,WAAU;GACV,IAAI,QAAQ,KAAK;aACjB,oBAAC,iBAAD;IACW;IACG;IACJ;GAAM,CAAA;EACV,CAAA;CAEZ,EAAA,CAAA;AAGV"}
@@ -1,5 +1,5 @@
1
1
  import type { FieldProps } from "../../types/fields.js";
2
- import type { StringProperty } from "@rebasepro/types";
2
+ import type { StringProperty } from "@rebasepro/cms-types";
3
3
  import React from "react";
4
4
  type UserSelectProps = FieldProps<StringProperty>;
5
5
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"UserSelectFieldBinding.js","names":[],"sources":["../../../src/form/field_bindings/UserSelectFieldBinding.tsx"],"sourcesContent":["import type { FieldProps } from \"../../types/fields\";\nimport type { StringProperty } from \"@rebasepro/types\";\nimport React from \"react\";\n\nimport { FieldHelperText } from \"../components/FieldHelperText\";\nimport { LabelWithIcon } from \"../components/LabelWithIcon\";\nimport { getIconForProperty } from \"../../util/property_utils\";\nimport { UserSelector } from \"../../components/UserSelector\";\n\ntype UserSelectProps = FieldProps<StringProperty>;\n\n/**\n * Field binding for selecting a user from the internal user management system.\n * Renders a searchable popover dropdown with user information including name and email,\n * with server-side search and pagination support.\n *\n * This is one of the internal components that get mapped natively inside forms\n * and tables to the specified properties.\n * @group Form fields\n */\nexport function UserSelectFieldBinding({\n propertyKey,\n value,\n setValue,\n error,\n showError,\n disabled,\n autoFocus,\n touched,\n property,\n includeDescription,\n hideLabel,\n size = \"large\"\n }: UserSelectProps) {\n\n // Passed straight through. Mapping the form's `large` onto the selector's\n // `medium` produced a 56px box next to 48px text fields — the labels lined\n // up and the boxes did not.\n const selectorSize = size;\n\n return (\n <>\n {!hideLabel && <LabelWithIcon\n icon={getIconForProperty(property, \"small\")}\n required={property.validation?.required}\n title={property.name}\n propertyKey={propertyKey}\n className={\"h-8 text-text-secondary dark:text-text-secondary-dark ml-3.5 my-0\"}\n />}\n\n <UserSelector\n value={value as string | null | undefined}\n onValueChange={(userId) => {\n setValue(userId);\n }}\n disabled={disabled}\n clearable={property.admin?.clearable}\n size={selectorSize}\n />\n\n <FieldHelperText includeDescription={includeDescription}\n showError={showError}\n error={error}\n disabled={disabled}\n property={property}/>\n\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAoBA,SAAgB,uBAAuB,EACI,aACA,OACA,UACA,OACA,WACA,UACA,WACA,SACA,UACA,oBACA,WACA,OAAO,WACS;CAKvD,MAAM,eAAe;CAErB,OACI,qBAAA,UAAA,EAAA,UAAA;EACK,CAAC,aAAa,oBAAC,eAAD;GACX,MAAM,mBAAmB,UAAU,OAAO;GAC1C,UAAU,SAAS,YAAY;GAC/B,OAAO,SAAS;GACH;GACb,WAAW;EACd,CAAA;EAED,oBAAC,cAAD;GACW;GACP,gBAAgB,WAAW;IACvB,SAAS,MAAM;GACnB;GACU;GACV,WAAW,SAAS,OAAO;GAC3B,MAAM;EACT,CAAA;EAED,oBAAC,iBAAD;GAAqC;GACT;GACJ;GACG;GACA;EAAU,CAAA;CAEvC,EAAA,CAAA;AAEV"}
1
+ {"version":3,"file":"UserSelectFieldBinding.js","names":[],"sources":["../../../src/form/field_bindings/UserSelectFieldBinding.tsx"],"sourcesContent":["import type { FieldProps } from \"../../types/fields\";\nimport type { StringProperty } from \"@rebasepro/cms-types\";\nimport React from \"react\";\n\nimport { FieldHelperText } from \"../components/FieldHelperText\";\nimport { LabelWithIcon } from \"../components/LabelWithIcon\";\nimport { getIconForProperty } from \"../../util/property_utils\";\nimport { UserSelector } from \"../../components/UserSelector\";\n\ntype UserSelectProps = FieldProps<StringProperty>;\n\n/**\n * Field binding for selecting a user from the internal user management system.\n * Renders a searchable popover dropdown with user information including name and email,\n * with server-side search and pagination support.\n *\n * This is one of the internal components that get mapped natively inside forms\n * and tables to the specified properties.\n * @group Form fields\n */\nexport function UserSelectFieldBinding({\n propertyKey,\n value,\n setValue,\n error,\n showError,\n disabled,\n autoFocus,\n touched,\n property,\n includeDescription,\n hideLabel,\n size = \"large\"\n }: UserSelectProps) {\n\n // Passed straight through. Mapping the form's `large` onto the selector's\n // `medium` produced a 56px box next to 48px text fields — the labels lined\n // up and the boxes did not.\n const selectorSize = size;\n\n return (\n <>\n {!hideLabel && <LabelWithIcon\n icon={getIconForProperty(property, \"small\")}\n required={property.validation?.required}\n title={property.name}\n propertyKey={propertyKey}\n className={\"h-8 text-text-secondary dark:text-text-secondary-dark ml-3.5 my-0\"}\n />}\n\n <UserSelector\n value={value as string | null | undefined}\n onValueChange={(userId) => {\n setValue(userId);\n }}\n disabled={disabled}\n clearable={property.admin?.clearable}\n size={selectorSize}\n />\n\n <FieldHelperText includeDescription={includeDescription}\n showError={showError}\n error={error}\n disabled={disabled}\n property={property}/>\n\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAoBA,SAAgB,uBAAuB,EACI,aACA,OACA,UACA,OACA,WACA,UACA,WACA,SACA,UACA,oBACA,WACA,OAAO,WACS;CAKvD,MAAM,eAAe;CAErB,OACI,qBAAA,UAAA,EAAA,UAAA;EACK,CAAC,aAAa,oBAAC,eAAD;GACX,MAAM,mBAAmB,UAAU,OAAO;GAC1C,UAAU,SAAS,YAAY;GAC/B,OAAO,SAAS;GACH;GACb,WAAW;EACd,CAAA;EAED,oBAAC,cAAD;GACW;GACP,gBAAgB,WAAW;IACvB,SAAS,MAAM;GACnB;GACU;GACV,WAAW,SAAS,OAAO;GAC3B,MAAM;EACT,CAAA;EAED,oBAAC,iBAAD;GAAqC;GACT;GACJ;GACG;GACA;EAAU,CAAA;CAEvC,EAAA,CAAA;AAEV"}
@@ -1,5 +1,5 @@
1
1
  import type { FieldProps } from "../../types/fields.js";
2
- import type { VectorProperty } from "@rebasepro/types";
2
+ import type { VectorProperty } from "@rebasepro/cms-types";
3
3
  import React from "react";
4
4
  /**
5
5
  * Custom field binding to render vector fields (e.g. for high-dimensional embeddings).
@@ -1 +1 @@
1
- {"version":3,"file":"VectorFieldBinding.js","names":[],"sources":["../../../src/form/field_bindings/VectorFieldBinding.tsx"],"sourcesContent":["import { useTranslation } from \"@rebasepro/app\";\nimport type { FieldProps } from \"../../types/fields\";\nimport type { VectorProperty } from \"@rebasepro/types\";\nimport React, { useState, useEffect, useCallback } from \"react\";\nimport {\n Button,\n CheckIcon,\n cls,\n defaultBorderMixin,\n EyeIcon,\n EyeOffIcon,\n IconButton,\n PencilIcon,\n TextField,\n Trash2Icon\n} from \"@rebasepro/ui\";\nimport { FieldHelperText } from \"../components/FieldHelperText\";\nimport { LabelWithIcon } from \"../components/LabelWithIcon\";\nimport { getIconForProperty } from \"../../util/property_utils\";\n\n/**\n * Custom field binding to render vector fields (e.g. for high-dimensional embeddings).\n * Shows a compact metadata card by default, and lets users expand values or edit them.\n *\n * Automatically parses inputs to number arrays and packages them into the canonical\n * Vector object structure expected by Rebase driver.\n * @group Form fields\n */\nexport function VectorFieldBinding({\n propertyKey,\n value,\n setValue,\n error,\n showError,\n disabled,\n autoFocus,\n property,\n includeDescription,\n hideLabel,\n size = \"large\"\n}: FieldProps<VectorProperty>) {\n const { t } = useTranslation();\n const isVectorObject = (val: unknown): val is { value: number[] } => {\n return typeof val === \"object\" && val !== null && \"value\" in val;\n };\n\n // Extract array value from the custom { __type: \"Vector\", value: number[] } wrapper\n const arrayValue = isVectorObject(value)\n ? value.value\n : (Array.isArray(value) ? value : []);\n\n const [textValue, setTextValue] = useState(() => arrayValue.join(\", \"));\n const [isEditing, setIsEditing] = useState(false);\n const [showValues, setShowValues] = useState(false);\n\n useEffect(() => {\n setTextValue(arrayValue.join(\", \"));\n }, [JSON.stringify(arrayValue)]);\n\n const handleClearClick = useCallback((e: React.MouseEvent) => {\n e.stopPropagation();\n e.preventDefault();\n setValue(null);\n setTextValue(\"\");\n }, [setValue]);\n\n const onChange = (event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n const raw = event.target.value;\n setTextValue(raw);\n\n // Parse comma-separated string to number array\n const numbers = raw\n .split(\",\")\n .map(str => str.trim())\n .filter(str => str !== \"\")\n .map(Number);\n\n setValue({\n __type: \"Vector\",\n value: numbers\n });\n };\n\n const label = hideLabel ? null : (\n <LabelWithIcon\n icon={getIconForProperty(property, \"small\")}\n required={property.validation?.required}\n title={property.name ?? propertyKey}\n />\n );\n\n const isPopulated = arrayValue.length > 0;\n\n return (\n <div className=\"flex flex-col gap-2 w-full\">\n {/* Only when there is a label to put in it — an empty row still\n spends its `mb-1` and the column's `gap-2`, and the control ends\n up below the one beside it under a label at the same height. */}\n {label && <div className=\"flex items-center justify-between mb-1\">\n {label}\n </div>}\n\n <div className=\"w-full\">\n {!isEditing ? (\n /* Compact Preview Card */\n <div className={cls(\"flex flex-col gap-3 p-4 rounded-xl border bg-surface-field transition-all duration-200\", defaultBorderMixin)}>\n <div className=\"flex items-center justify-between flex-wrap gap-2\">\n <div className=\"flex items-center gap-2.5\">\n {/* Status Dot */}\n <div className={`w-2.5 h-2.5 rounded-full ${isPopulated ? \"bg-emerald-500 animate-pulse\" : \"bg-surface-300 dark:bg-surface-600\"}`} />\n <span className=\"text-sm font-semibold text-text-primary dark:text-text-primary-dark\">\n {isPopulated ? `${arrayValue.length} Dimensions` : \"Empty Vector\"}\n </span>\n {isPopulated && (\n <span className=\"text-xs text-text-secondary dark:text-text-secondary-dark px-2 py-0.5 rounded-full bg-surface-raised font-medium\">\n Embedding\n </span>\n )}\n </div>\n\n <div className=\"flex items-center gap-2\">\n {isPopulated && (\n <Button\n variant=\"text\"\n size=\"small\"\n onClick={() => setShowValues(!showValues)}\n startIcon={showValues ? <EyeOffIcon size={14} /> : <EyeIcon size={14} />}\n >\n {showValues ? \"Hide values\" : \"Show values\"}\n </Button>\n )}\n {!disabled && (\n <Button\n variant=\"outlined\"\n size=\"small\"\n onClick={() => setIsEditing(true)}\n startIcon={<PencilIcon size={14} />}\n >\n {isPopulated ? \"Edit values\" : \"Add values\"}\n </Button>\n )}\n {isPopulated && !disabled && (\n <IconButton aria-label={t(\"clear\")} size=\"small\" onClick={handleClearClick} className=\"text-text-secondary hover:text-red-500\">\n <Trash2Icon size={14} />\n </IconButton>\n )}\n </div>\n </div>\n\n {/* Collapsible scrollable numbers list */}\n {showValues && isPopulated && (\n <div className=\"mt-1 p-3 rounded-lg bg-surface-well border border-hairline max-h-36 overflow-y-auto font-mono text-[11px] leading-relaxed text-text-secondary dark:text-text-secondary-dark break-all selection:bg-primary/20\">\n {arrayValue.join(\", \")}\n </div>\n )}\n </div>\n ) : (\n /* Editing View: Text Input */\n <div className={cls(\"flex flex-col gap-2 p-4 rounded-xl border bg-surface-field\", defaultBorderMixin)}>\n <TextField\n size={size}\n aria-label={`${property.name ?? propertyKey} vector values`}\n value={textValue}\n onChange={onChange}\n autoFocus={true}\n placeholder={`e.g., 0.15, -0.42, 0.88 (Requires ${property.dimensions} dimensions)`}\n disabled={disabled}\n error={showError ? !!error : undefined}\n inputClassName={error ? \"text-red-500 dark:text-red-600 font-mono text-xs\" : \"font-mono text-xs\"}\n />\n <div className=\"flex justify-end gap-2 mt-2\">\n <Button\n variant=\"outlined\"\n size=\"small\"\n onClick={() => setIsEditing(false)}\n >\n Cancel\n </Button>\n <Button\n variant=\"filled\"\n size=\"small\"\n onClick={() => setIsEditing(false)}\n startIcon={<CheckIcon size={14} />}\n >\n Done\n </Button>\n </div>\n </div>\n )}\n </div>\n\n <FieldHelperText\n includeDescription={includeDescription}\n showError={showError}\n error={error}\n disabled={disabled}\n property={property}\n />\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA4BA,SAAgB,mBAAmB,EAC/B,aACA,OACA,UACA,OACA,WACA,UACA,WACA,UACA,oBACA,WACA,OAAO,WACoB;CAC3B,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,kBAAkB,QAA6C;EACjE,OAAO,OAAO,QAAQ,YAAY,QAAQ,QAAQ,WAAW;CACjE;CAGA,MAAM,aAAa,eAAe,KAAK,IACjC,MAAM,QACL,MAAM,QAAQ,KAAK,IAAI,QAAQ,CAAC;CAEvC,MAAM,CAAC,WAAW,gBAAgB,eAAe,WAAW,KAAK,IAAI,CAAC;CACtE,MAAM,CAAC,WAAW,gBAAgB,SAAS,KAAK;CAChD,MAAM,CAAC,YAAY,iBAAiB,SAAS,KAAK;CAElD,gBAAgB;EACZ,aAAa,WAAW,KAAK,IAAI,CAAC;CACtC,GAAG,CAAC,KAAK,UAAU,UAAU,CAAC,CAAC;CAE/B,MAAM,mBAAmB,aAAa,MAAwB;EAC1D,EAAE,gBAAgB;EAClB,EAAE,eAAe;EACjB,SAAS,IAAI;EACb,aAAa,EAAE;CACnB,GAAG,CAAC,QAAQ,CAAC;CAEb,MAAM,YAAY,UAAqE;EACnF,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CAAA;mBAEjC,cAAc,gBAAgB;QAC3B,CAAA;QAEX,eAAe,CAAC,YACb,oBAAC,YAAD;SAAY,cAAY,EAAE,OAAO;SAAG,MAAK;SAAQ,SAAS;SAAkB,WAAU;mBAClF,oBAAC,YAAD,EAAY,MAAM,GAAK,CAAA;QACf,CAAA;OAEf;QACJ;SAGJ,cAAc,eACX,oBAAC,OAAD;MAAK,WAAU;gBACV,WAAW,KAAK,IAAI;KACpB,CAAA,CAER;SAGL,qBAAC,OAAD;KAAK,WAAW,IAAI,8DAA8D,kBAAkB;eAApG,CACI,oBAAC,WAAD;MACU;MACN,cAAY,GAAG,SAAS,QAAQ,YAAY;MAC5C,OAAO;MACG;MACV,WAAW;MACX,aAAa,qCAAqC,SAAS,WAAW;MAC5D;MACV,OAAO,YAAY,CAAC,CAAC,QAAQ,KAAA;MAC7B,gBAAgB,QAAQ,qDAAqD;KAChF,CAAA,GACD,qBAAC,OAAD;MAAK,WAAU;gBAAf,CACI,oBAAC,QAAD;OACI,SAAQ;OACR,MAAK;OACL,eAAe,aAAa,KAAK;iBACpC;MAEO,CAAA,GACR,oBAAC,QAAD;OACI,SAAQ;OACR,MAAK;OACL,eAAe,aAAa,KAAK;OACjC,WAAW,oBAAC,WAAD,EAAW,MAAM,GAAK,CAAA;iBACpC;MAEO,CAAA,CACP;OACJ;;GAER,CAAA;GAEL,oBAAC,iBAAD;IACwB;IACT;IACJ;IACG;IACA;GACb,CAAA;EACA;;AAEb"}
1
+ {"version":3,"file":"VectorFieldBinding.js","names":[],"sources":["../../../src/form/field_bindings/VectorFieldBinding.tsx"],"sourcesContent":["import { useTranslation } from \"@rebasepro/app\";\nimport type { FieldProps } from \"../../types/fields\";\nimport type { VectorProperty } from \"@rebasepro/cms-types\";\nimport React, { useState, useEffect, useCallback } from \"react\";\nimport {\n Button,\n CheckIcon,\n cls,\n defaultBorderMixin,\n EyeIcon,\n EyeOffIcon,\n IconButton,\n PencilIcon,\n TextField,\n Trash2Icon\n} from \"@rebasepro/ui\";\nimport { FieldHelperText } from \"../components/FieldHelperText\";\nimport { LabelWithIcon } from \"../components/LabelWithIcon\";\nimport { getIconForProperty } from \"../../util/property_utils\";\n\n/**\n * Custom field binding to render vector fields (e.g. for high-dimensional embeddings).\n * Shows a compact metadata card by default, and lets users expand values or edit them.\n *\n * Automatically parses inputs to number arrays and packages them into the canonical\n * Vector object structure expected by Rebase driver.\n * @group Form fields\n */\nexport function VectorFieldBinding({\n propertyKey,\n value,\n setValue,\n error,\n showError,\n disabled,\n autoFocus,\n property,\n includeDescription,\n hideLabel,\n size = \"large\"\n}: FieldProps<VectorProperty>) {\n const { t } = useTranslation();\n const isVectorObject = (val: unknown): val is { value: number[] } => {\n return typeof val === \"object\" && val !== null && \"value\" in val;\n };\n\n // Extract array value from the custom { __type: \"Vector\", value: number[] } wrapper\n const arrayValue = isVectorObject(value)\n ? value.value\n : (Array.isArray(value) ? value : []);\n\n const [textValue, setTextValue] = useState(() => arrayValue.join(\", \"));\n const [isEditing, setIsEditing] = useState(false);\n const [showValues, setShowValues] = useState(false);\n\n useEffect(() => {\n setTextValue(arrayValue.join(\", \"));\n }, [JSON.stringify(arrayValue)]);\n\n const handleClearClick = useCallback((e: React.MouseEvent) => {\n e.stopPropagation();\n e.preventDefault();\n setValue(null);\n setTextValue(\"\");\n }, [setValue]);\n\n const onChange = (event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n const raw = event.target.value;\n setTextValue(raw);\n\n // Parse comma-separated string to number array\n const numbers = raw\n .split(\",\")\n .map(str => str.trim())\n .filter(str => str !== \"\")\n .map(Number);\n\n setValue({\n __type: \"Vector\",\n value: numbers\n });\n };\n\n const label = hideLabel ? null : (\n <LabelWithIcon\n icon={getIconForProperty(property, \"small\")}\n required={property.validation?.required}\n title={property.name ?? propertyKey}\n />\n );\n\n const isPopulated = arrayValue.length > 0;\n\n return (\n <div className=\"flex flex-col gap-2 w-full\">\n {/* Only when there is a label to put in it — an empty row still\n spends its `mb-1` and the column's `gap-2`, and the control ends\n up below the one beside it under a label at the same height. */}\n {label && <div className=\"flex items-center justify-between mb-1\">\n {label}\n </div>}\n\n <div className=\"w-full\">\n {!isEditing ? (\n /* Compact Preview Card */\n <div className={cls(\"flex flex-col gap-3 p-4 rounded-xl border bg-surface-field transition-all duration-200\", defaultBorderMixin)}>\n <div className=\"flex items-center justify-between flex-wrap gap-2\">\n <div className=\"flex items-center gap-2.5\">\n {/* Status Dot */}\n <div className={`w-2.5 h-2.5 rounded-full ${isPopulated ? \"bg-emerald-500 animate-pulse\" : \"bg-surface-300 dark:bg-surface-600\"}`} />\n <span className=\"text-sm font-semibold text-text-primary dark:text-text-primary-dark\">\n {isPopulated ? `${arrayValue.length} Dimensions` : \"Empty Vector\"}\n </span>\n {isPopulated && (\n <span className=\"text-xs text-text-secondary dark:text-text-secondary-dark px-2 py-0.5 rounded-full bg-surface-raised font-medium\">\n Embedding\n </span>\n )}\n </div>\n\n <div className=\"flex items-center gap-2\">\n {isPopulated && (\n <Button\n variant=\"text\"\n size=\"small\"\n onClick={() => setShowValues(!showValues)}\n startIcon={showValues ? <EyeOffIcon size={14} /> : <EyeIcon size={14} />}\n >\n {showValues ? \"Hide values\" : \"Show values\"}\n </Button>\n )}\n {!disabled && (\n <Button\n variant=\"outlined\"\n size=\"small\"\n onClick={() => setIsEditing(true)}\n startIcon={<PencilIcon size={14} />}\n >\n {isPopulated ? \"Edit values\" : \"Add values\"}\n </Button>\n )}\n {isPopulated && !disabled && (\n <IconButton aria-label={t(\"clear\")} size=\"small\" onClick={handleClearClick} className=\"text-text-secondary hover:text-red-500\">\n <Trash2Icon size={14} />\n </IconButton>\n )}\n </div>\n </div>\n\n {/* Collapsible scrollable numbers list */}\n {showValues && isPopulated && (\n <div className=\"mt-1 p-3 rounded-lg bg-surface-well border border-hairline max-h-36 overflow-y-auto font-mono text-[11px] leading-relaxed text-text-secondary dark:text-text-secondary-dark break-all selection:bg-primary/20\">\n {arrayValue.join(\", \")}\n </div>\n )}\n </div>\n ) : (\n /* Editing View: Text Input */\n <div className={cls(\"flex flex-col gap-2 p-4 rounded-xl border bg-surface-field\", defaultBorderMixin)}>\n <TextField\n size={size}\n aria-label={`${property.name ?? propertyKey} vector values`}\n value={textValue}\n onChange={onChange}\n autoFocus={true}\n placeholder={`e.g., 0.15, -0.42, 0.88 (Requires ${property.dimensions} dimensions)`}\n disabled={disabled}\n error={showError ? !!error : undefined}\n inputClassName={error ? \"text-red-500 dark:text-red-600 font-mono text-xs\" : \"font-mono text-xs\"}\n />\n <div className=\"flex justify-end gap-2 mt-2\">\n <Button\n variant=\"outlined\"\n size=\"small\"\n onClick={() => setIsEditing(false)}\n >\n Cancel\n </Button>\n <Button\n variant=\"filled\"\n size=\"small\"\n onClick={() => setIsEditing(false)}\n startIcon={<CheckIcon size={14} />}\n >\n Done\n </Button>\n </div>\n </div>\n )}\n </div>\n\n <FieldHelperText\n includeDescription={includeDescription}\n showError={showError}\n error={error}\n disabled={disabled}\n property={property}\n />\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA4BA,SAAgB,mBAAmB,EAC/B,aACA,OACA,UACA,OACA,WACA,UACA,WACA,UACA,oBACA,WACA,OAAO,WACoB;CAC3B,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,kBAAkB,QAA6C;EACjE,OAAO,OAAO,QAAQ,YAAY,QAAQ,QAAQ,WAAW;CACjE;CAGA,MAAM,aAAa,eAAe,KAAK,IACjC,MAAM,QACL,MAAM,QAAQ,KAAK,IAAI,QAAQ,CAAC;CAEvC,MAAM,CAAC,WAAW,gBAAgB,eAAe,WAAW,KAAK,IAAI,CAAC;CACtE,MAAM,CAAC,WAAW,gBAAgB,SAAS,KAAK;CAChD,MAAM,CAAC,YAAY,iBAAiB,SAAS,KAAK;CAElD,gBAAgB;EACZ,aAAa,WAAW,KAAK,IAAI,CAAC;CACtC,GAAG,CAAC,KAAK,UAAU,UAAU,CAAC,CAAC;CAE/B,MAAM,mBAAmB,a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E,aAAa,gBAAgB;QAC1B,CAAA;QAEX,CAAC,YACE,oBAAC,QAAD;SACI,SAAQ;SACR,MAAK;SACL,eAAe,aAAa,IAAI;SAChC,WAAW,oBAAC,YAAD,EAAY,MAAM,GAAK,CAAA;mBAEjC,cAAc,gBAAgB;QAC3B,CAAA;QAEX,eAAe,CAAC,YACb,oBAAC,YAAD;SAAY,cAAY,EAAE,OAAO;SAAG,MAAK;SAAQ,SAAS;SAAkB,WAAU;mBAClF,oBAAC,YAAD,EAAY,MAAM,GAAK,CAAA;QACf,CAAA;OAEf;QACJ;SAGJ,cAAc,eACX,oBAAC,OAAD;MAAK,WAAU;gBACV,WAAW,KAAK,IAAI;KACpB,CAAA,CAER;SAGL,qBAAC,OAAD;KAAK,WAAW,IAAI,8DAA8D,kBAAkB;eAApG,CACI,oBAAC,WAAD;MACU;MACN,cAAY,GAAG,SAAS,QAAQ,YAAY;MAC5C,OAAO;MACG;MACV,WAAW;MACX,aAAa,qCAAqC,SAAS,WAAW;MAC5D;MACV,OAAO,YAAY,CAAC,CAAC,QAAQ,KAAA;MAC7B,gBAAgB,QAAQ,qDAAqD;KAChF,CAAA,GACD,qBAAC,OAAD;MAAK,WAAU;gBAAf,CACI,oBAAC,QAAD;OACI,SAAQ;OACR,MAAK;OACL,eAAe,aAAa,KAAK;iBACpC;MAEO,CAAA,GACR,oBAAC,QAAD;OACI,SAAQ;OACR,MAAK;OACL,eAAe,aAAa,KAAK;OACjC,WAAW,oBAAC,WAAD,EAAW,MAAM,GAAK,CAAA;iBACpC;MAEO,CAAA,CACP;OACJ;;GAER,CAAA;GAEL,oBAAC,iBAAD;IACwB;IACT;IACJ;IACG;IACA;GACb,CAAA;EACA;;AAEb"}
@@ -1,7 +1,7 @@
1
1
  import type { PropertyConfig, AdminCollection } from "@rebasepro/cms-types";
2
- import type { CollectionConfig, CollectionRegistryController, Entity, EntityStatus, EntityValues } from "@rebasepro/types";
3
- import { EntityRelation } from "@rebasepro/types";
4
- import type { AuthController } from "@rebasepro/cms-types";
2
+ import type { EntityStatus } from "@rebasepro/types";
3
+ import type { AuthController, CollectionRegistryController, CollectionConfig, Entity, EntityValues } from "@rebasepro/cms-types";
4
+ import { EntityRelation } from "@rebasepro/cms-types";
5
5
  import { z } from "zod";
6
6
  export declare function extractTouchedValues(values: unknown, touched: Record<string, boolean>): Record<string, unknown>;
7
7
  /**
@@ -1,7 +1,6 @@
1
1
  import { deepEqual } from "fast-equals";
2
- import { buildConditionContext, evaluateCondition, findRelation, getCopyValues, getDefaultValuesFor, getEntityChildViews, resolveCollectionRelations } from "@rebasepro/common";
2
+ import { EntityRelation, buildConditionContext, evaluateCondition, findRelation, getCopyValues, getDefaultValuesFor, getEntityChildViews, resolveCollectionRelations } from "@rebasepro/cms-types";
3
3
  import { getIn, setIn } from "@rebasepro/forms";
4
- import { EntityRelation } from "@rebasepro/types";
5
4
  import { isPlainObject } from "@rebasepro/utils";
6
5
  //#region src/form/form_utils.ts
7
6
  function extractTouchedValues(values, touched) {
@@ -1 +1 @@
1
- {"version":3,"file":"form_utils.js","names":[],"sources":["../../src/form/form_utils.ts"],"sourcesContent":["\nimport type { PropertyConfig, AdminCollection } from \"@rebasepro/cms-types\";\nimport type { CollectionConfig, CollectionRegistryController, Entity, EntityStatus, EntityValues } from \"@rebasepro/types\";\nimport { EntityRelation } from \"@rebasepro/types\";\nimport type { AuthController } from \"@rebasepro/cms-types\";\nimport { deepEqual as equal } from \"fast-equals\";\nimport { getIn, setIn } from \"@rebasepro/forms\";\nimport {\n buildConditionContext,\n evaluateCondition,\n findRelation,\n getCopyValues,\n getDefaultValuesFor,\n getEntityChildViews,\n resolveCollectionRelations\n} from \"@rebasepro/common\";\nimport { isPlainObject } from \"@rebasepro/utils\";\nimport { z } from \"zod\";\n\n// extract touched values for nested touched trees and map to current values\nexport function extractTouchedValues(values: unknown, touched: Record<string, boolean>): Record<string, unknown> {\n let acc: Record<string, unknown> = {};\n if (!touched || typeof touched !== \"object\") {\n return acc;\n }\n\n Object.entries(touched).forEach(([key, value]) => {\n if (value) {\n acc = setIn(acc, key, getIn(values, key)) as Record<string, unknown>;\n }\n })\n\n return acc;\n}\n\n/**\n * The edit to carry or back up: each top-level property the user touched,\n * **whole** — the same unit a save writes.\n *\n * `extractTouchedValues` builds a tree of only the touched paths, which is a\n * diff, and a diff cannot say \"this item is gone\": a list that shrank from\n * three items to one, or a key-value map with a key deleted, came back whole\n * when the diff was merged onto the stored record. Carrying the property whole\n * and overlaying it (see {@link overlayEdit}) shows exactly what the user left.\n *\n * Which properties count is still decided by the touched tree with its ghost\n * containers removed, so a field merely focused carries nothing.\n */\nexport function getTouchedPropertyValues<M extends Record<string, unknown>>(\n values: Partial<M>,\n touched: Record<string, boolean>\n): Partial<M> {\n const touchedTree = removeEmptyContainers(extractTouchedValues(values, touched ?? {}));\n const result: Record<string, unknown> = {};\n if (!touchedTree || typeof touchedTree !== \"object\") return result as Partial<M>;\n for (const key of Object.keys(touchedTree)) {\n if (Object.prototype.hasOwnProperty.call(values, key)) {\n result[key] = (values as Record<string, unknown>)[key];\n }\n }\n return result as Partial<M>;\n}\n\n/**\n * What a form shows when an edit is laid over `base`: each property the edit\n * carries replaces the base's, whole.\n *\n * Not `mergeDeep`, which merged arrays of maps index by index and kept the base\n * items past the edit's length, and kept map keys the edit had dropped — so a\n * deleted section or key came back when the edit changed layout or a draft was\n * restored, in a form that then read as clean.\n */\nexport function overlayEdit<M extends Record<string, unknown>>(base: Partial<M>, edit: Partial<M>): Partial<M> {\n return { ...base, ...edit };\n}\n\n/**\n * Recursively removes empty plain objects `{}` and empty arrays `[]` from a value tree.\n * This prevents ghost containers created by `setIn` intermediate path construction\n * (e.g. `{ address: {} }` when only `address.city` was touched but value is undefined)\n * from falsely triggering the unsaved local changes indicator.\n */\n/**\n * Check if a value is semantically empty (null, undefined, or empty string).\n */\nfunction isSemanticEmpty(v: unknown): boolean {\n return v === null || v === undefined || v === \"\";\n}\n\nexport function removeEmptyContainers(obj: unknown): unknown {\n if (Array.isArray(obj)) {\n const cleaned = obj.map(removeEmptyContainers);\n // Keep arrays even if they contain only nulls/undefined — that's intentional data\n return cleaned;\n }\n if (obj && typeof obj === \"object\" && Object.getPrototypeOf(obj) === Object.prototype) {\n const result: Record<string, unknown> = {};\n for (const key of Object.keys(obj)) {\n const cleaned = removeEmptyContainers((obj as Record<string, unknown>)[key]);\n // Skip empty plain objects\n if (cleaned && typeof cleaned === \"object\" && !Array.isArray(cleaned)\n && Object.getPrototypeOf(cleaned) === Object.prototype\n && Object.keys(cleaned).length === 0) {\n continue;\n }\n result[key] = cleaned;\n }\n // After cleaning, check if all remaining values are semantically empty\n // (null, undefined, or \"\"). This catches ghost objects like {type: \"\", value: null}\n // created by oneOf block initialization that aren't meaningful changes.\n if (Object.keys(result).length > 0 && Object.values(result).every(isSemanticEmpty)) {\n return {};\n }\n return result;\n }\n return obj;\n}\n\nexport function getChanges<T extends object>(source: Partial<T>, comparison: Partial<T>): Partial<T> {\n const changes: Partial<T> = {};\n\n if (!source) {\n return {};\n }\n if (!comparison) {\n return source;\n }\n\n const allKeys = Array.from(new Set([...Object.keys(source), ...Object.keys(comparison)]));\n\n for (const key of allKeys) {\n const sourceValue = (source as Record<string, unknown>)[key];\n const comparisonValue = (comparison as Record<string, unknown>)[key];\n\n if (equal(sourceValue, comparisonValue)) {\n continue;\n }\n\n const sourceHasKey = source && typeof source === \"object\" && Object.prototype.hasOwnProperty.call(source, key);\n const comparisonHasKey = comparison && typeof comparison === \"object\" && Object.prototype.hasOwnProperty.call(comparison, key);\n\n if (comparisonHasKey && !sourceHasKey) {\n (changes as Record<string, unknown>)[key] = undefined;\n } else if (Array.isArray(sourceValue)) {\n const comparisonArray = Array.isArray(comparisonValue) ? comparisonValue : [];\n if (sourceValue.length !== comparisonArray.length) {\n (changes as Record<string, unknown>)[key] = sourceValue;\n continue;\n }\n const hasChanges = sourceValue.some((item, index) => !equal(item, comparisonArray[index]));\n if (hasChanges) {\n (changes as Record<string, unknown>)[key] = sourceValue;\n }\n } else if (isPlainObject(sourceValue) && isPlainObject(comparisonValue)) {\n // Plain objects only. A `Date` has no keys of its own, so walking\n // into two different dates finds nothing and loses the edit; a\n // class instance (a relation) would come back as a bare `{ id }`\n // that no longer says what it is.\n const nestedChanges = getChanges(sourceValue, comparisonValue);\n if (Object.keys(nestedChanges).length > 0) {\n (changes as Record<string, unknown>)[key] = nestedChanges;\n }\n } else {\n (changes as Record<string, unknown>)[key] = sourceValue;\n }\n }\n\n return changes;\n}\n\n/**\n * What an update of a stored record sends: every top-level property whose value\n * differs from the stored one — whole.\n *\n * Whole, because that is the unit an update replaces. It sets each property it\n * carries, so the value sent *is* the property's new value: a map sent as the\n * one key that changed would erase every key left out, a key-value map with a\n * key removed would arrive empty, and a geopoint with one coordinate moved is\n * refused for lacking the other. {@link getChanges} walks into plain objects to\n * find what changed inside them, which is right for comparing a draft with the\n * form and wrong for a write.\n */\nexport function getChangedProperties<M extends Record<string, unknown>>(\n values: Partial<M>,\n storedValues: Partial<M>\n): Partial<M> {\n const changes: Partial<M> = {};\n const keys = new Set([...Object.keys(values), ...Object.keys(storedValues)]);\n for (const key of keys) {\n if (!equal(values[key], storedValues[key])) {\n (changes as Record<string, unknown>)[key] = values[key];\n }\n }\n return changes;\n}\n\n/**\n * What a create sends: the form's values without the empty ones nobody set.\n *\n * A key the form opened as `null` and still holds as `null` is not a value\n * the user chose. Sent, it is an explicit `NULL`, which beats the column's\n * `DEFAULT` — `published_at timestamptz DEFAULT now()` was created empty from\n * the panel and filled from the API. Left out, the database fills it. A\n * `null` the user set over an opening value (a declared default) is sent, and\n * so is every non-null value, `false` and `[]` included.\n */\nexport function withoutUnsetNulls<M extends Record<string, unknown>>(\n values: M,\n openingValues: Partial<M> | undefined\n): M {\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(values)) {\n const opening = openingValues?.[key];\n if ((value === null || value === undefined) && (opening === null || opening === undefined)) continue;\n result[key] = value;\n }\n return result as M;\n}\n\n/**\n * What the local-changes backup still has to offer, given what the form is\n * already showing — the answer the \"unsaved local changes\" banner is asking for.\n * `undefined` means there is nothing left to apply, and no banner.\n *\n * Measured against what the form *opens showing*, not against the stored\n * record. The banner exists to offer a draft the form is not already displaying,\n * and an edit carried across a change of layout is in both the backup and the\n * form: measuring against the stored values alone offered to restore the values\n * already on screen, over an edit the user had never left.\n */\nexport function getUnappliedLocalChanges<M extends Record<string, unknown>>(\n backupValues: Partial<M>,\n openingValues: Partial<M>\n): Partial<M> | undefined {\n if (!backupValues || typeof backupValues !== \"object\") return undefined;\n // The backup holds whole properties (see `getTouchedPropertyValues`), so\n // each one is compared whole and offered whole: a diff of it could not say\n // that a key was deleted, and `overlayEdit` lays down what it is given as\n // the property's entire value.\n const unapplied: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(backupValues)) {\n if (!equal(value, (openingValues as Record<string, unknown> | undefined)?.[key])) {\n unapplied[key] = value;\n }\n }\n return Object.keys(unapplied).length > 0 ? unapplied as Partial<M> : undefined;\n}\n\n/**\n * What travels when the same record changes layout — the split's \"hide list\",\n * full screen's \"show list\", the side panel's \"open full screen\". One mounted\n * form is replaced by another showing the same record, so the edit in progress\n * has to be handed over; left to the local-changes backup alone, the new form\n * met it as a draft from a closed tab and raised the \"unsaved local changes\"\n * banner over changes the user had made a second earlier and never left.\n *\n * Returns `undefined` when there is nothing to carry, which is its own answer: a\n * record nobody edited must open in the next layout exactly as clean as it was.\n *\n * Only what was edited here travels, keyed by `touched` — the same subset the\n * backup stores. Carrying the whole record instead marks every field touched in\n * the receiving form, which lights up every empty required field as an error and\n * writes the entire record back out as a \"local change\".\n */\nexport function getEditHandoffValues<M extends Record<string, unknown>>({\n status,\n dirty,\n values,\n touched,\n storedValues\n}: {\n status: EntityStatus;\n /** Whether `values` differ from what is stored. */\n dirty: boolean;\n values: Partial<M>;\n touched: Record<string, boolean>;\n /** The stored record, for the fallback below. Absent for a new one. */\n storedValues?: Partial<M>;\n}): Partial<M> | undefined {\n\n if (!values) return undefined;\n\n // A record with nothing stored behind it carries whole: there is no\n // baseline to fall back to, so anything not carried is simply lost.\n if (status === \"new\" || status === \"copy\") {\n return Object.keys(values).length > 0 ? values : undefined;\n }\n\n if (!dirty) return undefined;\n\n const touchedValues = getTouchedPropertyValues(values, touched ?? {});\n if (Object.keys(touchedValues).length > 0) {\n return touchedValues;\n }\n\n // Dirty with nothing touched — a value set programmatically, by a plugin or\n // a custom field that writes through `setFieldValue` without the blur that\n // marks it. Diffing against the stored record still finds it, and dropping\n // it here would hand over a form that opens clean over an edit.\n const changes = getChangedProperties(values, storedValues ?? {});\n return Object.keys(changes).length > 0 ? changes : undefined;\n}\n\n/**\n * A new record's values with each top-level `conditions.defaultValue` applied —\n * the rule evaluated against the declared defaults, as a new record has nothing\n * else yet. Without it the rule was documented, editable in Studio, and never\n * read: a new record opened with the static default.\n */\nfunction withConditionalDefaults<M extends Record<string, unknown>>(\n values: Partial<EntityValues<M>>,\n properties: AdminCollection[\"properties\"],\n path: string,\n authController: AuthController\n): Partial<EntityValues<M>> {\n let result = values;\n for (const [key, property] of Object.entries(properties ?? {})) {\n const rule = property?.conditions?.defaultValue;\n if (rule === undefined) continue;\n const context = buildConditionContext({\n propertyKey: key,\n values: values as Record<string, unknown>,\n path,\n authController\n });\n result = { ...result, [key]: evaluateCondition(rule, context) };\n }\n return result;\n}\n\n/**\n * `alwaysApplyDefaultValues`: a property's declared `defaultValue` fills a\n * stored value that is empty, inside maps too.\n *\n * A Postgres row carries every column, an unset one as `null`, so merging the\n * defaults *under* the row let `null` win and the flag did nothing. `false`,\n * `0` and `\"\"` are values the row holds, and are kept.\n */\nfunction fillDeclaredDefaults(properties: AdminCollection[\"properties\"], values: Record<string, unknown>): Record<string, unknown> {\n const result: Record<string, unknown> = { ...values };\n for (const [key, property] of Object.entries(properties ?? {})) {\n if (!property || typeof property !== \"object\" || !(\"type\" in property)) continue;\n const current = result[key];\n if (current === null || current === undefined) {\n if (property.defaultValue !== undefined && property.defaultValue !== null) {\n result[key] = property.defaultValue;\n }\n } else if (property.type === \"map\" && property.properties && isPlainObject(current)) {\n result[key] = fillDeclaredDefaults(property.properties as AdminCollection[\"properties\"], current as Record<string, unknown>);\n }\n }\n return result;\n}\n\nexport function getInitialEntityValues<M extends Record<string, unknown>>(\n authController: AuthController,\n collection: AdminCollection,\n path: string,\n status: \"new\" | \"existing\" | \"copy\",\n entity: Entity<M> | undefined,\n propertyConfigs?: Record<string, PropertyConfig>\n): Partial<EntityValues<M>> {\n const properties = collection.properties;\n if ((status === \"existing\" || status === \"copy\") && entity) {\n let values: Partial<EntityValues<M>>;\n if (!collection.alwaysApplyDefaultValues) {\n values = entity.values ?? getDefaultValuesFor(properties);\n } else {\n values = fillDeclaredDefaults(properties, entity.values ?? {}) as Partial<EntityValues<M>>;\n }\n // A copy gets its own key, and leaves behind every relation it could\n // only take by re-pointing another row — see `getCopyValues`.\n if (status === \"copy\") {\n return getCopyValues(collection, values);\n }\n return values;\n } else if (status === \"new\") {\n return withConditionalDefaults(getDefaultValuesFor(properties), properties, path, authController);\n } else {\n console.error({\n status,\n entity\n });\n throw new Error(\"Form has not been initialised with the correct parameters\");\n }\n}\n\n/**\n * The link back to the parent that a record created under\n * `parent/{id}/{relation}` takes from its address: `{ customer: <the parent> }`\n * for a transaction created from a customer's Transactions tab.\n *\n * The server already stamps the parent's key onto a create through an owned\n * `hasMany`/`hasOne`, so the address alone decides the link. The form did not\n * know that: it opened the child's `belongsTo` empty, and a required one asked\n * the user to pick the record they had just come from.\n *\n * Empty when the address does not decide a link — a root collection, a\n * many-to-many (that link is a junction row, not a property), a `sourceKey`\n * (the value is a column of the parent row, which the address does not carry),\n * or a child with no `belongsTo` on the relation's foreign key.\n */\nexport function getParentLinkValues(\n registry: Pick<CollectionRegistryController, \"getCollection\" | \"getParentEntityIds\">,\n path: string,\n collection: CollectionConfig\n): Record<string, EntityRelation> {\n // Asked of the registry first: only it knows where a slug ends, and a\n // slashed root slug (`content/de-DE/podcasts`) has no parent at all.\n if (registry.getParentEntityIds(path).length === 0) return {};\n\n const segments = path.split(\"/\").filter(Boolean);\n if (segments.length < 3) return {};\n const relationKey = segments[segments.length - 1];\n const parentId = segments[segments.length - 2];\n const parent = registry.getCollection(segments.slice(0, -2).join(\"/\"));\n if (!parent) return {};\n\n const view = getEntityChildViews(parent).find(v => v.key === relationKey);\n if (view?.source.kind !== \"relation\" || view.source.mode !== \"owned\") return {};\n const link = findRelation(resolveCollectionRelations(parent), view.source.relationKey);\n if (!link || (link.kind !== \"hasMany\" && link.kind !== \"hasOne\") || link.sourceKey) return {};\n\n const childRelations = resolveCollectionRelations(collection);\n for (const [key, property] of Object.entries(collection.properties ?? {})) {\n if (property?.type !== \"relation\") continue;\n const relation = childRelations[key];\n if (relation?.kind === \"belongsTo\" && relation.localKey === link.foreignKeyOnTarget) {\n return { [key]: new EntityRelation(parentId, relation.targetSlug) };\n }\n }\n return {};\n}\n\nexport function zodToFormErrors(zodError: z.ZodError): Record<string, string> {\n let errors: Record<string, string> = {};\n for (const issue of zodError.issues) {\n const path = issue.path.join(\".\");\n if (path && !getIn(errors, path)) {\n errors = setIn(errors, path, issue.message) as Record<string, string>;\n }\n }\n return errors;\n}\n\n/**\n * The fields a server refusal names, as form errors keyed by the property each\n * belongs to: `{ title: \"…\", address: \"…\" }`.\n *\n * The server answers a write it refuses with `details.violations` —\n * `[{ field, code, message }]`, `field` the wire path (`address.city`,\n * `tags[2]`). The form printed the sentence in its footer and marked no\n * field, so a unique 409 or a rule only the server checks left the user\n * hunting for the input. A path is marked on its top-level property, which is\n * the field the form shows; a field the form does not have is left out. The\n * first message for a property wins.\n */\nexport function serverViolationErrors(error: unknown, propertyKeys: readonly string[]): Record<string, string> {\n const errors: Record<string, string> = {};\n if (typeof error !== \"object\" || error === null || !(\"details\" in error)) return errors;\n const details = error.details;\n if (typeof details !== \"object\" || details === null || !(\"violations\" in details)) return errors;\n const violations = details.violations;\n if (!Array.isArray(violations)) return errors;\n for (const violation of violations) {\n if (typeof violation !== \"object\" || violation === null) continue;\n if (!(\"field\" in violation) || !(\"message\" in violation)) continue;\n const { field, message } = violation;\n if (typeof field !== \"string\" || typeof message !== \"string\") continue;\n const property = field.split(/[.[]/)[0];\n if (!propertyKeys.includes(property) || property in errors) continue;\n errors[property] = message;\n }\n return errors;\n}\n"],"mappings":";;;;;;AAoBA,SAAgB,qBAAqB,QAAiB,SAA2D;CAC7G,IAAI,MAA+B,CAAC;CACpC,IAAI,CAAC,WAAW,OAAO,YAAY,UAC/B,OAAO;CAGX,OAAO,QAAQ,OAAO,CAAC,CAAC,SAAS,CAAC,KAAK,WAAW;EAC9C,IAAI,OACA,MAAM,MAAM,KAAK,KAAK,MAAM,QAAQ,GAAG,CAAC;CAEhD,CAAC;CAED,OAAO;AACX;;;;;;;;;;;;;;AAeA,SAAgB,yBACZ,QACA,SACU;CACV,MAAM,cAAc,sBAAsB,qBAAqB,QAAQ,WAAW,CAAC,CAAC,CAAC;CACrF,MAAM,SAAkC,CAAC;CACzC,IAAI,CAAC,eAAe,OAAO,gBAAgB,UAAU,OAAO;CAC5D,KAAK,MAAM,OAAO,OAAO,KAAK,WAAW,GACrC,IAAI,OAAO,UAAU,eAAe,KAAK,QAAQ,GAAG,GAChD,OAAO,OAAQ,OAAmC;CAG1D,OAAO;AACX;;;;;;;;;;AAWA,SAAgB,YAA+C,MAAkB,MAA8B;CAC3G,OAAO;EAAE,GAAG;EAAM,GAAG;CAAK;AAC9B;;;;;;;;;;AAWA,SAAS,gBAAgB,GAAqB;CAC1C,OAAO,MAAM,QAAQ,MAAM,KAAA,KAAa,MAAM;AAClD;AAEA,SAAgB,sBAAsB,KAAuB;CACzD,IAAI,MAAM,QAAQ,GAAG,GAGjB,OAFgB,IAAI,IAAI,qBAEjB;CAEX,IAAI,OAAO,OAAO,QAAQ,YAAY,OAAO,eAAe,GAAG,MAAM,OAAO,WAAW;EACnF,MAAM,SAAkC,CAAC;EACzC,KAAK,MAAM,OAAO,OAAO,KAAK,GAA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AAC,GAAG;EACvE,IAAI,UAAU,SAAS,YAAY;EACnC,MAAM,WAAW,eAAe;EAChC,IAAI,UAAU,SAAS,eAAe,SAAS,aAAa,KAAK,oBAC7D,OAAO,GAAG,MAAM,IAAI,eAAe,UAAU,SAAS,UAAU,EAAE;CAE1E;CACA,OAAO,CAAC;AACZ;AAEA,SAAgB,gBAAgB,UAA8C;CAC1E,IAAI,SAAiC,CAAC;CACtC,KAAK,MAAM,SAAS,SAAS,QAAQ;EACjC,MAAM,OAAO,MAAM,KAAK,KAAK,GAAG;EAChC,IAAI,QAAQ,CAAC,MAAM,QAAQ,IAAI,GAC3B,SAAS,MAAM,QAAQ,MAAM,MAAM,OAAO;CAElD;CACA,OAAO;AACX;;;;;;;;;;;;;AAcA,SAAgB,sBAAsB,OAAgB,cAAyD;CAC3G,MAAM,SAAiC,CAAC;CACxC,IAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,EAAE,aAAa,QAAQ,OAAO;CACjF,MAAM,UAAU,MAAM;CACtB,IAAI,OAAO,YAAY,YAAY,YAAY,QAAQ,EAAE,gBAAgB,UAAU,OAAO;CAC1F,MAAM,aAAa,QAAQ;CAC3B,IAAI,CAAC,MAAM,QAAQ,UAAU,GAAG,OAAO;CACvC,KAAK,MAAM,aAAa,YAAY;EAChC,IAAI,OAAO,cAAc,YAAY,cAAc,MAAM;EACzD,IAAI,EAAE,WAAW,cAAc,EAAE,aAAa,YAAY;EAC1D,MAAM,EAAE,OAAO,YAAY;EAC3B,IAAI,OAAO,UAAU,YAAY,OAAO,YAAY,UAAU;EAC9D,MAAM,WAAW,MAAM,MAAM,MAAM,CAAC,CAAC;EACrC,IAAI,CAAC,aAAa,SAAS,QAAQ,KAAK,YAAY,QAAQ;EAC5D,OAAO,YAAY;CACvB;CACA,OAAO;AACX"}
1
+ {"version":3,"file":"form_utils.js","names":[],"sources":["../../src/form/form_utils.ts"],"sourcesContent":["\nimport type { PropertyConfig, AdminCollection } from \"@rebasepro/cms-types\";\nimport type { EntityStatus } from \"@rebasepro/types\";\nimport type { AuthController, CollectionRegistryController, CollectionConfig, Entity, EntityValues } from \"@rebasepro/cms-types\";\nimport { deepEqual as equal } from \"fast-equals\";\nimport { getIn, setIn } from \"@rebasepro/forms\";\nimport {\n buildConditionContext,\n evaluateCondition,\n getDefaultValuesFor,\n getCopyValues,\n getEntityChildViews,\n findRelation,\n resolveCollectionRelations,\n EntityRelation\n} from \"@rebasepro/cms-types\";\nimport { isPlainObject } from \"@rebasepro/utils\";\nimport { z } from \"zod\";\n\n// extract touched values for nested touched trees and map to current values\nexport function extractTouchedValues(values: unknown, touched: Record<string, boolean>): Record<string, unknown> {\n let acc: Record<string, unknown> = {};\n if (!touched || typeof touched !== \"object\") {\n return acc;\n }\n\n Object.entries(touched).forEach(([key, value]) => {\n if (value) {\n acc = setIn(acc, key, getIn(values, key)) as Record<string, unknown>;\n }\n })\n\n return acc;\n}\n\n/**\n * The edit to carry or back up: each top-level property the user touched,\n * **whole** — the same unit a save writes.\n *\n * `extractTouchedValues` builds a tree of only the touched paths, which is a\n * diff, and a diff cannot say \"this item is gone\": a list that shrank from\n * three items to one, or a key-value map with a key deleted, came back whole\n * when the diff was merged onto the stored record. Carrying the property whole\n * and overlaying it (see {@link overlayEdit}) shows exactly what the user left.\n *\n * Which properties count is still decided by the touched tree with its ghost\n * containers removed, so a field merely focused carries nothing.\n */\nexport function getTouchedPropertyValues<M extends Record<string, unknown>>(\n values: Partial<M>,\n touched: Record<string, boolean>\n): Partial<M> {\n const touchedTree = removeEmptyContainers(extractTouchedValues(values, touched ?? {}));\n const result: Record<string, unknown> = {};\n if (!touchedTree || typeof touchedTree !== \"object\") return result as Partial<M>;\n for (const key of Object.keys(touchedTree)) {\n if (Object.prototype.hasOwnProperty.call(values, key)) {\n result[key] = (values as Record<string, unknown>)[key];\n }\n }\n return result as Partial<M>;\n}\n\n/**\n * What a form shows when an edit is laid over `base`: each property the edit\n * carries replaces the base's, whole.\n *\n * Not `mergeDeep`, which merged arrays of maps index by index and kept the base\n * items past the edit's length, and kept map keys the edit had dropped — so a\n * deleted section or key came back when the edit changed layout or a draft was\n * restored, in a form that then read as clean.\n */\nexport function overlayEdit<M extends Record<string, unknown>>(base: Partial<M>, edit: Partial<M>): Partial<M> {\n return { ...base, ...edit };\n}\n\n/**\n * Recursively removes empty plain objects `{}` and empty arrays `[]` from a value tree.\n * This prevents ghost containers created by `setIn` intermediate path construction\n * (e.g. `{ address: {} }` when only `address.city` was touched but value is undefined)\n * from falsely triggering the unsaved local changes indicator.\n */\n/**\n * Check if a value is semantically empty (null, undefined, or empty string).\n */\nfunction isSemanticEmpty(v: unknown): boolean {\n return v === null || v === undefined || v === \"\";\n}\n\nexport function removeEmptyContainers(obj: unknown): unknown {\n if (Array.isArray(obj)) {\n const cleaned = obj.map(removeEmptyContainers);\n // Keep arrays even if they contain only nulls/undefined — that's intentional data\n return cleaned;\n }\n if (obj && typeof obj === \"object\" && Object.getPrototypeOf(obj) === Object.prototype) {\n const result: Record<string, unknown> = {};\n for (const key of Object.keys(obj)) {\n const cleaned = removeEmptyContainers((obj as Record<string, unknown>)[key]);\n // Skip empty plain objects\n if (cleaned && typeof cleaned === \"object\" && !Array.isArray(cleaned)\n && Object.getPrototypeOf(cleaned) === Object.prototype\n && Object.keys(cleaned).length === 0) {\n continue;\n }\n result[key] = cleaned;\n }\n // After cleaning, check if all remaining values are semantically empty\n // (null, undefined, or \"\"). This catches ghost objects like {type: \"\", value: null}\n // created by oneOf block initialization that aren't meaningful changes.\n if (Object.keys(result).length > 0 && Object.values(result).every(isSemanticEmpty)) {\n return {};\n }\n return result;\n }\n return obj;\n}\n\nexport function getChanges<T extends object>(source: Partial<T>, comparison: Partial<T>): Partial<T> {\n const changes: Partial<T> = {};\n\n if (!source) {\n return {};\n }\n if (!comparison) {\n return source;\n }\n\n const allKeys = Array.from(new Set([...Object.keys(source), ...Object.keys(comparison)]));\n\n for (const key of allKeys) {\n const sourceValue = (source as Record<string, unknown>)[key];\n const comparisonValue = (comparison as Record<string, unknown>)[key];\n\n if (equal(sourceValue, comparisonValue)) {\n continue;\n }\n\n const sourceHasKey = source && typeof source === \"object\" && Object.prototype.hasOwnProperty.call(source, key);\n const comparisonHasKey = comparison && typeof comparison === \"object\" && Object.prototype.hasOwnProperty.call(comparison, key);\n\n if (comparisonHasKey && !sourceHasKey) {\n (changes as Record<string, unknown>)[key] = undefined;\n } else if (Array.isArray(sourceValue)) {\n const comparisonArray = Array.isArray(comparisonValue) ? comparisonValue : [];\n if (sourceValue.length !== comparisonArray.length) {\n (changes as Record<string, unknown>)[key] = sourceValue;\n continue;\n }\n const hasChanges = sourceValue.some((item, index) => !equal(item, comparisonArray[index]));\n if (hasChanges) {\n (changes as Record<string, unknown>)[key] = sourceValue;\n }\n } else if (isPlainObject(sourceValue) && isPlainObject(comparisonValue)) {\n // Plain objects only. A `Date` has no keys of its own, so walking\n // into two different dates finds nothing and loses the edit; a\n // class instance (a relation) would come back as a bare `{ id }`\n // that no longer says what it is.\n const nestedChanges = getChanges(sourceValue, comparisonValue);\n if (Object.keys(nestedChanges).length > 0) {\n (changes as Record<string, unknown>)[key] = nestedChanges;\n }\n } else {\n (changes as Record<string, unknown>)[key] = sourceValue;\n }\n }\n\n return changes;\n}\n\n/**\n * What an update of a stored record sends: every top-level property whose value\n * differs from the stored one — whole.\n *\n * Whole, because that is the unit an update replaces. It sets each property it\n * carries, so the value sent *is* the property's new value: a map sent as the\n * one key that changed would erase every key left out, a key-value map with a\n * key removed would arrive empty, and a geopoint with one coordinate moved is\n * refused for lacking the other. {@link getChanges} walks into plain objects to\n * find what changed inside them, which is right for comparing a draft with the\n * form and wrong for a write.\n */\nexport function getChangedProperties<M extends Record<string, unknown>>(\n values: Partial<M>,\n storedValues: Partial<M>\n): Partial<M> {\n const changes: Partial<M> = {};\n const keys = new Set([...Object.keys(values), ...Object.keys(storedValues)]);\n for (const key of keys) {\n if (!equal(values[key], storedValues[key])) {\n (changes as Record<string, unknown>)[key] = values[key];\n }\n }\n return changes;\n}\n\n/**\n * What a create sends: the form's values without the empty ones nobody set.\n *\n * A key the form opened as `null` and still holds as `null` is not a value\n * the user chose. Sent, it is an explicit `NULL`, which beats the column's\n * `DEFAULT` — `published_at timestamptz DEFAULT now()` was created empty from\n * the panel and filled from the API. Left out, the database fills it. A\n * `null` the user set over an opening value (a declared default) is sent, and\n * so is every non-null value, `false` and `[]` included.\n */\nexport function withoutUnsetNulls<M extends Record<string, unknown>>(\n values: M,\n openingValues: Partial<M> | undefined\n): M {\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(values)) {\n const opening = openingValues?.[key];\n if ((value === null || value === undefined) && (opening === null || opening === undefined)) continue;\n result[key] = value;\n }\n return result as M;\n}\n\n/**\n * What the local-changes backup still has to offer, given what the form is\n * already showing — the answer the \"unsaved local changes\" banner is asking for.\n * `undefined` means there is nothing left to apply, and no banner.\n *\n * Measured against what the form *opens showing*, not against the stored\n * record. The banner exists to offer a draft the form is not already displaying,\n * and an edit carried across a change of layout is in both the backup and the\n * form: measuring against the stored values alone offered to restore the values\n * already on screen, over an edit the user had never left.\n */\nexport function getUnappliedLocalChanges<M extends Record<string, unknown>>(\n backupValues: Partial<M>,\n openingValues: Partial<M>\n): Partial<M> | undefined {\n if (!backupValues || typeof backupValues !== \"object\") return undefined;\n // The backup holds whole properties (see `getTouchedPropertyValues`), so\n // each one is compared whole and offered whole: a diff of it could not say\n // that a key was deleted, and `overlayEdit` lays down what it is given as\n // the property's entire value.\n const unapplied: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(backupValues)) {\n if (!equal(value, (openingValues as Record<string, unknown> | undefined)?.[key])) {\n unapplied[key] = value;\n }\n }\n return Object.keys(unapplied).length > 0 ? unapplied as Partial<M> : undefined;\n}\n\n/**\n * What travels when the same record changes layout — the split's \"hide list\",\n * full screen's \"show list\", the side panel's \"open full screen\". One mounted\n * form is replaced by another showing the same record, so the edit in progress\n * has to be handed over; left to the local-changes backup alone, the new form\n * met it as a draft from a closed tab and raised the \"unsaved local changes\"\n * banner over changes the user had made a second earlier and never left.\n *\n * Returns `undefined` when there is nothing to carry, which is its own answer: a\n * record nobody edited must open in the next layout exactly as clean as it was.\n *\n * Only what was edited here travels, keyed by `touched` — the same subset the\n * backup stores. Carrying the whole record instead marks every field touched in\n * the receiving form, which lights up every empty required field as an error and\n * writes the entire record back out as a \"local change\".\n */\nexport function getEditHandoffValues<M extends Record<string, unknown>>({\n status,\n dirty,\n values,\n touched,\n storedValues\n}: {\n status: EntityStatus;\n /** Whether `values` differ from what is stored. */\n dirty: boolean;\n values: Partial<M>;\n touched: Record<string, boolean>;\n /** The stored record, for the fallback below. Absent for a new one. */\n storedValues?: Partial<M>;\n}): Partial<M> | undefined {\n\n if (!values) return undefined;\n\n // A record with nothing stored behind it carries whole: there is no\n // baseline to fall back to, so anything not carried is simply lost.\n if (status === \"new\" || status === \"copy\") {\n return Object.keys(values).length > 0 ? values : undefined;\n }\n\n if (!dirty) return undefined;\n\n const touchedValues = getTouchedPropertyValues(values, touched ?? {});\n if (Object.keys(touchedValues).length > 0) {\n return touchedValues;\n }\n\n // Dirty with nothing touched — a value set programmatically, by a plugin or\n // a custom field that writes through `setFieldValue` without the blur that\n // marks it. Diffing against the stored record still finds it, and dropping\n // it here would hand over a form that opens clean over an edit.\n const changes = getChangedProperties(values, storedValues ?? {});\n return Object.keys(changes).length > 0 ? changes : undefined;\n}\n\n/**\n * A new record's values with each top-level `conditions.defaultValue` applied —\n * the rule evaluated against the declared defaults, as a new record has nothing\n * else yet. Without it the rule was documented, editable in Studio, and never\n * read: a new record opened with the static default.\n */\nfunction withConditionalDefaults<M extends Record<string, unknown>>(\n values: Partial<EntityValues<M>>,\n properties: AdminCollection[\"properties\"],\n path: string,\n authController: AuthController\n): Partial<EntityValues<M>> {\n let result = values;\n for (const [key, property] of Object.entries(properties ?? {})) {\n const rule = property?.conditions?.defaultValue;\n if (rule === undefined) continue;\n const context = buildConditionContext({\n propertyKey: key,\n values: values as Record<string, unknown>,\n path,\n authController\n });\n result = { ...result, [key]: evaluateCondition(rule, context) };\n }\n return result;\n}\n\n/**\n * `alwaysApplyDefaultValues`: a property's declared `defaultValue` fills a\n * stored value that is empty, inside maps too.\n *\n * A Postgres row carries every column, an unset one as `null`, so merging the\n * defaults *under* the row let `null` win and the flag did nothing. `false`,\n * `0` and `\"\"` are values the row holds, and are kept.\n */\nfunction fillDeclaredDefaults(properties: AdminCollection[\"properties\"], values: Record<string, unknown>): Record<string, unknown> {\n const result: Record<string, unknown> = { ...values };\n for (const [key, property] of Object.entries(properties ?? {})) {\n if (!property || typeof property !== \"object\" || !(\"type\" in property)) continue;\n const current = result[key];\n if (current === null || current === undefined) {\n if (property.defaultValue !== undefined && property.defaultValue !== null) {\n result[key] = property.defaultValue;\n }\n } else if (property.type === \"map\" && property.properties && isPlainObject(current)) {\n result[key] = fillDeclaredDefaults(property.properties as AdminCollection[\"properties\"], current as Record<string, unknown>);\n }\n }\n return result;\n}\n\nexport function getInitialEntityValues<M extends Record<string, unknown>>(\n authController: AuthController,\n collection: AdminCollection,\n path: string,\n status: \"new\" | \"existing\" | \"copy\",\n entity: Entity<M> | undefined,\n propertyConfigs?: Record<string, PropertyConfig>\n): Partial<EntityValues<M>> {\n const properties = collection.properties;\n if ((status === \"existing\" || status === \"copy\") && entity) {\n let values: Partial<EntityValues<M>>;\n if (!collection.alwaysApplyDefaultValues) {\n values = entity.values ?? getDefaultValuesFor(properties);\n } else {\n values = fillDeclaredDefaults(properties, entity.values ?? {}) as Partial<EntityValues<M>>;\n }\n // A copy gets its own key, and leaves behind every relation it could\n // only take by re-pointing another row — see `getCopyValues`.\n if (status === \"copy\") {\n return getCopyValues(collection, values);\n }\n return values;\n } else if (status === \"new\") {\n return withConditionalDefaults(getDefaultValuesFor(properties), properties, path, authController);\n } else {\n console.error({\n status,\n entity\n });\n throw new Error(\"Form has not been initialised with the correct parameters\");\n }\n}\n\n/**\n * The link back to the parent that a record created under\n * `parent/{id}/{relation}` takes from its address: `{ customer: <the parent> }`\n * for a transaction created from a customer's Transactions tab.\n *\n * The server already stamps the parent's key onto a create through an owned\n * `hasMany`/`hasOne`, so the address alone decides the link. The form did not\n * know that: it opened the child's `belongsTo` empty, and a required one asked\n * the user to pick the record they had just come from.\n *\n * Empty when the address does not decide a link — a root collection, a\n * many-to-many (that link is a junction row, not a property), a `sourceKey`\n * (the value is a column of the parent row, which the address does not carry),\n * or a child with no `belongsTo` on the relation's foreign key.\n */\nexport function getParentLinkValues(\n registry: Pick<CollectionRegistryController, \"getCollection\" | \"getParentEntityIds\">,\n path: string,\n collection: CollectionConfig\n): Record<string, EntityRelation> {\n // Asked of the registry first: only it knows where a slug ends, and a\n // slashed root slug (`content/de-DE/podcasts`) has no parent at all.\n if (registry.getParentEntityIds(path).length === 0) return {};\n\n const segments = path.split(\"/\").filter(Boolean);\n if (segments.length < 3) return {};\n const relationKey = segments[segments.length - 1];\n const parentId = segments[segments.length - 2];\n const parent = registry.getCollection(segments.slice(0, -2).join(\"/\"));\n if (!parent) return {};\n\n const view = getEntityChildViews(parent).find(v => v.key === relationKey);\n if (view?.source.kind !== \"relation\" || view.source.mode !== \"owned\") return {};\n const link = findRelation(resolveCollectionRelations(parent), view.source.relationKey);\n if (!link || (link.kind !== \"hasMany\" && link.kind !== \"hasOne\") || link.sourceKey) return {};\n\n const childRelations = resolveCollectionRelations(collection);\n for (const [key, property] of Object.entries(collection.properties ?? {})) {\n if (property?.type !== \"relation\") continue;\n const relation = childRelations[key];\n if (relation?.kind === \"belongsTo\" && relation.localKey === link.foreignKeyOnTarget) {\n return { [key]: new EntityRelation(parentId, relation.targetSlug) };\n }\n }\n return {};\n}\n\nexport function zodToFormErrors(zodError: z.ZodError): Record<string, string> {\n let errors: Record<string, string> = {};\n for (const issue of zodError.issues) {\n const path = issue.path.join(\".\");\n if (path && !getIn(errors, path)) {\n errors = setIn(errors, path, issue.message) as Record<string, string>;\n }\n }\n return errors;\n}\n\n/**\n * The fields a server refusal names, as form errors keyed by the property each\n * belongs to: `{ title: \"…\", address: \"…\" }`.\n *\n * The server answers a write it refuses with `details.violations` —\n * `[{ field, code, message }]`, `field` the wire path (`address.city`,\n * `tags[2]`). The form printed the sentence in its footer and marked no\n * field, so a unique 409 or a rule only the server checks left the user\n * hunting for the input. A path is marked on its top-level property, which is\n * the field the form shows; a field the form does not have is left out. The\n * first message for a property wins.\n */\nexport function serverViolationErrors(error: unknown, propertyKeys: readonly string[]): Record<string, string> {\n const errors: Record<string, string> = {};\n if (typeof error !== \"object\" || error === null || !(\"details\" in error)) return errors;\n const details = error.details;\n if (typeof details !== \"object\" || details === null || !(\"violations\" in details)) return errors;\n const violations = details.violations;\n if (!Array.isArray(violations)) return errors;\n for (const violation of violations) {\n if (typeof violation !== \"object\" || violation === null) continue;\n if (!(\"field\" in violation) || !(\"message\" in violation)) continue;\n const { field, message } = violation;\n if (typeof field !== \"string\" || typeof message !== \"string\") continue;\n const property = field.split(/[.[]/)[0];\n if (!propertyKeys.includes(property) || property in errors) continue;\n errors[property] = message;\n }\n return errors;\n}\n"],"mappings":";;;;;AAoBA,SAAgB,qBAAqB,QAAiB,SAA2D;CAC7G,IAAI,MAA+B,CAAC;CACpC,IAAI,CAAC,WAAW,OAAO,YAAY,UAC/B,OAAO;CAGX,OAAO,QAAQ,OAAO,CAAC,CAAC,SAAS,CAAC,KAAK,WAAW;EAC9C,IAAI,OACA,MAAM,MAAM,KAAK,KAAK,MAAM,QAAQ,GAAG,CAAC;CAEhD,CAAC;CAED,OAAO;AACX;;;;;;;;;;;;;;AAeA,SAAgB,yBACZ,QACA,SACU;CACV,MAAM,cAAc,sBAAsB,qBAAqB,QAAQ,WAAW,CAAC,CAAC,CAAC;CACrF,MAAM,SAAkC,CAAC;CACzC,IAAI,CAAC,eAAe,OAAO,gBAAgB,UAAU,OAAO;CAC5D,KAAK,MAAM,OAAO,OAAO,KAAK,WAAW,GACrC,IAAI,OAAO,UAAU,eAAe,KAAK,QAAQ,GAAG,GACh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;CACvC,KAAK,MAAM,aAAa,YAAY;EAChC,IAAI,OAAO,cAAc,YAAY,cAAc,MAAM;EACzD,IAAI,EAAE,WAAW,cAAc,EAAE,aAAa,YAAY;EAC1D,MAAM,EAAE,OAAO,YAAY;EAC3B,IAAI,OAAO,UAAU,YAAY,OAAO,YAAY,UAAU;EAC9D,MAAM,WAAW,MAAM,MAAM,MAAM,CAAC,CAAC;EACrC,IAAI,CAAC,aAAa,SAAS,QAAQ,KAAK,YAAY,QAAQ;EAC5D,OAAO,YAAY;CACvB;CACA,OAAO;AACX"}
@@ -1,5 +1,4 @@
1
- import type { Property } from "@rebasepro/types";
2
- import type { PropertyConfig } from "@rebasepro/cms-types";
1
+ import type { PropertyConfig, Property } from "@rebasepro/cms-types";
3
2
  /**
4
3
  * Whether the form leaves this property's label to its binding, which draws it
5
4
  * inside the control.
@@ -1 +1 @@
1
- {"version":3,"file":"label_placement.js","names":[],"sources":["../../src/form/label_placement.ts"],"sourcesContent":["import type { Property } from \"@rebasepro/types\";\nimport type { PropertyConfig } from \"@rebasepro/cms-types\";\nimport { isReadOnly } from \"@rebasepro/app\";\nimport { getFieldId } from \"../components/field_ids\";\n\n/**\n * Where a record-form field's label goes: inside its own box, or above it.\n *\n * A one-line control carries its label inside, the way FireCMS draws a field:\n * a filled box, the label shrunk into its top edge, the value under it. Text,\n * numbers, dates, switches and single selects are all one line, so they come\n * out the same height, and two of them paired on a row line up box to box.\n *\n * Everything else keeps the label above, drawn by `FieldBlock`: a multi-select\n * (its chips wrap onto more lines, and a label sitting on the first of them\n * reads as one more chip), uploads, markdown, relations and references, and the\n * panel editors, which carry a header of their own.\n *\n * Not exported from the package. Which editor draws its label where is the\n * form's own decision, and it has to stay in step with the bindings: the ones\n * listed here render their label inside when the form does not set\n * `hideLabel`.\n */\nconst LABEL_INSIDE_FIELDS: ReadonlySet<string> = new Set([\n \"text_field\",\n \"multiline\",\n \"url\",\n \"email\",\n \"number_input\",\n \"select\",\n \"number_select\",\n \"date_time\",\n \"switch\"\n]);\n\n/**\n * Whether the form leaves this property's label to its binding, which draws it\n * inside the control.\n *\n * Decided from the declared property, as `isSelfLabellingProperty` is. Anything\n * the form cannot vouch for keeps the label above, where `FieldBlock` draws it\n * whatever the editor renders: a custom `admin.Field`, a custom property config,\n * and a built-in editor a plugin has replaced through `propertyConfigs`.\n */\nexport function labelsInsideControl(\n property: Property,\n propertyConfigs?: Record<string, PropertyConfig>\n): boolean {\n if (property.admin?.Field) return false;\n if (isReadOnly(property)) return readOnlyLabelsInside(property);\n const fieldId = getFieldId(property);\n if (!fieldId || !LABEL_INSIDE_FIELDS.has(fieldId)) return false;\n if (propertyConfigs?.[fieldId]?.property.admin?.Field) return false;\n return true;\n}\n\n/**\n * Whether a read-only value is one line, and so drawn like the one-line fields\n * around it: a box of the same height with the label inside.\n *\n * Read-only properties are rendered by `ReadOnlyFieldBinding` whatever their\n * type, so this asks of the value what `LABEL_INSIDE_FIELDS` asks of the\n * editor. A computed subtotal paired with an editable tax amount is the case it\n * exists for — with the label above, its box sat a label's height lower than\n * the one beside it.\n */\nexport function readOnlyLabelsInside(property: Property): boolean {\n switch (property.type) {\n case \"number\":\n case \"date\":\n return true;\n case \"string\":\n return !property.admin?.markdown\n && !property.admin?.multiline\n && !property.storage;\n default:\n return false;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAuBA,IAAM,sCAA2C,IAAI,IAAI;CACrD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACJ,CAAC;;;;;;;;;;AAWD,SAAgB,oBACZ,UACA,iBACO;CACP,IAAI,SAAS,OAAO,OAAO,OAAO;CAClC,IAAI,WAAW,QAAQ,GAAG,OAAO,qBAAqB,QAAQ;CAC9D,MAAM,UAAU,WAAW,QAAQ;CACnC,IAAI,CAAC,WAAW,CAAC,oBAAoB,IAAI,OAAO,GAAG,OAAO;CAC1D,IAAI,kBAAkB,QAAQ,EAAE,SAAS,OAAO,OAAO,OAAO;CAC9D,OAAO;AACX;;;;;;;;;;;AAYA,SAAgB,qBAAqB,UAA6B;CAC9D,QAAQ,SAAS,MAAjB;EACI,KAAK;EACL,KAAK,QACD,OAAO;EACX,KAAK,UACD,OAAO,CAAC,SAAS,OAAO,YACjB,CAAC,SAAS,OAAO,aACjB,CAAC,SAAS;EACrB,SACI,OAAO;CACf;AACJ"}
1
+ {"version":3,"file":"label_placement.js","names":[],"sources":["../../src/form/label_placement.ts"],"sourcesContent":["import type { PropertyConfig, Property } from \"@rebasepro/cms-types\";\nimport { isReadOnly } from \"@rebasepro/app\";\nimport { getFieldId } from \"../components/field_ids\";\n\n/**\n * Where a record-form field's label goes: inside its own box, or above it.\n *\n * A one-line control carries its label inside, the way FireCMS draws a field:\n * a filled box, the label shrunk into its top edge, the value under it. Text,\n * numbers, dates, switches and single selects are all one line, so they come\n * out the same height, and two of them paired on a row line up box to box.\n *\n * Everything else keeps the label above, drawn by `FieldBlock`: a multi-select\n * (its chips wrap onto more lines, and a label sitting on the first of them\n * reads as one more chip), uploads, markdown, relations and references, and the\n * panel editors, which carry a header of their own.\n *\n * Not exported from the package. Which editor draws its label where is the\n * form's own decision, and it has to stay in step with the bindings: the ones\n * listed here render their label inside when the form does not set\n * `hideLabel`.\n */\nconst LABEL_INSIDE_FIELDS: ReadonlySet<string> = new Set([\n \"text_field\",\n \"multiline\",\n \"url\",\n \"email\",\n \"number_input\",\n \"select\",\n \"number_select\",\n \"date_time\",\n \"switch\"\n]);\n\n/**\n * Whether the form leaves this property's label to its binding, which draws it\n * inside the control.\n *\n * Decided from the declared property, as `isSelfLabellingProperty` is. Anything\n * the form cannot vouch for keeps the label above, where `FieldBlock` draws it\n * whatever the editor renders: a custom `admin.Field`, a custom property config,\n * and a built-in editor a plugin has replaced through `propertyConfigs`.\n */\nexport function labelsInsideControl(\n property: Property,\n propertyConfigs?: Record<string, PropertyConfig>\n): boolean {\n if (property.admin?.Field) return false;\n if (isReadOnly(property)) return readOnlyLabelsInside(property);\n const fieldId = getFieldId(property);\n if (!fieldId || !LABEL_INSIDE_FIELDS.has(fieldId)) return false;\n if (propertyConfigs?.[fieldId]?.property.admin?.Field) return false;\n return true;\n}\n\n/**\n * Whether a read-only value is one line, and so drawn like the one-line fields\n * around it: a box of the same height with the label inside.\n *\n * Read-only properties are rendered by `ReadOnlyFieldBinding` whatever their\n * type, so this asks of the value what `LABEL_INSIDE_FIELDS` asks of the\n * editor. A computed subtotal paired with an editable tax amount is the case it\n * exists for — with the label above, its box sat a label's height lower than\n * the one beside it.\n */\nexport function readOnlyLabelsInside(property: Property): boolean {\n switch (property.type) {\n case \"number\":\n case \"date\":\n return true;\n case \"string\":\n return !property.admin?.markdown\n && !property.admin?.multiline\n && !property.storage;\n default:\n return false;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAsBA,IAAM,sCAA2C,IAAI,IAAI;CACrD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACJ,CAAC;;;;;;;;;;AAWD,SAAgB,oBACZ,UACA,iBACO;CACP,IAAI,SAAS,OAAO,OAAO,OAAO;CAClC,IAAI,WAAW,QAAQ,GAAG,OAAO,qBAAqB,QAAQ;CAC9D,MAAM,UAAU,WAAW,QAAQ;CACnC,IAAI,CAAC,WAAW,CAAC,oBAAoB,IAAI,OAAO,GAAG,OAAO;CAC1D,IAAI,kBAAkB,QAAQ,EAAE,SAAS,OAAO,OAAO,OAAO;CAC9D,OAAO;AACX;;;;;;;;;;;AAYA,SAAgB,qBAAqB,UAA6B;CAC9D,QAAQ,SAAS,MAAjB;EACI,KAAK;EACL,KAAK,QACD,OAAO;EACX,KAAK,UACD,OAAO,CAAC,SAAS,OAAO,YACjB,CAAC,SAAS,OAAO,aACjB,CAAC,SAAS;EACrB,SACI,OAAO;CACf;AACJ"}
@@ -1,5 +1,4 @@
1
- import type { AuthController, PropertyConfig } from "@rebasepro/cms-types";
2
- import type { Entity, Properties, Property } from "@rebasepro/types";
1
+ import type { AuthController, PropertyConfig, Properties, Property, Entity } from "@rebasepro/cms-types";
3
2
  /**
4
3
  * The table's two editors — the inline cell and the popup — judged a value
5
4
  * against the raw declaration, as the record form once did: a `dynamicProps`
@@ -1,5 +1,5 @@
1
1
  import { resolveFormProperty, resolvePropertiesForValidation } from "./resolve_form_properties.js";
2
- import { isPropertyBuilder } from "@rebasepro/common";
2
+ import { isPropertyBuilder } from "@rebasepro/cms-types";
3
3
  //#region src/form/resolve_cell_property.ts
4
4
  /**
5
5
  * Resolved per row, and held as long as the row object is: a column of plain
@@ -1 +1 @@
1
- {"version":3,"file":"resolve_cell_property.js","names":[],"sources":["../../src/form/resolve_cell_property.ts"],"sourcesContent":["import type { AuthController, PropertyConfig } from \"@rebasepro/cms-types\";\nimport type { Entity, Properties, Property } from \"@rebasepro/types\";\nimport { isPropertyBuilder } from \"@rebasepro/common\";\nimport { resolveFormProperty, resolvePropertiesForValidation } from \"./resolve_form_properties\";\n\n/**\n * The table's two editors — the inline cell and the popup — judged a value\n * against the raw declaration, as the record form once did: a `dynamicProps`\n * validation or a `conditions` rule (`disabled`, `min`, `required`…) applied\n * in the form and nowhere in the table. These resolve a cell's property\n * against its own row, with the record form's {@link resolveFormProperty}.\n */\nexport interface CellResolutionContext {\n path: string;\n authController: AuthController;\n propertyConfigs?: Record<string, PropertyConfig>;\n}\n\n/**\n * Resolved per row, and held as long as the row object is: a column of plain\n * properties keeps its property object (and so its cached schema and its\n * memoised cells); only a builder or a property with `conditions` is resolved,\n * once per row value.\n */\nconst resolvedByRow = new WeakMap<object, Map<string, { raw: Property; resolved: Property | null }>>();\n\nexport function resolveCellProperty(\n property: Property,\n propertyKey: string,\n entity: Entity<Record<string, unknown>>,\n context: CellResolutionContext\n): Property | null {\n if (!isPropertyBuilder(property) && !property.conditions) return property;\n const rowKey: object = entity.values ?? entity;\n let byKey = resolvedByRow.get(rowKey);\n if (!byKey) {\n byKey = new Map();\n resolvedByRow.set(rowKey, byKey);\n }\n const cached = byKey.get(propertyKey);\n if (cached && cached.raw === property) return cached.resolved;\n const resolved = resolveFormProperty({\n property,\n propertyKey,\n values: entity.values,\n previousValues: entity.values,\n path: context.path,\n entityId: entity.id,\n propertyConfigs: context.propertyConfigs,\n authController: context.authController,\n ignoreMissingFields: true\n });\n byKey.set(propertyKey, { raw: property, resolved });\n return resolved;\n}\n\n/**\n * The properties that judge one cell: the property at `propertyKey`, under the\n * maps its key goes through, and nothing beside it.\n *\n * A spread map's child is `address.street`, a path into `properties` rather\n * than a key of it; looked up as a key it found nothing, and the popup\n * validated nothing. The maps on the way carry only the edited child and none\n * of their own rules: the popup shows one field, and an error anywhere else\n * would block the save where no one could see it.\n */\nexport function propertiesOfCell(properties: Properties, propertyKey: string): Properties {\n if (propertyKey in properties) return { [propertyKey]: properties[propertyKey] };\n const dot = propertyKey.indexOf(\".\");\n if (dot === -1) return {};\n const mapKey = propertyKey.slice(0, dot);\n const map = properties[mapKey];\n if (map?.type !== \"map\" || !map.properties) return {};\n const children = propertiesOfCell(map.properties, propertyKey.slice(dot + 1));\n return Object.keys(children).length > 0\n ? { [mapKey]: { type: \"map\", properties: children } }\n : {};\n}\n\n/**\n * The properties that judge a form showing only `keys`: each key's property as\n * {@link propertiesOfCell} cuts it, two children of one map under one map.\n */\nexport function propertiesOfFields(properties: Properties, keys: Iterable<string>): Properties {\n let result: Properties = {};\n for (const key of keys) result = mergeProperties(result, propertiesOfCell(properties, key));\n return result;\n}\n\nfunction mergeProperties(a: Properties, b: Properties): Properties {\n const merged: Properties = { ...a };\n for (const [key, property] of Object.entries(b)) {\n const existing = merged[key];\n merged[key] = existing?.type === \"map\" && property.type === \"map\" && existing !== property\n ? { ...existing, ...property, properties: mergeProperties(existing.properties ?? {}, property.properties ?? {}) }\n : property;\n }\n return merged;\n}\n\n/**\n * What the popup judges a cell by, given the values it holds now: the\n * collection's properties resolved as the record form resolves them on submit\n * (so a field a rule hides or disables is not judged), cut to the cell.\n */\nexport function cellValidationProperties<M extends Record<string, unknown>>(\n properties: Properties,\n propertyKey: string,\n values: Partial<M>,\n previousValues: Partial<M> | undefined,\n entityId: string | number | undefined,\n context: CellResolutionContext\n): Properties {\n const resolved = resolvePropertiesForValidation<M>({\n properties,\n values,\n previousValues,\n path: context.path,\n entityId,\n propertyConfigs: context.propertyConfigs,\n authController: context.authController\n });\n return propertiesOfCell(resolved, propertyKey);\n}\n"],"mappings":";;;;;;;;;AAwBA,IAAM,gCAAgB,IAAI,QAA2E;AAErG,SAAgB,oBACZ,UACA,aACA,QACA,SACe;CACf,IAAI,CAAC,kBAAkB,QAAQ,KAAK,CAAC,SAAS,YAAY,OAAO;CACjE,MAAM,SAAiB,OAAO,UAAU;CACxC,IAAI,QAAQ,cAAc,IAAI,MAAM;CACpC,IAAI,CAAC,OAAO;EACR,wBAAQ,IAAI,IAAI;EAChB,cAAc,IAAI,QAAQ,KAAK;CACnC;CACA,MAAM,SAAS,MAAM,IAAI,WAAW;CACpC,IAAI,UAAU,OAAO,QAAQ,UAAU,OAAO,OAAO;CACrD,MAAM,WAAW,oBAAoB;EACjC;EACA;EACA,QAAQ,OAAO;EACf,gBAAgB,OAAO;EACvB,MAAM,QAAQ;EACd,UAAU,OAAO;EACjB,iBAAiB,QAAQ;EACzB,gBAAgB,QAAQ;EACxB,qBAAqB;CACzB,CAAC;CACD,MAAM,IAAI,aAAa;EAAE,KAAK;EAAU;CAAS,CAAC;CAClD,OAAO;AACX;;;;;;;;;;;AAYA,SAAgB,iBAAiB,YAAwB,aAAiC;CACtF,IAAI,eAAe,YAAY,OAAO,GAAG,cAAc,WAAW,aAAa;CAC/E,MAAM,MAAM,YAAY,QAAQ,GAAG;CACnC,IAAI,QAAQ,IAAI,OAAO,CAAC;CACxB,MAAM,SAAS,YAAY,MAAM,GAAG,GAAG;CACvC,MAAM,MAAM,WAAW;CACvB,IAAI,KAAK,SAAS,SAAS,CAAC,IAAI,YAAY,OAAO,CAAC;CACpD,MAAM,WAAW,iBAAiB,IAAI,YAAY,YAAY,MAAM,MAAM,CAAC,CAAC;CAC5E,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,SAAS,IAChC,GAAG,SAAS;EAAE,MAAM;EAAO,YAAY;CAAS,EAAE,IAClD,CAAC;AACX;;;;;AAMA,SAAgB,mBAAmB,YAAwB,MAAoC;CAC3F,IAAI,SAAqB,CAAC;CAC1B,KAAK,MAAM,OAAO,MAAM,SAAS,gBAAgB,QAAQ,iBAAiB,YAAY,GAAG,CAAC;CAC1F,OAAO;AACX;AAEA,SAAS,gBAAgB,GAAe,GAA2B;CAC/D,MAAM,SAAqB,EAAE,GAAG,EAAE;CAClC,KAAK,MAAM,CAAC,KAAK,aAAa,OAAO,QAAQ,CAAC,GAAG;EAC7C,MAAM,WAAW,OAAO;EACxB,OAAO,OAAO,UAAU,SAAS,SAAS,SAAS,SAAS,SAAS,aAAa,WAC5E;GAAE,GAAG;GAAU,GAAG;GAAU,YAAY,gBAAgB,SAAS,cAAc,CAAC,GAAG,SAAS,cAAc,CAAC,CAAC;EAAE,IAC9G;CACV;CACA,OAAO;AACX;;;;;;AAOA,SAAgB,yBACZ,YACA,aACA,QACA,gBACA,UACA,SACU;CAUV,OAAO,iBATU,+BAAkC;EAC/C;EACA;EACA;EACA,MAAM,QAAQ;EACd;EACA,iBAAiB,QAAQ;EACzB,gBAAgB,QAAQ;CAC5B,CACwB,GAAU,WAAW;AACjD"}
1
+ {"version":3,"file":"resolve_cell_property.js","names":[],"sources":["../../src/form/resolve_cell_property.ts"],"sourcesContent":["import type { AuthController, PropertyConfig, Properties, Property, Entity } from \"@rebasepro/cms-types\";\nimport { isPropertyBuilder } from \"@rebasepro/cms-types\";\nimport { resolveFormProperty, resolvePropertiesForValidation } from \"./resolve_form_properties\";\n\n/**\n * The table's two editors — the inline cell and the popup — judged a value\n * against the raw declaration, as the record form once did: a `dynamicProps`\n * validation or a `conditions` rule (`disabled`, `min`, `required`…) applied\n * in the form and nowhere in the table. These resolve a cell's property\n * against its own row, with the record form's {@link resolveFormProperty}.\n */\nexport interface CellResolutionContext {\n path: string;\n authController: AuthController;\n propertyConfigs?: Record<string, PropertyConfig>;\n}\n\n/**\n * Resolved per row, and held as long as the row object is: a column of plain\n * properties keeps its property object (and so its cached schema and its\n * memoised cells); only a builder or a property with `conditions` is resolved,\n * once per row value.\n */\nconst resolvedByRow = new WeakMap<object, Map<string, { raw: Property; resolved: Property | null }>>();\n\nexport function resolveCellProperty(\n property: Property,\n propertyKey: string,\n entity: Entity<Record<string, unknown>>,\n context: CellResolutionContext\n): Property | null {\n if (!isPropertyBuilder(property) && !property.conditions) return property;\n const rowKey: object = entity.values ?? entity;\n let byKey = resolvedByRow.get(rowKey);\n if (!byKey) {\n byKey = new Map();\n resolvedByRow.set(rowKey, byKey);\n }\n const cached = byKey.get(propertyKey);\n if (cached && cached.raw === property) return cached.resolved;\n const resolved = resolveFormProperty({\n property,\n propertyKey,\n values: entity.values,\n previousValues: entity.values,\n path: context.path,\n entityId: entity.id,\n propertyConfigs: context.propertyConfigs,\n authController: context.authController,\n ignoreMissingFields: true\n });\n byKey.set(propertyKey, { raw: property, resolved });\n return resolved;\n}\n\n/**\n * The properties that judge one cell: the property at `propertyKey`, under the\n * maps its key goes through, and nothing beside it.\n *\n * A spread map's child is `address.street`, a path into `properties` rather\n * than a key of it; looked up as a key it found nothing, and the popup\n * validated nothing. The maps on the way carry only the edited child and none\n * of their own rules: the popup shows one field, and an error anywhere else\n * would block the save where no one could see it.\n */\nexport function propertiesOfCell(properties: Properties, propertyKey: string): Properties {\n if (propertyKey in properties) return { [propertyKey]: properties[propertyKey] };\n const dot = propertyKey.indexOf(\".\");\n if (dot === -1) return {};\n const mapKey = propertyKey.slice(0, dot);\n const map = properties[mapKey];\n if (map?.type !== \"map\" || !map.properties) return {};\n const children = propertiesOfCell(map.properties, propertyKey.slice(dot + 1));\n return Object.keys(children).length > 0\n ? { [mapKey]: { type: \"map\", properties: children } }\n : {};\n}\n\n/**\n * The properties that judge a form showing only `keys`: each key's property as\n * {@link propertiesOfCell} cuts it, two children of one map under one map.\n */\nexport function propertiesOfFields(properties: Properties, keys: Iterable<string>): Properties {\n let result: Properties = {};\n for (const key of keys) result = mergeProperties(result, propertiesOfCell(properties, key));\n return result;\n}\n\nfunction mergeProperties(a: Properties, b: Properties): Properties {\n const merged: Properties = { ...a };\n for (const [key, property] of Object.entries(b)) {\n const existing = merged[key];\n merged[key] = existing?.type === \"map\" && property.type === \"map\" && existing !== property\n ? { ...existing, ...property, properties: mergeProperties(existing.properties ?? {}, property.properties ?? {}) }\n : property;\n }\n return merged;\n}\n\n/**\n * What the popup judges a cell by, given the values it holds now: the\n * collection's properties resolved as the record form resolves them on submit\n * (so a field a rule hides or disables is not judged), cut to the cell.\n */\nexport function cellValidationProperties<M extends Record<string, unknown>>(\n properties: Properties,\n propertyKey: string,\n values: Partial<M>,\n previousValues: Partial<M> | undefined,\n entityId: string | number | undefined,\n context: CellResolutionContext\n): Properties {\n const resolved = resolvePropertiesForValidation<M>({\n properties,\n values,\n previousValues,\n path: context.path,\n entityId,\n propertyConfigs: context.propertyConfigs,\n authController: context.authController\n });\n return propertiesOfCell(resolved, propertyKey);\n}\n"],"mappings":";;;;;;;;;AAuBA,IAAM,gCAAgB,IAAI,QAA2E;AAErG,SAAgB,oBACZ,UACA,aACA,QACA,SACe;CACf,IAAI,CAAC,kBAAkB,QAAQ,KAAK,CAAC,SAAS,YAAY,OAAO;CACjE,MAAM,SAAiB,OAAO,UAAU;CACxC,IAAI,QAAQ,cAAc,IAAI,MAAM;CACpC,IAAI,CAAC,OAAO;EACR,wBAAQ,IAAI,IAAI;EAChB,cAAc,IAAI,QAAQ,KAAK;CACnC;CACA,MAAM,SAAS,MAAM,IAAI,WAAW;CACpC,IAAI,UAAU,OAAO,QAAQ,UAAU,OAAO,OAAO;CACrD,MAAM,WAAW,oBAAoB;EACjC;EACA;EACA,QAAQ,OAAO;EACf,gBAAgB,OAAO;EACvB,MAAM,QAAQ;EACd,UAAU,OAAO;EACjB,iBAAiB,QAAQ;EACzB,gBAAgB,Q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