@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
package/CHANGELOG.md
CHANGED
|
@@ -3,9 +3,12 @@
|
|
|
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
|
-
## [11.7.3-snapshot-
|
|
6
|
+
## [11.7.3-snapshot-26](https://github.com/instructure/instructure-ui/compare/v11.7.2...v11.7.3-snapshot-26) (2026-05-05)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **many:** update dependencies, remove lots of Babel plugins, remove Webpack 4 support ([f916fca](https://github.com/instructure/instructure-ui/commit/f916fcafdddcb2d7de401f93e8ff92cfdfa47bba))
|
|
9
12
|
|
|
10
13
|
|
|
11
14
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _dec, _class
|
|
1
|
+
var _dec, _class;
|
|
2
2
|
/*
|
|
3
3
|
* The MIT License (MIT)
|
|
4
4
|
*
|
|
@@ -38,33 +38,36 @@ id: TreeBrowser.Button
|
|
|
38
38
|
---
|
|
39
39
|
**/
|
|
40
40
|
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
41
|
-
let TreeButton = (_dec = withStyle(generateStyles, generateComponentTheme), _dec(_class =
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
41
|
+
let TreeButton = (_dec = withStyle(generateStyles, generateComponentTheme), _dec(_class = class TreeButton extends Component {
|
|
42
|
+
static displayName = "TreeButton";
|
|
43
|
+
static componentId = 'TreeBrowser.Button';
|
|
44
|
+
static allowedProps = allowedProps;
|
|
45
|
+
static contextType = TreeBrowserContext;
|
|
46
|
+
static defaultProps = {
|
|
47
|
+
type: 'treeButton',
|
|
48
|
+
size: 'medium',
|
|
49
|
+
variant: 'folderTree',
|
|
50
|
+
selected: false,
|
|
51
|
+
focused: false,
|
|
52
|
+
expanded: false
|
|
53
|
+
};
|
|
54
|
+
ref = null;
|
|
52
55
|
componentDidMount() {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
animation: (_this$context = this.context) === null || _this$context === void 0 ? void 0 : _this$context.animation
|
|
56
|
+
this.props.makeStyles?.({
|
|
57
|
+
animation: this.context?.animation
|
|
56
58
|
});
|
|
57
59
|
}
|
|
58
60
|
componentDidUpdate() {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
animation: (_this$context2 = this.context) === null || _this$context2 === void 0 ? void 0 : _this$context2.animation
|
|
61
|
+
this.props.makeStyles?.({
|
|
62
|
+
animation: this.context?.animation
|
|
62
63
|
});
|
|
63
64
|
}
|
|
64
65
|
defaultContentRenderer(props) {
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
const {
|
|
67
|
+
name,
|
|
68
|
+
descriptor,
|
|
69
|
+
styles
|
|
70
|
+
} = props;
|
|
68
71
|
return _jsxs("span", {
|
|
69
72
|
css: styles.layout,
|
|
70
73
|
children: [this.renderImage(), _jsxs("span", {
|
|
@@ -81,7 +84,9 @@ let TreeButton = (_dec = withStyle(generateStyles, generateComponentTheme), _dec
|
|
|
81
84
|
});
|
|
82
85
|
}
|
|
83
86
|
renderImage() {
|
|
84
|
-
const
|
|
87
|
+
const {
|
|
88
|
+
type
|
|
89
|
+
} = this.props;
|
|
85
90
|
switch (type) {
|
|
86
91
|
case 'collection':
|
|
87
92
|
return this.renderCollectionIcon();
|
|
@@ -90,30 +95,32 @@ let TreeButton = (_dec = withStyle(generateStyles, generateComponentTheme), _dec
|
|
|
90
95
|
default:
|
|
91
96
|
break;
|
|
92
97
|
}
|
|
93
|
-
return
|
|
98
|
+
return undefined;
|
|
94
99
|
}
|
|
95
100
|
renderCollectionIcon() {
|
|
96
|
-
const
|
|
97
|
-
expanded
|
|
98
|
-
collectionIcon
|
|
99
|
-
collectionIconExpanded
|
|
100
|
-
styles
|
|
101
|
+
const {
|
|
102
|
+
expanded,
|
|
103
|
+
collectionIcon,
|
|
104
|
+
collectionIconExpanded,
|
|
105
|
+
styles
|
|
106
|
+
} = this.props;
|
|
101
107
|
if (collectionIcon || collectionIconExpanded) {
|
|
102
108
|
return _jsx("div", {
|
|
103
|
-
css: styles
|
|
109
|
+
css: styles?.icon,
|
|
104
110
|
children: callRenderProp(expanded ? collectionIconExpanded : collectionIcon)
|
|
105
111
|
});
|
|
106
112
|
}
|
|
107
|
-
return
|
|
113
|
+
return undefined;
|
|
108
114
|
}
|
|
109
115
|
renderItemImage() {
|
|
110
|
-
const
|
|
111
|
-
thumbnail
|
|
112
|
-
itemIcon
|
|
113
|
-
styles
|
|
116
|
+
const {
|
|
117
|
+
thumbnail,
|
|
118
|
+
itemIcon,
|
|
119
|
+
styles
|
|
120
|
+
} = this.props;
|
|
114
121
|
if (thumbnail) {
|
|
115
122
|
return _jsx("div", {
|
|
116
|
-
css: styles
|
|
123
|
+
css: styles?.thumbnail,
|
|
117
124
|
children: _jsx(Img, {
|
|
118
125
|
src: thumbnail,
|
|
119
126
|
constrain: "cover",
|
|
@@ -123,34 +130,34 @@ let TreeButton = (_dec = withStyle(generateStyles, generateComponentTheme), _dec
|
|
|
123
130
|
}
|
|
124
131
|
if (itemIcon) {
|
|
125
132
|
return _jsx("div", {
|
|
126
|
-
css: styles
|
|
133
|
+
css: styles?.icon,
|
|
127
134
|
children: callRenderProp(itemIcon)
|
|
128
135
|
});
|
|
129
136
|
}
|
|
130
|
-
return
|
|
137
|
+
return undefined;
|
|
131
138
|
}
|
|
139
|
+
handleRef = el => {
|
|
140
|
+
if (el && typeof this.props.containerRef === 'function') {
|
|
141
|
+
this.props.containerRef(el.parentElement);
|
|
142
|
+
}
|
|
143
|
+
this.ref = el;
|
|
144
|
+
};
|
|
132
145
|
render() {
|
|
133
|
-
const
|
|
134
|
-
styles
|
|
135
|
-
renderContent
|
|
146
|
+
const {
|
|
147
|
+
styles,
|
|
148
|
+
renderContent
|
|
149
|
+
} = this.props;
|
|
136
150
|
const buttonContent = renderContent ? renderContent(this.props) : this.defaultContentRenderer(this.props);
|
|
137
151
|
// VoiceOver can't navigate without the buttons, even though they don't do anything
|
|
138
152
|
return _jsx("button", {
|
|
139
153
|
ref: this.handleRef,
|
|
140
154
|
tabIndex: -1,
|
|
141
155
|
type: "button",
|
|
142
|
-
css: styles
|
|
156
|
+
css: styles?.treeButton,
|
|
143
157
|
"data-cid": "TreeButton",
|
|
144
158
|
children: buttonContent
|
|
145
159
|
});
|
|
146
160
|
}
|
|
147
|
-
}
|
|
148
|
-
type: 'treeButton',
|
|
149
|
-
size: 'medium',
|
|
150
|
-
variant: 'folderTree',
|
|
151
|
-
selected: false,
|
|
152
|
-
focused: false,
|
|
153
|
-
expanded: false
|
|
154
|
-
}, _TreeButton)) || _class);
|
|
161
|
+
}) || _class);
|
|
155
162
|
export default TreeButton;
|
|
156
163
|
export { TreeButton };
|
|
@@ -45,11 +45,13 @@ 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, state) => {
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
const {
|
|
49
|
+
size,
|
|
50
|
+
variant,
|
|
51
|
+
selected,
|
|
52
|
+
focused,
|
|
53
|
+
level
|
|
54
|
+
} = props;
|
|
53
55
|
const isRootButton = level && level === 1;
|
|
54
56
|
const sizeMap = {
|
|
55
57
|
small: {
|
|
@@ -28,12 +28,13 @@
|
|
|
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
|
|
34
|
-
typography
|
|
35
|
-
themeName
|
|
36
|
-
spacing
|
|
31
|
+
const {
|
|
32
|
+
colors,
|
|
33
|
+
borders,
|
|
34
|
+
typography,
|
|
35
|
+
key: themeName,
|
|
36
|
+
spacing
|
|
37
|
+
} = theme;
|
|
37
38
|
const themeSpecificStyles = {
|
|
38
39
|
canvas: {
|
|
39
40
|
iconColor: theme['ic-brand-font-color-dark'],
|
|
@@ -44,32 +45,32 @@ const generateComponentTheme = theme => {
|
|
|
44
45
|
}
|
|
45
46
|
};
|
|
46
47
|
const componentVariables = {
|
|
47
|
-
hoverBackgroundColor: colors
|
|
48
|
-
hoverTextColor: colors
|
|
49
|
-
focusOutlineWidth: borders
|
|
50
|
-
focusOutlineColor: colors
|
|
51
|
-
focusOutlineStyle: borders
|
|
52
|
-
iconColor: colors
|
|
53
|
-
iconsMarginRight: spacing
|
|
54
|
-
descriptorMarginTop: spacing
|
|
55
|
-
descriptorTextColor: colors
|
|
56
|
-
descriptorFontSizeSmall: typography
|
|
57
|
-
descriptorFontSizeMedium: typography
|
|
58
|
-
descriptorFontSizeLarge: typography
|
|
59
|
-
nameTextColor: colors
|
|
60
|
-
nameFontSizeSmall: typography
|
|
61
|
-
nameFontSizeMedium: typography
|
|
62
|
-
nameFontSizeLarge: typography
|
|
63
|
-
baseSpacingSmall: spacing
|
|
64
|
-
baseSpacingMedium: spacing
|
|
48
|
+
hoverBackgroundColor: colors?.contrasts?.blue4570,
|
|
49
|
+
hoverTextColor: colors?.contrasts?.white1010,
|
|
50
|
+
focusOutlineWidth: borders?.widthMedium,
|
|
51
|
+
focusOutlineColor: colors?.contrasts?.blue4570,
|
|
52
|
+
focusOutlineStyle: borders?.style,
|
|
53
|
+
iconColor: colors?.contrasts?.grey125125,
|
|
54
|
+
iconsMarginRight: spacing?.xSmall,
|
|
55
|
+
descriptorMarginTop: spacing?.xxxSmall,
|
|
56
|
+
descriptorTextColor: colors?.contrasts?.grey125125,
|
|
57
|
+
descriptorFontSizeSmall: typography?.fontSizeXSmall,
|
|
58
|
+
descriptorFontSizeMedium: typography?.fontSizeXSmall,
|
|
59
|
+
descriptorFontSizeLarge: typography?.fontSizeSmall,
|
|
60
|
+
nameTextColor: colors?.contrasts?.blue4570,
|
|
61
|
+
nameFontSizeSmall: typography?.fontSizeXSmall,
|
|
62
|
+
nameFontSizeMedium: typography?.fontSizeSmall,
|
|
63
|
+
nameFontSizeLarge: typography?.fontSizeMedium,
|
|
64
|
+
baseSpacingSmall: spacing?.xSmall,
|
|
65
|
+
baseSpacingMedium: spacing?.small,
|
|
65
66
|
baseSpacingLarge: '1rem',
|
|
66
|
-
borderWidth: borders
|
|
67
|
-
borderRadius: borders
|
|
68
|
-
borderColor: colors
|
|
69
|
-
textLineHeight: typography
|
|
70
|
-
selectedTextColor: colors
|
|
71
|
-
selectedBackgroundColor: colors
|
|
72
|
-
selectedOutlineWidth: borders
|
|
67
|
+
borderWidth: borders?.widthSmall,
|
|
68
|
+
borderRadius: borders?.radiusMedium,
|
|
69
|
+
borderColor: colors?.contrasts?.grey4570,
|
|
70
|
+
textLineHeight: typography?.lineHeightCondensed,
|
|
71
|
+
selectedTextColor: colors?.contrasts?.white1010,
|
|
72
|
+
selectedBackgroundColor: colors?.contrasts?.grey4570,
|
|
73
|
+
selectedOutlineWidth: borders?.widthLarge
|
|
73
74
|
};
|
|
74
75
|
return {
|
|
75
76
|
...componentVariables,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _dec, _class
|
|
1
|
+
var _dec, _class;
|
|
2
2
|
/*
|
|
3
3
|
* The MIT License (MIT)
|
|
4
4
|
*
|
|
@@ -39,72 +39,88 @@ parent: TreeBrowser
|
|
|
39
39
|
id: TreeBrowser.Collection
|
|
40
40
|
---
|
|
41
41
|
**/
|
|
42
|
-
let TreeCollection = (_dec = withStyle(generateStyles, generateComponentTheme), _dec(_class =
|
|
42
|
+
let TreeCollection = (_dec = withStyle(generateStyles, generateComponentTheme), _dec(_class = class TreeCollection extends Component {
|
|
43
|
+
static displayName = "TreeCollection";
|
|
44
|
+
static componentId = 'TreeBrowser.Collection';
|
|
45
|
+
static allowedProps = allowedProps;
|
|
46
|
+
static contextType = TreeBrowserContext;
|
|
47
|
+
static defaultProps = {
|
|
48
|
+
collections: [],
|
|
49
|
+
items: [],
|
|
50
|
+
expanded: false,
|
|
51
|
+
selection: '',
|
|
52
|
+
size: 'medium',
|
|
53
|
+
variant: 'folderTree',
|
|
54
|
+
getItemProps: props => props,
|
|
55
|
+
getCollectionProps: props => props,
|
|
56
|
+
isCollectionFlattened: false
|
|
57
|
+
};
|
|
58
|
+
ref = null;
|
|
43
59
|
constructor(props) {
|
|
44
60
|
super(props);
|
|
45
|
-
this.ref = null;
|
|
46
|
-
this.handleFocus = (e, item) => {
|
|
47
|
-
e.stopPropagation();
|
|
48
|
-
this.setState({
|
|
49
|
-
focused: `${item.type}_${item.id}`
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
this.handleBlur = (e, _item) => {
|
|
53
|
-
e.stopPropagation();
|
|
54
|
-
this.setState({
|
|
55
|
-
focused: ''
|
|
56
|
-
});
|
|
57
|
-
};
|
|
58
|
-
this.handleCollectionClick = e => {
|
|
59
|
-
const _this$props = this.props,
|
|
60
|
-
id = _this$props.id,
|
|
61
|
-
onCollectionClick = _this$props.onCollectionClick,
|
|
62
|
-
expanded = _this$props.expanded;
|
|
63
|
-
const collection = {
|
|
64
|
-
id,
|
|
65
|
-
expanded: !expanded,
|
|
66
|
-
type: 'collection'
|
|
67
|
-
};
|
|
68
|
-
if (onCollectionClick && typeof onCollectionClick === 'function') {
|
|
69
|
-
onCollectionClick(e, collection);
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
this.handleCollectionKeyDown = e => {
|
|
73
|
-
const _this$props2 = this.props,
|
|
74
|
-
id = _this$props2.id,
|
|
75
|
-
onKeyDown = _this$props2.onKeyDown,
|
|
76
|
-
expanded = _this$props2.expanded;
|
|
77
|
-
const collection = {
|
|
78
|
-
id,
|
|
79
|
-
expanded: !expanded,
|
|
80
|
-
type: 'collection'
|
|
81
|
-
};
|
|
82
|
-
if (onKeyDown && typeof onKeyDown === 'function') {
|
|
83
|
-
onKeyDown(e, collection);
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
61
|
this.state = {
|
|
87
62
|
focused: ''
|
|
88
63
|
};
|
|
89
64
|
}
|
|
90
65
|
componentDidMount() {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
animation: (_this$context = this.context) === null || _this$context === void 0 ? void 0 : _this$context.animation
|
|
66
|
+
this.props.makeStyles?.({
|
|
67
|
+
animation: this.context?.animation
|
|
94
68
|
});
|
|
95
69
|
}
|
|
96
70
|
componentDidUpdate() {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
animation: (_this$context2 = this.context) === null || _this$context2 === void 0 ? void 0 : _this$context2.animation
|
|
71
|
+
this.props.makeStyles?.({
|
|
72
|
+
animation: this.context?.animation
|
|
100
73
|
});
|
|
101
74
|
}
|
|
102
75
|
get itemsLevel() {
|
|
103
|
-
const
|
|
104
|
-
level
|
|
105
|
-
isCollectionFlattened
|
|
76
|
+
const {
|
|
77
|
+
level,
|
|
78
|
+
isCollectionFlattened
|
|
79
|
+
} = this.props;
|
|
106
80
|
return isCollectionFlattened ? level : level + 1;
|
|
107
81
|
}
|
|
82
|
+
handleFocus = (e, item) => {
|
|
83
|
+
e.stopPropagation();
|
|
84
|
+
this.setState({
|
|
85
|
+
focused: `${item.type}_${item.id}`
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
handleBlur = (e, _item) => {
|
|
89
|
+
e.stopPropagation();
|
|
90
|
+
this.setState({
|
|
91
|
+
focused: ''
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
handleCollectionClick = e => {
|
|
95
|
+
const {
|
|
96
|
+
id,
|
|
97
|
+
onCollectionClick,
|
|
98
|
+
expanded
|
|
99
|
+
} = this.props;
|
|
100
|
+
const collection = {
|
|
101
|
+
id,
|
|
102
|
+
expanded: !expanded,
|
|
103
|
+
type: 'collection'
|
|
104
|
+
};
|
|
105
|
+
if (onCollectionClick && typeof onCollectionClick === 'function') {
|
|
106
|
+
onCollectionClick(e, collection);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
handleCollectionKeyDown = e => {
|
|
110
|
+
const {
|
|
111
|
+
id,
|
|
112
|
+
onKeyDown,
|
|
113
|
+
expanded
|
|
114
|
+
} = this.props;
|
|
115
|
+
const collection = {
|
|
116
|
+
id,
|
|
117
|
+
expanded: !expanded,
|
|
118
|
+
type: 'collection'
|
|
119
|
+
};
|
|
120
|
+
if (onKeyDown && typeof onKeyDown === 'function') {
|
|
121
|
+
onKeyDown(e, collection);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
108
124
|
get collectionsCount() {
|
|
109
125
|
const collections = this.props.collections;
|
|
110
126
|
return collections && collections.length > 0 ? collections.length : 0;
|
|
@@ -117,10 +133,11 @@ let TreeCollection = (_dec = withStyle(generateStyles, generateComponentTheme),
|
|
|
117
133
|
return this.collectionsCount + this.itemsCount + (this.props.renderBeforeItems ? 1 : 0) + (this.props.renderAfterItems ? 1 : 0);
|
|
118
134
|
}
|
|
119
135
|
sortChildren() {
|
|
120
|
-
const
|
|
121
|
-
collections
|
|
122
|
-
items
|
|
123
|
-
compareFunc
|
|
136
|
+
const {
|
|
137
|
+
collections,
|
|
138
|
+
items,
|
|
139
|
+
compareFunc
|
|
140
|
+
} = this.props;
|
|
124
141
|
if (!compareFunc) return [];
|
|
125
142
|
const collections_ = collections ? collections.map(collection => {
|
|
126
143
|
return {
|
|
@@ -139,13 +156,14 @@ let TreeCollection = (_dec = withStyle(generateStyles, generateComponentTheme),
|
|
|
139
156
|
return renderQueue;
|
|
140
157
|
}
|
|
141
158
|
renderChildren() {
|
|
142
|
-
const
|
|
143
|
-
collections
|
|
144
|
-
items
|
|
145
|
-
id
|
|
146
|
-
renderBeforeItems
|
|
147
|
-
renderAfterItems
|
|
148
|
-
compareFunc
|
|
159
|
+
const {
|
|
160
|
+
collections,
|
|
161
|
+
items,
|
|
162
|
+
id,
|
|
163
|
+
renderBeforeItems,
|
|
164
|
+
renderAfterItems,
|
|
165
|
+
compareFunc
|
|
166
|
+
} = this.props;
|
|
149
167
|
let position = 1;
|
|
150
168
|
const sortedChildren = this.sortChildren();
|
|
151
169
|
return _jsxs(_Fragment, {
|
|
@@ -163,11 +181,12 @@ let TreeCollection = (_dec = withStyle(generateStyles, generateComponentTheme),
|
|
|
163
181
|
});
|
|
164
182
|
}
|
|
165
183
|
renderCollectionChildren(collectionId, child, position, keyword) {
|
|
166
|
-
const
|
|
167
|
-
selection
|
|
168
|
-
onKeyDown
|
|
169
|
-
getItemProps
|
|
170
|
-
styles
|
|
184
|
+
const {
|
|
185
|
+
selection,
|
|
186
|
+
onKeyDown,
|
|
187
|
+
getItemProps,
|
|
188
|
+
styles
|
|
189
|
+
} = this.props;
|
|
171
190
|
const key = `${collectionId}_${keyword}`;
|
|
172
191
|
const ariaSelected = {};
|
|
173
192
|
if (selection) {
|
|
@@ -187,7 +206,7 @@ let TreeCollection = (_dec = withStyle(generateStyles, generateComponentTheme),
|
|
|
187
206
|
id: key
|
|
188
207
|
/* eslint-disable-next-line jsx-a11y/role-has-required-aria-props */,
|
|
189
208
|
role: "treeitem",
|
|
190
|
-
css: styles
|
|
209
|
+
css: styles?.item,
|
|
191
210
|
tabIndex: -1,
|
|
192
211
|
"aria-posinset": position,
|
|
193
212
|
"aria-setsize": this.childCount,
|
|
@@ -205,7 +224,7 @@ let TreeCollection = (_dec = withStyle(generateStyles, generateComponentTheme),
|
|
|
205
224
|
if (typeof child.props.onKeyDown === 'function') {
|
|
206
225
|
child.props.onKeyDown(e);
|
|
207
226
|
} else {
|
|
208
|
-
onKeyDown
|
|
227
|
+
onKeyDown?.(e, itemHash);
|
|
209
228
|
}
|
|
210
229
|
},
|
|
211
230
|
onBlur: e => this.handleBlur(e, itemHash),
|
|
@@ -234,12 +253,13 @@ let TreeCollection = (_dec = withStyle(generateStyles, generateComponentTheme),
|
|
|
234
253
|
});
|
|
235
254
|
}
|
|
236
255
|
renderItemNode(item, position) {
|
|
237
|
-
const
|
|
238
|
-
selection
|
|
239
|
-
onItemClick
|
|
240
|
-
onKeyDown
|
|
241
|
-
getItemProps
|
|
242
|
-
styles
|
|
256
|
+
const {
|
|
257
|
+
selection,
|
|
258
|
+
onItemClick,
|
|
259
|
+
onKeyDown,
|
|
260
|
+
getItemProps,
|
|
261
|
+
styles
|
|
262
|
+
} = this.props;
|
|
243
263
|
const ariaSelected = {};
|
|
244
264
|
if (selection) {
|
|
245
265
|
ariaSelected['aria-selected'] = selection === `item_${item.id}`;
|
|
@@ -263,12 +283,12 @@ let TreeCollection = (_dec = withStyle(generateStyles, generateComponentTheme),
|
|
|
263
283
|
/* eslint-disable-next-line jsx-a11y/role-has-required-aria-props */,
|
|
264
284
|
role: "treeitem",
|
|
265
285
|
"aria-label": item.name,
|
|
266
|
-
css: styles
|
|
286
|
+
css: styles?.item,
|
|
267
287
|
"aria-level": this.itemsLevel,
|
|
268
288
|
"aria-posinset": position,
|
|
269
289
|
"aria-setsize": this.childCount,
|
|
270
|
-
onClick: e => onItemClick
|
|
271
|
-
onKeyDown: e => onKeyDown
|
|
290
|
+
onClick: e => onItemClick?.(e, itemHash),
|
|
291
|
+
onKeyDown: e => onKeyDown?.(e, itemHash),
|
|
272
292
|
onFocus: e => this.handleFocus(e, itemHash),
|
|
273
293
|
onBlur: e => this.handleBlur(e, itemHash),
|
|
274
294
|
...ariaSelected,
|
|
@@ -290,17 +310,18 @@ let TreeCollection = (_dec = withStyle(generateStyles, generateComponentTheme),
|
|
|
290
310
|
};
|
|
291
311
|
}
|
|
292
312
|
render() {
|
|
293
|
-
const
|
|
294
|
-
id
|
|
295
|
-
name
|
|
296
|
-
expanded
|
|
297
|
-
collectionIcon
|
|
298
|
-
collectionIconExpanded
|
|
299
|
-
isCollectionFlattened
|
|
300
|
-
getCollectionProps
|
|
301
|
-
level
|
|
302
|
-
position
|
|
303
|
-
styles
|
|
313
|
+
const {
|
|
314
|
+
id,
|
|
315
|
+
name,
|
|
316
|
+
expanded,
|
|
317
|
+
collectionIcon,
|
|
318
|
+
collectionIconExpanded,
|
|
319
|
+
isCollectionFlattened,
|
|
320
|
+
getCollectionProps,
|
|
321
|
+
level,
|
|
322
|
+
position,
|
|
323
|
+
styles
|
|
324
|
+
} = this.props;
|
|
304
325
|
const collectionProps = getCollectionProps({
|
|
305
326
|
...this.getCommonButtonProps(),
|
|
306
327
|
expanded: expanded,
|
|
@@ -313,14 +334,14 @@ let TreeCollection = (_dec = withStyle(generateStyles, generateComponentTheme),
|
|
|
313
334
|
level
|
|
314
335
|
});
|
|
315
336
|
const ariaSelected = {
|
|
316
|
-
'aria-selected':
|
|
337
|
+
'aria-selected': undefined
|
|
317
338
|
};
|
|
318
339
|
if (this.props.selection) ariaSelected['aria-selected'] = this.props.selection === `collection_${id}`;
|
|
319
340
|
return isCollectionFlattened ? this.renderChildren() : _jsxs("li", {
|
|
320
341
|
ref: el => {
|
|
321
342
|
this.ref = el;
|
|
322
343
|
},
|
|
323
|
-
css: styles
|
|
344
|
+
css: styles?.treeCollection,
|
|
324
345
|
tabIndex: -1
|
|
325
346
|
/* eslint-disable-next-line jsx-a11y/role-has-required-aria-props */,
|
|
326
347
|
role: "treeitem",
|
|
@@ -345,22 +366,12 @@ let TreeCollection = (_dec = withStyle(generateStyles, generateComponentTheme),
|
|
|
345
366
|
...collectionProps
|
|
346
367
|
}), expanded && this.childCount > 0 && _jsx("ul", {
|
|
347
368
|
"aria-label": name,
|
|
348
|
-
css: styles
|
|
369
|
+
css: styles?.list,
|
|
349
370
|
role: "group",
|
|
350
371
|
children: this.renderChildren()
|
|
351
372
|
})]
|
|
352
373
|
});
|
|
353
374
|
}
|
|
354
|
-
}
|
|
355
|
-
collections: [],
|
|
356
|
-
items: [],
|
|
357
|
-
expanded: false,
|
|
358
|
-
selection: '',
|
|
359
|
-
size: 'medium',
|
|
360
|
-
variant: 'folderTree',
|
|
361
|
-
getItemProps: props => props,
|
|
362
|
-
getCollectionProps: props => props,
|
|
363
|
-
isCollectionFlattened: false
|
|
364
|
-
}, _TreeCollection)) || _class);
|
|
375
|
+
}) || _class);
|
|
365
376
|
export default TreeCollection;
|
|
366
377
|
export { TreeCollection };
|
|
@@ -28,18 +28,19 @@
|
|
|
28
28
|
* @return {Object} The final theme object with the overrides and component variables
|
|
29
29
|
*/
|
|
30
30
|
const generateComponentTheme = theme => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
spacing
|
|
34
|
-
typography
|
|
35
|
-
borders
|
|
31
|
+
const {
|
|
32
|
+
colors,
|
|
33
|
+
spacing,
|
|
34
|
+
typography,
|
|
35
|
+
borders
|
|
36
|
+
} = theme;
|
|
36
37
|
const componentVariables = {
|
|
37
|
-
fontFamily: typography
|
|
38
|
-
baseSpacingSmall: spacing
|
|
39
|
-
baseSpacingMedium: spacing
|
|
38
|
+
fontFamily: typography?.fontFamily,
|
|
39
|
+
baseSpacingSmall: spacing?.xSmall,
|
|
40
|
+
baseSpacingMedium: spacing?.small,
|
|
40
41
|
baseSpacingLarge: '1rem',
|
|
41
|
-
borderWidth: borders
|
|
42
|
-
borderColor: colors
|
|
42
|
+
borderWidth: borders?.widthSmall,
|
|
43
|
+
borderColor: colors?.contrasts?.grey4570
|
|
43
44
|
};
|
|
44
45
|
return {
|
|
45
46
|
...componentVariables
|