@scania/tegel 1.25.0-fix-a11y-chip-more-improvements-beta.0 → 1.25.0-tooltip-beta.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/dist/cjs/index-ca8040ad.js +4 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/tds-chip.cjs.entry.js +2 -7
- package/dist/cjs/tds-tooltip-beta.cjs.entry.js +123 -0
- package/dist/cjs/tegel.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +2 -1
- package/dist/collection/components/chip/chip.js +2 -24
- package/dist/collection/components/tooltip-beta/tooltip-beta.css +40 -0
- package/dist/collection/components/tooltip-beta/tooltip-beta.js +319 -0
- package/dist/collection/types/Tooltip.js +1 -0
- package/dist/components/tds-chip.js +3 -9
- package/dist/components/tds-tooltip-beta.d.ts +11 -0
- package/dist/components/tds-tooltip-beta.js +149 -0
- package/dist/esm/index-51d04e39.js +4 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/tds-chip.entry.js +2 -7
- package/dist/esm/tds-tooltip-beta.entry.js +119 -0
- package/dist/esm/tegel.js +1 -1
- package/dist/tegel/p-0c1e632d.entry.js +1 -0
- package/dist/tegel/p-ef3671d8.entry.js +1 -0
- package/dist/tegel/tegel.esm.js +1 -1
- package/dist/types/components/chip/chip.d.ts +0 -3
- package/dist/types/components/tooltip-beta/tooltip-beta.d.ts +28 -0
- package/dist/types/components.d.ts +35 -8
- package/dist/types/types/Tooltip.d.ts +4 -0
- package/package.json +1 -1
- package/dist/tegel/p-b08886e3.entry.js +0 -1
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
import { h, Host } from "@stencil/core";
|
|
2
|
+
export class TdsTooltipBeta {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.debounce = (func, delay) => (...args) => {
|
|
5
|
+
let debounceTimer;
|
|
6
|
+
clearTimeout(debounceTimer);
|
|
7
|
+
debounceTimer = setTimeout(() => func.apply(this, args), delay);
|
|
8
|
+
};
|
|
9
|
+
this.showTooltip = this.debounce(() => {
|
|
10
|
+
this.isVisible = true;
|
|
11
|
+
this.updateTooltipPosition();
|
|
12
|
+
}, 100);
|
|
13
|
+
this.hideTooltip = this.debounce(() => {
|
|
14
|
+
this.isVisible = false;
|
|
15
|
+
}, 100);
|
|
16
|
+
this.toggleTooltip = () => {
|
|
17
|
+
this.isVisible = !this.isVisible;
|
|
18
|
+
this.updateTooltipPosition();
|
|
19
|
+
};
|
|
20
|
+
this.setTooltipRef = (element) => {
|
|
21
|
+
this.tooltipEl = element;
|
|
22
|
+
};
|
|
23
|
+
this.text = '';
|
|
24
|
+
this.selector = undefined;
|
|
25
|
+
this.referenceEl = undefined;
|
|
26
|
+
this.defaultShow = false;
|
|
27
|
+
this.mouseOverTooltip = false;
|
|
28
|
+
this.trigger = 'hover';
|
|
29
|
+
this.show = null;
|
|
30
|
+
this.placement = 'bottom';
|
|
31
|
+
this.offsetSkidding = 0;
|
|
32
|
+
this.offsetDistance = 8;
|
|
33
|
+
this.isVisible = this.defaultShow;
|
|
34
|
+
}
|
|
35
|
+
componentDidLoad() {
|
|
36
|
+
if (!this.referenceEl && this.selector) {
|
|
37
|
+
this.referenceEl = document.querySelector(this.selector);
|
|
38
|
+
}
|
|
39
|
+
if (this.referenceEl) {
|
|
40
|
+
this.bindEvents();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
connectedCallback() {
|
|
44
|
+
this.resizeObserver = new ResizeObserver(() => this.updateTooltipPosition());
|
|
45
|
+
if (this.referenceEl) {
|
|
46
|
+
this.resizeObserver.observe(this.referenceEl);
|
|
47
|
+
}
|
|
48
|
+
window.addEventListener('resize', this.updateTooltipPosition);
|
|
49
|
+
}
|
|
50
|
+
disconnectedCallback() {
|
|
51
|
+
this.resizeObserver.disconnect();
|
|
52
|
+
window.removeEventListener('resize', this.updateTooltipPosition);
|
|
53
|
+
}
|
|
54
|
+
bindEvents() {
|
|
55
|
+
var _a, _b;
|
|
56
|
+
if (this.trigger === 'hover') {
|
|
57
|
+
this.referenceEl.addEventListener('mouseenter', this.showTooltip);
|
|
58
|
+
this.referenceEl.addEventListener('mouseleave', this.hideTooltip);
|
|
59
|
+
if (this.mouseOverTooltip) {
|
|
60
|
+
(_a = this.tooltipEl) === null || _a === void 0 ? void 0 : _a.addEventListener('mouseenter', this.showTooltip);
|
|
61
|
+
(_b = this.tooltipEl) === null || _b === void 0 ? void 0 : _b.addEventListener('mouseleave', this.hideTooltip);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
else if (this.trigger === 'click') {
|
|
65
|
+
this.referenceEl.addEventListener('click', this.toggleTooltip);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
updateTooltipPosition() {
|
|
69
|
+
if (!this.tooltipEl || !this.referenceEl)
|
|
70
|
+
return;
|
|
71
|
+
requestAnimationFrame(() => {
|
|
72
|
+
const rect = this.referenceEl.getBoundingClientRect();
|
|
73
|
+
const { height, width, bottom } = rect;
|
|
74
|
+
let { top, left } = rect;
|
|
75
|
+
switch (this.placement) {
|
|
76
|
+
case 'top':
|
|
77
|
+
top -= this.tooltipEl.offsetHeight + this.offsetDistance;
|
|
78
|
+
left += width / 2 - this.tooltipEl.offsetWidth / 2;
|
|
79
|
+
break;
|
|
80
|
+
case 'bottom':
|
|
81
|
+
top += height + this.offsetDistance;
|
|
82
|
+
left += width / 2 - this.tooltipEl.offsetWidth / 2;
|
|
83
|
+
break;
|
|
84
|
+
case 'left':
|
|
85
|
+
top += height / 2 - this.tooltipEl.offsetHeight / 2;
|
|
86
|
+
left -= this.tooltipEl.offsetWidth + this.offsetDistance;
|
|
87
|
+
break;
|
|
88
|
+
case 'right':
|
|
89
|
+
top += height / 2 - this.tooltipEl.offsetHeight / 2;
|
|
90
|
+
left += width + this.offsetDistance;
|
|
91
|
+
break;
|
|
92
|
+
// Handle more complex placements like 'top-start', 'bottom-end', etc.
|
|
93
|
+
default:
|
|
94
|
+
top = bottom + this.offsetDistance;
|
|
95
|
+
left = left + width / 2 - this.tooltipEl.offsetWidth / 2;
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
// Additional offsets
|
|
99
|
+
left += this.offsetSkidding;
|
|
100
|
+
this.tooltipEl.style.top = `${top}px`;
|
|
101
|
+
this.tooltipEl.style.left = `${left}px`;
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
render() {
|
|
105
|
+
return (h(Host, { key: 'ccab2630363c007e8d4719d22ab140e80547251b' }, h("div", { key: '3c64224e0620e60f42089205e3ca8d0766df90cc', class: {
|
|
106
|
+
'tds-tooltip': true,
|
|
107
|
+
'tds-tooltip-show': this.isVisible,
|
|
108
|
+
}, ref: this.setTooltipRef }, this.text, h("slot", { key: '4674e18dbf5bfe563ca3c01757280ccd660c5049' }))));
|
|
109
|
+
}
|
|
110
|
+
static get is() { return "tds-tooltip-beta"; }
|
|
111
|
+
static get encapsulation() { return "scoped"; }
|
|
112
|
+
static get originalStyleUrls() {
|
|
113
|
+
return {
|
|
114
|
+
"$": ["tooltip-beta.scss"]
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
static get styleUrls() {
|
|
118
|
+
return {
|
|
119
|
+
"$": ["tooltip-beta.css"]
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
static get properties() {
|
|
123
|
+
return {
|
|
124
|
+
"text": {
|
|
125
|
+
"type": "string",
|
|
126
|
+
"mutable": false,
|
|
127
|
+
"complexType": {
|
|
128
|
+
"original": "string",
|
|
129
|
+
"resolved": "string",
|
|
130
|
+
"references": {}
|
|
131
|
+
},
|
|
132
|
+
"required": false,
|
|
133
|
+
"optional": false,
|
|
134
|
+
"docs": {
|
|
135
|
+
"tags": [],
|
|
136
|
+
"text": ""
|
|
137
|
+
},
|
|
138
|
+
"attribute": "text",
|
|
139
|
+
"reflect": false,
|
|
140
|
+
"defaultValue": "''"
|
|
141
|
+
},
|
|
142
|
+
"selector": {
|
|
143
|
+
"type": "string",
|
|
144
|
+
"mutable": false,
|
|
145
|
+
"complexType": {
|
|
146
|
+
"original": "string",
|
|
147
|
+
"resolved": "string",
|
|
148
|
+
"references": {}
|
|
149
|
+
},
|
|
150
|
+
"required": false,
|
|
151
|
+
"optional": false,
|
|
152
|
+
"docs": {
|
|
153
|
+
"tags": [],
|
|
154
|
+
"text": ""
|
|
155
|
+
},
|
|
156
|
+
"attribute": "selector",
|
|
157
|
+
"reflect": false
|
|
158
|
+
},
|
|
159
|
+
"referenceEl": {
|
|
160
|
+
"type": "unknown",
|
|
161
|
+
"mutable": false,
|
|
162
|
+
"complexType": {
|
|
163
|
+
"original": "HTMLElement | null",
|
|
164
|
+
"resolved": "HTMLElement",
|
|
165
|
+
"references": {
|
|
166
|
+
"HTMLElement": {
|
|
167
|
+
"location": "global",
|
|
168
|
+
"id": "global::HTMLElement"
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
"required": false,
|
|
173
|
+
"optional": true,
|
|
174
|
+
"docs": {
|
|
175
|
+
"tags": [],
|
|
176
|
+
"text": ""
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
"defaultShow": {
|
|
180
|
+
"type": "boolean",
|
|
181
|
+
"mutable": false,
|
|
182
|
+
"complexType": {
|
|
183
|
+
"original": "boolean",
|
|
184
|
+
"resolved": "boolean",
|
|
185
|
+
"references": {}
|
|
186
|
+
},
|
|
187
|
+
"required": false,
|
|
188
|
+
"optional": false,
|
|
189
|
+
"docs": {
|
|
190
|
+
"tags": [],
|
|
191
|
+
"text": ""
|
|
192
|
+
},
|
|
193
|
+
"attribute": "default-show",
|
|
194
|
+
"reflect": false,
|
|
195
|
+
"defaultValue": "false"
|
|
196
|
+
},
|
|
197
|
+
"mouseOverTooltip": {
|
|
198
|
+
"type": "boolean",
|
|
199
|
+
"mutable": false,
|
|
200
|
+
"complexType": {
|
|
201
|
+
"original": "boolean",
|
|
202
|
+
"resolved": "boolean",
|
|
203
|
+
"references": {}
|
|
204
|
+
},
|
|
205
|
+
"required": false,
|
|
206
|
+
"optional": false,
|
|
207
|
+
"docs": {
|
|
208
|
+
"tags": [],
|
|
209
|
+
"text": ""
|
|
210
|
+
},
|
|
211
|
+
"attribute": "mouse-over-tooltip",
|
|
212
|
+
"reflect": false,
|
|
213
|
+
"defaultValue": "false"
|
|
214
|
+
},
|
|
215
|
+
"trigger": {
|
|
216
|
+
"type": "string",
|
|
217
|
+
"mutable": false,
|
|
218
|
+
"complexType": {
|
|
219
|
+
"original": "'click' | 'hover'",
|
|
220
|
+
"resolved": "\"click\" | \"hover\"",
|
|
221
|
+
"references": {}
|
|
222
|
+
},
|
|
223
|
+
"required": false,
|
|
224
|
+
"optional": false,
|
|
225
|
+
"docs": {
|
|
226
|
+
"tags": [],
|
|
227
|
+
"text": ""
|
|
228
|
+
},
|
|
229
|
+
"attribute": "trigger",
|
|
230
|
+
"reflect": false,
|
|
231
|
+
"defaultValue": "'hover'"
|
|
232
|
+
},
|
|
233
|
+
"show": {
|
|
234
|
+
"type": "boolean",
|
|
235
|
+
"mutable": true,
|
|
236
|
+
"complexType": {
|
|
237
|
+
"original": "boolean",
|
|
238
|
+
"resolved": "boolean",
|
|
239
|
+
"references": {}
|
|
240
|
+
},
|
|
241
|
+
"required": false,
|
|
242
|
+
"optional": false,
|
|
243
|
+
"docs": {
|
|
244
|
+
"tags": [],
|
|
245
|
+
"text": ""
|
|
246
|
+
},
|
|
247
|
+
"attribute": "show",
|
|
248
|
+
"reflect": false,
|
|
249
|
+
"defaultValue": "null"
|
|
250
|
+
},
|
|
251
|
+
"placement": {
|
|
252
|
+
"type": "string",
|
|
253
|
+
"mutable": false,
|
|
254
|
+
"complexType": {
|
|
255
|
+
"original": "Placement",
|
|
256
|
+
"resolved": "\"bottom\" | \"bottom-end\" | \"bottom-start\" | \"left\" | \"left-end\" | \"left-start\" | \"right\" | \"right-end\" | \"right-start\" | \"top\" | \"top-end\" | \"top-start\"",
|
|
257
|
+
"references": {
|
|
258
|
+
"Placement": {
|
|
259
|
+
"location": "import",
|
|
260
|
+
"path": "../../types/Tooltip",
|
|
261
|
+
"id": "src/types/Tooltip.ts::Placement"
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
},
|
|
265
|
+
"required": false,
|
|
266
|
+
"optional": false,
|
|
267
|
+
"docs": {
|
|
268
|
+
"tags": [],
|
|
269
|
+
"text": ""
|
|
270
|
+
},
|
|
271
|
+
"attribute": "placement",
|
|
272
|
+
"reflect": false,
|
|
273
|
+
"defaultValue": "'bottom'"
|
|
274
|
+
},
|
|
275
|
+
"offsetSkidding": {
|
|
276
|
+
"type": "number",
|
|
277
|
+
"mutable": false,
|
|
278
|
+
"complexType": {
|
|
279
|
+
"original": "number",
|
|
280
|
+
"resolved": "number",
|
|
281
|
+
"references": {}
|
|
282
|
+
},
|
|
283
|
+
"required": false,
|
|
284
|
+
"optional": false,
|
|
285
|
+
"docs": {
|
|
286
|
+
"tags": [],
|
|
287
|
+
"text": ""
|
|
288
|
+
},
|
|
289
|
+
"attribute": "offset-skidding",
|
|
290
|
+
"reflect": false,
|
|
291
|
+
"defaultValue": "0"
|
|
292
|
+
},
|
|
293
|
+
"offsetDistance": {
|
|
294
|
+
"type": "number",
|
|
295
|
+
"mutable": false,
|
|
296
|
+
"complexType": {
|
|
297
|
+
"original": "number",
|
|
298
|
+
"resolved": "number",
|
|
299
|
+
"references": {}
|
|
300
|
+
},
|
|
301
|
+
"required": false,
|
|
302
|
+
"optional": false,
|
|
303
|
+
"docs": {
|
|
304
|
+
"tags": [],
|
|
305
|
+
"text": ""
|
|
306
|
+
},
|
|
307
|
+
"attribute": "offset-distance",
|
|
308
|
+
"reflect": false,
|
|
309
|
+
"defaultValue": "8"
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
static get states() {
|
|
314
|
+
return {
|
|
315
|
+
"isVisible": {}
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
static get elementRef() { return "host"; }
|
|
319
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -51,7 +51,6 @@ const TdsChip$1 = /*@__PURE__*/ proxyCustomElement(class TdsChip extends H {
|
|
|
51
51
|
this.name = undefined;
|
|
52
52
|
this.value = undefined;
|
|
53
53
|
this.disabled = false;
|
|
54
|
-
this.tdsAriaLabel = undefined;
|
|
55
54
|
}
|
|
56
55
|
handleInternaRadioChange(event) {
|
|
57
56
|
const { chipId, checked, groupName } = event.detail;
|
|
@@ -72,16 +71,12 @@ const TdsChip$1 = /*@__PURE__*/ proxyCustomElement(class TdsChip extends H {
|
|
|
72
71
|
}
|
|
73
72
|
return Object.assign(Object.assign({}, commonAttributes), { onClick: () => this.handleClick() });
|
|
74
73
|
}
|
|
75
|
-
connectedCallback() {
|
|
76
|
-
if (!this.tdsAriaLabel) {
|
|
77
|
-
console.warn('Tegel Chip component: tdsAriaLabel prop is missing');
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
74
|
render() {
|
|
81
75
|
const inputAttributes = this.renderInputAttributes();
|
|
82
76
|
const hasPrefixSlot = hasSlot('prefix', this.host);
|
|
83
77
|
const hasLabelSlot = hasSlot('label', this.host);
|
|
84
78
|
const hasSuffixSlot = hasSlot('suffix', this.host);
|
|
79
|
+
const textInsideLabel = this.host.querySelector(`[slot="label"]`).innerHTML;
|
|
85
80
|
const chipClasses = {
|
|
86
81
|
'tds-chip-component': true,
|
|
87
82
|
'sm': this.size === 'sm',
|
|
@@ -90,7 +85,7 @@ const TdsChip$1 = /*@__PURE__*/ proxyCustomElement(class TdsChip extends H {
|
|
|
90
85
|
'suffix': hasSuffixSlot,
|
|
91
86
|
'disabled': this.disabled,
|
|
92
87
|
};
|
|
93
|
-
return (h(Host, { key: '
|
|
88
|
+
return (h(Host, { key: 'e7a9ea9750272388e5a8988622865d3aef8104d0' }, h("div", { key: '96ef34ec0764c1c2082d32d6403a86fef836d83b', class: "component" }, h("div", { key: '3a565a0fcb663e8bae82e962d810f6316bd72843', class: chipClasses }, h("input", Object.assign({ key: 'fe6d46749f8d45d90ca4990d009db405ce3c00c2', type: this.type, id: this.chipId, "aria-checked": this.type === 'button' ? undefined : String(this.checked), role: this.type, "aria-label": hasLabelSlot && textInsideLabel ? textInsideLabel : 'Chip' }, inputAttributes)), h("label", { key: 'b395ede6ab012ed36bd32ad95490da2bfbd3c8a7', onClick: (event) => event.stopPropagation(), htmlFor: this.chipId }, hasPrefixSlot && h("slot", { key: '2713979e0184a424ea5d9dc6c3f2ed19d10564ca', name: "prefix" }), hasLabelSlot && h("slot", { key: '7707873c5ea761b6c64e1591064c7126e85686ba', name: "label" }), hasSuffixSlot && h("slot", { key: '73d2517b2cbc1ef6b690fa7c6ef7b1fda126bee2', name: "suffix" }))))));
|
|
94
89
|
}
|
|
95
90
|
get host() { return this; }
|
|
96
91
|
static get style() { return TdsChipStyle0; }
|
|
@@ -101,8 +96,7 @@ const TdsChip$1 = /*@__PURE__*/ proxyCustomElement(class TdsChip extends H {
|
|
|
101
96
|
"checked": [1540],
|
|
102
97
|
"name": [1],
|
|
103
98
|
"value": [1],
|
|
104
|
-
"disabled": [4]
|
|
105
|
-
"tdsAriaLabel": [1, "tds-aria-label"]
|
|
99
|
+
"disabled": [4]
|
|
106
100
|
}, [[16, "internalRadioOnChange", "handleInternaRadioChange"]]]);
|
|
107
101
|
function defineCustomElement$1() {
|
|
108
102
|
if (typeof customElements === "undefined") {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface TdsTooltipBeta extends Components.TdsTooltipBeta, HTMLElement {}
|
|
4
|
+
export const TdsTooltipBeta: {
|
|
5
|
+
prototype: TdsTooltipBeta;
|
|
6
|
+
new (): TdsTooltipBeta;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { p as proxyCustomElement, H, h, c as Host } from './p-28ef5186.js';
|
|
2
|
+
|
|
3
|
+
const tooltipBetaCss = ".sc-tds-tooltip-beta-h{position:absolute}.tds-tooltip.sc-tds-tooltip-beta{box-sizing:border-box;font:var(--tds-detail-05);letter-spacing:var(--tds-detail-05-ls);color:var(--tds-tooltip-color);background-color:var(--tds-tooltip-background);border-radius:4px;padding:8px;word-wrap:break-word;white-space:normal;max-width:192px;z-index:900;opacity:0;visibility:hidden;transition:opacity 200ms ease-in, visibility 200ms ease-in}.tds-tooltip.sc-tds-tooltip-beta *.sc-tds-tooltip-beta{box-sizing:border-box}.tds-tooltip.tds-tooltip-top-left.sc-tds-tooltip-beta{border-radius:0 4px 4px}.tds-tooltip.tds-tooltip-top-right.sc-tds-tooltip-beta{border-radius:4px 0 4px 4px}.tds-tooltip.tds-tooltip-bottom-right.sc-tds-tooltip-beta{border-radius:4px 4px 0}.tds-tooltip.tds-tooltip-bottom-left.sc-tds-tooltip-beta{border-radius:4px 4px 4px 0}.tds-tooltip-show.sc-tds-tooltip-beta{opacity:1;visibility:visible}";
|
|
4
|
+
const TdsTooltipBetaStyle0 = tooltipBetaCss;
|
|
5
|
+
|
|
6
|
+
const TdsTooltipBeta$1 = /*@__PURE__*/ proxyCustomElement(class TdsTooltipBeta extends H {
|
|
7
|
+
constructor() {
|
|
8
|
+
super();
|
|
9
|
+
this.__registerHost();
|
|
10
|
+
this.debounce = (func, delay) => (...args) => {
|
|
11
|
+
let debounceTimer;
|
|
12
|
+
clearTimeout(debounceTimer);
|
|
13
|
+
debounceTimer = setTimeout(() => func.apply(this, args), delay);
|
|
14
|
+
};
|
|
15
|
+
this.showTooltip = this.debounce(() => {
|
|
16
|
+
this.isVisible = true;
|
|
17
|
+
this.updateTooltipPosition();
|
|
18
|
+
}, 100);
|
|
19
|
+
this.hideTooltip = this.debounce(() => {
|
|
20
|
+
this.isVisible = false;
|
|
21
|
+
}, 100);
|
|
22
|
+
this.toggleTooltip = () => {
|
|
23
|
+
this.isVisible = !this.isVisible;
|
|
24
|
+
this.updateTooltipPosition();
|
|
25
|
+
};
|
|
26
|
+
this.setTooltipRef = (element) => {
|
|
27
|
+
this.tooltipEl = element;
|
|
28
|
+
};
|
|
29
|
+
this.text = '';
|
|
30
|
+
this.selector = undefined;
|
|
31
|
+
this.referenceEl = undefined;
|
|
32
|
+
this.defaultShow = false;
|
|
33
|
+
this.mouseOverTooltip = false;
|
|
34
|
+
this.trigger = 'hover';
|
|
35
|
+
this.show = null;
|
|
36
|
+
this.placement = 'bottom';
|
|
37
|
+
this.offsetSkidding = 0;
|
|
38
|
+
this.offsetDistance = 8;
|
|
39
|
+
this.isVisible = this.defaultShow;
|
|
40
|
+
}
|
|
41
|
+
componentDidLoad() {
|
|
42
|
+
if (!this.referenceEl && this.selector) {
|
|
43
|
+
this.referenceEl = document.querySelector(this.selector);
|
|
44
|
+
}
|
|
45
|
+
if (this.referenceEl) {
|
|
46
|
+
this.bindEvents();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
connectedCallback() {
|
|
50
|
+
this.resizeObserver = new ResizeObserver(() => this.updateTooltipPosition());
|
|
51
|
+
if (this.referenceEl) {
|
|
52
|
+
this.resizeObserver.observe(this.referenceEl);
|
|
53
|
+
}
|
|
54
|
+
window.addEventListener('resize', this.updateTooltipPosition);
|
|
55
|
+
}
|
|
56
|
+
disconnectedCallback() {
|
|
57
|
+
this.resizeObserver.disconnect();
|
|
58
|
+
window.removeEventListener('resize', this.updateTooltipPosition);
|
|
59
|
+
}
|
|
60
|
+
bindEvents() {
|
|
61
|
+
var _a, _b;
|
|
62
|
+
if (this.trigger === 'hover') {
|
|
63
|
+
this.referenceEl.addEventListener('mouseenter', this.showTooltip);
|
|
64
|
+
this.referenceEl.addEventListener('mouseleave', this.hideTooltip);
|
|
65
|
+
if (this.mouseOverTooltip) {
|
|
66
|
+
(_a = this.tooltipEl) === null || _a === void 0 ? void 0 : _a.addEventListener('mouseenter', this.showTooltip);
|
|
67
|
+
(_b = this.tooltipEl) === null || _b === void 0 ? void 0 : _b.addEventListener('mouseleave', this.hideTooltip);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
else if (this.trigger === 'click') {
|
|
71
|
+
this.referenceEl.addEventListener('click', this.toggleTooltip);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
updateTooltipPosition() {
|
|
75
|
+
if (!this.tooltipEl || !this.referenceEl)
|
|
76
|
+
return;
|
|
77
|
+
requestAnimationFrame(() => {
|
|
78
|
+
const rect = this.referenceEl.getBoundingClientRect();
|
|
79
|
+
const { height, width, bottom } = rect;
|
|
80
|
+
let { top, left } = rect;
|
|
81
|
+
switch (this.placement) {
|
|
82
|
+
case 'top':
|
|
83
|
+
top -= this.tooltipEl.offsetHeight + this.offsetDistance;
|
|
84
|
+
left += width / 2 - this.tooltipEl.offsetWidth / 2;
|
|
85
|
+
break;
|
|
86
|
+
case 'bottom':
|
|
87
|
+
top += height + this.offsetDistance;
|
|
88
|
+
left += width / 2 - this.tooltipEl.offsetWidth / 2;
|
|
89
|
+
break;
|
|
90
|
+
case 'left':
|
|
91
|
+
top += height / 2 - this.tooltipEl.offsetHeight / 2;
|
|
92
|
+
left -= this.tooltipEl.offsetWidth + this.offsetDistance;
|
|
93
|
+
break;
|
|
94
|
+
case 'right':
|
|
95
|
+
top += height / 2 - this.tooltipEl.offsetHeight / 2;
|
|
96
|
+
left += width + this.offsetDistance;
|
|
97
|
+
break;
|
|
98
|
+
// Handle more complex placements like 'top-start', 'bottom-end', etc.
|
|
99
|
+
default:
|
|
100
|
+
top = bottom + this.offsetDistance;
|
|
101
|
+
left = left + width / 2 - this.tooltipEl.offsetWidth / 2;
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
// Additional offsets
|
|
105
|
+
left += this.offsetSkidding;
|
|
106
|
+
this.tooltipEl.style.top = `${top}px`;
|
|
107
|
+
this.tooltipEl.style.left = `${left}px`;
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
render() {
|
|
111
|
+
return (h(Host, { key: 'ccab2630363c007e8d4719d22ab140e80547251b' }, h("div", { key: '3c64224e0620e60f42089205e3ca8d0766df90cc', class: {
|
|
112
|
+
'tds-tooltip': true,
|
|
113
|
+
'tds-tooltip-show': this.isVisible,
|
|
114
|
+
}, ref: this.setTooltipRef }, this.text, h("slot", { key: '4674e18dbf5bfe563ca3c01757280ccd660c5049' }))));
|
|
115
|
+
}
|
|
116
|
+
get host() { return this; }
|
|
117
|
+
static get style() { return TdsTooltipBetaStyle0; }
|
|
118
|
+
}, [6, "tds-tooltip-beta", {
|
|
119
|
+
"text": [1],
|
|
120
|
+
"selector": [1],
|
|
121
|
+
"referenceEl": [16],
|
|
122
|
+
"defaultShow": [4, "default-show"],
|
|
123
|
+
"mouseOverTooltip": [4, "mouse-over-tooltip"],
|
|
124
|
+
"trigger": [1],
|
|
125
|
+
"show": [1028],
|
|
126
|
+
"placement": [1],
|
|
127
|
+
"offsetSkidding": [2, "offset-skidding"],
|
|
128
|
+
"offsetDistance": [2, "offset-distance"],
|
|
129
|
+
"isVisible": [32]
|
|
130
|
+
}]);
|
|
131
|
+
function defineCustomElement$1() {
|
|
132
|
+
if (typeof customElements === "undefined") {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
const components = ["tds-tooltip-beta"];
|
|
136
|
+
components.forEach(tagName => { switch (tagName) {
|
|
137
|
+
case "tds-tooltip-beta":
|
|
138
|
+
if (!customElements.get(tagName)) {
|
|
139
|
+
customElements.define(tagName, TdsTooltipBeta$1);
|
|
140
|
+
}
|
|
141
|
+
break;
|
|
142
|
+
} });
|
|
143
|
+
}
|
|
144
|
+
defineCustomElement$1();
|
|
145
|
+
|
|
146
|
+
const TdsTooltipBeta = TdsTooltipBeta$1;
|
|
147
|
+
const defineCustomElement = defineCustomElement$1;
|
|
148
|
+
|
|
149
|
+
export { TdsTooltipBeta, defineCustomElement };
|
|
@@ -320,6 +320,10 @@ var loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
|
|
320
320
|
return import(
|
|
321
321
|
/* webpackMode: "lazy" */
|
|
322
322
|
'./tds-tooltip.entry.js').then(processMod, consoleError);
|
|
323
|
+
case 'tds-tooltip-beta':
|
|
324
|
+
return import(
|
|
325
|
+
/* webpackMode: "lazy" */
|
|
326
|
+
'./tds-tooltip-beta.entry.js').then(processMod, consoleError);
|
|
323
327
|
case 'tds-divider':
|
|
324
328
|
return import(
|
|
325
329
|
/* webpackMode: "lazy" */
|