@instructure/ui-navigation 8.25.1-snapshot-10 → 8.25.1-snapshot-13

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 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
- ## [8.25.1-snapshot-10](https://github.com/instructure/instructure-ui/compare/v8.25.0...v8.25.1-snapshot-10) (2022-06-20)
6
+ ## [8.25.1-snapshot-13](https://github.com/instructure/instructure-ui/compare/v8.25.0...v8.25.1-snapshot-13) (2022-06-22)
7
7
 
8
8
  **Note:** Version bump only for package @instructure/ui-navigation
9
9
 
@@ -1,4 +1,4 @@
1
- var _dec, _dec2, _class;
1
+ var _dec, _dec2, _class, _class2;
2
2
 
3
3
  /*
4
4
  * The MIT License (MIT)
@@ -44,51 +44,45 @@ id: AppNav.Item
44
44
  @module Item
45
45
  **/
46
46
 
47
- let Item = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = class Item extends Component {
48
- static displayName = "Item";
49
- static componentId = 'AppNav.Item';
50
- static allowedProps = allowedProps;
51
- static propTypes = propTypes;
52
- static defaultProps = {
53
- children: null,
54
- isSelected: false,
55
- cursor: 'pointer',
56
- isDisabled: false
57
- };
58
- ref = null;
47
+ let Item = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = (_class2 = class Item extends Component {
48
+ constructor() {
49
+ super(...arguments);
50
+ this.ref = null;
59
51
 
60
- componentDidMount() {
61
- var _this$props$makeStyle, _this$props;
52
+ this.handleRef = el => {
53
+ const elementRef = this.props.elementRef;
54
+ this.ref = el;
55
+
56
+ if (typeof elementRef === 'function') {
57
+ elementRef(el);
58
+ }
59
+ };
60
+
61
+ this.handleClick = e => {
62
+ const _this$props = this.props,
63
+ isDisabled = _this$props.isDisabled,
64
+ onClick = _this$props.onClick;
62
65
 
63
- (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
66
+ if (isDisabled) {
67
+ e.preventDefault();
68
+ e.stopPropagation();
69
+ } else if (typeof onClick === 'function') {
70
+ onClick(e);
71
+ }
72
+ };
64
73
  }
65
74
 
66
- componentDidUpdate() {
67
- var _this$props$makeStyle2, _this$props2;
75
+ componentDidMount() {
76
+ var _this$props$makeStyle, _this$props2;
68
77
 
69
- (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
78
+ (_this$props$makeStyle = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props2);
70
79
  }
71
80
 
72
- handleRef = el => {
73
- const elementRef = this.props.elementRef;
74
- this.ref = el;
81
+ componentDidUpdate() {
82
+ var _this$props$makeStyle2, _this$props3;
75
83
 
76
- if (typeof elementRef === 'function') {
77
- elementRef(el);
78
- }
79
- };
80
- handleClick = e => {
81
- const _this$props3 = this.props,
82
- isDisabled = _this$props3.isDisabled,
83
- onClick = _this$props3.onClick;
84
-
85
- if (isDisabled) {
86
- e.preventDefault();
87
- e.stopPropagation();
88
- } else if (typeof onClick === 'function') {
89
- onClick(e);
90
- }
91
- };
84
+ (_this$props$makeStyle2 = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props3);
85
+ }
92
86
 
93
87
  render() {
94
88
  var _this$props$styles, _this$props$styles2;
@@ -125,6 +119,11 @@ let Item = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = tes
125
119
  }, label), renderAfter && callRenderProp(renderAfter));
126
120
  }
127
121
 
128
- }) || _class) || _class);
122
+ }, _class2.displayName = "Item", _class2.componentId = 'AppNav.Item', _class2.allowedProps = allowedProps, _class2.propTypes = propTypes, _class2.defaultProps = {
123
+ children: null,
124
+ isSelected: false,
125
+ cursor: 'pointer',
126
+ isDisabled: false
127
+ }, _class2)) || _class) || _class);
129
128
  export default Item;
130
129
  export { Item };
@@ -1,4 +1,4 @@
1
- var _dec, _dec2, _class;
1
+ var _dec, _dec2, _class, _class2;
2
2
 
3
3
  /*
4
4
  * The MIT License (MIT)
@@ -45,34 +45,88 @@ category: components
45
45
  ---
46
46
  @tsProps
47
47
  **/
