@proximus/lavender-icon-common 2.0.0-alpha.12 → 2.0.0-alpha.120
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 +26 -0
- package/dist/IconSet.d.ts +6 -0
- package/dist/attributeValues.d.ts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.es.js +48 -45
- package/package.json +3 -3
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;
|
|
13
|
+
set name(value: string);
|
|
14
|
+
get size(): string;
|
|
15
|
+
set size(value: string);
|
|
16
|
+
get color(): string;
|
|
17
|
+
set color(value: string);
|
|
18
|
+
get arialabel(): string;
|
|
19
|
+
set arialabel(value: string);
|
|
20
|
+
get inverted(): string;
|
|
21
|
+
set inverted(value: string);
|
|
22
|
+
get from(): string;
|
|
23
|
+
set from(value: string);
|
|
24
|
+
get disabled(): string;
|
|
25
|
+
set disabled(value: string);
|
|
26
|
+
}
|
|
@@ -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];
|
package/dist/index.d.ts
ADDED
package/dist/index.es.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
var u = (
|
|
2
|
-
throw TypeError(
|
|
1
|
+
var u = (o) => {
|
|
2
|
+
throw TypeError(o);
|
|
3
3
|
};
|
|
4
|
-
var p = (
|
|
5
|
-
var s = (
|
|
6
|
-
import { WithExtraAttributes as m, iconSizeValuesKC as b } from "@proximus/lavender-common";
|
|
7
|
-
class
|
|
4
|
+
var p = (o, i, e) => i.has(o) || u("Cannot " + e);
|
|
5
|
+
var s = (o, i, e) => (p(o, i, "read from private field"), e ? e.call(o) : i.get(o)), a = (o, i, e) => i.has(o) ? u("Cannot add the same private member more than once") : i instanceof WeakSet ? i.add(o) : i.set(o, e), d = (o, i, e, t) => (p(o, i, "write to private field"), t ? t.call(o, e) : i.set(o, e), e);
|
|
6
|
+
import { WithExtraAttributes as m, iconSizeValuesKC as f, log as b } from "@proximus/lavender-common";
|
|
7
|
+
class g extends HTMLElement {
|
|
8
8
|
constructor() {
|
|
9
9
|
super();
|
|
10
10
|
}
|
|
@@ -31,14 +31,14 @@ class f extends HTMLElement {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
disconnectedCallback() {
|
|
34
|
-
const
|
|
34
|
+
const i = document.querySelector(
|
|
35
35
|
`style[data-name="${this.getAttribute("name")}"]`
|
|
36
36
|
);
|
|
37
|
-
|
|
37
|
+
i && i.remove();
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
customElements.get("px-icon-set") || customElements.define("px-icon-set",
|
|
41
|
-
const
|
|
40
|
+
customElements.get("px-icon-set") || customElements.define("px-icon-set", g);
|
|
41
|
+
const x = [
|
|
42
42
|
"Brand",
|
|
43
43
|
"Accent",
|
|
44
44
|
"Neutral",
|
|
@@ -51,19 +51,10 @@ const g = [
|
|
|
51
51
|
"StateHover",
|
|
52
52
|
"StateActive",
|
|
53
53
|
"StateDisabled"
|
|
54
|
-
],
|
|
55
|
-
(
|
|
56
|
-
),
|
|
57
|
-
h.replaceSync(
|
|
58
|
-
const z = [
|
|
59
|
-
"name",
|
|
60
|
-
"size",
|
|
61
|
-
"color",
|
|
62
|
-
"aria-label",
|
|
63
|
-
"inverted",
|
|
64
|
-
"from",
|
|
65
|
-
"disabled"
|
|
66
|
-
];
|
|
54
|
+
], A = ["Inherit", ...x].map(
|
|
55
|
+
(o) => o.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);
|
|
67
58
|
var c, n, l;
|
|
68
59
|
class $ extends m {
|
|
69
60
|
constructor(...e) {
|
|
@@ -72,24 +63,33 @@ class $ extends m {
|
|
|
72
63
|
a(this, c);
|
|
73
64
|
a(this, n);
|
|
74
65
|
a(this, l, () => `<svg aria-hidden="true">
|
|
75
|
-
<use
|
|
66
|
+
<use></use>
|
|
76
67
|
</svg>`);
|
|
77
|
-
this.shadowRoot.innerHTML = s(this, l).call(this),
|
|
68
|
+
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
69
|
}
|
|
79
70
|
static get observedAttributes() {
|
|
80
|
-
return [
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
71
|
+
return [
|
|
72
|
+
...super.observedAttributes,
|
|
73
|
+
"name",
|
|
74
|
+
"size",
|
|
75
|
+
"color",
|
|
76
|
+
"aria-label",
|
|
77
|
+
"inverted",
|
|
78
|
+
"from",
|
|
79
|
+
"disabled"
|
|
80
|
+
];
|
|
81
|
+
}
|
|
82
|
+
attributeChangedCallback(e, t, r) {
|
|
83
|
+
if (t !== r)
|
|
84
84
|
switch (e) {
|
|
85
85
|
case "name":
|
|
86
|
-
this.updateName(t,
|
|
86
|
+
this.updateName(t, r);
|
|
87
87
|
break;
|
|
88
88
|
case "size":
|
|
89
|
-
this.updateAttribute(e, t,
|
|
89
|
+
this.updateAttribute(e, t, r, f);
|
|
90
90
|
break;
|
|
91
91
|
case "color":
|
|
92
|
-
this.updateAttribute(e, t,
|
|
92
|
+
this.updateAttribute(e, t, r, A);
|
|
93
93
|
break;
|
|
94
94
|
case "disabled":
|
|
95
95
|
this.color = "state-disabled";
|
|
@@ -97,31 +97,35 @@ class $ extends m {
|
|
|
97
97
|
case "aria-label":
|
|
98
98
|
if (!s(this, n))
|
|
99
99
|
return;
|
|
100
|
-
|
|
100
|
+
r ? (s(this, n).ariaHidden = "false", this.ariaHidden = "false") : (s(this, n).ariaHidden = "true", this.ariaHidden = "true");
|
|
101
101
|
break;
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
connectedCallback() {
|
|
105
|
+
var t;
|
|
106
|
+
this.role = "img";
|
|
105
107
|
const e = document.querySelectorAll("px-icon-set");
|
|
106
108
|
e || console.log("<px-icon-set> component not found");
|
|
107
|
-
for (const
|
|
108
|
-
if (!
|
|
109
|
+
for (const r of e) {
|
|
110
|
+
if (!r.getAttribute("name") || !r.getAttribute("src")) {
|
|
109
111
|
console.error("Icon name or src not found");
|
|
110
112
|
continue;
|
|
111
113
|
}
|
|
112
|
-
|
|
113
|
-
"
|
|
114
|
+
r.getAttribute("name") === this.from && r.getAttribute("type") !== "font" && (d(this, c, r.getAttribute("src")), this.$el.firstElementChild.setAttribute(
|
|
115
|
+
"href",
|
|
114
116
|
`${s(this, c)}#icon-${this.name}`
|
|
115
117
|
));
|
|
116
118
|
}
|
|
117
|
-
!this.ariaLabel && s(this, n) && (s(this, n).ariaHidden = "true", this.ariaHidden = "true");
|
|
119
|
+
!this.ariaLabel && s(this, n) && (s(this, n).ariaHidden = "true", this.ariaHidden = "true"), ((t = this.parentElement) == null ? void 0 : t.localName) === "px-a" && this.slot !== "before" && this.slot !== "after" && (this.color || this.setAttribute("color", "inherit"));
|
|
118
120
|
}
|
|
119
|
-
updateAttribute(e, t,
|
|
120
|
-
t !== null && t !== "" && (e === "size" ? this.$el.classList.toggle(`${e}-${t}`) : this.$el.classList.toggle(t)),
|
|
121
|
+
updateAttribute(e, t, r, v) {
|
|
122
|
+
t !== null && t !== "" && (e === "size" ? this.$el.classList.toggle(`${e}-${t}`) : this.$el.classList.toggle(t)), r !== null && r !== "" && (e === "size" ? this.$el.classList.toggle(`${e}-${r}`) : this.$el.classList.toggle(r)), this.checkName(v, r) || b(
|
|
123
|
+
`${r} is not an allowed ${e} value for ${this.tagName.toLowerCase()}`
|
|
124
|
+
);
|
|
121
125
|
}
|
|
122
126
|
updateName(e, t) {
|
|
123
127
|
s(this, c) && this.$el.firstElementChild.setAttribute(
|
|
124
|
-
"
|
|
128
|
+
"href",
|
|
125
129
|
`${s(this, c)}#icon-${t}`
|
|
126
130
|
);
|
|
127
131
|
}
|
|
@@ -175,9 +179,8 @@ c = new WeakMap(), n = new WeakMap(), l = new WeakMap();
|
|
|
175
179
|
customElements.get("px-icon") || customElements.define("px-icon", $);
|
|
176
180
|
export {
|
|
177
181
|
$ as Icon,
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
z as observedAttributes,
|
|
182
|
+
g as IconSet,
|
|
183
|
+
x as iconColorValues,
|
|
184
|
+
A as iconColorValuesKC,
|
|
182
185
|
h as styleSheet
|
|
183
186
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@proximus/lavender-icon-common",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.120",
|
|
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
|
|
16
|
+
"wc-manifest": "cem analyze --globs \"src/*\" --config ../../../custom-elements-manifest.config.js --outdir dist"
|
|
17
17
|
},
|
|
18
18
|
"publishConfig": {
|
|
19
19
|
"access": "public"
|