@proximus/lavender-price 1.4.14-beta.3 → 1.4.14
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/Price.d.ts +6 -6
- package/dist/index.es.js +94 -89
- package/package.json +1 -1
package/dist/Price.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export declare const priceVariantValues: string[];
|
|
|
3
3
|
export declare const priceSizeValues: string[];
|
|
4
4
|
export declare class Price extends PxElement<HTMLDivElement> {
|
|
5
5
|
static nativeName: string;
|
|
6
|
-
observer: MutationObserver
|
|
6
|
+
observer: MutationObserver;
|
|
7
7
|
private template;
|
|
8
8
|
constructor();
|
|
9
9
|
static get observedAttributes(): string[];
|
|
@@ -12,11 +12,11 @@ export declare class Price extends PxElement<HTMLDivElement> {
|
|
|
12
12
|
disconnectedCallback(): void;
|
|
13
13
|
toggleClass(oldValue: string, newValue: string): void;
|
|
14
14
|
updateAttribute(attrName: string, oldValue: string, newValue: string, attrValues: string[]): void;
|
|
15
|
-
buildPrice
|
|
16
|
-
get variant(): string
|
|
17
|
-
set variant(value: string
|
|
18
|
-
get size(): string
|
|
19
|
-
set size(value: string
|
|
15
|
+
buildPrice(): void;
|
|
16
|
+
get variant(): string;
|
|
17
|
+
set variant(value: string);
|
|
18
|
+
get size(): string;
|
|
19
|
+
set size(value: string);
|
|
20
20
|
get inverted(): boolean;
|
|
21
21
|
set inverted(value: boolean);
|
|
22
22
|
}
|
package/dist/index.es.js
CHANGED
|
@@ -1,90 +1,95 @@
|
|
|
1
|
-
import { PxElement as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
1
|
+
import { PxElement as c, log as l } from "@proximus/lavender-common";
|
|
2
|
+
const d = ".price{--price-s: var(--px-price-size-unit-s-mobile);--price-m: var(--px-price-size-unit-m-mobile);--price-l: var(--px-price-size-unit-l-mobile);font-family:var(--px-font-family);white-space:nowrap;font-weight:var(--px-font-weight-title);color:var(--px-color-text-brand-default);font-size:var(--price-s);line-height:var(--px-line-height-ratio-l)}@media screen and (min-width: 48rem){.price{--price-s: var(--px-price-size-unit-s-tablet);--price-m: var(--px-price-size-unit-m-tablet);--price-l: var(--px-price-size-unit-l-tablet)}}@media screen and (min-width: 64.0625rem){.price{--price-s: var(--px-price-size-unit-s-laptop);--price-m: var(--px-price-size-unit-m-laptop);--price-l: var(--px-price-size-unit-l-laptop)}}.promo,.free{color:var(--px-color-text-purpose-promo-default)}.neutral{color:var(--px-color-text-neutral-default)}.exceeding{color:var(--px-color-text-purpose-error-default)}.disabled{color:var(--px-color-text-state-disabled-default)}:host([inverted]) .price{color:var(--px-color-text-brand-inverted)}:host([inverted]) .promo,:host([inverted]) .free{color:var(--px-color-text-purpose-promo-inverted)}:host([inverted]) .neutral{color:var(--px-color-text-neutral-inverted)}:host([inverted]) .exceeding{color:var(--px-color-text-purpose-error-inverted)}:host([inverted]) .disabled{color:var(--px-color-text-state-disabled-inverted)}.price:not(.promo):not(.free) ::slotted(s){display:none}.euro{font-size:var(--px-price-ratio-l)}.decimals{font-size:var(--px-price-ratio-s)}.m{font-size:var(--price-m)}.l{font-size:var(--price-l)}", o = new CSSStyleSheet();
|
|
3
|
+
o.replaceSync(d);
|
|
4
|
+
const u = [
|
|
5
|
+
"default",
|
|
6
|
+
"promo",
|
|
7
|
+
"free",
|
|
8
|
+
"neutral",
|
|
9
|
+
"exceeding",
|
|
10
|
+
"disabled"
|
|
11
|
+
], v = ["", "s", "m", "l"], a = class a extends c {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(o), this.template = () => '<span class="price"></span>', this.shadowRoot.innerHTML = this.template();
|
|
14
|
+
}
|
|
15
|
+
static get observedAttributes() {
|
|
16
|
+
return [...super.observedAttributes, "variant", "size", "inverted"];
|
|
17
|
+
}
|
|
18
|
+
connectedCallback() {
|
|
19
|
+
this.buildPrice(), this.observer = new MutationObserver(() => {
|
|
20
|
+
this.buildPrice();
|
|
21
|
+
}), this.observer.observe(this, {
|
|
22
|
+
childList: !0,
|
|
23
|
+
subtree: !0,
|
|
24
|
+
// By observing characterData, we ensure that any changes to the text content of the price element will trigger a rebuild of the price display, allowing it to update correctly in response to dynamic data changes.
|
|
25
|
+
characterData: !0
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
attributeChangedCallback(e, t, r) {
|
|
29
|
+
if (t !== r)
|
|
30
|
+
switch (e) {
|
|
31
|
+
case "variant":
|
|
32
|
+
this.updateAttribute(
|
|
33
|
+
e,
|
|
34
|
+
t,
|
|
35
|
+
r,
|
|
36
|
+
u
|
|
37
|
+
), this.buildPrice();
|
|
38
|
+
break;
|
|
39
|
+
case "size":
|
|
40
|
+
this.updateAttribute(e, t, r, v);
|
|
41
|
+
break;
|
|
42
|
+
default:
|
|
43
|
+
super.attributeChangedCallback(e, t, r);
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
disconnectedCallback() {
|
|
48
|
+
this.observer.disconnect();
|
|
49
|
+
}
|
|
50
|
+
toggleClass(e, t) {
|
|
51
|
+
e !== null && e !== "" && e !== "default" && this.$el.classList.toggle(e), t !== null && t !== "" && t !== "default" && this.$el.classList.toggle(t);
|
|
52
|
+
}
|
|
53
|
+
updateAttribute(e, t, r, i) {
|
|
54
|
+
this.toggleClass(t, r), this.checkName(i, r) || l(
|
|
55
|
+
`"${r}" is not a valid ${e} value for ${this.tagName.toLowerCase()}. Allowed values are: "${i.join('", "')}".`
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
buildPrice() {
|
|
59
|
+
const e = this.innerHTML.trim(), t = /^[\d|.|,]+/.test(e);
|
|
60
|
+
let r = "";
|
|
61
|
+
t ? r = '<span class="euro">€</span>' : r = "";
|
|
62
|
+
const i = e.charAt(e.length - 3);
|
|
63
|
+
if (i === "." || i === ",") {
|
|
64
|
+
const [n, p] = e.split(i);
|
|
65
|
+
this.$el.innerHTML = `${r}${n}<span class="decimals">${i}${p}</span>`;
|
|
66
|
+
} else
|
|
67
|
+
this.$el.innerHTML = `${r}${e}`;
|
|
68
|
+
}
|
|
69
|
+
get variant() {
|
|
70
|
+
return this.getAttribute("variant");
|
|
71
|
+
}
|
|
72
|
+
set variant(e) {
|
|
73
|
+
super._updateAttribute("variant", e);
|
|
74
|
+
}
|
|
75
|
+
get size() {
|
|
76
|
+
return this.getAttribute("size");
|
|
77
|
+
}
|
|
78
|
+
set size(e) {
|
|
79
|
+
super._updateAttribute("size", e);
|
|
80
|
+
}
|
|
81
|
+
get inverted() {
|
|
82
|
+
return this.hasAttribute("inverted");
|
|
83
|
+
}
|
|
84
|
+
set inverted(e) {
|
|
85
|
+
super._updateBooleanAttribute("inverted", e);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
a.nativeName = "span";
|
|
89
|
+
let s = a;
|
|
90
|
+
customElements.get("px-price") || customElements.define("px-price", s);
|
|
91
|
+
export {
|
|
92
|
+
s as Price,
|
|
93
|
+
v as priceSizeValues,
|
|
94
|
+
u as priceVariantValues
|
|
87
95
|
};
|
|
88
|
-
customElements.get("px-price") || customElements.define("px-price", o);
|
|
89
|
-
//#endregion
|
|
90
|
-
export { o as Price, a as priceSizeValues, i as priceVariantValues };
|