@instructure/ui-tree-browser 8.25.1-snapshot-7 → 8.25.1-snapshot-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.
@@ -11,7 +11,7 @@ var _react = require("react");
11
11
 
12
12
  var _testable = require("@instructure/ui-testable/lib/testable.js");
13
13
 
14
- var _Img2 = require("@instructure/ui-img/lib/Img");
14
+ var _Img = require("@instructure/ui-img/lib/Img");
15
15
 
16
16
  var _callRenderProp = require("@instructure/ui-react-utils/lib/callRenderProp.js");
17
17
 
@@ -23,7 +23,7 @@ var _theme = _interopRequireDefault(require("./theme"));
23
23
 
24
24
  var _props = require("./props");
25
25
 
26
- var _dec, _dec2, _class, _class2;
26
+ var _dec, _dec2, _class;
27
27
 
28
28
  // Todo: merge TreeButton and TreeNode: TreeButton should be a special type of TreeNode
29
29
 
@@ -34,19 +34,20 @@ id: TreeBrowser.Button
34
34
  ---
35
35
  @tsProps
36
36
  **/
37
- let TreeButton = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec2 = (0, _testable.testable)(), _dec(_class = _dec2(_class = (_class2 = class TreeButton extends _react.Component {
38
- constructor() {
39
- super(...arguments);
40
- this.ref = null;
41
-
42
- this.handleRef = el => {
43
- if (el && typeof this.props.containerRef === 'function') {
44
- this.props.containerRef(el.parentElement);
45
- }
46
-
47
- this.ref = el;
48
- };
49
- }
37
+ let TreeButton = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec2 = (0, _testable.testable)(), _dec(_class = _dec2(_class = class TreeButton extends _react.Component {
38
+ static displayName = "TreeButton";
39
+ static componentId = 'TreeBrowser.Button';
40
+ static allowedProps = _props.allowedProps;
41
+ static propTypes = _props.propTypes;
42
+ static defaultProps = {
43
+ type: 'treeButton',
44
+ size: 'medium',
45
+ variant: 'folderTree',
46
+ selected: false,
47
+ focused: false,
48
+ expanded: false
49
+ };
50
+ ref = null;
50
51
 
51
52
  componentDidMount() {
52
53
  var _this$props$makeStyle, _this$props;
@@ -110,8 +111,6 @@ let TreeButton = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default
110
111
  }
111
112
 
112
113
  renderItemImage() {
113
- var _Img;
114
-
115
114
  const _this$props4 = this.props,
116
115
  thumbnail = _this$props4.thumbnail,
117
116
  itemIcon = _this$props4.itemIcon,
@@ -120,11 +119,11 @@ let TreeButton = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default
120
119
  if (thumbnail) {
121
120
  return (0, _emotion.jsx)("div", {
122
121
  css: styles === null || styles === void 0 ? void 0 : styles.thumbnail
123
- }, _Img || (_Img = (0, _emotion.jsx)(_Img2.Img, {
122
+ }, (0, _emotion.jsx)(_Img.Img, {
124
123
  src: thumbnail,
125
124
  constrain: "cover",
126
125
  alt: ""
127
- })));
126
+ }));
128
127
  }
129
128
 
130
129
  if (itemIcon) {
@@ -136,6 +135,14 @@ let TreeButton = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default
136
135
  return void 0;
137
136
  }
138
137
 
138
+ handleRef = el => {
139
+ if (el && typeof this.props.containerRef === 'function') {
140
+ this.props.containerRef(el.parentElement);
141
+ }
142
+
143
+ this.ref = el;
144
+ };
145
+
139
146
  render() {
140
147
  const _this$props5 = this.props,
141
148
  styles = _this$props5.styles,
@@ -150,14 +157,7 @@ let TreeButton = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default
150
157
  }, buttonContent);
151
158
  }
152
159
 
153
- }, _class2.displayName = "TreeButton", _class2.componentId = 'TreeBrowser.Button', _class2.allowedProps = _props.allowedProps, _class2.propTypes = _props.propTypes, _class2.defaultProps = {
154
- type: 'treeButton',
155
- size: 'medium',
156
- variant: 'folderTree',
157
- selected: false,
158
- focused: false,
159
- expanded: false
160
- }, _class2)) || _class) || _class);
160
+ }) || _class) || _class);
161
161
  exports.TreeButton = TreeButton;
