@elliemae/ds-treeview 2.3.0-alpha.8 → 2.3.0-next.10

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 (333) hide show
  1. package/cjs/TreeView.js +30 -0
  2. package/cjs/TreeViewContext.js +98 -0
  3. package/cjs/config/cssClassesConstants.js +13 -0
  4. package/cjs/config/useTreeview.js +127 -0
  5. package/cjs/hoc/DnDTreeContext.js +18 -0
  6. package/cjs/hoc/SortableItemContext.js +21 -0
  7. package/cjs/hoc/WithConditionalDnDContext.js +138 -0
  8. package/cjs/hoc/WithDnDSortableItemContext.js +70 -0
  9. package/cjs/index.js +26 -0
  10. package/cjs/parts/CheckboxSelectable.js +86 -0
  11. package/cjs/parts/ChildrenCountDisplayer.js +30 -0
  12. package/cjs/parts/DnDHandle.js +46 -0
  13. package/cjs/parts/DropIndicator.js +75 -0
  14. package/cjs/parts/ExpandCaret.js +94 -0
  15. package/cjs/parts/Icon.js +37 -0
  16. package/cjs/parts/NestingSpace.js +47 -0
  17. package/cjs/parts/RadioSelectable.js +59 -0
  18. package/cjs/parts/TreeItem.js +185 -0
  19. package/cjs/parts/TreeItemText.js +108 -0
  20. package/cjs/parts/TreeList.js +139 -0
  21. package/cjs/plugins/dnd/TreeDndPlugin.js +7 -0
  22. package/cjs/plugins/dnd/index.js +9 -0
  23. package/cjs/plugins/index.js +21 -0
  24. package/cjs/plugins/roving/TreeRovingPlugin.js +7 -0
  25. package/cjs/plugins/roving/index.js +9 -0
  26. package/cjs/plugins/searchable/SearchableTreePlugin.js +7 -0
  27. package/cjs/plugins/searchable/index.js +9 -0
  28. package/cjs/plugins/selectable/SelectablePluginTree.js +7 -0
  29. package/cjs/plugins/selectable/index.js +9 -0
  30. package/cjs/plugins/toolbar/TreeToolbarPlugin.js +7 -0
  31. package/cjs/plugins/toolbar/index.js +9 -0
  32. package/cjs/plugins/tree/TreeDataPlugin.js +7 -0
  33. package/cjs/plugins/tree/index.js +9 -0
  34. package/cjs/plugins/virtualization/TreeVirtualizationPlugin.js +7 -0
  35. package/cjs/plugins/virtualization/index.js +9 -0
  36. package/cjs/react-desc-prop-types.js +56 -0
  37. package/cjs/related-components/TreeViewSearchBar.js +48 -0
  38. package/cjs/sharedTypes.js +2 -0
  39. package/cjs/utils/array-helpers.js +24 -0
  40. package/cjs/utils/group-expands-helpers.js +111 -0
  41. package/cjs/utils/keyboard-helpers.js +175 -0
  42. package/cjs/utils/object-helpers.js +69 -0
  43. package/cjs/utils/refs-helpers.js +31 -0
  44. package/cjs/utils/selectable-helper.js +80 -0
  45. package/cjs/utils/string-helpers.js +7 -0
  46. package/cjs/utils/tree-helpers.js +220 -0
  47. package/cjs/utils/useInstanceRefActions.js +87 -0
  48. package/cjs/utils/useTree.js +108 -0
  49. package/esm/TreeView.js +21 -0
  50. package/{dist/esm → esm}/TreeViewContext.js +29 -24
  51. package/esm/config/cssClassesConstants.js +6 -0
  52. package/esm/config/useTreeview.js +119 -0
  53. package/esm/hoc/DnDTreeContext.js +14 -0
  54. package/esm/hoc/SortableItemContext.js +17 -0
  55. package/esm/hoc/WithConditionalDnDContext.js +128 -0
  56. package/esm/hoc/WithDnDSortableItemContext.js +61 -0
  57. package/esm/index.js +9 -0
  58. package/esm/parts/CheckboxSelectable.js +78 -0
  59. package/esm/parts/ChildrenCountDisplayer.js +22 -0
  60. package/esm/parts/DnDHandle.js +38 -0
  61. package/esm/parts/DropIndicator.js +68 -0
  62. package/esm/parts/ExpandCaret.js +85 -0
  63. package/esm/parts/Icon.js +29 -0
  64. package/esm/parts/NestingSpace.js +39 -0
  65. package/esm/parts/RadioSelectable.js +53 -0
  66. package/esm/parts/TreeItem.js +173 -0
  67. package/esm/parts/TreeItemText.js +99 -0
  68. package/esm/parts/TreeList.js +127 -0
  69. package/esm/plugins/dnd/TreeDndPlugin.js +3 -0
  70. package/esm/plugins/dnd/index.js +1 -0
  71. package/esm/plugins/index.js +7 -0
  72. package/esm/plugins/roving/TreeRovingPlugin.js +3 -0
  73. package/esm/plugins/roving/index.js +1 -0
  74. package/esm/plugins/searchable/SearchableTreePlugin.js +3 -0
  75. package/esm/plugins/searchable/index.js +1 -0
  76. package/esm/plugins/selectable/SelectablePluginTree.js +3 -0
  77. package/esm/plugins/selectable/index.js +1 -0
  78. package/esm/plugins/toolbar/TreeToolbarPlugin.js +3 -0
  79. package/esm/plugins/toolbar/index.js +1 -0
  80. package/esm/plugins/tree/TreeDataPlugin.js +3 -0
  81. package/esm/plugins/tree/index.js +1 -0
  82. package/esm/plugins/virtualization/TreeVirtualizationPlugin.js +3 -0
  83. package/esm/plugins/virtualization/index.js +1 -0
  84. package/esm/react-desc-prop-types.js +52 -0
  85. package/esm/related-components/TreeViewSearchBar.js +40 -0
  86. package/esm/sharedTypes.js +1 -0
  87. package/{dist/esm → esm}/utils/array-helpers.js +6 -6
  88. package/esm/utils/group-expands-helpers.js +99 -0
  89. package/{dist/esm → esm}/utils/keyboard-helpers.js +71 -43
  90. package/esm/utils/object-helpers.js +64 -0
  91. package/esm/utils/refs-helpers.js +27 -0
  92. package/esm/utils/selectable-helper.js +70 -0
  93. package/esm/utils/string-helpers.js +3 -0
  94. package/esm/utils/tree-helpers.js +205 -0
  95. package/{dist/esm → esm}/utils/useInstanceRefActions.js +35 -21
  96. package/esm/utils/useTree.js +99 -0
  97. package/package.json +121 -124
  98. package/types/TreeView.d.ts +13 -0
  99. package/types/TreeViewContext.d.ts +17 -0
  100. package/types/config/cssClassesConstants.d.ts +4 -0
  101. package/types/config/useTreeview.d.ts +7 -0
  102. package/types/hoc/DnDTreeContext.d.ts +14 -0
  103. package/types/hoc/SortableItemContext.d.ts +19 -0
  104. package/types/hoc/WithConditionalDnDContext.d.ts +4 -0
  105. package/types/hoc/WithDnDSortableItemContext.d.ts +4 -0
  106. package/types/index.d.ts +3 -0
  107. package/types/parts/CheckboxSelectable.d.ts +8 -0
  108. package/types/parts/ChildrenCountDisplayer.d.ts +7 -0
  109. package/types/parts/DnDHandle.d.ts +6 -0
  110. package/types/parts/DropIndicator.d.ts +10 -0
  111. package/types/parts/ExpandCaret.d.ts +7 -0
  112. package/types/parts/Icon.d.ts +7 -0
  113. package/types/parts/NestingSpace.d.ts +8 -0
  114. package/types/parts/RadioSelectable.d.ts +8 -0
  115. package/types/parts/TreeItem.d.ts +17 -0
  116. package/types/parts/TreeItemText.d.ts +7 -0
  117. package/types/parts/TreeList.d.ts +20 -0
  118. package/types/plugins/dnd/TreeDndPlugin.d.ts +1 -0
  119. package/types/plugins/dnd/index.d.ts +1 -0
  120. package/types/plugins/index.d.ts +7 -0
  121. package/types/plugins/roving/TreeRovingPlugin.d.ts +1 -0
  122. package/types/plugins/roving/index.d.ts +1 -0
  123. package/types/plugins/searchable/SearchableTreePlugin.d.ts +1 -0
  124. package/types/plugins/searchable/index.d.ts +1 -0
  125. package/types/plugins/selectable/SelectablePluginTree.d.ts +1 -0
  126. package/types/plugins/selectable/index.d.ts +1 -0
  127. package/types/plugins/toolbar/TreeToolbarPlugin.d.ts +1 -0
  128. package/types/plugins/toolbar/index.d.ts +1 -0
  129. package/types/plugins/tree/TreeDataPlugin.d.ts +1 -0
  130. package/types/plugins/tree/index.d.ts +1 -0
  131. package/types/plugins/virtualization/TreeVirtualizationPlugin.d.ts +1 -0
  132. package/types/plugins/virtualization/index.d.ts +1 -0
  133. package/types/react-desc-prop-types.d.ts +210 -0
  134. package/types/related-components/TreeViewSearchBar.d.ts +16 -0
  135. package/types/sharedTypes.d.ts +47 -0
  136. package/types/utils/array-helpers.d.ts +2 -0
  137. package/types/utils/group-expands-helpers.d.ts +14 -0
  138. package/types/utils/keyboard-helpers.d.ts +6 -0
  139. package/types/utils/object-helpers.d.ts +6 -0
  140. package/types/utils/refs-helpers.d.ts +4 -0
  141. package/types/utils/selectable-helper.d.ts +7 -0
  142. package/types/utils/string-helpers.d.ts +1 -0
  143. package/types/utils/tree-helpers.d.ts +28 -0
  144. package/types/utils/useInstanceRefActions.d.ts +3 -0
  145. package/types/utils/useTree.d.ts +14 -0
  146. package/dist/cjs/TreeView.js +0 -50
  147. package/dist/cjs/TreeView.js.map +0 -7
  148. package/dist/cjs/TreeViewContext.js +0 -116
  149. package/dist/cjs/TreeViewContext.js.map +0 -7
  150. package/dist/cjs/config/cssClassesConstants.js +0 -41
  151. package/dist/cjs/config/cssClassesConstants.js.map +0 -7
  152. package/dist/cjs/config/useTreeview.js +0 -151
  153. package/dist/cjs/config/useTreeview.js.map +0 -7
  154. package/dist/cjs/hoc/DnDTreeContext.js +0 -45
  155. package/dist/cjs/hoc/DnDTreeContext.js.map +0 -7
  156. package/dist/cjs/hoc/SortableItemContext.js +0 -46
  157. package/dist/cjs/hoc/SortableItemContext.js.map +0 -7
  158. package/dist/cjs/hoc/WithConditionalDnDContext.js +0 -128
  159. package/dist/cjs/hoc/WithConditionalDnDContext.js.map +0 -7
  160. package/dist/cjs/hoc/WithDnDSortableItemContext.js +0 -69
  161. package/dist/cjs/hoc/WithDnDSortableItemContext.js.map +0 -7
  162. package/dist/cjs/index.js +0 -37
  163. package/dist/cjs/index.js.map +0 -7
  164. package/dist/cjs/parts/CheckboxSelectable.js +0 -97
  165. package/dist/cjs/parts/CheckboxSelectable.js.map +0 -7
  166. package/dist/cjs/parts/ChildrenCountDisplayer.js +0 -47
  167. package/dist/cjs/parts/ChildrenCountDisplayer.js.map +0 -7
  168. package/dist/cjs/parts/DnDHandle.js +0 -57
  169. package/dist/cjs/parts/DnDHandle.js.map +0 -7
  170. package/dist/cjs/parts/DropIndicator.js +0 -80
  171. package/dist/cjs/parts/DropIndicator.js.map +0 -7
  172. package/dist/cjs/parts/ExpandCaret.js +0 -96
  173. package/dist/cjs/parts/ExpandCaret.js.map +0 -7
  174. package/dist/cjs/parts/Icon.js +0 -52
  175. package/dist/cjs/parts/Icon.js.map +0 -7
  176. package/dist/cjs/parts/NestingSpace.js +0 -55
  177. package/dist/cjs/parts/NestingSpace.js.map +0 -7
  178. package/dist/cjs/parts/RadioSelectable.js +0 -74
  179. package/dist/cjs/parts/RadioSelectable.js.map +0 -7
  180. package/dist/cjs/parts/TreeItem.js +0 -166
  181. package/dist/cjs/parts/TreeItem.js.map +0 -7
  182. package/dist/cjs/parts/TreeItemText.js +0 -101
  183. package/dist/cjs/parts/TreeItemText.js.map +0 -7
  184. package/dist/cjs/parts/TreeList.js +0 -123
  185. package/dist/cjs/parts/TreeList.js.map +0 -7
  186. package/dist/cjs/plugins/dnd/TreeDndPlugin.js +0 -35
  187. package/dist/cjs/plugins/dnd/TreeDndPlugin.js.map +0 -7
  188. package/dist/cjs/plugins/dnd/index.js +0 -28
  189. package/dist/cjs/plugins/dnd/index.js.map +0 -7
  190. package/dist/cjs/plugins/index.js +0 -34
  191. package/dist/cjs/plugins/index.js.map +0 -7
  192. package/dist/cjs/plugins/roving/TreeRovingPlugin.js +0 -35
  193. package/dist/cjs/plugins/roving/TreeRovingPlugin.js.map +0 -7
  194. package/dist/cjs/plugins/roving/index.js +0 -28
  195. package/dist/cjs/plugins/roving/index.js.map +0 -7
  196. package/dist/cjs/plugins/searchable/SearchableTreePlugin.js +0 -35
  197. package/dist/cjs/plugins/searchable/SearchableTreePlugin.js.map +0 -7
  198. package/dist/cjs/plugins/searchable/index.js +0 -28
  199. package/dist/cjs/plugins/searchable/index.js.map +0 -7
  200. package/dist/cjs/plugins/selectable/SelectablePluginTree.js +0 -35
  201. package/dist/cjs/plugins/selectable/SelectablePluginTree.js.map +0 -7
  202. package/dist/cjs/plugins/selectable/index.js +0 -28
  203. package/dist/cjs/plugins/selectable/index.js.map +0 -7
  204. package/dist/cjs/plugins/toolbar/TreeToolbarPlugin.js +0 -35
  205. package/dist/cjs/plugins/toolbar/TreeToolbarPlugin.js.map +0 -7
  206. package/dist/cjs/plugins/toolbar/index.js +0 -28
  207. package/dist/cjs/plugins/toolbar/index.js.map +0 -7
  208. package/dist/cjs/plugins/tree/TreeDataPlugin.js +0 -35
  209. package/dist/cjs/plugins/tree/TreeDataPlugin.js.map +0 -7
  210. package/dist/cjs/plugins/tree/index.js +0 -28
  211. package/dist/cjs/plugins/tree/index.js.map +0 -7
  212. package/dist/cjs/plugins/virtualization/TreeVirtualizationPlugin.js +0 -35
  213. package/dist/cjs/plugins/virtualization/TreeVirtualizationPlugin.js.map +0 -7
  214. package/dist/cjs/plugins/virtualization/index.js +0 -28
  215. package/dist/cjs/plugins/virtualization/index.js.map +0 -7
  216. package/dist/cjs/react-desc-prop-types.js +0 -85
  217. package/dist/cjs/react-desc-prop-types.js.map +0 -7
  218. package/dist/cjs/related-components/TreeViewSearchBar.js +0 -50
  219. package/dist/cjs/related-components/TreeViewSearchBar.js.map +0 -7
  220. package/dist/cjs/sharedTypes.js +0 -27
  221. package/dist/cjs/sharedTypes.js.map +0 -7
  222. package/dist/cjs/utils/array-helpers.js +0 -48
  223. package/dist/cjs/utils/array-helpers.js.map +0 -7
  224. package/dist/cjs/utils/group-expands-helpers.js +0 -138
  225. package/dist/cjs/utils/group-expands-helpers.js.map +0 -7
  226. package/dist/cjs/utils/keyboard-helpers.js +0 -170
  227. package/dist/cjs/utils/keyboard-helpers.js.map +0 -7
  228. package/dist/cjs/utils/object-helpers.js +0 -76
  229. package/dist/cjs/utils/object-helpers.js.map +0 -7
  230. package/dist/cjs/utils/refs-helpers.js +0 -52
  231. package/dist/cjs/utils/refs-helpers.js.map +0 -7
  232. package/dist/cjs/utils/selectable-helper.js +0 -88
  233. package/dist/cjs/utils/selectable-helper.js.map +0 -7
  234. package/dist/cjs/utils/string-helpers.js +0 -35
  235. package/dist/cjs/utils/string-helpers.js.map +0 -7
  236. package/dist/cjs/utils/tree-helpers.js +0 -184
  237. package/dist/cjs/utils/tree-helpers.js.map +0 -7
  238. package/dist/cjs/utils/useInstanceRefActions.js +0 -98
  239. package/dist/cjs/utils/useInstanceRefActions.js.map +0 -7
  240. package/dist/cjs/utils/useTree.js +0 -106
  241. package/dist/cjs/utils/useTree.js.map +0 -7
  242. package/dist/esm/TreeView.js +0 -21
  243. package/dist/esm/TreeView.js.map +0 -7
  244. package/dist/esm/TreeViewContext.js.map +0 -7
  245. package/dist/esm/config/cssClassesConstants.js +0 -12
  246. package/dist/esm/config/cssClassesConstants.js.map +0 -7
  247. package/dist/esm/config/useTreeview.js +0 -122
  248. package/dist/esm/config/useTreeview.js.map +0 -7
  249. package/dist/esm/hoc/DnDTreeContext.js +0 -16
  250. package/dist/esm/hoc/DnDTreeContext.js.map +0 -7
  251. package/dist/esm/hoc/SortableItemContext.js +0 -17
  252. package/dist/esm/hoc/SortableItemContext.js.map +0 -7
  253. package/dist/esm/hoc/WithConditionalDnDContext.js +0 -99
  254. package/dist/esm/hoc/WithConditionalDnDContext.js.map +0 -7
  255. package/dist/esm/hoc/WithDnDSortableItemContext.js +0 -40
  256. package/dist/esm/hoc/WithDnDSortableItemContext.js.map +0 -7
  257. package/dist/esm/index.js +0 -8
  258. package/dist/esm/index.js.map +0 -7
  259. package/dist/esm/parts/CheckboxSelectable.js +0 -68
  260. package/dist/esm/parts/CheckboxSelectable.js.map +0 -7
  261. package/dist/esm/parts/ChildrenCountDisplayer.js +0 -18
  262. package/dist/esm/parts/ChildrenCountDisplayer.js.map +0 -7
  263. package/dist/esm/parts/DnDHandle.js +0 -28
  264. package/dist/esm/parts/DnDHandle.js.map +0 -7
  265. package/dist/esm/parts/DropIndicator.js +0 -51
  266. package/dist/esm/parts/DropIndicator.js.map +0 -7
  267. package/dist/esm/parts/ExpandCaret.js +0 -67
  268. package/dist/esm/parts/ExpandCaret.js.map +0 -7
  269. package/dist/esm/parts/Icon.js +0 -23
  270. package/dist/esm/parts/Icon.js.map +0 -7
  271. package/dist/esm/parts/NestingSpace.js +0 -26
  272. package/dist/esm/parts/NestingSpace.js.map +0 -7
  273. package/dist/esm/parts/RadioSelectable.js +0 -45
  274. package/dist/esm/parts/RadioSelectable.js.map +0 -7
  275. package/dist/esm/parts/TreeItem.js +0 -137
  276. package/dist/esm/parts/TreeItem.js.map +0 -7
  277. package/dist/esm/parts/TreeItemText.js +0 -72
  278. package/dist/esm/parts/TreeItemText.js.map +0 -7
  279. package/dist/esm/parts/TreeList.js +0 -94
  280. package/dist/esm/parts/TreeList.js.map +0 -7
  281. package/dist/esm/plugins/dnd/TreeDndPlugin.js +0 -6
  282. package/dist/esm/plugins/dnd/TreeDndPlugin.js.map +0 -7
  283. package/dist/esm/plugins/dnd/index.js +0 -3
  284. package/dist/esm/plugins/dnd/index.js.map +0 -7
  285. package/dist/esm/plugins/index.js +0 -9
  286. package/dist/esm/plugins/index.js.map +0 -7
  287. package/dist/esm/plugins/roving/TreeRovingPlugin.js +0 -6
  288. package/dist/esm/plugins/roving/TreeRovingPlugin.js.map +0 -7
  289. package/dist/esm/plugins/roving/index.js +0 -3
  290. package/dist/esm/plugins/roving/index.js.map +0 -7
  291. package/dist/esm/plugins/searchable/SearchableTreePlugin.js +0 -6
  292. package/dist/esm/plugins/searchable/SearchableTreePlugin.js.map +0 -7
  293. package/dist/esm/plugins/searchable/index.js +0 -3
  294. package/dist/esm/plugins/searchable/index.js.map +0 -7
  295. package/dist/esm/plugins/selectable/SelectablePluginTree.js +0 -6
  296. package/dist/esm/plugins/selectable/SelectablePluginTree.js.map +0 -7
  297. package/dist/esm/plugins/selectable/index.js +0 -3
  298. package/dist/esm/plugins/selectable/index.js.map +0 -7
  299. package/dist/esm/plugins/toolbar/TreeToolbarPlugin.js +0 -6
  300. package/dist/esm/plugins/toolbar/TreeToolbarPlugin.js.map +0 -7
  301. package/dist/esm/plugins/toolbar/index.js +0 -3
  302. package/dist/esm/plugins/toolbar/index.js.map +0 -7
  303. package/dist/esm/plugins/tree/TreeDataPlugin.js +0 -6
  304. package/dist/esm/plugins/tree/TreeDataPlugin.js.map +0 -7
  305. package/dist/esm/plugins/tree/index.js +0 -3
  306. package/dist/esm/plugins/tree/index.js.map +0 -7
  307. package/dist/esm/plugins/virtualization/TreeVirtualizationPlugin.js +0 -6
  308. package/dist/esm/plugins/virtualization/TreeVirtualizationPlugin.js.map +0 -7
  309. package/dist/esm/plugins/virtualization/index.js +0 -3
  310. package/dist/esm/plugins/virtualization/index.js.map +0 -7
  311. package/dist/esm/react-desc-prop-types.js +0 -56
  312. package/dist/esm/react-desc-prop-types.js.map +0 -7
  313. package/dist/esm/related-components/TreeViewSearchBar.js +0 -21
  314. package/dist/esm/related-components/TreeViewSearchBar.js.map +0 -7
  315. package/dist/esm/sharedTypes.js +0 -2
  316. package/dist/esm/sharedTypes.js.map +0 -7
  317. package/dist/esm/utils/array-helpers.js.map +0 -7
  318. package/dist/esm/utils/group-expands-helpers.js +0 -109
  319. package/dist/esm/utils/group-expands-helpers.js.map +0 -7
  320. package/dist/esm/utils/keyboard-helpers.js.map +0 -7
  321. package/dist/esm/utils/object-helpers.js +0 -47
  322. package/dist/esm/utils/object-helpers.js.map +0 -7
  323. package/dist/esm/utils/refs-helpers.js +0 -23
  324. package/dist/esm/utils/refs-helpers.js.map +0 -7
  325. package/dist/esm/utils/selectable-helper.js +0 -59
  326. package/dist/esm/utils/selectable-helper.js.map +0 -7
  327. package/dist/esm/utils/string-helpers.js +0 -6
  328. package/dist/esm/utils/string-helpers.js.map +0 -7
  329. package/dist/esm/utils/tree-helpers.js +0 -155
  330. package/dist/esm/utils/tree-helpers.js.map +0 -7
  331. package/dist/esm/utils/useInstanceRefActions.js.map +0 -7
  332. package/dist/esm/utils/useTree.js +0 -77
  333. package/dist/esm/utils/useTree.js.map +0 -7
