@instructure/ui-tree-browser 10.25.1-snapshot-4 → 10.25.1-snapshot-6

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 (43) hide show
  1. package/CHANGELOG.md +5 -2
  2. package/es/TreeBrowser/TreeBrowserContext.js +39 -0
  3. package/es/TreeBrowser/TreeButton/index.js +10 -5
  4. package/es/TreeBrowser/TreeButton/styles.js +12 -9
  5. package/es/TreeBrowser/TreeCollection/index.js +10 -5
  6. package/es/TreeBrowser/TreeCollection/styles.js +9 -7
  7. package/es/TreeBrowser/TreeNode/index.js +10 -5
  8. package/es/TreeBrowser/index.js +17 -10
  9. package/es/TreeBrowser/props.js +3 -2
  10. package/lib/TreeBrowser/TreeBrowserContext.js +44 -0
  11. package/lib/TreeBrowser/TreeButton/index.js +10 -5
  12. package/lib/TreeBrowser/TreeButton/styles.js +12 -9
  13. package/lib/TreeBrowser/TreeCollection/index.js +10 -5
  14. package/lib/TreeBrowser/TreeCollection/styles.js +9 -7
  15. package/lib/TreeBrowser/TreeNode/index.js +10 -5
  16. package/lib/TreeBrowser/index.js +17 -10
  17. package/lib/TreeBrowser/props.js +3 -2
  18. package/package.json +13 -13
  19. package/src/TreeBrowser/TreeBrowserContext.ts +49 -0
  20. package/src/TreeBrowser/TreeButton/index.tsx +7 -3
  21. package/src/TreeBrowser/TreeButton/styles.ts +19 -12
  22. package/src/TreeBrowser/TreeCollection/index.tsx +7 -3
  23. package/src/TreeBrowser/TreeCollection/styles.ts +12 -7
  24. package/src/TreeBrowser/TreeNode/index.tsx +7 -3
  25. package/src/TreeBrowser/index.tsx +19 -11
  26. package/src/TreeBrowser/props.ts +8 -2
  27. package/tsconfig.build.tsbuildinfo +1 -1
  28. package/types/TreeBrowser/TreeBrowserContext.d.ts +20 -0
  29. package/types/TreeBrowser/TreeBrowserContext.d.ts.map +1 -0
  30. package/types/TreeBrowser/TreeButton/index.d.ts +4 -1
  31. package/types/TreeBrowser/TreeButton/index.d.ts.map +1 -1
  32. package/types/TreeBrowser/TreeButton/styles.d.ts +4 -1
  33. package/types/TreeBrowser/TreeButton/styles.d.ts.map +1 -1
  34. package/types/TreeBrowser/TreeCollection/index.d.ts +4 -1
  35. package/types/TreeBrowser/TreeCollection/index.d.ts.map +1 -1
  36. package/types/TreeBrowser/TreeCollection/styles.d.ts +3 -1
  37. package/types/TreeBrowser/TreeCollection/styles.d.ts.map +1 -1
  38. package/types/TreeBrowser/TreeNode/index.d.ts +4 -1
  39. package/types/TreeBrowser/TreeNode/index.d.ts.map +1 -1
  40. package/types/TreeBrowser/index.d.ts +3 -2
  41. package/types/TreeBrowser/index.d.ts.map +1 -1
  42. package/types/TreeBrowser/props.d.ts +4 -0
  43. package/types/TreeBrowser/props.d.ts.map +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
- ## [10.25.1-snapshot-4](https://github.com/instructure/instructure-ui/compare/v10.25.0...v10.25.1-snapshot-4) (2025-09-25)
6
+ ## [10.25.1-snapshot-6](https://github.com/instructure/instructure-ui/compare/v10.25.0...v10.25.1-snapshot-6) (2025-09-26)
7
7
 
