@rebasepro/cms 0.30.1 → 0.31.0-canary.g902a0ce

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":"TableStorageUpload.js","names":[],"sources":["../../../../src/components/CollectionTableBinding/fields/TableStorageUpload.tsx"],"sourcesContent":["import type { ArrayProperty, StringProperty } from \"@rebasepro/types\";\nimport * as React from \"react\";\nimport { useMemo } from \"react\";\n\nimport { Entity, StorageConfig } from \"@rebasepro/types\";\nimport { PreviewSize } from \"../../../types\";\nimport { useDropzone } from \"react-dropzone\";\nimport { PropertyPreview } from \"../../../preview\";\nimport { ErrorBoundary } from \"@rebasepro/ui\";\nimport { cls, IconButton, PencilIcon, Typography } from \"@rebasepro/ui\";\nimport { useSnackbarController, useStorageSource, useTranslation, StorageFieldItem, useStorageUploadController, StorageSourceContext } from \"@rebasepro/app\";\nimport { getThumbnailMeasure } from \"../../../preview/util\";\nimport { StorageUploadProgress } from \"../../../form/components/StorageUploadProgress\";\nimport { useCollectionRegistryController } from \"../../../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { EntityTableCellActions } from \"../internal/EntityTableCellActions\";\n\nconst dropZoneClasses = \"max-w-full box-border relative pt-[2px] items-center border border-transparent outline-hidden rounded-md duration-200 ease-[cubic-bezier(0.4,0,0.2,1)] focus:border-primary\";\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 bg-green-50 dark:bg-green-900\"\nconst rejectDropClasses = \"transition-colors duration-200 ease-[cubic-bezier(0,0,0.2,1)] border-2 border-solid border-red-500 bg-red-50 dark:bg-red-900\"\n\n/**\n * Field that allows to upload files to Google Cloud Storage.\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 TableStorageUpload(props: {\n propertyKey: string;\n error: Error | undefined;\n disabled: boolean;\n value: string | string[] | null;\n updateValue: (newValue: (string | string[] | null)) => void;\n selected: boolean;\n focused: boolean;\n property: StringProperty | ArrayProperty;\n entity: Entity<Record<string, unknown>>;\n path: string;\n previewSize: PreviewSize;\n openPopup?: (cellRect?: DOMRect) => void;\n onBlur?: React.FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;\n}) {\n\n const {\n propertyKey,\n error,\n selected,\n openPopup,\n value,\n disabled,\n property,\n entity,\n path,\n previewSize,\n updateValue\n } = props;\n\n const storageSource = useStorageSource();\n const collectionSlug = useCollectionRegistryController().getCollection(path)?.slug;\n\n const {\n internalValue,\n setInternalValue,\n onFilesAdded,\n storage,\n onFileUploadComplete,\n storagePathBuilder,\n multipleFilesSupported,\n resolvedStorageSource\n } = useStorageUploadController({\n entityValues: entity.values,\n entityId: entity.id,\n path,\n collectionSlug,\n property: property as StringProperty,\n propertyKey,\n storageSource,\n onChange: updateValue,\n value,\n disabled\n });\n\n return (\n\n <StorageSourceContext.Provider value={resolvedStorageSource}>\n <StorageUpload\n internalValue={internalValue}\n setInternalValue={setInternalValue}\n name={propertyKey}\n disabled={disabled}\n autoFocus={false}\n openPopup={openPopup}\n error={error}\n selected={selected}\n property={property}\n onChange={updateValue}\n entity={entity}\n storagePathBuilder={storagePathBuilder}\n storage={storage}\n multipleFilesSupported={multipleFilesSupported}\n onFilesAdded={onFilesAdded}\n onFileUploadComplete={onFileUploadComplete}\n previewSize={previewSize}/>\n </StorageSourceContext.Provider>\n\n );\n}\n\ninterface StorageUploadProps {\n internalValue: StorageFieldItem[];\n setInternalValue: (v: StorageFieldItem[]) => void;\n name: string;\n error?: Error;\n property: StringProperty | ArrayProperty;\n onChange: (value: string | string[] | null) => void;\n multipleFilesSupported: boolean;\n autoFocus: boolean;\n selected: boolean;\n disabled: boolean;\n entity: Entity<Record<string, unknown>>;\n previewSize: PreviewSize;\n storage: StorageConfig;\n onFilesAdded: (acceptedFiles: File[]) => void;\n storagePathBuilder: (file: File) => string;\n openPopup?: (cellRect?: DOMRect) => void;\n onFileUploadComplete: (uploadedPath: string, entry: StorageFieldItem, fileMetadata?: Record<string, unknown>) => Promise<void>;\n}\n\nfunction StorageUpload({\n property,\n name,\n internalValue,\n setInternalValue,\n openPopup,\n entity,\n selected,\n error,\n onChange,\n multipleFilesSupported,\n previewSize: previewSizeInput,\n disabled,\n autoFocus,\n storage,\n onFilesAdded,\n onFileUploadComplete,\n storagePathBuilder\n}: StorageUploadProps) {\n\n const previewSize = previewSizeInput;\n if (multipleFilesSupported) {\n const arrayProperty = property as ArrayProperty;\n if (Array.isArray(arrayProperty.of)) {\n throw Error(\"Using array properties instead of single one in `of` in ArrayProperty\");\n }\n if (arrayProperty.of) {\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 hasValue = Boolean(internalValue);\n\n const snackbarContext = useSnackbarController();\n const { t } = useTranslation();\n\n const {\n open,\n getRootProps,\n getInputProps,\n isDragActive,\n isDragAccept,\n isDragReject\n } = useDropzone({\n accept: storage.acceptedFiles ? storage.acceptedFiles.map(e => ({ [e]: [] })).reduce((a, b) => ({ ...a,\n...b }), {}) : undefined,\n disabled,\n maxSize: storage.maxSize,\n noClick: true,\n noKeyboard: true,\n onDrop: onFilesAdded,\n onDropRejected: (fileRejections, event) => {\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: t(\"error_uploading_file_size\", { maxSize: String(storage.maxSize) })\n });\n } else if (error.code === \"file-invalid-type\") {\n snackbarContext.open({\n type: \"error\",\n message: t(\"error_uploading_file_type\")\n });\n }\n }\n }\n }\n }\n );\n\n const { ...rootProps } = getRootProps();\n\n const helpText = multipleFilesSupported\n ? t(\"drag_drop_files\")\n : t(\"drag_drop_file\");\n\n const renderProperty = multipleFilesSupported\n ? (property as ArrayProperty).of as StringProperty\n : property as StringProperty;\n\n const imageSize = useMemo(() => getThumbnailMeasure(previewSize), [previewSize]);\n const showError = !disabled && error;\n\n return (\n <div {...rootProps}\n className={cls(dropZoneClasses,\n \"relative w-full h-full flex\",\n `justify-${hasValue ? \"start\" : \"center\"}`,\n isDragActive ? activeDropClasses : \"\",\n isDragAccept ? acceptDropClasses : \"\",\n isDragReject ? rejectDropClasses : \"\"\n )}\n >\n\n <input autoFocus={autoFocus} {...getInputProps()}/>\n\n {internalValue.map((entry, index) => {\n let child;\n if (entry.storagePathOrDownloadUrl) {\n child = (\n <TableStorageItemPreview\n key={`storage_preview_${index}`}\n propertyKey={name}\n property={renderProperty}\n value={entry.storagePathOrDownloadUrl}\n entity={entity}\n size={previewSize}/>\n );\n } else if (entry.file) {\n child = (\n <StorageUploadProgress\n key={`storage_progress_${index}`}\n entry={entry}\n metadata={metadata}\n storagePath={storagePathBuilder(entry.file)}\n onFileUploadComplete={onFileUploadComplete}\n imageSize={imageSize}\n simple={true}\n />\n );\n }\n\n return child;\n })}\n\n {!internalValue && <div\n className=\"grow m-2 max-w-[200px]\"\n onClick={open}>\n <Typography\n className=\"text-surface-400 dark:text-surface-600\"\n variant={\"body2\"}\n align={\"center\"}>\n {helpText}\n </Typography>\n </div>}\n\n <EntityTableCellActions\n showError={showError}\n disabled={disabled}\n showExpandIcon={true}\n selected={selected}\n openPopup={!disabled ? openPopup : undefined}>\n <IconButton aria-label={t(\"edit\")}\n size={\"small\"}\n onClick={open}>\n <PencilIcon className={\"text-surface-500\"}/>\n </IconButton>\n </EntityTableCellActions>\n\n </div>\n );\n\n}\n\ninterface TableStorageItemPreviewProps {\n propertyKey: string;\n property: StringProperty;\n value: string,\n size: PreviewSize;\n entity: Entity<Record<string, unknown>>;\n}\n\nexport function TableStorageItemPreview({\n propertyKey,\n property,\n value,\n size,\n entity\n}: TableStorageItemPreviewProps) {\n\n // shrink-0: an image with a percentage max-height has no min-content width,\n // so a row of them in a narrow cell squeezes each one to a sliver. They\n // keep their size and the cell clips the ones that do not fit.\n return (\n <div\n className={\"relative p-2 max-w-full shrink-0\"}\n >\n\n {value &&\n <ErrorBoundary>\n <PropertyPreview\n propertyKey={propertyKey}\n value={value}\n property={property}\n // entity={entity}\n size={size}/>\n </ErrorBoundary>\n }\n\n </div>\n );\n\n}\n"],"mappings":";;;;;;;;;;;AAgBA,IAAM,kBAAkB;AACxB,IAAM,oBAAoB;AAC1B,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X,QAAQ;IACX,GAPQ,oBAAoB,OAO5B;IAIT,OAAO;GACX,CAAC;GAEA,CAAC,iBAAiB,oBAAC,OAAD;IACf,WAAU;IACV,SAAS;cACT,oBAAC,YAAD;KACI,WAAU;KACV,SAAS;KACT,OAAO;eACN;IACO,CAAA;GACX,CAAA;GAEL,oBAAC,wBAAD;IACe;IACD;IACV,gBAAgB;IACN;IACV,WAAW,CAAC,WAAW,YAAY,KAAA;cACnC,oBAAC,YAAD;KAAY,cAAY,EAAE,MAAM;KAC5B,MAAM;KACN,SAAS;eACT,oBAAC,YAAD,EAAY,WAAW,mBAAoB,CAAA;IACnC,CAAA;GACQ,CAAA;EAEvB;;AAGb;AAUA,SAAgB,wBAAwB,EACpC,aACA,UACA,OACA,MACA,UAC6B;CAK7B,OACI,oBAAC,OAAD;EACI,WAAW;YAGV,SACG,oBAAC,eAAD,EAAA,UACI,oBAAC,iBAAD;GACiB;GACN;GACG;GAEJ;EAAM,CAAA,EACL,CAAA;CAGlB,CAAA;AAGb"}
1
+ {"version":3,"file":"TableStorageUpload.js","names":[],"sources":["../../../../src/components/CollectionTableBinding/fields/TableStorageUpload.tsx"],"sourcesContent":["import type { ArrayProperty, StringProperty } from \"@rebasepro/cms-types\";\nimport * as React from \"react\";\nimport { useMemo } from \"react\";\n\nimport { StorageConfig, Entity } from \"@rebasepro/cms-types\";\nimport { PreviewSize } from \"../../../types\";\nimport { useDropzone } from \"react-dropzone\";\nimport { PropertyPreview } from \"../../../preview\";\nimport { ErrorBoundary } from \"@rebasepro/ui\";\nimport { cls, IconButton, PencilIcon, Typography } from \"@rebasepro/ui\";\nimport { useSnackbarController, useStorageSource, useTranslation, StorageFieldItem, useStorageUploadController, StorageSourceContext } from \"@rebasepro/app\";\nimport { getThumbnailMeasure } from \"../../../preview/util\";\nimport { StorageUploadProgress } from \"../../../form/components/StorageUploadProgress\";\nimport { useCollectionRegistryController } from \"../../../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { EntityTableCellActions } from \"../internal/EntityTableCellActions\";\n\nconst dropZoneClasses = \"max-w-full box-border relative pt-[2px] items-center border border-transparent outline-hidden rounded-md duration-200 ease-[cubic-bezier(0.4,0,0.2,1)] focus:border-primary\";\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 bg-green-50 dark:bg-green-900\"\nconst rejectDropClasses = \"transition-colors duration-200 ease-[cubic-bezier(0,0,0.2,1)] border-2 border-solid border-red-500 bg-red-50 dark:bg-red-900\"\n\n/**\n * Field that allows to upload files to Google Cloud Storage.\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 TableStorageUpload(props: {\n propertyKey: string;\n error: Error | undefined;\n disabled: boolean;\n value: string | string[] | null;\n updateValue: (newValue: (string | string[] | null)) => void;\n selected: boolean;\n focused: boolean;\n property: StringProperty | ArrayProperty;\n entity: Entity<Record<string, unknown>>;\n path: string;\n previewSize: PreviewSize;\n openPopup?: (cellRect?: DOMRect) => void;\n onBlur?: React.FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;\n}) {\n\n const {\n propertyKey,\n error,\n selected,\n openPopup,\n value,\n disabled,\n property,\n entity,\n path,\n previewSize,\n updateValue\n } = props;\n\n const storageSource = useStorageSource();\n const collectionSlug = useCollectionRegistryController().getCollection(path)?.slug;\n\n const {\n internalValue,\n setInternalValue,\n onFilesAdded,\n storage,\n onFileUploadComplete,\n storagePathBuilder,\n multipleFilesSupported,\n resolvedStorageSource\n } = useStorageUploadController({\n entityValues: entity.values,\n entityId: entity.id,\n path,\n collectionSlug,\n property: property as StringProperty,\n propertyKey,\n storageSource,\n onChange: updateValue,\n value,\n disabled\n });\n\n return (\n\n <StorageSourceContext.Provider value={resolvedStorageSource}>\n <StorageUpload\n internalValue={internalValue}\n setInternalValue={setInternalValue}\n name={propertyKey}\n disabled={disabled}\n autoFocus={false}\n openPopup={openPopup}\n error={error}\n selected={selected}\n property={property}\n onChange={updateValue}\n entity={entity}\n storagePathBuilder={storagePathBuilder}\n storage={storage}\n multipleFilesSupported={multipleFilesSupported}\n onFilesAdded={onFilesAdded}\n onFileUploadComplete={onFileUploadComplete}\n previewSize={previewSize}/>\n </StorageSourceContext.Provider>\n\n );\n}\n\ninterface StorageUploadProps {\n internalValue: StorageFieldItem[];\n setInternalValue: (v: StorageFieldItem[]) => void;\n name: string;\n error?: Error;\n property: StringProperty | ArrayProperty;\n onChange: (value: string | string[] | null) => void;\n multipleFilesSupported: boolean;\n autoFocus: boolean;\n selected: boolean;\n disabled: boolean;\n entity: Entity<Record<string, unknown>>;\n previewSize: PreviewSize;\n storage: StorageConfig;\n onFilesAdded: (acceptedFiles: File[]) => void;\n storagePathBuilder: (file: File) => string;\n openPopup?: (cellRect?: DOMRect) => void;\n onFileUploadComplete: (uploadedPath: string, entry: StorageFieldItem, fileMetadata?: Record<string, unknown>) => Promise<void>;\n}\n\nfunction StorageUpload({\n property,\n name,\n internalValue,\n setInternalValue,\n openPopup,\n entity,\n selected,\n error,\n onChange,\n multipleFilesSupported,\n previewSize: previewSizeInput,\n disabled,\n autoFocus,\n storage,\n onFilesAdded,\n onFileUploadComplete,\n storagePathBuilder\n}: StorageUploadProps) {\n\n const previewSize = previewSizeInput;\n if (multipleFilesSupported) {\n const arrayProperty = property as ArrayProperty;\n if (Array.isArray(arrayProperty.of)) {\n throw Error(\"Using array properties instead of single one in `of` in ArrayProperty\");\n }\n if (arrayProperty.of) {\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 hasValue = Boolean(internalValue);\n\n const snackbarContext = useSnackbarController();\n const { t } = useTranslation();\n\n const {\n open,\n getRootProps,\n getInputProps,\n isDragActive,\n isDragAccept,\n isDragReject\n } = useDropzone({\n accept: storage.acceptedFiles ? storage.acceptedFiles.map(e => ({ [e]: [] })).reduce((a, b) => ({ ...a,\n...b }), {}) : undefined,\n disabled,\n maxSize: storage.maxSize,\n noClick: true,\n noKeyboard: true,\n onDrop: onFilesAdded,\n onDropRejected: (fileRejections, event) => {\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: t(\"error_uploading_file_size\", { maxSize: String(storage.maxSize) })\n });\n } else if (error.code === \"file-invalid-type\") {\n snackbarContext.open({\n type: \"error\",\n message: t(\"error_uploading_file_type\")\n });\n }\n }\n }\n }\n }\n );\n\n const { ...rootProps } = getRootProps();\n\n const helpText = multipleFilesSupported\n ? t(\"drag_drop_files\")\n : t(\"drag_drop_file\");\n\n const renderProperty = multipleFilesSupported\n ? (property as ArrayProperty).of as StringProperty\n : property as StringProperty;\n\n const imageSize = useMemo(() => getThumbnailMeasure(previewSize), [previewSize]);\n const showError = !disabled && error;\n\n return (\n <div {...rootProps}\n className={cls(dropZoneClasses,\n \"relative w-full h-full flex\",\n `justify-${hasValue ? \"start\" : \"center\"}`,\n isDragActive ? activeDropClasses : \"\",\n isDragAccept ? acceptDropClasses : \"\",\n isDragReject ? rejectDropClasses : \"\"\n )}\n >\n\n <input autoFocus={autoFocus} {...getInputProps()}/>\n\n {internalValue.map((entry, index) => {\n let child;\n if (entry.storagePathOrDownloadUrl) {\n child = (\n <TableStorageItemPreview\n key={`storage_preview_${index}`}\n propertyKey={name}\n property={renderProperty}\n value={entry.storagePathOrDownloadUrl}\n entity={entity}\n size={previewSize}/>\n );\n } else if (entry.file) {\n child = (\n <StorageUploadProgress\n key={`storage_progress_${index}`}\n entry={entry}\n metadata={metadata}\n storagePath={storagePathBuilder(entry.file)}\n onFileUploadComplete={onFileUploadComplete}\n imageSize={imageSize}\n simple={true}\n />\n );\n }\n\n return child;\n })}\n\n {!internalValue && <div\n className=\"grow m-2 max-w-[200px]\"\n onClick={open}>\n <Typography\n className=\"text-surface-400 dark:text-surface-600\"\n variant={\"body2\"}\n align={\"center\"}>\n {helpText}\n </Typography>\n </div>}\n\n <EntityTableCellActions\n showError={showError}\n disabled={disabled}\n showExpandIcon={true}\n selected={selected}\n openPopup={!disabled ? openPopup : undefined}>\n <IconButton aria-label={t(\"edit\")}\n size={\"small\"}\n onClick={open}>\n <PencilIcon className={\"text-surface-500\"}/>\n </IconButton>\n </EntityTableCellActions>\n\n </div>\n );\n\n}\n\ninterface TableStorageItemPreviewProps {\n propertyKey: string;\n property: StringProperty;\n value: string,\n size: PreviewSize;\n entity: Entity<Record<string, unknown>>;\n}\n\nexport function TableStorageItemPreview({\n propertyKey,\n property,\n value,\n size,\n entity\n}: TableStorageItemPreviewProps) {\n\n // shrink-0: an image with a percentage max-height has no min-content width,\n // so a row of them in a narrow cell squeezes each one to a sliver. They\n // keep their size and the cell clips the ones that do not fit.\n return (\n <div\n className={\"relative p-2 max-w-full shrink-0\"}\n >\n\n {value &&\n <ErrorBoundary>\n <PropertyPreview\n propertyKey={propertyKey}\n value={value}\n property={property}\n // entity={entity}\n size={size}/>\n </ErrorBoundary>\n }\n\n </div>\n );\n\n}\n"],"mappings":";;;;;;;;;;;AAgBA,IAAM,kBAAkB;AACxB,IAAM,oBAAoB;AAC1B,IAAM,oBAAoB;AAC1B,IAAM,oBAAoB;;;;;;;;AAS1B,SAAgB,mBAAmB,OAchC;CAEC,MAAM,EACF,aACA,OACA,UACA,WACA,OACA,UACA,UACA,QACA,MACA,aACA,gBACA;CAEJ,MAAM,gBAAgB,iBAAiB;CACvC,MAAM,iBAAiB,gCAAgC,CAAC,CAAC,cAAc,IAAI,CAAC,EAAE;CAE9E,MAAM,EACF,eACA,kBACA,cACA,SACA,sBACA,oBACA,wBACA,0BACA,2BAA2B;EAC3B,cAAc,OAAO;EACrB,UAAU,OAAO;EACjB;EACA;EACU;EACV;EACA;EACA,UAAU;EACV;EACA;CACJ,CAAC;CAED,O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EAEvB;;AAGb;AAUA,SAAgB,wBAAwB,EACpC,aACA,UACA,OACA,MACA,UAC6B;CAK7B,OACI,oBAAC,OAAD;EACI,WAAW;YAGV,SACG,oBAAC,eAAD,EAAA,UACI,oBAAC,iBAAD;GACiB;GACN;GACG;GAEJ;EAAM,CAAA,EACL,CAAA;CAGlB,CAAA;AAGb"}
@@ -1,5 +1,5 @@
1
- import { EnumValues } from "@rebasepro/types";
2
1
  import React from "react";
