@momentum-design/components 0.100.0 → 0.100.2

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 (91) hide show
  1. package/dist/browser/index.js +1440 -1210
  2. package/dist/browser/index.js.map +4 -4
  3. package/dist/components/accordion/accordion.component.d.ts +74 -0
  4. package/dist/components/accordion/accordion.component.js +128 -0
  5. package/dist/components/accordion/accordion.constants.d.ts +2 -0
  6. package/dist/components/accordion/accordion.constants.js +3 -0
  7. package/dist/components/accordion/accordion.styles.d.ts +2 -0
  8. package/dist/components/accordion/accordion.styles.js +17 -0
  9. package/dist/components/accordion/index.d.ts +10 -0
  10. package/dist/components/accordion/index.js +7 -0
  11. package/dist/components/accordionbutton/accordionbutton.component.d.ts +119 -0
  12. package/dist/components/accordionbutton/accordionbutton.component.js +238 -0
  13. package/dist/components/accordionbutton/accordionbutton.constants.d.ts +17 -0
  14. package/dist/components/accordionbutton/accordionbutton.constants.js +19 -0
  15. package/dist/components/accordionbutton/accordionbutton.styles.d.ts +2 -0
  16. package/dist/components/accordionbutton/accordionbutton.styles.js +121 -0
  17. package/dist/components/accordionbutton/accordionbutton.types.d.ts +8 -0
  18. package/dist/components/accordionbutton/accordionbutton.types.js +1 -0
  19. package/dist/components/accordionbutton/index.d.ts +10 -0
  20. package/dist/components/accordionbutton/index.js +7 -0
  21. package/dist/components/accordiongroup/accordiongroup.component.d.ts +71 -0
  22. package/dist/components/accordiongroup/accordiongroup.component.js +132 -0
  23. package/dist/components/accordiongroup/accordiongroup.constants.d.ts +15 -0
  24. package/dist/components/accordiongroup/accordiongroup.constants.js +16 -0
  25. package/dist/components/accordiongroup/accordiongroup.styles.d.ts +2 -0
  26. package/dist/components/accordiongroup/accordiongroup.styles.js +48 -0
  27. package/dist/components/accordiongroup/accordiongroup.types.d.ts +5 -0
  28. package/dist/components/accordiongroup/accordiongroup.types.js +1 -0
  29. package/dist/components/accordiongroup/index.d.ts +7 -0
  30. package/dist/components/accordiongroup/index.js +4 -0
  31. package/dist/components/animation/animation.component.d.ts +1 -0
  32. package/dist/components/animation/animation.component.js +9 -0
  33. package/dist/components/cardcheckbox/cardcheckbox.component.js +3 -3
  34. package/dist/components/cardradio/cardradio.component.js +3 -3
  35. package/dist/components/dialog/dialog.component.js +5 -0
  36. package/dist/components/formfieldwrapper/formfieldwrapper.styles.js +1 -0
  37. package/dist/components/icon/icon.component.d.ts +2 -1
  38. package/dist/components/icon/icon.component.js +9 -1
  39. package/dist/components/linksimple/linksimple.component.js +11 -11
  40. package/dist/components/listitem/listitem.component.js +6 -6
  41. package/dist/components/listitem/listitem.events.js +3 -1
  42. package/dist/components/menubar/menubar.component.d.ts +9 -0
  43. package/dist/components/menubar/menubar.component.js +38 -4
  44. package/dist/components/menuitem/menuitem.component.js +1 -1
  45. package/dist/components/menuitemcheckbox/menuitemcheckbox.component.js +12 -12
  46. package/dist/components/menuitemradio/menuitemradio.component.js +13 -13
  47. package/dist/components/menupopover/menupopover.component.d.ts +30 -12
  48. package/dist/components/menupopover/menupopover.component.js +231 -179
  49. package/dist/components/menupopover/menupopover.utils.d.ts +2 -2
  50. package/dist/components/menupopover/menupopover.utils.js +2 -2
  51. package/dist/components/navmenuitem/navmenuitem.component.js +1 -1
  52. package/dist/components/popover/popover.component.d.ts +29 -9
  53. package/dist/components/popover/popover.component.js +277 -212
  54. package/dist/components/popover/popover.constants.d.ts +1 -0
  55. package/dist/components/popover/popover.constants.js +1 -0
  56. package/dist/components/popover/popover.types.d.ts +19 -6
  57. package/dist/components/popover/popover.utils.d.ts +7 -2
  58. package/dist/components/popover/popover.utils.js +19 -8
  59. package/dist/components/select/select.component.js +2 -0
  60. package/dist/components/select/select.styles.js +1 -1
  61. package/dist/components/select/select.types.d.ts +5 -1
  62. package/dist/components/sidenavigation/sidenavigation.component.js +1 -1
  63. package/dist/components/spinner/spinner.component.d.ts +1 -1
  64. package/dist/components/spinner/spinner.component.js +1 -1
  65. package/dist/components/tablist/tablist.component.d.ts +1 -0
  66. package/dist/components/tablist/tablist.component.js +284 -273
  67. package/dist/components/textarea/textarea.component.d.ts +2 -2
  68. package/dist/components/textarea/textarea.component.js +2 -2
  69. package/dist/components/tooltip/tooltip.component.d.ts +1 -1
  70. package/dist/components/tooltip/tooltip.component.js +14 -15
  71. package/dist/custom-elements.json +7364 -6056
  72. package/dist/index.d.ts +10 -7
  73. package/dist/index.js +10 -7
  74. package/dist/react/accordion/index.d.ts +53 -0
  75. package/dist/react/accordion/index.js +61 -0
  76. package/dist/react/accordionbutton/index.d.ts +50 -0
  77. package/dist/react/accordionbutton/index.js +58 -0
  78. package/dist/react/accordiongroup/index.d.ts +30 -0
  79. package/dist/react/accordiongroup/index.js +39 -0
  80. package/dist/react/coachmark/index.d.ts +12 -4
  81. package/dist/react/index.d.ts +9 -6
  82. package/dist/react/index.js +9 -6
  83. package/dist/react/menupopover/index.d.ts +12 -4
  84. package/dist/react/popover/index.d.ts +12 -4
  85. package/dist/react/toggletip/index.d.ts +12 -4
  86. package/dist/react/tooltip/index.d.ts +12 -4
  87. package/dist/utils/keys.d.ts +1 -0
  88. package/dist/utils/keys.js +1 -0
  89. package/dist/utils/roles.d.ts +2 -0
  90. package/dist/utils/roles.js +2 -0
  91. package/package.json +2 -2
