@proximus/lavender-price 2.0.0-alpha.4 → 2.0.0-alpha.41

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 CHANGED
@@ -3,18 +3,20 @@ 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
7
  private template;
7
8
  constructor();
8
9
  static get observedAttributes(): string[];
9
- get variant(): string;
10
- set variant(value: string);
11
- get size(): string;
12
- set size(value: string);
13
- get inverted(): string;
14
- set inverted(value: string);
15
10
  connectedCallback(): void;
16
11
  attributeChangedCallback(attrName: string, oldValue: string, newValue: string): void;
12
+ disconnectedCallback(): void;
17
13
  toggleClass(oldValue: string, newValue: string): void;
18
14
  updateAttribute(attrName: string, oldValue: string, newValue: string, attrValues: string[]): void;
19
15
  buildPrice(): void;
16
+ get variant(): string;
17
+ set variant(value: string);
18
+ get size(): string;
19
+ set size(value: string);
20
+ get inverted(): boolean;
21
+ set inverted(value: boolean);
20
22
  }
package/dist/index.es.js CHANGED
@@ -1,7 +1,7 @@
1
- import { PxElement as c } from "@proximus/lavender-common";
2
- const l = ".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 only screen and (min-width: 48em){.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 only screen and (min-width: 64.0625em){.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)}", a = new CSSStyleSheet();
3
- a.replaceSync(l);
4
- const d = [
1
+ import { PxElement as c, log as l } from "@proximus/lavender-common";
2
+ const d = ":host{font-size:var(--px-font-size-base)}.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 only screen and (min-width: 48em){.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 only screen and (min-width: 64.0625em){.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)}", a = new CSSStyleSheet();
3
+ a.replaceSync(d);
4
+ const u = [
5
5
  "default",
6
6
  "promo",
7
7
  "free",
@@ -15,26 +15,13 @@ const d = [
15
15
  static get observedAttributes() {
16
16
  return [...super.observedAttributes, "variant", "size", "inverted"];
17
17
  }
18
- get variant() {
19
- return this.getAttribute("variant");
20
- }
21
- set variant(e) {
22
- this.setAttribute("variant", e);
23
- }
24
- get size() {
25
- return this.getAttribute("size");
26
- }
27
- set size(e) {
28
- this.setAttribute("size", e);
29
- }
30
- get inverted() {
31
- return this.getAttribute("inverted");
32
- }
33
- set inverted(e) {
34
- this.setAttribute("inverted", e);
35
- }
36
18
  connectedCallback() {
37
- this.buildPrice();
19
+ this.buildPrice(), this.observer = new MutationObserver(() => {
20
+ this.buildPrice();
21
+ }), this.observer.observe(this, {
22
+ childList: !0,
23
+ subtree: !0
24
+ });
38
25
  }
39
26
  attributeChangedCallback(e, t, r) {
40
27
  if (t !== r)
@@ -44,7 +31,7 @@ const d = [
44
31
  e,
45
32
  t,
46
33
  r,
47
- d
34
+ u
48
35
  ), this.buildPrice();
49
36
  break;
50
37
  case "size":
@@ -55,11 +42,16 @@ const d = [
55
42
  break;
56
43
  }
57
44
  }
45
+ disconnectedCallback() {
46
+ this.observer.disconnect();
47
+ }
58
48
  toggleClass(e, t) {
59
49
  e !== null && e !== "" && e !== "default" && this.$el.classList.toggle(e), t !== null && t !== "" && t !== "default" && this.$el.classList.toggle(t);
60
50
  }
61
51
  updateAttribute(e, t, r, i) {
62
- this.toggleClass(t, r), this.checkName(i, r) || console.error(`${r} is not an allowed ${e} value`);
52
+ this.toggleClass(t, r), this.checkName(i, r) || l(
53
+ `${r} is not an allowed ${e} value for ${this.tagName.toLowerCase()}`
54
+ );
63
55
  }
64
56
  buildPrice() {
65
57
  const e = this.innerHTML.trim(), t = /^[\d|.|,]+/.test(e);
@@ -72,6 +64,24 @@ const d = [
72
64
  } else
73
65
  this.$el.innerHTML = `${r}${e}`;
74
66
  }
67
+ get variant() {
68
+ return this.getAttribute("variant");
69
+ }
70
+ set variant(e) {
71
+ super._updateAttribute("variant", e);
72
+ }
73
+ get size() {
74
+ return this.getAttribute("size");
75
+ }
76
+ set size(e) {
77
+ super._updateAttribute("size", e);
78
+ }
79
+ get inverted() {
80
+ return this.hasAttribute("inverted");
81
+ }
82
+ set inverted(e) {
83
+ super._updateBooleanAttribute("inverted", e);
84
+ }
75
85
  };
76
86
  o.nativeName = "span";
77
87
  let s = o;
@@ -79,5 +89,5 @@ customElements.get("px-price") || customElements.define("px-price", s);
79
89
  export {
80
90
  s as Price,
81
91
  v as priceSizeValues,
82
- d as priceVariantValues
92
+ u as priceVariantValues
83
93
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proximus/lavender-price",
3
- "version": "2.0.0-alpha.4",
3
+ "version": "2.0.0-alpha.41",
4
4
  "description": "",
5
5
  "main": "dist/index.es.js",
6
6
  "types": "dist/index.d.ts",
@@ -13,7 +13,7 @@
13
13
  "clean": "rm -rf dist",
14
14
  "build": "npm run clean && NODE_ENV=development vite build && tsc && npm run transform-package-json && npm run wc-manifest",
15
15
  "test": "vitest run --coverage",
16
- "wc-manifest": "cem analyze --globs \"src/*\" --config ../custom-elements-manifest.config.js --outdir dist"
16
+ "wc-manifest": "cem analyze --globs \"src/*\" --config ../../custom-elements-manifest.config.js --outdir dist"
17
17
  },
18
18
  "publishConfig": {
19
19
  "access": "public"