@proximus/lavender-switch 2.0.0-alpha.8 → 2.0.0-alpha.81
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 -29
- 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,40 +1,37 @@
|
|
|
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
|
-
</div>`, this.shadowRoot.innerHTML = this.template(), this.internals = (e = this.attachInternals) == null ? void 0 : e.call(this);
|
|
11
|
+
</div>`, this.shadowRoot.innerHTML = this.template(), this.internals = (e = this.attachInternals) == null ? void 0 : e.call(this), this.role = "switch";
|
|
12
12
|
}
|
|
13
13
|
static get observedAttributes() {
|
|
14
14
|
return [...super.observedAttributes, "inverted", "hover"];
|
|
15
15
|
}
|
|
16
16
|
connectedCallback() {
|
|
17
|
-
|
|
17
|
+
const e = () => {
|
|
18
18
|
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}`;
|
|
19
|
+
this.disabled || (this.checked = !this.checked, this.dispatchEvent(
|
|
20
|
+
new Event("change", { bubbles: !0, composed: !0 })
|
|
21
|
+
), (t = this.internals) == null || t.setFormValue(this.formData()));
|
|
22
|
+
};
|
|
23
|
+
this.addEventListener("click", e), this.addEventListener("keypress", (t) => {
|
|
24
|
+
(t.code === "Space" || t.code === "Enter") && e();
|
|
25
|
+
}), this.tabIndex = 0, this.hasAttribute("checked") && (this.checked = !0), this.ariaChecked = `${this.checked}`;
|
|
29
26
|
}
|
|
30
27
|
attributeChangedCallback(e, t, s) {
|
|
31
28
|
if (t !== s)
|
|
32
29
|
switch (e) {
|
|
33
30
|
case "checked":
|
|
34
|
-
this.$el.checked = s !== null, this
|
|
31
|
+
this.$el.checked = s !== null, this.ariaChecked = `${this.$el.checked}`;
|
|
35
32
|
break;
|
|
36
33
|
case "disabled":
|
|
37
|
-
this.$el.disabled = s !== null, this
|
|
34
|
+
this.$el.disabled = s !== null, this.ariaDisabled = `${this.$el.disabled}`, this.tabIndex = this.$el.disabled ? -1 : 0;
|
|
38
35
|
break;
|
|
39
36
|
case "hover":
|
|
40
37
|
this.$el.classList.toggle("hover");
|
|
@@ -63,10 +60,7 @@ const o = class o extends l {
|
|
|
63
60
|
}
|
|
64
61
|
setupForId() {
|
|
65
62
|
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");
|
|
63
|
+
this.$el.setAttribute("id", e);
|
|
70
64
|
}
|
|
71
65
|
get $switch() {
|
|
72
66
|
return this.shadowRoot.querySelector(".switch");
|
|
@@ -81,17 +75,17 @@ const o = class o extends l {
|
|
|
81
75
|
return this.$el.checked;
|
|
82
76
|
}
|
|
83
77
|
set checked(e) {
|
|
84
|
-
this.$el.checked = e, e ? this.setAttribute("checked", "") : this.removeAttribute("checked"), this
|
|
78
|
+
this.$el.checked = e, e ? this.setAttribute("checked", "") : this.removeAttribute("checked"), this.ariaChecked = `${e}`;
|
|
85
79
|
}
|
|
86
80
|
set disabled(e) {
|
|
87
|
-
this.$el.disabled = e, e ? this.setAttribute("disabled", "") : this.removeAttribute("disabled"), this
|
|
81
|
+
this.$el.disabled = e, e ? this.setAttribute("disabled", "") : this.removeAttribute("disabled"), this.ariaDisabled = `${e}`, this.tabIndex = e ? -1 : 0;
|
|
88
82
|
}
|
|
89
83
|
get disabled() {
|
|
90
84
|
return this.$el.disabled;
|
|
91
85
|
}
|
|
92
86
|
};
|
|
93
|
-
|
|
94
|
-
let r =
|
|
87
|
+
i.nativeName = "input", i.accessorExclusions = ["checked", "disabled"];
|
|
88
|
+
let r = i;
|
|
95
89
|
customElements.get("px-switch") || customElements.define("px-switch", r);
|
|
96
90
|
export {
|
|
97
91
|
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.81",
|
|
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"
|