@proximus/lavender-button-icon 1.0.0-alpha.9 → 1.0.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/ButtonIcon.d.ts +27 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +106 -0
- package/package.json +10 -27
- package/dist/index.js +0 -93
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { PxElement } from '@proximus/lavender-common';
|
|
2
|
+
export declare const buttonIconSizeValues: readonly ["", "default", "small"];
|
|
3
|
+
export declare const buttonIconVariantValues: readonly ["", "default", "secondary", "naked"];
|
|
4
|
+
export type ButtonIconSize = (typeof buttonIconSizeValues)[number];
|
|
5
|
+
export type ButtonIconVariant = (typeof buttonIconVariantValues)[number];
|
|
6
|
+
export declare class ButtonIcon extends PxElement<HTMLButtonElement> {
|
|
7
|
+
static nativeName: string;
|
|
8
|
+
private template;
|
|
9
|
+
constructor();
|
|
10
|
+
static get observedAttributes(): string[];
|
|
11
|
+
connectedCallback(): void;
|
|
12
|
+
attributeChangedCallback(attrName: string, oldValue: string, newValue: string): void;
|
|
13
|
+
_toggleClass(oldValue: string, newValue: string): void;
|
|
14
|
+
updateLoading(): void;
|
|
15
|
+
updateSize(oldValue: string, newValue: string): void;
|
|
16
|
+
updateVariant(oldValue: string, newValue: string): void;
|
|
17
|
+
get inverted(): string;
|
|
18
|
+
set inverted(value: string);
|
|
19
|
+
get loading(): string;
|
|
20
|
+
set loading(value: string);
|
|
21
|
+
get size(): string;
|
|
22
|
+
set size(value: string);
|
|
23
|
+
get variant(): string;
|
|
24
|
+
set variant(value: string);
|
|
25
|
+
get ariaExpanded(): string;
|
|
26
|
+
set ariaExpanded(value: string);
|
|
27
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ButtonIcon';
|
package/dist/index.es.js
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { PxElement as n, transferAccessibilityAttributes as s } from "@proximus/lavender-common";
|
|
2
|
+
const d = ".btn-icon{font-size:var(--px-font-size-base);display:inline-flex;width:var(--px-size-l);height:var(--px-size-l);vertical-align:middle;align-items:center;justify-content:center;cursor:pointer;--btn-transition: all .2s ease-in-out 0s;transition:var(--btn-transition);background:var(--px-color-background-container-primary-default);color:var(--px-color-icon-brand-inverted);border-radius:var(--px-radius-pill);padding:var(--px-padding-xs-mobile);border:var(--px-size-border-m) solid transparent}.btn-icon,.btn-icon *{box-sizing:border-box}.btn-icon ::slotted(px-icon){line-height:0}.btn-icon:hover:not([disabled],[aria-disabled=true],.btn-icon--state-loading){background:var(--px-color-background-state-hover-bordered-default);color:var(--px-color-icon-brand-default);border-color:var(--px-color-border-state-hover-default)}.btn-icon:active:not([disabled],[aria-disabled=true],.btn-icon--state-loading){background:var(--px-color-background-state-active-inverted);color:var(--px-color-icon-state-active-default);border-color:var(--px-color-border-state-active-default)}.btn-icon:focus-visible:not([disabled],[aria-disabled=true]){outline-offset:var(--px-focus-offset-mobile);outline:var(--px-focus-outline-mobile) solid var(--px-color-border-focus-outline-default)}.btn-icon[disabled],.btn-icon[aria-disabled=true]{background:var(--px-color-background-state-disabled-default);color:var(--px-color-icon-state-disabled-default);cursor:default;pointer-events:none}.btn-icon.btn-icon--state-loading{background:var(--px-color-background-state-disabled-default);color:var(--px-color-icon-brand-default);cursor:inherit}.btn-icon--size-small{padding:var(--px-padding-2xs-mobile);width:var(--px-size-m);height:var(--px-size-m)}.btn-icon--variant-secondary{background-color:var(--px-color-background-container-secondary-default);color:var(--px-color-icon-brand-default)}.btn-icon--variant-naked{background-color:transparent;color:var(--px-color-icon-brand-default);width:auto;height:auto}:host([inverted]) .btn-icon{background:var(--px-color-background-container-primary-inverted);color:var(--px-color-icon-brand-default)}:host([inverted]) .btn-icon:hover:not([disabled],[aria-disabled=true],.btn-icon--state-loading){background:var(--px-color-background-state-hover-bordered-inverted);color:var(--px-color-icon-brand-inverted);border-color:var(--px-color-border-state-hover-inverted)}:host([inverted]) .btn-icon:active:not([disabled],[aria-disabled=true],.btn-icon--state-loading){background:var(--px-color-background-state-hover-default);color:var(--px-color-icon-state-active-inverted);border-color:var(--px-color-border-state-active-inverted)}:host([inverted]) .btn-icon:focus-visible:not([disabled],[aria-disabled=true]){outline-color:var(--px-color-border-focus-outline-inverted)}:host([inverted]) .btn-icon[disabled],:host([inverted]) .btn-icon[aria-disabled=true]{background:var(--px-color-background-state-disabled-inverted);color:var(--px-color-icon-state-disabled-inverted)}:host([inverted]) .btn-icon.btn-icon--state-loading{background:var(--px-color-background-state-disabled-inverted);color:var(--px-color-icon-brand-inverted);border-color:transparent}:host([inverted]) .btn-icon.btn-icon--variant-naked{background-color:transparent;color:var(--px-color-icon-brand-inverted)}:host([inverted]) .btn-icon--variant-secondary{background-color:var(--px-color-background-container-secondary-inverted);color:var(--px-color-icon-brand-inverted)}@media only screen and (min-width: 768px){.btn-icon{padding:var(--px-padding-xs-desktop)}.btn-icon:focus-visible:not([disabled],[aria-disabled=true]){outline-offset:var(--px-focus-offset-desktop);outline-width:var(--px-focus-outline-desktop)}.btn-icon--size-small{padding:var(--px-padding-2xs-desktop)}}@media only screen and (min-width: 1025px){.btn-icon{padding:var(--px-padding-xs-desktop)}.btn-icon:focus-visible:not([disabled],[aria-disabled=true]){outline-offset:var(--px-focus-offset-desktop);outline-width:var(--px-focus-outline-desktop)}.btn-icon--size-small{padding:var(--px-padding-2xs-desktop)}}", a = new CSSStyleSheet();
|
|
3
|
+
a.replaceSync(d);
|
|
4
|
+
const c = ["", "default", "small"], l = [
|
|
5
|
+
"",
|
|
6
|
+
"default",
|
|
7
|
+
"secondary",
|
|
8
|
+
"naked"
|
|
9
|
+
], r = class r extends n {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(a), this.template = () => "<slot></slot>";
|
|
12
|
+
const t = document.createElement(this.nativeName);
|
|
13
|
+
t.classList.add("btn-icon"), t.innerHTML = this.template(), this.shadowRoot.appendChild(t);
|
|
14
|
+
}
|
|
15
|
+
static get observedAttributes() {
|
|
16
|
+
return [
|
|
17
|
+
...super.observedAttributes,
|
|
18
|
+
"inverted",
|
|
19
|
+
"loading",
|
|
20
|
+
"size",
|
|
21
|
+
"variant",
|
|
22
|
+
"aria-expanded"
|
|
23
|
+
];
|
|
24
|
+
}
|
|
25
|
+
connectedCallback() {
|
|
26
|
+
super.connectedCallback();
|
|
27
|
+
const t = this.querySelector("px-icon");
|
|
28
|
+
if (t) {
|
|
29
|
+
const e = t.getAttribute("size"), i = t.getAttribute("color");
|
|
30
|
+
t.addEventListener("click", () => {
|
|
31
|
+
this.$el.focus();
|
|
32
|
+
}), e || t.setAttribute("size", "s"), this.size === "small" && t.setAttribute("size", "xs"), i || t.setAttribute("color", "inherit");
|
|
33
|
+
}
|
|
34
|
+
s(this, this.$el, !1);
|
|
35
|
+
}
|
|
36
|
+
attributeChangedCallback(t, e, i) {
|
|
37
|
+
if (e !== i)
|
|
38
|
+
switch (t) {
|
|
39
|
+
case "loading":
|
|
40
|
+
this.updateLoading();
|
|
41
|
+
break;
|
|
42
|
+
case "size":
|
|
43
|
+
this.updateSize(e, i);
|
|
44
|
+
break;
|
|
45
|
+
case "variant":
|
|
46
|
+
this.updateVariant(e, i);
|
|
47
|
+
break;
|
|
48
|
+
case "aria-expanded":
|
|
49
|
+
i && (this.$el.setAttribute("aria-expanded", i), this.removeAttribute("aria-expanded"));
|
|
50
|
+
break;
|
|
51
|
+
default:
|
|
52
|
+
super.attributeChangedCallback(t, e, i);
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
_toggleClass(t, e) {
|
|
57
|
+
t !== null && t !== "" && t !== "default" && this.$el.classList.toggle(t), e !== null && e !== "" && e !== "default" && this.$el.classList.toggle(e);
|
|
58
|
+
}
|
|
59
|
+
updateLoading() {
|
|
60
|
+
this.$el.classList.toggle("btn-icon--state-loading");
|
|
61
|
+
}
|
|
62
|
+
updateSize(t, e) {
|
|
63
|
+
this.checkName(c, e) ? (t !== null && t !== "" && t !== "default" && this.$el.classList.toggle(`btn-icon--size-${t}`), e !== null && e !== "" && e !== "default" && this.$el.classList.toggle(`btn-icon--size-${e}`)) : console.error(`${e} is not a valid size value`);
|
|
64
|
+
}
|
|
65
|
+
updateVariant(t, e) {
|
|
66
|
+
this.checkName(l, e) ? (t !== null && t !== "" && t !== "default" && this.$el.classList.toggle(`btn-icon--variant-${t}`), e !== null && e !== "" && e !== "default" && this.$el.classList.toggle(`btn-icon--variant-${e}`)) : console.error(`${e} is not a valid variant value`);
|
|
67
|
+
}
|
|
68
|
+
get inverted() {
|
|
69
|
+
return this.getAttribute("inverted");
|
|
70
|
+
}
|
|
71
|
+
set inverted(t) {
|
|
72
|
+
this.setAttribute("inverted", t);
|
|
73
|
+
}
|
|
74
|
+
get loading() {
|
|
75
|
+
return this.getAttribute("loading");
|
|
76
|
+
}
|
|
77
|
+
set loading(t) {
|
|
78
|
+
this.setAttribute("loading", t);
|
|
79
|
+
}
|
|
80
|
+
get size() {
|
|
81
|
+
return this.getAttribute("size");
|
|
82
|
+
}
|
|
83
|
+
set size(t) {
|
|
84
|
+
this.setAttribute("size", t);
|
|
85
|
+
}
|
|
86
|
+
get variant() {
|
|
87
|
+
return this.getAttribute("variant");
|
|
88
|
+
}
|
|
89
|
+
set variant(t) {
|
|
90
|
+
this.setAttribute("variant", t);
|
|
91
|
+
}
|
|
92
|
+
get ariaExpanded() {
|
|
93
|
+
return this.getAttribute("aria-expanded");
|
|
94
|
+
}
|
|
95
|
+
set ariaExpanded(t) {
|
|
96
|
+
t ? this.setAttribute("aria-expanded", t) : this.removeAttribute("aria-expanded");
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
r.nativeName = "button";
|
|
100
|
+
let o = r;
|
|
101
|
+
customElements.get("px-button-icon") || customElements.define("px-button-icon", o);
|
|
102
|
+
export {
|
|
103
|
+
o as ButtonIcon,
|
|
104
|
+
c as buttonIconSizeValues,
|
|
105
|
+
l as buttonIconVariantValues
|
|
106
|
+
};
|
package/package.json
CHANGED
|
@@ -1,40 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@proximus/lavender-button-icon",
|
|
3
|
-
"version": "1.0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"
|
|
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
|
-
},
|
|
5
|
+
"main": "dist/index.es.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
16
7
|
"files": [
|
|
17
8
|
"dist"
|
|
18
9
|
],
|
|
19
10
|
"type": "module",
|
|
20
11
|
"scripts": {
|
|
21
|
-
"
|
|
22
|
-
"
|
|
12
|
+
"transform-package-json": "node ../../../scripts/tranformPackageJson.js package.json dist/far/away",
|
|
13
|
+
"clean": "rm -rf dist",
|
|
14
|
+
"build": "npm run clean && NODE_ENV=development vite build && tsc && npm run transform-package-json && npm run wc-manifest",
|
|
15
|
+
"test": "vitest run --coverage",
|
|
16
|
+
"wc-manifest": "cem analyze --globs \"src/*\" --config ../custom-elements-manifest.config.js --outdir dist"
|
|
23
17
|
},
|
|
24
18
|
"publishConfig": {
|
|
25
19
|
"access": "public"
|
|
26
20
|
},
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
"publish": {
|
|
30
|
-
"assets": [
|
|
31
|
-
"CHANGELOG.md",
|
|
32
|
-
"package.json",
|
|
33
|
-
"dist/*.js",
|
|
34
|
-
"dist/css/**/*.css"
|
|
35
|
-
]
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
"gitHead": "d7d79386241af5327dcf3b2e2995d1f6589adf6e"
|
|
21
|
+
"customElements": "dist/custom-elements.json",
|
|
22
|
+
"web-types": "./dist/web-types.json"
|
|
40
23
|
}
|
package/dist/index.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { PxElement as a } from "@proximus/lavender-common";
|
|
2
|
-
const s = ".btn-icon{display:inline-flex;vertical-align:middle;align-items:center;justify-content:center;cursor:pointer;--btn-transition: all .2s ease-in-out 0s;transition:var(--btn-transition);background:var(--px-color-bg-action-primary-default);color:var(--px-color-icon-primary-inverted);border-radius:var(--px-radius-pill);padding:var(--px-padding-xs);border:var(--px-border-m) solid transparent}.btn-icon,.btn-icon *{box-sizing:border-box}.btn-icon ::slotted(px-icon){line-height:0}.btn-icon:hover:not([disabled],[aria-disabled=true],.btn-icon--state-loading){background:var(--px-color-bg-action-hover-bordered-default);color:var(--px-color-icon-primary-default);border-color:var(--px-color-border-action-hover-default)}.btn-icon:focus:not([disabled],[aria-disabled=true]){outline-offset:var(--px-offset-s);outline:var(--px-outline-s) solid var(--px-color-outline-default)}.btn-icon[disabled],.btn-icon[aria-disabled=true]{background:var(--px-color-bg-action-disabled-default);color:var(--px-color-icon-disabled-default);cursor:default;pointer-events:none}.btn-icon.btn-icon--state-loading{background:var(--px-color-bg-action-disabled-default);color:var(--px-color-icon-primary-default);cursor:inherit}.btn-icon--size-small{padding:var(--px-padding-2xs)}.btn-icon--variant-secondary{background-color:var(--px-color-bg-action-secondary-default);color:var(--px-color-icon-primary-default)}:host([inverted]) .btn-icon{background:var(--px-color-bg-action-primary-inverted);color:var(--px-color-icon-primary-default)}:host([inverted]) .btn-icon:hover:not([disabled],[aria-disabled=true],.btn-icon--state-loading){background:var(--px-color-bg-action-hover-bordered-default);color:var(--px-color-icon-primary-inverted);border-color:var(--px-color-border-action-hover-inverted)}:host([inverted]) .btn-icon:focus:not([disabled],[aria-disabled=true]){outline-color:var(--px-color-outline-inverted)}:host([inverted]) .btn-icon[disabled],:host([inverted]) .btn-icon[aria-disabled=true]{background:var(--px-color-bg-action-disabled-inverted);color:var(--px-color-icon-disabled-inverted)}:host([inverted]) .btn-icon.btn-icon--state-loading{background:var(--px-color-bg-action-disabled-inverted);color:var(--px-color-icon-primary-inverted);border-color:transparent}:host([inverted]) .btn-icon--variant-secondary{background-color:var(--px-color-bg-action-secondary-inverted);color:var(--px-color-icon-primary-inverted)}@media screen and (min-width: 1441px){.btn-icon:focus:not([disabled],[aria-disabled=true]){outline-offset:var(--px-offset);outline-width:var(--px-outline)}}", n = new CSSStyleSheet();
|
|
3
|
-
n.replaceSync(s);
|
|
4
|
-
const c = ["", "default", "small"], d = ["", "default", "secondary"], r = class r extends a {
|
|
5
|
-
constructor() {
|
|
6
|
-
super(n), this.template = () => "<slot></slot>";
|
|
7
|
-
const t = document.createElement(this.nativeName);
|
|
8
|
-
t.classList.add("btn-icon"), t.innerHTML = this.template(), this.shadowRoot.appendChild(t);
|
|
9
|
-
}
|
|
10
|
-
static get observedAttributes() {
|
|
11
|
-
return [
|
|
12
|
-
...super.observedAttributes,
|
|
13
|
-
"inverted",
|
|
14
|
-
"loading",
|
|
15
|
-
"size",
|
|
16
|
-
"variant"
|
|
17
|
-
];
|
|
18
|
-
}
|
|
19
|
-
connectedCallback() {
|
|
20
|
-
super.connectedCallback();
|
|
21
|
-
const t = this.querySelector("px-icon");
|
|
22
|
-
if (t) {
|
|
23
|
-
const e = t.getAttribute("size"), i = t.getAttribute("color");
|
|
24
|
-
t.addEventListener("click", () => {
|
|
25
|
-
this.$el.focus();
|
|
26
|
-
}), e || t.setAttribute("size", "xs"), i || t.setAttribute("color", "inherit");
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
attributeChangedCallback(t, e, i) {
|
|
30
|
-
if (e !== i)
|
|
31
|
-
switch (t) {
|
|
32
|
-
case "loading":
|
|
33
|
-
this.updateLoading();
|
|
34
|
-
break;
|
|
35
|
-
case "size":
|
|
36
|
-
this.updateSize(e, i, c);
|
|
37
|
-
break;
|
|
38
|
-
case "variant":
|
|
39
|
-
this.updateVariant(e, i, d);
|
|
40
|
-
break;
|
|
41
|
-
default:
|
|
42
|
-
super.attributeChangedCallback(t, e, i);
|
|
43
|
-
break;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
checkName(t, e) {
|
|
47
|
-
return t.includes(e);
|
|
48
|
-
}
|
|
49
|
-
_toggleClass(t, e) {
|
|
50
|
-
t !== null && t !== "" && t !== "default" && this.$el.classList.toggle(t), e !== null && e !== "" && e !== "default" && this.$el.classList.toggle(e);
|
|
51
|
-
}
|
|
52
|
-
updateLoading() {
|
|
53
|
-
this.$el.classList.toggle("btn-icon--state-loading");
|
|
54
|
-
}
|
|
55
|
-
updateSize(t, e, i) {
|
|
56
|
-
this.checkName(i, e) ? (t !== null && t !== "" && t !== "default" && this.$el.classList.toggle(`btn-icon--size-${t}`), e !== null && e !== "" && e !== "default" && this.$el.classList.toggle(`btn-icon--size-${e}`)) : console.error("Bad size value for", this.$el);
|
|
57
|
-
}
|
|
58
|
-
updateVariant(t, e, i) {
|
|
59
|
-
this.checkName(i, e) ? (t !== null && t !== "" && t !== "default" && this.$el.classList.toggle(`btn-icon--variant-${t}`), e !== null && e !== "" && e !== "default" && this.$el.classList.toggle(`btn-icon--variant-${e}`)) : console.error(`Bad "variant" value for ${this.$el}`);
|
|
60
|
-
}
|
|
61
|
-
get inverted() {
|
|
62
|
-
return this.getAttribute("inverted");
|
|
63
|
-
}
|
|
64
|
-
set inverted(t) {
|
|
65
|
-
this.setAttribute("inverted", t);
|
|
66
|
-
}
|
|
67
|
-
get loading() {
|
|
68
|
-
return this.getAttribute("loading");
|
|
69
|
-
}
|
|
70
|
-
set loading(t) {
|
|
71
|
-
this.setAttribute("loading", t);
|
|
72
|
-
}
|
|
73
|
-
get size() {
|
|
74
|
-
return this.getAttribute("size");
|
|
75
|
-
}
|
|
76
|
-
set size(t) {
|
|
77
|
-
this.setAttribute("size", t);
|
|
78
|
-
}
|
|
79
|
-
get variant() {
|
|
80
|
-
return this.getAttribute("variant");
|
|
81
|
-
}
|
|
82
|
-
set variant(t) {
|
|
83
|
-
this.setAttribute("variant", t);
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
r.nativeName = "button";
|
|
87
|
-
let o = r;
|
|
88
|
-
customElements.get("px-button-icon") || customElements.define("px-button-icon", o);
|
|
89
|
-
export {
|
|
90
|
-
o as ButtonIcon,
|
|
91
|
-
c as buttonIconSizeValues,
|
|
92
|
-
d as buttonIconVariantValues
|
|
93
|
-
};
|