@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.
- package/CHANGELOG.md +1 -1
- package/es/TreeBrowser/TreeButton/index.js +26 -26
- package/es/TreeBrowser/TreeCollection/index.js +70 -68
- package/es/TreeBrowser/TreeNode/index.js +24 -24
- package/es/TreeBrowser/index.js +99 -91
- package/lib/TreeBrowser/TreeButton/index.js +27 -27
- package/lib/TreeBrowser/TreeCollection/index.js +70 -68
- package/lib/TreeBrowser/TreeNode/index.js +25 -25
- package/lib/TreeBrowser/index.js +99 -91
- package/package.json +14 -14
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/TreeBrowser/TreeBrowserLocator.d.ts +14 -14
- package/types/TreeBrowser/index.d.ts +1 -1
- package/types/TreeBrowser/index.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## [8.25.1-snapshot-
|
|
6
|
+
## [8.25.1-snapshot-10](https://github.com/instructure/instructure-ui/compare/v8.25.0...v8.25.1-snapshot-10) (2022-06-20)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @instructure/ui-tree-browser
|
|
9
9
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _dec, _dec2, _class
|
|
1
|
+
var _dec, _dec2, _class;
|
|
2
2
|
|
|
3
3
|
/*
|
|
4
4
|
* The MIT License (MIT)
|
|
@@ -42,19 +42,20 @@ id: TreeBrowser.Button
|
|
|
42
42
|
@tsProps
|
|
43
43
|
**/
|
|
44
44
|
|
|
45
|
-
let TreeButton = (_dec = withStyle(generateStyles, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class =
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
45
|
+
let TreeButton = (_dec = withStyle(generateStyles, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = class TreeButton extends Component {
|
|
46
|
+
static displayName = "TreeButton";
|
|
47
|
+
static componentId = 'TreeBrowser.Button';
|
|
48
|
+
static allowedProps = allowedProps;
|
|
49
|
+
static propTypes = propTypes;
|
|
50
|
+
static defaultProps = {
|
|
51
|
+
type: 'treeButton',
|
|
52
|
+
size: 'medium',
|
|
53
|
+
variant: 'folderTree',
|
|
54
|
+
selected: false,
|
|
55
|
+
focused: false,
|
|
56
|
+
expanded: false
|
|
57
|
+
};
|
|
58
|
+
ref = null;
|
|
58
59
|
|
|
59
60
|
componentDidMount() {
|
|
60
61
|
var _this$props$makeStyle, _this$props;
|
|
@@ -118,8 +119,6 @@ let TreeButton = (_dec = withStyle(generateStyles, generateComponentTheme), _dec
|
|
|
118
119
|
}
|
|
119
120
|
|
|
120
121
|
renderItemImage() {
|
|
121
|
-
var _Img;
|
|
122
|
-
|
|
123
122
|
const _this$props4 = this.props,
|
|
124
123
|
thumbnail = _this$props4.thumbnail,
|
|
125
124
|
itemIcon = _this$props4.itemIcon,
|
|
@@ -128,11 +127,11 @@ let TreeButton = (_dec = withStyle(generateStyles, generateComponentTheme), _dec
|
|
|
128
127
|
if (thumbnail) {
|
|
129
128
|
return jsx("div", {
|
|
130
129
|
css: styles === null || styles === void 0 ? void 0 : styles.thumbnail
|
|
131
|
-
},
|
|
130
|
+
}, jsx(Img, {
|
|
132
131
|
src: thumbnail,
|
|
133
132
|
constrain: "cover",
|
|
134
133
|
alt: ""
|
|
135
|
-
}))
|
|
134
|
+
}));
|
|
136
135
|
}
|
|
137
136
|
|
|
138
137
|
if (itemIcon) {
|
|
@@ -144,6 +143,14 @@ let TreeButton = (_dec = withStyle(generateStyles, generateComponentTheme), _dec
|
|
|
144
143
|
return void 0;
|
|
145
144
|
}
|
|
146
145
|
|
|
146
|
+
handleRef = el => {
|
|
147
|
+
if (el && typeof this.props.containerRef === 'function') {
|
|
148
|
+
this.props.containerRef(el.parentElement);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
this.ref = el;
|
|
152
|
+
};
|
|
153
|
+
|
|
147
154
|
render() {
|
|
148
155
|
const _this$props5 = this.props,
|
|
149
156
|
styles = _this$props5.styles,
|
|
@@ -158,13 +165,6 @@ let TreeButton = (_dec = withStyle(generateStyles, generateComponentTheme), _dec
|
|
|
158
165
|
}, buttonContent);
|
|
159
166
|
}
|
|
160
167
|
|
|
161
|
-
}
|
|
162
|
-
type: 'treeButton',
|
|
163
|
-
size: 'medium',
|
|
164
|
-
variant: 'folderTree',
|
|
165
|
-
selected: false,
|
|
166
|
-
focused: false,
|
|
167
|
-
expanded: false
|
|
168
|
-
}, _class2)) || _class) || _class);
|
|
168
|
+
}) || _class) || _class);
|
|
169
169
|
export default TreeButton;
|
|
170
170
|
export { TreeButton };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _dec, _dec2, _class
|
|
1
|
+
var _dec, _dec2, _class;
|
|
2
2
|
|
|
3
3
|
/*
|
|
4
4
|
* The MIT License (MIT)
|
|
@@ -44,81 +44,93 @@ id: TreeBrowser.Collection
|
|
|
44
44
|
---
|
|
45
45
|
@tsProps
|
|
46
46
|
**/
|
|
47
|
-
let TreeCollection = (_dec = withStyle(generateStyles, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class =
|
|
47
|
+
let TreeCollection = (_dec = withStyle(generateStyles, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = class TreeCollection extends Component {
|
|
48
|
+
static displayName = "TreeCollection";
|
|
49
|
+
static componentId = 'TreeBrowser.Collection';
|
|
50
|
+
static allowedProps = allowedProps;
|
|
51
|
+
static propTypes = propTypes;
|
|
52
|
+
static defaultProps = {
|
|
53
|
+
collections: [],
|
|
54
|
+
items: [],
|
|
55
|
+
expanded: false,
|
|
56
|
+
selection: '',
|
|
57
|
+
size: 'medium',
|
|
58
|
+
variant: 'folderTree',
|
|
59
|
+
getItemProps: props => props,
|
|
60
|
+
getCollectionProps: props => props,
|
|
61
|
+
isCollectionFlattened: false
|
|
62
|
+
};
|
|
63
|
+
ref = null;
|
|
64
|
+
|
|
48
65
|
constructor(props) {
|
|
49
66
|
super(props);
|
|
50
|
-
this.ref = null;
|
|
51
|
-
|
|
52
|
-
this.handleFocus = (e, item) => {
|
|
53
|
-
e.stopPropagation();
|
|
54
|
-
this.setState({
|
|
55
|
-
focused: `${item.type}_${item.id}`
|
|
56
|
-
});
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
this.handleBlur = (e, _item) => {
|
|
60
|
-
e.stopPropagation();
|
|
61
|
-
this.setState({
|
|
62
|
-
focused: ''
|
|
63
|
-
});
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
this.handleCollectionClick = e => {
|
|
67
|
-
const _this$props = this.props,
|
|
68
|
-
id = _this$props.id,
|
|
69
|
-
onCollectionClick = _this$props.onCollectionClick,
|
|
70
|
-
expanded = _this$props.expanded;
|
|
71
|
-
const collection = {
|
|
72
|
-
id,
|
|
73
|
-
expanded: !expanded,
|
|
74
|
-
type: 'collection'
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
if (onCollectionClick && typeof onCollectionClick === 'function') {
|
|
78
|
-
onCollectionClick(e, collection);
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
this.handleCollectionKeyDown = e => {
|
|
83
|
-
const _this$props2 = this.props,
|
|
84
|
-
id = _this$props2.id,
|
|
85
|
-
onKeyDown = _this$props2.onKeyDown,
|
|
86
|
-
expanded = _this$props2.expanded;
|
|
87
|
-
const collection = {
|
|
88
|
-
id,
|
|
89
|
-
expanded: !expanded,
|
|
90
|
-
type: 'collection'
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
if (onKeyDown && typeof onKeyDown === 'function') {
|
|
94
|
-
onKeyDown(e, collection);
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
|
|
98
67
|
this.state = {
|
|
99
68
|
focused: ''
|
|
100
69
|
};
|
|
101
70
|
}
|
|
102
71
|
|
|
103
72
|
componentDidMount() {
|
|
104
|
-
var _this$props$makeStyle, _this$
|
|
73
|
+
var _this$props$makeStyle, _this$props;
|
|
105
74
|
|
|
106
|
-
(_this$props$makeStyle = (_this$
|
|
75
|
+
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
107
76
|
}
|
|
108
77
|
|
|
109
78
|
componentDidUpdate() {
|
|
110
|
-
var _this$props$makeStyle2, _this$
|
|
79
|
+
var _this$props$makeStyle2, _this$props2;
|
|
111
80
|
|
|
112
|
-
(_this$props$makeStyle2 = (_this$
|
|
81
|
+
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
113
82
|
}
|
|
114
83
|
|
|
115
84
|
get itemsLevel() {
|
|
116
|
-
const _this$
|
|
117
|
-
level = _this$
|
|
118
|
-
isCollectionFlattened = _this$
|
|
85
|
+
const _this$props3 = this.props,
|
|
86
|
+
level = _this$props3.level,
|
|
87
|
+
isCollectionFlattened = _this$props3.isCollectionFlattened;
|
|
119
88
|
return isCollectionFlattened ? level : level + 1;
|
|
120
89
|
}
|
|
121
90
|
|
|
91
|
+
handleFocus = (e, item) => {
|
|
92
|
+
e.stopPropagation();
|
|
93
|
+
this.setState({
|
|
94
|
+
focused: `${item.type}_${item.id}`
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
handleBlur = (e, _item) => {
|
|
98
|
+
e.stopPropagation();
|
|
99
|
+
this.setState({
|
|
100
|
+
focused: ''
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
handleCollectionClick = e => {
|
|
104
|
+
const _this$props4 = this.props,
|
|
105
|
+
id = _this$props4.id,
|
|
106
|
+
onCollectionClick = _this$props4.onCollectionClick,
|
|
107
|
+
expanded = _this$props4.expanded;
|
|
108
|
+
const collection = {
|
|
109
|
+
id,
|
|
110
|
+
expanded: !expanded,
|
|
111
|
+
type: 'collection'
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
if (onCollectionClick && typeof onCollectionClick === 'function') {
|
|
115
|
+
onCollectionClick(e, collection);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
handleCollectionKeyDown = e => {
|
|
119
|
+
const _this$props5 = this.props,
|
|
120
|
+
id = _this$props5.id,
|
|
121
|
+
onKeyDown = _this$props5.onKeyDown,
|
|
122
|
+
expanded = _this$props5.expanded;
|
|
123
|
+
const collection = {
|
|
124
|
+
id,
|
|
125
|
+
expanded: !expanded,
|
|
126
|
+
type: 'collection'
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
if (onKeyDown && typeof onKeyDown === 'function') {
|
|
130
|
+
onKeyDown(e, collection);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
|
|
122
134
|
get collectionsCount() {
|
|
123
135
|
const collections = this.props.collections;
|
|
124
136
|
return collections && collections.length > 0 ? collections.length : 0;
|
|
@@ -360,16 +372,6 @@ let TreeCollection = (_dec = withStyle(generateStyles, generateComponentTheme),
|
|
|
360
372
|
}, this.renderChildren()));
|
|
361
373
|
}
|
|
362
374
|
|
|
363
|
-
}
|
|
364
|
-
collections: [],
|
|
365
|
-
items: [],
|
|
366
|
-
expanded: false,
|
|
367
|
-
selection: '',
|
|
368
|
-
size: 'medium',
|
|
369
|
-
variant: 'folderTree',
|
|
370
|
-
getItemProps: props => props,
|
|
371
|
-
getCollectionProps: props => props,
|
|
372
|
-
isCollectionFlattened: false
|
|
373
|
-
}, _class2)) || _class) || _class);
|
|
375
|
+
}) || _class) || _class);
|
|
374
376
|
export default TreeCollection;
|
|
375
377
|
export { TreeCollection };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _dec, _dec2, _class
|
|
1
|
+
var _dec, _dec2, _class;
|
|
2
2
|
|
|
3
3
|
/*
|
|
4
4
|
* The MIT License (MIT)
|
|
@@ -45,19 +45,18 @@ A helper class used to render the :renderBeforeItems and :renderAfterItems
|
|
|
45
45
|
in the TreeBrowser.
|
|
46
46
|
**/
|
|
47
47
|
|
|
48
|
-
let TreeNode = (_dec = withStyle(generateStyles, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class =
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
48
|
+
let TreeNode = (_dec = withStyle(generateStyles, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = class TreeNode extends Component {
|
|
49
|
+
static displayName = "TreeNode";
|
|
50
|
+
static componentId = 'TreeBrowser.Node';
|
|
51
|
+
static allowedProps = allowedProps;
|
|
52
|
+
static propTypes = propTypes;
|
|
53
|
+
static defaultProps = {
|
|
54
|
+
size: 'medium',
|
|
55
|
+
variant: 'folderTree',
|
|
56
|
+
selected: false,
|
|
57
|
+
focused: false
|
|
58
|
+
};
|
|
59
|
+
ref = null;
|
|
61
60
|
|
|
62
61
|
componentDidMount() {
|
|
63
62
|
var _this$props$makeStyle, _this$props;
|
|
@@ -71,9 +70,15 @@ let TreeNode = (_dec = withStyle(generateStyles, generateComponentTheme), _dec2
|
|
|
71
70
|
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
72
71
|
}
|
|
73
72
|
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
handleRef = el => {
|
|
74
|
+
if (el && typeof this.props.containerRef === 'function') {
|
|
75
|
+
this.props.containerRef(el.parentElement);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
this.ref = el;
|
|
79
|
+
};
|
|
76
80
|
|
|
81
|
+
renderItemImage() {
|
|
77
82
|
const _this$props3 = this.props,
|
|
78
83
|
thumbnail = _this$props3.thumbnail,
|
|
79
84
|
itemIcon = _this$props3.itemIcon,
|
|
@@ -82,11 +87,11 @@ let TreeNode = (_dec = withStyle(generateStyles, generateComponentTheme), _dec2
|
|
|
82
87
|
if (thumbnail) {
|
|
83
88
|
return jsx("div", {
|
|
84
89
|
css: styles === null || styles === void 0 ? void 0 : styles.thumbnail
|
|
85
|
-
},
|
|
90
|
+
}, jsx(Img, {
|
|
86
91
|
src: thumbnail,
|
|
87
92
|
constrain: "cover",
|
|
88
93
|
alt: ""
|
|
89
|
-
}))
|
|
94
|
+
}));
|
|
90
95
|
}
|
|
91
96
|
|
|
92
97
|
if (itemIcon) {
|
|
@@ -113,11 +118,6 @@ let TreeNode = (_dec = withStyle(generateStyles, generateComponentTheme), _dec2
|
|
|
113
118
|
}, children)));
|
|
114
119
|
}
|
|
115
120
|
|
|
116
|
-
}
|
|
117
|
-
size: 'medium',
|
|
118
|
-
variant: 'folderTree',
|
|
119
|
-
selected: false,
|
|
120
|
-
focused: false
|
|
121
|
-
}, _class2)) || _class) || _class);
|
|
121
|
+
}) || _class) || _class);
|
|
122
122
|
export default TreeNode;
|
|
123
123
|
export { TreeNode };
|
package/es/TreeBrowser/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _dec, _dec2, _class
|
|
1
|
+
var _dec, _dec2, _class;
|
|
2
2
|
|
|
3
3
|
/*
|
|
4
4
|
* The MIT License (MIT)
|
|
@@ -44,74 +44,33 @@ category: components
|
|
|
44
44
|
@tsProps
|
|
45
45
|
**/
|
|
46
46
|
|
|
47
|
-
let TreeBrowser = (_dec = withStyle(generateStyles, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class =
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
let TreeBrowser = (_dec = withStyle(generateStyles, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = class TreeBrowser extends Component {
|
|
48
|
+
static displayName = "TreeBrowser";
|
|
49
|
+
static componentId = 'TreeBrowser';
|
|
50
|
+
static allowedProps = allowedProps;
|
|
51
|
+
static propTypes = propTypes;
|
|
52
|
+
static defaultProps = {
|
|
53
|
+
size: 'medium',
|
|
54
|
+
variant: 'folderTree',
|
|
55
|
+
showRootCollection: true,
|
|
56
|
+
collectionIcon: IconFolderLine,
|
|
57
|
+
collectionIconExpanded: IconFolderLine,
|
|
58
|
+
itemIcon: IconDocumentLine,
|
|
59
|
+
getItemProps: props => props,
|
|
60
|
+
getCollectionProps: props => props,
|
|
61
|
+
defaultExpanded: [],
|
|
62
|
+
selectionType: 'none',
|
|
63
|
+
sortOrder: function () {
|
|
64
|
+
return 0;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
static Node = TreeNode;
|
|
68
|
+
static Collection = TreeCollection;
|
|
69
|
+
static Button = TreeButton;
|
|
70
|
+
ref = null;
|
|
50
71
|
|
|
72
|
+
constructor(props) {
|
|
51
73
|
super(props);
|
|
52
|
-
_this = this;
|
|
53
|
-
this.ref = null;
|
|
54
|
-
|
|
55
|
-
this.handleCollectionClick = function (e, collection) {
|
|
56
|
-
let expand = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true;
|
|
57
|
-
e.stopPropagation();
|
|
58
|
-
const onCollectionClick = _this.props.onCollectionClick;
|
|
59
|
-
if (expand) _this.expandOrCollapseNode(collection);
|
|
60
|
-
onCollectionClick === null || onCollectionClick === void 0 ? void 0 : onCollectionClick(collection.id, collection); // TODO: this should pass the event as the first arg
|
|
61
|
-
|
|
62
|
-
_this.handleSelection(collection.id, 'collection');
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
this.handleItemClick = (e, item) => {
|
|
66
|
-
var _this$props$onItemCli, _this$props;
|
|
67
|
-
|
|
68
|
-
e.stopPropagation();
|
|
69
|
-
(_this$props$onItemCli = (_this$props = this.props).onItemClick) === null || _this$props$onItemCli === void 0 ? void 0 : _this$props$onItemCli.call(_this$props, item);
|
|
70
|
-
this.handleSelection(item.id, 'item');
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
this.handleKeyDown = (event, node) => {
|
|
74
|
-
event.stopPropagation();
|
|
75
|
-
|
|
76
|
-
switch (event.keyCode) {
|
|
77
|
-
case keycode.codes.down:
|
|
78
|
-
case keycode.codes.j:
|
|
79
|
-
this.moveFocus(1);
|
|
80
|
-
break;
|
|
81
|
-
|
|
82
|
-
case keycode.codes.up:
|
|
83
|
-
case keycode.codes.k:
|
|
84
|
-
this.moveFocus(-1);
|
|
85
|
-
break;
|
|
86
|
-
|
|
87
|
-
case keycode.codes.home:
|
|
88
|
-
case keycode.codes.end:
|
|
89
|
-
this.homeOrEnd(event.keyCode);
|
|
90
|
-
break;
|
|
91
|
-
|
|
92
|
-
case keycode.codes.left:
|
|
93
|
-
case keycode.codes.right:
|
|
94
|
-
this.handleLeftOrRightArrow(event.keyCode, node);
|
|
95
|
-
break;
|
|
96
|
-
|
|
97
|
-
case keycode.codes.enter:
|
|
98
|
-
case keycode.codes.space:
|
|
99
|
-
this.handleActivation(event, node);
|
|
100
|
-
break;
|
|
101
|
-
|
|
102
|
-
default:
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
event.preventDefault();
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
this.getIsFlattened = collection => {
|
|
110
|
-
const _this$props2 = this.props,
|
|
111
|
-
rootId = _this$props2.rootId,
|
|
112
|
-
showRootCollection = _this$props2.showRootCollection;
|
|
113
|
-
return !showRootCollection && typeof rootId !== 'undefined' && collection.id === rootId;
|
|
114
|
-
};
|
|
115
74
|
|
|
116
75
|
if (typeof this.props.expanded === 'undefined') {
|
|
117
76
|
this.state = {
|
|
@@ -126,25 +85,81 @@ let TreeBrowser = (_dec = withStyle(generateStyles, generateComponentTheme), _de
|
|
|
126
85
|
}
|
|
127
86
|
|
|
128
87
|
componentDidMount() {
|
|
129
|
-
var _this$props$makeStyle, _this$
|
|
88
|
+
var _this$props$makeStyle, _this$props;
|
|
130
89
|
|
|
131
|
-
(_this$props$makeStyle = (_this$
|
|
90
|
+
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
132
91
|
}
|
|
133
92
|
|
|
134
93
|
componentDidUpdate() {
|
|
135
|
-
var _this$props$makeStyle2, _this$
|
|
94
|
+
var _this$props$makeStyle2, _this$props2;
|
|
136
95
|
|
|
137
|
-
(_this$props$makeStyle2 = (_this$
|
|
96
|
+
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
138
97
|
}
|
|
139
98
|
|
|
140
99
|
get _root() {
|
|
141
100
|
return this.ref;
|
|
142
101
|
}
|
|
143
102
|
|
|
103
|
+
handleCollectionClick = (() => {
|
|
104
|
+
var _this = this;
|
|
105
|
+
|
|
106
|
+
return function (e, collection) {
|
|
107
|
+
let expand = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true;
|
|
108
|
+
e.stopPropagation();
|
|
109
|
+
const onCollectionClick = _this.props.onCollectionClick;
|
|
110
|
+
if (expand) _this.expandOrCollapseNode(collection);
|
|
111
|
+
onCollectionClick === null || onCollectionClick === void 0 ? void 0 : onCollectionClick(collection.id, collection); // TODO: this should pass the event as the first arg
|
|
112
|
+
|
|
113
|
+
_this.handleSelection(collection.id, 'collection');
|
|
114
|
+
};
|
|
115
|
+
})();
|
|
116
|
+
handleItemClick = (e, item) => {
|
|
117
|
+
var _this$props$onItemCli, _this$props3;
|
|
118
|
+
|
|
119
|
+
e.stopPropagation();
|
|
120
|
+
(_this$props$onItemCli = (_this$props3 = this.props).onItemClick) === null || _this$props$onItemCli === void 0 ? void 0 : _this$props$onItemCli.call(_this$props3, item);
|
|
121
|
+
this.handleSelection(item.id, 'item');
|
|
122
|
+
};
|
|
123
|
+
handleKeyDown = (event, node) => {
|
|
124
|
+
event.stopPropagation();
|
|
125
|
+
|
|
126
|
+
switch (event.keyCode) {
|
|
127
|
+
case keycode.codes.down:
|
|
128
|
+
case keycode.codes.j:
|
|
129
|
+
this.moveFocus(1);
|
|
130
|
+
break;
|
|
131
|
+
|
|
132
|
+
case keycode.codes.up:
|
|
133
|
+
case keycode.codes.k:
|
|
134
|
+
this.moveFocus(-1);
|
|
135
|
+
break;
|
|
136
|
+
|
|
137
|
+
case keycode.codes.home:
|
|
138
|
+
case keycode.codes.end:
|
|
139
|
+
this.homeOrEnd(event.keyCode);
|
|
140
|
+
break;
|
|
141
|
+
|
|
142
|
+
case keycode.codes.left:
|
|
143
|
+
case keycode.codes.right:
|
|
144
|
+
this.handleLeftOrRightArrow(event.keyCode, node);
|
|
145
|
+
break;
|
|
146
|
+
|
|
147
|
+
case keycode.codes.enter:
|
|
148
|
+
case keycode.codes.space:
|
|
149
|
+
this.handleActivation(event, node);
|
|
150
|
+
break;
|
|
151
|
+
|
|
152
|
+
default:
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
event.preventDefault();
|
|
157
|
+
};
|
|
158
|
+
|
|
144
159
|
get collections() {
|
|
145
|
-
const _this$
|
|
146
|
-
collections = _this$
|
|
147
|
-
rootId = _this$
|
|
160
|
+
const _this$props4 = this.props,
|
|
161
|
+
collections = _this$props4.collections,
|
|
162
|
+
rootId = _this$props4.rootId;
|
|
148
163
|
|
|
149
164
|
if (typeof rootId !== 'undefined') {
|
|
150
165
|
return [collections[rootId]];
|
|
@@ -162,9 +177,9 @@ let TreeBrowser = (_dec = withStyle(generateStyles, generateComponentTheme), _de
|
|
|
162
177
|
}
|
|
163
178
|
|
|
164
179
|
expandOrCollapseNode(collection) {
|
|
165
|
-
var _this$props$onCollect, _this$
|
|
180
|
+
var _this$props$onCollect, _this$props5;
|
|
166
181
|
|
|
167
|
-
(_this$props$onCollect = (_this$
|
|
182
|
+
(_this$props$onCollect = (_this$props5 = this.props).onCollectionToggle) === null || _this$props$onCollect === void 0 ? void 0 : _this$props$onCollect.call(_this$props5, collection);
|
|
168
183
|
|
|
169
184
|
if (typeof this.props.expanded === 'undefined') {
|
|
170
185
|
this.setState((state, props) => {
|
|
@@ -285,6 +300,13 @@ let TreeBrowser = (_dec = withStyle(generateStyles, generateComponentTheme), _de
|
|
|
285
300
|
}
|
|
286
301
|
}
|
|
287
302
|
|
|
303
|
+
getIsFlattened = collection => {
|
|
304
|
+
const _this$props6 = this.props,
|
|
305
|
+
rootId = _this$props6.rootId,
|
|
306
|
+
showRootCollection = _this$props6.showRootCollection;
|
|
307
|
+
return !showRootCollection && typeof rootId !== 'undefined' && collection.id === rootId;
|
|
308
|
+
};
|
|
309
|
+
|
|
288
310
|
getCollectionProps(collection) {
|
|
289
311
|
return {
|
|
290
312
|
id: collection.id,
|
|
@@ -334,20 +356,6 @@ let TreeBrowser = (_dec = withStyle(generateStyles, generateComponentTheme), _de
|
|
|
334
356
|
}, this.renderRoot());
|
|
335
357
|
}
|
|
336
358
|
|
|
337
|
-
}
|
|
338
|
-
size: 'medium',
|
|
339
|
-
variant: 'folderTree',
|
|
340
|
-
showRootCollection: true,
|
|
341
|
-
collectionIcon: IconFolderLine,
|
|
342
|
-
collectionIconExpanded: IconFolderLine,
|
|
343
|
-
itemIcon: IconDocumentLine,
|
|
344
|
-
getItemProps: props => props,
|
|
345
|
-
getCollectionProps: props => props,
|
|
346
|
-
defaultExpanded: [],
|
|
347
|
-
selectionType: 'none',
|
|
348
|
-
sortOrder: function () {
|
|
349
|
-
return 0;
|
|
350
|
-
}
|
|
351
|
-
}, _class2.Node = TreeNode, _class2.Collection = TreeCollection, _class2.Button = TreeButton, _class2)) || _class) || _class);
|
|
359
|
+
}) || _class) || _class);
|
|
352
360
|
export default TreeBrowser;
|
|
353
361
|
export { TreeBrowser };
|