@cupra/ui-kit 1.0.0-canary.16 → 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/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/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
|
|
@@ -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
|
|
@@ -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 {
|