@elliemae/ds-treeview 2.2.0-next.4 → 2.3.0-alpha.2

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 (207) hide show
  1. package/cjs/TreeView.js +49 -27
  2. package/cjs/TreeView.js.map +7 -0
  3. package/cjs/TreeViewContext.js +61 -37
  4. package/cjs/TreeViewContext.js.map +7 -0
  5. package/cjs/config/cssClassesConstants.js +41 -13
  6. package/cjs/config/cssClassesConstants.js.map +7 -0
  7. package/cjs/config/useTreeview.js +116 -78
  8. package/cjs/config/useTreeview.js.map +7 -0
  9. package/cjs/index.js +37 -26
  10. package/cjs/index.js.map +7 -0
  11. package/cjs/parts/CheckboxSelectable.js +70 -59
  12. package/cjs/parts/CheckboxSelectable.js.map +7 -0
  13. package/cjs/parts/ChildrenCountDisplayer.js +45 -28
  14. package/cjs/parts/ChildrenCountDisplayer.js.map +7 -0
  15. package/cjs/parts/ExpandCaret.js +85 -83
  16. package/cjs/parts/ExpandCaret.js.map +7 -0
  17. package/cjs/parts/Icon.js +46 -31
  18. package/cjs/parts/Icon.js.map +7 -0
  19. package/cjs/parts/NestingSpace.js +43 -35
  20. package/cjs/parts/NestingSpace.js.map +7 -0
  21. package/cjs/parts/RadioSelectable.js +52 -37
  22. package/cjs/parts/RadioSelectable.js.map +7 -0
  23. package/cjs/parts/TreeItem.js +147 -141
  24. package/cjs/parts/TreeItem.js.map +7 -0
  25. package/cjs/parts/TreeItemText.js +88 -95
  26. package/cjs/parts/TreeItemText.js.map +7 -0
  27. package/cjs/parts/TreeList.js +119 -130
  28. package/cjs/parts/TreeList.js.map +7 -0
  29. package/cjs/plugins/dnd/TreeDndPlugin.js +59 -7
  30. package/cjs/plugins/dnd/TreeDndPlugin.js.map +7 -0
  31. package/cjs/plugins/dnd/index.js +28 -9
  32. package/cjs/plugins/dnd/index.js.map +7 -0
  33. package/cjs/plugins/index.js +34 -21
  34. package/cjs/plugins/index.js.map +7 -0
  35. package/cjs/plugins/roving/TreeRovingPlugin.js +35 -7
  36. package/cjs/plugins/roving/TreeRovingPlugin.js.map +7 -0
  37. package/cjs/plugins/roving/index.js +28 -9
  38. package/cjs/plugins/roving/index.js.map +7 -0
  39. package/cjs/plugins/searchable/SearchableTreePlugin.js +35 -7
  40. package/cjs/plugins/searchable/SearchableTreePlugin.js.map +7 -0
  41. package/cjs/plugins/searchable/index.js +28 -9
  42. package/cjs/plugins/searchable/index.js.map +7 -0
  43. package/cjs/plugins/selectable/SelectablePluginTree.js +35 -7
  44. package/cjs/plugins/selectable/SelectablePluginTree.js.map +7 -0
  45. package/cjs/plugins/selectable/index.js +28 -9
  46. package/cjs/plugins/selectable/index.js.map +7 -0
  47. package/cjs/plugins/toolbar/TreeToolbarPlugin.js +35 -7
  48. package/cjs/plugins/toolbar/TreeToolbarPlugin.js.map +7 -0
  49. package/cjs/plugins/toolbar/index.js +28 -9
  50. package/cjs/plugins/toolbar/index.js.map +7 -0
  51. package/cjs/plugins/tree/TreeDataPlugin.js +35 -7
  52. package/cjs/plugins/tree/TreeDataPlugin.js.map +7 -0
  53. package/cjs/plugins/tree/index.js +28 -9
  54. package/cjs/plugins/tree/index.js.map +7 -0
  55. package/cjs/plugins/virtualization/TreeVirtualizationPlugin.js +35 -7
  56. package/cjs/plugins/virtualization/TreeVirtualizationPlugin.js.map +7 -0
  57. package/cjs/plugins/virtualization/index.js +28 -9
  58. package/cjs/plugins/virtualization/index.js.map +7 -0
  59. package/cjs/react-desc-prop-types.js +82 -54
  60. package/cjs/react-desc-prop-types.js.map +7 -0
  61. package/cjs/related-components/TreeViewSearchBar.js +42 -40
  62. package/cjs/related-components/TreeViewSearchBar.js.map +7 -0
  63. package/cjs/sharedTypes.js +27 -2
  64. package/cjs/sharedTypes.js.map +7 -0
  65. package/cjs/utils/array-helpers.js +35 -11
  66. package/cjs/utils/array-helpers.js.map +7 -0
  67. package/cjs/utils/dnd-helpers.js +146 -0
  68. package/cjs/utils/dnd-helpers.js.map +7 -0
  69. package/cjs/utils/group-expands-helpers.js +86 -59
  70. package/cjs/utils/group-expands-helpers.js.map +7 -0
  71. package/cjs/utils/keyboard-helpers.js +85 -90
  72. package/cjs/utils/keyboard-helpers.js.map +7 -0
  73. package/cjs/utils/object-helpers.js +43 -36
  74. package/cjs/utils/object-helpers.js.map +7 -0
  75. package/cjs/utils/refs-helpers.js +43 -22
  76. package/cjs/utils/refs-helpers.js.map +7 -0
  77. package/cjs/utils/selectable-helper.js +61 -53
  78. package/cjs/utils/selectable-helper.js.map +7 -0
  79. package/cjs/utils/string-helpers.js +35 -7
  80. package/cjs/utils/string-helpers.js.map +7 -0
  81. package/cjs/utils/tree-helpers.js +105 -161
  82. package/cjs/utils/tree-helpers.js.map +7 -0
  83. package/cjs/utils/useDnDHelpers.js +199 -0
  84. package/cjs/utils/useDnDHelpers.js.map +7 -0
  85. package/cjs/utils/useInstanceRefActions.js +54 -43
  86. package/cjs/utils/useInstanceRefActions.js.map +7 -0
  87. package/cjs/utils/useTree.js +76 -80
  88. package/cjs/utils/useTree.js.map +7 -0
  89. package/esm/TreeView.js +18 -16
  90. package/esm/TreeView.js.map +7 -0
  91. package/esm/TreeViewContext.js +32 -31
  92. package/esm/TreeViewContext.js.map +7 -0
  93. package/esm/config/cssClassesConstants.js +12 -6
  94. package/esm/config/cssClassesConstants.js.map +7 -0
  95. package/esm/config/useTreeview.js +73 -56
  96. package/esm/config/useTreeview.js.map +7 -0
  97. package/esm/index.js +8 -9
  98. package/esm/index.js.map +7 -0
  99. package/esm/parts/CheckboxSelectable.js +36 -46
  100. package/esm/parts/CheckboxSelectable.js.map +7 -0
  101. package/esm/parts/ChildrenCountDisplayer.js +16 -20
  102. package/esm/parts/ChildrenCountDisplayer.js.map +7 -0
  103. package/esm/parts/ExpandCaret.js +54 -72
  104. package/esm/parts/ExpandCaret.js.map +7 -0
  105. package/esm/parts/Icon.js +16 -22
  106. package/esm/parts/Icon.js.map +7 -0
  107. package/esm/parts/NestingSpace.js +14 -27
  108. package/esm/parts/NestingSpace.js.map +7 -0
  109. package/esm/parts/RadioSelectable.js +20 -28
  110. package/esm/parts/RadioSelectable.js.map +7 -0
  111. package/esm/parts/TreeItem.js +114 -125
  112. package/esm/parts/TreeItem.js.map +7 -0
  113. package/esm/parts/TreeItemText.js +58 -85
  114. package/esm/parts/TreeItemText.js.map +7 -0
  115. package/esm/parts/TreeList.js +91 -119
  116. package/esm/parts/TreeList.js.map +7 -0
  117. package/esm/plugins/dnd/TreeDndPlugin.js +30 -3
  118. package/esm/plugins/dnd/TreeDndPlugin.js.map +7 -0
  119. package/esm/plugins/dnd/index.js +3 -1
  120. package/esm/plugins/dnd/index.js.map +7 -0
  121. package/esm/plugins/index.js +9 -7
  122. package/esm/plugins/index.js.map +7 -0
  123. package/esm/plugins/roving/TreeRovingPlugin.js +6 -3
  124. package/esm/plugins/roving/TreeRovingPlugin.js.map +7 -0
  125. package/esm/plugins/roving/index.js +3 -1
  126. package/esm/plugins/roving/index.js.map +7 -0
  127. package/esm/plugins/searchable/SearchableTreePlugin.js +6 -3
  128. package/esm/plugins/searchable/SearchableTreePlugin.js.map +7 -0
  129. package/esm/plugins/searchable/index.js +3 -1
  130. package/esm/plugins/searchable/index.js.map +7 -0
  131. package/esm/plugins/selectable/SelectablePluginTree.js +6 -3
  132. package/esm/plugins/selectable/SelectablePluginTree.js.map +7 -0
  133. package/esm/plugins/selectable/index.js +3 -1
  134. package/esm/plugins/selectable/index.js.map +7 -0
  135. package/esm/plugins/toolbar/TreeToolbarPlugin.js +6 -3
  136. package/esm/plugins/toolbar/TreeToolbarPlugin.js.map +7 -0
  137. package/esm/plugins/toolbar/index.js +3 -1
  138. package/esm/plugins/toolbar/index.js.map +7 -0
  139. package/esm/plugins/tree/TreeDataPlugin.js +6 -3
  140. package/esm/plugins/tree/TreeDataPlugin.js.map +7 -0
  141. package/esm/plugins/tree/index.js +3 -1
  142. package/esm/plugins/tree/index.js.map +7 -0
  143. package/esm/plugins/virtualization/TreeVirtualizationPlugin.js +6 -3
  144. package/esm/plugins/virtualization/TreeVirtualizationPlugin.js.map +7 -0
  145. package/esm/plugins/virtualization/index.js +3 -1
  146. package/esm/plugins/virtualization/index.js.map +7 -0
  147. package/esm/react-desc-prop-types.js +47 -44
  148. package/esm/react-desc-prop-types.js.map +7 -0
  149. package/esm/related-components/TreeViewSearchBar.js +13 -32
  150. package/esm/related-components/TreeViewSearchBar.js.map +7 -0
  151. package/esm/sharedTypes.js +2 -1
  152. package/esm/sharedTypes.js.map +7 -0
  153. package/esm/utils/array-helpers.js +6 -6
  154. package/esm/utils/array-helpers.js.map +7 -0
  155. package/esm/utils/dnd-helpers.js +117 -0
  156. package/esm/utils/dnd-helpers.js.map +7 -0
  157. package/esm/utils/group-expands-helpers.js +56 -46
  158. package/esm/utils/group-expands-helpers.js.map +7 -0
  159. package/esm/utils/keyboard-helpers.js +46 -74
  160. package/esm/utils/keyboard-helpers.js.map +7 -0
  161. package/esm/utils/object-helpers.js +14 -31
  162. package/esm/utils/object-helpers.js.map +7 -0
  163. package/esm/utils/refs-helpers.js +15 -19
  164. package/esm/utils/refs-helpers.js.map +7 -0
  165. package/esm/utils/selectable-helper.js +32 -43
  166. package/esm/utils/selectable-helper.js.map +7 -0
  167. package/esm/utils/string-helpers.js +6 -3
  168. package/esm/utils/string-helpers.js.map +7 -0
  169. package/esm/utils/tree-helpers.js +73 -143
  170. package/esm/utils/tree-helpers.js.map +7 -0
  171. package/esm/utils/useDnDHelpers.js +170 -0
  172. package/esm/utils/useDnDHelpers.js.map +7 -0
  173. package/esm/utils/useInstanceRefActions.js +21 -35
  174. package/esm/utils/useInstanceRefActions.js.map +7 -0
  175. package/esm/utils/useTree.js +35 -59
  176. package/esm/utils/useTree.js.map +7 -0
  177. package/package.json +19 -35
  178. package/types/TreeView.d.ts +1 -1
  179. package/types/parts/TreeItem.d.ts +11 -4
  180. package/types/parts/TreeList.d.ts +4 -0
  181. package/types/plugins/dnd/TreeDndPlugin.d.ts +2 -0
  182. package/types/react-desc-prop-types.d.ts +3 -17
  183. package/types/sharedTypes.d.ts +8 -1
  184. package/types/utils/dnd-helpers.d.ts +39 -0
  185. package/types/utils/keyboard-helpers.d.ts +1 -2
  186. package/types/utils/refs-helpers.d.ts +1 -1
  187. package/types/utils/tree-helpers.d.ts +1 -4
  188. package/types/utils/useDnDHelpers.d.ts +26 -0
  189. package/types/utils/useTree.d.ts +0 -1
  190. package/cjs/hoc/DnDTreeContext.js +0 -18
  191. package/cjs/hoc/SortableItemContext.js +0 -21
  192. package/cjs/hoc/WithConditionalDnDContext.js +0 -138
  193. package/cjs/hoc/WithDnDSortableItemContext.js +0 -70
  194. package/cjs/parts/DnDHandle.js +0 -46
  195. package/cjs/parts/DropIndicator.js +0 -75
  196. package/esm/hoc/DnDTreeContext.js +0 -14
  197. package/esm/hoc/SortableItemContext.js +0 -17
  198. package/esm/hoc/WithConditionalDnDContext.js +0 -128
  199. package/esm/hoc/WithDnDSortableItemContext.js +0 -61
  200. package/esm/parts/DnDHandle.js +0 -38
  201. package/esm/parts/DropIndicator.js +0 -68
  202. package/types/hoc/DnDTreeContext.d.ts +0 -14
  203. package/types/hoc/SortableItemContext.d.ts +0 -19
  204. package/types/hoc/WithConditionalDnDContext.d.ts +0 -4
  205. package/types/hoc/WithDnDSortableItemContext.d.ts +0 -4
  206. package/types/parts/DnDHandle.d.ts +0 -6
  207. package/types/parts/DropIndicator.d.ts +0 -10
