@instructure/ui-tree-browser 8.18.0 → 8.18.1-snapshot.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/LICENSE.md +27 -0
- package/es/TreeBrowser/TreeButton/index.js +22 -18
- package/es/TreeBrowser/TreeButton/theme.js +25 -25
- package/es/TreeBrowser/TreeCollection/index.js +44 -40
- package/es/TreeBrowser/TreeCollection/theme.js +5 -5
- package/es/TreeBrowser/TreeNode/index.js +18 -14
- package/es/TreeBrowser/index.js +20 -12
- package/es/TreeBrowser/theme.js +4 -4
- package/lib/TreeBrowser/TreeButton/index.js +22 -18
- package/lib/TreeBrowser/TreeButton/theme.js +25 -25
- package/lib/TreeBrowser/TreeCollection/index.js +44 -40
- package/lib/TreeBrowser/TreeCollection/theme.js +5 -5
- package/lib/TreeBrowser/TreeNode/index.js +18 -14
- package/lib/TreeBrowser/index.js +20 -12
- package/lib/TreeBrowser/theme.js +4 -4
- package/package.json +16 -15
package/LICENSE.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: The MIT License (MIT)
|
|
3
|
+
category: Getting Started
|
|
4
|
+
order: 9
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# The MIT License (MIT)
|
|
8
|
+
|
|
9
|
+
Copyright (c) 2015 Instructure, Inc.
|
|
10
|
+
|
|
11
|
+
**Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
13
|
+
in the Software without restriction, including without limitation the rights
|
|
14
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
16
|
+
furnished to do so, subject to the following conditions.**
|
|
17
|
+
|
|
18
|
+
The above copyright notice and this permission notice shall be included in all
|
|
19
|
+
copies or substantial portions of the Software.
|
|
20
|
+
|
|
21
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
|
+
SOFTWARE.
|
|
@@ -57,11 +57,15 @@ let TreeButton = (_dec = withStyle(generateStyles, generateComponentTheme), _dec
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
componentDidMount() {
|
|
60
|
-
|
|
60
|
+
var _this$props$makeStyle, _this$props;
|
|
61
|
+
|
|
62
|
+
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
61
63
|
}
|
|
62
64
|
|
|
63
65
|
componentDidUpdate() {
|
|
64
|
-
|
|
66
|
+
var _this$props$makeStyle2, _this$props2;
|
|
67
|
+
|
|
68
|
+
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
65
69
|
}
|
|
66
70
|
|
|
67
71
|
defaultContentRenderer(props) {
|
|
@@ -98,15 +102,15 @@ let TreeButton = (_dec = withStyle(generateStyles, generateComponentTheme), _dec
|
|
|
98
102
|
}
|
|
99
103
|
|
|
100
104
|
renderCollectionIcon() {
|
|
101
|
-
const _this$
|
|
102
|
-
expanded = _this$
|
|
103
|
-
collectionIcon = _this$
|
|
104
|
-
collectionIconExpanded = _this$
|
|
105
|
-
styles = _this$
|
|
105
|
+
const _this$props3 = this.props,
|
|
106
|
+
expanded = _this$props3.expanded,
|
|
107
|
+
collectionIcon = _this$props3.collectionIcon,
|
|
108
|
+
collectionIconExpanded = _this$props3.collectionIconExpanded,
|
|
109
|
+
styles = _this$props3.styles;
|
|
106
110
|
|
|
107
111
|
if (collectionIcon || collectionIconExpanded) {
|
|
108
112
|
return jsx("div", {
|
|
109
|
-
css: styles
|
|
113
|
+
css: styles === null || styles === void 0 ? void 0 : styles.icon
|
|
110
114
|
}, callRenderProp(expanded ? collectionIconExpanded : collectionIcon));
|
|
111
115
|
}
|
|
112
116
|
|
|
@@ -116,14 +120,14 @@ let TreeButton = (_dec = withStyle(generateStyles, generateComponentTheme), _dec
|
|
|
116
120
|
renderItemImage() {
|
|
117
121
|
var _Img;
|
|
118
122
|
|
|
119
|
-
const _this$
|
|
120
|
-
thumbnail = _this$
|
|
121
|
-
itemIcon = _this$
|
|
122
|
-
styles = _this$
|
|
123
|
+
const _this$props4 = this.props,
|
|
124
|
+
thumbnail = _this$props4.thumbnail,
|
|
125
|
+
itemIcon = _this$props4.itemIcon,
|
|
126
|
+
styles = _this$props4.styles;
|
|
123
127
|
|
|
124
128
|
if (thumbnail) {
|
|
125
129
|
return jsx("div", {
|
|
126
|
-
css: styles
|
|
130
|
+
css: styles === null || styles === void 0 ? void 0 : styles.thumbnail
|
|
127
131
|
}, _Img || (_Img = jsx(Img, {
|
|
128
132
|
src: thumbnail,
|
|
129
133
|
constrain: "cover",
|
|
@@ -133,7 +137,7 @@ let TreeButton = (_dec = withStyle(generateStyles, generateComponentTheme), _dec
|
|
|
133
137
|
|
|
134
138
|
if (itemIcon) {
|
|
135
139
|
return jsx("div", {
|
|
136
|
-
css: styles
|
|
140
|
+
css: styles === null || styles === void 0 ? void 0 : styles.icon
|
|
137
141
|
}, callRenderProp(itemIcon));
|
|
138
142
|
}
|
|
139
143
|
|
|
@@ -141,16 +145,16 @@ let TreeButton = (_dec = withStyle(generateStyles, generateComponentTheme), _dec
|
|
|
141
145
|
}
|
|
142
146
|
|
|
143
147
|
render() {
|
|
144
|
-
const _this$
|
|
145
|
-
styles = _this$
|
|
146
|
-
renderContent = _this$
|
|
148
|
+
const _this$props5 = this.props,
|
|
149
|
+
styles = _this$props5.styles,
|
|
150
|
+
renderContent = _this$props5.renderContent;
|
|
147
151
|
const buttonContent = renderContent ? renderContent(this.props) : this.defaultContentRenderer(this.props); // VoiceOver can't navigate without the buttons, even though they don't do anything
|
|
148
152
|
|
|
149
153
|
return jsx("button", {
|
|
150
154
|
ref: this.handleRef,
|
|
151
155
|
tabIndex: -1,
|
|
152
156
|
type: "button",
|
|
153
|
-
css: styles
|
|
157
|
+
css: styles === null || styles === void 0 ? void 0 : styles.treeButton
|
|
154
158
|
}, buttonContent);
|
|
155
159
|
}
|
|
156
160
|
|
|
@@ -43,32 +43,32 @@ const generateComponentTheme = theme => {
|
|
|
43
43
|
}
|
|
44
44
|
};
|
|
45
45
|
const componentVariables = {
|
|
46
|
-
hoverBackgroundColor: colors
|
|
47
|
-
hoverTextColor: colors
|
|
48
|
-
focusOutlineWidth: borders
|
|
49
|
-
focusOutlineColor: colors
|
|
50
|
-
focusOutlineStyle: borders
|
|
51
|
-
iconColor: colors
|
|
52
|
-
iconsMarginRight: spacing
|
|
53
|
-
descriptorMarginTop: spacing
|
|
54
|
-
descriptorTextColor: colors
|
|
55
|
-
descriptorFontSizeSmall: typography
|
|
56
|
-
descriptorFontSizeMedium: typography
|
|
57
|
-
descriptorFontSizeLarge: typography
|
|
58
|
-
nameTextColor: colors
|
|
59
|
-
nameFontSizeSmall: typography
|
|
60
|
-
nameFontSizeMedium: typography
|
|
61
|
-
nameFontSizeLarge: typography
|
|
62
|
-
baseSpacingSmall: spacing
|
|
63
|
-
baseSpacingMedium: spacing
|
|
46
|
+
hoverBackgroundColor: colors === null || colors === void 0 ? void 0 : colors.backgroundBrand,
|
|
47
|
+
hoverTextColor: colors === null || colors === void 0 ? void 0 : colors.textLightest,
|
|
48
|
+
focusOutlineWidth: borders === null || borders === void 0 ? void 0 : borders.widthMedium,
|
|
49
|
+
focusOutlineColor: colors === null || colors === void 0 ? void 0 : colors.borderBrand,
|
|
50
|
+
focusOutlineStyle: borders === null || borders === void 0 ? void 0 : borders.style,
|
|
51
|
+
iconColor: colors === null || colors === void 0 ? void 0 : colors.textDarkest,
|
|
52
|
+
iconsMarginRight: spacing === null || spacing === void 0 ? void 0 : spacing.xSmall,
|
|
53
|
+
descriptorMarginTop: spacing === null || spacing === void 0 ? void 0 : spacing.xxxSmall,
|
|
54
|
+
descriptorTextColor: colors === null || colors === void 0 ? void 0 : colors.textDarkest,
|
|
55
|
+
descriptorFontSizeSmall: typography === null || typography === void 0 ? void 0 : typography.fontSizeXSmall,
|
|
56
|
+
descriptorFontSizeMedium: typography === null || typography === void 0 ? void 0 : typography.fontSizeXSmall,
|
|
57
|
+
descriptorFontSizeLarge: typography === null || typography === void 0 ? void 0 : typography.fontSizeSmall,
|
|
58
|
+
nameTextColor: colors === null || colors === void 0 ? void 0 : colors.textBrand,
|
|
59
|
+
nameFontSizeSmall: typography === null || typography === void 0 ? void 0 : typography.fontSizeXSmall,
|
|
60
|
+
nameFontSizeMedium: typography === null || typography === void 0 ? void 0 : typography.fontSizeSmall,
|
|
61
|
+
nameFontSizeLarge: typography === null || typography === void 0 ? void 0 : typography.fontSizeMedium,
|
|
62
|
+
baseSpacingSmall: spacing === null || spacing === void 0 ? void 0 : spacing.xSmall,
|
|
63
|
+
baseSpacingMedium: spacing === null || spacing === void 0 ? void 0 : spacing.small,
|
|
64
64
|
baseSpacingLarge: '1rem',
|
|
65
|
-
borderWidth: borders
|
|
66
|
-
borderRadius: borders
|
|
67
|
-
borderColor: colors
|
|
68
|
-
textLineHeight: typography
|
|
69
|
-
selectedTextColor: colors
|
|
70
|
-
selectedBackgroundColor: colors
|
|
71
|
-
selectedOutlineWidth: borders
|
|
65
|
+
borderWidth: borders === null || borders === void 0 ? void 0 : borders.widthSmall,
|
|
66
|
+
borderRadius: borders === null || borders === void 0 ? void 0 : borders.radiusMedium,
|
|
67
|
+
borderColor: colors === null || colors === void 0 ? void 0 : colors.borderDark,
|
|
68
|
+
textLineHeight: typography === null || typography === void 0 ? void 0 : typography.lineHeightCondensed,
|
|
69
|
+
selectedTextColor: colors === null || colors === void 0 ? void 0 : colors.textLightest,
|
|
70
|
+
selectedBackgroundColor: colors === null || colors === void 0 ? void 0 : colors.backgroundDark,
|
|
71
|
+
selectedOutlineWidth: borders === null || borders === void 0 ? void 0 : borders.widthLarge
|
|
72
72
|
};
|
|
73
73
|
return { ...componentVariables,
|
|
74
74
|
...themeSpecificStyles[themeName]
|
|
@@ -101,17 +101,21 @@ let TreeCollection = (_dec = withStyle(generateStyles, generateComponentTheme),
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
componentDidMount() {
|
|
104
|
-
|
|
104
|
+
var _this$props$makeStyle, _this$props3;
|
|
105
|
+
|
|
106
|
+
(_this$props$makeStyle = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props3);
|
|
105
107
|
}
|
|
106
108
|
|
|
107
109
|
componentDidUpdate() {
|
|
108
|
-
|
|
110
|
+
var _this$props$makeStyle2, _this$props4;
|
|
111
|
+
|
|
112
|
+
(_this$props$makeStyle2 = (_this$props4 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props4);
|
|
109
113
|
}
|
|
110
114
|
|
|
111
115
|
get itemsLevel() {
|
|
112
|
-
const _this$
|
|
113
|
-
level = _this$
|
|
114
|
-
isCollectionFlattened = _this$
|
|
116
|
+
const _this$props5 = this.props,
|
|
117
|
+
level = _this$props5.level,
|
|
118
|
+
isCollectionFlattened = _this$props5.isCollectionFlattened;
|
|
115
119
|
return isCollectionFlattened ? level : level + 1;
|
|
116
120
|
}
|
|
117
121
|
|
|
@@ -130,12 +134,12 @@ let TreeCollection = (_dec = withStyle(generateStyles, generateComponentTheme),
|
|
|
130
134
|
}
|
|
131
135
|
|
|
132
136
|
renderChildren() {
|
|
133
|
-
const _this$
|
|
134
|
-
collections = _this$
|
|
135
|
-
items = _this$
|
|
136
|
-
id = _this$
|
|
137
|
-
renderBeforeItems = _this$
|
|
138
|
-
renderAfterItems = _this$
|
|
137
|
+
const _this$props6 = this.props,
|
|
138
|
+
collections = _this$props6.collections,
|
|
139
|
+
items = _this$props6.items,
|
|
140
|
+
id = _this$props6.id,
|
|
141
|
+
renderBeforeItems = _this$props6.renderBeforeItems,
|
|
142
|
+
renderAfterItems = _this$props6.renderAfterItems;
|
|
139
143
|
let position = 1;
|
|
140
144
|
return jsx(React.Fragment, null, renderBeforeItems && this.renderCollectionChildren(id, renderBeforeItems, position++, 'before'), collections.map(collection => {
|
|
141
145
|
return this.renderCollectionNode(collection, position++);
|
|
@@ -145,11 +149,11 @@ let TreeCollection = (_dec = withStyle(generateStyles, generateComponentTheme),
|
|
|
145
149
|
}
|
|
146
150
|
|
|
147
151
|
renderCollectionChildren(collectionId, child, position, keyword) {
|
|
148
|
-
const _this$
|
|
149
|
-
selection = _this$
|
|
150
|
-
onKeyDown = _this$
|
|
151
|
-
getItemProps = _this$
|
|
152
|
-
styles = _this$
|
|
152
|
+
const _this$props7 = this.props,
|
|
153
|
+
selection = _this$props7.selection,
|
|
154
|
+
onKeyDown = _this$props7.onKeyDown,
|
|
155
|
+
getItemProps = _this$props7.getItemProps,
|
|
156
|
+
styles = _this$props7.styles;
|
|
153
157
|
const key = `${collectionId}_${keyword}`;
|
|
154
158
|
const ariaSelected = {};
|
|
155
159
|
|
|
@@ -170,7 +174,7 @@ let TreeCollection = (_dec = withStyle(generateStyles, generateComponentTheme),
|
|
|
170
174
|
return jsx("li", Object.assign({
|
|
171
175
|
id: key,
|
|
172
176
|
role: "treeitem",
|
|
173
|
-
css: styles
|
|
177
|
+
css: styles === null || styles === void 0 ? void 0 : styles.item,
|
|
174
178
|
tabIndex: -1,
|
|
175
179
|
key: key,
|
|
176
180
|
"aria-posinset": position,
|
|
@@ -191,7 +195,7 @@ let TreeCollection = (_dec = withStyle(generateStyles, generateComponentTheme),
|
|
|
191
195
|
if (typeof child.props.onKeyDown === 'function') {
|
|
192
196
|
child.props.onKeyDown(e, n);
|
|
193
197
|
} else {
|
|
194
|
-
onKeyDown
|
|
198
|
+
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(e, itemHash);
|
|
195
199
|
}
|
|
196
200
|
},
|
|
197
201
|
onBlur: e => this.handleBlur(e, itemHash)
|
|
@@ -219,12 +223,12 @@ let TreeCollection = (_dec = withStyle(generateStyles, generateComponentTheme),
|
|
|
219
223
|
}
|
|
220
224
|
|
|
221
225
|
renderItemNode(item, position) {
|
|
222
|
-
const _this$
|
|
223
|
-
selection = _this$
|
|
224
|
-
onItemClick = _this$
|
|
225
|
-
onKeyDown = _this$
|
|
226
|
-
getItemProps = _this$
|
|
227
|
-
styles = _this$
|
|
226
|
+
const _this$props8 = this.props,
|
|
227
|
+
selection = _this$props8.selection,
|
|
228
|
+
onItemClick = _this$props8.onItemClick,
|
|
229
|
+
onKeyDown = _this$props8.onKeyDown,
|
|
230
|
+
getItemProps = _this$props8.getItemProps,
|
|
231
|
+
styles = _this$props8.styles;
|
|
228
232
|
const ariaSelected = {};
|
|
229
233
|
|
|
230
234
|
if (selection) {
|
|
@@ -249,12 +253,12 @@ let TreeCollection = (_dec = withStyle(generateStyles, generateComponentTheme),
|
|
|
249
253
|
tabIndex: -1,
|
|
250
254
|
role: "treeitem",
|
|
251
255
|
"aria-label": item.name,
|
|
252
|
-
css: styles
|
|
256
|
+
css: styles === null || styles === void 0 ? void 0 : styles.item,
|
|
253
257
|
"aria-level": this.itemsLevel,
|
|
254
258
|
"aria-posinset": position,
|
|
255
259
|
"aria-setsize": this.childCount,
|
|
256
|
-
onClick: e => onItemClick
|
|
257
|
-
onKeyDown: e => onKeyDown
|
|
260
|
+
onClick: e => onItemClick === null || onItemClick === void 0 ? void 0 : onItemClick(e, itemHash),
|
|
261
|
+
onKeyDown: e => onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(e, itemHash),
|
|
258
262
|
onFocus: e => this.handleFocus(e, itemHash),
|
|
259
263
|
onBlur: e => this.handleBlur(e, itemHash)
|
|
260
264
|
}, ariaSelected), jsx(TreeButton, itemProps));
|
|
@@ -274,17 +278,17 @@ let TreeCollection = (_dec = withStyle(generateStyles, generateComponentTheme),
|
|
|
274
278
|
}
|
|
275
279
|
|
|
276
280
|
render() {
|
|
277
|
-
const _this$
|
|
278
|
-
id = _this$
|
|
279
|
-
name = _this$
|
|
280
|
-
expanded = _this$
|
|
281
|
-
collectionIcon = _this$
|
|
282
|
-
collectionIconExpanded = _this$
|
|
283
|
-
isCollectionFlattened = _this$
|
|
284
|
-
getCollectionProps = _this$
|
|
285
|
-
level = _this$
|
|
286
|
-
position = _this$
|
|
287
|
-
styles = _this$
|
|
281
|
+
const _this$props9 = this.props,
|
|
282
|
+
id = _this$props9.id,
|
|
283
|
+
name = _this$props9.name,
|
|
284
|
+
expanded = _this$props9.expanded,
|
|
285
|
+
collectionIcon = _this$props9.collectionIcon,
|
|
286
|
+
collectionIconExpanded = _this$props9.collectionIconExpanded,
|
|
287
|
+
isCollectionFlattened = _this$props9.isCollectionFlattened,
|
|
288
|
+
getCollectionProps = _this$props9.getCollectionProps,
|
|
289
|
+
level = _this$props9.level,
|
|
290
|
+
position = _this$props9.position,
|
|
291
|
+
styles = _this$props9.styles;
|
|
288
292
|
const collectionProps = getCollectionProps({ ...this.getCommonButtonProps(),
|
|
289
293
|
expanded: expanded,
|
|
290
294
|
collectionIcon: collectionIcon,
|
|
@@ -301,7 +305,7 @@ let TreeCollection = (_dec = withStyle(generateStyles, generateComponentTheme),
|
|
|
301
305
|
ref: el => {
|
|
302
306
|
this.ref = el;
|
|
303
307
|
},
|
|
304
|
-
css: styles
|
|
308
|
+
css: styles === null || styles === void 0 ? void 0 : styles.treeCollection,
|
|
305
309
|
tabIndex: -1,
|
|
306
310
|
role: "treeitem",
|
|
307
311
|
"aria-label": this.props.name,
|
|
@@ -321,7 +325,7 @@ let TreeCollection = (_dec = withStyle(generateStyles, generateComponentTheme),
|
|
|
321
325
|
})
|
|
322
326
|
}, ariaSelected), jsx(TreeButton, collectionProps), expanded && this.childCount > 0 && jsx("ul", {
|
|
323
327
|
"aria-label": name,
|
|
324
|
-
css: styles
|
|
328
|
+
css: styles === null || styles === void 0 ? void 0 : styles.list,
|
|
325
329
|
role: "group"
|
|
326
330
|
}, this.renderChildren()));
|
|
327
331
|
}
|
|
@@ -33,12 +33,12 @@ const generateComponentTheme = theme => {
|
|
|
33
33
|
typography = theme.typography,
|
|
34
34
|
borders = theme.borders;
|
|
35
35
|
const componentVariables = {
|
|
36
|
-
fontFamily: typography
|
|
37
|
-
baseSpacingSmall: spacing
|
|
38
|
-
baseSpacingMedium: spacing
|
|
36
|
+
fontFamily: typography === null || typography === void 0 ? void 0 : typography.fontFamily,
|
|
37
|
+
baseSpacingSmall: spacing === null || spacing === void 0 ? void 0 : spacing.xSmall,
|
|
38
|
+
baseSpacingMedium: spacing === null || spacing === void 0 ? void 0 : spacing.small,
|
|
39
39
|
baseSpacingLarge: '1rem',
|
|
40
|
-
borderWidth: borders
|
|
41
|
-
borderColor: colors
|
|
40
|
+
borderWidth: borders === null || borders === void 0 ? void 0 : borders.widthSmall,
|
|
41
|
+
borderColor: colors === null || colors === void 0 ? void 0 : colors.borderDark
|
|
42
42
|
};
|
|
43
43
|
return { ...componentVariables
|
|
44
44
|
};
|
|
@@ -60,24 +60,28 @@ let TreeNode = (_dec = withStyle(generateStyles, generateComponentTheme), _dec2
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
componentDidMount() {
|
|
63
|
-
|
|
63
|
+
var _this$props$makeStyle, _this$props;
|
|
64
|
+
|
|
65
|
+
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
64
66
|
}
|
|
65
67
|
|
|
66
68
|
componentDidUpdate() {
|
|
67
|
-
|
|
69
|
+
var _this$props$makeStyle2, _this$props2;
|
|
70
|
+
|
|
71
|
+
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
68
72
|
}
|
|
69
73
|
|
|
70
74
|
renderItemImage() {
|
|
71
75
|
var _Img;
|
|
72
76
|
|
|
73
|
-
const _this$
|
|
74
|
-
thumbnail = _this$
|
|
75
|
-
itemIcon = _this$
|
|
76
|
-
styles = _this$
|
|
77
|
+
const _this$props3 = this.props,
|
|
78
|
+
thumbnail = _this$props3.thumbnail,
|
|
79
|
+
itemIcon = _this$props3.itemIcon,
|
|
80
|
+
styles = _this$props3.styles;
|
|
77
81
|
|
|
78
82
|
if (thumbnail) {
|
|
79
83
|
return jsx("div", {
|
|
80
|
-
css: styles
|
|
84
|
+
css: styles === null || styles === void 0 ? void 0 : styles.thumbnail
|
|
81
85
|
}, _Img || (_Img = jsx(Img, {
|
|
82
86
|
src: thumbnail,
|
|
83
87
|
constrain: "cover",
|
|
@@ -87,7 +91,7 @@ let TreeNode = (_dec = withStyle(generateStyles, generateComponentTheme), _dec2
|
|
|
87
91
|
|
|
88
92
|
if (itemIcon) {
|
|
89
93
|
return jsx("div", {
|
|
90
|
-
css: styles
|
|
94
|
+
css: styles === null || styles === void 0 ? void 0 : styles.icon
|
|
91
95
|
}, callRenderProp(itemIcon));
|
|
92
96
|
}
|
|
93
97
|
|
|
@@ -95,17 +99,17 @@ let TreeNode = (_dec = withStyle(generateStyles, generateComponentTheme), _dec2
|
|
|
95
99
|
}
|
|
96
100
|
|
|
97
101
|
render() {
|
|
98
|
-
const _this$
|
|
99
|
-
children = _this$
|
|
100
|
-
styles = _this$
|
|
102
|
+
const _this$props4 = this.props,
|
|
103
|
+
children = _this$props4.children,
|
|
104
|
+
styles = _this$props4.styles;
|
|
101
105
|
return jsx("div", {
|
|
102
106
|
ref: this.handleRef,
|
|
103
107
|
tabIndex: -1,
|
|
104
|
-
css: styles
|
|
108
|
+
css: styles === null || styles === void 0 ? void 0 : styles.treeButton
|
|
105
109
|
}, jsx("span", {
|
|
106
|
-
css: styles
|
|
110
|
+
css: styles === null || styles === void 0 ? void 0 : styles.layout
|
|
107
111
|
}, this.renderItemImage(), jsx("span", {
|
|
108
|
-
css: styles
|
|
112
|
+
css: styles === null || styles === void 0 ? void 0 : styles.node
|
|
109
113
|
}, children)));
|
|
110
114
|
}
|
|
111
115
|
|
package/es/TreeBrowser/index.js
CHANGED
|
@@ -57,14 +57,16 @@ let TreeBrowser = (_dec = withStyle(generateStyles, generateComponentTheme), _de
|
|
|
57
57
|
e.stopPropagation();
|
|
58
58
|
const onCollectionClick = _this.props.onCollectionClick;
|
|
59
59
|
if (expand) _this.expandOrCollapseNode(collection);
|
|
60
|
-
onCollectionClick
|
|
60
|
+
onCollectionClick === null || onCollectionClick === void 0 ? void 0 : onCollectionClick(collection.id, collection); // TODO: this should pass the event as the first arg
|
|
61
61
|
|
|
62
62
|
_this.handleSelection(collection.id, 'collection');
|
|
63
63
|
};
|
|
64
64
|
|
|
65
65
|
this.handleItemClick = (e, item) => {
|
|
66
|
+
var _this$props$onItemCli, _this$props;
|
|
67
|
+
|
|
66
68
|
e.stopPropagation();
|
|
67
|
-
this.props.onItemClick
|
|
69
|
+
(_this$props$onItemCli = (_this$props = this.props).onItemClick) === null || _this$props$onItemCli === void 0 ? void 0 : _this$props$onItemCli.call(_this$props, item);
|
|
68
70
|
this.handleSelection(item.id, 'item');
|
|
69
71
|
};
|
|
70
72
|
|
|
@@ -105,9 +107,9 @@ let TreeBrowser = (_dec = withStyle(generateStyles, generateComponentTheme), _de
|
|
|
105
107
|
};
|
|
106
108
|
|
|
107
109
|
this.getIsFlattened = collection => {
|
|
108
|
-
const _this$
|
|
109
|
-
rootId = _this$
|
|
110
|
-
showRootCollection = _this$
|
|
110
|
+
const _this$props2 = this.props,
|
|
111
|
+
rootId = _this$props2.rootId,
|
|
112
|
+
showRootCollection = _this$props2.showRootCollection;
|
|
111
113
|
return !showRootCollection && typeof rootId !== 'undefined' && collection.id === rootId;
|
|
112
114
|
};
|
|
113
115
|
|
|
@@ -124,11 +126,15 @@ let TreeBrowser = (_dec = withStyle(generateStyles, generateComponentTheme), _de
|
|
|
124
126
|
}
|
|
125
127
|
|
|
126
128
|
componentDidMount() {
|
|
127
|
-
|
|
129
|
+
var _this$props$makeStyle, _this$props3;
|
|
130
|
+
|
|
131
|
+
(_this$props$makeStyle = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props3);
|
|
128
132
|
}
|
|
129
133
|
|
|
130
134
|
componentDidUpdate() {
|
|
131
|
-
|
|
135
|
+
var _this$props$makeStyle2, _this$props4;
|
|
136
|
+
|
|
137
|
+
(_this$props$makeStyle2 = (_this$props4 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props4);
|
|
132
138
|
}
|
|
133
139
|
|
|
134
140
|
get _root() {
|
|
@@ -136,9 +142,9 @@ let TreeBrowser = (_dec = withStyle(generateStyles, generateComponentTheme), _de
|
|
|
136
142
|
}
|
|
137
143
|
|
|
138
144
|
get collections() {
|
|
139
|
-
const _this$
|
|
140
|
-
collections = _this$
|
|
141
|
-
rootId = _this$
|
|
145
|
+
const _this$props5 = this.props,
|
|
146
|
+
collections = _this$props5.collections,
|
|
147
|
+
rootId = _this$props5.rootId;
|
|
142
148
|
|
|
143
149
|
if (typeof rootId !== 'undefined') {
|
|
144
150
|
return [collections[rootId]];
|
|
@@ -156,7 +162,9 @@ let TreeBrowser = (_dec = withStyle(generateStyles, generateComponentTheme), _de
|
|
|
156
162
|
}
|
|
157
163
|
|
|
158
164
|
expandOrCollapseNode(collection) {
|
|
159
|
-
|
|
165
|
+
var _this$props$onCollect, _this$props6;
|
|
166
|
+
|
|
167
|
+
(_this$props$onCollect = (_this$props6 = this.props).onCollectionToggle) === null || _this$props$onCollect === void 0 ? void 0 : _this$props$onCollect.call(_this$props6, collection);
|
|
160
168
|
|
|
161
169
|
if (typeof this.props.expanded === 'undefined') {
|
|
162
170
|
this.setState((state, props) => {
|
|
@@ -314,7 +322,7 @@ let TreeBrowser = (_dec = withStyle(generateStyles, generateComponentTheme), _de
|
|
|
314
322
|
render() {
|
|
315
323
|
const styles = this.props.styles;
|
|
316
324
|
return jsx("ul", {
|
|
317
|
-
css: styles
|
|
325
|
+
css: styles === null || styles === void 0 ? void 0 : styles.treeBrowser,
|
|
318
326
|
tabIndex: 0,
|
|
319
327
|
role: "tree",
|
|
320
328
|
onKeyDown: this.handleKeyDown,
|
package/es/TreeBrowser/theme.js
CHANGED
|
@@ -31,10 +31,10 @@ const generateComponentTheme = theme => {
|
|
|
31
31
|
const colors = theme.colors,
|
|
32
32
|
borders = theme.borders;
|
|
33
33
|
const componentVariables = {
|
|
34
|
-
borderRadius: borders
|
|
35
|
-
focusOutlineWidth: borders
|
|
36
|
-
focusOutlineColor: colors
|
|
37
|
-
focusOutlineStyle: borders
|
|
34
|
+
borderRadius: borders === null || borders === void 0 ? void 0 : borders.radiusMedium,
|
|
35
|
+
focusOutlineWidth: borders === null || borders === void 0 ? void 0 : borders.widthMedium,
|
|
36
|
+
focusOutlineColor: colors === null || colors === void 0 ? void 0 : colors.borderBrand,
|
|
37
|
+
focusOutlineStyle: borders === null || borders === void 0 ? void 0 : borders.style
|
|
38
38
|
};
|
|
39
39
|
return { ...componentVariables
|
|
40
40
|
};
|
|
@@ -49,11 +49,15 @@ let TreeButton = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
componentDidMount() {
|
|
52
|
-
|
|
52
|
+
var _this$props$makeStyle, _this$props;
|
|
53
|
+
|
|
54
|
+
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
53
55
|
}
|
|
54
56
|
|
|
55
57
|
componentDidUpdate() {
|
|
56
|
-
|
|
58
|
+
var _this$props$makeStyle2, _this$props2;
|
|
59
|
+
|
|
60
|
+
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
57
61
|
}
|
|
58
62
|
|
|
59
63
|
defaultContentRenderer(props) {
|
|
@@ -90,15 +94,15 @@ let TreeButton = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default
|
|
|
90
94
|
}
|
|
91
95
|
|
|
92
96
|
renderCollectionIcon() {
|
|
93
|
-
const _this$
|
|
94
|
-
expanded = _this$
|
|
95
|
-
collectionIcon = _this$
|
|
96
|
-
collectionIconExpanded = _this$
|
|
97
|
-
styles = _this$
|
|
97
|
+
const _this$props3 = this.props,
|
|
98
|
+
expanded = _this$props3.expanded,
|
|
99
|
+
collectionIcon = _this$props3.collectionIcon,
|
|
100
|
+
collectionIconExpanded = _this$props3.collectionIconExpanded,
|
|
101
|
+
styles = _this$props3.styles;
|
|
98
102
|
|
|
99
103
|
if (collectionIcon || collectionIconExpanded) {
|
|
100
104
|
return (0, _emotion.jsx)("div", {
|
|
101
|
-
css: styles
|
|
105
|
+
css: styles === null || styles === void 0 ? void 0 : styles.icon
|
|
102
106
|
}, (0, _callRenderProp.callRenderProp)(expanded ? collectionIconExpanded : collectionIcon));
|
|
103
107
|
}
|
|
104
108
|
|
|
@@ -108,14 +112,14 @@ let TreeButton = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default
|
|
|
108
112
|
renderItemImage() {
|
|
109
113
|
var _Img;
|
|
110
114
|
|
|
111
|
-
const _this$
|
|
112
|
-
thumbnail = _this$
|
|
113
|
-
itemIcon = _this$
|
|
114
|
-
styles = _this$
|
|
115
|
+
const _this$props4 = this.props,
|
|
116
|
+
thumbnail = _this$props4.thumbnail,
|
|
117
|
+
itemIcon = _this$props4.itemIcon,
|
|
118
|
+
styles = _this$props4.styles;
|
|
115
119
|
|
|
116
120
|
if (thumbnail) {
|
|
117
121
|
return (0, _emotion.jsx)("div", {
|
|
118
|
-
css: styles
|
|
122
|
+
css: styles === null || styles === void 0 ? void 0 : styles.thumbnail
|
|
119
123
|
}, _Img || (_Img = (0, _emotion.jsx)(_Img2.Img, {
|
|
120
124
|
src: thumbnail,
|
|
121
125
|
constrain: "cover",
|
|
@@ -125,7 +129,7 @@ let TreeButton = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default
|
|
|
125
129
|
|
|
126
130
|
if (itemIcon) {
|
|
127
131
|
return (0, _emotion.jsx)("div", {
|
|
128
|
-
css: styles
|
|
132
|
+
css: styles === null || styles === void 0 ? void 0 : styles.icon
|
|
129
133
|
}, (0, _callRenderProp.callRenderProp)(itemIcon));
|
|
130
134
|
}
|
|
131
135
|
|
|
@@ -133,16 +137,16 @@ let TreeButton = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default
|
|
|
133
137
|
}
|
|
134
138
|
|
|
135
139
|
render() {
|
|
136
|
-
const _this$
|
|
137
|
-
styles = _this$
|
|
138
|
-
renderContent = _this$
|
|
140
|
+
const _this$props5 = this.props,
|
|
141
|
+
styles = _this$props5.styles,
|
|
142
|
+
renderContent = _this$props5.renderContent;
|
|
139
143
|
const buttonContent = renderContent ? renderContent(this.props) : this.defaultContentRenderer(this.props); // VoiceOver can't navigate without the buttons, even though they don't do anything
|
|
140
144
|
|
|
141
145
|
return (0, _emotion.jsx)("button", {
|
|
142
146
|
ref: this.handleRef,
|
|
143
147
|
tabIndex: -1,
|
|
144
148
|
type: "button",
|
|
145
|
-
css: styles
|
|
149
|
+
css: styles === null || styles === void 0 ? void 0 : styles.treeButton
|
|
146
150
|
}, buttonContent);
|
|
147
151
|
}
|
|
148
152
|
|
|
@@ -50,32 +50,32 @@ const generateComponentTheme = theme => {
|
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
52
|
const componentVariables = {
|
|
53
|
-
hoverBackgroundColor: colors
|
|
54
|
-
hoverTextColor: colors
|
|
55
|
-
focusOutlineWidth: borders
|
|
56
|
-
focusOutlineColor: colors
|
|
57
|
-
focusOutlineStyle: borders
|
|
58
|
-
iconColor: colors
|
|
59
|
-
iconsMarginRight: spacing
|
|
60
|
-
descriptorMarginTop: spacing
|
|
61
|
-
descriptorTextColor: colors
|
|
62
|
-
descriptorFontSizeSmall: typography
|
|
63
|
-
descriptorFontSizeMedium: typography
|
|
64
|
-
descriptorFontSizeLarge: typography
|
|
65
|
-
nameTextColor: colors
|
|
66
|
-
nameFontSizeSmall: typography
|
|
67
|
-
nameFontSizeMedium: typography
|
|
68
|
-
nameFontSizeLarge: typography
|
|
69
|
-
baseSpacingSmall: spacing
|
|
70
|
-
baseSpacingMedium: spacing
|
|
53
|
+
hoverBackgroundColor: colors === null || colors === void 0 ? void 0 : colors.backgroundBrand,
|
|
54
|
+
hoverTextColor: colors === null || colors === void 0 ? void 0 : colors.textLightest,
|
|
55
|
+
focusOutlineWidth: borders === null || borders === void 0 ? void 0 : borders.widthMedium,
|
|
56
|
+
focusOutlineColor: colors === null || colors === void 0 ? void 0 : colors.borderBrand,
|
|
57
|
+
focusOutlineStyle: borders === null || borders === void 0 ? void 0 : borders.style,
|
|
58
|
+
iconColor: colors === null || colors === void 0 ? void 0 : colors.textDarkest,
|
|
59
|
+
iconsMarginRight: spacing === null || spacing === void 0 ? void 0 : spacing.xSmall,
|
|
60
|
+
descriptorMarginTop: spacing === null || spacing === void 0 ? void 0 : spacing.xxxSmall,
|
|
61
|
+
descriptorTextColor: colors === null || colors === void 0 ? void 0 : colors.textDarkest,
|
|
62
|
+
descriptorFontSizeSmall: typography === null || typography === void 0 ? void 0 : typography.fontSizeXSmall,
|
|
63
|
+
descriptorFontSizeMedium: typography === null || typography === void 0 ? void 0 : typography.fontSizeXSmall,
|
|
64
|
+
descriptorFontSizeLarge: typography === null || typography === void 0 ? void 0 : typography.fontSizeSmall,
|
|
65
|
+
nameTextColor: colors === null || colors === void 0 ? void 0 : colors.textBrand,
|
|
66
|
+
nameFontSizeSmall: typography === null || typography === void 0 ? void 0 : typography.fontSizeXSmall,
|
|
67
|
+
nameFontSizeMedium: typography === null || typography === void 0 ? void 0 : typography.fontSizeSmall,
|
|
68
|
+
nameFontSizeLarge: typography === null || typography === void 0 ? void 0 : typography.fontSizeMedium,
|
|
69
|
+
baseSpacingSmall: spacing === null || spacing === void 0 ? void 0 : spacing.xSmall,
|
|
70
|
+
baseSpacingMedium: spacing === null || spacing === void 0 ? void 0 : spacing.small,
|
|
71
71
|
baseSpacingLarge: '1rem',
|
|
72
|
-
borderWidth: borders
|
|
73
|
-
borderRadius: borders
|
|
74
|
-
borderColor: colors
|
|
75
|
-
textLineHeight: typography
|
|
76
|
-
selectedTextColor: colors
|
|
77
|
-
selectedBackgroundColor: colors
|
|
78
|
-
selectedOutlineWidth: borders
|
|
72
|
+
borderWidth: borders === null || borders === void 0 ? void 0 : borders.widthSmall,
|
|
73
|
+
borderRadius: borders === null || borders === void 0 ? void 0 : borders.radiusMedium,
|
|
74
|
+
borderColor: colors === null || colors === void 0 ? void 0 : colors.borderDark,
|
|
75
|
+
textLineHeight: typography === null || typography === void 0 ? void 0 : typography.lineHeightCondensed,
|
|
76
|
+
selectedTextColor: colors === null || colors === void 0 ? void 0 : colors.textLightest,
|
|
77
|
+
selectedBackgroundColor: colors === null || colors === void 0 ? void 0 : colors.backgroundDark,
|
|
78
|
+
selectedOutlineWidth: borders === null || borders === void 0 ? void 0 : borders.widthLarge
|
|
79
79
|
};
|
|
80
80
|
return { ...componentVariables,
|
|
81
81
|
...themeSpecificStyles[themeName]
|
|
@@ -91,17 +91,21 @@ let TreeCollection = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.def
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
componentDidMount() {
|
|
94
|
-
|
|
94
|
+
var _this$props$makeStyle, _this$props3;
|
|
95
|
+
|
|
96
|
+
(_this$props$makeStyle = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props3);
|
|
95
97
|
}
|
|
96
98
|
|
|
97
99
|
componentDidUpdate() {
|
|
98
|
-
|
|
100
|
+
var _this$props$makeStyle2, _this$props4;
|
|
101
|
+
|
|
102
|
+
(_this$props$makeStyle2 = (_this$props4 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props4);
|
|
99
103
|
}
|
|
100
104
|
|
|
101
105
|
get itemsLevel() {
|
|
102
|
-
const _this$
|
|
103
|
-
level = _this$
|
|
104
|
-
isCollectionFlattened = _this$
|
|
106
|
+
const _this$props5 = this.props,
|
|
107
|
+
level = _this$props5.level,
|
|
108
|
+
isCollectionFlattened = _this$props5.isCollectionFlattened;
|
|
105
109
|
return isCollectionFlattened ? level : level + 1;
|
|
106
110
|
}
|
|
107
111
|
|
|
@@ -120,12 +124,12 @@ let TreeCollection = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.def
|
|
|
120
124
|
}
|
|
121
125
|
|
|
122
126
|
renderChildren() {
|
|
123
|
-
const _this$
|
|
124
|
-
collections = _this$
|
|
125
|
-
items = _this$
|
|
126
|
-
id = _this$
|
|
127
|
-
renderBeforeItems = _this$
|
|
128
|
-
renderAfterItems = _this$
|
|
127
|
+
const _this$props6 = this.props,
|
|
128
|
+
collections = _this$props6.collections,
|
|
129
|
+
items = _this$props6.items,
|
|
130
|
+
id = _this$props6.id,
|
|
131
|
+
renderBeforeItems = _this$props6.renderBeforeItems,
|
|
132
|
+
renderAfterItems = _this$props6.renderAfterItems;
|
|
129
133
|
let position = 1;
|
|
130
134
|
return (0, _emotion.jsx)(_react.default.Fragment, null, renderBeforeItems && this.renderCollectionChildren(id, renderBeforeItems, position++, 'before'), collections.map(collection => {
|
|
131
135
|
return this.renderCollectionNode(collection, position++);
|
|
@@ -135,11 +139,11 @@ let TreeCollection = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.def
|
|
|
135
139
|
}
|
|
136
140
|
|
|
137
141
|
renderCollectionChildren(collectionId, child, position, keyword) {
|
|
138
|
-
const _this$
|
|
139
|
-
selection = _this$
|
|
140
|
-
onKeyDown = _this$
|
|
141
|
-
getItemProps = _this$
|
|
142
|
-
styles = _this$
|
|
142
|
+
const _this$props7 = this.props,
|
|
143
|
+
selection = _this$props7.selection,
|
|
144
|
+
onKeyDown = _this$props7.onKeyDown,
|
|
145
|
+
getItemProps = _this$props7.getItemProps,
|
|
146
|
+
styles = _this$props7.styles;
|
|
143
147
|
const key = `${collectionId}_${keyword}`;
|
|
144
148
|
const ariaSelected = {};
|
|
145
149
|
|
|
@@ -160,7 +164,7 @@ let TreeCollection = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.def
|
|
|
160
164
|
return (0, _emotion.jsx)("li", Object.assign({
|
|
161
165
|
id: key,
|
|
162
166
|
role: "treeitem",
|
|
163
|
-
css: styles
|
|
167
|
+
css: styles === null || styles === void 0 ? void 0 : styles.item,
|
|
164
168
|
tabIndex: -1,
|
|
165
169
|
key: key,
|
|
166
170
|
"aria-posinset": position,
|
|
@@ -181,7 +185,7 @@ let TreeCollection = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.def
|
|
|
181
185
|
if (typeof child.props.onKeyDown === 'function') {
|
|
182
186
|
child.props.onKeyDown(e, n);
|
|
183
187
|
} else {
|
|
184
|
-
onKeyDown
|
|
188
|
+
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(e, itemHash);
|
|
185
189
|
}
|
|
186
190
|
},
|
|
187
191
|
onBlur: e => this.handleBlur(e, itemHash)
|
|
@@ -209,12 +213,12 @@ let TreeCollection = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.def
|
|
|
209
213
|
}
|
|
210
214
|
|
|
211
215
|
renderItemNode(item, position) {
|
|
212
|
-
const _this$
|
|
213
|
-
selection = _this$
|
|
214
|
-
onItemClick = _this$
|
|
215
|
-
onKeyDown = _this$
|
|
216
|
-
getItemProps = _this$
|
|
217
|
-
styles = _this$
|
|
216
|
+
const _this$props8 = this.props,
|
|
217
|
+
selection = _this$props8.selection,
|
|
218
|
+
onItemClick = _this$props8.onItemClick,
|
|
219
|
+
onKeyDown = _this$props8.onKeyDown,
|
|
220
|
+
getItemProps = _this$props8.getItemProps,
|
|
221
|
+
styles = _this$props8.styles;
|
|
218
222
|
const ariaSelected = {};
|
|
219
223
|
|
|
220
224
|
if (selection) {
|
|
@@ -239,12 +243,12 @@ let TreeCollection = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.def
|
|
|
239
243
|
tabIndex: -1,
|
|
240
244
|
role: "treeitem",
|
|
241
245
|
"aria-label": item.name,
|
|
242
|
-
css: styles
|
|
246
|
+
css: styles === null || styles === void 0 ? void 0 : styles.item,
|
|
243
247
|
"aria-level": this.itemsLevel,
|
|
244
248
|
"aria-posinset": position,
|
|
245
249
|
"aria-setsize": this.childCount,
|
|
246
|
-
onClick: e => onItemClick
|
|
247
|
-
onKeyDown: e => onKeyDown
|
|
250
|
+
onClick: e => onItemClick === null || onItemClick === void 0 ? void 0 : onItemClick(e, itemHash),
|
|
251
|
+
onKeyDown: e => onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(e, itemHash),
|
|
248
252
|
onFocus: e => this.handleFocus(e, itemHash),
|
|
249
253
|
onBlur: e => this.handleBlur(e, itemHash)
|
|
250
254
|
}, ariaSelected), (0, _emotion.jsx)(_TreeButton.TreeButton, itemProps));
|
|
@@ -264,17 +268,17 @@ let TreeCollection = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.def
|
|
|
264
268
|
}
|
|
265
269
|
|
|
266
270
|
render() {
|
|
267
|
-
const _this$
|
|
268
|
-
id = _this$
|
|
269
|
-
name = _this$
|
|
270
|
-
expanded = _this$
|
|
271
|
-
collectionIcon = _this$
|
|
272
|
-
collectionIconExpanded = _this$
|
|
273
|
-
isCollectionFlattened = _this$
|
|
274
|
-
getCollectionProps = _this$
|
|
275
|
-
level = _this$
|
|
276
|
-
position = _this$
|
|
277
|
-
styles = _this$
|
|
271
|
+
const _this$props9 = this.props,
|
|
272
|
+
id = _this$props9.id,
|
|
273
|
+
name = _this$props9.name,
|
|
274
|
+
expanded = _this$props9.expanded,
|
|
275
|
+
collectionIcon = _this$props9.collectionIcon,
|
|
276
|
+
collectionIconExpanded = _this$props9.collectionIconExpanded,
|
|
277
|
+
isCollectionFlattened = _this$props9.isCollectionFlattened,
|
|
278
|
+
getCollectionProps = _this$props9.getCollectionProps,
|
|
279
|
+
level = _this$props9.level,
|
|
280
|
+
position = _this$props9.position,
|
|
281
|
+
styles = _this$props9.styles;
|
|
278
282
|
const collectionProps = getCollectionProps({ ...this.getCommonButtonProps(),
|
|
279
283
|
expanded: expanded,
|
|
280
284
|
collectionIcon: collectionIcon,
|
|
@@ -291,7 +295,7 @@ let TreeCollection = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.def
|
|
|
291
295
|
ref: el => {
|
|
292
296
|
this.ref = el;
|
|
293
297
|
},
|
|
294
|
-
css: styles
|
|
298
|
+
css: styles === null || styles === void 0 ? void 0 : styles.treeCollection,
|
|
295
299
|
tabIndex: -1,
|
|
296
300
|
role: "treeitem",
|
|
297
301
|
"aria-label": this.props.name,
|
|
@@ -311,7 +315,7 @@ let TreeCollection = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.def
|
|
|
311
315
|
})
|
|
312
316
|
}, ariaSelected), (0, _emotion.jsx)(_TreeButton.TreeButton, collectionProps), expanded && this.childCount > 0 && (0, _emotion.jsx)("ul", {
|
|
313
317
|
"aria-label": name,
|
|
314
|
-
css: styles
|
|
318
|
+
css: styles === null || styles === void 0 ? void 0 : styles.list,
|
|
315
319
|
role: "group"
|
|
316
320
|
}, this.renderChildren()));
|
|
317
321
|
}
|
|
@@ -40,12 +40,12 @@ const generateComponentTheme = theme => {
|
|
|
40
40
|
typography = theme.typography,
|
|
41
41
|
borders = theme.borders;
|
|
42
42
|
const componentVariables = {
|
|
43
|
-
fontFamily: typography
|
|
44
|
-
baseSpacingSmall: spacing
|
|
45
|
-
baseSpacingMedium: spacing
|
|
43
|
+
fontFamily: typography === null || typography === void 0 ? void 0 : typography.fontFamily,
|
|
44
|
+
baseSpacingSmall: spacing === null || spacing === void 0 ? void 0 : spacing.xSmall,
|
|
45
|
+
baseSpacingMedium: spacing === null || spacing === void 0 ? void 0 : spacing.small,
|
|
46
46
|
baseSpacingLarge: '1rem',
|
|
47
|
-
borderWidth: borders
|
|
48
|
-
borderColor: colors
|
|
47
|
+
borderWidth: borders === null || borders === void 0 ? void 0 : borders.widthSmall,
|
|
48
|
+
borderColor: colors === null || colors === void 0 ? void 0 : colors.borderDark
|
|
49
49
|
};
|
|
50
50
|
return { ...componentVariables
|
|
51
51
|
};
|
|
@@ -51,24 +51,28 @@ let TreeNode = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default),
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
componentDidMount() {
|
|
54
|
-
|
|
54
|
+
var _this$props$makeStyle, _this$props;
|
|
55
|
+
|
|
56
|
+
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
componentDidUpdate() {
|
|
58
|
-
|
|
60
|
+
var _this$props$makeStyle2, _this$props2;
|
|
61
|
+
|
|
62
|
+
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
59
63
|
}
|
|
60
64
|
|
|
61
65
|
renderItemImage() {
|
|
62
66
|
var _Img;
|
|
63
67
|
|
|
64
|
-
const _this$
|
|
65
|
-
thumbnail = _this$
|
|
66
|
-
itemIcon = _this$
|
|
67
|
-
styles = _this$
|
|
68
|
+
const _this$props3 = this.props,
|
|
69
|
+
thumbnail = _this$props3.thumbnail,
|
|
70
|
+
itemIcon = _this$props3.itemIcon,
|
|
71
|
+
styles = _this$props3.styles;
|
|
68
72
|
|
|
69
73
|
if (thumbnail) {
|
|
70
74
|
return (0, _emotion.jsx)("div", {
|
|
71
|
-
css: styles
|
|
75
|
+
css: styles === null || styles === void 0 ? void 0 : styles.thumbnail
|
|
72
76
|
}, _Img || (_Img = (0, _emotion.jsx)(_Img2.Img, {
|
|
73
77
|
src: thumbnail,
|
|
74
78
|
constrain: "cover",
|
|
@@ -78,7 +82,7 @@ let TreeNode = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default),
|
|
|
78
82
|
|
|
79
83
|
if (itemIcon) {
|
|
80
84
|
return (0, _emotion.jsx)("div", {
|
|
81
|
-
css: styles
|
|
85
|
+
css: styles === null || styles === void 0 ? void 0 : styles.icon
|
|
82
86
|
}, (0, _callRenderProp.callRenderProp)(itemIcon));
|
|
83
87
|
}
|
|
84
88
|
|
|
@@ -86,17 +90,17 @@ let TreeNode = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default),
|
|
|
86
90
|
}
|
|
87
91
|
|
|
88
92
|
render() {
|
|
89
|
-
const _this$
|
|
90
|
-
children = _this$
|
|
91
|
-
styles = _this$
|
|
93
|
+
const _this$props4 = this.props,
|
|
94
|
+
children = _this$props4.children,
|
|
95
|
+
styles = _this$props4.styles;
|
|
92
96
|
return (0, _emotion.jsx)("div", {
|
|
93
97
|
ref: this.handleRef,
|
|
94
98
|
tabIndex: -1,
|
|
95
|
-
css: styles
|
|
99
|
+
css: styles === null || styles === void 0 ? void 0 : styles.treeButton
|
|
96
100
|
}, (0, _emotion.jsx)("span", {
|
|
97
|
-
css: styles
|
|
101
|
+
css: styles === null || styles === void 0 ? void 0 : styles.layout
|
|
98
102
|
}, this.renderItemImage(), (0, _emotion.jsx)("span", {
|
|
99
|
-
css: styles
|
|
103
|
+
css: styles === null || styles === void 0 ? void 0 : styles.node
|
|
100
104
|
}, children)));
|
|
101
105
|
}
|
|
102
106
|
|
package/lib/TreeBrowser/index.js
CHANGED
|
@@ -56,14 +56,16 @@ let TreeBrowser = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.defaul
|
|
|
56
56
|
e.stopPropagation();
|
|
57
57
|
const onCollectionClick = _this.props.onCollectionClick;
|
|
58
58
|
if (expand) _this.expandOrCollapseNode(collection);
|
|
59
|
-
onCollectionClick
|
|
59
|
+
onCollectionClick === null || onCollectionClick === void 0 ? void 0 : onCollectionClick(collection.id, collection); // TODO: this should pass the event as the first arg
|
|
60
60
|
|
|
61
61
|
_this.handleSelection(collection.id, 'collection');
|
|
62
62
|
};
|
|
63
63
|
|
|
64
64
|
this.handleItemClick = (e, item) => {
|
|
65
|
+
var _this$props$onItemCli, _this$props;
|
|
66
|
+
|
|
65
67
|
e.stopPropagation();
|
|
66
|
-
this.props.onItemClick
|
|
68
|
+
(_this$props$onItemCli = (_this$props = this.props).onItemClick) === null || _this$props$onItemCli === void 0 ? void 0 : _this$props$onItemCli.call(_this$props, item);
|
|
67
69
|
this.handleSelection(item.id, 'item');
|
|
68
70
|
};
|
|
69
71
|
|
|
@@ -104,9 +106,9 @@ let TreeBrowser = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.defaul
|
|
|
104
106
|
};
|
|
105
107
|
|
|
106
108
|
this.getIsFlattened = collection => {
|
|
107
|
-
const _this$
|
|
108
|
-
rootId = _this$
|
|
109
|
-
showRootCollection = _this$
|
|
109
|
+
const _this$props2 = this.props,
|
|
110
|
+
rootId = _this$props2.rootId,
|
|
111
|
+
showRootCollection = _this$props2.showRootCollection;
|
|
110
112
|
return !showRootCollection && typeof rootId !== 'undefined' && collection.id === rootId;
|
|
111
113
|
};
|
|
112
114
|
|
|
@@ -123,11 +125,15 @@ let TreeBrowser = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.defaul
|
|
|
123
125
|
}
|
|
124
126
|
|
|
125
127
|
componentDidMount() {
|
|
126
|
-
|
|
128
|
+
var _this$props$makeStyle, _this$props3;
|
|
129
|
+
|
|
130
|
+
(_this$props$makeStyle = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props3);
|
|
127
131
|
}
|
|
128
132
|
|
|
129
133
|
componentDidUpdate() {
|
|
130
|
-
|
|
134
|
+
var _this$props$makeStyle2, _this$props4;
|
|
135
|
+
|
|
136
|
+
(_this$props$makeStyle2 = (_this$props4 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props4);
|
|
131
137
|
}
|
|
132
138
|
|
|
133
139
|
get _root() {
|
|
@@ -135,9 +141,9 @@ let TreeBrowser = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.defaul
|
|
|
135
141
|
}
|
|
136
142
|
|
|
137
143
|
get collections() {
|
|
138
|
-
const _this$
|
|
139
|
-
collections = _this$
|
|
140
|
-
rootId = _this$
|
|
144
|
+
const _this$props5 = this.props,
|
|
145
|
+
collections = _this$props5.collections,
|
|
146
|
+
rootId = _this$props5.rootId;
|
|
141
147
|
|
|
142
148
|
if (typeof rootId !== 'undefined') {
|
|
143
149
|
return [collections[rootId]];
|
|
@@ -155,7 +161,9 @@ let TreeBrowser = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.defaul
|
|
|
155
161
|
}
|
|
156
162
|
|
|
157
163
|
expandOrCollapseNode(collection) {
|
|
158
|
-
|
|
164
|
+
var _this$props$onCollect, _this$props6;
|
|
165
|
+
|
|
166
|
+
(_this$props$onCollect = (_this$props6 = this.props).onCollectionToggle) === null || _this$props$onCollect === void 0 ? void 0 : _this$props$onCollect.call(_this$props6, collection);
|
|
159
167
|
|
|
160
168
|
if (typeof this.props.expanded === 'undefined') {
|
|
161
169
|
this.setState((state, props) => {
|
|
@@ -313,7 +321,7 @@ let TreeBrowser = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.defaul
|
|
|
313
321
|
render() {
|
|
314
322
|
const styles = this.props.styles;
|
|
315
323
|
return (0, _emotion.jsx)("ul", {
|
|
316
|
-
css: styles
|
|
324
|
+
css: styles === null || styles === void 0 ? void 0 : styles.treeBrowser,
|
|
317
325
|
tabIndex: 0,
|
|
318
326
|
role: "tree",
|
|
319
327
|
onKeyDown: this.handleKeyDown,
|
package/lib/TreeBrowser/theme.js
CHANGED
|
@@ -38,10 +38,10 @@ const generateComponentTheme = theme => {
|
|
|
38
38
|
const colors = theme.colors,
|
|
39
39
|
borders = theme.borders;
|
|
40
40
|
const componentVariables = {
|
|
41
|
-
borderRadius: borders
|
|
42
|
-
focusOutlineWidth: borders
|
|
43
|
-
focusOutlineColor: colors
|
|
44
|
-
focusOutlineStyle: borders
|
|
41
|
+
borderRadius: borders === null || borders === void 0 ? void 0 : borders.radiusMedium,
|
|
42
|
+
focusOutlineWidth: borders === null || borders === void 0 ? void 0 : borders.widthMedium,
|
|
43
|
+
focusOutlineColor: colors === null || colors === void 0 ? void 0 : colors.borderBrand,
|
|
44
|
+
focusOutlineStyle: borders === null || borders === void 0 ? void 0 : borders.style
|
|
45
45
|
};
|
|
46
46
|
return { ...componentVariables
|
|
47
47
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-tree-browser",
|
|
3
|
-
"version": "8.18.
|
|
3
|
+
"version": "8.18.1-snapshot.2+ca4c1ff9d",
|
|
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.18.
|
|
27
|
-
"@instructure/ui-color-utils": "8.18.
|
|
28
|
-
"@instructure/ui-test-locator": "8.18.
|
|
29
|
-
"@instructure/ui-test-utils": "8.18.
|
|
30
|
-
"@instructure/ui-themes": "8.18.
|
|
26
|
+
"@instructure/ui-babel-preset": "8.18.1-snapshot.2+ca4c1ff9d",
|
|
27
|
+
"@instructure/ui-color-utils": "8.18.1-snapshot.2+ca4c1ff9d",
|
|
28
|
+
"@instructure/ui-test-locator": "8.18.1-snapshot.2+ca4c1ff9d",
|
|
29
|
+
"@instructure/ui-test-utils": "8.18.1-snapshot.2+ca4c1ff9d",
|
|
30
|
+
"@instructure/ui-themes": "8.18.1-snapshot.2+ca4c1ff9d"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@babel/runtime": "^7.13.10",
|
|
34
|
-
"@instructure/emotion": "8.18.
|
|
35
|
-
"@instructure/shared-types": "8.18.
|
|
36
|
-
"@instructure/ui-icons": "8.18.
|
|
37
|
-
"@instructure/ui-img": "8.18.
|
|
38
|
-
"@instructure/ui-prop-types": "8.18.
|
|
39
|
-
"@instructure/ui-react-utils": "8.18.
|
|
40
|
-
"@instructure/ui-testable": "8.18.
|
|
41
|
-
"@instructure/ui-utils": "8.18.
|
|
34
|
+
"@instructure/emotion": "8.18.1-snapshot.2+ca4c1ff9d",
|
|
35
|
+
"@instructure/shared-types": "8.18.1-snapshot.2+ca4c1ff9d",
|
|
36
|
+
"@instructure/ui-icons": "8.18.1-snapshot.2+ca4c1ff9d",
|
|
37
|
+
"@instructure/ui-img": "8.18.1-snapshot.2+ca4c1ff9d",
|
|
38
|
+
"@instructure/ui-prop-types": "8.18.1-snapshot.2+ca4c1ff9d",
|
|
39
|
+
"@instructure/ui-react-utils": "8.18.1-snapshot.2+ca4c1ff9d",
|
|
40
|
+
"@instructure/ui-testable": "8.18.1-snapshot.2+ca4c1ff9d",
|
|
41
|
+
"@instructure/ui-utils": "8.18.1-snapshot.2+ca4c1ff9d",
|
|
42
42
|
"keycode": "^2",
|
|
43
43
|
"prop-types": "^15"
|
|
44
44
|
},
|
|
@@ -48,5 +48,6 @@
|
|
|
48
48
|
"publishConfig": {
|
|
49
49
|
"access": "public"
|
|
50
50
|
},
|
|
51
|
-
"sideEffects": false
|
|
51
|
+
"sideEffects": false,
|
|
52
|
+
"gitHead": "ca4c1ff9d3985151ae0758fb596de41652dbb58b"
|
|
52
53
|
}
|