@proximus/lavender-switch 1.0.0-alpha.3 → 1.0.0-alpha.5
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 +20 -17
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { PxElement as
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
const
|
|
1
|
+
import { PxElement as l } from "@proximus/lavender-common";
|
|
2
|
+
const d = ':host{display:inline-flex}.switch *{box-sizing:border-box}.switch{display:inline-flex;align-items:center;border-radius:var(--px-radius-pill)}.switch:focus-visible{outline:var(--px-focus-outline-mobile) solid var(--px-border-color-focus-outline-default);outline-offset:var(--px-focus-offset-mobile)}.switch:has(input[inverted]):focus-visible{outline-color:var(--px-border-color-focus-outline-inverted)}label{display:flex;flex-shrink:0;padding:var(--px-padding-3xs-mobile);border-radius:var(--px-radius-pill);background-color:var(--px-background-color-action-neutral-strong-default);outline:var(--px-border-size-m) solid var(--px-border-color-none);width:var(--px-action-input-switch-size-width);height:calc(var(--px-action-size-m) + (var(--px-padding-3xs-mobile) * 2));position:relative}input:not([disabled])+label:hover:not([disabled]){outline-color:var(--px-border-color-action-neutral-default)}label:after{content:"";position:absolute;top:50%;left:var(--px-padding-3xs-mobile);width:var(--px-action-size-m);max-width:var(--px-action-size-m);height:var(--px-action-size-m);border-radius:var(--px-radius-pill);background-color:var(--px-background-color-action-neutral-bare-default);transform:translateY(-50%);transition:transform .2s ease-in-out}:host input{-webkit-appearance:none;-moz-appearance:none;appearance:none;margin:0}:host([checked]) label{background-color:var(--px-background-color-purpose-success-default);transition:background-color .2s ease-in-out}:host([checked]) label:after{transform:translateY(-50%) translate(calc(var(--px-action-size-m) - var(--px-padding-3xs-mobile)));transition:transform .2s ease-in-out}:host(:hover) :is(:host(:not([disabled])) :is(:host([checked]) label)),:host([hover]) :is(:host(:not([disabled])) :is(:host([checked]) label)){outline-color:var(--px-border-color-purpose-success-default)}:host([disabled]) label{background-color:var(--px-background-color-action-disabled-default)}:host([disabled]) label:after{background-color:var(--px-background-color-action-disabled-default)}:host([inverted]) label{background-color:var(--px-background-color-action-neutral-strong-inverted)}:host(:hover) :is(:host(:not([disabled])) :is(:host([inverted]) label)),:host([hover]) :is(:host(:not([disabled])) :is(:host([inverted]) label)){outline-color:var(--px-border-color-action-neutral-inverted)}:host([checked]:not([disabled])) :is(:host([inverted]) label){background-color:var(--px-background-color-purpose-success-inverted)}:host(:hover) :is(:host([checked]:not([disabled])) :is(:host([inverted]) label)),:host([hover]) :is(:host([checked]:not([disabled])) :is(:host([inverted]) label)){outline-color:var(--px-border-color-purpose-success-inverted)}:host([disabled]) :is(:host([inverted]) label){background-color:var(--px-background-color-action-disabled-inverted)}:host([disabled]) :is(:host([inverted]) label):after{background-color:var(--px-background-color-action-disabled-inverted)}@media only screen and (min-width: 768px){label{padding:var(--px-padding-3xs-tablet)}}@media only screen and (min-width: 1025px){label{padding:var(--px-padding-3xs-desktop)}}', a = new CSSStyleSheet();
|
|
3
|
+
a.replaceSync(d);
|
|
4
|
+
var n = /* @__PURE__ */ ((i) => (i.ERROR = "error", i.SUCCESS = "success", i))(n || {});
|
|
5
|
+
const o = class o extends l {
|
|
6
6
|
constructor() {
|
|
7
7
|
var e;
|
|
8
|
-
super(
|
|
8
|
+
super(a), this.template = () => `<div class="switch" tabindex="0" role="switch">
|
|
9
9
|
<input type="checkbox" tabindex="-1"/>
|
|
10
10
|
<label></label>
|
|
11
11
|
</div>`, this.shadowRoot.innerHTML = this.template(), this.internals = (e = this.attachInternals) == null ? void 0 : e.call(this);
|
|
12
12
|
}
|
|
13
13
|
static get observedAttributes() {
|
|
14
|
-
return [...super.observedAttributes, "inverted"];
|
|
14
|
+
return [...super.observedAttributes, "inverted", "hover"];
|
|
15
15
|
}
|
|
16
16
|
connectedCallback() {
|
|
17
17
|
this.$el.addEventListener("change", () => {
|
|
@@ -27,17 +27,20 @@ const s = class s extends n {
|
|
|
27
27
|
(e.code === "Space" || e.code === "Enter") && this.$el.click();
|
|
28
28
|
}), this.setupForId(), this.hasAttribute("checked") && (this.checked = !0), this.$switch.ariaChecked = `${this.checked}`;
|
|
29
29
|
}
|
|
30
|
-
attributeChangedCallback(e, t,
|
|
31
|
-
if (t !==
|
|
30
|
+
attributeChangedCallback(e, t, s) {
|
|
31
|
+
if (t !== s)
|
|
32
32
|
switch (e) {
|
|
33
33
|
case "checked":
|
|
34
|
-
this.$el.checked =
|
|
34
|
+
this.$el.checked = s !== null, this.$switch.ariaChecked = `${this.$el.checked}`;
|
|
35
35
|
break;
|
|
36
36
|
case "disabled":
|
|
37
|
-
this.$el.disabled =
|
|
37
|
+
this.$el.disabled = s !== null, this.$switch.ariaDisabled = `${this.$el.disabled}`;
|
|
38
|
+
break;
|
|
39
|
+
case "hover":
|
|
40
|
+
this.$el.classList.toggle("hover");
|
|
38
41
|
break;
|
|
39
42
|
default:
|
|
40
|
-
super.attributeChangedCallback(e, t,
|
|
43
|
+
super.attributeChangedCallback(e, t, s);
|
|
41
44
|
break;
|
|
42
45
|
}
|
|
43
46
|
}
|
|
@@ -84,10 +87,10 @@ const s = class s extends n {
|
|
|
84
87
|
return this.$el.disabled;
|
|
85
88
|
}
|
|
86
89
|
};
|
|
87
|
-
|
|
88
|
-
let
|
|
89
|
-
customElements.define("px-switch",
|
|
90
|
+
o.nativeName = "input";
|
|
91
|
+
let r = o;
|
|
92
|
+
customElements.define("px-switch", r);
|
|
90
93
|
export {
|
|
91
|
-
|
|
92
|
-
|
|
94
|
+
n as InputState,
|
|
95
|
+
r as Switch
|
|
93
96
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@proximus/lavender-switch",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"publishConfig": {
|
|
25
25
|
"access": "public"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "4e94c97e61c3c470209ef31b59552e8fa5709a40",
|
|
28
28
|
"lerna": {
|
|
29
29
|
"command": {
|
|
30
30
|
"publish": {
|