@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/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
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.33.2](https://github.com/instructure/instructure-ui/compare/v8.33.1...v8.33.2) (2023-01-25)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @instructure/ui-tree-browser
|
|
9
|
+
|
|
6
10
|
## [8.33.1](https://github.com/instructure/instructure-ui/compare/v8.33.0...v8.33.1) (2023-01-06)
|
|
7
11
|
|
|
8
12
|
**Note:** Version bump only for package @instructure/ui-tree-browser
|
|
@@ -22,10 +22,12 @@
|
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
import { locator } from '@instructure/ui-test-locator';
|
|
25
|
-
import { TreeBrowser } from './index';
|
|
25
|
+
import { TreeBrowser } from './index';
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
// TODO: if we make a TreeBrowserItem component + locator we could use it here.
|
|
28
|
+
const TreeBrowserItemLocator = locator('[role="treeitem"]');
|
|
28
29
|
|
|
30
|
+
// @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
|
|
29
31
|
export const TreeBrowserLocator = locator(TreeBrowser.selector, {
|
|
30
32
|
findAllItems: function () {
|
|
31
33
|
return TreeBrowserItemLocator.findAll(...arguments);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
var _dec, _dec2, _class, _class2;
|
|
2
|
-
|
|
3
2
|
/*
|
|
4
3
|
* The MIT License (MIT)
|
|
5
4
|
*
|
|
@@ -32,7 +31,9 @@ import { callRenderProp } from '@instructure/ui-react-utils';
|
|
|
32
31
|
import { withStyle, jsx } from '@instructure/emotion';
|
|
33
32
|
import generateStyles from './styles';
|
|
34
33
|
import generateComponentTheme from './theme';
|
|
35
|
-
import { allowedProps, propTypes } from './props';
|
|
34
|
+
import { allowedProps, propTypes } from './props';
|
|
35
|
+
|
|
36
|
+
// Todo: merge TreeButton and TreeNode: TreeButton should be a special type of TreeNode
|
|
36
37
|
|
|
37
38
|
/**
|
|
38
39
|
---
|
|
@@ -41,37 +42,29 @@ id: TreeBrowser.Button
|
|
|
41
42
|
---
|
|
42
43
|
@tsProps
|
|
43
44
|
**/
|
|
44
|
-
|
|
45
45
|
let TreeButton = (_dec = withStyle(generateStyles, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = (_class2 = class TreeButton extends Component {
|
|
46
46
|
constructor() {
|
|
47
47
|
super(...arguments);
|
|
48
48
|
this.ref = null;
|
|
49
|
-
|
|
50
49
|
this.handleRef = el => {
|
|
51
50
|
if (el && typeof this.props.containerRef === 'function') {
|
|
52
51
|
this.props.containerRef(el.parentElement);
|
|
53
52
|
}
|
|
54
|
-
|
|
55
53
|
this.ref = el;
|
|
56
54
|
};
|
|
57
55
|
}
|
|
58
|
-
|
|
59
56
|
componentDidMount() {
|
|
60
57
|
var _this$props$makeStyle, _this$props;
|
|
61
|
-
|
|
62
58
|
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
63
59
|
}
|
|
64
|
-
|
|
65
60
|
componentDidUpdate() {
|
|
66
61
|
var _this$props$makeStyle2, _this$props2;
|
|
67
|
-
|
|
68
62
|
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
69
63
|
}
|
|
70
|
-
|
|
71
64
|
defaultContentRenderer(props) {
|
|
72
65
|
const name = props.name,
|
|
73
|
-
|
|
74
|
-
|
|
66
|
+
descriptor = props.descriptor,
|
|
67
|
+
styles = props.styles;
|
|
75
68
|
return jsx("span", {
|
|
76
69
|
css: styles.layout
|
|
77
70
|
}, this.renderImage(), jsx("span", {
|
|
@@ -83,46 +76,36 @@ let TreeButton = (_dec = withStyle(generateStyles, generateComponentTheme), _dec
|
|
|
83
76
|
title: descriptor
|
|
84
77
|
}, descriptor) : null));
|
|
85
78
|
}
|
|
86
|
-
|
|
87
79
|
renderImage() {
|
|
88
80
|
const type = this.props.type;
|
|
89
|
-
|
|
90
81
|
switch (type) {
|
|
91
82
|
case 'collection':
|
|
92
83
|
return this.renderCollectionIcon();
|
|
93
|
-
|
|
94
84
|
case 'item':
|
|
95
85
|
return this.renderItemImage();
|
|
96
|
-
|
|
97
86
|
default:
|
|
98
87
|
break;
|
|
99
88
|
}
|
|
100
|
-
|
|
101
89
|
return void 0;
|
|
102
90
|
}
|
|
103
|
-
|
|
104
91
|
renderCollectionIcon() {
|
|
105
92
|
const _this$props3 = this.props,
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
93
|
+
expanded = _this$props3.expanded,
|
|
94
|
+
collectionIcon = _this$props3.collectionIcon,
|
|
95
|
+
collectionIconExpanded = _this$props3.collectionIconExpanded,
|
|
96
|
+
styles = _this$props3.styles;
|
|
111
97
|
if (collectionIcon || collectionIconExpanded) {
|
|
112
98
|
return jsx("div", {
|
|
113
99
|
css: styles === null || styles === void 0 ? void 0 : styles.icon
|
|
114
100
|
}, callRenderProp(expanded ? collectionIconExpanded : collectionIcon));
|
|
115
101
|
}
|
|
116
|
-
|
|
117
102
|
return void 0;
|
|
118
103
|
}
|
|
119
|
-
|
|
120
104
|
renderItemImage() {
|
|
121
105
|
const _this$props4 = this.props,
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
106
|
+
thumbnail = _this$props4.thumbnail,
|
|
107
|
+
itemIcon = _this$props4.itemIcon,
|
|
108
|
+
styles = _this$props4.styles;
|
|
126
109
|
if (thumbnail) {
|
|
127
110
|
return jsx("div", {
|
|
128
111
|
css: styles === null || styles === void 0 ? void 0 : styles.thumbnail
|
|
@@ -132,22 +115,19 @@ let TreeButton = (_dec = withStyle(generateStyles, generateComponentTheme), _dec
|
|
|
132
115
|
alt: ""
|
|
133
116
|
}));
|
|
134
117
|
}
|
|
135
|
-
|
|
136
118
|
if (itemIcon) {
|
|
137
119
|
return jsx("div", {
|
|
138
120
|
css: styles === null || styles === void 0 ? void 0 : styles.icon
|
|
139
121
|
}, callRenderProp(itemIcon));
|
|
140
122
|
}
|
|
141
|
-
|
|
142
123
|
return void 0;
|
|
143
124
|
}
|
|
144
|
-
|
|
145
125
|
render() {
|
|
146
126
|
const _this$props5 = this.props,
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
const buttonContent = renderContent ? renderContent(this.props) : this.defaultContentRenderer(this.props);
|
|
150
|
-
|
|
127
|
+
styles = _this$props5.styles,
|
|
128
|
+
renderContent = _this$props5.renderContent;
|
|
129
|
+
const buttonContent = renderContent ? renderContent(this.props) : this.defaultContentRenderer(this.props);
|
|
130
|
+
// VoiceOver can't navigate without the buttons, even though they don't do anything
|
|
151
131
|
return jsx("button", {
|
|
152
132
|
ref: this.handleRef,
|
|
153
133
|
tabIndex: -1,
|
|
@@ -155,7 +135,6 @@ let TreeButton = (_dec = withStyle(generateStyles, generateComponentTheme), _dec
|
|
|
155
135
|
css: styles === null || styles === void 0 ? void 0 : styles.treeButton
|
|
156
136
|
}, buttonContent);
|
|
157
137
|
}
|
|
158
|
-
|
|
159
138
|
}, _class2.displayName = "TreeButton", _class2.componentId = 'TreeBrowser.Button', _class2.allowedProps = allowedProps, _class2.propTypes = propTypes, _class2.defaultProps = {
|
|
160
139
|
type: 'treeButton',
|
|
161
140
|
size: 'medium',
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
+
|
|
24
25
|
import { keyframes } from '@instructure/emotion';
|
|
25
26
|
const transform = keyframes`
|
|
26
27
|
50% {
|
|
@@ -42,13 +43,12 @@ const transform = keyframes`
|
|
|
42
43
|
* @param {Object} props the props of the component, the style is applied to
|
|
43
44
|
* @return {Object} The final style object, which will be used in the component
|
|
44
45
|
*/
|
|
45
|
-
|
|
46
46
|
const generateStyles = (componentTheme, props) => {
|
|
47
47
|
const size = props.size,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
variant = props.variant,
|
|
49
|
+
selected = props.selected,
|
|
50
|
+
focused = props.focused,
|
|
51
|
+
level = props.level;
|
|
52
52
|
const isRootButton = level && level === 1;
|
|
53
53
|
const sizeMap = {
|
|
54
54
|
small: {
|
|
@@ -324,5 +324,4 @@ const generateStyles = (componentTheme, props) => {
|
|
|
324
324
|
}
|
|
325
325
|
};
|
|
326
326
|
};
|
|
327
|
-
|
|
328
327
|
export default generateStyles;
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
*/
|
|
30
30
|
const generateComponentTheme = theme => {
|
|
31
31
|
const colors = theme.colors,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
borders = theme.borders,
|
|
33
|
+
typography = theme.typography,
|
|
34
|
+
themeName = theme.key,
|
|
35
|
+
spacing = theme.spacing;
|
|
36
36
|
const themeSpecificStyles = {
|
|
37
37
|
canvas: {
|
|
38
38
|
iconColor: theme['ic-brand-font-color-dark'],
|
|
@@ -70,9 +70,9 @@ const generateComponentTheme = theme => {
|
|
|
70
70
|
selectedBackgroundColor: colors === null || colors === void 0 ? void 0 : colors.backgroundDark,
|
|
71
71
|
selectedOutlineWidth: borders === null || borders === void 0 ? void 0 : borders.widthLarge
|
|
72
72
|
};
|
|
73
|
-
return {
|
|
73
|
+
return {
|
|
74
|
+
...componentVariables,
|
|
74
75
|
...themeSpecificStyles[themeName]
|
|
75
76
|
};
|
|
76
77
|
};
|
|
77
|
-
|
|
78
78
|
export default generateComponentTheme;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
var _dec, _dec2, _class, _class2;
|
|
2
|
-
|
|
3
2
|
/*
|
|
4
3
|
* The MIT License (MIT)
|
|
5
4
|
*
|
|
@@ -25,7 +24,6 @@ var _dec, _dec2, _class, _class2;
|
|
|
25
24
|
*/
|
|
26
25
|
|
|
27
26
|
/** @jsx jsx */
|
|
28
|
-
|
|
29
27
|
/** @jsxFrag React.Fragment */
|
|
30
28
|
// eslint-disable-next-line no-unused-vars
|
|
31
29
|
import React, { Component } from 'react';
|
|
@@ -36,7 +34,6 @@ import { TreeButton } from '../TreeButton';
|
|
|
36
34
|
import generateStyles from './styles';
|
|
37
35
|
import generateComponentTheme from './theme';
|
|
38
36
|
import { allowedProps, propTypes } from './props';
|
|
39
|
-
|
|
40
37
|
/**
|
|
41
38
|
---
|
|
42
39
|
parent: TreeBrowser
|
|
@@ -48,104 +45,90 @@ let TreeCollection = (_dec = withStyle(generateStyles, generateComponentTheme),
|
|
|
48
45
|
constructor(props) {
|
|
49
46
|
super(props);
|
|
50
47
|
this.ref = null;
|
|
51
|
-
|
|
52
48
|
this.handleFocus = (e, item) => {
|
|
53
49
|
e.stopPropagation();
|
|
54
50
|
this.setState({
|
|
55
51
|
focused: `${item.type}_${item.id}`
|
|
56
52
|
});
|
|
57
53
|
};
|
|
58
|
-
|
|
59
54
|
this.handleBlur = (e, _item) => {
|
|
60
55
|
e.stopPropagation();
|
|
61
56
|
this.setState({
|
|
62
57
|
focused: ''
|
|
63
58
|
});
|
|
64
59
|
};
|
|
65
|
-
|
|
66
60
|
this.handleCollectionClick = e => {
|
|
67
61
|
const _this$props = this.props,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
62
|
+
id = _this$props.id,
|
|
63
|
+
onCollectionClick = _this$props.onCollectionClick,
|
|
64
|
+
expanded = _this$props.expanded;
|
|
71
65
|
const collection = {
|
|
72
66
|
id,
|
|
73
67
|
expanded: !expanded,
|
|
74
68
|
type: 'collection'
|
|
75
69
|
};
|
|
76
|
-
|
|
77
70
|
if (onCollectionClick && typeof onCollectionClick === 'function') {
|
|
78
71
|
onCollectionClick(e, collection);
|
|
79
72
|
}
|
|
80
73
|
};
|
|
81
|
-
|
|
82
74
|
this.handleCollectionKeyDown = e => {
|
|
83
75
|
const _this$props2 = this.props,
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
76
|
+
id = _this$props2.id,
|
|
77
|
+
onKeyDown = _this$props2.onKeyDown,
|
|
78
|
+
expanded = _this$props2.expanded;
|
|
87
79
|
const collection = {
|
|
88
80
|
id,
|
|
89
81
|
expanded: !expanded,
|
|
90
82
|
type: 'collection'
|
|
91
83
|
};
|
|
92
|
-
|
|
93
84
|
if (onKeyDown && typeof onKeyDown === 'function') {
|
|
94
85
|
onKeyDown(e, collection);
|
|
95
86
|
}
|
|
96
87
|
};
|
|
97
|
-
|
|
98
88
|
this.state = {
|
|
99
89
|
focused: ''
|
|
100
90
|
};
|
|
101
91
|
}
|
|
102
|
-
|
|
103
92
|
componentDidMount() {
|
|
104
93
|
var _this$props$makeStyle, _this$props3;
|
|
105
|
-
|
|
106
94
|
(_this$props$makeStyle = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props3);
|
|
107
95
|
}
|
|
108
|
-
|
|
109
96
|
componentDidUpdate() {
|
|
110
97
|
var _this$props$makeStyle2, _this$props4;
|
|
111
|
-
|
|
112
98
|
(_this$props$makeStyle2 = (_this$props4 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props4);
|
|
113
99
|
}
|
|
114
|
-
|
|
115
100
|
get itemsLevel() {
|
|
116
101
|
const _this$props5 = this.props,
|
|
117
|
-
|
|
118
|
-
|
|
102
|
+
level = _this$props5.level,
|
|
103
|
+
isCollectionFlattened = _this$props5.isCollectionFlattened;
|
|
119
104
|
return isCollectionFlattened ? level : level + 1;
|
|
120
105
|
}
|
|
121
|
-
|
|
122
106
|
get collectionsCount() {
|
|
123
107
|
const collections = this.props.collections;
|
|
124
108
|
return collections && collections.length > 0 ? collections.length : 0;
|
|
125
109
|
}
|
|
126
|
-
|
|
127
110
|
get itemsCount() {
|
|
128
111
|
const items = this.props.items;
|
|
129
112
|
return items && items.length > 0 ? items.length : 0;
|
|
130
113
|
}
|
|
131
|
-
|
|
132
114
|
get childCount() {
|
|
133
115
|
return this.collectionsCount + this.itemsCount + (this.props.renderBeforeItems ? 1 : 0) + (this.props.renderAfterItems ? 1 : 0);
|
|
134
116
|
}
|
|
135
|
-
|
|
136
117
|
sortChildren() {
|
|
137
118
|
const _this$props6 = this.props,
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
119
|
+
collections = _this$props6.collections,
|
|
120
|
+
items = _this$props6.items,
|
|
121
|
+
compareFunc = _this$props6.compareFunc;
|
|
141
122
|
if (!compareFunc) return [];
|
|
142
123
|
const collections_ = collections ? collections.map(collection => {
|
|
143
|
-
return {
|
|
124
|
+
return {
|
|
125
|
+
...collection,
|
|
144
126
|
type: 'collection'
|
|
145
127
|
};
|
|
146
128
|
}) : [];
|
|
147
129
|
const items_ = items ? items.map(item => {
|
|
148
|
-
return {
|
|
130
|
+
return {
|
|
131
|
+
...item,
|
|
149
132
|
type: 'item'
|
|
150
133
|
};
|
|
151
134
|
}) : [];
|
|
@@ -153,15 +136,14 @@ let TreeCollection = (_dec = withStyle(generateStyles, generateComponentTheme),
|
|
|
153
136
|
renderQueue.sort(compareFunc);
|
|
154
137
|
return renderQueue;
|
|
155
138
|
}
|
|
156
|
-
|
|
157
139
|
renderChildren() {
|
|
158
140
|
const _this$props7 = this.props,
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
141
|
+
collections = _this$props7.collections,
|
|
142
|
+
items = _this$props7.items,
|
|
143
|
+
id = _this$props7.id,
|
|
144
|
+
renderBeforeItems = _this$props7.renderBeforeItems,
|
|
145
|
+
renderAfterItems = _this$props7.renderAfterItems,
|
|
146
|
+
compareFunc = _this$props7.compareFunc;
|
|
165
147
|
let position = 1;
|
|
166
148
|
const sortedChildren = this.sortChildren();
|
|
167
149
|
return jsx(React.Fragment, null, renderBeforeItems && this.renderCollectionChildren(id, renderBeforeItems, position++, 'before'), !compareFunc && collections.map(collection => {
|
|
@@ -176,20 +158,17 @@ let TreeCollection = (_dec = withStyle(generateStyles, generateComponentTheme),
|
|
|
176
158
|
}
|
|
177
159
|
}), renderAfterItems && this.renderCollectionChildren(id, renderAfterItems, position++, 'after'));
|
|
178
160
|
}
|
|
179
|
-
|
|
180
161
|
renderCollectionChildren(collectionId, child, position, keyword) {
|
|
181
162
|
const _this$props8 = this.props,
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
163
|
+
selection = _this$props8.selection,
|
|
164
|
+
onKeyDown = _this$props8.onKeyDown,
|
|
165
|
+
getItemProps = _this$props8.getItemProps,
|
|
166
|
+
styles = _this$props8.styles;
|
|
186
167
|
const key = `${collectionId}_${keyword}`;
|
|
187
168
|
const ariaSelected = {};
|
|
188
|
-
|
|
189
169
|
if (selection) {
|
|
190
170
|
ariaSelected['aria-selected'] = selection === `child_${key}`;
|
|
191
171
|
}
|
|
192
|
-
|
|
193
172
|
const itemHash = {
|
|
194
173
|
id: key,
|
|
195
174
|
type: 'child'
|
|
@@ -228,7 +207,6 @@ let TreeCollection = (_dec = withStyle(generateStyles, generateComponentTheme),
|
|
|
228
207
|
onBlur: e => this.handleBlur(e, itemHash)
|
|
229
208
|
}), safeCloneElement(child, itemProps));
|
|
230
209
|
}
|
|
231
|
-
|
|
232
210
|
renderCollectionNode(collection, position) {
|
|
233
211
|
return jsx(TreeCollection, Object.assign({}, this.props, {
|
|
234
212
|
key: `c${position}`,
|
|
@@ -249,25 +227,23 @@ let TreeCollection = (_dec = withStyle(generateStyles, generateComponentTheme),
|
|
|
249
227
|
compareFunc: collection.compareFunc
|
|
250
228
|
}));
|
|
251
229
|
}
|
|
252
|
-
|
|
253
230
|
renderItemNode(item, position) {
|
|
254
231
|
const _this$props9 = this.props,
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
232
|
+
selection = _this$props9.selection,
|
|
233
|
+
onItemClick = _this$props9.onItemClick,
|
|
234
|
+
onKeyDown = _this$props9.onKeyDown,
|
|
235
|
+
getItemProps = _this$props9.getItemProps,
|
|
236
|
+
styles = _this$props9.styles;
|
|
260
237
|
const ariaSelected = {};
|
|
261
|
-
|
|
262
238
|
if (selection) {
|
|
263
239
|
ariaSelected['aria-selected'] = selection === `item_${item.id}`;
|
|
264
240
|
}
|
|
265
|
-
|
|
266
241
|
const itemHash = {
|
|
267
242
|
id: item.id,
|
|
268
243
|
type: 'item'
|
|
269
244
|
};
|
|
270
|
-
const itemProps = getItemProps({
|
|
245
|
+
const itemProps = getItemProps({
|
|
246
|
+
...this.getCommonButtonProps(),
|
|
271
247
|
id: item.id,
|
|
272
248
|
name: item.name,
|
|
273
249
|
descriptor: item.descriptor,
|
|
@@ -291,7 +267,6 @@ let TreeCollection = (_dec = withStyle(generateStyles, generateComponentTheme),
|
|
|
291
267
|
onBlur: e => this.handleBlur(e, itemHash)
|
|
292
268
|
}, ariaSelected), jsx(TreeButton, itemProps));
|
|
293
269
|
}
|
|
294
|
-
|
|
295
270
|
getCommonButtonProps() {
|
|
296
271
|
return {
|
|
297
272
|
id: this.props.id,
|
|
@@ -304,20 +279,20 @@ let TreeCollection = (_dec = withStyle(generateStyles, generateComponentTheme),
|
|
|
304
279
|
renderContent: this.props.renderContent
|
|
305
280
|
};
|
|
306
281
|
}
|
|
307
|
-
|
|
308
282
|
render() {
|
|
309
283
|
const _this$props10 = this.props,
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
const collectionProps = getCollectionProps({
|
|
284
|
+
id = _this$props10.id,
|
|
285
|
+
name = _this$props10.name,
|
|
286
|
+
expanded = _this$props10.expanded,
|
|
287
|
+
collectionIcon = _this$props10.collectionIcon,
|
|
288
|
+
collectionIconExpanded = _this$props10.collectionIconExpanded,
|
|
289
|
+
isCollectionFlattened = _this$props10.isCollectionFlattened,
|
|
290
|
+
getCollectionProps = _this$props10.getCollectionProps,
|
|
291
|
+
level = _this$props10.level,
|
|
292
|
+
position = _this$props10.position,
|
|
293
|
+
styles = _this$props10.styles;
|
|
294
|
+
const collectionProps = getCollectionProps({
|
|
295
|
+
...this.getCommonButtonProps(),
|
|
321
296
|
expanded: expanded,
|
|
322
297
|
collectionIcon: collectionIcon,
|
|
323
298
|
collectionIconExpanded: collectionIconExpanded,
|
|
@@ -357,7 +332,6 @@ let TreeCollection = (_dec = withStyle(generateStyles, generateComponentTheme),
|
|
|
357
332
|
role: "group"
|
|
358
333
|
}, this.renderChildren()));
|
|
359
334
|
}
|
|
360
|
-
|
|
361
335
|
}, _class2.displayName = "TreeCollection", _class2.componentId = 'TreeBrowser.Collection', _class2.allowedProps = allowedProps, _class2.propTypes = propTypes, _class2.defaultProps = {
|
|
362
336
|
collections: [],
|
|
363
337
|
items: [],
|
|
@@ -21,11 +21,13 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
+
|
|
24
25
|
import { keyframes } from '@instructure/emotion';
|
|
25
26
|
const list = keyframes`
|
|
26
27
|
to {
|
|
27
28
|
transform: scaleY(1);
|
|
28
29
|
}`;
|
|
30
|
+
|
|
29
31
|
/**
|
|
30
32
|
* ---
|
|
31
33
|
* private: true
|
|
@@ -39,7 +41,7 @@ const list = keyframes`
|
|
|
39
41
|
|
|
40
42
|
const generateStyles = (componentTheme, props) => {
|
|
41
43
|
const size = props.size,
|
|
42
|
-
|
|
44
|
+
variant = props.variant;
|
|
43
45
|
const sizeMap = {
|
|
44
46
|
small: {
|
|
45
47
|
indent: {
|
|
@@ -125,5 +127,4 @@ const generateStyles = (componentTheme, props) => {
|
|
|
125
127
|
}
|
|
126
128
|
};
|
|
127
129
|
};
|
|
128
|
-
|
|
129
130
|
export default generateStyles;
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
*/
|
|
30
30
|
const generateComponentTheme = theme => {
|
|
31
31
|
const colors = theme.colors,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
spacing = theme.spacing,
|
|
33
|
+
typography = theme.typography,
|
|
34
|
+
borders = theme.borders;
|
|
35
35
|
const componentVariables = {
|
|
36
36
|
fontFamily: typography === null || typography === void 0 ? void 0 : typography.fontFamily,
|
|
37
37
|
baseSpacingSmall: spacing === null || spacing === void 0 ? void 0 : spacing.xSmall,
|
|
@@ -40,8 +40,8 @@ const generateComponentTheme = theme => {
|
|
|
40
40
|
borderWidth: borders === null || borders === void 0 ? void 0 : borders.widthSmall,
|
|
41
41
|
borderColor: colors === null || colors === void 0 ? void 0 : colors.borderDark
|
|
42
42
|
};
|
|
43
|
-
return {
|
|
43
|
+
return {
|
|
44
|
+
...componentVariables
|
|
44
45
|
};
|
|
45
46
|
};
|
|
46
|
-
|
|
47
47
|
export default generateComponentTheme;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
var _dec, _dec2, _class, _class2;
|
|
2
|
-
|
|
3
2
|
/*
|
|
4
3
|
* The MIT License (MIT)
|
|
5
4
|
*
|
|
@@ -33,7 +32,9 @@ import { testable } from '@instructure/ui-testable';
|
|
|
33
32
|
import { withStyle, jsx } from '@instructure/emotion';
|
|
34
33
|
import generateStyles from '../TreeButton/styles';
|
|
35
34
|
import generateComponentTheme from '../TreeButton/theme';
|
|
36
|
-
import { allowedProps, propTypes } from './props';
|
|
35
|
+
import { allowedProps, propTypes } from './props';
|
|
36
|
+
|
|
37
|
+
// Todo: merge TreeButton and TreeNode: TreeButton should be a special type of TreeNode
|
|
37
38
|
|
|
38
39
|
/**
|
|
39
40
|
---
|
|
@@ -44,39 +45,30 @@ id: TreeBrowser.Node
|
|
|
44
45
|
A helper class used to render the :renderBeforeItems and :renderAfterItems
|
|
45
46
|
in the TreeBrowser.
|
|
46
47
|
**/
|
|
47
|
-
|
|
48
48
|
let TreeNode = (_dec = withStyle(generateStyles, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = (_class2 = class TreeNode extends Component {
|
|
49
49
|
constructor() {
|
|
50
50
|
super(...arguments);
|
|
51
51
|
this.ref = null;
|
|
52
|
-
|
|
53
52
|
this.handleRef = el => {
|
|
54
53
|
if (el && typeof this.props.containerRef === 'function') {
|
|
55
54
|
this.props.containerRef(el.parentElement);
|
|
56
55
|
}
|
|
57
|
-
|
|
58
56
|
this.ref = el;
|
|
59
57
|
};
|
|
60
58
|
}
|
|
61
|
-
|
|
62
59
|
componentDidMount() {
|
|
63
60
|
var _this$props$makeStyle, _this$props;
|
|
64
|
-
|
|
65
61
|
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
66
62
|
}
|
|
67
|
-
|
|
68
63
|
componentDidUpdate() {
|
|
69
64
|
var _this$props$makeStyle2, _this$props2;
|
|
70
|
-
|
|
71
65
|
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
72
66
|
}
|
|
73
|
-
|
|
74
67
|
renderItemImage() {
|
|
75
68
|
const _this$props3 = this.props,
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
69
|
+
thumbnail = _this$props3.thumbnail,
|
|
70
|
+
itemIcon = _this$props3.itemIcon,
|
|
71
|
+
styles = _this$props3.styles;
|
|
80
72
|
if (thumbnail) {
|
|
81
73
|
return jsx("div", {
|
|
82
74
|
css: styles === null || styles === void 0 ? void 0 : styles.thumbnail
|
|
@@ -86,20 +78,17 @@ let TreeNode = (_dec = withStyle(generateStyles, generateComponentTheme), _dec2
|
|
|
86
78
|
alt: ""
|
|
87
79
|
}));
|
|
88
80
|
}
|
|
89
|
-
|
|
90
81
|
if (itemIcon) {
|
|
91
82
|
return jsx("div", {
|
|
92
83
|
css: styles === null || styles === void 0 ? void 0 : styles.icon
|
|
93
84
|
}, callRenderProp(itemIcon));
|
|
94
85
|
}
|
|
95
|
-
|
|
96
86
|
return void 0;
|
|
97
87
|
}
|
|
98
|
-
|
|
99
88
|
render() {
|
|
100
89
|
const _this$props4 = this.props,
|
|
101
|
-
|
|
102
|
-
|
|
90
|
+
children = _this$props4.children,
|
|
91
|
+
styles = _this$props4.styles;
|
|
103
92
|
return jsx("div", {
|
|
104
93
|
ref: this.handleRef,
|
|
105
94
|
tabIndex: -1,
|
|
@@ -110,7 +99,6 @@ let TreeNode = (_dec = withStyle(generateStyles, generateComponentTheme), _dec2
|
|
|
110
99
|
css: styles === null || styles === void 0 ? void 0 : styles.node
|
|
111
100
|
}, children)));
|
|
112
101
|
}
|
|
113
|
-
|
|
114
102
|
}, _class2.displayName = "TreeNode", _class2.componentId = 'TreeBrowser.Node', _class2.allowedProps = allowedProps, _class2.propTypes = propTypes, _class2.defaultProps = {
|
|
115
103
|
size: 'medium',
|
|
116
104
|
variant: 'folderTree',
|