@proximus/lavender-icon-common 2.0.0-alpha.19 → 2.0.0-alpha.190

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/Icon.d.ts ADDED
@@ -0,0 +1,26 @@
1
+ import { WithExtraAttributes } from '@proximus/lavender-common';
2
+ export declare const styleSheet: CSSStyleSheet;
3
+ export declare class Icon extends WithExtraAttributes {
4
+ #private;
5
+ static get observedAttributes(): string[];
6
+ constructor(...styleSheets: CSSStyleSheet[]);
7
+ attributeChangedCallback(attrName: string, oldValue: string, newValue: string): void;
8
+ connectedCallback(): void;
9
+ updateAttribute(attrName: string, oldValue: string, newValue: string, attrValues: readonly string[]): void;
10
+ updateName(oldValue: string, newValue: string): void;
11
+ get $el(): SVGElement;
12
+ get name(): string | null;
13
+ set name(value: string | null);
14
+ get size(): string | null;
15
+ set size(value: string | null);
16
+ get color(): string | null;
17
+ set color(value: string | null);
18
+ get arialabel(): string | null;
19
+ set arialabel(value: string | null);
20
+ get inverted(): boolean;
21
+ set inverted(value: boolean);
22
+ get from(): string | null;
23
+ set from(value: string | null);
24
+ get disabled(): boolean;
25
+ set disabled(value: boolean);
26
+ }
@@ -0,0 +1,6 @@
1
+ export declare class IconSet extends HTMLElement {
2
+ constructor();
3
+ static get observedAttributes(): string[];
4
+ connectedCallback(): void;
5
+ disconnectedCallback(): void;
6
+ }
@@ -0,0 +1,3 @@
1
+ export declare const iconColorValues: readonly ["Brand", "Accent", "Neutral", "Dimmed", "PurposeSuccess", "PurposeWarning", "PurposeError", "PurposeUnlimited", "PurposePromo", "StateHover", "StateActive", "StateDisabled"];
2
+ export declare const iconColorValuesKC: string[];
3
+ export type IconColor = (typeof iconColorValues)[number];
@@ -0,0 +1,3 @@
1
+ export * from './IconSet';
2
+ export * from './Icon';
3
+ export * from './attributeValues';
package/dist/index.es.js CHANGED
@@ -1,24 +1,23 @@
1
- var u = (r) => {
2
- throw TypeError(r);
3
- };
4
- var p = (r, o, e) => o.has(r) || u("Cannot " + e);
5
- var s = (r, o, e) => (p(r, o, "read from private field"), e ? e.call(r) : o.get(r)), a = (r, o, e) => o.has(r) ? u("Cannot add the same private member more than once") : o instanceof WeakSet ? o.add(r) : o.set(r, e), d = (r, o, e, t) => (p(r, o, "write to private field"), t ? t.call(r, e) : o.set(r, e), e);
6
- import { WithExtraAttributes as m, iconSizeValuesKC as f, log as b } from "@proximus/lavender-common";
7
- class g extends HTMLElement {
8
- constructor() {
9
- super();
10
- }
11
- static get observedAttributes() {
12
- return ["name", "src", "type", "format"];
13
- }
14
- connectedCallback() {
15
- if (document.querySelectorAll(
16
- `px-icon-set[name="${this.getAttribute("name")}"]`
17
- ).length > 1 && (console.warn(
18
- "Only one <px-icon-set> component is allowed, self removing"
19
- ), this.remove()), this.getAttribute("type") === "font") {
20
- const e = document.createElement("style");
21
- e.setAttribute("type", "text/css"), e.setAttribute("data-name", this.getAttribute("name")), e.textContent = `
1
+ import { WithExtraAttributes as e, booleanPropertyToAttributeSetter as t, iconSizeValuesKC as n, log as r, propertyToAttributeSetter as i } from "@proximus/lavender-common";
2
+ //#region src/IconSet.ts
3
+ var a = class extends HTMLElement {
4
+ constructor() {
5
+ super();
6
+ }
7
+ static get observedAttributes() {
8
+ return [
9
+ "name",
10
+ "src",
11
+ "type",
12
+ "format"
13
+ ];
14
+ }
15
+ connectedCallback() {
16
+ if (document.querySelectorAll(`px-icon-set[name="${this.getAttribute("name")}"]`).length > 1 && (console.warn("Only one <px-icon-set> component is allowed, self removing"), this.remove()), this.getAttribute("type") === "font") {
17
+ let e = document.createElement("style");
18
+ e.setAttribute("type", "text/css");
19
+ let t = this.getAttribute("name");
20
+ t && e.setAttribute("data-name", t), e.textContent = `
22
21
  @font-face {
23
22
  font-family: 'lavender';
24
23
  src:
@@ -28,162 +27,134 @@ class g extends HTMLElement {
28
27
  font-display: block;
29
28
  }
30
29
  `, document.head.appendChild(e);
31
- }
32
- }
33
- disconnectedCallback() {
34
- const o = document.querySelector(
35
- `style[data-name="${this.getAttribute("name")}"]`
36
- );
37
- o && o.remove();
38
- }
39
- }
40
- customElements.get("px-icon-set") || customElements.define("px-icon-set", g);
41
- const x = [
42
- "Brand",
43
- "Accent",
44
- "Neutral",
45
- "Dimmed",
46
- "PurposeSuccess",
47
- "PurposeWarning",
48
- "PurposeError",
49
- "PurposeUnlimited",
50
- "PurposePromo",
51
- "StateHover",
52
- "StateActive",
53
- "StateDisabled"
54
- ], A = ["Inherit", ...x].map(
55
- (r) => r.replace(/([A-Z])/g, "-$1").toLowerCase().slice(1)
56
- ), z = ":host{display:inline-flex;flex-direction:column;justify-content:center}svg{font-size:var(--px-size-icon-s);line-height:var(--px-font-line-height-xs);width:1em;height:1em;color:var(--px-color-icon-accent-default)}.inherit{color:inherit}.brand{color:var(--px-color-icon-brand-default)}.accent{color:var(--px-color-icon-accent-default)}.neutral{color:var(--px-color-icon-neutral-default)}.dimmed{color:var(--px-color-icon-dimmed-default)}.purpose-success{color:var(--px-color-icon-purpose-success-default)}.purpose-warning{color:var(--px-color-icon-purpose-warning-default)}.purpose-error{color:var(--px-color-icon-purpose-error-default)}.purpose-unlimited{color:var(--px-color-icon-purpose-unlimited-default)}.purpose-promo{color:var(--px-color-icon-purpose-promo-default)}.state-hover:hover{color:var(--px-color-icon-state-hover-default)}.state-active:active{color:var(--px-color-icon-state-active-default)}.state-disabled{color:var(--px-color-icon-state-disabled-default)}:host([inverted]) svg{color:var(--px-color-icon-accent-inverted)}:host([inverted]) .inherit{color:inherit}:host([inverted]) .brand{color:var(--px-color-icon-brand-inverted)}:host([inverted]) .accent{color:var(--px-color-icon-accent-inverted)}:host([inverted]) .neutral{color:var(--px-color-icon-neutral-inverted)}:host([inverted]) .dimmed{color:var(--px-color-icon-dimmed-inverted)}:host([inverted]) .purpose-success{color:var(--px-color-icon-purpose-success-inverted)}:host([inverted]) .purpose-warning{color:var(--px-color-icon-purpose-warning-inverted)}:host([inverted]) .purpose-error{color:var(--px-color-icon-purpose-error-inverted)}:host([inverted]) .purpose-unlimited{color:var(--px-color-icon-purpose-unlimited-inverted)}:host([inverted]) .purpose-promo{color:var(--px-color-icon-purpose-promo-inverted)}:host([inverted]) .state-hover:hover{color:var(--px-color-icon-state-hover-inverted)}:host([inverted]) .state-active:active{color:var(--px-color-icon-state-active-inverted)}:host([inverted]) .state-disabled{color:var(--px-color-icon-state-disabled-inverted)}.size-xs{font-size:var(--px-size-icon-xs)}.size-s{font-size:var(--px-size-icon-s)}.size-m{font-size:var(--px-size-icon-m)}.size-l{font-size:var(--px-size-icon-l)}.size-xl{font-size:var(--px-size-icon-xl)}", h = new CSSStyleSheet();
57
- h.replaceSync(z);
58
- const $ = [
59
- "name",
60
- "size",
61
- "color",
62
- "aria-label",
63
- "inverted",
64
- "from",
65
- "disabled"
66
- ];
67
- var c, n, l;
68
- class y extends m {
69
- constructor(...e) {
70
- var t;
71
- super(...e, h);
72
- a(this, c);
73
- a(this, n);
74
- a(this, l, () => `<svg aria-hidden="true">
75
- <use xlink:href=""></use>
76
- </svg>`);
77
- this.shadowRoot.innerHTML = s(this, l).call(this), d(this, n, (t = this.attachInternals) == null ? void 0 : t.call(this)), s(this, n) && (s(this, n).role = "img");
78
- }
79
- static get observedAttributes() {
80
- return [...super.observedAttributes, ...$];
81
- }
82
- attributeChangedCallback(e, t, i) {
83
- if (t !== i)
84
- switch (e) {
85
- case "name":
86
- this.updateName(t, i);
87
- break;
88
- case "size":
89
- this.updateAttribute(e, t, i, f);
90
- break;
91
- case "color":
92
- this.updateAttribute(e, t, i, A);
93
- break;
94
- case "disabled":
95
- this.color = "state-disabled";
96
- break;
97
- case "aria-label":
98
- if (!s(this, n))
99
- return;
100
- i ? (s(this, n).ariaHidden = "false", this.ariaHidden = "false") : (s(this, n).ariaHidden = "true", this.ariaHidden = "true");
101
- break;
102
- }
103
- }
104
- connectedCallback() {
105
- this.role = "img", this.name && this.$el.firstElementChild.setAttribute(
106
- "xlink:href",
107
- `#icon-${this.name}`
108
- );
109
- const e = document.querySelectorAll("px-icon-set");
110
- e || console.log("<px-icon-set> component not found");
111
- for (const t of e) {
112
- if (!t.getAttribute("name") || !t.getAttribute("src")) {
113
- console.error("Icon name or src not found");
114
- continue;
115
- }
116
- t.getAttribute("name") === this.from && t.getAttribute("type") !== "font" && (d(this, c, t.getAttribute("src")), this.$el.firstElementChild.setAttribute(
117
- "xlink:href",
118
- `${s(this, c)}#icon-${this.name}`
119
- ));
120
- }
121
- !this.ariaLabel && s(this, n) && (s(this, n).ariaHidden = "true", this.ariaHidden = "true");
122
- }
123
- updateAttribute(e, t, i, v) {
124
- t !== null && t !== "" && (e === "size" ? this.$el.classList.toggle(`${e}-${t}`) : this.$el.classList.toggle(t)), i !== null && i !== "" && (e === "size" ? this.$el.classList.toggle(`${e}-${i}`) : this.$el.classList.toggle(i)), this.checkName(v, i) || b(
125
- `${i} is not an allowed ${e} value for ${this.tagName.toLowerCase()}`
126
- );
127
- }
128
- updateName(e, t) {
129
- s(this, c) && this.$el.firstElementChild.setAttribute(
130
- "xlink:href",
131
- `${s(this, c)}#icon-${t}`
132
- );
133
- }
134
- get $el() {
135
- return this.shadowRoot.querySelector("svg");
136
- }
137
- get name() {
138
- return this.getAttribute("name");
139
- }
140
- set name(e) {
141
- this.setAttribute("name", e);
142
- }
143
- get size() {
144
- return this.getAttribute("size");
145
- }
146
- set size(e) {
147
- this.setAttribute("size", e);
148
- }
149
- get color() {
150
- return this.getAttribute("color");
151
- }
152
- set color(e) {
153
- this.setAttribute("color", e);
154
- }
155
- get arialabel() {
156
- return this.getAttribute("aria-label");
157
- }
158
- set arialabel(e) {
159
- this.setAttribute("aria-label", e);
160
- }
161
- get inverted() {
162
- return this.getAttribute("inverted");
163
- }
164
- set inverted(e) {
165
- this.setAttribute("inverted", e);
166
- }
167
- get from() {
168
- return this.getAttribute("from");
169
- }
170
- set from(e) {
171
- this.setAttribute("from", e);
172
- }
173
- get disabled() {
174
- return this.getAttribute("disabled");
175
- }
176
- set disabled(e) {
177
- this.setAttribute("disabled", e);
178
- }
179
- }
180
- c = new WeakMap(), n = new WeakMap(), l = new WeakMap();
181
- customElements.get("px-icon") || customElements.define("px-icon", y);
182
- export {
183
- y as Icon,
184
- g as IconSet,
185
- x as iconColorValues,
186
- A as iconColorValuesKC,
187
- $ as observedAttributes,
188
- h as styleSheet
30
+ }
31
+ }
32
+ disconnectedCallback() {
33
+ let e = document.querySelector(`style[data-name="${this.getAttribute("name")}"]`);
34
+ e && e.remove();
35
+ }
36
+ };
37
+ customElements.get("px-icon-set") || customElements.define("px-icon-set", a);
38
+ //#endregion
39
+ //#region src/attributeValues.ts
40
+ var o = [
41
+ "Brand",
42
+ "Accent",
43
+ "Neutral",
44
+ "Dimmed",
45
+ "PurposeSuccess",
46
+ "PurposeWarning",
47
+ "PurposeError",
48
+ "PurposeUnlimited",
49
+ "PurposePromo",
50
+ "StateHover",
51
+ "StateActive",
52
+ "StateDisabled"
53
+ ], s = ["Inherit", ...o].map((e) => e.replace(/([A-Z])/g, "-$1").toLowerCase().slice(1)), c = ":host{flex-direction:column;justify-content:center;display:inline-flex}svg{font-size:var(--px-size-icon-s);width:1em;height:1em;color:var(--px-color-icon-accent-default);line-height:1}.inherit{color:inherit}.brand{color:var(--px-color-icon-brand-default)}.accent{color:var(--px-color-icon-accent-default)}.neutral{color:var(--px-color-icon-neutral-default)}.dimmed{color:var(--px-color-icon-dimmed-default)}.purpose-success{color:var(--px-color-icon-purpose-success-default)}.purpose-warning{color:var(--px-color-icon-purpose-warning-default)}.purpose-error{color:var(--px-color-icon-purpose-error-default)}.purpose-unlimited{color:var(--px-color-icon-purpose-unlimited-default)}.purpose-promo{color:var(--px-color-icon-purpose-promo-default)}.state-hover:hover{color:var(--px-color-icon-state-hover-default)}.state-active:active{color:var(--px-color-icon-state-active-default)}.state-disabled{color:var(--px-color-icon-state-disabled-default)}:host([inverted]) svg{color:var(--px-color-icon-accent-inverted)}:host([inverted]) .inherit{color:inherit}:host([inverted]) .brand{color:var(--px-color-icon-brand-inverted)}:host([inverted]) .accent{color:var(--px-color-icon-accent-inverted)}:host([inverted]) .neutral{color:var(--px-color-icon-neutral-inverted)}:host([inverted]) .dimmed{color:var(--px-color-icon-dimmed-inverted)}:host([inverted]) .purpose-success{color:var(--px-color-icon-purpose-success-inverted)}:host([inverted]) .purpose-warning{color:var(--px-color-icon-purpose-warning-inverted)}:host([inverted]) .purpose-error{color:var(--px-color-icon-purpose-error-inverted)}:host([inverted]) .purpose-unlimited{color:var(--px-color-icon-purpose-unlimited-inverted)}:host([inverted]) .purpose-promo{color:var(--px-color-icon-purpose-promo-inverted)}:host([inverted]) .state-hover:hover{color:var(--px-color-icon-state-hover-inverted)}:host([inverted]) .state-active:active{color:var(--px-color-icon-state-active-inverted)}:host([inverted]) .state-disabled{color:var(--px-color-icon-state-disabled-inverted)}.size-xs{font-size:var(--px-size-icon-xs)}.size-s{font-size:var(--px-size-icon-s)}.size-m{font-size:var(--px-size-icon-m)}.size-l{font-size:var(--px-size-icon-l)}.size-xl{font-size:var(--px-size-icon-xl)}", l = new CSSStyleSheet();
54
+ l.replaceSync(c);
55
+ var u = class extends e {
56
+ #e = null;
57
+ #t;
58
+ #n = () => "<svg aria-hidden=\"true\">\n <use></use>\n </svg>";
59
+ static get observedAttributes() {
60
+ return [
61
+ ...super.observedAttributes,
62
+ "name",
63
+ "size",
64
+ "color",
65
+ "aria-label",
66
+ "inverted",
67
+ "from",
68
+ "disabled"
69
+ ];
70
+ }
71
+ constructor(...e) {
72
+ super(...e, l), this.shadowRoot.innerHTML = this.#n(), this.#t = this.attachInternals?.(), this.#t && (this.#t.role = "img");
73
+ }
74
+ attributeChangedCallback(e, t, r) {
75
+ if (t !== r) switch (e) {
76
+ case "name":
77
+ this.updateName(t, r);
78
+ break;
79
+ case "size":
80
+ this.updateAttribute(e, t, r, n);
81
+ break;
82
+ case "color":
83
+ this.updateAttribute(e, t, r, s);
84
+ break;
85
+ case "disabled":
86
+ this.color = "state-disabled";
87
+ break;
88
+ case "aria-label":
89
+ if (!this.#t) return;
90
+ r ? (this.#t.ariaHidden = "false", this.ariaHidden = "false") : (this.#t.ariaHidden = "true", this.ariaHidden = "true");
91
+ }
92
+ }
93
+ connectedCallback() {
94
+ this.role = "img";
95
+ let e = document.querySelectorAll("px-icon-set");
96
+ e || console.log("<px-icon-set> component not found");
97
+ for (let t of e) {
98
+ if (!t.getAttribute("name") || !t.getAttribute("src")) {
99
+ console.error("Icon name or src not found");
100
+ continue;
101
+ }
102
+ t.getAttribute("name") === this.from && t.getAttribute("type") !== "font" && (this.#e = t.getAttribute("src"), this.$el.firstElementChild?.setAttribute("href", `${this.#e}#icon-${this.name}`));
103
+ }
104
+ !this.ariaLabel && this.#t && (this.#t.ariaHidden = "true", this.ariaHidden = "true"), this.parentElement?.localName === "px-a" && this.slot !== "before" && this.slot !== "after" && (this.color || this.setAttribute("color", "inherit"));
105
+ }
106
+ updateAttribute(e, t, n, i) {
107
+ t !== null && t !== "" && (e === "size" ? this.$el.classList.toggle(`${e}-${t}`) : this.$el.classList.toggle(t)), n !== null && n !== "" && (e === "size" ? this.$el.classList.toggle(`${e}-${n}`) : this.$el.classList.toggle(n)), this.checkName(i, n) || r(`${n} is not an allowed ${e} value for ${this.tagName.toLowerCase()}`);
108
+ }
109
+ updateName(e, t) {
110
+ this.#e && this.$el.firstElementChild?.setAttribute("href", `${this.#e}#icon-${t}`);
111
+ }
112
+ get $el() {
113
+ return this.shadowRoot.querySelector("svg");
114
+ }
115
+ get name() {
116
+ return this.getAttribute("name");
117
+ }
118
+ set name(e) {
119
+ i(this, "name", e);
120
+ }
121
+ get size() {
122
+ return this.getAttribute("size");
123
+ }
124
+ set size(e) {
125
+ i(this, "size", e);
126
+ }
127
+ get color() {
128
+ return this.getAttribute("color");
129
+ }
130
+ set color(e) {
131
+ i(this, "color", e);
132
+ }
133
+ get arialabel() {
134
+ return this.getAttribute("aria-label");
135
+ }
136
+ set arialabel(e) {
137
+ i(this, "aria-label", e);
138
+ }
139
+ get inverted() {
140
+ return this.hasAttribute("inverted");
141
+ }
142
+ set inverted(e) {
143
+ t(this, "inverted", e);
144
+ }
145
+ get from() {
146
+ return this.getAttribute("from");
147
+ }
148
+ set from(e) {
149
+ i(this, "from", e);
150
+ }
151
+ get disabled() {
152
+ return this.hasAttribute("disabled");
153
+ }
154
+ set disabled(e) {
155
+ t(this, "disabled", e);
156
+ }
189
157
  };
158
+ customElements.get("px-icon") || customElements.define("px-icon", u);
159
+ //#endregion
160
+ export { u as Icon, a as IconSet, o as iconColorValues, s as iconColorValuesKC, l as styleSheet };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proximus/lavender-icon-common",
3
- "version": "2.0.0-alpha.19",
3
+ "version": "2.0.0-alpha.190",
4
4
  "description": "",
5
5
  "main": "dist/index.es.js",
6
6
  "types": "dist/index.d.ts",
@@ -10,10 +10,10 @@
10
10
  "type": "module",
11
11
  "scripts": {
12
12
  "clean": "rm -rf dist",
13
- "build": "npm run clean && vite build && npm run transform-package-json && npm run wc-manifest",
13
+ "build": "npm run clean && vite build && tsc && npm run transform-package-json && npm run wc-manifest",
14
14
  "test": "vitest run --coverage",
15
15
  "transform-package-json": "node ../../../../scripts/tranformPackageJson.js package.json dist/far/away",
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"