48
- let AppNav = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = class AppNav extends Component {
49
- static displayName = "AppNav";
50
- static componentId = 'AppNav';
51
- static allowedProps = allowedProps;
52
- static propTypes = propTypes;
53
- static defaultProps = {
54
- children: null,
55
- debounce: 300,
56
- margin: '0',
57
- renderTruncateLabel: () => 'More',
58
- visibleItemsCount: 0
59
- };
60
- static Item = Item;
61
- state = {
62
- isMeasuring: false
63
- };
64
- ref = null;
65
- _list = null;
66
- _debounced;
67
- _resizeListener;
48
+ let AppNav = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = (_class2 = class AppNav extends Component {
49
+ constructor() {
50
+ super(...arguments);
51
+ this.state = {
52
+ isMeasuring: false
53
+ };
54
+ this.ref = null;
55
+ this._list = null;
56
+ this._debounced = void 0;
57
+ this._resizeListener = void 0;
58
+
59
+ this.measureItems = () => {
60
+ var _this$props$styles;
61
+
62
+ const menuTriggerWidth = px((_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.menuTriggerWidth);
63
+ let visibleItemsCount = 0;
64
+
65
+ if (this._list) {
66
+ const _getBoundingClientRec = getBoundingClientRect(this._list),
67
+ navWidth = _getBoundingClientRec.width;
68
+
69
+ const itemWidths = Array.from(this._list.getElementsByTagName('li')).map(item => {
70
+ // Todo: if item's type isn't `unknown`, can remove `Element`
71
+ const _getBoundingClientRec2 = getBoundingClientRect(item),
72
+ width = _getBoundingClientRec2.width;
73
+
74
+ return width;
75
+ });
76
+ let currentWidth = 0;
77
+
78
+ for (let i = 0; i < itemWidths.length; i++) {
79
+ currentWidth += itemWidths[i];
80
+
81
+ if (currentWidth <= navWidth - menuTriggerWidth) {
82
+ visibleItemsCount++;
83
+ } else {
84
+ break;
85
+ }
86
+ }
87
+ }
88
+
89
+ return {
90
+ visibleItemsCount
91
+ };
92
+ };
93
+
94
+ this.handleResize = () => {
95
+ this.setState({
96
+ isMeasuring: true
97
+ }, () => {
98
+ const _this$measureItems = this.measureItems(),
99
+ visibleItemsCount = _this$measureItems.visibleItemsCount;
100
+
101
+ if (typeof this.props.onUpdate === 'function') {
102
+ this.props.onUpdate({
103
+ visibleItemsCount
104
+ });
105
+ }
106
+
107
+ this.setState({
108
+ isMeasuring: false
109
+ });
110
+ });
111
+ };
112
+
113
+ this.handleRef = el => {
114
+ const elementRef = this.props.elementRef;
115
+ this.ref = el;
116
+
117
+ if (typeof elementRef === 'function') {
118
+ elementRef(el);
119
+ }
120
+ };
121
+ }
68
122
 
69
123
  componentDidMount() {
70
124
  var _this$props$makeStyle, _this$props;
71
125
 
72
126
  (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
73
127
 
74
- const _getBoundingClientRec = getBoundingClientRect(this._list),
75
- origWidth = _getBoundingClientRec.width;
128
+ const _getBoundingClientRec3 = getBoundingClientRect(this._list),
129
+ origWidth = _getBoundingClientRec3.width;
76
130
 
77
131
  this._debounced = debounce(this.handleResize, this.props.debounce, {
78
132
  leading: true,
@@ -109,67 +163,6 @@ let AppNav = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = t
109
163
  }
110
164
  }
111
165
 
112
- measureItems = () => {
113
- var _this$props$styles;
114
-
115
- const menuTriggerWidth = px((_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.menuTriggerWidth);
116
- let visibleItemsCount = 0;
117
-
118
- if (this._list) {
119
- const _getBoundingClientRec2 = getBoundingClientRect(this._list),
120
- navWidth = _getBoundingClientRec2.width;
121
-
122
- const itemWidths = Array.from(this._list.getElementsByTagName('li')).map(item => {
123
- // Todo: if item's type isn't `unknown`, can remove `Element`
124
- const _getBoundingClientRec3 = getBoundingClientRect(item),
125
- width = _getBoundingClientRec3.width;
126
-
127
- return width;
128
- });
129
- let currentWidth = 0;
130
-
131
- for (let i = 0; i < itemWidths.length; i++) {
132
- currentWidth += itemWidths[i];
133
-
134
- if (currentWidth <= navWidth - menuTriggerWidth) {
135
- visibleItemsCount++;
136
- } else {
137
- break;
138
- }
139
- }
140
- }
141
-
142
- return {
143
- visibleItemsCount
144
- };
145
- };
146
- handleResize = () => {
147
- this.setState({
148
- isMeasuring: true
149
- }, () => {
150
- const _this$measureItems = this.measureItems(),
151
- visibleItemsCount = _this$measureItems.visibleItemsCount;
152
-
153
- if (typeof this.props.onUpdate === 'function') {
154
- this.props.onUpdate({
155
- visibleItemsCount
156
- });
157
- }
158
-
159
- this.setState({
160
- isMeasuring: false
161
- });
162
- });
163
- };
164
- handleRef = el => {
165
- const elementRef = this.props.elementRef;
166
- this.ref = el;
167
-
168
- if (typeof elementRef === 'function') {
169
- elementRef(el);
170
- }
171
- };
172
-
173
166
  renderListItem(item, isMenuTrigger, key) {
174
167
  var _this$props$styles2, _this$props$styles3;
175
168
 
@@ -225,6 +218,12 @@ let AppNav = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = t
225
218
  }), hiddenChildren.length > 0 && this.renderMenu(hiddenChildren)), renderAfterItems && jsx("span", null, renderAfterItems));
226
219
  }
227
220
 
228
- }) || _class) || _class);
221
+ }, _class2.displayName = "AppNav", _class2.componentId = 'AppNav', _class2.allowedProps = allowedProps, _class2.propTypes = propTypes, _class2.defaultProps = {
222
+ children: null,
223
+ debounce: 300,
224
+ margin: '0',
225
+ renderTruncateLabel: () => 'More',
226
+ visibleItemsCount: 0
227
+ }, _class2.Item = Item, _class2)) || _class) || _class);
229
228
  export { AppNav };