8
- **Note:** Version bump only for package @instructure/ui-tree-browser
8
+
9
+ ### Features
10
+
11
+ * **ui-tree-browser:** add animation prop to TreeBrowser ([5906a0a](https://github.com/instructure/instructure-ui/commit/5906a0acb19564db6b54d0088a7a356b02533c13))
9
12
 
10
13
 
11
14
 
@@ -0,0 +1,39 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import { createContext } from 'react';
26
+ /**
27
+ * ---
28
+ * category: utilities/react
29
+ * ---
30
+ * React context created by the `TreeBrowser` component to hold its data which are
31
+ * read by its children.
32
+ *
33
+ * @module
34
+ */
35
+ const TreeBrowserContext = /*#__PURE__*/createContext({
36
+ animation: true
37
+ });
38
+ export default TreeBrowserContext;
39
+ export { TreeBrowserContext };
@@ -31,6 +31,7 @@ import { withStyle } from '@instructure/emotion';
31
31
  import generateStyles from './styles';
32
32
  import generateComponentTheme from './theme';
33
33
  import { allowedProps, propTypes } from './props';
34
+ import TreeBrowserContext from '../TreeBrowserContext';
34
35
 
35
36
  // Todo: merge TreeButton and TreeNode: TreeButton should be a special type of TreeNode
36
37
 
@@ -53,12 +54,16 @@ let TreeButton = (_dec = withStyle(generateStyles, generateComponentTheme), _dec
53
54
  };
54
55
  }
55
56
  componentDidMount() {
56
- var _this$props$makeStyle, _this$props;
57
- (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
57
+ var _this$props$makeStyle, _this$props, _this$context;
58
+ (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props, {
59
+ animation: (_this$context = this.context) === null || _this$context === void 0 ? void 0 : _this$context.animation
60
+ });
58
61
  }
59
62
  componentDidUpdate() {
60
- var _this$props$makeStyle2, _this$props2;
61
- (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
63
+ var _this$props$makeStyle2, _this$props2, _this$context2;
64
+ (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2, {
65
+ animation: (_this$context2 = this.context) === null || _this$context2 === void 0 ? void 0 : _this$context2.animation
66
+ });
62
67
  }
63
68
  defaultContentRenderer(props) {
64
69
  const name = props.name,
@@ -142,7 +147,7 @@ let TreeButton = (_dec = withStyle(generateStyles, generateComponentTheme), _dec
142
147
  children: buttonContent
143
148
  });
144
149
  }
145
- }, _TreeButton.displayName = "TreeButton", _TreeButton.componentId = 'TreeBrowser.Button', _TreeButton.allowedProps = allowedProps, _TreeButton.propTypes = propTypes, _TreeButton.defaultProps = {
150
+ }, _TreeButton.displayName = "TreeButton", _TreeButton.componentId = 'TreeBrowser.Button', _TreeButton.allowedProps = allowedProps, _TreeButton.propTypes = propTypes, _TreeButton.contextType = TreeBrowserContext, _TreeButton.defaultProps = {
146
151
  type: 'treeButton',
147
152
  size: 'medium',
148
153
  variant: 'folderTree',
@@ -41,9 +41,10 @@ const transform = keyframes`
41
41
  * Generates the style object from the theme and provided additional information
42
42
  * @param {Object} componentTheme The theme variable object.
43
43
  * @param {Object} props the props of the component, the style is applied to
44
+ * @param {Object} state the state of the component, the style is applied to
44
45
  * @return {Object} The final style object, which will be used in the component
45
46
  */
46
- const generateStyles = (componentTheme, props) => {
47
+ const generateStyles = (componentTheme, props, state) => {
47
48
  const size = props.size,
48
49
  variant = props.variant,
49
50
  selected = props.selected,
@@ -217,14 +218,16 @@ const generateStyles = (componentTheme, props) => {
217
218
  borderRadius: componentTheme.borderRadius,
218
219
  position: 'relative',
219
220
  zIndex: 1,
220
- transform: 'translate3d(-2%, 0, 0)',
221
- opacity: 0.01,
222
- transformOrigin: 'left center',
223
- animationName: transform,
224
- animationDuration: '0.2s',
225
- animationFillMode: 'forwards',
226
- animationTimingFunction: 'ease-out',
227
- animationDelay: '0.2s',
221
+ ...(state.animation ? {
222
+ transform: 'translate3d(-2%, 0, 0)',
223
+ opacity: 0.01,
224
+ transformOrigin: 'left center',
225
+ animationName: transform,
226
+ animationDuration: '0.2s',
227
+ animationFillMode: 'forwards',
228
+ animationTimingFunction: 'ease-out',
229
+ animationDelay: '0.2s'
230
+ } : {}),
228
231
  outline: '0',
229
232
  padding: '0',
230
233
  ...(variant === 'folderTree' && !isRootButton && {
@@ -31,6 +31,7 @@ import { TreeButton } from '../TreeButton';
31
31
  import generateStyles from './styles';
32
32
  import generateComponentTheme from './theme';
33
33
  import { allowedProps, propTypes } from './props';
34
+ import TreeBrowserContext from '../TreeBrowserContext';
34
35
  import { Fragment as _Fragment, jsxs as _jsxs, jsx as _jsx } from "@emotion/react/jsx-runtime";
35
36
  import { createElement as _createElement } from "@emotion/react";
36
37
  /**
@@ -88,12 +89,16 @@ let TreeCollection = (_dec = withStyle(generateStyles, generateComponentTheme),
88
89
  };
89
90
  }
90
91
  componentDidMount() {
91
- var _this$props$makeStyle, _this$props3;
92
- (_this$props$makeStyle = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props3);
92
+ var _this$props$makeStyle, _this$props3, _this$context;
93
+ (_this$props$makeStyle = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props3, {
94
+ animation: (_this$context = this.context) === null || _this$context === void 0 ? void 0 : _this$context.animation
95
+ });
93
96
  }
94
97
  componentDidUpdate() {
95
- var _this$props$makeStyle2, _this$props4;
96
- (_this$props$makeStyle2 = (_this$props4 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props4);
98
+ var _this$props$makeStyle2, _this$props4, _this$context2;
99
+ (_this$props$makeStyle2 = (_this$props4 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props4, {
100
+ animation: (_this$context2 = this.context) === null || _this$context2 === void 0 ? void 0 : _this$context2.animation
101
+ });
97
102
  }
98
103
  get itemsLevel() {
99
104
  const _this$props5 = this.props,
@@ -346,7 +351,7 @@ let TreeCollection = (_dec = withStyle(generateStyles, generateComponentTheme),
346
351
  })]
347
352
  });
348
353
  }
349
- }, _TreeCollection.displayName = "TreeCollection", _TreeCollection.componentId = 'TreeBrowser.Collection', _TreeCollection.allowedProps = allowedProps, _TreeCollection.propTypes = propTypes, _TreeCollection.defaultProps = {
354
+ }, _TreeCollection.displayName = "TreeCollection", _TreeCollection.componentId = 'TreeBrowser.Collection', _TreeCollection.allowedProps = allowedProps, _TreeCollection.propTypes = propTypes, _TreeCollection.contextType = TreeBrowserContext, _TreeCollection.defaultProps = {
350
355
  collections: [],
351
356
  items: [],
352
357
  expanded: false,
@@ -39,7 +39,7 @@ const list = keyframes`
39
39
  * @return {Object} The final style object, which will be used in the component
40
40
  */
41
41
 
42
- const generateStyles = (componentTheme, props) => {
42
+ const generateStyles = (componentTheme, props, state) => {
43
43
  const size = props.size,
44
44
  variant = props.variant;
45
45
  const sizeMap = {
@@ -106,12 +106,14 @@ const generateStyles = (componentTheme, props) => {
106
106
  bottom: '1.1875rem',
107
107
  insetInlineStart: '0',
108
108
  insetInlineEnd: 'auto',
109
- transform: 'scaleY(0.01)',
110
- transformOrigin: 'center top',
111
- animationName: list,
112
- animationDuration: '0.2s',
113
- animationFillMode: 'forwards',
114
- animationTimingFunction: 'ease-out',
109
+ ...(state.animation ? {
110
+ transform: 'scaleY(0.01)',
111
+ transformOrigin: 'center top',
112
+ animationName: list,
113
+ animationDuration: '0.2s',
114
+ animationFillMode: 'forwards',
115
+ animationTimingFunction: 'ease-out'
116
+ } : {}),
115
117
  pointerEvents: 'none',
116
118
  width: componentTheme.borderWidth,
117
119
  background: componentTheme.borderColor
@@ -31,6 +31,7 @@ import { withStyle } from '@instructure/emotion';
31
31
  import generateStyles from '../TreeButton/styles';
32
32
  import generateComponentTheme from '../TreeButton/theme';
33
33
  import { allowedProps, propTypes } from './props';
34
+ import TreeBrowserContext from '../TreeBrowserContext';
34
35
 
35
36
  // Todo: merge TreeButton and TreeNode: TreeButton should be a special type of TreeNode
36
37
 
@@ -55,12 +56,16 @@ let TreeNode = (_dec = withStyle(generateStyles, generateComponentTheme), _dec2
55
56
  };
56
57
  }
57
58
  componentDidMount() {
58
- var _this$props$makeStyle, _this$props;
59
- (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
59
+ var _this$props$makeStyle, _this$props, _this$context;
60
+ (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props, {
61
+ animation: (_this$context = this.context) === null || _this$context === void 0 ? void 0 : _this$context.animation
62
+ });
60
63
  }
61
64
  componentDidUpdate() {
62
- var _this$props$makeStyle2, _this$props2;
63
- (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
65
+ var _this$props$makeStyle2, _this$props2, _this$context2;
66
+ (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2, {
67
+ animation: (_this$context2 = this.context) === null || _this$context2 === void 0 ? void 0 : _this$context2.animation
68
+ });
64
69
  }
65
70
  renderItemImage() {
66
71
  const _this$props3 = this.props,
@@ -102,7 +107,7 @@ let TreeNode = (_dec = withStyle(generateStyles, generateComponentTheme), _dec2
102
107
  })
103
108
  });
104
109
  }
105
- }, _TreeNode.displayName = "TreeNode", _TreeNode.componentId = 'TreeBrowser.Node', _TreeNode.allowedProps = allowedProps, _TreeNode.propTypes = propTypes, _TreeNode.defaultProps = {
110
+ }, _TreeNode.displayName = "TreeNode", _TreeNode.componentId = 'TreeBrowser.Node', _TreeNode.allowedProps = allowedProps, _TreeNode.propTypes = propTypes, _TreeNode.contextType = TreeBrowserContext, _TreeNode.defaultProps = {
106
111
  size: 'medium',
107
112
  variant: 'folderTree',
108
113
  selected: false,
@@ -35,6 +35,7 @@ import { TreeNode } from './TreeNode';
35
35
  import generateStyles from './styles';
36
36
  import generateComponentTheme from './theme';
37
37
  import { allowedProps, propTypes } from './props';
38
+ import TreeBrowserContext from './TreeBrowserContext';
38
39
 
39
40
  /**
40
41
  ---
@@ -273,16 +274,21 @@ let TreeBrowser = (_dec = withStyle(generateStyles, generateComponentTheme), _de
273
274
  }
274
275
  render() {
275
276
  const styles = this.props.styles;
276
- return _jsx("ul", {
277
- css: styles === null || styles === void 0 ? void 0 : styles.treeBrowser,
278
- tabIndex: 0,
279
- role: "tree",
280
- onKeyDown: this.handleKeyDown,
281
- ref: el => {
282
- this.ref = el;
277
+ return _jsx(TreeBrowserContext.Provider, {
278
+ value: {
279
+ animation: this.props.animation
283
280
  },
284
- "aria-label": this.props.treeLabel,
285
- children: this.renderRoot()
281
+ children: _jsx("ul", {
282
+ css: styles === null || styles === void 0 ? void 0 : styles.treeBrowser,
283
+ tabIndex: 0,
284
+ role: "tree",
285
+ onKeyDown: this.handleKeyDown,
286
+ ref: el => {
287
+ this.ref = el;
288
+ },
289
+ "aria-label": this.props.treeLabel,
290
+ children: this.renderRoot()
291
+ })
286
292
  });
287
293
  }
288
294
  }, _TreeBrowser.displayName = "TreeBrowser", _TreeBrowser.componentId = 'TreeBrowser', _TreeBrowser.allowedProps = allowedProps, _TreeBrowser.propTypes = propTypes, _TreeBrowser.defaultProps = {
@@ -298,7 +304,8 @@ let TreeBrowser = (_dec = withStyle(generateStyles, generateComponentTheme), _de
298
304
  selectionType: 'none',
299
305
  sortOrder: function () {
300
306
  return 0;
301
- }
307
+ },
308
+ animation: true
302
309
  }, _TreeBrowser.Node = TreeNode, _TreeBrowser.Collection = TreeCollection, _TreeBrowser.Button = TreeButton, _TreeBrowser)) || _class) || _class);
303
310
  export default TreeBrowser;
304
311
  export { TreeBrowser };
@@ -54,7 +54,8 @@ const propTypes = {
54
54
  onItemClick: PropTypes.func,
55
55
  treeLabel: PropTypes.string,
56
56
  renderContent: PropTypes.func,
57
- sortOrder: PropTypes.func
57
+ sortOrder: PropTypes.func,
58
+ animation: PropTypes.bool
58
59
  };
59
- const allowedProps = ['collections', 'items', 'rootId', 'expanded', 'defaultExpanded', 'selectionType', 'size', 'variant', 'collectionIcon', 'collectionIconExpanded', 'itemIcon', 'getItemProps', 'getCollectionProps', 'showRootCollection', 'onCollectionClick', 'onCollectionToggle', 'onItemClick', 'treeLabel', 'renderContent', 'sortOrder'];
60
+ const allowedProps = ['collections', 'items', 'rootId', 'expanded', 'defaultExpanded', 'selectionType', 'size', 'variant', 'collectionIcon', 'collectionIconExpanded', 'itemIcon', 'getItemProps', 'getCollectionProps', 'showRootCollection', 'onCollectionClick', 'onCollectionToggle', 'onItemClick', 'treeLabel', 'renderContent', 'sortOrder', 'animation'];
60
61
  export { propTypes, allowedProps };
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.TreeBrowserContext = void 0;
7
+ var _react = require("react");
8
+ /*
9
+ * The MIT License (MIT)
10
+ *
11
+ * Copyright (c) 2015 - present Instructure, Inc.
12
+ *
13
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
14
+ * of this software and associated documentation files (the "Software"), to deal
15
+ * in the Software without restriction, including without limitation the rights
16
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
+ * copies of the Software, and to permit persons to whom the Software is
18
+ * furnished to do so, subject to the following conditions:
19
+ *
20
+ * The above copyright notice and this permission notice shall be included in all
21
+ * copies or substantial portions of the Software.
22
+ *
23
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
+ * SOFTWARE.
30
+ */
31
+
32
+ /**
33
+ * ---
34
+ * category: utilities/react
35
+ * ---
36
+ * React context created by the `TreeBrowser` component to hold its data which are
37
+ * read by its children.
38
+ *
39
+ * @module
40
+ */
41
+ const TreeBrowserContext = exports.TreeBrowserContext = /*#__PURE__*/(0, _react.createContext)({
42
+ animation: true
43
+ });
44
+ var _default = exports.default = TreeBrowserContext;
@@ -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 _TreeBrowserContext = _interopRequireDefault(require("../TreeBrowserContext"));
16
17
  var _jsxRuntime = require("@emotion/react/jsx-runtime");
17
18
  var _dec, _dec2, _class, _TreeButton;
18
19
  /*
@@ -57,12 +58,16 @@ let TreeButton = exports.TreeButton = (_dec = (0, _emotion.withStyle)(_styles.de
57
58
  };
58
59
  }
59
60
  componentDidMount() {
60
- var _this$props$makeStyle, _this$props;
61
- (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
61
+ var _this$props$makeStyle, _this$props, _this$context;
62
+ (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props, {
63
+ animation: (_this$context = this.context) === null || _this$context === void 0 ? void 0 : _this$context.animation
64
+ });
62
65
  }
63
66
  componentDidUpdate() {
64
- var _this$props$makeStyle2, _this$props2;
65
- (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
67
+ var _this$props$makeStyle2, _this$props2, _this$context2;
68
+ (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2, {
69
+ animation: (_this$context2 = this.context) === null || _this$context2 === void 0 ? void 0 : _this$context2.animation
70
+ });
66
71
  }
67
72
  defaultContentRenderer(props) {
68
73
  const name = props.name,
@@ -146,7 +151,7 @@ let TreeButton = exports.TreeButton = (_dec = (0, _emotion.withStyle)(_styles.de
146
151
  children: buttonContent
147
152
  });
148
153
  }
149
- }, _TreeButton.displayName = "TreeButton", _TreeButton.componentId = 'TreeBrowser.Button', _TreeButton.allowedProps = _props.allowedProps, _TreeButton.propTypes = _props.propTypes, _TreeButton.defaultProps = {
154
+ }, _TreeButton.displayName = "TreeButton", _TreeButton.componentId = 'TreeBrowser.Button', _TreeButton.allowedProps = _props.allowedProps, _TreeButton.propTypes = _props.propTypes, _TreeButton.contextType = _TreeBrowserContext.default, _TreeButton.defaultProps = {
150
155
  type: 'treeButton',
151
156
  size: 'medium',
152
157
  variant: 'folderTree',
@@ -47,9 +47,10 @@ const transform = (0, _emotion.keyframes)`
47
47
  * Generates the style object from the theme and provided additional information
48
48
  * @param {Object} componentTheme The theme variable object.
49
49
  * @param {Object} props the props of the component, the style is applied to
50
+ * @param {Object} state the state of the component, the style is applied to
50
51
  * @return {Object} The final style object, which will be used in the component
51
52
  */
52
- const generateStyles = (componentTheme, props) => {
53
+ const generateStyles = (componentTheme, props, state) => {
53
54
  const size = props.size,
54
55
  variant = props.variant,
55
56
  selected = props.selected,
@@ -223,14 +224,16 @@ const generateStyles = (componentTheme, props) => {
223
224
  borderRadius: componentTheme.borderRadius,
224
225
  position: 'relative',
225
226
  zIndex: 1,
226
- transform: 'translate3d(-2%, 0, 0)',
227
- opacity: 0.01,
228
- transformOrigin: 'left center',
229
- animationName: transform,
230
- animationDuration: '0.2s',
231
- animationFillMode: 'forwards',
232
- animationTimingFunction: 'ease-out',
233
- animationDelay: '0.2s',
227
+ ...(state.animation ? {
228
+ transform: 'translate3d(-2%, 0, 0)',
229
+ opacity: 0.01,
230
+ transformOrigin: 'left center',
231
+ animationName: transform,
232
+ animationDuration: '0.2s',
233
+ animationFillMode: 'forwards',
234
+ animationTimingFunction: 'ease-out',
235
+ animationDelay: '0.2s'
236
+ } : {}),
234
237
  outline: '0',
235
238
  padding: '0',
236
239
  ...(variant === 'folderTree' && !isRootButton && {
@@ -13,6 +13,7 @@ var _TreeButton = require("../TreeButton");
13
13
  var _styles = _interopRequireDefault(require("./styles"));
14
14
  var _theme = _interopRequireDefault(require("./theme"));
15
15
  var _props = require("./props");
16
+ var _TreeBrowserContext = _interopRequireDefault(require("../TreeBrowserContext"));
16
17
  var _jsxRuntime = require("@emotion/react/jsx-runtime");
17
18
  var _react2 = require("@emotion/react");
18
19
  var _dec, _dec2, _class, _TreeCollection;
@@ -94,12 +95,16 @@ let TreeCollection = exports.TreeCollection = (_dec = (0, _emotion.withStyle)(_s
94
95
  };
95
96
  }
96
97
  componentDidMount() {
97
- var _this$props$makeStyle, _this$props3;
98
- (_this$props$makeStyle = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props3);
98
+ var _this$props$makeStyle, _this$props3, _this$context;
99
+ (_this$props$makeStyle = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props3, {
100
+ animation: (_this$context = this.context) === null || _this$context === void 0 ? void 0 : _this$context.animation
101
+ });
99
102
  }
100
103
  componentDidUpdate() {
101
- var _this$props$makeStyle2, _this$props4;
102
- (_this$props$makeStyle2 = (_this$props4 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props4);
104
+ var _this$props$makeStyle2, _this$props4, _this$context2;
105
+ (_this$props$makeStyle2 = (_this$props4 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props4, {
106
+ animation: (_this$context2 = this.context) === null || _this$context2 === void 0 ? void 0 : _this$context2.animation
107
+ });
103
108
  }
104
109
  get itemsLevel() {
105
110
  const _this$props5 = this.props,
@@ -352,7 +357,7 @@ let TreeCollection = exports.TreeCollection = (_dec = (0, _emotion.withStyle)(_s
352
357
  })]
353
358
  });
354
359
  }
355
- }, _TreeCollection.displayName = "TreeCollection", _TreeCollection.componentId = 'TreeBrowser.Collection', _TreeCollection.allowedProps = _props.allowedProps, _TreeCollection.propTypes = _props.propTypes, _TreeCollection.defaultProps = {
360
+ }, _TreeCollection.displayName = "TreeCollection", _TreeCollection.componentId = 'TreeBrowser.Collection', _TreeCollection.allowedProps = _props.allowedProps, _TreeCollection.propTypes = _props.propTypes, _TreeCollection.contextType = _TreeBrowserContext.default, _TreeCollection.defaultProps = {
356
361
  collections: [],
357
362
  items: [],
358
363
  expanded: false,
@@ -45,7 +45,7 @@ const list = (0, _emotion.keyframes)`
45
45
  * @return {Object} The final style object, which will be used in the component
46
46
  */
47
47
 
48
- const generateStyles = (componentTheme, props) => {
48
+ const generateStyles = (componentTheme, props, state) => {
49
49
  const size = props.size,
50
50
  variant = props.variant;
51
51
  const sizeMap = {
@@ -112,12 +112,14 @@ const generateStyles = (componentTheme, props) => {
112
112
  bottom: '1.1875rem',
113
113
  insetInlineStart: '0',
114
114
  insetInlineEnd: 'auto',
115
- transform: 'scaleY(0.01)',
116
- transformOrigin: 'center top',
117
- animationName: list,
118
- animationDuration: '0.2s',
119
- animationFillMode: 'forwards',
120
- animationTimingFunction: 'ease-out',
115
+ ...(state.animation ? {
116
+ transform: 'scaleY(0.01)',
117
+ transformOrigin: 'center top',
118
+ animationName: list,
119
+ animationDuration: '0.2s',
120
+ animationFillMode: 'forwards',
121
+ animationTimingFunction: 'ease-out'
122
+ } : {}),
121
123
  pointerEvents: 'none',
122
124
  width: componentTheme.borderWidth,
123
125
  background: componentTheme.borderColor
@@ -13,6 +13,7 @@ var _emotion = require("@instructure/emotion");
13
13
  var _styles = _interopRequireDefault(require("../TreeButton/styles"));
14
14
  var _theme = _interopRequireDefault(require("../TreeButton/theme"));
15
15
  var _props = require("./props");
16
+ var _TreeBrowserContext = _interopRequireDefault(require("../TreeBrowserContext"));
16
17
  var _jsxRuntime = require("@emotion/react/jsx-runtime");
17
18
  var _dec, _dec2, _class, _TreeNode;
18
19
  /*
@@ -59,12 +60,16 @@ let TreeNode = exports.TreeNode = (_dec = (0, _emotion.withStyle)(_styles.defaul
59
60
  };
60
61
  }
61
62
  componentDidMount() {
62
- var _this$props$makeStyle, _this$props;
63
- (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
63
+ var _this$props$makeStyle, _this$props, _this$context;
64
+ (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props, {
65
+ animation: (_this$context = this.context) === null || _this$context === void 0 ? void 0 : _this$context.animation
66
+ });
64
67
  }
65
68
  componentDidUpdate() {
66
- var _this$props$makeStyle2, _this$props2;
67
- (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
69
+ var _this$props$makeStyle2, _this$props2, _this$context2;
70
+ (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2, {
71
+ animation: (_this$context2 = this.context) === null || _this$context2 === void 0 ? void 0 : _this$context2.animation
72
+ });
68
73
  }
69
74
  renderItemImage() {
70
75
  const _this$props3 = this.props,
@@ -106,7 +111,7 @@ let TreeNode = exports.TreeNode = (_dec = (0, _emotion.withStyle)(_styles.defaul
106
111
  })
107
112
  });
108
113
  }
109
- }, _TreeNode.displayName = "TreeNode", _TreeNode.componentId = 'TreeBrowser.Node', _TreeNode.allowedProps = _props.allowedProps, _TreeNode.propTypes = _props.propTypes, _TreeNode.defaultProps = {
114
+ }, _TreeNode.displayName = "TreeNode", _TreeNode.componentId = 'TreeBrowser.Node', _TreeNode.allowedProps = _props.allowedProps, _TreeNode.propTypes = _props.propTypes, _TreeNode.contextType = _TreeBrowserContext.default, _TreeNode.defaultProps = {
110
115
  size: 'medium',
111
116
  variant: 'folderTree',
112
117
  selected: false,
@@ -19,6 +19,7 @@ var _TreeNode = require("./TreeNode");
19
19
  var _styles = _interopRequireDefault(require("./styles"));
20
20
  var _theme = _interopRequireDefault(require("./theme"));
21
21
  var _props = require("./props");
22
+ var _TreeBrowserContext = _interopRequireDefault(require("./TreeBrowserContext"));
22
23
  var _jsxRuntime = require("@emotion/react/jsx-runtime");
23
24
  var _dec, _dec2, _class, _TreeBrowser;
24
25
  /*
@@ -280,16 +281,21 @@ let TreeBrowser = exports.TreeBrowser = (_dec = (0, _emotion.withStyle)(_styles.
280
281
  }
281
282
  render() {
282
283
  const styles = this.props.styles;
283
- return (0, _jsxRuntime.jsx)("ul", {
284
- css: styles === null || styles === void 0 ? void 0 : styles.treeBrowser,
285
- tabIndex: 0,
286
- role: "tree",
287
- onKeyDown: this.handleKeyDown,
288
- ref: el => {
289
- this.ref = el;
284
+ return (0, _jsxRuntime.jsx)(_TreeBrowserContext.default.Provider, {
285
+ value: {
286
+ animation: this.props.animation
290
287
  },
291
- "aria-label": this.props.treeLabel,
292
- children: this.renderRoot()
288
+ children: (0, _jsxRuntime.jsx)("ul", {
289
+ css: styles === null || styles === void 0 ? void 0 : styles.treeBrowser,
290
+ tabIndex: 0,
291
+ role: "tree",
292
+ onKeyDown: this.handleKeyDown,
293
+ ref: el => {
294
+ this.ref = el;
295
+ },
296
+ "aria-label": this.props.treeLabel,
297
+ children: this.renderRoot()
298
+ })
293
299
  });
294
300
  }
295
301
  }, _TreeBrowser.displayName = "TreeBrowser", _TreeBrowser.componentId = 'TreeBrowser', _TreeBrowser.allowedProps = _props.allowedProps, _TreeBrowser.propTypes = _props.propTypes, _TreeBrowser.defaultProps = {
@@ -305,6 +311,7 @@ let TreeBrowser = exports.TreeBrowser = (_dec = (0, _emotion.withStyle)(_styles.
305
311
  selectionType: 'none',
306
312
  sortOrder: function () {
307
313
  return 0;
308
- }
314
+ },
315
+ animation: true
309
316
  }, _TreeBrowser.Node = _TreeNode.TreeNode, _TreeBrowser.Collection = _TreeCollection.TreeCollection, _TreeBrowser.Button = _TreeButton.TreeButton, _TreeBrowser)) || _class) || _class);
310
317
  var _default = exports.default = TreeBrowser;
@@ -60,6 +60,7 @@ const propTypes = exports.propTypes = {
60
60
  onItemClick: _propTypes.default.func,
61
61
  treeLabel: _propTypes.default.string,
62
62
  renderContent: _propTypes.default.func,
63
- sortOrder: _propTypes.default.func
63
+ sortOrder: _propTypes.default.func,
64
+ animation: _propTypes.default.bool
64
65
  };
65
- const allowedProps = exports.allowedProps = ['collections', 'items', 'rootId', 'expanded', 'defaultExpanded', 'selectionType', 'size', 'variant', 'collectionIcon', 'collectionIconExpanded', 'itemIcon', 'getItemProps', 'getCollectionProps', 'showRootCollection', 'onCollectionClick', 'onCollectionToggle', 'onItemClick', 'treeLabel', 'renderContent', 'sortOrder'];
66
+ const allowedProps = exports.allowedProps = ['collections', 'items', 'rootId', 'expanded', 'defaultExpanded', 'selectionType', 'size', 'variant', 'collectionIcon', 'collectionIconExpanded', 'itemIcon', 'getItemProps', 'getCollectionProps', 'showRootCollection', 'onCollectionClick', 'onCollectionToggle', 'onItemClick', 'treeLabel', 'renderContent', 'sortOrder', 'animation'];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-tree-browser",
3
- "version": "10.25.1-snapshot-4",
3
+ "version": "10.25.1-snapshot-6",
4
4
  "description": "A component for displaying a hierarchical view of information",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "module": "./es/index.js",
@@ -23,24 +23,24 @@
23
23
  },
24
24
  "license": "MIT",
25
25
  "devDependencies": {
26
- "@instructure/ui-axe-check": "10.25.1-snapshot-4",
27
- "@instructure/ui-babel-preset": "10.25.1-snapshot-4",
28
- "@instructure/ui-color-utils": "10.25.1-snapshot-4",
29
- "@instructure/ui-themes": "10.25.1-snapshot-4",
26
+ "@instructure/ui-axe-check": "10.25.1-snapshot-6",
27
+ "@instructure/ui-babel-preset": "10.25.1-snapshot-6",
28
+ "@instructure/ui-color-utils": "10.25.1-snapshot-6",
29
+ "@instructure/ui-themes": "10.25.1-snapshot-6",
30
30
  "@testing-library/jest-dom": "^6.6.3",
31
31
  "@testing-library/react": "^16.0.1",
32
32
  "vitest": "^3.2.2"
33
33
  },
34
34
  "dependencies": {
35
35
  "@babel/runtime": "^7.27.6",
36
- "@instructure/emotion": "10.25.1-snapshot-4",
37
- "@instructure/shared-types": "10.25.1-snapshot-4",
38
- "@instructure/ui-icons": "10.25.1-snapshot-4",
39
- "@instructure/ui-img": "10.25.1-snapshot-4",
40
- "@instructure/ui-prop-types": "10.25.1-snapshot-4",
41
- "@instructure/ui-react-utils": "10.25.1-snapshot-4",
42
- "@instructure/ui-testable": "10.25.1-snapshot-4",
43
- "@instructure/ui-utils": "10.25.1-snapshot-4",
36
+ "@instructure/emotion": "10.25.1-snapshot-6",
37
+ "@instructure/shared-types": "10.25.1-snapshot-6",
38
+ "@instructure/ui-icons": "10.25.1-snapshot-6",
39
+ "@instructure/ui-img": "10.25.1-snapshot-6",
40
+ "@instructure/ui-prop-types": "10.25.1-snapshot-6",
41
+ "@instructure/ui-react-utils": "10.25.1-snapshot-6",
42
+ "@instructure/ui-testable": "10.25.1-snapshot-6",
43
+ "@instructure/ui-utils": "10.25.1-snapshot-6",
44
44
  "keycode": "^2",
45
45
  "prop-types": "^15.8.1"
46
46
  },