@cupra/ui-kit 1.0.0-canary.15 → 1.0.0-canary.17
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/base/UiKitElement.js +17 -15
- package/dist/components/ds-theme-provider/ds-theme-provider.js +28 -27
- package/dist/components/ds-tooltip/ds-tooltip.d.ts +1 -0
- package/dist/components/ds-tooltip/ds-tooltip.js +70 -56
- package/dist/core/theme.constants.d.ts +1 -0
- package/dist/core/theme.constants.js +4 -0
- package/dist/utils/IconsManager.js +9 -7
- package/dist/utils/PubSub.d.ts +0 -2
- package/dist/utils/PubSub.js +17 -12
- 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/base/UiKitElement.js +17 -15
- package/dist-react/components/ds-theme-provider/ds-theme-provider.js +28 -27
- package/dist-react/components/ds-tooltip/ds-tooltip.d.ts +1 -0
- package/dist-react/components/ds-tooltip/ds-tooltip.js +70 -56
- package/dist-react/core/theme.constants.d.ts +1 -0
- package/dist-react/core/theme.constants.js +4 -0
- package/dist-react/utils/IconsManager.js +9 -7
- package/dist-react/utils/PubSub.d.ts +0 -2
- package/dist-react/utils/PubSub.js +17 -12
- 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 +1 -1
|
@@ -1,31 +1,33 @@
|
|
|
1
|
-
import { themeContext as
|
|
2
|
-
import {
|
|
1
|
+
import { themeContext as m } from "../ds-theme-provider/themeContext.js";
|
|
2
|
+
import { THEME_STORAGE_KEY as d } from "../../core/theme.constants.js";
|
|
3
|
+
import { consume as u } from "../../node_modules/.pnpm/@lit_context@1.1.6/node_modules/@lit/context/lib/decorators/consume.js";
|
|
3
4
|
import { pubSub as p } from "../../utils/PubSub.js";
|
|
4
|
-
import { stylesRegistry as
|
|
5
|
+
import { stylesRegistry as S } from "../../utils/StylesRegistry/StylesRegistry.js";
|
|
5
6
|
import "../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/reactive-element.js";
|
|
6
7
|
import "../../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/lit-html.js";
|
|
7
8
|
import { LitElement as y } from "../../node_modules/.pnpm/lit-element@4.2.1/node_modules/lit-element/lit-element.js";
|
|
8
|
-
import { property as
|
|
9
|
-
import { state as
|
|
10
|
-
import { css as
|
|
11
|
-
var
|
|
9
|
+
import { property as b } from "../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/property.js";
|
|
10
|
+
import { state as f } from "../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/state.js";
|
|
11
|
+
import { css as C, adoptStyles as T } from "../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/css-tag.js";
|
|
12
|
+
var g = Object.defineProperty, l = (n, e, t, i) => {
|
|
12
13
|
for (var o = void 0, a = n.length - 1, s; a >= 0; a--)
|
|
13
14
|
(s = n[a]) && (o = s(e, t, o) || o);
|
|
14
|
-
return o &&
|
|
15
|
+
return o && g(e, t, o), o;
|
|
15
16
|
};
|
|
16
|
-
const
|
|
17
|
+
const E = C`:host([unresolved]){visibility:hidden}`, h = class c extends y {
|
|
17
18
|
constructor() {
|
|
18
19
|
super(), this.appliedConstructables = [], this.appliedStyleTags = [], this.handleChangeTheme = (e) => {
|
|
19
20
|
this.pubSubTheme = e;
|
|
20
21
|
}, this.pubSubTheme = p.subscribe("theme", this.handleChangeTheme);
|
|
21
22
|
}
|
|
22
23
|
get theme() {
|
|
23
|
-
|
|
24
|
+
const e = sessionStorage == null ? void 0 : sessionStorage.getItem(d);
|
|
25
|
+
return this.contextTheme ?? this.pubSubTheme ?? e;
|
|
24
26
|
}
|
|
25
27
|
connectedCallback() {
|
|
26
28
|
super.connectedCallback(), this.shadowRoot || this.attachShadow({ mode: "open" }), this.setAttribute("unresolved", "");
|
|
27
29
|
const e = this.constructor, t = Array.isArray(e.styles) ? e.styles : [e.styles].filter(Boolean);
|
|
28
|
-
|
|
30
|
+
T(this.shadowRoot, [...t, E]), this.applyThemeStyles();
|
|
29
31
|
}
|
|
30
32
|
disconnectedCallback() {
|
|
31
33
|
super.disconnectedCallback(), p.unsubscribe("theme", this.handleChangeTheme);
|
|
@@ -48,7 +50,7 @@ const g = f`:host([unresolved]){visibility:hidden}`, h = class c extends y {
|
|
|
48
50
|
if (!(!this.theme || !(e != null && e.length)))
|
|
49
51
|
try {
|
|
50
52
|
const t = await Promise.all(
|
|
51
|
-
e.map((s) =>
|
|
53
|
+
e.map((s) => S.getStyles({ componentName: s, theme: this.theme }))
|
|
52
54
|
), i = this.supportsAdoptedSheets(), o = this.shadowRoot.adoptedStyleSheets || [], a = this.appliedConstructables ? o.filter((s) => !this.appliedConstructables.includes(s)) : o;
|
|
53
55
|
this.appliedConstructables = [], this.appliedStyleTags.forEach((s) => s.remove()), this.appliedStyleTags = [], t.forEach((s) => {
|
|
54
56
|
if (s)
|
|
@@ -68,11 +70,11 @@ const g = f`:host([unresolved]){visibility:hidden}`, h = class c extends y {
|
|
|
68
70
|
}
|
|
69
71
|
};
|
|
70
72
|
l([
|
|
71
|
-
|
|
72
|
-
|
|
73
|
+
b({ attribute: !1 }),
|
|
74
|
+
u({ context: m, subscribe: !0 })
|
|
73
75
|
], h.prototype, "contextTheme");
|
|
74
76
|
l([
|
|
75
|
-
|
|
77
|
+
f()
|
|
76
78
|
], h.prototype, "pubSubTheme");
|
|
77
79
|
let N = h;
|
|
78
80
|
export {
|
|
@@ -1,31 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { THEME_STORAGE_KEY as p } from "../../core/theme.constants.js";
|
|
2
|
+
import { customUiKitElement as f } from "../../decorators/customUiKitElement.js";
|
|
3
|
+
import { provide as c } from "../../node_modules/.pnpm/@lit_context@1.1.6/node_modules/@lit/context/lib/decorators/provide.js";
|
|
4
|
+
import { pubSub as u } from "../../utils/PubSub.js";
|
|
4
5
|
import { booleanConverter as i } from "../../utils/booleanConverter.js";
|
|
5
6
|
import "../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/reactive-element.js";
|
|
6
|
-
import { nothing as
|
|
7
|
-
import { LitElement as
|
|
8
|
-
import { property as
|
|
7
|
+
import { nothing as y, html as $ } from "../../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/lit-html.js";
|
|
8
|
+
import { LitElement as v } from "../../node_modules/.pnpm/lit-element@4.2.1/node_modules/lit-element/lit-element.js";
|
|
9
|
+
import { property as d } from "../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/property.js";
|
|
9
10
|
import { state as l } from "../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/state.js";
|
|
10
|
-
import { fontsConfig as
|
|
11
|
-
import { themeContext as
|
|
12
|
-
var
|
|
13
|
-
for (var e = r > 1 ? void 0 : r ?
|
|
11
|
+
import { fontsConfig as F } from "../../styles/fonts-config.js";
|
|
12
|
+
import { themeContext as S } from "./themeContext.js";
|
|
13
|
+
var w = Object.defineProperty, E = Object.getOwnPropertyDescriptor, h = (t, o, s, r) => {
|
|
14
|
+
for (var e = r > 1 ? void 0 : r ? E(o, s) : o, a = t.length - 1, n; a >= 0; a--)
|
|
14
15
|
(n = t[a]) && (e = (r ? n(o, s, e) : n(e)) || e);
|
|
15
|
-
return r && e &&
|
|
16
|
+
return r && e && w(o, s, e), e;
|
|
16
17
|
};
|
|
17
|
-
let m = class extends
|
|
18
|
+
let m = class extends v {
|
|
18
19
|
constructor() {
|
|
19
20
|
super(...arguments), this.loadFonts = !0, this.loadStyles = !0, this.cssLoaded = !1, this.loadedFonts = /* @__PURE__ */ new Set();
|
|
20
21
|
}
|
|
21
22
|
updated(t) {
|
|
22
|
-
super.updated(t), t.has("theme") && (
|
|
23
|
+
super.updated(t), t.has("theme") && (u.publish("theme", this.theme), sessionStorage == null || sessionStorage.setItem(p, this.theme), this.loadThemeFonts(), this.loadThemeStyles().then(() => {
|
|
23
24
|
this.cssLoaded = !0;
|
|
24
25
|
}));
|
|
25
26
|
}
|
|
26
27
|
loadThemeFonts() {
|
|
27
28
|
var t;
|
|
28
|
-
(t =
|
|
29
|
+
(t = F[this.theme]) == null || t.fonts.forEach((o) => {
|
|
29
30
|
this.loadThemeFont(o);
|
|
30
31
|
});
|
|
31
32
|
}
|
|
@@ -53,7 +54,7 @@ let m = class extends $ {
|
|
|
53
54
|
}
|
|
54
55
|
loadThemeStyles() {
|
|
55
56
|
return this.loadStyles ? new Promise((t, o) => {
|
|
56
|
-
const s = "/1.0.0-canary.
|
|
57
|
+
const s = "/1.0.0-canary.17", r = `https://ds-assets.cupra.com${s}/styles/${this.theme}/theme.css`;
|
|
57
58
|
if (document.head.querySelector(`link[href="${r}"]`)) t();
|
|
58
59
|
else {
|
|
59
60
|
const e = `ui-kit-theme-${s}`, a = document.getElementById(e), n = document.createElement("link");
|
|
@@ -62,27 +63,27 @@ let m = class extends $ {
|
|
|
62
63
|
}) : Promise.resolve();
|
|
63
64
|
}
|
|
64
65
|
render() {
|
|
65
|
-
return this.cssLoaded ?
|
|
66
|
+
return this.cssLoaded ? $`<slot></slot>` : y;
|
|
66
67
|
}
|
|
67
68
|
};
|
|
68
|
-
|
|
69
|
-
|
|
69
|
+
h([
|
|
70
|
+
d({ type: Boolean, converter: i, attribute: "load-fonts" })
|
|
70
71
|
], m.prototype, "loadFonts", 2);
|
|
71
|
-
|
|
72
|
-
|
|
72
|
+
h([
|
|
73
|
+
d({ type: Boolean, converter: i, attribute: "load-styles" })
|
|
73
74
|
], m.prototype, "loadStyles", 2);
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
h([
|
|
76
|
+
c({ context: S }),
|
|
77
|
+
d({ type: String })
|
|
77
78
|
], m.prototype, "theme", 2);
|
|
78
|
-
|
|
79
|
+
h([
|
|
79
80
|
l()
|
|
80
81
|
], m.prototype, "cssLoaded", 2);
|
|
81
|
-
|
|
82
|
+
h([
|
|
82
83
|
l()
|
|
83
84
|
], m.prototype, "loadedFonts", 2);
|
|
84
|
-
m =
|
|
85
|
-
|
|
85
|
+
m = h([
|
|
86
|
+
f("ds-theme-provider")
|
|
86
87
|
], m);
|
|
87
88
|
export {
|
|
88
89
|
m as DsThemeProvider
|
|
@@ -11,6 +11,7 @@ export declare class DsTooltip extends DsTooltip_base {
|
|
|
11
11
|
disableFocusListener: DsTooltipAttrs['disable-focus-listener'];
|
|
12
12
|
disablePressListener: DsTooltipAttrs['disable-press-listener'];
|
|
13
13
|
protected tooltopPlacement: Placement;
|
|
14
|
+
private tooltipId;
|
|
14
15
|
protected container: HTMLInputElement;
|
|
15
16
|
protected anchorContainer: HTMLInputElement;
|
|
16
17
|
protected arrow: HTMLInputElement;
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import { UiKitElement as
|
|
1
|
+
import { UiKitElement as y } from "../base/UiKitElement.js";
|
|
2
2
|
import { customUiKitElement as v } from "../../decorators/customUiKitElement.js";
|
|
3
|
-
import { computePosition as
|
|
4
|
-
import { ViewportMixin as
|
|
5
|
-
import { booleanConverter as
|
|
6
|
-
import { debounce as
|
|
7
|
-
import { htmlWithTokens as
|
|
3
|
+
import { computePosition as g, flip as $, shift as P, offset as L, arrow as E, size as C } from "../../node_modules/.pnpm/@floating-ui_dom@1.7.4/node_modules/@floating-ui/dom/dist/floating-ui.dom.js";
|
|
4
|
+
import { ViewportMixin as x } from "../../mixins/ViewportMixin.js";
|
|
5
|
+
import { booleanConverter as u } from "../../utils/booleanConverter.js";
|
|
6
|
+
import { debounce as O } from "../../utils/debounce.js";
|
|
7
|
+
import { htmlWithTokens as A } from "../../utils/htmlWithTokens.js";
|
|
8
8
|
import "../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/reactive-element.js";
|
|
9
|
-
import { html as
|
|
9
|
+
import { html as m, nothing as d } from "../../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/lit-html.js";
|
|
10
10
|
import "../../node_modules/.pnpm/lit-element@4.2.1/node_modules/lit-element/lit-element.js";
|
|
11
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
|
|
13
|
-
import { query as
|
|
14
|
-
import { queryAssignedElements as
|
|
15
|
-
import { classMap as
|
|
16
|
-
import { commonStyles as
|
|
17
|
-
var
|
|
18
|
-
for (var
|
|
19
|
-
(a = e[h]) && (
|
|
20
|
-
return
|
|
12
|
+
import { state as b } from "../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/state.js";
|
|
13
|
+
import { query as f } from "../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/query.js";
|
|
14
|
+
import { queryAssignedElements as p } from "../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/query-assigned-elements.js";
|
|
15
|
+
import { classMap as c } from "../../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/directives/class-map.js";
|
|
16
|
+
import { commonStyles as M } from "./styles/common.styles.js";
|
|
17
|
+
var D = Object.defineProperty, F = Object.getOwnPropertyDescriptor, r = (e, t, o, n) => {
|
|
18
|
+
for (var i = n > 1 ? void 0 : n ? F(t, o) : t, h = e.length - 1, a; h >= 0; h--)
|
|
19
|
+
(a = e[h]) && (i = (n ? a(t, o, i) : a(i)) || i);
|
|
20
|
+
return n && i && D(t, o, i), i;
|
|
21
21
|
};
|
|
22
|
-
let s = class extends
|
|
22
|
+
let s = class extends x(y) {
|
|
23
23
|
constructor() {
|
|
24
|
-
super(...arguments), this.mode = "light", this.show = !1, this.disableHoverListener = !1, this.disableFocusListener = !1, this.disablePressListener = !1, this.usingKeyboard = !1, this.handleKeyDown = () => {
|
|
24
|
+
super(...arguments), this.mode = "light", this.show = !1, this.disableHoverListener = !1, this.disableFocusListener = !1, this.disablePressListener = !1, this.tooltipId = `ds-tooltip-${Date.now()}-${Math.floor(Math.random() * 1e6)}`, this.usingKeyboard = !1, this.handleKeyDown = () => {
|
|
25
25
|
this.usingKeyboard = !0;
|
|
26
26
|
}, this.handlePointerDown = () => {
|
|
27
27
|
this.usingKeyboard = !1;
|
|
28
|
-
}, this.handleResize =
|
|
28
|
+
}, this.handleResize = O({ func: () => this.requestUpdate() }), this.handleClose = () => {
|
|
29
29
|
this.show = !1;
|
|
30
30
|
}, this.handleAnchorPointerDown = (e) => {
|
|
31
31
|
this.disablePressListener || e.button === 0 && (this.show = !this.show);
|
|
@@ -33,8 +33,8 @@ let s = class extends $(w) {
|
|
|
33
33
|
this.disableHoverListener || (this.show = !0);
|
|
34
34
|
}, this.handleAnchorMouseOut = () => {
|
|
35
35
|
this.disableHoverListener || setTimeout(() => {
|
|
36
|
-
var e, t, o,
|
|
37
|
-
!((t = (e = this.container) == null ? void 0 : e.matches) != null && t.call(e, ":hover")) && !((
|
|
36
|
+
var e, t, o, n, i;
|
|
37
|
+
!((t = (e = this.container) == null ? void 0 : e.matches) != null && t.call(e, ":hover")) && !((n = (o = this.arrow) == null ? void 0 : o.matches) != null && n.call(o, ":hover")) && !((i = this == null ? void 0 : this.matches) != null && i.call(this, ":hover")) && (this.show = !1);
|
|
38
38
|
}, 150);
|
|
39
39
|
}, this.handleAnchorFocusIn = () => {
|
|
40
40
|
this.usingKeyboard && (this.disableFocusListener || (this.show = !0));
|
|
@@ -56,16 +56,16 @@ let s = class extends $(w) {
|
|
|
56
56
|
updatePosition() {
|
|
57
57
|
requestAnimationFrame(() => {
|
|
58
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) || (
|
|
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) || (g(this.anchorContainer, this.container, {
|
|
60
60
|
placement: "bottom-start",
|
|
61
61
|
middleware: [
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
$(),
|
|
63
|
+
P(),
|
|
64
|
+
L(8),
|
|
65
65
|
E({ element: this.arrow }),
|
|
66
|
-
|
|
67
|
-
apply({ availableWidth: t, availableHeight: o, elements:
|
|
68
|
-
Object.assign(
|
|
66
|
+
C({
|
|
67
|
+
apply({ availableWidth: t, availableHeight: o, elements: n }) {
|
|
68
|
+
Object.assign(n.floating.style, {
|
|
69
69
|
maxWidth: `${Math.min(240, t - 8)}px`,
|
|
70
70
|
maxHeight: `${Math.max(0, o - 8)}px`
|
|
71
71
|
});
|
|
@@ -73,15 +73,15 @@ let s = class extends $(w) {
|
|
|
73
73
|
})
|
|
74
74
|
]
|
|
75
75
|
}).then((t) => {
|
|
76
|
-
const { x: o, y:
|
|
76
|
+
const { x: o, y: n, middlewareData: i, placement: h } = t;
|
|
77
77
|
if (this.tooltopPlacement = h, Object.assign(this.container.style, {
|
|
78
78
|
left: `${o ?? 0}px`,
|
|
79
|
-
top: `${
|
|
80
|
-
}),
|
|
81
|
-
const { x: a, y:
|
|
79
|
+
top: `${n ?? 0}px`
|
|
80
|
+
}), i.arrow) {
|
|
81
|
+
const { x: a, y: w } = i.arrow;
|
|
82
82
|
Object.assign(this.arrow.style, {
|
|
83
83
|
left: a != null ? `${a}px` : "",
|
|
84
|
-
top:
|
|
84
|
+
top: w != null ? `${w}px` : ""
|
|
85
85
|
});
|
|
86
86
|
}
|
|
87
87
|
}), this.requestUpdate());
|
|
@@ -119,28 +119,34 @@ let s = class extends $(w) {
|
|
|
119
119
|
};
|
|
120
120
|
}
|
|
121
121
|
get arrowTemplate() {
|
|
122
|
-
return
|
|
123
|
-
<svg id="arrow" xmlns="http://www.w3.org/2000/svg" width="17" height="9" viewBox="0 0 17 9" fill="none" class=${
|
|
122
|
+
return m`
|
|
123
|
+
<svg id="arrow" xmlns="http://www.w3.org/2000/svg" width="17" height="9" viewBox="0 0 17 9" fill="none" class=${c(this.arrowClasses)} @mouseout="${this.handleAnchorMouseOut}" aria-hidden="true" focusable="false">
|
|
124
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
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
126
|
</svg>`;
|
|
127
127
|
}
|
|
128
128
|
get tooltipTemplate() {
|
|
129
|
-
return this.show && this.anchorElements.length > 0 ?
|
|
130
|
-
<div
|
|
131
|
-
|
|
129
|
+
return this.show && this.anchorElements.length > 0 ? m`
|
|
130
|
+
<div
|
|
131
|
+
id=${this.tooltipId}
|
|
132
|
+
part="container"
|
|
133
|
+
class=${c(this.containerClasses)}
|
|
134
|
+
@mouseout=${this.handleAnchorMouseOut}
|
|
135
|
+
role="tooltip"
|
|
136
|
+
>
|
|
137
|
+
<header part="header" class=${c(this.headerClasses)}>
|
|
132
138
|
<slot @slotchange=${this.updatePosition} name="header"></slot>
|
|
133
139
|
<slot @slotchange=${this.updatePosition} name="close-button" @click=${this.handleClose}></slot>
|
|
134
140
|
</header>
|
|
135
|
-
<div part="content" class=${
|
|
141
|
+
<div part="content" class=${c(this.contentClasses)}>
|
|
136
142
|
<slot @slotchange=${this.updatePosition} name="content"></slot>
|
|
137
143
|
</div>
|
|
138
144
|
<slot part="image" @slotchange=${this.updatePosition} name="image"></slot>
|
|
139
145
|
${this.arrowTemplate}
|
|
140
|
-
</div>` :
|
|
146
|
+
</div>` : d;
|
|
141
147
|
}
|
|
142
148
|
get styleTokens() {
|
|
143
|
-
return
|
|
149
|
+
return A`
|
|
144
150
|
<style>
|
|
145
151
|
:host {
|
|
146
152
|
color-scheme: ${this.mode};
|
|
@@ -149,17 +155,22 @@ let s = class extends $(w) {
|
|
|
149
155
|
`;
|
|
150
156
|
}
|
|
151
157
|
render() {
|
|
152
|
-
return
|
|
158
|
+
return m`
|
|
153
159
|
<style>
|
|
154
160
|
.anchor {
|
|
155
161
|
cursor: ${this.disablePressListener ? "default" : "pointer"};
|
|
156
162
|
}
|
|
157
163
|
</style>
|
|
158
164
|
${this.styleTokens}
|
|
159
|
-
<div
|
|
165
|
+
<div
|
|
160
166
|
id="button"
|
|
161
167
|
class="anchor"
|
|
162
168
|
tabindex="0"
|
|
169
|
+
role=${this.disablePressListener ? d : "button"}
|
|
170
|
+
aria-controls=${this.tooltipId}
|
|
171
|
+
aria-expanded=${this.disablePressListener ? d : String(this.show)}
|
|
172
|
+
aria-describedby=${this.show ? this.tooltipId : d}
|
|
173
|
+
aria-label="open tooltip"
|
|
163
174
|
@mouseover="${this.handleAnchorMouseOver}"
|
|
164
175
|
@mouseout="${this.handleAnchorMouseOut}"
|
|
165
176
|
@pointerdown="${this.handleAnchorPointerDown}"
|
|
@@ -172,45 +183,48 @@ let s = class extends $(w) {
|
|
|
172
183
|
`;
|
|
173
184
|
}
|
|
174
185
|
};
|
|
175
|
-
s.styles = [
|
|
186
|
+
s.styles = [M];
|
|
176
187
|
r([
|
|
177
188
|
l({ type: String, reflect: !0 })
|
|
178
189
|
], s.prototype, "mode", 2);
|
|
179
190
|
r([
|
|
180
|
-
l({ type: Boolean, reflect: !0, converter:
|
|
191
|
+
l({ type: Boolean, reflect: !0, converter: u })
|
|
181
192
|
], s.prototype, "show", 2);
|
|
182
193
|
r([
|
|
183
|
-
l({ type: Boolean, reflect: !0, converter:
|
|
194
|
+
l({ type: Boolean, reflect: !0, converter: u, attribute: "disable-hover-listener" })
|
|
184
195
|
], s.prototype, "disableHoverListener", 2);
|
|
185
196
|
r([
|
|
186
|
-
l({ type: Boolean, reflect: !0, converter:
|
|
197
|
+
l({ type: Boolean, reflect: !0, converter: u, attribute: "disable-focus-listener" })
|
|
187
198
|
], s.prototype, "disableFocusListener", 2);
|
|
188
199
|
r([
|
|
189
|
-
l({ type: Boolean, reflect: !0, converter:
|
|
200
|
+
l({ type: Boolean, reflect: !0, converter: u, attribute: "disable-press-listener" })
|
|
190
201
|
], s.prototype, "disablePressListener", 2);
|
|
191
202
|
r([
|
|
192
|
-
|
|
203
|
+
b()
|
|
193
204
|
], s.prototype, "tooltopPlacement", 2);
|
|
194
205
|
r([
|
|
195
|
-
|
|
206
|
+
b()
|
|
207
|
+
], s.prototype, "tooltipId", 2);
|
|
208
|
+
r([
|
|
209
|
+
f(".container")
|
|
196
210
|
], s.prototype, "container", 2);
|
|
197
211
|
r([
|
|
198
|
-
|
|
212
|
+
f("#button")
|
|
199
213
|
], s.prototype, "anchorContainer", 2);
|
|
200
214
|
r([
|
|
201
|
-
|
|
215
|
+
f("#arrow")
|
|
202
216
|
], s.prototype, "arrow", 2);
|
|
203
217
|
r([
|
|
204
|
-
|
|
218
|
+
p({ slot: "" })
|
|
205
219
|
], s.prototype, "anchorElements", 2);
|
|
206
220
|
r([
|
|
207
|
-
|
|
221
|
+
p({ slot: "header" })
|
|
208
222
|
], s.prototype, "headerElements", 2);
|
|
209
223
|
r([
|
|
210
|
-
|
|
224
|
+
p({ slot: "close-button" })
|
|
211
225
|
], s.prototype, "closeButtonElements", 2);
|
|
212
226
|
r([
|
|
213
|
-
|
|
227
|
+
p({ slot: "content" })
|
|
214
228
|
], s.prototype, "contentElements", 2);
|
|
215
229
|
s = r([
|
|
216
230
|
v("ds-tooltip")
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const THEME_STORAGE_KEY: "@cupra/ui-kit/theme";
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
import { THEME_STORAGE_KEY as i } from "../core/theme.constants.js";
|
|
1
2
|
import { pubSub as n } from "./PubSub.js";
|
|
2
3
|
class c {
|
|
3
4
|
constructor() {
|
|
4
5
|
this.icons = {}, this.handleChangeTheme = (t) => {
|
|
5
6
|
this.theme = t;
|
|
6
7
|
const h = Object.keys(this.icons);
|
|
7
|
-
this.icons = {}, h.forEach((
|
|
8
|
+
this.icons = {}, h.forEach((e) => this.fetchIcon(e));
|
|
8
9
|
}, this.fetchIcon = async (t, h = {}) => {
|
|
9
|
-
|
|
10
|
+
const e = sessionStorage == null ? void 0 : sessionStorage.getItem(i);
|
|
11
|
+
!this.theme && e && (this.theme = e);
|
|
10
12
|
const s = await this.getCachedIcon(t);
|
|
11
13
|
return s || (this.icons[t] = this.loadIcon(t, h), this.icons[t]);
|
|
12
14
|
}, n.subscribe("theme", this.handleChangeTheme);
|
|
@@ -17,14 +19,14 @@ class c {
|
|
|
17
19
|
getCachedIcon(t) {
|
|
18
20
|
return this.icons[t];
|
|
19
21
|
}
|
|
20
|
-
loadIcon(t, { cache: h = "force-cache", ...
|
|
22
|
+
loadIcon(t, { cache: h = "force-cache", ...e }) {
|
|
21
23
|
return this.theme ? fetch(`https://ds-assets.cupra.com/icons/${this.theme}/${t}.svg`, {
|
|
22
24
|
cache: h,
|
|
23
|
-
...
|
|
24
|
-
}).then((
|
|
25
|
+
...e
|
|
26
|
+
}).then((s) => s.text()).catch((s) => ((s == null ? void 0 : s.name) !== "AbortError" && console.error(`Failed to fetch icon "${t}":`, s), "")) : Promise.resolve('<svg class="ds-icon"></svg>');
|
|
25
27
|
}
|
|
26
28
|
}
|
|
27
|
-
const
|
|
29
|
+
const r = c.getInstance();
|
|
28
30
|
export {
|
|
29
|
-
|
|
31
|
+
r as iconsManager
|
|
30
32
|
};
|
package/dist/utils/PubSub.d.ts
CHANGED
|
@@ -5,11 +5,9 @@ type LastPublishedData = {
|
|
|
5
5
|
[key: string]: any;
|
|
6
6
|
};
|
|
7
7
|
export declare class PubSub {
|
|
8
|
-
private static instance;
|
|
9
8
|
subscribers: Subscribers;
|
|
10
9
|
lastPublishedData: LastPublishedData;
|
|
11
10
|
constructor();
|
|
12
|
-
static getInstance(): PubSub;
|
|
13
11
|
subscribe(event: string, callback: Function): any;
|
|
14
12
|
unsubscribe(event: string, callback: Function): void;
|
|
15
13
|
publish(event: string, data: unknown): void;
|
package/dist/utils/PubSub.js
CHANGED
|
@@ -1,28 +1,33 @@
|
|
|
1
|
-
class
|
|
1
|
+
class c {
|
|
2
2
|
constructor() {
|
|
3
3
|
this.subscribers = {}, this.lastPublishedData = {};
|
|
4
4
|
}
|
|
5
|
-
static getInstance() {
|
|
6
|
-
return i.instance || (i.instance = new i()), i.instance;
|
|
7
|
-
}
|
|
8
5
|
subscribe(s, r) {
|
|
9
6
|
return this.subscribers[s] || (this.subscribers[s] = []), this.subscribers[s].push(r), this.lastPublishedData[s];
|
|
10
7
|
}
|
|
11
8
|
unsubscribe(s, r) {
|
|
12
|
-
this.subscribers[s] && (this.subscribers[s] = this.subscribers[s].filter((
|
|
9
|
+
this.subscribers[s] && (this.subscribers[s] = this.subscribers[s].filter((i) => i !== r));
|
|
13
10
|
}
|
|
14
11
|
publish(s, r) {
|
|
15
|
-
this.lastPublishedData[s] = r, this.subscribers[s] && this.subscribers[s].forEach((
|
|
12
|
+
this.lastPublishedData[s] = r, this.subscribers[s] && this.subscribers[s].forEach((i) => {
|
|
16
13
|
try {
|
|
17
|
-
|
|
18
|
-
} catch (
|
|
19
|
-
console.error(`Error in subscriber for event "${s}":`,
|
|
14
|
+
i(r);
|
|
15
|
+
} catch (e) {
|
|
16
|
+
console.error(`Error in subscriber for event "${s}":`, e);
|
|
20
17
|
}
|
|
21
18
|
});
|
|
22
19
|
}
|
|
23
20
|
}
|
|
24
|
-
const
|
|
21
|
+
const u = Symbol.for("@cupra/ui-kit/pubsub"), t = globalThis;
|
|
22
|
+
let b = t[u];
|
|
23
|
+
b || (b = new c(), Object.defineProperty(t, u, {
|
|
24
|
+
value: b,
|
|
25
|
+
writable: !1,
|
|
26
|
+
configurable: !1,
|
|
27
|
+
enumerable: !1
|
|
28
|
+
}));
|
|
29
|
+
const a = b;
|
|
25
30
|
export {
|
|
26
|
-
|
|
27
|
-
|
|
31
|
+
c as PubSub,
|
|
32
|
+
a as pubSub
|
|
28
33
|
};
|
|
@@ -5,7 +5,7 @@ class s {
|
|
|
5
5
|
theme: t
|
|
6
6
|
}) => {
|
|
7
7
|
if (!t || !e) return;
|
|
8
|
-
const c = `https://ds-assets.cupra.com/1.0.0-canary.
|
|
8
|
+
const c = `https://ds-assets.cupra.com/1.0.0-canary.17/styles/${t}/components/${e}.css`, r = this.getCachedStyleSheetPromise({ url: c });
|
|
9
9
|
if (r) return r;
|
|
10
10
|
const i = this.fetchStyle({ url: c }).then((n) => (n || this.stylePromises.delete(c), n));
|
|
11
11
|
return this.stylePromises.set(c, i), this.stylePromises.get(c);
|
|
@@ -3,7 +3,7 @@ import "../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/lit-html.js";
|
|
|
3
3
|
import "../node_modules/.pnpm/lit-element@4.2.1/node_modules/lit-element/lit-element.js";
|
|
4
4
|
import { unsafeCSS as n, css as o } from "../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/css-tag.js";
|
|
5
5
|
function x(t, ...r) {
|
|
6
|
-
const e = String.raw({ raw: t }, ...r).replace(/(--private-[\w-]+)(?=\s*[):,])/g, "$1-v1-0-0-canary-
|
|
6
|
+
const e = String.raw({ raw: t }, ...r).replace(/(--private-[\w-]+)(?=\s*[):,])/g, "$1-v1-0-0-canary-17"), i = n(e);
|
|
7
7
|
return o`${i}`;
|
|
8
8
|
}
|
|
9
9
|
export {
|
|
@@ -3,7 +3,7 @@ import { html as n } from "../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit
|
|
|
3
3
|
import "../node_modules/.pnpm/lit-element@4.2.1/node_modules/lit-element/lit-element.js";
|
|
4
4
|
import { unsafeHTML as i } from "../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/directives/unsafe-html.js";
|
|
5
5
|
function x(t, ...r) {
|
|
6
|
-
const o = String.raw({ raw: t }, ...r).replace(/(--private-[\w-]+)(?=\s*[):,])/g, "$1-v1-0-0-canary-
|
|
6
|
+
const o = String.raw({ raw: t }, ...r).replace(/(--private-[\w-]+)(?=\s*[):,])/g, "$1-v1-0-0-canary-17"), e = i(o);
|
|
7
7
|
return n`${e}`;
|
|
8
8
|
}
|
|
9
9
|
export {
|
|
@@ -1,31 +1,33 @@
|
|
|
1
|
-
import { themeContext as
|
|
2
|
-
import {
|
|
1
|
+
import { themeContext as m } from "../ds-theme-provider/themeContext.js";
|
|
2
|
+
import { THEME_STORAGE_KEY as d } from "../../core/theme.constants.js";
|
|
3
|
+
import { consume as u } from "../../node_modules/.pnpm/@lit_context@1.1.6/node_modules/@lit/context/lib/decorators/consume.js";
|
|
3
4
|
import { pubSub as p } from "../../utils/PubSub.js";
|
|
4
|
-
import { stylesRegistry as
|
|
5
|
+
import { stylesRegistry as S } from "../../utils/StylesRegistry/StylesRegistry.js";
|
|
5
6
|
import "../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/reactive-element.js";
|
|
6
7
|
import "../../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/lit-html.js";
|
|
7
8
|
import { LitElement as y } from "../../node_modules/.pnpm/lit-element@4.2.1/node_modules/lit-element/lit-element.js";
|
|
8
|
-
import { property as
|
|
9
|
-
import { state as
|
|
10
|
-
import { css as
|
|
11
|
-
var
|
|
9
|
+
import { property as b } from "../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/property.js";
|
|
10
|
+
import { state as f } from "../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/state.js";
|
|
11
|
+
import { css as C, adoptStyles as T } from "../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/css-tag.js";
|
|
12
|
+
var g = Object.defineProperty, l = (n, e, t, i) => {
|
|
12
13
|
for (var o = void 0, a = n.length - 1, s; a >= 0; a--)
|
|
13
14
|
(s = n[a]) && (o = s(e, t, o) || o);
|
|
14
|
-
return o &&
|
|
15
|
+
return o && g(e, t, o), o;
|
|
15
16
|
};
|
|
16
|
-
const
|
|
17
|
+
const E = C`:host([unresolved]){visibility:hidden}`, h = class c extends y {
|
|
17
18
|
constructor() {
|
|
18
19
|
super(), this.appliedConstructables = [], this.appliedStyleTags = [], this.handleChangeTheme = (e) => {
|
|
19
20
|
this.pubSubTheme = e;
|
|
20
21
|
}, this.pubSubTheme = p.subscribe("theme", this.handleChangeTheme);
|
|
21
22
|
}
|
|
22
23
|
get theme() {
|
|
23
|
-
|
|
24
|
+
const e = sessionStorage == null ? void 0 : sessionStorage.getItem(d);
|
|
25
|
+
return this.contextTheme ?? this.pubSubTheme ?? e;
|
|
24
26
|
}
|
|
25
27
|
connectedCallback() {
|
|
26
28
|
super.connectedCallback(), this.shadowRoot || this.attachShadow({ mode: "open" }), this.setAttribute("unresolved", "");
|
|
27
29
|
const e = this.constructor, t = Array.isArray(e.styles) ? e.styles : [e.styles].filter(Boolean);
|
|
28
|
-
|
|
30
|
+
T(this.shadowRoot, [...t, E]), this.applyThemeStyles();
|
|
29
31
|
}
|
|
30
32
|
disconnectedCallback() {
|
|
31
33
|
super.disconnectedCallback(), p.unsubscribe("theme", this.handleChangeTheme);
|
|
@@ -48,7 +50,7 @@ const g = f`:host([unresolved]){visibility:hidden}`, h = class c extends y {
|
|
|
48
50
|
if (!(!this.theme || !(e != null && e.length)))
|
|
49
51
|
try {
|
|
50
52
|
const t = await Promise.all(
|
|
51
|
-
e.map((s) =>
|
|
53
|
+
e.map((s) => S.getStyles({ componentName: s, theme: this.theme }))
|
|
52
54
|
), i = this.supportsAdoptedSheets(), o = this.shadowRoot.adoptedStyleSheets || [], a = this.appliedConstructables ? o.filter((s) => !this.appliedConstructables.includes(s)) : o;
|
|
53
55
|
this.appliedConstructables = [], this.appliedStyleTags.forEach((s) => s.remove()), this.appliedStyleTags = [], t.forEach((s) => {
|
|
54
56
|
if (s)
|
|
@@ -68,11 +70,11 @@ const g = f`:host([unresolved]){visibility:hidden}`, h = class c extends y {
|
|
|
68
70
|
}
|
|
69
71
|
};
|
|
70
72
|
l([
|
|
71
|
-
|
|
72
|
-
|
|
73
|
+
b({ attribute: !1 }),
|
|
74
|
+
u({ context: m, subscribe: !0 })
|
|
73
75
|
], h.prototype, "contextTheme");
|
|
74
76
|
l([
|
|
75
|
-
|
|
77
|
+
f()
|
|
76
78
|
], h.prototype, "pubSubTheme");
|
|
77
79
|
let N = h;
|
|
78
80
|
export {
|
|
@@ -1,31 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { THEME_STORAGE_KEY as p } from "../../core/theme.constants.js";
|
|
2
|
+
import { customUiKitElement as f } from "../../decorators/customUiKitElement.js";
|
|
3
|
+
import { provide as c } from "../../node_modules/.pnpm/@lit_context@1.1.6/node_modules/@lit/context/lib/decorators/provide.js";
|
|
4
|
+
import { pubSub as u } from "../../utils/PubSub.js";
|
|
4
5
|
import { booleanConverter as i } from "../../utils/booleanConverter.js";
|
|
5
6
|
import "../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/reactive-element.js";
|
|
6
|
-
import { nothing as
|
|
7
|
-
import { LitElement as
|
|
8
|
-
import { property as
|
|
7
|
+
import { nothing as y, html as $ } from "../../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/lit-html.js";
|
|
8
|
+
import { LitElement as v } from "../../node_modules/.pnpm/lit-element@4.2.1/node_modules/lit-element/lit-element.js";
|
|
9
|
+
import { property as d } from "../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/property.js";
|
|
9
10
|
import { state as l } from "../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/state.js";
|
|
10
|
-
import { fontsConfig as
|
|
11
|
-
import { themeContext as
|
|
12
|
-
var
|
|
13
|
-
for (var e = r > 1 ? void 0 : r ?
|
|
11
|
+
import { fontsConfig as F } from "../../styles/fonts-config.js";
|
|
12
|
+
import { themeContext as S } from "./themeContext.js";
|
|
13
|
+
var w = Object.defineProperty, E = Object.getOwnPropertyDescriptor, h = (t, o, s, r) => {
|
|
14
|
+
for (var e = r > 1 ? void 0 : r ? E(o, s) : o, a = t.length - 1, n; a >= 0; a--)
|
|
14
15
|
(n = t[a]) && (e = (r ? n(o, s, e) : n(e)) || e);
|
|
15
|
-
return r && e &&
|
|
16
|
+
return r && e && w(o, s, e), e;
|
|
16
17
|
};
|
|
17
|
-
let m = class extends
|
|
18
|
+
let m = class extends v {
|
|
18
19
|
constructor() {
|
|
19
20
|
super(...arguments), this.loadFonts = !0, this.loadStyles = !0, this.cssLoaded = !1, this.loadedFonts = /* @__PURE__ */ new Set();
|
|
20
21
|
}
|
|
21
22
|
updated(t) {
|
|
22
|
-
super.updated(t), t.has("theme") && (
|
|
23
|
+
super.updated(t), t.has("theme") && (u.publish("theme", this.theme), sessionStorage == null || sessionStorage.setItem(p, this.theme), this.loadThemeFonts(), this.loadThemeStyles().then(() => {
|
|
23
24
|
this.cssLoaded = !0;
|
|
24
25
|
}));
|
|
25
26
|
}
|
|
26
27
|
loadThemeFonts() {
|
|
27
28
|
var t;
|
|
28
|
-
(t =
|
|
29
|
+
(t = F[this.theme]) == null || t.fonts.forEach((o) => {
|
|
29
30
|
this.loadThemeFont(o);
|
|
30
31
|
});
|
|
31
32
|
}
|
|
@@ -53,7 +54,7 @@ let m = class extends $ {
|
|
|
53
54
|
}
|
|
54
55
|
loadThemeStyles() {
|
|
55
56
|
return this.loadStyles ? new Promise((t, o) => {
|
|
56
|
-
const s = "/1.0.0-canary.
|
|
57
|
+
const s = "/1.0.0-canary.17", r = `https://ds-assets.cupra.com${s}/styles/${this.theme}/theme.css`;
|
|
57
58
|
if (document.head.querySelector(`link[href="${r}"]`)) t();
|
|
58
59
|
else {
|
|
59
60
|
const e = `ui-kit-theme-${s}`, a = document.getElementById(e), n = document.createElement("link");
|
|
@@ -62,27 +63,27 @@ let m = class extends $ {
|
|
|
62
63
|
}) : Promise.resolve();
|
|
63
64
|
}
|
|
64
65
|
render() {
|
|
65
|
-
return this.cssLoaded ?
|
|
66
|
+
return this.cssLoaded ? $`<slot></slot>` : y;
|
|
66
67
|
}
|
|
67
68
|
};
|
|
68
|
-
|
|
69
|
-
|
|
69
|
+
h([
|
|
70
|
+
d({ type: Boolean, converter: i, attribute: "load-fonts" })
|
|
70
71
|
], m.prototype, "loadFonts", 2);
|
|
71
|
-
|
|
72
|
-
|
|
72
|
+
h([
|
|
73
|
+
d({ type: Boolean, converter: i, attribute: "load-styles" })
|
|
73
74
|
], m.prototype, "loadStyles", 2);
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
h([
|
|
76
|
+
c({ context: S }),
|
|
77
|
+
d({ type: String })
|
|
77
78
|
], m.prototype, "theme", 2);
|
|
78
|
-
|
|
79
|
+
h([
|
|
79
80
|
l()
|
|
80
81
|
], m.prototype, "cssLoaded", 2);
|
|
81
|
-
|
|
82
|
+
h([
|
|
82
83
|
l()
|
|
83
84
|
], m.prototype, "loadedFonts", 2);
|
|
84
|
-
m =
|
|
85
|
-
|
|
85
|
+
m = h([
|
|
86
|
+
f("ds-theme-provider")
|
|
86
87
|
], m);
|
|
87
88
|
export {
|
|
88
89
|
m as DsThemeProvider
|
|
@@ -11,6 +11,7 @@ export declare class DsTooltip extends DsTooltip_base {
|
|
|
11
11
|
disableFocusListener: DsTooltipAttrs['disable-focus-listener'];
|
|
12
12
|
disablePressListener: DsTooltipAttrs['disable-press-listener'];
|
|
13
13
|
protected tooltopPlacement: Placement;
|
|
14
|
+
private tooltipId;
|
|
14
15
|
protected container: HTMLInputElement;
|
|
15
16
|
protected anchorContainer: HTMLInputElement;
|
|
16
17
|
protected arrow: HTMLInputElement;
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import { UiKitElement as
|
|
1
|
+
import { UiKitElement as y } from "../base/UiKitElement.js";
|
|
2
2
|
import { customUiKitElement as v } from "../../decorators/customUiKitElement.js";
|
|
3
|
-
import { computePosition as
|
|
4
|
-
import { ViewportMixin as
|
|
5
|
-
import { booleanConverter as
|
|
6
|
-
import { debounce as
|
|
7
|
-
import { htmlWithTokens as
|
|
3
|
+
import { computePosition as g, flip as $, shift as P, offset as L, arrow as E, size as C } from "../../node_modules/.pnpm/@floating-ui_dom@1.7.4/node_modules/@floating-ui/dom/dist/floating-ui.dom.js";
|
|
4
|
+
import { ViewportMixin as x } from "../../mixins/ViewportMixin.js";
|
|
5
|
+
import { booleanConverter as u } from "../../utils/booleanConverter.js";
|
|
6
|
+
import { debounce as O } from "../../utils/debounce.js";
|
|
7
|
+
import { htmlWithTokens as A } from "../../utils/htmlWithTokens.js";
|
|
8
8
|
import "../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/reactive-element.js";
|
|
9
|
-
import { html as
|
|
9
|
+
import { html as m, nothing as d } from "../../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/lit-html.js";
|
|
10
10
|
import "../../node_modules/.pnpm/lit-element@4.2.1/node_modules/lit-element/lit-element.js";
|
|
11
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
|
|
13
|
-
import { query as
|
|
14
|
-
import { queryAssignedElements as
|
|
15
|
-
import { classMap as
|
|
16
|
-
import { commonStyles as
|
|
17
|
-
var
|
|
18
|
-
for (var
|
|
19
|
-
(a = e[h]) && (
|
|
20
|
-
return
|
|
12
|
+
import { state as b } from "../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/state.js";
|
|
13
|
+
import { query as f } from "../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/query.js";
|
|
14
|
+
import { queryAssignedElements as p } from "../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/query-assigned-elements.js";
|
|
15
|
+
import { classMap as c } from "../../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/directives/class-map.js";
|
|
16
|
+
import { commonStyles as M } from "./styles/common.styles.js";
|
|
17
|
+
var D = Object.defineProperty, F = Object.getOwnPropertyDescriptor, r = (e, t, o, n) => {
|
|
18
|
+
for (var i = n > 1 ? void 0 : n ? F(t, o) : t, h = e.length - 1, a; h >= 0; h--)
|
|
19
|
+
(a = e[h]) && (i = (n ? a(t, o, i) : a(i)) || i);
|
|
20
|
+
return n && i && D(t, o, i), i;
|
|
21
21
|
};
|
|
22
|
-
let s = class extends
|
|
22
|
+
let s = class extends x(y) {
|
|
23
23
|
constructor() {
|
|
24
|
-
super(...arguments), this.mode = "light", this.show = !1, this.disableHoverListener = !1, this.disableFocusListener = !1, this.disablePressListener = !1, this.usingKeyboard = !1, this.handleKeyDown = () => {
|
|
24
|
+
super(...arguments), this.mode = "light", this.show = !1, this.disableHoverListener = !1, this.disableFocusListener = !1, this.disablePressListener = !1, this.tooltipId = `ds-tooltip-${Date.now()}-${Math.floor(Math.random() * 1e6)}`, this.usingKeyboard = !1, this.handleKeyDown = () => {
|
|
25
25
|
this.usingKeyboard = !0;
|
|
26
26
|
}, this.handlePointerDown = () => {
|
|
27
27
|
this.usingKeyboard = !1;
|
|
28
|
-
}, this.handleResize =
|
|
28
|
+
}, this.handleResize = O({ func: () => this.requestUpdate() }), this.handleClose = () => {
|
|
29
29
|
this.show = !1;
|
|
30
30
|
}, this.handleAnchorPointerDown = (e) => {
|
|
31
31
|
this.disablePressListener || e.button === 0 && (this.show = !this.show);
|
|
@@ -33,8 +33,8 @@ let s = class extends $(w) {
|
|
|
33
33
|
this.disableHoverListener || (this.show = !0);
|
|
34
34
|
}, this.handleAnchorMouseOut = () => {
|
|
35
35
|
this.disableHoverListener || setTimeout(() => {
|
|
36
|
-
var e, t, o,
|
|
37
|
-
!((t = (e = this.container) == null ? void 0 : e.matches) != null && t.call(e, ":hover")) && !((
|
|
36
|
+
var e, t, o, n, i;
|
|
37
|
+
!((t = (e = this.container) == null ? void 0 : e.matches) != null && t.call(e, ":hover")) && !((n = (o = this.arrow) == null ? void 0 : o.matches) != null && n.call(o, ":hover")) && !((i = this == null ? void 0 : this.matches) != null && i.call(this, ":hover")) && (this.show = !1);
|
|
38
38
|
}, 150);
|
|
39
39
|
}, this.handleAnchorFocusIn = () => {
|
|
40
40
|
this.usingKeyboard && (this.disableFocusListener || (this.show = !0));
|
|
@@ -56,16 +56,16 @@ let s = class extends $(w) {
|
|
|
56
56
|
updatePosition() {
|
|
57
57
|
requestAnimationFrame(() => {
|
|
58
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) || (
|
|
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) || (g(this.anchorContainer, this.container, {
|
|
60
60
|
placement: "bottom-start",
|
|
61
61
|
middleware: [
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
$(),
|
|
63
|
+
P(),
|
|
64
|
+
L(8),
|
|
65
65
|
E({ element: this.arrow }),
|
|
66
|
-
|
|
67
|
-
apply({ availableWidth: t, availableHeight: o, elements:
|
|
68
|
-
Object.assign(
|
|
66
|
+
C({
|
|
67
|
+
apply({ availableWidth: t, availableHeight: o, elements: n }) {
|
|
68
|
+
Object.assign(n.floating.style, {
|
|
69
69
|
maxWidth: `${Math.min(240, t - 8)}px`,
|
|
70
70
|
maxHeight: `${Math.max(0, o - 8)}px`
|
|
71
71
|
});
|
|
@@ -73,15 +73,15 @@ let s = class extends $(w) {
|
|
|
73
73
|
})
|
|
74
74
|
]
|
|
75
75
|
}).then((t) => {
|
|
76
|
-
const { x: o, y:
|
|
76
|
+
const { x: o, y: n, middlewareData: i, placement: h } = t;
|
|
77
77
|
if (this.tooltopPlacement = h, Object.assign(this.container.style, {
|
|
78
78
|
left: `${o ?? 0}px`,
|
|
79
|
-
top: `${
|
|
80
|
-
}),
|
|
81
|
-
const { x: a, y:
|
|
79
|
+
top: `${n ?? 0}px`
|
|
80
|
+
}), i.arrow) {
|
|
81
|
+
const { x: a, y: w } = i.arrow;
|
|
82
82
|
Object.assign(this.arrow.style, {
|
|
83
83
|
left: a != null ? `${a}px` : "",
|
|
84
|
-
top:
|
|
84
|
+
top: w != null ? `${w}px` : ""
|
|
85
85
|
});
|
|
86
86
|
}
|
|
87
87
|
}), this.requestUpdate());
|
|
@@ -119,28 +119,34 @@ let s = class extends $(w) {
|
|
|
119
119
|
};
|
|
120
120
|
}
|
|
121
121
|
get arrowTemplate() {
|
|
122
|
-
return
|
|
123
|
-
<svg id="arrow" xmlns="http://www.w3.org/2000/svg" width="17" height="9" viewBox="0 0 17 9" fill="none" class=${
|
|
122
|
+
return m`
|
|
123
|
+
<svg id="arrow" xmlns="http://www.w3.org/2000/svg" width="17" height="9" viewBox="0 0 17 9" fill="none" class=${c(this.arrowClasses)} @mouseout="${this.handleAnchorMouseOut}" aria-hidden="true" focusable="false">
|
|
124
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
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
126
|
</svg>`;
|
|
127
127
|
}
|
|
128
128
|
get tooltipTemplate() {
|
|
129
|
-
return this.show && this.anchorElements.length > 0 ?
|
|
130
|
-
<div
|
|
131
|
-
|
|
129
|
+
return this.show && this.anchorElements.length > 0 ? m`
|
|
130
|
+
<div
|
|
131
|
+
id=${this.tooltipId}
|
|
132
|
+
part="container"
|
|
133
|
+
class=${c(this.containerClasses)}
|
|
134
|
+
@mouseout=${this.handleAnchorMouseOut}
|
|
135
|
+
role="tooltip"
|
|
136
|
+
>
|
|
137
|
+
<header part="header" class=${c(this.headerClasses)}>
|
|
132
138
|
<slot @slotchange=${this.updatePosition} name="header"></slot>
|
|
133
139
|
<slot @slotchange=${this.updatePosition} name="close-button" @click=${this.handleClose}></slot>
|
|
134
140
|
</header>
|
|
135
|
-
<div part="content" class=${
|
|
141
|
+
<div part="content" class=${c(this.contentClasses)}>
|
|
136
142
|
<slot @slotchange=${this.updatePosition} name="content"></slot>
|
|
137
143
|
</div>
|
|
138
144
|
<slot part="image" @slotchange=${this.updatePosition} name="image"></slot>
|
|
139
145
|
${this.arrowTemplate}
|
|
140
|
-
</div>` :
|
|
146
|
+
</div>` : d;
|
|
141
147
|
}
|
|
142
148
|
get styleTokens() {
|
|
143
|
-
return
|
|
149
|
+
return A`
|
|
144
150
|
<style>
|
|
145
151
|
:host {
|
|
146
152
|
color-scheme: ${this.mode};
|
|
@@ -149,17 +155,22 @@ let s = class extends $(w) {
|
|
|
149
155
|
`;
|
|
150
156
|
}
|
|
151
157
|
render() {
|
|
152
|
-
return
|
|
158
|
+
return m`
|
|
153
159
|
<style>
|
|
154
160
|
.anchor {
|
|
155
161
|
cursor: ${this.disablePressListener ? "default" : "pointer"};
|
|
156
162
|
}
|
|
157
163
|
</style>
|
|
158
164
|
${this.styleTokens}
|
|
159
|
-
<div
|
|
165
|
+
<div
|
|
160
166
|
id="button"
|
|
161
167
|
class="anchor"
|
|
162
168
|
tabindex="0"
|
|
169
|
+
role=${this.disablePressListener ? d : "button"}
|
|
170
|
+
aria-controls=${this.tooltipId}
|
|
171
|
+
aria-expanded=${this.disablePressListener ? d : String(this.show)}
|
|
172
|
+
aria-describedby=${this.show ? this.tooltipId : d}
|
|
173
|
+
aria-label="open tooltip"
|
|
163
174
|
@mouseover="${this.handleAnchorMouseOver}"
|
|
164
175
|
@mouseout="${this.handleAnchorMouseOut}"
|
|
165
176
|
@pointerdown="${this.handleAnchorPointerDown}"
|
|
@@ -172,45 +183,48 @@ let s = class extends $(w) {
|
|
|
172
183
|
`;
|
|
173
184
|
}
|
|
174
185
|
};
|
|
175
|
-
s.styles = [
|
|
186
|
+
s.styles = [M];
|
|
176
187
|
r([
|
|
177
188
|
l({ type: String, reflect: !0 })
|
|
178
189
|
], s.prototype, "mode", 2);
|
|
179
190
|
r([
|
|
180
|
-
l({ type: Boolean, reflect: !0, converter:
|
|
191
|
+
l({ type: Boolean, reflect: !0, converter: u })
|
|
181
192
|
], s.prototype, "show", 2);
|
|
182
193
|
r([
|
|
183
|
-
l({ type: Boolean, reflect: !0, converter:
|
|
194
|
+
l({ type: Boolean, reflect: !0, converter: u, attribute: "disable-hover-listener" })
|
|
184
195
|
], s.prototype, "disableHoverListener", 2);
|
|
185
196
|
r([
|
|
186
|
-
l({ type: Boolean, reflect: !0, converter:
|
|
197
|
+
l({ type: Boolean, reflect: !0, converter: u, attribute: "disable-focus-listener" })
|
|
187
198
|
], s.prototype, "disableFocusListener", 2);
|
|
188
199
|
r([
|
|
189
|
-
l({ type: Boolean, reflect: !0, converter:
|
|
200
|
+
l({ type: Boolean, reflect: !0, converter: u, attribute: "disable-press-listener" })
|
|
190
201
|
], s.prototype, "disablePressListener", 2);
|
|
191
202
|
r([
|
|
192
|
-
|
|
203
|
+
b()
|
|
193
204
|
], s.prototype, "tooltopPlacement", 2);
|
|
194
205
|
r([
|
|
195
|
-
|
|
206
|
+
b()
|
|
207
|
+
], s.prototype, "tooltipId", 2);
|
|
208
|
+
r([
|
|
209
|
+
f(".container")
|
|
196
210
|
], s.prototype, "container", 2);
|
|
197
211
|
r([
|
|
198
|
-
|
|
212
|
+
f("#button")
|
|
199
213
|
], s.prototype, "anchorContainer", 2);
|
|
200
214
|
r([
|
|
201
|
-
|
|
215
|
+
f("#arrow")
|
|
202
216
|
], s.prototype, "arrow", 2);
|
|
203
217
|
r([
|
|
204
|
-
|
|
218
|
+
p({ slot: "" })
|
|
205
219
|
], s.prototype, "anchorElements", 2);
|
|
206
220
|
r([
|
|
207
|
-
|
|
221
|
+
p({ slot: "header" })
|
|
208
222
|
], s.prototype, "headerElements", 2);
|
|
209
223
|
r([
|
|
210
|
-
|
|
224
|
+
p({ slot: "close-button" })
|
|
211
225
|
], s.prototype, "closeButtonElements", 2);
|
|
212
226
|
r([
|
|
213
|
-
|
|
227
|
+
p({ slot: "content" })
|
|
214
228
|
], s.prototype, "contentElements", 2);
|
|
215
229
|
s = r([
|
|
216
230
|
v("ds-tooltip")
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const THEME_STORAGE_KEY: "@cupra/ui-kit/theme";
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
import { THEME_STORAGE_KEY as i } from "../core/theme.constants.js";
|
|
1
2
|
import { pubSub as n } from "./PubSub.js";
|
|
2
3
|
class c {
|
|
3
4
|
constructor() {
|
|
4
5
|
this.icons = {}, this.handleChangeTheme = (t) => {
|
|
5
6
|
this.theme = t;
|
|
6
7
|
const h = Object.keys(this.icons);
|
|
7
|
-
this.icons = {}, h.forEach((
|
|
8
|
+
this.icons = {}, h.forEach((e) => this.fetchIcon(e));
|
|
8
9
|
}, this.fetchIcon = async (t, h = {}) => {
|
|
9
|
-
|
|
10
|
+
const e = sessionStorage == null ? void 0 : sessionStorage.getItem(i);
|
|
11
|
+
!this.theme && e && (this.theme = e);
|
|
10
12
|
const s = await this.getCachedIcon(t);
|
|
11
13
|
return s || (this.icons[t] = this.loadIcon(t, h), this.icons[t]);
|
|
12
14
|
}, n.subscribe("theme", this.handleChangeTheme);
|
|
@@ -17,14 +19,14 @@ class c {
|
|
|
17
19
|
getCachedIcon(t) {
|
|
18
20
|
return this.icons[t];
|
|
19
21
|
}
|
|
20
|
-
loadIcon(t, { cache: h = "force-cache", ...
|
|
22
|
+
loadIcon(t, { cache: h = "force-cache", ...e }) {
|
|
21
23
|
return this.theme ? fetch(`https://ds-assets.cupra.com/icons/${this.theme}/${t}.svg`, {
|
|
22
24
|
cache: h,
|
|
23
|
-
...
|
|
24
|
-
}).then((
|
|
25
|
+
...e
|
|
26
|
+
}).then((s) => s.text()).catch((s) => ((s == null ? void 0 : s.name) !== "AbortError" && console.error(`Failed to fetch icon "${t}":`, s), "")) : Promise.resolve('<svg class="ds-icon"></svg>');
|
|
25
27
|
}
|
|
26
28
|
}
|
|
27
|
-
const
|
|
29
|
+
const r = c.getInstance();
|
|
28
30
|
export {
|
|
29
|
-
|
|
31
|
+
r as iconsManager
|
|
30
32
|
};
|
|
@@ -5,11 +5,9 @@ type LastPublishedData = {
|
|
|
5
5
|
[key: string]: any;
|
|
6
6
|
};
|
|
7
7
|
export declare class PubSub {
|
|
8
|
-
private static instance;
|
|
9
8
|
subscribers: Subscribers;
|
|
10
9
|
lastPublishedData: LastPublishedData;
|
|
11
10
|
constructor();
|
|
12
|
-
static getInstance(): PubSub;
|
|
13
11
|
subscribe(event: string, callback: Function): any;
|
|
14
12
|
unsubscribe(event: string, callback: Function): void;
|
|
15
13
|
publish(event: string, data: unknown): void;
|
|
@@ -1,28 +1,33 @@
|
|
|
1
|
-
class
|
|
1
|
+
class c {
|
|
2
2
|
constructor() {
|
|
3
3
|
this.subscribers = {}, this.lastPublishedData = {};
|
|
4
4
|
}
|
|
5
|
-
static getInstance() {
|
|
6
|
-
return i.instance || (i.instance = new i()), i.instance;
|
|
7
|
-
}
|
|
8
5
|
subscribe(s, r) {
|
|
9
6
|
return this.subscribers[s] || (this.subscribers[s] = []), this.subscribers[s].push(r), this.lastPublishedData[s];
|
|
10
7
|
}
|
|
11
8
|
unsubscribe(s, r) {
|
|
12
|
-
this.subscribers[s] && (this.subscribers[s] = this.subscribers[s].filter((
|
|
9
|
+
this.subscribers[s] && (this.subscribers[s] = this.subscribers[s].filter((i) => i !== r));
|
|
13
10
|
}
|
|
14
11
|
publish(s, r) {
|
|
15
|
-
this.lastPublishedData[s] = r, this.subscribers[s] && this.subscribers[s].forEach((
|
|
12
|
+
this.lastPublishedData[s] = r, this.subscribers[s] && this.subscribers[s].forEach((i) => {
|
|
16
13
|
try {
|
|
17
|
-
|
|
18
|
-
} catch (
|
|
19
|
-
console.error(`Error in subscriber for event "${s}":`,
|
|
14
|
+
i(r);
|
|
15
|
+
} catch (e) {
|
|
16
|
+
console.error(`Error in subscriber for event "${s}":`, e);
|
|
20
17
|
}
|
|
21
18
|
});
|
|
22
19
|
}
|
|
23
20
|
}
|
|
24
|
-
const
|
|
21
|
+
const u = Symbol.for("@cupra/ui-kit/pubsub"), t = globalThis;
|
|
22
|
+
let b = t[u];
|
|
23
|
+
b || (b = new c(), Object.defineProperty(t, u, {
|
|
24
|
+
value: b,
|
|
25
|
+
writable: !1,
|
|
26
|
+
configurable: !1,
|
|
27
|
+
enumerable: !1
|
|
28
|
+
}));
|
|
29
|
+
const a = b;
|
|
25
30
|
export {
|
|
26
|
-
|
|
27
|
-
|
|
31
|
+
c as PubSub,
|
|
32
|
+
a as pubSub
|
|
28
33
|
};
|
|
@@ -5,7 +5,7 @@ class s {
|
|
|
5
5
|
theme: t
|
|
6
6
|
}) => {
|
|
7
7
|
if (!t || !e) return;
|
|
8
|
-
const c = `https://ds-assets.cupra.com/1.0.0-canary.
|
|
8
|
+
const c = `https://ds-assets.cupra.com/1.0.0-canary.17/styles/${t}/components/${e}.css`, r = this.getCachedStyleSheetPromise({ url: c });
|
|
9
9
|
if (r) return r;
|
|
10
10
|
const i = this.fetchStyle({ url: c }).then((n) => (n || this.stylePromises.delete(c), n));
|
|
11
11
|
return this.stylePromises.set(c, i), this.stylePromises.get(c);
|
|
@@ -3,7 +3,7 @@ import "../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/lit-html.js";
|
|
|
3
3
|
import "../node_modules/.pnpm/lit-element@4.2.1/node_modules/lit-element/lit-element.js";
|
|
4
4
|
import { unsafeCSS as n, css as o } from "../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/css-tag.js";
|
|
5
5
|
function x(t, ...r) {
|
|
6
|
-
const e = String.raw({ raw: t }, ...r).replace(/(--private-[\w-]+)(?=\s*[):,])/g, "$1-v1-0-0-canary-
|
|
6
|
+
const e = String.raw({ raw: t }, ...r).replace(/(--private-[\w-]+)(?=\s*[):,])/g, "$1-v1-0-0-canary-17"), i = n(e);
|
|
7
7
|
return o`${i}`;
|
|
8
8
|
}
|
|
9
9
|
export {
|
|
@@ -3,7 +3,7 @@ import { html as n } from "../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit
|
|
|
3
3
|
import "../node_modules/.pnpm/lit-element@4.2.1/node_modules/lit-element/lit-element.js";
|
|
4
4
|
import { unsafeHTML as i } from "../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/directives/unsafe-html.js";
|
|
5
5
|
function x(t, ...r) {
|
|
6
|
-
const o = String.raw({ raw: t }, ...r).replace(/(--private-[\w-]+)(?=\s*[):,])/g, "$1-v1-0-0-canary-
|
|
6
|
+
const o = String.raw({ raw: t }, ...r).replace(/(--private-[\w-]+)(?=\s*[):,])/g, "$1-v1-0-0-canary-17"), e = i(o);
|
|
7
7
|
return n`${e}`;
|
|
8
8
|
}
|
|
9
9
|
export {
|