@@ -0,0 +1,108 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _defineProperty = require('@babel/runtime/helpers/defineProperty');
6
+ require('core-js/modules/web.dom-collections.iterator.js');
7
+ require('core-js/modules/esnext.async-iterator.filter.js');
8
+ require('core-js/modules/esnext.iterator.constructor.js');
9
+ require('core-js/modules/esnext.iterator.filter.js');
10
+ require('core-js/modules/esnext.async-iterator.for-each.js');
11
+ require('core-js/modules/esnext.iterator.for-each.js');
12
+ var React = require('react');
13
+ var TreeModel = require('tree-model');
14
+ var lodash = require('lodash');
15
+ var treeHelpers = require('./tree-helpers.js');
16
+ var groupExpandsHelpers = require('./group-expands-helpers.js');
17
+
18
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
19
+
20
+ var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
21
+ var TreeModel__default = /*#__PURE__*/_interopDefaultLegacy(TreeModel);
22
+
23
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
24
+
25
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
26
+ const useTree = (data, props, states) => {
27
+ const {
28
+ setExpandedGroups
29
+ } = states;
30
+ const unfrozenData = React.useMemo(() => lodash.cloneDeep(data), [data]); // convert data into a TreeModel with extra isExpanded prop
31
+ // root element type is an exception, children model is based on what the dev passed on
32
+ // since root is an excepcion we must typecast
33
+
34
+ const tree = React.useMemo(() => new TreeModel__default["default"](), []);
35
+ const [treeData, setTreeData] = React.useState({
36
+ id: '__ds_tree_root',
37
+ name: '__root',
38
+ isExpanded: true,
39
+ children: unfrozenData
40
+ });
41
+ React.useEffect(() => {
42
+ setTreeData({
43
+ id: '__ds_tree_root',
44
+ name: '__root',
45
+ isExpanded: true,
46
+ children: unfrozenData
47
+ });
48
+ }, [unfrozenData]); // expose a way to rerender the tree
49
+ // used for expand functionality
50
+
51
+ const [rerenderItems, setRerenderItems] = React.useState({});
52
+ const triggerTreeRerender = React.useCallback(() => {
53
+ setRerenderItems({});
54
+ }, []); // when re-rendering we re-parse the list
55
+
56
+ const [treeRoot, setTreeRoot] = React.useState(tree.parse(treeData));
57
+ React.useEffect(() => {
58
+ setTreeRoot(tree.parse(treeData));
59
+ }, [treeData, rerenderItems, tree]);
60
+ const [visibleItems, setVisibleItems] = React.useState([]);
61
+ const {
62
+ searchQuery,
63
+ highlightOnlyQuery,
64
+ onVisibleItemsChange,
65
+ selection,
66
+ expanded,
67
+ onExpandChange
68
+ } = props;
69
+ const updateUserExpandedState = React.useCallback(() => {
70
+ groupExpandsHelpers.updateExpandedState(treeRoot, onExpandChange);
71
+ }, [treeRoot, onExpandChange]); // we add missing properties to the received Items
72
+ // not the best of the patterns, but it works
73
+ // this is where we convert "SimpleItems" to "Items"
74
+ // this was done to avoid breaking changes back in v1
75
+
76
+ React.useEffect(() => {
77
+ const parsedVisibleItems = [];
78
+ const newExpandedHashMap = {};
79
+ const shouldContinueWalking = true; // tree-model ask we return true if we want to continue walking
80
+
81
+ treeRoot.walk(node => {
82
+ treeHelpers.enrichNodeModelInPlace(node, searchQuery, selection, expanded);
83
+ if (node.model.id && node.model.isGroup && node.model.isExpanded) newExpandedHashMap[node.model.id] = true;
84
+ return shouldContinueWalking;
85
+ });
86
+ treeHelpers.walkVisibles(treeRoot, node => {
87
+ parsedVisibleItems.push(_objectSpread(_objectSpread({}, node.model), {}, {
88
+ node
89
+ }));
90
+ }, true, highlightOnlyQuery);
91
+ setVisibleItems(parsedVisibleItems);
92
+ onVisibleItemsChange(parsedVisibleItems);
93
+ setExpandedGroups(newExpandedHashMap); // eslint-disable-next-line react-hooks/exhaustive-deps
94
+ }, [treeRoot, rerenderItems, searchQuery, highlightOnlyQuery, selection, expanded, setExpandedGroups // onVisibleItemsChange // evaluate potential performance hit?
95
+ ]);
96
+ const flattenedItems = React.useMemo(() => treeHelpers.flattenTreeForDnD(data), [data]);
97
+ return {
98
+ visibleItems,
99
+ flattenedItems,
100
+ tree,
101
+ treeRoot,
102
+ rerenderItems,
103
+ triggerTreeRerender,
104
+ updateUserExpandedState
105
+ };
106
+ };
107
+
108
+ exports.useTree = useTree;
@@ -0,0 +1,21 @@
1
+ import _jsx from '@babel/runtime/helpers/esm/jsx';
2
+ import 'react';
3
+ import { describe } from 'react-desc';
4
+ import { TreeViewPropTypes } from './react-desc-prop-types.js';
5
+ import TreeViewContext from './TreeViewContext.js';
6
+ import { useTreeview } from './config/useTreeview.js';
7
+ import { TreeList } from './parts/TreeList.js';
8
+
9
+ var _TreeList;
10
+ function TreeView(props) {
11
+ const {
12
+ ctx
13
+ } = useTreeview(props);
14
+ return /*#__PURE__*/_jsx(TreeViewContext.Provider, {
15
+ value: ctx
16
+ }, void 0, _TreeList || (_TreeList = /*#__PURE__*/_jsx(TreeList, {})));
17
+ }
18
+ const TreeViewWithSchema = describe(TreeView);
19
+ TreeViewWithSchema.propTypes = TreeViewPropTypes;
20
+
21
+ export { TreeView, TreeViewWithSchema };
@@ -1,11 +1,14 @@
1
- import * as React from "react";
2
- import { createContext, createRef } from "react";
3
- function noop(..._args) {
4
- }
1
+ import { createRef, createContext } from 'react';
2
+
3
+ /* eslint-disable no-unused-vars */
4
+
5
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
6
+ function noop() {}
7
+
5
8
  const defaultProps = {
6
9
  plugins: [],
7
10
  selection: {},
8
- instanceRef: createRef(),
11
+ instanceRef: /*#__PURE__*/createRef(),
9
12
  isItemDisabled: () => false,
10
13
  disableIcons: false,
11
14
  fluid: false,
@@ -24,15 +27,20 @@ const defaultProps = {
24
27
  onSelectionChange: noop,
25
28
  onExpandChange: noop,
26
29
  onInstanceRefInitialized: noop,
27
- rowSize: "normal",
28
- labelOverflow: "wrap",
29
- noItemsPlaceholder: "No items found",
30
- nameKey: "name",
31
- width: "100%",
32
- height: "100%",
30
+ rowSize: 'normal',
31
+ labelOverflow: 'wrap',
32
+ noItemsPlaceholder: 'No items found',
33
+ nameKey: 'name',
34
+ width: '100%',
35
+ height: '100%',
33
36
  groupIcon: null,
34
37
  itemIcon: null,
35
- searchQuery: ""
38
+ searchQuery: '' // workaround on the typings over the fact that
39
+ // when we instantiate the context we can't have all the props
40
+ // we only have a part of them but the final typings will include missing props
41
+ // this is safe to do because
42
+ // we will "mergeWithDefaults" + "validatePropTypes" when we do instantiate the context
43
+
36
44
  };
37
45
  const defaultRelativeMouseCoord = {
38
46
  isBefore: false,
@@ -52,16 +60,16 @@ const defaultContext = {
52
60
  withCheckboxChecks: false,
53
61
  withDragAndDrop: false,
54
62
  triggerTreeRerender: noop,
55
- tree: void 0,
56
- treeRoot: void 0,
63
+ tree: undefined,
64
+ treeRoot: undefined,
57
65
  virtualListHelpers: {
58
66
  virtualItems: [],
59
67
  totalSize: 0,
60
68
  scrollToOffset: noop,
61
69
  scrollToIndex: noop
62
70
  },
63
- virtualListRef: void 0,
64
- uniqueTreeViewUUID: "",
71
+ virtualListRef: undefined,
72
+ uniqueTreeViewUUID: '',
65
73
  selectedItem: null,
66
74
  setSelectedItem: noop,
67
75
  focusedItem: null,
@@ -77,11 +85,8 @@ const defaultContext = {
77
85
  handleExpandGroup: noop,
78
86
  updateUserExpandedState: noop
79
87
  };
80
- const TreeViewContext = createContext(defaultContext);
81
- var TreeViewContext_default = TreeViewContext;
82
- export {
83
- TreeViewContext_default as default,
84
- defaultProps,
85
- defaultRelativeMouseCoord
86
- };
87
- //# sourceMappingURL=TreeViewContext.js.map
88
+ /** Context for cross component communication */
89
+
90
+ const TreeViewContext = /*#__PURE__*/createContext(defaultContext);
91
+
92
+ export { TreeViewContext as default, defaultProps, defaultRelativeMouseCoord };
@@ -0,0 +1,6 @@
1
+ const DSTreeViewPrefix = 'em-ds';
2
+ const treeItemBlockName = 'tree-item';
3
+ const treeListBlockName = 'tree-list';
4
+ const treeListNoItemsBn = "".concat(treeListBlockName, "-no-items");
5
+
6
+ export { DSTreeViewPrefix, treeItemBlockName, treeListBlockName, treeListNoItemsBn };
@@ -0,0 +1,119 @@
1
+ import 'core-js/modules/esnext.async-iterator.filter.js';
2
+ import 'core-js/modules/esnext.iterator.constructor.js';
3
+ import 'core-js/modules/esnext.iterator.filter.js';
4
+ import 'core-js/modules/esnext.async-iterator.for-each.js';
5
+ import 'core-js/modules/esnext.iterator.for-each.js';
6
+ import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
7
+ import 'core-js/modules/web.dom-collections.iterator.js';
8
+ import { useRef, useState, useCallback, useMemo, useEffect } from 'react';
9
+ import { useVirtual } from 'react-virtual';
10
+ import { useMemoMergePropsWithDefault, useValidateTypescriptPropTypes } from '@elliemae/ds-props-helpers';
11
+ import { v4 } from 'uuid';
12
+ import { TreeViewPropTypes } from '../react-desc-prop-types.js';
13
+ import { defaultProps } from '../TreeViewContext.js';
14
+ import { TreeDndPlugin } from '../plugins/dnd/TreeDndPlugin.js';
15
+ import { useTree } from '../utils/useTree.js';
16
+ import { toggleItemExpand, useNotifyExpandedChange } from '../utils/group-expands-helpers.js';
17
+ import { useInstanceRefActions } from '../utils/useInstanceRefActions.js';
18
+ import { useGlobalToggleAllExpandShortcut } from '../utils/keyboard-helpers.js';
19
+
20
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
21
+
22
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
23
+ const useTreeview = props => {
24
+ const propsWithDefault = useMemoMergePropsWithDefault(props, defaultProps);
25
+ useValidateTypescriptPropTypes(propsWithDefault, TreeViewPropTypes);
26
+ const defaultActions = {
27
+ actions: {
28
+ toggleExpandAll: () => {},
29
+ scrollTo: () => {},
30
+ setSelectedItemByVirtualIndex: () => {},
31
+ setFocusedItemByVirtualIndex: () => {}
32
+ }
33
+ };
34
+ const treeRef = useRef(defaultActions);
35
+ const {
36
+ data,
37
+ plugins,
38
+ onOrderChange,
39
+ isMultiSelect,
40
+ isSingleSelect,
41
+ instanceRef,
42
+ selection,
43
+ onInstanceRefInitialized
44
+ } = propsWithDefault;
45
+ const [uniqueTreeViewUUID] = useState(v4());
46
+ const [hoverItem, setHoverItem] = useState(null);
47
+ const [latestToggledItem, setLatestToggledItem] = useState(null);
48
+ const [selectedItem, setSelectedItem] = useState(null);
49
+ const [focusedItem, setFocusedItem] = useState(null);
50
+ const [selectedCheckboxes, setSelectedCheckboxes] = useState(_objectSpread({}, selection));
51
+ const [expandedGroups, setExpandedGroups] = useState({});
52
+ const {
53
+ visibleItems,
54
+ flattenedItems,
55
+ tree,
56
+ treeRoot,
57
+ triggerTreeRerender,
58
+ updateUserExpandedState
59
+ } = useTree(data, propsWithDefault, {
60
+ setExpandedGroups
61
+ });
62
+ const virtualListRef = useRef(); // estimateSize should not be really required given what was stated on
63
+ // https://github.com/tannerlinsley/react-virtual/issues/23
64
+
65
+ const virtualListHelpers = useVirtual({
66
+ size: visibleItems.length,
67
+ parentRef: virtualListRef,
68
+ overscan: 15
69
+ });
70
+ const withDragAndDrop = !!(plugins !== null && plugins !== void 0 && plugins.includes(TreeDndPlugin) && onOrderChange);
71
+ const withRadioChecks = isSingleSelect && !isMultiSelect;
72
+ const withCheckboxChecks = !isSingleSelect && isMultiSelect;
73
+ const handleExpandGroup = useCallback(toggleItemExpand, []);
74
+ const ctx = useMemo(() => ({
75
+ props: propsWithDefault,
76
+ virtualListHelpers,
77
+ virtualListRef,
78
+ tree,
79
+ treeRoot,
80
+ visibleItems,
81
+ flattenedItems,
82
+ triggerTreeRerender,
83
+ withRadioChecks,
84
+ withCheckboxChecks,
85
+ withDragAndDrop,
86
+ uniqueTreeViewUUID,
87
+ selectedCheckboxes,
88
+ setSelectedCheckboxes,
89
+ selectedItem,
90
+ setSelectedItem,
91
+ expandedGroups,
92
+ setExpandedGroups,
93
+ latestToggledItem,
94
+ setLatestToggledItem,
95
+ focusedItem,
96
+ setFocusedItem,
97
+ hoverItem,
98
+ setHoverItem,
99
+ handleExpandGroup,
100
+ updateUserExpandedState
101
+ }), [propsWithDefault, virtualListHelpers, tree, treeRoot, visibleItems, flattenedItems, triggerTreeRerender, withRadioChecks, withCheckboxChecks, withDragAndDrop, uniqueTreeViewUUID, selectedCheckboxes, selectedItem, expandedGroups, latestToggledItem, focusedItem, hoverItem, handleExpandGroup, updateUserExpandedState]); // this hooks can't use the context because the context provider doesn't wrap this
102
+ // as such we manually pass the second parameter as fit
103
+
104
+ if (instanceRef) instanceRef.current = treeRef.current;
105
+ useInstanceRefActions(treeRef.current, ctx);
106
+ useGlobalToggleAllExpandShortcut(treeRoot, triggerTreeRerender, setLatestToggledItem, updateUserExpandedState);
107
+ useNotifyExpandedChange(propsWithDefault, ctx); // this is an horrible hack.
108
+ // this is required because there is no "on rendered" react-way to check if every children has finished rendering
109
+ // this should be working for now, in the future we may want to review this for a better solution
110
+
111
+ useEffect(() => {
112
+ setTimeout(() => onInstanceRefInitialized(treeRef), 100); // eslint-disable-next-line react-hooks/exhaustive-deps
113
+ }, []);
114
+ return useMemo(() => ({
115
+ ctx
116
+ }), [ctx]);
117
+ };
118
+
119
+ export { useTreeview };
@@ -0,0 +1,14 @@
1
+ import { createContext } from 'react';
2
+ import { DropIndicatorPosition } from './SortableItemContext.js';
3
+
4
+ const DnDTreeContext = /*#__PURE__*/createContext({
5
+ depth: undefined,
6
+ activeIndex: undefined,
7
+ visibleItems: undefined,
8
+ dropIndicatorPosition: DropIndicatorPosition.None,
9
+ lastActiveId: undefined,
10
+ setLastActiveId: undefined,
11
+ isDropValid: false
12
+ });
13
+
14
+ export { DnDTreeContext };
@@ -0,0 +1,17 @@
1
+ import { createContext } from 'react';
2
+
3
+ let DropIndicatorPosition;
4
+
5
+ (function (DropIndicatorPosition) {
6
+ DropIndicatorPosition[DropIndicatorPosition["None"] = 0] = "None";
7
+ DropIndicatorPosition[DropIndicatorPosition["Before"] = 1] = "Before";
8
+ DropIndicatorPosition[DropIndicatorPosition["After"] = 2] = "After";
9
+ DropIndicatorPosition[DropIndicatorPosition["Inside"] = 3] = "Inside";
10
+ })(DropIndicatorPosition || (DropIndicatorPosition = {}));
11
+
12
+ /** Context for cross component communication */
13
+ const SortableItemContext = /*#__PURE__*/createContext({
14
+ draggableProps: false
15
+ });
16
+
17
+ export { DropIndicatorPosition, SortableItemContext };
@@ -0,0 +1,128 @@
1
+ import 'core-js/modules/esnext.async-iterator.filter.js';
2
+ import 'core-js/modules/esnext.iterator.filter.js';
3
+ import _jsx from '@babel/runtime/helpers/esm/jsx';
4
+ import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
5
+ import 'core-js/modules/web.dom-collections.iterator.js';
6
+ import 'core-js/modules/esnext.async-iterator.map.js';
7
+ import 'core-js/modules/esnext.iterator.map.js';
8
+ import 'core-js/modules/esnext.async-iterator.for-each.js';
9
+ import 'core-js/modules/esnext.iterator.constructor.js';
10
+ import 'core-js/modules/esnext.iterator.for-each.js';
11
+ import 'core-js/modules/esnext.async-iterator.find.js';
12
+ import 'core-js/modules/esnext.iterator.find.js';
13
+ import React, { useContext, useMemo, useCallback } from 'react';
14
+ import { DndContext, DragOverlay } from '@dnd-kit/core';
15
+ import { SortableContext } from '@dnd-kit/sortable';
16
+ import { useTreeDndkitConfig } from '@elliemae/ds-drag-and-drop';
17
+ import TreeViewContext from '../TreeViewContext.js';
18
+ import { TreeItem } from '../parts/TreeItem.js';
19
+ import { DnDTreeContext } from './DnDTreeContext.js';
20
+ import { jsxs, jsx } from 'react/jsx-runtime';
21
+
22
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
23
+
24
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
25
+
26
+ const ensure = function (argument) {
27
+ let message = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'This should never happen';
28
+
29
+ if (argument === undefined || argument === null) {
30
+ throw new TypeError(message);
31
+ }
32
+
33
+ return argument;
34
+ }; // only wraps in "DnDContext" and "DnDTreeContext" if any Drag and Drop functionality is requested
35
+
36
+
37
+ const withConditionalDnDRowContext = Component => props => {
38
+ const [lastActiveId, setLastActiveId] = React.useState('');
39
+ const {
40
+ props: {
41
+ data,
42
+ onOrderChange,
43
+ getIsDropValid
44
+ },
45
+ flattenedItems,
46
+ visibleItems: flattenedVisibleTree,
47
+ withDragAndDrop
48
+ } = useContext(TreeViewContext);
49
+ const flattenedVisibleTreeForDnD = useMemo(() => flattenedVisibleTree.map((item, index) => {
50
+ var _item$treeDepth, _item$children$length, _item$children, _item$node$parent$mod, _item$node$parent, _item$node$parent$mod2, _item$node$parent$mod3;
51
+
52
+ return {
53
+ uid: item.id.toString(),
54
+ depth: ((_item$treeDepth = item.treeDepth) !== null && _item$treeDepth !== void 0 ? _item$treeDepth : 1) - 1,
55
+ realIndex: index,
56
+ childrenCount: (_item$children$length = (_item$children = item.children) === null || _item$children === void 0 ? void 0 : _item$children.length) !== null && _item$children$length !== void 0 ? _item$children$length : 0,
57
+ parentId: (_item$node$parent$mod = (_item$node$parent = item.node.parent) === null || _item$node$parent === void 0 ? void 0 : (_item$node$parent$mod2 = _item$node$parent.model) === null || _item$node$parent$mod2 === void 0 ? void 0 : (_item$node$parent$mod3 = _item$node$parent$mod2.id) === null || _item$node$parent$mod3 === void 0 ? void 0 : _item$node$parent$mod3.toString()) !== null && _item$node$parent$mod !== void 0 ? _item$node$parent$mod : null,
58
+ original: item
59
+ };
60
+ }), [flattenedVisibleTree]);
61
+ const onReorder = useCallback((tree, indexes) => {
62
+ // Pull the row's original data into an object
63
+ const nodes = {};
64
+ tree.forEach(item => {
65
+ const originalItem = item.original;
66
+ originalItem.children = [];
67
+ nodes[item.uid] = item.original;
68
+ });
69
+ const newUserTree = [];
70
+ tree.forEach(item => {
71
+ // If row has parent, insert it to it's subrows
72
+ // otherwise append it to the new user data
73
+ if (item.parentId !== null && item.parentId !== undefined && item.parentId !== '__ds_tree_root') {
74
+ var _parentNode$children;
75
+
76
+ const parentNode = nodes[item.parentId];
77
+ (_parentNode$children = parentNode.children) === null || _parentNode$children === void 0 ? void 0 : _parentNode$children.push(item.original);
78
+ } else if (item.uid !== '__ds_tree_root') newUserTree.push(item.original);
79
+ }); // Tell the user that the order has change, he can chose to commit it or not
80
+
81
+ onOrderChange(newUserTree, data, flattenedItems[indexes.fromIndex]);
82
+ }, [onOrderChange, data, flattenedItems]);
83
+ const {
84
+ dndContextProps,
85
+ sortableContextProps,
86
+ activeId,
87
+ activeIndex,
88
+ depth,
89
+ dropIndicatorPosition,
90
+ visibleItems,
91
+ isDropValid
92
+ } = useTreeDndkitConfig({
93
+ flattenedItems,
94
+ visibleItems: flattenedVisibleTreeForDnD,
95
+ isHorizontalDnD: false,
96
+ isExpandable: true,
97
+ onReorder,
98
+ getIsDropValid,
99
+ maxDragAndDropLevel: Infinity
100
+ });
101
+ if (lastActiveId !== activeId && activeId) setLastActiveId(activeId);
102
+ if (withDragAndDrop) return /*#__PURE__*/jsxs(DndContext, _objectSpread(_objectSpread({}, dndContextProps), {}, {
103
+ children: [/*#__PURE__*/jsx(SortableContext, _objectSpread(_objectSpread({}, sortableContextProps), {}, {
104
+ children: /*#__PURE__*/_jsx(DnDTreeContext.Provider, {
105
+ value: {
106
+ activeIndex,
107
+ depth,
108
+ visibleItems: visibleItems.map(item => item.original),
109
+ dropIndicatorPosition,
110
+ lastActiveId,
111
+ setLastActiveId,
112
+ isDropValid
113
+ }
114
+ }, void 0, /*#__PURE__*/jsx(Component, _objectSpread({}, props)))
115
+ })), /*#__PURE__*/_jsx(DragOverlay, {
116
+ style: {
117
+ width: 'auto'
118
+ }
119
+ }, void 0, activeId ? /*#__PURE__*/_jsx(TreeItem, {
120
+ itemIndex: activeIndex,
121
+ item: ensure(flattenedVisibleTree.find(item => item.id.toString() === activeId)),
122
+ isDragOverlay: true
123
+ }) : null)]
124
+ }));
125
+ return /*#__PURE__*/jsx(Component, _objectSpread({}, props));
126
+ };
127
+
128
+ export { withConditionalDnDRowContext };
@@ -0,0 +1,61 @@
1
+ import 'core-js/modules/esnext.async-iterator.filter.js';
2
+ import 'core-js/modules/esnext.iterator.constructor.js';
3
+ import 'core-js/modules/esnext.iterator.filter.js';
4
+ import 'core-js/modules/esnext.async-iterator.for-each.js';
5
+ import 'core-js/modules/esnext.iterator.for-each.js';
6
+ import _jsx from '@babel/runtime/helpers/esm/jsx';
7
+ import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
8
+ import { useContext, useMemo } from 'react';
9
+ import { useSortable } from '@dnd-kit/sortable';
10
+ import { SortableItemContext } from './SortableItemContext.js';
11
+ import TreeViewContext from '../TreeViewContext.js';
12
+ import { DnDTreeContext } from './DnDTreeContext.js';
13
+ import { jsx } from 'react/jsx-runtime';
14
+
15
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
16
+
17
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
18
+ const withDnDSortableItemContext = Component => props => {
19
+ const {
20
+ withDragAndDrop
21
+ } = useContext(TreeViewContext);
22
+ const {
23
+ dropIndicatorPosition,
24
+ lastActiveId,
25
+ setLastActiveId,
26
+ isDropValid
27
+ } = useContext(DnDTreeContext);
28
+ const id = props.item.id.toString(); // onMount generate unique options, so everyting is only ran once
29
+
30
+ const draggableOptions = useMemo(() => ({
31
+ id
32
+ }), [id]);
33
+ const useSortableHelpers = useSortable(draggableOptions); // calculate all the "useSortable" values as per required
34
+
35
+ const draggableProps = useMemo(() => {
36
+ if (!withDragAndDrop) return false;
37
+ const {
38
+ index,
39
+ overIndex
40
+ } = useSortableHelpers;
41
+ return _objectSpread(_objectSpread({}, useSortableHelpers), {}, {
42
+ shouldShowDropIndicatorPosition: overIndex === index,
43
+ dropIndicatorPosition,
44
+ lastActiveId,
45
+ setLastActiveId,
46
+ isDropValid
47
+ });
48
+ }, [withDragAndDrop, useSortableHelpers, dropIndicatorPosition, lastActiveId, setLastActiveId, isDropValid]); // we use a context so we can easly access information wherever without bubbling down
49
+ // this context is all Memoized so as long as component is not re-mounted,
50
+ // the context won't trigger un-required renders per-se...
51
+
52
+ const ctx = useMemo(() => ({
53
+ draggableProps
54
+ }), [draggableProps]); // we always add the context, if draggableProps===false we don't have the DnD enabled.
55
+
56
+ return /*#__PURE__*/_jsx(SortableItemContext.Provider, {
57
+ value: ctx
58
+ }, void 0, /*#__PURE__*/jsx(Component, _objectSpread({}, props)));
59
+ };
60
+
61
+ export { withDnDSortableItemContext };
package/esm/index.js ADDED
@@ -0,0 +1,9 @@
1
+ export { TreeView, TreeViewWithSchema } from './TreeView.js';
2
+ export { TreeDndPlugin } from './plugins/dnd/TreeDndPlugin.js';
3
+ export { TreeRovingPlugin } from './plugins/roving/TreeRovingPlugin.js';
4
+ export { SelectablePluginTree } from './plugins/selectable/SelectablePluginTree.js';
5
+ export { TreeToolbarPlugin } from './plugins/toolbar/TreeToolbarPlugin.js';
6
+ export { TreePluginList } from './plugins/tree/TreeDataPlugin.js';
7
+ export { TreeVirtualizationPlugin } from './plugins/virtualization/TreeVirtualizationPlugin.js';
8
+ export { SearchableTreePlugin } from './plugins/searchable/SearchableTreePlugin.js';
9
+ export { TreeViewSearchBar } from './related-components/TreeViewSearchBar.js';
@@ -0,0 +1,78 @@
1
+ import 'core-js/modules/esnext.async-iterator.filter.js';
2
+ import 'core-js/modules/esnext.iterator.constructor.js';
3
+ import 'core-js/modules/esnext.iterator.filter.js';
4
+ import 'core-js/modules/esnext.async-iterator.for-each.js';
5
+ import 'core-js/modules/esnext.iterator.for-each.js';
6
+ import _jsx from '@babel/runtime/helpers/esm/jsx';
7
+ import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
8
+ import { useContext, useCallback, useMemo } from 'react';
9
+ import { DSCheckbox } from '@elliemae/ds-form';
10
+ import styled from 'styled-components';
11
+ import TreeViewContext from '../TreeViewContext.js';
12
+ import { toggleCheckboxItem } from '../utils/selectable-helper.js';
13
+ import { filterObject } from '../utils/object-helpers.js';
14
+
15
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
16
+
17
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
18
+ const StyledCheckboxWrapper = /*#__PURE__*/styled.span.withConfig({
19
+ componentId: "sc-1tyhs3t-0"
20
+ })(["padding-top:3px;"]);
21
+
22
+ function CheckboxSelectable(props) {
23
+ const {
24
+ item,
25
+ itemIndex
26
+ } = props;
27
+ const {
28
+ id
29
+ } = item;
30
+ const ctx = useContext(TreeViewContext);
31
+ const {
32
+ props: {
33
+ onSelectionChange,
34
+ isItemDisabled
35
+ },
36
+ virtualListHelpers: {
37
+ scrollToIndex
38
+ },
39
+ triggerTreeRerender,
40
+ selectedCheckboxes,
41
+ setSelectedCheckboxes
42
+ } = ctx;
43
+ const onCheckboxChange = useCallback(() => {
44
+ const newSelections = toggleCheckboxItem(item);
45
+ const newSelectionHasmap = filterObject(_objectSpread(_objectSpread({}, selectedCheckboxes), newSelections), value => value !== false);
46
+ setSelectedCheckboxes(newSelectionHasmap);
47
+ triggerTreeRerender();
48
+ const indexAndScrollTo = {
49
+ scrollToItem: () => {
50
+ if (typeof item.virtualIndex === 'number') scrollToIndex(item.virtualIndex);
51
+ },
52
+ itemIndex
53
+ };
54
+ if (onSelectionChange) onSelectionChange(newSelectionHasmap, item, indexAndScrollTo);
55
+ }, [item, triggerTreeRerender, onSelectionChange, itemIndex, scrollToIndex, selectedCheckboxes, setSelectedCheckboxes]);
56
+ const isChecked = useMemo(() => {
57
+ if (selectedCheckboxes[id] === 'mixed') {
58
+ return 'mixed';
59
+ }
60
+
61
+ if (selectedCheckboxes[id] === true) {
62
+ return true;
63
+ }
64
+
65
+ return false;
66
+ }, [selectedCheckboxes, id]);
67
+ const isDisabled = useMemo(() => isItemDisabled(item), [item, isItemDisabled]);
68
+ return /*#__PURE__*/_jsx(StyledCheckboxWrapper, {}, void 0, /*#__PURE__*/_jsx(DSCheckbox, {
69
+ checked: isChecked,
70
+ disabled: isDisabled,
71
+ className: "em-ds-tree-item-checkbox",
72
+ "data-testid": "tree-item-checkbox",
73
+ onChange: onCheckboxChange,
74
+ tabIndex: "0"
75
+ }));
76
+ }
77
+
78
+ export { CheckboxSelectable as default };