@proximus/lavender-switch 2.0.0-alpha.9 → 2.0.0-alpha.91
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/Switch.d.ts +1 -1
- package/dist/index.es.js +23 -28
- package/package.json +2 -2
package/dist/Switch.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export declare enum InputState {
|
|
|
5
5
|
}
|
|
6
6
|
export declare class Switch extends PxElement<HTMLInputElement> {
|
|
7
7
|
static nativeName: string;
|
|
8
|
+
static accessorExclusions: string[];
|
|
8
9
|
protected internals: ElementInternals;
|
|
9
10
|
private template;
|
|
10
11
|
constructor();
|
|
@@ -16,7 +17,6 @@ export declare class Switch extends PxElement<HTMLInputElement> {
|
|
|
16
17
|
formResetCallback(): void;
|
|
17
18
|
formStateRestoreCallback(state: any): void;
|
|
18
19
|
setupForId(): void;
|
|
19
|
-
get $label(): HTMLLabelElement;
|
|
20
20
|
get $switch(): Element;
|
|
21
21
|
get inverted(): string;
|
|
22
22
|
set inverted(value: string);
|
package/dist/index.es.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { PxElement as
|
|
2
|
-
const
|
|
3
|
-
a.replaceSync(
|
|
4
|
-
var c = /* @__PURE__ */ ((
|
|
5
|
-
const
|
|
1
|
+
import { PxElement as d } from "@proximus/lavender-common";
|
|
2
|
+
const l = ':host{display:inline-flex}.switch *{box-sizing:border-box}.switch{display:inline-flex;align-items:center;border-radius:var(--px-radius-pill)}:host(:focus-visible){outline:none}:host(:focus-visible) .switch{outline:var(--px-focus-outline-mobile) solid var(--px-color-border-focus-outline-default);outline-offset:var(--px-focus-offset-mobile)}:host([inverted]:focus-visible) .switch{outline-color:var(--px-color-border-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-color-background-container-strong-default);outline:var(--px-size-border-m) solid var(--px-color-border-none-default);width:var(--px-size-action-input-switch-width);height:calc(var(--px-size-icon-m) + (var(--px-padding-3xs-mobile) * 2));position:relative}label:after{content:"";position:absolute;top:50%;left:var(--px-padding-3xs-mobile);width:var(--px-size-icon-m);max-width:var(--px-size-icon-m);height:var(--px-size-icon-m);border-radius:var(--px-radius-pill);background-color:var(--px-color-background-container-light-default);transform:translateY(-50%);transition:transform .2s ease-in-out}:host input{-webkit-appearance:none;-moz-appearance:none;appearance:none;margin:0}:host(:not([disabled])):host(:hover) label,:host(:not([disabled])):host([hover]) label{outline-color:var(--px-color-border-neutral-default);cursor:pointer}:host([checked]) label{background-color:var(--px-color-background-purpose-success-default);transition:background-color .2s ease-in-out}:host([checked]) label:after{transform:translateY(-50%) translate(calc(var(--px-size-icon-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-color-border-purpose-success-default)}:host([disabled]) label{background-color:var(--px-color-background-state-disabled-default)}:host([disabled]) label:after{background-color:var(--px-color-background-state-disabled-default)}:host([inverted]) label{background-color:var(--px-color-background-container-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-color-border-neutral-inverted)}:host([checked]:not([disabled])) :is(:host([inverted]) label){background-color:var(--px-color-background-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-color-border-purpose-success-inverted)}:host([disabled]) :is(:host([inverted]) label){background-color:var(--px-color-background-state-disabled-inverted)}:host([disabled]) :is(:host([inverted]) label):after{background-color:var(--px-color-background-state-disabled-inverted)}@media only screen and (min-width: 48em){label{padding:var(--px-padding-3xs-desktop)}}@media only screen and (min-width: 64.0625em){label{padding:var(--px-padding-3xs-desktop)}}', a = new CSSStyleSheet();
|
|
3
|
+
a.replaceSync(l);
|
|
4
|
+
var c = /* @__PURE__ */ ((o) => (o.ERROR = "error", o.SUCCESS = "success", o))(c || {});
|
|
5
|
+
const i = class i extends d {
|
|
6
6
|
constructor() {
|
|
7
7
|
var e;
|
|
8
|
-
super(a), this.template = () => `<div class="switch"
|
|
9
|
-
<input type="checkbox" tabindex="-1"/>
|
|
8
|
+
super(a), this.template = () => `<div class="switch">
|
|
9
|
+
<input type="checkbox" tabindex="-1" inert/>
|
|
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
|
}
|
|
@@ -14,27 +14,25 @@ const o = class o extends l {
|
|
|
14
14
|
return [...super.observedAttributes, "inverted", "hover"];
|
|
15
15
|
}
|
|
16
16
|
connectedCallback() {
|
|
17
|
-
this
|
|
17
|
+
this.role = "switch";
|
|
18
|
+
const e = () => {
|
|
18
19
|
var t;
|
|
19
|
-
this.checked = this
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}), this.addEventListener("keypress", (e) => {
|
|
27
|
-
(e.code === "Space" || e.code === "Enter") && this.$el.click();
|
|
28
|
-
}), this.setupForId(), this.hasAttribute("checked") && (this.checked = !0), this.$switch.ariaChecked = `${this.checked}`;
|
|
20
|
+
this.disabled || (this.checked = !this.checked, this.dispatchEvent(
|
|
21
|
+
new Event("change", { bubbles: !0, composed: !0 })
|
|
22
|
+
), (t = this.internals) == null || t.setFormValue(this.formData()));
|
|
23
|
+
};
|
|
24
|
+
this.addEventListener("click", e), this.addEventListener("keypress", (t) => {
|
|
25
|
+
(t.code === "Space" || t.code === "Enter") && e();
|
|
26
|
+
}), this.tabIndex = 0, this.hasAttribute("checked") && (this.checked = !0), this.ariaChecked = `${this.checked}`;
|
|
29
27
|
}
|
|
30
28
|
attributeChangedCallback(e, t, s) {
|
|
31
29
|
if (t !== s)
|
|
32
30
|
switch (e) {
|
|
33
31
|
case "checked":
|
|
34
|
-
this.$el.checked = s !== null, this
|
|
32
|
+
this.$el.checked = s !== null, this.ariaChecked = `${this.$el.checked}`;
|
|
35
33
|
break;
|
|
36
34
|
case "disabled":
|
|
37
|
-
this.$el.disabled = s !== null, this
|
|
35
|
+
this.$el.disabled = s !== null, this.ariaDisabled = `${this.$el.disabled}`, this.tabIndex = this.$el.disabled ? -1 : 0;
|
|
38
36
|
break;
|
|
39
37
|
case "hover":
|
|
40
38
|
this.$el.classList.toggle("hover");
|
|
@@ -63,10 +61,7 @@ const o = class o extends l {
|
|
|
63
61
|
}
|
|
64
62
|
setupForId() {
|
|
65
63
|
const e = Math.random().toString(36).substr(2, 9);
|
|
66
|
-
this.$el.setAttribute("id", e)
|
|
67
|
-
}
|
|
68
|
-
get $label() {
|
|
69
|
-
return this.shadowRoot.querySelector("label");
|
|
64
|
+
this.$el.setAttribute("id", e);
|
|
70
65
|
}
|
|
71
66
|
get $switch() {
|
|
72
67
|
return this.shadowRoot.querySelector(".switch");
|
|
@@ -81,17 +76,17 @@ const o = class o extends l {
|
|
|
81
76
|
return this.$el.checked;
|
|
82
77
|
}
|
|
83
78
|
set checked(e) {
|
|
84
|
-
this.$el.checked = e, e ? this.setAttribute("checked", "") : this.removeAttribute("checked"), this
|
|
79
|
+
this.$el.checked = e, e ? this.setAttribute("checked", "") : this.removeAttribute("checked"), this.ariaChecked = `${e}`;
|
|
85
80
|
}
|
|
86
81
|
set disabled(e) {
|
|
87
|
-
this.$el.disabled = e, e ? this.setAttribute("disabled", "") : this.removeAttribute("disabled"), this
|
|
82
|
+
this.$el.disabled = e, e ? this.setAttribute("disabled", "") : this.removeAttribute("disabled"), this.ariaDisabled = `${e}`, this.tabIndex = e ? -1 : 0;
|
|
88
83
|
}
|
|
89
84
|
get disabled() {
|
|
90
85
|
return this.$el.disabled;
|
|
91
86
|
}
|
|
92
87
|
};
|
|
93
|
-
|
|
94
|
-
let r =
|
|
88
|
+
i.nativeName = "input", i.accessorExclusions = ["checked", "disabled"];
|
|
89
|
+
let r = i;
|
|
95
90
|
customElements.get("px-switch") || customElements.define("px-switch", r);
|
|
96
91
|
export {
|
|
97
92
|
c as InputState,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@proximus/lavender-switch",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.91",
|
|
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"
|