@instructure/ui-tree-browser 11.7.3-snapshot-7 → 11.7.3-snapshot-26
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 +5 -2
- package/es/TreeBrowser/v1/TreeButton/index.js +56 -49
- package/es/TreeBrowser/v1/TreeButton/styles.js +7 -5
- package/es/TreeBrowser/v1/TreeButton/theme.js +32 -31
- package/es/TreeBrowser/v1/TreeCollection/index.js +115 -104
- package/es/TreeBrowser/v1/TreeCollection/styles.js +4 -2
- package/es/TreeBrowser/v1/TreeCollection/theme.js +11 -10
- package/es/TreeBrowser/v1/TreeNode/index.js +39 -37
- package/es/TreeBrowser/v1/index.js +94 -82
- package/es/TreeBrowser/v1/theme.js +8 -7
- package/es/TreeBrowser/v2/TreeButton/index.js +82 -71
- package/es/TreeBrowser/v2/TreeButton/styles.js +10 -8
- package/es/TreeBrowser/v2/TreeCollection/index.js +115 -104
- package/es/TreeBrowser/v2/TreeCollection/styles.js +4 -2
- package/es/TreeBrowser/v2/TreeNode/index.js +64 -58
- package/es/TreeBrowser/v2/index.js +112 -99
- package/lib/TreeBrowser/v1/TreeButton/index.js +56 -49
- package/lib/TreeBrowser/v1/TreeButton/styles.js +7 -5
- package/lib/TreeBrowser/v1/TreeButton/theme.js +32 -31
- package/lib/TreeBrowser/v1/TreeCollection/index.js +115 -104
- package/lib/TreeBrowser/v1/TreeCollection/styles.js +4 -2
- package/lib/TreeBrowser/v1/TreeCollection/theme.js +11 -10
- package/lib/TreeBrowser/v1/TreeNode/index.js +39 -37
- package/lib/TreeBrowser/v1/index.js +94 -82
- package/lib/TreeBrowser/v1/theme.js +8 -7
- package/lib/TreeBrowser/v2/TreeButton/index.js +82 -71
- package/lib/TreeBrowser/v2/TreeButton/styles.js +10 -8
- package/lib/TreeBrowser/v2/TreeCollection/index.js +115 -104
- package/lib/TreeBrowser/v2/TreeCollection/styles.js +4 -2
- package/lib/TreeBrowser/v2/TreeNode/index.js +64 -58
- package/lib/TreeBrowser/v2/index.js +112 -99
- package/package.json +12 -12
- package/tsconfig.build.tsbuildinfo +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _dec, _class
|
|
1
|
+
var _dec, _class;
|
|
2
2
|
/*
|
|
3
3
|
* The MIT License (MIT)
|
|
4
4
|
*
|
|
@@ -40,37 +40,43 @@ A helper class used to render the :renderBeforeItems and :renderAfterItems
|
|
|
40
40
|
in the TreeBrowser.
|
|
41
41
|
**/
|
|
42
42
|
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
43
|
-
let TreeNode = (_dec = withStyle(generateStyles, generateComponentTheme), _dec(_class =
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
43
|
+
let TreeNode = (_dec = withStyle(generateStyles, generateComponentTheme), _dec(_class = class TreeNode extends Component {
|
|
44
|
+
static displayName = "TreeNode";
|
|
45
|
+
static componentId = 'TreeBrowser.Node';
|
|
46
|
+
static allowedProps = allowedProps;
|
|
47
|
+
static contextType = TreeBrowserContext;
|
|
48
|
+
static defaultProps = {
|
|
49
|
+
size: 'medium',
|
|
50
|
+
variant: 'folderTree',
|
|
51
|
+
selected: false,
|
|
52
|
+
focused: false
|
|
53
|
+
};
|
|
54
|
+
ref = null;
|
|
54
55
|
componentDidMount() {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
animation: (_this$context = this.context) === null || _this$context === void 0 ? void 0 : _this$context.animation
|
|
56
|
+
this.props.makeStyles?.({
|
|
57
|
+
animation: this.context?.animation
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
60
|
componentDidUpdate() {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
animation: (_this$context2 = this.context) === null || _this$context2 === void 0 ? void 0 : _this$context2.animation
|
|
61
|
+
this.props.makeStyles?.({
|
|
62
|
+
animation: this.context?.animation
|
|
64
63
|
});
|
|
65
64
|
}
|
|
65
|
+
handleRef = el => {
|
|
66
|
+
if (el && typeof this.props.containerRef === 'function') {
|
|
67
|
+
this.props.containerRef(el.parentElement);
|
|
68
|
+
}
|
|
69
|
+
this.ref = el;
|
|
70
|
+
};
|
|
66
71
|
renderItemImage() {
|
|
67
|
-
const
|
|
68
|
-
thumbnail
|
|
69
|
-
itemIcon
|
|
70
|
-
styles
|
|
72
|
+
const {
|
|
73
|
+
thumbnail,
|
|
74
|
+
itemIcon,
|
|
75
|
+
styles
|
|
76
|
+
} = this.props;
|
|
71
77
|
if (thumbnail) {
|
|
72
78
|
return _jsx("div", {
|
|
73
|
-
css: styles
|
|
79
|
+
css: styles?.thumbnail,
|
|
74
80
|
children: _jsx(Img, {
|
|
75
81
|
src: thumbnail,
|
|
76
82
|
constrain: "cover",
|
|
@@ -80,35 +86,31 @@ let TreeNode = (_dec = withStyle(generateStyles, generateComponentTheme), _dec(_
|
|
|
80
86
|
}
|
|
81
87
|
if (itemIcon) {
|
|
82
88
|
return _jsx("div", {
|
|
83
|
-
css: styles
|
|
89
|
+
css: styles?.icon,
|
|
84
90
|
children: callRenderProp(itemIcon)
|
|
85
91
|
});
|
|
86
92
|
}
|
|
87
|
-
return
|
|
93
|
+
return undefined;
|
|
88
94
|
}
|
|
89
95
|
render() {
|
|
90
|
-
const
|
|
91
|
-
children
|
|
92
|
-
styles
|
|
96
|
+
const {
|
|
97
|
+
children,
|
|
98
|
+
styles
|
|
99
|
+
} = this.props;
|
|
93
100
|
return _jsx("div", {
|
|
94
101
|
ref: this.handleRef,
|
|
95
102
|
tabIndex: -1,
|
|
96
|
-
css: styles
|
|
103
|
+
css: styles?.treeButton,
|
|
97
104
|
"data-cid": "TreeNode",
|
|
98
105
|
children: _jsxs("span", {
|
|
99
|
-
css: styles
|
|
106
|
+
css: styles?.layout,
|
|
100
107
|
children: [this.renderItemImage(), _jsx("span", {
|
|
101
|
-
css: styles
|
|
108
|
+
css: styles?.node,
|
|
102
109
|
children: children
|
|
103
110
|
})]
|
|
104
111
|
})
|
|
105
112
|
});
|
|
106
113
|
}
|
|
107
|
-
}
|
|
108
|
-
size: 'medium',
|
|
109
|
-
variant: 'folderTree',
|
|
110
|
-
selected: false,
|
|
111
|
-
focused: false
|
|
112
|
-
}, _TreeNode)) || _class);
|
|
114
|
+
}) || _class);
|
|
113
115
|
export default TreeNode;
|
|
114
116
|
export { TreeNode };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
var _dec, _class
|
|
1
|
+
var _dec, _class;
|
|
2
|
+
import "core-js/modules/es.array.includes.js";
|
|
2
3
|
/*
|
|
3
4
|
* The MIT License (MIT)
|
|
4
5
|
*
|
|
@@ -41,61 +42,32 @@ category: components
|
|
|
41
42
|
---
|
|
42
43
|
**/
|
|
43
44
|
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
44
|
-
let TreeBrowser = (_dec = withStyle(generateStyles, generateComponentTheme), _dec(_class =
|
|
45
|
+
let TreeBrowser = (_dec = withStyle(generateStyles, generateComponentTheme), _dec(_class = class TreeBrowser extends Component {
|
|
46
|
+
static displayName = "TreeBrowser";
|
|
47
|
+
static componentId = 'TreeBrowser';
|
|
48
|
+
static allowedProps = allowedProps;
|
|
49
|
+
static defaultProps = {
|
|
50
|
+
size: 'medium',
|
|
51
|
+
variant: 'folderTree',
|
|
52
|
+
showRootCollection: true,
|
|
53
|
+
collectionIcon: IconFolderLine,
|
|
54
|
+
collectionIconExpanded: IconFolderLine,
|
|
55
|
+
itemIcon: IconDocumentLine,
|
|
56
|
+
getItemProps: props => props,
|
|
57
|
+
getCollectionProps: props => props,
|
|
58
|
+
defaultExpanded: [],
|
|
59
|
+
selectionType: 'none',
|
|
60
|
+
sortOrder: function () {
|
|
61
|
+
return 0;
|
|
62
|
+
},
|
|
63
|
+
animation: true
|
|
64
|
+
};
|
|
65
|
+
static Node = TreeNode;
|
|
66
|
+
static Collection = TreeCollection;
|
|
67
|
+
static Button = TreeButton;
|
|
68
|
+
ref = null;
|
|
45
69
|
constructor(props) {
|
|
46
70
|
super(props);
|
|
47
|
-
this.ref = null;
|
|
48
|
-
this.handleCollectionClick = (e, collection, expand = true) => {
|
|
49
|
-
e.stopPropagation();
|
|
50
|
-
const onCollectionClick = this.props.onCollectionClick;
|
|
51
|
-
if (expand) this.expandOrCollapseNode(collection);
|
|
52
|
-
onCollectionClick === null || onCollectionClick === void 0 ? void 0 : onCollectionClick(collection.id, collection); // TODO: this should pass the event as the first arg
|
|
53
|
-
this.handleSelection(collection.id, 'collection');
|
|
54
|
-
};
|
|
55
|
-
this.handleItemClick = (e, item) => {
|
|
56
|
-
var _this$props$onItemCli, _this$props;
|
|
57
|
-
e.stopPropagation();
|
|
58
|
-
(_this$props$onItemCli = (_this$props = this.props).onItemClick) === null || _this$props$onItemCli === void 0 ? void 0 : _this$props$onItemCli.call(_this$props, item);
|
|
59
|
-
this.handleSelection(item.id, 'item');
|
|
60
|
-
};
|
|
61
|
-
this.handleKeyDown = (event, node) => {
|
|
62
|
-
switch (event.keyCode) {
|
|
63
|
-
case keycode.codes.down:
|
|
64
|
-
case keycode.codes.j:
|
|
65
|
-
event.stopPropagation();
|
|
66
|
-
this.moveFocus(1);
|
|
67
|
-
break;
|
|
68
|
-
case keycode.codes.up:
|
|
69
|
-
case keycode.codes.k:
|
|
70
|
-
event.stopPropagation();
|
|
71
|
-
this.moveFocus(-1);
|
|
72
|
-
break;
|
|
73
|
-
case keycode.codes.home:
|
|
74
|
-
case keycode.codes.end:
|
|
75
|
-
event.stopPropagation();
|
|
76
|
-
this.homeOrEnd(event.keyCode);
|
|
77
|
-
break;
|
|
78
|
-
case keycode.codes.left:
|
|
79
|
-
case keycode.codes.right:
|
|
80
|
-
event.stopPropagation();
|
|
81
|
-
this.handleLeftOrRightArrow(event.keyCode, node);
|
|
82
|
-
break;
|
|
83
|
-
case keycode.codes.enter:
|
|
84
|
-
case keycode.codes.space:
|
|
85
|
-
event.stopPropagation();
|
|
86
|
-
this.handleActivation(event, node);
|
|
87
|
-
break;
|
|
88
|
-
default:
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
event.preventDefault();
|
|
92
|
-
};
|
|
93
|
-
this.getIsFlattened = collection => {
|
|
94
|
-
const _this$props2 = this.props,
|
|
95
|
-
rootId = _this$props2.rootId,
|
|
96
|
-
showRootCollection = _this$props2.showRootCollection;
|
|
97
|
-
return !showRootCollection && typeof rootId !== 'undefined' && collection.id === rootId;
|
|
98
|
-
};
|
|
99
71
|
if (typeof this.props.expanded === 'undefined') {
|
|
100
72
|
this.state = {
|
|
101
73
|
expanded: this.props.defaultExpanded,
|
|
@@ -108,20 +80,65 @@ let TreeBrowser = (_dec = withStyle(generateStyles, generateComponentTheme), _de
|
|
|
108
80
|
}
|
|
109
81
|
}
|
|
110
82
|
componentDidMount() {
|
|
111
|
-
|
|
112
|
-
(_this$props$makeStyle = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props3);
|
|
83
|
+
this.props.makeStyles?.();
|
|
113
84
|
}
|
|
114
85
|
componentDidUpdate() {
|
|
115
|
-
|
|
116
|
-
(_this$props$makeStyle2 = (_this$props4 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props4);
|
|
86
|
+
this.props.makeStyles?.();
|
|
117
87
|
}
|
|
118
88
|
get _root() {
|
|
119
89
|
return this.ref;
|
|
120
90
|
}
|
|
91
|
+
handleCollectionClick = (e, collection, expand = true) => {
|
|
92
|
+
e.stopPropagation();
|
|
93
|
+
const {
|
|
94
|
+
onCollectionClick
|
|
95
|
+
} = this.props;
|
|
96
|
+
if (expand) this.expandOrCollapseNode(collection);
|
|
97
|
+
onCollectionClick?.(collection.id, collection); // TODO: this should pass the event as the first arg
|
|
98
|
+
this.handleSelection(collection.id, 'collection');
|
|
99
|
+
};
|
|
100
|
+
handleItemClick = (e, item) => {
|
|
101
|
+
e.stopPropagation();
|
|
102
|
+
this.props.onItemClick?.(item);
|
|
103
|
+
this.handleSelection(item.id, 'item');
|
|
104
|
+
};
|
|
105
|
+
handleKeyDown = (event, node) => {
|
|
106
|
+
switch (event.keyCode) {
|
|
107
|
+
case keycode.codes.down:
|
|
108
|
+
case keycode.codes.j:
|
|
109
|
+
event.stopPropagation();
|
|
110
|
+
this.moveFocus(1);
|
|
111
|
+
break;
|
|
112
|
+
case keycode.codes.up:
|
|
113
|
+
case keycode.codes.k:
|
|
114
|
+
event.stopPropagation();
|
|
115
|
+
this.moveFocus(-1);
|
|
116
|
+
break;
|
|
117
|
+
case keycode.codes.home:
|
|
118
|
+
case keycode.codes.end:
|
|
119
|
+
event.stopPropagation();
|
|
120
|
+
this.homeOrEnd(event.keyCode);
|
|
121
|
+
break;
|
|
122
|
+
case keycode.codes.left:
|
|
123
|
+
case keycode.codes.right:
|
|
124
|
+
event.stopPropagation();
|
|
125
|
+
this.handleLeftOrRightArrow(event.keyCode, node);
|
|
126
|
+
break;
|
|
127
|
+
case keycode.codes.enter:
|
|
128
|
+
case keycode.codes.space:
|
|
129
|
+
event.stopPropagation();
|
|
130
|
+
this.handleActivation(event, node);
|
|
131
|
+
break;
|
|
132
|
+
default:
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
event.preventDefault();
|
|
136
|
+
};
|
|
121
137
|
get collections() {
|
|
122
|
-
const
|
|
123
|
-
collections
|
|
124
|
-
rootId
|
|
138
|
+
const {
|
|
139
|
+
collections,
|
|
140
|
+
rootId
|
|
141
|
+
} = this.props;
|
|
125
142
|
if (typeof rootId !== 'undefined') {
|
|
126
143
|
return [collections[rootId]];
|
|
127
144
|
} else {
|
|
@@ -135,8 +152,7 @@ let TreeBrowser = (_dec = withStyle(generateStyles, generateComponentTheme), _de
|
|
|
135
152
|
return typeof props.expanded === 'undefined' ? state.expanded : props.expanded;
|
|
136
153
|
}
|
|
137
154
|
expandOrCollapseNode(collection) {
|
|
138
|
-
|
|
139
|
-
(_this$props$onCollect = (_this$props6 = this.props).onCollectionToggle) === null || _this$props$onCollect === void 0 ? void 0 : _this$props$onCollect.call(_this$props6, collection);
|
|
155
|
+
this.props.onCollectionToggle?.(collection);
|
|
140
156
|
if (typeof this.props.expanded === 'undefined') {
|
|
141
157
|
this.setState((state, props) => {
|
|
142
158
|
const expanded = [...this.getExpanded(state, props)];
|
|
@@ -153,7 +169,9 @@ let TreeBrowser = (_dec = withStyle(generateStyles, generateComponentTheme), _de
|
|
|
153
169
|
}
|
|
154
170
|
}
|
|
155
171
|
handleSelection(id, type) {
|
|
156
|
-
const
|
|
172
|
+
const {
|
|
173
|
+
selectionType
|
|
174
|
+
} = this.props;
|
|
157
175
|
selectionType === 'single' && this.setState(state => {
|
|
158
176
|
const selection = `${type}_${id}`;
|
|
159
177
|
if (state.selection !== selection) {
|
|
@@ -238,6 +256,13 @@ let TreeBrowser = (_dec = withStyle(generateStyles, generateComponentTheme), _de
|
|
|
238
256
|
return [];
|
|
239
257
|
}
|
|
240
258
|
}
|
|
259
|
+
getIsFlattened = collection => {
|
|
260
|
+
const {
|
|
261
|
+
rootId,
|
|
262
|
+
showRootCollection
|
|
263
|
+
} = this.props;
|
|
264
|
+
return !showRootCollection && typeof rootId !== 'undefined' && collection.id === rootId;
|
|
265
|
+
};
|
|
241
266
|
getCollectionProps(collection) {
|
|
242
267
|
return {
|
|
243
268
|
id: collection.id,
|
|
@@ -271,13 +296,15 @@ let TreeBrowser = (_dec = withStyle(generateStyles, generateComponentTheme), _de
|
|
|
271
296
|
}, i));
|
|
272
297
|
}
|
|
273
298
|
render() {
|
|
274
|
-
const
|
|
299
|
+
const {
|
|
300
|
+
styles
|
|
301
|
+
} = this.props;
|
|
275
302
|
return _jsx(TreeBrowserContext.Provider, {
|
|
276
303
|
value: {
|
|
277
304
|
animation: this.props.animation
|
|
278
305
|
},
|
|
279
306
|
children: _jsx("ul", {
|
|
280
|
-
css: styles
|
|
307
|
+
css: styles?.treeBrowser,
|
|
281
308
|
tabIndex: 0,
|
|
282
309
|
role: "tree",
|
|
283
310
|
onKeyDown: this.handleKeyDown,
|
|
@@ -290,21 +317,6 @@ let TreeBrowser = (_dec = withStyle(generateStyles, generateComponentTheme), _de
|
|
|
290
317
|
})
|
|
291
318
|
});
|
|
292
319
|
}
|
|
293
|
-
}
|
|
294
|
-
size: 'medium',
|
|
295
|
-
variant: 'folderTree',
|
|
296
|
-
showRootCollection: true,
|
|
297
|
-
collectionIcon: IconFolderLine,
|
|
298
|
-
collectionIconExpanded: IconFolderLine,
|
|
299
|
-
itemIcon: IconDocumentLine,
|
|
300
|
-
getItemProps: props => props,
|
|
301
|
-
getCollectionProps: props => props,
|
|
302
|
-
defaultExpanded: [],
|
|
303
|
-
selectionType: 'none',
|
|
304
|
-
sortOrder: function () {
|
|
305
|
-
return 0;
|
|
306
|
-
},
|
|
307
|
-
animation: true
|
|
308
|
-
}, _TreeBrowser.Node = TreeNode, _TreeBrowser.Collection = TreeCollection, _TreeBrowser.Button = TreeButton, _TreeBrowser)) || _class);
|
|
320
|
+
}) || _class);
|
|
309
321
|
export default TreeBrowser;
|
|
310
322
|
export { TreeBrowser };
|
|
@@ -28,14 +28,15 @@
|
|
|
28
28
|
* @return {Object} The final theme object with the overrides and component variables
|
|
29
29
|
*/
|
|
30
30
|
const generateComponentTheme = theme => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
borders
|
|
31
|
+
const {
|
|
32
|
+
colors,
|
|
33
|
+
borders
|
|
34
|
+
} = theme;
|
|
34
35
|
const componentVariables = {
|
|
35
|
-
borderRadius: borders
|
|
36
|
-
focusOutlineWidth: borders
|
|
37
|
-
focusOutlineColor: colors
|
|
38
|
-
focusOutlineStyle: borders
|
|
36
|
+
borderRadius: borders?.radiusMedium,
|
|
37
|
+
focusOutlineWidth: borders?.widthMedium,
|
|
38
|
+
focusOutlineColor: colors?.contrasts?.blue4570,
|
|
39
|
+
focusOutlineStyle: borders?.style
|
|
39
40
|
};
|
|
40
41
|
return {
|
|
41
42
|
...componentVariables
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _dec, _class
|
|
1
|
+
var _dec, _class;
|
|
2
2
|
/*
|
|
3
3
|
* The MIT License (MIT)
|
|
4
4
|
*
|
|
@@ -44,52 +44,42 @@ parent: TreeBrowser
|
|
|
44
44
|
id: TreeBrowser.Button
|
|
45
45
|
---
|
|
46
46
|
**/
|
|
47
|
-
let TreeButton = (_dec = withStyle(generateStyles, 'TreeBrowserTreeButton'), _dec(_class =
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
this.handleMouseLeave = () => {
|
|
68
|
-
if (this.props.hoverable) {
|
|
69
|
-
this.setState({
|
|
70
|
-
isHovered: false
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
}
|
|
47
|
+
let TreeButton = (_dec = withStyle(generateStyles, 'TreeBrowserTreeButton'), _dec(_class = class TreeButton extends Component {
|
|
48
|
+
static displayName = "TreeButton";
|
|
49
|
+
static componentId = 'TreeBrowser.Button';
|
|
50
|
+
static allowedProps = allowedProps;
|
|
51
|
+
static contextType = TreeBrowserContext;
|
|
52
|
+
static defaultProps = {
|
|
53
|
+
type: 'treeButton',
|
|
54
|
+
size: 'medium',
|
|
55
|
+
variant: 'folderTree',
|
|
56
|
+
selected: false,
|
|
57
|
+
focused: false,
|
|
58
|
+
expanded: false,
|
|
59
|
+
hoverable: true
|
|
60
|
+
};
|
|
61
|
+
ref = null;
|
|
62
|
+
state = {
|
|
63
|
+
isHovered: false
|
|
64
|
+
};
|
|
75
65
|
componentDidMount() {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
animation: (_this$context = this.context) === null || _this$context === void 0 ? void 0 : _this$context.animation,
|
|
66
|
+
this.props.makeStyles?.({
|
|
67
|
+
animation: this.context?.animation,
|
|
79
68
|
hoverable: this.props.hoverable
|
|
80
69
|
});
|
|
81
70
|
}
|
|
82
71
|
componentDidUpdate() {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
animation: (_this$context2 = this.context) === null || _this$context2 === void 0 ? void 0 : _this$context2.animation,
|
|
72
|
+
this.props.makeStyles?.({
|
|
73
|
+
animation: this.context?.animation,
|
|
86
74
|
hoverable: this.props.hoverable
|
|
87
75
|
});
|
|
88
76
|
}
|
|
89
77
|
defaultContentRenderer(props) {
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
78
|
+
const {
|
|
79
|
+
name,
|
|
80
|
+
descriptor,
|
|
81
|
+
styles
|
|
82
|
+
} = props;
|
|
93
83
|
return _jsxs("span", {
|
|
94
84
|
css: styles.layout,
|
|
95
85
|
children: [this.renderImage(), _jsxs("span", {
|
|
@@ -106,8 +96,12 @@ let TreeButton = (_dec = withStyle(generateStyles, 'TreeBrowserTreeButton'), _de
|
|
|
106
96
|
});
|
|
107
97
|
}
|
|
108
98
|
getIconColor() {
|
|
109
|
-
const
|
|
110
|
-
|
|
99
|
+
const {
|
|
100
|
+
selected
|
|
101
|
+
} = this.props;
|
|
102
|
+
const {
|
|
103
|
+
isHovered
|
|
104
|
+
} = this.state;
|
|
111
105
|
|
|
112
106
|
// Priority: selected > hover > default
|
|
113
107
|
if (selected) return 'onColor';
|
|
@@ -115,7 +109,9 @@ let TreeButton = (_dec = withStyle(generateStyles, 'TreeBrowserTreeButton'), _de
|
|
|
115
109
|
return 'baseColor';
|
|
116
110
|
}
|
|
117
111
|
renderImage() {
|
|
118
|
-
const
|
|
112
|
+
const {
|
|
113
|
+
type
|
|
114
|
+
} = this.props;
|
|
119
115
|
switch (type) {
|
|
120
116
|
case 'collection':
|
|
121
117
|
return this.renderCollectionIcon();
|
|
@@ -124,36 +120,38 @@ let TreeButton = (_dec = withStyle(generateStyles, 'TreeBrowserTreeButton'), _de
|
|
|
124
120
|
default:
|
|
125
121
|
break;
|
|
126
122
|
}
|
|
127
|
-
return
|
|
123
|
+
return undefined;
|
|
128
124
|
}
|
|
129
125
|
renderCollectionIcon() {
|
|
130
|
-
const
|
|
131
|
-
expanded
|
|
132
|
-
collectionIcon
|
|
133
|
-
collectionIconExpanded
|
|
134
|
-
styles
|
|
135
|
-
size
|
|
126
|
+
const {
|
|
127
|
+
expanded,
|
|
128
|
+
collectionIcon,
|
|
129
|
+
collectionIconExpanded,
|
|
130
|
+
styles,
|
|
131
|
+
size
|
|
132
|
+
} = this.props;
|
|
136
133
|
if (collectionIcon || collectionIconExpanded) {
|
|
137
134
|
const icon = expanded ? collectionIconExpanded : collectionIcon;
|
|
138
135
|
const iconSize = treeBrowserSizeToIconSize[size];
|
|
139
136
|
const iconColor = this.getIconColor();
|
|
140
137
|
const iconElement = renderIconWithProps(icon, iconSize, iconColor);
|
|
141
138
|
return _jsx("div", {
|
|
142
|
-
css: styles
|
|
139
|
+
css: styles?.icon,
|
|
143
140
|
children: iconElement
|
|
144
141
|
});
|
|
145
142
|
}
|
|
146
|
-
return
|
|
143
|
+
return undefined;
|
|
147
144
|
}
|
|
148
145
|
renderItemImage() {
|
|
149
|
-
const
|
|
150
|
-
thumbnail
|
|
151
|
-
itemIcon
|
|
152
|
-
styles
|
|
153
|
-
size
|
|
146
|
+
const {
|
|
147
|
+
thumbnail,
|
|
148
|
+
itemIcon,
|
|
149
|
+
styles,
|
|
150
|
+
size
|
|
151
|
+
} = this.props;
|
|
154
152
|
if (thumbnail) {
|
|
155
153
|
return _jsx("div", {
|
|
156
|
-
css: styles
|
|
154
|
+
css: styles?.thumbnail,
|
|
157
155
|
children: _jsx(Img, {
|
|
158
156
|
src: thumbnail,
|
|
159
157
|
constrain: "cover",
|
|
@@ -166,37 +164,50 @@ let TreeButton = (_dec = withStyle(generateStyles, 'TreeBrowserTreeButton'), _de
|
|
|
166
164
|
const iconColor = this.getIconColor();
|
|
167
165
|
const iconElement = renderIconWithProps(itemIcon, iconSize, iconColor);
|
|
168
166
|
return _jsx("div", {
|
|
169
|
-
css: styles
|
|
167
|
+
css: styles?.icon,
|
|
170
168
|
children: iconElement
|
|
171
169
|
});
|
|
172
170
|
}
|
|
173
|
-
return
|
|
171
|
+
return undefined;
|
|
174
172
|
}
|
|
173
|
+
handleRef = el => {
|
|
174
|
+
if (el && typeof this.props.containerRef === 'function') {
|
|
175
|
+
this.props.containerRef(el.parentElement);
|
|
176
|
+
}
|
|
177
|
+
this.ref = el;
|
|
178
|
+
};
|
|
179
|
+
handleMouseEnter = () => {
|
|
180
|
+
if (this.props.hoverable) {
|
|
181
|
+
this.setState({
|
|
182
|
+
isHovered: true
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
handleMouseLeave = () => {
|
|
187
|
+
if (this.props.hoverable) {
|
|
188
|
+
this.setState({
|
|
189
|
+
isHovered: false
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
};
|
|
175
193
|
render() {
|
|
176
|
-
const
|
|
177
|
-
styles
|
|
178
|
-
renderContent
|
|
194
|
+
const {
|
|
195
|
+
styles,
|
|
196
|
+
renderContent
|
|
197
|
+
} = this.props;
|
|
179
198
|
const buttonContent = renderContent ? renderContent(this.props) : this.defaultContentRenderer(this.props);
|
|
180
199
|
// VoiceOver can't navigate without the buttons, even though they don't do anything
|
|
181
200
|
return _jsx("button", {
|
|
182
201
|
ref: this.handleRef,
|
|
183
202
|
tabIndex: -1,
|
|
184
203
|
type: "button",
|
|
185
|
-
css: styles
|
|
204
|
+
css: styles?.treeButton,
|
|
186
205
|
"data-cid": "TreeButton",
|
|
187
206
|
onMouseEnter: this.handleMouseEnter,
|
|
188
207
|
onMouseLeave: this.handleMouseLeave,
|
|
189
208
|
children: buttonContent
|
|
190
209
|
});
|
|
191
210
|
}
|
|
192
|
-
}
|
|
193
|
-
type: 'treeButton',
|
|
194
|
-
size: 'medium',
|
|
195
|
-
variant: 'folderTree',
|
|
196
|
-
selected: false,
|
|
197
|
-
focused: false,
|
|
198
|
-
expanded: false,
|
|
199
|
-
hoverable: true
|
|
200
|
-
}, _TreeButton)) || _class);
|
|
211
|
+
}) || _class);
|
|
201
212
|
export default TreeButton;
|
|
202
213
|
export { TreeButton };
|
|
@@ -45,10 +45,12 @@ const transform = keyframes`
|
|
|
45
45
|
* @return {Object} The final style object, which will be used in the component
|
|
46
46
|
*/
|
|
47
47
|
const generateStyles = (componentTheme, props, sharedTokens, state) => {
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
const {
|
|
49
|
+
size,
|
|
50
|
+
variant,
|
|
51
|
+
selected,
|
|
52
|
+
level
|
|
53
|
+
} = props;
|
|
52
54
|
const isRootButton = level && level === 1;
|
|
53
55
|
const sizeMap = {
|
|
54
56
|
small: {
|
|
@@ -211,7 +213,7 @@ const generateStyles = (componentTheme, props, sharedTokens, state) => {
|
|
|
211
213
|
borderRadius: componentTheme.borderRadius,
|
|
212
214
|
position: 'relative',
|
|
213
215
|
zIndex: 1,
|
|
214
|
-
...(state
|
|
216
|
+
...(state?.animation ? {
|
|
215
217
|
transform: 'translate3d(-2%, 0, 0)',
|
|
216
218
|
opacity: 0.01,
|
|
217
219
|
transformOrigin: 'left center',
|
|
@@ -223,7 +225,7 @@ const generateStyles = (componentTheme, props, sharedTokens, state) => {
|
|
|
223
225
|
} : {}),
|
|
224
226
|
outline: '0',
|
|
225
227
|
padding: '0',
|
|
226
|
-
...(sharedTokens
|
|
228
|
+
...(sharedTokens?.focusOutline ? calcFocusOutlineStyles(sharedTokens.focusOutline) : {}),
|
|
227
229
|
...(variant === 'folderTree' && !isRootButton && {
|
|
228
230
|
'&::before': {
|
|
229
231
|
content: '""',
|
|
@@ -240,10 +242,10 @@ const generateStyles = (componentTheme, props, sharedTokens, state) => {
|
|
|
240
242
|
...sizeMap[size][variant].before
|
|
241
243
|
},
|
|
242
244
|
'&:hover::before': {
|
|
243
|
-
visibility: state
|
|
245
|
+
visibility: state?.hoverable ? 'hidden' : 'visible'
|
|
244
246
|
}
|
|
245
247
|
}),
|
|
246
|
-
...(
|
|
248
|
+
...(state?.hoverable !== false && {
|
|
247
249
|
'&:hover': {
|
|
248
250
|
backgroundColor: selected ? componentTheme.selectedBackgroundColor : componentTheme.hoverBackgroundColor,
|
|
249
251
|
'[class$=-treeButton__textName], [class$=-treeButton__textDescriptor], [class$=-treeButton__node]': {
|