tyrell-components 1.0.0-TC44 → 1.0.0-TC46
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/tyrell.js +1 -1
- package/lib/base/ty-component.d.ts +12 -7
- package/lib/base/ty-component.js +8 -139
- package/lib/components/button.d.ts +2 -16
- package/lib/components/button.js +0 -36
- package/lib/components/calendar-month.d.ts +2 -48
- package/lib/components/calendar-month.js +4 -166
- package/lib/components/calendar-navigation.d.ts +3 -48
- package/lib/components/calendar-navigation.js +3 -126
- package/lib/components/calendar.d.ts +3 -80
- package/lib/components/calendar.js +8 -230
- package/lib/components/checkbox.d.ts +4 -71
- package/lib/components/checkbox.js +7 -151
- package/lib/components/copy.d.ts +3 -56
- package/lib/components/copy.js +1 -120
- package/lib/components/date-picker.d.ts +10 -160
- package/lib/components/date-picker.js +31 -577
- package/lib/components/file-upload.d.ts +3 -15
- package/lib/components/file-upload.js +0 -37
- package/lib/components/icon.d.ts +3 -24
- package/lib/components/icon.js +1 -90
- package/lib/components/input.d.ts +7 -107
- package/lib/components/input.js +4 -193
- package/lib/components/modal.d.ts +3 -26
- package/lib/components/modal.js +1 -188
- package/lib/components/option.d.ts +2 -9
- package/lib/components/option.js +0 -48
- package/lib/components/popup.d.ts +2 -17
- package/lib/components/popup.js +3 -130
- package/lib/components/radio.d.ts +3 -23
- package/lib/components/radio.js +0 -63
- package/lib/components/resize-observer.d.ts +2 -30
- package/lib/components/resize-observer.js +0 -45
- package/lib/components/scroll-container.d.ts +2 -12
- package/lib/components/scroll-container.js +3 -46
- package/lib/components/select.d.ts +43 -150
- package/lib/components/select.js +68 -558
- package/lib/components/selected-tags.d.ts +4 -47
- package/lib/components/selected-tags.js +0 -94
- package/lib/components/step.d.ts +1 -6
- package/lib/components/step.js +0 -6
- package/lib/components/switch.d.ts +0 -11
- package/lib/components/switch.js +2 -36
- package/lib/components/tab.d.ts +1 -6
- package/lib/components/tab.js +0 -7
- package/lib/components/tabs.d.ts +3 -63
- package/lib/components/tabs.js +2 -282
- package/lib/components/tag.d.ts +2 -36
- package/lib/components/tag.js +5 -105
- package/lib/components/textarea.d.ts +6 -86
- package/lib/components/textarea.js +2 -173
- package/lib/components/tooltip.d.ts +3 -11
- package/lib/components/tooltip.js +0 -154
- package/lib/components/wizard.d.ts +4 -54
- package/lib/components/wizard.js +0 -228
- package/lib/icons/fontawesome/brands.d.ts +0 -1
- package/lib/icons/fontawesome/brands.js +0 -8
- package/lib/icons/fontawesome/regular.d.ts +0 -1
- package/lib/icons/fontawesome/regular.js +0 -8
- package/lib/icons/fontawesome/solid.d.ts +0 -1
- package/lib/icons/fontawesome/solid.js +0 -8
- package/lib/icons/heroicons/micro.d.ts +0 -1
- package/lib/icons/heroicons/micro.js +0 -8
- package/lib/icons/heroicons/mini.d.ts +0 -1
- package/lib/icons/heroicons/mini.js +0 -8
- package/lib/icons/heroicons/outline.d.ts +0 -1
- package/lib/icons/heroicons/outline.js +0 -8
- package/lib/icons/heroicons/solid.d.ts +0 -1
- package/lib/icons/heroicons/solid.js +0 -8
- package/lib/icons/lucide.d.ts +0 -1
- package/lib/icons/lucide.js +0 -1872
- package/lib/icons/material/filled.d.ts +0 -1
- package/lib/icons/material/filled.js +0 -10
- package/lib/icons/material/outlined.d.ts +0 -1
- package/lib/icons/material/outlined.js +0 -10
- package/lib/icons/material/round.d.ts +0 -1
- package/lib/icons/material/round.js +0 -10
- package/lib/icons/material/sharp.d.ts +0 -1
- package/lib/icons/material/sharp.js +0 -10
- package/lib/icons/material/two-tone.d.ts +0 -1
- package/lib/icons/material/two-tone.js +0 -10
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -20
- package/lib/styles/button.d.ts +2 -20
- package/lib/styles/button.js +13 -120
- package/lib/styles/calendar-month.d.ts +1 -5
- package/lib/styles/calendar-month.js +3 -60
- package/lib/styles/calendar-navigation.d.ts +2 -6
- package/lib/styles/calendar-navigation.js +1 -26
- package/lib/styles/calendar.d.ts +1 -2
- package/lib/styles/calendar.js +0 -13
- package/lib/styles/checkbox.d.ts +0 -1
- package/lib/styles/checkbox.js +1 -23
- package/lib/styles/copy.d.ts +0 -1
- package/lib/styles/copy.js +2 -17
- package/lib/styles/custom-scrollbar.d.ts +1 -2
- package/lib/styles/custom-scrollbar.js +3 -18
- package/lib/styles/date-picker.d.ts +1 -5
- package/lib/styles/date-picker.js +5 -35
- package/lib/styles/file-upload.d.ts +1 -2
- package/lib/styles/file-upload.js +0 -15
- package/lib/styles/icon.d.ts +2 -6
- package/lib/styles/icon.js +1 -26
- package/lib/styles/input.d.ts +1 -6
- package/lib/styles/input.js +3 -53
- package/lib/styles/modal.d.ts +1 -2
- package/lib/styles/modal.js +3 -23
- package/lib/styles/option.d.ts +2 -6
- package/lib/styles/option.js +1 -11
- package/lib/styles/popup.d.ts +1 -2
- package/lib/styles/popup.js +4 -25
- package/lib/styles/radio.d.ts +0 -1
- package/lib/styles/radio.js +1 -15
- package/lib/styles/resize-observer.d.ts +1 -2
- package/lib/styles/resize-observer.js +0 -7
- package/lib/styles/scroll-container.d.ts +1 -2
- package/lib/styles/scroll-container.js +0 -19
- package/lib/styles/select-base.d.ts +0 -1
- package/lib/styles/select-base.js +9 -70
- package/lib/styles/select.d.ts +1 -2
- package/lib/styles/select.js +50 -18
- package/lib/styles/step.d.ts +1 -2
- package/lib/styles/step.js +0 -4
- package/lib/styles/switch.d.ts +0 -1
- package/lib/styles/switch.js +2 -20
- package/lib/styles/tab.d.ts +1 -2
- package/lib/styles/tab.js +0 -5
- package/lib/styles/tabs.d.ts +3 -11
- package/lib/styles/tabs.js +4 -47
- package/lib/styles/tag.d.ts +1 -5
- package/lib/styles/tag.js +2 -31
- package/lib/styles/textarea.d.ts +1 -2
- package/lib/styles/textarea.js +0 -44
- package/lib/styles/tooltip.d.ts +0 -1
- package/lib/styles/tooltip.js +0 -10
- package/lib/styles/wizard.d.ts +5 -21
- package/lib/styles/wizard.js +5 -85
- package/lib/types/common.d.ts +0 -2
- package/lib/types/common.js +0 -12
- package/lib/utils/calendar-utils.d.ts +4 -21
- package/lib/utils/calendar-utils.js +4 -177
- package/lib/utils/custom-scrollbar.d.ts +6 -20
- package/lib/utils/custom-scrollbar.js +1 -45
- package/lib/utils/flavor-sheet.d.ts +0 -1
- package/lib/utils/flavor-sheet.js +0 -23
- package/lib/utils/icon-registry.d.ts +0 -2
- package/lib/utils/icon-registry.js +1 -107
- package/lib/utils/icons.d.ts +0 -1
- package/lib/utils/icons.js +0 -9
- package/lib/utils/loader-registry.d.ts +0 -1
- package/lib/utils/loader-registry.js +0 -32
- package/lib/utils/locale.d.ts +2 -23
- package/lib/utils/locale.js +0 -86
- package/lib/utils/mobile.d.ts +0 -1
- package/lib/utils/mobile.js +0 -17
- package/lib/utils/number-format.d.ts +0 -2
- package/lib/utils/number-format.js +2 -65
- package/lib/utils/positioning.d.ts +4 -2
- package/lib/utils/positioning.js +2 -54
- package/lib/utils/property-capture.d.ts +5 -27
- package/lib/utils/property-capture.js +0 -108
- package/lib/utils/property-manager.d.ts +0 -1
- package/lib/utils/property-manager.js +0 -70
- package/lib/utils/resize-observer.d.ts +0 -1
- package/lib/utils/resize-observer.js +0 -36
- package/lib/utils/scroll-lock.d.ts +4 -11
- package/lib/utils/scroll-lock.js +0 -107
- package/lib/utils/styles.d.ts +0 -1
- package/lib/utils/styles.js +0 -24
- package/lib/version.d.ts +1 -2
- package/lib/version.js +1 -11
- package/package.json +2 -2
- package/lib/base/ty-component.d.ts.map +0 -1
- package/lib/base/ty-component.js.map +0 -1
- package/lib/components/button.d.ts.map +0 -1
- package/lib/components/button.js.map +0 -1
- package/lib/components/calendar-month.d.ts.map +0 -1
- package/lib/components/calendar-month.js.map +0 -1
- package/lib/components/calendar-navigation.d.ts.map +0 -1
- package/lib/components/calendar-navigation.js.map +0 -1
- package/lib/components/calendar.d.ts.map +0 -1
- package/lib/components/calendar.js.map +0 -1
- package/lib/components/checkbox.d.ts.map +0 -1
- package/lib/components/checkbox.js.map +0 -1
- package/lib/components/copy.d.ts.map +0 -1
- package/lib/components/copy.js.map +0 -1
- package/lib/components/date-picker.d.ts.map +0 -1
- package/lib/components/date-picker.js.map +0 -1
- package/lib/components/file-upload.d.ts.map +0 -1
- package/lib/components/file-upload.js.map +0 -1
- package/lib/components/icon.d.ts.map +0 -1
- package/lib/components/icon.js.map +0 -1
- package/lib/components/input.d.ts.map +0 -1
- package/lib/components/input.js.map +0 -1
- package/lib/components/modal.d.ts.map +0 -1
- package/lib/components/modal.js.map +0 -1
- package/lib/components/option.d.ts.map +0 -1
- package/lib/components/option.js.map +0 -1
- package/lib/components/popup.d.ts.map +0 -1
- package/lib/components/popup.js.map +0 -1
- package/lib/components/radio.d.ts.map +0 -1
- package/lib/components/radio.js.map +0 -1
- package/lib/components/resize-observer.d.ts.map +0 -1
- package/lib/components/resize-observer.js.map +0 -1
- package/lib/components/scroll-container.d.ts.map +0 -1
- package/lib/components/scroll-container.js.map +0 -1
- package/lib/components/select.d.ts.map +0 -1
- package/lib/components/select.js.map +0 -1
- package/lib/components/selected-tags.d.ts.map +0 -1
- package/lib/components/selected-tags.js.map +0 -1
- package/lib/components/step.d.ts.map +0 -1
- package/lib/components/step.js.map +0 -1
- package/lib/components/switch.d.ts.map +0 -1
- package/lib/components/switch.js.map +0 -1
- package/lib/components/tab.d.ts.map +0 -1
- package/lib/components/tab.js.map +0 -1
- package/lib/components/tabs.d.ts.map +0 -1
- package/lib/components/tabs.js.map +0 -1
- package/lib/components/tag.d.ts.map +0 -1
- package/lib/components/tag.js.map +0 -1
- package/lib/components/textarea.d.ts.map +0 -1
- package/lib/components/textarea.js.map +0 -1
- package/lib/components/tooltip.d.ts.map +0 -1
- package/lib/components/tooltip.js.map +0 -1
- package/lib/components/wizard.d.ts.map +0 -1
- package/lib/components/wizard.js.map +0 -1
- package/lib/icons/fontawesome/brands.d.ts.map +0 -1
- package/lib/icons/fontawesome/brands.js.map +0 -1
- package/lib/icons/fontawesome/regular.d.ts.map +0 -1
- package/lib/icons/fontawesome/regular.js.map +0 -1
- package/lib/icons/fontawesome/solid.d.ts.map +0 -1
- package/lib/icons/fontawesome/solid.js.map +0 -1
- package/lib/icons/heroicons/micro.d.ts.map +0 -1
- package/lib/icons/heroicons/micro.js.map +0 -1
- package/lib/icons/heroicons/mini.d.ts.map +0 -1
- package/lib/icons/heroicons/mini.js.map +0 -1
- package/lib/icons/heroicons/outline.d.ts.map +0 -1
- package/lib/icons/heroicons/outline.js.map +0 -1
- package/lib/icons/heroicons/solid.d.ts.map +0 -1
- package/lib/icons/heroicons/solid.js.map +0 -1
- package/lib/icons/lucide.d.ts.map +0 -1
- package/lib/icons/lucide.js.map +0 -1
- package/lib/icons/material/filled.d.ts.map +0 -1
- package/lib/icons/material/filled.js.map +0 -1
- package/lib/icons/material/outlined.d.ts.map +0 -1
- package/lib/icons/material/outlined.js.map +0 -1
- package/lib/icons/material/round.d.ts.map +0 -1
- package/lib/icons/material/round.js.map +0 -1
- package/lib/icons/material/sharp.d.ts.map +0 -1
- package/lib/icons/material/sharp.js.map +0 -1
- package/lib/icons/material/two-tone.d.ts.map +0 -1
- package/lib/icons/material/two-tone.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/styles/button.d.ts.map +0 -1
- package/lib/styles/button.js.map +0 -1
- package/lib/styles/calendar-month.d.ts.map +0 -1
- package/lib/styles/calendar-month.js.map +0 -1
- package/lib/styles/calendar-navigation.d.ts.map +0 -1
- package/lib/styles/calendar-navigation.js.map +0 -1
- package/lib/styles/calendar.d.ts.map +0 -1
- package/lib/styles/calendar.js.map +0 -1
- package/lib/styles/checkbox.d.ts.map +0 -1
- package/lib/styles/checkbox.js.map +0 -1
- package/lib/styles/copy.d.ts.map +0 -1
- package/lib/styles/copy.js.map +0 -1
- package/lib/styles/custom-scrollbar.d.ts.map +0 -1
- package/lib/styles/custom-scrollbar.js.map +0 -1
- package/lib/styles/date-picker.d.ts.map +0 -1
- package/lib/styles/date-picker.js.map +0 -1
- package/lib/styles/file-upload.d.ts.map +0 -1
- package/lib/styles/file-upload.js.map +0 -1
- package/lib/styles/icon.d.ts.map +0 -1
- package/lib/styles/icon.js.map +0 -1
- package/lib/styles/input.d.ts.map +0 -1
- package/lib/styles/input.js.map +0 -1
- package/lib/styles/modal.d.ts.map +0 -1
- package/lib/styles/modal.js.map +0 -1
- package/lib/styles/multiselect.d.ts +0 -8
- package/lib/styles/multiselect.d.ts.map +0 -1
- package/lib/styles/multiselect.js +0 -849
- package/lib/styles/multiselect.js.map +0 -1
- package/lib/styles/option.d.ts.map +0 -1
- package/lib/styles/option.js.map +0 -1
- package/lib/styles/popup.d.ts.map +0 -1
- package/lib/styles/popup.js.map +0 -1
- package/lib/styles/radio.d.ts.map +0 -1
- package/lib/styles/radio.js.map +0 -1
- package/lib/styles/resize-observer.d.ts.map +0 -1
- package/lib/styles/resize-observer.js.map +0 -1
- package/lib/styles/scroll-container.d.ts.map +0 -1
- package/lib/styles/scroll-container.js.map +0 -1
- package/lib/styles/select-base.d.ts.map +0 -1
- package/lib/styles/select-base.js.map +0 -1
- package/lib/styles/select.d.ts.map +0 -1
- package/lib/styles/select.js.map +0 -1
- package/lib/styles/step.d.ts.map +0 -1
- package/lib/styles/step.js.map +0 -1
- package/lib/styles/switch.d.ts.map +0 -1
- package/lib/styles/switch.js.map +0 -1
- package/lib/styles/tab.d.ts.map +0 -1
- package/lib/styles/tab.js.map +0 -1
- package/lib/styles/tabs.d.ts.map +0 -1
- package/lib/styles/tabs.js.map +0 -1
- package/lib/styles/tag.d.ts.map +0 -1
- package/lib/styles/tag.js.map +0 -1
- package/lib/styles/textarea.d.ts.map +0 -1
- package/lib/styles/textarea.js.map +0 -1
- package/lib/styles/tooltip.d.ts.map +0 -1
- package/lib/styles/tooltip.js.map +0 -1
- package/lib/styles/wizard.d.ts.map +0 -1
- package/lib/styles/wizard.js.map +0 -1
- package/lib/types/common.d.ts.map +0 -1
- package/lib/types/common.js.map +0 -1
- package/lib/utils/calendar-utils.d.ts.map +0 -1
- package/lib/utils/calendar-utils.js.map +0 -1
- package/lib/utils/custom-scrollbar.d.ts.map +0 -1
- package/lib/utils/custom-scrollbar.js.map +0 -1
- package/lib/utils/flavor-sheet.d.ts.map +0 -1
- package/lib/utils/flavor-sheet.js.map +0 -1
- package/lib/utils/icon-registry.d.ts.map +0 -1
- package/lib/utils/icon-registry.js.map +0 -1
- package/lib/utils/icons.d.ts.map +0 -1
- package/lib/utils/icons.js.map +0 -1
- package/lib/utils/loader-registry.d.ts.map +0 -1
- package/lib/utils/loader-registry.js.map +0 -1
- package/lib/utils/locale.d.ts.map +0 -1
- package/lib/utils/locale.js.map +0 -1
- package/lib/utils/mobile.d.ts.map +0 -1
- package/lib/utils/mobile.js.map +0 -1
- package/lib/utils/number-format.d.ts.map +0 -1
- package/lib/utils/number-format.js.map +0 -1
- package/lib/utils/parse-boolean.d.ts +0 -39
- package/lib/utils/parse-boolean.d.ts.map +0 -1
- package/lib/utils/parse-boolean.js +0 -58
- package/lib/utils/parse-boolean.js.map +0 -1
- package/lib/utils/positioning.d.ts.map +0 -1
- package/lib/utils/positioning.js.map +0 -1
- package/lib/utils/property-capture.d.ts.map +0 -1
- package/lib/utils/property-capture.js.map +0 -1
- package/lib/utils/property-manager.d.ts.map +0 -1
- package/lib/utils/property-manager.js.map +0 -1
- package/lib/utils/resize-observer.d.ts.map +0 -1
- package/lib/utils/resize-observer.js.map +0 -1
- package/lib/utils/scroll-lock.d.ts.map +0 -1
- package/lib/utils/scroll-lock.js.map +0 -1
- package/lib/utils/styles.d.ts.map +0 -1
- package/lib/utils/styles.js.map +0 -1
- package/lib/version.d.ts.map +0 -1
- package/lib/version.js.map +0 -1
|
@@ -1,46 +1,16 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tooltip Component
|
|
3
|
-
*
|
|
4
|
-
* Shows helpful content on hover/focus with smart positioning.
|
|
5
|
-
* Follows the same shadow DOM pattern as other components.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* <ty-tooltip placement="top" flavor="primary" delay="600">
|
|
9
|
-
* Helpful tooltip text
|
|
10
|
-
* </ty-tooltip>
|
|
11
|
-
*/
|
|
12
1
|
import { findBestPosition, placementPreferences } from '../utils/positioning.js';
|
|
13
2
|
import { ensureStyles } from '../utils/styles.js';
|
|
14
3
|
import { tooltipStyles } from '../styles/tooltip.js';
|
|
15
|
-
// ============================================================================
|
|
16
|
-
// WeakMaps for State Management
|
|
17
|
-
// ============================================================================
|
|
18
4
|
const autoUpdateCleanup = new WeakMap();
|
|
19
5
|
const eventCleanup = new WeakMap();
|
|
20
6
|
const timeoutState = new WeakMap();
|
|
21
7
|
const popoverElements = new WeakMap();
|
|
22
|
-
// Cached separately from getAnchorElement()/el.parentElement — by the time
|
|
23
|
-
// disconnectedCallback fires the element has already been removed from the
|
|
24
|
-
// DOM, so parentElement is null and cleanup() couldn't otherwise find the
|
|
25
|
-
// anchor to strip its aria-describedby.
|
|
26
8
|
const anchorElements = new WeakMap();
|
|
27
|
-
// ============================================================================
|
|
28
|
-
// Helper Functions
|
|
29
|
-
// ============================================================================
|
|
30
|
-
/**
|
|
31
|
-
* Normalize the flavor attribute. Any plain identifier (with optional +/-
|
|
32
|
-
* shade suffix) is accepted — built-ins and custom flavors alike get their
|
|
33
|
-
* colors from tokens in applyFlavorStyles(). Anything else (including
|
|
34
|
-
* would-be CSS injection through the attribute) falls back to 'dark'.
|
|
35
|
-
*/
|
|
36
9
|
function validateFlavor(flavor) {
|
|
37
10
|
const full = flavor || 'dark';
|
|
38
11
|
const base = full.replace(/[+-]$/, '');
|
|
39
12
|
return /^[A-Za-z][A-Za-z0-9_-]*$/.test(base) ? full : 'dark';
|
|
40
13
|
}
|
|
41
|
-
/**
|
|
42
|
-
* Get timeout state for element
|
|
43
|
-
*/
|
|
44
14
|
function getTimeoutState(el) {
|
|
45
15
|
let state = timeoutState.get(el);
|
|
46
16
|
if (!state) {
|
|
@@ -49,15 +19,9 @@ function getTimeoutState(el) {
|
|
|
49
19
|
}
|
|
50
20
|
return state;
|
|
51
21
|
}
|
|
52
|
-
/**
|
|
53
|
-
* Parse boolean attribute
|
|
54
|
-
*/
|
|
55
22
|
function parseBoolAttr(el, name) {
|
|
56
23
|
return el.hasAttribute(name);
|
|
57
24
|
}
|
|
58
|
-
/**
|
|
59
|
-
* Parse integer attribute
|
|
60
|
-
*/
|
|
61
25
|
function parseIntAttr(el, name, defaultValue) {
|
|
62
26
|
const value = el.getAttribute(name);
|
|
63
27
|
if (value === null)
|
|
@@ -65,9 +29,6 @@ function parseIntAttr(el, name, defaultValue) {
|
|
|
65
29
|
const parsed = parseInt(value, 10);
|
|
66
30
|
return isNaN(parsed) ? defaultValue : parsed;
|
|
67
31
|
}
|
|
68
|
-
/**
|
|
69
|
-
* Read all tooltip attributes from element
|
|
70
|
-
*/
|
|
71
32
|
function getTooltipAttributes(el) {
|
|
72
33
|
return {
|
|
73
34
|
placement: (el.getAttribute('placement') || 'top'),
|
|
@@ -77,17 +38,9 @@ function getTooltipAttributes(el) {
|
|
|
77
38
|
flavor: validateFlavor(el.getAttribute('flavor')),
|
|
78
39
|
};
|
|
79
40
|
}
|
|
80
|
-
/**
|
|
81
|
-
* Get the parent element (anchor)
|
|
82
|
-
*/
|
|
83
41
|
function getAnchorElement(el) {
|
|
84
42
|
return el.parentElement;
|
|
85
43
|
}
|
|
86
|
-
/**
|
|
87
|
-
* Add `id` to the anchor's aria-describedby without clobbering a value the
|
|
88
|
-
* consumer may already have set for something else (WAI-ARIA APG tooltip
|
|
89
|
-
* pattern: append, don't overwrite).
|
|
90
|
-
*/
|
|
91
44
|
function addDescribedBy(anchor, id) {
|
|
92
45
|
const ids = (anchor.getAttribute('aria-describedby') || '').split(/\s+/).filter(Boolean);
|
|
93
46
|
if (!ids.includes(id)) {
|
|
@@ -95,7 +48,6 @@ function addDescribedBy(anchor, id) {
|
|
|
95
48
|
anchor.setAttribute('aria-describedby', ids.join(' '));
|
|
96
49
|
}
|
|
97
50
|
}
|
|
98
|
-
/** Inverse of addDescribedBy — used on teardown. */
|
|
99
51
|
function removeDescribedBy(anchor, id) {
|
|
100
52
|
const ids = (anchor.getAttribute('aria-describedby') || '').split(/\s+/).filter((x) => x && x !== id);
|
|
101
53
|
if (ids.length > 0) {
|
|
@@ -105,24 +57,14 @@ function removeDescribedBy(anchor, id) {
|
|
|
105
57
|
anchor.removeAttribute('aria-describedby');
|
|
106
58
|
}
|
|
107
59
|
}
|
|
108
|
-
/**
|
|
109
|
-
* Get or create popover element using Popover API
|
|
110
|
-
* The popover is created in document.body for top-layer placement
|
|
111
|
-
*/
|
|
112
60
|
function getOrCreatePopover(el) {
|
|
113
61
|
let popover = popoverElements.get(el);
|
|
114
62
|
if (!popover) {
|
|
115
|
-
// Create popover element
|
|
116
63
|
popover = document.createElement('div');
|
|
117
64
|
popover.id = `ty-tooltip-${Math.random().toString(36).slice(2, 11)}`;
|
|
118
65
|
popover.setAttribute('popover', 'manual');
|
|
119
|
-
// WAI-ARIA APG tooltip pattern: the popover needs role="tooltip" and
|
|
120
|
-
// the trigger needs aria-describedby pointing at it, or a keyboard/
|
|
121
|
-
// screen-reader user gets no indication the tooltip exists at all —
|
|
122
|
-
// hover-only visibility isn't enough on its own.
|
|
123
66
|
popover.setAttribute('role', 'tooltip');
|
|
124
67
|
popover.className = 'ty-tooltip-popover';
|
|
125
|
-
// Apply inline styles (since popover is outside shadow DOM, we need inline styles)
|
|
126
68
|
const styles = `
|
|
127
69
|
position: fixed;
|
|
128
70
|
margin: 0;
|
|
@@ -141,51 +83,24 @@ function getOrCreatePopover(el) {
|
|
|
141
83
|
pointer-events: none;
|
|
142
84
|
`;
|
|
143
85
|
popover.style.cssText = styles;
|
|
144
|
-
// Append to body
|
|
145
86
|
document.body.appendChild(popover);
|
|
146
|
-
// Store reference
|
|
147
87
|
popoverElements.set(el, popover);
|
|
148
88
|
const anchor = anchorElements.get(el);
|
|
149
89
|
if (anchor)
|
|
150
90
|
addDescribedBy(anchor, popover.id);
|
|
151
91
|
}
|
|
152
|
-
// Resync on every call (not just creation) — content and flavor can
|
|
153
|
-
// change between shows, and this is eagerly called from connectedCallback
|
|
154
|
-
// (see below) so a keyboard user tabbing straight to the trigger gets a
|
|
155
|
-
// real aria-describedby target immediately, not one that only exists
|
|
156
|
-
// after the (default 600ms) hover delay has already elapsed.
|
|
157
92
|
const { flavor } = getTooltipAttributes(el);
|
|
158
93
|
popover.setAttribute('data-flavor', flavor);
|
|
159
|
-
// innerHTML, not textContent — the tooltip's own docs promise "Content is
|
|
160
|
-
// any HTML nested inside the ty-tooltip element"; textContent silently
|
|
161
|
-
// stripped it. Relocating the developer's own authored markup between two
|
|
162
|
-
// elements they control isn't a new trust boundary (same model ty-select
|
|
163
|
-
// already uses to clone rich option HTML into its trigger).
|
|
164
94
|
popover.innerHTML = el.innerHTML;
|
|
165
95
|
applyFlavorStyles(popover, flavor);
|
|
166
96
|
return popover;
|
|
167
97
|
}
|
|
168
|
-
/**
|
|
169
|
-
* Apply flavor-specific styles to popover.
|
|
170
|
-
*
|
|
171
|
-
* dark / light / info are hand-written extras; every other flavor —
|
|
172
|
-
* built-in semantic or custom — is one token formula, with neutral
|
|
173
|
-
* fallbacks so a custom flavor with missing tokens degrades gracefully.
|
|
174
|
-
* flavor has passed validateFlavor's identifier guard, so interpolating
|
|
175
|
-
* it into var() names is safe.
|
|
176
|
-
*/
|
|
177
98
|
function applyFlavorStyles(popover, flavor) {
|
|
178
|
-
// Reset to defaults first
|
|
179
99
|
popover.style.removeProperty('background');
|
|
180
100
|
popover.style.removeProperty('color');
|
|
181
101
|
popover.style.removeProperty('border-color');
|
|
182
102
|
switch (flavor) {
|
|
183
103
|
case 'dark':
|
|
184
|
-
// Default look — theme-INDEPENDENT on purpose (matches Material/
|
|
185
|
-
// Bootstrap/Ant/Shoelace: a tooltip stays a fixed dark chip whether
|
|
186
|
-
// the page is light or dark, so it always pops). Routed through the
|
|
187
|
-
// --ty-tooltip-* tokens (defined once in :root, not redeclared in
|
|
188
|
-
// html.dark) so consumers can retheme without a flavor.
|
|
189
104
|
popover.style.background = 'var(--ty-tooltip-bg, #262626)';
|
|
190
105
|
popover.style.color = 'var(--ty-tooltip-color, #f5f5f5)';
|
|
191
106
|
popover.style.borderColor = 'var(--ty-tooltip-border, #404040)';
|
|
@@ -211,9 +126,6 @@ function applyFlavorStyles(popover, flavor) {
|
|
|
211
126
|
}
|
|
212
127
|
}
|
|
213
128
|
}
|
|
214
|
-
/**
|
|
215
|
-
* Update tooltip position based on current anchor/popover state
|
|
216
|
-
*/
|
|
217
129
|
function updatePosition(el) {
|
|
218
130
|
const { placement, offset } = getTooltipAttributes(el);
|
|
219
131
|
const anchor = getAnchorElement(el);
|
|
@@ -222,26 +134,20 @@ function updatePosition(el) {
|
|
|
222
134
|
console.warn('[ty-tooltip] updatePosition: missing anchor or popover');
|
|
223
135
|
return;
|
|
224
136
|
}
|
|
225
|
-
// Calculate preferences based on placement
|
|
226
137
|
const preferences = placement === 'top' ? placementPreferences.tooltip :
|
|
227
138
|
placement === 'bottom' ? ['bottom', 'top', 'left', 'right'] :
|
|
228
139
|
placement === 'left' ? ['left', 'right', 'top', 'bottom'] :
|
|
229
140
|
placement === 'right' ? ['right', 'left', 'top', 'bottom'] :
|
|
230
141
|
placementPreferences.tooltip;
|
|
231
|
-
// Use positioning engine to find best position
|
|
232
142
|
const position = findBestPosition({
|
|
233
143
|
targetEl: anchor,
|
|
234
144
|
floatingEl: popover,
|
|
235
145
|
preferences,
|
|
236
146
|
offset,
|
|
237
147
|
});
|
|
238
|
-
// Apply position directly to popover
|
|
239
148
|
popover.style.left = `${position.x}px`;
|
|
240
149
|
popover.style.top = `${position.y}px`;
|
|
241
150
|
}
|
|
242
|
-
/**
|
|
243
|
-
* Cleanup auto-update system
|
|
244
|
-
*/
|
|
245
151
|
function cleanupAutoUpdate(el) {
|
|
246
152
|
const cleanup = autoUpdateCleanup.get(el);
|
|
247
153
|
if (cleanup) {
|
|
@@ -249,10 +155,6 @@ function cleanupAutoUpdate(el) {
|
|
|
249
155
|
autoUpdateCleanup.delete(el);
|
|
250
156
|
}
|
|
251
157
|
}
|
|
252
|
-
/**
|
|
253
|
-
* Setup auto-update system for position tracking
|
|
254
|
-
* Note: This does NOT calculate initial position - call updatePosition() separately
|
|
255
|
-
*/
|
|
256
158
|
function setupAutoUpdate(el) {
|
|
257
159
|
const anchor = getAnchorElement(el);
|
|
258
160
|
const popover = popoverElements.get(el);
|
|
@@ -260,7 +162,6 @@ function setupAutoUpdate(el) {
|
|
|
260
162
|
console.warn('[ty-tooltip] setupAutoUpdate: missing anchor or popover');
|
|
261
163
|
return;
|
|
262
164
|
}
|
|
263
|
-
// Debounced update function
|
|
264
165
|
let timeoutId = null;
|
|
265
166
|
const debouncedUpdate = () => {
|
|
266
167
|
if (timeoutId !== null) {
|
|
@@ -271,11 +172,9 @@ function setupAutoUpdate(el) {
|
|
|
271
172
|
updatePosition(el);
|
|
272
173
|
}, 10);
|
|
273
174
|
};
|
|
274
|
-
// Setup ResizeObserver for anchor and popover
|
|
275
175
|
const resizeObserver = new ResizeObserver(debouncedUpdate);
|
|
276
176
|
resizeObserver.observe(anchor);
|
|
277
177
|
resizeObserver.observe(popover);
|
|
278
|
-
// Scroll handler with requestAnimationFrame
|
|
279
178
|
let scrollRafId = null;
|
|
280
179
|
const handleScroll = () => {
|
|
281
180
|
if (scrollRafId === null) {
|
|
@@ -285,10 +184,8 @@ function setupAutoUpdate(el) {
|
|
|
285
184
|
});
|
|
286
185
|
}
|
|
287
186
|
};
|
|
288
|
-
// Listen for scroll and resize
|
|
289
187
|
window.addEventListener('scroll', handleScroll, true);
|
|
290
188
|
window.addEventListener('resize', debouncedUpdate);
|
|
291
|
-
// Store cleanup function
|
|
292
189
|
const cleanup = () => {
|
|
293
190
|
resizeObserver.disconnect();
|
|
294
191
|
window.removeEventListener('scroll', handleScroll, true);
|
|
@@ -302,9 +199,6 @@ function setupAutoUpdate(el) {
|
|
|
302
199
|
};
|
|
303
200
|
autoUpdateCleanup.set(el, cleanup);
|
|
304
201
|
}
|
|
305
|
-
/**
|
|
306
|
-
* Clear all timeouts
|
|
307
|
-
*/
|
|
308
202
|
function clearTimeouts(el) {
|
|
309
203
|
const state = getTimeoutState(el);
|
|
310
204
|
if (state.showTimeout !== null) {
|
|
@@ -316,20 +210,14 @@ function clearTimeouts(el) {
|
|
|
316
210
|
state.hideTimeout = null;
|
|
317
211
|
}
|
|
318
212
|
}
|
|
319
|
-
/**
|
|
320
|
-
* Show tooltip immediately using Popover API
|
|
321
|
-
*/
|
|
322
213
|
function showTooltip(el) {
|
|
323
214
|
const { disabled } = getTooltipAttributes(el);
|
|
324
215
|
if (disabled)
|
|
325
216
|
return;
|
|
326
|
-
// Create popover if it doesn't exist
|
|
327
217
|
const popover = getOrCreatePopover(el);
|
|
328
218
|
try {
|
|
329
|
-
// Show using Popover API
|
|
330
219
|
popover.showPopover();
|
|
331
220
|
el._open = true;
|
|
332
|
-
// Position and setup observers
|
|
333
221
|
updatePosition(el);
|
|
334
222
|
setupAutoUpdate(el);
|
|
335
223
|
}
|
|
@@ -337,9 +225,6 @@ function showTooltip(el) {
|
|
|
337
225
|
console.warn('[ty-tooltip] Failed to show popover', e);
|
|
338
226
|
}
|
|
339
227
|
}
|
|
340
|
-
/**
|
|
341
|
-
* Hide tooltip immediately using Popover API
|
|
342
|
-
*/
|
|
343
228
|
function hideTooltip(el) {
|
|
344
229
|
const popover = popoverElements.get(el);
|
|
345
230
|
if (!popover)
|
|
@@ -350,29 +235,19 @@ function hideTooltip(el) {
|
|
|
350
235
|
cleanupAutoUpdate(el);
|
|
351
236
|
}
|
|
352
237
|
catch (e) {
|
|
353
|
-
// Already hidden, ignore
|
|
354
238
|
}
|
|
355
239
|
}
|
|
356
|
-
/**
|
|
357
|
-
* Schedule tooltip to show after delay
|
|
358
|
-
*/
|
|
359
240
|
function scheduleShow(el) {
|
|
360
241
|
const state = getTimeoutState(el);
|
|
361
242
|
const { delay } = getTooltipAttributes(el);
|
|
362
243
|
clearTimeouts(el);
|
|
363
244
|
state.showTimeout = window.setTimeout(() => showTooltip(el), delay);
|
|
364
245
|
}
|
|
365
|
-
/**
|
|
366
|
-
* Schedule tooltip to hide after delay
|
|
367
|
-
*/
|
|
368
246
|
function scheduleHide(el) {
|
|
369
247
|
const state = getTimeoutState(el);
|
|
370
248
|
clearTimeouts(el);
|
|
371
249
|
state.hideTimeout = window.setTimeout(() => hideTooltip(el), 200);
|
|
372
250
|
}
|
|
373
|
-
/**
|
|
374
|
-
* Setup event listeners on anchor element
|
|
375
|
-
*/
|
|
376
251
|
function setupEvents(el) {
|
|
377
252
|
const anchor = getAnchorElement(el);
|
|
378
253
|
if (!anchor)
|
|
@@ -382,12 +257,10 @@ function setupEvents(el) {
|
|
|
382
257
|
const handleLeave = () => scheduleHide(el);
|
|
383
258
|
const handleFocus = () => scheduleShow(el);
|
|
384
259
|
const handleBlur = () => scheduleHide(el);
|
|
385
|
-
// Add event listeners
|
|
386
260
|
anchor.addEventListener('mouseenter', handleEnter);
|
|
387
261
|
anchor.addEventListener('mouseleave', handleLeave);
|
|
388
262
|
anchor.addEventListener('focusin', handleFocus);
|
|
389
263
|
anchor.addEventListener('focusout', handleBlur);
|
|
390
|
-
// Store cleanup function
|
|
391
264
|
eventCleanup.set(el, () => {
|
|
392
265
|
anchor.removeEventListener('mouseenter', handleEnter);
|
|
393
266
|
anchor.removeEventListener('mouseleave', handleLeave);
|
|
@@ -395,9 +268,6 @@ function setupEvents(el) {
|
|
|
395
268
|
anchor.removeEventListener('focusout', handleBlur);
|
|
396
269
|
});
|
|
397
270
|
}
|
|
398
|
-
/**
|
|
399
|
-
* Cleanup all resources including popover element
|
|
400
|
-
*/
|
|
401
271
|
function cleanup(el) {
|
|
402
272
|
clearTimeouts(el);
|
|
403
273
|
cleanupAutoUpdate(el);
|
|
@@ -406,9 +276,6 @@ function cleanup(el) {
|
|
|
406
276
|
eventsCleanup();
|
|
407
277
|
eventCleanup.delete(el);
|
|
408
278
|
}
|
|
409
|
-
// Strip aria-describedby before removing the popover it points at — by
|
|
410
|
-
// this point (disconnectedCallback) el.parentElement is already null, so
|
|
411
|
-
// this must use the cached anchor, not getAnchorElement(el).
|
|
412
279
|
const popover = popoverElements.get(el);
|
|
413
280
|
const anchor = anchorElements.get(el);
|
|
414
281
|
if (popover && anchor) {
|
|
@@ -421,43 +288,25 @@ function cleanup(el) {
|
|
|
421
288
|
anchorElements.delete(el);
|
|
422
289
|
timeoutState.delete(el);
|
|
423
290
|
}
|
|
424
|
-
// ============================================================================
|
|
425
|
-
// Component Definition
|
|
426
|
-
// ============================================================================
|
|
427
|
-
/**
|
|
428
|
-
* TyTooltip Web Component
|
|
429
|
-
*/
|
|
430
291
|
export class TyTooltip extends HTMLElement {
|
|
431
|
-
/** Observed attributes */
|
|
432
292
|
static get observedAttributes() {
|
|
433
293
|
return ['placement', 'offset', 'delay', 'disabled', 'flavor'];
|
|
434
294
|
}
|
|
435
295
|
constructor() {
|
|
436
296
|
super();
|
|
437
|
-
/** Internal open state */
|
|
438
297
|
this._open = false;
|
|
439
298
|
this.attachShadow({ mode: 'open' });
|
|
440
299
|
}
|
|
441
300
|
connectedCallback() {
|
|
442
|
-
// Initialize open state
|
|
443
301
|
this._open = false;
|
|
444
|
-
// Inject styles (for :host display: contents)
|
|
445
302
|
ensureStyles(this.shadowRoot, tooltipStyles);
|
|
446
|
-
// Setup events on anchor
|
|
447
303
|
setupEvents(this);
|
|
448
|
-
// Eagerly create the (hidden) popover so role="tooltip" + the anchor's
|
|
449
|
-
// aria-describedby exist from connect, not only after the first show —
|
|
450
|
-
// a keyboard user tabbing to the trigger must not wait out the hover
|
|
451
|
-
// delay just to get an accessible description.
|
|
452
304
|
getOrCreatePopover(this);
|
|
453
305
|
}
|
|
454
306
|
disconnectedCallback() {
|
|
455
307
|
cleanup(this);
|
|
456
308
|
}
|
|
457
309
|
attributeChangedCallback(name, _oldValue, newValue) {
|
|
458
|
-
// Restyle the popover on flavor change even while hidden — it's cached
|
|
459
|
-
// in popoverElements once created, so a change made while closed would
|
|
460
|
-
// otherwise be silently lost until the element is torn down.
|
|
461
310
|
if (name === 'flavor') {
|
|
462
311
|
const popover = popoverElements.get(this);
|
|
463
312
|
if (popover) {
|
|
@@ -465,14 +314,11 @@ export class TyTooltip extends HTMLElement {
|
|
|
465
314
|
applyFlavorStyles(popover, flavor);
|
|
466
315
|
}
|
|
467
316
|
}
|
|
468
|
-
// Close tooltip if disabled
|
|
469
317
|
if (name === 'disabled' && newValue !== null) {
|
|
470
318
|
hideTooltip(this);
|
|
471
319
|
}
|
|
472
320
|
}
|
|
473
321
|
}
|
|
474
|
-
// Register the custom element
|
|
475
322
|
if (!customElements.get('ty-tooltip')) {
|
|
476
323
|
customElements.define('ty-tooltip', TyTooltip);
|
|
477
324
|
}
|
|
478
|
-
//# sourceMappingURL=tooltip.js.map
|
|
@@ -1,56 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Wizard Component
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* Behaves like tabs - a "dumb" component that only renders and fires events. All navigation and validation
|
|
7
|
-
* is controlled by the user.
|
|
8
|
-
*
|
|
9
|
-
* Features:
|
|
10
|
-
* - Carousel animation with smooth sliding transitions between steps
|
|
11
|
-
* - Fixed dimensions prevent layout shift between steps
|
|
12
|
-
* - Animated progress line showing completion status
|
|
13
|
-
* - Step indicators with completed/active/pending states
|
|
14
|
-
* - Rich indicator support via slots (icons, custom content)
|
|
15
|
-
* - Independent panel scrolling with scroll position reset
|
|
16
|
-
* - ResizeObserver for responsive percentage widths
|
|
17
|
-
* - Smart rendering - only updates DOM when necessary
|
|
18
|
-
* - Accessibility with ARIA roles and attributes
|
|
19
|
-
* - Fires events on step clicks - user controls navigation
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* <!-- Basic wizard with text labels -->
|
|
23
|
-
* <ty-wizard width="900px" height="600px" active="welcome">
|
|
24
|
-
* <ty-step id="welcome" label="Welcome">
|
|
25
|
-
* <div class="p-6">
|
|
26
|
-
* <h1>Welcome!</h1>
|
|
27
|
-
* <button onclick="goToStep('account')">Next</button>
|
|
28
|
-
* </div>
|
|
29
|
-
* </ty-step>
|
|
30
|
-
* <ty-step id="account" label="Account Setup">
|
|
31
|
-
* <div class="p-6">
|
|
32
|
-
* <h2>Account Setup</h2>
|
|
33
|
-
* <button onclick="goToStep('welcome')">Previous</button>
|
|
34
|
-
* <button onclick="goToStep('complete')">Next</button>
|
|
35
|
-
* </div>
|
|
36
|
-
* </ty-step>
|
|
37
|
-
* </ty-wizard>
|
|
38
|
-
*
|
|
39
|
-
* @example
|
|
40
|
-
* <!-- Wizard with custom indicators -->
|
|
41
|
-
* <ty-wizard width="100%" height="700px" active="welcome" completed="welcome,account">
|
|
42
|
-
* <!-- Custom indicator icons -->
|
|
43
|
-
* <div slot="indicator-welcome">
|
|
44
|
-
* <ty-icon name="hand" size="sm"></ty-icon>
|
|
45
|
-
* </div>
|
|
46
|
-
* <div slot="indicator-account">
|
|
47
|
-
* <span class="text-lg font-bold">1</span>
|
|
48
|
-
* </div>
|
|
49
|
-
*
|
|
50
|
-
* <ty-step id="welcome" label="Welcome">...</ty-step>
|
|
51
|
-
* <ty-step id="account" label="Account">...</ty-step>
|
|
52
|
-
* <ty-step id="profile" label="Profile">...</ty-step>
|
|
53
|
-
* </ty-wizard>
|
|
2
|
+
* Wizard Component — carousel-based stepper with sliding transitions, an
|
|
3
|
+
* animated progress line, and step completion tracking. Expects `ty-step`
|
|
4
|
+
* children. "Dumb" like ty-tabs: it renders and fires events; all navigation
|
|
5
|
+
* and validation is the consumer's.
|
|
54
6
|
*/
|
|
55
7
|
/**
|
|
56
8
|
* Wizard container attributes configuration
|
|
@@ -76,11 +28,9 @@ export interface WizardStepChangeDetail {
|
|
|
76
28
|
* TyWizard Web Component
|
|
77
29
|
*/
|
|
78
30
|
export declare class TyWizard extends HTMLElement {
|
|
79
|
-
/** Observed attributes */
|
|
80
31
|
static get observedAttributes(): string[];
|
|
81
32
|
constructor();
|
|
82
33
|
connectedCallback(): void;
|
|
83
34
|
disconnectedCallback(): void;
|
|
84
35
|
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
85
36
|
}
|
|
86
|
-
//# sourceMappingURL=wizard.d.ts.map
|