@proximus/lavender-price 2.0.0-alpha.21 → 2.0.0-alpha.210

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
@@ -2,19 +2,21 @@ import { PxElement } from '@proximus/lavender-common';
2
2
  export declare const priceVariantValues: string[];
3
3
  export declare const priceSizeValues: string[];
4
4
  export declare class Price extends PxElement<HTMLDivElement> {
5
+ protected static readonly template: HTMLTemplateElement;
5
6
  static nativeName: string;
6
- private template;
7
+ observer: MutationObserver | null;
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
- buildPrice(): void;
15
+ buildPrice: () => void;
16
+ get variant(): string | null;
17
+ set variant(value: string | null);
18
+ get size(): string | null;
19
+ set size(value: string | null);
20
+ get inverted(): boolean;
21
+ set inverted(value: boolean);
20
22
  }
@@ -0,0 +1,195 @@
1
+ {
2
+ "schemaVersion": "1.0.0",
3
+ "readme": "",
4
+ "modules": [
5
+ {
6
+ "kind": "javascript-module",
7
+ "path": "src/Price.ts",
8
+ "declarations": [
9
+ {
10
+ "kind": "variable",
11
+ "name": "priceVariantValues",
12
+ "type": {
13
+ "text": "array"
14
+ },
15
+ "default": "[ 'default', 'promo', 'free', 'neutral', 'exceeding', 'disabled', ]"
16
+ },
17
+ {
18
+ "kind": "variable",
19
+ "name": "priceSizeValues",
20
+ "type": {
21
+ "text": "array"
22
+ },
23
+ "default": "['', 's', 'm', 'l']"
24
+ },
25
+ {
26
+ "kind": "class",
27
+ "description": "",
28
+ "name": "Price",
29
+ "members": [
30
+ {
31
+ "kind": "field",
32
+ "name": "template",
33
+ "privacy": "protected",
34
+ "static": true,
35
+ "readonly": true
36
+ },
37
+ {
38
+ "kind": "field",
39
+ "name": "nativeName",
40
+ "type": {
41
+ "text": "string"
42
+ },
43
+ "static": true,
44
+ "default": "'span'"
45
+ },
46
+ {
47
+ "kind": "field",
48
+ "name": "observer",
49
+ "type": {
50
+ "text": "MutationObserver | null"
51
+ },
52
+ "default": "null"
53
+ },
54
+ {
55
+ "kind": "method",
56
+ "name": "toggleClass",
57
+ "parameters": [
58
+ {
59
+ "name": "oldValue",
60
+ "type": {
61
+ "text": "string"
62
+ }
63
+ },
64
+ {
65
+ "name": "newValue",
66
+ "type": {
67
+ "text": "string"
68
+ }
69
+ }
70
+ ]
71
+ },
72
+ {
73
+ "kind": "method",
74
+ "name": "updateAttribute",
75
+ "parameters": [
76
+ {
77
+ "name": "attrName",
78
+ "type": {
79
+ "text": "string"
80
+ }
81
+ },
82
+ {
83
+ "name": "oldValue",
84
+ "type": {
85
+ "text": "string"
86
+ }
87
+ },
88
+ {
89
+ "name": "newValue",
90
+ "type": {
91
+ "text": "string"
92
+ }
93
+ },
94
+ {
95
+ "name": "attrValues",
96
+ "type": {
97
+ "text": "string[]"
98
+ }
99
+ }
100
+ ]
101
+ },
102
+ {
103
+ "kind": "field",
104
+ "name": "buildPrice"
105
+ },
106
+ {
107
+ "kind": "field",
108
+ "name": "variant"
109
+ },
110
+ {
111
+ "kind": "field",
112
+ "name": "size"
113
+ },
114
+ {
115
+ "kind": "field",
116
+ "name": "inverted"
117
+ }
118
+ ],
119
+ "attributes": [
120
+ {
121
+ "name": "variant"
122
+ },
123
+ {
124
+ "name": "size"
125
+ },
126
+ {
127
+ "name": "inverted"
128
+ }
129
+ ],
130
+ "superclass": {
131
+ "name": "PxElement",
132
+ "package": "@proximus/lavender-common"
133
+ },
134
+ "tagName": "px-price",
135
+ "customElement": true
136
+ }
137
+ ],
138
+ "exports": [
139
+ {
140
+ "kind": "js",
141
+ "name": "priceVariantValues",
142
+ "declaration": {
143
+ "name": "priceVariantValues",
144
+ "module": "src/Price.ts"
145
+ }
146
+ },
147
+ {
148
+ "kind": "js",
149
+ "name": "priceSizeValues",
150
+ "declaration": {
151
+ "name": "priceSizeValues",
152
+ "module": "src/Price.ts"
153
+ }
154
+ },
155
+ {
156
+ "kind": "js",
157
+ "name": "Price",
158
+ "declaration": {
159
+ "name": "Price",
160
+ "module": "src/Price.ts"
161
+ }
162
+ },
163
+ {
164
+ "kind": "custom-element-definition",
165
+ "name": "px-price",
166
+ "declaration": {
167
+ "name": "Price",
168
+ "module": "src/Price.ts"
169
+ }
170
+ }
171
+ ]
172
+ },
173
+ {
174
+ "kind": "javascript-module",
175
+ "path": "src/index.ts",
176
+ "declarations": [],
177
+ "exports": [
178
+ {
179
+ "kind": "js",
180
+ "name": "*",
181
+ "declaration": {
182
+ "name": "*",
183
+ "module": "src/Price"
184
+ }
185
+ }
186
+ ]
187
+ },
188
+ {
189
+ "kind": "javascript-module",
190
+ "path": "src/price.css",
191
+ "declarations": [],
192
+ "exports": []
193
+ }
194
+ ]
195
+ }
package/dist/index.es.js CHANGED
@@ -1,85 +1,93 @@
1
- import { PxElement as l, log as c } 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 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 v = [
5
- "default",
6
- "promo",
7
- "free",
8
- "neutral",
9
- "exceeding",
10
- "disabled"
11
- ], u = ["", "s", "m", "l"], o = class o extends l {
12
- constructor() {
13
- super(a), this.template = () => '<span class="price"><slot></slot></span>', this.shadowRoot.innerHTML = this.template();
14
- }
15
- static get observedAttributes() {
16
- return [...super.observedAttributes, "variant", "size", "inverted"];
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
- connectedCallback() {
37
- this.buildPrice();
38
- }
39
- attributeChangedCallback(e, t, r) {
40
- if (t !== r)
41
- switch (e) {
42
- case "variant":
43
- this.updateAttribute(
44
- e,
45
- t,
46
- r,
47
- v
48
- ), this.buildPrice();
49
- break;
50
- case "size":
51
- this.updateAttribute(e, t, r, u);
52
- break;
53
- default:
54
- super.attributeChangedCallback(e, t, r);
55
- break;
56
- }
57
- }
58
- toggleClass(e, t) {
59
- e !== null && e !== "" && e !== "default" && this.$el.classList.toggle(e), t !== null && t !== "" && t !== "default" && this.$el.classList.toggle(t);
60
- }
61
- updateAttribute(e, t, r, i) {
62
- this.toggleClass(t, r), this.checkName(i, r) || c(
63
- `${r} is not an allowed ${e} value for ${this.tagName.toLowerCase()}`
64
- );
65
- }
66
- buildPrice() {
67
- const e = this.innerHTML.trim(), t = /^[\d|.|,]+/.test(e);
68
- let r = "";
69
- t ? r = '<span class="euro">€</span>' : r = "";
70
- const i = e.charAt(e.length - 3);
71
- if (i === "." || i === ",") {
72
- const [n, p] = e.split(i);
73
- this.$el.innerHTML = `${r}${n}<span class="decimals">${i}${p}</span>`;
74
- } else
75
- this.$el.innerHTML = `${r}${e}`;
76
- }
77
- };
78
- o.nativeName = "span";
79
- let s = o;
80
- customElements.get("px-price") || customElements.define("px-price", s);
81
- export {
82
- s as Price,
83
- u as priceSizeValues,
84
- v as priceVariantValues
1
+ import { PxElement as e, createTemplate as t, log as n, renderTemplate as r } from "@proximus/lavender-common";
2
+ //#region src/price.css?inline
3
+ var i = ".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)}@media screen and (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 (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)}}.price{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)}.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();
4
+ a.replaceSync(i);
5
+ var o = [
6
+ "default",
7
+ "promo",
8
+ "free",
9
+ "neutral",
10
+ "exceeding",
11
+ "disabled"
12
+ ], s = [
13
+ "",
14
+ "s",
15
+ "m",
16
+ "l"
17
+ ], c = class i extends e {
18
+ static {
19
+ this.template = t("<span class=\"price\"></span>");
20
+ }
21
+ static {
22
+ this.nativeName = "span";
23
+ }
24
+ constructor() {
25
+ super(a), this.observer = null, this.buildPrice = () => {
26
+ let e = this.innerHTML.trim(), t = /^[\d|.|,]+/.test(e), n = "";
27
+ n = t ? "<span class=\"euro\">€</span>" : "";
28
+ let r = e.charAt(e.length - 3);
29
+ if (r === "." || r === ",") {
30
+ let [t, i] = e.split(r);
31
+ this.$el.innerHTML = `${n}${t}<span class="decimals">${r}${i}</span>`;
32
+ } else this.$el.innerHTML = `${n}${e}`;
33
+ }, r(this.shadowRoot, i.template);
34
+ }
35
+ static get observedAttributes() {
36
+ return [
37
+ ...super.observedAttributes,
38
+ "variant",
39
+ "size",
40
+ "inverted"
41
+ ];
42
+ }
43
+ connectedCallback() {
44
+ this.buildPrice(), this.observer = new MutationObserver(() => {
45
+ this.buildPrice();
46
+ }), this.observer.observe(this, {
47
+ childList: !0,
48
+ subtree: !0,
49
+ characterData: !0
50
+ });
51
+ }
52
+ attributeChangedCallback(e, t, n) {
53
+ if (t !== n) switch (e) {
54
+ case "variant":
55
+ this.updateAttribute(e, t, n, o), this.buildPrice();
56
+ break;
57
+ case "size":
58
+ this.updateAttribute(e, t, n, s);
59
+ break;
60
+ default: super.attributeChangedCallback(e, t, n);
61
+ }
62
+ }
63
+ disconnectedCallback() {
64
+ this.observer?.disconnect();
65
+ }
66
+ toggleClass(e, t) {
67
+ e !== null && e !== "" && e !== "default" && this.$el.classList.toggle(e), t !== null && t !== "" && t !== "default" && this.$el.classList.toggle(t);
68
+ }
69
+ updateAttribute(e, t, r, i) {
70
+ this.toggleClass(t, r), this.checkName(i, r) || n(`"${r}" is not a valid ${e} value for ${this.tagName.toLowerCase()}. Allowed values are: "${i.join("\", \"")}".`);
71
+ }
72
+ get variant() {
73
+ return this.getAttribute("variant");
74
+ }
75
+ set variant(e) {
76
+ this._updateAttribute("variant", e);
77
+ }
78
+ get size() {
79
+ return this.getAttribute("size");
80
+ }
81
+ set size(e) {
82
+ this._updateAttribute("size", e);
83
+ }
84
+ get inverted() {
85
+ return this.hasAttribute("inverted");
86
+ }
87
+ set inverted(e) {
88
+ this._updateBooleanAttribute("inverted", e);
89
+ }
85
90
  };
91
+ customElements.get("px-price") || customElements.define("px-price", c);
92
+ //#endregion
93
+ export { c as Price, s as priceSizeValues, o as priceVariantValues };
@@ -0,0 +1,6 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/microsoft/vscode-css-languageservice/main/docs/customData.schema.json",
3
+ "version": 1.1,
4
+ "properties": [],
5
+ "pseudoElements": []
6
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/microsoft/vscode-html-languageservice/main/docs/customData.schema.json",
3
+ "version": 1.1,
4
+ "tags": [
5
+ {
6
+ "name": "px-price",
7
+ "description": "\n---\n",
8
+ "attributes": [
9
+ { "name": "variant", "values": [] },
10
+ { "name": "size", "values": [] },
11
+ { "name": "inverted", "values": [] }
12
+ ],
13
+ "references": []
14
+ }
15
+ ]
16
+ }
@@ -0,0 +1,37 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json",
3
+ "name": "@proximus/lavender-price",
4
+ "version": "2.0.0-alpha.210",
5
+ "description-markup": "markdown",
6
+ "contributions": {
7
+ "html": {
8
+ "elements": [
9
+ {
10
+ "name": "px-price",
11
+ "description": "\n\n---\n",
12
+ "doc-url": "",
13
+ "attributes": [
14
+ { "name": "variant", "value": { "type": "string" } },
15
+ { "name": "size", "value": { "type": "string" } },
16
+ { "name": "inverted", "value": { "type": "string" } }
17
+ ],
18
+ "events": [],
19
+ "js": {
20
+ "properties": [
21
+ { "name": "observer", "type": "MutationObserver | null" },
22
+ { "name": "buildPrice" },
23
+ { "name": "variant" },
24
+ { "name": "size" },
25
+ { "name": "inverted" }
26
+ ],
27
+ "events": []
28
+ }
29
+ }
30
+ ]
31
+ },
32
+ "css": {
33
+ "properties": [],
34
+ "pseudo-elements": []
35
+ }
36
+ }
37
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proximus/lavender-price",
3
- "version": "2.0.0-alpha.21",
3
+ "version": "2.0.0-alpha.210",
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"