@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,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
|
*
|
|
@@ -40,76 +41,32 @@ category: components
|
|
|
40
41
|
---
|
|
41
42
|
**/
|
|
42
43
|
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
43
|
-
let TreeBrowser = (_dec = withStyle(generateStyles), _dec(_class =
|
|
44
|
+
let TreeBrowser = (_dec = withStyle(generateStyles), _dec(_class = class TreeBrowser extends Component {
|
|
45
|
+
static displayName = "TreeBrowser";
|
|
46
|
+
static componentId = 'TreeBrowser';
|
|
47
|
+
static allowedProps = allowedProps;
|
|
48
|
+
static defaultProps = {
|
|
49
|
+
size: 'medium',
|
|
50
|
+
variant: 'folderTree',
|
|
51
|
+
showRootCollection: true,
|
|
52
|
+
collectionIcon: FolderClosedInstUIIcon,
|
|
53
|
+
collectionIconExpanded: FolderClosedInstUIIcon,
|
|
54
|
+
itemIcon: FileTextInstUIIcon,
|
|
55
|
+
getItemProps: props => props,
|
|
56
|
+
getCollectionProps: props => props,
|
|
57
|
+
defaultExpanded: [],
|
|
58
|
+
selectionType: 'none',
|
|
59
|
+
sortOrder: function () {
|
|
60
|
+
return 0;
|
|
61
|
+
},
|
|
62
|
+
animation: true
|
|
63
|
+
};
|
|
64
|
+
static Node = TreeNode;
|
|
65
|
+
static Collection = TreeCollection;
|
|
66
|
+
static Button = TreeButton;
|
|
67
|
+
ref = null;
|
|
44
68
|
constructor(props) {
|
|
45
69
|
super(props);
|
|
46
|
-
this.ref = null;
|
|
47
|
-
this.handleCollectionClick = (e, collection, expand = true) => {
|
|
48
|
-
e.stopPropagation();
|
|
49
|
-
const onCollectionClick = this.props.onCollectionClick;
|
|
50
|
-
if (expand) this.expandOrCollapseNode(collection);
|
|
51
|
-
onCollectionClick === null || onCollectionClick === void 0 ? void 0 : onCollectionClick(collection.id, collection); // TODO: this should pass the event as the first arg
|
|
52
|
-
this.handleSelection(collection.id, 'collection');
|
|
53
|
-
};
|
|
54
|
-
this.handleItemClick = (e, item) => {
|
|
55
|
-
var _this$props$onItemCli, _this$props;
|
|
56
|
-
e.stopPropagation();
|
|
57
|
-
(_this$props$onItemCli = (_this$props = this.props).onItemClick) === null || _this$props$onItemCli === void 0 ? void 0 : _this$props$onItemCli.call(_this$props, item);
|
|
58
|
-
this.handleSelection(item.id, 'item');
|
|
59
|
-
};
|
|
60
|
-
this.handleKeyDown = (event, node) => {
|
|
61
|
-
switch (event.keyCode) {
|
|
62
|
-
case keycode.codes.down:
|
|
63
|
-
case keycode.codes.j:
|
|
64
|
-
event.stopPropagation();
|
|
65
|
-
this.moveFocus(1);
|
|
66
|
-
break;
|
|
67
|
-
case keycode.codes.up:
|
|
68
|
-
case keycode.codes.k:
|
|
69
|
-
event.stopPropagation();
|
|
70
|
-
this.moveFocus(-1);
|
|
71
|
-
break;
|
|
72
|
-
case keycode.codes.home:
|
|
73
|
-
case keycode.codes.end:
|
|
74
|
-
event.stopPropagation();
|
|
75
|
-
this.homeOrEnd(event.keyCode);
|
|
76
|
-
break;
|
|
77
|
-
case keycode.codes.left:
|
|
78
|
-
case keycode.codes.right:
|
|
79
|
-
event.stopPropagation();
|
|
80
|
-
this.handleLeftOrRightArrow(event.keyCode, node);
|
|
81
|
-
break;
|
|
82
|
-
case keycode.codes.enter:
|
|
83
|
-
case keycode.codes.space:
|
|
84
|
-
event.stopPropagation();
|
|
85
|
-
this.handleActivation(event, node);
|
|
86
|
-
break;
|
|
87
|
-
default:
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
event.preventDefault();
|
|
91
|
-
};
|
|
92
|
-
this.clearSelection = () => {
|
|
93
|
-
const onSelectionChange = this.props.onSelectionChange;
|
|
94
|
-
|
|
95
|
-
// Call the callback if provided (for controlled selection)
|
|
96
|
-
if (onSelectionChange) {
|
|
97
|
-
onSelectionChange('', 'item', void 0);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// Update internal state only if uncontrolled
|
|
101
|
-
if (typeof this.props.selection === 'undefined') {
|
|
102
|
-
this.setState({
|
|
103
|
-
selection: ''
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
this.getIsFlattened = collection => {
|
|
108
|
-
const _this$props2 = this.props,
|
|
109
|
-
rootId = _this$props2.rootId,
|
|
110
|
-
showRootCollection = _this$props2.showRootCollection;
|
|
111
|
-
return !showRootCollection && typeof rootId !== 'undefined' && collection.id === rootId;
|
|
112
|
-
};
|
|
113
70
|
const initialState = {
|
|
114
71
|
selection: ''
|
|
115
72
|
};
|
|
@@ -126,20 +83,65 @@ let TreeBrowser = (_dec = withStyle(generateStyles), _dec(_class = (_TreeBrowser
|
|
|
126
83
|
this.state = initialState;
|
|
127
84
|
}
|
|
128
85
|
componentDidMount() {
|
|
129
|
-
|
|
130
|
-
(_this$props$makeStyle = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props3);
|
|
86
|
+
this.props.makeStyles?.();
|
|
131
87
|
}
|
|
132
88
|
componentDidUpdate() {
|
|
133
|
-
|
|
134
|
-
(_this$props$makeStyle2 = (_this$props4 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props4);
|
|
89
|
+
this.props.makeStyles?.();
|
|
135
90
|
}
|
|
136
91
|
get _root() {
|
|
137
92
|
return this.ref;
|
|
138
93
|
}
|
|
94
|
+
handleCollectionClick = (e, collection, expand = true) => {
|
|
95
|
+
e.stopPropagation();
|
|
96
|
+
const {
|
|
97
|
+
onCollectionClick
|
|
98
|
+
} = this.props;
|
|
99
|
+
if (expand) this.expandOrCollapseNode(collection);
|
|
100
|
+
onCollectionClick?.(collection.id, collection); // TODO: this should pass the event as the first arg
|
|
101
|
+
this.handleSelection(collection.id, 'collection');
|
|
102
|
+
};
|
|
103
|
+
handleItemClick = (e, item) => {
|
|
104
|
+
e.stopPropagation();
|
|
105
|
+
this.props.onItemClick?.(item);
|
|
106
|
+
this.handleSelection(item.id, 'item');
|
|
107
|
+
};
|
|
108
|
+
handleKeyDown = (event, node) => {
|
|
109
|
+
switch (event.keyCode) {
|
|
110
|
+
case keycode.codes.down:
|
|
111
|
+
case keycode.codes.j:
|
|
112
|
+
event.stopPropagation();
|
|
113
|
+
this.moveFocus(1);
|
|
114
|
+
break;
|
|
115
|
+
case keycode.codes.up:
|
|
116
|
+
case keycode.codes.k:
|
|
117
|
+
event.stopPropagation();
|
|
118
|
+
this.moveFocus(-1);
|
|
119
|
+
break;
|
|
120
|
+
case keycode.codes.home:
|
|
121
|
+
case keycode.codes.end:
|
|
122
|
+
event.stopPropagation();
|
|
123
|
+
this.homeOrEnd(event.keyCode);
|
|
124
|
+
break;
|
|
125
|
+
case keycode.codes.left:
|
|
126
|
+
case keycode.codes.right:
|
|
127
|
+
event.stopPropagation();
|
|
128
|
+
this.handleLeftOrRightArrow(event.keyCode, node);
|
|
129
|
+
break;
|
|
130
|
+
case keycode.codes.enter:
|
|
131
|
+
case keycode.codes.space:
|
|
132
|
+
event.stopPropagation();
|
|
133
|
+
this.handleActivation(event, node);
|
|
134
|
+
break;
|
|
135
|
+
default:
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
event.preventDefault();
|
|
139
|
+
};
|
|
139
140
|
get collections() {
|
|
140
|
-
const
|
|
141
|
-
collections
|
|
142
|
-
rootId
|
|
141
|
+
const {
|
|
142
|
+
collections,
|
|
143
|
+
rootId
|
|
144
|
+
} = this.props;
|
|
143
145
|
if (typeof rootId !== 'undefined') {
|
|
144
146
|
return [collections[rootId]];
|
|
145
147
|
} else {
|
|
@@ -159,8 +161,7 @@ let TreeBrowser = (_dec = withStyle(generateStyles), _dec(_class = (_TreeBrowser
|
|
|
159
161
|
return typeof props.selection === 'undefined' ? state.selection : props.selection;
|
|
160
162
|
}
|
|
161
163
|
expandOrCollapseNode(collection) {
|
|
162
|
-
|
|
163
|
-
(_this$props$onCollect = (_this$props6 = this.props).onCollectionToggle) === null || _this$props$onCollect === void 0 ? void 0 : _this$props$onCollect.call(_this$props6, collection);
|
|
164
|
+
this.props.onCollectionToggle?.(collection);
|
|
164
165
|
if (typeof this.props.expanded === 'undefined') {
|
|
165
166
|
this.setState((state, props) => {
|
|
166
167
|
const expanded = [...this.getExpanded(state, props)];
|
|
@@ -177,9 +178,10 @@ let TreeBrowser = (_dec = withStyle(generateStyles), _dec(_class = (_TreeBrowser
|
|
|
177
178
|
}
|
|
178
179
|
}
|
|
179
180
|
handleSelection(id, type) {
|
|
180
|
-
const
|
|
181
|
-
selectionType
|
|
182
|
-
onSelectionChange
|
|
181
|
+
const {
|
|
182
|
+
selectionType,
|
|
183
|
+
onSelectionChange
|
|
184
|
+
} = this.props;
|
|
183
185
|
if (selectionType !== 'single') return;
|
|
184
186
|
const selection = `${type}_${id}`;
|
|
185
187
|
|
|
@@ -201,6 +203,23 @@ let TreeBrowser = (_dec = withStyle(generateStyles), _dec(_class = (_TreeBrowser
|
|
|
201
203
|
});
|
|
202
204
|
}
|
|
203
205
|
}
|
|
206
|
+
clearSelection = () => {
|
|
207
|
+
const {
|
|
208
|
+
onSelectionChange
|
|
209
|
+
} = this.props;
|
|
210
|
+
|
|
211
|
+
// Call the callback if provided (for controlled selection)
|
|
212
|
+
if (onSelectionChange) {
|
|
213
|
+
onSelectionChange('', 'item', undefined);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// Update internal state only if uncontrolled
|
|
217
|
+
if (typeof this.props.selection === 'undefined') {
|
|
218
|
+
this.setState({
|
|
219
|
+
selection: ''
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
};
|
|
204
223
|
getNavigableNodes() {
|
|
205
224
|
return Array.from(this.ref.querySelectorAll('[role="treeitem"]'));
|
|
206
225
|
}
|
|
@@ -274,6 +293,13 @@ let TreeBrowser = (_dec = withStyle(generateStyles), _dec(_class = (_TreeBrowser
|
|
|
274
293
|
return [];
|
|
275
294
|
}
|
|
276
295
|
}
|
|
296
|
+
getIsFlattened = collection => {
|
|
297
|
+
const {
|
|
298
|
+
rootId,
|
|
299
|
+
showRootCollection
|
|
300
|
+
} = this.props;
|
|
301
|
+
return !showRootCollection && typeof rootId !== 'undefined' && collection.id === rootId;
|
|
302
|
+
};
|
|
277
303
|
getCollectionProps(collection) {
|
|
278
304
|
return {
|
|
279
305
|
id: collection.id,
|
|
@@ -307,14 +333,16 @@ let TreeBrowser = (_dec = withStyle(generateStyles), _dec(_class = (_TreeBrowser
|
|
|
307
333
|
}, i));
|
|
308
334
|
}
|
|
309
335
|
render() {
|
|
310
|
-
const
|
|
336
|
+
const {
|
|
337
|
+
styles
|
|
338
|
+
} = this.props;
|
|
311
339
|
return _jsx(TreeBrowserContext.Provider, {
|
|
312
340
|
value: {
|
|
313
341
|
animation: this.props.animation,
|
|
314
342
|
clearSelection: this.clearSelection
|
|
315
343
|
},
|
|
316
344
|
children: _jsx("ul", {
|
|
317
|
-
css: styles
|
|
345
|
+
css: styles?.treeBrowser,
|
|
318
346
|
tabIndex: 0,
|
|
319
347
|
role: "tree",
|
|
320
348
|
onKeyDown: this.handleKeyDown,
|
|
@@ -327,21 +355,6 @@ let TreeBrowser = (_dec = withStyle(generateStyles), _dec(_class = (_TreeBrowser
|
|
|
327
355
|
})
|
|
328
356
|
});
|
|
329
357
|
}
|
|
330
|
-
}
|
|
331
|
-
size: 'medium',
|
|
332
|
-
variant: 'folderTree',
|
|
333
|
-
showRootCollection: true,
|
|
334
|
-
collectionIcon: FolderClosedInstUIIcon,
|
|
335
|
-
collectionIconExpanded: FolderClosedInstUIIcon,
|
|
336
|
-
itemIcon: FileTextInstUIIcon,
|
|
337
|
-
getItemProps: props => props,
|
|
338
|
-
getCollectionProps: props => props,
|
|
339
|
-
defaultExpanded: [],
|
|
340
|
-
selectionType: 'none',
|
|
341
|
-
sortOrder: function () {
|
|
342
|
-
return 0;
|
|
343
|
-
},
|
|
344
|
-
animation: true
|
|
345
|
-
}, _TreeBrowser.Node = TreeNode, _TreeBrowser.Collection = TreeCollection, _TreeBrowser.Button = TreeButton, _TreeBrowser)) || _class);
|
|
358
|
+
}) || _class);
|
|
346
359
|
export default TreeBrowser;
|
|
347
360
|
export { TreeBrowser };
|
|
@@ -14,7 +14,7 @@ var _theme = _interopRequireDefault(require("./theme"));
|
|
|
14
14
|
var _props = require("./props");
|
|
15
15
|
var _TreeBrowserContext = _interopRequireDefault(require("../TreeBrowserContext"));
|
|
16
16
|
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
17
|
-
var _dec, _class
|
|
17
|
+
var _dec, _class;
|
|
18
18
|
/*
|
|
19
19
|
* The MIT License (MIT)
|
|
20
20
|
*
|
|
@@ -45,33 +45,36 @@ parent: TreeBrowser
|
|
|
45
45
|
id: TreeBrowser.Button
|
|
46
46
|
---
|
|
47
47
|
**/
|
|
48
|
-
let TreeButton = exports.TreeButton = (_dec = (0, _emotion.withStyleLegacy)(_styles.default, _theme.default), _dec(_class =
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
48
|
+
let TreeButton = exports.TreeButton = (_dec = (0, _emotion.withStyleLegacy)(_styles.default, _theme.default), _dec(_class = class TreeButton extends _react.Component {
|
|
49
|
+
static displayName = "TreeButton";
|
|
50
|
+
static componentId = 'TreeBrowser.Button';
|
|
51
|
+
static allowedProps = _props.allowedProps;
|
|
52
|
+
static contextType = _TreeBrowserContext.default;
|
|
53
|
+
static defaultProps = {
|
|
54
|
+
type: 'treeButton',
|
|
55
|
+
size: 'medium',
|
|
56
|
+
variant: 'folderTree',
|
|
57
|
+
selected: false,
|
|
58
|
+
focused: false,
|
|
59
|
+
expanded: false
|
|
60
|
+
};
|
|
61
|
+
ref = null;
|
|
59
62
|
componentDidMount() {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
animation: (_this$context = this.context) === null || _this$context === void 0 ? void 0 : _this$context.animation
|
|
63
|
+
this.props.makeStyles?.({
|
|
64
|
+
animation: this.context?.animation
|
|
63
65
|
});
|
|
64
66
|
}
|
|
65
67
|
componentDidUpdate() {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
animation: (_this$context2 = this.context) === null || _this$context2 === void 0 ? void 0 : _this$context2.animation
|
|
68
|
+
this.props.makeStyles?.({
|
|
69
|
+
animation: this.context?.animation
|
|
69
70
|
});
|
|
70
71
|
}
|
|
71
72
|
defaultContentRenderer(props) {
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
const {
|
|
74
|
+
name,
|
|
75
|
+
descriptor,
|
|
76
|
+
styles
|
|
77
|
+
} = props;
|
|
75
78
|
return (0, _jsxRuntime.jsxs)("span", {
|
|
76
79
|
css: styles.layout,
|
|
77
80
|
children: [this.renderImage(), (0, _jsxRuntime.jsxs)("span", {
|
|
@@ -88,7 +91,9 @@ let TreeButton = exports.TreeButton = (_dec = (0, _emotion.withStyleLegacy)(_sty
|
|
|
88
91
|
});
|
|
89
92
|
}
|
|
90
93
|
renderImage() {
|
|
91
|
-
const
|
|
94
|
+
const {
|
|
95
|
+
type
|
|
96
|
+
} = this.props;
|
|
92
97
|
switch (type) {
|
|
93
98
|
case 'collection':
|
|
94
99
|
return this.renderCollectionIcon();
|
|
@@ -97,30 +102,32 @@ let TreeButton = exports.TreeButton = (_dec = (0, _emotion.withStyleLegacy)(_sty
|
|
|
97
102
|
default:
|
|
98
103
|
break;
|
|
99
104
|
}
|
|
100
|
-
return
|
|
105
|
+
return undefined;
|
|
101
106
|
}
|
|
102
107
|
renderCollectionIcon() {
|
|
103
|
-
const
|
|
104
|
-
expanded
|
|
105
|
-
collectionIcon
|
|
106
|
-
collectionIconExpanded
|
|
107
|
-
styles
|
|
108
|
+
const {
|
|
109
|
+
expanded,
|
|
110
|
+
collectionIcon,
|
|
111
|
+
collectionIconExpanded,
|
|
112
|
+
styles
|
|
113
|
+
} = this.props;
|
|
108
114
|
if (collectionIcon || collectionIconExpanded) {
|
|
109
115
|
return (0, _jsxRuntime.jsx)("div", {
|
|
110
|
-
css: styles
|
|
116
|
+
css: styles?.icon,
|
|
111
117
|
children: (0, _callRenderProp.callRenderProp)(expanded ? collectionIconExpanded : collectionIcon)
|
|
112
118
|
});
|
|
113
119
|
}
|
|
114
|
-
return
|
|
120
|
+
return undefined;
|
|
115
121
|
}
|
|
116
122
|
renderItemImage() {
|
|
117
|
-
const
|
|
118
|
-
thumbnail
|
|
119
|
-
itemIcon
|
|
120
|
-
styles
|
|
123
|
+
const {
|
|
124
|
+
thumbnail,
|
|
125
|
+
itemIcon,
|
|
126
|
+
styles
|
|
127
|
+
} = this.props;
|
|
121
128
|
if (thumbnail) {
|
|
122
129
|
return (0, _jsxRuntime.jsx)("div", {
|
|
123
|
-
css: styles
|
|
130
|
+
css: styles?.thumbnail,
|
|
124
131
|
children: (0, _jsxRuntime.jsx)(_v11_.Img, {
|
|
125
132
|
src: thumbnail,
|
|
126
133
|
constrain: "cover",
|
|
@@ -130,33 +137,33 @@ let TreeButton = exports.TreeButton = (_dec = (0, _emotion.withStyleLegacy)(_sty
|
|
|
130
137
|
}
|
|
131
138
|
if (itemIcon) {
|
|
132
139
|
return (0, _jsxRuntime.jsx)("div", {
|
|
133
|
-
css: styles
|
|
140
|
+
css: styles?.icon,
|
|
134
141
|
children: (0, _callRenderProp.callRenderProp)(itemIcon)
|
|
135
142
|
});
|
|
136
143
|
}
|
|
137
|
-
return
|
|
144
|
+
return undefined;
|
|
138
145
|
}
|
|
146
|
+
handleRef = el => {
|
|
147
|
+
if (el && typeof this.props.containerRef === 'function') {
|
|
148
|
+
this.props.containerRef(el.parentElement);
|
|
149
|
+
}
|
|
150
|
+
this.ref = el;
|
|
151
|
+
};
|
|
139
152
|
render() {
|
|
140
|
-
const
|
|
141
|
-
styles
|
|
142
|
-
renderContent
|
|
153
|
+
const {
|
|
154
|
+
styles,
|
|
155
|
+
renderContent
|
|
156
|
+
} = this.props;
|
|
143
157
|
const buttonContent = renderContent ? renderContent(this.props) : this.defaultContentRenderer(this.props);
|
|
144
158
|
// VoiceOver can't navigate without the buttons, even though they don't do anything
|
|
145
159
|
return (0, _jsxRuntime.jsx)("button", {
|
|
146
160
|
ref: this.handleRef,
|
|
147
161
|
tabIndex: -1,
|
|
148
162
|
type: "button",
|
|
149
|
-
css: styles
|
|
163
|
+
css: styles?.treeButton,
|
|
150
164
|
"data-cid": "TreeButton",
|
|
151
165
|
children: buttonContent
|
|
152
166
|
});
|
|
153
167
|
}
|
|
154
|
-
}
|
|
155
|
-
type: 'treeButton',
|
|
156
|
-
size: 'medium',
|
|
157
|
-
variant: 'folderTree',
|
|
158
|
-
selected: false,
|
|
159
|
-
focused: false,
|
|
160
|
-
expanded: false
|
|
161
|
-
}, _TreeButton)) || _class);
|
|
168
|
+
}) || _class);
|
|
162
169
|
var _default = exports.default = TreeButton;
|
|
@@ -51,11 +51,13 @@ 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, state) => {
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
const {
|
|
55
|
+
size,
|
|
56
|
+
variant,
|
|
57
|
+
selected,
|
|
58
|
+
focused,
|
|
59
|
+
level
|
|
60
|
+
} = props;
|
|
59
61
|
const isRootButton = level && level === 1;
|
|
60
62
|
const sizeMap = {
|
|
61
63
|
small: {
|
|
@@ -34,12 +34,13 @@ 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
|
|
40
|
-
typography
|
|
41
|
-
themeName
|
|
42
|
-
spacing
|
|
37
|
+
const {
|
|
38
|
+
colors,
|
|
39
|
+
borders,
|
|
40
|
+
typography,
|
|
41
|
+
key: themeName,
|
|
42
|
+
spacing
|
|
43
|
+
} = theme;
|
|
43
44
|
const themeSpecificStyles = {
|
|
44
45
|
canvas: {
|
|
45
46
|
iconColor: theme['ic-brand-font-color-dark'],
|
|
@@ -50,32 +51,32 @@ const generateComponentTheme = theme => {
|
|
|
50
51
|
}
|
|
51
52
|
};
|
|
52
53
|
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
|
|
54
|
+
hoverBackgroundColor: colors?.contrasts?.blue4570,
|
|
55
|
+
hoverTextColor: colors?.contrasts?.white1010,
|
|
56
|
+
focusOutlineWidth: borders?.widthMedium,
|
|
57
|
+
focusOutlineColor: colors?.contrasts?.blue4570,
|
|
58
|
+
focusOutlineStyle: borders?.style,
|
|
59
|
+
iconColor: colors?.contrasts?.grey125125,
|
|
60
|
+
iconsMarginRight: spacing?.xSmall,
|
|
61
|
+
descriptorMarginTop: spacing?.xxxSmall,
|
|
62
|
+
descriptorTextColor: colors?.contrasts?.grey125125,
|
|
63
|
+
descriptorFontSizeSmall: typography?.fontSizeXSmall,
|
|
64
|
+
descriptorFontSizeMedium: typography?.fontSizeXSmall,
|
|
65
|
+
descriptorFontSizeLarge: typography?.fontSizeSmall,
|
|
66
|
+
nameTextColor: colors?.contrasts?.blue4570,
|
|
67
|
+
nameFontSizeSmall: typography?.fontSizeXSmall,
|
|
68
|
+
nameFontSizeMedium: typography?.fontSizeSmall,
|
|
69
|
+
nameFontSizeLarge: typography?.fontSizeMedium,
|
|
70
|
+
baseSpacingSmall: spacing?.xSmall,
|
|
71
|
+
baseSpacingMedium: spacing?.small,
|
|
71
72
|
baseSpacingLarge: '1rem',
|
|
72
|
-
borderWidth: borders
|
|
73
|
-
borderRadius: borders
|
|
74
|
-
borderColor: colors
|
|
75
|
-
textLineHeight: typography
|
|
76
|
-
selectedTextColor: colors
|
|
77
|
-
selectedBackgroundColor: colors
|
|
78
|
-
selectedOutlineWidth: borders
|
|
73
|
+
borderWidth: borders?.widthSmall,
|
|
74
|
+
borderRadius: borders?.radiusMedium,
|
|
75
|
+
borderColor: colors?.contrasts?.grey4570,
|
|
76
|
+
textLineHeight: typography?.lineHeightCondensed,
|
|
77
|
+
selectedTextColor: colors?.contrasts?.white1010,
|
|
78
|
+
selectedBackgroundColor: colors?.contrasts?.grey4570,
|
|
79
|
+
selectedOutlineWidth: borders?.widthLarge
|
|
79
80
|
};
|
|
80
81
|
return {
|
|
81
82
|
...componentVariables,
|