@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.
Files changed (33) hide show
  1. package/CHANGELOG.md +5 -2
  2. package/es/TreeBrowser/v1/TreeButton/index.js +56 -49
  3. package/es/TreeBrowser/v1/TreeButton/styles.js +7 -5
  4. package/es/TreeBrowser/v1/TreeButton/theme.js +32 -31
  5. package/es/TreeBrowser/v1/TreeCollection/index.js +115 -104
  6. package/es/TreeBrowser/v1/TreeCollection/styles.js +4 -2
  7. package/es/TreeBrowser/v1/TreeCollection/theme.js +11 -10
  8. package/es/TreeBrowser/v1/TreeNode/index.js +39 -37
  9. package/es/TreeBrowser/v1/index.js +94 -82
  10. package/es/TreeBrowser/v1/theme.js +8 -7
  11. package/es/TreeBrowser/v2/TreeButton/index.js +82 -71
  12. package/es/TreeBrowser/v2/TreeButton/styles.js +10 -8
  13. package/es/TreeBrowser/v2/TreeCollection/index.js +115 -104
  14. package/es/TreeBrowser/v2/TreeCollection/styles.js +4 -2
  15. package/es/TreeBrowser/v2/TreeNode/index.js +64 -58
  16. package/es/TreeBrowser/v2/index.js +112 -99
  17. package/lib/TreeBrowser/v1/TreeButton/index.js +56 -49
  18. package/lib/TreeBrowser/v1/TreeButton/styles.js +7 -5
  19. package/lib/TreeBrowser/v1/TreeButton/theme.js +32 -31
  20. package/lib/TreeBrowser/v1/TreeCollection/index.js +115 -104
  21. package/lib/TreeBrowser/v1/TreeCollection/styles.js +4 -2
  22. package/lib/TreeBrowser/v1/TreeCollection/theme.js +11 -10
  23. package/lib/TreeBrowser/v1/TreeNode/index.js +39 -37
  24. package/lib/TreeBrowser/v1/index.js +94 -82
  25. package/lib/TreeBrowser/v1/theme.js +8 -7
  26. package/lib/TreeBrowser/v2/TreeButton/index.js +82 -71
  27. package/lib/TreeBrowser/v2/TreeButton/styles.js +10 -8
  28. package/lib/TreeBrowser/v2/TreeCollection/index.js +115 -104
  29. package/lib/TreeBrowser/v2/TreeCollection/styles.js +4 -2
  30. package/lib/TreeBrowser/v2/TreeNode/index.js +64 -58
  31. package/lib/TreeBrowser/v2/index.js +112 -99
  32. package/package.json +12 -12
  33. 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-7](https://github.com/instructure/instructure-ui/compare/v11.7.2...v11.7.3-snapshot-7) (2026-04-29)
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
- **Note:** Version bump only for package @instructure/ui-tree-browser
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, _TreeButton;
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 = (_TreeButton = class TreeButton extends Component {
42
- constructor(...args) {
43
- super(...args);
44
- this.ref = null;
45
- this.handleRef = el => {
46
- if (el && typeof this.props.containerRef === 'function') {
47
- this.props.containerRef(el.parentElement);
48
- }
49
- this.ref = el;
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
- var _this$props$makeStyle, _this$props, _this$context;
54
- (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props, {
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
- var _this$props$makeStyle2, _this$props2, _this$context2;
60
- (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2, {
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 name = props.name,
66
- descriptor = props.descriptor,
67
- styles = props.styles;
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 type = this.props.type;
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 void 0;
98
+ return undefined;
94
99
  }
95
100
  renderCollectionIcon() {
96
- const _this$props3 = this.props,
97
- expanded = _this$props3.expanded,
98
- collectionIcon = _this$props3.collectionIcon,
99
- collectionIconExpanded = _this$props3.collectionIconExpanded,
100
- styles = _this$props3.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 === null || styles === void 0 ? void 0 : styles.icon,
109
+ css: styles?.icon,
104
110
  children: callRenderProp(expanded ? collectionIconExpanded : collectionIcon)
105
111
  });
106
112
  }
107
- return void 0;
113
+ return undefined;
108
114
  }
109
115
  renderItemImage() {
110
- const _this$props4 = this.props,
111
- thumbnail = _this$props4.thumbnail,
112
- itemIcon = _this$props4.itemIcon,
113
- styles = _this$props4.styles;
116
+ const {
117
+ thumbnail,
118
+ itemIcon,
119
+ styles
120
+ } = this.props;
114
121
  if (thumbnail) {
115
122
  return _jsx("div", {
116
- css: styles === null || styles === void 0 ? void 0 : styles.thumbnail,
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 === null || styles === void 0 ? void 0 : styles.icon,
133
+ css: styles?.icon,
127
134
  children: callRenderProp(itemIcon)
128
135
  });
129
136
  }
130
- return void 0;
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 _this$props5 = this.props,
134
- styles = _this$props5.styles,
135
- renderContent = _this$props5.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 === null || styles === void 0 ? void 0 : styles.treeButton,
156
+ css: styles?.treeButton,
143
157
  "data-cid": "TreeButton",
144
158
  children: buttonContent
145
159
  });
146
160
  }
147
- }, _TreeButton.displayName = "TreeButton", _TreeButton.componentId = 'TreeBrowser.Button', _TreeButton.allowedProps = allowedProps, _TreeButton.contextType = TreeBrowserContext, _TreeButton.defaultProps = {
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 size = props.size,
49
- variant = props.variant,
50
- selected = props.selected,
51
- focused = props.focused,
52
- level = props.level;
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
- var _colors$contrasts, _colors$contrasts2, _colors$contrasts3, _colors$contrasts4, _colors$contrasts5, _colors$contrasts6, _colors$contrasts7, _colors$contrasts8, _colors$contrasts9;
32
- const colors = theme.colors,
33
- borders = theme.borders,
34
- typography = theme.typography,
35
- themeName = theme.key,
36
- spacing = theme.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 === null || colors === void 0 ? void 0 : (_colors$contrasts = colors.contrasts) === null || _colors$contrasts === void 0 ? void 0 : _colors$contrasts.blue4570,
48
- hoverTextColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts2 = colors.contrasts) === null || _colors$contrasts2 === void 0 ? void 0 : _colors$contrasts2.white1010,
49
- focusOutlineWidth: borders === null || borders === void 0 ? void 0 : borders.widthMedium,
50
- focusOutlineColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts3 = colors.contrasts) === null || _colors$contrasts3 === void 0 ? void 0 : _colors$contrasts3.blue4570,
51
- focusOutlineStyle: borders === null || borders === void 0 ? void 0 : borders.style,
52
- iconColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts4 = colors.contrasts) === null || _colors$contrasts4 === void 0 ? void 0 : _colors$contrasts4.grey125125,
53
- iconsMarginRight: spacing === null || spacing === void 0 ? void 0 : spacing.xSmall,
54
- descriptorMarginTop: spacing === null || spacing === void 0 ? void 0 : spacing.xxxSmall,
55
- descriptorTextColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts5 = colors.contrasts) === null || _colors$contrasts5 === void 0 ? void 0 : _colors$contrasts5.grey125125,
56
- descriptorFontSizeSmall: typography === null || typography === void 0 ? void 0 : typography.fontSizeXSmall,
57
- descriptorFontSizeMedium: typography === null || typography === void 0 ? void 0 : typography.fontSizeXSmall,
58
- descriptorFontSizeLarge: typography === null || typography === void 0 ? void 0 : typography.fontSizeSmall,
59
- nameTextColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts6 = colors.contrasts) === null || _colors$contrasts6 === void 0 ? void 0 : _colors$contrasts6.blue4570,
60
- nameFontSizeSmall: typography === null || typography === void 0 ? void 0 : typography.fontSizeXSmall,
61
- nameFontSizeMedium: typography === null || typography === void 0 ? void 0 : typography.fontSizeSmall,
62
- nameFontSizeLarge: typography === null || typography === void 0 ? void 0 : typography.fontSizeMedium,
63
- baseSpacingSmall: spacing === null || spacing === void 0 ? void 0 : spacing.xSmall,
64
- baseSpacingMedium: spacing === null || spacing === void 0 ? void 0 : spacing.small,
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 === null || borders === void 0 ? void 0 : borders.widthSmall,
67
- borderRadius: borders === null || borders === void 0 ? void 0 : borders.radiusMedium,
68
- borderColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts7 = colors.contrasts) === null || _colors$contrasts7 === void 0 ? void 0 : _colors$contrasts7.grey4570,
69
- textLineHeight: typography === null || typography === void 0 ? void 0 : typography.lineHeightCondensed,
70
- selectedTextColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts8 = colors.contrasts) === null || _colors$contrasts8 === void 0 ? void 0 : _colors$contrasts8.white1010,
71
- selectedBackgroundColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts9 = colors.contrasts) === null || _colors$contrasts9 === void 0 ? void 0 : _colors$contrasts9.grey4570,
72
- selectedOutlineWidth: borders === null || borders === void 0 ? void 0 : borders.widthLarge
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, _TreeCollection;
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 = (_TreeCollection = class TreeCollection extends Component {
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
- var _this$props$makeStyle, _this$props3, _this$context;
92
- (_this$props$makeStyle = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props3, {
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
- var _this$props$makeStyle2, _this$props4, _this$context2;
98
- (_this$props$makeStyle2 = (_this$props4 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props4, {
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 _this$props5 = this.props,
104
- level = _this$props5.level,
105
- isCollectionFlattened = _this$props5.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 _this$props6 = this.props,
121
- collections = _this$props6.collections,
122
- items = _this$props6.items,
123
- compareFunc = _this$props6.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 _this$props7 = this.props,
143
- collections = _this$props7.collections,
144
- items = _this$props7.items,
145
- id = _this$props7.id,
146
- renderBeforeItems = _this$props7.renderBeforeItems,
147
- renderAfterItems = _this$props7.renderAfterItems,
148
- compareFunc = _this$props7.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 _this$props8 = this.props,
167
- selection = _this$props8.selection,
168
- onKeyDown = _this$props8.onKeyDown,
169
- getItemProps = _this$props8.getItemProps,
170
- styles = _this$props8.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 === null || styles === void 0 ? void 0 : styles.item,
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 === null || onKeyDown === void 0 ? void 0 : onKeyDown(e, itemHash);
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 _this$props9 = this.props,
238
- selection = _this$props9.selection,
239
- onItemClick = _this$props9.onItemClick,
240
- onKeyDown = _this$props9.onKeyDown,
241
- getItemProps = _this$props9.getItemProps,
242
- styles = _this$props9.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 === null || styles === void 0 ? void 0 : styles.item,
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 === null || onItemClick === void 0 ? void 0 : onItemClick(e, itemHash),
271
- onKeyDown: e => onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(e, itemHash),
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 _this$props0 = this.props,
294
- id = _this$props0.id,
295
- name = _this$props0.name,
296
- expanded = _this$props0.expanded,
297
- collectionIcon = _this$props0.collectionIcon,
298
- collectionIconExpanded = _this$props0.collectionIconExpanded,
299
- isCollectionFlattened = _this$props0.isCollectionFlattened,
300
- getCollectionProps = _this$props0.getCollectionProps,
301
- level = _this$props0.level,
302
- position = _this$props0.position,
303
- styles = _this$props0.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': void 0
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 === null || styles === void 0 ? void 0 : styles.treeCollection,
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 === null || styles === void 0 ? void 0 : styles.list,
369
+ css: styles?.list,
349
370
  role: "group",
350
371
  children: this.renderChildren()
351
372
  })]
352
373
  });
353
374
  }
354
- }, _TreeCollection.displayName = "TreeCollection", _TreeCollection.componentId = 'TreeBrowser.Collection', _TreeCollection.allowedProps = allowedProps, _TreeCollection.contextType = TreeBrowserContext, _TreeCollection.defaultProps = {
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 };
@@ -40,8 +40,10 @@ const list = keyframes`
40
40
  */
41
41
 
42
42
  const generateStyles = (componentTheme, props, state) => {
43
- const size = props.size,
44
- variant = props.variant;
43
+ const {
44
+ size,
45
+ variant
46
+ } = props;
45
47
  const sizeMap = {
46
48
  small: {
47
49
  indent: {
@@ -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
- var _colors$contrasts;
32
- const colors = theme.colors,
33
- spacing = theme.spacing,
34
- typography = theme.typography,
35
- borders = theme.borders;
31
+ const {
32
+ colors,
33
+ spacing,
34
+ typography,
35
+ borders
36
+ } = theme;
36
37
  const componentVariables = {
37
- fontFamily: typography === null || typography === void 0 ? void 0 : typography.fontFamily,
38
- baseSpacingSmall: spacing === null || spacing === void 0 ? void 0 : spacing.xSmall,
39
- baseSpacingMedium: spacing === null || spacing === void 0 ? void 0 : spacing.small,
38
+ fontFamily: typography?.fontFamily,
39
+ baseSpacingSmall: spacing?.xSmall,
40
+ baseSpacingMedium: spacing?.small,
40
41
  baseSpacingLarge: '1rem',
41
- borderWidth: borders === null || borders === void 0 ? void 0 : borders.widthSmall,
42
- borderColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts = colors.contrasts) === null || _colors$contrasts === void 0 ? void 0 : _colors$contrasts.grey4570
42
+ borderWidth: borders?.widthSmall,
43
+ borderColor: colors?.contrasts?.grey4570
43
44
  };
44
45
  return {
45
46
  ...componentVariables