230
229
  export default AppNav;
@@ -1,4 +1,4 @@
1
- var _dec, _dec2, _class;
1
+ var _dec, _dec2, _class, _class2;
2
2
 
3
3
  /*
4
4
  * The MIT License (MIT)
@@ -42,25 +42,20 @@ id: Navigation.Item
42
42
  @tsProps
43
43
  **/
44
44
 
45
- let NavigationItem = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = class NavigationItem extends Component {
46
- static displayName = "NavigationItem";
47
- static componentId = 'Navigation.Item';
48
- static allowedProps = allowedProps;
49
- static propTypes = propTypes;
50
- static defaultProps = {
51
- as: 'a',
52
- selected: false,
53
- minimized: false
54
- };
55
- ref = null;
56
- handleRef = el => {
57
- const elementRef = this.props.elementRef;
58
- this.ref = el;
45
+ let NavigationItem = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = (_class2 = class NavigationItem extends Component {
46
+ constructor() {
47
+ super(...arguments);
48
+ this.ref = null;
59
49
 
60
- if (typeof elementRef === 'function') {
61
- elementRef(el);
62
- }
63
- };
50
+ this.handleRef = el => {
51
+ const elementRef = this.props.elementRef;
52
+ this.ref = el;
53
+
54
+ if (typeof elementRef === 'function') {
55
+ elementRef(el);
56
+ }
57
+ };
58
+ }
64
59
 
65
60
  componentDidMount() {
66
61
  var _this$props$makeStyle, _this$props;
@@ -116,6 +111,10 @@ let NavigationItem = (_dec = withStyle(generateStyle, generateComponentTheme), _
116
111
  }, link) : link;
117
112
  }
118
113
 
119
- }) || _class) || _class);
114
+ }, _class2.displayName = "NavigationItem", _class2.componentId = 'Navigation.Item', _class2.allowedProps = allowedProps, _class2.propTypes = propTypes, _class2.defaultProps = {
115
+ as: 'a',
116
+ selected: false,
117
+ minimized: false
118
+ }, _class2)) || _class) || _class);
120
119
  export default NavigationItem;
121
120
  export { NavigationItem };
@@ -1,4 +1,4 @@
1
- var _dec, _dec2, _dec3, _class;
1
+ var _dec, _dec2, _dec3, _class, _class2;
2
2
 
3
3
  /*
4
4
  * The MIT License (MIT)
@@ -50,22 +50,21 @@ category: components/deprecated
50
50
  **/
51
51
 
52
52
 