@@ -61,6 +61,13 @@ import { getFirstTab, getLastTab, getNextTab, getPreviousTab, findTab, getActive
61
61
  * @cssproperty --mdc-tablist-arrow-button-margin - Margin value for the arrow button
62
62
  */
63
63
  class TabList extends Component {
64
+ /**
65
+ * @internal
66
+ */
67
+ isRtl() {
68
+ var _a;
69
+ return (((_a = document.querySelector('html')) === null || _a === void 0 ? void 0 : _a.getAttribute('dir')) === 'rtl' || window.getComputedStyle(this).direction === 'rtl');
70
+ }
64
71
  constructor() {
65
72
  super();
66
73
  /**
@@ -77,277 +84,7 @@ class TabList extends Component {
77
84
  * @internal
78
85
  */
79
86
  this.showBackwardArrowButton = false;
80
- /**
81
- * @internal
82
- */
83
- this.isRtl = () => { var _a; return ((_a = document.querySelector('html')) === null || _a === void 0 ? void 0 : _a.getAttribute('dir')) === 'rtl' || window.getComputedStyle(this).direction === 'rtl'; };
84
- /**
85
- * Dispatch the change event.
86
- *
87
- * @internal
88
- *
89
- * @param newTab - the new tab that is active.
90
- */
91
- this.fireTabChangeEvent = (newTab) => {
92
- const event = new CustomEvent('change', {
93
- detail: { tabId: newTab.tabId },
94
- });
95
- this.dispatchEvent(event);
96
- };
97
- /**
98
- * When the tablist receives focus, then focus the active tab.
99
- *
100
- * @internal
101
- *
102
- * @param event - Focus event.
103
- */
104
- this.handleFocus = async (event) => {
105
- /**
106
- * If the element losing focus is a tab, do nothing.
107
- * This also covers the case when previous focus was on a tab that belongs to another tablist.
108
- */
109
- if (event.relatedTarget instanceof Tab) {
110
- return;
111
- }
112
- /**
113
- * If the element gaining focus is not a tab, do nothing.
114
- */
115
- if (!(event.target instanceof Tab)) {
116
- return;
117
- }
118
- const activeTab = getActiveTab(this.tabs || []);
119
- if (!(activeTab instanceof Tab)) {
120
- return;
121
- }
122
- await this.focusTab(activeTab);
123
- };
124
- /**
125
- * Prevent the mousedown event from triggering a focus event before the click event.
126
- *
127
- * @internal
128
- *
129
- * @param event - Mouse event.
130
- */
131
- this.handleMousedown = (event) => {
132
- if (!(event.target instanceof Tab)) {
133
- return;
134
- }
135
- event.preventDefault();
136
- };
137
- /**
138
- * Handle the tab active change event fired from the nested tab.
139
- *
140
- * @internal
141
- *
142
- * @param event - Custom Event fired from the nested tab.
143
- */
144
- this.handleNestedTabActiveChange = async (event) => {
145
- event.stopPropagation();
146
- const tab = event.target;
147
- if (!(tab instanceof Tab)) {
148
- return;
149
- }
150
- this.setActiveTab(tab);
151
- await this.focusTab(tab);
152
- this.activeTabId = tab.tabId;
153
- };
154
- /**
155
- * Resets all tabs' tabindex to -1 and sets the tabindex of the
156
- * given tab to 0.
157
- * This is used when navigating the tabs via keyboard.
158
- *
159
- * @internal
160
- *
161
- * @param tabId - The id of the new active tab in the tabs.
162
- */
163
- this.resetTabIndexAndSetNewTabIndex = (newTab) => {
164
- var _a;
165
- (_a = this.tabs) === null || _a === void 0 ? void 0 : _a.forEach(tab => {
166
- tab.setAttribute('tabindex', tab === newTab ? '0' : '-1');
167
- });
168
- };
169
- /**
170
- * Removes active attribute from all tabs and sets active on the new tab.
171
- *
172
- * @internal
173
- *
174
- * @param tabId - The id of the new active tab.
175
- */
176
- this.setActiveTab = (newTab) => {
177
- var _a;
178
- (_a = this.tabs) === null || _a === void 0 ? void 0 : _a.forEach(tab => {
179
- if (tab === newTab) {
180
- tab.setAttribute('active', '');
181
- }
182
- else {
183
- tab.removeAttribute('active');
184
- }
185
- });
186
- };
187
- /**
188
- * Set focus on the new tab, then scroll it into view.
189
- *
190
- * @internal
191
- *
192
- * @param tab - Tab to set focus on.
193
- */
194
- this.focusTab = async (tab) => {
195
- if (!(tab instanceof Tab)) {
196
- return;
197
- }
198
- if (tab !== (document === null || document === void 0 ? void 0 : document.activeElement)) {
199
- this.resetTabIndexAndSetNewTabIndex(tab);
200
- tab.focus();
201
- }
202
- await this.handleArrowButtonVisibility();
203
- };
204
- /**
205
- * Handle the keydown event. The arrow keys, Home, End, Enter, and Space keys are supported.
206
- *
207
- * @internal
208
- *
209
- * @param event - HTML Keyboard Event.
210
- */
211
- this.handleKeydown = async (event) => {
212
- const tab = event.target;
213
- if (!(tab instanceof Tab)) {
214
- return;
215
- }
216
- if (!this.tabs) {
217
- return;
218
- }
219
- const previousTab = getPreviousTab(this.tabs, tab);
220
- const nextTab = getNextTab(this.tabs, tab);
221
- const firstTab = getFirstTab(this.tabs);
222
- const lastTab = getLastTab(this.tabs);
223
- switch (event.code) {
224
- case KEYCODES.LEFT:
225
- event.preventDefault();
226
- await this.focusTab(!this.isRtl() ? previousTab : nextTab);
227
- break;
228
- case KEYCODES.RIGHT:
229
- event.preventDefault();
230
- await this.focusTab(!this.isRtl() ? nextTab : previousTab);
231
- break;
232
- case KEYCODES.HOME:
233
- await this.focusTab(firstTab);
234
- break;
235
- case KEYCODES.END:
236
- await this.focusTab(lastTab);
237
- break;
238
- default:
239
- }
240
- };
241
- /**
242
- * Should the arrow button be shown.
243
- *
244
- * @internal
245
- *
246
- * @param direction - The direction of the arrow button.
247
- */
248
- this.shouldShowArrowButton = (direction) => direction === ARROW_BUTTON_DIRECTION.FORWARD ? this.showForwardArrowButton : this.showBackwardArrowButton;
249
- /**
250
- * If an arrow button is in focus and it gets removed, switch focus to the opposite arrow button.
251
- * If both arrow buttons are removed, switch focus to the active tab.
252
- *
253
- * @internal
254
- */
255
- this.switchFocus = async () => {
256
- var _a, _b;
257
- await this.updateComplete;
258
- if (!this.showBackwardArrowButton && !this.showForwardArrowButton) {
259
- (_a = getActiveTab(this.tabs || [])) === null || _a === void 0 ? void 0 : _a.focus();
260
- }
261
- else if ((this.showBackwardArrowButton && !this.showForwardArrowButton) ||
262
- (this.showForwardArrowButton && !this.showBackwardArrowButton)) {
263
- (_b = this.notFocusedArrowButton) === null || _b === void 0 ? void 0 : _b.focus();
264
- }
265
- };
266
- /**
267
- * Show or hide the arrow buttons based on the position of the tabs
268
- * corresponding to the tab list.
269
- *
270
- * @internal
271
- */
272
- this.handleArrowButtonVisibility = async () => {
273
- var _a, _b, _c;
274
- if (!this.tabs) {
275
- return;
276
- }
277
- if (!this.tabsContainer) {
278
- return;
279
- }
280
- let isArrowButtonFocused = false;
281
- /**
282
- * If the active element is an arrow button,
283
- * then run the switchFocus function after setting the arrow button visibility.
284
- */
285
- if (((_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.activeElement) instanceof Button) {
286
- isArrowButtonFocused = true;
287
- }
288
- const firstTab = getFirstTab(this.tabs);
289
- const lastTab = getLastTab(this.tabs);
290
- const firstTabLeftEdgePosition = firstTab.getBoundingClientRect().left;
291
- const tabListLeftEdgePosition = (_b = this.tabsContainer) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect().left;
292
- const lastTabRightEdgePosition = lastTab.getBoundingClientRect().right;
293
- const tabListRightEdgePosition = (_c = this.tabsContainer) === null || _c === void 0 ? void 0 : _c.getBoundingClientRect().right;
294
- // when RTL, the edges are reversed
295
- const firstTabRightEdgePosition = firstTab.getBoundingClientRect().right;
296
- const lastTabLeftEdgePosition = lastTab.getBoundingClientRect().left;
297
- if (!this.isRtl()) {
298
- if (firstTabLeftEdgePosition <= tabListLeftEdgePosition) {
299
- this.showBackwardArrowButton = true;
300
- }
301
- else {
302
- this.showBackwardArrowButton = false;
303
- }
304
- if (lastTabRightEdgePosition > tabListRightEdgePosition) {
305
- this.showForwardArrowButton = true;
306
- }
307
- else {
308
- this.showForwardArrowButton = false;
309
- }
310
- if (isArrowButtonFocused) {
311
- await this.switchFocus();
312
- }
313
- return;
314
- }
315
- if (firstTabRightEdgePosition > tabListRightEdgePosition) {
316
- this.showBackwardArrowButton = true;
317
- }
318
- else {
319
- this.showBackwardArrowButton = false;
320
- }
321
- if (lastTabLeftEdgePosition < tabListLeftEdgePosition) {
322
- this.showForwardArrowButton = true;
323
- }
324
- else {
325
- this.showForwardArrowButton = false;
326
- }
327
- if (isArrowButtonFocused) {
328
- await this.switchFocus();
329
- }
330
- };
331
- /**
332
- * Scroll tabs forward or backward.
333
- *
334
- * @internal
335
- *
336
- * @param direction - The direction to scroll the tabs in.
337
- */
338
- this.scrollTabs = async (direction) => {
339
- var _a;
340
- const forwardMultiplier = !this.isRtl() ? 1 : -1;
341
- const backwardMultiplier = !this.isRtl() ? -1 : 1;
342
- (_a = this.tabsContainer) === null || _a === void 0 ? void 0 : _a.scrollBy({
343
- left: this.tabsContainer.clientWidth *
344
- (direction === ARROW_BUTTON_DIRECTION.FORWARD ? forwardMultiplier : backwardMultiplier),
345
- // @ts-ignore : https://github.com/Microsoft/TypeScript/issues/28755
346
- behavior: 'instant',
347
- });
348
- await this.handleArrowButtonVisibility();
349
- };
350
- this.addEventListener('keydown', this.handleKeydown);
87
+ this.addEventListener('keydown', this.handleKeydown.bind(this));
351
88
  // Reason for assertion below: https://github.com/microsoft/TypeScript/issues/28357
352
89
  this.addEventListener('activechange', this.handleNestedTabActiveChange);
353
90
  }
@@ -386,8 +123,14 @@ class TabList extends Component {
386
123
  if (!this.activeTabId) {
387
124
  this.activeTabId = (_a = getFirstTab(this.tabs)) === null || _a === void 0 ? void 0 : _a.tabId;
388
125
  }
389
- (_b = this.tabsContainer) === null || _b === void 0 ? void 0 : _b.addEventListener('focusin', this.handleFocus);
390
- (_c = this.tabsContainer) === null || _c === void 0 ? void 0 : _c.addEventListener('mousedown', this.handleMousedown);
126
+ (_b = this.tabsContainer) === null || _b === void 0 ? void 0 : _b.addEventListener('focusin', this.handleFocus.bind(this));
127
+ (_c = this.tabsContainer) === null || _c === void 0 ? void 0 : _c.addEventListener('mousedown', this.handleMousedown.bind(this));
128
+ }
129
+ disconnectedCallback() {
130
+ var _a, _b;
131
+ super.disconnectedCallback();
132
+ (_a = this.tabsContainer) === null || _a === void 0 ? void 0 : _a.removeEventListener('focusin', this.handleFocus);
133
+ (_b = this.tabsContainer) === null || _b === void 0 ? void 0 : _b.removeEventListener('mousedown', this.handleMousedown);
391
134
  }
392
135
  /**
393
136
  * Observe the tablist element for changes in the activeTabId attribute.
@@ -426,6 +169,274 @@ class TabList extends Component {
426
169
  }
427
170
  }
428
171
  }
172
+ /**
173
+ * Dispatch the change event.
174
+ *
175
+ * @internal
176
+ *
177
+ * @param newTab - the new tab that is active.
178
+ */
179
+ fireTabChangeEvent(newTab) {
180
+ const event = new CustomEvent('change', {
181
+ detail: { tabId: newTab.tabId },
182
+ });
183
+ this.dispatchEvent(event);
184
+ }
185
+ /**
186
+ * When the tablist receives focus, then focus the active tab.
187
+ *
188
+ * @internal
189
+ *
190
+ * @param event - Focus event.
191
+ */
192
+ async handleFocus(event) {
193
+ /**
194
+ * If the element losing focus is a tab, do nothing.
195
+ * This also covers the case when previous focus was on a tab that belongs to another tablist.
196
+ */
197
+ if (event.relatedTarget instanceof Tab) {
198
+ return;
199
+ }
200
+ /**
201
+ * If the element gaining focus is not a tab, do nothing.
202
+ */
203
+ if (!(event.target instanceof Tab)) {
204
+ return;
205
+ }
206
+ const activeTab = getActiveTab(this.tabs || []);
207
+ if (!(activeTab instanceof Tab)) {
208
+ return;
209
+ }
210
+ await this.focusTab(activeTab);
211
+ }
212
+ /**
213
+ * Prevent the mousedown event from triggering a focus event before the click event.
214
+ *
215
+ * @internal
216
+ *
217
+ * @param event - Mouse event.
218
+ */
219
+ handleMousedown(event) {
220
+ if (!(event.target instanceof Tab)) {
221
+ return;
222
+ }
223
+ event.preventDefault();
224
+ }
225
+ /**
226
+ * Handle the tab active change event fired from the nested tab.
227
+ *
228
+ * @internal
229
+ *
230
+ * @param event - Custom Event fired from the nested tab.
231
+ */
232
+ async handleNestedTabActiveChange(event) {
233
+ event.stopPropagation();
234
+ const tab = event.target;
235
+ if (!(tab instanceof Tab)) {
236
+ return;
237
+ }
238
+ this.setActiveTab(tab);
239
+ await this.focusTab(tab);
240
+ this.activeTabId = tab.tabId;
241
+ }
242
+ /**
243
+ * Resets all tabs' tabindex to -1 and sets the tabindex of the
244
+ * given tab to 0.
245
+ * This is used when navigating the tabs via keyboard.
246
+ *
247
+ * @internal
248
+ *
249
+ * @param tabId - The id of the new active tab in the tabs.
250
+ */
251
+ resetTabIndexAndSetNewTabIndex(newTab) {
252
+ var _a;
253
+ (_a = this.tabs) === null || _a === void 0 ? void 0 : _a.forEach(tab => {
254
+ tab.setAttribute('tabindex', tab === newTab ? '0' : '-1');
255
+ });
256
+ }
257
+ /**
258
+ * Removes active attribute from all tabs and sets active on the new tab.
259
+ *
260
+ * @internal
261
+ *
262
+ * @param tabId - The id of the new active tab.
263
+ */
264
+ setActiveTab(newTab) {
265
+ var _a;
266
+ (_a = this.tabs) === null || _a === void 0 ? void 0 : _a.forEach(tab => {
267
+ if (tab === newTab) {
268
+ tab.setAttribute('active', '');
269
+ }
270
+ else {
271
+ tab.removeAttribute('active');
272
+ }
273
+ });
274
+ }
275
+ /**
276
+ * Set focus on the new tab, then scroll it into view.
277
+ *
278
+ * @internal
279
+ *
280
+ * @param tab - Tab to set focus on.
281
+ */
282
+ async focusTab(tab) {
283
+ if (!(tab instanceof Tab)) {
284
+ return;
285
+ }
286
+ if (tab !== (document === null || document === void 0 ? void 0 : document.activeElement)) {
287
+ this.resetTabIndexAndSetNewTabIndex(tab);
288
+ tab.focus();
289
+ }
290
+ await this.handleArrowButtonVisibility();
291
+ }
292
+ /**
293
+ * Handle the keydown event. The arrow keys, Home, End, Enter, and Space keys are supported.
294
+ *
295
+ * @internal
296
+ *
297
+ * @param event - HTML Keyboard Event.
298
+ */
299
+ async handleKeydown(event) {
300
+ const tab = event.target;
301
+ if (!(tab instanceof Tab)) {
302
+ return;
303
+ }
304
+ if (!this.tabs) {
305
+ return;
306
+ }
307
+ const previousTab = getPreviousTab(this.tabs, tab);
308
+ const nextTab = getNextTab(this.tabs, tab);
309
+ const firstTab = getFirstTab(this.tabs);
310
+ const lastTab = getLastTab(this.tabs);
311
+ switch (event.code) {
312
+ case KEYCODES.LEFT:
313
+ event.preventDefault();
314
+ await this.focusTab(!this.isRtl() ? previousTab : nextTab);
315
+ break;
316
+ case KEYCODES.RIGHT:
317
+ event.preventDefault();
318
+ await this.focusTab(!this.isRtl() ? nextTab : previousTab);
319
+ break;
320
+ case KEYCODES.HOME:
321
+ await this.focusTab(firstTab);
322
+ break;
323
+ case KEYCODES.END:
324
+ await this.focusTab(lastTab);
325
+ break;
326
+ default:
327
+ }
328
+ }
329
+ /**
330
+ * Should the arrow button be shown.
331
+ *
332
+ * @internal
333
+ *
334
+ * @param direction - The direction of the arrow button.
335
+ */
336
+ shouldShowArrowButton(direction) {
337
+ return direction === ARROW_BUTTON_DIRECTION.FORWARD ? this.showForwardArrowButton : this.showBackwardArrowButton;
338
+ }
339
+ /**
340
+ * If an arrow button is in focus and it gets removed, switch focus to the opposite arrow button.
341
+ * If both arrow buttons are removed, switch focus to the active tab.
342
+ *
343
+ * @internal
344
+ */
345
+ async switchFocus() {
346
+ var _a, _b;
347
+ await this.updateComplete;
348
+ if (!this.showBackwardArrowButton && !this.showForwardArrowButton) {
349
+ (_a = getActiveTab(this.tabs || [])) === null || _a === void 0 ? void 0 : _a.focus();
350
+ }
351
+ else if ((this.showBackwardArrowButton && !this.showForwardArrowButton) ||
352
+ (this.showForwardArrowButton && !this.showBackwardArrowButton)) {
353
+ (_b = this.notFocusedArrowButton) === null || _b === void 0 ? void 0 : _b.focus();
354
+ }
355
+ }
356
+ /**
357
+ * Show or hide the arrow buttons based on the position of the tabs
358
+ * corresponding to the tab list.
359
+ *
360
+ * @internal
361
+ */
362
+ async handleArrowButtonVisibility() {
363
+ var _a, _b, _c;
364
+ if (!this.tabs) {
365
+ return;
366
+ }
367
+ if (!this.tabsContainer) {
368
+ return;
369
+ }
370
+ let isArrowButtonFocused = false;
371
+ /**
372
+ * If the active element is an arrow button,
373
+ * then run the switchFocus function after setting the arrow button visibility.
374
+ */
375
+ if (((_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.activeElement) instanceof Button) {
376
+ isArrowButtonFocused = true;
377
+ }
378
+ const firstTab = getFirstTab(this.tabs);
379
+ const lastTab = getLastTab(this.tabs);
380
+ const firstTabLeftEdgePosition = firstTab.getBoundingClientRect().left;
381
+ const tabListLeftEdgePosition = (_b = this.tabsContainer) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect().left;
382
+ const lastTabRightEdgePosition = lastTab.getBoundingClientRect().right;
383
+ const tabListRightEdgePosition = (_c = this.tabsContainer) === null || _c === void 0 ? void 0 : _c.getBoundingClientRect().right;
384
+ // when RTL, the edges are reversed
385
+ const firstTabRightEdgePosition = firstTab.getBoundingClientRect().right;
386
+ const lastTabLeftEdgePosition = lastTab.getBoundingClientRect().left;
387
+ if (!this.isRtl()) {
388
+ if (firstTabLeftEdgePosition <= tabListLeftEdgePosition) {
389
+ this.showBackwardArrowButton = true;
390
+ }
391
+ else {
392
+ this.showBackwardArrowButton = false;
393
+ }
394
+ if (lastTabRightEdgePosition > tabListRightEdgePosition) {
395
+ this.showForwardArrowButton = true;
396
+ }
397
+ else {
398
+ this.showForwardArrowButton = false;
399
+ }
400
+ if (isArrowButtonFocused) {
401
+ await this.switchFocus();
402
+ }
403
+ return;
404
+ }
405
+ if (firstTabRightEdgePosition > tabListRightEdgePosition) {
406
+ this.showBackwardArrowButton = true;
407
+ }
408
+ else {
409
+ this.showBackwardArrowButton = false;
410
+ }
411
+ if (lastTabLeftEdgePosition < tabListLeftEdgePosition) {
412
+ this.showForwardArrowButton = true;
413
+ }
414
+ else {
415
+ this.showForwardArrowButton = false;
416
+ }
417
+ if (isArrowButtonFocused) {
418
+ await this.switchFocus();
419
+ }
420
+ }
421
+ /**
422
+ * Scroll tabs forward or backward.
423
+ *
424
+ * @internal
425
+ *
426
+ * @param direction - The direction to scroll the tabs in.
427
+ */
428
+ async scrollTabs(direction) {
429
+ var _a;
430
+ const forwardMultiplier = !this.isRtl() ? 1 : -1;
431
+ const backwardMultiplier = !this.isRtl() ? -1 : 1;
432
+ (_a = this.tabsContainer) === null || _a === void 0 ? void 0 : _a.scrollBy({
433
+ left: this.tabsContainer.clientWidth *
434
+ (direction === ARROW_BUTTON_DIRECTION.FORWARD ? forwardMultiplier : backwardMultiplier),
435
+ // @ts-ignore : https://github.com/Microsoft/TypeScript/issues/28755
436
+ behavior: 'instant',
437
+ });
438
+ await this.handleArrowButtonVisibility();
439
+ }
429
440
  render() {
430
441
  const forwardArrowDirection = !this.isRtl() ? 'right' : 'left';
431
442
  const backwardArrowDirection = !this.isRtl() ? 'left' : 'right';
@@ -66,12 +66,12 @@ declare class Textarea extends Textarea_base {
66
66
  * The rows attribute specifies the visible number of lines in a text area.
67
67
  * @default 5
68
68
  */
69
- rows: 5;
69
+ rows?: number;
70
70
  /**
71
71
  * The cols attribute specifies the visible number of lines in a text area.
72
72
  * @default 40
73
73
  */
74
- cols: 40;
74
+ cols?: number;
75
75
  /**
76
76
  * The wrap attribute specifies how the text in a text area is to be wrapped when submitted in a form.
77
77
  * @default 'soft'
@@ -317,11 +317,11 @@ __decorate([
317
317
  ], Textarea.prototype, "readonly", void 0);
318
318
  __decorate([
319
319
  property({ type: Number }),
320
- __metadata("design:type", Object)
320
+ __metadata("design:type", Number)
321
321
  ], Textarea.prototype, "rows", void 0);
322
322
  __decorate([
323
323
  property({ type: Number }),
324
- __metadata("design:type", Object)
324
+ __metadata("design:type", Number)
325
325
  ], Textarea.prototype, "cols", void 0);
326
326
  __decorate([
327
327
  property({ type: String }),
@@ -58,7 +58,7 @@ declare class Tooltip extends Popover {
58
58
  * @param changedProperties - The changed properties.
59
59
  */
60
60
  private onTooltipTypeUpdated;
61
- update(changedProperties: PropertyValues): void;
61
+ update(changedProperties: PropertyValues): Promise<void>;
62
62
  static styles: Array<CSSResult>;
63
63
  }
64
64
  export default Tooltip;
@@ -86,20 +86,20 @@ class Tooltip extends Popover {
86
86
  /**
87
87
  * Updates the tooltip id if it is empty.
88
88
  */
89
- onIdUpdated() {
89
+ async onIdUpdated() {
90
90
  // Set tooltip ID if not set.
91
91
  if (this.id.length === 0) {
92
92
  this.id = `mdc-tooltip-${uuidv4()}`;
93
93
  }
94
+ await this.updateComplete;
94
95
  // Update the aria props on the trigger component to updated tooltip id.
95
- const triggerElement = document.getElementById(this.triggerID);
96
- if (triggerElement) {
96
+ if (this.triggerElement) {
97
97
  switch (this.tooltipType) {
98
98
  case TOOLTIP_TYPES.DESCRIPTION:
99
- triggerElement.setAttribute('aria-describedby', this.id);
99
+ this.triggerElement.setAttribute('aria-describedby', this.id);
100
100
  break;
101
101
  case TOOLTIP_TYPES.LABEL:
102
- triggerElement.setAttribute('aria-labelledby', this.id);
102
+ this.triggerElement.setAttribute('aria-labelledby', this.id);
103
103
  break;
104
104
  default:
105
105
  break;
@@ -124,28 +124,27 @@ class Tooltip extends Popover {
124
124
  if (!Object.values(TOOLTIP_TYPES).includes(this.tooltipType)) {
125
125
  this.setTooltipType(DEFAULTS.TOOLTIP_TYPE);
126
126
  }
127
- const triggerElement = document.getElementById(this.triggerID);
128
- if (triggerElement) {
127
+ if (this.triggerElement) {
129
128
  const tooltipText = this.getTooltipText();
130
129
  switch (this.tooltipType) {
131
130
  case TOOLTIP_TYPES.DESCRIPTION:
132
131
  if (previousTooltipType === TOOLTIP_TYPES.LABEL) {
133
- triggerElement.removeAttribute('aria-labelledby');
132
+ this.triggerElement.removeAttribute('aria-labelledby');
134
133
  }
135
- triggerElement.setAttribute('aria-describedby', this.id);
134
+ this.triggerElement.setAttribute('aria-describedby', this.id);
136
135
  break;
137
136
  case TOOLTIP_TYPES.LABEL:
138
137
  if (previousTooltipType === TOOLTIP_TYPES.DESCRIPTION) {
139
- triggerElement.removeAttribute('aria-describedby');
138
+ this.triggerElement.removeAttribute('aria-describedby');
140
139
  }
141
- triggerElement.setAttribute('aria-labelledby', this.id);
140
+ this.triggerElement.setAttribute('aria-labelledby', this.id);
142
141
  break;
143
142
  default:
144
143
  if (previousTooltipType === TOOLTIP_TYPES.DESCRIPTION) {
145
- triggerElement.removeAttribute('aria-describedby');
144
+ this.triggerElement.removeAttribute('aria-describedby');
146
145
  }
147
146
  else if (previousTooltipType === TOOLTIP_TYPES.LABEL) {
148
- triggerElement.removeAttribute('aria-labelledby');
147
+ this.triggerElement.removeAttribute('aria-labelledby');
149
148
  }
150
149
  break;
151
150
  }
@@ -154,10 +153,10 @@ class Tooltip extends Popover {
154
153
  }
155
154
  }
156
155
  }
157
- update(changedProperties) {
156
+ async update(changedProperties) {
158
157
  super.update(changedProperties);
159
158
  if (changedProperties.has('id')) {
160
- this.onIdUpdated();
159
+ await this.onIdUpdated();
161
160
  }
162
161
  if (changedProperties.has('placement')) {
163
162
  this.onPlacementUpdated();