q2-tecton-elements 1.4.4 → 1.5.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.
Files changed (168) hide show
  1. package/dist/cjs/click-elsewhere.cjs.entry.js +1 -1
  2. package/dist/cjs/{index-88eda03b.js → index-56373ad4.js} +6 -1
  3. package/dist/cjs/loader.cjs.js +3 -3
  4. package/dist/cjs/{patch-e20a85b4.js → patch-9ecad880.js} +1 -1
  5. package/dist/cjs/q2-avatar.cjs.entry.js +1 -1
  6. package/dist/cjs/q2-btn.cjs.entry.js +1 -1
  7. package/dist/cjs/q2-calendar.cjs.entry.js +1 -1
  8. package/dist/cjs/q2-carousel-pane.cjs.entry.js +1 -1
  9. package/dist/cjs/q2-carousel.cjs.entry.js +1 -1
  10. package/dist/cjs/q2-checkbox-group.cjs.entry.js +1 -1
  11. package/dist/cjs/q2-checkbox.cjs.entry.js +1 -1
  12. package/dist/cjs/q2-dropdown-item.cjs.entry.js +1 -1
  13. package/dist/cjs/q2-dropdown.cjs.entry.js +6 -4
  14. package/dist/cjs/q2-editable-field.cjs.entry.js +1 -1
  15. package/dist/cjs/q2-icon.cjs.entry.js +1 -1
  16. package/dist/cjs/q2-input_2.cjs.entry.js +2 -2
  17. package/dist/cjs/q2-loading-element.cjs.entry.js +2 -2
  18. package/dist/cjs/q2-loading.cjs.entry.js +2 -2
  19. package/dist/cjs/q2-loc.cjs.entry.js +1 -1
  20. package/dist/cjs/q2-optgroup.cjs.entry.js +1 -1
  21. package/dist/cjs/q2-option.cjs.entry.js +1 -1
  22. package/dist/cjs/q2-radio-group.cjs.entry.js +1 -1
  23. package/dist/cjs/q2-radio.cjs.entry.js +1 -1
  24. package/dist/cjs/q2-section.cjs.entry.js +1 -1
  25. package/dist/cjs/q2-select.cjs.entry.js +1 -1
  26. package/dist/cjs/q2-tab-container.cjs.entry.js +521 -1042
  27. package/dist/cjs/q2-tab-pane.cjs.entry.js +1 -1
  28. package/dist/cjs/q2-tecton-elements.cjs.js +3 -3
  29. package/dist/cjs/{shapes-00766dc3.js → shapes-8ec3a001.js} +1 -1
  30. package/dist/cjs/tecton-tab-pane.cjs.entry.js +2 -1
  31. package/dist/collection/components/q2-dropdown/index.js +8 -4
  32. package/dist/collection/components/q2-input/formatting/phone.js +1 -1
  33. package/dist/collection/components/q2-tab-container/index.js +108 -38
  34. package/dist/collection/components/q2-tab-container/styles.css +4 -2
  35. package/dist/collection/components/tecton-tab-pane/index.js +1 -0
  36. package/dist/esm/click-elsewhere.entry.js +1 -1
  37. package/dist/esm/{index-b70f7228.js → index-06403810.js} +6 -1
  38. package/dist/esm/loader.mjs +3 -3
  39. package/dist/esm/{patch-187aa2d6.js → patch-580829e4.js} +1 -1
  40. package/dist/esm/q2-avatar.entry.js +1 -1
  41. package/dist/esm/q2-btn.entry.js +1 -1
  42. package/dist/esm/q2-calendar.entry.js +1 -1
  43. package/dist/esm/q2-carousel-pane.entry.js +1 -1
  44. package/dist/esm/q2-carousel.entry.js +1 -1
  45. package/dist/esm/q2-checkbox-group.entry.js +1 -1
  46. package/dist/esm/q2-checkbox.entry.js +1 -1
  47. package/dist/esm/q2-dropdown-item.entry.js +1 -1
  48. package/dist/esm/q2-dropdown.entry.js +6 -4
  49. package/dist/esm/q2-editable-field.entry.js +1 -1
  50. package/dist/esm/q2-icon.entry.js +1 -1
  51. package/dist/esm/q2-input_2.entry.js +2 -2
  52. package/dist/esm/q2-loading-element.entry.js +2 -2
  53. package/dist/esm/q2-loading.entry.js +2 -2
  54. package/dist/esm/q2-loc.entry.js +1 -1
  55. package/dist/esm/q2-optgroup.entry.js +1 -1
  56. package/dist/esm/q2-option.entry.js +1 -1
  57. package/dist/esm/q2-radio-group.entry.js +1 -1
  58. package/dist/esm/q2-radio.entry.js +1 -1
  59. package/dist/esm/q2-section.entry.js +1 -1
  60. package/dist/esm/q2-select.entry.js +1 -1
  61. package/dist/esm/q2-tab-container.entry.js +521 -1042
  62. package/dist/esm/q2-tab-pane.entry.js +1 -1
  63. package/dist/esm/q2-tecton-elements.mjs +3 -3
  64. package/dist/esm/{shapes-1a12324b.js → shapes-ac99fc8e.js} +1 -1
  65. package/dist/esm/tecton-tab-pane.entry.js +2 -1
  66. package/dist/esm-es5/click-elsewhere.entry.js +1 -1
  67. package/dist/esm-es5/{index-b70f7228.js → index-06403810.js} +6 -1
  68. package/dist/esm-es5/loader.mjs +3 -3
  69. package/dist/esm-es5/{patch-187aa2d6.js → patch-580829e4.js} +1 -1
  70. package/dist/esm-es5/q2-avatar.entry.js +1 -1
  71. package/dist/esm-es5/q2-btn.entry.js +1 -1
  72. package/dist/esm-es5/q2-calendar.entry.js +1 -1
  73. package/dist/esm-es5/q2-carousel-pane.entry.js +1 -1
  74. package/dist/esm-es5/q2-carousel.entry.js +1 -1
  75. package/dist/esm-es5/q2-checkbox-group.entry.js +1 -1
  76. package/dist/esm-es5/q2-checkbox.entry.js +1 -1
  77. package/dist/esm-es5/q2-dropdown-item.entry.js +1 -1
  78. package/dist/esm-es5/q2-dropdown.entry.js +6 -4
  79. package/dist/esm-es5/q2-editable-field.entry.js +1 -1
  80. package/dist/esm-es5/q2-icon.entry.js +1 -1
  81. package/dist/esm-es5/q2-input_2.entry.js +2 -2
  82. package/dist/esm-es5/q2-loading-element.entry.js +2 -2
  83. package/dist/esm-es5/q2-loading.entry.js +2 -2
  84. package/dist/esm-es5/q2-loc.entry.js +1 -1
  85. package/dist/esm-es5/q2-optgroup.entry.js +1 -1
  86. package/dist/esm-es5/q2-option.entry.js +1 -1
  87. package/dist/esm-es5/q2-radio-group.entry.js +1 -1
  88. package/dist/esm-es5/q2-radio.entry.js +1 -1
  89. package/dist/esm-es5/q2-section.entry.js +1 -1
  90. package/dist/esm-es5/q2-select.entry.js +1 -1
  91. package/dist/esm-es5/q2-tab-container.entry.js +426 -1068
  92. package/dist/esm-es5/q2-tab-pane.entry.js +1 -1
  93. package/dist/esm-es5/q2-tecton-elements.mjs +3 -3
  94. package/dist/esm-es5/{shapes-1a12324b.js → shapes-ac99fc8e.js} +1 -1
  95. package/dist/esm-es5/tecton-tab-pane.entry.js +2 -1
  96. package/dist/q2-tecton-elements/{p-c96424ae.entry.js → p-0898c601.entry.js} +1 -1
  97. package/dist/q2-tecton-elements/{p-c164ff6e.entry.js → p-1118a9a2.entry.js} +1 -1
  98. package/dist/q2-tecton-elements/{p-06e01d71.system.js → p-1b41293f.system.js} +1 -1
  99. package/dist/q2-tecton-elements/{p-b1fb02bf.entry.js → p-2071c411.entry.js} +1 -1
  100. package/dist/q2-tecton-elements/p-2b69fdec.system.js +1 -0
  101. package/dist/q2-tecton-elements/p-2b775411.entry.js +1 -0
  102. package/dist/q2-tecton-elements/{p-30c73ea9.entry.js → p-368f6eee.entry.js} +1 -1
  103. package/dist/q2-tecton-elements/{p-33a4a4e6.system.entry.js → p-3788add3.system.entry.js} +1 -1
  104. package/dist/q2-tecton-elements/{p-5adaa91d.system.entry.js → p-3de63622.system.entry.js} +1 -1
  105. package/dist/q2-tecton-elements/p-43a05b9f.entry.js +1 -0
  106. package/dist/q2-tecton-elements/{p-b96a2e11.entry.js → p-441decb7.entry.js} +1 -1
  107. package/dist/q2-tecton-elements/{p-5f52c28d.system.js → p-46e098a0.system.js} +1 -1
  108. package/dist/q2-tecton-elements/{p-843fdb33.system.entry.js → p-55ff8885.system.entry.js} +1 -1
  109. package/dist/q2-tecton-elements/{p-f01bebc8.system.entry.js → p-560cadce.system.entry.js} +1 -1
  110. package/dist/q2-tecton-elements/{p-9fc24628.js → p-5f9033b7.js} +1 -1
  111. package/dist/q2-tecton-elements/{p-1113bf25.system.entry.js → p-63ec6e3d.system.entry.js} +1 -1
  112. package/dist/q2-tecton-elements/{p-323cbdd3.entry.js → p-65d32cb9.entry.js} +1 -1
  113. package/dist/q2-tecton-elements/{p-a53e34ff.system.entry.js → p-66c9c34a.system.entry.js} +1 -1
  114. package/dist/q2-tecton-elements/p-6c2249f2.entry.js +1 -0
  115. package/dist/q2-tecton-elements/{p-d3d487ce.entry.js → p-7624ed0d.entry.js} +1 -1
  116. package/dist/q2-tecton-elements/{p-9f4d9ea2.system.entry.js → p-7e5a1320.system.entry.js} +1 -1
  117. package/dist/q2-tecton-elements/{p-a68a88bb.system.entry.js → p-824c4b15.system.entry.js} +1 -1
  118. package/dist/q2-tecton-elements/{p-3d8e5455.system.entry.js → p-82ce1d2d.system.entry.js} +1 -1
  119. package/dist/q2-tecton-elements/{p-12cf6e8b.entry.js → p-84e239ae.entry.js} +1 -1
  120. package/dist/q2-tecton-elements/{p-ce2eb03c.js → p-885ad5bb.js} +1 -1
  121. package/dist/q2-tecton-elements/{p-208d0c6e.system.entry.js → p-8fa28d27.system.entry.js} +1 -1
  122. package/dist/q2-tecton-elements/{p-7b10d18b.entry.js → p-94944dd4.entry.js} +1 -1
  123. package/dist/q2-tecton-elements/p-94a26b0f.system.js +1 -0
  124. package/dist/q2-tecton-elements/{p-b88eabe8.system.entry.js → p-9644093a.system.entry.js} +1 -1
  125. package/dist/q2-tecton-elements/{p-5fc58e19.entry.js → p-967e5b17.entry.js} +1 -1
  126. package/dist/q2-tecton-elements/p-9d45cb48.system.entry.js +1 -0
  127. package/dist/q2-tecton-elements/{p-b2a4162a.entry.js → p-9d82b5a4.entry.js} +1 -1
  128. package/dist/q2-tecton-elements/{p-4b737f84.system.entry.js → p-a0865160.system.entry.js} +1 -1
  129. package/dist/q2-tecton-elements/{p-832f3e02.entry.js → p-a7831802.entry.js} +1 -1
  130. package/dist/q2-tecton-elements/p-aa243b6a.system.entry.js +1 -0
  131. package/dist/q2-tecton-elements/{p-5f0adaa9.system.entry.js → p-ad806b56.system.entry.js} +1 -1
  132. package/dist/q2-tecton-elements/{p-75be017a.entry.js → p-b0d0f85d.entry.js} +1 -1
  133. package/dist/q2-tecton-elements/{p-2fce6304.entry.js → p-b3b046f3.entry.js} +1 -1
  134. package/dist/q2-tecton-elements/p-b5ebb4cb.js +1 -0
  135. package/dist/q2-tecton-elements/{p-f6023957.entry.js → p-ba96d37c.entry.js} +1 -1
  136. package/dist/q2-tecton-elements/{p-f6f4572b.system.entry.js → p-bbef2e56.system.entry.js} +1 -1
  137. package/dist/q2-tecton-elements/{p-07203a0e.entry.js → p-c39e81d3.entry.js} +1 -1
  138. package/dist/q2-tecton-elements/{p-46204d10.entry.js → p-c3d24f40.entry.js} +1 -1
  139. package/dist/q2-tecton-elements/p-c88975f8.entry.js +1 -0
  140. package/dist/q2-tecton-elements/{p-535687b4.system.entry.js → p-cb8d4e07.system.entry.js} +1 -1
  141. package/dist/q2-tecton-elements/{p-ad2fa69f.system.entry.js → p-cf340d13.system.entry.js} +1 -1
  142. package/dist/q2-tecton-elements/{p-390b9415.entry.js → p-d30f657f.entry.js} +1 -1
  143. package/dist/q2-tecton-elements/{p-8dfd0e89.system.entry.js → p-db3ade12.system.entry.js} +1 -1
  144. package/dist/q2-tecton-elements/{p-7b3a7b01.entry.js → p-dc4b38dc.entry.js} +1 -1
  145. package/dist/q2-tecton-elements/{p-4fd89735.system.entry.js → p-ebc8a18d.system.entry.js} +1 -1
  146. package/dist/q2-tecton-elements/{p-83ac78cd.entry.js → p-ed186964.entry.js} +1 -1
  147. package/dist/q2-tecton-elements/{p-3a2e7aad.system.entry.js → p-f1717e3c.system.entry.js} +1 -1
  148. package/dist/q2-tecton-elements/{p-dbf210b9.system.entry.js → p-f248c3db.system.entry.js} +1 -1
  149. package/dist/q2-tecton-elements/{p-9a298ef4.entry.js → p-f7f06773.entry.js} +1 -1
  150. package/dist/q2-tecton-elements/p-fc9ea618.system.entry.js +1 -0
  151. package/dist/q2-tecton-elements/{p-49ec33ae.system.entry.js → p-fcc00d73.system.entry.js} +1 -1
  152. package/dist/q2-tecton-elements/{p-b4637b36.system.entry.js → p-fefca9c1.system.entry.js} +1 -1
  153. package/dist/q2-tecton-elements/q2-tecton-elements.esm.js +1 -1
  154. package/dist/q2-tecton-elements/q2-tecton-elements.js +1 -1
  155. package/dist/types/components/q2-dropdown/index.d.ts +1 -0
  156. package/dist/types/components/q2-tab-container/index.d.ts +8 -4
  157. package/dist/types/workspace/workspace/{_tecton-production_release_1.4.x → _tecton-production_release_1.5.x}/packages/q2-tecton-elements/.stencil/test/helpers.d.ts +0 -0
  158. package/package.json +3 -2
  159. package/dist/q2-tecton-elements/p-00067d0a.system.js +0 -1
  160. package/dist/q2-tecton-elements/p-154bd5bd.entry.js +0 -1
  161. package/dist/q2-tecton-elements/p-1a8e579d.js +0 -1
  162. package/dist/q2-tecton-elements/p-268818c7.entry.js +0 -1
  163. package/dist/q2-tecton-elements/p-7e020511.system.entry.js +0 -1
  164. package/dist/q2-tecton-elements/p-bc15b363.entry.js +0 -1
  165. package/dist/q2-tecton-elements/p-ce8573ad.system.entry.js +0 -1
  166. package/dist/q2-tecton-elements/p-e41762c1.system.entry.js +0 -1
  167. package/dist/q2-tecton-elements/p-f08aea0c.system.js +0 -1
  168. package/dist/q2-tecton-elements/p-f15af226.entry.js +0 -1
