@limetech/lime-elements 40.6.1 → 40.6.3
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 +17 -0
- package/dist/cjs/{component-CFk7Dfoi.js → component-Cz24PdGy.js} +3 -3
- package/dist/cjs/{component-BrNWuGdj.js → component-DNiVfYHV.js} +1 -1
- package/dist/cjs/{component-y8swlNNR.js → component-GW2n79GH.js} +1 -1
- package/dist/cjs/{component-UyqdiWGc.js → component-xiw46M1b.js} +1 -1
- package/dist/cjs/{isArrayLikeObject-BhSkOTkw.js → isArrayLikeObject-U2Ddbw4n.js} +0 -17
- package/dist/cjs/{keycodes-k-EdzcMX.js → keycodes-BQ_AERli.js} +4 -0
- package/dist/cjs/limel-breadcrumbs_6.cjs.entry.js +6 -6
- package/dist/cjs/limel-chip-set.cjs.entry.js +5 -5
- package/dist/cjs/limel-chip_2.cjs.entry.js +1 -1
- package/dist/cjs/limel-date-picker.cjs.entry.js +4 -4
- package/dist/cjs/limel-dialog.cjs.entry.js +2 -2
- package/dist/cjs/limel-form.cjs.entry.js +18 -2
- package/dist/cjs/limel-helper-line_3.cjs.entry.js +2 -2
- package/dist/cjs/limel-pagination-jump.cjs.entry.js +1 -1
- package/dist/cjs/limel-picker.cjs.entry.js +1 -1
- package/dist/cjs/limel-popover_2.cjs.entry.js +1 -1
- package/dist/cjs/limel-select.cjs.entry.js +3 -3
- package/dist/cjs/limel-tab-bar.cjs.entry.js +176 -1985
- package/dist/cjs/limel-text-editor-link-menu.cjs.entry.js +1 -1
- package/dist/cjs/{ponyfill-BgIFyUG5.js → ponyfill-CHp7Zocr.js} +0 -1
- package/dist/collection/components/tab-bar/tab-bar.css +145 -434
- package/dist/collection/components/tab-bar/tab-bar.js +36 -59
- package/dist/collection/util/keyboard-navigation.js +144 -0
- package/dist/collection/util/keycodes.js +2 -0
- package/dist/esm/{component-wGVqvUmL.js → component-CVihTrav.js} +3 -3
- package/dist/esm/{component-7QB0OUSF.js → component-CrjPGt1I.js} +1 -1
- package/dist/esm/{component-D4qgwaTf.js → component-CyFeUQ0l.js} +1 -1
- package/dist/esm/{component-B2Vy44Z3.js → component-kP1jCDLp.js} +1 -1
- package/dist/esm/{isArrayLikeObject-tmUOLOWr.js → isArrayLikeObject-CJB8HbtH.js} +1 -17
- package/dist/esm/{keycodes-C4_9qUMP.js → keycodes-DQ5DmW_Y.js} +3 -1
- package/dist/esm/limel-breadcrumbs_6.entry.js +6 -6
- package/dist/esm/limel-chip-set.entry.js +5 -5
- package/dist/esm/limel-chip_2.entry.js +1 -1
- package/dist/esm/limel-date-picker.entry.js +4 -4
- package/dist/esm/limel-dialog.entry.js +2 -2
- package/dist/esm/limel-form.entry.js +17 -1
- package/dist/esm/limel-helper-line_3.entry.js +2 -2
- package/dist/esm/limel-pagination-jump.entry.js +1 -1
- package/dist/esm/limel-picker.entry.js +1 -1
- package/dist/esm/limel-popover_2.entry.js +1 -1
- package/dist/esm/limel-select.entry.js +3 -3
- package/dist/esm/limel-tab-bar.entry.js +176 -1985
- package/dist/esm/limel-text-editor-link-menu.entry.js +1 -1
- package/dist/esm/{ponyfill-ChRGk668.js → ponyfill-6YuZiAPi.js} +1 -1
- package/dist/lime-elements/lime-elements.esm.js +1 -1
- package/dist/lime-elements/{p-6adc7c88.entry.js → p-02a06cf7.entry.js} +1 -1
- package/dist/lime-elements/{p-80153f45.entry.js → p-0ece667e.entry.js} +1 -1
- package/dist/lime-elements/p-107654bb.entry.js +13 -0
- package/dist/lime-elements/{p-440a0b43.entry.js → p-120ca628.entry.js} +1 -1
- package/dist/lime-elements/{p-BwJGg-WI.js → p-1CgnIGyd.js} +4 -4
- package/dist/lime-elements/{p-5386c629.entry.js → p-45461ec5.entry.js} +1 -1
- package/dist/lime-elements/{p-8988b7e1.entry.js → p-5e448070.entry.js} +1 -1
- package/dist/lime-elements/{p-ChRGk668.js → p-6YuZiAPi.js} +3 -3
- package/dist/lime-elements/{p-159603cf.entry.js → p-74060535.entry.js} +3 -3
- package/dist/lime-elements/{p-b6c0dc91.entry.js → p-7fa85785.entry.js} +2 -2
- package/dist/lime-elements/p-958396b5.entry.js +1 -0
- package/dist/lime-elements/{p-92669910.entry.js → p-970e0810.entry.js} +1 -1
- package/dist/lime-elements/{p-BN1-aIOw.js → p-BZXGwiAr.js} +1 -1
- package/dist/lime-elements/{p-DZkKQUDM.js → p-C1FFnUvf.js} +3 -3
- package/dist/lime-elements/{p-C9yTLqR8.js → p-CmtleG1y.js} +1 -1
- package/dist/lime-elements/{p-C4_9qUMP.js → p-DQ5DmW_Y.js} +1 -1
- package/dist/lime-elements/{p-31f314e6.entry.js → p-a42f8c2d.entry.js} +1 -1
- package/dist/lime-elements/p-b35a912c.entry.js +1 -0
- package/dist/lime-elements/{p-f04e2897.entry.js → p-d1b7cc55.entry.js} +1 -1
- package/dist/lime-elements/p-pk5KIdKH.js +1 -0
- package/dist/types/components/tab-bar/tab-bar.d.ts +4 -7
- package/dist/types/components.d.ts +4 -0
- package/dist/types/util/keyboard-navigation.d.ts +105 -0
- package/dist/types/util/keycodes.d.ts +2 -0
- package/package.json +1 -1
- package/dist/lime-elements/p-31226737.entry.js +0 -13
- package/dist/lime-elements/p-4dfd1962.entry.js +0 -67
- package/dist/lime-elements/p-DWMfAkOE.js +0 -1
- package/dist/lime-elements/p-ab8021b9.entry.js +0 -1
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import { r as registerInstance, c as createEvent, h, a as getElement } from './index-BU9IJqli.js';
|
|
2
2
|
import { g as getIconName, b as getIconColor } from './get-icon-props-CgNJbSP4.js';
|
|
3
|
+
import { A as ARROW_UP, b as ARROW_DOWN, H as HOME, c as END, d as ARROW_LEFT, e as ARROW_RIGHT } from './keycodes-DQ5DmW_Y.js';
|
|
3
4
|
import { i as isEqual } from './isEqual-CE83yS8T.js';
|
|
4
|
-
import { _ as __extends, a as __assign, f as __read, M as MDCFoundation, c as MDCComponent, m as matches, b as __values } from './ponyfill-ChRGk668.js';
|
|
5
|
-
import { a as applyPassive, b as MDCRippleFoundation, M as MDCRipple } from './component-7QB0OUSF.js';
|
|
6
|
-
import { a as arrayIncludes, b as baseRest, i as isArrayLikeObject, c as baseFlatten, n as noop } from './isArrayLikeObject-tmUOLOWr.js';
|
|
7
5
|
import { S as SetCache, c as cacheHas } from './_baseIsEqual-CyF4P8uM.js';
|
|
8
|
-
import './
|
|
9
|
-
import './
|
|
10
|
-
import './_getNative-COawFdVX.js';
|
|
11
|
-
import './isFunction-9zQTeQI8.js';
|
|
12
|
-
import './isObject-BJQylLSL.js';
|
|
6
|
+
import { a as arrayIncludes, b as baseRest, i as isArrayLikeObject, c as baseFlatten } from './isArrayLikeObject-CJB8HbtH.js';
|
|
7
|
+
import './eq-CZ30nDJE.js';
|
|
13
8
|
import './_getTag-BiAaLWvH.js';
|
|
9
|
+
import './isObject-BJQylLSL.js';
|
|
14
10
|
import './isObjectLike-oiMYqRQ0.js';
|
|
15
11
|
import './isArrayLike-CyVGB489.js';
|
|
12
|
+
import './isFunction-9zQTeQI8.js';
|
|
13
|
+
import './_getNative-COawFdVX.js';
|
|
16
14
|
import './isArray-B8VKuhvH.js';
|
|
17
|
-
import './eq-CZ30nDJE.js';
|
|
18
15
|
import './_isIndex-B--C3qwe.js';
|
|
16
|
+
import './identity-CK4jS9_E.js';
|
|
17
|
+
import './_defineProperty-C69Btzid.js';
|
|
19
18
|
|
|
20
19
|
/** Used as the size to enable large array optimizations. */
|
|
21
20
|
var LARGE_ARRAY_SIZE = 200;
|
|
@@ -97,1963 +96,172 @@ var difference = baseRest(function(array, values) {
|
|
|
97
96
|
});
|
|
98
97
|
|
|
99
98
|
/**
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
104
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
105
|
-
* in the Software without restriction, including without limitation the rights
|
|
106
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
107
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
108
|
-
* furnished to do so, subject to the following conditions:
|
|
109
|
-
*
|
|
110
|
-
* The above copyright notice and this permission notice shall be included in
|
|
111
|
-
* all copies or substantial portions of the Software.
|
|
112
|
-
*
|
|
113
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
114
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
115
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
116
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
117
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
118
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
119
|
-
* THE SOFTWARE.
|
|
120
|
-
*/
|
|
121
|
-
var cssClasses$2 = {
|
|
122
|
-
ANIMATING: 'mdc-tab-scroller--animating',
|
|
123
|
-
SCROLL_AREA_SCROLL: 'mdc-tab-scroller__scroll-area--scroll',
|
|
124
|
-
SCROLL_TEST: 'mdc-tab-scroller__test',
|
|
125
|
-
};
|
|
126
|
-
var strings$4 = {
|
|
127
|
-
AREA_SELECTOR: '.mdc-tab-scroller__scroll-area',
|
|
128
|
-
CONTENT_SELECTOR: '.mdc-tab-scroller__scroll-content',
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* @license
|
|
133
|
-
* Copyright 2018 Google Inc.
|
|
134
|
-
*
|
|
135
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
136
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
137
|
-
* in the Software without restriction, including without limitation the rights
|
|
138
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
139
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
140
|
-
* furnished to do so, subject to the following conditions:
|
|
141
|
-
*
|
|
142
|
-
* The above copyright notice and this permission notice shall be included in
|
|
143
|
-
* all copies or substantial portions of the Software.
|
|
144
|
-
*
|
|
145
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
146
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
147
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
148
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
149
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
150
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
151
|
-
* THE SOFTWARE.
|
|
152
|
-
*/
|
|
153
|
-
var MDCTabScrollerRTL = /** @class */ (function () {
|
|
154
|
-
function MDCTabScrollerRTL(adapter) {
|
|
155
|
-
this.adapter = adapter;
|
|
156
|
-
}
|
|
157
|
-
return MDCTabScrollerRTL;
|
|
158
|
-
}());
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* @license
|
|
162
|
-
* Copyright 2018 Google Inc.
|
|
163
|
-
*
|
|
164
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
165
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
166
|
-
* in the Software without restriction, including without limitation the rights
|
|
167
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
168
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
169
|
-
* furnished to do so, subject to the following conditions:
|
|
170
|
-
*
|
|
171
|
-
* The above copyright notice and this permission notice shall be included in
|
|
172
|
-
* all copies or substantial portions of the Software.
|
|
173
|
-
*
|
|
174
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
175
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
176
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
177
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
178
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
179
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
180
|
-
* THE SOFTWARE.
|
|
181
|
-
*/
|
|
182
|
-
var MDCTabScrollerRTLDefault = /** @class */ (function (_super) {
|
|
183
|
-
__extends(MDCTabScrollerRTLDefault, _super);
|
|
184
|
-
function MDCTabScrollerRTLDefault() {
|
|
185
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
186
|
-
}
|
|
187
|
-
MDCTabScrollerRTLDefault.prototype.getScrollPositionRTL = function () {
|
|
188
|
-
var currentScrollLeft = this.adapter.getScrollAreaScrollLeft();
|
|
189
|
-
var right = this.calculateScrollEdges().right;
|
|
190
|
-
// Scroll values on most browsers are ints instead of floats so we round
|
|
191
|
-
return Math.round(right - currentScrollLeft);
|
|
192
|
-
};
|
|
193
|
-
MDCTabScrollerRTLDefault.prototype.scrollToRTL = function (scrollX) {
|
|
194
|
-
var edges = this.calculateScrollEdges();
|
|
195
|
-
var currentScrollLeft = this.adapter.getScrollAreaScrollLeft();
|
|
196
|
-
var clampedScrollLeft = this.clampScrollValue(edges.right - scrollX);
|
|
197
|
-
return {
|
|
198
|
-
finalScrollPosition: clampedScrollLeft,
|
|
199
|
-
scrollDelta: clampedScrollLeft - currentScrollLeft,
|
|
200
|
-
};
|
|
201
|
-
};
|
|
202
|
-
MDCTabScrollerRTLDefault.prototype.incrementScrollRTL = function (scrollX) {
|
|
203
|
-
var currentScrollLeft = this.adapter.getScrollAreaScrollLeft();
|
|
204
|
-
var clampedScrollLeft = this.clampScrollValue(currentScrollLeft - scrollX);
|
|
205
|
-
return {
|
|
206
|
-
finalScrollPosition: clampedScrollLeft,
|
|
207
|
-
scrollDelta: clampedScrollLeft - currentScrollLeft,
|
|
208
|
-
};
|
|
209
|
-
};
|
|
210
|
-
MDCTabScrollerRTLDefault.prototype.getAnimatingScrollPosition = function (scrollX) {
|
|
211
|
-
return scrollX;
|
|
212
|
-
};
|
|
213
|
-
MDCTabScrollerRTLDefault.prototype.calculateScrollEdges = function () {
|
|
214
|
-
var contentWidth = this.adapter.getScrollContentOffsetWidth();
|
|
215
|
-
var rootWidth = this.adapter.getScrollAreaOffsetWidth();
|
|
216
|
-
return {
|
|
217
|
-
left: 0,
|
|
218
|
-
right: contentWidth - rootWidth,
|
|
219
|
-
};
|
|
220
|
-
};
|
|
221
|
-
MDCTabScrollerRTLDefault.prototype.clampScrollValue = function (scrollX) {
|
|
222
|
-
var edges = this.calculateScrollEdges();
|
|
223
|
-
return Math.min(Math.max(edges.left, scrollX), edges.right);
|
|
224
|
-
};
|
|
225
|
-
return MDCTabScrollerRTLDefault;
|
|
226
|
-
}(MDCTabScrollerRTL));
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* @license
|
|
230
|
-
* Copyright 2018 Google Inc.
|
|
231
|
-
*
|
|
232
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
233
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
234
|
-
* in the Software without restriction, including without limitation the rights
|
|
235
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
236
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
237
|
-
* furnished to do so, subject to the following conditions:
|
|
238
|
-
*
|
|
239
|
-
* The above copyright notice and this permission notice shall be included in
|
|
240
|
-
* all copies or substantial portions of the Software.
|
|
241
|
-
*
|
|
242
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
243
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
244
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
245
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
246
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
247
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
248
|
-
* THE SOFTWARE.
|
|
249
|
-
*/
|
|
250
|
-
var MDCTabScrollerRTLNegative = /** @class */ (function (_super) {
|
|
251
|
-
__extends(MDCTabScrollerRTLNegative, _super);
|
|
252
|
-
function MDCTabScrollerRTLNegative() {
|
|
253
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
254
|
-
}
|
|
255
|
-
MDCTabScrollerRTLNegative.prototype.getScrollPositionRTL = function (translateX) {
|
|
256
|
-
var currentScrollLeft = this.adapter.getScrollAreaScrollLeft();
|
|
257
|
-
return Math.round(translateX - currentScrollLeft);
|
|
258
|
-
};
|
|
259
|
-
MDCTabScrollerRTLNegative.prototype.scrollToRTL = function (scrollX) {
|
|
260
|
-
var currentScrollLeft = this.adapter.getScrollAreaScrollLeft();
|
|
261
|
-
var clampedScrollLeft = this.clampScrollValue(-scrollX);
|
|
262
|
-
return {
|
|
263
|
-
finalScrollPosition: clampedScrollLeft,
|
|
264
|
-
scrollDelta: clampedScrollLeft - currentScrollLeft,
|
|
265
|
-
};
|
|
266
|
-
};
|
|
267
|
-
MDCTabScrollerRTLNegative.prototype.incrementScrollRTL = function (scrollX) {
|
|
268
|
-
var currentScrollLeft = this.adapter.getScrollAreaScrollLeft();
|
|
269
|
-
var clampedScrollLeft = this.clampScrollValue(currentScrollLeft - scrollX);
|
|
270
|
-
return {
|
|
271
|
-
finalScrollPosition: clampedScrollLeft,
|
|
272
|
-
scrollDelta: clampedScrollLeft - currentScrollLeft,
|
|
273
|
-
};
|
|
274
|
-
};
|
|
275
|
-
MDCTabScrollerRTLNegative.prototype.getAnimatingScrollPosition = function (scrollX, translateX) {
|
|
276
|
-
return scrollX - translateX;
|
|
277
|
-
};
|
|
278
|
-
MDCTabScrollerRTLNegative.prototype.calculateScrollEdges = function () {
|
|
279
|
-
var contentWidth = this.adapter.getScrollContentOffsetWidth();
|
|
280
|
-
var rootWidth = this.adapter.getScrollAreaOffsetWidth();
|
|
281
|
-
return {
|
|
282
|
-
left: rootWidth - contentWidth,
|
|
283
|
-
right: 0,
|
|
284
|
-
};
|
|
285
|
-
};
|
|
286
|
-
MDCTabScrollerRTLNegative.prototype.clampScrollValue = function (scrollX) {
|
|
287
|
-
var edges = this.calculateScrollEdges();
|
|
288
|
-
return Math.max(Math.min(edges.right, scrollX), edges.left);
|
|
289
|
-
};
|
|
290
|
-
return MDCTabScrollerRTLNegative;
|
|
291
|
-
}(MDCTabScrollerRTL));
|
|
292
|
-
|
|
293
|
-
/**
|
|
294
|
-
* @license
|
|
295
|
-
* Copyright 2018 Google Inc.
|
|
296
|
-
*
|
|
297
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
298
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
299
|
-
* in the Software without restriction, including without limitation the rights
|
|
300
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
301
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
302
|
-
* furnished to do so, subject to the following conditions:
|
|
303
|
-
*
|
|
304
|
-
* The above copyright notice and this permission notice shall be included in
|
|
305
|
-
* all copies or substantial portions of the Software.
|
|
306
|
-
*
|
|
307
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
308
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
309
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
310
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
311
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
312
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
313
|
-
* THE SOFTWARE.
|
|
314
|
-
*/
|
|
315
|
-
var MDCTabScrollerRTLReverse = /** @class */ (function (_super) {
|
|
316
|
-
__extends(MDCTabScrollerRTLReverse, _super);
|
|
317
|
-
function MDCTabScrollerRTLReverse() {
|
|
318
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
319
|
-
}
|
|
320
|
-
MDCTabScrollerRTLReverse.prototype.getScrollPositionRTL = function (translateX) {
|
|
321
|
-
var currentScrollLeft = this.adapter.getScrollAreaScrollLeft();
|
|
322
|
-
// Scroll values on most browsers are ints instead of floats so we round
|
|
323
|
-
return Math.round(currentScrollLeft - translateX);
|
|
324
|
-
};
|
|
325
|
-
MDCTabScrollerRTLReverse.prototype.scrollToRTL = function (scrollX) {
|
|
326
|
-
var currentScrollLeft = this.adapter.getScrollAreaScrollLeft();
|
|
327
|
-
var clampedScrollLeft = this.clampScrollValue(scrollX);
|
|
328
|
-
return {
|
|
329
|
-
finalScrollPosition: clampedScrollLeft,
|
|
330
|
-
scrollDelta: currentScrollLeft - clampedScrollLeft,
|
|
331
|
-
};
|
|
332
|
-
};
|
|
333
|
-
MDCTabScrollerRTLReverse.prototype.incrementScrollRTL = function (scrollX) {
|
|
334
|
-
var currentScrollLeft = this.adapter.getScrollAreaScrollLeft();
|
|
335
|
-
var clampedScrollLeft = this.clampScrollValue(currentScrollLeft + scrollX);
|
|
336
|
-
return {
|
|
337
|
-
finalScrollPosition: clampedScrollLeft,
|
|
338
|
-
scrollDelta: currentScrollLeft - clampedScrollLeft,
|
|
339
|
-
};
|
|
340
|
-
};
|
|
341
|
-
MDCTabScrollerRTLReverse.prototype.getAnimatingScrollPosition = function (scrollX, translateX) {
|
|
342
|
-
return scrollX + translateX;
|
|
343
|
-
};
|
|
344
|
-
MDCTabScrollerRTLReverse.prototype.calculateScrollEdges = function () {
|
|
345
|
-
var contentWidth = this.adapter.getScrollContentOffsetWidth();
|
|
346
|
-
var rootWidth = this.adapter.getScrollAreaOffsetWidth();
|
|
347
|
-
return {
|
|
348
|
-
left: contentWidth - rootWidth,
|
|
349
|
-
right: 0,
|
|
350
|
-
};
|
|
351
|
-
};
|
|
352
|
-
MDCTabScrollerRTLReverse.prototype.clampScrollValue = function (scrollX) {
|
|
353
|
-
var edges = this.calculateScrollEdges();
|
|
354
|
-
return Math.min(Math.max(edges.right, scrollX), edges.left);
|
|
355
|
-
};
|
|
356
|
-
return MDCTabScrollerRTLReverse;
|
|
357
|
-
}(MDCTabScrollerRTL));
|
|
358
|
-
|
|
359
|
-
/**
|
|
360
|
-
* @license
|
|
361
|
-
* Copyright 2018 Google Inc.
|
|
362
|
-
*
|
|
363
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
364
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
365
|
-
* in the Software without restriction, including without limitation the rights
|
|
366
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
367
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
368
|
-
* furnished to do so, subject to the following conditions:
|
|
369
|
-
*
|
|
370
|
-
* The above copyright notice and this permission notice shall be included in
|
|
371
|
-
* all copies or substantial portions of the Software.
|
|
372
|
-
*
|
|
373
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
374
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
375
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
376
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
377
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
378
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
379
|
-
* THE SOFTWARE.
|
|
380
|
-
*/
|
|
381
|
-
var MDCTabScrollerFoundation = /** @class */ (function (_super) {
|
|
382
|
-
__extends(MDCTabScrollerFoundation, _super);
|
|
383
|
-
function MDCTabScrollerFoundation(adapter) {
|
|
384
|
-
var _this = _super.call(this, __assign(__assign({}, MDCTabScrollerFoundation.defaultAdapter), adapter)) || this;
|
|
385
|
-
/**
|
|
386
|
-
* Controls whether we should handle the transitionend and interaction events during the animation.
|
|
387
|
-
*/
|
|
388
|
-
_this.isAnimating = false;
|
|
389
|
-
return _this;
|
|
390
|
-
}
|
|
391
|
-
Object.defineProperty(MDCTabScrollerFoundation, "cssClasses", {
|
|
392
|
-
get: function () {
|
|
393
|
-
return cssClasses$2;
|
|
394
|
-
},
|
|
395
|
-
enumerable: false,
|
|
396
|
-
configurable: true
|
|
397
|
-
});
|
|
398
|
-
Object.defineProperty(MDCTabScrollerFoundation, "strings", {
|
|
399
|
-
get: function () {
|
|
400
|
-
return strings$4;
|
|
401
|
-
},
|
|
402
|
-
enumerable: false,
|
|
403
|
-
configurable: true
|
|
404
|
-
});
|
|
405
|
-
Object.defineProperty(MDCTabScrollerFoundation, "defaultAdapter", {
|
|
406
|
-
get: function () {
|
|
407
|
-
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
|
|
408
|
-
return {
|
|
409
|
-
eventTargetMatchesSelector: function () { return false; },
|
|
410
|
-
addClass: function () { return undefined; },
|
|
411
|
-
removeClass: function () { return undefined; },
|
|
412
|
-
addScrollAreaClass: function () { return undefined; },
|
|
413
|
-
setScrollAreaStyleProperty: function () { return undefined; },
|
|
414
|
-
setScrollContentStyleProperty: function () { return undefined; },
|
|
415
|
-
getScrollContentStyleValue: function () { return ''; },
|
|
416
|
-
setScrollAreaScrollLeft: function () { return undefined; },
|
|
417
|
-
getScrollAreaScrollLeft: function () { return 0; },
|
|
418
|
-
getScrollContentOffsetWidth: function () { return 0; },
|
|
419
|
-
getScrollAreaOffsetWidth: function () { return 0; },
|
|
420
|
-
computeScrollAreaClientRect: function () {
|
|
421
|
-
return ({ top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 });
|
|
422
|
-
},
|
|
423
|
-
computeScrollContentClientRect: function () {
|
|
424
|
-
return ({ top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 });
|
|
425
|
-
},
|
|
426
|
-
computeHorizontalScrollbarHeight: function () { return 0; },
|
|
427
|
-
};
|
|
428
|
-
// tslint:enable:object-literal-sort-keys
|
|
429
|
-
},
|
|
430
|
-
enumerable: false,
|
|
431
|
-
configurable: true
|
|
432
|
-
});
|
|
433
|
-
MDCTabScrollerFoundation.prototype.init = function () {
|
|
434
|
-
// Compute horizontal scrollbar height on scroller with overflow initially hidden, then update overflow to scroll
|
|
435
|
-
// and immediately adjust bottom margin to avoid the scrollbar initially appearing before JS runs.
|
|
436
|
-
var horizontalScrollbarHeight = this.adapter.computeHorizontalScrollbarHeight();
|
|
437
|
-
this.adapter.setScrollAreaStyleProperty('margin-bottom', -horizontalScrollbarHeight + 'px');
|
|
438
|
-
this.adapter.addScrollAreaClass(MDCTabScrollerFoundation.cssClasses.SCROLL_AREA_SCROLL);
|
|
439
|
-
};
|
|
440
|
-
/**
|
|
441
|
-
* Computes the current visual scroll position
|
|
442
|
-
*/
|
|
443
|
-
MDCTabScrollerFoundation.prototype.getScrollPosition = function () {
|
|
444
|
-
if (this.isRTL()) {
|
|
445
|
-
return this.computeCurrentScrollPositionRTL();
|
|
446
|
-
}
|
|
447
|
-
var currentTranslateX = this.calculateCurrentTranslateX();
|
|
448
|
-
var scrollLeft = this.adapter.getScrollAreaScrollLeft();
|
|
449
|
-
return scrollLeft - currentTranslateX;
|
|
450
|
-
};
|
|
451
|
-
/**
|
|
452
|
-
* Handles interaction events that occur during transition
|
|
453
|
-
*/
|
|
454
|
-
MDCTabScrollerFoundation.prototype.handleInteraction = function () {
|
|
455
|
-
// Early exit if we aren't animating
|
|
456
|
-
if (!this.isAnimating) {
|
|
457
|
-
return;
|
|
458
|
-
}
|
|
459
|
-
// Prevent other event listeners from handling this event
|
|
460
|
-
this.stopScrollAnimation();
|
|
461
|
-
};
|
|
462
|
-
/**
|
|
463
|
-
* Handles the transitionend event
|
|
464
|
-
*/
|
|
465
|
-
MDCTabScrollerFoundation.prototype.handleTransitionEnd = function (evt) {
|
|
466
|
-
// Early exit if we aren't animating or the event was triggered by a different element.
|
|
467
|
-
var evtTarget = evt.target;
|
|
468
|
-
if (!this.isAnimating ||
|
|
469
|
-
!this.adapter.eventTargetMatchesSelector(evtTarget, MDCTabScrollerFoundation.strings.CONTENT_SELECTOR)) {
|
|
470
|
-
return;
|
|
471
|
-
}
|
|
472
|
-
this.isAnimating = false;
|
|
473
|
-
this.adapter.removeClass(MDCTabScrollerFoundation.cssClasses.ANIMATING);
|
|
474
|
-
};
|
|
475
|
-
/**
|
|
476
|
-
* Increment the scroll value by the scrollXIncrement using animation.
|
|
477
|
-
* @param scrollXIncrement The value by which to increment the scroll position
|
|
478
|
-
*/
|
|
479
|
-
MDCTabScrollerFoundation.prototype.incrementScroll = function (scrollXIncrement) {
|
|
480
|
-
// Early exit for non-operational increment values
|
|
481
|
-
if (scrollXIncrement === 0) {
|
|
482
|
-
return;
|
|
483
|
-
}
|
|
484
|
-
this.animate(this.getIncrementScrollOperation(scrollXIncrement));
|
|
485
|
-
};
|
|
486
|
-
/**
|
|
487
|
-
* Increment the scroll value by the scrollXIncrement without animation.
|
|
488
|
-
* @param scrollXIncrement The value by which to increment the scroll position
|
|
489
|
-
*/
|
|
490
|
-
MDCTabScrollerFoundation.prototype.incrementScrollImmediate = function (scrollXIncrement) {
|
|
491
|
-
// Early exit for non-operational increment values
|
|
492
|
-
if (scrollXIncrement === 0) {
|
|
493
|
-
return;
|
|
494
|
-
}
|
|
495
|
-
var operation = this.getIncrementScrollOperation(scrollXIncrement);
|
|
496
|
-
if (operation.scrollDelta === 0) {
|
|
497
|
-
return;
|
|
498
|
-
}
|
|
499
|
-
this.stopScrollAnimation();
|
|
500
|
-
this.adapter.setScrollAreaScrollLeft(operation.finalScrollPosition);
|
|
501
|
-
};
|
|
502
|
-
/**
|
|
503
|
-
* Scrolls to the given scrollX value
|
|
504
|
-
*/
|
|
505
|
-
MDCTabScrollerFoundation.prototype.scrollTo = function (scrollX) {
|
|
506
|
-
if (this.isRTL()) {
|
|
507
|
-
this.scrollToImplRTL(scrollX);
|
|
508
|
-
return;
|
|
509
|
-
}
|
|
510
|
-
this.scrollToImpl(scrollX);
|
|
511
|
-
};
|
|
512
|
-
/**
|
|
513
|
-
* @return Browser-specific {@link MDCTabScrollerRTL} instance.
|
|
514
|
-
*/
|
|
515
|
-
MDCTabScrollerFoundation.prototype.getRTLScroller = function () {
|
|
516
|
-
if (!this.rtlScrollerInstance) {
|
|
517
|
-
this.rtlScrollerInstance = this.rtlScrollerFactory();
|
|
518
|
-
}
|
|
519
|
-
return this.rtlScrollerInstance;
|
|
520
|
-
};
|
|
521
|
-
/**
|
|
522
|
-
* @return translateX value from a CSS matrix transform function string.
|
|
523
|
-
*/
|
|
524
|
-
MDCTabScrollerFoundation.prototype.calculateCurrentTranslateX = function () {
|
|
525
|
-
var transformValue = this.adapter.getScrollContentStyleValue('transform');
|
|
526
|
-
// Early exit if no transform is present
|
|
527
|
-
if (transformValue === 'none') {
|
|
528
|
-
return 0;
|
|
529
|
-
}
|
|
530
|
-
// The transform value comes back as a matrix transformation in the form
|
|
531
|
-
// of `matrix(a, b, c, d, tx, ty)`. We only care about tx (translateX) so
|
|
532
|
-
// we're going to grab all the parenthesized values, strip out tx, and
|
|
533
|
-
// parse it.
|
|
534
|
-
var match = /\((.+?)\)/.exec(transformValue);
|
|
535
|
-
if (!match) {
|
|
536
|
-
return 0;
|
|
537
|
-
}
|
|
538
|
-
var matrixParams = match[1];
|
|
539
|
-
// tslint:disable-next-line:ban-ts-ignore "Unused vars" should be a linter warning, not a compiler error.
|
|
540
|
-
// @ts-ignore These unused variables should retain their semantic names for clarity.
|
|
541
|
-
var _a = __read(matrixParams.split(','), 6), tx = _a[4];
|
|
542
|
-
return parseFloat(tx); // tslint:disable-line:ban
|
|
543
|
-
};
|
|
544
|
-
/**
|
|
545
|
-
* Calculates a safe scroll value that is > 0 and < the max scroll value
|
|
546
|
-
* @param scrollX The distance to scroll
|
|
547
|
-
*/
|
|
548
|
-
MDCTabScrollerFoundation.prototype.clampScrollValue = function (scrollX) {
|
|
549
|
-
var edges = this.calculateScrollEdges();
|
|
550
|
-
return Math.min(Math.max(edges.left, scrollX), edges.right);
|
|
551
|
-
};
|
|
552
|
-
MDCTabScrollerFoundation.prototype.computeCurrentScrollPositionRTL = function () {
|
|
553
|
-
var translateX = this.calculateCurrentTranslateX();
|
|
554
|
-
return this.getRTLScroller().getScrollPositionRTL(translateX);
|
|
555
|
-
};
|
|
556
|
-
MDCTabScrollerFoundation.prototype.calculateScrollEdges = function () {
|
|
557
|
-
var contentWidth = this.adapter.getScrollContentOffsetWidth();
|
|
558
|
-
var rootWidth = this.adapter.getScrollAreaOffsetWidth();
|
|
559
|
-
return {
|
|
560
|
-
left: 0,
|
|
561
|
-
right: contentWidth - rootWidth,
|
|
562
|
-
};
|
|
563
|
-
};
|
|
564
|
-
/**
|
|
565
|
-
* Internal scroll method
|
|
566
|
-
* @param scrollX The new scroll position
|
|
567
|
-
*/
|
|
568
|
-
MDCTabScrollerFoundation.prototype.scrollToImpl = function (scrollX) {
|
|
569
|
-
var currentScrollX = this.getScrollPosition();
|
|
570
|
-
var safeScrollX = this.clampScrollValue(scrollX);
|
|
571
|
-
var scrollDelta = safeScrollX - currentScrollX;
|
|
572
|
-
this.animate({
|
|
573
|
-
finalScrollPosition: safeScrollX,
|
|
574
|
-
scrollDelta: scrollDelta,
|
|
575
|
-
});
|
|
576
|
-
};
|
|
577
|
-
/**
|
|
578
|
-
* Internal RTL scroll method
|
|
579
|
-
* @param scrollX The new scroll position
|
|
580
|
-
*/
|
|
581
|
-
MDCTabScrollerFoundation.prototype.scrollToImplRTL = function (scrollX) {
|
|
582
|
-
var animation = this.getRTLScroller().scrollToRTL(scrollX);
|
|
583
|
-
this.animate(animation);
|
|
584
|
-
};
|
|
585
|
-
/**
|
|
586
|
-
* Internal method to compute the increment scroll operation values.
|
|
587
|
-
* @param scrollX The desired scroll position increment
|
|
588
|
-
* @return MDCTabScrollerAnimation with the sanitized values for performing the scroll operation.
|
|
589
|
-
*/
|
|
590
|
-
MDCTabScrollerFoundation.prototype.getIncrementScrollOperation = function (scrollX) {
|
|
591
|
-
if (this.isRTL()) {
|
|
592
|
-
return this.getRTLScroller().incrementScrollRTL(scrollX);
|
|
593
|
-
}
|
|
594
|
-
var currentScrollX = this.getScrollPosition();
|
|
595
|
-
var targetScrollX = scrollX + currentScrollX;
|
|
596
|
-
var safeScrollX = this.clampScrollValue(targetScrollX);
|
|
597
|
-
var scrollDelta = safeScrollX - currentScrollX;
|
|
598
|
-
return {
|
|
599
|
-
finalScrollPosition: safeScrollX,
|
|
600
|
-
scrollDelta: scrollDelta,
|
|
601
|
-
};
|
|
602
|
-
};
|
|
603
|
-
/**
|
|
604
|
-
* Animates the tab scrolling
|
|
605
|
-
* @param animation The animation to apply
|
|
606
|
-
*/
|
|
607
|
-
MDCTabScrollerFoundation.prototype.animate = function (animation) {
|
|
608
|
-
var _this = this;
|
|
609
|
-
// Early exit if translateX is 0, which means there's no animation to perform
|
|
610
|
-
if (animation.scrollDelta === 0) {
|
|
611
|
-
return;
|
|
612
|
-
}
|
|
613
|
-
this.stopScrollAnimation();
|
|
614
|
-
// This animation uses the FLIP approach.
|
|
615
|
-
// Read more here: https://aerotwist.com/blog/flip-your-animations/
|
|
616
|
-
this.adapter.setScrollAreaScrollLeft(animation.finalScrollPosition);
|
|
617
|
-
this.adapter.setScrollContentStyleProperty('transform', "translateX(" + animation.scrollDelta + "px)");
|
|
618
|
-
// Force repaint
|
|
619
|
-
this.adapter.computeScrollAreaClientRect();
|
|
620
|
-
requestAnimationFrame(function () {
|
|
621
|
-
_this.adapter.addClass(MDCTabScrollerFoundation.cssClasses.ANIMATING);
|
|
622
|
-
_this.adapter.setScrollContentStyleProperty('transform', 'none');
|
|
623
|
-
});
|
|
624
|
-
this.isAnimating = true;
|
|
625
|
-
};
|
|
626
|
-
/**
|
|
627
|
-
* Stops scroll animation
|
|
628
|
-
*/
|
|
629
|
-
MDCTabScrollerFoundation.prototype.stopScrollAnimation = function () {
|
|
630
|
-
this.isAnimating = false;
|
|
631
|
-
var currentScrollPosition = this.getAnimatingScrollPosition();
|
|
632
|
-
this.adapter.removeClass(MDCTabScrollerFoundation.cssClasses.ANIMATING);
|
|
633
|
-
this.adapter.setScrollContentStyleProperty('transform', 'translateX(0px)');
|
|
634
|
-
this.adapter.setScrollAreaScrollLeft(currentScrollPosition);
|
|
635
|
-
};
|
|
636
|
-
/**
|
|
637
|
-
* Gets the current scroll position during animation
|
|
638
|
-
*/
|
|
639
|
-
MDCTabScrollerFoundation.prototype.getAnimatingScrollPosition = function () {
|
|
640
|
-
var currentTranslateX = this.calculateCurrentTranslateX();
|
|
641
|
-
var scrollLeft = this.adapter.getScrollAreaScrollLeft();
|
|
642
|
-
if (this.isRTL()) {
|
|
643
|
-
return this.getRTLScroller().getAnimatingScrollPosition(scrollLeft, currentTranslateX);
|
|
644
|
-
}
|
|
645
|
-
return scrollLeft - currentTranslateX;
|
|
646
|
-
};
|
|
647
|
-
/**
|
|
648
|
-
* Determines the RTL Scroller to use
|
|
649
|
-
*/
|
|
650
|
-
MDCTabScrollerFoundation.prototype.rtlScrollerFactory = function () {
|
|
651
|
-
// Browsers have three different implementations of scrollLeft in RTL mode,
|
|
652
|
-
// dependent on the browser. The behavior is based off the max LTR
|
|
653
|
-
// scrollLeft value and 0.
|
|
654
|
-
//
|
|
655
|
-
// * Default scrolling in RTL *
|
|
656
|
-
// - Left-most value: 0
|
|
657
|
-
// - Right-most value: Max LTR scrollLeft value
|
|
658
|
-
//
|
|
659
|
-
// * Negative scrolling in RTL *
|
|
660
|
-
// - Left-most value: Negated max LTR scrollLeft value
|
|
661
|
-
// - Right-most value: 0
|
|
662
|
-
//
|
|
663
|
-
// * Reverse scrolling in RTL *
|
|
664
|
-
// - Left-most value: Max LTR scrollLeft value
|
|
665
|
-
// - Right-most value: 0
|
|
666
|
-
//
|
|
667
|
-
// We use those principles below to determine which RTL scrollLeft
|
|
668
|
-
// behavior is implemented in the current browser.
|
|
669
|
-
var initialScrollLeft = this.adapter.getScrollAreaScrollLeft();
|
|
670
|
-
this.adapter.setScrollAreaScrollLeft(initialScrollLeft - 1);
|
|
671
|
-
var newScrollLeft = this.adapter.getScrollAreaScrollLeft();
|
|
672
|
-
// If the newScrollLeft value is negative,then we know that the browser has
|
|
673
|
-
// implemented negative RTL scrolling, since all other implementations have
|
|
674
|
-
// only positive values.
|
|
675
|
-
if (newScrollLeft < 0) {
|
|
676
|
-
// Undo the scrollLeft test check
|
|
677
|
-
this.adapter.setScrollAreaScrollLeft(initialScrollLeft);
|
|
678
|
-
return new MDCTabScrollerRTLNegative(this.adapter);
|
|
679
|
-
}
|
|
680
|
-
var rootClientRect = this.adapter.computeScrollAreaClientRect();
|
|
681
|
-
var contentClientRect = this.adapter.computeScrollContentClientRect();
|
|
682
|
-
var rightEdgeDelta = Math.round(contentClientRect.right - rootClientRect.right);
|
|
683
|
-
// Undo the scrollLeft test check
|
|
684
|
-
this.adapter.setScrollAreaScrollLeft(initialScrollLeft);
|
|
685
|
-
// By calculating the clientRect of the root element and the clientRect of
|
|
686
|
-
// the content element, we can determine how much the scroll value changed
|
|
687
|
-
// when we performed the scrollLeft subtraction above.
|
|
688
|
-
if (rightEdgeDelta === newScrollLeft) {
|
|
689
|
-
return new MDCTabScrollerRTLReverse(this.adapter);
|
|
690
|
-
}
|
|
691
|
-
return new MDCTabScrollerRTLDefault(this.adapter);
|
|
692
|
-
};
|
|
693
|
-
MDCTabScrollerFoundation.prototype.isRTL = function () {
|
|
694
|
-
return this.adapter.getScrollContentStyleValue('direction') === 'rtl';
|
|
695
|
-
};
|
|
696
|
-
return MDCTabScrollerFoundation;
|
|
697
|
-
}(MDCFoundation));
|
|
698
|
-
|
|
699
|
-
/**
|
|
700
|
-
* @license
|
|
701
|
-
* Copyright 2018 Google Inc.
|
|
702
|
-
*
|
|
703
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
704
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
705
|
-
* in the Software without restriction, including without limitation the rights
|
|
706
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
707
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
708
|
-
* furnished to do so, subject to the following conditions:
|
|
709
|
-
*
|
|
710
|
-
* The above copyright notice and this permission notice shall be included in
|
|
711
|
-
* all copies or substantial portions of the Software.
|
|
99
|
+
* Set a tabs `active` state to true in a list of tabs. The previous tab with
|
|
100
|
+
* `active` set to true will have it set to `false` instead.
|
|
712
101
|
*
|
|
713
|
-
*
|
|
714
|
-
*
|
|
715
|
-
*
|
|
716
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
717
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
718
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
719
|
-
* THE SOFTWARE.
|
|
720
|
-
*/
|
|
721
|
-
/**
|
|
722
|
-
* Stores result from computeHorizontalScrollbarHeight to avoid redundant processing.
|
|
723
|
-
*/
|
|
724
|
-
var horizontalScrollbarHeight_;
|
|
725
|
-
/**
|
|
726
|
-
* Computes the height of browser-rendered horizontal scrollbars using a self-created test element.
|
|
727
|
-
* May return 0 (e.g. on OS X browsers under default configuration).
|
|
102
|
+
* @param tabs - list of tabs
|
|
103
|
+
* @param index - the index of the tab to set to active
|
|
104
|
+
* @returns a copy of the list of tabs with the changed tabs replaced
|
|
728
105
|
*/
|
|
729
|
-
function
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
var el = documentObj.createElement('div');
|
|
735
|
-
el.classList.add(cssClasses$2.SCROLL_TEST);
|
|
736
|
-
documentObj.body.appendChild(el);
|
|
737
|
-
var horizontalScrollbarHeight = el.offsetHeight - el.clientHeight;
|
|
738
|
-
documentObj.body.removeChild(el);
|
|
739
|
-
if (shouldCacheResult) {
|
|
740
|
-
horizontalScrollbarHeight_ = horizontalScrollbarHeight;
|
|
106
|
+
function setActiveTab(tabs, index) {
|
|
107
|
+
const oldSelectedTabIndex = tabs.findIndex((t) => t.active === true);
|
|
108
|
+
const result = [...tabs];
|
|
109
|
+
if (oldSelectedTabIndex !== -1) {
|
|
110
|
+
result[oldSelectedTabIndex] = Object.assign(Object.assign({}, tabs[oldSelectedTabIndex]), { active: false });
|
|
741
111
|
}
|
|
742
|
-
|
|
112
|
+
result[index] = Object.assign(Object.assign({}, tabs[index]), { active: true });
|
|
113
|
+
return result;
|
|
743
114
|
}
|
|
744
115
|
|
|
745
116
|
/**
|
|
746
|
-
*
|
|
747
|
-
* Copyright 2018 Google Inc.
|
|
748
|
-
*
|
|
749
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
750
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
751
|
-
* in the Software without restriction, including without limitation the rights
|
|
752
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
753
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
754
|
-
* furnished to do so, subject to the following conditions:
|
|
755
|
-
*
|
|
756
|
-
* The above copyright notice and this permission notice shall be included in
|
|
757
|
-
* all copies or substantial portions of the Software.
|
|
758
|
-
*
|
|
759
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
760
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
761
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
762
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
763
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
764
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
765
|
-
* THE SOFTWARE.
|
|
766
|
-
*/
|
|
767
|
-
var MDCTabScroller = /** @class */ (function (_super) {
|
|
768
|
-
__extends(MDCTabScroller, _super);
|
|
769
|
-
function MDCTabScroller() {
|
|
770
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
771
|
-
}
|
|
772
|
-
MDCTabScroller.attachTo = function (root) {
|
|
773
|
-
return new MDCTabScroller(root);
|
|
774
|
-
};
|
|
775
|
-
// initialSyncWithDOM()
|
|
776
|
-
MDCTabScroller.prototype.initialize = function () {
|
|
777
|
-
this.area = this.root.querySelector(MDCTabScrollerFoundation.strings.AREA_SELECTOR);
|
|
778
|
-
this.content = this.root.querySelector(MDCTabScrollerFoundation.strings.CONTENT_SELECTOR);
|
|
779
|
-
};
|
|
780
|
-
MDCTabScroller.prototype.initialSyncWithDOM = function () {
|
|
781
|
-
var _this = this;
|
|
782
|
-
this.handleInteraction = function () {
|
|
783
|
-
_this.foundation.handleInteraction();
|
|
784
|
-
};
|
|
785
|
-
this.handleTransitionEnd = function (evt) {
|
|
786
|
-
_this.foundation.handleTransitionEnd(evt);
|
|
787
|
-
};
|
|
788
|
-
this.area.addEventListener('wheel', this.handleInteraction, applyPassive());
|
|
789
|
-
this.area.addEventListener('touchstart', this.handleInteraction, applyPassive());
|
|
790
|
-
this.area.addEventListener('pointerdown', this.handleInteraction, applyPassive());
|
|
791
|
-
this.area.addEventListener('mousedown', this.handleInteraction, applyPassive());
|
|
792
|
-
this.area.addEventListener('keydown', this.handleInteraction, applyPassive());
|
|
793
|
-
this.content.addEventListener('transitionend', this.handleTransitionEnd);
|
|
794
|
-
};
|
|
795
|
-
MDCTabScroller.prototype.destroy = function () {
|
|
796
|
-
_super.prototype.destroy.call(this);
|
|
797
|
-
this.area.removeEventListener('wheel', this.handleInteraction, applyPassive());
|
|
798
|
-
this.area.removeEventListener('touchstart', this.handleInteraction, applyPassive());
|
|
799
|
-
this.area.removeEventListener('pointerdown', this.handleInteraction, applyPassive());
|
|
800
|
-
this.area.removeEventListener('mousedown', this.handleInteraction, applyPassive());
|
|
801
|
-
this.area.removeEventListener('keydown', this.handleInteraction, applyPassive());
|
|
802
|
-
this.content.removeEventListener('transitionend', this.handleTransitionEnd);
|
|
803
|
-
};
|
|
804
|
-
MDCTabScroller.prototype.getDefaultFoundation = function () {
|
|
805
|
-
var _this = this;
|
|
806
|
-
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
|
|
807
|
-
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
|
|
808
|
-
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
|
|
809
|
-
var adapter = {
|
|
810
|
-
eventTargetMatchesSelector: function (evtTarget, selector) {
|
|
811
|
-
return matches(evtTarget, selector);
|
|
812
|
-
},
|
|
813
|
-
addClass: function (className) {
|
|
814
|
-
_this.root.classList.add(className);
|
|
815
|
-
},
|
|
816
|
-
removeClass: function (className) {
|
|
817
|
-
_this.root.classList.remove(className);
|
|
818
|
-
},
|
|
819
|
-
addScrollAreaClass: function (className) {
|
|
820
|
-
_this.area.classList.add(className);
|
|
821
|
-
},
|
|
822
|
-
setScrollAreaStyleProperty: function (prop, value) {
|
|
823
|
-
_this.area.style.setProperty(prop, value);
|
|
824
|
-
},
|
|
825
|
-
setScrollContentStyleProperty: function (prop, value) {
|
|
826
|
-
_this.content.style.setProperty(prop, value);
|
|
827
|
-
},
|
|
828
|
-
getScrollContentStyleValue: function (propName) {
|
|
829
|
-
return window.getComputedStyle(_this.content).getPropertyValue(propName);
|
|
830
|
-
},
|
|
831
|
-
setScrollAreaScrollLeft: function (scrollX) { return _this.area.scrollLeft = scrollX; },
|
|
832
|
-
getScrollAreaScrollLeft: function () { return _this.area.scrollLeft; },
|
|
833
|
-
getScrollContentOffsetWidth: function () { return _this.content.offsetWidth; },
|
|
834
|
-
getScrollAreaOffsetWidth: function () { return _this.area.offsetWidth; },
|
|
835
|
-
computeScrollAreaClientRect: function () { return _this.area.getBoundingClientRect(); },
|
|
836
|
-
computeScrollContentClientRect: function () {
|
|
837
|
-
return _this.content.getBoundingClientRect();
|
|
838
|
-
},
|
|
839
|
-
computeHorizontalScrollbarHeight: function () {
|
|
840
|
-
return computeHorizontalScrollbarHeight(document);
|
|
841
|
-
},
|
|
842
|
-
};
|
|
843
|
-
// tslint:enable:object-literal-sort-keys
|
|
844
|
-
return new MDCTabScrollerFoundation(adapter);
|
|
845
|
-
};
|
|
846
|
-
/**
|
|
847
|
-
* Returns the current visual scroll position
|
|
848
|
-
*/
|
|
849
|
-
MDCTabScroller.prototype.getScrollPosition = function () {
|
|
850
|
-
return this.foundation.getScrollPosition();
|
|
851
|
-
};
|
|
852
|
-
/**
|
|
853
|
-
* Returns the width of the scroll content
|
|
854
|
-
*/
|
|
855
|
-
MDCTabScroller.prototype.getScrollContentWidth = function () {
|
|
856
|
-
return this.content.offsetWidth;
|
|
857
|
-
};
|
|
858
|
-
/**
|
|
859
|
-
* Increments the scroll value by the given amount
|
|
860
|
-
* @param scrollXIncrement The pixel value by which to increment the scroll value
|
|
861
|
-
*/
|
|
862
|
-
MDCTabScroller.prototype.incrementScroll = function (scrollXIncrement) {
|
|
863
|
-
this.foundation.incrementScroll(scrollXIncrement);
|
|
864
|
-
};
|
|
865
|
-
/**
|
|
866
|
-
* Scrolls to the given pixel position
|
|
867
|
-
* @param scrollX The pixel value to scroll to
|
|
868
|
-
*/
|
|
869
|
-
MDCTabScroller.prototype.scrollTo = function (scrollX) {
|
|
870
|
-
this.foundation.scrollTo(scrollX);
|
|
871
|
-
};
|
|
872
|
-
return MDCTabScroller;
|
|
873
|
-
}(MDCComponent));
|
|
874
|
-
|
|
875
|
-
/**
|
|
876
|
-
* @license
|
|
877
|
-
* Copyright 2018 Google Inc.
|
|
878
|
-
*
|
|
879
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
880
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
881
|
-
* in the Software without restriction, including without limitation the rights
|
|
882
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
883
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
884
|
-
* furnished to do so, subject to the following conditions:
|
|
885
|
-
*
|
|
886
|
-
* The above copyright notice and this permission notice shall be included in
|
|
887
|
-
* all copies or substantial portions of the Software.
|
|
888
|
-
*
|
|
889
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
890
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
891
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
892
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
893
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
894
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
895
|
-
* THE SOFTWARE.
|
|
117
|
+
* Returned when there is no item to move to.
|
|
896
118
|
*/
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
119
|
+
const NO_NAVIGATION_TARGET = -1;
|
|
120
|
+
const MOVES = {
|
|
121
|
+
horizontal: new Map([
|
|
122
|
+
[ARROW_LEFT, 'previous'],
|
|
123
|
+
[ARROW_RIGHT, 'next'],
|
|
124
|
+
[HOME, 'first'],
|
|
125
|
+
[END, 'last'],
|
|
126
|
+
]),
|
|
127
|
+
vertical: new Map([
|
|
128
|
+
[ARROW_UP, 'previous'],
|
|
129
|
+
[ARROW_DOWN, 'next'],
|
|
130
|
+
[HOME, 'first'],
|
|
131
|
+
[END, 'last'],
|
|
132
|
+
]),
|
|
904
133
|
};
|
|
905
|
-
|
|
906
134
|
/**
|
|
907
|
-
*
|
|
908
|
-
*
|
|
135
|
+
* Whether a keyboard event is one that moves between the items: an arrow key
|
|
136
|
+
* that goes along the orientation, or Home or End.
|
|
909
137
|
*
|
|
910
|
-
*
|
|
911
|
-
*
|
|
912
|
-
*
|
|
913
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
914
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
915
|
-
* furnished to do so, subject to the following conditions:
|
|
138
|
+
* A key that is pressed with Alt, Ctrl or Cmd is not, since the browser puts
|
|
139
|
+
* those to its own use, such as going back with Alt and the left arrow. Shift
|
|
140
|
+
* is allowed.
|
|
916
141
|
*
|
|
917
|
-
*
|
|
918
|
-
*
|
|
142
|
+
* When this returns `true`, the component should prevent the default action
|
|
143
|
+
* of the event, so that the page does not scroll. Also when there turns out to
|
|
144
|
+
* be nowhere to move to.
|
|
919
145
|
*
|
|
920
|
-
*
|
|
921
|
-
*
|
|
922
|
-
*
|
|
923
|
-
*
|
|
924
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
925
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
926
|
-
* THE SOFTWARE.
|
|
146
|
+
* @param event - the keyboard event to inspect
|
|
147
|
+
* @param options - the same options that are used to move between the items.
|
|
148
|
+
* Only the orientation matters here.
|
|
149
|
+
* @returns `true` when the event is for moving between the items
|
|
927
150
|
*/
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
return _super.call(this, __assign(__assign({}, MDCTabIndicatorFoundation.defaultAdapter), adapter)) || this;
|
|
151
|
+
function isNavigationKey(event, options) {
|
|
152
|
+
if (event.altKey || event.ctrlKey || event.metaKey) {
|
|
153
|
+
return false;
|
|
932
154
|
}
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
return cssClasses$1;
|
|
936
|
-
},
|
|
937
|
-
enumerable: false,
|
|
938
|
-
configurable: true
|
|
939
|
-
});
|
|
940
|
-
Object.defineProperty(MDCTabIndicatorFoundation, "strings", {
|
|
941
|
-
get: function () {
|
|
942
|
-
return strings$3;
|
|
943
|
-
},
|
|
944
|
-
enumerable: false,
|
|
945
|
-
configurable: true
|
|
946
|
-
});
|
|
947
|
-
Object.defineProperty(MDCTabIndicatorFoundation, "defaultAdapter", {
|
|
948
|
-
get: function () {
|
|
949
|
-
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
|
|
950
|
-
return {
|
|
951
|
-
addClass: function () { return undefined; },
|
|
952
|
-
removeClass: function () { return undefined; },
|
|
953
|
-
computeContentClientRect: function () {
|
|
954
|
-
return ({ top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 });
|
|
955
|
-
},
|
|
956
|
-
setContentStyleProperty: function () { return undefined; },
|
|
957
|
-
};
|
|
958
|
-
// tslint:enable:object-literal-sort-keys
|
|
959
|
-
},
|
|
960
|
-
enumerable: false,
|
|
961
|
-
configurable: true
|
|
962
|
-
});
|
|
963
|
-
MDCTabIndicatorFoundation.prototype.computeContentClientRect = function () {
|
|
964
|
-
return this.adapter.computeContentClientRect();
|
|
965
|
-
};
|
|
966
|
-
return MDCTabIndicatorFoundation;
|
|
967
|
-
}(MDCFoundation));
|
|
968
|
-
|
|
969
|
-
/**
|
|
970
|
-
* @license
|
|
971
|
-
* Copyright 2018 Google Inc.
|
|
972
|
-
*
|
|
973
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
974
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
975
|
-
* in the Software without restriction, including without limitation the rights
|
|
976
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
977
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
978
|
-
* furnished to do so, subject to the following conditions:
|
|
979
|
-
*
|
|
980
|
-
* The above copyright notice and this permission notice shall be included in
|
|
981
|
-
* all copies or substantial portions of the Software.
|
|
982
|
-
*
|
|
983
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
984
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
985
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
986
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
987
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
988
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
989
|
-
* THE SOFTWARE.
|
|
990
|
-
*/
|
|
991
|
-
/* istanbul ignore next: subclass is not a branch statement */
|
|
992
|
-
var MDCFadingTabIndicatorFoundation = /** @class */ (function (_super) {
|
|
993
|
-
__extends(MDCFadingTabIndicatorFoundation, _super);
|
|
994
|
-
function MDCFadingTabIndicatorFoundation() {
|
|
995
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
996
|
-
}
|
|
997
|
-
MDCFadingTabIndicatorFoundation.prototype.activate = function () {
|
|
998
|
-
this.adapter.addClass(MDCTabIndicatorFoundation.cssClasses.ACTIVE);
|
|
999
|
-
};
|
|
1000
|
-
MDCFadingTabIndicatorFoundation.prototype.deactivate = function () {
|
|
1001
|
-
this.adapter.removeClass(MDCTabIndicatorFoundation.cssClasses.ACTIVE);
|
|
1002
|
-
};
|
|
1003
|
-
return MDCFadingTabIndicatorFoundation;
|
|
1004
|
-
}(MDCTabIndicatorFoundation));
|
|
1005
|
-
|
|
1006
|
-
/**
|
|
1007
|
-
* @license
|
|
1008
|
-
* Copyright 2018 Google Inc.
|
|
1009
|
-
*
|
|
1010
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
1011
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
1012
|
-
* in the Software without restriction, including without limitation the rights
|
|
1013
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
1014
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
1015
|
-
* furnished to do so, subject to the following conditions:
|
|
1016
|
-
*
|
|
1017
|
-
* The above copyright notice and this permission notice shall be included in
|
|
1018
|
-
* all copies or substantial portions of the Software.
|
|
1019
|
-
*
|
|
1020
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
1021
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
1022
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
1023
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
1024
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
1025
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
1026
|
-
* THE SOFTWARE.
|
|
1027
|
-
*/
|
|
1028
|
-
/* istanbul ignore next: subclass is not a branch statement */
|
|
1029
|
-
var MDCSlidingTabIndicatorFoundation = /** @class */ (function (_super) {
|
|
1030
|
-
__extends(MDCSlidingTabIndicatorFoundation, _super);
|
|
1031
|
-
function MDCSlidingTabIndicatorFoundation() {
|
|
1032
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
1033
|
-
}
|
|
1034
|
-
MDCSlidingTabIndicatorFoundation.prototype.activate = function (previousIndicatorClientRect) {
|
|
1035
|
-
// Early exit if no indicator is present to handle cases where an indicator
|
|
1036
|
-
// may be activated without a prior indicator state
|
|
1037
|
-
if (!previousIndicatorClientRect) {
|
|
1038
|
-
this.adapter.addClass(MDCTabIndicatorFoundation.cssClasses.ACTIVE);
|
|
1039
|
-
return;
|
|
1040
|
-
}
|
|
1041
|
-
// This animation uses the FLIP approach. You can read more about it at the link below:
|
|
1042
|
-
// https://aerotwist.com/blog/flip-your-animations/
|
|
1043
|
-
// Calculate the dimensions based on the dimensions of the previous indicator
|
|
1044
|
-
var currentClientRect = this.computeContentClientRect();
|
|
1045
|
-
var widthDelta = previousIndicatorClientRect.width / currentClientRect.width;
|
|
1046
|
-
var xPosition = previousIndicatorClientRect.left - currentClientRect.left;
|
|
1047
|
-
this.adapter.addClass(MDCTabIndicatorFoundation.cssClasses.NO_TRANSITION);
|
|
1048
|
-
this.adapter.setContentStyleProperty('transform', "translateX(" + xPosition + "px) scaleX(" + widthDelta + ")");
|
|
1049
|
-
// Force repaint before updating classes and transform to ensure the transform properly takes effect
|
|
1050
|
-
this.computeContentClientRect();
|
|
1051
|
-
this.adapter.removeClass(MDCTabIndicatorFoundation.cssClasses.NO_TRANSITION);
|
|
1052
|
-
this.adapter.addClass(MDCTabIndicatorFoundation.cssClasses.ACTIVE);
|
|
1053
|
-
this.adapter.setContentStyleProperty('transform', '');
|
|
1054
|
-
};
|
|
1055
|
-
MDCSlidingTabIndicatorFoundation.prototype.deactivate = function () {
|
|
1056
|
-
this.adapter.removeClass(MDCTabIndicatorFoundation.cssClasses.ACTIVE);
|
|
1057
|
-
};
|
|
1058
|
-
return MDCSlidingTabIndicatorFoundation;
|
|
1059
|
-
}(MDCTabIndicatorFoundation));
|
|
1060
|
-
|
|
1061
|
-
/**
|
|
1062
|
-
* @license
|
|
1063
|
-
* Copyright 2018 Google Inc.
|
|
1064
|
-
*
|
|
1065
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
1066
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
1067
|
-
* in the Software without restriction, including without limitation the rights
|
|
1068
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
1069
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
1070
|
-
* furnished to do so, subject to the following conditions:
|
|
1071
|
-
*
|
|
1072
|
-
* The above copyright notice and this permission notice shall be included in
|
|
1073
|
-
* all copies or substantial portions of the Software.
|
|
1074
|
-
*
|
|
1075
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
1076
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
1077
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
1078
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
1079
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
1080
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
1081
|
-
* THE SOFTWARE.
|
|
1082
|
-
*/
|
|
1083
|
-
var MDCTabIndicator = /** @class */ (function (_super) {
|
|
1084
|
-
__extends(MDCTabIndicator, _super);
|
|
1085
|
-
function MDCTabIndicator() {
|
|
1086
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
1087
|
-
}
|
|
1088
|
-
MDCTabIndicator.attachTo = function (root) {
|
|
1089
|
-
return new MDCTabIndicator(root);
|
|
1090
|
-
};
|
|
1091
|
-
MDCTabIndicator.prototype.initialize = function () {
|
|
1092
|
-
this.content = this.root.querySelector(MDCTabIndicatorFoundation.strings.CONTENT_SELECTOR);
|
|
1093
|
-
};
|
|
1094
|
-
MDCTabIndicator.prototype.computeContentClientRect = function () {
|
|
1095
|
-
return this.foundation.computeContentClientRect();
|
|
1096
|
-
};
|
|
1097
|
-
MDCTabIndicator.prototype.getDefaultFoundation = function () {
|
|
1098
|
-
var _this = this;
|
|
1099
|
-
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
|
|
1100
|
-
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
|
|
1101
|
-
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
|
|
1102
|
-
var adapter = {
|
|
1103
|
-
addClass: function (className) { return _this.root.classList.add(className); },
|
|
1104
|
-
removeClass: function (className) { return _this.root.classList.remove(className); },
|
|
1105
|
-
computeContentClientRect: function () { return _this.content.getBoundingClientRect(); },
|
|
1106
|
-
setContentStyleProperty: function (prop, value) {
|
|
1107
|
-
_this.content.style.setProperty(prop, value);
|
|
1108
|
-
},
|
|
1109
|
-
};
|
|
1110
|
-
// tslint:enable:object-literal-sort-keys
|
|
1111
|
-
if (this.root.classList.contains(MDCTabIndicatorFoundation.cssClasses.FADE)) {
|
|
1112
|
-
return new MDCFadingTabIndicatorFoundation(adapter);
|
|
1113
|
-
}
|
|
1114
|
-
// Default to the sliding indicator
|
|
1115
|
-
return new MDCSlidingTabIndicatorFoundation(adapter);
|
|
1116
|
-
};
|
|
1117
|
-
MDCTabIndicator.prototype.activate = function (previousIndicatorClientRect) {
|
|
1118
|
-
this.foundation.activate(previousIndicatorClientRect);
|
|
1119
|
-
};
|
|
1120
|
-
MDCTabIndicator.prototype.deactivate = function () {
|
|
1121
|
-
this.foundation.deactivate();
|
|
1122
|
-
};
|
|
1123
|
-
return MDCTabIndicator;
|
|
1124
|
-
}(MDCComponent));
|
|
1125
|
-
|
|
1126
|
-
/**
|
|
1127
|
-
* @license
|
|
1128
|
-
* Copyright 2018 Google Inc.
|
|
1129
|
-
*
|
|
1130
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
1131
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
1132
|
-
* in the Software without restriction, including without limitation the rights
|
|
1133
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
1134
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
1135
|
-
* furnished to do so, subject to the following conditions:
|
|
1136
|
-
*
|
|
1137
|
-
* The above copyright notice and this permission notice shall be included in
|
|
1138
|
-
* all copies or substantial portions of the Software.
|
|
1139
|
-
*
|
|
1140
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
1141
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
1142
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
1143
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
1144
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
1145
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
1146
|
-
* THE SOFTWARE.
|
|
1147
|
-
*/
|
|
1148
|
-
var cssClasses = {
|
|
1149
|
-
ACTIVE: 'mdc-tab--active',
|
|
1150
|
-
};
|
|
1151
|
-
var strings$2 = {
|
|
1152
|
-
ARIA_SELECTED: 'aria-selected',
|
|
1153
|
-
CONTENT_SELECTOR: '.mdc-tab__content',
|
|
1154
|
-
INTERACTED_EVENT: 'MDCTab:interacted',
|
|
1155
|
-
RIPPLE_SELECTOR: '.mdc-tab__ripple',
|
|
1156
|
-
TABINDEX: 'tabIndex',
|
|
1157
|
-
TAB_INDICATOR_SELECTOR: '.mdc-tab-indicator',
|
|
1158
|
-
};
|
|
1159
|
-
|
|
1160
|
-
/**
|
|
1161
|
-
* @license
|
|
1162
|
-
* Copyright 2018 Google Inc.
|
|
1163
|
-
*
|
|
1164
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
1165
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
1166
|
-
* in the Software without restriction, including without limitation the rights
|
|
1167
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
1168
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
1169
|
-
* furnished to do so, subject to the following conditions:
|
|
1170
|
-
*
|
|
1171
|
-
* The above copyright notice and this permission notice shall be included in
|
|
1172
|
-
* all copies or substantial portions of the Software.
|
|
1173
|
-
*
|
|
1174
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
1175
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
1176
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
1177
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
1178
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
1179
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
1180
|
-
* THE SOFTWARE.
|
|
1181
|
-
*/
|
|
1182
|
-
var MDCTabFoundation = /** @class */ (function (_super) {
|
|
1183
|
-
__extends(MDCTabFoundation, _super);
|
|
1184
|
-
function MDCTabFoundation(adapter) {
|
|
1185
|
-
var _this = _super.call(this, __assign(__assign({}, MDCTabFoundation.defaultAdapter), adapter)) || this;
|
|
1186
|
-
_this.focusOnActivate = true;
|
|
1187
|
-
return _this;
|
|
1188
|
-
}
|
|
1189
|
-
Object.defineProperty(MDCTabFoundation, "cssClasses", {
|
|
1190
|
-
get: function () {
|
|
1191
|
-
return cssClasses;
|
|
1192
|
-
},
|
|
1193
|
-
enumerable: false,
|
|
1194
|
-
configurable: true
|
|
1195
|
-
});
|
|
1196
|
-
Object.defineProperty(MDCTabFoundation, "strings", {
|
|
1197
|
-
get: function () {
|
|
1198
|
-
return strings$2;
|
|
1199
|
-
},
|
|
1200
|
-
enumerable: false,
|
|
1201
|
-
configurable: true
|
|
1202
|
-
});
|
|
1203
|
-
Object.defineProperty(MDCTabFoundation, "defaultAdapter", {
|
|
1204
|
-
get: function () {
|
|
1205
|
-
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
|
|
1206
|
-
return {
|
|
1207
|
-
addClass: function () { return undefined; },
|
|
1208
|
-
removeClass: function () { return undefined; },
|
|
1209
|
-
hasClass: function () { return false; },
|
|
1210
|
-
setAttr: function () { return undefined; },
|
|
1211
|
-
activateIndicator: function () { return undefined; },
|
|
1212
|
-
deactivateIndicator: function () { return undefined; },
|
|
1213
|
-
notifyInteracted: function () { return undefined; },
|
|
1214
|
-
getOffsetLeft: function () { return 0; },
|
|
1215
|
-
getOffsetWidth: function () { return 0; },
|
|
1216
|
-
getContentOffsetLeft: function () { return 0; },
|
|
1217
|
-
getContentOffsetWidth: function () { return 0; },
|
|
1218
|
-
focus: function () { return undefined; },
|
|
1219
|
-
};
|
|
1220
|
-
// tslint:enable:object-literal-sort-keys
|
|
1221
|
-
},
|
|
1222
|
-
enumerable: false,
|
|
1223
|
-
configurable: true
|
|
1224
|
-
});
|
|
1225
|
-
MDCTabFoundation.prototype.handleClick = function () {
|
|
1226
|
-
// It's up to the parent component to keep track of the active Tab and
|
|
1227
|
-
// ensure we don't activate a Tab that's already active.
|
|
1228
|
-
this.adapter.notifyInteracted();
|
|
1229
|
-
};
|
|
1230
|
-
MDCTabFoundation.prototype.isActive = function () {
|
|
1231
|
-
return this.adapter.hasClass(cssClasses.ACTIVE);
|
|
1232
|
-
};
|
|
1233
|
-
/**
|
|
1234
|
-
* Sets whether the tab should focus itself when activated
|
|
1235
|
-
*/
|
|
1236
|
-
MDCTabFoundation.prototype.setFocusOnActivate = function (focusOnActivate) {
|
|
1237
|
-
this.focusOnActivate = focusOnActivate;
|
|
1238
|
-
};
|
|
1239
|
-
/**
|
|
1240
|
-
* Activates the Tab
|
|
1241
|
-
*/
|
|
1242
|
-
MDCTabFoundation.prototype.activate = function (previousIndicatorClientRect) {
|
|
1243
|
-
this.adapter.addClass(cssClasses.ACTIVE);
|
|
1244
|
-
this.adapter.setAttr(strings$2.ARIA_SELECTED, 'true');
|
|
1245
|
-
this.adapter.setAttr(strings$2.TABINDEX, '0');
|
|
1246
|
-
this.adapter.activateIndicator(previousIndicatorClientRect);
|
|
1247
|
-
if (this.focusOnActivate) {
|
|
1248
|
-
this.adapter.focus();
|
|
1249
|
-
}
|
|
1250
|
-
};
|
|
1251
|
-
/**
|
|
1252
|
-
* Deactivates the Tab
|
|
1253
|
-
*/
|
|
1254
|
-
MDCTabFoundation.prototype.deactivate = function () {
|
|
1255
|
-
// Early exit
|
|
1256
|
-
if (!this.isActive()) {
|
|
1257
|
-
return;
|
|
1258
|
-
}
|
|
1259
|
-
this.adapter.removeClass(cssClasses.ACTIVE);
|
|
1260
|
-
this.adapter.setAttr(strings$2.ARIA_SELECTED, 'false');
|
|
1261
|
-
this.adapter.setAttr(strings$2.TABINDEX, '-1');
|
|
1262
|
-
this.adapter.deactivateIndicator();
|
|
1263
|
-
};
|
|
1264
|
-
/**
|
|
1265
|
-
* Returns the dimensions of the Tab
|
|
1266
|
-
*/
|
|
1267
|
-
MDCTabFoundation.prototype.computeDimensions = function () {
|
|
1268
|
-
var rootWidth = this.adapter.getOffsetWidth();
|
|
1269
|
-
var rootLeft = this.adapter.getOffsetLeft();
|
|
1270
|
-
var contentWidth = this.adapter.getContentOffsetWidth();
|
|
1271
|
-
var contentLeft = this.adapter.getContentOffsetLeft();
|
|
1272
|
-
return {
|
|
1273
|
-
contentLeft: rootLeft + contentLeft,
|
|
1274
|
-
contentRight: rootLeft + contentLeft + contentWidth,
|
|
1275
|
-
rootLeft: rootLeft,
|
|
1276
|
-
rootRight: rootLeft + rootWidth,
|
|
1277
|
-
};
|
|
1278
|
-
};
|
|
1279
|
-
return MDCTabFoundation;
|
|
1280
|
-
}(MDCFoundation));
|
|
1281
|
-
|
|
1282
|
-
/**
|
|
1283
|
-
* @license
|
|
1284
|
-
* Copyright 2018 Google Inc.
|
|
1285
|
-
*
|
|
1286
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
1287
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
1288
|
-
* in the Software without restriction, including without limitation the rights
|
|
1289
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
1290
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
1291
|
-
* furnished to do so, subject to the following conditions:
|
|
1292
|
-
*
|
|
1293
|
-
* The above copyright notice and this permission notice shall be included in
|
|
1294
|
-
* all copies or substantial portions of the Software.
|
|
1295
|
-
*
|
|
1296
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
1297
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
1298
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
1299
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
1300
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
1301
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
1302
|
-
* THE SOFTWARE.
|
|
1303
|
-
*/
|
|
1304
|
-
var MDCTab = /** @class */ (function (_super) {
|
|
1305
|
-
__extends(MDCTab, _super);
|
|
1306
|
-
function MDCTab() {
|
|
1307
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
1308
|
-
}
|
|
1309
|
-
MDCTab.attachTo = function (root) {
|
|
1310
|
-
return new MDCTab(root);
|
|
1311
|
-
};
|
|
1312
|
-
MDCTab.prototype.initialize = function (rippleFactory, tabIndicatorFactory) {
|
|
1313
|
-
if (rippleFactory === void 0) { rippleFactory = function (el, foundation) { return new MDCRipple(el, foundation); }; }
|
|
1314
|
-
if (tabIndicatorFactory === void 0) { tabIndicatorFactory = function (el) { return new MDCTabIndicator(el); }; }
|
|
1315
|
-
this.id = this.root.id;
|
|
1316
|
-
var rippleFoundation = new MDCRippleFoundation(MDCRipple.createAdapter(this));
|
|
1317
|
-
this.ripple = rippleFactory(this.root, rippleFoundation);
|
|
1318
|
-
var tabIndicatorElement = this.root.querySelector(MDCTabFoundation.strings.TAB_INDICATOR_SELECTOR);
|
|
1319
|
-
this.tabIndicator = tabIndicatorFactory(tabIndicatorElement);
|
|
1320
|
-
this.content = this.root.querySelector(MDCTabFoundation.strings.CONTENT_SELECTOR);
|
|
1321
|
-
};
|
|
1322
|
-
MDCTab.prototype.initialSyncWithDOM = function () {
|
|
1323
|
-
var _this = this;
|
|
1324
|
-
this.handleClick = function () {
|
|
1325
|
-
_this.foundation.handleClick();
|
|
1326
|
-
};
|
|
1327
|
-
this.listen('click', this.handleClick);
|
|
1328
|
-
};
|
|
1329
|
-
MDCTab.prototype.destroy = function () {
|
|
1330
|
-
this.unlisten('click', this.handleClick);
|
|
1331
|
-
this.ripple.destroy();
|
|
1332
|
-
_super.prototype.destroy.call(this);
|
|
1333
|
-
};
|
|
1334
|
-
MDCTab.prototype.getDefaultFoundation = function () {
|
|
1335
|
-
var _this = this;
|
|
1336
|
-
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
|
|
1337
|
-
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
|
|
1338
|
-
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
|
|
1339
|
-
var adapter = {
|
|
1340
|
-
setAttr: function (attr, value) { return _this.root.setAttribute(attr, value); },
|
|
1341
|
-
addClass: function (className) { return _this.root.classList.add(className); },
|
|
1342
|
-
removeClass: function (className) { return _this.root.classList.remove(className); },
|
|
1343
|
-
hasClass: function (className) { return _this.root.classList.contains(className); },
|
|
1344
|
-
activateIndicator: function (previousIndicatorClientRect) {
|
|
1345
|
-
_this.tabIndicator.activate(previousIndicatorClientRect);
|
|
1346
|
-
},
|
|
1347
|
-
deactivateIndicator: function () {
|
|
1348
|
-
_this.tabIndicator.deactivate();
|
|
1349
|
-
},
|
|
1350
|
-
notifyInteracted: function () { return _this.emit(MDCTabFoundation.strings.INTERACTED_EVENT, { tabId: _this.id }, true /* bubble */); },
|
|
1351
|
-
getOffsetLeft: function () { return _this.root.offsetLeft; },
|
|
1352
|
-
getOffsetWidth: function () { return _this.root.offsetWidth; },
|
|
1353
|
-
getContentOffsetLeft: function () { return _this.content.offsetLeft; },
|
|
1354
|
-
getContentOffsetWidth: function () { return _this.content.offsetWidth; },
|
|
1355
|
-
focus: function () { return _this.root.focus(); },
|
|
1356
|
-
};
|
|
1357
|
-
// tslint:enable:object-literal-sort-keys
|
|
1358
|
-
return new MDCTabFoundation(adapter);
|
|
1359
|
-
};
|
|
1360
|
-
Object.defineProperty(MDCTab.prototype, "active", {
|
|
1361
|
-
/**
|
|
1362
|
-
* Getter for the active state of the tab
|
|
1363
|
-
*/
|
|
1364
|
-
get: function () {
|
|
1365
|
-
return this.foundation.isActive();
|
|
1366
|
-
},
|
|
1367
|
-
enumerable: false,
|
|
1368
|
-
configurable: true
|
|
1369
|
-
});
|
|
1370
|
-
Object.defineProperty(MDCTab.prototype, "focusOnActivate", {
|
|
1371
|
-
set: function (focusOnActivate) {
|
|
1372
|
-
this.foundation.setFocusOnActivate(focusOnActivate);
|
|
1373
|
-
},
|
|
1374
|
-
enumerable: false,
|
|
1375
|
-
configurable: true
|
|
1376
|
-
});
|
|
1377
|
-
/**
|
|
1378
|
-
* Activates the tab
|
|
1379
|
-
*/
|
|
1380
|
-
MDCTab.prototype.activate = function (computeIndicatorClientRect) {
|
|
1381
|
-
this.foundation.activate(computeIndicatorClientRect);
|
|
1382
|
-
};
|
|
1383
|
-
/**
|
|
1384
|
-
* Deactivates the tab
|
|
1385
|
-
*/
|
|
1386
|
-
MDCTab.prototype.deactivate = function () {
|
|
1387
|
-
this.foundation.deactivate();
|
|
1388
|
-
};
|
|
1389
|
-
/**
|
|
1390
|
-
* Returns the indicator's client rect
|
|
1391
|
-
*/
|
|
1392
|
-
MDCTab.prototype.computeIndicatorClientRect = function () {
|
|
1393
|
-
return this.tabIndicator.computeContentClientRect();
|
|
1394
|
-
};
|
|
1395
|
-
MDCTab.prototype.computeDimensions = function () {
|
|
1396
|
-
return this.foundation.computeDimensions();
|
|
1397
|
-
};
|
|
1398
|
-
/**
|
|
1399
|
-
* Focuses the tab
|
|
1400
|
-
*/
|
|
1401
|
-
MDCTab.prototype.focus = function () {
|
|
1402
|
-
this.root.focus();
|
|
1403
|
-
};
|
|
1404
|
-
return MDCTab;
|
|
1405
|
-
}(MDCComponent));
|
|
1406
|
-
|
|
155
|
+
return MOVES[options.orientation].has(event.key);
|
|
156
|
+
}
|
|
1407
157
|
/**
|
|
1408
|
-
*
|
|
1409
|
-
*
|
|
1410
|
-
*
|
|
1411
|
-
*
|
|
1412
|
-
*
|
|
1413
|
-
*
|
|
1414
|
-
*
|
|
1415
|
-
*
|
|
1416
|
-
*
|
|
1417
|
-
*
|
|
1418
|
-
*
|
|
1419
|
-
*
|
|
1420
|
-
*
|
|
1421
|
-
*
|
|
1422
|
-
*
|
|
1423
|
-
*
|
|
1424
|
-
*
|
|
1425
|
-
*
|
|
1426
|
-
*
|
|
1427
|
-
*
|
|
158
|
+
* Find the item that a key press moves to.
|
|
159
|
+
*
|
|
160
|
+
* - The arrow keys that go along the orientation move to the next and the
|
|
161
|
+
* previous item. At the ends they stop, or continue at the other end when
|
|
162
|
+
* `options.wrap` is set.
|
|
163
|
+
* - Home and End move to the first and the last item.
|
|
164
|
+
* - Items that cannot be moved to are skipped.
|
|
165
|
+
* - Without a current item, moving forward starts at the first item, and
|
|
166
|
+
* moving back at the last one.
|
|
167
|
+
*
|
|
168
|
+
* @param items - the items, in the order that they are laid out in. Only their
|
|
169
|
+
* number matters, unless `options.isDisabled` is given.
|
|
170
|
+
* @param key - the `key` of the keyboard event
|
|
171
|
+
* @param currentIndex - the index of the item to move from, usually the one
|
|
172
|
+
* that has focus. Anything outside `items` is treated as "no current item".
|
|
173
|
+
* @param options - which keys move, and how
|
|
174
|
+
* @returns the index of the item to move to. That is `currentIndex` itself
|
|
175
|
+
* when there is nowhere to go from there, since the end is reached and it does
|
|
176
|
+
* not wrap, or since it is the only item that can be moved to. It is
|
|
177
|
+
* `NO_NAVIGATION_TARGET` when the key does not move in this orientation, and
|
|
178
|
+
* when none of the items can be moved to.
|
|
1428
179
|
*/
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
}
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
180
|
+
function findNavigationTarget(items, key, currentIndex, options) {
|
|
181
|
+
const move = MOVES[options.orientation].get(key);
|
|
182
|
+
const count = items.length;
|
|
183
|
+
const canMoveTo = createReachableTest(items, options);
|
|
184
|
+
const first = findReachable(count, 0, 1, false, canMoveTo);
|
|
185
|
+
if (!move || first === NO_NAVIGATION_TARGET) {
|
|
186
|
+
return NO_NAVIGATION_TARGET;
|
|
187
|
+
}
|
|
188
|
+
if (move === 'first') {
|
|
189
|
+
return first;
|
|
190
|
+
}
|
|
191
|
+
const last = findReachable(count, count - 1, -1, false, canMoveTo);
|
|
192
|
+
if (move === 'last') {
|
|
193
|
+
return last;
|
|
194
|
+
}
|
|
195
|
+
if (!isWithin(currentIndex, count)) {
|
|
196
|
+
return move === 'next' ? first : last;
|
|
197
|
+
}
|
|
198
|
+
const step = move === 'next' ? 1 : -1;
|
|
199
|
+
const target = findReachable(count, currentIndex + step, step, Boolean(options.wrap), canMoveTo);
|
|
200
|
+
return target === NO_NAVIGATION_TARGET ? currentIndex : target;
|
|
201
|
+
}
|
|
1450
202
|
/**
|
|
1451
|
-
*
|
|
1452
|
-
*
|
|
1453
|
-
*
|
|
1454
|
-
*
|
|
1455
|
-
*
|
|
1456
|
-
*
|
|
1457
|
-
*
|
|
1458
|
-
*
|
|
1459
|
-
*
|
|
1460
|
-
*
|
|
1461
|
-
*
|
|
1462
|
-
*
|
|
1463
|
-
*
|
|
1464
|
-
*
|
|
1465
|
-
*
|
|
1466
|
-
*
|
|
1467
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
1468
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
1469
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
1470
|
-
* THE SOFTWARE.
|
|
203
|
+
* Find the item that should be in the tab order, which is the one that Tab
|
|
204
|
+
* lands on when it enters the group. The rest of the items are left out of the
|
|
205
|
+
* tab order, and are reached with the arrow keys.
|
|
206
|
+
*
|
|
207
|
+
* That is the preferred item, if it can be moved to. Otherwise the first item
|
|
208
|
+
* that can.
|
|
209
|
+
*
|
|
210
|
+
* @param items - the items, in the order that they are laid out in. Only their
|
|
211
|
+
* number matters, unless `options.isDisabled` is given.
|
|
212
|
+
* @param preferredIndex - the index of the item that should be in the tab
|
|
213
|
+
* order if possible. For a group with a selection that is the selected item,
|
|
214
|
+
* and otherwise the item that last had focus, which the component has to keep
|
|
215
|
+
* track of. Anything outside `items` means that there is no preference.
|
|
216
|
+
* @param options - the same options that are used to move between the items
|
|
217
|
+
* @returns the index of the item to put in the tab order, or
|
|
218
|
+
* `NO_NAVIGATION_TARGET` when none of the items can be moved to
|
|
1471
219
|
*/
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
ACCEPTABLE_KEYS.add(strings$1.HOME_KEY);
|
|
1478
|
-
ACCEPTABLE_KEYS.add(strings$1.ENTER_KEY);
|
|
1479
|
-
ACCEPTABLE_KEYS.add(strings$1.SPACE_KEY);
|
|
1480
|
-
var KEYCODE_MAP = new Map();
|
|
1481
|
-
// IE11 has no support for new Map with iterable so we need to initialize this by hand
|
|
1482
|
-
KEYCODE_MAP.set(numbers.ARROW_LEFT_KEYCODE, strings$1.ARROW_LEFT_KEY);
|
|
1483
|
-
KEYCODE_MAP.set(numbers.ARROW_RIGHT_KEYCODE, strings$1.ARROW_RIGHT_KEY);
|
|
1484
|
-
KEYCODE_MAP.set(numbers.END_KEYCODE, strings$1.END_KEY);
|
|
1485
|
-
KEYCODE_MAP.set(numbers.HOME_KEYCODE, strings$1.HOME_KEY);
|
|
1486
|
-
KEYCODE_MAP.set(numbers.ENTER_KEYCODE, strings$1.ENTER_KEY);
|
|
1487
|
-
KEYCODE_MAP.set(numbers.SPACE_KEYCODE, strings$1.SPACE_KEY);
|
|
1488
|
-
var MDCTabBarFoundation = /** @class */ (function (_super) {
|
|
1489
|
-
__extends(MDCTabBarFoundation, _super);
|
|
1490
|
-
function MDCTabBarFoundation(adapter) {
|
|
1491
|
-
var _this = _super.call(this, __assign(__assign({}, MDCTabBarFoundation.defaultAdapter), adapter)) || this;
|
|
1492
|
-
_this.useAutomaticActivation = false;
|
|
1493
|
-
return _this;
|
|
220
|
+
function findTabStop(items, preferredIndex, options) {
|
|
221
|
+
const count = items.length;
|
|
222
|
+
const canMoveTo = createReachableTest(items, options);
|
|
223
|
+
if (isWithin(preferredIndex, count) && canMoveTo(preferredIndex)) {
|
|
224
|
+
return preferredIndex;
|
|
1494
225
|
}
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
get: function () {
|
|
1504
|
-
return numbers;
|
|
1505
|
-
},
|
|
1506
|
-
enumerable: false,
|
|
1507
|
-
configurable: true
|
|
1508
|
-
});
|
|
1509
|
-
Object.defineProperty(MDCTabBarFoundation, "defaultAdapter", {
|
|
1510
|
-
get: function () {
|
|
1511
|
-
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
|
|
1512
|
-
return {
|
|
1513
|
-
scrollTo: function () { return undefined; },
|
|
1514
|
-
incrementScroll: function () { return undefined; },
|
|
1515
|
-
getScrollPosition: function () { return 0; },
|
|
1516
|
-
getScrollContentWidth: function () { return 0; },
|
|
1517
|
-
getOffsetWidth: function () { return 0; },
|
|
1518
|
-
isRTL: function () { return false; },
|
|
1519
|
-
setActiveTab: function () { return undefined; },
|
|
1520
|
-
activateTabAtIndex: function () { return undefined; },
|
|
1521
|
-
deactivateTabAtIndex: function () { return undefined; },
|
|
1522
|
-
focusTabAtIndex: function () { return undefined; },
|
|
1523
|
-
getTabIndicatorClientRectAtIndex: function () {
|
|
1524
|
-
return ({ top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 });
|
|
1525
|
-
},
|
|
1526
|
-
getTabDimensionsAtIndex: function () {
|
|
1527
|
-
return ({ rootLeft: 0, rootRight: 0, contentLeft: 0, contentRight: 0 });
|
|
1528
|
-
},
|
|
1529
|
-
getPreviousActiveTabIndex: function () { return -1; },
|
|
1530
|
-
getFocusedTabIndex: function () { return -1; },
|
|
1531
|
-
getIndexOfTabById: function () { return -1; },
|
|
1532
|
-
getTabListLength: function () { return 0; },
|
|
1533
|
-
notifyTabActivated: function () { return undefined; },
|
|
1534
|
-
};
|
|
1535
|
-
// tslint:enable:object-literal-sort-keys
|
|
1536
|
-
},
|
|
1537
|
-
enumerable: false,
|
|
1538
|
-
configurable: true
|
|
1539
|
-
});
|
|
1540
|
-
/**
|
|
1541
|
-
* Switches between automatic and manual activation modes.
|
|
1542
|
-
* See https://www.w3.org/TR/wai-aria-practices/#tabpanel for examples.
|
|
1543
|
-
*/
|
|
1544
|
-
MDCTabBarFoundation.prototype.setUseAutomaticActivation = function (useAutomaticActivation) {
|
|
1545
|
-
this.useAutomaticActivation = useAutomaticActivation;
|
|
1546
|
-
};
|
|
1547
|
-
MDCTabBarFoundation.prototype.activateTab = function (index) {
|
|
1548
|
-
var previousActiveIndex = this.adapter.getPreviousActiveTabIndex();
|
|
1549
|
-
if (!this.indexIsInRange(index) || index === previousActiveIndex) {
|
|
1550
|
-
return;
|
|
1551
|
-
}
|
|
1552
|
-
var previousClientRect;
|
|
1553
|
-
if (previousActiveIndex !== -1) {
|
|
1554
|
-
this.adapter.deactivateTabAtIndex(previousActiveIndex);
|
|
1555
|
-
previousClientRect =
|
|
1556
|
-
this.adapter.getTabIndicatorClientRectAtIndex(previousActiveIndex);
|
|
1557
|
-
}
|
|
1558
|
-
this.adapter.activateTabAtIndex(index, previousClientRect);
|
|
1559
|
-
this.scrollIntoView(index);
|
|
1560
|
-
this.adapter.notifyTabActivated(index);
|
|
1561
|
-
};
|
|
1562
|
-
MDCTabBarFoundation.prototype.handleKeyDown = function (evt) {
|
|
1563
|
-
// Get the key from the event
|
|
1564
|
-
var key = this.getKeyFromEvent(evt);
|
|
1565
|
-
// Early exit if the event key isn't one of the keyboard navigation keys
|
|
1566
|
-
if (key === undefined) {
|
|
1567
|
-
return;
|
|
1568
|
-
}
|
|
1569
|
-
// Prevent default behavior for movement keys, but not for activation keys, since :active is used to apply ripple
|
|
1570
|
-
if (!this.isActivationKey(key)) {
|
|
1571
|
-
evt.preventDefault();
|
|
1572
|
-
}
|
|
1573
|
-
if (this.useAutomaticActivation) {
|
|
1574
|
-
if (this.isActivationKey(key)) {
|
|
1575
|
-
return;
|
|
1576
|
-
}
|
|
1577
|
-
var index = this.determineTargetFromKey(this.adapter.getPreviousActiveTabIndex(), key);
|
|
1578
|
-
this.adapter.setActiveTab(index);
|
|
1579
|
-
this.scrollIntoView(index);
|
|
1580
|
-
}
|
|
1581
|
-
else {
|
|
1582
|
-
var focusedTabIndex = this.adapter.getFocusedTabIndex();
|
|
1583
|
-
if (this.isActivationKey(key)) {
|
|
1584
|
-
this.adapter.setActiveTab(focusedTabIndex);
|
|
1585
|
-
}
|
|
1586
|
-
else {
|
|
1587
|
-
var index = this.determineTargetFromKey(focusedTabIndex, key);
|
|
1588
|
-
this.adapter.focusTabAtIndex(index);
|
|
1589
|
-
this.scrollIntoView(index);
|
|
1590
|
-
}
|
|
1591
|
-
}
|
|
1592
|
-
};
|
|
1593
|
-
/**
|
|
1594
|
-
* Handles the MDCTab:interacted event
|
|
1595
|
-
*/
|
|
1596
|
-
MDCTabBarFoundation.prototype.handleTabInteraction = function (evt) {
|
|
1597
|
-
this.adapter.setActiveTab(this.adapter.getIndexOfTabById(evt.detail.tabId));
|
|
1598
|
-
};
|
|
1599
|
-
/**
|
|
1600
|
-
* Scrolls the tab at the given index into view
|
|
1601
|
-
* @param index The tab index to make visible
|
|
1602
|
-
*/
|
|
1603
|
-
MDCTabBarFoundation.prototype.scrollIntoView = function (index) {
|
|
1604
|
-
// Early exit if the index is out of range
|
|
1605
|
-
if (!this.indexIsInRange(index)) {
|
|
1606
|
-
return;
|
|
1607
|
-
}
|
|
1608
|
-
// Always scroll to 0 if scrolling to the 0th index
|
|
1609
|
-
if (index === 0) {
|
|
1610
|
-
this.adapter.scrollTo(0);
|
|
1611
|
-
return;
|
|
1612
|
-
}
|
|
1613
|
-
// Always scroll to the max value if scrolling to the Nth index
|
|
1614
|
-
// MDCTabScroller.scrollTo() will never scroll past the max possible value
|
|
1615
|
-
if (index === this.adapter.getTabListLength() - 1) {
|
|
1616
|
-
this.adapter.scrollTo(this.adapter.getScrollContentWidth());
|
|
1617
|
-
return;
|
|
1618
|
-
}
|
|
1619
|
-
if (this.isRTL()) {
|
|
1620
|
-
this.scrollIntoViewImplRTL(index);
|
|
1621
|
-
return;
|
|
1622
|
-
}
|
|
1623
|
-
this.scrollIntoViewImpl(index);
|
|
1624
|
-
};
|
|
1625
|
-
/**
|
|
1626
|
-
* Private method for determining the index of the destination tab based on what key was pressed
|
|
1627
|
-
* @param origin The original index from which to determine the destination
|
|
1628
|
-
* @param key The name of the key
|
|
1629
|
-
*/
|
|
1630
|
-
MDCTabBarFoundation.prototype.determineTargetFromKey = function (origin, key) {
|
|
1631
|
-
var isRTL = this.isRTL();
|
|
1632
|
-
var maxIndex = this.adapter.getTabListLength() - 1;
|
|
1633
|
-
var shouldGoToEnd = key === strings$1.END_KEY;
|
|
1634
|
-
var shouldDecrement = key === strings$1.ARROW_LEFT_KEY && !isRTL || key === strings$1.ARROW_RIGHT_KEY && isRTL;
|
|
1635
|
-
var shouldIncrement = key === strings$1.ARROW_RIGHT_KEY && !isRTL || key === strings$1.ARROW_LEFT_KEY && isRTL;
|
|
1636
|
-
var index = origin;
|
|
1637
|
-
if (shouldGoToEnd) {
|
|
1638
|
-
index = maxIndex;
|
|
1639
|
-
}
|
|
1640
|
-
else if (shouldDecrement) {
|
|
1641
|
-
index -= 1;
|
|
1642
|
-
}
|
|
1643
|
-
else if (shouldIncrement) {
|
|
1644
|
-
index += 1;
|
|
1645
|
-
}
|
|
1646
|
-
else {
|
|
1647
|
-
index = 0;
|
|
1648
|
-
}
|
|
1649
|
-
if (index < 0) {
|
|
1650
|
-
index = maxIndex;
|
|
1651
|
-
}
|
|
1652
|
-
else if (index > maxIndex) {
|
|
1653
|
-
index = 0;
|
|
1654
|
-
}
|
|
1655
|
-
return index;
|
|
1656
|
-
};
|
|
1657
|
-
/**
|
|
1658
|
-
* Calculates the scroll increment that will make the tab at the given index visible
|
|
1659
|
-
* @param index The index of the tab
|
|
1660
|
-
* @param nextIndex The index of the next tab
|
|
1661
|
-
* @param scrollPosition The current scroll position
|
|
1662
|
-
* @param barWidth The width of the Tab Bar
|
|
1663
|
-
*/
|
|
1664
|
-
MDCTabBarFoundation.prototype.calculateScrollIncrement = function (index, nextIndex, scrollPosition, barWidth) {
|
|
1665
|
-
var nextTabDimensions = this.adapter.getTabDimensionsAtIndex(nextIndex);
|
|
1666
|
-
var relativeContentLeft = nextTabDimensions.contentLeft - scrollPosition - barWidth;
|
|
1667
|
-
var relativeContentRight = nextTabDimensions.contentRight - scrollPosition;
|
|
1668
|
-
var leftIncrement = relativeContentRight - numbers.EXTRA_SCROLL_AMOUNT;
|
|
1669
|
-
var rightIncrement = relativeContentLeft + numbers.EXTRA_SCROLL_AMOUNT;
|
|
1670
|
-
if (nextIndex < index) {
|
|
1671
|
-
return Math.min(leftIncrement, 0);
|
|
1672
|
-
}
|
|
1673
|
-
return Math.max(rightIncrement, 0);
|
|
1674
|
-
};
|
|
1675
|
-
/**
|
|
1676
|
-
* Calculates the scroll increment that will make the tab at the given index visible in RTL
|
|
1677
|
-
* @param index The index of the tab
|
|
1678
|
-
* @param nextIndex The index of the next tab
|
|
1679
|
-
* @param scrollPosition The current scroll position
|
|
1680
|
-
* @param barWidth The width of the Tab Bar
|
|
1681
|
-
* @param scrollContentWidth The width of the scroll content
|
|
1682
|
-
*/
|
|
1683
|
-
MDCTabBarFoundation.prototype.calculateScrollIncrementRTL = function (index, nextIndex, scrollPosition, barWidth, scrollContentWidth) {
|
|
1684
|
-
var nextTabDimensions = this.adapter.getTabDimensionsAtIndex(nextIndex);
|
|
1685
|
-
var relativeContentLeft = scrollContentWidth - nextTabDimensions.contentLeft - scrollPosition;
|
|
1686
|
-
var relativeContentRight = scrollContentWidth - nextTabDimensions.contentRight - scrollPosition - barWidth;
|
|
1687
|
-
var leftIncrement = relativeContentRight + numbers.EXTRA_SCROLL_AMOUNT;
|
|
1688
|
-
var rightIncrement = relativeContentLeft - numbers.EXTRA_SCROLL_AMOUNT;
|
|
1689
|
-
if (nextIndex > index) {
|
|
1690
|
-
return Math.max(leftIncrement, 0);
|
|
1691
|
-
}
|
|
1692
|
-
return Math.min(rightIncrement, 0);
|
|
1693
|
-
};
|
|
1694
|
-
/**
|
|
1695
|
-
* Determines the index of the adjacent tab closest to either edge of the Tab Bar
|
|
1696
|
-
* @param index The index of the tab
|
|
1697
|
-
* @param tabDimensions The dimensions of the tab
|
|
1698
|
-
* @param scrollPosition The current scroll position
|
|
1699
|
-
* @param barWidth The width of the tab bar
|
|
1700
|
-
*/
|
|
1701
|
-
MDCTabBarFoundation.prototype.findAdjacentTabIndexClosestToEdge = function (index, tabDimensions, scrollPosition, barWidth) {
|
|
1702
|
-
/**
|
|
1703
|
-
* Tabs are laid out in the Tab Scroller like this:
|
|
1704
|
-
*
|
|
1705
|
-
* Scroll Position
|
|
1706
|
-
* +---+
|
|
1707
|
-
* | | Bar Width
|
|
1708
|
-
* | +-----------------------------------+
|
|
1709
|
-
* | | |
|
|
1710
|
-
* | V V
|
|
1711
|
-
* | +-----------------------------------+
|
|
1712
|
-
* V | Tab Scroller |
|
|
1713
|
-
* +------------+--------------+-------------------+
|
|
1714
|
-
* | Tab | Tab | Tab |
|
|
1715
|
-
* +------------+--------------+-------------------+
|
|
1716
|
-
* | |
|
|
1717
|
-
* +-----------------------------------+
|
|
1718
|
-
*
|
|
1719
|
-
* To determine the next adjacent index, we look at the Tab root left and
|
|
1720
|
-
* Tab root right, both relative to the scroll position. If the Tab root
|
|
1721
|
-
* left is less than 0, then we know it's out of view to the left. If the
|
|
1722
|
-
* Tab root right minus the bar width is greater than 0, we know the Tab is
|
|
1723
|
-
* out of view to the right. From there, we either increment or decrement
|
|
1724
|
-
* the index.
|
|
1725
|
-
*/
|
|
1726
|
-
var relativeRootLeft = tabDimensions.rootLeft - scrollPosition;
|
|
1727
|
-
var relativeRootRight = tabDimensions.rootRight - scrollPosition - barWidth;
|
|
1728
|
-
var relativeRootDelta = relativeRootLeft + relativeRootRight;
|
|
1729
|
-
var leftEdgeIsCloser = relativeRootLeft < 0 || relativeRootDelta < 0;
|
|
1730
|
-
var rightEdgeIsCloser = relativeRootRight > 0 || relativeRootDelta > 0;
|
|
1731
|
-
if (leftEdgeIsCloser) {
|
|
1732
|
-
return index - 1;
|
|
1733
|
-
}
|
|
1734
|
-
if (rightEdgeIsCloser) {
|
|
1735
|
-
return index + 1;
|
|
1736
|
-
}
|
|
1737
|
-
return -1;
|
|
1738
|
-
};
|
|
1739
|
-
/**
|
|
1740
|
-
* Determines the index of the adjacent tab closest to either edge of the Tab Bar in RTL
|
|
1741
|
-
* @param index The index of the tab
|
|
1742
|
-
* @param tabDimensions The dimensions of the tab
|
|
1743
|
-
* @param scrollPosition The current scroll position
|
|
1744
|
-
* @param barWidth The width of the tab bar
|
|
1745
|
-
* @param scrollContentWidth The width of the scroller content
|
|
1746
|
-
*/
|
|
1747
|
-
MDCTabBarFoundation.prototype.findAdjacentTabIndexClosestToEdgeRTL = function (index, tabDimensions, scrollPosition, barWidth, scrollContentWidth) {
|
|
1748
|
-
var rootLeft = scrollContentWidth - tabDimensions.rootLeft - barWidth - scrollPosition;
|
|
1749
|
-
var rootRight = scrollContentWidth - tabDimensions.rootRight - scrollPosition;
|
|
1750
|
-
var rootDelta = rootLeft + rootRight;
|
|
1751
|
-
var leftEdgeIsCloser = rootLeft > 0 || rootDelta > 0;
|
|
1752
|
-
var rightEdgeIsCloser = rootRight < 0 || rootDelta < 0;
|
|
1753
|
-
if (leftEdgeIsCloser) {
|
|
1754
|
-
return index + 1;
|
|
1755
|
-
}
|
|
1756
|
-
if (rightEdgeIsCloser) {
|
|
1757
|
-
return index - 1;
|
|
1758
|
-
}
|
|
1759
|
-
return -1;
|
|
1760
|
-
};
|
|
1761
|
-
/**
|
|
1762
|
-
* Returns the key associated with a keydown event
|
|
1763
|
-
* @param evt The keydown event
|
|
1764
|
-
*/
|
|
1765
|
-
MDCTabBarFoundation.prototype.getKeyFromEvent = function (evt) {
|
|
1766
|
-
if (ACCEPTABLE_KEYS.has(evt.key)) {
|
|
1767
|
-
return evt.key;
|
|
1768
|
-
}
|
|
1769
|
-
return KEYCODE_MAP.get(evt.keyCode);
|
|
1770
|
-
};
|
|
1771
|
-
MDCTabBarFoundation.prototype.isActivationKey = function (key) {
|
|
1772
|
-
return key === strings$1.SPACE_KEY || key === strings$1.ENTER_KEY;
|
|
1773
|
-
};
|
|
1774
|
-
/**
|
|
1775
|
-
* Returns whether a given index is inclusively between the ends
|
|
1776
|
-
* @param index The index to test
|
|
1777
|
-
*/
|
|
1778
|
-
MDCTabBarFoundation.prototype.indexIsInRange = function (index) {
|
|
1779
|
-
return index >= 0 && index < this.adapter.getTabListLength();
|
|
1780
|
-
};
|
|
1781
|
-
/**
|
|
1782
|
-
* Returns the view's RTL property
|
|
1783
|
-
*/
|
|
1784
|
-
MDCTabBarFoundation.prototype.isRTL = function () {
|
|
1785
|
-
return this.adapter.isRTL();
|
|
1786
|
-
};
|
|
1787
|
-
/**
|
|
1788
|
-
* Scrolls the tab at the given index into view for left-to-right user agents.
|
|
1789
|
-
* @param index The index of the tab to scroll into view
|
|
1790
|
-
*/
|
|
1791
|
-
MDCTabBarFoundation.prototype.scrollIntoViewImpl = function (index) {
|
|
1792
|
-
var scrollPosition = this.adapter.getScrollPosition();
|
|
1793
|
-
var barWidth = this.adapter.getOffsetWidth();
|
|
1794
|
-
var tabDimensions = this.adapter.getTabDimensionsAtIndex(index);
|
|
1795
|
-
var nextIndex = this.findAdjacentTabIndexClosestToEdge(index, tabDimensions, scrollPosition, barWidth);
|
|
1796
|
-
if (!this.indexIsInRange(nextIndex)) {
|
|
1797
|
-
return;
|
|
1798
|
-
}
|
|
1799
|
-
var scrollIncrement = this.calculateScrollIncrement(index, nextIndex, scrollPosition, barWidth);
|
|
1800
|
-
this.adapter.incrementScroll(scrollIncrement);
|
|
1801
|
-
};
|
|
1802
|
-
/**
|
|
1803
|
-
* Scrolls the tab at the given index into view in RTL
|
|
1804
|
-
* @param index The tab index to make visible
|
|
1805
|
-
*/
|
|
1806
|
-
MDCTabBarFoundation.prototype.scrollIntoViewImplRTL = function (index) {
|
|
1807
|
-
var scrollPosition = this.adapter.getScrollPosition();
|
|
1808
|
-
var barWidth = this.adapter.getOffsetWidth();
|
|
1809
|
-
var tabDimensions = this.adapter.getTabDimensionsAtIndex(index);
|
|
1810
|
-
var scrollWidth = this.adapter.getScrollContentWidth();
|
|
1811
|
-
var nextIndex = this.findAdjacentTabIndexClosestToEdgeRTL(index, tabDimensions, scrollPosition, barWidth, scrollWidth);
|
|
1812
|
-
if (!this.indexIsInRange(nextIndex)) {
|
|
1813
|
-
return;
|
|
1814
|
-
}
|
|
1815
|
-
var scrollIncrement = this.calculateScrollIncrementRTL(index, nextIndex, scrollPosition, barWidth, scrollWidth);
|
|
1816
|
-
this.adapter.incrementScroll(scrollIncrement);
|
|
1817
|
-
};
|
|
1818
|
-
return MDCTabBarFoundation;
|
|
1819
|
-
}(MDCFoundation));
|
|
1820
|
-
|
|
226
|
+
return findReachable(count, 0, 1, false, canMoveTo);
|
|
227
|
+
}
|
|
228
|
+
function isWithin(index, count) {
|
|
229
|
+
return index >= 0 && index < count;
|
|
230
|
+
}
|
|
231
|
+
function createReachableTest(items, options) {
|
|
232
|
+
return (index) => { var _a; return !((_a = options === null || options === void 0 ? void 0 : options.isDisabled) === null || _a === void 0 ? void 0 : _a.call(options, items[index])); };
|
|
233
|
+
}
|
|
1821
234
|
/**
|
|
1822
|
-
*
|
|
1823
|
-
*
|
|
1824
|
-
*
|
|
1825
|
-
*
|
|
1826
|
-
*
|
|
1827
|
-
*
|
|
1828
|
-
*
|
|
1829
|
-
*
|
|
1830
|
-
*
|
|
1831
|
-
*
|
|
1832
|
-
* The above copyright notice and this permission notice shall be included in
|
|
1833
|
-
* all copies or substantial portions of the Software.
|
|
1834
|
-
*
|
|
1835
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
1836
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
1837
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
1838
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
1839
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
1840
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
1841
|
-
* THE SOFTWARE.
|
|
235
|
+
* Look for an item that can be moved to, one item at a time.
|
|
236
|
+
*
|
|
237
|
+
* @param count - the number of items
|
|
238
|
+
* @param start - the index to start looking at
|
|
239
|
+
* @param step - the direction to look in, `1` for forward and `-1` for back
|
|
240
|
+
* @param wrap - whether to continue at the other end, instead of giving up at
|
|
241
|
+
* the end of the items. Every item is looked at once at most.
|
|
242
|
+
* @param canMoveTo - tells whether the item at an index can be moved to
|
|
243
|
+
* @returns the index of the first item that can be moved to, or
|
|
244
|
+
* `NO_NAVIGATION_TARGET` when there is none
|
|
1842
245
|
*/
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
1849
|
-
}
|
|
1850
|
-
MDCTabBar.attachTo = function (root) {
|
|
1851
|
-
return new MDCTabBar(root);
|
|
1852
|
-
};
|
|
1853
|
-
Object.defineProperty(MDCTabBar.prototype, "focusOnActivate", {
|
|
1854
|
-
set: function (focusOnActivate) {
|
|
1855
|
-
var e_1, _a;
|
|
1856
|
-
try {
|
|
1857
|
-
for (var _b = __values(this.tabList), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1858
|
-
var tab = _c.value;
|
|
1859
|
-
tab.focusOnActivate = focusOnActivate;
|
|
1860
|
-
}
|
|
1861
|
-
}
|
|
1862
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1863
|
-
finally {
|
|
1864
|
-
try {
|
|
1865
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1866
|
-
}
|
|
1867
|
-
finally { if (e_1) throw e_1.error; }
|
|
1868
|
-
}
|
|
1869
|
-
},
|
|
1870
|
-
enumerable: false,
|
|
1871
|
-
configurable: true
|
|
1872
|
-
});
|
|
1873
|
-
Object.defineProperty(MDCTabBar.prototype, "useAutomaticActivation", {
|
|
1874
|
-
set: function (useAutomaticActivation) {
|
|
1875
|
-
this.foundation.setUseAutomaticActivation(useAutomaticActivation);
|
|
1876
|
-
},
|
|
1877
|
-
enumerable: false,
|
|
1878
|
-
configurable: true
|
|
1879
|
-
});
|
|
1880
|
-
MDCTabBar.prototype.initialize = function (tabFactory, tabScrollerFactory) {
|
|
1881
|
-
if (tabFactory === void 0) { tabFactory = function (el) { return new MDCTab(el); }; }
|
|
1882
|
-
if (tabScrollerFactory === void 0) { tabScrollerFactory = function (el) { return new MDCTabScroller(el); }; }
|
|
1883
|
-
this.tabList = this.instantiateTabs(tabFactory);
|
|
1884
|
-
this.tabScroller = this.instantiatetabScroller(tabScrollerFactory);
|
|
1885
|
-
};
|
|
1886
|
-
MDCTabBar.prototype.initialSyncWithDOM = function () {
|
|
1887
|
-
var _this = this;
|
|
1888
|
-
this.handleTabInteraction = function (evt) {
|
|
1889
|
-
_this.foundation.handleTabInteraction(evt);
|
|
1890
|
-
};
|
|
1891
|
-
this.handleKeyDown = function (evt) {
|
|
1892
|
-
_this.foundation.handleKeyDown(evt);
|
|
1893
|
-
};
|
|
1894
|
-
this.listen(MDCTabFoundation.strings.INTERACTED_EVENT, this.handleTabInteraction);
|
|
1895
|
-
this.listen('keydown', this.handleKeyDown);
|
|
1896
|
-
for (var i = 0; i < this.tabList.length; i++) {
|
|
1897
|
-
if (this.tabList[i].active) {
|
|
1898
|
-
this.scrollIntoView(i);
|
|
1899
|
-
break;
|
|
1900
|
-
}
|
|
1901
|
-
}
|
|
1902
|
-
};
|
|
1903
|
-
MDCTabBar.prototype.destroy = function () {
|
|
1904
|
-
var e_2, _a;
|
|
1905
|
-
_super.prototype.destroy.call(this);
|
|
1906
|
-
this.unlisten(MDCTabFoundation.strings.INTERACTED_EVENT, this.handleTabInteraction);
|
|
1907
|
-
this.unlisten('keydown', this.handleKeyDown);
|
|
1908
|
-
try {
|
|
1909
|
-
for (var _b = __values(this.tabList), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1910
|
-
var tab = _c.value;
|
|
1911
|
-
tab.destroy();
|
|
1912
|
-
}
|
|
246
|
+
function findReachable(count, start, step, wrap, canMoveTo) {
|
|
247
|
+
for (let distance = 0; distance < count; distance += 1) {
|
|
248
|
+
const position = start + step * distance;
|
|
249
|
+
if (!wrap && !isWithin(position, count)) {
|
|
250
|
+
break;
|
|
1913
251
|
}
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1918
|
-
}
|
|
1919
|
-
finally { if (e_2) throw e_2.error; }
|
|
252
|
+
const index = ((position % count) + count) % count;
|
|
253
|
+
if (canMoveTo(index)) {
|
|
254
|
+
return index;
|
|
1920
255
|
}
|
|
1921
|
-
if (this.tabScroller) {
|
|
1922
|
-
this.tabScroller.destroy();
|
|
1923
|
-
}
|
|
1924
|
-
};
|
|
1925
|
-
MDCTabBar.prototype.getDefaultFoundation = function () {
|
|
1926
|
-
var _this = this;
|
|
1927
|
-
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
|
|
1928
|
-
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
|
|
1929
|
-
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
|
|
1930
|
-
var adapter = {
|
|
1931
|
-
scrollTo: function (scrollX) {
|
|
1932
|
-
_this.tabScroller.scrollTo(scrollX);
|
|
1933
|
-
},
|
|
1934
|
-
incrementScroll: function (scrollXIncrement) {
|
|
1935
|
-
_this.tabScroller.incrementScroll(scrollXIncrement);
|
|
1936
|
-
},
|
|
1937
|
-
getScrollPosition: function () { return _this.tabScroller.getScrollPosition(); },
|
|
1938
|
-
getScrollContentWidth: function () { return _this.tabScroller.getScrollContentWidth(); },
|
|
1939
|
-
getOffsetWidth: function () { return _this.root.offsetWidth; },
|
|
1940
|
-
isRTL: function () { return window.getComputedStyle(_this.root).getPropertyValue('direction') === 'rtl'; },
|
|
1941
|
-
setActiveTab: function (index) {
|
|
1942
|
-
_this.foundation.activateTab(index);
|
|
1943
|
-
},
|
|
1944
|
-
activateTabAtIndex: function (index, clientRect) {
|
|
1945
|
-
_this.tabList[index].activate(clientRect);
|
|
1946
|
-
},
|
|
1947
|
-
deactivateTabAtIndex: function (index) {
|
|
1948
|
-
_this.tabList[index].deactivate();
|
|
1949
|
-
},
|
|
1950
|
-
focusTabAtIndex: function (index) {
|
|
1951
|
-
_this.tabList[index].focus();
|
|
1952
|
-
},
|
|
1953
|
-
getTabIndicatorClientRectAtIndex: function (index) {
|
|
1954
|
-
return _this.tabList[index].computeIndicatorClientRect();
|
|
1955
|
-
},
|
|
1956
|
-
getTabDimensionsAtIndex: function (index) {
|
|
1957
|
-
return _this.tabList[index].computeDimensions();
|
|
1958
|
-
},
|
|
1959
|
-
getPreviousActiveTabIndex: function () {
|
|
1960
|
-
for (var i = 0; i < _this.tabList.length; i++) {
|
|
1961
|
-
if (_this.tabList[i].active) {
|
|
1962
|
-
return i;
|
|
1963
|
-
}
|
|
1964
|
-
}
|
|
1965
|
-
return -1;
|
|
1966
|
-
},
|
|
1967
|
-
getFocusedTabIndex: function () {
|
|
1968
|
-
var tabElements = _this.getTabElements();
|
|
1969
|
-
var activeElement = document.activeElement;
|
|
1970
|
-
return tabElements.indexOf(activeElement);
|
|
1971
|
-
},
|
|
1972
|
-
getIndexOfTabById: function (id) {
|
|
1973
|
-
for (var i = 0; i < _this.tabList.length; i++) {
|
|
1974
|
-
if (_this.tabList[i].id === id) {
|
|
1975
|
-
return i;
|
|
1976
|
-
}
|
|
1977
|
-
}
|
|
1978
|
-
return -1;
|
|
1979
|
-
},
|
|
1980
|
-
getTabListLength: function () { return _this.tabList.length; },
|
|
1981
|
-
notifyTabActivated: function (index) { return _this.emit(strings.TAB_ACTIVATED_EVENT, { index: index }, true); },
|
|
1982
|
-
};
|
|
1983
|
-
// tslint:enable:object-literal-sort-keys
|
|
1984
|
-
return new MDCTabBarFoundation(adapter);
|
|
1985
|
-
};
|
|
1986
|
-
/**
|
|
1987
|
-
* Activates the tab at the given index
|
|
1988
|
-
* @param index The index of the tab
|
|
1989
|
-
*/
|
|
1990
|
-
MDCTabBar.prototype.activateTab = function (index) {
|
|
1991
|
-
this.foundation.activateTab(index);
|
|
1992
|
-
};
|
|
1993
|
-
/**
|
|
1994
|
-
* Scrolls the tab at the given index into view
|
|
1995
|
-
* @param index THe index of the tab
|
|
1996
|
-
*/
|
|
1997
|
-
MDCTabBar.prototype.scrollIntoView = function (index) {
|
|
1998
|
-
this.foundation.scrollIntoView(index);
|
|
1999
|
-
};
|
|
2000
|
-
/**
|
|
2001
|
-
* Returns all the tab elements in a nice clean array
|
|
2002
|
-
*/
|
|
2003
|
-
MDCTabBar.prototype.getTabElements = function () {
|
|
2004
|
-
return [].slice.call(this.root.querySelectorAll(strings.TAB_SELECTOR));
|
|
2005
|
-
};
|
|
2006
|
-
/**
|
|
2007
|
-
* Instantiates tab components on all child tab elements
|
|
2008
|
-
*/
|
|
2009
|
-
MDCTabBar.prototype.instantiateTabs = function (tabFactory) {
|
|
2010
|
-
return this.getTabElements().map(function (el) {
|
|
2011
|
-
el.id = el.id || "mdc-tab-" + ++tabIdCounter;
|
|
2012
|
-
return tabFactory(el);
|
|
2013
|
-
});
|
|
2014
|
-
};
|
|
2015
|
-
/**
|
|
2016
|
-
* Instantiates tab scroller component on the child tab scroller element
|
|
2017
|
-
*/
|
|
2018
|
-
MDCTabBar.prototype.instantiatetabScroller = function (tabScrollerFactory) {
|
|
2019
|
-
var tabScrollerElement = this.root.querySelector(strings.TAB_SCROLLER_SELECTOR);
|
|
2020
|
-
if (tabScrollerElement) {
|
|
2021
|
-
return tabScrollerFactory(tabScrollerElement);
|
|
2022
|
-
}
|
|
2023
|
-
return null;
|
|
2024
|
-
};
|
|
2025
|
-
return MDCTabBar;
|
|
2026
|
-
}(MDCComponent));
|
|
2027
|
-
|
|
2028
|
-
/**
|
|
2029
|
-
* Set a tabs `active` state to true in a list of tabs. The previous tab with
|
|
2030
|
-
* `active` set to true will have it set to `false` instead.
|
|
2031
|
-
*
|
|
2032
|
-
* @param tabs - list of tabs
|
|
2033
|
-
* @param index - the index of the tab to set to active
|
|
2034
|
-
* @returns a copy of the list of tabs with the changed tabs replaced
|
|
2035
|
-
*/
|
|
2036
|
-
function setActiveTab(tabs, index) {
|
|
2037
|
-
const oldSelectedTabIndex = tabs.findIndex((t) => t.active === true);
|
|
2038
|
-
const result = [...tabs];
|
|
2039
|
-
if (oldSelectedTabIndex !== -1) {
|
|
2040
|
-
result[oldSelectedTabIndex] = Object.assign(Object.assign({}, tabs[oldSelectedTabIndex]), { active: false });
|
|
2041
256
|
}
|
|
2042
|
-
|
|
2043
|
-
return result;
|
|
257
|
+
return NO_NAVIGATION_TARGET;
|
|
2044
258
|
}
|
|
2045
259
|
|
|
2046
|
-
const tabBarCss = () => `.mdc-tab-bar{width:100%}.mdc-tab{height:48px}.mdc-tab--stacked{height:72px}.mdc-tab-indicator .mdc-tab-indicator__content--underline{border-color:#6200ee;border-color:var(--mdc-theme-primary, #6200ee)}.mdc-tab-indicator .mdc-tab-indicator__content--icon{color:#018786;color:var(--mdc-theme-secondary, #018786)}.mdc-tab-indicator .mdc-tab-indicator__content--underline{border-top-width:2px}.mdc-tab-indicator .mdc-tab-indicator__content--icon{height:34px;font-size:34px}.mdc-tab-indicator{display:flex;position:absolute;top:0;left:0;justify-content:center;width:100%;height:100%;pointer-events:none;z-index:1}.mdc-tab-indicator__content{transform-origin:left;opacity:0}.mdc-tab-indicator__content--underline{align-self:flex-end;box-sizing:border-box;width:100%;border-top-style:solid}.mdc-tab-indicator__content--icon{align-self:center;margin:0 auto}.mdc-tab-indicator--active .mdc-tab-indicator__content{opacity:1}.mdc-tab-indicator .mdc-tab-indicator__content{transition:250ms transform cubic-bezier(0.4, 0, 0.2, 1)}.mdc-tab-indicator--no-transition .mdc-tab-indicator__content{transition:none}.mdc-tab-indicator--fade .mdc-tab-indicator__content{transition:150ms opacity linear}.mdc-tab-indicator--active.mdc-tab-indicator--fade .mdc-tab-indicator__content{transition-delay:100ms}.mdc-tab{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;font-family:Roboto, sans-serif;font-family:var(--mdc-typography-button-font-family, var(--mdc-typography-font-family, Roboto, sans-serif));font-size:0.875rem;font-size:var(--mdc-typography-button-font-size, 0.875rem);line-height:2.25rem;line-height:var(--mdc-typography-button-line-height, 2.25rem);font-weight:500;font-weight:var(--mdc-typography-button-font-weight, 500);letter-spacing:0.0892857143em;letter-spacing:var(--mdc-typography-button-letter-spacing, 0.0892857143em);text-decoration:none;text-decoration:var(--mdc-typography-button-text-decoration, none);text-transform:uppercase;text-transform:var(--mdc-typography-button-text-transform, uppercase)}.mdc-tab .mdc-tab__text-label{color:rgba(0, 0, 0, 0.6)}.mdc-tab .mdc-tab__icon{color:rgba(0, 0, 0, 0.54);fill:currentColor}.mdc-tab{position:relative}.mdc-tab__content{position:relative}.mdc-tab__icon{width:24px;height:24px;font-size:24px}.mdc-tab--active .mdc-tab__text-label{color:#6200ee;color:var(--mdc-theme-primary, #6200ee)}.mdc-tab--active .mdc-tab__icon{color:#6200ee;color:var(--mdc-theme-primary, #6200ee);fill:currentColor}.mdc-tab{background:none}.mdc-tab{min-width:90px;padding-right:24px;padding-left:24px;display:flex;flex:1 0 auto;justify-content:center;box-sizing:border-box;margin:0;padding-top:0;padding-bottom:0;border:none;outline:none;text-align:center;white-space:nowrap;cursor:pointer;-webkit-appearance:none;z-index:1}.mdc-tab::-moz-focus-inner{padding:0;border:0}.mdc-tab--min-width{flex:0 1 auto}.mdc-tab__content{display:flex;align-items:center;justify-content:center;height:inherit;pointer-events:none}.mdc-tab__text-label{transition:150ms color linear;display:inline-block;line-height:1;z-index:2}.mdc-tab__icon{transition:150ms color linear;z-index:2}.mdc-tab--stacked .mdc-tab__content{flex-direction:column;align-items:center;justify-content:center}.mdc-tab--stacked .mdc-tab__text-label{padding-top:6px;padding-bottom:4px}.mdc-tab--active .mdc-tab__text-label,.mdc-tab--active .mdc-tab__icon{transition-delay:100ms}.mdc-tab:not(.mdc-tab--stacked) .mdc-tab__icon+.mdc-tab__text-label{padding-left:8px;padding-right:0}[dir=rtl] .mdc-tab:not(.mdc-tab--stacked) .mdc-tab__icon+.mdc-tab__text-label,.mdc-tab:not(.mdc-tab--stacked) .mdc-tab__icon+.mdc-tab__text-label[dir=rtl]{padding-left:0;padding-right:8px;}@keyframes mdc-ripple-fg-radius-in{from{animation-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transform:translate(var(--mdc-ripple-fg-translate-start, 0)) scale(1)}to{transform:translate(var(--mdc-ripple-fg-translate-end, 0)) scale(var(--mdc-ripple-fg-scale, 1))}}@keyframes mdc-ripple-fg-opacity-in{from{animation-timing-function:linear;opacity:0}to{opacity:var(--mdc-ripple-fg-opacity, 0)}}@keyframes mdc-ripple-fg-opacity-out{from{animation-timing-function:linear;opacity:var(--mdc-ripple-fg-opacity, 0)}to{opacity:0}}.mdc-tab{--mdc-ripple-fg-size:0;--mdc-ripple-left:0;--mdc-ripple-top:0;--mdc-ripple-fg-scale:1;--mdc-ripple-fg-translate-end:0;--mdc-ripple-fg-translate-start:0;-webkit-tap-highlight-color:rgba(0, 0, 0, 0)}.mdc-tab .mdc-tab__ripple::before,.mdc-tab .mdc-tab__ripple::after{position:absolute;border-radius:50%;opacity:0;pointer-events:none;content:""}.mdc-tab .mdc-tab__ripple::before{transition:opacity 15ms linear, background-color 15ms linear;z-index:1;z-index:var(--mdc-ripple-z-index, 1)}.mdc-tab .mdc-tab__ripple::after{z-index:0;z-index:var(--mdc-ripple-z-index, 0)}.mdc-tab.mdc-ripple-upgraded .mdc-tab__ripple::before{transform:scale(var(--mdc-ripple-fg-scale, 1))}.mdc-tab.mdc-ripple-upgraded .mdc-tab__ripple::after{top:0;left:0;transform:scale(0);transform-origin:center center}.mdc-tab.mdc-ripple-upgraded--unbounded .mdc-tab__ripple::after{top:var(--mdc-ripple-top, 0);left:var(--mdc-ripple-left, 0)}.mdc-tab.mdc-ripple-upgraded--foreground-activation .mdc-tab__ripple::after{animation:mdc-ripple-fg-radius-in 225ms forwards, mdc-ripple-fg-opacity-in 75ms forwards}.mdc-tab.mdc-ripple-upgraded--foreground-deactivation .mdc-tab__ripple::after{animation:mdc-ripple-fg-opacity-out 150ms;transform:translate(var(--mdc-ripple-fg-translate-end, 0)) scale(var(--mdc-ripple-fg-scale, 1))}.mdc-tab .mdc-tab__ripple::before,.mdc-tab .mdc-tab__ripple::after{top:calc(50% - 100%);left:calc(50% - 100%);width:200%;height:200%}.mdc-tab.mdc-ripple-upgraded .mdc-tab__ripple::after{width:var(--mdc-ripple-fg-size, 100%);height:var(--mdc-ripple-fg-size, 100%)}.mdc-tab .mdc-tab__ripple::before,.mdc-tab .mdc-tab__ripple::after{background-color:#6200ee;background-color:var(--mdc-ripple-color, var(--mdc-theme-primary, #6200ee))}.mdc-tab:hover .mdc-tab__ripple::before,.mdc-tab.mdc-ripple-surface--hover .mdc-tab__ripple::before{opacity:0.04;opacity:var(--mdc-ripple-hover-opacity, 0.04)}.mdc-tab.mdc-ripple-upgraded--background-focused .mdc-tab__ripple::before,.mdc-tab:not(.mdc-ripple-upgraded):focus .mdc-tab__ripple::before{transition-duration:75ms;opacity:0.12;opacity:var(--mdc-ripple-focus-opacity, 0.12)}.mdc-tab:not(.mdc-ripple-upgraded) .mdc-tab__ripple::after{transition:opacity 150ms linear}.mdc-tab:not(.mdc-ripple-upgraded):active .mdc-tab__ripple::after{transition-duration:75ms;opacity:0.12;opacity:var(--mdc-ripple-press-opacity, 0.12)}.mdc-tab.mdc-ripple-upgraded{--mdc-ripple-fg-opacity:var(--mdc-ripple-press-opacity, 0.12)}.mdc-tab__ripple{position:absolute;top:0;left:0;width:100%;height:100%;overflow:hidden;will-change:transform, opacity}:host(limel-tab-bar){--limel-tab-background-color:var(--contrast-300);--limel-tab-border-radius:0.625rem;--limel-active-tab-background-color:var( --tab-panel-background-color, rgb(var(--contrast-100)) );--limel-tab-active-outer-edge-curve-size:0.75rem;--limel-tab-separator-width:0.125rem;--limel-tab-separator-background-color:rgb(var(--contrast-600));isolation:isolate;display:block;position:relative}limel-scroller{--limel-scroller-fade-color:var(--limel-tab-background-color);--limel-scroller-content-padding:0.25rem var(--limel-tab-active-outer-edge-curve-size) 0;background-color:rgb(var(--limel-tab-background-color))}:host(.has-tabs-with-equal-width) .mdc-tab{flex:1 0 auto}.mdc-tab{font-family:inherit;font-weight:400;letter-spacing:normal;font-size:var(--limel-theme-default-font-size);text-transform:none}.mdc-tab-indicator .mdc-tab-indicator__content{border:none}.mdc-tab__ripple{box-sizing:border-box;border-radius:var(--limel-tab-border-radius);border-style:solid;border-color:transparent;border-width:0.25rem;opacity:0.7}.mdc-tab__ripple:before,.mdc-tab__ripple:after{transition:background-color 0.5s ease}.mdc-tab{border-radius:0;padding-right:1rem;padding-left:1rem;min-width:2.5rem;background-color:transparent;flex:0 0 auto;height:2.5rem}.mdc-tab:not(.mdc-tab--active):after{content:"";display:block;background-color:var(--limel-tab-separator-background-color);width:var(--limel-tab-separator-width);height:1rem;margin:auto;position:absolute;top:0;bottom:0;border-radius:1rem;right:calc(-1 * var(--limel-tab-separator-width))}.mdc-tab:not(.mdc-tab--active):last-of-type:after{display:none}.mdc-tab .mdc-tab__icon{color:rgb(var(--contrast-800));margin-left:-0.25rem}.mdc-tab limel-badge{margin-right:-0.25rem;box-shadow:0 0 0 1px rgb(var(--contrast-600))}.mdc-tab--active{border-radius:var(--limel-tab-border-radius) var(--limel-tab-border-radius) 0 0;background-color:var(--limel-active-tab-background-color);z-index:2}.mdc-tab--active:before,.mdc-tab--active:after{content:"";display:block;width:var(--limel-tab-active-outer-edge-curve-size);height:var(--limel-tab-active-outer-edge-curve-size);position:absolute;bottom:0;background-color:var(--limel-active-tab-background-color);-webkit-mask-image:url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20fill-rule='evenodd'%20stroke-linejoin='round'%20stroke-miterlimit='2'%20clip-rule='evenodd'%20viewBox='0%200%2050%2050'%3E%3Cdefs/%3E%3Cpath%20d='M0%200c0%2027.594%2022.406%2050%2050%2050H0V0z'/%3E%3C/svg%3E");mask-image:url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20fill-rule='evenodd'%20stroke-linejoin='round'%20stroke-miterlimit='2'%20clip-rule='evenodd'%20viewBox='0%200%2050%2050'%3E%3Cdefs/%3E%3Cpath%20d='M0%200c0%2027.594%2022.406%2050%2050%2050H0V0z'/%3E%3C/svg%3E")}.mdc-tab--active:before{left:calc(-1 * var(--limel-tab-active-outer-edge-curve-size));transform:rotateY(180deg)}.mdc-tab--active:after{right:calc(-1 * var(--limel-tab-active-outer-edge-curve-size))}.mdc-tab--active .mdc-ripple-upgraded--background-focused:before{background-color:transparent;transition:background-color 1s ease}.mdc-tab--active .mdc-tab__icon{color:var(--mdc-theme-primary)}.mdc-tab__content{gap:0.375rem}.mdc-tab .mdc-tab__text-label{transition:color 0.2s ease;padding-left:0 !important;color:var(--limel-theme-on-surface-color)}.mdc-tab:hover .mdc-tab__text-label{color:var(--limel-theme-text-primary-on-background-color)}.mdc-tab.mdc-tab--active .mdc-tab__text-label{color:var(--lime-primary-color, var(--limel-theme-primary-color))}`;
|
|
260
|
+
const tabBarCss = () => `@charset "UTF-8";:host(limel-tab-bar){--limel-tab-background-color:var(--contrast-300);--limel-tab-border-radius:0.625rem;--limel-tab-content-inset:0.25rem;--limel-active-tab-background-color:var( --tab-panel-background-color, rgb(var(--contrast-100)) );--limel-active-tab-color:var( --lime-primary-color, var(--limel-theme-primary-color) );--limel-tab-active-outer-edge-curve-size:0.75rem;--limel-tab-separator-width:0.125rem;--limel-tab-separator-background-color:rgb(var(--contrast-600));isolation:isolate;display:block;position:relative}limel-scroller{--limel-scroller-fade-color:var(--limel-tab-background-color);--limel-scroller-content-padding:0.25rem var(--limel-tab-active-outer-edge-curve-size) 0;background-color:rgb(var(--limel-tab-background-color))}:host(.has-tabs-with-equal-width) button{flex:1 0 auto}button{appearance:none;background:none;border:none;padding:0;margin:0;font:inherit;color:inherit;text-align:inherit;position:relative;display:flex;box-sizing:border-box;border-radius:0;padding:var(--limel-tab-content-inset);min-width:2.5rem;background-color:transparent;flex:0 0 auto;height:2.5rem;outline:none;cursor:pointer;white-space:nowrap;font-size:var(--limel-theme-default-font-size)}button:not([aria-selected=true]):after{content:"";display:block;background-color:var(--limel-tab-separator-background-color);width:var(--limel-tab-separator-width);height:1rem;margin:auto;position:absolute;top:0;bottom:0;border-radius:1rem;right:calc(-1 * var(--limel-tab-separator-width))}button:not([aria-selected=true]):last-of-type:after{display:none}button limel-icon{transition:color 0.2s ease;color:rgb(var(--contrast-800));margin-left:-0.25rem}button span.text{transition:color 0.2s ease;line-height:1;color:var(--limel-theme-on-surface-color)}button:hover span.text{color:var(--limel-theme-text-primary-on-background-color)}button limel-badge{margin-right:-0.25rem;box-shadow:0 0 0 1px rgb(var(--contrast-600));pointer-events:none}button[aria-selected=true]{border-radius:var(--limel-tab-border-radius) var(--limel-tab-border-radius) 0 0;background-color:var(--limel-active-tab-background-color);z-index:2}button[aria-selected=true]:before,button[aria-selected=true]:after{content:"";display:block;width:var(--limel-tab-active-outer-edge-curve-size);height:var(--limel-tab-active-outer-edge-curve-size);position:absolute;bottom:0;background-color:var(--limel-active-tab-background-color);-webkit-mask-image:url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20fill-rule='evenodd'%20stroke-linejoin='round'%20stroke-miterlimit='2'%20clip-rule='evenodd'%20viewBox='0%200%2050%2050'%3E%3Cdefs/%3E%3Cpath%20d='M0%200c0%2027.594%2022.406%2050%2050%2050H0V0z'/%3E%3C/svg%3E");mask-image:url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20fill-rule='evenodd'%20stroke-linejoin='round'%20stroke-miterlimit='2'%20clip-rule='evenodd'%20viewBox='0%200%2050%2050'%3E%3Cdefs/%3E%3Cpath%20d='M0%200c0%2027.594%2022.406%2050%2050%2050H0V0z'/%3E%3C/svg%3E")}button[aria-selected=true]:before{left:calc(-1 * var(--limel-tab-active-outer-edge-curve-size));transform:rotateY(180deg)}button[aria-selected=true]:after{right:calc(-1 * var(--limel-tab-active-outer-edge-curve-size))}button[aria-selected=true] limel-icon{color:var(--limel-active-tab-color)}button[aria-selected=true] span.text{color:var(--limel-active-tab-color)}span.content{transition:box-shadow 0.2s ease;display:flex;flex-grow:1;align-items:center;justify-content:center;gap:0.375rem;padding:0 0.75rem;border-radius:calc(var(--limel-tab-border-radius) - var(--limel-tab-content-inset))}button:focus-visible span.content{transition-duration:0.3s;box-shadow:var(--shadow-depth-8-focused)}`;
|
|
2047
261
|
|
|
2048
|
-
const
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
const tabScrollerForMdc = {
|
|
2052
|
-
scrollTo: noop,
|
|
2053
|
-
incrementScroll: noop,
|
|
2054
|
-
getScrollPosition: () => 0,
|
|
2055
|
-
getScrollContentWidth: () => 0,
|
|
2056
|
-
destroy: noop,
|
|
262
|
+
const NAVIGATION = {
|
|
263
|
+
orientation: 'horizontal',
|
|
264
|
+
wrap: true,
|
|
2057
265
|
};
|
|
2058
266
|
const TabBar = class {
|
|
2059
267
|
constructor(hostRef) {
|
|
@@ -2063,13 +271,10 @@ const TabBar = class {
|
|
|
2063
271
|
* List of tabs to display
|
|
2064
272
|
*/
|
|
2065
273
|
this.tabs = [];
|
|
2066
|
-
this.setupMdc = false;
|
|
2067
274
|
this.hasLoaded = false;
|
|
2068
|
-
this.
|
|
2069
|
-
this.renderTab = this.renderTab.bind(this);
|
|
275
|
+
this.handleKeyDown = this.handleKeyDown.bind(this);
|
|
2070
276
|
}
|
|
2071
277
|
async connectedCallback() {
|
|
2072
|
-
this.setup();
|
|
2073
278
|
// Connecting after the first render means that the bar was moved, which
|
|
2074
279
|
// resets how far it is scrolled.
|
|
2075
280
|
if (!this.hasLoaded) {
|
|
@@ -2080,24 +285,14 @@ const TabBar = class {
|
|
|
2080
285
|
}
|
|
2081
286
|
componentDidLoad() {
|
|
2082
287
|
this.hasLoaded = true;
|
|
2083
|
-
this.setup();
|
|
2084
288
|
this.triggerIconColorWarning();
|
|
2085
289
|
}
|
|
2086
290
|
async componentDidRender() {
|
|
2087
291
|
await this.revealActiveTab(this.hasLoaded ? undefined : 'auto');
|
|
2088
292
|
}
|
|
2089
|
-
componentDidUpdate() {
|
|
2090
|
-
if (!this.setupMdc) {
|
|
2091
|
-
return;
|
|
2092
|
-
}
|
|
2093
|
-
this.setup();
|
|
2094
|
-
this.setupMdc = false;
|
|
2095
|
-
}
|
|
2096
|
-
disconnectedCallback() {
|
|
2097
|
-
this.tearDown();
|
|
2098
|
-
}
|
|
2099
293
|
render() {
|
|
2100
|
-
|
|
294
|
+
const tabStop = findTabStop(this.tabs, this.tabs.findIndex((tab) => tab.active), NAVIGATION);
|
|
295
|
+
return (h("div", { key: '9998014061ef483531099bfe9b9b30904bb1090d', role: "tablist", onKeyDown: this.handleKeyDown }, h("limel-scroller", { key: 'e09578e9daaeef1a3d05b4f0258fdd40e97ec39b' }, this.tabs.map((tab, index) => this.renderTab(tab, index, index === tabStop)))));
|
|
2101
296
|
}
|
|
2102
297
|
tabsChanged(newTabs = [], oldTabs = []) {
|
|
2103
298
|
const newIds = newTabs.map((tab) => tab.id);
|
|
@@ -2105,26 +300,12 @@ const TabBar = class {
|
|
|
2105
300
|
if (isEqual(newIds, oldIds)) {
|
|
2106
301
|
return;
|
|
2107
302
|
}
|
|
2108
|
-
this.setupMdc = true;
|
|
2109
303
|
this.revealedTabId = undefined;
|
|
2110
|
-
this.tearDown();
|
|
2111
304
|
}
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
}
|
|
2117
|
-
this.mdcTabBar = new MDCTabBar(element, undefined, undefined, () => tabScrollerForMdc);
|
|
2118
|
-
this.mdcTabBar.focusOnActivate = true;
|
|
2119
|
-
this.mdcTabBar.useAutomaticActivation = true;
|
|
2120
|
-
this.mdcTabBar.listen(TAB_ACTIVATED_EVENT, this.handleTabActivated);
|
|
2121
|
-
}
|
|
2122
|
-
tearDown() {
|
|
2123
|
-
if (!this.mdcTabBar) {
|
|
2124
|
-
return;
|
|
2125
|
-
}
|
|
2126
|
-
this.mdcTabBar.unlisten(TAB_ACTIVATED_EVENT, this.handleTabActivated);
|
|
2127
|
-
this.mdcTabBar.destroy();
|
|
305
|
+
getTabElements() {
|
|
306
|
+
return [
|
|
307
|
+
...this.host.shadowRoot.querySelectorAll('button[role="tab"]'),
|
|
308
|
+
];
|
|
2128
309
|
}
|
|
2129
310
|
/**
|
|
2130
311
|
* A tab that is activated by the user has focus, and the scroller reveals
|
|
@@ -2143,7 +324,7 @@ const TabBar = class {
|
|
|
2143
324
|
return;
|
|
2144
325
|
}
|
|
2145
326
|
this.revealedTabId = this.tabs[index].id;
|
|
2146
|
-
const element = this.
|
|
327
|
+
const element = this.getTabElements()[index];
|
|
2147
328
|
const scroller = this.host.shadowRoot.querySelector('limel-scroller');
|
|
2148
329
|
if (!element || !scroller || element.matches(':focus')) {
|
|
2149
330
|
return;
|
|
@@ -2151,8 +332,24 @@ const TabBar = class {
|
|
|
2151
332
|
await scroller.componentOnReady();
|
|
2152
333
|
await scroller.reveal(element, behavior);
|
|
2153
334
|
}
|
|
2154
|
-
|
|
2155
|
-
|
|
335
|
+
handleKeyDown(event) {
|
|
336
|
+
if (!isNavigationKey(event, NAVIGATION)) {
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
event.preventDefault();
|
|
340
|
+
const current = this.getTabElements().indexOf(event.target);
|
|
341
|
+
this.activateTab(findNavigationTarget(this.tabs, event.key, current, NAVIGATION));
|
|
342
|
+
}
|
|
343
|
+
activateTab(index) {
|
|
344
|
+
if (index === NO_NAVIGATION_TARGET) {
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
// Not every browser focuses a button that is clicked, and a key can
|
|
348
|
+
// lead to the selected tab from another tab that has focus.
|
|
349
|
+
this.getTabElements()[index].focus();
|
|
350
|
+
if (index === this.tabs.findIndex((tab) => tab.active)) {
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
2156
353
|
const newTabs = setActiveTab(this.tabs, index);
|
|
2157
354
|
const changedTabs = difference(newTabs, this.tabs).sort(this.sortByInactive);
|
|
2158
355
|
for (const tab of changedTabs) {
|
|
@@ -2173,16 +370,10 @@ const TabBar = class {
|
|
|
2173
370
|
if (color) {
|
|
2174
371
|
style.color = color;
|
|
2175
372
|
}
|
|
2176
|
-
return (h("limel-icon", {
|
|
373
|
+
return (h("limel-icon", { name: name, style: style, size: "small", "aria-hidden": "true" }));
|
|
2177
374
|
}
|
|
2178
|
-
renderTab(tab) {
|
|
2179
|
-
return (h("button", { class: {
|
|
2180
|
-
'mdc-tab': true,
|
|
2181
|
-
'mdc-tab--active': !!tab.active,
|
|
2182
|
-
}, role: "tab", "aria-selected": tab.active ? 'true' : 'false', tabindex: tab.active ? 0 : -1 }, h("span", { class: "mdc-tab__content" }, this.renderIcon(tab), h("span", { class: "mdc-tab__text-label" }, tab.text), tab.badge ? h("limel-badge", { label: tab.badge }) : ''), h("span", { class: {
|
|
2183
|
-
'mdc-tab-indicator': true,
|
|
2184
|
-
'mdc-tab-indicator--active': !!tab.active,
|
|
2185
|
-
} }, h("span", { class: "mdc-tab-indicator__content mdc-tab-indicator__content--underline" })), h("span", { class: "mdc-tab__ripple" })));
|
|
375
|
+
renderTab(tab, index, isTabStop) {
|
|
376
|
+
return (h("button", { role: "tab", "aria-selected": tab.active ? 'true' : 'false', tabindex: isTabStop ? 0 : -1, onClick: () => this.activateTab(index) }, h("span", { class: "content" }, this.renderIcon(tab), h("span", { class: "text" }, tab.text), tab.badge ? h("limel-badge", { label: tab.badge }) : '')));
|
|
2186
377
|
}
|
|
2187
378
|
triggerIconColorWarning() {
|
|
2188
379
|
if (this.tabs.some((tab) => tab.iconColor)) {
|