53
- let Navigation = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = testable(), _dec3 = deprecated('9.0.0', null, 'No one uses <Navigation>, so we will deprecate it.'), _dec(_class = _dec2(_class = _dec3(_class = class Navigation extends Component {
54
- static displayName = "Navigation";
55
- static componentId = 'Navigation';
56
- static allowedProps = allowedProps;
57
- static propTypes = propTypes;
58
- static defaultProps = {
59
- children: null,
60
- defaultMinimized: false,
61
- // TODO we should investigate later if it used or not
62
- onClick: function (_e) {}
63
- };
64
- static Item = NavigationItem;
65
- ref = null;
66
-
53
+ let Navigation = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = testable(), _dec3 = deprecated('9.0.0', null, 'No one uses <Navigation>, so we will deprecate it.'), _dec(_class = _dec2(_class = _dec3(_class = (_class2 = class Navigation extends Component {
67
54
  constructor(props) {
68
55
  super(props);
56
+ this.ref = null;
57
+
58
+ this.handleNavToggle = event => {
59
+ if (!this.isControlled()) {
60
+ this.setState(navMinimized);
61
+ }
62
+
63
+ if (typeof this.props.onMinimized === 'function') {
64
+ this.props.onMinimized(event, !this.minimized);
65
+ }
66
+ };
67
+
69
68
  this.state = {
70
69
  minimized: this.isControlled(props) ? !!props.minimized : !!props.defaultMinimized
71
70
  };
@@ -100,16 +99,6 @@ let Navigation = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2
100
99
  return typeof props.minimized === 'boolean';
101
100
  }
102
101
 
103
- handleNavToggle = event => {
104
- if (!this.isControlled()) {
105
- this.setState(navMinimized);
106
- }
107
-
108
- if (typeof this.props.onMinimized === 'function') {
109
- this.props.onMinimized(event, !this.minimized);
110
- }
111
- };
112
-
113
102
  renderChildren() {
114
103
  return Children.map(this.props.children, child => {
115
104
  var _this$props$styles;
@@ -153,6 +142,11 @@ let Navigation = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2
153
142
  })));
154
143
  }
155
144
 
156
- }) || _class) || _class) || _class);
145
+ }, _class2.displayName = "Navigation", _class2.componentId = 'Navigation', _class2.allowedProps = allowedProps, _class2.propTypes = propTypes, _class2.defaultProps = {
146
+ children: null,
147
+ defaultMinimized: false,
148
+ // TODO we should investigate later if it used or not
149
+ onClick: function (_e) {}
150
+ }, _class2.Item = NavigationItem, _class2)) || _class) || _class) || _class);
157
151
  export default Navigation;
158
152
  export { Navigation, NavigationItem };
@@ -35,7 +35,7 @@ var _theme = _interopRequireDefault(require("./theme"));
35
35
 
36
36
  var _props = require("./props");
37
37
 
38
- var _dec, _dec2, _class;
38
+ var _dec, _dec2, _class, _class2;
39
39
 
40
40
  /**
41
41
  ---
@@ -45,52 +45,46 @@ id: AppNav.Item
45
45
  @tsProps
46
46
  @module Item
47
47
  **/
48
- let Item = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec2 = (0, _testable.testable)(), _dec(_class = _dec2(_class = class Item extends _react.Component {
49
- static displayName = "Item";
50
- static componentId = 'AppNav.Item';
51
- static allowedProps = _props.allowedProps;
52
- static propTypes = _props.propTypes;
53
- static defaultProps = {
54
- children: null,
55
- isSelected: false,
56
- cursor: 'pointer',
57
- isDisabled: false
58
- };
59
- ref = null;
48
+ let Item = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec2 = (0, _testable.testable)(), _dec(_class = _dec2(_class = (_class2 = class Item extends _react.Component {
49
+ constructor() {
50
+ super(...arguments);
51
+ this.ref = null;
52
+
53
+ this.handleRef = el => {
54
+ const elementRef = this.props.elementRef;
55
+ this.ref = el;
56
+
57
+ if (typeof elementRef === 'function') {
58
+ elementRef(el);
59
+ }
60
+ };
61
+
62
+ this.handleClick = e => {
63
+ const _this$props = this.props,
64
+ isDisabled = _this$props.isDisabled,
65
+ onClick = _this$props.onClick;
66
+
67
+ if (isDisabled) {
68
+ e.preventDefault();
69
+ e.stopPropagation();
70
+ } else if (typeof onClick === 'function') {
71
+ onClick(e);
72
+ }
73
+ };
74
+ }
60
75
 
61
76
  componentDidMount() {
62
- var _this$props$makeStyle, _this$props;
77
+ var _this$props$makeStyle, _this$props2;
63
78
 
64
- (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
79
+ (_this$props$makeStyle = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props2);
65
80
  }
66
81
 
67
82
  componentDidUpdate() {
68
- var _this$props$makeStyle2, _this$props2;
83
+ var _this$props$makeStyle2, _this$props3;
69
84
 
70
- (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
85
+ (_this$props$makeStyle2 = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props3);
71
86
  }
72
87
 
73
- handleRef = el => {
74
- const elementRef = this.props.elementRef;
75
- this.ref = el;
76
-
77
- if (typeof elementRef === 'function') {
78
- elementRef(el);
79
- }
80
- };
81
- handleClick = e => {
82
- const _this$props3 = this.props,
83
- isDisabled = _this$props3.isDisabled,
84
- onClick = _this$props3.onClick;
85
-
86
- if (isDisabled) {
87
- e.preventDefault();
88
- e.stopPropagation();
89
- } else if (typeof onClick === 'function') {
90
- onClick(e);
91
- }
92
- };
93
-
94
88
  render() {
95
89
  var _this$props$styles, _this$props$styles2;
96
90
 
@@ -126,7 +120,12 @@ let Item = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _de
126
120
  }, label), renderAfter && (0, _callRenderProp.callRenderProp)(renderAfter));
127
121
  }
128
122
 
129
- }) || _class) || _class);
123
+ }, _class2.displayName = "Item", _class2.componentId = 'AppNav.Item', _class2.allowedProps = _props.allowedProps, _class2.propTypes = _props.propTypes, _class2.defaultProps = {
124
+ children: null,
125
+ isSelected: false,
126
+ cursor: 'pointer',
127
+ isDisabled: false
128
+ }, _class2)) || _class) || _class);
130
129
  exports.Item = Item;
