@cupra/ui-kit 1.0.0-canary.13 → 1.0.0-canary.15
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/components/ds-rating/ds-rating.d.ts +14 -0
- package/dist/components/ds-rating/ds-rating.js +73 -0
- package/dist/components/ds-rating/ds-rating.test.d.ts +8 -0
- package/dist/components/ds-rating/ds-rating.types.d.ts +6 -0
- package/dist/components/ds-rating/styles/common.styles.d.ts +1 -0
- package/dist/components/ds-rating/styles/common.styles.js +14 -0
- package/dist/components/ds-theme-provider/ds-theme-provider.js +1 -1
- package/dist/components/ds-tooltip/ds-tooltip.d.ts +37 -23
- package/dist/components/ds-tooltip/ds-tooltip.js +179 -157
- package/dist/components/ds-tooltip/ds-tooltip.test.d.ts +8 -0
- package/dist/components/ds-tooltip/ds-tooltip.types.d.ts +5 -10
- package/dist/components/ds-tooltip/styles/common.styles.d.ts +0 -2
- package/dist/components/ds-tooltip/styles/common.styles.js +69 -102
- package/dist/components/index.d.ts +2 -1
- package/dist/index.js +4 -3
- package/dist/node_modules/.pnpm/@floating-ui_core@1.7.3/node_modules/@floating-ui/core/dist/floating-ui.core.js +430 -0
- package/dist/node_modules/.pnpm/@floating-ui_dom@1.7.4/node_modules/@floating-ui/dom/dist/floating-ui.dom.js +313 -0
- package/dist/node_modules/.pnpm/@floating-ui_utils@0.2.10/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js +132 -0
- package/dist/node_modules/.pnpm/@floating-ui_utils@0.2.10/node_modules/@floating-ui/utils/dist/floating-ui.utils.js +128 -0
- package/dist/utils/StylesRegistry/StylesRegistry.js +1 -1
- package/dist/utils/cssWithTokens.js +1 -1
- package/dist/utils/htmlWithTokens.js +1 -1
- package/dist-react/components/ds-rating/ds-rating.d.ts +14 -0
- package/dist-react/components/ds-rating/ds-rating.js +73 -0
- package/dist-react/components/ds-rating/ds-rating.test.d.ts +8 -0
- package/dist-react/components/ds-rating/ds-rating.types.d.ts +6 -0
- package/dist-react/components/ds-rating/styles/common.styles.d.ts +1 -0
- package/dist-react/components/ds-rating/styles/common.styles.js +14 -0
- package/dist-react/components/ds-theme-provider/ds-theme-provider.js +1 -1
- package/dist-react/components/ds-tooltip/ds-tooltip.d.ts +37 -23
- package/dist-react/components/ds-tooltip/ds-tooltip.js +179 -157
- package/dist-react/components/ds-tooltip/ds-tooltip.test.d.ts +8 -0
- package/dist-react/components/ds-tooltip/ds-tooltip.types.d.ts +5 -10
- package/dist-react/components/ds-tooltip/styles/common.styles.d.ts +0 -2
- package/dist-react/components/ds-tooltip/styles/common.styles.js +69 -102
- package/dist-react/components/index.d.ts +2 -1
- package/dist-react/index.js +4 -3
- package/dist-react/node_modules/.pnpm/@floating-ui_core@1.7.3/node_modules/@floating-ui/core/dist/floating-ui.core.js +430 -0
- package/dist-react/node_modules/.pnpm/@floating-ui_dom@1.7.4/node_modules/@floating-ui/dom/dist/floating-ui.dom.js +313 -0
- package/dist-react/node_modules/.pnpm/@floating-ui_utils@0.2.10/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js +132 -0
- package/dist-react/node_modules/.pnpm/@floating-ui_utils@0.2.10/node_modules/@floating-ui/utils/dist/floating-ui.utils.js +128 -0
- package/dist-react/utils/StylesRegistry/StylesRegistry.js +1 -1
- package/dist-react/utils/cssWithTokens.js +1 -1
- package/dist-react/utils/htmlWithTokens.js +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { UiKitElement } from '../base/UiKitElement.ts';
|
|
2
|
+
import '../ds-icon/ds-icon.ts';
|
|
3
|
+
import type { DsRatingAttrs } from './ds-rating.types';
|
|
4
|
+
export declare class DsRating extends UiKitElement {
|
|
5
|
+
static styles: import("lit").CSSResult[];
|
|
6
|
+
value: DsRatingAttrs['value'];
|
|
7
|
+
disabled: DsRatingAttrs['disabled'];
|
|
8
|
+
hideRatingText: DsRatingAttrs['hide-rating-text'];
|
|
9
|
+
private get displayValue();
|
|
10
|
+
private get classes();
|
|
11
|
+
private getStarIconName;
|
|
12
|
+
protected get starsTemplate(): any[];
|
|
13
|
+
render(): import("lit").TemplateResult<1>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { UiKitElement as c } from "../base/UiKitElement.js";
|
|
2
|
+
import { customUiKitElement as h } from "../../decorators/customUiKitElement.js";
|
|
3
|
+
import { booleanConverter as u } from "../../utils/booleanConverter.js";
|
|
4
|
+
import "../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/reactive-element.js";
|
|
5
|
+
import { html as p } from "../../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/lit-html.js";
|
|
6
|
+
import "../../node_modules/.pnpm/lit-element@4.2.1/node_modules/lit-element/lit-element.js";
|
|
7
|
+
import { property as m } from "../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/property.js";
|
|
8
|
+
import { classMap as d } from "../../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/directives/class-map.js";
|
|
9
|
+
import "../ds-icon/ds-icon.js";
|
|
10
|
+
import { commonStyles as f } from "./styles/common.styles.js";
|
|
11
|
+
var v = Object.defineProperty, g = Object.getOwnPropertyDescriptor, o = (e, t, r, a) => {
|
|
12
|
+
for (var s = a > 1 ? void 0 : a ? g(t, r) : t, l = e.length - 1, n; l >= 0; l--)
|
|
13
|
+
(n = e[l]) && (s = (a ? n(t, r, s) : n(s)) || s);
|
|
14
|
+
return a && s && v(t, r, s), s;
|
|
15
|
+
};
|
|
16
|
+
let i = class extends c {
|
|
17
|
+
constructor() {
|
|
18
|
+
super(...arguments), this.disabled = !1, this.hideRatingText = !1;
|
|
19
|
+
}
|
|
20
|
+
get displayValue() {
|
|
21
|
+
if (this.value === void 0 || this.value === null || this.value < 0) return 0;
|
|
22
|
+
const e = Math.max(0, Math.min(5, this.value)), t = Math.floor(e), r = Number((e - t).toFixed(2));
|
|
23
|
+
return t + Math.round(r / 0.5) * 0.5;
|
|
24
|
+
}
|
|
25
|
+
get classes() {
|
|
26
|
+
return {
|
|
27
|
+
container: !0,
|
|
28
|
+
disabled: this.disabled
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
getStarIconName(e, t) {
|
|
32
|
+
return t >= e ? "star-filled" : t >= e - 0.5 ? "half-star-filled" : "star";
|
|
33
|
+
}
|
|
34
|
+
get starsTemplate() {
|
|
35
|
+
const e = this.displayValue, t = [];
|
|
36
|
+
for (let r = 1; r <= 5; r++) {
|
|
37
|
+
const a = this.getStarIconName(r, e);
|
|
38
|
+
a && t.push(
|
|
39
|
+
this.componentFactory.createIcon({
|
|
40
|
+
class: "star-icon",
|
|
41
|
+
"icon-name": a,
|
|
42
|
+
size: 16
|
|
43
|
+
})
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
return t;
|
|
47
|
+
}
|
|
48
|
+
render() {
|
|
49
|
+
const e = this.value !== void 0 && this.value >= 0 ? this.value : 0, r = Math.max(0, Math.min(5, e)).toString();
|
|
50
|
+
return p`
|
|
51
|
+
<div class=${d(this.classes)} aria-label=${`Rating: ${r} out of 5`} role="img">
|
|
52
|
+
<div class="stars-wrapper">${this.starsTemplate}</div>
|
|
53
|
+
${this.hideRatingText ? "" : p`<span class="rating-text">${r}</span>`}
|
|
54
|
+
</div>
|
|
55
|
+
`;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
i.styles = [f];
|
|
59
|
+
o([
|
|
60
|
+
m({ type: Number })
|
|
61
|
+
], i.prototype, "value", 2);
|
|
62
|
+
o([
|
|
63
|
+
m({ type: Boolean, converter: u, reflect: !0 })
|
|
64
|
+
], i.prototype, "disabled", 2);
|
|
65
|
+
o([
|
|
66
|
+
m({ type: Boolean, converter: u, attribute: "hide-rating-text" })
|
|
67
|
+
], i.prototype, "hideRatingText", 2);
|
|
68
|
+
i = o([
|
|
69
|
+
h("ds-rating")
|
|
70
|
+
], i);
|
|
71
|
+
export {
|
|
72
|
+
i as DsRating
|
|
73
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const commonStyles: import("lit").CSSResult;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import "../../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/reactive-element.js";
|
|
2
|
+
import "../../../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/lit-html.js";
|
|
3
|
+
import "../../../node_modules/.pnpm/lit-element@4.2.1/node_modules/lit-element/lit-element.js";
|
|
4
|
+
import { css as r } from "../../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/css-tag.js";
|
|
5
|
+
const e = r`
|
|
6
|
+
.container,
|
|
7
|
+
.stars-wrapper {
|
|
8
|
+
display: flex;
|
|
9
|
+
align-items: center;
|
|
10
|
+
}
|
|
11
|
+
`;
|
|
12
|
+
export {
|
|
13
|
+
e as commonStyles
|
|
14
|
+
};
|
|
@@ -53,7 +53,7 @@ let m = class extends $ {
|
|
|
53
53
|
}
|
|
54
54
|
loadThemeStyles() {
|
|
55
55
|
return this.loadStyles ? new Promise((t, o) => {
|
|
56
|
-
const s = "/1.0.0-canary.
|
|
56
|
+
const s = "/1.0.0-canary.15", r = `https://ds-assets.cupra.com${s}/styles/${this.theme}/theme.css`;
|
|
57
57
|
if (document.head.querySelector(`link[href="${r}"]`)) t();
|
|
58
58
|
else {
|
|
59
59
|
const e = `ui-kit-theme-${s}`, a = document.getElementById(e), n = document.createElement("link");
|
|
@@ -1,45 +1,59 @@
|
|
|
1
1
|
import { UiKitElement } from '../base/UiKitElement.ts';
|
|
2
|
+
import { type Placement } from '@floating-ui/dom';
|
|
2
3
|
import { nothing } from 'lit';
|
|
3
4
|
import type { DsTooltipAttrs } from './ds-tooltip.types';
|
|
4
5
|
declare const DsTooltip_base: (new (...args: any[]) => import("../../mixins/ViewportMixin").ViewportInterface) & typeof UiKitElement;
|
|
5
6
|
export declare class DsTooltip extends DsTooltip_base {
|
|
6
7
|
static styles: import("lit").CSSResult[];
|
|
7
8
|
mode: DsTooltipAttrs['mode'];
|
|
8
|
-
titleText: DsTooltipAttrs['title-text'];
|
|
9
|
-
bodyText: DsTooltipAttrs['body-text'];
|
|
10
|
-
position: DsTooltipAttrs['position'];
|
|
11
|
-
align: DsTooltipAttrs['align'];
|
|
12
|
-
cancelButtonText: DsTooltipAttrs['cancel-button-text'];
|
|
13
|
-
confirmButtonText: DsTooltipAttrs['confirm-button-text'];
|
|
14
9
|
show: DsTooltipAttrs['show'];
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
disableHoverListener: DsTooltipAttrs['disable-hover-listener'];
|
|
11
|
+
disableFocusListener: DsTooltipAttrs['disable-focus-listener'];
|
|
12
|
+
disablePressListener: DsTooltipAttrs['disable-press-listener'];
|
|
13
|
+
protected tooltopPlacement: Placement;
|
|
14
|
+
protected container: HTMLInputElement;
|
|
15
|
+
protected anchorContainer: HTMLInputElement;
|
|
18
16
|
protected arrow: HTMLInputElement;
|
|
19
|
-
|
|
17
|
+
private anchorElements;
|
|
18
|
+
private headerElements;
|
|
19
|
+
private closeButtonElements;
|
|
20
|
+
private contentElements;
|
|
21
|
+
protected usingKeyboard: boolean;
|
|
20
22
|
disconnectedCallback(): void;
|
|
21
|
-
protected
|
|
23
|
+
protected updated(changedProperties: Map<string | number | symbol, unknown>): void;
|
|
24
|
+
protected updatePosition(): void;
|
|
25
|
+
protected handleKeyDown: () => void;
|
|
26
|
+
protected handlePointerDown: () => void;
|
|
22
27
|
protected handleResize: (params?: any) => void | Function;
|
|
23
28
|
protected get arrowClasses(): {
|
|
24
29
|
[x: string]: boolean;
|
|
25
30
|
arrow: boolean;
|
|
26
31
|
'not-positionable': boolean;
|
|
27
32
|
};
|
|
28
|
-
protected get
|
|
29
|
-
[x: string]:
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
protected get containerClasses(): {
|
|
34
|
+
[x: string]: boolean;
|
|
35
|
+
container: boolean;
|
|
36
|
+
};
|
|
37
|
+
protected get headerClasses(): {
|
|
38
|
+
'header-container': boolean;
|
|
39
|
+
hidden: boolean;
|
|
40
|
+
};
|
|
41
|
+
protected get contentClasses(): {
|
|
42
|
+
'content-container': boolean;
|
|
43
|
+
'ds-scroll': boolean;
|
|
44
|
+
'ds-scroll--size-s': boolean;
|
|
45
|
+
hidden: boolean;
|
|
32
46
|
};
|
|
33
|
-
protected
|
|
47
|
+
protected handleClose: () => void;
|
|
48
|
+
protected get arrowTemplate(): import("lit").TemplateResult<1>;
|
|
34
49
|
protected get tooltipTemplate(): typeof nothing | import("lit").TemplateResult<1>;
|
|
35
|
-
private getTooltipWidth;
|
|
36
50
|
protected get styleTokens(): import("lit").HTMLTemplateResult;
|
|
51
|
+
protected handleAnchorPointerDown: (event: PointerEvent) => void;
|
|
52
|
+
protected handleAnchorMouseOver: () => void;
|
|
53
|
+
protected handleAnchorMouseOut: () => void;
|
|
54
|
+
protected handleAnchorFocusIn: () => void;
|
|
55
|
+
protected handleAnchorFocusOut: () => void;
|
|
56
|
+
protected handlePressOutside: (event: MouseEvent) => void;
|
|
37
57
|
render(): import("lit").TemplateResult<1>;
|
|
38
|
-
protected handleClickSlot(): void;
|
|
39
|
-
protected handleMouseOver(): void;
|
|
40
|
-
protected handleMouseOut(): void;
|
|
41
|
-
protected handleClickCancelButton(): void;
|
|
42
|
-
protected handleClickConfirmButton(): void;
|
|
43
|
-
protected handleClickOutside: (event: MouseEvent | TouchEvent) => void;
|
|
44
58
|
}
|
|
45
59
|
export {};
|
|
@@ -1,95 +1,143 @@
|
|
|
1
|
-
import { UiKitElement as
|
|
2
|
-
import { customUiKitElement as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { UiKitElement as w } from "../base/UiKitElement.js";
|
|
2
|
+
import { customUiKitElement as v } from "../../decorators/customUiKitElement.js";
|
|
3
|
+
import { computePosition as y, flip as b, shift as g, offset as P, arrow as E, size as L } from "../../node_modules/.pnpm/@floating-ui_dom@1.7.4/node_modules/@floating-ui/dom/dist/floating-ui.dom.js";
|
|
4
|
+
import { ViewportMixin as $ } from "../../mixins/ViewportMixin.js";
|
|
5
|
+
import { booleanConverter as c } from "../../utils/booleanConverter.js";
|
|
6
|
+
import { debounce as C } from "../../utils/debounce.js";
|
|
6
7
|
import { htmlWithTokens as x } from "../../utils/htmlWithTokens.js";
|
|
7
8
|
import "../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/reactive-element.js";
|
|
8
|
-
import {
|
|
9
|
+
import { html as p, nothing as O } from "../../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/lit-html.js";
|
|
9
10
|
import "../../node_modules/.pnpm/lit-element@4.2.1/node_modules/lit-element/lit-element.js";
|
|
10
|
-
import { property as
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
import { property as l } from "../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/property.js";
|
|
12
|
+
import { state as A } from "../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/state.js";
|
|
13
|
+
import { query as m } from "../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/query.js";
|
|
14
|
+
import { queryAssignedElements as u } from "../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/query-assigned-elements.js";
|
|
15
|
+
import { classMap as d } from "../../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/directives/class-map.js";
|
|
16
|
+
import { commonStyles as D } from "./styles/common.styles.js";
|
|
17
|
+
var F = Object.defineProperty, M = Object.getOwnPropertyDescriptor, r = (e, t, o, i) => {
|
|
18
|
+
for (var n = i > 1 ? void 0 : i ? M(t, o) : t, h = e.length - 1, a; h >= 0; h--)
|
|
19
|
+
(a = e[h]) && (n = (i ? a(t, o, n) : a(n)) || n);
|
|
20
|
+
return i && n && F(t, o, n), n;
|
|
18
21
|
};
|
|
19
|
-
let
|
|
22
|
+
let s = class extends $(w) {
|
|
20
23
|
constructor() {
|
|
21
|
-
super(...arguments), this.mode = "light", this.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
super(...arguments), this.mode = "light", this.show = !1, this.disableHoverListener = !1, this.disableFocusListener = !1, this.disablePressListener = !1, this.usingKeyboard = !1, this.handleKeyDown = () => {
|
|
25
|
+
this.usingKeyboard = !0;
|
|
26
|
+
}, this.handlePointerDown = () => {
|
|
27
|
+
this.usingKeyboard = !1;
|
|
28
|
+
}, this.handleResize = C({ func: () => this.requestUpdate() }), this.handleClose = () => {
|
|
29
|
+
this.show = !1;
|
|
30
|
+
}, this.handleAnchorPointerDown = (e) => {
|
|
31
|
+
this.disablePressListener || e.button === 0 && (this.show = !this.show);
|
|
32
|
+
}, this.handleAnchorMouseOver = () => {
|
|
33
|
+
this.disableHoverListener || (this.show = !0);
|
|
34
|
+
}, this.handleAnchorMouseOut = () => {
|
|
35
|
+
this.disableHoverListener || setTimeout(() => {
|
|
36
|
+
var e, t, o, i, n;
|
|
37
|
+
!((t = (e = this.container) == null ? void 0 : e.matches) != null && t.call(e, ":hover")) && !((i = (o = this.arrow) == null ? void 0 : o.matches) != null && i.call(o, ":hover")) && !((n = this == null ? void 0 : this.matches) != null && n.call(this, ":hover")) && (this.show = !1);
|
|
38
|
+
}, 150);
|
|
39
|
+
}, this.handleAnchorFocusIn = () => {
|
|
40
|
+
this.usingKeyboard && (this.disableFocusListener || (this.show = !0));
|
|
41
|
+
}, this.handleAnchorFocusOut = () => {
|
|
42
|
+
this.usingKeyboard && (this.disableFocusListener || (this.show = !1));
|
|
43
|
+
}, this.handlePressOutside = (e) => {
|
|
44
|
+
var o;
|
|
45
|
+
if (this.disablePressListener || e.button !== 0) return;
|
|
46
|
+
const t = e.target;
|
|
47
|
+
t === this || this.contains(t) || (o = this.shadowRoot) != null && o.contains(t) || this.anchorElements[0] === t || this.anchorElements[0].contains(t) || (this.show = !1);
|
|
25
48
|
};
|
|
26
49
|
}
|
|
27
|
-
connectedCallback() {
|
|
28
|
-
super.connectedCallback(), window.addEventListener("resize", this.handleResize);
|
|
29
|
-
}
|
|
30
50
|
disconnectedCallback() {
|
|
31
|
-
super.disconnectedCallback(), window.removeEventListener("resize", this.handleResize);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
51
|
+
super.disconnectedCallback(), window.removeEventListener("resize", this.handleResize), document.removeEventListener("pointerdown", this.handlePressOutside), document.removeEventListener("keydown", this.handleKeyDown), document.removeEventListener("pointerdown", this.handlePointerDown);
|
|
52
|
+
}
|
|
53
|
+
updated(e) {
|
|
54
|
+
document.addEventListener("keydown", this.handleKeyDown), document.addEventListener("pointerdown", this.handlePointerDown), this.updatePosition(), e.has("show") && (this.show ? (window.addEventListener("resize", this.handleResize), document.addEventListener("pointerdown", this.handlePressOutside)) : (window.removeEventListener("resize", this.handleResize), document.removeEventListener("pointerdown", this.handlePressOutside)));
|
|
55
|
+
}
|
|
56
|
+
updatePosition() {
|
|
57
|
+
requestAnimationFrame(() => {
|
|
58
|
+
var e;
|
|
59
|
+
!this.anchorContainer || !this.container || !this.show || !((e = this.anchorElements) != null && e[0]) || !(this.anchorContainer instanceof Element) || !(this.container instanceof Element) || !(this.arrow instanceof Element) || (y(this.anchorContainer, this.container, {
|
|
60
|
+
placement: "bottom-start",
|
|
61
|
+
middleware: [
|
|
62
|
+
b(),
|
|
63
|
+
g(),
|
|
64
|
+
P(8),
|
|
65
|
+
E({ element: this.arrow }),
|
|
66
|
+
L({
|
|
67
|
+
apply({ availableWidth: t, availableHeight: o, elements: i }) {
|
|
68
|
+
Object.assign(i.floating.style, {
|
|
69
|
+
maxWidth: `${Math.min(240, t - 8)}px`,
|
|
70
|
+
maxHeight: `${Math.max(0, o - 8)}px`
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
})
|
|
74
|
+
]
|
|
75
|
+
}).then((t) => {
|
|
76
|
+
const { x: o, y: i, middlewareData: n, placement: h } = t;
|
|
77
|
+
if (this.tooltopPlacement = h, Object.assign(this.container.style, {
|
|
78
|
+
left: `${o ?? 0}px`,
|
|
79
|
+
top: `${i ?? 0}px`
|
|
80
|
+
}), n.arrow) {
|
|
81
|
+
const { x: a, y: f } = n.arrow;
|
|
82
|
+
Object.assign(this.arrow.style, {
|
|
83
|
+
left: a != null ? `${a}px` : "",
|
|
84
|
+
top: f != null ? `${f}px` : ""
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}), this.requestUpdate());
|
|
88
|
+
});
|
|
35
89
|
}
|
|
36
90
|
get arrowClasses() {
|
|
37
|
-
var
|
|
91
|
+
var e;
|
|
38
92
|
return {
|
|
39
93
|
arrow: !0,
|
|
40
|
-
[this.position]: !0,
|
|
41
|
-
[this.align]: !0,
|
|
42
94
|
[this.mode]: !0,
|
|
43
|
-
"not-positionable": (this == null ? void 0 : this.offsetWidth) > ((
|
|
95
|
+
"not-positionable": (this == null ? void 0 : this.offsetWidth) > ((e = this.container) == null ? void 0 : e.offsetWidth)
|
|
44
96
|
};
|
|
45
97
|
}
|
|
46
|
-
get
|
|
98
|
+
get containerClasses() {
|
|
47
99
|
return {
|
|
48
|
-
|
|
49
|
-
[this.
|
|
50
|
-
[this.
|
|
51
|
-
[this.mode]: !0,
|
|
52
|
-
complex: this.cancelButtonText || this.confirmButtonText
|
|
100
|
+
container: !0,
|
|
101
|
+
[this.tooltopPlacement]: !!this.tooltopPlacement,
|
|
102
|
+
[this.mode]: !0
|
|
53
103
|
};
|
|
54
104
|
}
|
|
55
|
-
get
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
class: "cancel-button",
|
|
62
|
-
"@click": this.handleClickCancelButton,
|
|
63
|
-
size: "small",
|
|
64
|
-
variant: "secondary",
|
|
65
|
-
mode: t,
|
|
66
|
-
children: this.cancelButtonText
|
|
67
|
-
}) : a}
|
|
68
|
-
${this.confirmButtonText ? this.componentFactory.createButton({
|
|
69
|
-
class: "confirm-button",
|
|
70
|
-
"@click": this.handleClickConfirmButton,
|
|
71
|
-
size: "small",
|
|
72
|
-
variant: "primary",
|
|
73
|
-
mode: t,
|
|
74
|
-
children: this.confirmButtonText
|
|
75
|
-
}) : a}
|
|
76
|
-
</div>
|
|
77
|
-
`;
|
|
105
|
+
get headerClasses() {
|
|
106
|
+
var e, t;
|
|
107
|
+
return {
|
|
108
|
+
"header-container": !0,
|
|
109
|
+
hidden: ((e = this.headerElements) == null ? void 0 : e.length) === 0 && ((t = this.closeButtonElements) == null ? void 0 : t.length) === 0
|
|
110
|
+
};
|
|
78
111
|
}
|
|
79
|
-
get
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
` : a;
|
|
112
|
+
get contentClasses() {
|
|
113
|
+
var e;
|
|
114
|
+
return {
|
|
115
|
+
"content-container": !0,
|
|
116
|
+
"ds-scroll": !0,
|
|
117
|
+
"ds-scroll--size-s": !0,
|
|
118
|
+
hidden: ((e = this.contentElements) == null ? void 0 : e.length) === 0
|
|
119
|
+
};
|
|
88
120
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
121
|
+
get arrowTemplate() {
|
|
122
|
+
return p`
|
|
123
|
+
<svg id="arrow" xmlns="http://www.w3.org/2000/svg" width="17" height="9" viewBox="0 0 17 9" fill="none" class=${d(this.arrowClasses)} @mouseout="${this.handleAnchorMouseOut}">
|
|
124
|
+
<path d="M5.77946 4.38048L0.5 9L16 9L11.1427 4.46656C9.88663 3.29419 9.25858 2.708 8.48883 2.69565C7.71909 2.68329 7.07255 3.24902 5.77946 4.38048Z" fill="#26262C" class="ds-tooltip-arrow-background"/>
|
|
125
|
+
<path d="M0.5 8.5L5.89467 4.11683C7.1398 3.10516 7.76236 2.59933 8.49029 2.6109C9.21822 2.62246 9.8244 3.14782 11.0368 4.19853L16 8.5" stroke="#FAFAFA" stroke-opacity="0.3" stroke-linecap="round" class="ds-tooltip-arrow-border"/>
|
|
126
|
+
</svg>`;
|
|
127
|
+
}
|
|
128
|
+
get tooltipTemplate() {
|
|
129
|
+
return this.show && this.anchorElements.length > 0 ? p`
|
|
130
|
+
<div id="tooltip" part="container" class=${d(this.containerClasses)} @mouseout=${this.handleAnchorMouseOut}>
|
|
131
|
+
<header part="header" class=${d(this.headerClasses)}>
|
|
132
|
+
<slot @slotchange=${this.updatePosition} name="header"></slot>
|
|
133
|
+
<slot @slotchange=${this.updatePosition} name="close-button" @click=${this.handleClose}></slot>
|
|
134
|
+
</header>
|
|
135
|
+
<div part="content" class=${d(this.contentClasses)}>
|
|
136
|
+
<slot @slotchange=${this.updatePosition} name="content"></slot>
|
|
137
|
+
</div>
|
|
138
|
+
<slot part="image" @slotchange=${this.updatePosition} name="image"></slot>
|
|
139
|
+
${this.arrowTemplate}
|
|
140
|
+
</div>` : O;
|
|
93
141
|
}
|
|
94
142
|
get styleTokens() {
|
|
95
143
|
return x`
|
|
@@ -101,98 +149,72 @@ let e = class extends y(m) {
|
|
|
101
149
|
`;
|
|
102
150
|
}
|
|
103
151
|
render() {
|
|
104
|
-
return
|
|
152
|
+
return p`
|
|
105
153
|
<style>
|
|
106
|
-
.
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
.tooltip,
|
|
110
|
-
.arrow {
|
|
111
|
-
z-index: ${this.zIndex};
|
|
112
|
-
}
|
|
113
|
-
.body {
|
|
114
|
-
max-width: ${this.bodyWidth};
|
|
154
|
+
.anchor {
|
|
155
|
+
cursor: ${this.disablePressListener ? "default" : "pointer"};
|
|
115
156
|
}
|
|
116
157
|
</style>
|
|
117
158
|
${this.styleTokens}
|
|
118
|
-
<
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
159
|
+
<div
|
|
160
|
+
id="button"
|
|
161
|
+
class="anchor"
|
|
162
|
+
tabindex="0"
|
|
163
|
+
@mouseover="${this.handleAnchorMouseOver}"
|
|
164
|
+
@mouseout="${this.handleAnchorMouseOut}"
|
|
165
|
+
@pointerdown="${this.handleAnchorPointerDown}"
|
|
166
|
+
@focusin=${this.handleAnchorFocusIn}
|
|
167
|
+
@focusout=${this.handleAnchorFocusOut}
|
|
168
|
+
>
|
|
169
|
+
<slot></slot>
|
|
170
|
+
</div>
|
|
124
171
|
${this.tooltipTemplate}
|
|
125
172
|
`;
|
|
126
173
|
}
|
|
127
|
-
handleClickSlot() {
|
|
128
|
-
["xs", "s", "m"].includes(this.viewport) && (this.show = !this.show);
|
|
129
|
-
}
|
|
130
|
-
handleMouseOver() {
|
|
131
|
-
["xs", "s", "m"].includes(this.viewport) || (this.show = !0);
|
|
132
|
-
}
|
|
133
|
-
handleMouseOut() {
|
|
134
|
-
["xs", "s", "m"].includes(this.viewport) || setTimeout(() => {
|
|
135
|
-
var t, n, r, i, o;
|
|
136
|
-
!((n = (t = this.tooltip) == null ? void 0 : t.matches) != null && n.call(t, ":hover")) && !((i = (r = this.arrow) == null ? void 0 : r.matches) != null && i.call(r, ":hover")) && !((o = this == null ? void 0 : this.matches) != null && o.call(this, ":hover")) && (this.show = !1);
|
|
137
|
-
}, 150);
|
|
138
|
-
}
|
|
139
|
-
handleClickCancelButton() {
|
|
140
|
-
this.dispatchEvent(
|
|
141
|
-
new CustomEvent("click-cancel-button", {
|
|
142
|
-
bubbles: !0,
|
|
143
|
-
composed: !0
|
|
144
|
-
})
|
|
145
|
-
), this.show = !1;
|
|
146
|
-
}
|
|
147
|
-
handleClickConfirmButton() {
|
|
148
|
-
this.dispatchEvent(
|
|
149
|
-
new CustomEvent("click-confirm-button", {
|
|
150
|
-
bubbles: !0,
|
|
151
|
-
composed: !0
|
|
152
|
-
})
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
174
|
};
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
],
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
],
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
],
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
],
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
],
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
],
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
],
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
],
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
],
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
],
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
],
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
],
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
],
|
|
175
|
+
s.styles = [D];
|
|
176
|
+
r([
|
|
177
|
+
l({ type: String, reflect: !0 })
|
|
178
|
+
], s.prototype, "mode", 2);
|
|
179
|
+
r([
|
|
180
|
+
l({ type: Boolean, reflect: !0, converter: c })
|
|
181
|
+
], s.prototype, "show", 2);
|
|
182
|
+
r([
|
|
183
|
+
l({ type: Boolean, reflect: !0, converter: c, attribute: "disable-hover-listener" })
|
|
184
|
+
], s.prototype, "disableHoverListener", 2);
|
|
185
|
+
r([
|
|
186
|
+
l({ type: Boolean, reflect: !0, converter: c, attribute: "disable-focus-listener" })
|
|
187
|
+
], s.prototype, "disableFocusListener", 2);
|
|
188
|
+
r([
|
|
189
|
+
l({ type: Boolean, reflect: !0, converter: c, attribute: "disable-press-listener" })
|
|
190
|
+
], s.prototype, "disablePressListener", 2);
|
|
191
|
+
r([
|
|
192
|
+
A()
|
|
193
|
+
], s.prototype, "tooltopPlacement", 2);
|
|
194
|
+
r([
|
|
195
|
+
m(".container")
|
|
196
|
+
], s.prototype, "container", 2);
|
|
197
|
+
r([
|
|
198
|
+
m("#button")
|
|
199
|
+
], s.prototype, "anchorContainer", 2);
|
|
200
|
+
r([
|
|
201
|
+
m("#arrow")
|
|
202
|
+
], s.prototype, "arrow", 2);
|
|
203
|
+
r([
|
|
204
|
+
u({ slot: "" })
|
|
205
|
+
], s.prototype, "anchorElements", 2);
|
|
206
|
+
r([
|
|
207
|
+
u({ slot: "header" })
|
|
208
|
+
], s.prototype, "headerElements", 2);
|
|
209
|
+
r([
|
|
210
|
+
u({ slot: "close-button" })
|
|
211
|
+
], s.prototype, "closeButtonElements", 2);
|
|
212
|
+
r([
|
|
213
|
+
u({ slot: "content" })
|
|
214
|
+
], s.prototype, "contentElements", 2);
|
|
215
|
+
s = r([
|
|
216
|
+
v("ds-tooltip")
|
|
217
|
+
], s);
|
|
196
218
|
export {
|
|
197
|
-
|
|
219
|
+
s as DsTooltip
|
|
198
220
|
};
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import type { CommonAttrs } from '../../types/types';
|
|
2
|
-
export
|
|
2
|
+
export type DsTooltipAttrs = CommonAttrs & {
|
|
3
3
|
mode?: 'dark' | 'light';
|
|
4
|
-
'title-text'?: string;
|
|
5
|
-
'body-text'?: string;
|
|
6
|
-
position?: 'top' | 'right' | 'bottom' | 'left';
|
|
7
|
-
align?: 'start' | 'center' | 'end';
|
|
8
4
|
show?: boolean;
|
|
9
|
-
'
|
|
10
|
-
'
|
|
11
|
-
'
|
|
12
|
-
|
|
13
|
-
}
|
|
5
|
+
'disable-hover-listener'?: boolean;
|
|
6
|
+
'disable-focus-listener'?: boolean;
|
|
7
|
+
'disable-press-listener'?: boolean;
|
|
8
|
+
};
|