tyrell-components 1.0.0-RC14 → 1.0.0-RC16
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/README.md +53 -53
- package/css/tyrell-theme.css +32 -4
- package/css/tyrell.css +10 -15
- package/dist/tyrell-colors-static.css +1 -316
- package/dist/tyrell-theme.css +1 -1443
- package/dist/tyrell.css +1 -1390
- package/dist/tyrell.js +1 -1
- package/lib/base/ty-component.d.ts +14 -0
- package/lib/base/ty-component.d.ts.map +1 -0
- package/lib/base/ty-component.js +223 -196
- package/lib/base/ty-component.js.map +1 -0
- package/lib/components/button.d.ts +1 -1
- package/lib/components/button.d.ts.map +1 -0
- package/lib/components/button.js +267 -259
- package/lib/components/button.js.map +1 -0
- package/lib/components/calendar-month.d.ts +2 -2
- package/lib/components/calendar-month.d.ts.map +1 -0
- package/lib/components/calendar-month.js +440 -416
- package/lib/components/calendar-month.js.map +1 -0
- package/lib/components/calendar-navigation.d.ts +11 -0
- package/lib/components/calendar-navigation.d.ts.map +1 -0
- package/lib/components/calendar-navigation.js +272 -261
- package/lib/components/calendar-navigation.js.map +1 -0
- package/lib/components/calendar.d.ts +31 -3
- package/lib/components/calendar.d.ts.map +1 -0
- package/lib/components/calendar.js +785 -603
- package/lib/components/calendar.js.map +1 -0
- package/lib/components/checkbox.d.ts +1 -1
- package/lib/components/checkbox.d.ts.map +1 -0
- package/lib/components/checkbox.js +273 -272
- package/lib/components/checkbox.js.map +1 -0
- package/lib/components/copy.d.ts +1 -1
- package/lib/components/copy.d.ts.map +1 -0
- package/lib/components/copy.js +287 -278
- package/lib/components/copy.js.map +1 -0
- package/lib/components/date-picker.d.ts +16 -10
- package/lib/components/date-picker.d.ts.map +1 -0
- package/lib/components/date-picker.js +1068 -1122
- package/lib/components/date-picker.js.map +1 -0
- package/lib/components/dropdown.d.ts +403 -0
- package/lib/components/dropdown.d.ts.map +1 -0
- package/lib/components/dropdown.js +1315 -0
- package/lib/components/dropdown.js.map +1 -0
- package/lib/components/file-upload.d.ts +4 -0
- package/lib/components/file-upload.js +418 -404
- package/lib/components/icon.d.ts.map +1 -0
- package/lib/components/icon.js +141 -141
- package/lib/components/icon.js.map +1 -0
- package/lib/components/input.d.ts +1 -1
- package/lib/components/input.d.ts.map +1 -0
- package/lib/components/input.js +593 -596
- package/lib/components/input.js.map +1 -0
- package/lib/components/modal.d.ts +2 -8
- package/lib/components/modal.d.ts.map +1 -0
- package/lib/components/modal.js +309 -319
- package/lib/components/modal.js.map +1 -0
- package/lib/components/multiselect.d.ts +389 -0
- package/lib/components/multiselect.d.ts.map +1 -0
- package/lib/components/multiselect.js +1301 -0
- package/lib/components/multiselect.js.map +1 -0
- package/lib/components/option.d.ts.map +1 -0
- package/lib/components/option.js +167 -167
- package/lib/components/option.js.map +1 -0
- package/lib/components/popup.d.ts.map +1 -0
- package/lib/components/popup.js +236 -233
- package/lib/components/popup.js.map +1 -0
- package/lib/components/radio.d.ts +17 -2
- package/lib/components/radio.js +437 -406
- package/lib/components/resize-observer.d.ts.map +1 -0
- package/lib/components/resize-observer.js +67 -67
- package/lib/components/resize-observer.js.map +1 -0
- package/lib/components/scroll-container.d.ts +3 -2
- package/lib/components/scroll-container.d.ts.map +1 -0
- package/lib/components/scroll-container.js +289 -294
- package/lib/components/scroll-container.js.map +1 -0
- package/lib/components/select.d.ts +85 -18
- package/lib/components/select.js +1647 -1529
- package/lib/components/selected-tags.d.ts +1 -1
- package/lib/components/selected-tags.js +188 -182
- package/lib/components/step.d.ts.map +1 -0
- package/lib/components/step.js +62 -62
- package/lib/components/step.js.map +1 -0
- package/lib/components/switch.d.ts +1 -1
- package/lib/components/switch.js +214 -213
- package/lib/components/tab.d.ts +49 -1
- package/lib/components/tab.d.ts.map +1 -0
- package/lib/components/tab.js +203 -62
- package/lib/components/tab.js.map +1 -0
- package/lib/components/tabs.d.ts +15 -2
- package/lib/components/tabs.d.ts.map +1 -0
- package/lib/components/tabs.js +576 -496
- package/lib/components/tabs.js.map +1 -0
- package/lib/components/tag.d.ts +5 -8
- package/lib/components/tag.d.ts.map +1 -0
- package/lib/components/tag.js +235 -235
- package/lib/components/tag.js.map +1 -0
- package/lib/components/textarea.d.ts +5 -4
- package/lib/components/textarea.d.ts.map +1 -0
- package/lib/components/textarea.js +458 -456
- package/lib/components/textarea.js.map +1 -0
- package/lib/components/tooltip.d.ts +4 -3
- package/lib/components/tooltip.d.ts.map +1 -0
- package/lib/components/tooltip.js +293 -283
- package/lib/components/tooltip.js.map +1 -0
- package/lib/components/wizard.d.ts +5 -4
- package/lib/components/wizard.d.ts.map +1 -0
- package/lib/components/wizard.js +359 -395
- package/lib/components/wizard.js.map +1 -0
- package/lib/icons/fontawesome/brands.d.ts.map +1 -0
- package/lib/icons/fontawesome/brands.js.map +1 -0
- package/lib/icons/fontawesome/regular.d.ts.map +1 -0
- package/lib/icons/fontawesome/regular.js.map +1 -0
- package/lib/icons/fontawesome/solid.d.ts.map +1 -0
- package/lib/icons/fontawesome/solid.js.map +1 -0
- package/lib/icons/heroicons/micro.d.ts.map +1 -0
- package/lib/icons/heroicons/micro.js +392 -392
- package/lib/icons/heroicons/micro.js.map +1 -0
- package/lib/icons/heroicons/mini.d.ts.map +1 -0
- package/lib/icons/heroicons/mini.js +382 -382
- package/lib/icons/heroicons/mini.js.map +1 -0
- package/lib/icons/heroicons/outline.d.ts.map +1 -0
- package/lib/icons/heroicons/outline.js +337 -337
- package/lib/icons/heroicons/outline.js.map +1 -0
- package/lib/icons/heroicons/solid.d.ts.map +1 -0
- package/lib/icons/heroicons/solid.js +407 -407
- package/lib/icons/heroicons/solid.js.map +1 -0
- package/lib/icons/lucide.d.ts.map +1 -0
- package/lib/icons/lucide.js +22843 -22843
- package/lib/icons/lucide.js.map +1 -0
- package/lib/icons/material/filled.d.ts.map +1 -0
- package/lib/icons/material/filled.js +9653 -9653
- package/lib/icons/material/filled.js.map +1 -0
- package/lib/icons/material/outlined.d.ts.map +1 -0
- package/lib/icons/material/outlined.js +10271 -10271
- package/lib/icons/material/outlined.js.map +1 -0
- package/lib/icons/material/round.d.ts.map +1 -0
- package/lib/icons/material/round.js +10495 -10495
- package/lib/icons/material/round.js.map +1 -0
- package/lib/icons/material/sharp.d.ts.map +1 -0
- package/lib/icons/material/sharp.js +9905 -9905
- package/lib/icons/material/sharp.js.map +1 -0
- package/lib/icons/material/two-tone.d.ts.map +1 -0
- package/lib/icons/material/two-tone.js +12792 -12792
- package/lib/icons/material/two-tone.js.map +1 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +21 -21
- package/lib/index.js.map +1 -0
- package/lib/styles/button.d.ts.map +1 -0
- package/lib/styles/button.js +200 -302
- package/lib/styles/button.js.map +1 -0
- package/lib/styles/calendar-month.d.ts +3 -0
- package/lib/styles/calendar-month.d.ts.map +1 -0
- package/lib/styles/calendar-month.js +141 -185
- package/lib/styles/calendar-month.js.map +1 -0
- package/lib/styles/calendar-navigation.d.ts +1 -1
- package/lib/styles/calendar-navigation.d.ts.map +1 -0
- package/lib/styles/calendar-navigation.js +100 -86
- package/lib/styles/calendar-navigation.js.map +1 -0
- package/lib/styles/calendar.d.ts +3 -2
- package/lib/styles/calendar.d.ts.map +1 -0
- package/lib/styles/calendar.js +83 -9
- package/lib/styles/calendar.js.map +1 -0
- package/lib/styles/checkbox.js +62 -77
- package/lib/styles/copy.d.ts.map +1 -0
- package/lib/styles/copy.js +71 -91
- package/lib/styles/copy.js.map +1 -0
- package/lib/styles/custom-scrollbar.js +80 -100
- package/lib/styles/date-picker.d.ts.map +1 -0
- package/lib/styles/date-picker.js +295 -335
- package/lib/styles/date-picker.js.map +1 -0
- package/lib/styles/dropdown.d.ts +12 -0
- package/lib/styles/dropdown.d.ts.map +1 -0
- package/lib/styles/dropdown.js +725 -0
- package/lib/styles/dropdown.js.map +1 -0
- package/lib/styles/field-size.d.ts +6 -0
- package/lib/styles/field-size.js +91 -0
- package/lib/styles/file-upload.js +139 -169
- package/lib/styles/icon.d.ts.map +1 -0
- package/lib/styles/icon.js +92 -156
- package/lib/styles/icon.js.map +1 -0
- package/lib/styles/input.d.ts.map +1 -0
- package/lib/styles/input.js +125 -241
- package/lib/styles/input.js.map +1 -0
- package/lib/styles/modal.d.ts.map +1 -0
- package/lib/styles/modal.js +67 -102
- package/lib/styles/modal.js.map +1 -0
- package/lib/styles/multiselect.d.ts +6 -0
- package/lib/styles/multiselect.d.ts.map +1 -0
- package/lib/styles/multiselect.js +568 -0
- package/lib/styles/multiselect.js.map +1 -0
- package/lib/styles/option.d.ts +1 -1
- package/lib/styles/option.d.ts.map +1 -0
- package/lib/styles/option.js +47 -67
- package/lib/styles/option.js.map +1 -0
- package/lib/styles/popup.d.ts +1 -1
- package/lib/styles/popup.d.ts.map +1 -0
- package/lib/styles/popup.js +37 -65
- package/lib/styles/popup.js.map +1 -0
- package/lib/styles/radio.js +75 -96
- package/lib/styles/resize-observer.d.ts.map +1 -0
- package/lib/styles/resize-observer.js +2 -5
- package/lib/styles/resize-observer.js.map +1 -0
- package/lib/styles/scroll-container.d.ts +1 -1
- package/lib/styles/scroll-container.d.ts.map +1 -0
- package/lib/styles/scroll-container.js +101 -131
- package/lib/styles/scroll-container.js.map +1 -0
- package/lib/styles/select-base.js +596 -773
- package/lib/styles/select.d.ts +1 -1
- package/lib/styles/select.js +146 -228
- package/lib/styles/step.d.ts +1 -1
- package/lib/styles/step.d.ts.map +1 -0
- package/lib/styles/step.js +15 -30
- package/lib/styles/step.js.map +1 -0
- package/lib/styles/switch.js +37 -55
- package/lib/styles/tab.d.ts +1 -1
- package/lib/styles/tab.d.ts.map +1 -0
- package/lib/styles/tab.js +86 -29
- package/lib/styles/tab.js.map +1 -0
- package/lib/styles/tabs.d.ts +1 -1
- package/lib/styles/tabs.d.ts.map +1 -0
- package/lib/styles/tabs.js +190 -180
- package/lib/styles/tabs.js.map +1 -0
- package/lib/styles/tag.d.ts.map +1 -0
- package/lib/styles/tag.js +137 -191
- package/lib/styles/tag.js.map +1 -0
- package/lib/styles/textarea.d.ts +1 -1
- package/lib/styles/textarea.d.ts.map +1 -0
- package/lib/styles/textarea.js +205 -271
- package/lib/styles/textarea.js.map +1 -0
- package/lib/styles/tooltip.d.ts.map +1 -0
- package/lib/styles/tooltip.js +3 -3
- package/lib/styles/tooltip.js.map +1 -0
- package/lib/styles/wizard.d.ts +9 -5
- package/lib/styles/wizard.d.ts.map +1 -0
- package/lib/styles/wizard.js +301 -245
- package/lib/styles/wizard.js.map +1 -0
- package/lib/types/common.d.ts +4 -2
- package/lib/types/common.d.ts.map +1 -0
- package/lib/types/common.js +6 -5
- package/lib/types/common.js.map +1 -0
- package/lib/utils/calendar-utils.d.ts.map +1 -0
- package/lib/utils/calendar-utils.js +100 -100
- package/lib/utils/calendar-utils.js.map +1 -0
- package/lib/utils/custom-scrollbar.js +272 -272
- package/lib/utils/flavor-sheet.js +14 -14
- package/lib/utils/icon-registry.d.ts.map +1 -0
- package/lib/utils/icon-registry.js +127 -127
- package/lib/utils/icon-registry.js.map +1 -0
- package/lib/utils/loader-registry.js +3 -3
- package/lib/utils/locale.d.ts.map +1 -0
- package/lib/utils/locale.js +34 -34
- package/lib/utils/locale.js.map +1 -0
- package/lib/utils/mobile.js +1 -1
- package/lib/utils/number-format.d.ts.map +1 -0
- package/lib/utils/number-format.js +54 -54
- package/lib/utils/number-format.js.map +1 -0
- package/lib/utils/parse-boolean.d.ts +39 -0
- package/lib/utils/parse-boolean.d.ts.map +1 -0
- package/lib/utils/parse-boolean.js +23 -0
- package/lib/utils/parse-boolean.js.map +1 -0
- package/lib/utils/positioning.d.ts.map +1 -0
- package/lib/utils/positioning.js +212 -212
- package/lib/utils/positioning.js.map +1 -0
- package/lib/utils/property-capture.d.ts.map +1 -0
- package/lib/utils/property-capture.js +36 -36
- package/lib/utils/property-capture.js.map +1 -0
- package/lib/utils/property-manager.d.ts +1 -1
- package/lib/utils/property-manager.d.ts.map +1 -0
- package/lib/utils/property-manager.js +127 -125
- package/lib/utils/property-manager.js.map +1 -0
- package/lib/utils/resize-observer.d.ts.map +1 -0
- package/lib/utils/resize-observer.js +23 -23
- package/lib/utils/resize-observer.js.map +1 -0
- package/lib/utils/scroll-lock.d.ts.map +1 -0
- package/lib/utils/scroll-lock.js +57 -57
- package/lib/utils/scroll-lock.js.map +1 -0
- package/lib/utils/styles.d.ts.map +1 -0
- package/lib/utils/styles.js +17 -17
- package/lib/utils/styles.js.map +1 -0
- package/lib/utils/validity.d.ts +26 -0
- package/lib/utils/validity.js +53 -0
- package/lib/version.d.ts +1 -1
- package/lib/version.d.ts.map +1 -0
- package/lib/version.js +1 -1
- package/lib/version.js.map +1 -0
- package/package.json +28 -7
package/lib/components/tab.js
CHANGED
|
@@ -1,69 +1,210 @@
|
|
|
1
1
|
import { ensureStyles } from '../utils/styles.js';
|
|
2
2
|
import { tabStyles } from '../styles/tab.js';
|
|
3
3
|
import { CustomScrollbar, isCustomScrollbarEnabled } from '../utils/custom-scrollbar.js';
|
|
4
|
+
import { getLoaderSvg } from '../utils/loader-registry.js';
|
|
5
|
+
const STATUS_SLOTS = new Set(['loading', 'error']);
|
|
6
|
+
const INERT_ELEMENTS = new Set(['template', 'script', 'style']);
|
|
4
7
|
export class TyTab extends HTMLElement {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
8
|
+
static get observedAttributes() {
|
|
9
|
+
return ['id', 'label', 'disabled', 'lazy'];
|
|
10
|
+
}
|
|
11
|
+
constructor() {
|
|
12
|
+
super();
|
|
13
|
+
this._scrollbar = null;
|
|
14
|
+
this._panelLabel = null;
|
|
15
|
+
this._shown = true;
|
|
16
|
+
this._load = 'idle';
|
|
17
|
+
this._contentObserver = null;
|
|
18
|
+
this._contentChanged = false;
|
|
19
|
+
this.attachShadow({ mode: 'open' });
|
|
20
|
+
}
|
|
21
|
+
connectedCallback() {
|
|
22
|
+
this._render();
|
|
23
|
+
if (!this._scrollbar)
|
|
24
|
+
this._setupScrollbar();
|
|
25
|
+
this._watchContent();
|
|
26
|
+
}
|
|
27
|
+
setPanelLabel(label) {
|
|
28
|
+
this._panelLabel = label;
|
|
29
|
+
this._syncPanel();
|
|
30
|
+
}
|
|
31
|
+
setShown(shown) {
|
|
32
|
+
this._shown = shown;
|
|
33
|
+
this._syncPanel();
|
|
34
|
+
}
|
|
35
|
+
disconnectedCallback() {
|
|
36
|
+
this._destroyScrollbar();
|
|
37
|
+
this._contentChanged = !!this._contentObserver?.takeRecords().length;
|
|
38
|
+
this._contentObserver?.disconnect();
|
|
39
|
+
this._contentObserver = null;
|
|
40
|
+
}
|
|
41
|
+
_requestLoad(index) {
|
|
42
|
+
if (this._contentObserver?.takeRecords().length)
|
|
43
|
+
this._checkContent(false);
|
|
44
|
+
if (this._load === 'empty' || this._load === 'failed')
|
|
45
|
+
this._fireLoad(index);
|
|
46
|
+
}
|
|
47
|
+
loadFailed() {
|
|
48
|
+
if (this._load === 'loading' || this._load === 'empty')
|
|
49
|
+
this._setLoad('failed');
|
|
50
|
+
}
|
|
51
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
52
|
+
this._render();
|
|
53
|
+
if (name === 'lazy') {
|
|
54
|
+
if (this.isConnected)
|
|
55
|
+
this._watchContent();
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const tabs = this.parentElement;
|
|
59
|
+
if (oldValue !== newValue && this.isConnected && tabs?.localName === 'ty-tabs') {
|
|
60
|
+
tabs._queueUpdate?.(true);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
_render() {
|
|
64
|
+
const shadowRoot = this.shadowRoot;
|
|
65
|
+
if (!shadowRoot)
|
|
66
|
+
return;
|
|
67
|
+
if (!shadowRoot.querySelector('.tab-wrapper')) {
|
|
68
|
+
ensureStyles(shadowRoot, { css: tabStyles, id: 'ty-tab' });
|
|
69
|
+
shadowRoot.innerHTML = `
|
|
70
|
+
<div class="tab-wrapper">
|
|
71
|
+
<div class="tab-panel" role="tabpanel" tabindex="0">
|
|
72
|
+
<slot></slot>
|
|
73
|
+
</div>
|
|
74
|
+
</div>
|
|
75
|
+
`;
|
|
76
|
+
}
|
|
77
|
+
this._syncPanel();
|
|
78
|
+
}
|
|
79
|
+
_watchContent() {
|
|
80
|
+
const lazy = this.hasAttribute('lazy');
|
|
81
|
+
if (lazy && !this._contentObserver) {
|
|
82
|
+
this._contentObserver = new MutationObserver(() => this._checkContent(true));
|
|
83
|
+
this._contentObserver.observe(this, { childList: true, characterData: true, subtree: true });
|
|
84
|
+
}
|
|
85
|
+
else if (!lazy && this._contentObserver) {
|
|
86
|
+
this._contentObserver.disconnect();
|
|
87
|
+
this._contentObserver = null;
|
|
88
|
+
}
|
|
89
|
+
const changed = this._contentChanged;
|
|
90
|
+
this._contentChanged = false;
|
|
91
|
+
this._checkContent(changed);
|
|
92
|
+
}
|
|
93
|
+
_hasContent() {
|
|
94
|
+
for (const node of Array.from(this.childNodes)) {
|
|
95
|
+
if (node.nodeType === Node.TEXT_NODE && node.textContent.trim())
|
|
96
|
+
return true;
|
|
97
|
+
if (node.nodeType !== Node.ELEMENT_NODE)
|
|
98
|
+
continue;
|
|
99
|
+
const el = node;
|
|
100
|
+
if (!STATUS_SLOTS.has(el.getAttribute('slot') ?? '') && !INERT_ELEMENTS.has(el.localName))
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
_checkContent(mutated) {
|
|
106
|
+
if (!this.hasAttribute('lazy') || this._hasContent()) {
|
|
107
|
+
this._setLoad('idle');
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if (this._load !== 'idle')
|
|
111
|
+
return;
|
|
112
|
+
this._setLoad('empty');
|
|
113
|
+
if (!mutated)
|
|
114
|
+
return;
|
|
115
|
+
queueMicrotask(() => {
|
|
116
|
+
if (this._load === 'empty' && this._shown && this.parentElement?.localName === 'ty-tabs')
|
|
117
|
+
this._fireLoad();
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
_fireLoad(index) {
|
|
121
|
+
const tabs = this.parentElement;
|
|
122
|
+
if (index === undefined) {
|
|
123
|
+
index = tabs?.localName === 'ty-tabs'
|
|
124
|
+
? Array.from(tabs.querySelectorAll(':scope > ty-tab')).indexOf(this)
|
|
125
|
+
: 0;
|
|
126
|
+
}
|
|
127
|
+
this._setLoad('loading');
|
|
128
|
+
this.dispatchEvent(new CustomEvent('ty-tab-load', { detail: { id: this.id, index } }));
|
|
129
|
+
}
|
|
130
|
+
_ensureStatus(panel) {
|
|
131
|
+
if (panel.querySelector('.tab-loading'))
|
|
132
|
+
return;
|
|
133
|
+
panel.insertAdjacentHTML('beforeend', `
|
|
134
|
+
<div class="tab-loading" part="loading">
|
|
135
|
+
<slot name="loading"><span class="tab-spinner" part="spinner" aria-hidden="true"></span></slot>
|
|
136
|
+
</div>
|
|
137
|
+
<div class="tab-error" part="error" role="alert">
|
|
138
|
+
<slot name="error">Couldn't load.</slot>
|
|
139
|
+
<button type="button" class="tab-retry" part="retry">Retry</button>
|
|
140
|
+
</div>
|
|
141
|
+
`);
|
|
142
|
+
panel.querySelector('.tab-retry').addEventListener('click', () => {
|
|
143
|
+
panel.focus({ preventScroll: true });
|
|
144
|
+
this._fireLoad();
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
_setLoad(state) {
|
|
148
|
+
if (state === this._load)
|
|
149
|
+
return;
|
|
150
|
+
this._load = state;
|
|
151
|
+
const panel = this.shadowRoot?.querySelector('.tab-panel');
|
|
152
|
+
if (!panel)
|
|
153
|
+
return;
|
|
154
|
+
if (state === 'loading' || state === 'failed') {
|
|
155
|
+
this._ensureStatus(panel);
|
|
156
|
+
panel.dataset.load = state;
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
delete panel.dataset.load;
|
|
160
|
+
}
|
|
161
|
+
if (state === 'loading') {
|
|
162
|
+
panel.setAttribute('aria-busy', 'true');
|
|
163
|
+
panel.querySelector('.tab-spinner').innerHTML = getLoaderSvg();
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
panel.removeAttribute('aria-busy');
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
_syncPanel() {
|
|
170
|
+
const panel = this.shadowRoot?.querySelector('.tab-panel');
|
|
171
|
+
if (!panel)
|
|
172
|
+
return;
|
|
173
|
+
const tabs = this.parentElement;
|
|
174
|
+
const rich = !this._panelLabel && this.id && tabs?.localName === 'ty-tabs'
|
|
175
|
+
? tabs.querySelector(`:scope > [slot="label-${CSS.escape(this.id)}"]`)
|
|
176
|
+
: null;
|
|
177
|
+
const label = this._panelLabel || rich?.textContent?.trim() || this.getAttribute('label');
|
|
178
|
+
if (label)
|
|
179
|
+
panel.setAttribute('aria-label', label);
|
|
180
|
+
else
|
|
181
|
+
panel.removeAttribute('aria-label');
|
|
182
|
+
panel.parentElement.inert = !this._shown;
|
|
183
|
+
}
|
|
184
|
+
_setupScrollbar() {
|
|
185
|
+
const panel = this.shadowRoot?.querySelector('.tab-panel');
|
|
186
|
+
const wrapper = this.shadowRoot?.querySelector('.tab-wrapper');
|
|
187
|
+
if (!panel || !wrapper)
|
|
188
|
+
return;
|
|
189
|
+
if (!isCustomScrollbarEnabled())
|
|
190
|
+
return;
|
|
191
|
+
panel.classList.add('ty-custom-scroll');
|
|
192
|
+
this._scrollbar = new CustomScrollbar(panel, { vertical: true });
|
|
193
|
+
if (this._scrollbar.trackY) {
|
|
194
|
+
wrapper.appendChild(this._scrollbar.trackY);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
_destroyScrollbar() {
|
|
198
|
+
if (this._scrollbar) {
|
|
199
|
+
this._scrollbar.trackY?.remove();
|
|
200
|
+
this._scrollbar.destroy();
|
|
201
|
+
this._scrollbar = null;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
resetScroll() {
|
|
205
|
+
this._scrollbar?.scrollToTop(false);
|
|
206
|
+
}
|
|
66
207
|
}
|
|
67
208
|
if (!customElements.get('ty-tab')) {
|
|
68
|
-
|
|
209
|
+
customElements.define('ty-tab', TyTab);
|
|
69
210
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tab.js","sourceRoot":"","sources":["../../src/components/tab.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAe7C,+EAA+E;AAC/E,mBAAmB;AACnB,+EAA+E;AAE/E;;GAEG;AACH,SAAS,gBAAgB,CAAC,EAAS;IACjC,OAAO;QACL,EAAE,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC;QACzB,KAAK,EAAE,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC;QAC/B,QAAQ,EAAE,EAAE,CAAC,YAAY,CAAC,UAAU,CAAC;KACtC,CAAC;AACJ,CAAC;AAED,+EAA+E;AAC/E,YAAY;AACZ,+EAA+E;AAE/E;;;GAGG;AACH,SAAS,MAAM,CAAC,EAAS;IACvB,MAAM,UAAU,GAAG,EAAE,CAAC,UAAU,CAAC;IACjC,IAAI,CAAC,UAAU;QAAE,OAAO;IAExB,MAAM,EAAE,EAAE,EAAE,GAAG,gBAAgB,CAAC,EAAE,CAAC,CAAC;IAEpC,2BAA2B;IAC3B,YAAY,CAAC,UAAU,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;IAE3D,mEAAmE;IACnE,0EAA0E;IAC1E,UAAU,CAAC,SAAS,GAAG;;;WAGd,EAAE,CAAC,CAAC,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE;WAC5B,EAAE,CAAC,CAAC,CAAC,wBAAwB,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE;;;;GAI/C,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAS,OAAO,CAAC,GAAU;IACzB,6BAA6B;AAC/B,CAAC;AAED,+EAA+E;AAC/E,uBAAuB;AACvB,+EAA+E;AAE/E;;GAEG;AACH,MAAM,OAAO,KAAM,SAAQ,WAAW;IACpC,0BAA0B;IAC1B,MAAM,KAAK,kBAAkB;QAC3B,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;IACrC,CAAC;IAED;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;IACtC,CAAC;IAED,iBAAiB;QACf,MAAM,CAAC,IAAI,CAAC,CAAC;IACf,CAAC;IAED,oBAAoB;QAClB,OAAO,CAAC,IAAI,CAAC,CAAC;IAChB,CAAC;IAED,wBAAwB,CAAC,KAAa,EAAE,SAAwB,EAAE,SAAwB;QACxF,MAAM,CAAC,IAAI,CAAC,CAAC;IACf,CAAC;CACF;AAED,8BAA8B;AAC9B,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;IAClC,cAAc,CAAC,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;AACzC,CAAC"}
|
package/lib/components/tabs.d.ts
CHANGED
|
@@ -11,9 +11,11 @@ export interface TabsAttributes {
|
|
|
11
11
|
height: string;
|
|
12
12
|
active: string | null;
|
|
13
13
|
placement: 'top' | 'bottom';
|
|
14
|
+
fixed: boolean;
|
|
14
15
|
}
|
|
15
16
|
/**
|
|
16
|
-
* Tab change event detail
|
|
17
|
+
* Tab change event detail. Fired whenever the shown tab changes after the
|
|
18
|
+
* first one is shown — never for the initial tab.
|
|
17
19
|
*/
|
|
18
20
|
export interface TabChangeDetail {
|
|
19
21
|
activeId: string;
|
|
@@ -28,8 +30,19 @@ export declare class TyTabs extends HTMLElement {
|
|
|
28
30
|
static get observedAttributes(): string[];
|
|
29
31
|
constructor();
|
|
30
32
|
private _childObserver;
|
|
31
|
-
private
|
|
33
|
+
private _updateQueued;
|
|
34
|
+
private _structureDirty;
|
|
35
|
+
/** ID of the tab currently shown (`active` may be stale or missing after a morph). */
|
|
36
|
+
get activeTab(): string | null;
|
|
32
37
|
connectedCallback(): void;
|
|
33
38
|
disconnectedCallback(): void;
|
|
39
|
+
/**
|
|
40
|
+
* External changes (`active` set by app or server, children added or
|
|
41
|
+
* removed, a ty-tab's id/label/disabled changed — ty-tab reports those)
|
|
42
|
+
* settle in one microtask: a morph sets attributes and swaps children in
|
|
43
|
+
* one go, and the shown tab must be decided once the whole batch has
|
|
44
|
+
* landed — `active` may name a tab that is appended after it.
|
|
45
|
+
*/
|
|
46
|
+
_queueUpdate(structure: boolean): void;
|
|
34
47
|
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
35
48
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tabs.d.ts","sourceRoot":"","sources":["../../src/components/tabs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AASH;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,SAAS,EAAE,KAAK,GAAG,QAAQ,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AA8pBD;;GAEG;AACH,qBAAa,MAAO,SAAQ,WAAW;IACrC,0BAA0B;IAC1B,MAAM,KAAK,kBAAkB,aAE5B;;IAOD,iBAAiB;IAIjB,oBAAoB;IAIpB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;CAcxF"}
|