131
130
  var _default = Item;
132
131
  exports.default = _default;
@@ -35,7 +35,7 @@ var _theme = _interopRequireDefault(require("./theme"));
35
35
 
36
36
  var _props = require("./props");
37
37
 
38
- var _dec, _dec2, _class;
38
+ var _dec, _dec2, _class, _class2;
39
39
 
40
40
  /**
41
41
  ---
@@ -43,34 +43,88 @@ category: components
43
43
  ---
44
44
  @tsProps
45
45
  **/
46
- let AppNav = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec2 = (0, _testable.testable)(), _dec(_class = _dec2(_class = class AppNav extends _react.Component {
47
- static displayName = "AppNav";
48
- static componentId = 'AppNav';
49
- static allowedProps = _props.allowedProps;
50
- static propTypes = _props.propTypes;
51
- static defaultProps = {
52
- children: null,
53
- debounce: 300,
54
- margin: '0',
55
- renderTruncateLabel: () => 'More',
56
- visibleItemsCount: 0
57
- };
58
- static Item = _Item.Item;
59
- state = {
60
- isMeasuring: false
61
- };
62
- ref = null;
63
- _list = null;
64
- _debounced;
65
- _resizeListener;
46
+ let AppNav = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec2 = (0, _testable.testable)(), _dec(_class = _dec2(_class = (_class2 = class AppNav extends _react.Component {
47
+ constructor() {
48
+ super(...arguments);
49
+ this.state = {
50
+ isMeasuring: false
51
+ };
52
+ this.ref = null;
53
+ this._list = null;
54
+ this._debounced = void 0;
55
+ this._resizeListener = void 0;
56
+
57
+ this.measureItems = () => {
58
+ var _this$props$styles;
59
+
60
+ const menuTriggerWidth = (0, _px.px)((_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.menuTriggerWidth);
61
+ let visibleItemsCount = 0;
62
+
63
+ if (this._list) {
64
+ const _getBoundingClientRec = (0, _getBoundingClientRect.getBoundingClientRect)(this._list),
65
+ navWidth = _getBoundingClientRec.width;
66
+
67
+ const itemWidths = Array.from(this._list.getElementsByTagName('li')).map(item => {
68
+ // Todo: if item's type isn't `unknown`, can remove `Element`
69
+ const _getBoundingClientRec2 = (0, _getBoundingClientRect.getBoundingClientRect)(item),
70
+ width = _getBoundingClientRec2.width;
71
+
72
+ return width;
73
+ });
74
+ let currentWidth = 0;
75
+
76
+ for (let i = 0; i < itemWidths.length; i++) {
77
+ currentWidth += itemWidths[i];
78
+
79
+ if (currentWidth <= navWidth - menuTriggerWidth) {
80
+ visibleItemsCount++;
81
+ } else {
82
+ break;
83
+ }
84
+ }
85
+ }
86
+
87
+ return {
88
+ visibleItemsCount
89
+ };
90
+ };
91
+
92
+ this.handleResize = () => {
93
+ this.setState({
94
+ isMeasuring: true
95
+ }, () => {
96
+ const _this$measureItems = this.measureItems(),
97
+ visibleItemsCount = _this$measureItems.visibleItemsCount;
98
+
99
+ if (typeof this.props.onUpdate === 'function') {
100
+ this.props.onUpdate({
101
+ visibleItemsCount
102
+ });
103
+ }
104
+
105
+ this.setState({
106
+ isMeasuring: false
107
+ });
108
+ });
109
+ };
110
+
111
+ this.handleRef = el => {
112
+ const elementRef = this.props.elementRef;
113
+ this.ref = el;
114
+
115
+ if (typeof elementRef === 'function') {
116
+ elementRef(el);
117
+ }
118
+ };
119
+ }
66
120
 
67
121
  componentDidMount() {
68
122
  var _this$props$makeStyle, _this$props;
69
123
 
70
124
  (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
71
125
 
72
- const _getBoundingClientRec = (0, _getBoundingClientRect.getBoundingClientRect)(this._list),
73
- origWidth = _getBoundingClientRec.width;
126
+ const _getBoundingClientRec3 = (0, _getBoundingClientRect.getBoundingClientRect)(this._list),
127
+ origWidth = _getBoundingClientRec3.width;
74
128
 
75
129
  this._debounced = (0, _debounce.debounce)(this.handleResize, this.props.debounce, {
76
130
  leading: true,
@@ -107,67 +161,6 @@ let AppNav = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _
107
161
  }
108
162
  }
109
163
 
110
- measureItems = () => {
111
- var _this$props$styles;
112
-
113
- const menuTriggerWidth = (0, _px.px)((_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.menuTriggerWidth);
114
- let visibleItemsCount = 0;
115
-
116
- if (this._list) {
117
- const _getBoundingClientRec2 = (0, _getBoundingClientRect.getBoundingClientRect)(this._list),
118
- navWidth = _getBoundingClientRec2.width;
119
-
120
- const itemWidths = Array.from(this._list.getElementsByTagName('li')).map(item => {
121
- // Todo: if item's type isn't `unknown`, can remove `Element`
122
- const _getBoundingClientRec3 = (0, _getBoundingClientRect.getBoundingClientRect)(item),
123
- width = _getBoundingClientRec3.width;
124
-
125
- return width;
126
- });
127
- let currentWidth = 0;
128
-
129
- for (let i = 0; i < itemWidths.length; i++) {
130
- currentWidth += itemWidths[i];
131
-
132
- if (currentWidth <= navWidth - menuTriggerWidth) {
133
- visibleItemsCount++;
134
- } else {
135
- break;
136
- }
137
- }
138
- }
139
-
140
- return {
141
- visibleItemsCount
142
- };
143
- };
144
- handleResize = () => {
145
- this.setState({
146
- isMeasuring: true
147
- }, () => {
148
- const _this$measureItems = this.measureItems(),
149
- visibleItemsCount = _this$measureItems.visibleItemsCount;
150
-
151
- if (typeof this.props.onUpdate === 'function') {
152
- this.props.onUpdate({
153
- visibleItemsCount
154
- });
155
- }
156
-
157
- this.setState({
158
- isMeasuring: false
159
- });
160
- });
161
- };
162
- handleRef = el => {
163
- const elementRef = this.props.elementRef;
164
- this.ref = el;
165
-
166
- if (typeof elementRef === 'function') {
167
- elementRef(el);
168
- }
169
- };
170
-
171
164
  renderListItem(item, isMenuTrigger, key) {
172
165
  var _this$props$styles2, _this$props$styles3;
173
166
 
@@ -227,7 +220,13 @@ let AppNav = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _
227
220
  }), hiddenChildren.length > 0 && this.renderMenu(hiddenChildren)), renderAfterItems && (0, _emotion.jsx)("span", null, renderAfterItems));
228
221
  }
229
222
 
230
- }) || _class) || _class);
223
+ }, _class2.displayName = "AppNav", _class2.componentId = 'AppNav', _class2.allowedProps = _props.allowedProps, _class2.propTypes = _props.propTypes, _class2.defaultProps = {
224
+ children: null,
225
+ debounce: 300,
226
+ margin: '0',
227
+ renderTruncateLabel: () => 'More',
228
+ visibleItemsCount: 0
229
+ }, _class2.Item = _Item.Item, _class2)) || _class) || _class);
231
230
  exports.AppNav = AppNav;
