@proximus/lavender-switch 1.0.0-alpha.4 → 1.0.0-alpha.6

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.
Files changed (2) hide show
  1. package/dist/index.js +15 -9
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { PxElement as l } from "@proximus/lavender-common";
2
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
3
  a.replaceSync(d);
4
- var n = /* @__PURE__ */ ((s) => (s.ERROR = "error", s.SUCCESS = "success", s))(n || {});
4
+ var c = /* @__PURE__ */ ((i) => (i.ERROR = "error", i.SUCCESS = "success", i))(c || {});
5
5
  const o = class o extends l {
6
6
  constructor() {
7
7
  var e;
@@ -11,7 +11,7 @@ const o = class o extends l {
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 o = class o extends l {
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, i) {
31
- if (t !== i)
30
+ attributeChangedCallback(e, t, s) {
31
+ if (t !== s)
32
32
  switch (e) {
33
33
  case "checked":
34
- this.$el.checked = i !== null, this.$switch.ariaChecked = `${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 = i !== null, this.$switch.ariaDisabled = `${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, i);
43
+ super.attributeChangedCallback(e, t, s);
41
44
  break;
42
45
  }
43
46
  }
@@ -53,7 +56,10 @@ const o = class o extends l {
53
56
  }
54
57
  // Set default behavior when the element is attached to a form
55
58
  formResetCallback() {
56
- this.$el.value = "";
59
+ this.checked = !1;
60
+ }
61
+ formStateRestoreCallback(e) {
62
+ this.checked = e;
57
63
  }
58
64
  setupForId() {
59
65
  const e = Math.random().toString(36).substr(2, 9);
@@ -88,6 +94,6 @@ o.nativeName = "input";
88
94
  let r = o;
89
95
  customElements.define("px-switch", r);
90
96
  export {
91
- n as InputState,
97
+ c as InputState,
92
98
  r as Switch
93
99
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proximus/lavender-switch",
3
- "version": "1.0.0-alpha.4",
3
+ "version": "1.0.0-alpha.6",
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": "edec2b5a831e4286158fde73db21ad0b49b61480",
27
+ "gitHead": "9eeabb86abf7f1326ab1a0694ac7a079dfb024c8",
28
28
  "lerna": {
29
29
  "command": {
30
30
  "publish": {