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