232
231
  var _default = AppNav;
233
232
  exports.default = _default;
@@ -27,7 +27,7 @@ var _theme = _interopRequireDefault(require("./theme"));
27
27
 
28
28
  var _props = require("./props");
29
29
 
30
- var _dec, _dec2, _class;
30
+ var _dec, _dec2, _class, _class2;
31
31
 
32
32
  /**
33
33
  ---
@@ -36,25 +36,20 @@ id: Navigation.Item
36
36
  ---
37
37
  @tsProps
38
38
  **/
39
- let NavigationItem = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec2 = (0, _testable.testable)(), _dec(_class = _dec2(_class = class NavigationItem extends _react.Component {
40
- static displayName = "NavigationItem";
41
- static componentId = 'Navigation.Item';
42
- static allowedProps = _props.allowedProps;
43
- static propTypes = _props.propTypes;
44
- static defaultProps = {
45
- as: 'a',
46
- selected: false,
47
- minimized: false
48
- };
49
- ref = null;
50
- handleRef = el => {
51
- const elementRef = this.props.elementRef;
52
- this.ref = el;
53
-
54
- if (typeof elementRef === 'function') {
55
- elementRef(el);
56
- }
57
- };
39
+ let NavigationItem = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec2 = (0, _testable.testable)(), _dec(_class = _dec2(_class = (_class2 = class NavigationItem extends _react.Component {
40
+ constructor() {
41
+ super(...arguments);
42
+ this.ref = null;
43
+
44
+ this.handleRef = el => {
45
+ const elementRef = this.props.elementRef;
46
+ this.ref = el;
47
+
48
+ if (typeof elementRef === 'function') {
49
+ elementRef(el);
50
+ }
51
+ };
52
+ }
58
53
 
59
54
  componentDidMount() {
60
55
  var _this$props$makeStyle, _this$props;
@@ -110,7 +105,11 @@ let NavigationItem = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.def
110
105
  }, link) : link;
111
106
  }
112
107
 
113
- }) || _class) || _class);
108
+ }, _class2.displayName = "NavigationItem", _class2.componentId = 'Navigation.Item', _class2.allowedProps = _props.allowedProps, _class2.propTypes = _props.propTypes, _class2.defaultProps = {
109
+ as: 'a',
110
+ selected: false,
111
+ minimized: false
112
+ }, _class2)) || _class) || _class);
114
113
  exports.NavigationItem = NavigationItem;
