@proximus/lavender-status 1.0.0-alpha.0
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/index.js +166 -0
- package/package.json +46 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { PxElement as l } from "@proximus/lavender-common";
|
|
2
|
+
const a = ":host,:host>*{display:block;box-sizing:border-box}.status{font-family:var(--px-font-family);font-size:var(--px-text-size-label-m-mobile);font-weight:400;line-height:var(--px-line-height-m);color:var(--px-text-color-heading-brand-default)}.status.success{color:var(--px-text-color-purpose-success-default)}.status.warning,.status.ongoing{color:var(--px-text-color-purpose-warning-default)}.status.error{color:var(--px-text-color-purpose-error-default)}.status.unlimited{color:var(--px-text-color-purpose-unlimited-default)}.status[disabled]{color:var(--px-text-color-action-disabled-default)}:host([inverted]) .status{color:var(--px-text-color-heading-brand-inverted)}:host([inverted]) .status.success{color:var(--px-text-color-purpose-success-inverted)}:host([inverted]) .status.warning,:host([inverted]) .status.ongoing{color:var(--px-text-color-purpose-warning-inverted)}:host([inverted]) .status.error{color:var(--px-text-color-purpose-error-inverted)}:host([inverted]) .status.unlimited{color:var(--px-text-color-purpose-unlimited-inverted)}:host([inverted]) .status[disabled]{color:var(--px-text-color-action-disabled-inverted)}@media only screen and (min-width: 768px){.status{font-size:var(--px-text-size-label-m-tablet)}}@media only screen and (min-width: 1025px){.status{font-size:var(--px-text-size-label-m-desktop)}}", r = new CSSStyleSheet();
|
|
3
|
+
r.replaceSync(a);
|
|
4
|
+
const c = [
|
|
5
|
+
"",
|
|
6
|
+
"info",
|
|
7
|
+
"success",
|
|
8
|
+
"warning",
|
|
9
|
+
"error",
|
|
10
|
+
"ongoing",
|
|
11
|
+
"unlimited"
|
|
12
|
+
], n = class n extends l {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(r), this.template = () => `
|
|
15
|
+
<div class="status">
|
|
16
|
+
<px-hstack gap="after-element-2xs" align-items="flex-start">
|
|
17
|
+
<px-icon name="information_fill" from="lavender" size="s" color="content-brand"></px-icon>
|
|
18
|
+
<slot name="label"></slot>
|
|
19
|
+
</px-hstack>
|
|
20
|
+
</div>`, this.shadowRoot.innerHTML = this.template(), (!this.$label || !this.iconAriaLabel) && console.warn(
|
|
21
|
+
'Label slot and icon aria-label slot are mandatory even with icon-only case. For accessibility the label slot will only be red by screen readers if the component is set to "icon-only".'
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
static get observedAttributes() {
|
|
25
|
+
return [
|
|
26
|
+
"state",
|
|
27
|
+
"icon-only",
|
|
28
|
+
"icon-only--mobile",
|
|
29
|
+
"icon-only--tablet",
|
|
30
|
+
"icon-only--laptop",
|
|
31
|
+
"disabled",
|
|
32
|
+
"inverted",
|
|
33
|
+
"icon-aria-label"
|
|
34
|
+
];
|
|
35
|
+
}
|
|
36
|
+
connectedCallback() {
|
|
37
|
+
super.connectedCallback(), this.state || this.setRole("info");
|
|
38
|
+
}
|
|
39
|
+
attributeChangedCallback(t, i, e) {
|
|
40
|
+
if (i !== e)
|
|
41
|
+
switch (t) {
|
|
42
|
+
case "state":
|
|
43
|
+
this.updateState(e), this.$el.classList.toggle(`${e}`), this.setRole(e);
|
|
44
|
+
break;
|
|
45
|
+
case "icon-aria-label":
|
|
46
|
+
this.$statusIcon.setAttribute("aria-label", e);
|
|
47
|
+
break;
|
|
48
|
+
case "icon-only":
|
|
49
|
+
this.updateIconOnly(null);
|
|
50
|
+
break;
|
|
51
|
+
case "icon-only--mobile":
|
|
52
|
+
this.updateIconOnly("mobile");
|
|
53
|
+
break;
|
|
54
|
+
case "icon-only--tablet":
|
|
55
|
+
this.updateIconOnly("tablet");
|
|
56
|
+
break;
|
|
57
|
+
case "icon-only--laptop":
|
|
58
|
+
this.updateIconOnly("laptop");
|
|
59
|
+
break;
|
|
60
|
+
case "disabled":
|
|
61
|
+
this.$el.toggleAttribute("disabled", e !== null), this.$statusIcon.color = "action-disabled";
|
|
62
|
+
break;
|
|
63
|
+
case "inverted":
|
|
64
|
+
for (let o = 0; o < this.$children.length; o++)
|
|
65
|
+
this.$children[o].hasAttribute("inverted") || this.$children[o].toggleAttribute("inverted");
|
|
66
|
+
this.$el.toggleAttribute("inverted", e !== null), this.$statusIcon.toggleAttribute("inverted", e !== null);
|
|
67
|
+
break;
|
|
68
|
+
default:
|
|
69
|
+
super.attributeChangedCallback(t, i, e);
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
updateState(t) {
|
|
74
|
+
if (!this.checkName(c, t)) {
|
|
75
|
+
console.error(`${t} is not a valid state value for ${this.$el}`);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const i = {
|
|
79
|
+
info: { name: "information_fill", color: "content-brand" },
|
|
80
|
+
success: { name: "checkmark_fill", color: "purpose-success" },
|
|
81
|
+
warning: { name: "exclamation_mark_fill", color: "purpose-warning" },
|
|
82
|
+
error: { name: "minus_fill", color: "purpose-error" },
|
|
83
|
+
ongoing: { name: "clock_fill", color: "purpose-warning" },
|
|
84
|
+
unlimited: { name: "infinity_fill", color: "purpose-unlimited" }
|
|
85
|
+
}, { name: e, color: o } = i[t] || i.info;
|
|
86
|
+
this.$statusIcon.name = e, this.$statusIcon.color = o;
|
|
87
|
+
}
|
|
88
|
+
setRole(t) {
|
|
89
|
+
this.$el.setAttribute(
|
|
90
|
+
"role",
|
|
91
|
+
!t || t === "info" ? "status" : t
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
updateIconOnly(t) {
|
|
95
|
+
var e;
|
|
96
|
+
const i = t ? `--${t}` : "";
|
|
97
|
+
this.$label.setAttribute(`shown--sr${i}`, ""), (t === "laptop" || t === null) && this.$statusIcon.setAttribute(
|
|
98
|
+
"title",
|
|
99
|
+
((e = this.$label.textContent) == null ? void 0 : e.trim()) || ""
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
get $label() {
|
|
103
|
+
return this.querySelector('[slot="label"]');
|
|
104
|
+
}
|
|
105
|
+
get $statusIcon() {
|
|
106
|
+
return this.shadowRoot.querySelector("px-icon");
|
|
107
|
+
}
|
|
108
|
+
get $children() {
|
|
109
|
+
return this.querySelectorAll("px-status > *");
|
|
110
|
+
}
|
|
111
|
+
get state() {
|
|
112
|
+
return this.getAttribute("state");
|
|
113
|
+
}
|
|
114
|
+
set state(t) {
|
|
115
|
+
this.setAttribute("state", t);
|
|
116
|
+
}
|
|
117
|
+
get iconAriaLabel() {
|
|
118
|
+
return this.getAttribute("icon-aria-label");
|
|
119
|
+
}
|
|
120
|
+
set iconAriaLabel(t) {
|
|
121
|
+
this.setAttribute("icon-aria-label", t);
|
|
122
|
+
}
|
|
123
|
+
get iconOnly() {
|
|
124
|
+
return this.hasAttribute("icon-only");
|
|
125
|
+
}
|
|
126
|
+
set iconOnly(t) {
|
|
127
|
+
t ? this.setAttribute("icon-only", "") : this.removeAttribute("icon-only");
|
|
128
|
+
}
|
|
129
|
+
get iconOnlyMobile() {
|
|
130
|
+
return this.hasAttribute("icon-only--mobile");
|
|
131
|
+
}
|
|
132
|
+
set iconOnlyMobile(t) {
|
|
133
|
+
t ? this.setAttribute("icon-only--mobile", "") : this.removeAttribute("icon-only--mobile");
|
|
134
|
+
}
|
|
135
|
+
get iconOnlyTablet() {
|
|
136
|
+
return this.hasAttribute("icon-only--tablet");
|
|
137
|
+
}
|
|
138
|
+
set iconOnlyTablet(t) {
|
|
139
|
+
t ? this.setAttribute("icon-only--tablet", "") : this.removeAttribute("icon-only--tablet");
|
|
140
|
+
}
|
|
141
|
+
get iconOnlyLaptop() {
|
|
142
|
+
return this.hasAttribute("icon-only--laptop");
|
|
143
|
+
}
|
|
144
|
+
set iconOnlyLaptop(t) {
|
|
145
|
+
t ? this.setAttribute("icon-only--laptop", "") : this.removeAttribute("icon-only--laptop");
|
|
146
|
+
}
|
|
147
|
+
get disabled() {
|
|
148
|
+
return this.hasAttribute("disabled");
|
|
149
|
+
}
|
|
150
|
+
set disabled(t) {
|
|
151
|
+
t ? this.setAttribute("disabled", "") : this.removeAttribute("disabled");
|
|
152
|
+
}
|
|
153
|
+
get inverted() {
|
|
154
|
+
return this.hasAttribute("inverted");
|
|
155
|
+
}
|
|
156
|
+
set inverted(t) {
|
|
157
|
+
t ? this.setAttribute("inverted", "") : this.removeAttribute("inverted");
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
n.nativeName = "div";
|
|
161
|
+
let s = n;
|
|
162
|
+
customElements.define("px-status", s);
|
|
163
|
+
export {
|
|
164
|
+
s as Status,
|
|
165
|
+
c as stateValues
|
|
166
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@proximus/lavender-status",
|
|
3
|
+
"version": "1.0.0-alpha.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./src/index.ts",
|
|
9
|
+
"development": "./src/index.ts",
|
|
10
|
+
"default": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./src/*.css": {
|
|
13
|
+
"development": "src/*.css"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"type": "module",
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsc; vite build",
|
|
22
|
+
"test": "vitest run --coverage"
|
|
23
|
+
},
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"lerna": {
|
|
28
|
+
"command": {
|
|
29
|
+
"publish": {
|
|
30
|
+
"assets": [
|
|
31
|
+
"CHANGELOG.md",
|
|
32
|
+
"package.json",
|
|
33
|
+
"dist/*.js",
|
|
34
|
+
"dist/*.cjs",
|
|
35
|
+
"dist/css/**/*.css",
|
|
36
|
+
"dist/js/**/*.js",
|
|
37
|
+
"dist/*.svg",
|
|
38
|
+
"dist/*.ttf",
|
|
39
|
+
"dist/glyphmap.json",
|
|
40
|
+
"dist/*.d.ts"
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"gitHead": "21c1cee9841df9d3f26e1b2a7809e152ef983fd6"
|
|
46
|
+
}
|