162
162
  var _default = TreeButton;
163
163
  exports.default = _default;
@@ -25,7 +25,7 @@ var _theme = _interopRequireDefault(require("./theme"));
25
25
 
26
26
  var _props = require("./props");
27
27
 
28
- var _dec, _dec2, _class, _class2;
28
+ var _dec, _dec2, _class;
29
29
 
30
30
  /**
31
31
  ---
@@ -34,81 +34,93 @@ id: TreeBrowser.Collection
34
34
  ---
35
35
  @tsProps
36
36
  **/
37
- let TreeCollection = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec2 = (0, _testable.testable)(), _dec(_class = _dec2(_class = (_class2 = class TreeCollection extends _react.Component {
37
+ let TreeCollection = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec2 = (0, _testable.testable)(), _dec(_class = _dec2(_class = class TreeCollection extends _react.Component {
38
+ static displayName = "TreeCollection";
39
+ static componentId = 'TreeBrowser.Collection';
40
+ static allowedProps = _props.allowedProps;
41
+ static propTypes = _props.propTypes;
42
+ static defaultProps = {
43
+ collections: [],
44
+ items: [],
45
+ expanded: false,
46
+ selection: '',
47
+ size: 'medium',
48
+ variant: 'folderTree',
49
+ getItemProps: props => props,
50
+ getCollectionProps: props => props,
51
+ isCollectionFlattened: false
52
+ };
53
+ ref = null;
54
+
38
55
  constructor(props) {
39
56
  super(props);
40
- this.ref = null;
41
-
42
- this.handleFocus = (e, item) => {
43
- e.stopPropagation();
44
- this.setState({
45
- focused: `${item.type}_${item.id}`
46
- });
47
- };
48
-
49
- this.handleBlur = (e, _item) => {
50
- e.stopPropagation();
51
- this.setState({
52
- focused: ''
53
- });
54
- };
55
-
56
- this.handleCollectionClick = e => {
57
- const _this$props = this.props,
58
- id = _this$props.id,
59
- onCollectionClick = _this$props.onCollectionClick,
60
- expanded = _this$props.expanded;
61
- const collection = {
62
- id,
63
- expanded: !expanded,
64
- type: 'collection'
65
- };
66
-
67
- if (onCollectionClick && typeof onCollectionClick === 'function') {
68
- onCollectionClick(e, collection);
69
- }
70
- };
71
-
72
- this.handleCollectionKeyDown = e => {
73
- const _this$props2 = this.props,
74
- id = _this$props2.id,
75
- onKeyDown = _this$props2.onKeyDown,
76
- expanded = _this$props2.expanded;
77
- const collection = {
78
- id,
79
- expanded: !expanded,
80
- type: 'collection'
81
- };
82
-
83
- if (onKeyDown && typeof onKeyDown === 'function') {
84
- onKeyDown(e, collection);
85
- }
86
- };
87
-
88
57
  this.state = {
89
58
  focused: ''
90
59
  };
91
60
  }
92
61
 
93
62
  componentDidMount() {
94
- var _this$props$makeStyle, _this$props3;
63
+ var _this$props$makeStyle, _this$props;
95
64
 
96
- (_this$props$makeStyle = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props3);
65
+ (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
97
66
  }
98
67
 
99
68
  componentDidUpdate() {
100
- var _this$props$makeStyle2, _this$props4;
69
+ var _this$props$makeStyle2, _this$props2;
101
70
 
102
- (_this$props$makeStyle2 = (_this$props4 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props4);
71
+ (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
103
72
  }
104
73
 
105
74
  get itemsLevel() {
106
- const _this$props5 = this.props,
107
- level = _this$props5.level,
108
- isCollectionFlattened = _this$props5.isCollectionFlattened;
75
+ const _this$props3 = this.props,
76
+ level = _this$props3.level,
77
+ isCollectionFlattened = _this$props3.isCollectionFlattened;
109
78
  return isCollectionFlattened ? level : level + 1;
110
79
  }
111
80
 
81
+ handleFocus = (e, item) => {
82
+ e.stopPropagation();
83
+ this.setState({
84
+ focused: `${item.type}_${item.id}`
85
+ });
86
+ };
87
+ handleBlur = (e, _item) => {
88
+ e.stopPropagation();
89
+ this.setState({
90
+ focused: ''
91
+ });
92
+ };
93
+ handleCollectionClick = e => {
94
+ const _this$props4 = this.props,
95
+ id = _this$props4.id,
96
+ onCollectionClick = _this$props4.onCollectionClick,
97
+ expanded = _this$props4.expanded;
98
+ const collection = {
99
+ id,
100
+ expanded: !expanded,
101
+ type: 'collection'
102
+ };
103
+
104
+ if (onCollectionClick && typeof onCollectionClick === 'function') {
105
+ onCollectionClick(e, collection);
106
+ }
107
+ };
108
+ handleCollectionKeyDown = e => {
109
+ const _this$props5 = this.props,
110
+ id = _this$props5.id,
111
+ onKeyDown = _this$props5.onKeyDown,
112
+ expanded = _this$props5.expanded;
113
+ const collection = {
114
+ id,
115
+ expanded: !expanded,
116
+ type: 'collection'
117
+ };
118
+
119
+ if (onKeyDown && typeof onKeyDown === 'function') {
120
+ onKeyDown(e, collection);
121
+ }
122
+ };
123
+
112
124
  get collectionsCount() {
113
125
  const collections = this.props.collections;
114
126
  return collections && collections.length > 0 ? collections.length : 0;
@@ -350,17 +362,7 @@ let TreeCollection = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.def
350
362
  }, this.renderChildren()));
351
363
  }
352
364
 
353
- }, _class2.displayName = "TreeCollection", _class2.componentId = 'TreeBrowser.Collection', _class2.allowedProps = _props.allowedProps, _class2.propTypes = _props.propTypes, _class2.defaultProps = {
354
- collections: [],
355
- items: [],
356
- expanded: false,
357
- selection: '',
358
- size: 'medium',
359
- variant: 'folderTree',
360
- getItemProps: props => props,
361
- getCollectionProps: props => props,
362
- isCollectionFlattened: false
363
- }, _class2)) || _class) || _class);
365
+ }) || _class) || _class);
364
366
  exports.TreeCollection = TreeCollection;