2
+ import { EnumValues } from "@rebasepro/cms-types";
3
3
  export declare function VirtualTableSelect(props: {
4
4
  name: string;
5
5
  enumValues: EnumValues;
@@ -2,7 +2,7 @@ import { EnumValuesChip } from "../../../preview/components/EnumValuesChip.js";
2
2
  import React, { useCallback, useEffect } from "react";
3
3
  import { jsx } from "react/jsx-runtime";
4
4
  import { MultiSelect, MultiSelectItem, Select, SelectItem } from "@rebasepro/ui";
5
- import { resolveEnumValues } from "@rebasepro/common";
5
+ import { resolveEnumValues } from "@rebasepro/cms-types";
6
6
  //#region src/components/CollectionTableBinding/fields/VirtualTableSelect.tsx
7
7
  function VirtualTableSelect(props) {
8
8
  const { enumValues, internalValue, disabled, small, focused, updateValue, multiple, valueType, open, onOpenChange, preview, anchorRef } = props;
@@ -1 +1 @@
1
- {"version":3,"file":"VirtualTableSelect.js","names":[],"sources":["../../../../src/components/CollectionTableBinding/fields/VirtualTableSelect.tsx"],"sourcesContent":["import { EnumValues } from \"@rebasepro/types\";\nimport { EnumValuesChip } from \"../../../preview\";\nimport React, { useCallback, useEffect } from \"react\";\nimport { MultiSelect, MultiSelectItem, Select, SelectItem } from \"@rebasepro/ui\";\nimport { resolveEnumValues } from \"@rebasepro/common\";\n\nexport function VirtualTableSelect(props: {\n name: string;\n enumValues: EnumValues;\n error: Error | undefined;\n multiple: boolean;\n disabled: boolean;\n small: boolean;\n internalValue: string | number | string[] | number[] | undefined;\n valueType: \"string\" | \"number\";\n updateValue: (newValue: (string | number | string[] | number[] | null)) => void;\n focused: boolean;\n /** Whether the list is open. Set by the cell's opener as well as the trigger. */\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n /**\n * What the cell shows at rest. The trigger shows the same node, so a\n * selected cell looks like an unselected one; the chevron is the cell's.\n */\n preview?: React.ReactNode;\n /** The cell: the list opens against it rather than against the trigger. */\n anchorRef?: React.RefObject<HTMLElement | null>;\n onBlur?: React.FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;\n}) {\n\n const {\n enumValues,\n internalValue,\n disabled,\n small,\n focused,\n updateValue,\n multiple,\n valueType,\n open,\n onOpenChange,\n preview,\n anchorRef\n } = props;\n\n const validValue = (Array.isArray(internalValue) && multiple) ||\n (!Array.isArray(internalValue) && !multiple);\n\n const ref = React.useRef<HTMLButtonElement>(null);\n useEffect(() => {\n if (ref.current && focused) {\n ref.current?.focus({ preventScroll: true });\n }\n }, [focused, ref]);\n\n const onChange = useCallback((updatedValue: string | string[]) => {\n if (valueType === \"number\") {\n if (multiple) {\n const newValue = (updatedValue as string[]).map((v) => parseFloat(v));\n updateValue(newValue);\n } else {\n updateValue(parseFloat(updatedValue as string));\n }\n } else if (valueType === \"string\") {\n if (!updatedValue)\n updateValue(null)\n else\n updateValue(updatedValue);\n } else {\n throw Error(\"Missing mapping in TableSelect\");\n }\n }, [multiple, updateValue, valueType]);\n\n const resolvedEnumValues = resolveEnumValues(enumValues);\n\n const renderValue = (enumKey?: string | number) => <EnumValuesChip\n key={`${enumKey}`}\n enumKey={String(enumKey)}\n enumValues={enumValues}\n size={small ? \"small\" : \"medium\"}/>;\n\n // When the dropdown closes (including on escape), restore focus to the trigger\n const handleOpenChange = useCallback((nextOpen: boolean) => {\n onOpenChange?.(nextOpen);\n if (!nextOpen && ref.current) {\n // Use setTimeout to ensure focus is restored after Radix finishes its cleanup\n setTimeout(() => {\n ref.current?.focus({ preventScroll: true });\n }, 0);\n }\n }, [onOpenChange]);\n\n return (\n multiple\n ? <MultiSelect\n invisible={true}\n inputRef={ref}\n // The trigger is the preview the cell shows at rest, with no\n // box, padding, height or chevron of its own: the cell pads it\n // and draws the opener, so the chips sit where they sit at rest.\n triggerContent={preview}\n size={\"smallest\"}\n className=\"w-full h-full p-0 bg-transparent outline-none\"\n disabled={disabled}\n includeClear={false}\n anchorRef={anchorRef}\n useChips={false}\n open={open}\n value={validValue\n ? ((internalValue as (string | number)[]).map(v => v.toString()))\n : ([])}\n onValueChange={onChange}\n onOpenChange={handleOpenChange}>\n {resolvedEnumValues?.map((enumConfig) => (\n <MultiSelectItem\n key={enumConfig.id}\n value={String(enumConfig.id)}>\n <EnumValuesChip\n enumKey={enumConfig.id}\n enumValues={enumValues}\n size={small ? \"small\" : \"medium\"}/>\n </MultiSelectItem>\n ))}\n </MultiSelect>\n : <Select\n inputRef={ref}\n // The cell draws the frame when it is selected; the control\n // inside must not draw its own field box on top of it, or a\n // selected enum cell shows two outlines. Same as the user select.\n invisible={true}\n fullWidth={true}\n className=\"w-full h-full p-0 bg-transparent outline-none [&_button]:ring-0 [&_button]:ring-offset-0\"\n inputClassName=\"ring-0 ring-offset-0 focus:ring-0 focus-visible:ring-0 outline-none focus:outline-none focus-visible:outline-none focus-visible:ring-offset-0\"\n position={\"item-aligned\"}\n disabled={disabled}\n // As above: the preview, exactly where it sits at rest.\n triggerContent={preview}\n padding={false}\n size={\"smallest\"}\n open={open}\n value={validValue\n ? internalValue?.toString()\n : \"\"}\n onValueChange={onChange}\n onOpenChange={handleOpenChange}\n renderValue={renderValue}>\n {resolvedEnumValues?.map((enumConfig) => (\n <SelectItem\n key={enumConfig.id}\n value={String(enumConfig.id)}\n textValue={enumConfig.label}>\n <EnumValuesChip\n enumKey={enumConfig.id}\n enumValues={enumValues}\n size={small ? \"small\" : \"medium\"}/>\n </SelectItem>\n ))}\n </Select>\n\n );\n}\n"],"mappings":";;;;;;AAMA,SAAgB,mBAAmB,OAsBhC;CAEC,MAAM,EACF,YACA,eACA,UACA,OACA,SACA,aACA,UACA,WACA,MACA,cACA,SACA,cACA;CAEJ,MAAM,aA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W;IACR;IACZ,MAAM,QAAQ,UAAU;GAAU,CAAA;EACzB,GANR,WAAW,EAMH,CACpB;CACQ,CAAA,IACX,oBAAC,QAAD;EACE,UAAU;EAIV,WAAW;EACX,WAAW;EACX,WAAU;EACV,gBAAe;EACf,UAAU;EACA;EAEV,gBAAgB;EAChB,SAAS;EACT,MAAM;EACA;EACN,OAAO,aACD,eAAe,SAAS,IACxB;EACN,eAAe;EACf,cAAc;EACD;YACZ,oBAAoB,KAAK,eACtB,oBAAC,YAAD;GAEI,OAAO,OAAO,WAAW,EAAE;GAC3B,WAAW,WAAW;aACtB,oBAAC,gBAAD;IACI,SAAS,WAAW;IACR;IACZ,MAAM,QAAQ,UAAU;GAAU,CAAA;EAC9B,GAPH,WAAW,EAOR,CACf;CACG,CAAA;AAGpB"}
1
+ {"version":3,"file":"VirtualTableSelect.js","names":[],"sources":["../../../../src/components/CollectionTableBinding/fields/VirtualTableSelect.tsx"],"sourcesContent":["import { EnumValuesChip } from \"../../../preview\";\nimport React, { useCallback, useEffect } from \"react\";\nimport { MultiSelect, MultiSelectItem, Select, SelectItem } from \"@rebasepro/ui\";\nimport { resolveEnumValues, EnumValues } from \"@rebasepro/cms-types\";\n\nexport function VirtualTableSelect(props: {\n name: string;\n enumValues: EnumValues;\n error: Error | undefined;\n multiple: boolean;\n disabled: boolean;\n small: boolean;\n internalValue: string | number | string[] | number[] | undefined;\n valueType: \"string\" | \"number\";\n updateValue: (newValue: (string | number | string[] | number[] | null)) => void;\n focused: boolean;\n /** Whether the list is open. Set by the cell's opener as well as the trigger. */\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n /**\n * What the cell shows at rest. The trigger shows the same node, so a\n * selected cell looks like an unselected one; the chevron is the cell's.\n */\n preview?: React.ReactNode;\n /** The cell: the list opens against it rather than against the trigger. */\n anchorRef?: React.RefObject<HTMLElement | null>;\n onBlur?: React.FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;\n}) {\n\n const {\n enumValues,\n internalValue,\n disabled,\n small,\n focused,\n updateValue,\n multiple,\n valueType,\n open,\n onOpenChange,\n preview,\n anchorRef\n } = props;\n\n const validValue = (Array.isArray(internalValue) && multiple) ||\n (!Array.isArray(internalValue) && !multiple);\n\n const ref = React.useRef<HTMLButtonElement>(null);\n useEffect(() => {\n if (ref.current && focused) {\n ref.current?.focus({ preventScroll: true });\n }\n }, [focused, ref]);\n\n const onChange = useCallback((updatedValue: string | string[]) => {\n if (valueType === \"number\") {\n if (multiple) {\n const newValue = (updatedValue as string[]).map((v) => parseFloat(v));\n updateValue(newValue);\n } else {\n updateValue(parseFloat(updatedValue as string));\n }\n } else if (valueType === \"string\") {\n if (!updatedValue)\n updateValue(null)\n else\n updateValue(updatedValue);\n } else {\n throw Error(\"Missing mapping in TableSelect\");\n }\n }, [multiple, updateValue, valueType]);\n\n const resolvedEnumValues = resolveEnumValues(enumValues);\n\n const renderValue = (enumKey?: string | number) => <EnumValuesChip\n key={`${enumKey}`}\n enumKey={String(enumKey)}\n enumValues={enumValues}\n size={small ? \"small\" : \"medium\"}/>;\n\n // When the dropdown closes (including on escape), restore focus to the trigger\n const handleOpenChange = useCallback((nextOpen: boolean) => {\n onOpenChange?.(nextOpen);\n if (!nextOpen && ref.current) {\n // Use setTimeout to ensure focus is restored after Radix finishes its cleanup\n setTimeout(() => {\n ref.current?.focus({ preventScroll: true });\n }, 0);\n }\n }, [onOpenChange]);\n\n return (\n multiple\n ? <MultiSelect\n invisible={true}\n inputRef={ref}\n // The trigger is the preview the cell shows at rest, with no\n // box, padding, height or chevron of its own: the cell pads it\n // and draws the opener, so the chips sit where they sit at rest.\n triggerContent={preview}\n size={\"smallest\"}\n className=\"w-full h-full p-0 bg-transparent outline-none\"\n disabled={disabled}\n includeClear={false}\n anchorRef={anchorRef}\n useChips={false}\n open={open}\n value={validValue\n ? ((internalValue as (string | number)[]).map(v => v.toString()))\n : ([])}\n onValueChange={onChange}\n onOpenChange={handleOpenChange}>\n {resolvedEnumValues?.map((enumConfig) => (\n <MultiSelectItem\n key={enumConfig.id}\n value={String(enumConfig.id)}>\n <EnumValuesChip\n enumKey={enumConfig.id}\n enumValues={enumValues}\n size={small ? \"small\" : \"medium\"}/>\n </MultiSelectItem>\n ))}\n </MultiSelect>\n : <Select\n inputRef={ref}\n // The cell draws the frame when it is selected; the control\n // inside must not draw its own field box on top of it, or a\n // selected enum cell shows two outlines. Same as the user select.\n invisible={true}\n fullWidth={true}\n className=\"w-full h-full p-0 bg-transparent outline-none [&_button]:ring-0 [&_button]:ring-offset-0\"\n inputClassName=\"ring-0 ring-offset-0 focus:ring-0 focus-visible:ring-0 outline-none focus:outline-none focus-visible:outline-none focus-visible:ring-offset-0\"\n position={\"item-aligned\"}\n disabled={disabled}\n // As above: the preview, exactly where it sits at rest.\n triggerContent={preview}\n padding={false}\n size={\"smallest\"}\n open={open}\n value={validValue\n ? internalValue?.toString()\n : \"\"}\n onValueChange={onChange}\n onOpenChange={handleOpenChange}\n renderValue={renderValue}>\n {resolvedEnumValues?.map((enumConfig) => (\n <SelectItem\n key={enumConfig.id}\n value={String(enumConfig.id)}\n textValue={enumConfig.label}>\n <EnumValuesChip\n enumKey={enumConfig.id}\n enumValues={enumValues}\n size={small ? \"small\" : \"medium\"}/>\n </SelectItem>\n ))}\n </Select>\n\n );\n}\n"],"mappings":";;;;;;AAKA,SAAgB,mBAAmB,OAsBhC;CAEC,MAAM,EACF,YACA,eACA,UACA,OACA,SACA,aACA,UACA,WACA,MACA,cACA,SACA,cACA;CAEJ,MAAM,aAAc,MAAM,QAAQ,aAAa,KAAK,YAC/C,CAAC,MAAM,QAAQ,aAAa,KAAK,CAAC;CAEvC,MAAM,MAAM,MAAM,OAA0B,IAAI;CAChD,gBAAgB;EACZ,IAAI,IAAI,WAAW,SACf,IAAI,SAAS,MAAM,EAAE,eAAe,KAAK,CAAC;CAElD,GAAG,CAAC,SAAS,GAAG,CAAC;CAEjB,MAAM,WAAW,aAAa,iBAAoC;EAC9D,IAAI,cAAc,UACd,I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KAAK,eACtB,oBAAC,YAAD;GAEI,OAAO,OAAO,WAAW,EAAE;GAC3B,WAAW,WAAW;aACtB,oBAAC,gBAAD;IACI,SAAS,WAAW;IACR;IACZ,MAAM,QAAQ,UAAU;GAAU,CAAA;EAC9B,GAPH,WAAW,EAOR,CACf;CACG,CAAA;AAGpB"}
@@ -1,5 +1,4 @@
1
- import type { DateProperty, Property } from "@rebasepro/types";
2
- import type { AdminCollection } from "@rebasepro/cms-types";
1
+ import type { AdminCollection, DateProperty, Property } from "@rebasepro/cms-types";
3
2
  import { DatePreviewFormatOptions } from "../../../preview/components/DatePreview.js";
4
3
  /**
5
4
  * What a date cell is formatted with, beyond the property itself: the admin's
@@ -1 +1 @@
1
- {"version":3,"file":"common.js","names":[],"sources":["../../../../src/components/CollectionTableBinding/internal/common.tsx"],"sourcesContent":["\nimport type { ArrayProperty, DateProperty, Property } from \"@rebasepro/types\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\nimport { DatePreviewFormatOptions, formatDatePreview } from \"../../../preview/components/DatePreview\";\nimport { getDatePropertyMode, getDatePropertyTimezone } from \"../../../preview/util\";\n\n/**\n * What a date cell is formatted with, beyond the property itself: the admin's\n * locale and format. Without it a column is sized for the defaults.\n */\nexport type DateColumnFormatting = Pick<DatePreviewFormatOptions, \"locale\" | \"dateTimeFormat\" | \"dateFnsLocale\"> & {\n /**\n * Whether the cell is the date input (inline editing on, property not\n * read-only) rather than the formatted preview. The input draws the\n * browser's short numeric form, whatever the admin's format says.\n */\n editable?: boolean;\n};\n\nexport function getTableCellAlignment(property: Property): \"right\" | \"left\" | \"center\" {\n if (property.type === \"boolean\") {\n return \"center\";\n } else if (property.type === \"number\") {\n if (property.enum)\n return \"left\";\n return \"right\";\n } else if (property.type === \"date\") {\n return \"right\";\n } else {\n return \"left\";\n }\n}\n\nexport function getTablePropertyColumnWidth(property: Property, dateFormatting?: DateColumnFormatting): number {\n\n if (property.admin?.columnWidth) {\n return property.admin?.columnWidth;\n }\n\n if (property.type === \"string\") {\n if (property.admin?.urlPreview) {\n return 280;\n } else if (property.storage) {\n return 160;\n } else if (property.enum) {\n return 200;\n } else if (property.admin?.multiline) {\n return 300;\n } else if (property.admin?.markdown) {\n return 300;\n } else if (property.email) {\n return 200;\n } else {\n return 200;\n }\n } else if (property.type === \"array\") {\n const arrayProperty = property as ArrayProperty;\n if (arrayProperty.of) {\n if (Array.isArray(property.of)) {\n return 300;\n } else {\n return getTablePropertyColumnWidth(arrayProperty.of as Property, dateFormatting);\n }\n } else {\n return 300;\n }\n } else if (property.type === \"number\") {\n if (property.enum) {\n return 200;\n }\n return 140;\n } else if (property.type === \"map\") {\n return 360;\n } else if (property.type === \"date\") {\n return getDateColumnWidth(property, dateFormatting);\n } else if (property.type === \"reference\") {\n return 220;\n } else if (property.type === \"relation\") {\n return 280;\n } else if (property.type === \"boolean\") {\n return 140;\n } else {\n return 200;\n }\n}\n\n/**\n * What a table cell spends around its content at the roomiest size: the 4px\n * border plus `p-4` (l and xl), on both sides. Sized for the roomiest so a\n * column fits at every size without changing width when the size does.\n */\nconst CELL_CHROME_WIDTH = 2 * (4 + 16);\n/** An editable cell's native input: `dd/mm/yyyy, --:--` and the picker. */\nconst EDITABLE_DATE_COLUMN_WIDTH = 200;\n/** Never narrower than this: the header's title, sort and filter need room too. */\nconst MIN_DATE_COLUMN_WIDTH = 140;\n/** A row's text (`text-sm`) and the zone after a zoned date (`text-xs`). */\nconst CELL_FONT_SIZE = 14;\nconst ZONE_FONT_SIZE = 12;\n/** `gap-1` between a zoned date and its zone. */\nconst ZONE_GAP = 4;\n/** Every mono face in `--font-mono` advances 0.6em per character. */\nconst MONO_ADVANCE = 0.6;\n\nlet measureContext: CanvasRenderingContext2D | null | undefined;\n\n/**\n * The width of `text` in the mono tier, as the browser will draw it.\n *\n * Measured, not counted, where a canvas exists: a locale's month names may be\n * in a script the mono face does not cover, and the fallback face it lands in\n * is not 0.6em wide. Counted elsewhere (tests, SSR).\n */\nfunction measureMonoText(text: string, fontSize: number): number {\n if (measureContext === undefined) {\n measureContext = typeof document !== \"undefined\"\n ? document.createElement(\"canvas\").getContext(\"2d\")\n : null;\n }\n if (!measureContext) return text.length * fontSize * MONO_ADVANCE;\n const family = getComputedStyle(document.documentElement).getPropertyValue(\"--font-mono\").trim() || \"monospace\";\n measureContext.font = `${fontSize}px ${family}`;\n return measureContext.measureText(text).width;\n}\n\n/**\n * Dates covering every month and weekday, at a two-digit day and the\n * two-digit hours of both clocks (23:58, 11:58 PM): the widest a format can\n * get is the widest of these, whatever its locale names the months and days.\n */\nconst WIDEST_DATE_SAMPLES: Date[] = Array.from({ length: 12 * 7 }, (_, i) =>\n new Date(2026, Math.floor(i / 7), 22 + i % 7, 23, 58, 58));\n\nconst dateColumnWidths = new Map<string, number>();\n\n/**\n * A date column wide enough for its widest value on one line.\n *\n * It used to be a flat 200px, and the default format — \"November 06, 2026,\n * 23:32:05\", 27 mono characters at 8.4px — needs 227px before the cell's own\n * padding. Every date wrapped after its year, and at the text sizes (xs–m) the\n * row has room for one line, so what showed was the bottom of one line and\n * the top of the next. The width now comes from formatting real dates exactly\n * as the cell will (`formatDatePreview`), in the admin's locale and format.\n */\nexport function getDateColumnWidth(property: DateProperty, formatting?: DateColumnFormatting): number {\n if (formatting?.editable) return EDITABLE_DATE_COLUMN_WIDTH;\n const options: DatePreviewFormatOptions = {\n locale: formatting?.locale,\n dateTimeFormat: formatting?.dateTimeFormat,\n dateFnsLocale: formatting?.dateFnsLocale,\n mode: getDatePropertyMode(property),\n timezone: getDatePropertyTimezone(property)\n };\n const key = [options.mode, options.timezone, options.locale, options.dateTimeFormat, options.dateFnsLocale?.code].join(\"|\");\n const cached = dateColumnWidths.get(key);\n if (cached !== undefined) return cached;\n\n let widest = 0;\n try {\n for (const date of WIDEST_DATE_SAMPLES) {\n const { text, zone } = formatDatePreview(date, options);\n const width = measureMonoText(text, CELL_FONT_SIZE)\n + (zone ? ZONE_GAP + measureMonoText(`(${zone})`, ZONE_FONT_SIZE) : 0);\n widest = Math.max(widest, width);\n }\n } catch (error) {\n // An unknown timezone or a malformed format throws here exactly as it\n // does in the cell, which reports it; the column keeps its old width.\n console.warn(\"Could not measure a date column\", error);\n return 200;\n }\n\n // Rounded up to the 4px grid, with a pixel of slack for subpixel glyphs.\n const width = Math.max(MIN_DATE_COLUMN_WIDTH, Math.ceil((widest + 1 + CELL_CHROME_WIDTH) / 4) * 4);\n dateColumnWidths.set(key, width);\n return width;\n}\n\nexport function getSubcollectionColumnId(collection: AdminCollection) {\n return `subcollection:${collection.slug}`;\n}\n"],"mappings":";;;AAmBA,SAAgB,sBAAsB,UAAiD;CACnF,IAAI,SAAS,SAAS,WAClB,OAAO;MACJ,IAAI,SAAS,SAAS,UAAU;EACnC,IAAI,SAAS,MACT,OAAO;EACX,OAAO;CACX,OAAO,IAAI,SAAS,SAAS,QACzB,OAAO;MAEP,OAAO;AAEf;AAEA,SAAgB,4BAA4B,UAAoB,gBAA+C;CAE3G,IAAI,SAAS,OAAO,aAChB,OAAO,SAAS,OAAO;CAG3B,IAAI,SAAS,SAAS,UAClB,IAAI,SAAS,OAAO,YAChB,OAAO;MACJ,IAAI,SAAS,SAChB,OAAO;MACJ,IAAI,SAAS,MAChB,OAAO;MACJ,IAAI,SAAS,OAAO,WACvB,OAAO;MACJ,IAAI,SAAS,OAAO,UACvB,OAAO;MACJ,IAAI,SAAS,OAChB,OAAO;MAEP,OAAO;MAER,IAAI,SAAS,SAAS,SAAS;EAClC,MAAM,gBAAgB;EACtB,IAAI,cAAc,IACd,IAAI,MAAM,QAAQ,SAAS,EAAE,GACzB,OAAO;OAEP,OAAO,4BAA4B,cAAc,IAAgB,cAAc;OAGnF,OAAO;CAEf,OAAO,IAAI,SAAS,SAAS,UAAU;EACnC,IAAI,SAAS,MACT,OAAO;EAEX,OAAO;CACX,OAAO,IAAI,SAAS,SAAS,OACzB,OAAO;MACJ,IAAI,SAAS,SAAS,QACzB,OAAO,mBAAmB,UAAU,cAAc;MAC/C,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AAiB,IAAI,GAAG;CACvC,IAAI,WAAW,KAAA,GAAW,OAAO;CAEjC,IAAI,SAAS;CACb,IAAI;EACA,KAAK,MAAM,QAAQ,qBAAqB;GACpC,MAAM,EAAE,MAAM,SAAS,kBAAkB,MAAM,OAAO;GACtD,MAAM,QAAQ,gBAAgB,MAAM,cAAc,KAC3C,OAAO,WAAW,gBAAgB,IAAI,KAAK,IAAI,cAAc,IAAI;GACxE,SAAS,KAAK,IAAI,QAAQ,KAAK;EACnC;CACJ,SAAS,OAAO;EAGZ,QAAQ,KAAK,mCAAmC,KAAK;EACrD,OAAO;CACX;CAGA,MAAM,QAAQ,KAAK,IAAI,uBAAuB,KAAK,MAAM,SAAS,IAAI,qBAAqB,CAAC,IAAI,CAAC;CACjG,iBAAiB,IAAI,KAAK,KAAK;CAC/B,OAAO;AACX;AAEA,SAAgB,yBAAyB,YAA6B;CAClE,OAAO,iBAAiB,WAAW;AACvC"}
1
+ {"version":3,"file":"common.js","names":[],"sources":["../../../../src/components/CollectionTableBinding/internal/common.tsx"],"sourcesContent":["\nimport type { AdminCollection, ArrayProperty, DateProperty, Property } from \"@rebasepro/cms-types\";\nimport { DatePreviewFormatOptions, formatDatePreview } from \"../../../preview/components/DatePreview\";\nimport { getDatePropertyMode, getDatePropertyTimezone } from \"../../../preview/util\";\n\n/**\n * What a date cell is formatted with, beyond the property itself: the admin's\n * locale and format. Without it a column is sized for the defaults.\n */\nexport type DateColumnFormatting = Pick<DatePreviewFormatOptions, \"locale\" | \"dateTimeFormat\" | \"dateFnsLocale\"> & {\n /**\n * Whether the cell is the date input (inline editing on, property not\n * read-only) rather than the formatted preview. The input draws the\n * browser's short numeric form, whatever the admin's format says.\n */\n editable?: boolean;\n};\n\nexport function getTableCellAlignment(property: Property): \"right\" | \"left\" | \"center\" {\n if (property.type === \"boolean\") {\n return \"center\";\n } else if (property.type === \"number\") {\n if (property.enum)\n return \"left\";\n return \"right\";\n } else if (property.type === \"date\") {\n return \"right\";\n } else {\n return \"left\";\n }\n}\n\nexport function getTablePropertyColumnWidth(property: Property, dateFormatting?: DateColumnFormatting): number {\n\n if (property.admin?.columnWidth) {\n return property.admin?.columnWidth;\n }\n\n if (property.type === \"string\") {\n if (property.admin?.urlPreview) {\n return 280;\n } else if (property.storage) {\n return 160;\n } else if (property.enum) {\n return 200;\n } else if (property.admin?.multiline) {\n return 300;\n } else if (property.admin?.markdown) {\n return 300;\n } else if (property.email) {\n return 200;\n } else {\n return 200;\n }\n } else if (property.type === \"array\") {\n const arrayProperty = property as ArrayProperty;\n if (arrayProperty.of) {\n if (Array.isArray(property.of)) {\n return 300;\n } else {\n return getTablePropertyColumnWidth(arrayProperty.of as Property, dateFormatting);\n }\n } else {\n return 300;\n }\n } else if (property.type === \"number\") {\n if (property.enum) {\n return 200;\n }\n return 140;\n } else if (property.type === \"map\") {\n return 360;\n } else if (property.type === \"date\") {\n return getDateColumnWidth(property, dateFormatting);\n } else if (property.type === \"reference\") {\n return 220;\n } else if (property.type === \"relation\") {\n return 280;\n } else if (property.type === \"boolean\") {\n return 140;\n } else {\n return 200;\n }\n}\n\n/**\n * What a table cell spends around its content at the roomiest size: the 4px\n * border plus `p-4` (l and xl), on both sides. Sized for the roomiest so a\n * column fits at every size without changing width when the size does.\n */\nconst CELL_CHROME_WIDTH = 2 * (4 + 16);\n/** An editable cell's native input: `dd/mm/yyyy, --:--` and the picker. */\nconst EDITABLE_DATE_COLUMN_WIDTH = 200;\n/** Never narrower than this: the header's title, sort and filter need room too. */\nconst MIN_DATE_COLUMN_WIDTH = 140;\n/** A row's text (`text-sm`) and the zone after a zoned date (`text-xs`). */\nconst CELL_FONT_SIZE = 14;\nconst ZONE_FONT_SIZE = 12;\n/** `gap-1` between a zoned date and its zone. */\nconst ZONE_GAP = 4;\n/** Every mono face in `--font-mono` advances 0.6em per character. */\nconst MONO_ADVANCE = 0.6;\n\nlet measureContext: CanvasRenderingContext2D | null | undefined;\n\n/**\n * The width of `text` in the mono tier, as the browser will draw it.\n *\n * Measured, not counted, where a canvas exists: a locale's month names may be\n * in a script the mono face does not cover, and the fallback face it lands in\n * is not 0.6em wide. Counted elsewhere (tests, SSR).\n */\nfunction measureMonoText(text: string, fontSize: number): number {\n if (measureContext === undefined) {\n measureContext = typeof document !== \"undefined\"\n ? document.createElement(\"canvas\").getContext(\"2d\")\n : null;\n }\n if (!measureContext) return text.length * fontSize * MONO_ADVANCE;\n const family = getComputedStyle(document.documentElement).getPropertyValue(\"--font-mono\").trim() || \"monospace\";\n measureContext.font = `${fontSize}px ${family}`;\n return measureContext.measureText(text).width;\n}\n\n/**\n * Dates covering every month and weekday, at a two-digit day and the\n * two-digit hours of both clocks (23:58, 11:58 PM): the widest a format can\n * get is the widest of these, whatever its locale names the months and days.\n */\nconst WIDEST_DATE_SAMPLES: Date[] = Array.from({ length: 12 * 7 }, (_, i) =>\n new Date(2026, Math.floor(i / 7), 22 + i % 7, 23, 58, 58));\n\nconst dateColumnWidths = new Map<string, number>();\n\n/**\n * A date column wide enough for its widest value on one line.\n *\n * It used to be a flat 200px, and the default format — \"November 06, 2026,\n * 23:32:05\", 27 mono characters at 8.4px — needs 227px before the cell's own\n * padding. Every date wrapped after its year, and at the text sizes (xs–m) the\n * row has room for one line, so what showed was the bottom of one line and\n * the top of the next. The width now comes from formatting real dates exactly\n * as the cell will (`formatDatePreview`), in the admin's locale and format.\n */\nexport function getDateColumnWidth(property: DateProperty, formatting?: DateColumnFormatting): number {\n if (formatting?.editable) return EDITABLE_DATE_COLUMN_WIDTH;\n const options: DatePreviewFormatOptions = {\n locale: formatting?.locale,\n dateTimeFormat: formatting?.dateTimeFormat,\n dateFnsLocale: formatting?.dateFnsLocale,\n mode: getDatePropertyMode(property),\n timezone: getDatePropertyTimezone(property)\n };\n const key = [options.mode, options.timezone, options.locale, options.dateTimeFormat, options.dateFnsLocale?.code].join(\"|\");\n const cached = dateColumnWidths.get(key);\n if (cached !== undefined) return cached;\n\n let widest = 0;\n try {\n for (const date of WIDEST_DATE_SAMPLES) {\n const { text, zone } = formatDatePreview(date, options);\n const width = measureMonoText(text, CELL_FONT_SIZE)\n + (zone ? ZONE_GAP + measureMonoText(`(${zone})`, ZONE_FONT_SIZE) : 0);\n widest = Math.max(widest, width);\n }\n } catch (error) {\n // An unknown timezone or a malformed format throws here exactly as it\n // does in the cell, which reports it; the column keeps its old width.\n console.warn(\"Could not measure a date column\", error);\n return 200;\n }\n\n // Rounded up to the 4px grid, with a pixel of slack for subpixel glyphs.\n const width = Math.max(MIN_DATE_COLUMN_WIDTH, Math.ceil((widest + 1 + CELL_CHROME_WIDTH) / 4) * 4);\n dateColumnWidths.set(key, width);\n return width;\n}\n\nexport function getSubcollectionColumnId(collection: AdminCollection) {\n return `subcollection:${collection.slug}`;\n}\n"],"mappings":";;;AAkBA,SAAgB,sBAAsB,UAAiD;CACnF,IAAI,SAAS,SAAS,WAClB,OAAO;MACJ,IAAI,SAAS,SAAS,UAAU;EACnC,IAAI,SAAS,MACT,OAAO;EACX,OAAO;CACX,OAAO,IAAI,SAAS,SAAS,QACzB,OAAO;MAEP,OAAO;AAEf;AAEA,SAAgB,4BAA4B,UAAoB,gBAA+C;CAE3G,IAAI,SAAS,OAAO,aAChB,OAAO,SAAS,OAAO;CAG3B,IAAI,SAAS,SAAS,UAClB,IAAI,SAAS,OAAO,YAChB,OAAO;MACJ,IAAI,SAAS,SAChB,OAAO;MACJ,IAAI,SAAS,MAChB,OAAO;MACJ,IAAI,SAAS,OAAO,WACvB,OAAO;MACJ,IAAI,SAAS,OAAO,UACvB,OAAO;MACJ,IAAI,SAAS,OAChB,OAAO;MAEP,OAAO;MAER,IAAI,SAAS,SAAS,SAAS;EAClC,MAAM,gBAAgB;EACtB,IAAI,cAAc,IACd,IAAI,MAAM,QAAQ,SAAS,EAAE,GACzB,OAAO;OAEP,OAAO,4BAA4B,cAAc,IAAgB,cAAc;OAGnF,OAAO;CAEf,OAAO,IAAI,SAAS,SAAS,UAAU;EACnC,IAAI,SAAS,MACT,OAAO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AQ;EAAM,QAAQ;EAAU,QAAQ;EAAQ,QAAQ;EAAgB,QAAQ,eAAe;CAAI,CAAC,CAAC,KAAK,GAAG;CAC1H,MAAM,SAAS,iBAAiB,IAAI,GAAG;CACvC,IAAI,WAAW,KAAA,GAAW,OAAO;CAEjC,IAAI,SAAS;CACb,IAAI;EACA,KAAK,MAAM,QAAQ,qBAAqB;GACpC,MAAM,EAAE,MAAM,SAAS,kBAAkB,MAAM,OAAO;GACtD,MAAM,QAAQ,gBAAgB,MAAM,cAAc,KAC3C,OAAO,WAAW,gBAAgB,IAAI,KAAK,IAAI,cAAc,IAAI;GACxE,SAAS,KAAK,IAAI,QAAQ,KAAK;EACnC;CACJ,SAAS,OAAO;EAGZ,QAAQ,KAAK,mCAAmC,KAAK;EACrD,OAAO;CACX;CAGA,MAAM,QAAQ,KAAK,IAAI,uBAAuB,KAAK,MAAM,SAAS,IAAI,qBAAqB,CAAC,IAAI,CAAC;CACjG,iBAAiB,IAAI,KAAK,KAAK;CAC/B,OAAO;AACX;AAEA,SAAgB,yBAAyB,YAA6B;CAClE,OAAO,iBAAiB,WAAW;AACvC"}
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { Entity } from "@rebasepro/types";
2
+ import { Entity } from "@rebasepro/cms-types";
3
3
  import { CustomFieldValidator } from "../../../../form/validation.js";
4
4
  import type { OnCellValueChangeParams } from "@rebasepro/app";
5
5
  import type { AdminCollection } from "@rebasepro/cms-types";
@@ -1,3 +1,4 @@
1
+ import { hasEntityId } from "../../../../util/identity.js";
1
2
  import { getPropertyInPath as getPropertyInPath$1 } from "../../../../util/property_utils.js";
2
3
  import { applyValueTransforms, getEntitySchema } from "../../../../form/validation.js";
3
4
  import { PropertyFieldBinding } from "../../../../form/PropertyFieldBinding.js";
@@ -8,7 +9,6 @@ import { useWindowSize } from "./useWindowSize.js";
8
9
  import React, { useCallback, useEffect, useLayoutEffect, useState } from "react";
9
10
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
10
11
  import { Button, DialogActions, IconButton, Portal, Typography, XIcon } from "@rebasepro/ui";
11
- import { hasEntityId } from "@rebasepro/common";
12
12
  import { PluginProviderStack, isDisabled, isReadOnly, rowOfEntity, useAuthController, useCustomizationController, useData, useRebaseContext, useTranslation } from "@rebasepro/app";
13
13
  import { Formex, getIn, useCreateFormex } from "@rebasepro/forms";
14
14
  //#region src/components/CollectionTableBinding/internal/popup_field/PopupFormField.tsx
@@ -20,7 +20,7 @@ function PopupFormFieldLoading({ tableKey, entityId, customFieldValidator, prope
20
20
  const dataClient = useData();
21
21
  const [entity, setEntity] = useState(void 0);
22
22
  useEffect(() => {
23
- if (hasEntityId(entityId) && inputCollection) dataClient.collection(path).findById(entityId).then((result) => setEntity(result));
23
+ if (hasEntityId(entityId) && inputCollection) dataClient.table(path).findById(entityId).then((result) => setEntity(result));
24
24
  }, [
25
25
  entityId,
26
26
  inputCollection,
@@ -1 +1 @@
1
- {"version":3,"file":"PopupFormField.js","names":[],"sources":["../../../../../src/components/CollectionTableBinding/internal/popup_field/PopupFormField.tsx"],"sourcesContent":["import type { Properties } from \"@rebasepro/types\";\nimport { hasEntityId } from \"@rebasepro/common\";\n\nimport type { FormContext, PropertyFieldBindingProps } from \"../../../../types/fields\";\nimport type { Property } from \"@rebasepro/types\";\nimport React, { useCallback, useEffect, useLayoutEffect, useState } from \"react\";\n\nimport { Button, DialogActions, IconButton, Portal, Typography, XIcon } from \"@rebasepro/ui\";\n\nimport { Entity, EntityValues } from \"@rebasepro/types\";\nimport { PluginProviderStack, useTranslation } from \"@rebasepro/app\";\nimport { Formex, FormexController, getIn, useCreateFormex } from \"@rebasepro/forms\";\nimport { useDraggable } from \"./useDraggable\";\nimport { applyValueTransforms, CustomFieldValidator, getEntitySchema } from \"../../../../form/validation\";\nimport { cellValidationProperties } from \"../../../../form/resolve_cell_property\";\nimport { useWindowSize } from \"./useWindowSize\";\nimport { getPropertyInPath } from \"../../../../util/property_utils\";\nimport { PropertyFieldBinding, zodToFormErrors } from \"../../../../form\";\nimport { useAuthController, useCustomizationController, useData, useRebaseContext } from \"@rebasepro/app\";\nimport type { OnCellValueChangeParams } from \"@rebasepro/app\";\nimport { isDisabled, isReadOnly } from \"@rebasepro/app\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\nimport { rowOfEntity } from \"@rebasepro/app\";\n\ninterface PopupFormFieldProps<M extends Record<string, unknown>> {\n customFieldValidator?: CustomFieldValidator;\n path: string;\n entityId: string | number;\n tableKey: string;\n // A column, or a key inside one (`address.street`, `tags[1]`): the popup\n // edits the value at that path, as the table cell it opened from does.\n propertyKey?: Extract<keyof M, string> | (string & {});\n // `AdminCollection<M>`, not `<any>`: the admin block's key-shaped fields\n // (titleProperty, sort, propertiesOrder) are typed against M, and\n // `AdminCollection<any>` collapses them to `string` — which then fails to\n // flow into the `FormContext<M>` built below.\n collection?: AdminCollection<M>;\n cellRect?: DOMRect;\n open: boolean;\n onClose: () => void;\n container: HTMLElement | null;\n /**\n * Callback when the value of a cell has been edited\n * @param params\n */\n onCellValueChange?: (params: OnCellValueChangeParams<any, any>) => Promise<void> | void;\n}\n\nexport function PopupFormField<M extends Record<string, unknown>>(props: PopupFormFieldProps<M>) {\n if (!props.open) return null;\n return <PopupFormFieldLoading {...props}/>;\n\n}\n\nexport function PopupFormFieldLoading<M extends Record<string, unknown>>({\n tableKey,\n entityId,\n customFieldValidator,\n propertyKey,\n collection: inputCollection,\n path,\n cellRect,\n open,\n onClose,\n onCellValueChange,\n container\n}: PopupFormFieldProps<M>) {\n const dataClient = useData();\n const [entity, setEntity] = useState<Entity<M> | undefined>(undefined);\n useEffect(() => {\n if (hasEntityId(entityId) && inputCollection) {\n dataClient.collection(path).findById(entityId).then((result) => setEntity(result as Entity<M> | undefined));\n }\n }, [entityId, inputCollection, dataClient, path]);\n\n if (!entity) return null;\n return <PopupFormFieldInternal {...{\n tableKey,\n entityId,\n customFieldValidator,\n propertyKey,\n collection: inputCollection,\n path,\n cellRect,\n open,\n onClose,\n onCellValueChange,\n container\n }} entity={entity}/>;\n}\n\nexport function PopupFormFieldInternal<M extends Record<string, unknown>>({\n tableKey,\n entityId,\n customFieldValidator,\n propertyKey,\n collection,\n path,\n cellRect,\n open,\n onClose,\n onCellValueChange,\n container,\n entity\n}: PopupFormFieldProps<M> & {\n entity?: Entity<M>\n}) {\n const { t } = useTranslation();\n\n const rebaseContext = useRebaseContext();\n const authController = useAuthController();\n const customizationController = useCustomizationController();\n\n const [savingError, setSavingError] = React.useState<any>();\n const [popupLocation, setPopupLocation] = useState<{\n x: number,\n y: number\n }>();\n\n const windowSize = useWindowSize();\n\n const draggableRef = React.useRef<HTMLDivElement>(null);\n const innerRef = React.useRef<HTMLDivElement>(null);\n\n const initialPositionSet = React.useRef<boolean>(false);\n\n const getInitialLocation = useCallback(() => {\n if (!cellRect) throw Error(\"getInitialLocation error\");\n\n return {\n x: cellRect.left < windowSize.width - cellRect.right\n ? cellRect.x + cellRect.width / 2\n : cellRect.x - cellRect.width / 2,\n y: cellRect.top < windowSize.height - cellRect.bottom\n ? cellRect.y + cellRect.height / 2\n : cellRect.y - cellRect.height / 2\n };\n }, [cellRect, windowSize.height, windowSize.width]);\n\n const normalizePosition = useCallback((\n pos: { x: number, y: number },\n draggableBoundingRect: DOMRect,\n currentWindowSize: { width: number, height: number }\n ) => {\n if (!draggableBoundingRect || draggableBoundingRect.width === 0 || draggableBoundingRect.height === 0) {\n return pos;\n }\n return {\n x: Math.max(0, Math.min(pos.x, currentWindowSize.width - draggableBoundingRect.width)),\n y: Math.max(0, Math.min(pos.y, currentWindowSize.height - draggableBoundingRect.height))\n };\n }, []);\n\n const updatePopupLocation = useCallback((newPositionCandidate?: {\n x: number,\n y: number\n }) => {\n const draggableBoundingRect = draggableRef.current?.getBoundingClientRect();\n if (!cellRect || !draggableBoundingRect || draggableBoundingRect.width === 0 || draggableBoundingRect.height === 0) {\n return;\n }\n const basePosition = newPositionCandidate ?? getInitialLocation();\n const newNormalizedPosition = normalizePosition(basePosition, draggableBoundingRect, windowSize);\n\n if (!popupLocation || newNormalizedPosition.x !== popupLocation.x || newNormalizedPosition.y !== popupLocation.y) {\n setPopupLocation(newNormalizedPosition);\n }\n }, [cellRect, getInitialLocation, normalizePosition, popupLocation, windowSize]);\n\n useDraggable({\n containerRef: draggableRef,\n innerRef,\n x: popupLocation?.x,\n y: popupLocation?.y,\n onMove: updatePopupLocation\n });\n\n useEffect(\n () => {\n initialPositionSet.current = false;\n },\n [propertyKey, entity]\n );\n\n useLayoutEffect(\n () => {\n if (!cellRect || initialPositionSet.current) return;\n // Ensure draggableRef is available and has dimensions before initial positioning\n const draggableBoundingRect = draggableRef.current?.getBoundingClientRect();\n if (!draggableBoundingRect || draggableBoundingRect.width === 0 || draggableBoundingRect.height === 0) {\n // If not ready, perhaps wait or log. For now, just return.\n // This might need a retry mechanism or ensure content is rendered first.\n return;\n }\n updatePopupLocation();\n initialPositionSet.current = true;\n },\n [cellRect, updatePopupLocation] // Removed initialPositionSet.current from deps as it's a ref\n );\n\n useLayoutEffect(\n () => {\n updatePopupLocation(popupLocation);\n },\n [windowSize, cellRect, updatePopupLocation, popupLocation]\n );\n\n // Built per validation, from the properties resolved against the values\n // the popup holds: a `conditions` rule or a `dynamicProps` validation\n // depends on them, as it does in the record form.\n const validationSchemaFor = (values: Partial<M>) => {\n if (!collection || !hasEntityId(entityId) || !propertyKey) return undefined;\n return getEntitySchema(\n entityId,\n cellValidationProperties<M>(collection.properties, propertyKey as string, values, entity?.values, entityId, {\n path,\n authController,\n propertyConfigs: customizationController.propertyConfigs\n }),\n customFieldValidator);\n };\n\n const adaptResize = useCallback(() => {\n // When the popup resizes, we want to re-evaluate its position\n // based on its current location and new dimensions.\n return updatePopupLocation(popupLocation);\n }, [popupLocation, updatePopupLocation]);\n\n // Setup ResizeObserver\n useEffect(() => {\n const element = draggableRef.current;\n if (!element) return;\n\n const observer = new ResizeObserver(() => {\n adaptResize();\n });\n\n observer.observe(element);\n\n return () => {\n observer.unobserve(element);\n observer.disconnect();\n };\n }, [adaptResize, draggableRef]);\n\n const saveValue = async (values: M) => {\n setSavingError(null);\n if (collection && entity && onCellValueChange && propertyKey) {\n // Written the way the form writes it: with the string transforms\n // the properties declare (`trim`, `lowercase`, `uppercase`) applied.\n const writtenValues = applyValueTransforms(values, collection.properties);\n return onCellValueChange({\n // By path: a spread map's child is `address.street`, which is\n // nested in the form values, not a key of them.\n value: getIn(writtenValues, propertyKey as string),\n propertyKey: propertyKey as string,\n data: entity,\n setError: setSavingError,\n onValueUpdated: () => {\n }\n });\n }\n return Promise.resolve();\n };\n\n const formex = useCreateFormex<M>({\n initialValues: (entity?.values ?? {}) as EntityValues<M>,\n validation: async (values) => {\n const validationSchema = validationSchemaFor(values);\n if (!validationSchema) return {};\n const result = await validationSchema.safeParseAsync(values);\n if (result.success) return {};\n return zodToFormErrors(result.error) as Record<string, string>;\n },\n validateOnInitialRender: true,\n onSubmit: (values, actions) => {\n saveValue(values)\n .then(() => {\n formex.resetForm({\n values: values\n })\n onClose();\n })\n .finally(() => actions.setSubmitting(false));\n }\n });\n\n const {\n values,\n isSubmitting,\n setFieldValue,\n handleSubmit\n } = formex;\n\n const disabled = isSubmitting;\n\n const formContext: FormContext<M> = {\n collection: collection,\n id: entityId,\n row: entity ? rowOfEntity(entity, collection) : undefined,\n values,\n path,\n setFieldValue,\n save: saveValue,\n submit: handleSubmit,\n formex,\n status: \"existing\",\n openEntityMode: \"side_panel\",\n disabled: false\n };\n\n const property: Property | undefined = propertyKey && getPropertyInPath(collection?.properties ?? {} as Properties, propertyKey as string);\n const fieldProps: PropertyFieldBindingProps<M> | undefined = propertyKey && property\n ? {\n propertyKey: propertyKey as string,\n disabled: isSubmitting || isReadOnly(property) || isDisabled(property),\n property,\n includeDescription: false,\n underlyingValueHasChanged: false,\n context: formContext,\n partOfArray: false,\n minimalistView: true,\n autoFocus: open\n }\n : undefined;\n\n let internalForm = <>\n <div\n key={`popup_form_${tableKey}_${entityId}_${propertyKey}`}\n className=\"w-[700px] max-w-full max-h-[85vh]\">\n <form\n onSubmit={handleSubmit}\n noValidate>\n\n <div\n className=\"mb-1 p-4 flex flex-col relative\">\n <div\n ref={innerRef}\n className=\"cursor-auto\"\n style={{ cursor: \"auto !important\" }}>\n {fieldProps &&\n <PropertyFieldBinding {...fieldProps}/>}\n </div>\n </div>\n\n <DialogActions>\n <Button\n variant=\"filled\"\n color=\"primary\"\n type=\"submit\"\n disabled={disabled}\n >\n Save\n </Button>\n </DialogActions>\n\n </form>\n\n </div>\n\n </>;\n\n const plugins = customizationController.plugins;\n if (plugins && plugins.length > 0) {\n internalForm = (\n <PluginProviderStack\n plugins={plugins}\n scope=\"form\"\n scopeProps={{\n status: \"existing\",\n path,\n collection,\n entity,\n context: rebaseContext,\n currentEntityId: entityId,\n formContext\n }}>\n {internalForm}\n </PluginProviderStack>\n );\n }\n const form = <div\n className={`text-surface-900 dark:text-white overflow-auto rounded-xs rounded-md bg-surface-card ${!open ? \"hidden\" : \"\"} cursor-grab max-w-[100vw]`}>\n\n {internalForm}\n\n {savingError &&\n <Typography color={\"error\"}>\n {savingError.message}\n </Typography>\n }\n </div>;\n\n const draggable = (\n <div\n key={`draggable_${propertyKey as string}_${entityId}_${open}`}\n style={{\n boxShadow: \"0 0 0 2px rgba(128,128,128,0.2)\"\n }}\n className={`inline-block fixed z-20 shadow-outline rounded-md bg-surface-card ${!open ? \"invisible\" : \"visible\"\n } cursor-grab overflow-visible`}\n ref={draggableRef}>\n\n {/* ElementResizeListener removed from here */}\n\n <div\n className=\"overflow-hidden\">\n\n {form}\n\n <div\n className=\"absolute -top-3.5 -right-3.5 bg-surface-500 rounded-full\"\n style={{\n width: \"32px\",\n height: \"32px\"\n }}>\n <IconButton aria-label={t(\"close\")}\n size={\"small\"}\n onClick={(event) => {\n event.stopPropagation();\n onClose();\n }}>\n <XIcon className=\"text-white\"/>\n </IconButton>\n </div>\n </div>\n\n </div>\n );\n\n return (\n <Portal.Root asChild\n container={container}>\n <Formex value={formex as FormexController<Record<string, unknown>>}>\n {draggable}\n </Formex>\n </Portal.Root>\n );\n\n}\n"],"mappings":";;;;;;;;;;;;;;AAgDA,SAAgB,eAAkD,OAA+B;CAC7F,IAAI,CAAC,MAAM,MAAM,OAAO;CACxB,OAAO,oBAAC,uBAAD,EAAuB,GAAI,MAAO,CAAA;AAE7C;AAEA,SAAgB,sBAAyD,EACrE,UACA,UACA,sBACA,aACA,YAAY,iBACZ,MACA,UACA,MACA,SACA,mBACA,aACuB;CACvB,MAAM,aAAa,QAAQ;CAC3B,MAAM,CAAC,QAAQ,aAAa,SAAgC,KAAA,CAAS;CACrE,gBAAgB;EACZ,IAAI,YAAY,QAAQ,KAAK,iBACzB,WAAW,WAAW,IAAI,CAAC,CAAC,SAAS,QAAQ,CAAC,CAAC,MAAM,WAAW,UAAU,MAA+B,CAAC;CAElH,GAAG;EAAC;EAAU;EAAiB;EAAY;CAAI,CAAC;CAEhD,IAAI,CAAC,QAAQ,OAAO;CACpB,OAAO,oBAAC,wBAAD;EACH;EACA;EACA;EACA;EACA,YAAY;EACZ;EACA;EACA;EACA;EACA;EACA;EACO;CAAQ,CAAA;AACvB;AAEA,SAAgB,uBAA0D,EACtE,UACA,UACA,sBACA,aACA,YACA,MACA,UACA,MACA,SACA,mBACA,WACA,UAGD;CACC,MAAM,EAAE,MAAM,eAAe;CAE7B,MAAM,gBAAgB,iBAAiB;CACvC,MAAM,iBAAiB,kBAAkB;CACzC,MAAM,0BAA0B,2BAA2B;CAE3D,MAAM,CAAC,aAAa,kBAAkB,MAAM,SAAc;CAC1D,MAAM,CAAC,eAAe,oBAAoB,SAGvC;CAEH,MAAM,aAAa,cAAc;CAEjC,MAAM,eAAe,MAAM,OAAuB,IAAI;CACtD,MAAM,WAAW,MAAM,OAAuB,IAAI;CAElD,MAAM,qBAAqB,MAAM,OAAgB,KAAK;CAEtD,MAAM,qBAAqB,kBAAkB;EACzC,IAAI,CAAC,UAAU,MAAM,MAAM,0BAA0B;EAErD,OA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Ac,SAAS,GAAG,SAAS,GAAG,aA8B1C,EAEP,CAAA;CAEF,MAAM,UAAU,wBAAwB;CACxC,IAAI,WAAW,QAAQ,SAAS,GAC5B,eACI,oBAAC,qBAAD;EACa;EACT,OAAM;EACN,YAAY;GACR,QAAQ;GACR;GACA;GACA;GACA,SAAS;GACT,iBAAiB;GACjB;EACJ;YACC;CACgB,CAAA;CAG7B,MAAM,OAAO,qBAAC,OAAD;EACT,WAAW,wFAAwF,CAAC,OAAO,WAAW,GAAG;YADhH,CAGR,cAEA,eACG,oBAAC,YAAD;GAAY,OAAO;aACd,YAAY;EACL,CAAA,CAEf;;CAEL,MAAM,YACF,oBAAC,OAAD;EAEI,OAAO,EACH,WAAW,kCACf;EACA,WAAW,qEAAqE,CAAC,OAAO,cAAc,UACjG;EACL,KAAK;YAIL,qBAAC,OAAD;GACI,WAAU;aADd,CAGK,MAED,oBAAC,OAAD;IACI,WAAU;IACV,OAAO;KACH,OAAO;KACP,QAAQ;IACZ;cACA,oBAAC,YAAD;KAAY,cAAY,EAAE,OAAO;KAC7B,MAAM;KACN,UAAU,UAAU;MAChB,MAAM,gBAAgB;MACtB,QAAQ;KACZ;eACA,oBAAC,OAAD,EAAO,WAAU,aAAa,CAAA;IACtB,CAAA;GACX,CAAA,CACJ;;CAEJ,GAhCI,aAAa,YAAsB,GAAG,SAAS,GAAG,MAgCtD;CAGT,OACI,oBAAC,OAAO,MAAR;EAAa,SAAA;EACE;YACX,oBAAC,QAAD;GAAQ,OAAO;aACV;EACG,CAAA;CACC,CAAA;AAGrB"}
1
+ {"version":3,"file":"PopupFormField.js","names":[],"sources":["../../../../../src/components/CollectionTableBinding/internal/popup_field/PopupFormField.tsx"],"sourcesContent":["import { hasEntityId } from \"../../../../util/identity\";\n\nimport type { FormContext, PropertyFieldBindingProps } from \"../../../../types/fields\";\nimport React, { useCallback, useEffect, useLayoutEffect, useState } from \"react\";\n\nimport { Button, DialogActions, IconButton, Portal, Typography, XIcon } from \"@rebasepro/ui\";\n\nimport { Entity, EntityValues } from \"@rebasepro/cms-types\";\nimport { PluginProviderStack, useTranslation } from \"@rebasepro/app\";\nimport { Formex, FormexController, getIn, useCreateFormex } from \"@rebasepro/forms\";\nimport { useDraggable } from \"./useDraggable\";\nimport { applyValueTransforms, CustomFieldValidator, getEntitySchema } from \"../../../../form/validation\";\nimport { cellValidationProperties } from \"../../../../form/resolve_cell_property\";\nimport { useWindowSize } from \"./useWindowSize\";\nimport { getPropertyInPath } from \"../../../../util/property_utils\";\nimport { PropertyFieldBinding, zodToFormErrors } from \"../../../../form\";\nimport { useAuthController, useCustomizationController, useData, useRebaseContext } from \"@rebasepro/app\";\nimport type { OnCellValueChangeParams } from \"@rebasepro/app\";\nimport { isDisabled, isReadOnly } from \"@rebasepro/app\";\nimport type { AdminCollection, Properties, Property } from \"@rebasepro/cms-types\";\nimport { rowOfEntity } from \"@rebasepro/app\";\n\ninterface PopupFormFieldProps<M extends Record<string, unknown>> {\n customFieldValidator?: CustomFieldValidator;\n path: string;\n entityId: string | number;\n tableKey: string;\n // A column, or a key inside one (`address.street`, `tags[1]`): the popup\n // edits the value at that path, as the table cell it opened from does.\n propertyKey?: Extract<keyof M, string> | (string & {});\n // `AdminCollection<M>`, not `<any>`: the admin block's key-shaped fields\n // (titleProperty, sort, propertiesOrder) are typed against M, and\n // `AdminCollection<any>` collapses them to `string` — which then fails to\n // flow into the `FormContext<M>` built below.\n collection?: AdminCollection<M>;\n cellRect?: DOMRect;\n open: boolean;\n onClose: () => void;\n container: HTMLElement | null;\n /**\n * Callback when the value of a cell has been edited\n * @param params\n */\n onCellValueChange?: (params: OnCellValueChangeParams<any, any>) => Promise<void> | void;\n}\n\nexport function PopupFormField<M extends Record<string, unknown>>(props: PopupFormFieldProps<M>) {\n if (!props.open) return null;\n return <PopupFormFieldLoading {...props}/>;\n\n}\n\nexport function PopupFormFieldLoading<M extends Record<string, unknown>>({\n tableKey,\n entityId,\n customFieldValidator,\n propertyKey,\n collection: inputCollection,\n path,\n cellRect,\n open,\n onClose,\n onCellValueChange,\n container\n}: PopupFormFieldProps<M>) {\n const dataClient = useData();\n const [entity, setEntity] = useState<Entity<M> | undefined>(undefined);\n useEffect(() => {\n if (hasEntityId(entityId) && inputCollection) {\n dataClient.table(path).findById(entityId).then((result) => setEntity(result as Entity<M> | undefined));\n }\n }, [entityId, inputCollection, dataClient, path]);\n\n if (!entity) return null;\n return <PopupFormFieldInternal {...{\n tableKey,\n entityId,\n customFieldValidator,\n propertyKey,\n collection: inputCollection,\n path,\n cellRect,\n open,\n onClose,\n onCellValueChange,\n container\n }} entity={entity}/>;\n}\n\nexport function PopupFormFieldInternal<M extends Record<string, unknown>>({\n tableKey,\n entityId,\n customFieldValidator,\n propertyKey,\n collection,\n path,\n cellRect,\n open,\n onClose,\n onCellValueChange,\n container,\n entity\n}: PopupFormFieldProps<M> & {\n entity?: Entity<M>\n}) {\n const { t } = useTranslation();\n\n const rebaseContext = useRebaseContext();\n const authController = useAuthController();\n const customizationController = useCustomizationController();\n\n const [savingError, setSavingError] = React.useState<any>();\n const [popupLocation, setPopupLocation] = useState<{\n x: number,\n y: number\n }>();\n\n const windowSize = useWindowSize();\n\n const draggableRef = React.useRef<HTMLDivElement>(null);\n const innerRef = React.useRef<HTMLDivElement>(null);\n\n const initialPositionSet = React.useRef<boolean>(false);\n\n const getInitialLocation = useCallback(() => {\n if (!cellRect) throw Error(\"getInitialLocation error\");\n\n return {\n x: cellRect.left < windowSize.width - cellRect.right\n ? cellRect.x + cellRect.width / 2\n : cellRect.x - cellRect.width / 2,\n y: cellRect.top < windowSize.height - cellRect.bottom\n ? cellRect.y + cellRect.height / 2\n : cellRect.y - cellRect.height / 2\n };\n }, [cellRect, windowSize.height, windowSize.width]);\n\n const normalizePosition = useCallback((\n pos: { x: number, y: number },\n draggableBoundingRect: DOMRect,\n currentWindowSize: { width: number, height: number }\n ) => {\n if (!draggableBoundingRect || draggableBoundingRect.width === 0 || draggableBoundingRect.height === 0) {\n return pos;\n }\n return {\n x: Math.max(0, Math.min(pos.x, currentWindowSize.width - draggableBoundingRect.width)),\n y: Math.max(0, Math.min(pos.y, currentWindowSize.height - draggableBoundingRect.height))\n };\n }, []);\n\n const updatePopupLocation = useCallback((newPositionCandidate?: {\n x: number,\n y: number\n }) => {\n const draggableBoundingRect = draggableRef.current?.getBoundingClientRect();\n if (!cellRect || !draggableBoundingRect || draggableBoundingRect.width === 0 || draggableBoundingRect.height === 0) {\n return;\n }\n const basePosition = newPositionCandidate ?? getInitialLocation();\n const newNormalizedPosition = normalizePosition(basePosition, draggableBoundingRect, windowSize);\n\n if (!popupLocation || newNormalizedPosition.x !== popupLocation.x || newNormalizedPosition.y !== popupLocation.y) {\n setPopupLocation(newNormalizedPosition);\n }\n }, [cellRect, getInitialLocation, normalizePosition, popupLocation, windowSize]);\n\n useDraggable({\n containerRef: draggableRef,\n innerRef,\n x: popupLocation?.x,\n y: popupLocation?.y,\n onMove: updatePopupLocation\n });\n\n useEffect(\n () => {\n initialPositionSet.current = false;\n },\n [propertyKey, entity]\n );\n\n useLayoutEffect(\n () => {\n if (!cellRect || initialPositionSet.current) return;\n // Ensure draggableRef is available and has dimensions before initial positioning\n const draggableBoundingRect = draggableRef.current?.getBoundingClientRect();\n if (!draggableBoundingRect || draggableBoundingRect.width === 0 || draggableBoundingRect.height === 0) {\n // If not ready, perhaps wait or log. For now, just return.\n // This might need a retry mechanism or ensure content is rendered first.\n return;\n }\n updatePopupLocation();\n initialPositionSet.current = true;\n },\n [cellRect, updatePopupLocation] // Removed initialPositionSet.current from deps as it's a ref\n );\n\n useLayoutEffect(\n () => {\n updatePopupLocation(popupLocation);\n },\n [windowSize, cellRect, updatePopupLocation, popupLocation]\n );\n\n // Built per validation, from the properties resolved against the values\n // the popup holds: a `conditions` rule or a `dynamicProps` validation\n // depends on them, as it does in the record form.\n const validationSchemaFor = (values: Partial<M>) => {\n if (!collection || !hasEntityId(entityId) || !propertyKey) return undefined;\n return getEntitySchema(\n entityId,\n cellValidationProperties<M>(collection.properties, propertyKey as string, values, entity?.values, entityId, {\n path,\n authController,\n propertyConfigs: customizationController.propertyConfigs\n }),\n customFieldValidator);\n };\n\n const adaptResize = useCallback(() => {\n // When the popup resizes, we want to re-evaluate its position\n // based on its current location and new dimensions.\n return updatePopupLocation(popupLocation);\n }, [popupLocation, updatePopupLocation]);\n\n // Setup ResizeObserver\n useEffect(() => {\n const element = draggableRef.current;\n if (!element) return;\n\n const observer = new ResizeObserver(() => {\n adaptResize();\n });\n\n observer.observe(element);\n\n return () => {\n observer.unobserve(element);\n observer.disconnect();\n };\n }, [adaptResize, draggableRef]);\n\n const saveValue = async (values: M) => {\n setSavingError(null);\n if (collection && entity && onCellValueChange && propertyKey) {\n // Written the way the form writes it: with the string transforms\n // the properties declare (`trim`, `lowercase`, `uppercase`) applied.\n const writtenValues = applyValueTransforms(values, collection.properties);\n return onCellValueChange({\n // By path: a spread map's child is `address.street`, which is\n // nested in the form values, not a key of them.\n value: getIn(writtenValues, propertyKey as string),\n propertyKey: propertyKey as string,\n data: entity,\n setError: setSavingError,\n onValueUpdated: () => {\n }\n });\n }\n return Promise.resolve();\n };\n\n const formex = useCreateFormex<M>({\n initialValues: (entity?.values ?? {}) as EntityValues<M>,\n validation: async (values) => {\n const validationSchema = validationSchemaFor(values);\n if (!validationSchema) return {};\n const result = await validationSchema.safeParseAsync(values);\n if (result.success) return {};\n return zodToFormErrors(result.error) as Record<string, string>;\n },\n validateOnInitialRender: true,\n onSubmit: (values, actions) => {\n saveValue(values)\n .then(() => {\n formex.resetForm({\n values: values\n })\n onClose();\n })\n .finally(() => actions.setSubmitting(false));\n }\n });\n\n const {\n values,\n isSubmitting,\n setFieldValue,\n handleSubmit\n } = formex;\n\n const disabled = isSubmitting;\n\n const formContext: FormContext<M> = {\n collection: collection,\n id: entityId,\n row: entity ? rowOfEntity(entity, collection) : undefined,\n values,\n path,\n setFieldValue,\n save: saveValue,\n submit: handleSubmit,\n formex,\n status: \"existing\",\n openEntityMode: \"side_panel\",\n disabled: false\n };\n\n const property: Property | undefined = propertyKey && getPropertyInPath(collection?.properties ?? {} as Properties, propertyKey as string);\n const fieldProps: PropertyFieldBindingProps<M> | undefined = propertyKey && property\n ? {\n propertyKey: propertyKey as string,\n disabled: isSubmitting || isReadOnly(property) || isDisabled(property),\n property,\n includeDescription: false,\n underlyingValueHasChanged: false,\n context: formContext,\n partOfArray: false,\n minimalistView: true,\n autoFocus: open\n }\n : undefined;\n\n let internalForm = <>\n <div\n key={`popup_form_${tableKey}_${entityId}_${propertyKey}`}\n className=\"w-[700px] max-w-full max-h-[85vh]\">\n <form\n onSubmit={handleSubmit}\n noValidate>\n\n <div\n className=\"mb-1 p-4 flex flex-col relative\">\n <div\n ref={innerRef}\n className=\"cursor-auto\"\n style={{ cursor: \"auto !important\" }}>\n {fieldProps &&\n <PropertyFieldBinding {...fieldProps}/>}\n </div>\n </div>\n\n <DialogActions>\n <Button\n variant=\"filled\"\n color=\"primary\"\n type=\"submit\"\n disabled={disabled}\n >\n Save\n </Button>\n </DialogActions>\n\n </form>\n\n </div>\n\n </>;\n\n const plugins = customizationController.plugins;\n if (plugins && plugins.length > 0) {\n internalForm = (\n <PluginProviderStack\n plugins={plugins}\n scope=\"form\"\n scopeProps={{\n status: \"existing\",\n path,\n collection,\n entity,\n context: rebaseContext,\n currentEntityId: entityId,\n formContext\n }}>\n {internalForm}\n </PluginProviderStack>\n );\n }\n const form = <div\n className={`text-surface-900 dark:text-white overflow-auto rounded-xs rounded-md bg-surface-card ${!open ? \"hidden\" : \"\"} cursor-grab max-w-[100vw]`}>\n\n {internalForm}\n\n {savingError &&\n <Typography color={\"error\"}>\n {savingError.message}\n </Typography>\n }\n </div>;\n\n const draggable = (\n <div\n key={`draggable_${propertyKey as string}_${entityId}_${open}`}\n style={{\n boxShadow: \"0 0 0 2px rgba(128,128,128,0.2)\"\n }}\n className={`inline-block fixed z-20 shadow-outline rounded-md bg-surface-card ${!open ? \"invisible\" : \"visible\"\n } cursor-grab overflow-visible`}\n ref={draggableRef}>\n\n {/* ElementResizeListener removed from here */}\n\n <div\n className=\"overflow-hidden\">\n\n {form}\n\n <div\n className=\"absolute -top-3.5 -right-3.5 bg-surface-500 rounded-full\"\n style={{\n width: \"32px\",\n height: \"32px\"\n }}>\n <IconButton aria-label={t(\"close\")}\n size={\"small\"}\n onClick={(event) => {\n event.stopPropagation();\n onClose();\n }}>\n <XIcon className=\"text-white\"/>\n </IconButton>\n </div>\n </div>\n\n </div>\n );\n\n return (\n <Portal.Root asChild\n container={container}>\n <Formex value={formex as FormexController<Record<string, unknown>>}>\n {draggable}\n </Formex>\n </Portal.Root>\n );\n\n}\n"],"mappings":";;;;;;;;;;;;;;AA8CA,SAAgB,eAAkD,OAA+B;CAC7F,IAAI,CAAC,MAAM,MAAM,OAAO;CACxB,OAAO,oBAAC,uBAAD,EAAuB,GAAI,MAAO,CAAA;AAE7C;AAEA,SAAgB,sBAAyD,EACrE,UACA,UACA,sBACA,aACA,YAAY,iBACZ,MACA,UACA,MACA,SACA,mBACA,aACuB;CACvB,MAAM,aAAa,QAAQ;CAC3B,MAAM,CAAC,QAAQ,aAAa,SAAgC,KAAA,CAAS;CACrE,gBAAgB;EACZ,IAAI,YAAY,QAAQ,KAAK,iBACzB,WAAW,MAAM,IAAI,CAAC,CAAC,SAAS,QAAQ,CAAC,CAAC,MAAM,WAAW,UAAU,MAA+B,CAAC;CAE7G,GAAG;EAAC;EAAU;EAAiB;EAAY;CAAI,CAAC;CAEhD,IAAI,CAAC,QAAQ,OAAO;CACpB,OAAO,oBAAC,wBAAD;EACH;EACA;EACA;EACA;EACA,YAAY;EACZ;EACA;EACA;EACA;EACA;EACA;EACO;CAAQ,CAAA;AACvB;AAEA,SAAgB,uBAA0D,EACtE,UACA,UACA,sBACA,aACA,YACA,MACA,UACA,MACA,SACA,mBACA,WACA,UAGD;CACC,MAAM,EAAE,MAAM,eAAe;CAE7B,MAAM,gBAAgB,iBAAiB;CACvC,MAAM,iBAA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EAAa,SAAA;EACE;YACX,oBAAC,QAAD;GAAQ,OAAO;aACV;EACG,CAAA;CACC,CAAA;AAGrB"}
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { Entity, Property } from "@rebasepro/types";
2
+ import { Property, Entity } from "@rebasepro/cms-types";
3
3
  import { TableSize } from "@rebasepro/app";
4
4
  import { TableCellOpenerKind } from "./internal/TableCellOpener.js";
5
5
  export interface TableFieldBindingProps<T = unknown> {
@@ -49,5 +49,5 @@ export interface TableFieldConfig {
49
49
  hideOverflow?: boolean;
50
50
  includeActions?: boolean;
51
51
  }
52
- export declare function isStorageProperty(property: Property): boolean | import("@rebasepro/types").StorageConfig | undefined;
52
+ export declare function isStorageProperty(property: Property): boolean | import("@rebasepro/cms-types").StorageConfig | undefined;
53
53
  export declare function getTableBindingForProperty(property: Property, selected: boolean): TableFieldConfig | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"table_bindings.js","names":[],"sources":["../../../src/components/CollectionTableBinding/table_bindings.tsx"],"sourcesContent":["import React, { useEffect, useRef } from \"react\";\nimport { ArrayProperty, DateProperty, Entity, EntityReference, EntityRelation, NumberProperty, Property, ReferenceProperty, RelationProperty, StringProperty } from \"@rebasepro/types\";\nimport { TableSize, useCustomizationController } from \"@rebasepro/app\";\nimport {\n VirtualTableInput,\n VirtualTableNumberInput,\n VirtualTableSwitch,\n VirtualTableDateField\n} from \"@rebasepro/ui\";\n\nimport { VirtualTableSelect } from \"./fields/VirtualTableSelect\";\nimport { VirtualTableUserSelect } from \"./fields/VirtualTableUserSelect\";\nimport { TableStorageUpload } from \"./fields/TableStorageUpload\";\nimport { TableReferenceField } from \"./fields/TableReferenceField\";\nimport { TableRelationField } from \"./fields/TableRelationField\";\nimport { TableRelationSelectorField } from \"./fields/TableRelationSelectorField\";\n\nimport { getDatePropertyMode, getDatePropertyTimezone, getPreviewSizeFrom } from \"../../preview/util\";\nimport { TableCellOpenerKind } from \"./internal/TableCellOpener\";\n\nexport interface TableFieldBindingProps<T = unknown> {\n propertyKey: string;\n property: Property;\n internalValue: T;\n updateValue: (newValue: T | null) => void;\n error?: Error;\n validationError?: Error;\n disabled: boolean;\n selected: boolean;\n size: TableSize;\n align: \"left\" | \"center\" | \"right\";\n entity: Entity<Record<string, unknown>>;\n path: string;\n openPopup?: (cellRect: DOMRect | undefined) => void;\n /**\n * Whether the cell's floating editor is open — its dropdown, its selection\n * dialog, its date picker. The cell's opener sets it as well as the\n * editor's own trigger, and it can be set before the editor has mounted.\n */\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n /**\n * What the cell shows at rest. An editor with a trigger shows this same\n * node in it, so selecting the cell changes its frame and nothing else.\n */\n preview?: React.ReactNode;\n /**\n * The cell's element. A floating editor opens against it rather than\n * against its own trigger, which can be taller than the cell clipping it.\n */\n anchorRef?: React.RefObject<HTMLElement | null>;\n}\n\nexport interface TableFieldConfig {\n Component: React.ComponentType<TableFieldBindingProps>;\n /**\n * The opener the cell reveals on hover, and keeps shown while selected,\n * to open this editor in one click. None for editors that are the value\n * itself (a text input, a switch) or that draw their own (storage).\n */\n opener?: TableCellOpenerKind;\n fullHeight?: boolean;\n allowScroll?: boolean;\n removePadding?: boolean;\n showExpandIcon?: boolean;\n hideOverflow?: boolean;\n includeActions?: boolean;\n}\n\nexport function isStorageProperty(property: Property) {\n if (property.type === \"string\" && property.admin?.markdown)\n return false;\n if (property.type === \"string\" && (property as StringProperty).storage)\n return true;\n if (property.type === \"array\") {\n if (Array.isArray(property.of)) {\n return false;\n } else {\n return ((property as ArrayProperty).of as Property)?.type === \"string\" &&\n ((property as ArrayProperty).of as StringProperty)?.storage\n }\n }\n return false;\n}\n\nexport function getTableBindingForProperty(\n property: Property,\n selected: boolean\n): TableFieldConfig | undefined {\n const isAStorageProperty = isStorageProperty(property);\n\n if (isAStorageProperty) {\n return {\n Component: ({ validationError, error, disabled, selected, openPopup, property, entity, path, internalValue, size, updateValue, propertyKey }: TableFieldBindingProps) => (\n <TableStorageUpload\n error={validationError ?? error}\n disabled={disabled}\n focused={selected}\n selected={selected}\n openPopup={openPopup}\n property={property as StringProperty | ArrayProperty}\n entity={entity}\n path={path}\n value={internalValue as string | string[] | null}\n previewSize={getPreviewSizeFrom(size)}\n updateValue={updateValue}\n propertyKey={propertyKey}\n />\n ),\n includeActions: false,\n showExpandIcon: true,\n fullHeight: true,\n removePadding: true\n };\n } else if (selected && property.type === \"number\") {\n const numberProperty = property as NumberProperty;\n if (numberProperty.enum) {\n return {\n Component: ({ propertyKey, disabled, selected, size, error, validationError, internalValue, updateValue, open, onOpenChange, preview, anchorRef }: TableFieldBindingProps) => (\n <VirtualTableSelect\n name={propertyKey}\n multiple={false}\n disabled={disabled}\n focused={selected}\n valueType={\"number\"}\n small={getPreviewSizeFrom(size) !== \"medium\"}\n enumValues={numberProperty.enum!}\n error={validationError ?? error}\n internalValue={internalValue as string | number}\n updateValue={updateValue}\n open={open}\n onOpenChange={onOpenChange}\n preview={preview}\n anchorRef={anchorRef}\n />\n ),\n opener: \"dropdown\"\n };\n } else {\n return {\n Component: ({ align, error, validationError, selected, disabled, internalValue, updateValue }: TableFieldBindingProps) => (\n <VirtualTableNumberInput\n align={align}\n error={validationError ?? error}\n focused={selected}\n disabled={disabled}\n value={internalValue as number}\n updateValue={updateValue}\n />\n ),\n allowScroll: true\n };\n }\n } else if (selected && property.type === \"string\") {\n const stringProperty = property as StringProperty;\n if (stringProperty.enum) {\n return {\n Component: ({ propertyKey, disabled, selected, size, error, validationError, internalValue, updateValue, open, onOpenChange, preview, anchorRef }: TableFieldBindingProps) => (\n <VirtualTableSelect\n name={propertyKey}\n multiple={false}\n focused={selected}\n disabled={disabled}\n valueType={\"string\"}\n small={getPreviewSizeFrom(size) !== \"medium\"}\n enumValues={stringProperty.enum!}\n error={validationError ?? error}\n internalValue={internalValue as string | number}\n updateValue={updateValue}\n open={open}\n onOpenChange={onOpenChange}\n preview={preview}\n anchorRef={anchorRef}\n />\n ),\n opener: \"dropdown\"\n };\n } else if (stringProperty.userSelect) {\n return {\n Component: ({ propertyKey, disabled, selected, size, error, validationError, internalValue, updateValue, open, onOpenChange, preview, anchorRef }: TableFieldBindingProps) => (\n <VirtualTableUserSelect\n name={propertyKey}\n multiple={false}\n focused={selected}\n disabled={disabled}\n small={getPreviewSizeFrom(size) !== \"medium\"}\n error={validationError ?? error}\n internalValue={internalValue as string}\n updateValue={updateValue}\n open={open}\n onOpenChange={onOpenChange}\n preview={preview}\n anchorRef={anchorRef}\n />\n ),\n opener: \"dropdown\"\n };\n } else if (stringProperty.admin?.markdown || !stringProperty.storage) {\n const markdown = Boolean(stringProperty.admin?.markdown);\n const multiline = Boolean(stringProperty.admin?.multiline) || markdown;\n return {\n Component: ({ error, validationError, disabled, selected, internalValue, updateValue }: TableFieldBindingProps) => {\n const input = <VirtualTableInput\n error={validationError ?? error}\n disabled={disabled}\n multiline={multiline}\n focused={selected}\n value={internalValue as string}\n // An emptied cell is NULL, as an emptied form field is.\n updateValue={(value) => updateValue(value === \"\" ? null : value)}\n />;\n // A cell draws markdown as `prose-sm`, on a 24px line. The\n // source is edited on that line too, so a paragraph stays\n // where it was when the cell is selected.\n return markdown ? <div className={\"flex w-full leading-6\"}>{input}</div> : input;\n },\n allowScroll: true\n };\n }\n } else if (property.type === \"boolean\") {\n return {\n Component: ({ error, validationError, disabled, selected, internalValue, updateValue }: TableFieldBindingProps) => (\n <VirtualTableSwitch\n error={validationError ?? error}\n disabled={disabled}\n focused={selected}\n internalValue={internalValue as boolean}\n updateValue={updateValue}\n />\n )\n };\n } else if (property.type === \"date\") {\n return {\n Component: DateBindingComponent,\n opener: \"calendar\",\n fullHeight: true,\n hideOverflow: false,\n allowScroll: false\n };\n } else if (property.type === \"reference\") {\n if ((property as ReferenceProperty).path) {\n return {\n Component: ({ propertyKey, internalValue, updateValue, disabled, size, property, selected, open, onOpenChange }: TableFieldBindingProps) => {\n return (\n <TableReferenceField\n name={propertyKey}\n selected={selected}\n open={open}\n onOpenChange={onOpenChange}\n internalValue={internalValue as EntityReference}\n updateValue={updateValue}\n disabled={disabled}\n size={size}\n path={(property as ReferenceProperty).path!}\n multiselect={false}\n previewProperties={(property as ReferenceProperty).admin?.previewProperties}\n includeId={(property as ReferenceProperty).admin?.includeId}\n includeEntityLink={(property as ReferenceProperty).admin?.includeEntityLink}\n fixedFilter={(property as ReferenceProperty).admin?.fixedFilter}\n />\n );\n },\n opener: \"dialog\",\n allowScroll: false\n };\n }\n } else if (property.type === \"relation\") {\n if ((property as RelationProperty).relation) {\n if ((property as RelationProperty).admin?.widget === \"dialog\") {\n return {\n Component: RelationDialogBindingComponent,\n opener: \"dialog\",\n allowScroll: false\n };\n } else if (selected) {\n // Gated on `selected`, like the number and string editors above.\n // This one mounts a live picker against the *target* collection,\n // and the cell is rendered once per visible row: ungated, opening\n // a table with one relation column fired a request — or, on the\n // realtime path, a subscription — per row, for data nobody had\n // asked to see. Unselected cells fall through to PropertyPreview.\n return {\n Component: RelationSelectorBindingComponent,\n opener: \"dropdown\",\n allowScroll: false\n };\n }\n }\n } else if (property.type === \"array\") {\n const arrayProperty = (property as ArrayProperty);\n\n if (!arrayProperty.of && !arrayProperty.oneOf) {\n throw Error(\"You need to specify an 'of' or 'oneOf' prop (or specify a custom field) in your array property\");\n } else if (arrayProperty.of && !Array.isArray(arrayProperty.of)) {\n const ofProp = arrayProperty.of as Property;\n if (ofProp.type === \"string\" || ofProp.type === \"number\") {\n if (selected && ofProp.enum) {\n return {\n Component: ({ propertyKey, disabled, selected, size, error, validationError, internalValue, updateValue, open, onOpenChange, preview, anchorRef }: TableFieldBindingProps) => (\n <VirtualTableSelect\n name={propertyKey}\n multiple={true}\n disabled={disabled}\n focused={selected}\n small={getPreviewSizeFrom(size) !== \"medium\"}\n valueType={ofProp.type}\n enumValues={ofProp.enum!}\n error={validationError ?? error}\n internalValue={internalValue as string | number}\n updateValue={updateValue}\n open={open}\n onOpenChange={onOpenChange}\n preview={preview}\n anchorRef={anchorRef}\n />\n ),\n opener: \"dropdown\"\n };\n }\n } else if (ofProp.type === \"reference\") {\n const refOfProp = ofProp as ReferenceProperty;\n if (refOfProp.path) {\n return {\n Component: ({ propertyKey, disabled, internalValue, updateValue, size, selected, open, onOpenChange }: TableFieldBindingProps) => (\n <TableReferenceField\n name={propertyKey}\n selected={selected}\n open={open}\n onOpenChange={onOpenChange}\n disabled={disabled}\n internalValue={internalValue as EntityReference[]}\n updateValue={updateValue}\n size={size}\n multiselect={true}\n path={refOfProp.path!}\n previewProperties={refOfProp.admin?.previewProperties}\n fixedFilter={refOfProp.admin?.fixedFilter}\n includeId={refOfProp.admin?.includeId}\n includeEntityLink={refOfProp.admin?.includeEntityLink}\n />\n ),\n opener: \"dialog\",\n allowScroll: false\n };\n }\n }\n }\n }\n\n return undefined;\n}\n\n/**\n * Stable component for date cells. The input is always there, at rest too, so\n * a date can be typed into; the cell's opener shows the picker through it.\n */\nfunction DateBindingComponent({ propertyKey, error, validationError, disabled, selected, size, property, internalValue, updateValue, open, onOpenChange }: TableFieldBindingProps) {\n const { locale } = useCustomizationController();\n const inputRef = useRef<HTMLInputElement>(null);\n\n // The native picker has no open state to report back: showing it is a\n // one-off request, handed straight back as closed. `showPicker` needs the\n // click that asked for it, which is still the current task here.\n useEffect(() => {\n if (!open) return;\n onOpenChange?.(false);\n const input = inputRef.current;\n if (!input) return;\n try {\n input.showPicker();\n } catch {\n input.focus();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [open]);\n\n return (\n <VirtualTableDateField\n name={propertyKey}\n error={validationError ?? error}\n disabled={disabled}\n small={getPreviewSizeFrom(size) !== \"medium\"}\n mode={getDatePropertyMode(property as DateProperty)}\n timezone={getDatePropertyTimezone(property as DateProperty)}\n focused={selected}\n internalValue={internalValue as Date}\n updateValue={updateValue}\n locale={locale}\n pickerButton={onOpenChange === undefined}\n inputRef={inputRef}\n />\n );\n}\n\n/** Stable component for relation fields rendered with the dialog widget */\nfunction RelationDialogBindingComponent({ propertyKey, internalValue, updateValue, disabled, size, property, selected, open, onOpenChange }: TableFieldBindingProps) {\n const relProp = property as RelationProperty;\n return (\n <TableRelationField\n name={propertyKey}\n selected={selected}\n open={open}\n onOpenChange={onOpenChange}\n internalValue={internalValue as EntityRelation}\n updateValue={updateValue}\n disabled={disabled}\n size={size}\n multiselect={false}\n relation={relProp.relation!}\n previewProperties={relProp.admin?.previewProperties}\n includeId={relProp.admin?.includeId}\n includeEntityLink={relProp.admin?.includeEntityLink}\n fixedFilter={relProp.admin?.fixedFilter}\n />\n );\n}\n\n/** Stable component for relation fields rendered with the inline selector */\nfunction RelationSelectorBindingComponent({ propertyKey, internalValue, updateValue, disabled, property, selected, open, onOpenChange, preview, anchorRef }: TableFieldBindingProps) {\n const relProp = property as RelationProperty;\n return (\n <TableRelationSelectorField\n name={propertyKey}\n internalValue={internalValue as EntityRelation}\n updateValue={updateValue}\n disabled={disabled}\n relation={relProp.relation!}\n fixedFilter={relProp.admin?.fixedFilter}\n focused={selected}\n open={open}\n onOpenChange={onOpenChange}\n preview={preview}\n anchorRef={anchorRef}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;;AAqEA,SAAgB,kBAAkB,UAAoB;CAClD,IAAI,SAAS,SAAS,YAAY,SAAS,OAAO,UAC9C,OAAO;CACX,IAAI,SAAS,SAAS,YAAa,SAA4B,SAC3D,OAAO;CACX,IAAI,SAAS,SAAS,SAClB,IAAI,MAAM,QAAQ,SAAS,EAAE,GACzB,OAAO;MAEP,OAAS,SAA2B,IAAiB,SAAS,YACxD,SAA2B,IAAuB;CAGhE,OAAO;AACX;AAEA,SAAgB,2BACZ,UACA,UAC4B;CAG5B,IAF2B,kBAAkB,QAEzC,GACA,OAAO;EACH,YAAY,EAAE,iBAAiB,OAAO,UAAU,UAAU,WAAW,UAAU,QAAQ,MAAM,eAAe,MAAM,aAAa,kBAC3H,oBAAC,oBAAD;GACI,OAAO,mBAAmB;GAChB;GACV,SAAS;GACC;GACC;GACD;GACF;GACF;GACN,OAAO;GACP,aAAa,mBA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K,MAAM,EAAE,WAAW,2BAA2B;CAC9C,MAAM,WAAW,OAAyB,IAAI;CAK9C,gBAAgB;EACZ,IAAI,CAAC,MAAM;EACX,eAAe,KAAK;EACpB,MAAM,QAAQ,SAAS;EACvB,IAAI,CAAC,OAAO;EACZ,IAAI;GACA,MAAM,WAAW;EACrB,QAAQ;GACJ,MAAM,MAAM;EAChB;CAEJ,GAAG,CAAC,IAAI,CAAC;CAET,OACI,oBAAC,uBAAD;EACI,MAAM;EACN,OAAO,mBAAmB;EAChB;EACV,OAAO,mBAAmB,IAAI,MAAM;EACpC,MAAM,oBAAoB,QAAwB;EAClD,UAAU,wBAAwB,QAAwB;EAC1D,SAAS;EACM;EACF;EACL;EACR,cAAc,iBAAiB,KAAA;EACrB;CACb,CAAA;AAET;;AAGA,SAAS,+BAA+B,EAAE,aAAa,eAAe,aAAa,UAAU,MAAM,UAAU,UAAU,MAAM,gBAAwC;CACjK,MAAM,UAAU;CAChB,OACI,oBAAC,oBAAD;EACI,MAAM;EACI;EACJ;EACQ;EACC;EACF;EACH;EACJ;EACN,aAAa;EACb,UAAU,QAAQ;EAClB,mBAAmB,QAAQ,OAAO;EAClC,WAAW,QAAQ,OAAO;EAC1B,mBAAmB,QAAQ,OAAO;EAClC,aAAa,QAAQ,OAAO;CAC/B,CAAA;AAET;;AAGA,SAAS,iCAAiC,EAAE,aAAa,eAAe,aAAa,UAAU,UAAU,UAAU,MAAM,cAAc,SAAS,aAAqC;CACjL,MAAM,UAAU;CAChB,OACI,oBAAC,4BAAD;EACI,MAAM;EACS;EACF;EACH;EACV,UAAU,QAAQ;EAClB,aAAa,QAAQ,OAAO;EAC5B,SAAS;EACH;EACQ;EACL;EACE;CACd,CAAA;AAET"}
1
+ {"version":3,"file":"table_bindings.js","names":[],"sources":["../../../src/components/CollectionTableBinding/table_bindings.tsx"],"sourcesContent":["import React, { useEffect, useRef } from \"react\";\nimport { ArrayProperty, DateProperty, NumberProperty, Property, ReferenceProperty, RelationProperty, StringProperty, EntityReference, EntityRelation, Entity } from \"@rebasepro/cms-types\";\nimport { TableSize, useCustomizationController } from \"@rebasepro/app\";\nimport {\n VirtualTableInput,\n VirtualTableNumberInput,\n VirtualTableSwitch,\n VirtualTableDateField\n} from \"@rebasepro/ui\";\n\nimport { VirtualTableSelect } from \"./fields/VirtualTableSelect\";\nimport { VirtualTableUserSelect } from \"./fields/VirtualTableUserSelect\";\nimport { TableStorageUpload } from \"./fields/TableStorageUpload\";\nimport { TableReferenceField } from \"./fields/TableReferenceField\";\nimport { TableRelationField } from \"./fields/TableRelationField\";\nimport { TableRelationSelectorField } from \"./fields/TableRelationSelectorField\";\n\nimport { getDatePropertyMode, getDatePropertyTimezone, getPreviewSizeFrom } from \"../../preview/util\";\nimport { TableCellOpenerKind } from \"./internal/TableCellOpener\";\n\nexport interface TableFieldBindingProps<T = unknown> {\n propertyKey: string;\n property: Property;\n internalValue: T;\n updateValue: (newValue: T | null) => void;\n error?: Error;\n validationError?: Error;\n disabled: boolean;\n selected: boolean;\n size: TableSize;\n align: \"left\" | \"center\" | \"right\";\n entity: Entity<Record<string, unknown>>;\n path: string;\n openPopup?: (cellRect: DOMRect | undefined) => void;\n /**\n * Whether the cell's floating editor is open — its dropdown, its selection\n * dialog, its date picker. The cell's opener sets it as well as the\n * editor's own trigger, and it can be set before the editor has mounted.\n */\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n /**\n * What the cell shows at rest. An editor with a trigger shows this same\n * node in it, so selecting the cell changes its frame and nothing else.\n */\n preview?: React.ReactNode;\n /**\n * The cell's element. A floating editor opens against it rather than\n * against its own trigger, which can be taller than the cell clipping it.\n */\n anchorRef?: React.RefObject<HTMLElement | null>;\n}\n\nexport interface TableFieldConfig {\n Component: React.ComponentType<TableFieldBindingProps>;\n /**\n * The opener the cell reveals on hover, and keeps shown while selected,\n * to open this editor in one click. None for editors that are the value\n * itself (a text input, a switch) or that draw their own (storage).\n */\n opener?: TableCellOpenerKind;\n fullHeight?: boolean;\n allowScroll?: boolean;\n removePadding?: boolean;\n showExpandIcon?: boolean;\n hideOverflow?: boolean;\n includeActions?: boolean;\n}\n\nexport function isStorageProperty(property: Property) {\n if (property.type === \"string\" && property.admin?.markdown)\n return false;\n if (property.type === \"string\" && (property as StringProperty).storage)\n return true;\n if (property.type === \"array\") {\n if (Array.isArray(property.of)) {\n return false;\n } else {\n return ((property as ArrayProperty).of as Property)?.type === \"string\" &&\n ((property as ArrayProperty).of as StringProperty)?.storage\n }\n }\n return false;\n}\n\nexport function getTableBindingForProperty(\n property: Property,\n selected: boolean\n): TableFieldConfig | undefined {\n const isAStorageProperty = isStorageProperty(property);\n\n if (isAStorageProperty) {\n return {\n Component: ({ validationError, error, disabled, selected, openPopup, property, entity, path, internalValue, size, updateValue, propertyKey }: TableFieldBindingProps) => (\n <TableStorageUpload\n error={validationError ?? error}\n disabled={disabled}\n focused={selected}\n selected={selected}\n openPopup={openPopup}\n property={property as StringProperty | ArrayProperty}\n entity={entity}\n path={path}\n value={internalValue as string | string[] | null}\n previewSize={getPreviewSizeFrom(size)}\n updateValue={updateValue}\n propertyKey={propertyKey}\n />\n ),\n includeActions: false,\n showExpandIcon: true,\n fullHeight: true,\n removePadding: true\n };\n } else if (selected && property.type === \"number\") {\n const numberProperty = property as NumberProperty;\n if (numberProperty.enum) {\n return {\n Component: ({ propertyKey, disabled, selected, size, error, validationError, internalValue, updateValue, open, onOpenChange, preview, anchorRef }: TableFieldBindingProps) => (\n <VirtualTableSelect\n name={propertyKey}\n multiple={false}\n disabled={disabled}\n focused={selected}\n valueType={\"number\"}\n small={getPreviewSizeFrom(size) !== \"medium\"}\n enumValues={numberProperty.enum!}\n error={validationError ?? error}\n internalValue={internalValue as string | number}\n updateValue={updateValue}\n open={open}\n onOpenChange={onOpenChange}\n preview={preview}\n anchorRef={anchorRef}\n />\n ),\n opener: \"dropdown\"\n };\n } else {\n return {\n Component: ({ align, error, validationError, selected, disabled, internalValue, updateValue }: TableFieldBindingProps) => (\n <VirtualTableNumberInput\n align={align}\n error={validationError ?? error}\n focused={selected}\n disabled={disabled}\n value={internalValue as number}\n updateValue={updateValue}\n />\n ),\n allowScroll: true\n };\n }\n } else if (selected && property.type === \"string\") {\n const stringProperty = property as StringProperty;\n if (stringProperty.enum) {\n return {\n Component: ({ propertyKey, disabled, selected, size, error, validationError, internalValue, updateValue, open, onOpenChange, preview, anchorRef }: TableFieldBindingProps) => (\n <VirtualTableSelect\n name={propertyKey}\n multiple={false}\n focused={selected}\n disabled={disabled}\n valueType={\"string\"}\n small={getPreviewSizeFrom(size) !== \"medium\"}\n enumValues={stringProperty.enum!}\n error={validationError ?? error}\n internalValue={internalValue as string | number}\n updateValue={updateValue}\n open={open}\n onOpenChange={onOpenChange}\n preview={preview}\n anchorRef={anchorRef}\n />\n ),\n opener: \"dropdown\"\n };\n } else if (stringProperty.userSelect) {\n return {\n Component: ({ propertyKey, disabled, selected, size, error, validationError, internalValue, updateValue, open, onOpenChange, preview, anchorRef }: TableFieldBindingProps) => (\n <VirtualTableUserSelect\n name={propertyKey}\n multiple={false}\n focused={selected}\n disabled={disabled}\n small={getPreviewSizeFrom(size) !== \"medium\"}\n error={validationError ?? error}\n internalValue={internalValue as string}\n updateValue={updateValue}\n open={open}\n onOpenChange={onOpenChange}\n preview={preview}\n anchorRef={anchorRef}\n />\n ),\n opener: \"dropdown\"\n };\n } else if (stringProperty.admin?.markdown || !stringProperty.storage) {\n const markdown = Boolean(stringProperty.admin?.markdown);\n const multiline = Boolean(stringProperty.admin?.multiline) || markdown;\n return {\n Component: ({ error, validationError, disabled, selected, internalValue, updateValue }: TableFieldBindingProps) => {\n const input = <VirtualTableInput\n error={validationError ?? error}\n disabled={disabled}\n multiline={multiline}\n focused={selected}\n value={internalValue as string}\n // An emptied cell is NULL, as an emptied form field is.\n updateValue={(value) => updateValue(value === \"\" ? null : value)}\n />;\n // A cell draws markdown as `prose-sm`, on a 24px line. The\n // source is edited on that line too, so a paragraph stays\n // where it was when the cell is selected.\n return markdown ? <div className={\"flex w-full leading-6\"}>{input}</div> : input;\n },\n allowScroll: true\n };\n }\n } else if (property.type === \"boolean\") {\n return {\n Component: ({ error, validationError, disabled, selected, internalValue, updateValue }: TableFieldBindingProps) => (\n <VirtualTableSwitch\n error={validationError ?? error}\n disabled={disabled}\n focused={selected}\n internalValue={internalValue as boolean}\n updateValue={updateValue}\n />\n )\n };\n } else if (property.type === \"date\") {\n return {\n Component: DateBindingComponent,\n opener: \"calendar\",\n fullHeight: true,\n hideOverflow: false,\n allowScroll: false\n };\n } else if (property.type === \"reference\") {\n if ((property as ReferenceProperty).path) {\n return {\n Component: ({ propertyKey, internalValue, updateValue, disabled, size, property, selected, open, onOpenChange }: TableFieldBindingProps) => {\n return (\n <TableReferenceField\n name={propertyKey}\n selected={selected}\n open={open}\n onOpenChange={onOpenChange}\n internalValue={internalValue as EntityReference}\n updateValue={updateValue}\n disabled={disabled}\n size={size}\n path={(property as ReferenceProperty).path!}\n multiselect={false}\n previewProperties={(property as ReferenceProperty).admin?.previewProperties}\n includeId={(property as ReferenceProperty).admin?.includeId}\n includeEntityLink={(property as ReferenceProperty).admin?.includeEntityLink}\n fixedFilter={(property as ReferenceProperty).admin?.fixedFilter}\n />\n );\n },\n opener: \"dialog\",\n allowScroll: false\n };\n }\n } else if (property.type === \"relation\") {\n if ((property as RelationProperty).relation) {\n if ((property as RelationProperty).admin?.widget === \"dialog\") {\n return {\n Component: RelationDialogBindingComponent,\n opener: \"dialog\",\n allowScroll: false\n };\n } else if (selected) {\n // Gated on `selected`, like the number and string editors above.\n // This one mounts a live picker against the *target* collection,\n // and the cell is rendered once per visible row: ungated, opening\n // a table with one relation column fired a request — or, on the\n // realtime path, a subscription — per row, for data nobody had\n // asked to see. Unselected cells fall through to PropertyPreview.\n return {\n Component: RelationSelectorBindingComponent,\n opener: \"dropdown\",\n allowScroll: false\n };\n }\n }\n } else if (property.type === \"array\") {\n const arrayProperty = (property as ArrayProperty);\n\n if (!arrayProperty.of && !arrayProperty.oneOf) {\n throw Error(\"You need to specify an 'of' or 'oneOf' prop (or specify a custom field) in your array property\");\n } else if (arrayProperty.of && !Array.isArray(arrayProperty.of)) {\n const ofProp = arrayProperty.of as Property;\n if (ofProp.type === \"string\" || ofProp.type === \"number\") {\n if (selected && ofProp.enum) {\n return {\n Component: ({ propertyKey, disabled, selected, size, error, validationError, internalValue, updateValue, open, onOpenChange, preview, anchorRef }: TableFieldBindingProps) => (\n <VirtualTableSelect\n name={propertyKey}\n multiple={true}\n disabled={disabled}\n focused={selected}\n small={getPreviewSizeFrom(size) !== \"medium\"}\n valueType={ofProp.type}\n enumValues={ofProp.enum!}\n error={validationError ?? error}\n internalValue={internalValue as string | number}\n updateValue={updateValue}\n open={open}\n onOpenChange={onOpenChange}\n preview={preview}\n anchorRef={anchorRef}\n />\n ),\n opener: \"dropdown\"\n };\n }\n } else if (ofProp.type === \"reference\") {\n const refOfProp = ofProp as ReferenceProperty;\n if (refOfProp.path) {\n return {\n Component: ({ propertyKey, disabled, internalValue, updateValue, size, selected, open, onOpenChange }: TableFieldBindingProps) => (\n <TableReferenceField\n name={propertyKey}\n selected={selected}\n open={open}\n onOpenChange={onOpenChange}\n disabled={disabled}\n internalValue={internalValue as EntityReference[]}\n updateValue={updateValue}\n size={size}\n multiselect={true}\n path={refOfProp.path!}\n previewProperties={refOfProp.admin?.previewProperties}\n fixedFilter={refOfProp.admin?.fixedFilter}\n includeId={refOfProp.admin?.includeId}\n includeEntityLink={refOfProp.admin?.includeEntityLink}\n />\n ),\n opener: \"dialog\",\n allowScroll: false\n };\n }\n }\n }\n }\n\n return undefined;\n}\n\n/**\n * Stable component for date cells. The input is always there, at rest too, so\n * a date can be typed into; the cell's opener shows the picker through it.\n */\nfunction DateBindingComponent({ propertyKey, error, validationError, disabled, selected, size, property, internalValue, updateValue, open, onOpenChange }: TableFieldBindingProps) {\n const { locale } = useCustomizationController();\n const inputRef = useRef<HTMLInputElement>(null);\n\n // The native picker has no open state to report back: showing it is a\n // one-off request, handed straight back as closed. `showPicker` needs the\n // click that asked for it, which is still the current task here.\n useEffect(() => {\n if (!open) return;\n onOpenChange?.(false);\n const input = inputRef.current;\n if (!input) return;\n try {\n input.showPicker();\n } catch {\n input.focus();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [open]);\n\n return (\n <VirtualTableDateField\n name={propertyKey}\n error={validationError ?? error}\n disabled={disabled}\n small={getPreviewSizeFrom(size) !== \"medium\"}\n mode={getDatePropertyMode(property as DateProperty)}\n timezone={getDatePropertyTimezone(property as DateProperty)}\n focused={selected}\n internalValue={internalValue as Date}\n updateValue={updateValue}\n locale={locale}\n pickerButton={onOpenChange === undefined}\n inputRef={inputRef}\n />\n );\n}\n\n/** Stable component for relation fields rendered with the dialog widget */\nfunction RelationDialogBindingComponent({ propertyKey, internalValue, updateValue, disabled, size, property, selected, open, onOpenChange }: TableFieldBindingProps) {\n const relProp = property as RelationProperty;\n return (\n <TableRelationField\n name={propertyKey}\n selected={selected}\n open={open}\n onOpenChange={onOpenChange}\n internalValue={internalValue as EntityRelation}\n updateValue={updateValue}\n disabled={disabled}\n size={size}\n multiselect={false}\n relation={relProp.relation!}\n previewProperties={relProp.admin?.previewProperties}\n includeId={relProp.admin?.includeId}\n includeEntityLink={relProp.admin?.includeEntityLink}\n fixedFilter={relProp.admin?.fixedFilter}\n />\n );\n}\n\n/** Stable component for relation fields rendered with the inline selector */\nfunction RelationSelectorBindingComponent({ propertyKey, internalValue, updateValue, disabled, property, selected, open, onOpenChange, preview, anchorRef }: TableFieldBindingProps) {\n const relProp = property as RelationProperty;\n return (\n <TableRelationSelectorField\n name={propertyKey}\n internalValue={internalValue as EntityRelation}\n updateValue={updateValue}\n disabled={disabled}\n relation={relProp.relation!}\n fixedFilter={relProp.admin?.fixedFilter}\n focused={selected}\n open={open}\n onOpenChange={onOpenChange}\n preview={preview}\n anchorRef={anchorRef}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;;AAqEA,SAAgB,kBAAkB,UAAoB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AO;EAClC,WAAW,QAAQ,OAAO;EAC1B,mBAAmB,QAAQ,OAAO;EAClC,aAAa,QAAQ,OAAO;CAC/B,CAAA;AAET;;AAGA,SAAS,iCAAiC,EAAE,aAAa,eAAe,aAAa,UAAU,UAAU,UAAU,MAAM,cAAc,SAAS,aAAqC;CACjL,MAAM,UAAU;CAChB,OACI,oBAAC,4BAAD;EACI,MAAM;EACS;EACF;EACH;EACV,UAAU,QAAQ;EAClB,aAAa,QAAQ,OAAO;EAC5B,SAAS;EACH;EACQ;EACL;EACE;CACd,CAAA;AAET"}
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { Entity } from "@rebasepro/types";
2
+ import { Entity } from "@rebasepro/cms-types";
3
3
  import { BoardItemViewProps } from "@rebasepro/ui";
4
4
  import type { AdminCollection } from "@rebasepro/cms-types";
5
5
  export type BoardCardBindingProps<M extends Record<string, unknown> = Record<string, unknown>> = BoardItemViewProps<Entity<M>> & {
@@ -1 +1 @@
1
- {"version":3,"file":"BoardCardBinding.js","names":[],"sources":["../../../src/components/CollectionViewBinding/BoardCardBinding.tsx"],"sourcesContent":["\nimport React, { memo, useCallback, useMemo } from \"react\";\nimport { Entity } from \"@rebasepro/types\";\nimport { Checkbox, Chip, cls, defaultBorderMixin } from \"@rebasepro/ui\";\nimport { StorageMarkdown } from \"../../preview/components/StorageMarkdown\";\nimport { PropertyPreview } from \"../../preview\";\nimport { useAuthController, useCustomizationController, useTranslation } from \"@rebasepro/app\";\nimport { IconForView } from \"@rebasepro/app\";\nimport { BoardItemViewProps } from \"@rebasepro/ui\";\nimport { useCollectionSlotKeys, useEntitySlots, useImagePlace } from \"./usePreviewSlots\";\nimport { SlotValue, TagChips } from \"./SlotValue\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\n\nexport type BoardCardBindingProps<M extends Record<string, unknown> = Record<string, unknown>> = BoardItemViewProps<Entity<M>> & {\n collection: AdminCollection<M>;\n onClick?: (entity: Entity<M>) => void;\n selected?: boolean;\n onSelectionChange?: (entity: Entity<M>, selected: boolean) => void;\n selectionEnabled?: boolean;\n /**\n * Draws the record's actions beside the card's title — the collection's\n * `entityActions` with Copy and Delete, placed as a table row places them.\n */\n renderActions?: (entity: Entity<M>) => React.ReactNode;\n};\n\n/**\n * Compact card component for displaying a entity in a Kanban board.\n * Uses the shared slot system for consistent preview rendering.\n *\n * Selection UX: The checkbox overlays on top of the image/icon thumbnail area,\n * revealed on card hover or when the card is selected. This keeps the card\n * layout clean while providing intuitive selection affordance.\n */\nfunction BoardCardBindingInner<M extends Record<string, unknown> = Record<string, unknown>>({\n item,\n isDragging,\n isGroupedOver,\n style,\n collection,\n onClick,\n selected,\n onSelectionChange,\n selectionEnabled = false,\n renderActions\n}: BoardCardBindingProps<M>) {\n const { t } = useTranslation();\n const entity = item.data;\n const authController = useAuthController();\n const customizationController = useCustomizationController();\n\n const slotKeys = useCollectionSlotKeys(\n collection as AdminCollection<Record<string, unknown>>,\n authController,\n customizationController.propertyConfigs\n );\n\n const slots = useEntitySlots(\n entity as Entity<Record<string, unknown>>,\n collection as AdminCollection<Record<string, unknown>>,\n slotKeys\n );\n const imagePlace = useImagePlace(slotKeys.imageKey);\n\n const handleClick = useCallback((e: React.MouseEvent) => {\n // Cmd+click (Mac) or Ctrl+click (Windows) toggles selection\n if ((e.metaKey || e.ctrlKey) && selectionEnabled) {\n e.preventDefault();\n e.stopPropagation();\n onSelectionChange?.(entity, !selected);\n return;\n }\n if (onClick) {\n e.stopPropagation();\n onClick(entity);\n }\n }, [entity, onClick, onSelectionChange, selected, selectionEnabled]);\n\n const handleThumbnailClick = useCallback((e: React.MouseEvent) => {\n if (!selectionEnabled) return;\n e.stopPropagation();\n e.preventDefault();\n onSelectionChange?.(entity, !selected);\n }, [entity, onSelectionChange, selected, selectionEnabled]);\n\n const handleSelectionChange = useCallback((checked: boolean) => {\n onSelectionChange?.(entity, checked);\n }, [entity, onSelectionChange]);\n\n // Memoize className computations\n const backgroundColor = useMemo((): string => {\n if (isDragging) {\n return \"bg-surface-raised\";\n }\n if (isGroupedOver) {\n return \"bg-surface-raised\";\n }\n return \"bg-surface-card hover:bg-surface-hover\";\n }, [isDragging, isGroupedOver]);\n\n const borderColor = useMemo((): string =>\n isDragging ? \"ring-2 ring-primary\" : \"\", [isDragging]);\n\n // Memoize the card className — use CSS group for hover-reveal of checkbox\n const cardClassName = useMemo(() => cls(\n \"group/card p-2 flex items-start border rounded-lg cursor-pointer transition-all duration-200\",\n defaultBorderMixin,\n borderColor,\n backgroundColor,\n selected\n ? \"ring-2 ring-primary bg-primary/[0.03] dark:bg-primary/[0.06]\"\n : \"hover:shadow-sm\"\n ), [borderColor, backgroundColor, selected]);\n\n return (\n <div\n style={style}\n className=\"py-1\"\n data-is-dragging={isDragging}\n data-testid={item.id}\n onClick={handleClick}\n >\n <div className={cardClassName}>\n {/* Thumbnail area with selection overlay. Where `fields` leaves\n every image out it holds only the checkbox, and with no\n selection it is not drawn. */}\n {(imagePlace || selectionEnabled) && <div\n className=\"relative w-10 h-10 rounded-md shrink-0 mr-2\"\n onClick={handleThumbnailClick}\n >\n {/* Image or fallback icon */}\n {!imagePlace ? null : slots.image ? (\n <div className={cls(\n \"w-10 h-10 rounded-md overflow-hidden transition-opacity duration-200\",\n selectionEnabled && \"group-hover/card:opacity-30\",\n selected && \"opacity-0\"\n )}>\n <SlotValue slot={slots.image} size=\"small\" fill={true}/>\n </div>\n ) : (\n <div className={cls(\n \"w-10 h-10 rounded-md bg-surface-raised flex items-center justify-center transition-opacity duration-200\",\n selectionEnabled && \"group-hover/card:opacity-30\",\n selected && \"opacity-0\"\n )}>\n <IconForView\n collectionOrView={collection}\n color=\"disabled\"\n size=\"small\"\n />\n </div>\n )}\n\n {/* Selection checkbox overlay — always in the DOM, visibility controlled by CSS */}\n <div className={cls(\n \"absolute inset-0 flex items-center justify-center rounded-md transition-[opacity,background-color] duration-200\",\n !selectionEnabled && \"invisible pointer-events-none\",\n selectionEnabled && (selected\n ? \"opacity-100 bg-primary/10 dark:bg-primary/20\"\n : \"opacity-0 group-hover/card:opacity-100\")\n )}>\n <div className={cls(\n \"transition-transform duration-200\",\n selected\n ? \"scale-100\"\n : \"scale-75 group-hover/card:scale-100\"\n )}>\n <Checkbox\n aria-label={t(\"select_row\", { id: String(entity.id) })}\n checked={selected ?? false}\n onCheckedChange={handleSelectionChange}\n size=\"small\"\n padding={false}\n />\n </div>\n </div>\n </div>}\n\n {/* Content */}\n <div className=\"flex-1 min-w-0\">\n {/* Title slot, and the record's actions beside it */}\n <div className=\"flex items-start gap-1\">\n <div className=\"flex-1 min-w-0 line-clamp-2 text-sm font-medium\">\n {slots.title ? (\n <SlotValue slot={slots.title} size=\"small\"/>\n ) : (\n <span className=\"text-surface-500\">{entity.id}</span>\n )}\n </div>\n {renderActions?.(entity)}\n </div>\n {/* Subtitle / Description */}\n {slots.subtitle ? (\n <div className=\"text-xs text-surface-500 mt-1 line-clamp-3 opacity-80\">\n {typeof slots.subtitle.value === \"string\" ? (\n <StorageMarkdown source={slots.subtitle.value} size=\"small\" />\n ) : (\n <SlotValue slot={slots.subtitle} size=\"small\"/>\n )}\n </div>\n ) : (\n <div className=\"text-xs text-surface-500 font-mono truncate mt-1\">\n {entity.id}\n </div>\n )}\n {/* Relation chips slot */}\n {slots.relations.length > 0 && (\n <div className=\"flex items-center gap-1 mt-1 overflow-hidden max-w-full flex-wrap\">\n {slots.relations.map((rel) => (\n rel.items.map((item) => (\n <Chip\n key={`${rel.propertyKey}-${item.id}`}\n size=\"smallest\"\n colorScheme={rel.colorScheme}\n className=\"!text-[10px] !leading-tight !py-0 shrink-0 max-w-[90px] truncate\"\n >\n {item.displayName}\n </Chip>\n ))\n ))}\n {slots.relations.some(r => r.totalCount > r.items.length) && (\n <span className=\"text-[10px] text-surface-400 dark:text-surface-500 shrink-0\">\n +{slots.relations.reduce((acc, r) => acc + Math.max(0, r.totalCount - r.items.length), 0)}\n </span>\n )}\n </div>\n )}\n\n {/* Tags slot */}\n {slots.tags && (\n <div className=\"flex items-center gap-1 mt-1 flex-wrap\">\n <TagChips slot={slots.tags} max={3}/>\n </div>\n )}\n\n {/* Date slot — a board card is a list row without the image, and\n the row shows it. The status is deliberately not repeated\n here: on a board grouped by it, the column header is already\n saying it. */}\n {slots.date && (\n <div className=\"text-[10px] text-surface-500 dark:text-surface-400 mt-1\">\n {slots.date.formatted}\n </div>\n )}\n </div>\n </div>\n </div>\n );\n}\n\n// Memoized to prevent unnecessary re-renders when other cards in the board change\nexport const BoardCardBinding = memo(BoardCardBindingInner) as typeof BoardCardBindingInner;\n\n/**\n * Wrapper component that adapts BoardCardBinding to BoardItemViewProps interface\n */\nexport function createBoardCardBindingComponent<M extends Record<string, unknown>>(\n collection: AdminCollection<M>,\n options: {\n onClick?: (entity: Entity<M>) => void;\n isEntitySelected?: (entity: Entity<M>) => boolean;\n onSelectionChange?: (entity: Entity<M>, selected: boolean) => void;\n selectionEnabled?: boolean;\n renderActions?: (entity: Entity<M>) => React.ReactNode;\n }\n): React.ComponentType<BoardItemViewProps<Entity<M>>> {\n return function BoardCardBindingWrapper(props: BoardItemViewProps<Entity<M>>) {\n return (\n <BoardCardBinding\n {...props}\n collection={collection}\n onClick={options.onClick}\n selected={options.isEntitySelected?.(props.item.data)}\n onSelectionChange={options.onSelectionChange}\n selectionEnabled={options.selectionEnabled}\n renderActions={options.renderActions}\n />\n );\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAkCA,SAAS,sBAAmF,EACxF,MACA,YACA,eACA,OACA,YACA,SACA,UACA,mBACA,mBAAmB,OACnB,iBACyB;CACzB,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,SAAS,KAAK;CAIpB,MAAM,WAAW,sBACb,YAJmB,kBAKnB,GAJ4B,2BAK5B,CAAA,CAAwB,eAC5B;CAEA,MAAM,QAAQ,eACV,QACA,YACA,QACJ;CACA,MAAM,aAAa,cAAc,SAAS,QAAQ;CAElD,MAAM,cAAc,aAAa,MAAwB;EAErD,KAAK,EAAE,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,GACA,MAAM,UAAU,MAAK,MAAK,EAAE,aAAa,EAAE,MAAM,MAAM,KACpD,qBAAC,QAAD;OAAM,WAAU;iBAAhB,CAA8E,KACxE,MAAM,UAAU,QAAQ,KAAK,MAAM,MAAM,KAAK,IAAI,GAAG,EAAE,aAAa,EAAE,MAAM,MAAM,GAAG,CAAC,CACtF;QAET;;KAIR,MAAM,QACH,oBAAC,OAAD;MAAK,WAAU;gBACX,oBAAC,UAAD;OAAU,MAAM,MAAM;OAAM,KAAK;MAAG,CAAA;KACnC,CAAA;KAOR,MAAM,QACH,oBAAC,OAAD;MAAK,WAAU;gBACV,MAAM,KAAK;KACX,CAAA;IAER;KACJ;;CACJ,CAAA;AAEb;AAGA,IAAa,mBAAmB,KAAK,qBAAqB"}
1
+ {"version":3,"file":"BoardCardBinding.js","names":[],"sources":["../../../src/components/CollectionViewBinding/BoardCardBinding.tsx"],"sourcesContent":["\nimport React, { memo, useCallback, useMemo } from \"react\";\nimport { Entity } from \"@rebasepro/cms-types\";\nimport { Checkbox, Chip, cls, defaultBorderMixin } from \"@rebasepro/ui\";\nimport { StorageMarkdown } from \"../../preview/components/StorageMarkdown\";\nimport { PropertyPreview } from \"../../preview\";\nimport { useAuthController, useCustomizationController, useTranslation } from \"@rebasepro/app\";\nimport { IconForView } from \"@rebasepro/app\";\nimport { BoardItemViewProps } from \"@rebasepro/ui\";\nimport { useCollectionSlotKeys, useEntitySlots, useImagePlace } from \"./usePreviewSlots\";\nimport { SlotValue, TagChips } from \"./SlotValue\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\n\nexport type BoardCardBindingProps<M extends Record<string, unknown> = Record<string, unknown>> = BoardItemViewProps<Entity<M>> & {\n collection: AdminCollection<M>;\n onClick?: (entity: Entity<M>) => void;\n selected?: boolean;\n onSelectionChange?: (entity: Entity<M>, selected: boolean) => void;\n selectionEnabled?: boolean;\n /**\n * Draws the record's actions beside the card's title — the collection's\n * `entityActions` with Copy and Delete, placed as a table row places them.\n */\n renderActions?: (entity: Entity<M>) => React.ReactNode;\n};\n\n/**\n * Compact card component for displaying a entity in a Kanban board.\n * Uses the shared slot system for consistent preview rendering.\n *\n * Selection UX: The checkbox overlays on top of the image/icon thumbnail area,\n * revealed on card hover or when the card is selected. This keeps the card\n * layout clean while providing intuitive selection affordance.\n */\nfunction BoardCardBindingInner<M extends Record<string, unknown> = Record<string, unknown>>({\n item,\n isDragging,\n isGroupedOver,\n style,\n collection,\n onClick,\n selected,\n onSelectionChange,\n selectionEnabled = false,\n renderActions\n}: BoardCardBindingProps<M>) {\n const { t } = useTranslation();\n const entity = item.data;\n const authController = useAuthController();\n const customizationController = useCustomizationController();\n\n const slotKeys = useCollectionSlotKeys(\n collection as AdminCollection<Record<string, unknown>>,\n authController,\n customizationController.propertyConfigs\n );\n\n const slots = useEntitySlots(\n entity as Entity<Record<string, unknown>>,\n collection as AdminCollection<Record<string, unknown>>,\n slotKeys\n );\n const imagePlace = useImagePlace(slotKeys.imageKey);\n\n const handleClick = useCallback((e: React.MouseEvent) => {\n // Cmd+click (Mac) or Ctrl+click (Windows) toggles selection\n if ((e.metaKey || e.ctrlKey) && selectionEnabled) {\n e.preventDefault();\n e.stopPropagation();\n onSelectionChange?.(entity, !selected);\n return;\n }\n if (onClick) {\n e.stopPropagation();\n onClick(entity);\n }\n }, [entity, onClick, onSelectionChange, selected, selectionEnabled]);\n\n const handleThumbnailClick = useCallback((e: React.MouseEvent) => {\n if (!selectionEnabled) return;\n e.stopPropagation();\n e.preventDefault();\n onSelectionChange?.(entity, !selected);\n }, [entity, onSelectionChange, selected, selectionEnabled]);\n\n const handleSelectionChange = useCallback((checked: boolean) => {\n onSelectionChange?.(entity, checked);\n }, [entity, onSelectionChange]);\n\n // Memoize className computations\n const backgroundColor = useMemo((): string => {\n if (isDragging) {\n return \"bg-surface-raised\";\n }\n if (isGroupedOver) {\n return \"bg-surface-raised\";\n }\n return \"bg-surface-card hover:bg-surface-hover\";\n }, [isDragging, isGroupedOver]);\n\n const borderColor = useMemo((): string =>\n isDragging ? \"ring-2 ring-primary\" : \"\", [isDragging]);\n\n // Memoize the card className — use CSS group for hover-reveal of checkbox\n const cardClassName = useMemo(() => cls(\n \"group/card p-2 flex items-start border rounded-lg cursor-pointer transition-all duration-200\",\n defaultBorderMixin,\n borderColor,\n backgroundColor,\n selected\n ? \"ring-2 ring-primary bg-primary/[0.03] dark:bg-primary/[0.06]\"\n : \"hover:shadow-sm\"\n ), [borderColor, backgroundColor, selected]);\n\n return (\n <div\n style={style}\n className=\"py-1\"\n data-is-dragging={isDragging}\n data-testid={item.id}\n onClick={handleClick}\n >\n <div className={cardClassName}>\n {/* Thumbnail area with selection overlay. Where `fields` leaves\n every image out it holds only the checkbox, and with no\n selection it is not drawn. */}\n {(imagePlace || selectionEnabled) && <div\n className=\"relative w-10 h-10 rounded-md shrink-0 mr-2\"\n onClick={handleThumbnailClick}\n >\n {/* Image or fallback icon */}\n {!imagePlace ? null : slots.image ? (\n <div className={cls(\n \"w-10 h-10 rounded-md overflow-hidden transition-opacity duration-200\",\n selectionEnabled && \"group-hover/card:opacity-30\",\n selected && \"opacity-0\"\n )}>\n <SlotValue slot={slots.image} size=\"small\" fill={true}/>\n </div>\n ) : (\n <div className={cls(\n \"w-10 h-10 rounded-md bg-surface-raised flex items-center justify-center transition-opacity duration-200\",\n selectionEnabled && \"group-hover/card:opacity-30\",\n selected && \"opacity-0\"\n )}>\n <IconForView\n collectionOrView={collection}\n color=\"disabled\"\n size=\"small\"\n />\n </div>\n )}\n\n {/* Selection checkbox overlay — always in the DOM, visibility controlled by CSS */}\n <div className={cls(\n \"absolute inset-0 flex items-center justify-center rounded-md transition-[opacity,background-color] duration-200\",\n !selectionEnabled && \"invisible pointer-events-none\",\n selectionEnabled && (selected\n ? \"opacity-100 bg-primary/10 dark:bg-primary/20\"\n : \"opacity-0 group-hover/card:opacity-100\")\n )}>\n <div className={cls(\n \"transition-transform duration-200\",\n selected\n ? \"scale-100\"\n : \"scale-75 group-hover/card:scale-100\"\n )}>\n <Checkbox\n aria-label={t(\"select_row\", { id: String(entity.id) })}\n checked={selected ?? false}\n onCheckedChange={handleSelectionChange}\n size=\"small\"\n padding={false}\n />\n </div>\n </div>\n </div>}\n\n {/* Content */}\n <div className=\"flex-1 min-w-0\">\n {/* Title slot, and the record's actions beside it */}\n <div className=\"flex items-start gap-1\">\n <div className=\"flex-1 min-w-0 line-clamp-2 text-sm font-medium\">\n {slots.title ? (\n <SlotValue slot={slots.title} size=\"small\"/>\n ) : (\n <span className=\"text-surface-500\">{entity.id}</span>\n )}\n </div>\n {renderActions?.(entity)}\n </div>\n {/* Subtitle / Description */}\n {slots.subtitle ? (\n <div className=\"text-xs text-surface-500 mt-1 line-clamp-3 opacity-80\">\n {typeof slots.subtitle.value === \"string\" ? (\n <StorageMarkdown source={slots.subtitle.value} size=\"small\" />\n ) : (\n <SlotValue slot={slots.subtitle} size=\"small\"/>\n )}\n </div>\n ) : (\n <div className=\"text-xs text-surface-500 font-mono truncate mt-1\">\n {entity.id}\n </div>\n )}\n {/* Relation chips slot */}\n {slots.relations.length > 0 && (\n <div className=\"flex items-center gap-1 mt-1 overflow-hidden max-w-full flex-wrap\">\n {slots.relations.map((rel) => (\n rel.items.map((item) => (\n <Chip\n key={`${rel.propertyKey}-${item.id}`}\n size=\"smallest\"\n colorScheme={rel.colorScheme}\n className=\"!text-[10px] !leading-tight !py-0 shrink-0 max-w-[90px] truncate\"\n >\n {item.displayName}\n </Chip>\n ))\n ))}\n {slots.relations.some(r => r.totalCount > r.items.length) && (\n <span className=\"text-[10px] text-surface-400 dark:text-surface-500 shrink-0\">\n +{slots.relations.reduce((acc, r) => acc + Math.max(0, r.totalCount - r.items.length), 0)}\n </span>\n )}\n </div>\n )}\n\n {/* Tags slot */}\n {slots.tags && (\n <div className=\"flex items-center gap-1 mt-1 flex-wrap\">\n <TagChips slot={slots.tags} max={3}/>\n </div>\n )}\n\n {/* Date slot — a board card is a list row without the image, and\n the row shows it. The status is deliberately not repeated\n here: on a board grouped by it, the column header is already\n saying it. */}\n {slots.date && (\n <div className=\"text-[10px] text-surface-500 dark:text-surface-400 mt-1\">\n {slots.date.formatted}\n </div>\n )}\n </div>\n </div>\n </div>\n );\n}\n\n// Memoized to prevent unnecessary re-renders when other cards in the board change\nexport const BoardCardBinding = memo(BoardCardBindingInner) as typeof BoardCardBindingInner;\n\n/**\n * Wrapper component that adapts BoardCardBinding to BoardItemViewProps interface\n */\nexport function createBoardCardBindingComponent<M extends Record<string, unknown>>(\n collection: AdminCollection<M>,\n options: {\n onClick?: (entity: Entity<M>) => void;\n isEntitySelected?: (entity: Entity<M>) => boolean;\n onSelectionChange?: (entity: Entity<M>, selected: boolean) => void;\n selectionEnabled?: boolean;\n renderActions?: (entity: Entity<M>) => React.ReactNode;\n }\n): React.ComponentType<BoardItemViewProps<Entity<M>>> {\n return function BoardCardBindingWrapper(props: BoardItemViewProps<Entity<M>>) {\n return (\n <BoardCardBinding\n {...props}\n collection={collection}\n onClick={options.onClick}\n selected={options.isEntitySelected?.(props.item.data)}\n onSelectionChange={options.onSelectionChange}\n selectionEnabled={options.selectionEnabled}\n renderActions={options.renderActions}\n />\n );\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAkCA,SAAS,sBAAmF,EACxF,MACA,YACA,eACA,OACA,YACA,SACA,UACA,mBACA,mBAAmB,OACnB,iBACyB;CACzB,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,SAAS,KAAK;CAIpB,MAAM,WAAW,sBACb,YAJmB,kBAKnB,GAJ4B,2BAK5B,CAAA,CAAwB,eAC5B;CAEA,MAAM,QAAQ,eACV,QACA,YACA,QACJ;CACA,MAAM,aAAa,cAAc,SAAS,QAAQ;CAElD,MAAM,cAAc,aAAa,MAAwB;EAErD,KAAK,EAAE,WAAW,EAAE,YAAY,kBAAkB;GAC9C,EAAE,eAAe;GACjB,EAAE,gBAAgB;GAClB,oBAAoB,QAAQ,CAAC,QAAQ;GACrC;EACJ;EACA,IAAI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U,QAAQ,KAAK,MAAM,MAAM,KAAK,IAAI,GAAG,EAAE,aAAa,EAAE,MAAM,MAAM,GAAG,CAAC,CACtF;QAET;;KAIR,MAAM,QACH,oBAAC,OAAD;MAAK,WAAU;gBACX,oBAAC,UAAD;OAAU,MAAM,MAAM;OAAM,KAAK;MAAG,CAAA;KACnC,CAAA;KAOR,MAAM,QACH,oBAAC,OAAD;MAAK,WAAU;gBACV,MAAM,KAAK;KACX,CAAA;IAER;KACJ;;CACJ,CAAA;AAEb;AAGA,IAAa,mBAAmB,KAAK,qBAAqB"}
@@ -1,6 +1,5 @@
1
1
  import React from "react";
2
- import { Entity } from "@rebasepro/types";
3
- import { EntityTableController, EntitySelectionController, AdminCollection } from "@rebasepro/cms-types";
2
+ import { EntityTableController, EntitySelectionController, AdminCollection, Entity } from "@rebasepro/cms-types";
4
3
  export type CollectionBoardViewBindingProps<M extends Record<string, unknown> = Record<string, unknown>> = {
5
4
  collection: AdminCollection<M>;
6
5
  tableController: EntityTableController<M>;