@proximus/lavender-tag 2.0.0-alpha.16 → 2.0.0-alpha.161
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/Tag.d.ts +24 -6
- package/dist/index.es.js +123 -26
- package/package.json +2 -2
package/dist/Tag.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { PxElement } from '@proximus/lavender-common';
|
|
2
2
|
import { type ButtonIcon } from '@proximus/lavender-button-icon';
|
|
3
3
|
import '@proximus/lavender-button-icon';
|
|
4
|
+
export declare const tagSizeValues: string[];
|
|
5
|
+
export declare const tagStateValues: string[];
|
|
4
6
|
export declare class Tag extends PxElement<HTMLDivElement> {
|
|
5
7
|
static nativeName: string;
|
|
6
8
|
private template;
|
|
@@ -8,10 +10,26 @@ export declare class Tag extends PxElement<HTMLDivElement> {
|
|
|
8
10
|
connectedCallback(): void;
|
|
9
11
|
static get observedAttributes(): string[];
|
|
10
12
|
attributeChangedCallback(attrName: string, oldValue: string, newValue: string): void;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
updateStateStyles(oldValue: string, newValue: string, attributeValues: string[]): void;
|
|
14
|
+
getStateIcon(state: string): "" | "checkmark_fill" | "minus_fill" | "exclamation_mark_fill";
|
|
15
|
+
updateStateIconLabel(newValue: string): void;
|
|
16
|
+
updateStateIconFrom(newValue: string): void;
|
|
17
|
+
styleBeforeIcon(): void;
|
|
18
|
+
styleAfterBtnIcon(): void;
|
|
19
|
+
get $slottedBeforeIcon(): HTMLSlotElement;
|
|
20
|
+
get $slotBefore(): HTMLSlotElement;
|
|
21
|
+
get $slottedAfterBtnIcon(): ButtonIcon;
|
|
22
|
+
get $slotAfter(): HTMLSlotElement;
|
|
23
|
+
get size(): string;
|
|
24
|
+
set size(value: string);
|
|
25
|
+
get state(): string;
|
|
26
|
+
set state(value: string);
|
|
27
|
+
get dismissible(): boolean;
|
|
28
|
+
set dismissible(value: boolean);
|
|
29
|
+
get inverted(): boolean;
|
|
30
|
+
set inverted(value: boolean);
|
|
31
|
+
get stateIconAriaLabel(): string;
|
|
32
|
+
set stateIconAriaLabel(value: string);
|
|
33
|
+
get stateIconFrom(): string;
|
|
34
|
+
set stateIconFrom(value: string);
|
|
17
35
|
}
|
package/dist/index.es.js
CHANGED
|
@@ -1,59 +1,156 @@
|
|
|
1
|
-
import { PxElement as
|
|
1
|
+
import { PxElement as n } from "@proximus/lavender-common";
|
|
2
2
|
import "@proximus/lavender-button-icon";
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
const s = class
|
|
3
|
+
const l = ':host:has(.tag){display:inline-block}.tag{display:inline-flex;vertical-align:middle;align-items:center;justify-content:center;font-family:var(--px-font-family);font-size:var(--px-text-size-label-m-mobile);line-height:var(--px-line-height-ratio-l);font-weight:var(--px-font-weight-body);gap:var(--px-spacing-2xs-mobile);background-color:var(--px-color-background-container-default-default);color:var(--px-color-text-neutral-default);padding:var(--px-padding-2xs-mobile) var(--px-padding-xs-mobile);border:var(--px-size-border-s) solid transparent;border-radius:var(--px-radius-main)}.tag,.tag *{box-sizing:border-box}:host([disabled]:not([dismissible])) .tag{background-color:var(--px-color-background-state-disabled-default);color:var(--px-color-text-state-disabled-default)}:host([size="s"]) .tag{padding:var(--px-padding-2xs-mobile) var(--px-padding-xs-mobile);gap:var(--px-spacing-2xs-mobile)}:host([size="m"]) .tag{padding:var(--px-padding-xs-mobile) var(--px-padding-s-mobile);gap:var(--px-spacing-xs-mobile)}:host([state="success"]) .tag{background-color:var(--px-color-background-purpose-success-default);color:var(--px-color-text-neutral-inverted)}:host([state="warning"]) .tag{background-color:var(--px-color-background-purpose-warning-default);color:var(--px-color-text-neutral-inverted)}:host([state="error"]) .tag{background-color:var(--px-color-background-purpose-error-default);color:var(--px-color-text-neutral-inverted)}:host([inverted]) .tag{background-color:var(--px-color-background-container-default-inverted);color:var(--px-color-text-neutral-inverted)}:host([inverted]):host([disabled]:not([dismissible])) .tag{background-color:var(--px-color-background-state-disabled-inverted);color:var(--px-color-text-state-disabled-inverted)}:host([inverted]):host([state="success"]) .tag{background-color:var(--px-color-background-purpose-success-inverted);color:var(--px-color-text-neutral-default)}:host([inverted]):host([state="warning"]) .tag{background-color:var(--px-color-background-purpose-warning-inverted);color:var(--px-color-text-neutral-default)}:host([inverted]):host([state="error"]) .tag{background-color:var(--px-color-background-purpose-error-inverted);color:var(--px-color-text-neutral-default)}@media screen and (min-width: 48rem){.tag{font-size:var(--px-text-size-label-m-tablet);gap:var(--px-spacing-2xs-tablet);padding:var(--px-padding-2xs-tablet) var(--px-padding-xs-tablet)}:host([size="s"]) .tag{padding:var(--px-padding-2xs-tablet) var(--px-padding-xs-tablet);gap:var(--px-spacing-2xs-tablet)}:host([size="m"]) .tag{padding:var(--px-padding-xs-tablet) var(--px-padding-s-tablet);gap:var(--px-spacing-xs-tablet)}}@media screen and (min-width: 64.0625rem){.tag{font-size:var(--px-text-size-label-m-laptop);gap:var(--px-spacing-2xs-laptop);padding:var(--px-padding-2xs-laptop) var(--px-padding-xs-laptop)}:host([size="s"]) .tag{padding:var(--px-padding-2xs-laptop) var(--px-padding-xs-laptop);gap:var(--px-spacing-2xs-laptop)}:host([size="m"]) .tag{padding:var(--px-padding-xs-laptop) var(--px-padding-s-laptop);gap:var(--px-spacing-xs-laptop)}}@media screen and (min-width: 90.0625rem){.tag{font-size:var(--px-text-size-label-m-desktop);gap:var(--px-spacing-2xs-desktop);padding:var(--px-padding-2xs-desktop) var(--px-padding-xs-desktop)}:host([size="s"]) .tag{padding:var(--px-padding-2xs-desktop) var(--px-padding-xs-desktop);gap:var(--px-spacing-2xs-desktop)}:host([size="m"]) .tag{padding:var(--px-padding-xs-desktop) var(--px-padding-s-desktop);gap:var(--px-spacing-xs-desktop)}}', r = new CSSStyleSheet();
|
|
4
|
+
r.replaceSync(l);
|
|
5
|
+
const g = ["", "s", "m"], d = ["", "success", "error", "warning"], o = class o extends n {
|
|
6
6
|
template() {
|
|
7
7
|
return `
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
<div class="tag">
|
|
9
|
+
<slot name="before"></slot>
|
|
10
|
+
<slot></slot>
|
|
11
|
+
<slot name="after"></slot>
|
|
12
|
+
</div>
|
|
13
13
|
`;
|
|
14
14
|
}
|
|
15
15
|
constructor() {
|
|
16
|
-
super(
|
|
16
|
+
super(r), this.shadowRoot.innerHTML = this.template(), this.shadowRoot.adoptedStyleSheets = [r];
|
|
17
17
|
}
|
|
18
18
|
connectedCallback() {
|
|
19
|
-
|
|
19
|
+
var t, e;
|
|
20
|
+
this.styleBeforeIcon = this.styleBeforeIcon.bind(this), this.styleBeforeIcon(), (t = this.$slotBefore) == null || t.addEventListener("slotchange", this.styleBeforeIcon), this.styleAfterBtnIcon = this.styleAfterBtnIcon.bind(this), this.styleAfterBtnIcon(), (e = this.$slotAfter) == null || e.addEventListener("slotchange", this.styleAfterBtnIcon);
|
|
20
21
|
}
|
|
21
22
|
static get observedAttributes() {
|
|
22
|
-
return [
|
|
23
|
+
return [
|
|
24
|
+
"dismissible",
|
|
25
|
+
"inverted",
|
|
26
|
+
"disabled",
|
|
27
|
+
"size",
|
|
28
|
+
"state",
|
|
29
|
+
"state-icon-aria-label",
|
|
30
|
+
"state-icon-from"
|
|
31
|
+
];
|
|
23
32
|
}
|
|
24
|
-
attributeChangedCallback(t,
|
|
25
|
-
if (
|
|
33
|
+
attributeChangedCallback(t, e, a) {
|
|
34
|
+
if (e !== a)
|
|
26
35
|
switch (t) {
|
|
27
36
|
case "inverted":
|
|
28
|
-
this.hasAttribute("dismissible") && this.$
|
|
37
|
+
this.hasAttribute("dismissible") && this.$slottedAfterBtnIcon.toggleAttribute("inverted");
|
|
38
|
+
break;
|
|
39
|
+
case "state":
|
|
40
|
+
this.hasAttribute("dismissible") || this.updateStateStyles(e, a, d);
|
|
41
|
+
break;
|
|
42
|
+
case "state-icon-aria-label":
|
|
43
|
+
this.hasAttribute("dismissible") || this.updateStateIconLabel(a);
|
|
44
|
+
break;
|
|
45
|
+
case "state-icon-from":
|
|
46
|
+
this.hasAttribute("dismissible") || this.updateStateIconFrom(a);
|
|
29
47
|
break;
|
|
30
48
|
default:
|
|
31
|
-
super.attributeChangedCallback(t,
|
|
49
|
+
super.attributeChangedCallback(t, e, a);
|
|
32
50
|
break;
|
|
33
51
|
}
|
|
34
52
|
}
|
|
35
|
-
|
|
53
|
+
updateStateStyles(t, e, a) {
|
|
54
|
+
if (!a.includes(t) && a.includes(e)) {
|
|
55
|
+
const s = document.createElement("px-icon");
|
|
56
|
+
s.setAttribute("size", "xs"), s.setAttribute("color", "inherit"), s.setAttribute(
|
|
57
|
+
"from",
|
|
58
|
+
this.stateIconFrom ? this.stateIconFrom : "lavender"
|
|
59
|
+
), s.setAttribute("name", this.getStateIcon(e)), this.stateIconAriaLabel && (s.setAttribute("aria-label", this.stateIconAriaLabel), s.setAttribute("title", this.stateIconAriaLabel)), this.$el.insertAdjacentElement("afterbegin", s);
|
|
60
|
+
} else if (a.includes(t) && !a.includes(e)) {
|
|
61
|
+
const s = this.$el.querySelector("px-icon");
|
|
62
|
+
s && this.$el.removeChild(s);
|
|
63
|
+
} else if (a.includes(t) && a.includes(e)) {
|
|
64
|
+
const s = this.$el.querySelector("px-icon");
|
|
65
|
+
s && s.setAttribute("name", this.getStateIcon(e));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
getStateIcon(t) {
|
|
69
|
+
switch (t) {
|
|
70
|
+
case "success":
|
|
71
|
+
return "checkmark_fill";
|
|
72
|
+
case "error":
|
|
73
|
+
return "minus_fill";
|
|
74
|
+
case "warning":
|
|
75
|
+
return "exclamation_mark_fill";
|
|
76
|
+
default:
|
|
77
|
+
return "";
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
updateStateIconLabel(t) {
|
|
81
|
+
const e = this.$el.querySelector("px-icon");
|
|
82
|
+
e && (t ? (e.setAttribute("aria-label", t), e.setAttribute("title", t)) : (e.removeAttribute("aria-label"), e.removeAttribute("title")));
|
|
83
|
+
}
|
|
84
|
+
updateStateIconFrom(t) {
|
|
85
|
+
const e = this.$el.querySelector("px-icon");
|
|
86
|
+
e && (t ? e.setAttribute("from", t) : e.setAttribute("from", "lavender"));
|
|
87
|
+
}
|
|
88
|
+
styleBeforeIcon() {
|
|
89
|
+
this.$slottedBeforeIcon && (this.$slottedBeforeIcon.setAttribute("size", "xs"), this.$slottedBeforeIcon.setAttribute("color", "inherit"));
|
|
90
|
+
}
|
|
91
|
+
styleAfterBtnIcon() {
|
|
92
|
+
this.$slottedAfterBtnIcon && (this.$slottedAfterBtnIcon.setAttribute("variant", "secondary"), this.$slottedAfterBtnIcon.setAttribute("size", "small"));
|
|
93
|
+
}
|
|
94
|
+
get $slottedBeforeIcon() {
|
|
36
95
|
return this.querySelector('px-icon[slot="before"]');
|
|
37
96
|
}
|
|
38
|
-
get $
|
|
39
|
-
|
|
97
|
+
get $slotBefore() {
|
|
98
|
+
var t;
|
|
99
|
+
return (t = this.shadowRoot) == null ? void 0 : t.querySelector(
|
|
100
|
+
'slot[name="before"]'
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
get $slottedAfterBtnIcon() {
|
|
104
|
+
return this.querySelector('px-button-icon[slot="after"]');
|
|
105
|
+
}
|
|
106
|
+
get $slotAfter() {
|
|
107
|
+
var t;
|
|
108
|
+
return (t = this.shadowRoot) == null ? void 0 : t.querySelector(
|
|
109
|
+
'slot[name="after"]'
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
get size() {
|
|
113
|
+
return this.getAttribute("size") || "";
|
|
114
|
+
}
|
|
115
|
+
set size(t) {
|
|
116
|
+
this.setAttribute("size", t);
|
|
117
|
+
}
|
|
118
|
+
get state() {
|
|
119
|
+
return this.getAttribute("state") || "";
|
|
120
|
+
}
|
|
121
|
+
set state(t) {
|
|
122
|
+
this.setAttribute("state", t);
|
|
40
123
|
}
|
|
41
124
|
get dismissible() {
|
|
42
|
-
return this.
|
|
125
|
+
return this.hasAttribute("dismissible");
|
|
43
126
|
}
|
|
44
127
|
set dismissible(t) {
|
|
45
|
-
this.setAttribute("dismissible",
|
|
128
|
+
t ? this.setAttribute("dismissible", "") : this.removeAttribute("dismissible");
|
|
46
129
|
}
|
|
47
130
|
get inverted() {
|
|
48
|
-
return this.
|
|
131
|
+
return this.hasAttribute("inverted");
|
|
49
132
|
}
|
|
50
133
|
set inverted(t) {
|
|
51
|
-
this.setAttribute("inverted",
|
|
134
|
+
t ? this.setAttribute("inverted", "") : this.removeAttribute("inverted");
|
|
135
|
+
}
|
|
136
|
+
get stateIconAriaLabel() {
|
|
137
|
+
return this.getAttribute("state-icon-aria-label") || "";
|
|
138
|
+
}
|
|
139
|
+
set stateIconAriaLabel(t) {
|
|
140
|
+
this.setAttribute("state-icon-aria-label", t);
|
|
141
|
+
}
|
|
142
|
+
get stateIconFrom() {
|
|
143
|
+
return this.getAttribute("state-icon-from") || "";
|
|
144
|
+
}
|
|
145
|
+
set stateIconFrom(t) {
|
|
146
|
+
this.setAttribute("state-icon-from", t);
|
|
52
147
|
}
|
|
53
148
|
};
|
|
54
|
-
|
|
55
|
-
let i =
|
|
149
|
+
o.nativeName = "div";
|
|
150
|
+
let i = o;
|
|
56
151
|
customElements.get("px-tag") || customElements.define("px-tag", i);
|
|
57
152
|
export {
|
|
58
|
-
i as Tag
|
|
153
|
+
i as Tag,
|
|
154
|
+
g as tagSizeValues,
|
|
155
|
+
d as tagStateValues
|
|
59
156
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@proximus/lavender-tag",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.161",
|
|
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
|
|
16
|
+
"wc-manifest": "cem analyze --globs \"src/*\" --config ../../custom-elements-manifest.config.js --outdir dist"
|
|
17
17
|
},
|
|
18
18
|
"publishConfig": {
|
|
19
19
|
"access": "public"
|