115
114
  var _default = NavigationItem;
116
115
  exports.default = _default;
@@ -40,7 +40,7 @@ var _theme = _interopRequireDefault(require("./theme"));
40
40
 
41
41
  var _props = require("./props");
42
42
 
43
- var _dec, _dec2, _dec3, _class;
43
+ var _dec, _dec2, _dec3, _class, _class2;
44
44
 
45
45
  const navMinimized = _ref => {
46
46
  let minimized = _ref.minimized;
@@ -56,22 +56,21 @@ category: components/deprecated
56
56
  **/
57
57
 
58
58
 
59
- let Navigation = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec2 = (0, _testable.testable)(), _dec3 = (0, _deprecated.deprecated)('9.0.0', null, 'No one uses <Navigation>, so we will deprecate it.'), _dec(_class = _dec2(_class = _dec3(_class = class Navigation extends _react.Component {
60
- static displayName = "Navigation";
61
- static componentId = 'Navigation';
62
- static allowedProps = _props.allowedProps;
63
- static propTypes = _props.propTypes;
64
- static defaultProps = {
65
- children: null,
66
- defaultMinimized: false,
67
- // TODO we should investigate later if it used or not
68
- onClick: function (_e) {}
69
- };
70
- static Item = _NavigationItem.NavigationItem;
71
- ref = null;
72
-
59
+ let Navigation = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec2 = (0, _testable.testable)(), _dec3 = (0, _deprecated.deprecated)('9.0.0', null, 'No one uses <Navigation>, so we will deprecate it.'), _dec(_class = _dec2(_class = _dec3(_class = (_class2 = class Navigation extends _react.Component {
73
60
  constructor(props) {
74
61
  super(props);
62
+ this.ref = null;
63
+
64
+ this.handleNavToggle = event => {
65
+ if (!this.isControlled()) {
66
+ this.setState(navMinimized);
67
+ }
68
+
69
+ if (typeof this.props.onMinimized === 'function') {
70
+ this.props.onMinimized(event, !this.minimized);
71
+ }
72
+ };
73
+
75
74
  this.state = {
76
75
  minimized: this.isControlled(props) ? !!props.minimized : !!props.defaultMinimized
77
76
  };
@@ -106,16 +105,6 @@ let Navigation = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default
106
105
  return typeof props.minimized === 'boolean';
107
106
  }
108
107
 
109
- handleNavToggle = event => {
110
- if (!this.isControlled()) {
111
- this.setState(navMinimized);
112
- }
113
-
114
- if (typeof this.props.onMinimized === 'function') {
115
- this.props.onMinimized(event, !this.minimized);
116
- }
117
- };
118
-
119
108
  renderChildren() {
120
109
  return _react.Children.map(this.props.children, child => {
121
110
  var _this$props$styles;
@@ -159,7 +148,12 @@ let Navigation = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default
159
148
  })));
160
149
  }
161
150
 
162
- }) || _class) || _class) || _class);
151
+ }, _class2.displayName = "Navigation", _class2.componentId = 'Navigation', _class2.allowedProps = _props.allowedProps, _class2.propTypes = _props.propTypes, _class2.defaultProps = {
152
+ children: null,
153
+ defaultMinimized: false,
154
+ // TODO we should investigate later if it used or not
155
+ onClick: function (_e) {}
156
+ }, _class2.Item = _NavigationItem.NavigationItem, _class2)) || _class) || _class) || _class);
163
157
  exports.Navigation = Navigation;
