@instructure/ui-truncate-list 11.7.3-snapshot-7 → 11.7.3-snapshot-26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md 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-truncate-list
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, _TruncateList;
1
+ var _dec, _class;
2
2
  /*
3
3
  * The MIT License (MIT)
4
4
  *
@@ -37,93 +37,50 @@ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
37
37
  category: components/utilities
38
38
  ---
39
39
  **/
40
- let TruncateList = (_dec = withStyle(generateStyle, null), _dec(_class = (_TruncateList = class TruncateList extends Component {
40
+ let TruncateList = (_dec = withStyle(generateStyle, null), _dec(_class = class TruncateList extends Component {
41
+ static displayName = "TruncateList";
42
+ static componentId = 'TruncateList';
43
+ static allowedProps = allowedProps;
44
+ static defaultProps = {
45
+ itemSpacing: '0',
46
+ debounce: 300
47
+ };
48
+ ref = null;
49
+ _menuTriggerRef = null;
50
+ _debouncedHandleResize;
51
+ _resizeListener;
52
+ handleRef = el => {
53
+ const {
54
+ elementRef
55
+ } = this.props;
56
+ this.ref = el;
57
+ if (typeof elementRef === 'function') {
58
+ elementRef(el);
59
+ }
60
+ };
41
61
  constructor(props) {
42
62
  super(props);
43
- this.ref = null;
44
- this._menuTriggerRef = null;
45
- this._debouncedHandleResize = void 0;
46
- this._resizeListener = void 0;
47
- this.handleRef = el => {
48
- const elementRef = this.props.elementRef;
49
- this.ref = el;
50
- if (typeof elementRef === 'function') {
51
- elementRef(el);
52
- }
53
- };
54
- this.measureItems = () => {
55
- const _this$props = this.props,
56
- fixMenuTriggerWidth = _this$props.fixMenuTriggerWidth,
57
- itemSpacing = _this$props.itemSpacing;
58
- const itemSpacingPx = px(itemSpacing);
59
- const menuTriggerWidthPx = px(fixMenuTriggerWidth || this.state.menuTriggerWidth);
60
- let visibleItemsCount = 0;
61
- if (this.ref) {
62
- var _style$paddingInlineS, _style$paddingInlineE;
63
- const _getBoundingClientRec = getBoundingClientRect(this.ref),
64
- navWidth = _getBoundingClientRec.width;
65
- const style = getCSSStyleDeclaration(this.ref);
66
- const paddingInlineStart = (_style$paddingInlineS = style === null || style === void 0 ? void 0 : style.paddingInlineStart) !== null && _style$paddingInlineS !== void 0 ? _style$paddingInlineS : '0';
67
- const paddingInlineEnd = (_style$paddingInlineE = style === null || style === void 0 ? void 0 : style.paddingInlineEnd) !== null && _style$paddingInlineE !== void 0 ? _style$paddingInlineE : '0';
68
- const navWidthWithoutPadding = navWidth - px(paddingInlineStart) - px(paddingInlineEnd);
69
- const itemWidths = Array.from(this.ref.getElementsByTagName('li')).map(item => {
70
- const _getBoundingClientRec2 = getBoundingClientRect(item),
71
- width = _getBoundingClientRec2.width;
72
- return width;
73
- });
74
- let currentWidth = 0;
75
- for (let i = 0; i < itemWidths.length; i++) {
76
- currentWidth += itemWidths[i];
77
-
78
- // for the last item we don't need to calculate with the menu trigger
79
- const maxWidth = i === itemWidths.length - 1 ? navWidthWithoutPadding : navWidthWithoutPadding - (menuTriggerWidthPx + itemSpacingPx);
80
- if (currentWidth <= maxWidth) {
81
- visibleItemsCount++;
82
- } else {
83
- break;
84
- }
85
- }
86
- }
87
- return {
88
- visibleItemsCount
89
- };
90
- };
91
- this.handleResize = () => {
92
- this.setState({
93
- isMeasuring: true
94
- }, () => {
95
- const _this$measureItems = this.measureItems(),
96
- visibleItemsCount = _this$measureItems.visibleItemsCount;
97
- if (typeof this.props.onUpdate === 'function') {
98
- this.props.onUpdate({
99
- visibleItemsCount
100
- });
101
- }
102
- this.setState({
103
- isMeasuring: false
104
- });
105
- });
106
- };
107
63
  this.state = {
108
64
  isMeasuring: false,
109
- menuTriggerWidth: void 0
65
+ menuTriggerWidth: undefined
110
66
  };
111
67
  }
112
68
  componentDidMount() {
113
- var _this$props$makeStyle, _this$props2;
114
- (_this$props$makeStyle = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props2);
115
- const _getBoundingClientRec3 = getBoundingClientRect(this.ref),
116
- origWidth = _getBoundingClientRec3.width;
69
+ this.props.makeStyles?.();
70
+ const {
71
+ width: origWidth
72
+ } = getBoundingClientRect(this.ref);
117
73
  this._debouncedHandleResize = debounce(this.handleResize, this.props.debounce, {
118
74
  leading: true,
119
75
  trailing: true
120
76
  });
121
77
  this._resizeListener = new ResizeObserver(entries => {
122
78
  for (const entry of entries) {
123
- const width = entry.contentRect.width;
79
+ const {
80
+ width
81
+ } = entry.contentRect;
124
82
  if (origWidth !== width) {
125
- var _this$_debouncedHandl;
126
- (_this$_debouncedHandl = this._debouncedHandleResize) === null || _this$_debouncedHandl === void 0 ? void 0 : _this$_debouncedHandl.call(this);
83
+ this._debouncedHandleResize?.();
127
84
  }
128
85
  }
129
86
  });
@@ -133,17 +90,14 @@ let TruncateList = (_dec = withStyle(generateStyle, null), _dec(_class = (_Trunc
133
90
  this.setState({
134
91
  menuTriggerWidth
135
92
  }, () => {
136
- var _this$_resizeListener, _this$_debouncedHandl2;
137
- (_this$_resizeListener = this._resizeListener) === null || _this$_resizeListener === void 0 ? void 0 : _this$_resizeListener.observe(this.ref);
138
- (_this$_debouncedHandl2 = this._debouncedHandleResize) === null || _this$_debouncedHandl2 === void 0 ? void 0 : _this$_debouncedHandl2.call(this);
93
+ this._resizeListener?.observe(this.ref);
94
+ this._debouncedHandleResize?.();
139
95
  });
140
96
  }
141
97
  componentDidUpdate(prevProps, prevState) {
142
- var _this$props$makeStyle2, _this$props3;
143
- (_this$props$makeStyle2 = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props3);
98
+ this.props.makeStyles?.();
144
99
  if (prevProps.fixMenuTriggerWidth !== this.props.fixMenuTriggerWidth || prevProps.itemSpacing !== this.props.itemSpacing) {
145
- var _this$_debouncedHandl3;
146
- (_this$_debouncedHandl3 = this._debouncedHandleResize) === null || _this$_debouncedHandl3 === void 0 ? void 0 : _this$_debouncedHandl3.call(this);
100
+ this._debouncedHandleResize?.();
147
101
  }
148
102
  if (this.ref && prevState.isMeasuring && prevState.isMeasuring !== this.state.isMeasuring) {
149
103
  const menuTriggerWidth = this.calcMenuTriggerWidth();
@@ -151,8 +105,7 @@ let TruncateList = (_dec = withStyle(generateStyle, null), _dec(_class = (_Trunc
151
105
  this.setState({
152
106
  menuTriggerWidth
153
107
  }, () => {
154
- var _this$_debouncedHandl4;
155
- (_this$_debouncedHandl4 = this._debouncedHandleResize) === null || _this$_debouncedHandl4 === void 0 ? void 0 : _this$_debouncedHandl4.call(this);
108
+ this._debouncedHandleResize?.();
156
109
  });
157
110
  }
158
111
  }
@@ -169,10 +122,13 @@ let TruncateList = (_dec = withStyle(generateStyle, null), _dec(_class = (_Trunc
169
122
  return Children.toArray(this.props.children);
170
123
  }
171
124
  get visibleChildren() {
172
- const visibleItemsCount = this.props.visibleItemsCount;
173
- const _this$state = this.state,
174
- isMeasuring = _this$state.isMeasuring,
175
- menuTriggerWidth = _this$state.menuTriggerWidth;
125
+ const {
126
+ visibleItemsCount
127
+ } = this.props;
128
+ const {
129
+ isMeasuring,
130
+ menuTriggerWidth
131
+ } = this.state;
176
132
 
177
133
  // for the first render we need to measure the trigger width
178
134
  if (typeof menuTriggerWidth === 'undefined') {
@@ -182,32 +138,97 @@ let TruncateList = (_dec = withStyle(generateStyle, null), _dec(_class = (_Trunc
182
138
  return isMeasuring ? this.childrenArray : visibleChildren;
183
139
  }
184
140
  get hiddenChildren() {
185
- const isMeasuring = this.state.isMeasuring;
141
+ const {
142
+ isMeasuring
143
+ } = this.state;
186
144
  return isMeasuring ? [] : this.childrenArray.splice(this.visibleChildren.length, this.childrenArray.length);
187
145
  }
188
146
  calcMenuTriggerWidth() {
189
- const fixMenuTriggerWidth = this.props.fixMenuTriggerWidth;
147
+ const {
148
+ fixMenuTriggerWidth
149
+ } = this.props;
190
150
  if (!this._menuTriggerRef) {
191
151
  return 0;
192
152
  }
193
153
  if (fixMenuTriggerWidth) {
194
154
  return px(fixMenuTriggerWidth);
195
155
  }
196
- const children = this._menuTriggerRef.children;
156
+ const {
157
+ children
158
+ } = this._menuTriggerRef;
197
159
  let width = 0;
198
160
  Array.from(children).forEach(child => {
199
161
  width += getBoundingClientRect(child).width;
200
162
  });
201
163
  return width;
202
164
  }
165
+ measureItems = () => {
166
+ const {
167
+ fixMenuTriggerWidth,
168
+ itemSpacing
169
+ } = this.props;
170
+ const itemSpacingPx = px(itemSpacing);
171
+ const menuTriggerWidthPx = px(fixMenuTriggerWidth || this.state.menuTriggerWidth);
172
+ let visibleItemsCount = 0;
173
+ if (this.ref) {
174
+ const {
175
+ width: navWidth
176
+ } = getBoundingClientRect(this.ref);
177
+ const style = getCSSStyleDeclaration(this.ref);
178
+ const paddingInlineStart = style?.paddingInlineStart ?? '0';
179
+ const paddingInlineEnd = style?.paddingInlineEnd ?? '0';
180
+ const navWidthWithoutPadding = navWidth - px(paddingInlineStart) - px(paddingInlineEnd);
181
+ const itemWidths = Array.from(this.ref.getElementsByTagName('li')).map(item => {
182
+ const {
183
+ width
184
+ } = getBoundingClientRect(item);
185
+ return width;
186
+ });
187
+ let currentWidth = 0;
188
+ for (let i = 0; i < itemWidths.length; i++) {
189
+ currentWidth += itemWidths[i];
190
+
191
+ // for the last item we don't need to calculate with the menu trigger
192
+ const maxWidth = i === itemWidths.length - 1 ? navWidthWithoutPadding : navWidthWithoutPadding - (menuTriggerWidthPx + itemSpacingPx);
193
+ if (currentWidth <= maxWidth) {
194
+ visibleItemsCount++;
195
+ } else {
196
+ break;
197
+ }
198
+ }
199
+ }
200
+ return {
201
+ visibleItemsCount
202
+ };
203
+ };
204
+ handleResize = () => {
205
+ this.setState({
206
+ isMeasuring: true
207
+ }, () => {
208
+ const {
209
+ visibleItemsCount
210
+ } = this.measureItems();
211
+ if (typeof this.props.onUpdate === 'function') {
212
+ this.props.onUpdate({
213
+ visibleItemsCount
214
+ });
215
+ }
216
+ this.setState({
217
+ isMeasuring: false
218
+ });
219
+ });
220
+ };
203
221
  render() {
204
- const _this$props4 = this.props,
205
- styles = _this$props4.styles,
206
- className = _this$props4.className,
207
- style = _this$props4.style,
208
- renderHiddenItemMenu = _this$props4.renderHiddenItemMenu;
209
- const visibleChildren = this.visibleChildren,
210
- hiddenChildren = this.hiddenChildren;
222
+ const {
223
+ styles,
224
+ className,
225
+ style,
226
+ renderHiddenItemMenu
227
+ } = this.props;
228
+ const {
229
+ visibleChildren,
230
+ hiddenChildren
231
+ } = this;
211
232
  return _jsxs("ul", {
212
233
  ref: this.handleRef,
213
234
  ...omitProps(this.props, allowedProps),
@@ -215,15 +236,15 @@ let TruncateList = (_dec = withStyle(generateStyle, null), _dec(_class = (_Trunc
215
236
  // (e.g. if emotion style is provided, it will be passed as a className)
216
237
  style: style,
217
238
  className: className,
218
- css: styles === null || styles === void 0 ? void 0 : styles.truncateList,
239
+ css: styles?.truncateList,
219
240
  "data-cid": combineDataCid('TruncateList', this.props),
220
241
  children: [visibleChildren.map((child, index) => {
221
242
  return _jsx("li", {
222
- css: styles === null || styles === void 0 ? void 0 : styles.listItem,
243
+ css: styles?.listItem,
223
244
  children: child
224
245
  }, index);
225
246
  }), typeof renderHiddenItemMenu === 'function' && hiddenChildren && hiddenChildren.length > 0 && _jsx("li", {
226
- css: [styles === null || styles === void 0 ? void 0 : styles.listItem, styles === null || styles === void 0 ? void 0 : styles.menuTrigger],
247
+ css: [styles?.listItem, styles?.menuTrigger],
227
248
  ref: e => {
228
249
  this._menuTriggerRef = e;
229
250
  },
@@ -231,9 +252,6 @@ let TruncateList = (_dec = withStyle(generateStyle, null), _dec(_class = (_Trunc
231
252
  }, "menuTrigger")]
232
253
  });
233
254
  }
234
- }, _TruncateList.displayName = "TruncateList", _TruncateList.componentId = 'TruncateList', _TruncateList.allowedProps = allowedProps, _TruncateList.defaultProps = {
235
- itemSpacing: '0',
236
- debounce: 300
237
- }, _TruncateList)) || _class);
255
+ }) || _class);
238
256
  export { TruncateList };
239
257
  export default TruncateList;
@@ -31,8 +31,10 @@
31
31
  * @return {Object} The final style object, which will be used in the component
32
32
  */
33
33
  const generateStyle = (_componentTheme, props) => {
34
- const itemSpacing = props.itemSpacing,
35
- fixMenuTriggerWidth = props.fixMenuTriggerWidth;
34
+ const {
35
+ itemSpacing,
36
+ fixMenuTriggerWidth
37
+ } = props;
36
38
  const listItemStyle = {
37
39
  minWidth: '0.0625rem',
38
40
  flexShrink: 0,
@@ -16,7 +16,7 @@ var _emotion = require("@instructure/emotion");
16
16
  var _styles = _interopRequireDefault(require("./styles"));
17
17
  var _props = require("./props");
18
18
  var _jsxRuntime = require("@emotion/react/jsx-runtime");
19
- var _dec, _class, _TruncateList;
19
+ var _dec, _class;
20
20
  /*
21
21
  * The MIT License (MIT)
22
22
  *
@@ -45,93 +45,50 @@ var _dec, _class, _TruncateList;
45
45
  category: components/utilities
46
46
  ---
47
47
  **/
48
- let TruncateList = exports.TruncateList = (_dec = (0, _emotion.withStyleLegacy)(_styles.default, null), _dec(_class = (_TruncateList = class TruncateList extends _react.Component {
48
+ let TruncateList = exports.TruncateList = (_dec = (0, _emotion.withStyleLegacy)(_styles.default, null), _dec(_class = class TruncateList extends _react.Component {
49
+ static displayName = "TruncateList";
50
+ static componentId = 'TruncateList';
51
+ static allowedProps = _props.allowedProps;
52
+ static defaultProps = {
53
+ itemSpacing: '0',
54
+ debounce: 300
55
+ };
56
+ ref = null;
57
+ _menuTriggerRef = null;
58
+ _debouncedHandleResize;
59
+ _resizeListener;
60
+ handleRef = el => {
61
+ const {
62
+ elementRef
63
+ } = this.props;
64
+ this.ref = el;
65
+ if (typeof elementRef === 'function') {
66
+ elementRef(el);
67
+ }
68
+ };
49
69
  constructor(props) {
50
70
  super(props);
51
- this.ref = null;
52
- this._menuTriggerRef = null;
53
- this._debouncedHandleResize = void 0;
54
- this._resizeListener = void 0;
55
- this.handleRef = el => {
56
- const elementRef = this.props.elementRef;
57
- this.ref = el;
58
- if (typeof elementRef === 'function') {
59
- elementRef(el);
60
- }
61
- };
62
- this.measureItems = () => {
63
- const _this$props = this.props,
64
- fixMenuTriggerWidth = _this$props.fixMenuTriggerWidth,
65
- itemSpacing = _this$props.itemSpacing;
66
- const itemSpacingPx = (0, _px.px)(itemSpacing);
67
- const menuTriggerWidthPx = (0, _px.px)(fixMenuTriggerWidth || this.state.menuTriggerWidth);
68
- let visibleItemsCount = 0;
69
- if (this.ref) {
70
- var _style$paddingInlineS, _style$paddingInlineE;
71
- const _getBoundingClientRec = (0, _getBoundingClientRect.getBoundingClientRect)(this.ref),
72
- navWidth = _getBoundingClientRec.width;
73
- const style = (0, _getCSSStyleDeclaration.getCSSStyleDeclaration)(this.ref);
74
- const paddingInlineStart = (_style$paddingInlineS = style === null || style === void 0 ? void 0 : style.paddingInlineStart) !== null && _style$paddingInlineS !== void 0 ? _style$paddingInlineS : '0';
75
- const paddingInlineEnd = (_style$paddingInlineE = style === null || style === void 0 ? void 0 : style.paddingInlineEnd) !== null && _style$paddingInlineE !== void 0 ? _style$paddingInlineE : '0';
76
- const navWidthWithoutPadding = navWidth - (0, _px.px)(paddingInlineStart) - (0, _px.px)(paddingInlineEnd);
77
- const itemWidths = Array.from(this.ref.getElementsByTagName('li')).map(item => {
78
- const _getBoundingClientRec2 = (0, _getBoundingClientRect.getBoundingClientRect)(item),
79
- width = _getBoundingClientRec2.width;
80
- return width;
81
- });
82
- let currentWidth = 0;
83
- for (let i = 0; i < itemWidths.length; i++) {
84
- currentWidth += itemWidths[i];
85
-
86
- // for the last item we don't need to calculate with the menu trigger
87
- const maxWidth = i === itemWidths.length - 1 ? navWidthWithoutPadding : navWidthWithoutPadding - (menuTriggerWidthPx + itemSpacingPx);
88
- if (currentWidth <= maxWidth) {
89
- visibleItemsCount++;
90
- } else {
91
- break;
92
- }
93
- }
94
- }
95
- return {
96
- visibleItemsCount
97
- };
98
- };
99
- this.handleResize = () => {
100
- this.setState({
101
- isMeasuring: true
102
- }, () => {
103
- const _this$measureItems = this.measureItems(),
104
- visibleItemsCount = _this$measureItems.visibleItemsCount;
105
- if (typeof this.props.onUpdate === 'function') {
106
- this.props.onUpdate({
107
- visibleItemsCount
108
- });
109
- }
110
- this.setState({
111
- isMeasuring: false
112
- });
113
- });
114
- };
115
71
  this.state = {
116
72
  isMeasuring: false,
117
- menuTriggerWidth: void 0
73
+ menuTriggerWidth: undefined
118
74
  };
119
75
  }
120
76
  componentDidMount() {
121
- var _this$props$makeStyle, _this$props2;
122
- (_this$props$makeStyle = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props2);
123
- const _getBoundingClientRec3 = (0, _getBoundingClientRect.getBoundingClientRect)(this.ref),
124
- origWidth = _getBoundingClientRec3.width;
77
+ this.props.makeStyles?.();
78
+ const {
79
+ width: origWidth
80
+ } = (0, _getBoundingClientRect.getBoundingClientRect)(this.ref);
125
81
  this._debouncedHandleResize = (0, _debounce.debounce)(this.handleResize, this.props.debounce, {
126
82
  leading: true,
127
83
  trailing: true
128
84
  });
129
85
  this._resizeListener = new ResizeObserver(entries => {
130
86
  for (const entry of entries) {
131
- const width = entry.contentRect.width;
87
+ const {
88
+ width
89
+ } = entry.contentRect;
132
90
  if (origWidth !== width) {
133
- var _this$_debouncedHandl;
134
- (_this$_debouncedHandl = this._debouncedHandleResize) === null || _this$_debouncedHandl === void 0 ? void 0 : _this$_debouncedHandl.call(this);
91
+ this._debouncedHandleResize?.();
135
92
  }
136
93
  }
137
94
  });
@@ -141,17 +98,14 @@ let TruncateList = exports.TruncateList = (_dec = (0, _emotion.withStyleLegacy)(
141
98
  this.setState({
142
99
  menuTriggerWidth
143
100
  }, () => {
144
- var _this$_resizeListener, _this$_debouncedHandl2;
145
- (_this$_resizeListener = this._resizeListener) === null || _this$_resizeListener === void 0 ? void 0 : _this$_resizeListener.observe(this.ref);
146
- (_this$_debouncedHandl2 = this._debouncedHandleResize) === null || _this$_debouncedHandl2 === void 0 ? void 0 : _this$_debouncedHandl2.call(this);
101
+ this._resizeListener?.observe(this.ref);
102
+ this._debouncedHandleResize?.();
147
103
  });
148
104
  }
149
105
  componentDidUpdate(prevProps, prevState) {
150
- var _this$props$makeStyle2, _this$props3;
151
- (_this$props$makeStyle2 = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props3);
106
+ this.props.makeStyles?.();
152
107
  if (prevProps.fixMenuTriggerWidth !== this.props.fixMenuTriggerWidth || prevProps.itemSpacing !== this.props.itemSpacing) {
153
- var _this$_debouncedHandl3;
154
- (_this$_debouncedHandl3 = this._debouncedHandleResize) === null || _this$_debouncedHandl3 === void 0 ? void 0 : _this$_debouncedHandl3.call(this);
108
+ this._debouncedHandleResize?.();
155
109
  }
156
110
  if (this.ref && prevState.isMeasuring && prevState.isMeasuring !== this.state.isMeasuring) {
157
111
  const menuTriggerWidth = this.calcMenuTriggerWidth();
@@ -159,8 +113,7 @@ let TruncateList = exports.TruncateList = (_dec = (0, _emotion.withStyleLegacy)(
159
113
  this.setState({
160
114
  menuTriggerWidth
161
115
  }, () => {
162
- var _this$_debouncedHandl4;
163
- (_this$_debouncedHandl4 = this._debouncedHandleResize) === null || _this$_debouncedHandl4 === void 0 ? void 0 : _this$_debouncedHandl4.call(this);
116
+ this._debouncedHandleResize?.();
164
117
  });
165
118
  }
166
119
  }
@@ -177,10 +130,13 @@ let TruncateList = exports.TruncateList = (_dec = (0, _emotion.withStyleLegacy)(
177
130
  return _react.Children.toArray(this.props.children);
178
131
  }
179
132
  get visibleChildren() {
180
- const visibleItemsCount = this.props.visibleItemsCount;
181
- const _this$state = this.state,
182
- isMeasuring = _this$state.isMeasuring,
183
- menuTriggerWidth = _this$state.menuTriggerWidth;
133
+ const {
134
+ visibleItemsCount
135
+ } = this.props;
136
+ const {
137
+ isMeasuring,
138
+ menuTriggerWidth
139
+ } = this.state;
184
140
 
185
141
  // for the first render we need to measure the trigger width
186
142
  if (typeof menuTriggerWidth === 'undefined') {
@@ -190,32 +146,97 @@ let TruncateList = exports.TruncateList = (_dec = (0, _emotion.withStyleLegacy)(
190
146
  return isMeasuring ? this.childrenArray : visibleChildren;
191
147
  }
192
148
  get hiddenChildren() {
193
- const isMeasuring = this.state.isMeasuring;
149
+ const {
150
+ isMeasuring
151
+ } = this.state;
194
152
  return isMeasuring ? [] : this.childrenArray.splice(this.visibleChildren.length, this.childrenArray.length);
195
153
  }
196
154
  calcMenuTriggerWidth() {
197
- const fixMenuTriggerWidth = this.props.fixMenuTriggerWidth;
155
+ const {
156
+ fixMenuTriggerWidth
157
+ } = this.props;
198
158
  if (!this._menuTriggerRef) {
199
159
  return 0;
200
160
  }
201
161
  if (fixMenuTriggerWidth) {
202
162
  return (0, _px.px)(fixMenuTriggerWidth);
203
163
  }
204
- const children = this._menuTriggerRef.children;
164
+ const {
165
+ children
166
+ } = this._menuTriggerRef;
205
167
  let width = 0;
206
168
  Array.from(children).forEach(child => {
207
169
  width += (0, _getBoundingClientRect.getBoundingClientRect)(child).width;
208
170
  });
209
171
  return width;
210
172
  }
173
+ measureItems = () => {
174
+ const {
175
+ fixMenuTriggerWidth,
176
+ itemSpacing
177
+ } = this.props;
178
+ const itemSpacingPx = (0, _px.px)(itemSpacing);
179
+ const menuTriggerWidthPx = (0, _px.px)(fixMenuTriggerWidth || this.state.menuTriggerWidth);
180
+ let visibleItemsCount = 0;
181
+ if (this.ref) {
182
+ const {
183
+ width: navWidth
184
+ } = (0, _getBoundingClientRect.getBoundingClientRect)(this.ref);
185
+ const style = (0, _getCSSStyleDeclaration.getCSSStyleDeclaration)(this.ref);
186
+ const paddingInlineStart = style?.paddingInlineStart ?? '0';
187
+ const paddingInlineEnd = style?.paddingInlineEnd ?? '0';
188
+ const navWidthWithoutPadding = navWidth - (0, _px.px)(paddingInlineStart) - (0, _px.px)(paddingInlineEnd);
189
+ const itemWidths = Array.from(this.ref.getElementsByTagName('li')).map(item => {
190
+ const {
191
+ width
192
+ } = (0, _getBoundingClientRect.getBoundingClientRect)(item);
193
+ return width;
194
+ });
195
+ let currentWidth = 0;
196
+ for (let i = 0; i < itemWidths.length; i++) {
197
+ currentWidth += itemWidths[i];
198
+
199
+ // for the last item we don't need to calculate with the menu trigger
200
+ const maxWidth = i === itemWidths.length - 1 ? navWidthWithoutPadding : navWidthWithoutPadding - (menuTriggerWidthPx + itemSpacingPx);
201
+ if (currentWidth <= maxWidth) {
202
+ visibleItemsCount++;
203
+ } else {
204
+ break;
205
+ }
206
+ }
207
+ }
208
+ return {
209
+ visibleItemsCount
210
+ };
211
+ };
212
+ handleResize = () => {
213
+ this.setState({
214
+ isMeasuring: true
215
+ }, () => {
216
+ const {
217
+ visibleItemsCount
218
+ } = this.measureItems();
219
+ if (typeof this.props.onUpdate === 'function') {
220
+ this.props.onUpdate({
221
+ visibleItemsCount
222
+ });
223
+ }
224
+ this.setState({
225
+ isMeasuring: false
226
+ });
227
+ });
228
+ };
211
229
  render() {
212
- const _this$props4 = this.props,
213
- styles = _this$props4.styles,
214
- className = _this$props4.className,
215
- style = _this$props4.style,
216
- renderHiddenItemMenu = _this$props4.renderHiddenItemMenu;
217
- const visibleChildren = this.visibleChildren,
218
- hiddenChildren = this.hiddenChildren;
230
+ const {
231
+ styles,
232
+ className,
233
+ style,
234
+ renderHiddenItemMenu
235
+ } = this.props;
236
+ const {
237
+ visibleChildren,
238
+ hiddenChildren
239
+ } = this;
219
240
  return (0, _jsxRuntime.jsxs)("ul", {
220
241
  ref: this.handleRef,
221
242
  ...(0, _omitProps.omitProps)(this.props, _props.allowedProps),
@@ -223,15 +244,15 @@ let TruncateList = exports.TruncateList = (_dec = (0, _emotion.withStyleLegacy)(
223
244
  // (e.g. if emotion style is provided, it will be passed as a className)
224
245
  style: style,
225
246
  className: className,
226
- css: styles === null || styles === void 0 ? void 0 : styles.truncateList,
247
+ css: styles?.truncateList,
227
248
  "data-cid": (0, _combineDataCid.combineDataCid)('TruncateList', this.props),
228
249
  children: [visibleChildren.map((child, index) => {
229
250
  return (0, _jsxRuntime.jsx)("li", {
230
- css: styles === null || styles === void 0 ? void 0 : styles.listItem,
251
+ css: styles?.listItem,
231
252
  children: child
232
253
  }, index);
233
254
  }), typeof renderHiddenItemMenu === 'function' && hiddenChildren && hiddenChildren.length > 0 && (0, _jsxRuntime.jsx)("li", {
234
- css: [styles === null || styles === void 0 ? void 0 : styles.listItem, styles === null || styles === void 0 ? void 0 : styles.menuTrigger],
255
+ css: [styles?.listItem, styles?.menuTrigger],
235
256
  ref: e => {
236
257
  this._menuTriggerRef = e;
237
258
  },
@@ -239,8 +260,5 @@ let TruncateList = exports.TruncateList = (_dec = (0, _emotion.withStyleLegacy)(
239
260
  }, "menuTrigger")]
240
261
  });
241
262
  }
242
- }, _TruncateList.displayName = "TruncateList", _TruncateList.componentId = 'TruncateList', _TruncateList.allowedProps = _props.allowedProps, _TruncateList.defaultProps = {
243
- itemSpacing: '0',
244
- debounce: 300
245
- }, _TruncateList)) || _class);
263
+ }) || _class);
246
264
  var _default = exports.default = TruncateList;
@@ -37,8 +37,10 @@ exports.default = void 0;
37
37
  * @return {Object} The final style object, which will be used in the component
38
38
  */
39
39
  const generateStyle = (_componentTheme, props) => {
40
- const itemSpacing = props.itemSpacing,
41
- fixMenuTriggerWidth = props.fixMenuTriggerWidth;
40
+ const {
41
+ itemSpacing,
42
+ fixMenuTriggerWidth
43
+ } = props;
42
44
  const listItemStyle = {
43
45
  minWidth: '0.0625rem',
44
46
  flexShrink: 0,