@instructure/ui-tree-browser 8.33.1 → 8.33.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.
- package/CHANGELOG.md +4 -0
- package/es/TreeBrowser/TreeBrowserLocator.js +4 -2
- package/es/TreeBrowser/TreeButton/index.js +16 -37
- package/es/TreeBrowser/TreeButton/props.js +1 -0
- package/es/TreeBrowser/TreeButton/styles.js +5 -6
- package/es/TreeBrowser/TreeButton/theme.js +6 -6
- package/es/TreeBrowser/TreeCollection/index.js +44 -70
- package/es/TreeBrowser/TreeCollection/props.js +1 -0
- package/es/TreeBrowser/TreeCollection/styles.js +3 -2
- package/es/TreeBrowser/TreeCollection/theme.js +5 -5
- package/es/TreeBrowser/TreeNode/index.js +8 -20
- package/es/TreeBrowser/TreeNode/props.js +1 -0
- package/es/TreeBrowser/index.js +8 -57
- package/es/TreeBrowser/props.js +1 -0
- package/es/TreeBrowser/styles.js +1 -1
- package/es/TreeBrowser/theme.js +3 -3
- package/lib/TreeBrowser/TreeBrowserLocator.js +3 -4
- package/lib/TreeBrowser/TreeButton/index.js +13 -46
- package/lib/TreeBrowser/TreeButton/props.js +1 -3
- package/lib/TreeBrowser/TreeButton/styles.js +5 -8
- package/lib/TreeBrowser/TreeButton/theme.js +6 -7
- package/lib/TreeBrowser/TreeCollection/index.js +44 -79
- package/lib/TreeBrowser/TreeCollection/props.js +1 -5
- package/lib/TreeBrowser/TreeCollection/styles.js +3 -4
- package/lib/TreeBrowser/TreeCollection/theme.js +5 -6
- package/lib/TreeBrowser/TreeNode/index.js +5 -29
- package/lib/TreeBrowser/TreeNode/props.js +1 -3
- package/lib/TreeBrowser/index.js +6 -72
- package/lib/TreeBrowser/locator.js +0 -2
- package/lib/TreeBrowser/props.js +1 -4
- package/lib/TreeBrowser/styles.js +1 -2
- package/lib/TreeBrowser/theme.js +3 -4
- package/lib/index.js +0 -1
- package/package.json +14 -14
- package/tsconfig.build.tsbuildinfo +1 -1
package/es/TreeBrowser/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
var _dec, _dec2, _class, _class2;
|
|
2
|
-
|
|
3
2
|
/*
|
|
4
3
|
* The MIT License (MIT)
|
|
5
4
|
*
|
|
@@ -25,6 +24,7 @@ var _dec, _dec2, _class, _class2;
|
|
|
25
24
|
*/
|
|
26
25
|
|
|
27
26
|
/** @jsx jsx */
|
|
27
|
+
|
|
28
28
|
import { Component } from 'react';
|
|
29
29
|
import keycode from 'keycode';
|
|
30
30
|
import { IconFolderLine, IconDocumentLine } from '@instructure/ui-icons';
|
|
@@ -37,82 +37,67 @@ import { TreeNode } from './TreeNode';
|
|
|
37
37
|
import generateStyles from './styles';
|
|
38
38
|
import generateComponentTheme from './theme';
|
|
39
39
|
import { allowedProps, propTypes } from './props';
|
|
40
|
+
|
|
40
41
|
/**
|
|
41
42
|
---
|
|
42
43
|
category: components
|
|
43
44
|
---
|
|
44
45
|
@tsProps
|
|
45
46
|
**/
|
|
46
|
-
|
|
47
47
|
let TreeBrowser = (_dec = withStyle(generateStyles, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = (_class2 = class TreeBrowser extends Component {
|
|
48
48
|
constructor(props) {
|
|
49
49
|
var _this;
|
|
50
|
-
|
|
51
50
|
super(props);
|
|
52
51
|
_this = this;
|
|
53
52
|
this.ref = null;
|
|
54
|
-
|
|
55
53
|
this.handleCollectionClick = function (e, collection) {
|
|
56
54
|
let expand = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true;
|
|
57
55
|
e.stopPropagation();
|
|
58
56
|
const onCollectionClick = _this.props.onCollectionClick;
|
|
59
57
|
if (expand) _this.expandOrCollapseNode(collection);
|
|
60
58
|
onCollectionClick === null || onCollectionClick === void 0 ? void 0 : onCollectionClick(collection.id, collection); // TODO: this should pass the event as the first arg
|
|
61
|
-
|
|
62
59
|
_this.handleSelection(collection.id, 'collection');
|
|
63
60
|
};
|
|
64
|
-
|
|
65
61
|
this.handleItemClick = (e, item) => {
|
|
66
62
|
var _this$props$onItemCli, _this$props;
|
|
67
|
-
|
|
68
63
|
e.stopPropagation();
|
|
69
64
|
(_this$props$onItemCli = (_this$props = this.props).onItemClick) === null || _this$props$onItemCli === void 0 ? void 0 : _this$props$onItemCli.call(_this$props, item);
|
|
70
65
|
this.handleSelection(item.id, 'item');
|
|
71
66
|
};
|
|
72
|
-
|
|
73
67
|
this.handleKeyDown = (event, node) => {
|
|
74
68
|
event.stopPropagation();
|
|
75
|
-
|
|
76
69
|
switch (event.keyCode) {
|
|
77
70
|
case keycode.codes.down:
|
|
78
71
|
case keycode.codes.j:
|
|
79
72
|
this.moveFocus(1);
|
|
80
73
|
break;
|
|
81
|
-
|
|
82
74
|
case keycode.codes.up:
|
|
83
75
|
case keycode.codes.k:
|
|
84
76
|
this.moveFocus(-1);
|
|
85
77
|
break;
|
|
86
|
-
|
|
87
78
|
case keycode.codes.home:
|
|
88
79
|
case keycode.codes.end:
|
|
89
80
|
this.homeOrEnd(event.keyCode);
|
|
90
81
|
break;
|
|
91
|
-
|
|
92
82
|
case keycode.codes.left:
|
|
93
83
|
case keycode.codes.right:
|
|
94
84
|
this.handleLeftOrRightArrow(event.keyCode, node);
|
|
95
85
|
break;
|
|
96
|
-
|
|
97
86
|
case keycode.codes.enter:
|
|
98
87
|
case keycode.codes.space:
|
|
99
88
|
this.handleActivation(event, node);
|
|
100
89
|
break;
|
|
101
|
-
|
|
102
90
|
default:
|
|
103
91
|
return;
|
|
104
92
|
}
|
|
105
|
-
|
|
106
93
|
event.preventDefault();
|
|
107
94
|
};
|
|
108
|
-
|
|
109
95
|
this.getIsFlattened = collection => {
|
|
110
96
|
const _this$props2 = this.props,
|
|
111
|
-
|
|
112
|
-
|
|
97
|
+
rootId = _this$props2.rootId,
|
|
98
|
+
showRootCollection = _this$props2.showRootCollection;
|
|
113
99
|
return !showRootCollection && typeof rootId !== 'undefined' && collection.id === rootId;
|
|
114
100
|
};
|
|
115
|
-
|
|
116
101
|
if (typeof this.props.expanded === 'undefined') {
|
|
117
102
|
this.state = {
|
|
118
103
|
expanded: this.props.defaultExpanded,
|
|
@@ -124,71 +109,55 @@ let TreeBrowser = (_dec = withStyle(generateStyles, generateComponentTheme), _de
|
|
|
124
109
|
};
|
|
125
110
|
}
|
|
126
111
|
}
|
|
127
|
-
|
|
128
112
|
componentDidMount() {
|
|
129
113
|
var _this$props$makeStyle, _this$props3;
|
|
130
|
-
|
|
131
114
|
(_this$props$makeStyle = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props3);
|
|
132
115
|
}
|
|
133
|
-
|
|
134
116
|
componentDidUpdate() {
|
|
135
117
|
var _this$props$makeStyle2, _this$props4;
|
|
136
|
-
|
|
137
118
|
(_this$props$makeStyle2 = (_this$props4 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props4);
|
|
138
119
|
}
|
|
139
|
-
|
|
140
120
|
get _root() {
|
|
141
121
|
return this.ref;
|
|
142
122
|
}
|
|
143
|
-
|
|
144
123
|
get collections() {
|
|
145
124
|
const _this$props5 = this.props,
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
125
|
+
collections = _this$props5.collections,
|
|
126
|
+
rootId = _this$props5.rootId;
|
|
149
127
|
if (typeof rootId !== 'undefined') {
|
|
150
128
|
return [collections[rootId]];
|
|
151
129
|
} else {
|
|
152
130
|
return Object.keys(collections).map(id => collections[id]).filter(collection => collection != null);
|
|
153
131
|
}
|
|
154
132
|
}
|
|
155
|
-
|
|
156
133
|
get expanded() {
|
|
157
134
|
return this.getExpanded(this.state, this.props);
|
|
158
135
|
}
|
|
159
|
-
|
|
160
136
|
getExpanded(state, props) {
|
|
161
137
|
return typeof props.expanded === 'undefined' ? state.expanded : props.expanded;
|
|
162
138
|
}
|
|
163
|
-
|
|
164
139
|
expandOrCollapseNode(collection) {
|
|
165
140
|
var _this$props$onCollect, _this$props6;
|
|
166
|
-
|
|
167
141
|
(_this$props$onCollect = (_this$props6 = this.props).onCollectionToggle) === null || _this$props$onCollect === void 0 ? void 0 : _this$props$onCollect.call(_this$props6, collection);
|
|
168
|
-
|
|
169
142
|
if (typeof this.props.expanded === 'undefined') {
|
|
170
143
|
this.setState((state, props) => {
|
|
171
144
|
const expanded = [...this.getExpanded(state, props)];
|
|
172
145
|
const expandedIndex = this.getExpandedIndex(expanded, collection.id);
|
|
173
|
-
|
|
174
146
|
if (collection.expanded && expandedIndex < 0) {
|
|
175
147
|
expanded.push(collection.id);
|
|
176
148
|
} else if (expandedIndex >= 0) {
|
|
177
149
|
expanded.splice(expandedIndex, 1);
|
|
178
150
|
}
|
|
179
|
-
|
|
180
151
|
return {
|
|
181
152
|
expanded
|
|
182
153
|
};
|
|
183
154
|
});
|
|
184
155
|
}
|
|
185
156
|
}
|
|
186
|
-
|
|
187
157
|
handleSelection(id, type) {
|
|
188
158
|
const selectionType = this.props.selectionType;
|
|
189
159
|
selectionType === 'single' && this.setState(state => {
|
|
190
160
|
const selection = `${type}_${id}`;
|
|
191
|
-
|
|
192
161
|
if (state.selection !== selection) {
|
|
193
162
|
return {
|
|
194
163
|
selection
|
|
@@ -198,50 +167,41 @@ let TreeBrowser = (_dec = withStyle(generateStyles, generateComponentTheme), _de
|
|
|
198
167
|
}
|
|
199
168
|
});
|
|
200
169
|
}
|
|
201
|
-
|
|
202
170
|
getNavigableNodes() {
|
|
203
171
|
return Array.from(this.ref.querySelectorAll('[role="treeitem"]'));
|
|
204
172
|
}
|
|
205
|
-
|
|
206
173
|
moveFocus(delta) {
|
|
207
174
|
const nodes = this.getNavigableNodes();
|
|
208
175
|
const closest = window.document.activeElement.closest('[role="treeitem"]');
|
|
209
176
|
const active = nodes.indexOf(closest);
|
|
210
177
|
let next = active + delta;
|
|
211
|
-
|
|
212
178
|
if (next < 0) {
|
|
213
179
|
next = 0;
|
|
214
180
|
} else if (next >= nodes.length) {
|
|
215
181
|
next = nodes.length - 1;
|
|
216
182
|
}
|
|
217
|
-
|
|
218
183
|
nodes.forEach(n => {
|
|
219
184
|
n.setAttribute('tabindex', '-1');
|
|
220
185
|
});
|
|
221
186
|
nodes[next].setAttribute('tabindex', '0');
|
|
222
187
|
nodes[next].focus();
|
|
223
188
|
}
|
|
224
|
-
|
|
225
189
|
homeOrEnd(keyCode) {
|
|
226
190
|
const length = this.getNavigableNodes().length;
|
|
227
|
-
|
|
228
191
|
if (keyCode === keycode.codes.home) {
|
|
229
192
|
this.moveFocus(1 - length);
|
|
230
193
|
} else {
|
|
231
194
|
this.moveFocus(length - 1);
|
|
232
195
|
}
|
|
233
196
|
}
|
|
234
|
-
|
|
235
197
|
handleLeftOrRightArrow(keyCode, node) {
|
|
236
198
|
const ltr = !(this.ref.parentElement.dir === 'rtl' || document.dir === 'rtl');
|
|
237
|
-
|
|
238
199
|
if (ltr && keyCode === keycode.codes.left || !ltr && keyCode == keycode.codes.right) {
|
|
239
200
|
this.handleCloseOrPrevious(node);
|
|
240
201
|
} else {
|
|
241
202
|
this.handleOpenOrNext(node);
|
|
242
203
|
}
|
|
243
204
|
}
|
|
244
|
-
|
|
245
205
|
handleOpenOrNext(node) {
|
|
246
206
|
if (node && !this.expanded.includes(node.id) && node.type === 'collection') {
|
|
247
207
|
this.expandOrCollapseNode(node);
|
|
@@ -249,7 +209,6 @@ let TreeBrowser = (_dec = withStyle(generateStyles, generateComponentTheme), _de
|
|
|
249
209
|
this.moveFocus(1);
|
|
250
210
|
}
|
|
251
211
|
}
|
|
252
|
-
|
|
253
212
|
handleCloseOrPrevious(node) {
|
|
254
213
|
if (node && this.expanded.includes(node.id) && node.type === 'collection') {
|
|
255
214
|
this.expandOrCollapseNode(node);
|
|
@@ -257,34 +216,30 @@ let TreeBrowser = (_dec = withStyle(generateStyles, generateComponentTheme), _de
|
|
|
257
216
|
this.moveFocus(-1);
|
|
258
217
|
}
|
|
259
218
|
}
|
|
260
|
-
|
|
261
219
|
handleActivation(event, node) {
|
|
262
220
|
if (node == null) return;
|
|
263
|
-
|
|
264
221
|
if (node.type === 'collection') {
|
|
265
222
|
this.handleCollectionClick(event, node, this.props.selectionType === 'none');
|
|
266
223
|
} else {
|
|
267
224
|
this.handleItemClick(event, node);
|
|
268
225
|
}
|
|
269
226
|
}
|
|
270
|
-
|
|
271
227
|
getSubCollections(collection) {
|
|
272
228
|
const collections = collection.collections ? [...collection.collections] : [];
|
|
273
229
|
return collections.map(id => this.getCollectionProps(this.props.collections[id])).filter(collection => collection != null).sort(this.props.sortOrder);
|
|
274
230
|
}
|
|
275
|
-
|
|
276
231
|
getItems(collection) {
|
|
277
232
|
if (collection.items) {
|
|
278
233
|
const items = collection.items ? [...collection.items] : [];
|
|
279
234
|
return items.map(id => {
|
|
280
|
-
return {
|
|
235
|
+
return {
|
|
236
|
+
...this.props.items[id]
|
|
281
237
|
};
|
|
282
238
|
}).filter(item => item != null).sort(this.props.sortOrder);
|
|
283
239
|
} else {
|
|
284
240
|
return [];
|
|
285
241
|
}
|
|
286
242
|
}
|
|
287
|
-
|
|
288
243
|
getCollectionProps(collection) {
|
|
289
244
|
return {
|
|
290
245
|
id: collection.id,
|
|
@@ -300,11 +255,9 @@ let TreeBrowser = (_dec = withStyle(generateStyles, generateComponentTheme), _de
|
|
|
300
255
|
compareFunc: collection.compareFunc
|
|
301
256
|
};
|
|
302
257
|
}
|
|
303
|
-
|
|
304
258
|
getExpandedIndex(expanded, id) {
|
|
305
259
|
return expanded.findIndex(expanded => String(expanded) === String(id));
|
|
306
260
|
}
|
|
307
|
-
|
|
308
261
|
renderRoot() {
|
|
309
262
|
return this.collections.sort(this.props.sortOrder).map((collection, i) => jsx(TreeCollection, Object.assign({
|
|
310
263
|
key: i
|
|
@@ -319,7 +272,6 @@ let TreeBrowser = (_dec = withStyle(generateStyles, generateComponentTheme), _de
|
|
|
319
272
|
renderContent: this.props.renderContent
|
|
320
273
|
})));
|
|
321
274
|
}
|
|
322
|
-
|
|
323
275
|
render() {
|
|
324
276
|
const styles = this.props.styles;
|
|
325
277
|
return jsx("ul", {
|
|
@@ -333,7 +285,6 @@ let TreeBrowser = (_dec = withStyle(generateStyles, generateComponentTheme), _de
|
|
|
333
285
|
"aria-label": this.props.treeLabel
|
|
334
286
|
}, this.renderRoot());
|
|
335
287
|
}
|
|
336
|
-
|
|
337
288
|
}, _class2.displayName = "TreeBrowser", _class2.componentId = 'TreeBrowser', _class2.allowedProps = allowedProps, _class2.propTypes = propTypes, _class2.defaultProps = {
|
|
338
289
|
size: 'medium',
|
|
339
290
|
variant: 'folderTree',
|
package/es/TreeBrowser/props.js
CHANGED
package/es/TreeBrowser/styles.js
CHANGED
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
* @param {Object} state the state of the component, the style is applied to
|
|
33
33
|
* @return {Object} The final style object, which will be used in the component
|
|
34
34
|
*/
|
|
35
|
+
|
|
35
36
|
const generateStyles = componentTheme => {
|
|
36
37
|
return {
|
|
37
38
|
treeBrowser: {
|
|
@@ -65,5 +66,4 @@ const generateStyles = componentTheme => {
|
|
|
65
66
|
}
|
|
66
67
|
};
|
|
67
68
|
};
|
|
68
|
-
|
|
69
69
|
export default generateStyles;
|
package/es/TreeBrowser/theme.js
CHANGED
|
@@ -29,15 +29,15 @@
|
|
|
29
29
|
*/
|
|
30
30
|
const generateComponentTheme = theme => {
|
|
31
31
|
const colors = theme.colors,
|
|
32
|
-
|
|
32
|
+
borders = theme.borders;
|
|
33
33
|
const componentVariables = {
|
|
34
34
|
borderRadius: borders === null || borders === void 0 ? void 0 : borders.radiusMedium,
|
|
35
35
|
focusOutlineWidth: borders === null || borders === void 0 ? void 0 : borders.widthMedium,
|
|
36
36
|
focusOutlineColor: colors === null || colors === void 0 ? void 0 : colors.borderBrand,
|
|
37
37
|
focusOutlineStyle: borders === null || borders === void 0 ? void 0 : borders.style
|
|
38
38
|
};
|
|
39
|
-
return {
|
|
39
|
+
return {
|
|
40
|
+
...componentVariables
|
|
40
41
|
};
|
|
41
42
|
};
|
|
42
|
-
|
|
43
43
|
export default generateComponentTheme;
|
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.TreeBrowserLocator = void 0;
|
|
7
|
-
|
|
8
7
|
var _locator = require("@instructure/ui-test-locator/lib/utils/locator.js");
|
|
9
|
-
|
|
10
8
|
var _index = require("./index");
|
|
11
|
-
|
|
12
9
|
/*
|
|
13
10
|
* The MIT License (MIT)
|
|
14
11
|
*
|
|
@@ -32,9 +29,11 @@ var _index = require("./index");
|
|
|
32
29
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
33
30
|
* SOFTWARE.
|
|
34
31
|
*/
|
|
32
|
+
|
|
35
33
|
// TODO: if we make a TreeBrowserItem component + locator we could use it here.
|
|
36
|
-
const TreeBrowserItemLocator = (0, _locator.locator)('[role="treeitem"]');
|
|
34
|
+
const TreeBrowserItemLocator = (0, _locator.locator)('[role="treeitem"]');
|
|
37
35
|
|
|
36
|
+
// @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
|
|
38
37
|
const TreeBrowserLocator = (0, _locator.locator)(_index.TreeBrowser.selector, {
|
|
39
38
|
findAllItems: function () {
|
|
40
39
|
return TreeBrowserItemLocator.findAll(...arguments);
|
|
@@ -1,32 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = exports.TreeButton = void 0;
|
|
9
|
-
|
|
10
8
|
var _react = require("react");
|
|
11
|
-
|
|
12
9
|
var _testable = require("@instructure/ui-testable/lib/testable.js");
|
|
13
|
-
|
|
14
10
|
var _Img = require("@instructure/ui-img/lib/Img");
|
|
15
|
-
|
|
16
11
|
var _callRenderProp = require("@instructure/ui-react-utils/lib/callRenderProp.js");
|
|
17
|
-
|
|
18
12
|
var _emotion = require("@instructure/emotion");
|
|
19
|
-
|
|
20
13
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
21
|
-
|
|
22
14
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
23
|
-
|
|
24
15
|
var _props = require("./props");
|
|
25
|
-
|
|
26
16
|
var _dec, _dec2, _class, _class2;
|
|
27
|
-
|
|
28
17
|
// Todo: merge TreeButton and TreeNode: TreeButton should be a special type of TreeNode
|
|
29
|
-
|
|
30
18
|
/**
|
|
31
19
|
---
|
|
32
20
|
parent: TreeBrowser
|
|
@@ -38,32 +26,25 @@ let TreeButton = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default
|
|
|
38
26
|
constructor() {
|
|
39
27
|
super(...arguments);
|
|
40
28
|
this.ref = null;
|
|
41
|
-
|
|
42
29
|
this.handleRef = el => {
|
|
43
30
|
if (el && typeof this.props.containerRef === 'function') {
|
|
44
31
|
this.props.containerRef(el.parentElement);
|
|
45
32
|
}
|
|
46
|
-
|
|
47
33
|
this.ref = el;
|
|
48
34
|
};
|
|
49
35
|
}
|
|
50
|
-
|
|
51
36
|
componentDidMount() {
|
|
52
37
|
var _this$props$makeStyle, _this$props;
|
|
53
|
-
|
|
54
38
|
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
55
39
|
}
|
|
56
|
-
|
|
57
40
|
componentDidUpdate() {
|
|
58
41
|
var _this$props$makeStyle2, _this$props2;
|
|
59
|
-
|
|
60
42
|
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
61
43
|
}
|
|
62
|
-
|
|
63
44
|
defaultContentRenderer(props) {
|
|
64
45
|
const name = props.name,
|
|
65
|
-
|
|
66
|
-
|
|
46
|
+
descriptor = props.descriptor,
|
|
47
|
+
styles = props.styles;
|
|
67
48
|
return (0, _emotion.jsx)("span", {
|
|
68
49
|
css: styles.layout
|
|
69
50
|
}, this.renderImage(), (0, _emotion.jsx)("span", {
|
|
@@ -75,46 +56,36 @@ let TreeButton = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default
|
|
|
75
56
|
title: descriptor
|
|
76
57
|
}, descriptor) : null));
|
|
77
58
|
}
|
|
78
|
-
|
|
79
59
|
renderImage() {
|
|
80
60
|
const type = this.props.type;
|
|
81
|
-
|
|
82
61
|
switch (type) {
|
|
83
62
|
case 'collection':
|
|
84
63
|
return this.renderCollectionIcon();
|
|
85
|
-
|
|
86
64
|
case 'item':
|
|
87
65
|
return this.renderItemImage();
|
|
88
|
-
|
|
89
66
|
default:
|
|
90
67
|
break;
|
|
91
68
|
}
|
|
92
|
-
|
|
93
69
|
return void 0;
|
|
94
70
|
}
|
|
95
|
-
|
|
96
71
|
renderCollectionIcon() {
|
|
97
72
|
const _this$props3 = this.props,
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
73
|
+
expanded = _this$props3.expanded,
|
|
74
|
+
collectionIcon = _this$props3.collectionIcon,
|
|
75
|
+
collectionIconExpanded = _this$props3.collectionIconExpanded,
|
|
76
|
+
styles = _this$props3.styles;
|
|
103
77
|
if (collectionIcon || collectionIconExpanded) {
|
|
104
78
|
return (0, _emotion.jsx)("div", {
|
|
105
79
|
css: styles === null || styles === void 0 ? void 0 : styles.icon
|
|
106
80
|
}, (0, _callRenderProp.callRenderProp)(expanded ? collectionIconExpanded : collectionIcon));
|
|
107
81
|
}
|
|
108
|
-
|
|
109
82
|
return void 0;
|
|
110
83
|
}
|
|
111
|
-
|
|
112
84
|
renderItemImage() {
|
|
113
85
|
const _this$props4 = this.props,
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
86
|
+
thumbnail = _this$props4.thumbnail,
|
|
87
|
+
itemIcon = _this$props4.itemIcon,
|
|
88
|
+
styles = _this$props4.styles;
|
|
118
89
|
if (thumbnail) {
|
|
119
90
|
return (0, _emotion.jsx)("div", {
|
|
120
91
|
css: styles === null || styles === void 0 ? void 0 : styles.thumbnail
|
|
@@ -124,22 +95,19 @@ let TreeButton = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default
|
|
|
124
95
|
alt: ""
|
|
125
96
|
}));
|
|
126
97
|
}
|
|
127
|
-
|
|
128
98
|
if (itemIcon) {
|
|
129
99
|
return (0, _emotion.jsx)("div", {
|
|
130
100
|
css: styles === null || styles === void 0 ? void 0 : styles.icon
|
|
131
101
|
}, (0, _callRenderProp.callRenderProp)(itemIcon));
|
|
132
102
|
}
|
|
133
|
-
|
|
134
103
|
return void 0;
|
|
135
104
|
}
|
|
136
|
-
|
|
137
105
|
render() {
|
|
138
106
|
const _this$props5 = this.props,
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
const buttonContent = renderContent ? renderContent(this.props) : this.defaultContentRenderer(this.props);
|
|
142
|
-
|
|
107
|
+
styles = _this$props5.styles,
|
|
108
|
+
renderContent = _this$props5.renderContent;
|
|
109
|
+
const buttonContent = renderContent ? renderContent(this.props) : this.defaultContentRenderer(this.props);
|
|
110
|
+
// VoiceOver can't navigate without the buttons, even though they don't do anything
|
|
143
111
|
return (0, _emotion.jsx)("button", {
|
|
144
112
|
ref: this.handleRef,
|
|
145
113
|
tabIndex: -1,
|
|
@@ -147,7 +115,6 @@ let TreeButton = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default
|
|
|
147
115
|
css: styles === null || styles === void 0 ? void 0 : styles.treeButton
|
|
148
116
|
}, buttonContent);
|
|
149
117
|
}
|
|
150
|
-
|
|
151
118
|
}, _class2.displayName = "TreeButton", _class2.componentId = 'TreeBrowser.Button', _class2.allowedProps = _props.allowedProps, _class2.propTypes = _props.propTypes, _class2.defaultProps = {
|
|
152
119
|
type: 'treeButton',
|
|
153
120
|
size: 'medium',
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.propTypes = exports.allowedProps = void 0;
|
|
9
|
-
|
|
10
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
9
|
/*
|
|
13
10
|
* The MIT License (MIT)
|
|
14
11
|
*
|
|
@@ -32,6 +29,7 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
32
29
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
33
30
|
* SOFTWARE.
|
|
34
31
|
*/
|
|
32
|
+
|
|
35
33
|
const propTypes = {
|
|
36
34
|
id: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
|
|
37
35
|
name: _propTypes.default.string,
|
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _emotion = require("@instructure/emotion");
|
|
9
|
-
|
|
10
8
|
/*
|
|
11
9
|
* The MIT License (MIT)
|
|
12
10
|
*
|
|
@@ -30,6 +28,7 @@ var _emotion = require("@instructure/emotion");
|
|
|
30
28
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
31
29
|
* SOFTWARE.
|
|
32
30
|
*/
|
|
31
|
+
|
|
33
32
|
const transform = (0, _emotion.keyframes)`
|
|
34
33
|
50% {
|
|
35
34
|
opacity: 0.5;
|
|
@@ -50,13 +49,12 @@ const transform = (0, _emotion.keyframes)`
|
|
|
50
49
|
* @param {Object} props the props of the component, the style is applied to
|
|
51
50
|
* @return {Object} The final style object, which will be used in the component
|
|
52
51
|
*/
|
|
53
|
-
|
|
54
52
|
const generateStyles = (componentTheme, props) => {
|
|
55
53
|
const size = props.size,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
54
|
+
variant = props.variant,
|
|
55
|
+
selected = props.selected,
|
|
56
|
+
focused = props.focused,
|
|
57
|
+
level = props.level;
|
|
60
58
|
const isRootButton = level && level === 1;
|
|
61
59
|
const sizeMap = {
|
|
62
60
|
small: {
|
|
@@ -332,6 +330,5 @@ const generateStyles = (componentTheme, props) => {
|
|
|
332
330
|
}
|
|
333
331
|
};
|
|
334
332
|
};
|
|
335
|
-
|
|
336
333
|
var _default = generateStyles;
|
|
337
334
|
exports.default = _default;
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
/*
|
|
9
8
|
* The MIT License (MIT)
|
|
10
9
|
*
|
|
@@ -36,10 +35,10 @@ exports.default = void 0;
|
|
|
36
35
|
*/
|
|
37
36
|
const generateComponentTheme = theme => {
|
|
38
37
|
const colors = theme.colors,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
borders = theme.borders,
|
|
39
|
+
typography = theme.typography,
|
|
40
|
+
themeName = theme.key,
|
|
41
|
+
spacing = theme.spacing;
|
|
43
42
|
const themeSpecificStyles = {
|
|
44
43
|
canvas: {
|
|
45
44
|
iconColor: theme['ic-brand-font-color-dark'],
|
|
@@ -77,10 +76,10 @@ const generateComponentTheme = theme => {
|
|
|
77
76
|
selectedBackgroundColor: colors === null || colors === void 0 ? void 0 : colors.backgroundDark,
|
|
78
77
|
selectedOutlineWidth: borders === null || borders === void 0 ? void 0 : borders.widthLarge
|
|
79
78
|
};
|
|
80
|
-
return {
|
|
79
|
+
return {
|
|
80
|
+
...componentVariables,
|
|
81
81
|
...themeSpecificStyles[themeName]
|
|
82
82
|
};
|
|
83
83
|
};
|
|
84
|
-
|
|
85
84
|
var _default = generateComponentTheme;
|
|
86
85
|
exports.default = _default;
|