package/esm/TreeView.js CHANGED
@@ -1,21 +1,23 @@
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;
1
+ import * as React from "react";
2
+ import React2 from "react";
3
+ import { describe } from "react-desc";
4
+ import { TreeViewPropTypes } from "./react-desc-prop-types";
5
+ import TreeViewContext from "./TreeViewContext";
6
+ import { TreeDnD, TreeDndPlugin } from "./plugins/dnd";
7
+ import { useTreeview } from "./config/useTreeview";
8
+ import { TreeList } from "./parts/TreeList";
10
9
  function TreeView(props) {
11
- const {
12
- ctx
13
- } = useTreeview(props);
14
- return /*#__PURE__*/_jsx(TreeViewContext.Provider, {
10
+ const { plugins } = props;
11
+ const { ctx } = useTreeview(props);
12
+ return /* @__PURE__ */ React2.createElement(TreeViewContext.Provider, {
15
13
  value: ctx
16
- }, void 0, _TreeList || (_TreeList = /*#__PURE__*/_jsx(TreeList, {})));
14
+ }, plugins?.includes(TreeDndPlugin) ? /* @__PURE__ */ React2.createElement(TreeDnD, null) : /* @__PURE__ */ React2.createElement(TreeList, null));
17
15
  }
16
+ TreeView.propTypes = TreeViewPropTypes;
18
17
  const TreeViewWithSchema = describe(TreeView);