365
367
  var _default = TreeCollection;
366
368
  exports.default = _default;
@@ -9,7 +9,7 @@ exports.default = exports.TreeNode = void 0;
9
9
 
10
10
  var _react = require("react");
11
11
 
12
- var _Img2 = require("@instructure/ui-img/lib/Img");
12
+ var _Img = require("@instructure/ui-img/lib/Img");
13
13
 
14
14
  var _callRenderProp = require("@instructure/ui-react-utils/lib/callRenderProp.js");
15
15
 
@@ -23,7 +23,7 @@ var _theme = _interopRequireDefault(require("../TreeButton/theme"));
23
23
 
24
24
  var _props = require("./props");
25
25
 
26
- var _dec, _dec2, _class, _class2;
26
+ var _dec, _dec2, _class;
27
27
 
28
28
  // Todo: merge TreeButton and TreeNode: TreeButton should be a special type of TreeNode
29
29
 
@@ -36,19 +36,18 @@ id: TreeBrowser.Node
36
36
  A helper class used to render the :renderBeforeItems and :renderAfterItems
37
37
  in the TreeBrowser.
38
38
  **/
39
- let TreeNode = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec2 = (0, _testable.testable)(), _dec(_class = _dec2(_class = (_class2 = class TreeNode extends _react.Component {
40
- constructor() {
41
- super(...arguments);
42
- this.ref = null;
43
-
44
- this.handleRef = el => {
45
- if (el && typeof this.props.containerRef === 'function') {
46
- this.props.containerRef(el.parentElement);
47
- }
48
-
49
- this.ref = el;
50
- };
51
- }
39
+ let TreeNode = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec2 = (0, _testable.testable)(), _dec(_class = _dec2(_class = class TreeNode extends _react.Component {
40
+ static displayName = "TreeNode";
41
+ static componentId = 'TreeBrowser.Node';
42
+ static allowedProps = _props.allowedProps;
43
+ static propTypes = _props.propTypes;
44
+ static defaultProps = {
45
+ size: 'medium',
46
+ variant: 'folderTree',
47
+ selected: false,
48
+ focused: false
49
+ };
50
+ ref = null;
52
51
 
53
52
  componentDidMount() {
54
53
  var _this$props$makeStyle, _this$props;
@@ -62,9 +61,15 @@ let TreeNode = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default),
62
61
  (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
63
62
  }
64
63
 
65
- renderItemImage() {
66
- var _Img;
64
+ handleRef = el => {
65
+ if (el && typeof this.props.containerRef === 'function') {
66
+ this.props.containerRef(el.parentElement);
67
+ }
67
68
 
69
+ this.ref = el;
70
+ };
71
+
72
+ renderItemImage() {
68
73
  const _this$props3 = this.props,
69
74
  thumbnail = _this$props3.thumbnail,
70
75
  itemIcon = _this$props3.itemIcon,
@@ -73,11 +78,11 @@ let TreeNode = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default),
73
78
  if (thumbnail) {
74
79
  return (0, _emotion.jsx)("div", {
75
80
  css: styles === null || styles === void 0 ? void 0 : styles.thumbnail
76
- }, _Img || (_Img = (0, _emotion.jsx)(_Img2.Img, {
81
+ }, (0, _emotion.jsx)(_Img.Img, {
77
82
  src: thumbnail,
78
83
  constrain: "cover",
79
84
  alt: ""
80
- })));
85
+ }));
81
86
  }
82
87
 
83
88
  if (itemIcon) {
@@ -104,12 +109,7 @@ let TreeNode = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default),
104
109
  }, children)));
105
110
  }
106
111
 
107
- }, _class2.displayName = "TreeNode", _class2.componentId = 'TreeBrowser.Node', _class2.allowedProps = _props.allowedProps, _class2.propTypes = _props.propTypes, _class2.defaultProps = {
108
- size: 'medium',
109
- variant: 'folderTree',
110
- selected: false,
111
- focused: false
112
- }, _class2)) || _class) || _class);
112
+ }) || _class) || _class);
113
113
  exports.TreeNode = TreeNode;
