@payloadcms/ui 3.80.0-internal.8d9ec7c → 3.80.0-internal.cdd7ef7

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 (286) hide show
  1. package/dist/elements/ClipboardAction/mergeFormStateFromClipboard.d.ts.map +1 -1
  2. package/dist/elements/ClipboardAction/mergeFormStateFromClipboard.js +4 -2
  3. package/dist/elements/ClipboardAction/mergeFormStateFromClipboard.js.map +1 -1
  4. package/dist/elements/ClipboardAction/mergeFormStateFromClipboard.spec.js +157 -0
  5. package/dist/elements/ClipboardAction/mergeFormStateFromClipboard.spec.js.map +1 -1
  6. package/dist/elements/Hierarchy/ColumnBrowser/Column/index.d.ts.map +1 -0
  7. package/dist/elements/{HierarchyColumnBrowser → Hierarchy/ColumnBrowser}/Column/index.js +5 -5
  8. package/dist/elements/Hierarchy/ColumnBrowser/Column/index.js.map +1 -0
  9. package/dist/elements/{HierarchyColumnBrowser → Hierarchy/ColumnBrowser}/Column/index.scss +1 -1
  10. package/dist/elements/Hierarchy/ColumnBrowser/ColumnItem/index.d.ts.map +1 -0
  11. package/dist/elements/{HierarchyColumnBrowser → Hierarchy/ColumnBrowser}/ColumnItem/index.js +3 -3
  12. package/dist/elements/Hierarchy/ColumnBrowser/ColumnItem/index.js.map +1 -0
  13. package/dist/elements/{HierarchyColumnBrowser → Hierarchy/ColumnBrowser}/ColumnItem/index.scss +1 -1
  14. package/dist/elements/Hierarchy/ColumnBrowser/index.d.ts.map +1 -0
  15. package/dist/elements/{HierarchyColumnBrowser → Hierarchy/ColumnBrowser}/index.js +6 -6
  16. package/dist/elements/Hierarchy/ColumnBrowser/index.js.map +1 -0
  17. package/dist/elements/Hierarchy/ColumnBrowser/types.d.ts.map +1 -0
  18. package/dist/elements/Hierarchy/ColumnBrowser/types.js.map +1 -0
  19. package/dist/elements/Hierarchy/DocHeaderButton/index.d.ts.map +1 -0
  20. package/dist/elements/{HierarchyButton → Hierarchy/DocHeaderButton}/index.js +6 -6
  21. package/dist/elements/Hierarchy/DocHeaderButton/index.js.map +1 -0
  22. package/dist/elements/Hierarchy/DocHeaderButton/index.server.d.ts.map +1 -0
  23. package/dist/elements/{HierarchyButton → Hierarchy/DocHeaderButton}/index.server.js +3 -3
  24. package/dist/elements/Hierarchy/DocHeaderButton/index.server.js.map +1 -0
  25. package/dist/elements/Hierarchy/Drawer/fetchAncestorPath.d.ts.map +1 -0
  26. package/dist/elements/Hierarchy/Drawer/fetchAncestorPath.js.map +1 -0
  27. package/dist/elements/{HierarchyDrawer → Hierarchy}/Drawer/index.d.ts +2 -2
  28. package/dist/elements/Hierarchy/Drawer/index.d.ts.map +1 -0
  29. package/dist/elements/{HierarchyDrawer → Hierarchy}/Drawer/index.js +2 -2
  30. package/dist/elements/Hierarchy/Drawer/index.js.map +1 -0
  31. package/dist/elements/{HierarchyDrawer → Hierarchy/Drawer}/types.d.ts +1 -1
  32. package/dist/elements/Hierarchy/Drawer/types.d.ts.map +1 -0
  33. package/dist/elements/Hierarchy/Drawer/types.js.map +1 -0
  34. package/dist/elements/{HierarchyDrawer/index.d.ts → Hierarchy/Drawer/useHierarchyDrawer.d.ts} +1 -1
  35. package/dist/elements/Hierarchy/Drawer/useHierarchyDrawer.d.ts.map +1 -0
  36. package/dist/elements/{HierarchyDrawer/index.js → Hierarchy/Drawer/useHierarchyDrawer.js} +6 -6
  37. package/dist/elements/Hierarchy/Drawer/useHierarchyDrawer.js.map +1 -0
  38. package/dist/elements/Hierarchy/Field/SelectedHierarchies.d.ts.map +1 -0
  39. package/dist/elements/{HierarchyField → Hierarchy/Field}/SelectedHierarchies.js +7 -16
  40. package/dist/elements/Hierarchy/Field/SelectedHierarchies.js.map +1 -0
  41. package/dist/elements/{HierarchyField → Hierarchy/Field}/SelectedHierarchies.scss +1 -1
  42. package/dist/elements/Hierarchy/Field/index.client.d.ts.map +1 -0
  43. package/dist/elements/{HierarchyField → Hierarchy/Field}/index.client.js +17 -29
  44. package/dist/elements/Hierarchy/Field/index.client.js.map +1 -0
  45. package/dist/elements/{HierarchyField → Hierarchy/Field}/index.scss +1 -1
  46. package/dist/elements/Hierarchy/Field/index.server.d.ts.map +1 -0
  47. package/dist/elements/{HierarchyField → Hierarchy/Field}/index.server.js +2 -2
  48. package/dist/elements/Hierarchy/Field/index.server.js.map +1 -0
  49. package/dist/elements/Hierarchy/HydrateProvider/index.d.ts +4 -0
  50. package/dist/elements/Hierarchy/HydrateProvider/index.d.ts.map +1 -0
  51. package/dist/elements/{HydrateHierarchyProvider → Hierarchy/HydrateProvider}/index.js +1 -1
  52. package/dist/elements/Hierarchy/HydrateProvider/index.js.map +1 -0
  53. package/dist/elements/{MoveMany → Hierarchy/MoveMany}/index.d.ts +3 -3
  54. package/dist/elements/Hierarchy/MoveMany/index.d.ts.map +1 -0
  55. package/dist/elements/{MoveMany → Hierarchy/MoveMany}/index.js +10 -10
  56. package/dist/elements/Hierarchy/MoveMany/index.js.map +1 -0
  57. package/dist/elements/{MoveMany → Hierarchy/MoveMany}/index.scss +1 -1
  58. package/dist/elements/Hierarchy/Search/HierarchySearchInput.d.ts.map +1 -0
  59. package/dist/elements/{HierarchySearch → Hierarchy/Search}/HierarchySearchInput.js +5 -5
  60. package/dist/elements/Hierarchy/Search/HierarchySearchInput.js.map +1 -0
  61. package/dist/elements/Hierarchy/Search/HierarchySearchResultItem.d.ts.map +1 -0
  62. package/dist/elements/Hierarchy/Search/HierarchySearchResultItem.js.map +1 -0
  63. package/dist/elements/Hierarchy/Search/HierarchySearchResults.d.ts.map +1 -0
  64. package/dist/elements/{HierarchySearch → Hierarchy/Search}/HierarchySearchResults.js +2 -2
  65. package/dist/elements/Hierarchy/Search/HierarchySearchResults.js.map +1 -0
  66. package/dist/elements/Hierarchy/Search/index.d.ts.map +1 -0
  67. package/dist/elements/{HierarchySearch → Hierarchy/Search}/index.js +2 -2
  68. package/dist/elements/Hierarchy/Search/index.js.map +1 -0
  69. package/dist/elements/{HierarchySearch → Hierarchy/Search}/index.scss +1 -1
  70. package/dist/elements/Hierarchy/Search/types.d.ts.map +1 -0
  71. package/dist/elements/Hierarchy/Search/types.js.map +1 -0
  72. package/dist/elements/Hierarchy/Search/useHierarchySearch.d.ts.map +1 -0
  73. package/dist/elements/{HierarchySearch → Hierarchy/Search}/useHierarchySearch.js +2 -2
  74. package/dist/elements/Hierarchy/Search/useHierarchySearch.js.map +1 -0
  75. package/dist/elements/Hierarchy/Tree/HierarchySidebarTab.d.ts.map +1 -0
  76. package/dist/elements/{HierarchyTree → Hierarchy/Tree}/HierarchySidebarTab.js +43 -48
  77. package/dist/elements/Hierarchy/Tree/HierarchySidebarTab.js.map +1 -0
  78. package/dist/elements/Hierarchy/Tree/HierarchySidebarTab.server.d.ts.map +1 -0
  79. package/dist/elements/{HierarchyTree → Hierarchy/Tree}/HierarchySidebarTab.server.js +6 -5
  80. package/dist/elements/Hierarchy/Tree/HierarchySidebarTab.server.js.map +1 -0
  81. package/dist/elements/Hierarchy/Tree/LoadMore/LoadMoreButton.d.ts.map +1 -0
  82. package/dist/elements/{Tree → Hierarchy/Tree}/LoadMore/LoadMoreButton.js +1 -1
  83. package/dist/elements/Hierarchy/Tree/LoadMore/LoadMoreButton.js.map +1 -0
  84. package/dist/elements/Hierarchy/Tree/LoadMore/index.d.ts.map +1 -0
  85. package/dist/elements/{Tree → Hierarchy/Tree}/LoadMore/index.js +1 -1
  86. package/dist/elements/Hierarchy/Tree/LoadMore/index.js.map +1 -0
  87. package/dist/elements/Hierarchy/Tree/TreeConnector.d.ts.map +1 -0
  88. package/dist/elements/Hierarchy/Tree/TreeConnector.js.map +1 -0
  89. package/dist/elements/Hierarchy/Tree/TreeFocusContext.d.ts.map +1 -0
  90. package/dist/elements/Hierarchy/Tree/TreeFocusContext.js.map +1 -0
  91. package/dist/elements/Hierarchy/Tree/TreeNode/index.d.ts.map +1 -0
  92. package/dist/elements/{Tree → Hierarchy/Tree}/TreeNode/index.js +8 -4
  93. package/dist/elements/Hierarchy/Tree/TreeNode/index.js.map +1 -0
  94. package/dist/elements/{Tree → Hierarchy/Tree}/TreeNode/index.scss +1 -1
  95. package/dist/elements/{HierarchyTree → Hierarchy/Tree}/index.d.ts +1 -0
  96. package/dist/elements/Hierarchy/Tree/index.d.ts.map +1 -0
  97. package/dist/elements/{Tree → Hierarchy/Tree}/index.js +72 -72
  98. package/dist/elements/Hierarchy/Tree/index.js.map +1 -0
  99. package/dist/elements/{Tree → Hierarchy/Tree}/index.scss +2 -5
  100. package/dist/elements/{Tree → Hierarchy/Tree}/types.d.ts +30 -24
  101. package/dist/elements/Hierarchy/Tree/types.d.ts.map +1 -0
  102. package/dist/elements/Hierarchy/Tree/types.js.map +1 -0
  103. package/dist/elements/{Tree → Hierarchy/Tree}/useChildren.d.ts +5 -1
  104. package/dist/elements/Hierarchy/Tree/useChildren.d.ts.map +1 -0
  105. package/dist/elements/{Tree → Hierarchy/Tree}/useChildren.js +41 -25
  106. package/dist/elements/Hierarchy/Tree/useChildren.js.map +1 -0
  107. package/dist/elements/LoadMoreRow/index.js +1 -1
  108. package/dist/elements/LoadMoreRow/index.js.map +1 -1
  109. package/dist/elements/RelationshipTable/index.d.ts.map +1 -1
  110. package/dist/elements/RelationshipTable/index.js +14 -9
  111. package/dist/elements/RelationshipTable/index.js.map +1 -1
  112. package/dist/elements/Table/DefaultCell/fields/Hierarchy/index.js +1 -1
  113. package/dist/elements/Table/DefaultCell/fields/Hierarchy/index.js.map +1 -1
  114. package/dist/exports/client/index.d.ts +11 -15
  115. package/dist/exports/client/index.d.ts.map +1 -1
  116. package/dist/exports/client/index.js +26 -26
  117. package/dist/exports/client/index.js.map +4 -4
  118. package/dist/exports/rsc/index.d.ts +3 -3
  119. package/dist/exports/rsc/index.d.ts.map +1 -1
  120. package/dist/exports/rsc/index.js +3 -3
  121. package/dist/exports/rsc/index.js.map +1 -1
  122. package/dist/forms/Form/mergeServerFormState.d.ts.map +1 -1
  123. package/dist/forms/Form/mergeServerFormState.js +101 -24
  124. package/dist/forms/Form/mergeServerFormState.js.map +1 -1
  125. package/dist/icons/TableView/index.d.ts +3 -0
  126. package/dist/icons/TableView/index.d.ts.map +1 -0
  127. package/dist/icons/TableView/index.js +16 -0
  128. package/dist/icons/TableView/index.js.map +1 -0
  129. package/dist/providers/Hierarchy/index.d.ts.map +1 -1
  130. package/dist/providers/Hierarchy/index.js +5 -1
  131. package/dist/providers/Hierarchy/index.js.map +1 -1
  132. package/dist/providers/Hierarchy/types.d.ts +1 -0
  133. package/dist/providers/Hierarchy/types.d.ts.map +1 -1
  134. package/dist/providers/Hierarchy/types.js.map +1 -1
  135. package/dist/providers/SidebarTabs/index.d.ts +19 -0
  136. package/dist/providers/SidebarTabs/index.d.ts.map +1 -0
  137. package/dist/providers/SidebarTabs/index.js +24 -0
  138. package/dist/providers/SidebarTabs/index.js.map +1 -0
  139. package/dist/styles.css +1 -1
  140. package/dist/views/Edit/index.d.ts.map +1 -1
  141. package/dist/views/Edit/index.js +11 -2
  142. package/dist/views/Edit/index.js.map +1 -1
  143. package/dist/views/HierarchyList/DocumentListSelection/index.d.ts.map +1 -1
  144. package/dist/views/HierarchyList/DocumentListSelection/index.js +145 -86
  145. package/dist/views/HierarchyList/DocumentListSelection/index.js.map +1 -1
  146. package/dist/views/HierarchyList/HierarchyTable/index.d.ts +1 -1
  147. package/dist/views/HierarchyList/HierarchyTable/index.d.ts.map +1 -1
  148. package/dist/views/HierarchyList/HierarchyTable/index.js.map +1 -1
  149. package/package.json +4 -4
  150. package/dist/elements/HierarchyButton/index.d.ts.map +0 -1
  151. package/dist/elements/HierarchyButton/index.js.map +0 -1
  152. package/dist/elements/HierarchyButton/index.server.d.ts.map +0 -1
  153. package/dist/elements/HierarchyButton/index.server.js.map +0 -1
  154. package/dist/elements/HierarchyColumnBrowser/Column/index.d.ts.map +0 -1
  155. package/dist/elements/HierarchyColumnBrowser/Column/index.js.map +0 -1
  156. package/dist/elements/HierarchyColumnBrowser/ColumnItem/index.d.ts.map +0 -1
  157. package/dist/elements/HierarchyColumnBrowser/ColumnItem/index.js.map +0 -1
  158. package/dist/elements/HierarchyColumnBrowser/index.d.ts.map +0 -1
  159. package/dist/elements/HierarchyColumnBrowser/index.js.map +0 -1
  160. package/dist/elements/HierarchyColumnBrowser/types.d.ts.map +0 -1
  161. package/dist/elements/HierarchyColumnBrowser/types.js.map +0 -1
  162. package/dist/elements/HierarchyDrawer/Drawer/index.d.ts.map +0 -1
  163. package/dist/elements/HierarchyDrawer/Drawer/index.js.map +0 -1
  164. package/dist/elements/HierarchyDrawer/fetchAncestorPath.d.ts.map +0 -1
  165. package/dist/elements/HierarchyDrawer/fetchAncestorPath.js.map +0 -1
  166. package/dist/elements/HierarchyDrawer/index.d.ts.map +0 -1
  167. package/dist/elements/HierarchyDrawer/index.js.map +0 -1
  168. package/dist/elements/HierarchyDrawer/types.d.ts.map +0 -1
  169. package/dist/elements/HierarchyDrawer/types.js.map +0 -1
  170. package/dist/elements/HierarchyField/SelectedHierarchies.d.ts.map +0 -1
  171. package/dist/elements/HierarchyField/SelectedHierarchies.js.map +0 -1
  172. package/dist/elements/HierarchyField/index.client.d.ts.map +0 -1
  173. package/dist/elements/HierarchyField/index.client.js.map +0 -1
  174. package/dist/elements/HierarchyField/index.server.d.ts.map +0 -1
  175. package/dist/elements/HierarchyField/index.server.js.map +0 -1
  176. package/dist/elements/HierarchySearch/HierarchySearchInput.d.ts.map +0 -1
  177. package/dist/elements/HierarchySearch/HierarchySearchInput.js.map +0 -1
  178. package/dist/elements/HierarchySearch/HierarchySearchResultItem.d.ts.map +0 -1
  179. package/dist/elements/HierarchySearch/HierarchySearchResultItem.js.map +0 -1
  180. package/dist/elements/HierarchySearch/HierarchySearchResults.d.ts.map +0 -1
  181. package/dist/elements/HierarchySearch/HierarchySearchResults.js.map +0 -1
  182. package/dist/elements/HierarchySearch/index.d.ts.map +0 -1
  183. package/dist/elements/HierarchySearch/index.js.map +0 -1
  184. package/dist/elements/HierarchySearch/types.d.ts.map +0 -1
  185. package/dist/elements/HierarchySearch/types.js.map +0 -1
  186. package/dist/elements/HierarchySearch/useHierarchySearch.d.ts.map +0 -1
  187. package/dist/elements/HierarchySearch/useHierarchySearch.js.map +0 -1
  188. package/dist/elements/HierarchyTree/HierarchySidebarTab.d.ts.map +0 -1
  189. package/dist/elements/HierarchyTree/HierarchySidebarTab.js.map +0 -1
  190. package/dist/elements/HierarchyTree/HierarchySidebarTab.server.d.ts.map +0 -1
  191. package/dist/elements/HierarchyTree/HierarchySidebarTab.server.js.map +0 -1
  192. package/dist/elements/HierarchyTree/LoadMore/LoadMoreButton.d.ts.map +0 -1
  193. package/dist/elements/HierarchyTree/LoadMore/LoadMoreButton.js +0 -36
  194. package/dist/elements/HierarchyTree/LoadMore/LoadMoreButton.js.map +0 -1
  195. package/dist/elements/HierarchyTree/LoadMore/index.d.ts.map +0 -1
  196. package/dist/elements/HierarchyTree/LoadMore/index.js +0 -29
  197. package/dist/elements/HierarchyTree/LoadMore/index.js.map +0 -1
  198. package/dist/elements/HierarchyTree/LoadMore/index.scss +0 -26
  199. package/dist/elements/HierarchyTree/TreeConnector.d.ts.map +0 -1
  200. package/dist/elements/HierarchyTree/TreeConnector.js.map +0 -1
  201. package/dist/elements/HierarchyTree/TreeFocusContext.d.ts.map +0 -1
  202. package/dist/elements/HierarchyTree/TreeFocusContext.js.map +0 -1
  203. package/dist/elements/HierarchyTree/TreeNode/index.d.ts +0 -5
  204. package/dist/elements/HierarchyTree/TreeNode/index.d.ts.map +0 -1
  205. package/dist/elements/HierarchyTree/TreeNode/index.js +0 -201
  206. package/dist/elements/HierarchyTree/TreeNode/index.js.map +0 -1
  207. package/dist/elements/HierarchyTree/TreeNode/index.scss +0 -99
  208. package/dist/elements/HierarchyTree/index.d.ts.map +0 -1
  209. package/dist/elements/HierarchyTree/index.js +0 -66
  210. package/dist/elements/HierarchyTree/index.js.map +0 -1
  211. package/dist/elements/HierarchyTree/index.scss +0 -42
  212. package/dist/elements/HierarchyTree/types.d.ts +0 -57
  213. package/dist/elements/HierarchyTree/types.d.ts.map +0 -1
  214. package/dist/elements/HierarchyTree/types.js.map +0 -1
  215. package/dist/elements/HierarchyTree/useChildren.d.ts +0 -26
  216. package/dist/elements/HierarchyTree/useChildren.d.ts.map +0 -1
  217. package/dist/elements/HierarchyTree/useChildren.js +0 -150
  218. package/dist/elements/HierarchyTree/useChildren.js.map +0 -1
  219. package/dist/elements/HierarchyTree/useTreeState.d.ts +0 -9
  220. package/dist/elements/HierarchyTree/useTreeState.d.ts.map +0 -1
  221. package/dist/elements/HierarchyTree/useTreeState.js +0 -50
  222. package/dist/elements/HierarchyTree/useTreeState.js.map +0 -1
  223. package/dist/elements/HydrateHierarchyProvider/index.d.ts +0 -4
  224. package/dist/elements/HydrateHierarchyProvider/index.d.ts.map +0 -1
  225. package/dist/elements/HydrateHierarchyProvider/index.js.map +0 -1
  226. package/dist/elements/MoveMany/index.d.ts.map +0 -1
  227. package/dist/elements/MoveMany/index.js.map +0 -1
  228. package/dist/elements/Tree/LoadMore/LoadMoreButton.d.ts +0 -8
  229. package/dist/elements/Tree/LoadMore/LoadMoreButton.d.ts.map +0 -1
  230. package/dist/elements/Tree/LoadMore/LoadMoreButton.js.map +0 -1
  231. package/dist/elements/Tree/LoadMore/index.d.ts +0 -12
  232. package/dist/elements/Tree/LoadMore/index.d.ts.map +0 -1
  233. package/dist/elements/Tree/LoadMore/index.js.map +0 -1
  234. package/dist/elements/Tree/TreeConnector.d.ts +0 -7
  235. package/dist/elements/Tree/TreeConnector.d.ts.map +0 -1
  236. package/dist/elements/Tree/TreeConnector.js +0 -23
  237. package/dist/elements/Tree/TreeConnector.js.map +0 -1
  238. package/dist/elements/Tree/TreeFocusContext.d.ts +0 -28
  239. package/dist/elements/Tree/TreeFocusContext.d.ts.map +0 -1
  240. package/dist/elements/Tree/TreeFocusContext.js +0 -140
  241. package/dist/elements/Tree/TreeFocusContext.js.map +0 -1
  242. package/dist/elements/Tree/TreeNode/index.d.ts.map +0 -1
  243. package/dist/elements/Tree/TreeNode/index.js.map +0 -1
  244. package/dist/elements/Tree/index.d.ts +0 -5
  245. package/dist/elements/Tree/index.d.ts.map +0 -1
  246. package/dist/elements/Tree/index.js.map +0 -1
  247. package/dist/elements/Tree/types.d.ts.map +0 -1
  248. package/dist/elements/Tree/types.js +0 -2
  249. package/dist/elements/Tree/types.js.map +0 -1
  250. package/dist/elements/Tree/useChildren.d.ts.map +0 -1
  251. package/dist/elements/Tree/useChildren.js.map +0 -1
  252. /package/dist/elements/{HierarchyColumnBrowser → Hierarchy/ColumnBrowser}/Column/index.d.ts +0 -0
  253. /package/dist/elements/{HierarchyColumnBrowser → Hierarchy/ColumnBrowser}/ColumnItem/index.d.ts +0 -0
  254. /package/dist/elements/{HierarchyColumnBrowser → Hierarchy/ColumnBrowser}/index.d.ts +0 -0
  255. /package/dist/elements/{HierarchyColumnBrowser → Hierarchy/ColumnBrowser}/index.scss +0 -0
  256. /package/dist/elements/{HierarchyColumnBrowser → Hierarchy/ColumnBrowser}/types.d.ts +0 -0
  257. /package/dist/elements/{HierarchyColumnBrowser → Hierarchy/ColumnBrowser}/types.js +0 -0
  258. /package/dist/elements/{HierarchyButton → Hierarchy/DocHeaderButton}/index.d.ts +0 -0
  259. /package/dist/elements/{HierarchyButton → Hierarchy/DocHeaderButton}/index.scss +0 -0
  260. /package/dist/elements/{HierarchyButton → Hierarchy/DocHeaderButton}/index.server.d.ts +0 -0
  261. /package/dist/elements/{HierarchyDrawer → Hierarchy/Drawer}/fetchAncestorPath.d.ts +0 -0
  262. /package/dist/elements/{HierarchyDrawer → Hierarchy/Drawer}/fetchAncestorPath.js +0 -0
  263. /package/dist/elements/{HierarchyDrawer → Hierarchy}/Drawer/index.scss +0 -0
  264. /package/dist/elements/{HierarchyDrawer → Hierarchy/Drawer}/types.js +0 -0
  265. /package/dist/elements/{HierarchyField → Hierarchy/Field}/SelectedHierarchies.d.ts +0 -0
  266. /package/dist/elements/{HierarchyField → Hierarchy/Field}/index.client.d.ts +0 -0
  267. /package/dist/elements/{HierarchyField → Hierarchy/Field}/index.server.d.ts +0 -0
  268. /package/dist/elements/{HierarchySearch → Hierarchy/Search}/HierarchySearchInput.d.ts +0 -0
  269. /package/dist/elements/{HierarchySearch → Hierarchy/Search}/HierarchySearchResultItem.d.ts +0 -0
  270. /package/dist/elements/{HierarchySearch → Hierarchy/Search}/HierarchySearchResultItem.js +0 -0
  271. /package/dist/elements/{HierarchySearch → Hierarchy/Search}/HierarchySearchResults.d.ts +0 -0
  272. /package/dist/elements/{HierarchySearch → Hierarchy/Search}/index.d.ts +0 -0
  273. /package/dist/elements/{HierarchySearch → Hierarchy/Search}/types.d.ts +0 -0
  274. /package/dist/elements/{HierarchySearch → Hierarchy/Search}/types.js +0 -0
  275. /package/dist/elements/{HierarchySearch → Hierarchy/Search}/useHierarchySearch.d.ts +0 -0
  276. /package/dist/elements/{HierarchyTree → Hierarchy/Tree}/HierarchySidebarTab.d.ts +0 -0
  277. /package/dist/elements/{HierarchyTree → Hierarchy/Tree}/HierarchySidebarTab.server.d.ts +0 -0
  278. /package/dist/elements/{HierarchyTree → Hierarchy/Tree}/LoadMore/LoadMoreButton.d.ts +0 -0
  279. /package/dist/elements/{HierarchyTree → Hierarchy/Tree}/LoadMore/index.d.ts +0 -0
  280. /package/dist/elements/{Tree → Hierarchy/Tree}/LoadMore/index.scss +0 -0
  281. /package/dist/elements/{HierarchyTree → Hierarchy/Tree}/TreeConnector.d.ts +0 -0
  282. /package/dist/elements/{HierarchyTree → Hierarchy/Tree}/TreeConnector.js +0 -0
  283. /package/dist/elements/{HierarchyTree → Hierarchy/Tree}/TreeFocusContext.d.ts +0 -0
  284. /package/dist/elements/{HierarchyTree → Hierarchy/Tree}/TreeFocusContext.js +0 -0
  285. /package/dist/elements/{Tree → Hierarchy/Tree}/TreeNode/index.d.ts +0 -0
  286. /package/dist/elements/{HierarchyTree → Hierarchy/Tree}/types.js +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":["useModal","getTranslation","formatAdminURL","qs","React","useCallback","useMemo","useState","toast","useConfig","useDocumentSelection","useLocale","useTranslation","requests","ConfirmationModal","useHierarchyDrawer","ListSelectionButton","Translation","baseClass","getParentFieldName","hierarchyConfig","config","hierarchy","undefined","parentFieldName","MoveMany","currentFolderId","hierarchySlug","Icon","modalPrefix","onSuccess","selections","i18n","t","code","locale","openModal","collections","routes","api","getSelectionsWithMetadata","destination","setDestination","confirmMoveDrawerSlug","requiredCollections","selectionsWithMeta","required","Set","collectionSlug","items","Object","entries","metadata","allowedCollections","slug","add","size","Array","from","disabledIds","folderIds","ids","length","HierarchyDrawer","closeDrawer","openDrawer","filterByCollection","hierarchyCollectionSlug","count","label","totalCount","labels","find","c","collectionLabel","plural","singular","push","join","hierarchyCollectionConfig","canMove","handleDrawerSave","selectionsMap","firstSelection","values","next","value","destinationId","id","destinationTitle","path","title","String","handleMoveToRoot","handleConfirmMove","totalMoved","hasErrors","queryString","stringify","where","in","addQueryPrefix","url","apiRoute","response","patch","body","JSON","headers","language","credentials","json","status","errors","error","message","description","map","movedCount","docs","successKey","success","_err","_jsxs","Fragment","_jsx","className","onClick","hasMany","initialSelections","onMoveToRoot","onSave","showMoveToRoot","elements","1","children","i18nKey","variables","confirmingLabel","heading","modalSlug","onConfirm"],"sources":["../../../src/elements/MoveMany/index.tsx"],"sourcesContent":["'use client'\nimport type { ClientCollectionConfig } from 'payload'\n\nimport { useModal } from '@faceless-ui/modal'\nimport { getTranslation } from '@payloadcms/translations'\nimport { formatAdminURL } from 'payload/shared'\nimport * as qs from 'qs-esm'\nimport React, { useCallback, useMemo, useState } from 'react'\nimport { toast } from 'sonner'\n\nimport type { SelectionWithPath } from '../HierarchyDrawer/types.js'\n\nimport { useConfig } from '../../providers/Config/index.js'\nimport { useDocumentSelection } from '../../providers/DocumentSelection/index.js'\nimport { useLocale } from '../../providers/Locale/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { requests } from '../../utilities/api.js'\nimport { ConfirmationModal } from '../ConfirmationModal/index.js'\nimport { useHierarchyDrawer } from '../HierarchyDrawer/index.js'\nimport { ListSelectionButton } from '../ListSelection/index.js'\nimport { Translation } from '../Translation/index.js'\nimport './index.scss'\n\nexport const baseClass = 'move-many'\n\ntype MoveManyProps = {\n /** Current folder ID - drawer will open expanded to this location */\n currentFolderId?: null | number | string\n /** The hierarchy collection slug (e.g., 'folders') */\n hierarchySlug: string\n /** Icon to display in the hierarchy drawer */\n Icon?: React.ReactNode\n /** When multiple MoveMany components are rendered on the page, this will differentiate them */\n modalPrefix?: string\n /** Callback after successful move */\n onSuccess?: () => void\n /** Selections grouped by collection slug */\n selections: Record<string, { ids: (number | string)[] }>\n}\n\n/**\n * Gets the parent field name from the hierarchy config.\n */\nfunction getParentFieldName(\n hierarchyConfig: ClientCollectionConfig | undefined,\n): string | undefined {\n const config =\n hierarchyConfig?.hierarchy && typeof hierarchyConfig.hierarchy === 'object'\n ? hierarchyConfig.hierarchy\n : undefined\n return config?.parentFieldName\n}\n\nexport function MoveMany({\n currentFolderId,\n hierarchySlug,\n Icon,\n modalPrefix,\n onSuccess,\n selections,\n}: MoveManyProps) {\n const { i18n, t } = useTranslation()\n const { code: locale } = useLocale()\n const { openModal } = useModal()\n const {\n config: {\n collections,\n routes: { api },\n },\n } = useConfig()\n\n const { getSelectionsWithMetadata } = useDocumentSelection()\n\n const [destination, setDestination] = useState<{\n id: null | number | string\n title: string\n } | null>(null)\n\n const confirmMoveDrawerSlug = `${modalPrefix ? `${modalPrefix}-` : ''}confirm-move-many`\n\n // Compute required collections from selection metadata\n // For related items: add their collection slug\n // For folders: add their allowedCollections values\n const requiredCollections = useMemo(() => {\n const selectionsWithMeta = getSelectionsWithMetadata()\n const required = new Set<string>()\n\n for (const [collectionSlug, { selections: items }] of Object.entries(selectionsWithMeta)) {\n if (collectionSlug === hierarchySlug) {\n // For folders, add their allowedCollections to required set\n for (const { metadata } of items) {\n if (metadata.allowedCollections) {\n for (const slug of metadata.allowedCollections) {\n required.add(slug)\n }\n }\n }\n } else {\n // For related items, add their collection slug\n required.add(collectionSlug)\n }\n }\n\n return required.size > 0 ? Array.from(required) : undefined\n }, [getSelectionsWithMetadata, hierarchySlug])\n\n // Folders being moved cannot be selected as destination (can't move into themselves)\n const disabledIds = useMemo(() => {\n const folderIds = selections[hierarchySlug]?.ids\n return folderIds?.length ? new Set(folderIds) : undefined\n }, [selections, hierarchySlug])\n\n const [HierarchyDrawer, , { closeDrawer, openDrawer }] = useHierarchyDrawer({\n disabledIds,\n filterByCollection: requiredCollections,\n hierarchyCollectionSlug: hierarchySlug,\n Icon,\n })\n\n // Calculate total count and label\n const { count, label } = useMemo(() => {\n let totalCount = 0\n const labels: string[] = []\n\n for (const [collectionSlug, { ids }] of Object.entries(selections)) {\n const config = collections.find((c) => c.slug === collectionSlug)\n\n if (config && ids.length > 0) {\n totalCount += ids.length\n const collectionLabel = getTranslation(\n ids.length > 1 ? config.labels.plural : config.labels.singular,\n i18n,\n )\n labels.push(collectionLabel)\n }\n }\n\n return {\n count: totalCount,\n label: labels.join(', '),\n }\n }, [selections, collections, i18n])\n\n const hierarchyCollectionConfig = collections.find((c) => c.slug === hierarchySlug)\n const parentFieldName = getParentFieldName(hierarchyCollectionConfig)\n\n // Check if hierarchy has a valid parentFieldName\n const canMove = parentFieldName !== undefined\n\n const handleDrawerSave = useCallback(\n ({ selections: selectionsMap }: { selections: Map<number | string, SelectionWithPath> }) => {\n if (selectionsMap.size === 0) {\n return\n }\n\n const firstSelection = selectionsMap.values().next().value\n const destinationId = firstSelection?.id\n const destinationTitle =\n firstSelection?.path?.[firstSelection.path.length - 1]?.title || String(destinationId)\n\n setDestination({ id: destinationId, title: destinationTitle })\n openModal(confirmMoveDrawerSlug)\n },\n [openModal, confirmMoveDrawerSlug],\n )\n\n const handleMoveToRoot = useCallback(() => {\n setDestination({ id: null, title: t('hierarchy:noParent') })\n openModal(confirmMoveDrawerSlug)\n }, [openModal, confirmMoveDrawerSlug, t])\n\n const handleConfirmMove = useCallback(async () => {\n if (destination === null) {\n return\n }\n\n let totalMoved = 0\n let hasErrors = false\n\n try {\n for (const [collectionSlug, { ids }] of Object.entries(selections)) {\n if (ids.length === 0) {\n continue\n }\n\n const queryString = qs.stringify(\n {\n locale,\n where: { id: { in: ids } },\n },\n { addQueryPrefix: true },\n )\n\n const url = formatAdminURL({\n apiRoute: api,\n path: `/${collectionSlug}${queryString}`,\n })\n\n const response = await requests.patch(url, {\n body: JSON.stringify({ [parentFieldName]: destination.id }),\n headers: {\n 'Accept-Language': i18n.language,\n 'Content-Type': 'application/json',\n credentials: 'include',\n },\n })\n\n const json = await response.json()\n\n if (response.status >= 400) {\n hasErrors = true\n\n if (json?.errors?.length > 0) {\n toast.error(json.message || t('error:unknown'), {\n description: json.errors\n .map((error: { message: string }) => error.message)\n .join('\\n'),\n })\n } else {\n toast.error(json?.message || t('error:unknown'))\n }\n\n continue\n }\n\n const movedCount = json?.docs?.length || 0\n totalMoved += movedCount\n\n if (json?.errors?.length > 0) {\n hasErrors = true\n toast.error(json.message, {\n description: json.errors.map((error: { message: string }) => error.message).join('\\n'),\n })\n }\n }\n\n if (totalMoved > 0) {\n const successKey =\n destination.id === null ? 'hierarchy:itemsMovedToRoot' : 'hierarchy:itemsMovedTo'\n\n toast.success(\n t(successKey, {\n destination: destination.title,\n title: label,\n }),\n )\n }\n\n if (!hasErrors || totalMoved > 0) {\n closeDrawer()\n onSuccess?.()\n }\n } catch (_err) {\n toast.error(t('error:unknown'))\n } finally {\n setDestination(null)\n }\n }, [\n closeDrawer,\n destination,\n selections,\n parentFieldName,\n locale,\n api,\n i18n,\n t,\n label,\n onSuccess,\n ])\n\n if (count === 0 || !canMove) {\n return null\n }\n\n return (\n <React.Fragment>\n <ListSelectionButton\n aria-label={t('general:move')}\n className={`${baseClass}__toggle`}\n onClick={openDrawer}\n >\n {t('general:move')}\n </ListSelectionButton>\n <HierarchyDrawer\n hasMany={false}\n initialSelections={currentFolderId ? [currentFolderId] : null}\n onMoveToRoot={handleMoveToRoot}\n onSave={handleDrawerSave}\n showMoveToRoot\n />\n <ConfirmationModal\n body={\n <p>\n {destination?.id === null ? (\n <Translation\n elements={{\n '1': ({ children }) => <strong>{children}</strong>,\n }}\n i18nKey=\"hierarchy:moveItemsToRootConfirmation\"\n t={t}\n variables={{\n count,\n label,\n }}\n />\n ) : (\n <Translation\n elements={{\n '1': ({ children }) => <strong>{children}</strong>,\n }}\n i18nKey=\"general:moveConfirm\"\n t={t}\n variables={{\n count,\n destination: destination?.title || '',\n label,\n }}\n />\n )}\n </p>\n }\n confirmingLabel={t('general:moving')}\n heading={t('general:confirmMove')}\n modalSlug={confirmMoveDrawerSlug}\n onConfirm={handleConfirmMove}\n />\n </React.Fragment>\n )\n}\n"],"mappings":"AAAA;;;AAGA,SAASA,QAAQ,QAAQ;AACzB,SAASC,cAAc,QAAQ;AAC/B,SAASC,cAAc,QAAQ;AAC/B,YAAYC,EAAA,MAAQ;AACpB,OAAOC,KAAA,IAASC,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ;AACtD,SAASC,KAAK,QAAQ;AAItB,SAASC,SAAS,QAAQ;AAC1B,SAASC,oBAAoB,QAAQ;AACrC,SAASC,SAAS,QAAQ;AAC1B,SAASC,cAAc,QAAQ;AAC/B,SAASC,QAAQ,QAAQ;AACzB,SAASC,iBAAiB,QAAQ;AAClC,SAASC,kBAAkB,QAAQ;AACnC,SAASC,mBAAmB,QAAQ;AACpC,SAASC,WAAW,QAAQ;AAC5B,OAAO;AAEP,OAAO,MAAMC,SAAA,GAAY;AAiBzB;;;AAGA,SAASC,mBACPC,eAAmD;EAEnD,MAAMC,MAAA,GACJD,eAAA,EAAiBE,SAAA,IAAa,OAAOF,eAAA,CAAgBE,SAAS,KAAK,WAC/DF,eAAA,CAAgBE,SAAS,GACzBC,SAAA;EACN,OAAOF,MAAA,EAAQG,eAAA;AACjB;AAEA,OAAO,SAASC,SAAS;EACvBC,eAAe;EACfC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kB,CAACA,eAAA,CAAgB,GAAG;MACzDwG,YAAA,EAAcrC,gBAAA;MACdsC,MAAA,EAAQlD,gBAAA;MACRmD,cAAc;qBAEhBP,IAAA,CAAC/G,iBAAA;MACC4F,IAAA,eACEmB,IAAA,CAAC;kBACEpF,WAAA,EAAa+C,EAAA,KAAO,oBACnBqC,IAAA,CAAC5G,WAAA;UACCoH,QAAA,EAAU;YACR,KAAKC,CAAC;cAAEC;YAAQ,CAAE,kBAAKV,IAAA,CAAC;wBAAQU;;UAClC;UACAC,OAAA,EAAQ;UACRvG,CAAA,EAAGA,CAAA;UACHwG,SAAA,EAAW;YACTrE,KAAA;YACAC;UACF;0BAGFwD,IAAA,CAAC5G,WAAA;UACCoH,QAAA,EAAU;YACR,KAAKC,CAAC;cAAEC,QAAQ,EAARA;YAAQ,CAAE,kBAAKV,IAAA,CAAC;wBAAQU;;UAClC;UACAC,OAAA,EAAQ;UACRvG,CAAA,EAAGA,CAAA;UACHwG,SAAA,EAAW;YACTrE,KAAA;YACA3B,WAAA,EAAaA,WAAA,EAAakD,KAAA,IAAS;YACnCtB;UACF;;;MAKRqE,eAAA,EAAiBzG,CAAA,CAAE;MACnB0G,OAAA,EAAS1G,CAAA,CAAE;MACX2G,SAAA,EAAWjG,qBAAA;MACXkG,SAAA,EAAW/C;;;AAInB","ignoreList":[]}
