@brightspot/ui 1.4.1 → 1.5.0
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 +12 -0
- package/dist/components/avatar/Avatar.d.ts +1 -1
- package/dist/components/avatar/Avatar.d.ts.map +1 -1
- package/dist/components/avatar/Avatar.js +3 -1
- package/dist/components/avatar/Avatar.js.map +1 -1
- package/dist/components/popover/Popover.d.ts +161 -0
- package/dist/components/popover/Popover.d.ts.map +1 -0
- package/dist/components/popover/Popover.js +436 -0
- package/dist/components/popover/Popover.js.map +1 -0
- package/dist/components/widget/Widget.css +104 -0
- package/dist/components/widget/Widget.d.ts +170 -0
- package/dist/components/widget/Widget.d.ts.map +1 -0
- package/dist/components/widget/Widget.js +434 -0
- package/dist/components/widget/Widget.js.map +1 -0
- package/dist/custom-elements.json +687 -184
- package/dist/global.d.ts +5 -0
- package/dist/storybook/assets/{Avatar.stories-QxWs-YfX.js → Avatar.stories-CPVNxsaA.js} +37 -32
- package/dist/storybook/assets/AvatarGroup.stories-Bl65NGHl.js +225 -0
- package/dist/storybook/assets/{Badge.stories-BpaApWbR.js → Badge.stories-Bbnc6fRy.js} +1 -1
- package/dist/storybook/assets/{Button.stories-C5h2usmd.js → Button.stories-CRJ5n2y4.js} +1 -1
- package/dist/storybook/assets/{CircularProgress.stories-DlPOiGja.js → CircularProgress.stories-D9vBj3JJ.js} +1 -1
- package/dist/storybook/assets/{ClipboardMixin.stories-Bb45-UOM.js → ClipboardMixin.stories-Dm-Jm4yb.js} +7 -7
- package/dist/storybook/assets/Color-6BZIO3FS-BcNIJY1U.js +1 -0
- package/dist/storybook/assets/{Colors.stories-DP2JKWUJ.js → Colors.stories-B9_090wL.js} +1 -1
- package/dist/storybook/assets/ComponentStatesMixin-ChiFBCuo.js +1 -0
- package/dist/storybook/assets/{ComponentStatesMixin.stories-CyQ2aSTu.js → ComponentStatesMixin.stories-DHv9MHmE.js} +3 -3
- package/dist/storybook/assets/{CopyToClipboard.stories-DR7pckeV.js → CopyToClipboard.stories-gtJlTP1l.js} +1 -1
- package/dist/storybook/assets/{Debounce.stories-hkqyvqmg.js → Debounce.stories-BBNX7mJA.js} +1 -1
- package/dist/storybook/assets/{DocsRenderer-LL677BLK-Dtw9GMer.js → DocsRenderer-LL677BLK-D-E99pXl.js} +6 -6
- package/dist/storybook/assets/{Events.stories-BAgDzdyl.js → Events.stories-DDmydlh_.js} +1 -1
- package/dist/storybook/assets/{Heading.stories-CN_fPsRf.js → Heading.stories-BLGfko-i.js} +1 -1
- package/dist/storybook/assets/{Icon.stories-CSx_2K8V.js → Icon.stories-BHnAGcFF.js} +1 -1
- package/dist/storybook/assets/{LinearProgress.stories-In48DY2g.js → LinearProgress.stories-Dx26a0P_.js} +1 -1
- package/dist/storybook/assets/Popover.stories-CbqpY6YR.js +431 -0
- package/dist/storybook/assets/ReadyMixin-BHiHoIbr.js +1 -0
- package/dist/storybook/assets/{Rtc.stories-19d7WXe4.js → Rtc.stories-CAjDv_Ub.js} +1 -1
- package/dist/storybook/assets/{ScrollShadow.stories-BFjracVd.js → ScrollShadow.stories-BSV4U-tq.js} +1 -1
- package/dist/storybook/assets/{Throttle.stories-DD6ydiVq.js → Throttle.stories-kaxXQ8RZ.js} +1 -1
- package/dist/storybook/assets/Tooltip.stories-CsxXkztr.js +143 -0
- package/dist/storybook/assets/Widget.stories-DqATHnSq.js +233 -0
- package/dist/storybook/assets/{WithTooltip-65CFNBJE-Be1dKqOF.js → WithTooltip-65CFNBJE-BtbbFYSA.js} +2 -2
- package/dist/storybook/assets/custom-element-UsVr97OX.js +1 -0
- package/dist/storybook/assets/{formatter-EIJCOSYU-anC2P5HS.js → formatter-EIJCOSYU-C87Csnpu.js} +1 -1
- package/dist/storybook/assets/if-defined-COHr0XBn.js +1 -0
- package/dist/storybook/assets/{iframe-B4njXYq6.css → iframe-BkDGeDre.css} +1 -1
- package/dist/storybook/assets/{iframe-Bl9oHz5c.js → iframe-CcloOV09.js} +77 -77
- package/dist/storybook/assets/{index-Cn5E5A3G.js → index-DP7vnJf7.js} +1 -1
- package/dist/storybook/assets/{onFind.stories-BMDLUk0l.js → onFind.stories-BxvoC-Z-.js} +1 -1
- package/dist/storybook/assets/{onRemove.stories-C3FcxtYh.js → onRemove.stories-Dwoixzb0.js} +1 -1
- package/dist/storybook/assets/{onVisible.stories-B8Zyu0Th.js → onVisible.stories-CinmRF9w.js} +1 -1
- package/dist/storybook/assets/{syntaxhighlighter-ED5Y7EFY-BfTKsIVL.js → syntaxhighlighter-ED5Y7EFY-BHLkDkOn.js} +1 -1
- package/dist/storybook/iframe.html +2 -2
- package/dist/storybook/index.json +1 -1
- package/dist/storybook/project.json +1 -1
- package/dist/tailwind-plugin-popover.d.ts +2 -0
- package/dist/tailwind-plugin-popover.d.ts.map +1 -0
- package/dist/tailwind-plugin-popover.js +177 -0
- package/dist/tailwind-plugin-popover.js.map +1 -0
- package/dist/tailwind-plugin-popover.ts +202 -0
- package/dist/tailwind-plugin-tooltip.d.ts +2 -0
- package/dist/tailwind-plugin-tooltip.d.ts.map +1 -0
- package/dist/tailwind-plugin-tooltip.js +184 -0
- package/dist/tailwind-plugin-tooltip.js.map +1 -0
- package/dist/tailwind-plugin-tooltip.ts +209 -0
- package/dist/util/EventEmitterMixin.d.ts +11 -0
- package/dist/util/EventEmitterMixin.d.ts.map +1 -1
- package/dist/util/EventEmitterMixin.js +1 -1
- package/dist/util/EventEmitterMixin.js.map +1 -1
- package/dist/util/TooltipController.d.ts +37 -0
- package/dist/util/TooltipController.d.ts.map +1 -0
- package/dist/util/TooltipController.js +133 -0
- package/dist/util/TooltipController.js.map +1 -0
- package/dist/util/TooltipMixin.d.ts +42 -0
- package/dist/util/TooltipMixin.d.ts.map +1 -0
- package/dist/util/TooltipMixin.js +401 -0
- package/dist/util/TooltipMixin.js.map +1 -0
- package/package.json +1 -1
- package/dist/storybook/assets/AvatarGroup.stories-Cy_Bvn7E.js +0 -211
- package/dist/storybook/assets/Color-6BZIO3FS-CcgGYVAo.js +0 -1
- package/dist/storybook/assets/ComponentStatesMixin-B7ci0thi.js +0 -1
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import plugin from 'tailwindcss/plugin';
|
|
2
|
+
/**
|
|
3
|
+
* Tooltip plugin using CSS anchor positioning and the native Popover API.
|
|
4
|
+
*
|
|
5
|
+
* Uses the HTML popover attribute for top-layer rendering. Animations use
|
|
6
|
+
* @starting-style for entry and transition-behavior: allow-discrete for exit.
|
|
7
|
+
*
|
|
8
|
+
* Class Names:
|
|
9
|
+
*
|
|
10
|
+
* btu-tooltip - Base tooltip styles (hidden by default via popover)
|
|
11
|
+
* btu-tooltip-top - Position above trigger (default)
|
|
12
|
+
* btu-tooltip-bottom - Position below trigger
|
|
13
|
+
* btu-tooltip-left - Position left of trigger
|
|
14
|
+
* btu-tooltip-right - Position right of trigger
|
|
15
|
+
* btu-tooltip-no-arrow - Hide the arrow pseudo-element
|
|
16
|
+
*
|
|
17
|
+
* Offset Sizes:
|
|
18
|
+
*
|
|
19
|
+
* btu-tooltip-offset-sm - 4px offset
|
|
20
|
+
* btu-tooltip-offset-md - 8px offset (same as default)
|
|
21
|
+
* btu-tooltip-offset-lg - 12px offset
|
|
22
|
+
* btu-tooltip-offset-xl - 16px offset
|
|
23
|
+
*
|
|
24
|
+
* CSS Custom Properties:
|
|
25
|
+
*
|
|
26
|
+
* --tooltip-color-background - Background color (default: var(--btu-theme-white, #fff))
|
|
27
|
+
* --tooltip-color-text - Text color (default: oklch(var(--btu-theme-gray-900)))
|
|
28
|
+
* --tooltip-border-radius - Border radius (default: theme borderRadius.lg)
|
|
29
|
+
*/
|
|
30
|
+
module.exports = plugin(function ({ addComponents, theme, config }) {
|
|
31
|
+
addComponents({
|
|
32
|
+
// Base tooltip styles — exit state (applied when closing, before display:none)
|
|
33
|
+
'.btu-tooltip': {
|
|
34
|
+
// Structural custom properties — kept as declarations since they're
|
|
35
|
+
// controlled by component props, not external CSS on parent elements.
|
|
36
|
+
'--tooltip-offset': '8px',
|
|
37
|
+
'--tooltip-arrow-size': '8px',
|
|
38
|
+
padding: '8px 12px',
|
|
39
|
+
backgroundColor: 'var(--tooltip-color-background, var(--btu-theme-white, #fff))',
|
|
40
|
+
color: `var(--tooltip-color-text, oklch(var(--btu-theme-gray-900)))`,
|
|
41
|
+
borderRadius: `var(--tooltip-border-radius, ${theme('borderRadius.lg')})`,
|
|
42
|
+
boxShadow: theme('boxShadow.lg'),
|
|
43
|
+
// theme('fontSize.xs') returns only the size string; config() gives the raw tuple
|
|
44
|
+
fontSize: config('theme.fontSize.xs')?.[0] ?? '0.75rem',
|
|
45
|
+
lineHeight: config('theme.fontSize.xs')?.[1] ?? '1.125rem',
|
|
46
|
+
fontWeight: '500',
|
|
47
|
+
whiteSpace: 'nowrap',
|
|
48
|
+
textAlign: 'left',
|
|
49
|
+
pointerEvents: 'none',
|
|
50
|
+
overflow: 'visible',
|
|
51
|
+
isolation: 'isolate',
|
|
52
|
+
margin: '0',
|
|
53
|
+
inset: 'unset',
|
|
54
|
+
border: 'none',
|
|
55
|
+
opacity: '0',
|
|
56
|
+
translate: '0 0',
|
|
57
|
+
transition: 'opacity 150ms ease, translate 150ms ease, display 150ms ease allow-discrete, overlay 150ms ease allow-discrete',
|
|
58
|
+
'position-visibility': 'anchors-visible',
|
|
59
|
+
// Native popover reset — browser defaults override otherwise
|
|
60
|
+
'&:popover-open': {
|
|
61
|
+
overflow: 'visible',
|
|
62
|
+
opacity: '1',
|
|
63
|
+
translate: '0 0',
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
// Position: top (default)
|
|
67
|
+
// Gap via inset `bottom`; margin-top drives the arrow flip via `margin: inherit`
|
|
68
|
+
'.btu-tooltip-top': {
|
|
69
|
+
'position-area': 'top',
|
|
70
|
+
bottom: 'var(--tooltip-offset)',
|
|
71
|
+
marginTop: 'var(--tooltip-offset)',
|
|
72
|
+
'position-try-fallbacks': 'flip-block',
|
|
73
|
+
translate: '0 4px',
|
|
74
|
+
'&:popover-open': {
|
|
75
|
+
translate: '0 0',
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
// Position: bottom
|
|
79
|
+
// Gap via inset `top`; margin-bottom drives the arrow flip
|
|
80
|
+
'.btu-tooltip-bottom': {
|
|
81
|
+
'position-area': 'bottom',
|
|
82
|
+
top: 'var(--tooltip-offset)',
|
|
83
|
+
marginBottom: 'var(--tooltip-offset)',
|
|
84
|
+
'position-try-fallbacks': 'flip-block',
|
|
85
|
+
translate: '0 -4px',
|
|
86
|
+
'&:popover-open': {
|
|
87
|
+
translate: '0 0',
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
// Position: left
|
|
91
|
+
// Gap via inset `right`; margin-left drives the arrow flip
|
|
92
|
+
'.btu-tooltip-left': {
|
|
93
|
+
'position-area': 'left',
|
|
94
|
+
right: 'var(--tooltip-offset)',
|
|
95
|
+
marginLeft: 'var(--tooltip-offset)',
|
|
96
|
+
'position-try-fallbacks': 'flip-inline',
|
|
97
|
+
translate: '4px 0',
|
|
98
|
+
'&:popover-open': {
|
|
99
|
+
translate: '0 0',
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
// Position: right
|
|
103
|
+
// Gap via inset `left`; margin-right drives the arrow flip
|
|
104
|
+
'.btu-tooltip-right': {
|
|
105
|
+
'position-area': 'right',
|
|
106
|
+
left: 'var(--tooltip-offset)',
|
|
107
|
+
marginRight: 'var(--tooltip-offset)',
|
|
108
|
+
'position-try-fallbacks': 'flip-inline',
|
|
109
|
+
translate: '-4px 0',
|
|
110
|
+
'&:popover-open': {
|
|
111
|
+
translate: '0 0',
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
// Offset sizes
|
|
115
|
+
'.btu-tooltip-offset-sm': { '--tooltip-offset': '4px' },
|
|
116
|
+
'.btu-tooltip-offset-md': { '--tooltip-offset': '8px' },
|
|
117
|
+
'.btu-tooltip-offset-lg': { '--tooltip-offset': '12px' },
|
|
118
|
+
'.btu-tooltip-offset-xl': { '--tooltip-offset': '16px' },
|
|
119
|
+
// @starting-style for entry animations
|
|
120
|
+
'@starting-style': {
|
|
121
|
+
'.btu-tooltip:popover-open': {
|
|
122
|
+
opacity: '0',
|
|
123
|
+
},
|
|
124
|
+
'.btu-tooltip-top:popover-open': {
|
|
125
|
+
translate: '0 4px',
|
|
126
|
+
},
|
|
127
|
+
'.btu-tooltip-bottom:popover-open': {
|
|
128
|
+
translate: '0 -4px',
|
|
129
|
+
},
|
|
130
|
+
'.btu-tooltip-left:popover-open': {
|
|
131
|
+
translate: '4px 0',
|
|
132
|
+
},
|
|
133
|
+
'.btu-tooltip-right:popover-open': {
|
|
134
|
+
translate: '-4px 0',
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
// Arrow for vertical tooltips (top/bottom).
|
|
138
|
+
// Extends beyond both tooltip edges via negative inset. A hexagonal
|
|
139
|
+
// clip-path creates arrow tips on both ends; margin: inherit auto-flips
|
|
140
|
+
// the visible tip when position-try-fallbacks: flip-block activates.
|
|
141
|
+
// See: https://frontendmasters.com/blog/perfectly-pointed-tooltips-a-foundation/
|
|
142
|
+
// Arrow for vertical tooltips (top/bottom).
|
|
143
|
+
// Centered at 50% of the tooltip panel. This aligns with the trigger center
|
|
144
|
+
// because position-area centers the tooltip on the anchor element.
|
|
145
|
+
'.btu-tooltip-top::before, .btu-tooltip-bottom::before': {
|
|
146
|
+
content: '""',
|
|
147
|
+
position: 'absolute',
|
|
148
|
+
zIndex: '-1',
|
|
149
|
+
width: 'var(--tooltip-arrow-size)',
|
|
150
|
+
top: 'calc(-1 * var(--tooltip-offset))',
|
|
151
|
+
bottom: 'calc(-1 * var(--tooltip-offset))',
|
|
152
|
+
left: 'calc(50% - var(--tooltip-arrow-size) / 2)',
|
|
153
|
+
clipPath: 'polygon(50% calc(var(--tooltip-offset) - var(--tooltip-arrow-size)), 100% var(--tooltip-offset), 100% calc(100% - var(--tooltip-offset)), 50% calc(100% - var(--tooltip-offset) + var(--tooltip-arrow-size)), 0 calc(100% - var(--tooltip-offset)), 0 var(--tooltip-offset))',
|
|
154
|
+
background: 'inherit',
|
|
155
|
+
margin: 'inherit',
|
|
156
|
+
},
|
|
157
|
+
// Arrow for horizontal tooltips (left/right).
|
|
158
|
+
// Same technique rotated 90° for flip-inline.
|
|
159
|
+
'.btu-tooltip-left::before, .btu-tooltip-right::before': {
|
|
160
|
+
content: '""',
|
|
161
|
+
position: 'absolute',
|
|
162
|
+
zIndex: '-1',
|
|
163
|
+
height: 'var(--tooltip-arrow-size)',
|
|
164
|
+
left: 'calc(-1 * var(--tooltip-offset))',
|
|
165
|
+
right: 'calc(-1 * var(--tooltip-offset))',
|
|
166
|
+
top: 'calc(50% - var(--tooltip-arrow-size) / 2)',
|
|
167
|
+
clipPath: 'polygon(calc(var(--tooltip-offset) - var(--tooltip-arrow-size)) 50%, var(--tooltip-offset) 0, calc(100% - var(--tooltip-offset)) 0, calc(100% - var(--tooltip-offset) + var(--tooltip-arrow-size)) 50%, calc(100% - var(--tooltip-offset)) 100%, var(--tooltip-offset) 100%)',
|
|
168
|
+
background: 'inherit',
|
|
169
|
+
margin: 'inherit',
|
|
170
|
+
},
|
|
171
|
+
// Hide arrow when opted out
|
|
172
|
+
'.btu-tooltip-no-arrow::before': {
|
|
173
|
+
content: 'none',
|
|
174
|
+
},
|
|
175
|
+
// Reduced motion: disable translate animation, keep opacity fade
|
|
176
|
+
'@media (prefers-reduced-motion: reduce)': {
|
|
177
|
+
'.btu-tooltip': {
|
|
178
|
+
translate: 'none !important',
|
|
179
|
+
transition: 'opacity 150ms ease, display 150ms ease allow-discrete, overlay 150ms ease allow-discrete',
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
//# sourceMappingURL=tailwind-plugin-tooltip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tailwind-plugin-tooltip.js","sourceRoot":"","sources":["../src/tailwind-plug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C,SAAS,EAAE,QAAQ;aACpB;YACD,gCAAgC,EAAE;gBAChC,SAAS,EAAE,OAAO;aACnB;YACD,iCAAiC,EAAE;gBACjC,SAAS,EAAE,QAAQ;aACpB;SACF;QAED,4CAA4C;QAC5C,oEAAoE;QACpE,wEAAwE;QACxE,qEAAqE;QACrE,iFAAiF;QACjF,4CAA4C;QAC5C,4EAA4E;QAC5E,mEAAmE;QACnE,uDAAuD,EAAE;YACvD,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,UAAU;YACpB,MAAM,EAAE,IAAI;YACZ,KAAK,EAAE,2BAA2B;YAClC,GAAG,EAAE,kCAAkC;YACvC,MAAM,EAAE,kCAAkC;YAC1C,IAAI,EAAE,2CAA2C;YACjD,QAAQ,EACN,8QAA8Q;YAChR,UAAU,EAAE,SAAS;YACrB,MAAM,EAAE,SAAS;SAClB;QAED,8CAA8C;QAC9C,8CAA8C;QAC9C,uDAAuD,EAAE;YACvD,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,UAAU;YACpB,MAAM,EAAE,IAAI;YACZ,MAAM,EAAE,2BAA2B;YACnC,IAAI,EAAE,kCAAkC;YACxC,KAAK,EAAE,kCAAkC;YACzC,GAAG,EAAE,2CAA2C;YAChD,QAAQ,EACN,8QAA8Q;YAChR,UAAU,EAAE,SAAS;YACrB,MAAM,EAAE,SAAS;SAClB;QAED,4BAA4B;QAC5B,+BAA+B,EAAE;YAC/B,OAAO,EAAE,MAAM;SAChB;QAED,iEAAiE;QACjE,yCAAyC,EAAE;YACzC,cAAc,EAAE;gBACd,SAAS,EAAE,iBAAiB;gBAC5B,UAAU,EAAE,0FAA0F;aACvG;SACF;KACF,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import plugin from 'tailwindcss/plugin'
|
|
2
|
+
declare let module: any
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Tooltip plugin using CSS anchor positioning and the native Popover API.
|
|
6
|
+
*
|
|
7
|
+
* Uses the HTML popover attribute for top-layer rendering. Animations use
|
|
8
|
+
* @starting-style for entry and transition-behavior: allow-discrete for exit.
|
|
9
|
+
*
|
|
10
|
+
* Class Names:
|
|
11
|
+
*
|
|
12
|
+
* btu-tooltip - Base tooltip styles (hidden by default via popover)
|
|
13
|
+
* btu-tooltip-top - Position above trigger (default)
|
|
14
|
+
* btu-tooltip-bottom - Position below trigger
|
|
15
|
+
* btu-tooltip-left - Position left of trigger
|
|
16
|
+
* btu-tooltip-right - Position right of trigger
|
|
17
|
+
* btu-tooltip-no-arrow - Hide the arrow pseudo-element
|
|
18
|
+
*
|
|
19
|
+
* Offset Sizes:
|
|
20
|
+
*
|
|
21
|
+
* btu-tooltip-offset-sm - 4px offset
|
|
22
|
+
* btu-tooltip-offset-md - 8px offset (same as default)
|
|
23
|
+
* btu-tooltip-offset-lg - 12px offset
|
|
24
|
+
* btu-tooltip-offset-xl - 16px offset
|
|
25
|
+
*
|
|
26
|
+
* CSS Custom Properties:
|
|
27
|
+
*
|
|
28
|
+
* --tooltip-color-background - Background color (default: var(--btu-theme-white, #fff))
|
|
29
|
+
* --tooltip-color-text - Text color (default: oklch(var(--btu-theme-gray-900)))
|
|
30
|
+
* --tooltip-border-radius - Border radius (default: theme borderRadius.lg)
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
module.exports = plugin(function ({ addComponents, theme, config }) {
|
|
34
|
+
addComponents({
|
|
35
|
+
// Base tooltip styles — exit state (applied when closing, before display:none)
|
|
36
|
+
'.btu-tooltip': {
|
|
37
|
+
// Structural custom properties — kept as declarations since they're
|
|
38
|
+
// controlled by component props, not external CSS on parent elements.
|
|
39
|
+
'--tooltip-offset': '8px',
|
|
40
|
+
'--tooltip-arrow-size': '8px',
|
|
41
|
+
|
|
42
|
+
padding: '8px 12px',
|
|
43
|
+
|
|
44
|
+
backgroundColor: 'var(--tooltip-color-background, var(--btu-theme-white, #fff))',
|
|
45
|
+
color: `var(--tooltip-color-text, oklch(var(--btu-theme-gray-900)))`,
|
|
46
|
+
borderRadius: `var(--tooltip-border-radius, ${theme('borderRadius.lg')})`,
|
|
47
|
+
boxShadow: theme('boxShadow.lg'),
|
|
48
|
+
|
|
49
|
+
// theme('fontSize.xs') returns only the size string; config() gives the raw tuple
|
|
50
|
+
fontSize: config('theme.fontSize.xs')?.[0] ?? '0.75rem',
|
|
51
|
+
lineHeight: config('theme.fontSize.xs')?.[1] ?? '1.125rem',
|
|
52
|
+
fontWeight: '500',
|
|
53
|
+
whiteSpace: 'nowrap',
|
|
54
|
+
textAlign: 'left',
|
|
55
|
+
|
|
56
|
+
pointerEvents: 'none',
|
|
57
|
+
overflow: 'visible',
|
|
58
|
+
isolation: 'isolate',
|
|
59
|
+
margin: '0',
|
|
60
|
+
inset: 'unset',
|
|
61
|
+
border: 'none',
|
|
62
|
+
opacity: '0',
|
|
63
|
+
translate: '0 0',
|
|
64
|
+
transition:
|
|
65
|
+
'opacity 150ms ease, translate 150ms ease, display 150ms ease allow-discrete, overlay 150ms ease allow-discrete',
|
|
66
|
+
|
|
67
|
+
'position-visibility': 'anchors-visible',
|
|
68
|
+
|
|
69
|
+
// Native popover reset — browser defaults override otherwise
|
|
70
|
+
'&:popover-open': {
|
|
71
|
+
overflow: 'visible',
|
|
72
|
+
opacity: '1',
|
|
73
|
+
translate: '0 0',
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
// Position: top (default)
|
|
78
|
+
// Gap via inset `bottom`; margin-top drives the arrow flip via `margin: inherit`
|
|
79
|
+
'.btu-tooltip-top': {
|
|
80
|
+
'position-area': 'top',
|
|
81
|
+
bottom: 'var(--tooltip-offset)',
|
|
82
|
+
marginTop: 'var(--tooltip-offset)',
|
|
83
|
+
'position-try-fallbacks': 'flip-block',
|
|
84
|
+
translate: '0 4px',
|
|
85
|
+
|
|
86
|
+
'&:popover-open': {
|
|
87
|
+
translate: '0 0',
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
// Position: bottom
|
|
92
|
+
// Gap via inset `top`; margin-bottom drives the arrow flip
|
|
93
|
+
'.btu-tooltip-bottom': {
|
|
94
|
+
'position-area': 'bottom',
|
|
95
|
+
top: 'var(--tooltip-offset)',
|
|
96
|
+
marginBottom: 'var(--tooltip-offset)',
|
|
97
|
+
'position-try-fallbacks': 'flip-block',
|
|
98
|
+
translate: '0 -4px',
|
|
99
|
+
|
|
100
|
+
'&:popover-open': {
|
|
101
|
+
translate: '0 0',
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
// Position: left
|
|
106
|
+
// Gap via inset `right`; margin-left drives the arrow flip
|
|
107
|
+
'.btu-tooltip-left': {
|
|
108
|
+
'position-area': 'left',
|
|
109
|
+
right: 'var(--tooltip-offset)',
|
|
110
|
+
marginLeft: 'var(--tooltip-offset)',
|
|
111
|
+
'position-try-fallbacks': 'flip-inline',
|
|
112
|
+
translate: '4px 0',
|
|
113
|
+
|
|
114
|
+
'&:popover-open': {
|
|
115
|
+
translate: '0 0',
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
|
|
119
|
+
// Position: right
|
|
120
|
+
// Gap via inset `left`; margin-right drives the arrow flip
|
|
121
|
+
'.btu-tooltip-right': {
|
|
122
|
+
'position-area': 'right',
|
|
123
|
+
left: 'var(--tooltip-offset)',
|
|
124
|
+
marginRight: 'var(--tooltip-offset)',
|
|
125
|
+
'position-try-fallbacks': 'flip-inline',
|
|
126
|
+
translate: '-4px 0',
|
|
127
|
+
|
|
128
|
+
'&:popover-open': {
|
|
129
|
+
translate: '0 0',
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
|
|
133
|
+
// Offset sizes
|
|
134
|
+
'.btu-tooltip-offset-sm': { '--tooltip-offset': '4px' },
|
|
135
|
+
'.btu-tooltip-offset-md': { '--tooltip-offset': '8px' },
|
|
136
|
+
'.btu-tooltip-offset-lg': { '--tooltip-offset': '12px' },
|
|
137
|
+
'.btu-tooltip-offset-xl': { '--tooltip-offset': '16px' },
|
|
138
|
+
|
|
139
|
+
// @starting-style for entry animations
|
|
140
|
+
'@starting-style': {
|
|
141
|
+
'.btu-tooltip:popover-open': {
|
|
142
|
+
opacity: '0',
|
|
143
|
+
},
|
|
144
|
+
'.btu-tooltip-top:popover-open': {
|
|
145
|
+
translate: '0 4px',
|
|
146
|
+
},
|
|
147
|
+
'.btu-tooltip-bottom:popover-open': {
|
|
148
|
+
translate: '0 -4px',
|
|
149
|
+
},
|
|
150
|
+
'.btu-tooltip-left:popover-open': {
|
|
151
|
+
translate: '4px 0',
|
|
152
|
+
},
|
|
153
|
+
'.btu-tooltip-right:popover-open': {
|
|
154
|
+
translate: '-4px 0',
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
|
|
158
|
+
// Arrow for vertical tooltips (top/bottom).
|
|
159
|
+
// Extends beyond both tooltip edges via negative inset. A hexagonal
|
|
160
|
+
// clip-path creates arrow tips on both ends; margin: inherit auto-flips
|
|
161
|
+
// the visible tip when position-try-fallbacks: flip-block activates.
|
|
162
|
+
// See: https://frontendmasters.com/blog/perfectly-pointed-tooltips-a-foundation/
|
|
163
|
+
// Arrow for vertical tooltips (top/bottom).
|
|
164
|
+
// Centered at 50% of the tooltip panel. This aligns with the trigger center
|
|
165
|
+
// because position-area centers the tooltip on the anchor element.
|
|
166
|
+
'.btu-tooltip-top::before, .btu-tooltip-bottom::before': {
|
|
167
|
+
content: '""',
|
|
168
|
+
position: 'absolute',
|
|
169
|
+
zIndex: '-1',
|
|
170
|
+
width: 'var(--tooltip-arrow-size)',
|
|
171
|
+
top: 'calc(-1 * var(--tooltip-offset))',
|
|
172
|
+
bottom: 'calc(-1 * var(--tooltip-offset))',
|
|
173
|
+
left: 'calc(50% - var(--tooltip-arrow-size) / 2)',
|
|
174
|
+
clipPath:
|
|
175
|
+
'polygon(50% calc(var(--tooltip-offset) - var(--tooltip-arrow-size)), 100% var(--tooltip-offset), 100% calc(100% - var(--tooltip-offset)), 50% calc(100% - var(--tooltip-offset) + var(--tooltip-arrow-size)), 0 calc(100% - var(--tooltip-offset)), 0 var(--tooltip-offset))',
|
|
176
|
+
background: 'inherit',
|
|
177
|
+
margin: 'inherit',
|
|
178
|
+
},
|
|
179
|
+
|
|
180
|
+
// Arrow for horizontal tooltips (left/right).
|
|
181
|
+
// Same technique rotated 90° for flip-inline.
|
|
182
|
+
'.btu-tooltip-left::before, .btu-tooltip-right::before': {
|
|
183
|
+
content: '""',
|
|
184
|
+
position: 'absolute',
|
|
185
|
+
zIndex: '-1',
|
|
186
|
+
height: 'var(--tooltip-arrow-size)',
|
|
187
|
+
left: 'calc(-1 * var(--tooltip-offset))',
|
|
188
|
+
right: 'calc(-1 * var(--tooltip-offset))',
|
|
189
|
+
top: 'calc(50% - var(--tooltip-arrow-size) / 2)',
|
|
190
|
+
clipPath:
|
|
191
|
+
'polygon(calc(var(--tooltip-offset) - var(--tooltip-arrow-size)) 50%, var(--tooltip-offset) 0, calc(100% - var(--tooltip-offset)) 0, calc(100% - var(--tooltip-offset) + var(--tooltip-arrow-size)) 50%, calc(100% - var(--tooltip-offset)) 100%, var(--tooltip-offset) 100%)',
|
|
192
|
+
background: 'inherit',
|
|
193
|
+
margin: 'inherit',
|
|
194
|
+
},
|
|
195
|
+
|
|
196
|
+
// Hide arrow when opted out
|
|
197
|
+
'.btu-tooltip-no-arrow::before': {
|
|
198
|
+
content: 'none',
|
|
199
|
+
},
|
|
200
|
+
|
|
201
|
+
// Reduced motion: disable translate animation, keep opacity fade
|
|
202
|
+
'@media (prefers-reduced-motion: reduce)': {
|
|
203
|
+
'.btu-tooltip': {
|
|
204
|
+
translate: 'none !important',
|
|
205
|
+
transition: 'opacity 150ms ease, display 150ms ease allow-discrete, overlay 150ms ease allow-discrete',
|
|
206
|
+
},
|
|
207
|
+
},
|
|
208
|
+
})
|
|
209
|
+
})
|
|
@@ -29,6 +29,17 @@ export interface CustomEventMap {
|
|
|
29
29
|
'btu-icon-ready': CustomEvent<unknown>;
|
|
30
30
|
'btu-progress-ready': CustomEvent<unknown>;
|
|
31
31
|
'btu-progress-complete': CustomEvent<unknown>;
|
|
32
|
+
'btu-popover-show': CustomEvent<unknown>;
|
|
33
|
+
'btu-popover-hide': CustomEvent<unknown>;
|
|
34
|
+
'btu-tooltip-show': CustomEvent<unknown>;
|
|
35
|
+
'btu-tooltip-hide': CustomEvent<unknown>;
|
|
36
|
+
'btu-widget-ready': CustomEvent<unknown>;
|
|
37
|
+
'btu-widget-collapse-changed': CustomEvent<{
|
|
38
|
+
collapsed: boolean;
|
|
39
|
+
}>;
|
|
40
|
+
'btu-widget-fullscreen-changed': CustomEvent<{
|
|
41
|
+
fullscreen: boolean;
|
|
42
|
+
}>;
|
|
32
43
|
}
|
|
33
44
|
interface CombinedEventMap extends HTMLElementEventMap, CustomEventMap {
|
|
34
45
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventEmitterMixin.d.ts","sourceRoot":"","sources":["../../src/util/EventEmitterMixin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAEhC,KAAK,WAAW,CAAC,CAAC,GAAG,MAAM,IAAI,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAA;AACxD,KAAK,iBAAiB,CAAC,CAAC,IAAI,CAAC,SAAS,WAAW,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;AAEtE;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,uBAAuB,EAAE,WAAW,CAAC,OAAO,CAAC,CAAA;IAC7C,0BAA0B,EAAE,WAAW,CAAC,OAAO,CAAC,CAAA;IAChD,mBAAmB,EAAE,WAAW,CAAC;QAAE,KAAK,EAAE,KAAK,CAAA;KAAE,CAAC,CAAA;IAClD,kBAAkB,EAAE,WAAW,CAAC,OAAO,CAAC,CAAA;IACxC,yBAAyB,EAAE,WAAW,CAAC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EAAE,MAAM,CAAC,EAAE,iBAAiB,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,CAAA;IACtG,gBAAgB,CAAC,CAAC,SAAS,MAAM,gBAAgB,EAC/C,IAAI,EAAE,CAAC,EACP,QAAQ,EAAE,CAAC,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE,gBAAgB,CAAC,CAAC,CAAC,KAAK,IAAI,EAC9D,OAAO,CAAC,EAAE,OAAO,GAAG,uBAAuB,GAC1C,IAAI;IACP,mBAAmB,CAAC,CAAC,SAAS,MAAM,gBAAgB,EAClD,IAAI,EAAE,CAAC,EACP,QAAQ,EAAE,CAAC,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE,gBAAgB,CAAC,CAAC,CAAC,KAAK,IAAI,EAC9D,OAAO,CAAC,EAAE,OAAO,GAAG,oBAAoB,GACvC,IAAI;CACR;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,iBAAiB,GAAI,CAAC,SAAS,WAAW,CAAC,UAAU,CAAC,EAAE,YAAY,CAAC,KAqD/C,WAAW,CAAC,0BAA0B,CAAC,GAAG,CAC5E,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventEmitterMixin.js","sourceRoot":"","sources":["../../src/util/EventEmitterMixin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;
|
|
1
|
+
{"version":3,"file":"EventEmitterMixin.js","sourceRoot":"","sources":["../../src/util/EventEmitterMixin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAqDhC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAoC,UAAa,EAAE,EAAE;IACpF,MAAM,sBAAuB,SAAQ,UAAU;QAC7C;;;;WAIG;QACH,iBAAiB;YACf,KAAK,CAAC,iBAAiB,EAAE,CAAA;YACzB,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CACpB,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,uBAAuB,EAAE,EAAE,CAAC,EAC5C,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,EAAE,KAAK,EAAE,CAAC,CACnD,CAAA;QACH,CAAC;QAED;;;;WAIG;QACH,oBAAoB;YAClB,KAAK,CAAC,oBAAoB,EAAE,CAAA;YAC5B,IAAI,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAA;QACvC,CAAC;QAED;;;;;;;;;;;;;;;;WAgBG;QACH,IAAI,CAAiC,IAAO,EAAE,MAA6C;YACzF,OAAO,IAAI,CAAC,aAAa,CACvB,IAAI,WAAW,CAAC,IAAI,EAAE;gBACpB,OAAO,EAAE,IAAI;gBACb,UAAU,EAAE,KAAK;gBACjB,QAAQ,EAAE,IAAI;gBACd,MAAM;aACP,CAAC,CACH,CAAA;QACH,CAAC;KACF;IACD,OAAO,sBAAqE,CAAA;AAC9E,CAAC,CAAA"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { ReactiveController, ReactiveControllerHost } from 'lit';
|
|
2
|
+
export interface TooltipControllerOptions {
|
|
3
|
+
/** CSS selector to find the target element within the host */
|
|
4
|
+
target: string;
|
|
5
|
+
/** Function returning the tooltip text (re-evaluated each render) */
|
|
6
|
+
text: () => string;
|
|
7
|
+
/** Position relative to target (default: 'top') */
|
|
8
|
+
position?: 'top' | 'bottom' | 'left' | 'right';
|
|
9
|
+
/** Hide the arrow (default: false) */
|
|
10
|
+
noArrow?: boolean;
|
|
11
|
+
/** Offset size (default: null) */
|
|
12
|
+
offset?: 'sm' | 'md' | 'lg' | 'xl' | null;
|
|
13
|
+
/** Show delay in ms for hover (default: 300) */
|
|
14
|
+
delay?: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Reactive Controller that attaches tooltips to sub-elements within a LitElement.
|
|
18
|
+
* Reuses the same CSS classes, Popover API, and CSS anchor positioning as TooltipMixin.
|
|
19
|
+
*/
|
|
20
|
+
export declare class TooltipController implements ReactiveController {
|
|
21
|
+
private _host;
|
|
22
|
+
private _options;
|
|
23
|
+
private _tooltipEl;
|
|
24
|
+
private _targetEl;
|
|
25
|
+
private _anchorName;
|
|
26
|
+
private _showTimer;
|
|
27
|
+
private _ac;
|
|
28
|
+
constructor(host: ReactiveControllerHost & HTMLElement, options: TooltipControllerOptions);
|
|
29
|
+
hostUpdated(): void;
|
|
30
|
+
hostDisconnected(): void;
|
|
31
|
+
private _attach;
|
|
32
|
+
private _detach;
|
|
33
|
+
private _show;
|
|
34
|
+
private _hide;
|
|
35
|
+
private _clearShowTimer;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=TooltipController.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TooltipController.d.ts","sourceRoot":"","sources":["../../src/util/TooltipController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,KAAK,CAAA;AAErE,MAAM,WAAW,wBAAwB;IACvC,8DAA8D;IAC9D,MAAM,EAAE,MAAM,CAAA;IACd,qEAAqE;IACrE,IAAI,EAAE,MAAM,MAAM,CAAA;IAClB,mDAAmD;IACnD,QAAQ,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAA;IAC9C,sCAAsC;IACtC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,kCAAkC;IAClC,MAAM,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;IACzC,gDAAgD;IAChD,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAiBD;;;GAGG;AACH,qBAAa,iBAAkB,YAAW,kBAAkB;IAC1D,OAAO,CAAC,KAAK,CAAsC;IACnD,OAAO,CAAC,QAAQ,CAA0B;IAC1C,OAAO,CAAC,UAAU,CAA8B;IAChD,OAAO,CAAC,SAAS,CAAuB;IACxC,OAAO,CAAC,WAAW,CAAyC;IAC5D,OAAO,CAAC,UAAU,CAA6C;IAC/D,OAAO,CAAC,GAAG,CAA+B;gBAE9B,IAAI,EAAE,sBAAsB,GAAG,WAAW,EAAE,OAAO,EAAE,wBAAwB;IAMzF,WAAW,IAAI,IAAI;IAmBnB,gBAAgB,IAAI,IAAI;IAIxB,OAAO,CAAC,OAAO;IA4Cf,OAAO,CAAC,OAAO;IAqBf,OAAO,CAAC,KAAK;IAUb,OAAO,CAAC,KAAK;IAUb,OAAO,CAAC,eAAe;CAMxB"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
// Tailwind content scanning requires complete class names (no template literals).
|
|
2
|
+
const POSITION_CLASSES = {
|
|
3
|
+
top: 'btu-tooltip-top',
|
|
4
|
+
bottom: 'btu-tooltip-bottom',
|
|
5
|
+
left: 'btu-tooltip-left',
|
|
6
|
+
right: 'btu-tooltip-right',
|
|
7
|
+
};
|
|
8
|
+
const OFFSET_CLASSES = {
|
|
9
|
+
sm: 'btu-tooltip-offset-sm',
|
|
10
|
+
md: 'btu-tooltip-offset-md',
|
|
11
|
+
lg: 'btu-tooltip-offset-lg',
|
|
12
|
+
xl: 'btu-tooltip-offset-xl',
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Reactive Controller that attaches tooltips to sub-elements within a LitElement.
|
|
16
|
+
* Reuses the same CSS classes, Popover API, and CSS anchor positioning as TooltipMixin.
|
|
17
|
+
*/
|
|
18
|
+
export class TooltipController {
|
|
19
|
+
constructor(host, options) {
|
|
20
|
+
this._tooltipEl = null;
|
|
21
|
+
this._targetEl = null;
|
|
22
|
+
this._anchorName = `--btu-trigger-${crypto.randomUUID()}`;
|
|
23
|
+
this._showTimer = null;
|
|
24
|
+
this._ac = null;
|
|
25
|
+
this._host = host;
|
|
26
|
+
this._options = options;
|
|
27
|
+
host.addController(this);
|
|
28
|
+
}
|
|
29
|
+
hostUpdated() {
|
|
30
|
+
const target = this._host.querySelector(this._options.target);
|
|
31
|
+
if (target && target !== this._targetEl) {
|
|
32
|
+
this._detach();
|
|
33
|
+
this._targetEl = target;
|
|
34
|
+
this._attach();
|
|
35
|
+
}
|
|
36
|
+
else if (!target && this._targetEl) {
|
|
37
|
+
this._detach();
|
|
38
|
+
}
|
|
39
|
+
if (this._tooltipEl) {
|
|
40
|
+
const text = this._options.text();
|
|
41
|
+
if (this._tooltipEl.textContent !== text) {
|
|
42
|
+
this._tooltipEl.textContent = text;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
hostDisconnected() {
|
|
47
|
+
this._detach();
|
|
48
|
+
}
|
|
49
|
+
_attach() {
|
|
50
|
+
if (!this._targetEl)
|
|
51
|
+
return;
|
|
52
|
+
const { position = 'top', offset, noArrow, text, delay = 300 } = this._options;
|
|
53
|
+
const classes = ['btu-tooltip', POSITION_CLASSES[position]];
|
|
54
|
+
if (offset)
|
|
55
|
+
classes.push(OFFSET_CLASSES[offset]);
|
|
56
|
+
if (noArrow)
|
|
57
|
+
classes.push('btu-tooltip-no-arrow');
|
|
58
|
+
const el = document.createElement('div');
|
|
59
|
+
el.className = classes.join(' ');
|
|
60
|
+
el.setAttribute('role', 'tooltip');
|
|
61
|
+
el.setAttribute('data-tooltip-internal', '');
|
|
62
|
+
el.setAttribute('popover', 'manual');
|
|
63
|
+
el.style.setProperty('position-anchor', this._anchorName);
|
|
64
|
+
el.textContent = text();
|
|
65
|
+
this._tooltipEl = el;
|
|
66
|
+
this._targetEl.style.setProperty('anchor-name', this._anchorName);
|
|
67
|
+
this._host.appendChild(el);
|
|
68
|
+
const ac = new AbortController();
|
|
69
|
+
this._ac = ac;
|
|
70
|
+
const o = { signal: ac.signal };
|
|
71
|
+
this._targetEl.addEventListener('mouseenter', () => {
|
|
72
|
+
this._clearShowTimer();
|
|
73
|
+
this._showTimer = setTimeout(() => this._show(), delay);
|
|
74
|
+
}, o);
|
|
75
|
+
this._targetEl.addEventListener('mouseleave', () => this._hide(), o);
|
|
76
|
+
this._targetEl.addEventListener('focusin', () => this._show(), o);
|
|
77
|
+
this._targetEl.addEventListener('focusout', () => this._hide(), o);
|
|
78
|
+
this._targetEl.addEventListener('click', () => this._hide(), o);
|
|
79
|
+
document.addEventListener('keydown', e => {
|
|
80
|
+
if (e.key === 'Escape')
|
|
81
|
+
this._hide();
|
|
82
|
+
}, o);
|
|
83
|
+
}
|
|
84
|
+
_detach() {
|
|
85
|
+
this._clearShowTimer();
|
|
86
|
+
this._ac?.abort();
|
|
87
|
+
this._ac = null;
|
|
88
|
+
if (this._targetEl) {
|
|
89
|
+
;
|
|
90
|
+
this._targetEl.style.removeProperty('anchor-name');
|
|
91
|
+
this._targetEl = null;
|
|
92
|
+
}
|
|
93
|
+
if (this._tooltipEl) {
|
|
94
|
+
try {
|
|
95
|
+
this._tooltipEl.hidePopover();
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
/* already hidden */
|
|
99
|
+
}
|
|
100
|
+
this._tooltipEl.remove();
|
|
101
|
+
this._tooltipEl = null;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
_show() {
|
|
105
|
+
this._clearShowTimer();
|
|
106
|
+
if (!this._tooltipEl || this._tooltipEl.matches(':popover-open'))
|
|
107
|
+
return;
|
|
108
|
+
try {
|
|
109
|
+
this._tooltipEl.showPopover();
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
/* invalid state */
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
_hide() {
|
|
116
|
+
this._clearShowTimer();
|
|
117
|
+
if (!this._tooltipEl || !this._tooltipEl.matches(':popover-open'))
|
|
118
|
+
return;
|
|
119
|
+
try {
|
|
120
|
+
this._tooltipEl.hidePopover();
|
|
121
|
+
}
|
|
122
|
+
catch {
|
|
123
|
+
/* invalid state */
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
_clearShowTimer() {
|
|
127
|
+
if (this._showTimer !== null) {
|
|
128
|
+
clearTimeout(this._showTimer);
|
|
129
|
+
this._showTimer = null;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=TooltipController.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TooltipController.js","sourceRoot":"","sources":["../../src/util/TooltipController.ts"],"names":[],"mappings":"AAiBA,kFAAkF;AAClF,MAAM,gBAAgB,GAAG;IACvB,GAAG,EAAE,iBAAiB;IACtB,MAAM,EAAE,oBAAoB;IAC5B,IAAI,EAAE,kBAAkB;IACxB,KAAK,EAAE,mBAAmB;CAClB,CAAA;AAEV,MAAM,cAAc,GAAG;IACrB,EAAE,EAAE,uBAAuB;IAC3B,EAAE,EAAE,uBAAuB;IAC3B,EAAE,EAAE,uBAAuB;IAC3B,EAAE,EAAE,uBAAuB;CACnB,CAAA;AAEV;;;GAGG;AACH,MAAM,OAAO,iBAAiB;IAS5B,YAAY,IAA0C,EAAE,OAAiC;QANjF,eAAU,GAA0B,IAAI,CAAA;QACxC,cAAS,GAAmB,IAAI,CAAA;QAChC,gBAAW,GAAG,iBAAiB,MAAM,CAAC,UAAU,EAAE,EAAE,CAAA;QACpD,eAAU,GAAyC,IAAI,CAAA;QACvD,QAAG,GAA2B,IAAI,CAAA;QAGxC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;QACjB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAA;QACvB,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAA;IAC1B,CAAC;IAED,WAAW;QACT,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;QAE7D,IAAI,MAAM,IAAI,MAAM,KAAK,IAAI,CAAC,SAAS,EAAE,CAAC;YACxC,IAAI,CAAC,OAAO,EAAE,CAAA;YACd,IAAI,CAAC,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