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

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-15](https://github.com/instructure/instructure-ui/compare/v8.25.0...v8.25.1-snapshot-15) (2022-06-23)
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;