@@ -1,8 +0,0 @@
1
- import React from 'react';
2
- type LoadMoreButtonProps = {
3
- id: string;
4
- onLoadMore: (() => Promise<void>) | (() => void);
5
- };
6
- export declare const LoadMoreButton: React.FC<LoadMoreButtonProps>;
7
- export {};
8
- //# sourceMappingURL=LoadMoreButton.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LoadMoreButton.d.ts","sourceRoot":"","sources":["../../../../src/elements/Tree/LoadMore/LoadMoreButton.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA8B,MAAM,OAAO,CAAA;AAKlD,KAAK,mBAAmB,GAAG;IACzB,EAAE,EAAE,MAAM,CAAA;IACV,UAAU,EAAE,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,CAAA;CACjD,CAAA;AAED,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAyBxD,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"LoadMoreButton.js","names":["React","useCallback","useRef","useTranslation","useFocusableItem","LoadMoreButton","id","onLoadMore","t","buttonRef","handleFocus","tabIndex","type","ref","handleClick","_jsx","className","onClick","onFocus"],"sources":["../../../../src/elements/Tree/LoadMore/LoadMoreButton.tsx"],"sourcesContent":["'use client'\n\nimport React, { useCallback, useRef } from 'react'\n\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { useFocusableItem } from '../TreeFocusContext.js'\n\ntype LoadMoreButtonProps = {\n id: string\n onLoadMore: (() => Promise<void>) | (() => void)\n}\n\nexport const LoadMoreButton: React.FC<LoadMoreButtonProps> = ({ id, onLoadMore }) => {\n const { t } = useTranslation()\n const buttonRef = useRef<HTMLButtonElement>(null)\n const { handleFocus, tabIndex } = useFocusableItem({\n id,\n type: 'load-more',\n ref: buttonRef,\n })\n\n const handleClick = useCallback(async () => {\n await onLoadMore()\n }, [onLoadMore])\n\n return (\n <button\n className=\"tree__load-more-button\"\n onClick={handleClick}\n onFocus={handleFocus}\n ref={buttonRef}\n tabIndex={tabIndex}\n type=\"button\"\n >\n {t('general:loadMore')}\n </button>\n )\n}\n"],"mappings":"AAAA;;;AAEA,OAAOA,KAAA,IAASC,WAAW,EAAEC,MAAM,QAAQ;AAE3C,SAASC,cAAc,QAAQ;AAC/B,SAASC,gBAAgB,QAAQ;AAOjC,OAAO,MAAMC,cAAA,GAAgDA,CAAC;EAAEC,EAAE;EAAEC;AAAU,CAAE;EAC9E,MAAM;IAAEC;EAAC,CAAE,GAAGL,cAAA;EACd,MAAMM,SAAA,GAAYP,MAAA,CAA0B;EAC5C,MAAM;IAAEQ,WAAW;IAAEC;EAAQ,CAAE,GAAGP,gBAAA,CAAiB;IACjDE,EAAA;IACAM,IAAA,EAAM;IACNC,GAAA,EAAKJ;EACP;EAEA,MAAMK,WAAA,GAAcb,WAAA,CAAY;IAC9B,MAAMM,UAAA;EACR,GAAG,CAACA,UAAA,CAAW;EAEf,oBACEQ,IAAA,CAAC;IACCC,SAAA,EAAU;IACVC,OAAA,EAASH,WAAA;IACTI,OAAA,EAASR,WAAA;IACTG,GAAA,EAAKJ,SAAA;IACLE,QAAA,EAAUA,QAAA;IACVC,IAAA,EAAK;cAEJJ,CAAA,CAAE;;AAGT","ignoreList":[]}
@@ -1,12 +0,0 @@
1
- import React from 'react';
2
- import './index.scss';
3
- type LoadMoreProps = {
4
- currentCount: number;
5
- depth: number;
6
- id: string;
7
- onLoadMore: (() => Promise<void>) | (() => void);
8
- totalDocs: number;
9
- };
10
- export declare const LoadMore: React.FC<LoadMoreProps>;
11
- export {};
12
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/elements/Tree/LoadMore/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,OAAO,cAAc,CAAA;AAErB,KAAK,aAAa,GAAG;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,EAAE,EAAE,MAAM,CAAA;IACV,UAAU,EAAE,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,CAAA;IAChD,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAiB5C,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":["React","LoadMoreRow","LoadMoreButton","LoadMore","id","currentCount","depth","onLoadMore","totalDocs","_jsx","className","hasMore","loadMoreButton","style"],"sources":["../../../../src/elements/Tree/LoadMore/index.tsx"],"sourcesContent":["'use client'\n\nimport React from 'react'\n\nimport { LoadMoreRow } from '../../LoadMoreRow/index.js'\nimport { LoadMoreButton } from './LoadMoreButton.js'\nimport './index.scss'\n\ntype LoadMoreProps = {\n currentCount: number\n depth: number\n id: string\n onLoadMore: (() => Promise<void>) | (() => void)\n totalDocs: number\n}\n\nexport const LoadMore: React.FC<LoadMoreProps> = ({\n id,\n currentCount,\n depth,\n onLoadMore,\n totalDocs,\n}) => {\n return (\n <LoadMoreRow\n className=\"tree__load-more\"\n currentCount={currentCount}\n hasMore={currentCount < totalDocs}\n loadMoreButton={<LoadMoreButton id={id} onLoadMore={onLoadMore} />}\n style={{ '--tree-depth': depth } as React.CSSProperties}\n totalDocs={totalDocs}\n />\n )\n}\n"],"mappings":"AAAA;;;AAEA,OAAOA,KAAA,MAAW;AAElB,SAASC,WAAW,QAAQ;AAC5B,SAASC,cAAc,QAAQ;AAC/B,OAAO;AAUP,OAAO,MAAMC,QAAA,GAAoCA,CAAC;EAChDC,EAAE;EACFC,YAAY;EACZC,KAAK;EACLC,UAAU;EACVC;AAAS,CACV;EACC,oBACEC,IAAA,CAACR,WAAA;IACCS,SAAA,EAAU;IACVL,YAAA,EAAcA,YAAA;IACdM,OAAA,EAASN,YAAA,GAAeG,SAAA;IACxBI,cAAA,eAAgBH,IAAA,CAACP,cAAA;MAAeE,EAAA,EAAIA,EAAA;MAAIG,UAAA,EAAYA;;IACpDM,KAAA,EAAO;MAAE,gBAAgBP;IAAM;IAC/BE,SAAA,EAAWA;;AAGjB","ignoreList":[]}
@@ -1,7 +0,0 @@
1
- import React from 'react';
2
- type TreeConnectorProps = {
3
- className?: string;
4
- };
5
- export declare const TreeConnector: React.FC<TreeConnectorProps>;
6
- export {};
7
- //# sourceMappingURL=TreeConnector.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TreeConnector.d.ts","sourceRoot":"","sources":["../../../src/elements/Tree/TreeConnector.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,KAAK,kBAAkB,GAAG;IACxB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAkBtD,CAAA"}
@@ -1,23 +0,0 @@
1
- 'use client';
2
-
3
- import { jsx as _jsx } from "react/jsx-runtime";
4
- import React from 'react';
5
- export const TreeConnector = ({
6
- className
7
- }) => {
8
- return /*#__PURE__*/_jsx("svg", {
9
- className: className,
10
- fill: "none",
11
- height: "9",
12
- viewBox: "0 0 9 9",
13
- width: "9",
14
- xmlns: "http://www.w3.org/2000/svg",
15
- children: /*#__PURE__*/_jsx("path", {
16
- d: "M7.59062 7.83333H3.16667C2.45942 7.83333 1.78115 7.55238 1.28105 7.05229C0.780951 6.55219 0.5 5.87391 0.5 5.16667V0.5",
17
- stroke: "currentColor",
18
- strokeLinecap: "round",
19
- strokeLinejoin: "round"
20
- })
21
- });
22
- };
23
- //# sourceMappingURL=TreeConnector.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TreeConnector.js","names":["React","TreeConnector","className","_jsx","fill","height","viewBox","width","xmlns","d","stroke","strokeLinecap","strokeLinejoin"],"sources":["../../../src/elements/Tree/TreeConnector.tsx"],"sourcesContent":["'use client'\n\nimport React from 'react'\n\ntype TreeConnectorProps = {\n className?: string\n}\n\nexport const TreeConnector: React.FC<TreeConnectorProps> = ({ className }) => {\n return (\n <svg\n className={className}\n fill=\"none\"\n height=\"9\"\n viewBox=\"0 0 9 9\"\n width=\"9\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M7.59062 7.83333H3.16667C2.45942 7.83333 1.78115 7.55238 1.28105 7.05229C0.780951 6.55219 0.5 5.87391 0.5 5.16667V0.5\"\n stroke=\"currentColor\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n )\n}\n"],"mappings":"AAAA;;;AAEA,OAAOA,KAAA,MAAW;AAMlB,OAAO,MAAMC,aAAA,GAA8CA,CAAC;EAAEC;AAAS,CAAE;EACvE,oBACEC,IAAA,CAAC;IACCD,SAAA,EAAWA,SAAA;IACXE,IAAA,EAAK;IACLC,MAAA,EAAO;IACPC,OAAA,EAAQ;IACRC,KAAA,EAAM;IACNC,KAAA,EAAM;cAEN,aAAAL,IAAA,CAAC;MACCM,CAAA,EAAE;MACFC,MAAA,EAAO;MACPC,aAAA,EAAc;MACdC,cAAA,EAAe;;;AAIvB","ignoreList":[]}
@@ -1,28 +0,0 @@
1
- import type React from 'react';
2
- type FocusableItem = {
3
- id: string;
4
- ref: React.RefObject<HTMLElement>;
5
- type: 'load-more' | 'node';
6
- };
7
- type TreeFocusContextType = {
8
- focusedId: null | string;
9
- moveFocus: (direction: 'down' | 'up') => void;
10
- registerItem: (item: FocusableItem) => void;
11
- setFocusedId: (id: null | string) => void;
12
- unregisterItem: (id: string) => void;
13
- };
14
- export declare const TreeFocusProvider: React.FC<{
15
- children: React.ReactNode;
16
- }>;
17
- export declare const useTreeFocus: () => TreeFocusContextType;
18
- export declare const useFocusableItem: ({ id, type, ref, }: {
19
- id: string;
20
- ref: React.RefObject<HTMLElement>;
21
- type: "load-more" | "node";
22
- }) => {
23
- handleFocus: () => void;
24
- isFocused: boolean;
25
- tabIndex: number;
26
- };
27
- export {};
28
- //# sourceMappingURL=TreeFocusContext.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TreeFocusContext.d.ts","sourceRoot":"","sources":["../../../src/elements/Tree/TreeFocusContext.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAI9B,KAAK,aAAa,GAAG;IACnB,EAAE,EAAE,MAAM,CAAA;IACV,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAA;IACjC,IAAI,EAAE,WAAW,GAAG,MAAM,CAAA;CAC3B,CAAA;AAED,KAAK,oBAAoB,GAAG;IAC1B,SAAS,EAAE,IAAI,GAAG,MAAM,CAAA;IACxB,SAAS,EAAE,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAA;IAC7C,YAAY,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,IAAI,CAAA;IAC3C,YAAY,EAAE,CAAC,EAAE,EAAE,IAAI,GAAG,MAAM,KAAK,IAAI,CAAA;IACzC,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAA;CACrC,CAAA;AAID,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,CAsErE,CAAA;AAED,eAAO,MAAM,YAAY,4BAMxB,CAAA;AAED,eAAO,MAAM,gBAAgB,uBAI1B;IACD,EAAE,EAAE,MAAM,CAAA;IACV,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAA;IACjC,IAAI,EAAE,WAAW,GAAG,MAAM,CAAA;CAC3B;;;;CAwBA,CAAA"}
@@ -1,140 +0,0 @@
1
- 'use client';
2
-
3
- import { c as _c } from "react/compiler-runtime";
4
- import { jsx as _jsx } from "react/jsx-runtime";
5
- import { createContext, use, useCallback, useEffect, useRef, useState } from 'react';
6
- const TreeFocusContext = /*#__PURE__*/createContext(undefined);
7
- export const TreeFocusProvider = ({
8
- children
9
- }) => {
10
- const [focusedId, setFocusedId] = useState(null);
11
- const itemsRef = useRef(new Map());
12
- const registerItem = useCallback(item => {
13
- itemsRef.current.set(item.id, item);
14
- }, []);
15
- const unregisterItem = useCallback(id => {
16
- itemsRef.current.delete(id);
17
- }, []);
18
- const moveFocus = useCallback(direction => {
19
- const items = Array.from(itemsRef.current.values());
20
- if (items.length === 0) {
21
- return;
22
- }
23
- // Sort items by their DOM position to ensure correct navigation order
24
- const sortedItems = items.filter(item_0 => item_0.ref.current).sort((a, b) => {
25
- const aElement = a.ref.current;
26
- const bElement = b.ref.current;
27
- if (!aElement || !bElement) {
28
- return 0;
29
- }
30
- const position = aElement.compareDocumentPosition(bElement);
31
- if (position & Node.DOCUMENT_POSITION_FOLLOWING) {
32
- return -1;
33
- }
34
- if (position & Node.DOCUMENT_POSITION_PRECEDING) {
35
- return 1;
36
- }
37
- return 0;
38
- });
39
- const currentIndex = focusedId ? sortedItems.findIndex(item_1 => item_1.id === focusedId) : -1;
40
- let nextIndex;
41
- if (direction === 'down') {
42
- nextIndex = currentIndex === -1 ? 0 : Math.min(currentIndex + 1, sortedItems.length - 1);
43
- } else {
44
- nextIndex = Math.max(currentIndex - 1, 0);
45
- }
46
- const nextItem = sortedItems[nextIndex];
47
- if (nextItem && nextItem.ref.current) {
48
- nextItem.ref.current.focus();
49
- setFocusedId(nextItem.id);
50
- }
51
- }, [focusedId]);
52
- return /*#__PURE__*/_jsx(TreeFocusContext, {
53
- value: {
54
- focusedId,
55
- moveFocus,
56
- registerItem,
57
- setFocusedId,
58
- unregisterItem
59
- },
60
- children: children
61
- });
62
- };
63
- export const useTreeFocus = () => {
64
- const context = use(TreeFocusContext);
65
- if (!context) {
66
- throw new Error('useTreeFocus must be used within TreeFocusProvider');
67
- }
68
- return context;
69
- };
70
- export const useFocusableItem = t0 => {
71
- const $ = _c(14);
72
- const {
73
- id,
74
- type,
75
- ref
76
- } = t0;
77
- const {
78
- focusedId,
79
- registerItem,
80
- setFocusedId,
81
- unregisterItem
82
- } = useTreeFocus();
83
- const isFocused = focusedId === id;
84
- const isFirstItemEver = focusedId === null;
85
- let t1;
86
- let t2;
87
- if ($[0] !== id || $[1] !== ref || $[2] !== registerItem || $[3] !== type || $[4] !== unregisterItem) {
88
- t1 = () => {
89
- registerItem({
90
- id,
91
- type,
92
- ref
93
- });
94
- return () => {
95
- unregisterItem(id);
96
- };
97
- };
98
- t2 = [id, ref, type, registerItem, unregisterItem];
99
- $[0] = id;
100
- $[1] = ref;
101
- $[2] = registerItem;
102
- $[3] = type;
103
- $[4] = unregisterItem;
104
- $[5] = t1;
105
- $[6] = t2;
106
- } else {
107
- t1 = $[5];
108
- t2 = $[6];
109
- }
110
- useEffect(t1, t2);
111
- let t3;
112
- if ($[7] !== id || $[8] !== setFocusedId) {
113
- t3 = () => {
114
- setFocusedId(id);
115
- };
116
- $[7] = id;
117
- $[8] = setFocusedId;
118
- $[9] = t3;
119
- } else {
120
- t3 = $[9];
121
- }
122
- const handleFocus = t3;
123
- const tabIndex = isFocused ? 0 : isFirstItemEver ? 0 : -1;
124
- let t4;
125
- if ($[10] !== handleFocus || $[11] !== isFocused || $[12] !== tabIndex) {
126
- t4 = {
127
- handleFocus,
128
- isFocused,
129
- tabIndex
130
- };
131
- $[10] = handleFocus;
132
- $[11] = isFocused;
133
- $[12] = tabIndex;
134
- $[13] = t4;
135
- } else {
136
- t4 = $[13];
137
- }
138
- return t4;
139
- };
140
- //# sourceMappingURL=TreeFocusContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TreeFocusContext.js","names":["c","_c","createContext","use","useCallback","useEffect","useRef","useState","TreeFocusContext","undefined","TreeFocusProvider","children","focusedId","setFocusedId","itemsRef","Map","registerItem","item","current","set","id","unregisterItem","delete","moveFocus","direction","items","Array","from","values","length","sortedItems","filter","ref","sort","a","b","aElement","bElement","position","compareDocumentPosition","Node","DOCUMENT_POSITION_FOLLOWING","DOCUMENT_POSITION_PRECEDING","currentIndex","findIndex","nextIndex","Math","min","max","nextItem","focus","_jsx","value","useTreeFocus","context","Error","useFocusableItem","t0","$","type","isFocused","isFirstItemEver","t1","t2","t3","handleFocus","tabIndex","t4"],"sources":["../../../src/elements/Tree/TreeFocusContext.tsx"],"sourcesContent":["'use client'\n\nimport type React from 'react'\n\nimport { createContext, use, useCallback, useEffect, useRef, useState } from 'react'\n\ntype FocusableItem = {\n id: string\n ref: React.RefObject<HTMLElement>\n type: 'load-more' | 'node'\n}\n\ntype TreeFocusContextType = {\n focusedId: null | string\n moveFocus: (direction: 'down' | 'up') => void\n registerItem: (item: FocusableItem) => void\n setFocusedId: (id: null | string) => void\n unregisterItem: (id: string) => void\n}\n\nconst TreeFocusContext = createContext<TreeFocusContextType | undefined>(undefined)\n\nexport const TreeFocusProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {\n const [focusedId, setFocusedId] = useState<null | string>(null)\n const itemsRef = useRef<Map<string, FocusableItem>>(new Map())\n\n const registerItem = useCallback((item: FocusableItem) => {\n itemsRef.current.set(item.id, item)\n }, [])\n\n const unregisterItem = useCallback((id: string) => {\n itemsRef.current.delete(id)\n }, [])\n\n const moveFocus = useCallback(\n (direction: 'down' | 'up') => {\n const items = Array.from(itemsRef.current.values())\n if (items.length === 0) {\n return\n }\n\n // Sort items by their DOM position to ensure correct navigation order\n const sortedItems = items\n .filter((item) => item.ref.current)\n .sort((a, b) => {\n const aElement = a.ref.current\n const bElement = b.ref.current\n if (!aElement || !bElement) {\n return 0\n }\n\n const position = aElement.compareDocumentPosition(bElement)\n if (position & Node.DOCUMENT_POSITION_FOLLOWING) {\n return -1\n }\n if (position & Node.DOCUMENT_POSITION_PRECEDING) {\n return 1\n }\n return 0\n })\n\n const currentIndex = focusedId ? sortedItems.findIndex((item) => item.id === focusedId) : -1\n\n let nextIndex: number\n if (direction === 'down') {\n nextIndex = currentIndex === -1 ? 0 : Math.min(currentIndex + 1, sortedItems.length - 1)\n } else {\n nextIndex = Math.max(currentIndex - 1, 0)\n }\n\n const nextItem = sortedItems[nextIndex]\n if (nextItem && nextItem.ref.current) {\n nextItem.ref.current.focus()\n setFocusedId(nextItem.id)\n }\n },\n [focusedId],\n )\n\n return (\n <TreeFocusContext\n value={{\n focusedId,\n moveFocus,\n registerItem,\n setFocusedId,\n unregisterItem,\n }}\n >\n {children}\n </TreeFocusContext>\n )\n}\n\nexport const useTreeFocus = () => {\n const context = use(TreeFocusContext)\n if (!context) {\n throw new Error('useTreeFocus must be used within TreeFocusProvider')\n }\n return context\n}\n\nexport const useFocusableItem = ({\n id,\n type,\n ref,\n}: {\n id: string\n ref: React.RefObject<HTMLElement>\n type: 'load-more' | 'node'\n}) => {\n const { focusedId, registerItem, setFocusedId, unregisterItem } = useTreeFocus()\n const isFocused = focusedId === id\n const isFirstItemEver = focusedId === null\n\n useEffect(() => {\n registerItem({ id, type, ref })\n return () => {\n unregisterItem(id)\n }\n }, [id, ref, type, registerItem, unregisterItem])\n\n const handleFocus = useCallback(() => {\n setFocusedId(id)\n }, [id, setFocusedId])\n\n // Roving tabindex: focused item gets 0, first item (when nothing focused) gets 0, all others get -1\n const tabIndex = isFocused ? 0 : isFirstItemEver ? 0 : -1\n\n return {\n handleFocus,\n isFocused,\n tabIndex,\n }\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAIA,SAASC,aAAa,EAAEC,GAAG,EAAEC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAgB7E,MAAMC,gBAAA,gBAAmBN,aAAA,CAAgDO,SAAA;AAEzE,OAAO,MAAMC,iBAAA,GAA6DA,CAAC;EAAEC;AAAQ,CAAE;EACrF,MAAM,CAACC,SAAA,EAAWC,YAAA,CAAa,GAAGN,QAAA,CAAwB;EAC1D,MAAMO,QAAA,GAAWR,MAAA,CAAmC,IAAIS,GAAA;EAExD,MAAMC,YAAA,GAAeZ,WAAA,CAAaa,IAAA;IAChCH,QAAA,CAASI,OAAO,CAACC,GAAG,CAACF,IAAA,CAAKG,EAAE,EAAEH,IAAA;EAChC,GAAG,EAAE;EAEL,MAAMI,cAAA,GAAiBjB,WAAA,CAAagB,EAAA;IAClCN,QAAA,CAASI,OAAO,CAACI,MAAM,CAACF,EAAA;EAC1B,GAAG,EAAE;EAEL,MAAMG,SAAA,GAAYnB,WAAA,CACfoB,SAAA;IACC,MAAMC,KAAA,GAAQC,KAAA,CAAMC,IAAI,CAACb,QAAA,CAASI,OAAO,CAACU,MAAM;IAChD,IAAIH,KAAA,CAAMI,MAAM,KAAK,GAAG;MACtB;IACF;IAEA;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;EAAA;EALhDrD,SAAA,CAAUyD,EAKV,EAAGC,EAA6C;EAAA,IAAAC,EAAA;EAAA,IAAAN,CAAA,QAAAtC,EAAA,IAAAsC,CAAA,QAAA7C,YAAA;IAEhBmD,EAAA,GAAAA,CAAA;MAC9BnD,YAAA,CAAaO,EAAA;IAAA;IACfsC,CAAA,MAAAtC,EAAA;IAAAsC,CAAA,MAAA7C,YAAA;IAAA6C,CAAA,MAAAM,EAAA;EAAA;IAAAA,EAAA,GAAAN,CAAA;EAAA;EAFA,MAAAO,WAAA,GAAoBD,EAEC;EAGrB,MAAAE,QAAA,GAAiBN,SAAA,OAAgBC,eAAA,SAAuB;EAAA,IAAAM,EAAA;EAAA,IAAAT,CAAA,SAAAO,WAAA,IAAAP,CAAA,SAAAE,SAAA,IAAAF,CAAA,SAAAQ,QAAA;IAEjDC,EAAA;MAAAF,WAAA;MAAAL,SAAA;MAAAM;IAAA;IAIPR,CAAA,OAAAO,WAAA;IAAAP,CAAA,OAAAE,SAAA;IAAAF,CAAA,OAAAQ,QAAA;IAAAR,CAAA,OAAAS,EAAA;EAAA;IAAAA,EAAA,GAAAT,CAAA;EAAA;EAAA,OAJOS,EAIP;AAAA,CACF","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/elements/Tree/TreeNode/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA8B,MAAM,OAAO,CAAA;AAElD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAQhD,OAAO,cAAc,CAAA;AAqBrB,eAAO,MAAM,QAAQ,oNAiBlB,aAAa,sBAgMf,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":["React","useCallback","useRef","Spinner","ChevronIcon","useTranslation","LoadMore","useFocusableItem","useTreeFocus","useChildren","DEFAULT_TREE_LIMIT","baseClass","getDocumentTitle","doc","useAsTitle","docId","id","idStr","String","value","TreeNode","allPossibleTypeValues","baseFilter","cache","collectionSlug","depth","expandedNodes","filterByCollections","limit","node","onSelect","onToggle","parentFieldName","selected","selectedNodeId","typeFieldName","t","expanded","has","nodeRef","setFocusedId","children","hasMore","isLoading","loadMore","loadMoreFromHook","totalDocs","enabled","parentId","handleLoadMore","newDocs","length","firstNewDoc","handleFocus","isFocused","tabIndex","type","ref","useEffect","current","document","activeElement","focus","hasChildren","handleToggleClick","e","stopPropagation","handleSelectClick","handleKeyDown","key","preventDefault","_jsxs","undefined","className","onFocus","onKeyDown","role","style","filter","Boolean","join","_jsx","onClick","onMouseDown","direction","title","loadingText","size","_Fragment","map","child","childData","childId","childTitle","currentCount","onLoadMore"],"sources":["../../../../src/elements/Tree/TreeNode/index.tsx"],"sourcesContent":["'use client'\n\nimport React, { useCallback, useRef } from 'react'\n\nimport type { TreeNodeProps } from '../types.js'\n\nimport { Spinner } from '../../../elements/Spinner/index.js'\nimport { ChevronIcon } from '../../../icons/Chevron/index.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { LoadMore } from '../LoadMore/index.js'\nimport { useFocusableItem, useTreeFocus } from '../TreeFocusContext.js'\nimport { useChildren } from '../useChildren.js'\nimport './index.scss'\n\nconst DEFAULT_TREE_LIMIT = 10\n\nconst baseClass = 'tree-node'\n\nconst getDocumentTitle = (doc: Record<string, unknown>, useAsTitle: string | undefined): string => {\n const docId: number | string = doc.id as number | string\n const idStr = typeof docId === 'number' ? String(docId) : docId\n\n if (!useAsTitle) {\n return idStr\n }\n\n const value = doc[useAsTitle]\n if (value && (typeof value === 'string' || typeof value === 'number')) {\n return String(value)\n }\n return idStr\n}\n\nexport const TreeNode = ({\n allPossibleTypeValues,\n baseFilter,\n cache,\n collectionSlug,\n depth = 0,\n expandedNodes,\n filterByCollections,\n limit = DEFAULT_TREE_LIMIT,\n node,\n onSelect,\n onToggle,\n parentFieldName,\n selected,\n selectedNodeId,\n typeFieldName,\n useAsTitle,\n}: TreeNodeProps) => {\n const { t } = useTranslation()\n const expanded = expandedNodes.has(node.id)\n const nodeRef = useRef<HTMLDivElement>(null)\n const { setFocusedId } = useTreeFocus()\n\n const {\n children,\n hasMore,\n isLoading,\n loadMore: loadMoreFromHook,\n totalDocs,\n } = useChildren({\n allPossibleTypeValues,\n baseFilter,\n cache,\n collectionSlug,\n enabled: expanded,\n filterByCollections,\n limit,\n parentFieldName,\n parentId: node.id,\n typeFieldName,\n useAsTitle,\n })\n\n const handleLoadMore = React.useCallback(async () => {\n const newDocs = await loadMoreFromHook()\n\n if (newDocs && newDocs.length > 0) {\n const firstNewDoc = newDocs[0]\n const docId: number | string = (firstNewDoc as { id: number | string }).id\n setFocusedId(`node-${docId}`)\n }\n }, [loadMoreFromHook, setFocusedId])\n\n const { handleFocus, isFocused, tabIndex } = useFocusableItem({\n id: `node-${node.id}`,\n type: 'node',\n ref: nodeRef,\n })\n\n // When focusedId points to this node, actually call .focus()\n React.useEffect(() => {\n if (isFocused && nodeRef.current && document.activeElement !== nodeRef.current) {\n nodeRef.current.focus()\n }\n }, [isFocused])\n\n // Determine if node has children:\n // - If explicitly set in data, use that\n // - If expanded and loaded, check the actual children\n // - Otherwise, assume it might have children (show chevron until proven otherwise)\n const hasChildren =\n node.hasChildren === true || (expanded && children !== null ? children.length > 0 : true)\n\n const handleToggleClick = useCallback(\n (e: React.MouseEvent) => {\n e.stopPropagation()\n onToggle({ id: node.id })\n },\n [node.id, onToggle],\n )\n\n const handleSelectClick = useCallback(() => {\n onSelect?.({ id: node.id })\n }, [node.id, onSelect])\n\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent) => {\n switch (e.key) {\n case ' ':\n case 'Enter':\n e.preventDefault()\n e.stopPropagation()\n handleSelectClick()\n break\n case 'ArrowLeft':\n e.preventDefault()\n e.stopPropagation()\n if (hasChildren && expanded) {\n onToggle({ id: node.id })\n }\n break\n case 'ArrowRight':\n e.preventDefault()\n e.stopPropagation()\n if (hasChildren && !expanded) {\n onToggle({ id: node.id })\n }\n break\n }\n },\n [hasChildren, expanded, handleSelectClick, onToggle, node.id],\n )\n\n return (\n <div\n aria-expanded={hasChildren ? expanded : undefined}\n aria-level={depth + 1}\n aria-selected={selected}\n className={baseClass}\n onFocus={handleFocus}\n onKeyDown={handleKeyDown}\n ref={nodeRef}\n role=\"treeitem\"\n style={{ '--tree-depth': depth } as React.CSSProperties}\n tabIndex={tabIndex}\n >\n <div\n className={[`${baseClass}__content`, selected && `${baseClass}__content--selected`]\n .filter(Boolean)\n .join(' ')}\n >\n <div className={`${baseClass}__indicator`} />\n {hasChildren ? (\n <button\n aria-label={expanded ? t('general:collapse') : t('general:open')}\n className={`${baseClass}__toggle`}\n onClick={handleToggleClick}\n onMouseDown={(e) => e.preventDefault()}\n tabIndex={-1}\n type=\"button\"\n >\n <ChevronIcon direction={expanded ? 'down' : 'right'} />\n </button>\n ) : (\n <div className={`${baseClass}__toggle-spacer`} />\n )}\n {/* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions -- keyboard handled by parent */}\n <span\n className={`${baseClass}__title`}\n onClick={handleSelectClick}\n onMouseDown={(e) => e.preventDefault()}\n title={node.title}\n >\n {node.title}\n </span>\n {isLoading && expanded && (\n <span className={`${baseClass}__loading`}>\n <Spinner loadingText={null} size=\"small\" />\n </span>\n )}\n </div>\n\n {expanded && children && children.length > 0 && (\n <>\n <div className={`${baseClass}__children`} role=\"group\">\n {children.map((child) => {\n const childData = child as { id: number | string }\n const childId = childData.id\n const childTitle = getDocumentTitle(child, useAsTitle)\n return (\n <TreeNode\n allPossibleTypeValues={allPossibleTypeValues}\n baseFilter={baseFilter}\n cache={cache}\n collectionSlug={collectionSlug}\n depth={depth + 1}\n expandedNodes={expandedNodes}\n filterByCollections={filterByCollections}\n key={String(childId)}\n limit={limit}\n node={{\n id: childId,\n hasChildren: true,\n title: childTitle,\n }}\n onSelect={onSelect}\n onToggle={onToggle}\n parentFieldName={parentFieldName}\n selected={String(childId) === String(selectedNodeId)}\n selectedNodeId={selectedNodeId}\n typeFieldName={typeFieldName}\n useAsTitle={useAsTitle}\n />\n )\n })}\n </div>\n {hasMore && (\n <LoadMore\n currentCount={children.length}\n depth={depth + 1}\n id={`load-more-${node.id}`}\n onLoadMore={handleLoadMore}\n totalDocs={totalDocs}\n />\n )}\n </>\n )}\n </div>\n )\n}\n"],"mappings":"AAAA;;;AAEA,OAAOA,KAAA,IAASC,WAAW,EAAEC,MAAM,QAAQ;AAI3C,SAASC,OAAO,QAAQ;AACxB,SAASC,WAAW,QAAQ;AAC5B,SAASC,cAAc,QAAQ;AAC/B,SAASC,QAAQ,QAAQ;AACzB,SAASC,gBAAgB,EAAEC,YAAY,QAAQ;AAC/C,SAASC,WAAW,QAAQ;AAC5B,OAAO;AAEP,MAAMC,kBAAA,GAAqB;AAE3B,MAAMC,SAAA,GAAY;AAElB,MAAMC,gBAAA,GAAmBA,CAACC,GAAA,EAA8BC,UAAA;EACtD,MAAMC,KAAA,GAAyBF,GAAA,CAAIG,EAAE;EACrC,MAAMC,KAAA,GAAQ,OAAOF,KAAA,KAAU,WAAWG,MAAA,CAAOH,KAAA,IAASA,KAAA;EAE1D,IAAI,CAACD,UAAA,EAAY;IACf,OAAOG,KAAA;EACT;EAEA,MAAME,KAAA,GAAQN,GAAG,CAACC,UAAA,CAAW;EAC7B,IAAIK,KAAA,KAAU,OAAOA,KAAA,KAAU,YAAY,OAAOA,KAAA,KAAU,QAAO,GAAI;IACrE,OAAOD,MAAA,CAAOC,KAAA;EAChB;EACA,OAAOF,KAAA;AACT;AAEA,OAAO,MAAMG,QAAA,GAAWA,CAAC;EACvBC,qBAAqB;EACrBC,UAAU;EACVC,KAAK;EACLC,cAAc;EACdC,KAAA,GAAQ,CAAC;EACTC,aAAa;EACbC,mBAAmB;EACnBC,KAAA,GAAQlB,kBAAkB;EAC1BmB,IAAI;EACJC,QAAQ;EACRC,QAAQ;EACRC,eAAe;EACfC,QAAQ;EACRC,cAAc;EACdC,aAAa;EACbrB;AAAU,CACI;EACd,MAAM;I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import React from 'react';
2
- import type { TreeProps } from './types.js';
3
- import './index.scss';
4
- export declare const Tree: React.FC<TreeProps>;
5
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/Tree/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAiC,MAAM,OAAO,CAAA;AAErD,OAAO,KAAK,EAAgC,SAAS,EAAE,MAAM,YAAY,CAAA;AASzE,OAAO,cAAc,CAAA;AA8QrB,eAAO,MAAM,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAMpC,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":["getTranslation","useRouter","React","useId","useMemo","useRef","CreateDocumentButton","DelayedSpinner","TagIcon","useConfig","useTranslation","LoadMore","TreeFocusProvider","useTreeFocus","TreeNode","useChildren","baseClass","DEFAULT_TREE_LIMIT","getDocumentTitle","doc","useAsTitle","docId","id","idStr","String","value","TreeInner","allPossibleTypeValues","baseFilter","collectionSlug","expandedNodes","filterByCollections","icon","initialData","onNodeClick","parentFieldName","selectedNodeId","showAllOption","toggleNode","treeLimit","typeFieldName","moveFocus","router","i18n","t","getEntityConfig","createDrawerSlug","childrenCache","Map","baseFilterKey","JSON","stringify","prevBaseFilterKeyRef","current","clear","docs","length","docsByParent","parentId","parentKey","has","set","parentDocs","get","push","filterKey","slice","sort","join","cacheKey","parentMeta","loadedParents","loadedCount","currentPage","Math","ceil","children","hasMore","page","totalDocs","treeRef","rootNodes","isLoading","loadMore","loadMoreFromHook","refresh","cache","enabled","limit","handleLoadMore","useCallback","handleNodeClick","_jsx","className","collectionLabel","buttonStyle","collections","drawerSlug","label","labels","singular","onSave","handleTreeKeyDown","e","key","preventDefault","isAllSelected","handleAllClick","_jsxs","onKeyDown","ref","role","tabIndex","onClick","color","plural","map","node","nodeId","nodeIdStr","nodeTitle","isSelected","depth","hasChildren","title","onSelect","onToggle","selected","currentCount","onLoadMore","Tree","props"],"sources":["../../../src/elements/Tree/index.tsx"],"sourcesContent":["'use client'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { useRouter } from 'next/navigation.js'\nimport React, { useId, useMemo, useRef } from 'react'\n\nimport type { CachedChildren, TreeDocument, TreeProps } from './types.js'\n\nimport { CreateDocumentButton } from '../../elements/CreateDocumentButton/index.js'\nimport { DelayedSpinner } from '../../elements/DelayedSpinner/index.js'\nimport { TagIcon } from '../../icons/Tag/index.js'\nimport { useConfig } from '../../providers/Config/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { LoadMore } from './LoadMore/index.js'\nimport { TreeFocusProvider, useTreeFocus } from './TreeFocusContext.js'\nimport './index.scss'\nimport { TreeNode } from './TreeNode/index.js'\nimport { useChildren } from './useChildren.js'\n\nconst baseClass = 'tree'\nconst DEFAULT_TREE_LIMIT = 10\n\nconst getDocumentTitle = (doc: TreeDocument, useAsTitle: string | undefined): string => {\n const docId: number | string = doc.id\n const idStr = typeof docId === 'number' ? String(docId) : docId\n\n if (!useAsTitle) {\n return idStr\n }\n\n const value = doc[useAsTitle]\n if (value && (typeof value === 'string' || typeof value === 'number')) {\n return String(value)\n }\n return idStr\n}\n\nconst TreeInner: React.FC<TreeProps> = ({\n allPossibleTypeValues,\n baseFilter,\n collectionSlug,\n expandedNodes,\n filterByCollections,\n icon,\n initialData,\n onNodeClick,\n parentFieldName,\n selectedNodeId,\n showAllOption = true,\n toggleNode,\n treeLimit = DEFAULT_TREE_LIMIT,\n typeFieldName,\n useAsTitle,\n}) => {\n const { moveFocus } = useTreeFocus()\n const router = useRouter()\n const { i18n, t } = useTranslation()\n const { getEntityConfig } = useConfig()\n const createDrawerSlug = `tree-create-${useId()}`\n\n // Pre-populate cache with initialData SYNCHRONOUSLY (before first render)\n // This ensures expanded children find their data immediately without client-side fetch\n const childrenCache = useRef<Map<string, CachedChildren>>(new Map())\n\n // Track previous baseFilter to clear cache when tenant changes\n // Use JSON string comparison since baseFilter is an object\n const baseFilterKey = baseFilter ? JSON.stringify(baseFilter) : ''\n\n const prevBaseFilterKeyRef = useRef(baseFilterKey)\n if (prevBaseFilterKeyRef.current !== baseFilterKey) {\n prevBaseFilterKeyRef.current = baseFilterKey\n childrenCache.current.clear()\n }\n\n // Populate cache from initialData\n useMemo(() => {\n if (!initialData || initialData.docs.length === 0) {\n return\n }\n\n // Group docs by parent to populate cache\n const docsByParent = new Map<string, TreeDocument[]>()\n\n for (const doc of initialData.docs) {\n const parentId = doc[parentFieldName] || 'null'\n const parentKey = String(parentId)\n\n if (!docsByParent.has(parentKey)) {\n docsByParent.set(parentKey, [])\n }\n const parentDocs = docsByParent.get(parentKey)\n if (parentDocs) {\n parentDocs.push(doc)\n }\n }\n\n // Populate cache with grouped docs and metadata from server\n const filterKey = filterByCollections?.length\n ? filterByCollections.slice().sort().join(',')\n : ''\n for (const [parentKey, docs] of docsByParent) {\n const cacheKey = `${collectionSlug}-${parentKey}-${filterKey}`\n const parentMeta = initialData.loadedParents[parentKey]\n\n if (parentMeta) {\n // Calculate page number based on loaded count\n // If server loaded multiple pages to find a selected node, loadedCount > treeLimit\n const loadedCount = parentMeta.loadedCount ?? docs.length\n const currentPage = Math.ceil(loadedCount / treeLimit) || 1\n\n childrenCache.current.set(cacheKey, {\n children: docs,\n hasMore: parentMeta.hasMore,\n page: currentPage,\n totalDocs: parentMeta.totalDocs,\n })\n } else {\n // Shouldn't happen, but fallback to conservative estimate\n childrenCache.current.set(cacheKey, {\n children: docs,\n hasMore: false,\n page: 1,\n totalDocs: docs.length,\n })\n }\n }\n }, [initialData, filterByCollections, parentFieldName, collectionSlug, treeLimit])\n const treeRef = useRef<HTMLDivElement>(null)\n\n // Fetch root nodes (items with no parent)\n const {\n children: rootNodes,\n hasMore,\n isLoading,\n loadMore: loadMoreFromHook,\n refresh,\n totalDocs,\n } = useChildren({\n allPossibleTypeValues,\n baseFilter,\n cache: childrenCache,\n collectionSlug,\n enabled: true,\n filterByCollections,\n initialData,\n limit: treeLimit,\n parentFieldName,\n parentId: 'null', // Special value to query for null parent\n typeFieldName,\n useAsTitle,\n })\n\n // Wrap loadMore - focusedId stays the same, tabindex handles the rest\n const handleLoadMore = React.useCallback(async () => {\n await loadMoreFromHook()\n }, [loadMoreFromHook])\n\n const handleNodeClick = ({ id }: { id: number | string }) => {\n if (onNodeClick) {\n onNodeClick({ id })\n }\n }\n\n // Show loading state with delay to prevent flash\n if (isLoading && !rootNodes) {\n return (\n <div className={baseClass}>\n <DelayedSpinner baseClass={baseClass} isLoading={true} />\n </div>\n )\n }\n\n // Show empty state after loading completes\n if (!rootNodes || rootNodes.length === 0) {\n const collectionLabel = getEntityConfig({ collectionSlug })\n return (\n <div className={baseClass}>\n <CreateDocumentButton\n buttonStyle=\"primary\"\n collections={[{ collectionSlug }]}\n drawerSlug={createDrawerSlug}\n label={t('general:createNewLabel', {\n label: getTranslation(collectionLabel.labels.singular, i18n),\n })}\n onSave={async () => {\n await refresh()\n router.refresh()\n }}\n />\n </div>\n )\n }\n\n const handleTreeKeyDown = (e: React.KeyboardEvent) => {\n if (e.key === 'ArrowDown') {\n e.preventDefault()\n moveFocus('down')\n } else if (e.key === 'ArrowUp') {\n e.preventDefault()\n moveFocus('up')\n }\n }\n\n const isAllSelected = selectedNodeId === null\n\n const handleAllClick = () => {\n if (onNodeClick) {\n onNodeClick({ id: null })\n }\n }\n\n return (\n <div\n className={baseClass}\n onKeyDown={handleTreeKeyDown}\n ref={treeRef}\n role=\"tree\"\n tabIndex={-1}\n >\n {showAllOption && (\n <div\n aria-selected={isAllSelected}\n className={`${baseClass}__all-option${isAllSelected ? ` ${baseClass}__all-option--selected` : ''}`}\n onClick={handleAllClick}\n onKeyDown={(e) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n handleAllClick()\n }\n }}\n role=\"treeitem\"\n tabIndex={0}\n >\n {icon || <TagIcon color=\"muted\" />}\n <span>\n {t('general:all')}{' '}\n {getTranslation(getEntityConfig({ collectionSlug })?.labels?.plural, i18n)}\n </span>\n </div>\n )}\n {rootNodes.map((node) => {\n const nodeId: number | string = node.id\n const nodeIdStr = typeof nodeId === 'number' ? String(nodeId) : nodeId\n const nodeTitle = getDocumentTitle(node, useAsTitle)\n const isSelected = nodeIdStr === String(selectedNodeId)\n\n return (\n <TreeNode\n allPossibleTypeValues={allPossibleTypeValues}\n baseFilter={baseFilter}\n cache={childrenCache}\n collectionSlug={collectionSlug}\n depth={0}\n expandedNodes={expandedNodes}\n filterByCollections={filterByCollections}\n key={nodeIdStr}\n limit={treeLimit}\n node={{\n id: nodeId,\n hasChildren: true,\n title: nodeTitle,\n }}\n onSelect={handleNodeClick}\n onToggle={toggleNode}\n parentFieldName={parentFieldName}\n selected={isSelected}\n selectedNodeId={selectedNodeId}\n typeFieldName={typeFieldName}\n useAsTitle={useAsTitle}\n />\n )\n })}\n {hasMore && (\n <LoadMore\n currentCount={rootNodes.length}\n depth={0}\n id=\"load-more-root\"\n onLoadMore={handleLoadMore}\n totalDocs={totalDocs}\n />\n )}\n </div>\n )\n}\n\nexport const Tree: React.FC<TreeProps> = (props) => {\n return (\n <TreeFocusProvider>\n <TreeInner {...props} />\n </TreeFocusProvider>\n )\n}\n"],"mappings":"AAAA;;;AAEA,SAASA,cAAc,QAAQ;AAC/B,SAASC,SAAS,QAAQ;AAC1B,OAAOC,KAAA,IAASC,KAAK,EAAEC,OAAO,EAAEC,MAAM,QAAQ;AAI9C,SAASC,oBAAoB,QAAQ;AACrC,SAASC,cAAc,QAAQ;AAC/B,SAASC,OAAO,QAAQ;AACxB,SAASC,SAAS,QAAQ;AAC1B,SAASC,cAAc,QAAQ;AAC/B,SAASC,QAAQ,QAAQ;AACzB,SAASC,iBAAiB,EAAEC,YAAY,QAAQ;AAChD,OAAO;AACP,SAASC,QAAQ,QAAQ;AACzB,SAASC,WAAW,QAAQ;AAE5B,MAAMC,SAAA,GAAY;AAClB,MAAMC,kBAAA,GAAqB;AAE3B,MAAMC,gBAAA,GAAmBA,CAACC,G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K,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,YAAY,CAAA;IAClB,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE;QAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;IACpD,QAAQ,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE;QAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;IACnD,eAAe,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAChC,aAAa,CAAC,EAAE,IAAI,GAAG,MAAM,CAAA;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,CAAA"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../src/elements/Tree/types.ts"],"sourcesContent":["import type { Where } from 'payload'\nimport type { MutableRefObject, ReactNode } from 'react'\n\nexport type TreeDocument = {\n [key: string]: unknown\n id: number | string\n}\n\nexport type TreeNodeData = {\n hasChildren: boolean\n id: number | string\n title: string\n}\n\nexport type CachedChildren = {\n children: TreeDocument[]\n hasMore: boolean\n page: number\n totalDocs: number\n}\n\nexport type TreeCache = MutableRefObject<Map<string, CachedChildren>>\n\nexport type TreeInitialData = {\n docs: TreeDocument[]\n loadedParents: Record<string, { hasMore: boolean; loadedCount?: number; totalDocs: number }>\n}\n\nexport type TreeProps = {\n allPossibleTypeValues?: string[]\n baseFilter?: null | Where\n collectionSlug: string\n expandedNodes: Set<number | string>\n filterByCollections?: string[]\n icon?: ReactNode\n initialData?: null | TreeInitialData\n onNodeClick?: ({ id }: { id: null | number | string }) => void\n parentFieldName: string\n selectedNodeId?: null | number | string\n showAllOption?: boolean\n toggleNode: ({ id }: { id: number | string }) => void\n treeLimit?: number\n typeFieldName?: string\n useAsTitle?: string\n}\n\nexport type TreeNodeProps = {\n allPossibleTypeValues?: string[]\n baseFilter?: null | Where\n cache: TreeCache\n collectionSlug: string\n depth: number\n expandedNodes: Set<number | string>\n filterByCollections?: string[]\n limit: number\n node: TreeNodeData\n onSelect?: ({ id }: { id: number | string }) => void\n onToggle: ({ id }: { id: number | string }) => void\n parentFieldName: string\n selected?: boolean\n selectedNodeId?: number | string\n typeFieldName?: null | string\n useAsTitle?: string\n}\n"],"mappings":"AA8CA","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"useChildren.d.ts","sourceRoot":"","sources":["../../../src/elements/Tree/useChildren.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAMpC,OAAO,KAAK,EAAkB,SAAS,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAK1F,KAAK,eAAe,GAAG;IACrB,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAA;IAChC,gEAAgE;IAChE,UAAU,CAAC,EAAE,IAAI,GAAG,KAAK,CAAA;IACzB,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,cAAc,EAAE,MAAM,CAAA;IACtB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC9B,WAAW,CAAC,EAAE,IAAI,GAAG,eAAe,CAAA;IACpC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,eAAe,EAAE,MAAM,CAAA;IACvB,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAA;IACzB,aAAa,CAAC,EAAE,IAAI,GAAG,MAAM,CAAA;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,KAAK,iBAAiB,GAAG;IACvB,QAAQ,EAAE,IAAI,GAAG,YAAY,EAAE,CAAA;IAC/B,OAAO,EAAE,OAAO,CAAA;IAChB,SAAS,EAAE,OAAO,CAAA;IAClB,QAAQ,EAAE,MAAM,OAAO,CAAC,YAAY,EAAE,CAAC,CAAA;IACvC,OAAO,EAAE,MAAM,OAAO,CAAC,YAAY,EAAE,CAAC,CAAA;IACtC,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,eAAO,MAAM,WAAW,0KAarB,eAAe,KAAG,iBAuOpB,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"useChildren.js","names":["combineWhereConstraints","formatAdminURL","qs","useCallback","useEffect","useRef","useState","useConfig","isSuperset","useChildren","allPossibleTypeValues","baseFilter","cache","collectionSlug","enabled","filterByCollections","initialData","limit","parentFieldName","parentId","typeFieldName","useAsTitle","filterKey","length","slice","sort","join","baseFilterKey","JSON","stringify","cacheKey","cachedData","current","get","parentKey","String","parentMeta","loadedParents","hasInitialData","initialDocsForParent","docs","filter","doc","docParent","children","setChildren","isLoading","setIsLoading","page","setPage","totalDocs","setTotalDocs","hasMore","setHasMore","initializedRef","config","routes","api","serverURL","fetchPage","pageToFetch","currentChildren","parentCondition","or","exists","equals","filterCondition","in","not_in","undefined","where","queryParams","queryString","addQueryPrefix","url","apiRoute","path","response","fetch","credentials","ok","Error","data","json","allDocs","newDocs","newChildren","hasNextPage","set","emptyChildren","prevFilterKeyRef","loadMore","shouldRefetchPage1","refresh","delete"],"sources":["../../../src/elements/Tree/useChildren.tsx"],"sourcesContent":["import type { Where } from 'payload'\n\nimport { combineWhereConstraints, formatAdminURL } from 'payload/shared'\nimport * as qs from 'qs-esm'\nimport { useCallback, useEffect, useRef, useState } from 'react'\n\nimport type { CachedChildren, TreeCache, TreeDocument, TreeInitialData } from './types.js'\n\nimport { useConfig } from '../../providers/Config/index.js'\nimport { isSuperset } from '../../utilities/isSuperset.js'\n\ntype UseChildrenArgs = {\n allPossibleTypeValues?: string[]\n /** Base filter to apply to all queries (e.g., tenant filter) */\n baseFilter?: null | Where\n cache?: TreeCache\n collectionSlug: string\n enabled?: boolean\n filterByCollections?: string[]\n initialData?: null | TreeInitialData\n limit?: number\n parentFieldName: string\n parentId: number | string\n typeFieldName?: null | string\n useAsTitle?: string\n}\n\ntype UseChildrenReturn = {\n children: null | TreeDocument[]\n hasMore: boolean\n isLoading: boolean\n loadMore: () => Promise<TreeDocument[]>\n refresh: () => Promise<TreeDocument[]>\n totalDocs: number\n}\n\nexport const useChildren = ({\n allPossibleTypeValues,\n baseFilter,\n cache,\n collectionSlug,\n enabled = true,\n filterByCollections,\n initialData,\n limit = 2,\n parentFieldName,\n parentId,\n typeFieldName,\n useAsTitle,\n}: UseChildrenArgs): UseChildrenReturn => {\n const filterKey = filterByCollections?.length ? filterByCollections.slice().sort().join(',') : ''\n const baseFilterKey = baseFilter ? JSON.stringify(baseFilter) : ''\n const cacheKey = `${collectionSlug}-${parentId}-${filterKey}-${baseFilterKey}`\n const cachedData = cache?.current.get(cacheKey)\n\n // Check if we have initial data for this specific parent\n const parentKey = parentId === 'null' ? 'null' : String(parentId)\n const parentMeta = initialData?.loadedParents?.[parentKey]\n const hasInitialData = !!parentMeta\n\n // Extract docs for this parent from initialData if available\n // Apply same superset filter as fetchPage for consistency\n const initialDocsForParent = hasInitialData\n ? initialData.docs.filter((doc) => {\n const docParent = doc[parentFieldName] || 'null'\n if (String(docParent) !== parentKey) {\n return false\n }\n if (filterByCollections?.length && typeFieldName) {\n return isSuperset(doc[typeFieldName] as string[] | undefined, filterByCollections)\n }\n return true\n })\n : null\n\n const [children, setChildren] = useState<null | TreeDocument[]>(\n initialDocsForParent || cachedData?.children || null,\n )\n const [isLoading, setIsLoading] = useState(!hasInitialData && !cachedData && enabled)\n const [page, setPage] = useState(cachedData?.page || 1)\n const [totalDocs, setTotalDocs] = useState(parentMeta?.totalDocs || cachedData?.totalDocs || 0)\n const [hasMore, setHasMore] = useState(parentMeta?.hasMore || cachedData?.hasMore || false)\n const initializedRef = useRef(!!hasInitialData)\n const {\n config: {\n routes: { api },\n serverURL,\n },\n } = useConfig()\n\n const fetchPage = useCallback(\n async (\n pageToFetch: number,\n currentChildren: null | TreeDocument[],\n ): Promise<TreeDocument[]> => {\n setIsLoading(true)\n\n try {\n const parentCondition =\n parentId === 'null' || parentId === null\n ? {\n or: [\n { [parentFieldName]: { exists: false } },\n { [parentFieldName]: { equals: null } },\n ],\n }\n : { [parentFieldName]: { equals: parentId } }\n\n // Build filter condition for collection type filtering\n // Matches items that:\n // - allow ANY of the selected collections, OR\n // - are unrestricted (type field doesn't exist), OR\n // - have empty allowedTypes array (unrestricted)\n const filterCondition: undefined | Where =\n filterByCollections?.length && typeFieldName\n ? {\n or: [\n { [typeFieldName]: { in: filterByCollections } },\n { [typeFieldName]: { exists: false } },\n // Using not_in with all possible values matches empty arrays in both MongoDB and Postgres\n ...(allPossibleTypeValues?.length\n ? [{ [typeFieldName]: { not_in: allPossibleTypeValues } }]\n : []),\n ],\n }\n : undefined\n\n // Combine conditions: parent + filter + baseFilter\n const where = combineWhereConstraints([parentCondition, filterCondition, baseFilter])\n\n const queryParams: Record<string, unknown> = {\n limit,\n page: pageToFetch,\n sort: useAsTitle ?? 'id',\n where,\n }\n\n const queryString = qs.stringify(queryParams, { addQueryPrefix: true })\n const url = formatAdminURL({\n apiRoute: api,\n path: `/${collectionSlug}${queryString}`,\n serverURL,\n })\n const response = await fetch(url, {\n credentials: 'include',\n })\n\n if (!response.ok) {\n throw new Error('Failed to fetch children')\n }\n\n const data = await response.json()\n const allDocs: TreeDocument[] = data.docs || []\n\n // Client-side filter: only show items that are a superset of required collections\n // Server query uses ANY (due to PG limitations), but we want ALL (superset)\n const newDocs =\n filterByCollections?.length && typeFieldName\n ? allDocs.filter((doc) =>\n isSuperset(doc[typeFieldName] as string[] | undefined, filterByCollections),\n )\n : allDocs\n\n const newChildren = pageToFetch === 1 ? newDocs : [...(currentChildren || []), ...newDocs]\n\n setChildren(newChildren)\n setTotalDocs(data.totalDocs || 0)\n setHasMore(data.hasNextPage || false)\n setPage(pageToFetch)\n\n if (cache) {\n cache.current.set(cacheKey, {\n children: newChildren,\n hasMore: data.hasNextPage || false,\n page: pageToFetch,\n totalDocs: data.totalDocs || 0,\n })\n }\n\n return newDocs\n } catch {\n if (pageToFetch === 1) {\n const emptyChildren: TreeDocument[] = []\n setChildren(emptyChildren)\n setHasMore(false)\n\n if (cache) {\n cache.current.set(cacheKey, {\n children: emptyChildren,\n hasMore: false,\n page: 1,\n totalDocs: 0,\n })\n }\n }\n\n return []\n } finally {\n setIsLoading(false)\n }\n },\n [\n allPossibleTypeValues,\n baseFilter,\n parentId,\n filterKey,\n parentFieldName,\n filterByCollections,\n typeFieldName,\n limit,\n useAsTitle,\n api,\n collectionSlug,\n serverURL,\n cache,\n cacheKey,\n ],\n )\n\n // Reset state when filter changes\n const prevFilterKeyRef = useRef(filterKey)\n useEffect(() => {\n if (prevFilterKeyRef.current !== filterKey) {\n prevFilterKeyRef.current = filterKey\n setChildren(null)\n setPage(1)\n setTotalDocs(0)\n setHasMore(false)\n }\n }, [filterKey])\n\n useEffect(() => {\n if (!enabled) {\n return\n }\n\n // Skip initial fetch if we have initialData\n if (initializedRef.current && children !== null) {\n initializedRef.current = false\n return\n }\n\n // Restore from cache if children was reset (e.g., filter changed)\n if (cachedData && children === null) {\n setChildren(cachedData.children)\n setPage(cachedData.page)\n setTotalDocs(cachedData.totalDocs)\n setHasMore(cachedData.hasMore)\n return\n }\n\n if (cachedData && page === cachedData.page) {\n return\n }\n\n void fetchPage(page, children)\n }, [enabled, page, cachedData, fetchPage, children])\n\n const loadMore = useCallback(async (): Promise<TreeDocument[]> => {\n if (isLoading || !hasMore) {\n return []\n }\n\n // If we have fewer items than our limit, the cached data was fetched with a smaller limit\n // We need to re-fetch page 1 with our limit to get the full first page\n const shouldRefetchPage1 = children && children.length < limit\n\n return fetchPage(shouldRefetchPage1 ? 1 : page + 1, children)\n }, [isLoading, hasMore, page, children, fetchPage, limit])\n\n const refresh = useCallback(async (): Promise<TreeDocument[]> => {\n if (cache) {\n cache.current.delete(cacheKey)\n }\n setChildren(null)\n setPage(1)\n return fetchP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