@elliemae/ds-treeview 2.2.0-alpha.5 → 2.2.0-beta.0

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 (178) hide show
  1. package/cjs/TreeView.js +31 -49
  2. package/cjs/TreeViewContext.js +35 -53
  3. package/cjs/config/cssClassesConstants.js +13 -41
  4. package/cjs/config/useTreeview.js +80 -108
  5. package/cjs/index.js +27 -37
  6. package/cjs/parts/CheckboxSelectable.js +59 -70
  7. package/cjs/parts/ChildrenCountDisplayer.js +28 -45
  8. package/cjs/parts/ExpandCaret.js +83 -85
  9. package/cjs/parts/Icon.js +31 -46
  10. package/cjs/parts/NestingSpace.js +35 -43
  11. package/cjs/parts/RadioSelectable.js +37 -52
  12. package/cjs/parts/TreeItem.js +147 -128
  13. package/cjs/parts/TreeItemText.js +95 -88
  14. package/cjs/parts/TreeList.js +130 -117
  15. package/cjs/plugins/dnd/TreeDndPlugin.js +36 -51
  16. package/cjs/plugins/dnd/index.js +10 -28
  17. package/cjs/plugins/index.js +22 -34
  18. package/cjs/plugins/roving/TreeRovingPlugin.js +7 -35
  19. package/cjs/plugins/roving/index.js +9 -28
  20. package/cjs/plugins/searchable/SearchableTreePlugin.js +7 -35
  21. package/cjs/plugins/searchable/index.js +9 -28
  22. package/cjs/plugins/selectable/SelectablePluginTree.js +7 -35
  23. package/cjs/plugins/selectable/index.js +9 -28
  24. package/cjs/plugins/toolbar/TreeToolbarPlugin.js +7 -35
  25. package/cjs/plugins/toolbar/index.js +9 -28
  26. package/cjs/plugins/tree/TreeDataPlugin.js +7 -35
  27. package/cjs/plugins/tree/index.js +9 -28
  28. package/cjs/plugins/virtualization/TreeVirtualizationPlugin.js +7 -35
  29. package/cjs/plugins/virtualization/index.js +9 -28
  30. package/cjs/react-desc-prop-types.js +53 -82
  31. package/cjs/related-components/TreeViewSearchBar.js +40 -42
  32. package/cjs/sharedTypes.js +2 -27
  33. package/cjs/utils/array-helpers.js +11 -35
  34. package/cjs/utils/dnd-helpers.js +84 -90
  35. package/cjs/utils/group-expands-helpers.js +59 -86
  36. package/cjs/utils/keyboard-helpers.js +88 -84
  37. package/cjs/utils/object-helpers.js +36 -43
  38. package/cjs/utils/refs-helpers.js +22 -43
  39. package/cjs/utils/selectable-helper.js +53 -61
  40. package/cjs/utils/string-helpers.js +7 -35
  41. package/cjs/utils/tree-helpers.js +135 -105
  42. package/cjs/utils/useDnDHelpers.js +118 -97
  43. package/cjs/utils/useInstanceRefActions.js +43 -54
  44. package/cjs/utils/useTree.js +78 -76
  45. package/esm/TreeView.js +20 -18
  46. package/esm/TreeViewContext.js +29 -24
  47. package/esm/config/cssClassesConstants.js +6 -12
  48. package/esm/config/useTreeview.js +54 -61
  49. package/esm/index.js +9 -8
  50. package/esm/parts/CheckboxSelectable.js +46 -36
  51. package/esm/parts/ChildrenCountDisplayer.js +20 -16
  52. package/esm/parts/ExpandCaret.js +72 -54
  53. package/esm/parts/Icon.js +22 -16
  54. package/esm/parts/NestingSpace.js +27 -14
  55. package/esm/parts/RadioSelectable.js +28 -20
  56. package/esm/parts/TreeItem.js +127 -91
  57. package/esm/parts/TreeItemText.js +85 -58
  58. package/esm/parts/TreeList.js +117 -88
  59. package/esm/plugins/dnd/TreeDndPlugin.js +26 -21
  60. package/esm/plugins/dnd/index.js +1 -3
  61. package/esm/plugins/index.js +7 -9
  62. package/esm/plugins/roving/TreeRovingPlugin.js +3 -6
  63. package/esm/plugins/roving/index.js +1 -3
  64. package/esm/plugins/searchable/SearchableTreePlugin.js +3 -6
  65. package/esm/plugins/searchable/index.js +1 -3
  66. package/esm/plugins/selectable/SelectablePluginTree.js +3 -6
  67. package/esm/plugins/selectable/index.js +1 -3
  68. package/esm/plugins/toolbar/TreeToolbarPlugin.js +3 -6
  69. package/esm/plugins/toolbar/index.js +1 -3
  70. package/esm/plugins/tree/TreeDataPlugin.js +3 -6
  71. package/esm/plugins/tree/index.js +1 -3
  72. package/esm/plugins/virtualization/TreeVirtualizationPlugin.js +3 -6
  73. package/esm/plugins/virtualization/index.js +1 -3
  74. package/esm/react-desc-prop-types.js +43 -47
  75. package/esm/related-components/TreeViewSearchBar.js +32 -13
  76. package/esm/sharedTypes.js +1 -2
  77. package/esm/utils/array-helpers.js +6 -6
  78. package/esm/utils/dnd-helpers.js +73 -58
  79. package/esm/utils/group-expands-helpers.js +46 -56
  80. package/esm/utils/keyboard-helpers.js +72 -45
  81. package/esm/utils/object-helpers.js +31 -14
  82. package/esm/utils/refs-helpers.js +19 -15
  83. package/esm/utils/selectable-helper.js +43 -32
  84. package/esm/utils/string-helpers.js +3 -6
  85. package/esm/utils/tree-helpers.js +119 -74
  86. package/esm/utils/useDnDHelpers.js +106 -60
  87. package/esm/utils/useInstanceRefActions.js +35 -21
  88. package/esm/utils/useTree.js +57 -35
  89. package/package.json +10 -10
  90. package/types/TreeView.d.ts +1 -1
  91. package/cjs/TreeView.js.map +0 -7
  92. package/cjs/TreeViewContext.js.map +0 -7
  93. package/cjs/config/cssClassesConstants.js.map +0 -7
  94. package/cjs/config/useTreeview.js.map +0 -7
  95. package/cjs/index.js.map +0 -7
  96. package/cjs/parts/CheckboxSelectable.js.map +0 -7
  97. package/cjs/parts/ChildrenCountDisplayer.js.map +0 -7
  98. package/cjs/parts/ExpandCaret.js.map +0 -7
  99. package/cjs/parts/Icon.js.map +0 -7
  100. package/cjs/parts/NestingSpace.js.map +0 -7
  101. package/cjs/parts/RadioSelectable.js.map +0 -7
  102. package/cjs/parts/TreeItem.js.map +0 -7
  103. package/cjs/parts/TreeItemText.js.map +0 -7
  104. package/cjs/parts/TreeList.js.map +0 -7
  105. package/cjs/plugins/dnd/TreeDndPlugin.js.map +0 -7
  106. package/cjs/plugins/dnd/index.js.map +0 -7
  107. package/cjs/plugins/index.js.map +0 -7
  108. package/cjs/plugins/roving/TreeRovingPlugin.js.map +0 -7
  109. package/cjs/plugins/roving/index.js.map +0 -7
  110. package/cjs/plugins/searchable/SearchableTreePlugin.js.map +0 -7
  111. package/cjs/plugins/searchable/index.js.map +0 -7
  112. package/cjs/plugins/selectable/SelectablePluginTree.js.map +0 -7
  113. package/cjs/plugins/selectable/index.js.map +0 -7
  114. package/cjs/plugins/toolbar/TreeToolbarPlugin.js.map +0 -7
  115. package/cjs/plugins/toolbar/index.js.map +0 -7
  116. package/cjs/plugins/tree/TreeDataPlugin.js.map +0 -7
  117. package/cjs/plugins/tree/index.js.map +0 -7
  118. package/cjs/plugins/virtualization/TreeVirtualizationPlugin.js.map +0 -7
  119. package/cjs/plugins/virtualization/index.js.map +0 -7
  120. package/cjs/react-desc-prop-types.js.map +0 -7
  121. package/cjs/related-components/TreeViewSearchBar.js.map +0 -7
  122. package/cjs/sharedTypes.js.map +0 -7
  123. package/cjs/utils/array-helpers.js.map +0 -7
  124. package/cjs/utils/dnd-helpers.js.map +0 -7
  125. package/cjs/utils/group-expands-helpers.js.map +0 -7
  126. package/cjs/utils/keyboard-helpers.js.map +0 -7
  127. package/cjs/utils/object-helpers.js.map +0 -7
  128. package/cjs/utils/refs-helpers.js.map +0 -7
  129. package/cjs/utils/selectable-helper.js.map +0 -7
  130. package/cjs/utils/string-helpers.js.map +0 -7
  131. package/cjs/utils/tree-helpers.js.map +0 -7
  132. package/cjs/utils/useDnDHelpers.js.map +0 -7
  133. package/cjs/utils/useInstanceRefActions.js.map +0 -7
  134. package/cjs/utils/useTree.js.map +0 -7
  135. package/esm/TreeView.js.map +0 -7
  136. package/esm/TreeViewContext.js.map +0 -7
  137. package/esm/config/cssClassesConstants.js.map +0 -7
  138. package/esm/config/useTreeview.js.map +0 -7
  139. package/esm/index.js.map +0 -7
  140. package/esm/parts/CheckboxSelectable.js.map +0 -7
  141. package/esm/parts/ChildrenCountDisplayer.js.map +0 -7
  142. package/esm/parts/ExpandCaret.js.map +0 -7
  143. package/esm/parts/Icon.js.map +0 -7
  144. package/esm/parts/NestingSpace.js.map +0 -7
  145. package/esm/parts/RadioSelectable.js.map +0 -7
  146. package/esm/parts/TreeItem.js.map +0 -7
  147. package/esm/parts/TreeItemText.js.map +0 -7
  148. package/esm/parts/TreeList.js.map +0 -7
  149. package/esm/plugins/dnd/TreeDndPlugin.js.map +0 -7
  150. package/esm/plugins/dnd/index.js.map +0 -7
  151. package/esm/plugins/index.js.map +0 -7
  152. package/esm/plugins/roving/TreeRovingPlugin.js.map +0 -7
  153. package/esm/plugins/roving/index.js.map +0 -7
  154. package/esm/plugins/searchable/SearchableTreePlugin.js.map +0 -7
  155. package/esm/plugins/searchable/index.js.map +0 -7
  156. package/esm/plugins/selectable/SelectablePluginTree.js.map +0 -7
  157. package/esm/plugins/selectable/index.js.map +0 -7
  158. package/esm/plugins/toolbar/TreeToolbarPlugin.js.map +0 -7
  159. package/esm/plugins/toolbar/index.js.map +0 -7
  160. package/esm/plugins/tree/TreeDataPlugin.js.map +0 -7
  161. package/esm/plugins/tree/index.js.map +0 -7
  162. package/esm/plugins/virtualization/TreeVirtualizationPlugin.js.map +0 -7
  163. package/esm/plugins/virtualization/index.js.map +0 -7
  164. package/esm/react-desc-prop-types.js.map +0 -7
  165. package/esm/related-components/TreeViewSearchBar.js.map +0 -7
  166. package/esm/sharedTypes.js.map +0 -7
  167. package/esm/utils/array-helpers.js.map +0 -7
  168. package/esm/utils/dnd-helpers.js.map +0 -7
  169. package/esm/utils/group-expands-helpers.js.map +0 -7
  170. package/esm/utils/keyboard-helpers.js.map +0 -7
  171. package/esm/utils/object-helpers.js.map +0 -7
  172. package/esm/utils/refs-helpers.js.map +0 -7
  173. package/esm/utils/selectable-helper.js.map +0 -7
  174. package/esm/utils/string-helpers.js.map +0 -7
  175. package/esm/utils/tree-helpers.js.map +0 -7
  176. package/esm/utils/useDnDHelpers.js.map +0 -7
  177. package/esm/utils/useInstanceRefActions.js.map +0 -7
  178. package/esm/utils/useTree.js.map +0 -7