164
158
  var _default = Navigation;
165
159
  exports.default = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-navigation",
3
- "version": "8.25.1-snapshot-10",
3
+ "version": "8.25.1-snapshot-13",
4
4
  "description": "Main and application level navigational components",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "module": "./es/index.js",
@@ -23,31 +23,31 @@
23
23
  },
24
24
  "license": "MIT",
25
25
  "devDependencies": {
26
- "@instructure/ui-babel-preset": "8.25.1-snapshot-10",
27
- "@instructure/ui-color-utils": "8.25.1-snapshot-10",
28
- "@instructure/ui-test-locator": "8.25.1-snapshot-10",
29
- "@instructure/ui-test-utils": "8.25.1-snapshot-10",
30
- "@instructure/ui-themes": "8.25.1-snapshot-10"
26
+ "@instructure/ui-babel-preset": "8.25.1-snapshot-13",
27
+ "@instructure/ui-color-utils": "8.25.1-snapshot-13",
28
+ "@instructure/ui-test-locator": "8.25.1-snapshot-13",
29
+ "@instructure/ui-test-utils": "8.25.1-snapshot-13",
30
+ "@instructure/ui-themes": "8.25.1-snapshot-13"
31
31
  },
32
32
  "dependencies": {
33
33
  "@babel/runtime": "^7.13.10",
34
- "@instructure/console": "8.25.1-snapshot-10",
35
- "@instructure/debounce": "8.25.1-snapshot-10",
36
- "@instructure/emotion": "8.25.1-snapshot-10",
37
- "@instructure/shared-types": "8.25.1-snapshot-10",
38
- "@instructure/ui-a11y-content": "8.25.1-snapshot-10",
39
- "@instructure/ui-a11y-utils": "8.25.1-snapshot-10",
40
- "@instructure/ui-badge": "8.25.1-snapshot-10",
41
- "@instructure/ui-dom-utils": "8.25.1-snapshot-10",
42
- "@instructure/ui-focusable": "8.25.1-snapshot-10",
43
- "@instructure/ui-icons": "8.25.1-snapshot-10",
44
- "@instructure/ui-menu": "8.25.1-snapshot-10",
45
- "@instructure/ui-prop-types": "8.25.1-snapshot-10",
46
- "@instructure/ui-react-utils": "8.25.1-snapshot-10",
47
- "@instructure/ui-testable": "8.25.1-snapshot-10",
48
- "@instructure/ui-tooltip": "8.25.1-snapshot-10",
49
- "@instructure/ui-utils": "8.25.1-snapshot-10",
50
- "@instructure/ui-view": "8.25.1-snapshot-10",
34
+ "@instructure/console": "8.25.1-snapshot-13",
35
+ "@instructure/debounce": "8.25.1-snapshot-13",
36
+ "@instructure/emotion": "8.25.1-snapshot-13",
37
+ "@instructure/shared-types": "8.25.1-snapshot-13",
38
+ "@instructure/ui-a11y-content": "8.25.1-snapshot-13",
39
+ "@instructure/ui-a11y-utils": "8.25.1-snapshot-13",
40
+ "@instructure/ui-badge": "8.25.1-snapshot-13",
41
+ "@instructure/ui-dom-utils": "8.25.1-snapshot-13",
42
+ "@instructure/ui-focusable": "8.25.1-snapshot-13",
43
+ "@instructure/ui-icons": "8.25.1-snapshot-13",
44
+ "@instructure/ui-menu": "8.25.1-snapshot-13",
45
+ "@instructure/ui-prop-types": "8.25.1-snapshot-13",
46
+ "@instructure/ui-react-utils": "8.25.1-snapshot-13",
47
+ "@instructure/ui-testable": "8.25.1-snapshot-13",
48
+ "@instructure/ui-tooltip": "8.25.1-snapshot-13",
49
+ "@instructure/ui-utils": "8.25.1-snapshot-13",
50
+ "@instructure/ui-view": "8.25.1-snapshot-13",
51
51
  "prop-types": "^15"
52
52
  },
53
53
  "peerDependencies": {