19
18
  TreeViewWithSchema.propTypes = TreeViewPropTypes;
20
-
21
- export { TreeView, TreeViewWithSchema };
19
+ export {
20
+ TreeView,
21
+ TreeViewWithSchema
22
+ };
23
+ //# sourceMappingURL=TreeView.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/TreeView.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-lines */\n/* eslint-disable max-statements */\nimport React, { WeakValidationMap } from 'react';\n\nimport { describe } from 'react-desc';\nimport { TreeViewPropTypes } from './react-desc-prop-types';\nimport TreeViewContext from './TreeViewContext';\nimport { TreeDnD, TreeDndPlugin } from './plugins/dnd';\nimport { useTreeview } from './config/useTreeview';\nimport { TreeList } from './parts/TreeList';\nimport type { DSTreeviewT } from './react-desc-prop-types';\nexport function TreeView(props: DSTreeviewT.Props) {\n const { plugins } = props;\n\n const { ctx } = useTreeview(props);\n\n return (\n <TreeViewContext.Provider value={ctx}>\n {plugins?.includes(TreeDndPlugin) ? <TreeDnD /> : <TreeList />}\n </TreeViewContext.Provider>\n );\n}\n\nTreeView.propTypes = TreeViewPropTypes as WeakValidationMap<unknown>;\nconst TreeViewWithSchema = describe(TreeView);\nTreeViewWithSchema.propTypes = TreeViewPropTypes;\n\nexport { TreeViewWithSchema };\n"],
5
+ "mappings": "AAAA;ACEA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEO,kBAAkB,OAA0B;AACjD,QAAM,EAAE,YAAY;AAEpB,QAAM,EAAE,QAAQ,YAAY;AAE5B,SACE,qCAAC,gBAAgB,UAAjB;AAAA,IAA0B,OAAO;AAAA,KAC9B,SAAS,SAAS,iBAAiB,qCAAC,SAAD,QAAc,qCAAC,UAAD;AAAA;AAKxD,SAAS,YAAY;AACrB,MAAM,qBAAqB,SAAS;AACpC,mBAAmB,YAAY;",
6
+ "names": []
7
+ }
@@ -1,20 +1,16 @@
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
-
1
+ import * as React from "react";
2
+ import { createContext, createRef } from "react";
3
+ function noop(..._args) {
4
+ }
8
5
  const defaultProps = {
9
6
  plugins: [],
10
7
  selection: {},
11
- instanceRef: /*#__PURE__*/createRef(),
8
+ instanceRef: createRef(),
12
9
  isItemDisabled: () => false,
13
10
  disableIcons: false,
14
11
  fluid: false,
15
12
  isMultiSelect: false,
16
13
  isSingleSelect: false,
17
- getIsDropValid: () => true,
18
14
  restrictDragAndDrop: false,
19
15
  showChildrenAmount: false,
20
16
  sortable: false,
@@ -27,20 +23,15 @@ const defaultProps = {
27
23
  onSelectionChange: noop,
28
24
  onExpandChange: noop,
29
25
  onInstanceRefInitialized: noop,
30
- rowSize: 'normal',
31
- labelOverflow: 'wrap',
32
- noItemsPlaceholder: 'No items found',
33
- nameKey: 'name',
34
- width: '100%',
35
- height: '100%',
26
+ rowSize: "normal",
27
+ labelOverflow: "wrap",
28
+ noItemsPlaceholder: "No items found",
29
+ nameKey: "name",
30
+ width: "100%",
31
+ height: "100%",
36
32
  groupIcon: null,
37
33
  itemIcon: null,
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
-
34
+ searchQuery: ""
44
35
  };
45
36
  const defaultRelativeMouseCoord = {
46
37
  isBefore: false,
@@ -55,21 +46,28 @@ const defaultRelativeMouseCoord = {
55
46
  const defaultContext = {
56
47
  props: defaultProps,
57
48
  visibleItems: [],
58
- flattenedItems: [],
59
49
  withRadioChecks: false,
60
50
  withCheckboxChecks: false,
61
51
  withDragAndDrop: false,
52
+ relativeMouseCord: defaultRelativeMouseCoord,
53
+ setRelativeMouseCord: noop,
62
54
  triggerTreeRerender: noop,
63
- tree: undefined,
64
- treeRoot: undefined,
55
+ tree: void 0,
56
+ treeRoot: void 0,
65
57
  virtualListHelpers: {
66
58
  virtualItems: [],
67
59
  totalSize: 0,
68
60
  scrollToOffset: noop,
69
61
  scrollToIndex: noop
70
62
  },
71
- virtualListRef: undefined,
72
- uniqueTreeViewUUID: '',
63
+ virtualListRef: void 0,
64
+ isDragging: false,
65
+ setIsDragging: noop,
66
+ isKeyboardDragging: false,
67
+ setIsKeyboardDragging: noop,
68
+ draggedItem: null,
69
+ setDraggedItem: noop,
70
+ uniqueTreeViewUUID: "",
73
71
  selectedItem: null,
74
72
  setSelectedItem: noop,
75
73
  focusedItem: null,
@@ -85,8 +83,11 @@ const defaultContext = {
85
83
  handleExpandGroup: noop,
86
84
  updateUserExpandedState: noop
87
85
  };
88
- /** Context for cross component communication */
89
-
90
- const TreeViewContext = /*#__PURE__*/createContext(defaultContext);
91
-
92
- export { TreeViewContext as default, defaultProps, defaultRelativeMouseCoord };
86
+ const TreeViewContext = createContext(defaultContext);
87
+ var TreeViewContext_default = TreeViewContext;
88
+ export {
89
+ TreeViewContext_default as default,
90
+ defaultProps,
91
+ defaultRelativeMouseCoord
92
+ };
93
+ //# sourceMappingURL=TreeViewContext.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/TreeViewContext.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable no-unused-vars */\nimport { createContext, createRef } from 'react';\nimport type { DSTreeviewT } from './react-desc-prop-types';\nimport type { DSTreeviewInternalsT } from './sharedTypes';\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nfunction noop<T extends unknown[]>(..._args: T): void {}\n\nexport const defaultProps = {\n plugins: [],\n selection: {},\n instanceRef: createRef(),\n isItemDisabled: () => false,\n disableIcons: false,\n fluid: false,\n isMultiSelect: false,\n isSingleSelect: false,\n restrictDragAndDrop: false,\n showChildrenAmount: false,\n sortable: false,\n isLoading: false,\n highlightOnlyQuery: false,\n onItemClick: noop,\n onItemFocus: noop,\n onVisibleItemsChange: noop,\n onOrderChange: noop,\n onSelectionChange: noop,\n onExpandChange: noop,\n onInstanceRefInitialized: noop,\n rowSize: 'normal',\n labelOverflow: 'wrap',\n noItemsPlaceholder: 'No items found',\n nameKey: 'name',\n width: '100%',\n height: '100%',\n groupIcon: null,\n itemIcon: null,\n searchQuery: '',\n // workaround on the typings over the fact that\n // when we instantiate the context we can't have all the props\n // we only have a part of them but the final typings will include missing props\n // this is safe to do because\n // we will \"mergeWithDefaults\" + \"validatePropTypes\" when we do instantiate the context\n} as unknown as DSTreeviewT.Props;\n\nexport const defaultRelativeMouseCoord = {\n isBefore: false,\n isAfter: false,\n isValid: true,\n item: null,\n x: null,\n y: null,\n relativeElementDOMRect: null,\n relativeElementIndex: null,\n};\n\nconst defaultContext: DSTreeviewInternalsT.CTX = {\n props: defaultProps,\n visibleItems: [],\n withRadioChecks: false,\n withCheckboxChecks: false,\n withDragAndDrop: false,\n relativeMouseCord: defaultRelativeMouseCoord,\n setRelativeMouseCord: noop,\n triggerTreeRerender: noop,\n tree: undefined,\n treeRoot: undefined,\n virtualListHelpers: {\n virtualItems: [],\n totalSize: 0,\n scrollToOffset: noop,\n scrollToIndex: noop,\n },\n virtualListRef: undefined,\n isDragging: false,\n setIsDragging: noop,\n isKeyboardDragging: false,\n setIsKeyboardDragging: noop,\n draggedItem: null,\n setDraggedItem: noop,\n uniqueTreeViewUUID: '',\n selectedItem: null,\n setSelectedItem: noop,\n focusedItem: null,\n setFocusedItem: noop,\n selectedCheckboxes: {},\n setSelectedCheckboxes: noop,\n expandedGroups: {},\n setExpandedGroups: noop,\n latestToggledItem: null,\n setLatestToggledItem: noop,\n hoverItem: null,\n setHoverItem: noop,\n handleExpandGroup: noop,\n updateUserExpandedState: noop,\n};\n\n/** Context for cross component communication */\nconst TreeViewContext = createContext(defaultContext);\n\nexport default TreeViewContext;\n"],
5
+ "mappings": "AAAA;ACCA;AAKA,iBAAsC,OAAgB;AAAA;AAE/C,MAAM,eAAe;AAAA,EAC1B,SAAS;AAAA,EACT,WAAW;AAAA,EACX,aAAa;AAAA,EACb,gBAAgB,MAAM;AAAA,EACtB,cAAc;AAAA,EACd,OAAO;AAAA,EACP,eAAe;AAAA,EACf,gBAAgB;AAAA,EAChB,qBAAqB;AAAA,EACrB,oBAAoB;AAAA,EACpB,UAAU;AAAA,EACV,WAAW;AAAA,EACX,oBAAoB;AAAA,EACpB,aAAa;AAAA,EACb,aAAa;AAAA,EACb,sBAAsB;AAAA,EACtB,eAAe;AAAA,EACf,mBAAmB;AAAA,EACnB,gBAAgB;AAAA,EAChB,0BAA0B;AAAA,EAC1B,SAAS;AAAA,EACT,eAAe;AAAA,EACf,oBAAoB;AAAA,EACpB,SAAS;AAAA,EACT,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,UAAU;AAAA,EACV,aAAa;AAAA;AAQR,MAAM,4BAA4B;AAAA,EACvC,UAAU;AAAA,EACV,SAAS;AAAA,EACT,SAAS;AAAA,EACT,MAAM;AAAA,EACN,GAAG;AAAA,EACH,GAAG;AAAA,EACH,wBAAwB;AAAA,EACxB,sBAAsB;AAAA;AAGxB,MAAM,iBAA2C;AAAA,EAC/C,OAAO;AAAA,EACP,cAAc;AAAA,EACd,iBAAiB;AAAA,EACjB,oBAAoB;AAAA,EACpB,iBAAiB;AAAA,EACjB,mBAAmB;AAAA,EACnB,sBAAsB;AAAA,EACtB,qBAAqB;AAAA,EACrB,MAAM;AAAA,EACN,UAAU;AAAA,EACV,oBAAoB;AAAA,IAClB,cAAc;AAAA,IACd,WAAW;AAAA,IACX,gBAAgB;AAAA,IAChB,eAAe;AAAA;AAAA,EAEjB,gBAAgB;AAAA,EAChB,YAAY;AAAA,EACZ,eAAe;AAAA,EACf,oBAAoB;AAAA,EACpB,uBAAuB;AAAA,EACvB,aAAa;AAAA,EACb,gBAAgB;AAAA,EAChB,oBAAoB;AAAA,EACpB,cAAc;AAAA,EACd,iBAAiB;AAAA,EACjB,aAAa;AAAA,EACb,gBAAgB;AAAA,EAChB,oBAAoB;AAAA,EACpB,uBAAuB;AAAA,EACvB,gBAAgB;AAAA,EAChB,mBAAmB;AAAA,EACnB,mBAAmB;AAAA,EACnB,sBAAsB;AAAA,EACtB,WAAW;AAAA,EACX,cAAc;AAAA,EACd,mBAAmB;AAAA,EACnB,yBAAyB;AAAA;AAI3B,MAAM,kBAAkB,cAAc;AAEtC,IAAO,0BAAQ;",
6
+ "names": []
7
+ }
@@ -1,6 +1,12 @@
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 };
1
+ import * as React from "react";
2
+ const DSTreeViewPrefix = "em-ds";
3
+ const treeItemBlockName = "tree-item";
4
+ const treeListBlockName = "tree-list";
5
+ const treeListNoItemsBn = `${treeListBlockName}-no-items`;
6
+ export {
7
+ DSTreeViewPrefix,
8
+ treeItemBlockName,
9
+ treeListBlockName,
10
+ treeListNoItemsBn
11
+ };
12
+ //# sourceMappingURL=cssClassesConstants.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/config/cssClassesConstants.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export const DSTreeViewPrefix = 'em-ds';\nexport const treeItemBlockName = 'tree-item';\nexport const treeListBlockName = 'tree-list';\nexport const treeListNoItemsBn = `${treeListBlockName}-no-items`;\n"],
5
+ "mappings": "AAAA;ACAO,MAAM,mBAAmB;AACzB,MAAM,oBAAoB;AAC1B,MAAM,oBAAoB;AAC1B,MAAM,oBAAoB,GAAG;",
6
+ "names": []
7
+ }
@@ -1,34 +1,28 @@
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 => {
1
+ import * as React from "react";
2
+ import { useState, useRef, useEffect, useMemo, useCallback } from "react";
3
+ import { useVirtual } from "react-virtual";
4
+ import { useMemoMergePropsWithDefault, useValidateTypescriptPropTypes } from "@elliemae/ds-props-helpers";
5
+ import { v4 as uuidv4 } from "uuid";
6
+ import { TreeViewPropTypes } from "../react-desc-prop-types";
7
+ import { defaultRelativeMouseCoord, defaultProps } from "../TreeViewContext";
8
+ import { TreeDndPlugin } from "../plugins/dnd";
9
+ import { useTree } from "../utils/useTree";
10
+ import { useNotifyExpandedChange, toggleItemExpand } from "../utils/group-expands-helpers";
11
+ import { useInstanceRefActions } from "../utils/useInstanceRefActions";
12
+ import { useGlobalToggleAllExpandShortcut } from "../utils/keyboard-helpers";
13
+ const useTreeview = (props) => {
24
14
  const propsWithDefault = useMemoMergePropsWithDefault(props, defaultProps);
25
15
  useValidateTypescriptPropTypes(propsWithDefault, TreeViewPropTypes);
26
16
  const defaultActions = {
27
17
  actions: {
28
- toggleExpandAll: () => {},
29
- scrollTo: () => {},
30
- setSelectedItemByVirtualIndex: () => {},
31
- setFocusedItemByVirtualIndex: () => {}
18
+ toggleExpandAll: () => {
19
+ },
20
+ scrollTo: () => {
21
+ },
22
+ setSelectedItemByVirtualIndex: () => {
23
+ },
24
+ setFocusedItemByVirtualIndex: () => {
25
+ }
32
26
  }
33
27
  };
34
28
  const treeRef = useRef(defaultActions);
@@ -42,44 +36,48 @@ const useTreeview = props => {
42
36
  selection,
43
37
  onInstanceRefInitialized
44
38
  } = propsWithDefault;
45
- const [uniqueTreeViewUUID] = useState(v4());
39
+ const [isDragging, setIsDragging] = useState(false);
40
+ const [isKeyboardDragging, setIsKeyboardDragging] = useState(false);
41
+ const [relativeMouseCord, setRelativeMouseCord] = useState(defaultRelativeMouseCoord);
42
+ const [uniqueTreeViewUUID] = useState(uuidv4());
43
+ const [draggedItem, setDraggedItem] = useState(null);
46
44
  const [hoverItem, setHoverItem] = useState(null);
47
45
  const [latestToggledItem, setLatestToggledItem] = useState(null);
48
46
  const [selectedItem, setSelectedItem] = useState(null);
49
47
  const [focusedItem, setFocusedItem] = useState(null);
50
- const [selectedCheckboxes, setSelectedCheckboxes] = useState(_objectSpread({}, selection));
48
+ const [selectedCheckboxes, setSelectedCheckboxes] = useState({
49
+ ...selection
50
+ });
51
51
  const [expandedGroups, setExpandedGroups] = useState({});
52
- const {
53
- visibleItems,
54
- flattenedItems,
55
- tree,
56
- treeRoot,
57
- triggerTreeRerender,
58
- updateUserExpandedState
59
- } = useTree(data, propsWithDefault, {
52
+ const { visibleItems, tree, treeRoot, triggerTreeRerender, updateUserExpandedState } = useTree(data, propsWithDefault, {
60
53
  setExpandedGroups
61
54
  });
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
-
55
+ const virtualListRef = useRef();
65
56
  const virtualListHelpers = useVirtual({
66
57
  size: visibleItems.length,
67
58
  parentRef: virtualListRef,
68
59
  overscan: 15
69
60
  });
70
- const withDragAndDrop = !!(plugins !== null && plugins !== void 0 && plugins.includes(TreeDndPlugin) && onOrderChange);
61
+ const withDragAndDrop = !!(plugins?.includes(TreeDndPlugin) && onOrderChange);
71
62
  const withRadioChecks = isSingleSelect && !isMultiSelect;
72
63
  const withCheckboxChecks = !isSingleSelect && isMultiSelect;
73
64
  const handleExpandGroup = useCallback(toggleItemExpand, []);
74
65
  const ctx = useMemo(() => ({
75
66
  props: propsWithDefault,
67
+ setRelativeMouseCord,
68
+ relativeMouseCord,
76
69
  virtualListHelpers,
77
70
  virtualListRef,
78
71
  tree,
79
72
  treeRoot,
80
73
  visibleItems,
81
- flattenedItems,
82
74
  triggerTreeRerender,
75
+ isDragging,
76
+ setIsDragging,
77
+ isKeyboardDragging,
78
+ setIsKeyboardDragging,
79
+ draggedItem,
80
+ setDraggedItem,
83
81
  withRadioChecks,
84
82
  withCheckboxChecks,
85
83
  withDragAndDrop,
@@ -98,22 +96,41 @@ const useTreeview = props => {
98
96
  setHoverItem,
99
97
  handleExpandGroup,
100
98
  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;
99
+ }), [
100
+ draggedItem,
101
+ expandedGroups,
102
+ focusedItem,
103
+ handleExpandGroup,
104
+ hoverItem,
105
+ isDragging,
106
+ isKeyboardDragging,
107
+ latestToggledItem,
108
+ propsWithDefault,
109
+ relativeMouseCord,
110
+ selectedCheckboxes,
111
+ selectedItem,
112
+ tree,
113
+ treeRoot,
114
+ triggerTreeRerender,
115
+ uniqueTreeViewUUID,
116
+ virtualListHelpers,
117
+ visibleItems,
118
+ withCheckboxChecks,
119
+ withDragAndDrop,
120
+ withRadioChecks,
121
+ updateUserExpandedState
122
+ ]);
123
+ if (instanceRef)
124
+ instanceRef.current = treeRef.current;
105
125
  useInstanceRefActions(treeRef.current, ctx);
106
126
  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
-
127
+ useNotifyExpandedChange(propsWithDefault, ctx);
111
128
  useEffect(() => {
112
- setTimeout(() => onInstanceRefInitialized(treeRef), 100); // eslint-disable-next-line react-hooks/exhaustive-deps
129
+ setTimeout(() => onInstanceRefInitialized(treeRef), 100);
113
130
  }, []);
114
- return useMemo(() => ({
115
- ctx
116
- }), [ctx]);
131
+ return useMemo(() => ({ ctx }), [ctx]);
132
+ };
133
+ export {
134
+ useTreeview
117
135
  };
118
-
119
- export { useTreeview };
136
+ //# sourceMappingURL=useTreeview.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/config/useTreeview.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-lines */\n/* eslint-disable max-statements */\nimport { useState, useRef, useEffect, useMemo, useCallback } from 'react';\nimport { useVirtual } from 'react-virtual';\nimport { useMemoMergePropsWithDefault, useValidateTypescriptPropTypes } from '@elliemae/ds-props-helpers';\nimport { v4 as uuidv4 } from 'uuid';\n\nimport { TreeViewPropTypes } from '../react-desc-prop-types';\nimport { defaultRelativeMouseCoord, defaultProps } from '../TreeViewContext';\nimport { TreeDndPlugin } from '../plugins/dnd';\nimport { useTree } from '../utils/useTree';\nimport { useNotifyExpandedChange, toggleItemExpand } from '../utils/group-expands-helpers';\nimport { useInstanceRefActions } from '../utils/useInstanceRefActions';\nimport { useGlobalToggleAllExpandShortcut } from '../utils/keyboard-helpers';\nimport type { DSTreeviewT } from '../react-desc-prop-types';\nimport type { DSTreeviewInternalsT } from '../sharedTypes';\n\ntype UseTreeviewT = (props: DSTreeviewT.Props) => { ctx: DSTreeviewInternalsT.CTX };\n\nexport const useTreeview: UseTreeviewT = (props) => {\n const propsWithDefault = useMemoMergePropsWithDefault<DSTreeviewT.Props>(props, defaultProps);\n useValidateTypescriptPropTypes<DSTreeviewT.Props>(propsWithDefault, TreeViewPropTypes);\n const defaultActions = {\n actions: {\n toggleExpandAll: () => {},\n scrollTo: () => {},\n setSelectedItemByVirtualIndex: () => {},\n setFocusedItemByVirtualIndex: () => {},\n },\n } as unknown as DSTreeviewT.InstanceRef;\n const treeRef = useRef(defaultActions);\n const {\n data,\n plugins,\n onOrderChange,\n isMultiSelect,\n isSingleSelect,\n instanceRef,\n selection,\n onInstanceRefInitialized,\n } = propsWithDefault;\n const [isDragging, setIsDragging] = useState(false);\n const [isKeyboardDragging, setIsKeyboardDragging] = useState(false);\n const [relativeMouseCord, setRelativeMouseCord] =\n useState<DSTreeviewInternalsT.MouseCoord>(defaultRelativeMouseCoord);\n const [uniqueTreeViewUUID] = useState(uuidv4());\n const [draggedItem, setDraggedItem] = useState<DSTreeviewT.Item | null>(null);\n const [hoverItem, setHoverItem] = useState<DSTreeviewT.Item | null>(null);\n const [latestToggledItem, setLatestToggledItem] = useState<DSTreeviewT.Item | null>(null);\n const [selectedItem, setSelectedItem] = useState<DSTreeviewT.Item | null>(null);\n const [focusedItem, setFocusedItem] = useState<DSTreeviewT.Item | null>(null);\n const [selectedCheckboxes, setSelectedCheckboxes] = useState({\n ...selection,\n });\n const [expandedGroups, setExpandedGroups] = useState<DSTreeviewT.ExpandedItems>({});\n const { visibleItems, tree, treeRoot, triggerTreeRerender, updateUserExpandedState } = useTree(\n data,\n propsWithDefault,\n {\n setExpandedGroups,\n },\n );\n\n const virtualListRef = useRef<HTMLUListElement>();\n // estimateSize should not be really required given what was stated on\n // https://github.com/tannerlinsley/react-virtual/issues/23\n\n const virtualListHelpers = useVirtual({\n size: visibleItems.length,\n parentRef: virtualListRef,\n overscan: 15,\n });\n\n const withDragAndDrop = !!(plugins?.includes(TreeDndPlugin) && onOrderChange);\n const withRadioChecks = isSingleSelect && !isMultiSelect;\n const withCheckboxChecks = !isSingleSelect && isMultiSelect;\n\n const handleExpandGroup = useCallback(toggleItemExpand, []);\n\n const ctx: DSTreeviewInternalsT.CTX = useMemo(\n () => ({\n props: propsWithDefault,\n setRelativeMouseCord,\n relativeMouseCord,\n virtualListHelpers,\n virtualListRef,\n tree,\n treeRoot,\n visibleItems,\n triggerTreeRerender,\n isDragging,\n setIsDragging,\n isKeyboardDragging,\n setIsKeyboardDragging,\n draggedItem,\n setDraggedItem,\n withRadioChecks,\n withCheckboxChecks,\n withDragAndDrop,\n uniqueTreeViewUUID,\n selectedCheckboxes,\n setSelectedCheckboxes,\n selectedItem,\n setSelectedItem,\n expandedGroups,\n setExpandedGroups,\n latestToggledItem,\n setLatestToggledItem,\n focusedItem,\n setFocusedItem,\n hoverItem,\n setHoverItem,\n handleExpandGroup,\n updateUserExpandedState,\n }),\n [\n draggedItem,\n expandedGroups,\n focusedItem,\n handleExpandGroup,\n hoverItem,\n isDragging,\n isKeyboardDragging,\n latestToggledItem,\n propsWithDefault,\n relativeMouseCord,\n selectedCheckboxes,\n selectedItem,\n tree,\n treeRoot,\n triggerTreeRerender,\n uniqueTreeViewUUID,\n virtualListHelpers,\n visibleItems,\n withCheckboxChecks,\n withDragAndDrop,\n withRadioChecks,\n updateUserExpandedState,\n ],\n );\n // this hooks can't use the context because the context provider doesn't wrap this\n // as such we manually pass the second parameter as fit\n if (instanceRef) instanceRef.current = treeRef.current;\n useInstanceRefActions(treeRef.current, ctx);\n useGlobalToggleAllExpandShortcut(treeRoot, triggerTreeRerender, setLatestToggledItem, updateUserExpandedState);\n useNotifyExpandedChange(propsWithDefault, ctx);\n\n // this is an horrible hack.\n // this is required because there is no \"on rendered\" react-way to check if every children has finished rendering\n // this should be working for now, in the future we may want to review this for a better solution\n useEffect(() => {\n setTimeout(() => onInstanceRefInitialized(treeRef), 100);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return useMemo(() => ({ ctx }), [ctx]);\n};\n"],
5
+ "mappings": "AAAA;ACEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAMO,MAAM,cAA4B,CAAC,UAAU;AAClD,QAAM,mBAAmB,6BAAgD,OAAO;AAChF,iCAAkD,kBAAkB;AACpE,QAAM,iBAAiB;AAAA,IACrB,SAAS;AAAA,MACP,iBAAiB,MAAM;AAAA;AAAA,MACvB,UAAU,MAAM;AAAA;AAAA,MAChB,+BAA+B,MAAM;AAAA;AAAA,MACrC,8BAA8B,MAAM;AAAA;AAAA;AAAA;AAGxC,QAAM,UAAU,OAAO;AACvB,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MACE;AACJ,QAAM,CAAC,YAAY,iBAAiB,SAAS;AAC7C,QAAM,CAAC,oBAAoB,yBAAyB,SAAS;AAC7D,QAAM,CAAC,mBAAmB,wBACxB,SAA0C;AAC5C,QAAM,CAAC,sBAAsB,SAAS;AACtC,QAAM,CAAC,aAAa,kBAAkB,SAAkC;AACxE,QAAM,CAAC,WAAW,gBAAgB,SAAkC;AACpE,QAAM,CAAC,mBAAmB,wBAAwB,SAAkC;AACpF,QAAM,CAAC,cAAc,mBAAmB,SAAkC;AAC1E,QAAM,CAAC,aAAa,kBAAkB,SAAkC;AACxE,QAAM,CAAC,oBAAoB,yBAAyB,SAAS;AAAA,OACxD;AAAA;AAEL,QAAM,CAAC,gBAAgB,qBAAqB,SAAoC;AAChF,QAAM,EAAE,cAAc,MAAM,UAAU,qBAAqB,4BAA4B,QACrF,MACA,kBACA;AAAA,IACE;AAAA;AAIJ,QAAM,iBAAiB;AAIvB,QAAM,qBAAqB,WAAW;AAAA,IACpC,MAAM,aAAa;AAAA,IACnB,WAAW;AAAA,IACX,UAAU;AAAA;AAGZ,QAAM,kBAAkB,CAAC,CAAE,UAAS,SAAS,kBAAkB;AAC/D,QAAM,kBAAkB,kBAAkB,CAAC;AAC3C,QAAM,qBAAqB,CAAC,kBAAkB;AAE9C,QAAM,oBAAoB,YAAY,kBAAkB;AAExD,QAAM,MAAgC,QACpC,MAAO;AAAA,IACL,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MAEF;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAKJ,MAAI;AAAa,gBAAY,UAAU,QAAQ;AAC/C,wBAAsB,QAAQ,SAAS;AACvC,mCAAiC,UAAU,qBAAqB,sBAAsB;AACtF,0BAAwB,kBAAkB;AAK1C,YAAU,MAAM;AACd,eAAW,MAAM,yBAAyB,UAAU;AAAA,KAEnD;AAEH,SAAO,QAAQ,MAAO,GAAE,QAAQ,CAAC;AAAA;",
6
+ "names": []
7
+ }
package/esm/index.js CHANGED
@@ -1,9 +1,8 @@
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';
1
+ import * as React from "react";
2
+ export * from "./TreeView";
3
+ export * from "./plugins";
4
+ import { TreeViewSearchBar } from "./related-components/TreeViewSearchBar";
5
+ export {
6
+ TreeViewSearchBar
7
+ };
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/index.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export * from './TreeView';\nexport * from './plugins';\n\nexport { TreeViewSearchBar } from './related-components/TreeViewSearchBar';\n"],
5
+ "mappings": "AAAA;ACAA;AACA;AAEA;",
6
+ "names": []
7
+ }
@@ -1,71 +1,58 @@
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
-
1
+ import * as React from "react";
2
+ import React2, { useContext, useCallback, useMemo } from "react";
3
+ import { DSCheckbox } from "@elliemae/ds-form";
4
+ import styled from "styled-components";
5
+ import TreeViewContext from "../TreeViewContext";
6
+ import { toggleCheckboxItem } from "../utils/selectable-helper";
7
+ import { filterObject } from "../utils/object-helpers";
8
+ const StyledCheckboxWrapper = styled.span`
9
+ padding-top: 3px;
10
+ `;
22
11
  function CheckboxSelectable(props) {
23
- const {
24
- item,
25
- itemIndex
26
- } = props;
27
- const {
28
- id
29
- } = item;
12
+ const { item, itemIndex } = props;
13
+ const { id } = item;
30
14
  const ctx = useContext(TreeViewContext);
31
15
  const {
32
- props: {
33
- onSelectionChange,
34
- isItemDisabled
35
- },
36
- virtualListHelpers: {
37
- scrollToIndex
38
- },
16
+ props: { onSelectionChange, isItemDisabled },
17
+ virtualListHelpers: { scrollToIndex },
39
18
  triggerTreeRerender,
40
19
  selectedCheckboxes,
41
20
  setSelectedCheckboxes
42
21
  } = ctx;
43
22
  const onCheckboxChange = useCallback(() => {
44
23
  const newSelections = toggleCheckboxItem(item);
45
- const newSelectionHasmap = filterObject(_objectSpread(_objectSpread({}, selectedCheckboxes), newSelections), value => value !== false);
24
+ const newSelectionHasmap = filterObject({ ...selectedCheckboxes, ...newSelections }, (value) => value !== false);
46
25
  setSelectedCheckboxes(newSelectionHasmap);
47
26
  triggerTreeRerender();
48
27
  const indexAndScrollTo = {
49
28
  scrollToItem: () => {
50
- if (typeof item.virtualIndex === 'number') scrollToIndex(item.virtualIndex);
29
+ if (typeof item.virtualIndex === "number")
30
+ scrollToIndex(item.virtualIndex);
51
31
  },
52
32
  itemIndex
53
33
  };
54
- if (onSelectionChange) onSelectionChange(newSelectionHasmap, item, indexAndScrollTo);
55
- }, [item, triggerTreeRerender, onSelectionChange, itemIndex, scrollToIndex, selectedCheckboxes, setSelectedCheckboxes]);
34
+ if (onSelectionChange)
35
+ onSelectionChange(newSelectionHasmap, item, indexAndScrollTo);
36
+ }, [
37
+ item,
38
+ triggerTreeRerender,
39
+ onSelectionChange,
40
+ itemIndex,
41
+ scrollToIndex,
42
+ selectedCheckboxes,
43
+ setSelectedCheckboxes
44
+ ]);
56
45
  const isChecked = useMemo(() => {
57
- if (selectedCheckboxes[id] === 'mixed') {
58
- return 'mixed';
46
+ if (selectedCheckboxes[id] === "mixed") {
47
+ return "mixed";
59
48
  }
60
-
61
49
  if (selectedCheckboxes[id] === true) {
62
50
  return true;
63
51
  }
64
-
65
52
  return false;
66
53
  }, [selectedCheckboxes, id]);
67
54
  const isDisabled = useMemo(() => isItemDisabled(item), [item, isItemDisabled]);
68
- return /*#__PURE__*/_jsx(StyledCheckboxWrapper, {}, void 0, /*#__PURE__*/_jsx(DSCheckbox, {
55
+ return /* @__PURE__ */ React2.createElement(StyledCheckboxWrapper, null, /* @__PURE__ */ React2.createElement(DSCheckbox, {
69
56
  checked: isChecked,
70
57
  disabled: isDisabled,
71
58
  className: "em-ds-tree-item-checkbox",
@@ -74,5 +61,8 @@ function CheckboxSelectable(props) {
74
61
  tabIndex: "0"
75
62
  }));
76
63
  }
77
-
78
- export { CheckboxSelectable as default };
64
+ var CheckboxSelectable_default = CheckboxSelectable;
65
+ export {
66
+ CheckboxSelectable_default as default
67
+ };
68
+ //# sourceMappingURL=CheckboxSelectable.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/parts/CheckboxSelectable.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext, useCallback, useMemo } from 'react';\nimport { DSCheckbox } from '@elliemae/ds-form';\nimport styled from 'styled-components';\nimport TreeViewContext from '../TreeViewContext';\nimport { toggleCheckboxItem } from '../utils/selectable-helper';\nimport { filterObject } from '../utils/object-helpers';\nimport type { DSTreeviewT } from '../react-desc-prop-types';\nconst StyledCheckboxWrapper = styled.span`\n padding-top: 3px;\n`;\ninterface PropsT {\n item: DSTreeviewT.Item;\n itemIndex: number;\n}\nfunction CheckboxSelectable(props: PropsT): JSX.Element | null {\n const { item, itemIndex } = props;\n const { id } = item;\n\n const ctx = useContext(TreeViewContext);\n const {\n props: { onSelectionChange, isItemDisabled },\n virtualListHelpers: { scrollToIndex },\n triggerTreeRerender,\n selectedCheckboxes,\n setSelectedCheckboxes,\n } = ctx;\n\n const onCheckboxChange = useCallback(() => {\n const newSelections = toggleCheckboxItem(item);\n const newSelectionHasmap = filterObject<DSTreeviewT.SelectionState>(\n { ...selectedCheckboxes, ...newSelections },\n (value) => value !== false,\n );\n setSelectedCheckboxes(newSelectionHasmap);\n triggerTreeRerender();\n\n const indexAndScrollTo = {\n scrollToItem: () => {\n if (typeof item.virtualIndex === 'number') scrollToIndex(item.virtualIndex);\n },\n itemIndex,\n };\n if (onSelectionChange) onSelectionChange(newSelectionHasmap, item, indexAndScrollTo);\n }, [\n item,\n triggerTreeRerender,\n onSelectionChange,\n itemIndex,\n scrollToIndex,\n selectedCheckboxes,\n setSelectedCheckboxes,\n ]);\n const isChecked = useMemo(() => {\n if (selectedCheckboxes[id] === 'mixed') {\n return 'mixed' as const;\n }\n if (selectedCheckboxes[id] === true) {\n return true;\n }\n return false;\n }, [selectedCheckboxes, id]);\n\n const isDisabled = useMemo(() => isItemDisabled(item), [item, isItemDisabled]);\n\n return (\n <StyledCheckboxWrapper>\n <DSCheckbox\n checked={isChecked}\n disabled={isDisabled}\n className=\"em-ds-tree-item-checkbox\"\n data-testid=\"tree-item-checkbox\"\n onChange={onCheckboxChange}\n tabIndex=\"0\"\n />\n </StyledCheckboxWrapper>\n );\n}\n\nexport default CheckboxSelectable;\n"],
5
+ "mappings": "AAAA;ACAA;AACA;AACA;AACA;AACA;AACA;AAEA,MAAM,wBAAwB,OAAO;AAAA;AAAA;AAOrC,4BAA4B,OAAmC;AAC7D,QAAM,EAAE,MAAM,cAAc;AAC5B,QAAM,EAAE,OAAO;AAEf,QAAM,MAAM,WAAW;AACvB,QAAM;AAAA,IACJ,OAAO,EAAE,mBAAmB;AAAA,IAC5B,oBAAoB,EAAE;AAAA,IACtB;AAAA,IACA;AAAA,IACA;AAAA,MACE;AAEJ,QAAM,mBAAmB,YAAY,MAAM;AACzC,UAAM,gBAAgB,mBAAmB;AACzC,UAAM,qBAAqB,aACzB,KAAK,uBAAuB,iBAC5B,CAAC,UAAU,UAAU;AAEvB,0BAAsB;AACtB;AAEA,UAAM,mBAAmB;AAAA,MACvB,cAAc,MAAM;AAClB,YAAI,OAAO,KAAK,iBAAiB;AAAU,wBAAc,KAAK;AAAA;AAAA,MAEhE;AAAA;AAEF,QAAI;AAAmB,wBAAkB,oBAAoB,MAAM;AAAA,KAClE;AAAA,IACD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAEF,QAAM,YAAY,QAAQ,MAAM;AAC9B,QAAI,mBAAmB,QAAQ,SAAS;AACtC,aAAO;AAAA;AAET,QAAI,mBAAmB,QAAQ,MAAM;AACnC,aAAO;AAAA;AAET,WAAO;AAAA,KACN,CAAC,oBAAoB;AAExB,QAAM,aAAa,QAAQ,MAAM,eAAe,OAAO,CAAC,MAAM;AAE9D,SACE,qCAAC,uBAAD,MACE,qCAAC,YAAD;AAAA,IACE,SAAS;AAAA,IACT,UAAU;AAAA,IACV,WAAU;AAAA,IACV,eAAY;AAAA,IACZ,UAAU;AAAA,IACV,UAAS;AAAA;AAAA;AAMjB,IAAO,6BAAQ;",
6
+ "names": []
7
+ }
@@ -1,22 +1,18 @@
1
- import _jsx from '@babel/runtime/helpers/esm/jsx';
2
- import 'react';
3
- import { DSTreeViewPrefix, treeItemBlockName } from '../config/cssClassesConstants.js';
4
-
5
- const className = "".concat(DSTreeViewPrefix, "-").concat(treeItemBlockName, "-children-count-displayer");
6
- const ChildrenCountDisplayer = props => {
7
- const {
8
- item
9
- } = props;
10
- const {
11
- isGroup,
12
- children
13
- } = item;
14
- if (!isGroup) return null; // return ` | ${children.length} Items`;
15
-
16
- return /*#__PURE__*/_jsx("span", {
1
+ import * as React from "react";
2
+ import React2 from "react";
3
+ import { DSTreeViewPrefix, treeItemBlockName } from "../config/cssClassesConstants";
4
+ const className = `${DSTreeViewPrefix}-${treeItemBlockName}-children-count-displayer`;
5
+ const ChildrenCountDisplayer = (props) => {
6
+ const { item } = props;
7
+ const { isGroup, children } = item;
8
+ if (!isGroup)
9
+ return null;
10
+ return /* @__PURE__ */ React2.createElement("span", {
17
11
  "data-testid": "tree-item-children-count-displayer",
18
- className: className
19
- }, void 0, " | ".concat(children.length, " Items"));
12
+ className
13
+ }, ` | ${children.length} Items`);
20
14
  };
21
-
22
- export { ChildrenCountDisplayer };
15
+ export {
16
+ ChildrenCountDisplayer
17
+ };
18
+ //# sourceMappingURL=ChildrenCountDisplayer.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/parts/ChildrenCountDisplayer.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport { DSTreeViewPrefix, treeItemBlockName } from '../config/cssClassesConstants';\nimport type { DSTreeviewT } from '../react-desc-prop-types';\n\nconst className = `${DSTreeViewPrefix}-${treeItemBlockName}-children-count-displayer`;\n\ninterface PropsT {\n item: DSTreeviewT.Item;\n}\n\nexport const ChildrenCountDisplayer = (props: PropsT): JSX.Element | null => {\n const { item } = props;\n const { isGroup, children } = item;\n\n if (!isGroup) return null;\n // return ` | ${children.length} Items`;\n return (\n <span data-testid=\"tree-item-children-count-displayer\" className={className}>{` | ${children.length} Items`}</span>\n );\n};\n"],
5
+ "mappings": "AAAA;ACAA;AACA;AAGA,MAAM,YAAY,GAAG,oBAAoB;AAMlC,MAAM,yBAAyB,CAAC,UAAsC;AAC3E,QAAM,EAAE,SAAS;AACjB,QAAM,EAAE,SAAS,aAAa;AAE9B,MAAI,CAAC;AAAS,WAAO;AAErB,SACE,qCAAC,QAAD;AAAA,IAAM,eAAY;AAAA,IAAqC;AAAA,KAAuB,MAAM,SAAS;AAAA;",
6
+ "names": []
7
+ }