@instructure/ui-tree-browser 10.16.1-snapshot-0 → 10.16.1
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 +1 -1
- package/es/TreeBrowser/TreeButton/index.js +36 -28
- package/es/TreeBrowser/TreeCollection/index.js +45 -34
- package/es/TreeBrowser/TreeNode/index.js +24 -19
- package/es/TreeBrowser/index.js +10 -10
- package/lib/TreeBrowser/TreeButton/index.js +35 -27
- package/lib/TreeBrowser/TreeCollection/index.js +44 -34
- package/lib/TreeBrowser/TreeNode/index.js +23 -18
- package/lib/TreeBrowser/index.js +9 -8
- package/package.json +14 -14
- package/src/TreeBrowser/TreeButton/index.tsx +1 -2
- package/src/TreeBrowser/TreeCollection/index.tsx +2 -4
- package/src/TreeBrowser/TreeNode/index.tsx +1 -2
- package/src/TreeBrowser/index.tsx +1 -3
- package/src/TreeBrowser/props.ts +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/TreeBrowser/TreeButton/index.d.ts +5 -7
- package/types/TreeBrowser/TreeButton/index.d.ts.map +1 -1
- package/types/TreeBrowser/TreeCollection/index.d.ts +6 -9
- package/types/TreeBrowser/TreeCollection/index.d.ts.map +1 -1
- package/types/TreeBrowser/TreeNode/index.d.ts +2 -4
- package/types/TreeBrowser/TreeNode/index.d.ts.map +1 -1
- package/types/TreeBrowser/index.d.ts +2 -4
- package/types/TreeBrowser/index.d.ts.map +1 -1
- package/types/TreeBrowser/props.d.ts +1 -1
- package/types/TreeBrowser/props.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## [10.16.1
|
|
6
|
+
## [10.16.1](https://github.com/instructure/instructure-ui/compare/v10.16.0...v10.16.1) (2025-04-22)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @instructure/ui-tree-browser
|
|
9
9
|
|
|
@@ -23,12 +23,11 @@ var _dec, _dec2, _class, _TreeButton;
|
|
|
23
23
|
* SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
/** @jsx jsx */
|
|
27
26
|
import { Component } from 'react';
|
|
28
27
|
import { testable } from '@instructure/ui-testable';
|
|
29
28
|
import { Img } from '@instructure/ui-img';
|
|
30
29
|
import { callRenderProp } from '@instructure/ui-react-utils';
|
|
31
|
-
import { withStyle
|
|
30
|
+
import { withStyle } from '@instructure/emotion';
|
|
32
31
|
import generateStyles from './styles';
|
|
33
32
|
import generateComponentTheme from './theme';
|
|
34
33
|
import { allowedProps, propTypes } from './props';
|
|
@@ -41,6 +40,7 @@ parent: TreeBrowser
|
|
|
41
40
|
id: TreeBrowser.Button
|
|
42
41
|
---
|
|
43
42
|
**/
|
|
43
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
44
44
|
let TreeButton = (_dec = withStyle(generateStyles, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = (_TreeButton = class TreeButton extends Component {
|
|
45
45
|
constructor(...args) {
|
|
46
46
|
super(...args);
|
|
@@ -64,16 +64,20 @@ let TreeButton = (_dec = withStyle(generateStyles, generateComponentTheme), _dec
|
|
|
64
64
|
const name = props.name,
|
|
65
65
|
descriptor = props.descriptor,
|
|
66
66
|
styles = props.styles;
|
|
67
|
-
return
|
|
68
|
-
css: styles.layout
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
67
|
+
return _jsxs("span", {
|
|
68
|
+
css: styles.layout,
|
|
69
|
+
children: [this.renderImage(), _jsxs("span", {
|
|
70
|
+
css: styles.text,
|
|
71
|
+
children: [_jsx("span", {
|
|
72
|
+
css: styles.textName,
|
|
73
|
+
children: name
|
|
74
|
+
}), descriptor ? _jsx("span", {
|
|
75
|
+
css: styles.textDescriptor,
|
|
76
|
+
title: descriptor,
|
|
77
|
+
children: descriptor
|
|
78
|
+
}) : null]
|
|
79
|
+
})]
|
|
80
|
+
});
|
|
77
81
|
}
|
|
78
82
|
renderImage() {
|
|
79
83
|
const type = this.props.type;
|
|
@@ -94,9 +98,10 @@ let TreeButton = (_dec = withStyle(generateStyles, generateComponentTheme), _dec
|
|
|
94
98
|
collectionIconExpanded = _this$props3.collectionIconExpanded,
|
|
95
99
|
styles = _this$props3.styles;
|
|
96
100
|
if (collectionIcon || collectionIconExpanded) {
|
|
97
|
-
return
|
|
98
|
-
css: styles === null || styles === void 0 ? void 0 : styles.icon
|
|
99
|
-
|
|
101
|
+
return _jsx("div", {
|
|
102
|
+
css: styles === null || styles === void 0 ? void 0 : styles.icon,
|
|
103
|
+
children: callRenderProp(expanded ? collectionIconExpanded : collectionIcon)
|
|
104
|
+
});
|
|
100
105
|
}
|
|
101
106
|
return void 0;
|
|
102
107
|
}
|
|
@@ -106,18 +111,20 @@ let TreeButton = (_dec = withStyle(generateStyles, generateComponentTheme), _dec
|
|
|
106
111
|
itemIcon = _this$props4.itemIcon,
|
|
107
112
|
styles = _this$props4.styles;
|
|
108
113
|
if (thumbnail) {
|
|
109
|
-
return
|
|
110
|
-
css: styles === null || styles === void 0 ? void 0 : styles.thumbnail
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
114
|
+
return _jsx("div", {
|
|
115
|
+
css: styles === null || styles === void 0 ? void 0 : styles.thumbnail,
|
|
116
|
+
children: _jsx(Img, {
|
|
117
|
+
src: thumbnail,
|
|
118
|
+
constrain: "cover",
|
|
119
|
+
alt: ""
|
|
120
|
+
})
|
|
121
|
+
});
|
|
116
122
|
}
|
|
117
123
|
if (itemIcon) {
|
|
118
|
-
return
|
|
119
|
-
css: styles === null || styles === void 0 ? void 0 : styles.icon
|
|
120
|
-
|
|
124
|
+
return _jsx("div", {
|
|
125
|
+
css: styles === null || styles === void 0 ? void 0 : styles.icon,
|
|
126
|
+
children: callRenderProp(itemIcon)
|
|
127
|
+
});
|
|
121
128
|
}
|
|
122
129
|
return void 0;
|
|
123
130
|
}
|
|
@@ -127,12 +134,13 @@ let TreeButton = (_dec = withStyle(generateStyles, generateComponentTheme), _dec
|
|
|
127
134
|
renderContent = _this$props5.renderContent;
|
|
128
135
|
const buttonContent = renderContent ? renderContent(this.props) : this.defaultContentRenderer(this.props);
|
|
129
136
|
// VoiceOver can't navigate without the buttons, even though they don't do anything
|
|
130
|
-
return
|
|
137
|
+
return _jsx("button", {
|
|
131
138
|
ref: this.handleRef,
|
|
132
139
|
tabIndex: -1,
|
|
133
140
|
type: "button",
|
|
134
|
-
css: styles === null || styles === void 0 ? void 0 : styles.treeButton
|
|
135
|
-
|
|
141
|
+
css: styles === null || styles === void 0 ? void 0 : styles.treeButton,
|
|
142
|
+
children: buttonContent
|
|
143
|
+
});
|
|
136
144
|
}
|
|
137
145
|
}, _TreeButton.displayName = "TreeButton", _TreeButton.componentId = 'TreeBrowser.Button', _TreeButton.allowedProps = allowedProps, _TreeButton.propTypes = propTypes, _TreeButton.defaultProps = {
|
|
138
146
|
type: 'treeButton',
|
|
@@ -23,16 +23,16 @@ var _dec, _dec2, _class, _TreeCollection;
|
|
|
23
23
|
* SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
/** @jsxFrag React.Fragment */
|
|
28
|
-
import React, { Component } from 'react';
|
|
26
|
+
import { Component } from 'react';
|
|
29
27
|
import { testable } from '@instructure/ui-testable';
|
|
30
|
-
import { withStyle
|
|
28
|
+
import { withStyle } from '@instructure/emotion';
|
|
31
29
|
import { safeCloneElement } from '@instructure/ui-react-utils';
|
|
32
30
|
import { TreeButton } from '../TreeButton';
|
|
33
31
|
import generateStyles from './styles';
|
|
34
32
|
import generateComponentTheme from './theme';
|
|
35
33
|
import { allowedProps, propTypes } from './props';
|
|
34
|
+
import { Fragment as _Fragment, jsxs as _jsxs, jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
35
|
+
import { createElement as _createElement } from "@emotion/react";
|
|
36
36
|
/**
|
|
37
37
|
---
|
|
38
38
|
parent: TreeBrowser
|
|
@@ -144,17 +144,19 @@ let TreeCollection = (_dec = withStyle(generateStyles, generateComponentTheme),
|
|
|
144
144
|
compareFunc = _this$props7.compareFunc;
|
|
145
145
|
let position = 1;
|
|
146
146
|
const sortedChildren = this.sortChildren();
|
|
147
|
-
return
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
147
|
+
return _jsxs(_Fragment, {
|
|
148
|
+
children: [renderBeforeItems && this.renderCollectionChildren(id, renderBeforeItems, position++, 'before'), !compareFunc && collections.map(collection => {
|
|
149
|
+
return this.renderCollectionNode(collection, position++);
|
|
150
|
+
}), !compareFunc && items.map(item => {
|
|
151
|
+
return this.renderItemNode(item, position++);
|
|
152
|
+
}), compareFunc && sortedChildren.map(child => {
|
|
153
|
+
if (child.type === 'collection') {
|
|
154
|
+
return this.renderCollectionNode(child, position++);
|
|
155
|
+
} else {
|
|
156
|
+
return this.renderItemNode(child, position++);
|
|
157
|
+
}
|
|
158
|
+
}), renderAfterItems && this.renderCollectionChildren(id, renderAfterItems, position++, 'after')]
|
|
159
|
+
});
|
|
158
160
|
}
|
|
159
161
|
renderCollectionChildren(collectionId, child, position, keyword) {
|
|
160
162
|
const _this$props8 = this.props,
|
|
@@ -177,17 +179,16 @@ let TreeCollection = (_dec = withStyle(generateStyles, generateComponentTheme),
|
|
|
177
179
|
focused: this.state.focused === `child_${key}`,
|
|
178
180
|
level: this.itemsLevel
|
|
179
181
|
});
|
|
180
|
-
return
|
|
182
|
+
return _jsx("li", {
|
|
181
183
|
id: key
|
|
182
184
|
/* eslint-disable-next-line jsx-a11y/role-has-required-aria-props */,
|
|
183
185
|
role: "treeitem",
|
|
184
186
|
css: styles === null || styles === void 0 ? void 0 : styles.item,
|
|
185
187
|
tabIndex: -1,
|
|
186
|
-
key: key,
|
|
187
188
|
"aria-posinset": position,
|
|
188
189
|
"aria-setsize": this.childCount,
|
|
189
|
-
"aria-level": this.itemsLevel
|
|
190
|
-
|
|
190
|
+
"aria-level": this.itemsLevel,
|
|
191
|
+
...ariaSelected,
|
|
191
192
|
onClick: e => {
|
|
192
193
|
if (typeof child.props.onClick === 'function') {
|
|
193
194
|
child.props.onClick(e);
|
|
@@ -203,11 +204,13 @@ let TreeCollection = (_dec = withStyle(generateStyles, generateComponentTheme),
|
|
|
203
204
|
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(e, itemHash);
|
|
204
205
|
}
|
|
205
206
|
},
|
|
206
|
-
onBlur: e => this.handleBlur(e, itemHash)
|
|
207
|
-
|
|
207
|
+
onBlur: e => this.handleBlur(e, itemHash),
|
|
208
|
+
children: safeCloneElement(child, itemProps)
|
|
209
|
+
}, key);
|
|
208
210
|
}
|
|
209
211
|
renderCollectionNode(collection, position) {
|
|
210
|
-
return
|
|
212
|
+
return _createElement(TreeCollection, {
|
|
213
|
+
...this.props,
|
|
211
214
|
key: `c${position}`,
|
|
212
215
|
id: collection.id,
|
|
213
216
|
name: collection.name,
|
|
@@ -224,7 +227,7 @@ let TreeCollection = (_dec = withStyle(generateStyles, generateComponentTheme),
|
|
|
224
227
|
isCollectionFlattened: false // only the root needs to be flattened
|
|
225
228
|
,
|
|
226
229
|
compareFunc: collection.compareFunc
|
|
227
|
-
})
|
|
230
|
+
});
|
|
228
231
|
}
|
|
229
232
|
renderItemNode(item, position) {
|
|
230
233
|
const _this$props9 = this.props,
|
|
@@ -251,8 +254,7 @@ let TreeCollection = (_dec = withStyle(generateStyles, generateComponentTheme),
|
|
|
251
254
|
focused: this.state.focused === `item_${item.id}`,
|
|
252
255
|
type: 'item'
|
|
253
256
|
});
|
|
254
|
-
return
|
|
255
|
-
key: `i${position}`,
|
|
257
|
+
return _jsx("li", {
|
|
256
258
|
tabIndex: -1
|
|
257
259
|
/* eslint-disable-next-line jsx-a11y/role-has-required-aria-props */,
|
|
258
260
|
role: "treeitem",
|
|
@@ -264,8 +266,12 @@ let TreeCollection = (_dec = withStyle(generateStyles, generateComponentTheme),
|
|
|
264
266
|
onClick: e => onItemClick === null || onItemClick === void 0 ? void 0 : onItemClick(e, itemHash),
|
|
265
267
|
onKeyDown: e => onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(e, itemHash),
|
|
266
268
|
onFocus: e => this.handleFocus(e, itemHash),
|
|
267
|
-
onBlur: e => this.handleBlur(e, itemHash)
|
|
268
|
-
|
|
269
|
+
onBlur: e => this.handleBlur(e, itemHash),
|
|
270
|
+
...ariaSelected,
|
|
271
|
+
children: _jsx(TreeButton, {
|
|
272
|
+
...itemProps
|
|
273
|
+
})
|
|
274
|
+
}, `i${position}`);
|
|
269
275
|
}
|
|
270
276
|
getCommonButtonProps() {
|
|
271
277
|
return {
|
|
@@ -306,7 +312,7 @@ let TreeCollection = (_dec = withStyle(generateStyles, generateComponentTheme),
|
|
|
306
312
|
'aria-selected': void 0
|
|
307
313
|
};
|
|
308
314
|
if (this.props.selection) ariaSelected['aria-selected'] = this.props.selection === `collection_${id}`;
|
|
309
|
-
return isCollectionFlattened ? this.renderChildren() :
|
|
315
|
+
return isCollectionFlattened ? this.renderChildren() : _jsxs("li", {
|
|
310
316
|
ref: el => {
|
|
311
317
|
this.ref = el;
|
|
312
318
|
},
|
|
@@ -328,12 +334,17 @@ let TreeCollection = (_dec = withStyle(generateStyles, generateComponentTheme),
|
|
|
328
334
|
onBlur: e => this.handleBlur(e, {
|
|
329
335
|
id: id,
|
|
330
336
|
type: 'collection'
|
|
331
|
-
})
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
+
}),
|
|
338
|
+
...ariaSelected,
|
|
339
|
+
children: [_jsx(TreeButton, {
|
|
340
|
+
...collectionProps
|
|
341
|
+
}), expanded && this.childCount > 0 && _jsx("ul", {
|
|
342
|
+
"aria-label": name,
|
|
343
|
+
css: styles === null || styles === void 0 ? void 0 : styles.list,
|
|
344
|
+
role: "group",
|
|
345
|
+
children: this.renderChildren()
|
|
346
|
+
})]
|
|
347
|
+
});
|
|
337
348
|
}
|
|
338
349
|
}, _TreeCollection.displayName = "TreeCollection", _TreeCollection.componentId = 'TreeBrowser.Collection', _TreeCollection.allowedProps = allowedProps, _TreeCollection.propTypes = propTypes, _TreeCollection.defaultProps = {
|
|
339
350
|
collections: [],
|
|
@@ -23,12 +23,11 @@ var _dec, _dec2, _class, _TreeNode;
|
|
|
23
23
|
* SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
/** @jsx jsx */
|
|
27
26
|
import { Component } from 'react';
|
|
28
27
|
import { Img } from '@instructure/ui-img';
|
|
29
28
|
import { callRenderProp } from '@instructure/ui-react-utils';
|
|
30
29
|
import { testable } from '@instructure/ui-testable';
|
|
31
|
-
import { withStyle
|
|
30
|
+
import { withStyle } from '@instructure/emotion';
|
|
32
31
|
import generateStyles from '../TreeButton/styles';
|
|
33
32
|
import generateComponentTheme from '../TreeButton/theme';
|
|
34
33
|
import { allowedProps, propTypes } from './props';
|
|
@@ -43,6 +42,7 @@ id: TreeBrowser.Node
|
|
|
43
42
|
A helper class used to render the :renderBeforeItems and :renderAfterItems
|
|
44
43
|
in the TreeBrowser.
|
|
45
44
|
**/
|
|
45
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
46
46
|
let TreeNode = (_dec = withStyle(generateStyles, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = (_TreeNode = class TreeNode extends Component {
|
|
47
47
|
constructor(...args) {
|
|
48
48
|
super(...args);
|
|
@@ -68,18 +68,20 @@ let TreeNode = (_dec = withStyle(generateStyles, generateComponentTheme), _dec2
|
|
|
68
68
|
itemIcon = _this$props3.itemIcon,
|
|
69
69
|
styles = _this$props3.styles;
|
|
70
70
|
if (thumbnail) {
|
|
71
|
-
return
|
|
72
|
-
css: styles === null || styles === void 0 ? void 0 : styles.thumbnail
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
71
|
+
return _jsx("div", {
|
|
72
|
+
css: styles === null || styles === void 0 ? void 0 : styles.thumbnail,
|
|
73
|
+
children: _jsx(Img, {
|
|
74
|
+
src: thumbnail,
|
|
75
|
+
constrain: "cover",
|
|
76
|
+
alt: ""
|
|
77
|
+
})
|
|
78
|
+
});
|
|
78
79
|
}
|
|
79
80
|
if (itemIcon) {
|
|
80
|
-
return
|
|
81
|
-
css: styles === null || styles === void 0 ? void 0 : styles.icon
|
|
82
|
-
|
|
81
|
+
return _jsx("div", {
|
|
82
|
+
css: styles === null || styles === void 0 ? void 0 : styles.icon,
|
|
83
|
+
children: callRenderProp(itemIcon)
|
|
84
|
+
});
|
|
83
85
|
}
|
|
84
86
|
return void 0;
|
|
85
87
|
}
|
|
@@ -87,15 +89,18 @@ let TreeNode = (_dec = withStyle(generateStyles, generateComponentTheme), _dec2
|
|
|
87
89
|
const _this$props4 = this.props,
|
|
88
90
|
children = _this$props4.children,
|
|
89
91
|
styles = _this$props4.styles;
|
|
90
|
-
return
|
|
92
|
+
return _jsx("div", {
|
|
91
93
|
ref: this.handleRef,
|
|
92
94
|
tabIndex: -1,
|
|
93
|
-
css: styles === null || styles === void 0 ? void 0 : styles.treeButton
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
95
|
+
css: styles === null || styles === void 0 ? void 0 : styles.treeButton,
|
|
96
|
+
children: _jsxs("span", {
|
|
97
|
+
css: styles === null || styles === void 0 ? void 0 : styles.layout,
|
|
98
|
+
children: [this.renderItemImage(), _jsx("span", {
|
|
99
|
+
css: styles === null || styles === void 0 ? void 0 : styles.node,
|
|
100
|
+
children: children
|
|
101
|
+
})]
|
|
102
|
+
})
|
|
103
|
+
});
|
|
99
104
|
}
|
|
100
105
|
}, _TreeNode.displayName = "TreeNode", _TreeNode.componentId = 'TreeBrowser.Node', _TreeNode.allowedProps = allowedProps, _TreeNode.propTypes = propTypes, _TreeNode.defaultProps = {
|
|
101
106
|
size: 'medium',
|
package/es/TreeBrowser/index.js
CHANGED
|
@@ -23,14 +23,12 @@ var _dec, _dec2, _class, _TreeBrowser;
|
|
|
23
23
|
* SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
/** @jsx jsx */
|
|
27
|
-
|
|
28
26
|
import { Component } from 'react';
|
|
29
27
|
import keycode from 'keycode';
|
|
30
28
|
import { IconFolderLine, IconDocumentLine } from '@instructure/ui-icons';
|
|
31
29
|
import { omitProps, pickProps } from '@instructure/ui-react-utils';
|
|
32
30
|
import { testable } from '@instructure/ui-testable';
|
|
33
|
-
import { withStyle
|
|
31
|
+
import { withStyle } from '@instructure/emotion';
|
|
34
32
|
import { TreeCollection } from './TreeCollection';
|
|
35
33
|
import { TreeButton } from './TreeButton';
|
|
36
34
|
import { TreeNode } from './TreeNode';
|
|
@@ -43,6 +41,7 @@ import { allowedProps, propTypes } from './props';
|
|
|
43
41
|
category: components
|
|
44
42
|
---
|
|
45
43
|
**/
|
|
44
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
46
45
|
let TreeBrowser = (_dec = withStyle(generateStyles, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = (_TreeBrowser = class TreeBrowser extends Component {
|
|
47
46
|
constructor(props) {
|
|
48
47
|
super(props);
|
|
@@ -259,9 +258,9 @@ let TreeBrowser = (_dec = withStyle(generateStyles, generateComponentTheme), _de
|
|
|
259
258
|
return expanded.findIndex(expanded => String(expanded) === String(id));
|
|
260
259
|
}
|
|
261
260
|
renderRoot() {
|
|
262
|
-
return this.collections.sort(this.props.sortOrder).map((collection, i) =>
|
|
263
|
-
|
|
264
|
-
|
|
261
|
+
return this.collections.sort(this.props.sortOrder).map((collection, i) => _jsx(TreeCollection, {
|
|
262
|
+
...pickProps(omitProps(this.props), TreeCollection.allowedProps),
|
|
263
|
+
...this.getCollectionProps(collection),
|
|
265
264
|
selection: this.state.selection,
|
|
266
265
|
onItemClick: this.handleItemClick,
|
|
267
266
|
onCollectionClick: this.handleCollectionClick,
|
|
@@ -270,11 +269,11 @@ let TreeBrowser = (_dec = withStyle(generateStyles, generateComponentTheme), _de
|
|
|
270
269
|
level: 1,
|
|
271
270
|
position: 1,
|
|
272
271
|
renderContent: this.props.renderContent
|
|
273
|
-
}))
|
|
272
|
+
}, i));
|
|
274
273
|
}
|
|
275
274
|
render() {
|
|
276
275
|
const styles = this.props.styles;
|
|
277
|
-
return
|
|
276
|
+
return _jsx("ul", {
|
|
278
277
|
css: styles === null || styles === void 0 ? void 0 : styles.treeBrowser,
|
|
279
278
|
tabIndex: 0,
|
|
280
279
|
role: "tree",
|
|
@@ -282,8 +281,9 @@ let TreeBrowser = (_dec = withStyle(generateStyles, generateComponentTheme), _de
|
|
|
282
281
|
ref: el => {
|
|
283
282
|
this.ref = el;
|
|
284
283
|
},
|
|
285
|
-
"aria-label": this.props.treeLabel
|
|
286
|
-
|
|
284
|
+
"aria-label": this.props.treeLabel,
|
|
285
|
+
children: this.renderRoot()
|
|
286
|
+
});
|
|
287
287
|
}
|
|
288
288
|
}, _TreeBrowser.displayName = "TreeBrowser", _TreeBrowser.componentId = 'TreeBrowser', _TreeBrowser.allowedProps = allowedProps, _TreeBrowser.propTypes = propTypes, _TreeBrowser.defaultProps = {
|
|
289
289
|
size: 'medium',
|
|
@@ -13,6 +13,7 @@ var _emotion = require("@instructure/emotion");
|
|
|
13
13
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
14
14
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
15
15
|
var _props = require("./props");
|
|
16
|
+
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
16
17
|
var _dec, _dec2, _class, _TreeButton;
|
|
17
18
|
/*
|
|
18
19
|
* The MIT License (MIT)
|
|
@@ -37,7 +38,6 @@ var _dec, _dec2, _class, _TreeButton;
|
|
|
37
38
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
38
39
|
* SOFTWARE.
|
|
39
40
|
*/
|
|
40
|
-
/** @jsx jsx */
|
|
41
41
|
// Todo: merge TreeButton and TreeNode: TreeButton should be a special type of TreeNode
|
|
42
42
|
/**
|
|
43
43
|
---
|
|
@@ -68,16 +68,20 @@ let TreeButton = exports.TreeButton = (_dec = (0, _emotion.withStyle)(_styles.de
|
|
|
68
68
|
const name = props.name,
|
|
69
69
|
descriptor = props.descriptor,
|
|
70
70
|
styles = props.styles;
|
|
71
|
-
return (0,
|
|
72
|
-
css: styles.layout
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
71
|
+
return (0, _jsxRuntime.jsxs)("span", {
|
|
72
|
+
css: styles.layout,
|
|
73
|
+
children: [this.renderImage(), (0, _jsxRuntime.jsxs)("span", {
|
|
74
|
+
css: styles.text,
|
|
75
|
+
children: [(0, _jsxRuntime.jsx)("span", {
|
|
76
|
+
css: styles.textName,
|
|
77
|
+
children: name
|
|
78
|
+
}), descriptor ? (0, _jsxRuntime.jsx)("span", {
|
|
79
|
+
css: styles.textDescriptor,
|
|
80
|
+
title: descriptor,
|
|
81
|
+
children: descriptor
|
|
82
|
+
}) : null]
|
|
83
|
+
})]
|
|
84
|
+
});
|
|
81
85
|
}
|
|
82
86
|
renderImage() {
|
|
83
87
|
const type = this.props.type;
|
|
@@ -98,9 +102,10 @@ let TreeButton = exports.TreeButton = (_dec = (0, _emotion.withStyle)(_styles.de
|
|
|
98
102
|
collectionIconExpanded = _this$props3.collectionIconExpanded,
|
|
99
103
|
styles = _this$props3.styles;
|
|
100
104
|
if (collectionIcon || collectionIconExpanded) {
|
|
101
|
-
return (0,
|
|
102
|
-
css: styles === null || styles === void 0 ? void 0 : styles.icon
|
|
103
|
-
|
|
105
|
+
return (0, _jsxRuntime.jsx)("div", {
|
|
106
|
+
css: styles === null || styles === void 0 ? void 0 : styles.icon,
|
|
107
|
+
children: (0, _callRenderProp.callRenderProp)(expanded ? collectionIconExpanded : collectionIcon)
|
|
108
|
+
});
|
|
104
109
|
}
|
|
105
110
|
return void 0;
|
|
106
111
|
}
|
|
@@ -110,18 +115,20 @@ let TreeButton = exports.TreeButton = (_dec = (0, _emotion.withStyle)(_styles.de
|
|
|
110
115
|
itemIcon = _this$props4.itemIcon,
|
|
111
116
|
styles = _this$props4.styles;
|
|
112
117
|
if (thumbnail) {
|
|
113
|
-
return (0,
|
|
114
|
-
css: styles === null || styles === void 0 ? void 0 : styles.thumbnail
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
118
|
+
return (0, _jsxRuntime.jsx)("div", {
|
|
119
|
+
css: styles === null || styles === void 0 ? void 0 : styles.thumbnail,
|
|
120
|
+
children: (0, _jsxRuntime.jsx)(_Img.Img, {
|
|
121
|
+
src: thumbnail,
|
|
122
|
+
constrain: "cover",
|
|
123
|
+
alt: ""
|
|
124
|
+
})
|
|
125
|
+
});
|
|
120
126
|
}
|
|
121
127
|
if (itemIcon) {
|
|
122
|
-
return (0,
|
|
123
|
-
css: styles === null || styles === void 0 ? void 0 : styles.icon
|
|
124
|
-
|
|
128
|
+
return (0, _jsxRuntime.jsx)("div", {
|
|
129
|
+
css: styles === null || styles === void 0 ? void 0 : styles.icon,
|
|
130
|
+
children: (0, _callRenderProp.callRenderProp)(itemIcon)
|
|
131
|
+
});
|
|
125
132
|
}
|
|
126
133
|
return void 0;
|
|
127
134
|
}
|
|
@@ -131,12 +138,13 @@ let TreeButton = exports.TreeButton = (_dec = (0, _emotion.withStyle)(_styles.de
|
|
|
131
138
|
renderContent = _this$props5.renderContent;
|
|
132
139
|
const buttonContent = renderContent ? renderContent(this.props) : this.defaultContentRenderer(this.props);
|
|
133
140
|
// VoiceOver can't navigate without the buttons, even though they don't do anything
|
|
134
|
-
return (0,
|
|
141
|
+
return (0, _jsxRuntime.jsx)("button", {
|
|
135
142
|
ref: this.handleRef,
|
|
136
143
|
tabIndex: -1,
|
|
137
144
|
type: "button",
|
|
138
|
-
css: styles === null || styles === void 0 ? void 0 : styles.treeButton
|
|
139
|
-
|
|
145
|
+
css: styles === null || styles === void 0 ? void 0 : styles.treeButton,
|
|
146
|
+
children: buttonContent
|
|
147
|
+
});
|
|
140
148
|
}
|
|
141
149
|
}, _TreeButton.displayName = "TreeButton", _TreeButton.componentId = 'TreeBrowser.Button', _TreeButton.allowedProps = _props.allowedProps, _TreeButton.propTypes = _props.propTypes, _TreeButton.defaultProps = {
|
|
142
150
|
type: 'treeButton',
|