@@ -2,1037 +2,466 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const index$1 = require('./index-88eda03b.js');
5
+ const index$1 = require('./index-56373ad4.js');
6
6
  const index$2 = require('./index-e73482dc.js');
7
7
 
8
- function isFunction(x) {
9
- return typeof x === 'function';
8
+ function createCommonjsModule(fn, basedir, module) {
9
+ return module = {
10
+ path: basedir,
11
+ exports: {},
12
+ require: function (path, base) {
13
+ return commonjsRequire();
14
+ }
15
+ }, fn(module, module.exports), module.exports;
10
16
  }
11
17
 
12
- let _enable_super_gross_mode_that_will_cause_bad_things = false;
13
- const config = {
14
- Promise: undefined,
15
- set useDeprecatedSynchronousErrorHandling(value) {
16
- if (value) {
17
- const error = new Error();
18
- console.warn('DEPRECATED! RxJS was set to use deprecated synchronous error handling behavior by code at: \n' + error.stack);
19
- }
20
- else if (_enable_super_gross_mode_that_will_cause_bad_things) {
21
- console.log('RxJS: Back to a better error behavior. Thank you. <3');
22
- }
23
- _enable_super_gross_mode_that_will_cause_bad_things = value;
24
- },
25
- get useDeprecatedSynchronousErrorHandling() {
26
- return _enable_super_gross_mode_that_will_cause_bad_things;
27
- },
28
- };
29
-
30
- function hostReportError(err) {
31
- setTimeout(() => { throw err; }, 0);
18
+ function commonjsRequire () {
19
+ throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
32
20
  }
33
21
 
34
- const empty = {
35
- closed: true,
36
- next(value) { },
37
- error(err) {
38
- if (config.useDeprecatedSynchronousErrorHandling) {
39
- throw err;
40
- }
41
- else {
42
- hostReportError(err);
43
- }
44
- },
45
- complete() { }
46
- };
47
-
48
- const isArray = (() => Array.isArray || ((x) => x && typeof x.length === 'number'))();
22
+ var smoothscroll = createCommonjsModule(function (module, exports) {
23
+ /* smoothscroll v0.4.4 - 2019 - Dustan Kasten, Jeremias Menichelli - MIT License */
24
+ (function () {
49
25
 
50
- function isObject(x) {
51
- return x !== null && typeof x === 'object';
52
- }
26
+ // polyfill
27
+ function polyfill() {
28
+ // aliases
29
+ var w = window;
30
+ var d = document;
53
31
 
54
- const UnsubscriptionErrorImpl = (() => {
55
- function UnsubscriptionErrorImpl(errors) {
56
- Error.call(this);
57
- this.message = errors ?
58
- `${errors.length} errors occurred during unsubscription:
59
- ${errors.map((err, i) => `${i + 1}) ${err.toString()}`).join('\n ')}` : '';
60
- this.name = 'UnsubscriptionError';
61
- this.errors = errors;
62
- return this;
32
+ // return if scroll behavior is supported and polyfill is not forced
33
+ if (
34
+ 'scrollBehavior' in d.documentElement.style &&
35
+ w.__forceSmoothScrollPolyfill__ !== true
36
+ ) {
37
+ return;
63
38
  }
64
- UnsubscriptionErrorImpl.prototype = Object.create(Error.prototype);
65
- return UnsubscriptionErrorImpl;
66
- })();
67
- const UnsubscriptionError = UnsubscriptionErrorImpl;
68
39
 
69
- class Subscription {
70
- constructor(unsubscribe) {
71
- this.closed = false;
72
- this._parentOrParents = null;
73
- this._subscriptions = null;
74
- if (unsubscribe) {
75
- this._ctorUnsubscribe = true;
76
- this._unsubscribe = unsubscribe;
77
- }
78
- }
79
- unsubscribe() {
80
- let errors;
81
- if (this.closed) {
82
- return;
83
- }
84
- let { _parentOrParents, _ctorUnsubscribe, _unsubscribe, _subscriptions } = this;
85
- this.closed = true;
86
- this._parentOrParents = null;
87
- this._subscriptions = null;
88
- if (_parentOrParents instanceof Subscription) {
89
- _parentOrParents.remove(this);
90
- }
91
- else if (_parentOrParents !== null) {
92
- for (let index = 0; index < _parentOrParents.length; ++index) {
93
- const parent = _parentOrParents[index];
94
- parent.remove(this);
95
- }
96
- }
97
- if (isFunction(_unsubscribe)) {
98
- if (_ctorUnsubscribe) {
99
- this._unsubscribe = undefined;
100
- }
101
- try {
102
- _unsubscribe.call(this);
103
- }
104
- catch (e) {
105
- errors = e instanceof UnsubscriptionError ? flattenUnsubscriptionErrors(e.errors) : [e];
106
- }
107
- }
108
- if (isArray(_subscriptions)) {
109
- let index = -1;
110
- let len = _subscriptions.length;
111
- while (++index < len) {
112
- const sub = _subscriptions[index];
113
- if (isObject(sub)) {
114
- try {
115
- sub.unsubscribe();
116
- }
117
- catch (e) {
118
- errors = errors || [];
119
- if (e instanceof UnsubscriptionError) {
120
- errors = errors.concat(flattenUnsubscriptionErrors(e.errors));
121
- }
122
- else {
123
- errors.push(e);
124
- }
125
- }
126
- }
127
- }
128
- }
129
- if (errors) {
130
- throw new UnsubscriptionError(errors);
131
- }
132
- }
133
- add(teardown) {
134
- let subscription = teardown;
135
- if (!teardown) {
136
- return Subscription.EMPTY;
137
- }
138
- switch (typeof teardown) {
139
- case 'function':
140
- subscription = new Subscription(teardown);
141
- case 'object':
142
- if (subscription === this || subscription.closed || typeof subscription.unsubscribe !== 'function') {
143
- return subscription;
144
- }
145
- else if (this.closed) {
146
- subscription.unsubscribe();
147
- return subscription;
148
- }
149
- else if (!(subscription instanceof Subscription)) {
150
- const tmp = subscription;
151
- subscription = new Subscription();
152
- subscription._subscriptions = [tmp];
153
- }
154
- break;
155
- default: {
156
- throw new Error('unrecognized teardown ' + teardown + ' added to Subscription.');
157
- }
158
- }
159
- let { _parentOrParents } = subscription;
160
- if (_parentOrParents === null) {
161
- subscription._parentOrParents = this;
162
- }
163
- else if (_parentOrParents instanceof Subscription) {
164
- if (_parentOrParents === this) {
165
- return subscription;
166
- }
167
- subscription._parentOrParents = [_parentOrParents, this];
168
- }
169
- else if (_parentOrParents.indexOf(this) === -1) {
170
- _parentOrParents.push(this);
171
- }
172
- else {
173
- return subscription;
174
- }
175
- const subscriptions = this._subscriptions;
176
- if (subscriptions === null) {
177
- this._subscriptions = [subscription];
178
- }
179
- else {
180
- subscriptions.push(subscription);
181
- }
182
- return subscription;
183
- }
184
- remove(subscription) {
185
- const subscriptions = this._subscriptions;
186
- if (subscriptions) {
187
- const subscriptionIndex = subscriptions.indexOf(subscription);
188
- if (subscriptionIndex !== -1) {
189
- subscriptions.splice(subscriptionIndex, 1);
190
- }
191
- }
192
- }
193
- }
194
- Subscription.EMPTY = (function (empty) {
195
- empty.closed = true;
196
- return empty;
197
- }(new Subscription()));
198
- function flattenUnsubscriptionErrors(errors) {
199
- return errors.reduce((errs, err) => errs.concat((err instanceof UnsubscriptionError) ? err.errors : err), []);
200
- }
40
+ // globals
41
+ var Element = w.HTMLElement || w.Element;
42
+ var SCROLL_TIME = 468;
201
43
 
202
- const rxSubscriber = (() => typeof Symbol === 'function'
203
- ? Symbol('rxSubscriber')
204
- : '@@rxSubscriber_' + Math.random())();
44
+ // object gathering original scroll methods
45
+ var original = {
46
+ scroll: w.scroll || w.scrollTo,
47
+ scrollBy: w.scrollBy,
48
+ elementScroll: Element.prototype.scroll || scrollElement,
49
+ scrollIntoView: Element.prototype.scrollIntoView
50
+ };
205
51
 
206
- class Subscriber extends Subscription {
207
- constructor(destinationOrNext, error, complete) {
208
- super();
209
- this.syncErrorValue = null;
210
- this.syncErrorThrown = false;
211
- this.syncErrorThrowable = false;
212
- this.isStopped = false;
213
- switch (arguments.length) {
214
- case 0:
215
- this.destination = empty;
216
- break;
217
- case 1:
218
- if (!destinationOrNext) {
219
- this.destination = empty;
220
- break;
221
- }
222
- if (typeof destinationOrNext === 'object') {
223
- if (destinationOrNext instanceof Subscriber) {
224
- this.syncErrorThrowable = destinationOrNext.syncErrorThrowable;
225
- this.destination = destinationOrNext;
226
- destinationOrNext.add(this);
227
- }
228
- else {
229
- this.syncErrorThrowable = true;
230
- this.destination = new SafeSubscriber(this, destinationOrNext);
231
- }
232
- break;
233
- }
234
- default:
235
- this.syncErrorThrowable = true;
236
- this.destination = new SafeSubscriber(this, destinationOrNext, error, complete);
237
- break;
238
- }
239
- }
240
- [rxSubscriber]() { return this; }
241
- static create(next, error, complete) {
242
- const subscriber = new Subscriber(next, error, complete);
243
- subscriber.syncErrorThrowable = false;
244
- return subscriber;
245
- }
246
- next(value) {
247
- if (!this.isStopped) {
248
- this._next(value);
249
- }
250
- }
251
- error(err) {
252
- if (!this.isStopped) {
253
- this.isStopped = true;
254
- this._error(err);
255
- }
256
- }
257
- complete() {
258
- if (!this.isStopped) {
259
- this.isStopped = true;
260
- this._complete();
261
- }
262
- }
263
- unsubscribe() {
264
- if (this.closed) {
265
- return;
266
- }
267
- this.isStopped = true;
268
- super.unsubscribe();
269
- }
270
- _next(value) {
271
- this.destination.next(value);
272
- }
273
- _error(err) {
274
- this.destination.error(err);
275
- this.unsubscribe();
276
- }
277
- _complete() {
278
- this.destination.complete();
279
- this.unsubscribe();
280
- }
281
- _unsubscribeAndRecycle() {
282
- const { _parentOrParents } = this;
283
- this._parentOrParents = null;
284
- this.unsubscribe();
285
- this.closed = false;
286
- this.isStopped = false;
287
- this._parentOrParents = _parentOrParents;
288
- return this;
289
- }
290
- }
291
- class SafeSubscriber extends Subscriber {
292
- constructor(_parentSubscriber, observerOrNext, error, complete) {
293
- super();
294
- this._parentSubscriber = _parentSubscriber;
295
- let next;
296
- let context = this;
297
- if (isFunction(observerOrNext)) {
298
- next = observerOrNext;
299
- }
300
- else if (observerOrNext) {
301
- next = observerOrNext.next;
302
- error = observerOrNext.error;
303
- complete = observerOrNext.complete;
304
- if (observerOrNext !== empty) {
305
- context = Object.create(observerOrNext);
306
- if (isFunction(context.unsubscribe)) {
307
- this.add(context.unsubscribe.bind(context));
308
- }
309
- context.unsubscribe = this.unsubscribe.bind(this);
310
- }
311
- }
312
- this._context = context;
313
- this._next = next;
314
- this._error = error;
315
- this._complete = complete;
316
- }
317
- next(value) {
318
- if (!this.isStopped && this._next) {
319
- const { _parentSubscriber } = this;
320
- if (!config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
321
- this.__tryOrUnsub(this._next, value);
322
- }
323
- else if (this.__tryOrSetError(_parentSubscriber, this._next, value)) {
324
- this.unsubscribe();
325
- }
326
- }
327
- }
328
- error(err) {
329
- if (!this.isStopped) {
330
- const { _parentSubscriber } = this;
331
- const { useDeprecatedSynchronousErrorHandling } = config;
332
- if (this._error) {
333
- if (!useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
334
- this.__tryOrUnsub(this._error, err);
335
- this.unsubscribe();
336
- }
337
- else {
338
- this.__tryOrSetError(_parentSubscriber, this._error, err);
339
- this.unsubscribe();
340
- }
341
- }
342
- else if (!_parentSubscriber.syncErrorThrowable) {
343
- this.unsubscribe();
344
- if (useDeprecatedSynchronousErrorHandling) {
345
- throw err;
346
- }
347
- hostReportError(err);
348
- }
349
- else {
350
- if (useDeprecatedSynchronousErrorHandling) {
351
- _parentSubscriber.syncErrorValue = err;
352
- _parentSubscriber.syncErrorThrown = true;
353
- }
354
- else {
355
- hostReportError(err);
356
- }
357
- this.unsubscribe();
358
- }
359
- }
360
- }
361
- complete() {
362
- if (!this.isStopped) {
363
- const { _parentSubscriber } = this;
364
- if (this._complete) {
365
- const wrappedComplete = () => this._complete.call(this._context);
366
- if (!config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
367
- this.__tryOrUnsub(wrappedComplete);
368
- this.unsubscribe();
369
- }
370
- else {
371
- this.__tryOrSetError(_parentSubscriber, wrappedComplete);
372
- this.unsubscribe();
373
- }
374
- }
375
- else {
376
- this.unsubscribe();
377
- }
378
- }
379
- }
380
- __tryOrUnsub(fn, value) {
381
- try {
382
- fn.call(this._context, value);
383
- }
384
- catch (err) {
385
- this.unsubscribe();
386
- if (config.useDeprecatedSynchronousErrorHandling) {
387
- throw err;
388
- }
389
- else {
390
- hostReportError(err);
391
- }
392
- }
393
- }
394
- __tryOrSetError(parent, fn, value) {
395
- if (!config.useDeprecatedSynchronousErrorHandling) {
396
- throw new Error('bad call');
397
- }
398
- try {
399
- fn.call(this._context, value);
400
- }
401
- catch (err) {
402
- if (config.useDeprecatedSynchronousErrorHandling) {
403
- parent.syncErrorValue = err;
404
- parent.syncErrorThrown = true;
405
- return true;
406
- }
407
- else {
408
- hostReportError(err);
409
- return true;
410
- }
411
- }
52
+ // define timing method
53
+ var now =
54
+ w.performance && w.performance.now
55
+ ? w.performance.now.bind(w.performance)
56
+ : Date.now;
57
+
58
+ /**
59
+ * indicates if a the current browser is made by Microsoft
60
+ * @method isMicrosoftBrowser
61
+ * @param {String} userAgent
62
+ * @returns {Boolean}
63
+ */
64
+ function isMicrosoftBrowser(userAgent) {
65
+ var userAgentPatterns = ['MSIE ', 'Trident/', 'Edge/'];
66
+
67
+ return new RegExp(userAgentPatterns.join('|')).test(userAgent);
68
+ }
69
+
70
+ /*
71
+ * IE has rounding bug rounding down clientHeight and clientWidth and
72
+ * rounding up scrollHeight and scrollWidth causing false positives
73
+ * on hasScrollableSpace
74
+ */
75
+ var ROUNDING_TOLERANCE = isMicrosoftBrowser(w.navigator.userAgent) ? 1 : 0;
76
+
77
+ /**
78
+ * changes scroll position inside an element
79
+ * @method scrollElement
80
+ * @param {Number} x
81
+ * @param {Number} y
82
+ * @returns {undefined}
83
+ */
84
+ function scrollElement(x, y) {
85
+ this.scrollLeft = x;
86
+ this.scrollTop = y;
87
+ }
88
+
89
+ /**
90
+ * returns result of applying ease math function to a number
91
+ * @method ease
92
+ * @param {Number} k
93
+ * @returns {Number}
94
+ */
95
+ function ease(k) {
96
+ return 0.5 * (1 - Math.cos(Math.PI * k));
97
+ }
98
+
99
+ /**
100
+ * indicates if a smooth behavior should be applied
101
+ * @method shouldBailOut
102
+ * @param {Number|Object} firstArg
103
+ * @returns {Boolean}
104
+ */
105
+ function shouldBailOut(firstArg) {
106
+ if (
107
+ firstArg === null ||
108
+ typeof firstArg !== 'object' ||
109
+ firstArg.behavior === undefined ||
110
+ firstArg.behavior === 'auto' ||
111
+ firstArg.behavior === 'instant'
112
+ ) {
113
+ // first argument is not an object/null
114
+ // or behavior is auto, instant or undefined
115
+ return true;
116
+ }
117
+
118
+ if (typeof firstArg === 'object' && firstArg.behavior === 'smooth') {
119
+ // first argument is an object and behavior is smooth
412
120
  return false;
413
- }
414
- _unsubscribe() {
415
- const { _parentSubscriber } = this;
416
- this._context = null;
417
- this._parentSubscriber = null;
418
- _parentSubscriber.unsubscribe();
419
- }
420
- }
421
-
422
- function canReportError(observer) {
423
- while (observer) {
424
- const { closed, destination, isStopped } = observer;
425
- if (closed || isStopped) {
426
- return false;
427
- }
428
- else if (destination && destination instanceof Subscriber) {
429
- observer = destination;
430
- }
431
- else {
432
- observer = null;
433
- }
434
- }
435
- return true;
436
- }
437
-
438
- function toSubscriber(nextOrObserver, error, complete) {
439
- if (nextOrObserver) {
440
- if (nextOrObserver instanceof Subscriber) {
441
- return nextOrObserver;
442
- }
443
- if (nextOrObserver[rxSubscriber]) {
444
- return nextOrObserver[rxSubscriber]();
445
- }
446
- }
447
- if (!nextOrObserver && !error && !complete) {
448
- return new Subscriber(empty);
449
- }
450
- return new Subscriber(nextOrObserver, error, complete);
451
- }
452
-
453
- const observable = (() => typeof Symbol === 'function' && Symbol.observable || '@@observable')();
454
-
455
- function identity(x) {
456
- return x;
457
- }
458
-
459
- function pipeFromArray(fns) {
460
- if (fns.length === 0) {
461
- return identity;
462
- }
463
- if (fns.length === 1) {
464
- return fns[0];
465
- }
466
- return function piped(input) {
467
- return fns.reduce((prev, fn) => fn(prev), input);
121
+ }
122
+
123
+ // throw error when behavior is not supported
124
+ throw new TypeError(
125
+ 'behavior member of ScrollOptions ' +
126
+ firstArg.behavior +
127
+ ' is not a valid value for enumeration ScrollBehavior.'
128
+ );
129
+ }
130
+
131
+ /**
132
+ * indicates if an element has scrollable space in the provided axis
133
+ * @method hasScrollableSpace
134
+ * @param {Node} el
135
+ * @param {String} axis
136
+ * @returns {Boolean}
137
+ */
138
+ function hasScrollableSpace(el, axis) {
139
+ if (axis === 'Y') {
140
+ return el.clientHeight + ROUNDING_TOLERANCE < el.scrollHeight;
141
+ }
142
+
143
+ if (axis === 'X') {
144
+ return el.clientWidth + ROUNDING_TOLERANCE < el.scrollWidth;
145
+ }
146
+ }
147
+
148
+ /**
149
+ * indicates if an element has a scrollable overflow property in the axis
150
+ * @method canOverflow
151
+ * @param {Node} el
152
+ * @param {String} axis
153
+ * @returns {Boolean}
154
+ */
155
+ function canOverflow(el, axis) {
156
+ var overflowValue = w.getComputedStyle(el, null)['overflow' + axis];
157
+
158
+ return overflowValue === 'auto' || overflowValue === 'scroll';
159
+ }
160
+
161
+ /**
162
+ * indicates if an element can be scrolled in either axis
163
+ * @method isScrollable
164
+ * @param {Node} el
165
+ * @param {String} axis
166
+ * @returns {Boolean}
167
+ */
168
+ function isScrollable(el) {
169
+ var isScrollableY = hasScrollableSpace(el, 'Y') && canOverflow(el, 'Y');
170
+ var isScrollableX = hasScrollableSpace(el, 'X') && canOverflow(el, 'X');
171
+
172
+ return isScrollableY || isScrollableX;
173
+ }
174
+
175
+ /**
176
+ * finds scrollable parent of an element
177
+ * @method findScrollableParent
178
+ * @param {Node} el
179
+ * @returns {Node} el
180
+ */
181
+ function findScrollableParent(el) {
182
+ while (el !== d.body && isScrollable(el) === false) {
183
+ el = el.parentNode || el.host;
184
+ }
185
+
186
+ return el;
187
+ }
188
+
189
+ /**
190
+ * self invoked function that, given a context, steps through scrolling
191
+ * @method step
192
+ * @param {Object} context
193
+ * @returns {undefined}
194
+ */
195
+ function step(context) {
196
+ var time = now();
197
+ var value;
198
+ var currentX;
199
+ var currentY;
200
+ var elapsed = (time - context.startTime) / SCROLL_TIME;
201
+
202
+ // avoid elapsed times higher than one
203
+ elapsed = elapsed > 1 ? 1 : elapsed;
204
+
205
+ // apply easing to elapsed time
206
+ value = ease(elapsed);
207
+
208
+ currentX = context.startX + (context.x - context.startX) * value;
209
+ currentY = context.startY + (context.y - context.startY) * value;
210
+
211
+ context.method.call(context.scrollable, currentX, currentY);
212
+
213
+ // scroll more if we have not reached our destination
214
+ if (currentX !== context.x || currentY !== context.y) {
215
+ w.requestAnimationFrame(step.bind(w, context));
216
+ }
217
+ }
218
+
219
+ /**
220
+ * scrolls window or element with a smooth behavior
221
+ * @method smoothScroll
222
+ * @param {Object|Node} el
223
+ * @param {Number} x
224
+ * @param {Number} y
225
+ * @returns {undefined}
226
+ */
227
+ function smoothScroll(el, x, y) {
228
+ var scrollable;
229
+ var startX;
230
+ var startY;
231
+ var method;
232
+ var startTime = now();
233
+
234
+ // define scroll context
235
+ if (el === d.body) {
236
+ scrollable = w;
237
+ startX = w.scrollX || w.pageXOffset;
238
+ startY = w.scrollY || w.pageYOffset;
239
+ method = original.scroll;
240
+ } else {
241
+ scrollable = el;
242
+ startX = el.scrollLeft;
243
+ startY = el.scrollTop;
244
+ method = scrollElement;
245
+ }
246
+
247
+ // scroll looping over a frame
248
+ step({
249
+ scrollable: scrollable,
250
+ method: method,
251
+ startTime: startTime,
252
+ startX: startX,
253
+ startY: startY,
254
+ x: x,
255
+ y: y
256
+ });
257
+ }
258
+
259
+ // ORIGINAL METHODS OVERRIDES
260
+ // w.scroll and w.scrollTo
261
+ w.scroll = w.scrollTo = function() {
262
+ // avoid action when no arguments are passed
263
+ if (arguments[0] === undefined) {
264
+ return;
265
+ }
266
+
267
+ // avoid smooth behavior if not required
268
+ if (shouldBailOut(arguments[0]) === true) {
269
+ original.scroll.call(
270
+ w,
271
+ arguments[0].left !== undefined
272
+ ? arguments[0].left
273
+ : typeof arguments[0] !== 'object'
274
+ ? arguments[0]
275
+ : w.scrollX || w.pageXOffset,
276
+ // use top prop, second argument if present or fallback to scrollY
277
+ arguments[0].top !== undefined
278
+ ? arguments[0].top
279
+ : arguments[1] !== undefined
280
+ ? arguments[1]
281
+ : w.scrollY || w.pageYOffset
282
+ );
283
+
284
+ return;
285
+ }
286
+
287
+ // LET THE SMOOTHNESS BEGIN!
288
+ smoothScroll.call(
289
+ w,
290
+ d.body,
291
+ arguments[0].left !== undefined
292
+ ? ~~arguments[0].left
293
+ : w.scrollX || w.pageXOffset,
294
+ arguments[0].top !== undefined
295
+ ? ~~arguments[0].top
296
+ : w.scrollY || w.pageYOffset
297
+ );
468
298
  };
469
- }
470
-
471
- class Observable {
472
- constructor(subscribe) {
473
- this._isScalar = false;
474
- if (subscribe) {
475
- this._subscribe = subscribe;
476
- }
477
- }
478
- lift(operator) {
479
- const observable = new Observable();
480
- observable.source = this;
481
- observable.operator = operator;
482
- return observable;
483
- }
484
- subscribe(observerOrNext, error, complete) {
485
- const { operator } = this;
486
- const sink = toSubscriber(observerOrNext, error, complete);
487
- if (operator) {
488
- sink.add(operator.call(sink, this.source));
489
- }
490
- else {
491
- sink.add(this.source || (config.useDeprecatedSynchronousErrorHandling && !sink.syncErrorThrowable) ?
492
- this._subscribe(sink) :
493
- this._trySubscribe(sink));
494
- }
495
- if (config.useDeprecatedSynchronousErrorHandling) {
496
- if (sink.syncErrorThrowable) {
497
- sink.syncErrorThrowable = false;
498
- if (sink.syncErrorThrown) {
499
- throw sink.syncErrorValue;
500
- }
501
- }
502
- }
503
- return sink;
504
- }
505
- _trySubscribe(sink) {
506
- try {
507
- return this._subscribe(sink);
508
- }
509
- catch (err) {
510
- if (config.useDeprecatedSynchronousErrorHandling) {
511
- sink.syncErrorThrown = true;
512
- sink.syncErrorValue = err;
513
- }
514
- if (canReportError(sink)) {
515
- sink.error(err);
516
- }
517
- else {
518
- console.warn(err);
519
- }
520
- }
521
- }
522
- forEach(next, promiseCtor) {
523
- promiseCtor = getPromiseCtor(promiseCtor);
524
- return new promiseCtor((resolve, reject) => {
525
- let subscription;
526
- subscription = this.subscribe((value) => {
527
- try {
528
- next(value);
529
- }
530
- catch (err) {
531
- reject(err);
532
- if (subscription) {
533
- subscription.unsubscribe();
534
- }
535
- }
536
- }, reject, resolve);
537
- });
538
- }
539
- _subscribe(subscriber) {
540
- const { source } = this;
541
- return source && source.subscribe(subscriber);
542
- }
543
- [observable]() {
544
- return this;
545
- }
546
- pipe(...operations) {
547
- if (operations.length === 0) {
548
- return this;
549
- }
550
- return pipeFromArray(operations)(this);
551
- }
552
- toPromise(promiseCtor) {
553
- promiseCtor = getPromiseCtor(promiseCtor);
554
- return new promiseCtor((resolve, reject) => {
555
- let value;
556
- this.subscribe((x) => value = x, (err) => reject(err), () => resolve(value));
557
- });
558
- }
559
- }
560
- Observable.create = (subscribe) => {
561
- return new Observable(subscribe);
562
- };
563
- function getPromiseCtor(promiseCtor) {
564
- if (!promiseCtor) {
565
- promiseCtor = Promise;
566
- }
567
- if (!promiseCtor) {
568
- throw new Error('no Promise impl found');
569
- }
570
- return promiseCtor;
571
- }
572
-
573
- class Action extends Subscription {
574
- constructor(scheduler, work) {
575
- super();
576
- }
577
- schedule(state, delay = 0) {
578
- return this;
579
- }
580
- }
581
-
582
- class AsyncAction extends Action {
583
- constructor(scheduler, work) {
584
- super(scheduler, work);
585
- this.scheduler = scheduler;
586
- this.work = work;
587
- this.pending = false;
588
- }
589
- schedule(state, delay = 0) {
590
- if (this.closed) {
591
- return this;
592
- }
593
- this.state = state;
594
- const id = this.id;
595
- const scheduler = this.scheduler;
596
- if (id != null) {
597
- this.id = this.recycleAsyncId(scheduler, id, delay);
598
- }
599
- this.pending = true;
600
- this.delay = delay;
601
- this.id = this.id || this.requestAsyncId(scheduler, this.id, delay);
602
- return this;
603
- }
604
- requestAsyncId(scheduler, id, delay = 0) {
605
- return setInterval(scheduler.flush.bind(scheduler, this), delay);
606
- }
607
- recycleAsyncId(scheduler, id, delay = 0) {
608
- if (delay !== null && this.delay === delay && this.pending === false) {
609
- return id;
610
- }
611
- clearInterval(id);
612
- return undefined;
613
- }
614
- execute(state, delay) {
615
- if (this.closed) {
616
- return new Error('executing a cancelled action');
617
- }
618
- this.pending = false;
619
- const error = this._execute(state, delay);
620
- if (error) {
621
- return error;
622
- }
623
- else if (this.pending === false && this.id != null) {
624
- this.id = this.recycleAsyncId(this.scheduler, this.id, null);
625
- }
626
- }
627
- _execute(state, delay) {
628
- let errored = false;
629
- let errorValue = undefined;
630
- try {
631
- this.work(state);
632
- }
633
- catch (e) {
634
- errored = true;
635
- errorValue = !!e && e || new Error(e);
636
- }
637
- if (errored) {
638
- this.unsubscribe();
639
- return errorValue;
640
- }
641
- }
642
- _unsubscribe() {
643
- const id = this.id;
644
- const scheduler = this.scheduler;
645
- const actions = scheduler.actions;
646
- const index = actions.indexOf(this);
647
- this.work = null;
648
- this.state = null;
649
- this.pending = false;
650
- this.scheduler = null;
651
- if (index !== -1) {
652
- actions.splice(index, 1);
653
- }
654
- if (id != null) {
655
- this.id = this.recycleAsyncId(scheduler, id, null);
656
- }
657
- this.delay = null;
658
- }
659
- }
660
-
661
- class Scheduler {
662
- constructor(SchedulerAction, now = Scheduler.now) {
663
- this.SchedulerAction = SchedulerAction;
664
- this.now = now;
665
- }
666
- schedule(work, delay = 0, state) {
667
- return new this.SchedulerAction(this, work).schedule(state, delay);
668
- }
669
- }
670
- Scheduler.now = () => Date.now();
671
-
672
- class AsyncScheduler extends Scheduler {
673
- constructor(SchedulerAction, now = Scheduler.now) {
674
- super(SchedulerAction, () => {
675
- if (AsyncScheduler.delegate && AsyncScheduler.delegate !== this) {
676
- return AsyncScheduler.delegate.now();
677
- }
678
- else {
679
- return now();
680
- }
681
- });
682
- this.actions = [];
683
- this.active = false;
684
- this.scheduled = undefined;
685
- }
686
- schedule(work, delay = 0, state) {
687
- if (AsyncScheduler.delegate && AsyncScheduler.delegate !== this) {
688
- return AsyncScheduler.delegate.schedule(work, delay, state);
689
- }
690
- else {
691
- return super.schedule(work, delay, state);
692
- }
693
- }
694
- flush(action) {
695
- const { actions } = this;
696
- if (this.active) {
697
- actions.push(action);
698
- return;
699
- }
700
- let error;
701
- this.active = true;
702
- do {
703
- if (error = action.execute(action.state, action.delay)) {
704
- break;
705
- }
706
- } while (action = actions.shift());
707
- this.active = false;
708
- if (error) {
709
- while (action = actions.shift()) {
710
- action.unsubscribe();
711
- }
712
- throw error;
713
- }
714
- }
715
- }
716
299
 
717
- const subscribeToArray = (array) => (subscriber) => {
718
- for (let i = 0, len = array.length; i < len && !subscriber.closed; i++) {
719
- subscriber.next(array[i]);
720
- }
721
- subscriber.complete();
722
- };
723
-
724
- const asyncScheduler = new AsyncScheduler(AsyncAction);
725
- const async = asyncScheduler;
726
-
727
- function map(project, thisArg) {
728
- return function mapOperation(source) {
729
- if (typeof project !== 'function') {
730
- throw new TypeError('argument is not a function. Are you looking for `mapTo()`?');
731
- }
732
- return source.lift(new MapOperator(project, thisArg));
300
+ // w.scrollBy
301
+ w.scrollBy = function() {
302
+ // avoid action when no arguments are passed
303
+ if (arguments[0] === undefined) {
304
+ return;
305
+ }
306
+
307
+ // avoid smooth behavior if not required
308
+ if (shouldBailOut(arguments[0])) {
309
+ original.scrollBy.call(
310
+ w,
311
+ arguments[0].left !== undefined
312
+ ? arguments[0].left
313
+ : typeof arguments[0] !== 'object' ? arguments[0] : 0,
314
+ arguments[0].top !== undefined
315
+ ? arguments[0].top
316
+ : arguments[1] !== undefined ? arguments[1] : 0
317
+ );
318
+
319
+ return;
320
+ }
321
+
322
+ // LET THE SMOOTHNESS BEGIN!
323
+ smoothScroll.call(
324
+ w,
325
+ d.body,
326
+ ~~arguments[0].left + (w.scrollX || w.pageXOffset),
327
+ ~~arguments[0].top + (w.scrollY || w.pageYOffset)
328
+ );
733
329
  };
734
- }
735
- class MapOperator {
736
- constructor(project, thisArg) {
737
- this.project = project;
738
- this.thisArg = thisArg;
739
- }
740
- call(subscriber, source) {
741
- return source.subscribe(new MapSubscriber(subscriber, this.project, this.thisArg));
742
- }
743
- }
744
- class MapSubscriber extends Subscriber {
745
- constructor(destination, project, thisArg) {
746
- super(destination);
747
- this.project = project;
748
- this.count = 0;
749
- this.thisArg = thisArg || this;
750
- }
751
- _next(value) {
752
- let result;
753
- try {
754
- result = this.project.call(this.thisArg, value, this.count++);
755
- }
756
- catch (err) {
757
- this.destination.error(err);
758
- return;
759
- }
760
- this.destination.next(result);
761
- }
762
- }
763
330
 
764
- const subscribeToPromise = (promise) => (subscriber) => {
765
- promise.then((value) => {
766
- if (!subscriber.closed) {
767
- subscriber.next(value);
768
- subscriber.complete();
769
- }
770
- }, (err) => subscriber.error(err))
771
- .then(null, hostReportError);
772
- return subscriber;
773
- };
331
+ // Element.prototype.scroll and Element.prototype.scrollTo
332
+ Element.prototype.scroll = Element.prototype.scrollTo = function() {
333
+ // avoid action when no arguments are passed
334
+ if (arguments[0] === undefined) {
335
+ return;
336
+ }
337
+
338
+ // avoid smooth behavior if not required
339
+ if (shouldBailOut(arguments[0]) === true) {
340
+ // if one number is passed, throw error to match Firefox implementation
341
+ if (typeof arguments[0] === 'number' && arguments[1] === undefined) {
342
+ throw new SyntaxError('Value could not be converted');
343
+ }
344
+
345
+ original.elementScroll.call(
346
+ this,
347
+ // use left prop, first number argument or fallback to scrollLeft
348
+ arguments[0].left !== undefined
349
+ ? ~~arguments[0].left
350
+ : typeof arguments[0] !== 'object' ? ~~arguments[0] : this.scrollLeft,
351
+ // use top prop, second argument or fallback to scrollTop
352
+ arguments[0].top !== undefined
353
+ ? ~~arguments[0].top
354
+ : arguments[1] !== undefined ? ~~arguments[1] : this.scrollTop
355
+ );
356
+
357
+ return;
358
+ }
359
+
360
+ var left = arguments[0].left;
361
+ var top = arguments[0].top;
362
+
363
+ // LET THE SMOOTHNESS BEGIN!
364
+ smoothScroll.call(
365
+ this,
366
+ this,
367
+ typeof left === 'undefined' ? this.scrollLeft : ~~left,
368
+ typeof top === 'undefined' ? this.scrollTop : ~~top
369
+ );
370
+ };
774
371
 
775
- function getSymbolIterator() {
776
- if (typeof Symbol !== 'function' || !Symbol.iterator) {
777
- return '@@iterator';
778
- }
779
- return Symbol.iterator;
780
- }
781
- const iterator = getSymbolIterator();
372
+ // Element.prototype.scrollBy
373
+ Element.prototype.scrollBy = function() {
374
+ // avoid action when no arguments are passed
375
+ if (arguments[0] === undefined) {
376
+ return;
377
+ }
378
+
379
+ // avoid smooth behavior if not required
380
+ if (shouldBailOut(arguments[0]) === true) {
381
+ original.elementScroll.call(
382
+ this,
383
+ arguments[0].left !== undefined
384
+ ? ~~arguments[0].left + this.scrollLeft
385
+ : ~~arguments[0] + this.scrollLeft,
386
+ arguments[0].top !== undefined
387
+ ? ~~arguments[0].top + this.scrollTop
388
+ : ~~arguments[1] + this.scrollTop
389
+ );
390
+
391
+ return;
392
+ }
393
+
394
+ this.scroll({
395
+ left: ~~arguments[0].left + this.scrollLeft,
396
+ top: ~~arguments[0].top + this.scrollTop,
397
+ behavior: arguments[0].behavior
398
+ });
399
+ };
782
400
 
783
- const subscribeToIterable = (iterable) => (subscriber) => {
784
- const iterator$1 = iterable[iterator]();
785
- do {
786
- let item;
787
- try {
788
- item = iterator$1.next();
789
- }
790
- catch (err) {
791
- subscriber.error(err);
792
- return subscriber;
793
- }
794
- if (item.done) {
795
- subscriber.complete();
796
- break;
797
- }
798
- subscriber.next(item.value);
799
- if (subscriber.closed) {
800
- break;
801
- }
802
- } while (true);
803
- if (typeof iterator$1.return === 'function') {
804
- subscriber.add(() => {
805
- if (iterator$1.return) {
806
- iterator$1.return();
807
- }
401
+ // Element.prototype.scrollIntoView
402
+ Element.prototype.scrollIntoView = function() {
403
+ // avoid smooth behavior if not required
404
+ if (shouldBailOut(arguments[0]) === true) {
405
+ original.scrollIntoView.call(
406
+ this,
407
+ arguments[0] === undefined ? true : arguments[0]
408
+ );
409
+
410
+ return;
411
+ }
412
+
413
+ // LET THE SMOOTHNESS BEGIN!
414
+ var scrollableParent = findScrollableParent(this);
415
+ var parentRects = scrollableParent.getBoundingClientRect();
416
+ var clientRects = this.getBoundingClientRect();
417
+
418
+ if (scrollableParent !== d.body) {
419
+ // reveal element inside parent
420
+ smoothScroll.call(
421
+ this,
422
+ scrollableParent,
423
+ scrollableParent.scrollLeft + clientRects.left - parentRects.left,
424
+ scrollableParent.scrollTop + clientRects.top - parentRects.top
425
+ );
426
+
427
+ // reveal parent in viewport unless is fixed
428
+ if (w.getComputedStyle(scrollableParent).position !== 'fixed') {
429
+ w.scrollBy({
430
+ left: parentRects.left,
431
+ top: parentRects.top,
432
+ behavior: 'smooth'
433
+ });
434
+ }
435
+ } else {
436
+ // reveal element in viewport
437
+ w.scrollBy({
438
+ left: clientRects.left,
439
+ top: clientRects.top,
440
+ behavior: 'smooth'
808
441
  });
809
- }
810
- return subscriber;
811
- };
812
-
813
- const subscribeToObservable = (obj) => (subscriber) => {
814
- const obs = obj[observable]();
815
- if (typeof obs.subscribe !== 'function') {
816
- throw new TypeError('Provided object does not correctly implement Symbol.observable');
817
- }
818
- else {
819
- return obs.subscribe(subscriber);
820
- }
821
- };
822
-
823
- const isArrayLike = ((x) => x && typeof x.length === 'number' && typeof x !== 'function');
824
-
825
- function isPromise(value) {
826
- return !!value && typeof value.subscribe !== 'function' && typeof value.then === 'function';
827
- }
828
-
829
- const subscribeTo = (result) => {
830
- if (!!result && typeof result[observable] === 'function') {
831
- return subscribeToObservable(result);
832
- }
833
- else if (isArrayLike(result)) {
834
- return subscribeToArray(result);
835
- }
836
- else if (isPromise(result)) {
837
- return subscribeToPromise(result);
838
- }
839
- else if (!!result && typeof result[iterator] === 'function') {
840
- return subscribeToIterable(result);
841
- }
842
- else {
843
- const value = isObject(result) ? 'an invalid object' : `'${result}'`;
844
- const msg = `You provided ${value} where a stream was expected.`
845
- + ' You can provide an Observable, Promise, Array, or Iterable.';
846
- throw new TypeError(msg);
847
- }
848
- };
849
-
850
- class SimpleInnerSubscriber extends Subscriber {
851
- constructor(parent) {
852
- super();
853
- this.parent = parent;
854
- }
855
- _next(value) {
856
- this.parent.notifyNext(value);
857
- }
858
- _error(error) {
859
- this.parent.notifyError(error);
860
- this.unsubscribe();
861
- }
862
- _complete() {
863
- this.parent.notifyComplete();
864
- this.unsubscribe();
865
- }
866
- }
867
- class SimpleOuterSubscriber extends Subscriber {
868
- notifyNext(innerValue) {
869
- this.destination.next(innerValue);
870
- }
871
- notifyError(err) {
872
- this.destination.error(err);
873
- }
874
- notifyComplete() {
875
- this.destination.complete();
876
- }
877
- }
878
- function innerSubscribe(result, innerSubscriber) {
879
- if (innerSubscriber.closed) {
880
- return undefined;
881
- }
882
- if (result instanceof Observable) {
883
- return result.subscribe(innerSubscriber);
884
- }
885
- return subscribeTo(result)(innerSubscriber);
886
- }
442
+ }
443
+ };
444
+ }
887
445
 
888
- function fromEvent(target, eventName, options, resultSelector) {
889
- if (isFunction(options)) {
890
- resultSelector = options;
891
- options = undefined;
892
- }
893
- if (resultSelector) {
894
- return fromEvent(target, eventName, options).pipe(map(args => isArray(args) ? resultSelector(...args) : resultSelector(args)));
895
- }
896
- return new Observable(subscriber => {
897
- function handler(e) {
898
- if (arguments.length > 1) {
899
- subscriber.next(Array.prototype.slice.call(arguments));
900
- }
901
- else {
902
- subscriber.next(e);
903
- }
904
- }
905
- setupSubscription(target, eventName, handler, subscriber, options);
906
- });
907
- }
908
- function setupSubscription(sourceObj, eventName, handler, subscriber, options) {
909
- let unsubscribe;
910
- if (isEventTarget(sourceObj)) {
911
- const source = sourceObj;
912
- sourceObj.addEventListener(eventName, handler, options);
913
- unsubscribe = () => source.removeEventListener(eventName, handler, options);
914
- }
915
- else if (isJQueryStyleEventEmitter(sourceObj)) {
916
- const source = sourceObj;
917
- sourceObj.on(eventName, handler);
918
- unsubscribe = () => source.off(eventName, handler);
919
- }
920
- else if (isNodeStyleEventEmitter(sourceObj)) {
921
- const source = sourceObj;
922
- sourceObj.addListener(eventName, handler);
923
- unsubscribe = () => source.removeListener(eventName, handler);
924
- }
925
- else if (sourceObj && sourceObj.length) {
926
- for (let i = 0, len = sourceObj.length; i < len; i++) {
927
- setupSubscription(sourceObj[i], eventName, handler, subscriber, options);
928
- }
929
- }
930
- else {
931
- throw new TypeError('Invalid event target');
932
- }
933
- subscriber.add(unsubscribe);
934
- }
935
- function isNodeStyleEventEmitter(sourceObj) {
936
- return sourceObj && typeof sourceObj.addListener === 'function' && typeof sourceObj.removeListener === 'function';
937
- }
938
- function isJQueryStyleEventEmitter(sourceObj) {
939
- return sourceObj && typeof sourceObj.on === 'function' && typeof sourceObj.off === 'function';
940
- }
941
- function isEventTarget(sourceObj) {
942
- return sourceObj && typeof sourceObj.addEventListener === 'function' && typeof sourceObj.removeEventListener === 'function';
943
- }
446
+ {
447
+ // commonjs
448
+ module.exports = { polyfill: polyfill };
449
+ }
944
450
 
945
- function isNumeric(val) {
946
- return !isArray(val) && (val - parseFloat(val) + 1) >= 0;
947
- }
451
+ }());
452
+ });
948
453
 
949
- function interval(period = 0, scheduler = async) {
950
- if (!isNumeric(period) || period < 0) {
951
- period = 0;
952
- }
953
- if (!scheduler || typeof scheduler.schedule !== 'function') {
954
- scheduler = async;
955
- }
956
- return new Observable(subscriber => {
957
- subscriber.add(scheduler.schedule(dispatch, period, { subscriber, counter: 0, period }));
958
- return subscriber;
959
- });
960
- }
961
- function dispatch(state) {
962
- const { subscriber, counter, period } = state;
963
- subscriber.next(counter);
964
- this.schedule({ subscriber, counter: counter + 1, period }, period);
965
- }
454
+ const stylesCss = "*{-webkit-box-sizing:border-box;box-sizing:border-box}*:active{outline:none}*:focus{outline:none;-webkit-box-shadow:var(--const-global-focus);box-shadow:var(--const-global-focus)}:host{-webkit-box-shadow:none !important;box-shadow:none !important}::-moz-focus-inner{border:none}input,button{font-family:inherit;font-size:inherit}:host(.sr),:host(.sr) button{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;white-space:nowrap}.sr,.sr button{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;white-space:nowrap}.hidden{display:none}:host([hidden]){display:none}.invisible{visibility:hidden}.tab-container{position:relative;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}.tab-list{padding:0;display:-ms-flexbox;display:flex;margin:0;list-style:none;border-bottom:1px solid\n var(--tct-tab-container-border-color, var(--tct-gray-l1, var(--app-gray-l1, #cccccc)));white-space:nowrap;overflow-x:hidden;-ms-flex-align:center;align-items:center}.tab-list li.nav{position:absolute;height:44px;width:46px}.tab-list li.nav-left{left:-15px;background:-webkit-gradient(linear, left top, right top, color-stop(60%, var(--tct-section-bg, var(--t-section-bg, #ffffff))), to(rgba(255,255,255,0)));background:linear-gradient(to right, var(--tct-section-bg, var(--t-section-bg, #ffffff)) 60%, rgba(255,255,255,0))}.tab-list li.nav-right{right:-15px;background:-webkit-gradient(linear, right top, left top, color-stop(60%, var(--tct-section-bg, var(--t-section-bg, #ffffff))), to(rgba(255,255,255,0)));background:linear-gradient(to left, var(--tct-section-bg, var(--t-section-bg, #ffffff)) 60%, rgba(255,255,255,0))}.tab-list li.nav .arrow-container{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center;height:inherit;width:inherit;cursor:pointer}.tab-list li.nav .arrow-container a{padding:0;margin:0;height:inherit;width:inherit;border-bottom:0;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center}.tab-list li.nav .arrow-container a q2-icon{width:19px;height:19px}.tab-list a{width:var(--tct-tab-hover-width, var(--t-tab-hover-width, 100%));text-align:center;text-decoration:none;padding:var(--tct-scale-2, var(--app-scale-2, 10px));margin:var(--tct-scale-1, var(--app-scale-1, 5px)) var(--tct-scale-1, var(--app-scale-1, 5px))\n 0;color:var(--tct-tab-inactive-color, var(--t-tab-inactive, inherit));font-size:var(--tct-tab-font-size, var(--t-tab-font-size, 17px));border-bottom:3px solid transparent;display:block;-webkit-transition:color var(--tct-tween-2, var(--app-tween-2, 0.4s ease)),\n border-color var(--tct-tween-1, var(--app-tween-1, 0.2s ease));transition:color var(--tct-tween-2, var(--app-tween-2, 0.4s ease)),\n border-color var(--tct-tween-1, var(--app-tween-1, 0.2s ease))}:host([type='section']) .tab-list a{font-size:inherit;padding:var(--tct-scale-2, var(--app-scale-2, 10px))\n var(--tct-scale-1, var(--app-scale-1, 5px))}@media screen and (max-width: 767px){.tab-list a{font-size:inherit;padding:var(--tct-scale-2, var(--app-scale-2, 10px))\n var(--tct-scale-1, var(--app-scale-1, 5px))}}.tab-list a:hover{color:var(--tct-tab-active-color, var(--t-tab-active, #2e2e2e));background-color:var(--tct-tab-hover-bg-color, var(--t-tab-hover-bg-color, inherit));width:var(--tct-tab-hover-width, var(--t-tab-hover-width, 100%))}.tab-list a[aria-selected='true']{color:var(--tct-tab-active-color, var(--t-tab-active, #2e2e2e));border-color:currentColor;width:var(--tct-tab-active-width, var(--t-tab-active-width, 100%));background-color:var(--tct-tab-active-bg-color, var(--t-tab-active-bg-color, inherit))}:host([color='alt']) .tab-list a{color:var(--tct-tab-alt-inactive-color, var(--t-tab-alt-inactive, inherit))}:host([color='alt']) .tab-list a:hover,:host([color='alt']) .tab-list a[aria-selected='true']{color:var(--tct-tab-alt-active-color, var(--t-tab-alt-active, inherit))}.tab-content{padding:var(--tct-scale-2, var(--app-scale-2, 10px)) 0}";
966
455
 
967
- function debounce(durationSelector) {
968
- return (source) => source.lift(new DebounceOperator(durationSelector));
969
- }
970
- class DebounceOperator {
971
- constructor(durationSelector) {
972
- this.durationSelector = durationSelector;
973
- }
974
- call(subscriber, source) {
975
- return source.subscribe(new DebounceSubscriber(subscriber, this.durationSelector));
976
- }
456
+ // enable scroll animation polyfill only on safari
457
+ const userAgent = navigator.userAgent.toLowerCase();
458
+ const isSafari = userAgent.includes('safari') && !userAgent.includes('chrome');
459
+ const isFirefox = userAgent.includes('firefox');
460
+ if (isSafari) {
461
+ // smooth scroll is not supported on safari
462
+ smoothscroll.polyfill();
463
+ window['__forceSmoothScrollPolyfill__'] = true;
977
464
  }
978
- class DebounceSubscriber extends SimpleOuterSubscriber {
979
- constructor(destination, durationSelector) {
980
- super(destination);
981
- this.durationSelector = durationSelector;
982
- this.hasValue = false;
983
- }
984
- _next(value) {
985
- try {
986
- const result = this.durationSelector.call(this, value);
987
- if (result) {
988
- this._tryNext(value, result);
989
- }
990
- }
991
- catch (err) {
992
- this.destination.error(err);
993
- }
994
- }
995
- _complete() {
996
- this.emitValue();
997
- this.destination.complete();
998
- }
999
- _tryNext(value, duration) {
1000
- let subscription = this.durationSubscription;
1001
- this.value = value;
1002
- this.hasValue = true;
1003
- if (subscription) {
1004
- subscription.unsubscribe();
1005
- this.remove(subscription);
1006
- }
1007
- subscription = innerSubscribe(duration, new SimpleInnerSubscriber(this));
1008
- if (subscription && !subscription.closed) {
1009
- this.add(this.durationSubscription = subscription);
1010
- }
1011
- }
1012
- notifyNext() {
1013
- this.emitValue();
1014
- }
1015
- notifyComplete() {
1016
- this.emitValue();
1017
- }
1018
- emitValue() {
1019
- if (this.hasValue) {
1020
- const value = this.value;
1021
- const subscription = this.durationSubscription;
1022
- if (subscription) {
1023
- this.durationSubscription = undefined;
1024
- subscription.unsubscribe();
1025
- this.remove(subscription);
1026
- }
1027
- this.value = undefined;
1028
- this.hasValue = false;
1029
- super._next(value);
1030
- }
1031
- }
1032
- }
1033
-
1034
- const stylesCss = "*{-webkit-box-sizing:border-box;box-sizing:border-box}*:active{outline:none}*:focus{outline:none;-webkit-box-shadow:var(--const-global-focus);box-shadow:var(--const-global-focus)}:host{-webkit-box-shadow:none !important;box-shadow:none !important}::-moz-focus-inner{border:none}input,button{font-family:inherit;font-size:inherit}:host(.sr),:host(.sr) button{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;white-space:nowrap}.sr,.sr button{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;white-space:nowrap}.hidden{display:none}:host([hidden]){display:none}.invisible{visibility:hidden}.tab-container{position:relative;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}.tab-list{padding:0;display:-ms-flexbox;display:flex;margin:0;list-style:none;border-bottom:1px solid\n var(--tct-tab-container-border-color, var(--tct-gray-l1, var(--app-gray-l1, #cccccc)));white-space:nowrap;overflow-x:hidden;-ms-flex-align:center;align-items:center}.tab-list li.nav{position:absolute;height:44px;width:46px}.tab-list li.nav-left{left:-15px;background:-webkit-gradient(linear, left top, right top, color-stop(60%, var(--tct-section-bg, var(--t-section-bg, #ffffff))), to(transparent));background:linear-gradient(to right, var(--tct-section-bg, var(--t-section-bg, #ffffff)) 60%, transparent)}.tab-list li.nav-right{right:-15px;background:-webkit-gradient(linear, right top, left top, color-stop(60%, var(--tct-section-bg, var(--t-section-bg, #ffffff))), to(transparent));background:linear-gradient(to left, var(--tct-section-bg, var(--t-section-bg, #ffffff)) 60%, transparent)}.tab-list li.nav .arrow-container{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center;height:inherit;width:inherit;cursor:pointer}.tab-list li.nav .arrow-container a{padding:0;margin:0;height:inherit;width:inherit;border-bottom:0;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center}.tab-list li.nav .arrow-container a q2-icon{width:19px;height:19px}.tab-list a{text-decoration:none;padding:var(--tct-scale-2, var(--app-scale-2, 10px));margin:var(--tct-scale-1, var(--app-scale-1, 5px)) var(--tct-scale-1, var(--app-scale-1, 5px))\n 0;color:var(--tct-tab-inactive-color, var(--t-tab-inactive, inherit));font-size:var(--tct-tab-font-size, var(--t-tab-font-size, 17px));border-bottom:3px solid transparent;display:block;-webkit-transition:color var(--tct-tween-2, var(--app-tween-2, 0.4s ease)),\n border-color var(--tct-tween-1, var(--app-tween-1, 0.2s ease));transition:color var(--tct-tween-2, var(--app-tween-2, 0.4s ease)),\n border-color var(--tct-tween-1, var(--app-tween-1, 0.2s ease))}:host([type='section']) .tab-list a{font-size:inherit;padding:var(--tct-scale-2, var(--app-scale-2, 10px))\n var(--tct-scale-1, var(--app-scale-1, 5px))}@media screen and (max-width: 767px){.tab-list a{font-size:inherit;padding:var(--tct-scale-2, var(--app-scale-2, 10px))\n var(--tct-scale-1, var(--app-scale-1, 5px))}}.tab-list a:hover{color:var(--tct-tab-active-color, var(--t-tab-active, #2e2e2e));background-color:var(--tct-tab-hover-bg-color, var(--t-tab-hover-bg-color, inherit));width:var(--tct-tab-hover-width, var(--t-tab-hover-width, 100%))}.tab-list a[aria-selected='true']{color:var(--tct-tab-active-color, var(--t-tab-active, #2e2e2e));border-color:currentColor;width:var(--tct-tab-active-width, var(--t-tab-active-width, 100%));background-color:var(--tct-tab-active-bg-color, var(--t-tab-active-bg-color, inherit))}:host([color='alt']) .tab-list a{color:var(--tct-tab-alt-inactive-color, var(--t-tab-alt-inactive, inherit))}:host([color='alt']) .tab-list a:hover,:host([color='alt']) .tab-list a[aria-selected='true']{color:var(--tct-tab-alt-active-color, var(--t-tab-alt-active, inherit))}.tab-content{padding:var(--tct-scale-2, var(--app-scale-2, 10px)) 0}";
1035
-
1036
465
  const Q2TabContainer = class {
1037
466
  constructor(hostRef) {
1038
467
  index$1.registerInstance(this, hostRef);
@@ -1040,16 +469,9 @@ const Q2TabContainer = class {
1040
469
  this.settled = index$1.createEvent(this, "settled", 7);
1041
470
  this.guid = index$2.createGuid();
1042
471
  this.scheduledAfterRender = [];
472
+ this.lastScrolled = new Date(null).getTime();
1043
473
  this.hasLeft = false;
1044
474
  this.hasRight = false;
1045
- this.initTabScroll = () => {
1046
- const tabList = this.hostElement.shadowRoot.querySelector('.tab-list');
1047
- if (tabList) {
1048
- const { scrollWidth, clientWidth, scrollLeft } = tabList;
1049
- this.hasLeft = scrollLeft > 0;
1050
- this.hasRight = scrollWidth > clientWidth;
1051
- }
1052
- };
1053
475
  ///////// Actions /////////
1054
476
  this.updateTabData = () => {
1055
477
  this.updateTabPaneProps();
@@ -1085,34 +507,77 @@ const Q2TabContainer = class {
1085
507
  this.moveToAdjacentTab(value, 'prev');
1086
508
  return;
1087
509
  }
510
+ if (event.code === 'Space' || event.code === 'Enter') {
511
+ // to prevent triggering scroll when press the space key
512
+ event.preventDefault();
513
+ this.change.emit({ value });
514
+ return;
515
+ }
1088
516
  };
1089
517
  this.moveToAdjacentTab = (value, direction) => {
1090
518
  let index = this.tabs.map(({ value }) => value).indexOf(value);
1091
- let indexUpdated = false;
1092
- if (direction === 'next' && index !== this.tabs.length - 1) {
1093
- index = index + 1;
1094
- indexUpdated = true;
1095
- }
1096
- if (direction === 'prev' && index !== 0) {
1097
- index = index - 1;
1098
- indexUpdated = true;
519
+ let newIndex = direction === 'next'
520
+ ? Math.min(index + 1, this.tabs.length - 1)
521
+ : Math.max(index - 1, 0);
522
+ if (index !== newIndex) {
523
+ const focusedTab = this.moveFocus(newIndex);
524
+ // Scroll only if it overflows
525
+ if (this.tabList.scrollWidth > this.tabList.clientWidth) {
526
+ // Scroll only if it's first or last tab
527
+ if (newIndex !== 0 && newIndex !== this.tabs.length - 1) {
528
+ this.scrollByKeyboard(direction, focusedTab);
529
+ }
530
+ else {
531
+ // first or last element: just show or hide nav arrow
532
+ this.onTabScroll(direction);
533
+ }
534
+ }
1099
535
  }
1100
- if (indexUpdated) {
1101
- const value = this.tabs[index].value;
1102
- this.hostElement.shadowRoot
1103
- .querySelector(`.tab-list a[data-value="${value}"]`)
1104
- .focus();
1105
- this.change.emit({ value });
536
+ };
537
+ this.moveFocus = (index) => {
538
+ const focusedValue = this.tabs[index].value;
539
+ const focusedTab = this.hostElement.shadowRoot.querySelector(`.tab-list a[data-value="${focusedValue}"]`);
540
+ focusedTab.focus({ preventScroll: true });
541
+ return focusedTab;
542
+ };
543
+ this.calculateKeyboardScroll = (direction, focusedTab) => {
544
+ const { left: tabListLeft } = this.tabList.getBoundingClientRect();
545
+ const { left: focusedTabLeft } = focusedTab.getBoundingClientRect();
546
+ const arrowWidth = 46;
547
+ let scrollAmount = 0;
548
+ // check how much focused tab overflows
549
+ if (direction === 'next' &&
550
+ focusedTabLeft + focusedTab.clientWidth >
551
+ tabListLeft + this.tabList.clientWidth + arrowWidth) {
552
+ scrollAmount =
553
+ this.tabList.scrollLeft +
554
+ arrowWidth +
555
+ (focusedTabLeft + focusedTab.clientWidth) -
556
+ (tabListLeft + this.tabList.clientWidth);
557
+ }
558
+ else if (direction === 'prev' && focusedTabLeft + arrowWidth < tabListLeft) {
559
+ scrollAmount = this.tabList.scrollLeft - arrowWidth + (focusedTabLeft - tabListLeft);
560
+ }
561
+ return scrollAmount;
562
+ };
563
+ this.scrollByKeyboard = (direction, focusedTab) => {
564
+ const scrollAmount = this.calculateKeyboardScroll(direction, focusedTab);
565
+ if (scrollAmount !== 0) {
566
+ this.tabList.scroll({ left: scrollAmount, behavior: 'smooth' });
567
+ // wait to finish scroll then show or hide nav arrow
568
+ setTimeout(() => this.onTabScroll(), 100);
1106
569
  }
1107
570
  };
1108
571
  this.calculateTabScroll = ({ direction, scrollWidth, clientWidth, scrollLeft }) => {
572
+ const directions = { prev: -1, next: 1 };
573
+ // step 0 means no scroll needed, re-render or resize can trigger this
574
+ const step = directions[direction] || 0;
1109
575
  const scrollRate = 0.5; // half of visual width
1110
- const step = direction === 'left' ? -1 : 1;
1111
576
  const delta = Math.round(clientWidth * scrollRate);
1112
577
  const newScrollLeft = scrollLeft + step * delta;
1113
578
  const scrolled = clientWidth + newScrollLeft;
1114
579
  const hasLeft = newScrollLeft > 0;
1115
- const hasRight = scrollWidth >= scrolled;
580
+ const hasRight = scrollWidth > scrolled;
1116
581
  return {
1117
582
  newScrollLeft,
1118
583
  hasLeft,
@@ -1120,8 +585,14 @@ const Q2TabContainer = class {
1120
585
  };
1121
586
  };
1122
587
  this.onTabScroll = (direction) => {
1123
- const tabList = this.hostElement.shadowRoot.querySelector('.tab-list');
1124
- let { scrollWidth, clientWidth, scrollLeft } = tabList;
588
+ // throttle under 50ms due to re-rendering & resizing
589
+ const now = new Date().getTime();
590
+ if (now - this.lastScrolled < 50)
591
+ return;
592
+ this.lastScrolled = now;
593
+ if (!this.tabList)
594
+ return;
595
+ let { scrollWidth, clientWidth, scrollLeft } = this.tabList;
1125
596
  const { newScrollLeft, hasLeft, hasRight } = this.calculateTabScroll({
1126
597
  direction,
1127
598
  scrollWidth,
@@ -1130,7 +601,9 @@ const Q2TabContainer = class {
1130
601
  });
1131
602
  this.hasLeft = hasLeft;
1132
603
  this.hasRight = hasRight;
1133
- tabList.scroll({ left: newScrollLeft, behavior: 'smooth' });
604
+ if (direction) {
605
+ this.tabList.scroll({ left: newScrollLeft, behavior: 'smooth' });
606
+ }
1134
607
  };
1135
608
  }
1136
609
  loc(key, subs) {
@@ -1153,12 +626,25 @@ const Q2TabContainer = class {
1153
626
  get selectedTabValue() {
1154
627
  return this.value || this.tabPanes[0].value || '';
1155
628
  }
629
+ get tabList() {
630
+ return this.hostElement.shadowRoot.querySelector('.tab-list');
631
+ }
1156
632
  ///////// Default Handler /////////
1157
633
  defaultChangeHandler(event) {
1158
634
  if (event.target === this.hostElement && !this.hostElement.onchange) {
1159
635
  this.value = event.detail.value;
1160
636
  }
1161
637
  }
638
+ onResize() {
639
+ this.onTabScroll();
640
+ }
641
+ onFocus() {
642
+ // firefox receives focus on overflowed element even if it's not interactive element
643
+ if (isFirefox) {
644
+ const index = this.tabs.findIndex(el => el.value === this.selectedTabValue);
645
+ this.moveFocus(index);
646
+ }
647
+ }
1162
648
  ///////// Lifecycle Hooks /////////
1163
649
  componentWillLoad() {
1164
650
  const observer = new MutationObserver(this.updateTabData);
@@ -1170,18 +656,11 @@ const Q2TabContainer = class {
1170
656
  this.scheduledAfterRender.forEach(fn => fn());
1171
657
  this.scheduledAfterRender = [];
1172
658
  this.settled.emit();
1173
- if (!this.resizeSubscription) {
1174
- this.initTabScroll();
1175
- this.resizeSubscription = fromEvent(window, 'resize')
1176
- .pipe(debounce(() => interval(200)))
1177
- .subscribe(this.initTabScroll);
1178
- }
659
+ this.onTabScroll();
1179
660
  }
1180
661
  disconnectedCallback() {
1181
662
  this.mutationObserver.disconnect();
1182
663
  this.mutationObserver = null;
1183
- this.resizeSubscription.unsubscribe();
1184
- this.resizeSubscription = null;
1185
664
  }
1186
665
  ///////// Observers /////////
1187
666
  valueObserver() {
@@ -1193,7 +672,7 @@ const Q2TabContainer = class {
1193
672
  }
1194
673
  ///////// View Methods /////////
1195
674
  render() {
1196
- return (index$1.h("div", { class: "tab-container" }, index$1.h("ul", { class: "tab-list", role: "tablist" }, this.hasLeft && (index$1.h("li", { role: "presentation", class: "nav nav-left", onClick: () => this.onTabScroll('left') }, index$1.h("div", { class: "arrow-container" }, index$1.h("a", null, index$1.h("q2-icon", { type: "chevron-left" }))))), this.tabs.map((tab, index) => this.generateTab(tab, index)), this.hasRight && (index$1.h("li", { role: "presentation", class: "nav nav-right", onClick: () => this.onTabScroll('right') }, index$1.h("div", { class: "arrow-container" }, index$1.h("a", null, index$1.h("q2-icon", { type: "chevron-right" })))))), index$1.h("div", { class: "tab-content" }, index$1.h("slot", null))));
675
+ return (index$1.h("div", { class: "tab-container" }, index$1.h("ul", { class: "tab-list", role: "tablist" }, this.hasLeft && (index$1.h("li", { role: "presentation", class: "nav nav-left", onClick: () => this.onTabScroll('prev') }, index$1.h("div", { class: "arrow-container" }, index$1.h("a", null, index$1.h("q2-icon", { type: "chevron-left" }))))), this.tabs.map((tab, index) => this.generateTab(tab, index)), this.hasRight && (index$1.h("li", { role: "presentation", class: "nav nav-right", onClick: () => this.onTabScroll('next') }, index$1.h("div", { class: "arrow-container" }, index$1.h("a", null, index$1.h("q2-icon", { type: "chevron-right" })))))), index$1.h("div", { class: "tab-content" }, index$1.h("slot", null))));
1197
676
  }
1198
677
  generateTab(tab, index) {
1199
678
  const { label, value } = tab;