@proximus/lavender-price 2.0.0-alpha.2 → 2.0.0-alpha.200

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