@luzmo/lucero 1.0.1-alpha.17 → 1.0.1-alpha.18
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.
|
@@ -116,9 +116,10 @@ class LuzmoTooltip extends sizedMixin.SizedMixin(base.LuzmoElement, {
|
|
|
116
116
|
this.delayed = false;
|
|
117
117
|
this.dependencyManager = new dependencyManger.DependencyManagerController(this);
|
|
118
118
|
this.disabled = false;
|
|
119
|
+
this.showOnlyIfTruncated = false;
|
|
119
120
|
this.selfManaged = false;
|
|
120
121
|
this.offset = 0;
|
|
121
|
-
this.
|
|
122
|
+
this._open = false;
|
|
122
123
|
this._variant = "";
|
|
123
124
|
this.handleOpenOverlay = () => {
|
|
124
125
|
this.open = true;
|
|
@@ -130,6 +131,15 @@ class LuzmoTooltip extends sizedMixin.SizedMixin(base.LuzmoElement, {
|
|
|
130
131
|
static get styles() {
|
|
131
132
|
return [lit.unsafeCSS(tooltipStyles)];
|
|
132
133
|
}
|
|
134
|
+
get open() {
|
|
135
|
+
return this._open;
|
|
136
|
+
}
|
|
137
|
+
set open(value) {
|
|
138
|
+
if (value && this.showOnlyIfTruncated && !this.isContentTruncated()) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
this._open = value;
|
|
142
|
+
}
|
|
133
143
|
get variant() {
|
|
134
144
|
return this._variant;
|
|
135
145
|
}
|
|
@@ -145,6 +155,19 @@ class LuzmoTooltip extends sizedMixin.SizedMixin(base.LuzmoElement, {
|
|
|
145
155
|
this.removeAttribute("variant");
|
|
146
156
|
this._variant = "";
|
|
147
157
|
}
|
|
158
|
+
isContentTruncated() {
|
|
159
|
+
const triggerEl = this.triggerElement;
|
|
160
|
+
if (!triggerEl) {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
if (this.truncatedElementSelector) {
|
|
164
|
+
const targetEl = triggerEl.querySelector(this.truncatedElementSelector);
|
|
165
|
+
if (targetEl) {
|
|
166
|
+
return targetEl.scrollWidth > targetEl.clientWidth;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return triggerEl.scrollWidth > triggerEl.clientWidth;
|
|
170
|
+
}
|
|
148
171
|
forwardTransitionEvent(event) {
|
|
149
172
|
this.dispatchEvent(
|
|
150
173
|
new TransitionEvent(event.type, {
|
|
@@ -230,6 +253,12 @@ __decorateClass([
|
|
|
230
253
|
__decorateClass([
|
|
231
254
|
decorators_js.property({ type: Boolean })
|
|
232
255
|
], LuzmoTooltip.prototype, "disabled", 2);
|
|
256
|
+
__decorateClass([
|
|
257
|
+
decorators_js.property({ type: Boolean, attribute: "show-only-if-truncated" })
|
|
258
|
+
], LuzmoTooltip.prototype, "showOnlyIfTruncated", 2);
|
|
259
|
+
__decorateClass([
|
|
260
|
+
decorators_js.property({ type: String, attribute: "truncated-element-selector" })
|
|
261
|
+
], LuzmoTooltip.prototype, "truncatedElementSelector", 2);
|
|
233
262
|
__decorateClass([
|
|
234
263
|
decorators_js.property({ type: Boolean, attribute: "self-managed" })
|
|
235
264
|
], LuzmoTooltip.prototype, "selfManaged", 2);
|
|
@@ -238,7 +267,7 @@ __decorateClass([
|
|
|
238
267
|
], LuzmoTooltip.prototype, "offset", 2);
|
|
239
268
|
__decorateClass([
|
|
240
269
|
decorators_js.property({ type: Boolean, reflect: true })
|
|
241
|
-
], LuzmoTooltip.prototype, "open",
|
|
270
|
+
], LuzmoTooltip.prototype, "open", 1);
|
|
242
271
|
__decorateClass([
|
|
243
272
|
decorators_js.query("luzmo-overlay")
|
|
244
273
|
], LuzmoTooltip.prototype, "overlayElement", 2);
|
|
@@ -123,9 +123,10 @@ class LuzmoTooltip extends SizedMixin(LuzmoElement, {
|
|
|
123
123
|
this.delayed = false;
|
|
124
124
|
this.dependencyManager = new DependencyManagerController(this);
|
|
125
125
|
this.disabled = false;
|
|
126
|
+
this.showOnlyIfTruncated = false;
|
|
126
127
|
this.selfManaged = false;
|
|
127
128
|
this.offset = 0;
|
|
128
|
-
this.
|
|
129
|
+
this._open = false;
|
|
129
130
|
this._variant = "";
|
|
130
131
|
this.handleOpenOverlay = () => {
|
|
131
132
|
this.open = true;
|
|
@@ -137,6 +138,15 @@ class LuzmoTooltip extends SizedMixin(LuzmoElement, {
|
|
|
137
138
|
static get styles() {
|
|
138
139
|
return [unsafeCSS(tooltipStyles)];
|
|
139
140
|
}
|
|
141
|
+
get open() {
|
|
142
|
+
return this._open;
|
|
143
|
+
}
|
|
144
|
+
set open(value) {
|
|
145
|
+
if (value && this.showOnlyIfTruncated && !this.isContentTruncated()) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
this._open = value;
|
|
149
|
+
}
|
|
140
150
|
get variant() {
|
|
141
151
|
return this._variant;
|
|
142
152
|
}
|
|
@@ -152,6 +162,19 @@ class LuzmoTooltip extends SizedMixin(LuzmoElement, {
|
|
|
152
162
|
this.removeAttribute("variant");
|
|
153
163
|
this._variant = "";
|
|
154
164
|
}
|
|
165
|
+
isContentTruncated() {
|
|
166
|
+
const triggerEl = this.triggerElement;
|
|
167
|
+
if (!triggerEl) {
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
if (this.truncatedElementSelector) {
|
|
171
|
+
const targetEl = triggerEl.querySelector(this.truncatedElementSelector);
|
|
172
|
+
if (targetEl) {
|
|
173
|
+
return targetEl.scrollWidth > targetEl.clientWidth;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return triggerEl.scrollWidth > triggerEl.clientWidth;
|
|
177
|
+
}
|
|
155
178
|
forwardTransitionEvent(event) {
|
|
156
179
|
this.dispatchEvent(
|
|
157
180
|
new TransitionEvent(event.type, {
|
|
@@ -237,6 +260,12 @@ __decorateClass([
|
|
|
237
260
|
__decorateClass([
|
|
238
261
|
property({ type: Boolean })
|
|
239
262
|
], LuzmoTooltip.prototype, "disabled", 2);
|
|
263
|
+
__decorateClass([
|
|
264
|
+
property({ type: Boolean, attribute: "show-only-if-truncated" })
|
|
265
|
+
], LuzmoTooltip.prototype, "showOnlyIfTruncated", 2);
|
|
266
|
+
__decorateClass([
|
|
267
|
+
property({ type: String, attribute: "truncated-element-selector" })
|
|
268
|
+
], LuzmoTooltip.prototype, "truncatedElementSelector", 2);
|
|
240
269
|
__decorateClass([
|
|
241
270
|
property({ type: Boolean, attribute: "self-managed" })
|
|
242
271
|
], LuzmoTooltip.prototype, "selfManaged", 2);
|
|
@@ -245,7 +274,7 @@ __decorateClass([
|
|
|
245
274
|
], LuzmoTooltip.prototype, "offset", 2);
|
|
246
275
|
__decorateClass([
|
|
247
276
|
property({ type: Boolean, reflect: true })
|
|
248
|
-
], LuzmoTooltip.prototype, "open",
|
|
277
|
+
], LuzmoTooltip.prototype, "open", 1);
|
|
249
278
|
__decorateClass([
|
|
250
279
|
query("luzmo-overlay")
|
|
251
280
|
], LuzmoTooltip.prototype, "overlayElement", 2);
|
|
@@ -27,13 +27,23 @@ export declare class LuzmoTooltip extends LuzmoTooltip_base {
|
|
|
27
27
|
* Whether to prevent a self-managed Tooltip from responding to user input.
|
|
28
28
|
*/
|
|
29
29
|
disabled: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Whether to show the tooltip only if the content is truncated.
|
|
32
|
+
*/
|
|
33
|
+
showOnlyIfTruncated: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* The selector of the element to check for truncation.
|
|
36
|
+
*/
|
|
37
|
+
truncatedElementSelector?: string;
|
|
30
38
|
/**
|
|
31
39
|
* Automatically bind to the parent element of the assigned `slot` or the parent element of the `luzmo-tooltip`.
|
|
32
40
|
* Without this, you must provide your own `overlay-trigger`.
|
|
33
41
|
*/
|
|
34
42
|
selfManaged: boolean;
|
|
35
43
|
offset: number;
|
|
36
|
-
|
|
44
|
+
private _open;
|
|
45
|
+
get open(): boolean;
|
|
46
|
+
set open(value: boolean);
|
|
37
47
|
overlayElement?: LuzmoOverlay;
|
|
38
48
|
/**
|
|
39
49
|
* @type {"top" | "top-start" | "top-end" | "right" | "right-start" | "right-end" | "bottom" | "bottom-start" | "bottom-end" | "left" | "left-start" | "left-end"}
|
|
@@ -45,6 +55,7 @@ export declare class LuzmoTooltip extends LuzmoTooltip_base {
|
|
|
45
55
|
private _variant;
|
|
46
56
|
get variant(): string;
|
|
47
57
|
set variant(variant: string);
|
|
58
|
+
private isContentTruncated;
|
|
48
59
|
private handleOpenOverlay;
|
|
49
60
|
protected handleCloseOverlay: () => void;
|
|
50
61
|
protected forwardTransitionEvent(event: TransitionEvent): void;
|