package/esm/index.js CHANGED
@@ -1,8 +1,9 @@
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
1
+ export { TreeView, TreeViewWithSchema } from './TreeView.js';
2
+ export { TreeDnD, 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,58 +1,71 @@
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
- `;
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
+
11
22
  function CheckboxSelectable(props) {
12
- const { item, itemIndex } = props;
13
- const { id } = item;
23
+ const {
24
+ item,
25
+ itemIndex
26
+ } = props;
27
+ const {
28
+ id
29
+ } = item;
14
30
  const ctx = useContext(TreeViewContext);
15
31
  const {
16
- props: { onSelectionChange, isItemDisabled },
17
- virtualListHelpers: { scrollToIndex },
32
+ props: {
33
+ onSelectionChange,
34
+ isItemDisabled
35
+ },
36
+ virtualListHelpers: {
37
+ scrollToIndex
38
+ },
18
39
  triggerTreeRerender,
19
40
  selectedCheckboxes,
20
41
  setSelectedCheckboxes
21
42
  } = ctx;
22
43
  const onCheckboxChange = useCallback(() => {
23
44
  const newSelections = toggleCheckboxItem(item);
24
- const newSelectionHasmap = filterObject({ ...selectedCheckboxes, ...newSelections }, (value) => value !== false);
45
+ const newSelectionHasmap = filterObject(_objectSpread(_objectSpread({}, selectedCheckboxes), newSelections), value => value !== false);
25
46
  setSelectedCheckboxes(newSelectionHasmap);
26
47
  triggerTreeRerender();
27
48
  const indexAndScrollTo = {
28
49
  scrollToItem: () => {
29
- if (typeof item.virtualIndex === "number")
30
- scrollToIndex(item.virtualIndex);
50
+ if (typeof item.virtualIndex === 'number') scrollToIndex(item.virtualIndex);
31
51
  },
32
52
  itemIndex
33
53
  };
34
- if (onSelectionChange)
35
- onSelectionChange(newSelectionHasmap, item, indexAndScrollTo);
36
- }, [
37
- item,
38
- triggerTreeRerender,
39
- onSelectionChange,
40
- itemIndex,
41
- scrollToIndex,
42
- selectedCheckboxes,
43
- setSelectedCheckboxes
44
- ]);
54
+ if (onSelectionChange) onSelectionChange(newSelectionHasmap, item, indexAndScrollTo);
55
+ }, [item, triggerTreeRerender, onSelectionChange, itemIndex, scrollToIndex, selectedCheckboxes, setSelectedCheckboxes]);
45
56
  const isChecked = useMemo(() => {
46
- if (selectedCheckboxes[id] === "mixed") {
47
- return "mixed";
57
+ if (selectedCheckboxes[id] === 'mixed') {
58
+ return 'mixed';
48
59
  }
60
+
49
61
  if (selectedCheckboxes[id] === true) {
50
62
  return true;
51
63
  }
64
+
52
65
  return false;
53
66
  }, [selectedCheckboxes, id]);
54
67
  const isDisabled = useMemo(() => isItemDisabled(item), [item, isItemDisabled]);
55
- return /* @__PURE__ */ React2.createElement(StyledCheckboxWrapper, null, /* @__PURE__ */ React2.createElement(DSCheckbox, {
68
+ return /*#__PURE__*/_jsx(StyledCheckboxWrapper, {}, void 0, /*#__PURE__*/_jsx(DSCheckbox, {
56
69
  checked: isChecked,
57
70
  disabled: isDisabled,
58
71
  className: "em-ds-tree-item-checkbox",
@@ -61,8 +74,5 @@ function CheckboxSelectable(props) {
61
74
  tabIndex: "0"
62
75
  }));
63
76
  }
64
- var CheckboxSelectable_default = CheckboxSelectable;
65
- export {
66
- CheckboxSelectable_default as default
67
- };
68
- //# sourceMappingURL=CheckboxSelectable.js.map
77
+
78
+ export { CheckboxSelectable as default };
@@ -1,18 +1,22 @@
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", {
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", {
11
17
  "data-testid": "tree-item-children-count-displayer",
12
- className
13
- }, ` | ${children.length} Items`);
18
+ className: className
19
+ }, void 0, " | ".concat(children.length, " Items"));
14
20
  };
15
- export {
16
- ChildrenCountDisplayer
17
- };
18
- //# sourceMappingURL=ChildrenCountDisplayer.js.map
21
+
22
+ export { ChildrenCountDisplayer };
@@ -1,67 +1,85 @@
1
- import * as React from "react";
2
- import React2, { useContext, useCallback } from "react";
3
- import Button from "@elliemae/ds-button";
4
- import { ArrowheadDown, ArrowheadRight } from "@elliemae/ds-icons";
5
- import { toggleItemExpand } from "../utils/group-expands-helpers";
6
- import { focusItem } from "../utils/tree-helpers";
7
- import TreeViewContext from "../TreeViewContext";
8
- const ExpandCaret = (props) => {
1
+ import _jsx from '@babel/runtime/helpers/esm/jsx';
2
+ import { useCallback, useContext } from 'react';
3
+ import Button from '@elliemae/ds-button';
4
+ import { ArrowheadDown, ArrowheadRight } from '@elliemae/ds-icons';
5
+ import { toggleItemExpand } from '../utils/group-expands-helpers.js';
6
+ import { focusItem } from '../utils/tree-helpers.js';
7
+ import TreeViewContext from '../TreeViewContext.js';
8
+
9
+ var _ArrowheadDown, _ArrowheadRight;
10
+ const ExpandCaret = props => {
9
11
  const defaultHandleExpandGroup = useCallback(toggleItemExpand, []);
10
- const { item } = props;
11
- const { id, isExpanded, isGroup, children } = item;
12
+ const {
13
+ item
14
+ } = props;
15
+ const {
16
+ id,
17
+ isExpanded,
18
+ isGroup,
19
+ children
20
+ } = item;
12
21
  const isGroupOrHasChildrens = isGroup || Array.isArray(children) && children.length > 0;
13
22
  const ctx = useContext(TreeViewContext);
14
23
  const {
15
- props: { onItemFocus },
24
+ props: {
25
+ onItemFocus
26
+ },
16
27
  handleExpandGroup = defaultHandleExpandGroup,
17
28
  triggerTreeRerender,
18
29
  updateUserExpandedState,
19
30
  setLatestToggledItem,
20
31
  setFocusedItem,
21
- virtualListHelpers: { scrollToIndex }
32
+ virtualListHelpers: {
33
+ scrollToIndex
34
+ }
22
35
  } = ctx;
23
- if (isGroupOrHasChildrens)
24
- return /* @__PURE__ */ React2.createElement(Button, {
25
- buttonType: "text",
26
- className: "expandable-arrow",
27
- "data-testid": "tree-item-expand-toggle",
28
- key: `${id}-expand-addon`,
29
- icon: isExpanded ? /* @__PURE__ */ React2.createElement(ArrowheadDown, {
30
- size: "s",
31
- "data-testid": "ic-arrow-head-down"
32
- }) : /* @__PURE__ */ React2.createElement(ArrowheadRight, {
33
- size: "s",
34
- "data-testid": "ic-arrow-head-right"
35
- }),
36
- onMouseDown: (e) => {
37
- if (e) {
38
- e.preventDefault();
39
- }
40
- },
41
- onClick: (e) => {
42
- e.stopPropagation();
43
- if (e)
44
- handleExpandGroup(item, triggerTreeRerender, updateUserExpandedState, scrollToIndex, e);
45
- setLatestToggledItem(item);
46
- const itemVitualIndex = item.virtualIndex;
47
- if (typeof itemVitualIndex === "number") {
48
- onItemFocus({
49
- itemIndex: itemVitualIndex,
50
- scrollToItem: (opts = { align: "start" }) => scrollToIndex(itemVitualIndex, opts),
51
- item
52
- });
53
- }
54
- setFocusedItem(item);
55
- focusItem(item);
56
- },
36
+ if (isGroupOrHasChildrens) return /*#__PURE__*/_jsx(Button, {
37
+ buttonType: "text",
38
+ className: "expandable-arrow",
39
+ "data-testid": "tree-item-expand-toggle",
40
+ icon: isExpanded ? _ArrowheadDown || (_ArrowheadDown = /*#__PURE__*/_jsx(ArrowheadDown, {
57
41
  size: "s",
58
- tabIndex: -1
59
- });
60
- return /* @__PURE__ */ React2.createElement("div", {
61
- style: { width: "24px" }
42
+ "data-testid": "ic-arrow-head-down"
43
+ })) : _ArrowheadRight || (_ArrowheadRight = /*#__PURE__*/_jsx(ArrowheadRight, {
44
+ size: "s",
45
+ "data-testid": "ic-arrow-head-right"
46
+ })),
47
+ onMouseDown: e => {
48
+ // prevent focusing the caret
49
+ if (e) {
50
+ e.preventDefault();
51
+ }
52
+ },
53
+ onClick: e => {
54
+ e.stopPropagation();
55
+ if (e) handleExpandGroup(item, triggerTreeRerender, updateUserExpandedState, scrollToIndex, e);
56
+ setLatestToggledItem(item);
57
+ const itemVitualIndex = item.virtualIndex;
58
+
59
+ if (typeof itemVitualIndex === 'number') {
60
+ onItemFocus({
61
+ itemIndex: itemVitualIndex,
62
+ scrollToItem: function () {
63
+ let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
64
+ align: 'start'
65
+ };
66
+ return scrollToIndex(itemVitualIndex, opts);
67
+ },
68
+ item
69
+ });
70
+ }
71
+
72
+ setFocusedItem(item);
73
+ focusItem(item);
74
+ },
75
+ size: "s",
76
+ tabIndex: -1
77
+ }, "".concat(id, "-expand-addon"));
78
+ return /*#__PURE__*/_jsx("div", {
79
+ style: {
80
+ width: '24px'
81
+ }
62
82
  });
63
83
  };
64
- export {
65
- ExpandCaret
66
- };
67
- //# sourceMappingURL=ExpandCaret.js.map
84
+
85
+ export { ExpandCaret };
package/esm/parts/Icon.js CHANGED
@@ -1,23 +1,29 @@
1
- import * as React from "react";
2
- import React2, { useContext } from "react";
3
- import { cx } from "@elliemae/ds-utilities";
4
- import TreeViewContext from "../TreeViewContext";
5
- const Icon = (props) => {
6
- const { item } = props;
1
+ import React, { useContext } from 'react';
2
+ import { cx } from '@elliemae/ds-utilities';
3
+ import TreeViewContext from '../TreeViewContext.js';
4
+
5
+ const Icon = props => {
6
+ const {
7
+ item
8
+ } = props;
7
9
  const isGroupOrHasChildrens = item.isGroup || Array.isArray(item.children) && item.children.length > 0;
8
10
  const ctx = useContext(TreeViewContext);
9
11
  const {
10
- props: { groupIcon, itemIcon }
12
+ props: {
13
+ groupIcon,
14
+ itemIcon
15
+ }
11
16
  } = ctx;
12
17
  const icon = isGroupOrHasChildrens ? groupIcon : itemIcon;
13
- if (!icon)
14
- return null;
15
- return React2.cloneElement(icon, {
16
- "data-testid": isGroupOrHasChildrens ? "tree-item-group-icon" : "tree-item-icon",
17
- className: cx(icon.props.className, "tree-item-icon")
18
+ if (!icon) return null;
19
+ return /*#__PURE__*/React.cloneElement(icon, {
20
+ 'data-testid': isGroupOrHasChildrens ? 'tree-item-group-icon' : 'tree-item-icon',
21
+ // legacy class-name way of handling things,
22
+ // this will eventually be deprecated in favor of styled components
23
+ // untill then, just eslint-ignore and move on
24
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment
25
+ className: cx(icon.props.className, 'tree-item-icon')
18
26
  });
19
27
  };
20
- export {
21
- Icon
22
- };
23
- //# sourceMappingURL=Icon.js.map
28
+
29
+ export { Icon };
@@ -1,26 +1,39 @@
1
- import * as React from "react";
2
- import React2 from "react";
1
+ import _jsx from '@babel/runtime/helpers/esm/jsx';
2
+ import 'react';
3
+
3
4
  const getItemNestingLeftPadding = (level, opts) => {
4
- const { spaceForNestingLevel = 1.5 } = opts;
5
+ const {
6
+ spaceForNestingLevel = 1.5
7
+ } = opts;
5
8
  const groupLeftPadding = spaceForNestingLevel * (level - 1);
6
- const finalLeftPadding = groupLeftPadding + spaceForNestingLevel - 0.1;
7
- return finalLeftPadding > 0 ? `${finalLeftPadding}em` : "0";
9
+ const finalLeftPadding = groupLeftPadding + spaceForNestingLevel - 0.1; // root level left-padding would be negative and would not be applied
10
+ // if "root-level" nesting, then defaults to 0 left-padding.
11
+
12
+ return finalLeftPadding > 0 ? "".concat(finalLeftPadding, "em") : '0';
8
13
  };
9
- const NestingSpace = (props) => {
10
- const { item, spaceForNestingLevel } = props;
11
- const { treeDepth } = item;
14
+
15
+ const NestingSpace = props => {
16
+ const {
17
+ item,
18
+ spaceForNestingLevel
19
+ } = props;
20
+ const {
21
+ treeDepth
22
+ } = item;
23
+
12
24
  if (treeDepth) {
13
25
  const itemNestingLeftPadding = getItemNestingLeftPadding(treeDepth - 1, {
14
26
  spaceForNestingLevel
15
27
  });
16
- return /* @__PURE__ */ React2.createElement("div", {
28
+ return /*#__PURE__*/_jsx("div", {
17
29
  "data-testid": "tree-item-nested-space",
18
- style: { width: itemNestingLeftPadding }
30
+ style: {
31
+ width: itemNestingLeftPadding
32
+ }
19
33
  });
20
34
  }
35
+
21
36
  return null;
22
37
  };
23
- export {
24
- NestingSpace
25
- };
26
- //# sourceMappingURL=NestingSpace.js.map
38
+
39
+ export { NestingSpace };
@@ -1,34 +1,45 @@
1
- import * as React from "react";
2
- import React2, { useContext, useCallback, useMemo } from "react";
3
- import { DSRadio } from "@elliemae/ds-form";
4
- import TreeViewContext from "../TreeViewContext";
1
+ import _jsx from '@babel/runtime/helpers/esm/jsx';
2
+ import { useContext, useCallback, useMemo } from 'react';
3
+ import { DSRadio } from '@elliemae/ds-form';
4
+ import TreeViewContext from '../TreeViewContext.js';
5
+
5
6
  function RadioSelectable(props) {
6
- const { item, itemIndex } = props;
7
+ const {
8
+ item,
9
+ itemIndex
10
+ } = props;
7
11
  const ctx = useContext(TreeViewContext);
8
12
  const {
9
- props: { onSelectionChange, isItemDisabled },
10
- virtualListHelpers: { scrollToIndex },
13
+ props: {
14
+ onSelectionChange,
15
+ isItemDisabled
16
+ },
17
+ virtualListHelpers: {
18
+ scrollToIndex
19
+ },
11
20
  uniqueTreeViewUUID,
12
21
  selectedCheckboxes,
13
22
  setSelectedCheckboxes
14
23
  } = ctx;
15
- const { id } = item;
24
+ const {
25
+ id
26
+ } = item;
16
27
  const onRadioChange = useCallback(() => {
17
- const newSelectionHasmap = { [id]: true };
28
+ const newSelectionHasmap = {
29
+ [id]: true
30
+ };
18
31
  setSelectedCheckboxes(newSelectionHasmap);
19
32
  const indexAndScrollTo = {
20
33
  scrollToItem: () => {
21
- if (item.virtualIndex)
22
- scrollToIndex(item.virtualIndex);
34
+ if (item.virtualIndex) scrollToIndex(item.virtualIndex);
23
35
  },
24
36
  itemIndex
25
37
  };
26
- if (onSelectionChange)
27
- onSelectionChange(newSelectionHasmap, item, indexAndScrollTo);
38
+ if (onSelectionChange) onSelectionChange(newSelectionHasmap, item, indexAndScrollTo);
28
39
  }, [id, setSelectedCheckboxes, itemIndex, onSelectionChange, item, scrollToIndex]);
29
- const radioName = useMemo(() => `radios-${uniqueTreeViewUUID}`, [uniqueTreeViewUUID]);
40
+ const radioName = useMemo(() => "radios-".concat(uniqueTreeViewUUID), [uniqueTreeViewUUID]);
30
41
  const isDisabled = useMemo(() => isItemDisabled(item), [item, isItemDisabled]);
31
- return /* @__PURE__ */ React2.createElement(DSRadio, {
42
+ return /*#__PURE__*/_jsx(DSRadio, {
32
43
  checked: selectedCheckboxes[id] === true,
33
44
  name: radioName,
34
45
  disabled: isDisabled,
@@ -38,8 +49,5 @@ function RadioSelectable(props) {
38
49
  tabIndex: 0
39
50
  });
40
51
  }
41
- var RadioSelectable_default = RadioSelectable;
42
- export {
43
- RadioSelectable_default as default
44
- };
45
- //# sourceMappingURL=RadioSelectable.js.map
52
+
53
+ export { RadioSelectable as default };