q2-tecton-elements 1.10.3 → 1.10.4
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/dist/cjs/click-elsewhere.cjs.entry.js +1 -1
- package/dist/cjs/{icons-fa5f4367.js → icons-921779df.js} +250 -1
- package/dist/cjs/{index-6b2c271e.js → index-c2e53804.js} +19 -0
- package/dist/cjs/{index-14348270.js → index-f4153f5a.js} +18 -4
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/q2-avatar.cjs.entry.js +3 -3
- package/dist/cjs/q2-btn_2.cjs.entry.js +3 -3
- package/dist/cjs/q2-calendar.cjs.entry.js +7 -3
- package/dist/cjs/q2-carousel-pane.cjs.entry.js +2 -2
- package/dist/cjs/q2-carousel.cjs.entry.js +2 -2
- package/dist/cjs/q2-checkbox-group.cjs.entry.js +2 -2
- package/dist/cjs/q2-checkbox.cjs.entry.js +2 -2
- package/dist/cjs/q2-dropdown-item.cjs.entry.js +2 -2
- package/dist/cjs/q2-dropdown.cjs.entry.js +2 -2
- package/dist/cjs/q2-editable-field.cjs.entry.js +2 -2
- package/dist/cjs/q2-icon.cjs.entry.js +3 -3
- package/dist/cjs/q2-input.cjs.entry.js +3 -3
- package/dist/cjs/q2-loading-element.cjs.entry.js +2 -2
- package/dist/cjs/q2-loc.cjs.entry.js +2 -2
- package/dist/cjs/q2-message.cjs.entry.js +21 -3
- package/dist/cjs/q2-optgroup.cjs.entry.js +2 -2
- package/dist/cjs/q2-option.cjs.entry.js +1 -1
- package/dist/cjs/q2-radio-group.cjs.entry.js +8 -4
- package/dist/cjs/q2-radio.cjs.entry.js +2 -2
- package/dist/cjs/q2-section.cjs.entry.js +2 -2
- package/dist/cjs/q2-select.cjs.entry.js +2 -2
- package/dist/cjs/q2-stepper-pane.cjs.entry.js +2 -2
- package/dist/cjs/q2-stepper.cjs.entry.js +2 -2
- package/dist/cjs/q2-tab-container.cjs.entry.js +85 -115
- package/dist/cjs/q2-tab-pane.cjs.entry.js +1 -1
- package/dist/cjs/q2-tecton-elements.cjs.js +2 -2
- package/dist/cjs/q2-textarea.cjs.entry.js +2 -2
- package/dist/cjs/{shapes-a7595d72.js → shapes-086c0365.js} +1 -1
- package/dist/cjs/tecton-tab-pane.cjs.entry.js +12 -1
- package/dist/collection/components/q2-avatar/index.js +2 -2
- package/dist/collection/components/q2-calendar/index.js +5 -1
- package/dist/collection/components/q2-icon/icons.js +249 -0
- package/dist/collection/components/q2-input/styles.css +5 -4
- package/dist/collection/components/q2-message/index.js +48 -8
- package/dist/collection/components/q2-message/styles.css +68 -75
- package/dist/collection/components/q2-radio-group/index.js +7 -3
- package/dist/collection/components/q2-radio-group/styles.css +3 -0
- package/dist/collection/components/q2-tab-container/index.js +97 -125
- package/dist/collection/components/q2-tab-container/styles.css +118 -98
- package/dist/collection/components/tecton-tab-pane/index.js +11 -0
- package/dist/collection/utils/index.js +9 -3
- package/dist/esm/click-elsewhere.entry.js +1 -1
- package/dist/esm/{icons-17612675.js → icons-a3817842.js} +250 -1
- package/dist/esm/{index-da24669a.js → index-476b86cc.js} +17 -5
- package/dist/esm/{index-5fa3e016.js → index-be8376c0.js} +19 -0
- package/dist/esm/loader.js +2 -2
- package/dist/esm/q2-avatar.entry.js +3 -3
- package/dist/esm/q2-btn_2.entry.js +3 -3
- package/dist/esm/q2-calendar.entry.js +7 -3
- package/dist/esm/q2-carousel-pane.entry.js +2 -2
- package/dist/esm/q2-carousel.entry.js +2 -2
- package/dist/esm/q2-checkbox-group.entry.js +2 -2
- package/dist/esm/q2-checkbox.entry.js +2 -2
- package/dist/esm/q2-dropdown-item.entry.js +2 -2
- package/dist/esm/q2-dropdown.entry.js +2 -2
- package/dist/esm/q2-editable-field.entry.js +2 -2
- package/dist/esm/q2-icon.entry.js +3 -3
- package/dist/esm/q2-input.entry.js +3 -3
- package/dist/esm/q2-loading-element.entry.js +2 -2
- package/dist/esm/q2-loc.entry.js +2 -2
- package/dist/esm/q2-message.entry.js +21 -3
- package/dist/esm/q2-optgroup.entry.js +2 -2
- package/dist/esm/q2-option.entry.js +1 -1
- package/dist/esm/q2-radio-group.entry.js +8 -4
- package/dist/esm/q2-radio.entry.js +2 -2
- package/dist/esm/q2-section.entry.js +2 -2
- package/dist/esm/q2-select.entry.js +2 -2
- package/dist/esm/q2-stepper-pane.entry.js +2 -2
- package/dist/esm/q2-stepper.entry.js +2 -2
- package/dist/esm/q2-tab-container.entry.js +85 -115
- package/dist/esm/q2-tab-pane.entry.js +1 -1
- package/dist/esm/q2-tecton-elements.js +2 -2
- package/dist/esm/q2-textarea.entry.js +2 -2
- package/dist/esm/{shapes-073c5aad.js → shapes-81c11dfe.js} +1 -1
- package/dist/esm/tecton-tab-pane.entry.js +12 -1
- package/dist/q2-tecton-elements/{p-c92e3bc2.entry.js → p-01e00610.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-080839ed.js +1 -0
- package/dist/q2-tecton-elements/{p-576509e6.entry.js → p-1fc4e6f6.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-6f570344.js → p-25a5f691.js} +1 -1
- package/dist/q2-tecton-elements/p-27353237.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-2c2a5d58.entry.js → p-3e100450.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-4229b057.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-7520656d.entry.js → p-428d15fd.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-3f2590c0.entry.js → p-4830affe.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-64eef8d1.entry.js → p-48fc317d.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-3b80823a.entry.js → p-5222b792.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-82b24667.entry.js → p-61c0e5fd.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-aaa55918.js → p-67d86e3c.js} +1 -1
- package/dist/q2-tecton-elements/{p-37d281b7.entry.js → p-74c1a311.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-65894494.entry.js → p-784af485.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-e3a27b97.entry.js → p-7c99a58b.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-7f74b629.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-ebee91e2.entry.js → p-831a461f.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-905a22d5.entry.js → p-84c05db6.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-2f2bbed9.entry.js → p-84c52d3b.entry.js} +2 -2
- package/dist/q2-tecton-elements/{p-dd33b297.entry.js → p-9024859f.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-7c06467f.entry.js → p-9314863f.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-c14e0622.entry.js → p-997e4c7e.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-d0d605dc.entry.js → p-9cb0fc37.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-a224bc9c.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-891ca6f8.entry.js → p-a9bdd814.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-fa6e46e2.js → p-c90a6016.js} +1 -1
- package/dist/q2-tecton-elements/{p-86116f5c.entry.js → p-d1d040ef.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-8b4f6d3f.entry.js → p-d893fcf2.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-4d283b84.entry.js → p-da7cca07.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-f17761da.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-5289f040.entry.js → p-f5e074f8.entry.js} +1 -1
- package/dist/q2-tecton-elements/q2-tecton-elements.esm.js +1 -1
- package/dist/types/components/q2-calendar/index.d.ts +1 -1
- package/dist/types/components/q2-message/index.d.ts +6 -2
- package/dist/types/components/q2-radio-group/index.d.ts +1 -1
- package/dist/types/components/q2-tab-container/index.d.ts +11 -16
- package/dist/types/components/tecton-tab-pane/index.d.ts +1 -0
- package/dist/types/components.d.ts +7 -6
- package/dist/types/utils/index.d.ts +2 -0
- package/package.json +2 -2
- package/dist/q2-tecton-elements/p-076b95fd.entry.js +0 -1
- package/dist/q2-tecton-elements/p-2a28baa9.entry.js +0 -1
- package/dist/q2-tecton-elements/p-6ed006a7.entry.js +0 -1
- package/dist/q2-tecton-elements/p-8e863fbc.js +0 -1
- package/dist/q2-tecton-elements/p-98bb1355.entry.js +0 -1
- package/dist/q2-tecton-elements/p-9b420e22.entry.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Component, Prop, Element, Event, State, Listen, Watch, h } from '@stencil/core';
|
|
1
|
+
import { Component, Prop, Element, Event, State, Listen, Watch, h, Fragment } from '@stencil/core';
|
|
2
2
|
import { createGuid, loc, addSmoothScrollPolyfill } from 'src/utils';
|
|
3
3
|
addSmoothScrollPolyfill();
|
|
4
4
|
const userAgent = navigator.userAgent.toLowerCase();
|
|
@@ -11,6 +11,9 @@ export class Q2TabContainer {
|
|
|
11
11
|
this.lastScrolled = new Date(null).getTime();
|
|
12
12
|
this.hasLeft = false;
|
|
13
13
|
this.hasRight = false;
|
|
14
|
+
this.scrollEnabled = false;
|
|
15
|
+
this.showScrollLeft = false;
|
|
16
|
+
this.showScrollRight = false;
|
|
14
17
|
///////// Actions /////////
|
|
15
18
|
this.updateTabData = () => {
|
|
16
19
|
this.updateTabPaneProps();
|
|
@@ -24,131 +27,97 @@ export class Q2TabContainer {
|
|
|
24
27
|
});
|
|
25
28
|
};
|
|
26
29
|
this.setTabs = () => {
|
|
27
|
-
this.tabs = this.tabPanes.map(({ label, value }) => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
};
|
|
32
|
-
});
|
|
30
|
+
this.tabs = this.tabPanes.map(({ label, value }) => ({
|
|
31
|
+
label: (label && loc(label)) || '',
|
|
32
|
+
value
|
|
33
|
+
}));
|
|
33
34
|
};
|
|
34
35
|
this.onTabClick = (event) => {
|
|
36
|
+
const isAlreadySelected = this.value === event.target.dataset.value;
|
|
37
|
+
if (isAlreadySelected)
|
|
38
|
+
return;
|
|
35
39
|
this.change.emit({
|
|
36
40
|
value: event.target.dataset.value
|
|
37
41
|
});
|
|
38
42
|
};
|
|
39
43
|
this.onTabKeyDown = (event) => {
|
|
40
44
|
const value = event.target.dataset.value;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
45
|
+
switch (event.key) {
|
|
46
|
+
case 'ArrowRight':
|
|
47
|
+
event.preventDefault();
|
|
48
|
+
this.moveToAdjacentTab(value, 'next');
|
|
49
|
+
break;
|
|
50
|
+
case 'ArrowLeft':
|
|
51
|
+
event.preventDefault();
|
|
52
|
+
this.moveToAdjacentTab(value, 'prev');
|
|
53
|
+
break;
|
|
54
|
+
case 'Home':
|
|
55
|
+
event.preventDefault();
|
|
56
|
+
this.moveToAdjacentTab(value, 'first');
|
|
57
|
+
break;
|
|
58
|
+
case 'End':
|
|
59
|
+
event.preventDefault();
|
|
60
|
+
this.moveToAdjacentTab(value, 'last');
|
|
61
|
+
break;
|
|
62
|
+
case 'Space':
|
|
63
|
+
case 'Enter':
|
|
64
|
+
event.preventDefault();
|
|
65
|
+
this.change.emit({ value });
|
|
66
|
+
break;
|
|
54
67
|
}
|
|
55
68
|
};
|
|
56
69
|
this.moveToAdjacentTab = (value, direction) => {
|
|
57
70
|
let index = this.tabs.map(({ value }) => value).indexOf(value);
|
|
58
|
-
let newIndex
|
|
59
|
-
|
|
60
|
-
:
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
}
|
|
71
|
+
let newIndex;
|
|
72
|
+
switch (direction) {
|
|
73
|
+
case 'next':
|
|
74
|
+
newIndex = Math.min(index + 1, this.tabs.length - 1);
|
|
75
|
+
break;
|
|
76
|
+
case 'prev':
|
|
77
|
+
newIndex = Math.max(index - 1, 0);
|
|
78
|
+
break;
|
|
79
|
+
case 'first':
|
|
80
|
+
newIndex = 0;
|
|
81
|
+
break;
|
|
82
|
+
case 'last':
|
|
83
|
+
newIndex = this.tabs.length - 1;
|
|
84
|
+
break;
|
|
74
85
|
}
|
|
86
|
+
if (index === newIndex)
|
|
87
|
+
return;
|
|
88
|
+
this.moveFocus(newIndex, false);
|
|
75
89
|
};
|
|
76
90
|
this.moveFocus = (index, preventScroll = true) => {
|
|
77
91
|
const focusedValue = this.tabs[index].value;
|
|
78
|
-
const focusedTab = this.
|
|
92
|
+
const focusedTab = this.listElement.querySelector(`[data-value="${focusedValue}"]`);
|
|
79
93
|
focusedTab.focus({ preventScroll });
|
|
94
|
+
const left = focusedTab.offsetLeft - this.listElement.clientWidth / 2;
|
|
95
|
+
this.listElement.scrollTo({
|
|
96
|
+
left,
|
|
97
|
+
behavior: 'smooth'
|
|
98
|
+
});
|
|
80
99
|
return focusedTab;
|
|
81
100
|
};
|
|
82
|
-
this.
|
|
83
|
-
const {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
// check how much focused tab overflows
|
|
88
|
-
if (direction === 'next' &&
|
|
89
|
-
focusedTabLeft + focusedTab.clientWidth >
|
|
90
|
-
tabListLeft + this.tabList.clientWidth + arrowWidth) {
|
|
91
|
-
scrollAmount =
|
|
92
|
-
this.tabList.scrollLeft +
|
|
93
|
-
arrowWidth +
|
|
94
|
-
(focusedTabLeft + focusedTab.clientWidth) -
|
|
95
|
-
(tabListLeft + this.tabList.clientWidth);
|
|
96
|
-
}
|
|
97
|
-
else if (direction === 'prev' && focusedTabLeft + arrowWidth < tabListLeft) {
|
|
98
|
-
scrollAmount = this.tabList.scrollLeft - arrowWidth + (focusedTabLeft - tabListLeft);
|
|
99
|
-
}
|
|
100
|
-
return scrollAmount;
|
|
101
|
+
this.checkScrollState = () => {
|
|
102
|
+
const { scrollLeft, scrollWidth, clientWidth } = this.listElement;
|
|
103
|
+
this.scrollEnabled = scrollWidth > clientWidth;
|
|
104
|
+
this.showScrollLeft = !!scrollLeft;
|
|
105
|
+
this.showScrollRight = scrollWidth !== scrollLeft + clientWidth;
|
|
101
106
|
};
|
|
102
|
-
this.
|
|
103
|
-
const scrollAmount = this.
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
setTimeout(() => this.onTabScroll(), 100);
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
this.calculateTabScroll = ({ direction, scrollWidth, clientWidth, scrollLeft }) => {
|
|
111
|
-
const directions = { prev: -1, next: 1 };
|
|
112
|
-
// step 0 means no scroll needed, re-render or resize can trigger this
|
|
113
|
-
const step = directions[direction] || 0;
|
|
114
|
-
const scrollRate = 0.5; // half of visual width
|
|
115
|
-
const delta = Math.round(clientWidth * scrollRate);
|
|
116
|
-
const newScrollLeft = scrollLeft + step * delta;
|
|
117
|
-
const scrolled = clientWidth + newScrollLeft;
|
|
118
|
-
const hasLeft = newScrollLeft > 0;
|
|
119
|
-
const hasRight = scrollWidth > scrolled;
|
|
120
|
-
return {
|
|
121
|
-
newScrollLeft,
|
|
122
|
-
hasLeft,
|
|
123
|
-
hasRight
|
|
124
|
-
};
|
|
125
|
-
};
|
|
126
|
-
this.onTabScroll = (direction) => {
|
|
127
|
-
// throttle under 50ms due to re-rendering & resizing
|
|
128
|
-
const now = new Date().getTime();
|
|
129
|
-
if (now - this.lastScrolled < 50)
|
|
130
|
-
return;
|
|
131
|
-
this.lastScrolled = now;
|
|
132
|
-
if (!this.tabList)
|
|
133
|
-
return;
|
|
134
|
-
let { scrollWidth, clientWidth, scrollLeft } = this.tabList;
|
|
135
|
-
const { newScrollLeft, hasLeft, hasRight } = this.calculateTabScroll({
|
|
136
|
-
direction,
|
|
137
|
-
scrollWidth,
|
|
138
|
-
clientWidth,
|
|
139
|
-
scrollLeft
|
|
107
|
+
this.onScrollBtnClick = (direction) => {
|
|
108
|
+
const scrollAmount = Math.floor(this.listElement.clientWidth / 2);
|
|
109
|
+
this.listElement.scrollBy({
|
|
110
|
+
left: direction === 'left' ? -scrollAmount : scrollAmount,
|
|
111
|
+
behavior: 'smooth'
|
|
140
112
|
});
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
this.tabList.scroll({ left: newScrollLeft, behavior: 'smooth' });
|
|
145
|
-
}
|
|
113
|
+
};
|
|
114
|
+
this.onSlotChange = () => {
|
|
115
|
+
this.checkScrollState();
|
|
146
116
|
};
|
|
147
117
|
}
|
|
148
118
|
resizeIframe() {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
window.TectonElements.resizeIframe());
|
|
119
|
+
var _a, _b;
|
|
120
|
+
return (_b = (_a = window.TectonElements) === null || _a === void 0 ? void 0 : _a.resizeIframe) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
152
121
|
}
|
|
153
122
|
get tabPanes() {
|
|
154
123
|
const tabPanes = this.hostElement.querySelectorAll('q2-tab-pane, tecton-tab-pane');
|
|
@@ -170,7 +139,7 @@ export class Q2TabContainer {
|
|
|
170
139
|
}
|
|
171
140
|
}
|
|
172
141
|
onResize() {
|
|
173
|
-
this.
|
|
142
|
+
this.checkScrollState();
|
|
174
143
|
}
|
|
175
144
|
onFocus() {
|
|
176
145
|
// firefox receives focus on overflowed element even if it's not interactive element
|
|
@@ -184,25 +153,26 @@ export class Q2TabContainer {
|
|
|
184
153
|
const observer = new MutationObserver(this.updateTabData);
|
|
185
154
|
observer.observe(this.hostElement, { childList: true, attributes: true });
|
|
186
155
|
this.mutationObserver = observer;
|
|
156
|
+
this.resizeObserver = new ResizeObserver(() => this.checkScrollState());
|
|
187
157
|
this.updateTabData();
|
|
188
158
|
}
|
|
189
159
|
componentDidRender() {
|
|
190
160
|
this.scheduledAfterRender.forEach(fn => fn());
|
|
191
161
|
this.scheduledAfterRender = [];
|
|
192
162
|
this.settled.emit();
|
|
193
|
-
this.onTabScroll();
|
|
194
163
|
}
|
|
195
164
|
componentDidLoad() {
|
|
165
|
+
this.resizeObserver.observe(this.listElement);
|
|
166
|
+
this.checkScrollState();
|
|
196
167
|
const index = this.tabs.findIndex(el => el.value === this.value);
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
this.
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
});
|
|
203
|
-
}
|
|
168
|
+
this.scheduledAfterRender.push(() => {
|
|
169
|
+
const tab = this.moveFocus(Math.max(index, 0), false);
|
|
170
|
+
this.value = tab.dataset.value;
|
|
171
|
+
tab.blur();
|
|
172
|
+
});
|
|
204
173
|
}
|
|
205
174
|
disconnectedCallback() {
|
|
175
|
+
this.resizeObserver.disconnect();
|
|
206
176
|
this.mutationObserver.disconnect();
|
|
207
177
|
this.mutationObserver = null;
|
|
208
178
|
}
|
|
@@ -220,30 +190,29 @@ export class Q2TabContainer {
|
|
|
220
190
|
}
|
|
221
191
|
///////// View Methods /////////
|
|
222
192
|
render() {
|
|
223
|
-
return (h(
|
|
224
|
-
h("
|
|
225
|
-
this.
|
|
226
|
-
h("div", { class: "
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
h("q2-icon", { type: "chevron-right" })))))),
|
|
193
|
+
return (h(Fragment, null,
|
|
194
|
+
h("div", { class: "tab-container" },
|
|
195
|
+
this.scrollEnabled && (h(Fragment, null,
|
|
196
|
+
h("div", { class: "gradient-left", hidden: !this.showScrollLeft }),
|
|
197
|
+
h("div", { class: "gradient-right", hidden: !this.showScrollRight }),
|
|
198
|
+
h("q2-btn", { class: "btn-left", hidden: !this.showScrollLeft, onClick: () => this.onScrollBtnClick('left') },
|
|
199
|
+
h("q2-icon", { type: "chevron-left" })),
|
|
200
|
+
h("q2-btn", { class: "btn-right", hidden: !this.showScrollRight, onClick: () => this.onScrollBtnClick('right') },
|
|
201
|
+
h("q2-icon", { type: "chevron-right" })))),
|
|
202
|
+
h("ul", { onScroll: this.checkScrollState, ref: el => (this.listElement = el), class: this.noPrint ? 'no-print' : null, role: "tablist" }, this.tabs.map((tab, index) => this.generateTab(tab, index)))),
|
|
234
203
|
h("div", { class: "tab-content" },
|
|
235
|
-
h("slot",
|
|
204
|
+
h("slot", { onSlotchange: () => this.onSlotChange() }))));
|
|
236
205
|
}
|
|
237
206
|
generateTab(tab, index) {
|
|
238
207
|
const { label, value } = tab;
|
|
239
208
|
const isSelected = this.selectedTabValue === value;
|
|
240
209
|
return (h("li", { role: "presentation" },
|
|
241
|
-
h("
|
|
210
|
+
h("button", { id: `tab-${this.guid}-${index}`, "data-value": value, "test-id": "tabLink", tabIndex: isSelected ? 0 : -1, role: "tab", "aria-selected": isSelected ? 'true' : undefined, "aria-controls": `tab-pane-${this.guid}-${index}`, onClick: this.onTabClick, onKeyDown: this.onTabKeyDown }, label)));
|
|
242
211
|
}
|
|
243
212
|
static get is() { return "q2-tab-container"; }
|
|
244
213
|
static get encapsulation() { return "shadow"; }
|
|
245
214
|
static get originalStyleUrls() { return {
|
|
246
|
-
"$": ["styles.
|
|
215
|
+
"$": ["styles.scss"]
|
|
247
216
|
}; }
|
|
248
217
|
static get styleUrls() { return {
|
|
249
218
|
"$": ["styles.css"]
|
|
@@ -339,6 +308,9 @@ export class Q2TabContainer {
|
|
|
339
308
|
static get states() { return {
|
|
340
309
|
"hasLeft": {},
|
|
341
310
|
"hasRight": {},
|
|
311
|
+
"scrollEnabled": {},
|
|
312
|
+
"showScrollLeft": {},
|
|
313
|
+
"showScrollRight": {},
|
|
342
314
|
"tabs": {}
|
|
343
315
|
}; }
|
|
344
316
|
static get events() { return [{
|
|
@@ -64,120 +64,140 @@ button {
|
|
|
64
64
|
visibility: hidden;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
:host {
|
|
68
|
+
display: block;
|
|
69
|
+
position: relative;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
button {
|
|
73
|
+
cursor: pointer;
|
|
74
|
+
margin: 0;
|
|
75
|
+
}
|
|
67
76
|
|
|
68
77
|
.tab-container {
|
|
69
|
-
|
|
70
|
-
display: flex;
|
|
71
|
-
flex-direction: column;
|
|
78
|
+
position: relative;
|
|
72
79
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
|
|
81
|
+
ul {
|
|
82
|
+
--comp-container-padding: var(--tct-scale-1, var(--app-scale-1, 5px)) var(--tct-scale-1, var(--app-scale-1, 5px)) 0;
|
|
83
|
+
padding: var(--tct-tab-container-padding, var(--t-tab-container-padding, var(--comp-container-padding)));
|
|
84
|
+
display: flex;
|
|
85
|
+
gap: var(--tct-tab-gap, var(--t-tab-gap, var(--tct-scale-1, var(--app-scale-1, 5px))));
|
|
86
|
+
list-style: none;
|
|
87
|
+
border-bottom: 1px solid var(--tct-tab-container-border-color, var(--t-tab-container-border-color, var(--tct-gray-11, var(--t-gray-11, var(--tct-gray-l1, var(--app-gray-l1, #cccccc))))));
|
|
88
|
+
overflow-x: auto;
|
|
89
|
+
align-items: center;
|
|
90
|
+
scrollbar-width: none;
|
|
91
|
+
scrollbar-color: transparent;
|
|
83
92
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
width: 46px;
|
|
88
|
-
}
|
|
89
|
-
.tab-list li.nav-left {
|
|
90
|
-
left: -15px;
|
|
91
|
-
background: linear-gradient(to right, var(--tct-section-bg, var(--t-section-bg, #ffffff)) 60%, rgba(255,255,255,0));
|
|
92
|
-
}
|
|
93
|
-
.tab-list li.nav-right {
|
|
94
|
-
right: -15px;
|
|
95
|
-
background: linear-gradient(to left, var(--tct-section-bg, var(--t-section-bg, #ffffff)) 60%, rgba(255,255,255,0));
|
|
96
|
-
}
|
|
97
|
-
.tab-list li.nav .arrow-container {
|
|
98
|
-
display: flex;
|
|
99
|
-
justify-content: center;
|
|
100
|
-
align-items: center;
|
|
101
|
-
height: inherit;
|
|
102
|
-
width: inherit;
|
|
103
|
-
cursor: pointer;
|
|
104
|
-
}
|
|
105
|
-
.tab-list li.nav .arrow-container a {
|
|
106
|
-
padding: 0;
|
|
107
|
-
margin: 0;
|
|
108
|
-
height: inherit;
|
|
109
|
-
width: inherit;
|
|
110
|
-
border-bottom: 0;
|
|
111
|
-
display: flex;
|
|
112
|
-
align-items: center;
|
|
113
|
-
justify-content: center;
|
|
114
|
-
}
|
|
115
|
-
.tab-list li.nav .arrow-container a q2-icon {
|
|
116
|
-
width: 19px;
|
|
117
|
-
height: 19px;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
.tab-list a {
|
|
121
|
-
width: var(--tct-tab-hover-width, var(--t-tab-hover-width, 100%));
|
|
122
|
-
text-align: center;
|
|
123
|
-
text-decoration: none;
|
|
124
|
-
padding: var(--tct-scale-2, var(--app-scale-2, 10px));
|
|
125
|
-
margin: var(--tct-scale-1, var(--app-scale-1, 5px)) var(--tct-scale-1, var(--app-scale-1, 5px))
|
|
126
|
-
0;
|
|
127
|
-
color: var(--tct-tab-inactive-color, var(--t-tab-inactive, inherit));
|
|
128
|
-
font-size: var(--tct-tab-font-size, var(--t-tab-font-size, 17px));
|
|
129
|
-
border-bottom: 3px solid transparent;
|
|
130
|
-
display: block;
|
|
131
|
-
transition: color var(--tct-tween-2, var(--app-tween-2, 0.4s ease)),
|
|
132
|
-
border-color var(--tct-tween-1, var(--app-tween-1, 0.2s ease));
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
:host([type='section']) .tab-list a {
|
|
136
|
-
font-size: inherit;
|
|
137
|
-
padding: var(--tct-scale-2, var(--app-scale-2, 10px))
|
|
138
|
-
var(--tct-scale-1, var(--app-scale-1, 5px));
|
|
93
|
+
ul::-webkit-scrollbar {
|
|
94
|
+
width: 0;
|
|
95
|
+
height: 0;
|
|
139
96
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
var(--tct-scale-1, var(--app-scale-1, 5px));
|
|
146
|
-
}
|
|
97
|
+
ul::-webkit-scrollbar-thumb {
|
|
98
|
+
background: transparent;
|
|
99
|
+
}
|
|
100
|
+
ul::-webkit-scrollbar-track {
|
|
101
|
+
background: transparent;
|
|
147
102
|
}
|
|
148
|
-
|
|
149
103
|
@media print {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
104
|
+
ul.no-print {
|
|
105
|
+
display: none;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
li {
|
|
110
|
+
flex: 0 0 auto;
|
|
111
|
+
}
|
|
112
|
+
li button {
|
|
113
|
+
background: var(--tct-tab-inactive-bg-color, var(--t-tab-inactive-bg-color, transparent));
|
|
114
|
+
border-width: var(--tct-tab-inactive-border-width, var(--t-tab-inactive-border-width, 0 0 3px 0));
|
|
115
|
+
border-color: var(--tct-tab-inactive-border-color, var(--t-tab-inactive-border-color, transparent));
|
|
116
|
+
border-style: var(--tct-tab-inactive-border-style, var(--t-tab-inactive-border-style, solid));
|
|
117
|
+
border-radius: var(--tct-tab-border-radius, var(--t-tab-border-radius, 0));
|
|
118
|
+
width: var(--tct-tab-width, var(--t-tab-width, 100%));
|
|
119
|
+
text-align: var(--tct-tab-text-align, var(--t-tab-text-align, center));
|
|
120
|
+
text-decoration: var(--tct-tab-text-decoration, var(--t-tab-text-decoration, none));
|
|
121
|
+
padding: var(--tct-tab-padding, var(--t-tab-padding, var(--tct-scale-2, var(--app-scale-2, 10px))));
|
|
122
|
+
color: var(--tct-tab-inactive-color, var(--t-tab-inactive-color, inherit));
|
|
123
|
+
font-size: var(--tct-tab-font-size, var(--t-tab-font-size, 17px));
|
|
124
|
+
display: block;
|
|
125
|
+
transition: color var(--tct-tween-2, var(--app-tween-2, 0.4s ease)), border-color var(--tct-tween-1, var(--app-tween-1, 0.2s ease));
|
|
126
|
+
}
|
|
127
|
+
:host([type=section]) li button {
|
|
128
|
+
--comp-tab-section-padding: var(--tct-scale-2, var(--app-scale-2, 10px)) var(--tct-scale-1, var(--app-scale-1, 5px));
|
|
129
|
+
font-size: inherit;
|
|
130
|
+
padding: var(--tct-tab-section-padding, var(--t-tab-section-padding, var(--comp-tab-section-padding)));
|
|
131
|
+
}
|
|
132
|
+
li button:hover {
|
|
133
|
+
color: var(--tct-tab-hover-color, var(--t-tab-hover-color, var(--tct-tab-active-color, var(--t-tab-active-color, #2e2e2e))));
|
|
134
|
+
background-color: var(--tct-tab-hover-bg-color, var(--t-tab-hover-bg-color, inherit));
|
|
135
|
+
width: var(--tct-tab-hover-width, var(--t-tab-hover-width, 100%));
|
|
136
|
+
}
|
|
137
|
+
li button[aria-selected=true] {
|
|
138
|
+
color: var(--tct-tab-active-color, var(--t-tab-active-color, #2e2e2e));
|
|
139
|
+
border-color: var(--tct-tab-active-border-color, var(--t-tab-active-border-color, currentColor));
|
|
140
|
+
border-style: var(--tct-tab-active-border-style, var(--t-tab-active-border-style, solid));
|
|
141
|
+
width: var(--tct-tab-active-width, var(--t-tab-active-width, 100%));
|
|
142
|
+
background-color: var(--tct-tab-active-bg-color, var(--t-tab-active-bg-color, inherit));
|
|
143
|
+
}
|
|
144
|
+
:host([color=alt]) li button {
|
|
145
|
+
color: var(--tct-tab-alt-inactive-color, var(--t-tab-alt-inactive-color, inherit));
|
|
146
|
+
}
|
|
147
|
+
:host([color=alt]) li button:hover, :host([color=alt]) li button[aria-selected=true] {
|
|
148
|
+
color: var(--tct-tab-alt-active-color, var(--t-tab-alt-active-color, inherit));
|
|
149
|
+
}
|
|
150
|
+
@media screen and (max-width: 767px) {
|
|
151
|
+
li button {
|
|
152
|
+
--comp-tab-padding: var(--tct-scale-2, var(--app-scale-2, 10px)) var(--tct-scale-1, var(--app-scale-1, 5px));
|
|
153
|
+
font-size: inherit;
|
|
154
|
+
padding: var(--tct-tab-padding, var(--t-tab-padding, var(--comp-tab-padding)));
|
|
155
|
+
}
|
|
153
156
|
}
|
|
154
157
|
|
|
155
|
-
.tab-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
158
|
+
.tab-content {
|
|
159
|
+
--comp-tab-content-padding: var(--tct-scale-2, var(--app-scale-2, 10px)) 0;
|
|
160
|
+
padding: var(--tct-tab-content-padding, var(--t-tab-content-padding, var(--comp-tab-content-padding)));
|
|
161
|
+
}
|
|
162
|
+
.tab-content:focus {
|
|
163
|
+
outline: none;
|
|
164
|
+
box-shadow: none;
|
|
159
165
|
}
|
|
160
166
|
|
|
161
|
-
.
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
167
|
+
.gradient-left,
|
|
168
|
+
.gradient-right {
|
|
169
|
+
z-index: 1;
|
|
170
|
+
position: absolute;
|
|
171
|
+
top: 0;
|
|
172
|
+
height: 100%;
|
|
173
|
+
width: 44px;
|
|
166
174
|
}
|
|
167
175
|
|
|
168
|
-
|
|
169
|
-
|
|
176
|
+
.gradient-left {
|
|
177
|
+
background-image: linear-gradient(to right, var(--t-base), var(--t-base-a0));
|
|
178
|
+
left: 0;
|
|
170
179
|
}
|
|
171
180
|
|
|
172
|
-
|
|
173
|
-
:
|
|
174
|
-
|
|
181
|
+
.gradient-right {
|
|
182
|
+
background-image: linear-gradient(to right, var(--t-base-a0), var(--t-base));
|
|
183
|
+
right: 0;
|
|
175
184
|
}
|
|
176
185
|
|
|
177
|
-
.
|
|
178
|
-
|
|
186
|
+
.btn-left,
|
|
187
|
+
.btn-right {
|
|
188
|
+
--tct-icon-size: 18px;
|
|
189
|
+
--tct-btn-icon-hover-bg: transparent;
|
|
190
|
+
--tct-btn-icon-width: 22px;
|
|
191
|
+
--tct-icon-stroke-primary: var(--tct-stepper-scroll-arrow-color, var(--t-stepper-scroll-arrow-color, var(--t-text, #4d4d4d)));
|
|
192
|
+
position: absolute;
|
|
193
|
+
top: calc(50% - 22px);
|
|
194
|
+
z-index: 2;
|
|
179
195
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
196
|
+
|
|
197
|
+
.btn-left {
|
|
198
|
+
left: 0;
|
|
183
199
|
}
|
|
200
|
+
|
|
201
|
+
.btn-right {
|
|
202
|
+
right: 0;
|
|
203
|
+
}
|
|
@@ -14,6 +14,13 @@ export class TectonTabPane {
|
|
|
14
14
|
.slice(-2)
|
|
15
15
|
.join('-');
|
|
16
16
|
}
|
|
17
|
+
componentWillRender() {
|
|
18
|
+
const loadingWrapper = this.hostElement.shadowRoot.querySelector('.loading-wrapper');
|
|
19
|
+
if (loadingWrapper) {
|
|
20
|
+
loadingWrapper.style.minHeight = this.minHeight;
|
|
21
|
+
loadingWrapper.hidden = !this.selected;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
17
24
|
componentWillLoad() {
|
|
18
25
|
this._showForm = this.showForm;
|
|
19
26
|
}
|
|
@@ -26,7 +33,11 @@ export class TectonTabPane {
|
|
|
26
33
|
}
|
|
27
34
|
///////// Observers /////////
|
|
28
35
|
selectedObserver() {
|
|
36
|
+
const loader = this.hostElement.shadowRoot.querySelector('div[slot="loading-wrapper"]');
|
|
29
37
|
this._showForm = this.showForm; // reset state
|
|
38
|
+
if (loader) {
|
|
39
|
+
loader.hidden = !this.selected;
|
|
40
|
+
}
|
|
30
41
|
}
|
|
31
42
|
///////// View Methods /////////
|
|
32
43
|
render() {
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import { h } from '@stencil/core';
|
|
2
2
|
import smoothscroll from 'smoothscroll-polyfill';
|
|
3
3
|
export function addSmoothScrollPolyfill() {
|
|
4
|
-
|
|
5
|
-
const isSafari = userAgent.includes('safari') && !userAgent.includes('chrome');
|
|
6
|
-
if (!isSafari)
|
|
4
|
+
if (!isSafari())
|
|
7
5
|
return false;
|
|
8
6
|
smoothscroll.polyfill();
|
|
9
7
|
return (window['__forceSmoothScrollPolyfill__'] = true);
|
|
10
8
|
}
|
|
9
|
+
export function isFirefox() {
|
|
10
|
+
const userAgent = navigator.userAgent.toLowerCase();
|
|
11
|
+
return userAgent.includes('firefox');
|
|
12
|
+
}
|
|
13
|
+
export function isSafari() {
|
|
14
|
+
const userAgent = navigator.userAgent.toLowerCase();
|
|
15
|
+
return userAgent.includes('safari') && !userAgent.includes('chrome');
|
|
16
|
+
}
|
|
11
17
|
let guid = 1000;
|
|
12
18
|
export function createGuid() {
|
|
13
19
|
return guid++;
|