114
114
  var _default = TreeNode;
115
115
  exports.default = _default;
@@ -35,7 +35,7 @@ var _theme = _interopRequireDefault(require("./theme"));
35
35
 
36
36
  var _props = require("./props");
37
37
 
38
- var _dec, _dec2, _class, _class2;
38
+ var _dec, _dec2, _class;
39
39
 
40
40
  /**
41
41
  ---
@@ -43,74 +43,33 @@ category: components
43
43
  ---
44
44
  @tsProps
45
45
  **/
46
- let TreeBrowser = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec2 = (0, _testable.testable)(), _dec(_class = _dec2(_class = (_class2 = class TreeBrowser extends _react.Component {
47
- constructor(props) {
48
- var _this;
46
+ let TreeBrowser = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec2 = (0, _testable.testable)(), _dec(_class = _dec2(_class = class TreeBrowser extends _react.Component {
47
+ static displayName = "TreeBrowser";
48
+ static componentId = 'TreeBrowser';
49
+ static allowedProps = _props.allowedProps;
50
+ static propTypes = _props.propTypes;
51
+ static defaultProps = {
52
+ size: 'medium',
53
+ variant: 'folderTree',
54
+ showRootCollection: true,
55
+ collectionIcon: _IconFolderLine.IconFolderLine,
56
+ collectionIconExpanded: _IconFolderLine.IconFolderLine,
57
+ itemIcon: _IconDocumentLine.IconDocumentLine,
58
+ getItemProps: props => props,
59
+ getCollectionProps: props => props,
60
+ defaultExpanded: [],
61
+ selectionType: 'none',
62
+ sortOrder: function () {
63
+ return 0;
64
+ }
65
+ };
66
+ static Node = _TreeNode.TreeNode;
67
+ static Collection = _TreeCollection.TreeCollection;
68
+ static Button = _TreeButton.TreeButton;
69
+ ref = null;
49
70
 
71
+ constructor(props) {
50
72
  super(props);
51
- _this = this;
52
- this.ref = null;
53
-
54
- this.handleCollectionClick = function (e, collection) {
55
- let expand = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true;
56
- e.stopPropagation();
57
- const onCollectionClick = _this.props.onCollectionClick;
58
- if (expand) _this.expandOrCollapseNode(collection);
59
- onCollectionClick === null || onCollectionClick === void 0 ? void 0 : onCollectionClick(collection.id, collection); // TODO: this should pass the event as the first arg
60
-
61
- _this.handleSelection(collection.id, 'collection');
62
- };
63
-
64
- this.handleItemClick = (e, item) => {
65
- var _this$props$onItemCli, _this$props;
66
-
67
- e.stopPropagation();
68
- (_this$props$onItemCli = (_this$props = this.props).onItemClick) === null || _this$props$onItemCli === void 0 ? void 0 : _this$props$onItemCli.call(_this$props, item);
69
- this.handleSelection(item.id, 'item');
70
- };
71
-
72
- this.handleKeyDown = (event, node) => {
73
- event.stopPropagation();
74
-
75
- switch (event.keyCode) {
76
- case _keycode.default.codes.down:
77
- case _keycode.default.codes.j:
78
- this.moveFocus(1);
79
- break;
80
-
81
- case _keycode.default.codes.up:
82
- case _keycode.default.codes.k:
83
- this.moveFocus(-1);
84
- break;
85
-
86
- case _keycode.default.codes.home:
87
- case _keycode.default.codes.end:
88
- this.homeOrEnd(event.keyCode);
89
- break;
90
-
91
- case _keycode.default.codes.left:
92
- case _keycode.default.codes.right:
93
- this.handleLeftOrRightArrow(event.keyCode, node);
94
- break;
95
-
96
- case _keycode.default.codes.enter:
97
- case _keycode.default.codes.space:
98
- this.handleActivation(event, node);
99
- break;
100
-
101
- default:
102
- return;
103
- }
104
-
105
- event.preventDefault();
106
- };
107
-
108
- this.getIsFlattened = collection => {
109
- const _this$props2 = this.props,
110
- rootId = _this$props2.rootId,
111
- showRootCollection = _this$props2.showRootCollection;
112
- return !showRootCollection && typeof rootId !== 'undefined' && collection.id === rootId;
113
- };
114
73
 
115
74
  if (typeof this.props.expanded === 'undefined') {
116
75
  this.state = {
@@ -125,25 +84,81 @@ let TreeBrowser = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.defaul
125
84
  }
126
85
 
127
86
  componentDidMount() {
128
- var _this$props$makeStyle, _this$props3;
87
+ var _this$props$makeStyle, _this$props;
129
88
 
130
- (_this$props$makeStyle = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props3);
89
+ (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
131
90
  }
132
91
 
133
92
  componentDidUpdate() {
134
- var _this$props$makeStyle2, _this$props4;
93
+ var _this$props$makeStyle2, _this$props2;
135
94
 
136
- (_this$props$makeStyle2 = (_this$props4 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props4);
95
+ (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
137
96
  }
138
97
 
139
98
  get _root() {
140
99
  return this.ref;
141
100
  }
142
101
 
102
+ handleCollectionClick = (() => {
103
+ var _this = this;
104
+
105
+ return function (e, collection) {
106
+ let expand = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true;
107
+ e.stopPropagation();
108
+ const onCollectionClick = _this.props.onCollectionClick;
109
+ if (expand) _this.expandOrCollapseNode(collection);
110
+ onCollectionClick === null || onCollectionClick === void 0 ? void 0 : onCollectionClick(collection.id, collection); // TODO: this should pass the event as the first arg
111
+
112
+ _this.handleSelection(collection.id, 'collection');
113
+ };
114
+ })();
115
+ handleItemClick = (e, item) => {
116
+ var _this$props$onItemCli, _this$props3;
117
+
118
+ e.stopPropagation();
119
+ (_this$props$onItemCli = (_this$props3 = this.props).onItemClick) === null || _this$props$onItemCli === void 0 ? void 0 : _this$props$onItemCli.call(_this$props3, item);
120
+ this.handleSelection(item.id, 'item');
121
+ };
122
+ handleKeyDown = (event, node) => {
123
+ event.stopPropagation();
124
+
125
+ switch (event.keyCode) {
126
+ case _keycode.default.codes.down:
127
+ case _keycode.default.codes.j:
128
+ this.moveFocus(1);
129
+ break;
130
+
131
+ case _keycode.default.codes.up:
132
+ case _keycode.default.codes.k:
133
+ this.moveFocus(-1);
134
+ break;
135
+
136
+ case _keycode.default.codes.home:
137
+ case _keycode.default.codes.end:
138
+ this.homeOrEnd(event.keyCode);
139
+ break;
140
+
141
+ case _keycode.default.codes.left:
142
+ case _keycode.default.codes.right:
143
+ this.handleLeftOrRightArrow(event.keyCode, node);
144
+ break;
145
+
146
+ case _keycode.default.codes.enter:
147
+ case _keycode.default.codes.space:
148
+ this.handleActivation(event, node);
149
+ break;
150
+
151
+ default:
152
+ return;
153
+ }
154
+
155
+ event.preventDefault();
156
+ };
157
+
143
158
  get collections() {
144
- const _this$props5 = this.props,
145
- collections = _this$props5.collections,
146
- rootId = _this$props5.rootId;
159
+ const _this$props4 = this.props,
160
+ collections = _this$props4.collections,
161
+ rootId = _this$props4.rootId;
147
162
 
148
163
  if (typeof rootId !== 'undefined') {
149
164
  return [collections[rootId]];
@@ -161,9 +176,9 @@ let TreeBrowser = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.defaul
161
176
  }
162
177
 
163
178
  expandOrCollapseNode(collection) {
164
- var _this$props$onCollect, _this$props6;
179
+ var _this$props$onCollect, _this$props5;
165
180
 
166
- (_this$props$onCollect = (_this$props6 = this.props).onCollectionToggle) === null || _this$props$onCollect === void 0 ? void 0 : _this$props$onCollect.call(_this$props6, collection);
181
+ (_this$props$onCollect = (_this$props5 = this.props).onCollectionToggle) === null || _this$props$onCollect === void 0 ? void 0 : _this$props$onCollect.call(_this$props5, collection);
167
182
 
168
183
  if (typeof this.props.expanded === 'undefined') {
169
184
  this.setState((state, props) => {
@@ -284,6 +299,13 @@ let TreeBrowser = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.defaul
284
299
  }
285
300
  }
286
301
 
302
+ getIsFlattened = collection => {
303
+ const _this$props6 = this.props,
304
+ rootId = _this$props6.rootId,
305
+ showRootCollection = _this$props6.showRootCollection;
306
+ return !showRootCollection && typeof rootId !== 'undefined' && collection.id === rootId;
307
+ };
308
+
287
309
  getCollectionProps(collection) {
288
310
  return {
289
311
  id: collection.id,
@@ -333,21 +355,7 @@ let TreeBrowser = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.defaul
333
355
  }, this.renderRoot());
334
356
  }
335
357
 
336
- }, _class2.displayName = "TreeBrowser", _class2.componentId = 'TreeBrowser', _class2.allowedProps = _props.allowedProps, _class2.propTypes = _props.propTypes, _class2.defaultProps = {
337
- size: 'medium',
338
- variant: 'folderTree',
339
- showRootCollection: true,
340
- collectionIcon: _IconFolderLine.IconFolderLine,
341
- collectionIconExpanded: _IconFolderLine.IconFolderLine,
342
- itemIcon: _IconDocumentLine.IconDocumentLine,
343
- getItemProps: props => props,
344
- getCollectionProps: props => props,
345
- defaultExpanded: [],
346
- selectionType: 'none',
347
- sortOrder: function () {
348
- return 0;
349
- }
350
- }, _class2.Node = _TreeNode.TreeNode, _class2.Collection = _TreeCollection.TreeCollection, _class2.Button = _TreeButton.TreeButton, _class2)) || _class) || _class);
358
+ }) || _class) || _class);
351
359
  exports.TreeBrowser = TreeBrowser;
352
360
  var _default = TreeBrowser;
353
361
  exports.default = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-tree-browser",
3
- "version": "8.25.1-snapshot-7",
3
+ "version": "8.25.1-snapshot-10",
4
4
  "description": "A component for displaying a hierarchical view of information",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "module": "./es/index.js",
@@ -23,22 +23,22 @@
23
23
  },
24
24
  "license": "MIT",
25
25
  "devDependencies": {
26
- "@instructure/ui-babel-preset": "8.25.1-snapshot-7",
27
- "@instructure/ui-color-utils": "8.25.1-snapshot-7",
28
- "@instructure/ui-test-locator": "8.25.1-snapshot-7",
29
- "@instructure/ui-test-utils": "8.25.1-snapshot-7",
30
- "@instructure/ui-themes": "8.25.1-snapshot-7"
26
+ "@instructure/ui-babel-preset": "8.25.1-snapshot-10",
27
+ "@instructure/ui-color-utils": "8.25.1-snapshot-10",
28
+ "@instructure/ui-test-locator": "8.25.1-snapshot-10",
29
+ "@instructure/ui-test-utils": "8.25.1-snapshot-10",
30
+ "@instructure/ui-themes": "8.25.1-snapshot-10"
31
31
  },
32
32
  "dependencies": {
33
33
  "@babel/runtime": "^7.13.10",
34
- "@instructure/emotion": "8.25.1-snapshot-7",
35
- "@instructure/shared-types": "8.25.1-snapshot-7",
36
- "@instructure/ui-icons": "8.25.1-snapshot-7",
37
- "@instructure/ui-img": "8.25.1-snapshot-7",
38
- "@instructure/ui-prop-types": "8.25.1-snapshot-7",
39
- "@instructure/ui-react-utils": "8.25.1-snapshot-7",
40
- "@instructure/ui-testable": "8.25.1-snapshot-7",
41
- "@instructure/ui-utils": "8.25.1-snapshot-7",
34
+ "@instructure/emotion": "8.25.1-snapshot-10",
35
+ "@instructure/shared-types": "8.25.1-snapshot-10",
36
+ "@instructure/ui-icons": "8.25.1-snapshot-10",
37
+ "@instructure/ui-img": "8.25.1-snapshot-10",
38
+ "@instructure/ui-prop-types": "8.25.1-snapshot-10",
39
+ "@instructure/ui-react-utils": "8.25.1-snapshot-10",
40
+ "@instructure/ui-testable": "8.25.1-snapshot-10",
41
+ "@instructure/ui-utils": "8.25.1-snapshot-10",
42
42
  "keycode": "^2",
43
43
  "prop-types": "^15"
44
44
  },