@proximus/lavender-button-icon 1.0.0-alpha.13 → 1.0.0-alpha.16
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.es.js +94 -0
- package/package.json +6 -33
- package/dist/index.js +0 -94
package/dist/index.es.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { PxElement as a, transferAccessibilityAttributes as s } from "@proximus/lavender-common";
|
|
2
|
+
const d = ".btn-icon{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: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)}: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: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--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: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: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)}}", n = new CSSStyleSheet();
|
|
3
|
+
n.replaceSync(d);
|
|
4
|
+
const c = ["", "default", "small"], l = ["", "default", "secondary", "naked"], 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"), o = t.getAttribute("color");
|
|
24
|
+
t.addEventListener("click", () => {
|
|
25
|
+
this.$el.focus();
|
|
26
|
+
}), e || t.setAttribute("size", "s"), this.size === "small" && t.setAttribute("size", "2xs"), o || t.setAttribute("color", "inherit");
|
|
27
|
+
}
|
|
28
|
+
s(this, this.$el);
|
|
29
|
+
}
|
|
30
|
+
attributeChangedCallback(t, e, o) {
|
|
31
|
+
if (e !== o)
|
|
32
|
+
switch (t) {
|
|
33
|
+
case "loading":
|
|
34
|
+
this.updateLoading();
|
|
35
|
+
break;
|
|
36
|
+
case "size":
|
|
37
|
+
this.updateSize(e, o, c);
|
|
38
|
+
break;
|
|
39
|
+
case "variant":
|
|
40
|
+
this.updateVariant(e, o, l);
|
|
41
|
+
break;
|
|
42
|
+
default:
|
|
43
|
+
super.attributeChangedCallback(t, e, o);
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
checkName(t, e) {
|
|
48
|
+
return t.includes(e);
|
|
49
|
+
}
|
|
50
|
+
_toggleClass(t, e) {
|
|
51
|
+
t !== null && t !== "" && t !== "default" && this.$el.classList.toggle(t), e !== null && e !== "" && e !== "default" && this.$el.classList.toggle(e);
|
|
52
|
+
}
|
|
53
|
+
updateLoading() {
|
|
54
|
+
this.$el.classList.toggle("btn-icon--state-loading");
|
|
55
|
+
}
|
|
56
|
+
updateSize(t, e, o) {
|
|
57
|
+
this.checkName(o, 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);
|
|
58
|
+
}
|
|
59
|
+
updateVariant(t, e, o) {
|
|
60
|
+
this.checkName(o, 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}`);
|
|
61
|
+
}
|
|
62
|
+
get inverted() {
|
|
63
|
+
return this.getAttribute("inverted");
|
|
64
|
+
}
|
|
65
|
+
set inverted(t) {
|
|
66
|
+
this.setAttribute("inverted", t);
|
|
67
|
+
}
|
|
68
|
+
get loading() {
|
|
69
|
+
return this.getAttribute("loading");
|
|
70
|
+
}
|
|
71
|
+
set loading(t) {
|
|
72
|
+
this.setAttribute("loading", t);
|
|
73
|
+
}
|
|
74
|
+
get size() {
|
|
75
|
+
return this.getAttribute("size");
|
|
76
|
+
}
|
|
77
|
+
set size(t) {
|
|
78
|
+
this.setAttribute("size", t);
|
|
79
|
+
}
|
|
80
|
+
get variant() {
|
|
81
|
+
return this.getAttribute("variant");
|
|
82
|
+
}
|
|
83
|
+
set variant(t) {
|
|
84
|
+
this.setAttribute("variant", t);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
r.nativeName = "button";
|
|
88
|
+
let i = r;
|
|
89
|
+
customElements.get("px-button-icon") || customElements.define("px-button-icon", i);
|
|
90
|
+
export {
|
|
91
|
+
i as ButtonIcon,
|
|
92
|
+
c as buttonIconSizeValues,
|
|
93
|
+
l as buttonIconVariantValues
|
|
94
|
+
};
|
package/package.json
CHANGED
|
@@ -1,46 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@proximus/lavender-button-icon",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.16",
|
|
4
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
|
-
},
|
|
5
|
+
"main": "dist/index.es.js",
|
|
16
6
|
"files": [
|
|
17
7
|
"dist"
|
|
18
8
|
],
|
|
19
9
|
"type": "module",
|
|
20
10
|
"scripts": {
|
|
21
|
-
"
|
|
11
|
+
"transform-package-json": "node ../../../scripts/tranformPackageJson.js package.json dist/far/away",
|
|
12
|
+
"clean": "rm -rf dist",
|
|
13
|
+
"build": "npm run clean && tsc && NODE_ENV=development vite build && npm run transform-package-json",
|
|
22
14
|
"test": "vitest run --coverage"
|
|
23
15
|
},
|
|
24
16
|
"publishConfig": {
|
|
25
17
|
"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": "ee5ec31f1093c03eab455e20db8e1a8832f5123d"
|
|
18
|
+
}
|
|
46
19
|
}
|
package/dist/index.js
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { PxElement as a, transferAccessibilityAttributes as c } from "@proximus/lavender-common";
|
|
2
|
-
const s = ".btn-icon{display:inline-flex;width:var(--px-action-size-l);height:var(--px-action-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-background-color-action-primary-default);color:var(--px-icon-color-action-brand-inverted);border-radius:var(--px-radius-pill);padding:var(--px-padding-xs-mobile);border:var(--px-border-size-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-background-color-action-hover-bordered-default);color:var(--px-icon-color-action-brand-default);border-color:var(--px-border-color-action-hover-default)}.btn-icon:active:not([disabled],[aria-disabled=true],.btn-icon--state-loading){background:var(--px-background-color-action-active-inverted);color:var(--px-icon-color-action-active-default);border-color:var(--px-border-color-action-active-default)}.btn-icon:focus:not([disabled],[aria-disabled=true]){outline-offset:var(--px-focus-offset-mobile);outline:var(--px-focus-outline-mobile) solid var(--px-border-color-focus-outline-default)}.btn-icon[disabled],.btn-icon[aria-disabled=true]{background:var(--px-background-color-action-disabled-default);color:var(--px-icon-color-action-disabled-default);cursor:default;pointer-events:none}.btn-icon.btn-icon--state-loading{background:var(--px-background-color-action-disabled-default);color:var(--px-icon-color-action-brand-default);cursor:inherit}.btn-icon--size-small{padding:var(--px-padding-2xs-mobile);width:var(--px-action-size-m);height:var(--px-action-size-m)}.btn-icon--variant-secondary{background-color:var(--px-background-color-action-secondary-default);color:var(--px-icon-color-action-brand-default)}.btn-icon--variant-naked{background-color:transparent;color:var(--px-icon-color-action-brand-default)}:host([inverted]) .btn-icon{background:var(--px-background-color-action-primary-inverted);color:var(--px-icon-color-action-brand-default)}:host([inverted]) .btn-icon:hover:not([disabled],[aria-disabled=true],.btn-icon--state-loading){background:var(--px-background-color-action-hover-bordered-inverted);color:var(--px-icon-color-action-brand-inverted);border-color:var(--px-border-color-action-hover-inverted)}:host([inverted]) .btn-icon:active:not([disabled],[aria-disabled=true],.btn-icon--state-loading){background:var(--px-background-color-action-hover-default);color:var(--px-icon-color-action-active-inverted);border-color:var(--px-border-color-action-active-inverted)}:host([inverted]) .btn-icon:focus:not([disabled],[aria-disabled=true]){outline-color:var(--px-border-color-focus-outline-inverted)}:host([inverted]) .btn-icon[disabled],:host([inverted]) .btn-icon[aria-disabled=true]{background:var(--px-background-color-action-disabled-inverted);color:var(--px-icon-color-action-disabled-inverted)}:host([inverted]) .btn-icon.btn-icon--state-loading{background:var(--px-background-color-action-disabled-inverted);color:var(--px-icon-color-action-brand-inverted);border-color:transparent}:host([inverted]) .btn-icon--variant-secondary{background-color:var(--px-background-color-action-secondary-inverted);color:var(--px-icon-color-action-brand-inverted)}@media only screen and (min-width: 768px){.btn-icon{padding:var(--px-padding-xs-tablet)}.btn-icon:focus:not([disabled],[aria-disabled=true]){outline-offset:var(--px-focus-offset-tablet);outline-width:var(--px-focus-outline-tablet)}.btn-icon--size-small{padding:var(--px-padding-2xs-tablet)}}@media only screen and (min-width: 1025px){.btn-icon{padding:var(--px-padding-xs-desktop)}.btn-icon:focus: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)}}", r = new CSSStyleSheet();
|
|
3
|
-
r.replaceSync(s);
|
|
4
|
-
const d = ["", "default", "small"], l = ["", "default", "secondary", "naked"], n = class n extends a {
|
|
5
|
-
constructor() {
|
|
6
|
-
super(r), 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 o = t.getAttribute("size"), i = t.getAttribute("color");
|
|
24
|
-
t.addEventListener("click", () => {
|
|
25
|
-
this.$el.focus();
|
|
26
|
-
}), o || t.setAttribute("size", "s"), this.size === "small" && t.setAttribute("size", "2xs"), i || t.setAttribute("color", "inherit");
|
|
27
|
-
}
|
|
28
|
-
c(this, this.$el);
|
|
29
|
-
}
|
|
30
|
-
attributeChangedCallback(t, o, i) {
|
|
31
|
-
if (o !== i)
|
|
32
|
-
switch (t) {
|
|
33
|
-
case "loading":
|
|
34
|
-
this.updateLoading();
|
|
35
|
-
break;
|
|
36
|
-
case "size":
|
|
37
|
-
this.updateSize(o, i, d);
|
|
38
|
-
break;
|
|
39
|
-
case "variant":
|
|
40
|
-
this.updateVariant(o, i, l);
|
|
41
|
-
break;
|
|
42
|
-
default:
|
|
43
|
-
super.attributeChangedCallback(t, o, i);
|
|
44
|
-
break;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
checkName(t, o) {
|
|
48
|
-
return t.includes(o);
|
|
49
|
-
}
|
|
50
|
-
_toggleClass(t, o) {
|
|
51
|
-
t !== null && t !== "" && t !== "default" && this.$el.classList.toggle(t), o !== null && o !== "" && o !== "default" && this.$el.classList.toggle(o);
|
|
52
|
-
}
|
|
53
|
-
updateLoading() {
|
|
54
|
-
this.$el.classList.toggle("btn-icon--state-loading");
|
|
55
|
-
}
|
|
56
|
-
updateSize(t, o, i) {
|
|
57
|
-
this.checkName(i, o) ? (t !== null && t !== "" && t !== "default" && this.$el.classList.toggle(`btn-icon--size-${t}`), o !== null && o !== "" && o !== "default" && this.$el.classList.toggle(`btn-icon--size-${o}`)) : console.error("Bad size value for", this.$el);
|
|
58
|
-
}
|
|
59
|
-
updateVariant(t, o, i) {
|
|
60
|
-
this.checkName(i, o) ? (t !== null && t !== "" && t !== "default" && this.$el.classList.toggle(`btn-icon--variant-${t}`), o !== null && o !== "" && o !== "default" && this.$el.classList.toggle(`btn-icon--variant-${o}`)) : console.error(`Bad "variant" value for ${this.$el}`);
|
|
61
|
-
}
|
|
62
|
-
get inverted() {
|
|
63
|
-
return this.getAttribute("inverted");
|
|
64
|
-
}
|
|
65
|
-
set inverted(t) {
|
|
66
|
-
this.setAttribute("inverted", t);
|
|
67
|
-
}
|
|
68
|
-
get loading() {
|
|
69
|
-
return this.getAttribute("loading");
|
|
70
|
-
}
|
|
71
|
-
set loading(t) {
|
|
72
|
-
this.setAttribute("loading", t);
|
|
73
|
-
}
|
|
74
|
-
get size() {
|
|
75
|
-
return this.getAttribute("size");
|
|
76
|
-
}
|
|
77
|
-
set size(t) {
|
|
78
|
-
this.setAttribute("size", t);
|
|
79
|
-
}
|
|
80
|
-
get variant() {
|
|
81
|
-
return this.getAttribute("variant");
|
|
82
|
-
}
|
|
83
|
-
set variant(t) {
|
|
84
|
-
this.setAttribute("variant", t);
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
n.nativeName = "button";
|
|
88
|
-
let e = n;
|
|
89
|
-
customElements.get("px-button-icon") || customElements.define("px-button-icon", e);
|
|
90
|
-
export {
|
|
91
|
-
e as ButtonIcon,
|
|
92
|
-
d as buttonIconSizeValues,
|
|
93
|
-
l as buttonIconVariantValues
|
|
94
|
-
};
|