@warp-ds/elements 2.8.1-next.4 → 2.8.1

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.
@@ -0,0 +1 @@
1
+ import './switch.js';
@@ -0,0 +1,78 @@
1
+ import { userEvent } from '@vitest/browser/context';
2
+ import { html } from 'lit';
3
+ import { describe, expect, test } from 'vitest';
4
+ import { render } from 'vitest-browser-lit';
5
+ import './switch.js';
6
+ describe('w-switch accessibility (WCAG 2.2)', () => {
7
+ describe('axe-core automated checks', () => {
8
+ test('default state has no violations', async () => {
9
+ const page = render(html `<w-switch aria-label="Enable notifications"></w-switch>`);
10
+ await expect(page).toHaveNoAxeViolations();
11
+ });
12
+ test('checked state has no violations', async () => {
13
+ const page = render(html `<w-switch checked aria-label="Enable notifications"></w-switch>`);
14
+ await expect(page).toHaveNoAxeViolations();
15
+ });
16
+ test('disabled state has no violations', async () => {
17
+ const page = render(html `<w-switch disabled aria-label="Enable notifications"></w-switch>`);
18
+ await expect(page).toHaveNoAxeViolations();
19
+ });
20
+ });
21
+ describe('WCAG 1.3.1 - Info and Relationships', () => {
22
+ test('switch has accessible name via aria-labelledby', async () => {
23
+ const page = render(html `
24
+ <div>
25
+ <span id="switch-label">Enable notifications</span>
26
+ <w-switch aria-labelledby="switch-label"></w-switch>
27
+ </div>
28
+ `);
29
+ await expect.element(page.getByRole('switch', { name: 'Enable notifications' })).toBeVisible();
30
+ });
31
+ });
32
+ describe('WCAG 4.1.2 - Name, Role, Value', () => {
33
+ test('switch exposes role and checked state', async () => {
34
+ const page = render(html `<w-switch aria-label="Enable notifications"></w-switch>`);
35
+ const wSwitch = page.container.querySelector('w-switch');
36
+ await expect.element(page.getByRole('switch', { name: 'Enable notifications' })).toBeVisible();
37
+ await expect.element(wSwitch).toHaveAttribute('aria-checked', 'false');
38
+ wSwitch.checked = true;
39
+ await wSwitch.updateComplete;
40
+ await expect.element(wSwitch).toHaveAttribute('aria-checked', 'true');
41
+ });
42
+ test('disabled state is exposed', async () => {
43
+ const page = render(html `<w-switch disabled aria-label="Enable notifications"></w-switch>`);
44
+ const wSwitch = page.container.querySelector('w-switch');
45
+ await expect.element(wSwitch).toHaveAttribute('aria-disabled', 'true');
46
+ });
47
+ });
48
+ describe('WCAG 2.1.1 - Keyboard', () => {
49
+ test('switch is reachable by tab and can be toggled with keyboard', async () => {
50
+ const page = render(html `
51
+ <button type="button">Before</button>
52
+ <w-switch aria-label="Enable notifications"></w-switch>
53
+ <button type="button">After</button>
54
+ `);
55
+ const wSwitch = page.container.querySelector('w-switch');
56
+ const beforeButton = page.getByRole('button', { name: 'Before' });
57
+ await wSwitch.updateComplete;
58
+ const beforeButtonEl = beforeButton.element();
59
+ beforeButtonEl.focus();
60
+ await expect.element(beforeButton).toHaveFocus();
61
+ await userEvent.tab();
62
+ await expect.element(wSwitch).toHaveFocus();
63
+ await userEvent.keyboard(' ');
64
+ await wSwitch.updateComplete;
65
+ expect(wSwitch.checked).toBe(true);
66
+ await expect.element(wSwitch).toHaveAttribute('aria-checked', 'true');
67
+ await userEvent.keyboard('{Enter}');
68
+ await wSwitch.updateComplete;
69
+ expect(wSwitch.checked).toBe(false);
70
+ wSwitch.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', altKey: true, bubbles: true }));
71
+ await wSwitch.updateComplete;
72
+ expect(wSwitch.checked).toBe(false);
73
+ wSwitch.dispatchEvent(new KeyboardEvent('keydown', { key: ' ', shiftKey: true, bubbles: true }));
74
+ await wSwitch.updateComplete;
75
+ expect(wSwitch.checked).toBe(false);
76
+ });
77
+ });
78
+ });
@@ -15,7 +15,14 @@ export declare class WarpSwitch extends WarpSwitch_base {
15
15
  get _handleClasses(): string;
16
16
  /** @internal */
17
17
  _handleClick(): void;
18
+ /** @internal */
19
+ _handleHostClick: (event: MouseEvent) => void;
20
+ /** @internal */
21
+ _handleKeyDown: (event: KeyboardEvent) => void;
22
+ /** @internal */
23
+ _syncA11yState(): void;
18
24
  connectedCallback(): void;
25
+ disconnectedCallback(): void;
19
26
  willUpdate(changedProperties: any): void;
20
27
  resetFormControl(): void;
21
28
  render(): import("lit").TemplateResult<1>;
@@ -1,4 +1,4 @@
1
- var K=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var $=t=>{throw TypeError(t)};var F=(t,e,a,o)=>{for(var n=o>1?void 0:o?Q(e,a):e,p=t.length-1,w;p>=0;p--)(w=t[p])&&(n=(o?w(e,a,n):w(n))||n);return o&&n&&K(e,a,n),n};var N=(t,e,a)=>e.has(t)||$("Cannot "+a);var U=(t,e,a)=>(N(t,e,"read from private field"),a?a.call(t):e.get(t)),L=(t,e,a)=>e.has(t)?$("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,a),G=(t,e,a,o)=>(N(t,e,"write to private field"),o?o.call(t,a):e.set(t,a),a);var Y=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return t.reduce(function(a,o){return a.concat(typeof o=="string"?o:Array.isArray(o)?Y.apply(void 0,o):typeof o=="object"&&o?Object.keys(o).map(function(n){return o[n]?n:""}):"")},[]).join(" ")};var s=function(t,e,a,o){if(a==="a"&&!o)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!o:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return a==="m"?o:a==="a"?o.call(t):o?o.value:e.get(t)},d=function(t,e,a,o,n){if(o==="m")throw new TypeError("Private method is not writable");if(o==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return o==="a"?n.call(t,a):n?n.value=a:e.set(t,a),a};function I(t){var e,a,o,n,p,w,m,H,k,X,A,Z,M,x,E,v,P,T,S;class J extends t{constructor(...r){var i,l,c;super(...r),e.add(this),this.internals=this.attachInternals(),a.set(this,!1),o.set(this,!1),n.set(this,!1),p.set(this,void 0),w.set(this,void 0),m.set(this,!0),k.set(this,""),X.set(this,()=>{d(this,n,!0,"f"),d(this,a,!0,"f"),s(this,e,"m",v).call(this)}),A.set(this,()=>{d(this,a,!1,"f"),s(this,e,"m",P).call(this,this.shouldFormValueUpdate()?s(this,k,"f"):""),!this.validity.valid&&s(this,n,"f")&&d(this,o,!0,"f");let g=s(this,e,"m",v).call(this);this.validationMessageCallback&&this.validationMessageCallback(g?this.internals.validationMessage:"")}),Z.set(this,()=>{var g;s(this,m,"f")&&this.validationTarget&&(this.internals.setValidity(this.validity,this.validationMessage,this.validationTarget),d(this,m,!1,"f")),d(this,n,!0,"f"),d(this,o,!0,"f"),s(this,e,"m",v).call(this),(g=this===null||this===void 0?void 0:this.validationMessageCallback)===null||g===void 0||g.call(this,this.showError?this.internals.validationMessage:"")}),M.set(this,void 0),x.set(this,!1),E.set(this,Promise.resolve()),(i=this.addEventListener)===null||i===void 0||i.call(this,"focus",s(this,X,"f")),(l=this.addEventListener)===null||l===void 0||l.call(this,"blur",s(this,A,"f")),(c=this.addEventListener)===null||c===void 0||c.call(this,"invalid",s(this,Z,"f")),this.setValue(null)}static get formAssociated(){return!0}static get validators(){return this.formControlValidators||[]}static get observedAttributes(){let r=this.validators.map(c=>c.attribute).flat(),i=super.observedAttributes||[];return[...new Set([...i,...r])]}static getValidator(r){return this.validators.find(i=>i.attribute===r)||null}static getValidators(r){return this.validators.filter(i=>{var l;if(i.attribute===r||!((l=i.attribute)===null||l===void 0)&&l.includes(r))return!0})}get form(){return this.internals.form}get showError(){return s(this,e,"m",v).call(this)}checkValidity(){return this.internals.checkValidity()}get validity(){return this.internals.validity}get validationMessage(){return this.internals.validationMessage}attributeChangedCallback(r,i,l){var c;(c=super.attributeChangedCallback)===null||c===void 0||c.call(this,r,i,l);let z=this.constructor.getValidators(r);z!=null&&z.length&&this.validationTarget&&this.setValue(s(this,k,"f"))}setValue(r){var i;d(this,o,!1,"f"),(i=this.validationMessageCallback)===null||i===void 0||i.call(this,""),d(this,k,r,"f");let c=this.shouldFormValueUpdate()?r:null;this.internals.setFormValue(c),s(this,e,"m",P).call(this,c),this.valueChangedCallback&&this.valueChangedCallback(c),s(this,e,"m",v).call(this)}shouldFormValueUpdate(){return!0}get validationComplete(){return new Promise(r=>r(s(this,E,"f")))}formResetCallback(){var r,i;d(this,n,!1,"f"),d(this,o,!1,"f"),s(this,e,"m",v).call(this),(r=this.resetFormControl)===null||r===void 0||r.call(this),(i=this.validationMessageCallback)===null||i===void 0||i.call(this,s(this,e,"m",v).call(this)?this.validationMessage:"")}}return a=new WeakMap,o=new WeakMap,n=new WeakMap,p=new WeakMap,w=new WeakMap,m=new WeakMap,k=new WeakMap,X=new WeakMap,A=new WeakMap,Z=new WeakMap,M=new WeakMap,x=new WeakMap,E=new WeakMap,e=new WeakSet,H=function(){let r=this.getRootNode(),i=`${this.localName}[name="${this.getAttribute("name")}"]`;return r.querySelectorAll(i)},v=function(){if(this.hasAttribute("disabled"))return!1;let r=s(this,o,"f")||s(this,n,"f")&&!this.validity.valid&&!s(this,a,"f");return r&&this.internals.states?this.internals.states.add("--show-error"):this.internals.states&&this.internals.states.delete("--show-error"),r},P=function(r){let i=this.constructor,l={},c=i.validators,g=[],z=c.some(h=>h.isValid instanceof Promise);s(this,x,"f")||(d(this,E,new Promise(h=>{d(this,M,h,"f")}),"f"),d(this,x,!0,"f")),s(this,p,"f")&&(s(this,p,"f").abort(),d(this,w,s(this,p,"f"),"f"));let _=new AbortController;d(this,p,_,"f");let C,W=!1;c.length&&(c.forEach(h=>{let O=h.key||"customError",f=h.isValid(this,r,_.signal);f instanceof Promise?(g.push(f),f.then(D=>{D!=null&&(l[O]=!D,C=s(this,e,"m",S).call(this,h,r),s(this,e,"m",T).call(this,l,C))})):(l[O]=!f,this.validity[O]!==!f&&(W=!0),!f&&!C&&(C=s(this,e,"m",S).call(this,h,r)))}),Promise.allSettled(g).then(()=>{var h;_!=null&&_.signal.aborted||(d(this,x,!1,"f"),(h=s(this,M,"f"))===null||h===void 0||h.call(this))}),(W||!z)&&s(this,e,"m",T).call(this,l,C))},T=function(r,i){if(this.validationTarget)this.internals.setValidity(r,i,this.validationTarget),d(this,m,!1,"f");else{if(this.internals.setValidity(r,i),this.internals.validity.valid)return;d(this,m,!0,"f")}},S=function(r,i){if(this.validityCallback){let l=this.validityCallback(r.key||"customError");if(l)return l}return r.message instanceof Function?r.message(this,i):r.message},J}import{html as re,LitElement as oe}from"lit";import{property as j}from"lit/decorators.js";import{css as R}from"lit";var q=R`
1
+ var J=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var L=a=>{throw TypeError(a)};var F=(a,e,r,t)=>{for(var n=t>1?void 0:t?Q(e,r):e,p=a.length-1,w;p>=0;p--)(w=a[p])&&(n=(t?w(e,r,n):w(n))||n);return t&&n&&J(e,r,n),n};var K=(a,e,r)=>e.has(a)||L("Cannot "+r);var N=(a,e,r)=>(K(a,e,"read from private field"),r?r.call(a):e.get(a)),U=(a,e,r)=>e.has(a)?L("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(a):e.set(a,r),$=(a,e,r,t)=>(K(a,e,"write to private field"),t?t.call(a,r):e.set(a,r),r);var Y=function(){for(var a=[],e=arguments.length;e--;)a[e]=arguments[e];return a.reduce(function(r,t){return r.concat(typeof t=="string"?t:Array.isArray(t)?Y.apply(void 0,t):typeof t=="object"&&t?Object.keys(t).map(function(n){return t[n]?n:""}):"")},[]).join(" ")};var s=function(a,e,r,t){if(r==="a"&&!t)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?a!==e||!t:!e.has(a))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?t:r==="a"?t.call(a):t?t.value:e.get(a)},d=function(a,e,r,t,n){if(t==="m")throw new TypeError("Private method is not writable");if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?a!==e||!n:!e.has(a))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t==="a"?n.call(a,r):n?n.value=r:e.set(a,r),r};function I(a){var e,r,t,n,p,w,m,B,k,j,X,Z,V,x,E,g,S,D,T;class H extends a{constructor(...o){var i,l,c;super(...o),e.add(this),this.internals=this.attachInternals(),r.set(this,!1),t.set(this,!1),n.set(this,!1),p.set(this,void 0),w.set(this,void 0),m.set(this,!0),k.set(this,""),j.set(this,()=>{d(this,n,!0,"f"),d(this,r,!0,"f"),s(this,e,"m",g).call(this)}),X.set(this,()=>{d(this,r,!1,"f"),s(this,e,"m",S).call(this,this.shouldFormValueUpdate()?s(this,k,"f"):""),!this.validity.valid&&s(this,n,"f")&&d(this,t,!0,"f");let v=s(this,e,"m",g).call(this);this.validationMessageCallback&&this.validationMessageCallback(v?this.internals.validationMessage:"")}),Z.set(this,()=>{var v;s(this,m,"f")&&this.validationTarget&&(this.internals.setValidity(this.validity,this.validationMessage,this.validationTarget),d(this,m,!1,"f")),d(this,n,!0,"f"),d(this,t,!0,"f"),s(this,e,"m",g).call(this),(v=this===null||this===void 0?void 0:this.validationMessageCallback)===null||v===void 0||v.call(this,this.showError?this.internals.validationMessage:"")}),V.set(this,void 0),x.set(this,!1),E.set(this,Promise.resolve()),(i=this.addEventListener)===null||i===void 0||i.call(this,"focus",s(this,j,"f")),(l=this.addEventListener)===null||l===void 0||l.call(this,"blur",s(this,X,"f")),(c=this.addEventListener)===null||c===void 0||c.call(this,"invalid",s(this,Z,"f")),this.setValue(null)}static get formAssociated(){return!0}static get validators(){return this.formControlValidators||[]}static get observedAttributes(){let o=this.validators.map(c=>c.attribute).flat(),i=super.observedAttributes||[];return[...new Set([...i,...o])]}static getValidator(o){return this.validators.find(i=>i.attribute===o)||null}static getValidators(o){return this.validators.filter(i=>{var l;if(i.attribute===o||!((l=i.attribute)===null||l===void 0)&&l.includes(o))return!0})}get form(){return this.internals.form}get showError(){return s(this,e,"m",g).call(this)}checkValidity(){return this.internals.checkValidity()}get validity(){return this.internals.validity}get validationMessage(){return this.internals.validationMessage}attributeChangedCallback(o,i,l){var c;(c=super.attributeChangedCallback)===null||c===void 0||c.call(this,o,i,l);let _=this.constructor.getValidators(o);_!=null&&_.length&&this.validationTarget&&this.setValue(s(this,k,"f"))}setValue(o){var i;d(this,t,!1,"f"),(i=this.validationMessageCallback)===null||i===void 0||i.call(this,""),d(this,k,o,"f");let c=this.shouldFormValueUpdate()?o:null;this.internals.setFormValue(c),s(this,e,"m",S).call(this,c),this.valueChangedCallback&&this.valueChangedCallback(c),s(this,e,"m",g).call(this)}shouldFormValueUpdate(){return!0}get validationComplete(){return new Promise(o=>o(s(this,E,"f")))}formResetCallback(){var o,i;d(this,n,!1,"f"),d(this,t,!1,"f"),s(this,e,"m",g).call(this),(o=this.resetFormControl)===null||o===void 0||o.call(this),(i=this.validationMessageCallback)===null||i===void 0||i.call(this,s(this,e,"m",g).call(this)?this.validationMessage:"")}}return r=new WeakMap,t=new WeakMap,n=new WeakMap,p=new WeakMap,w=new WeakMap,m=new WeakMap,k=new WeakMap,j=new WeakMap,X=new WeakMap,Z=new WeakMap,V=new WeakMap,x=new WeakMap,E=new WeakMap,e=new WeakSet,B=function(){let o=this.getRootNode(),i=`${this.localName}[name="${this.getAttribute("name")}"]`;return o.querySelectorAll(i)},g=function(){if(this.hasAttribute("disabled"))return!1;let o=s(this,t,"f")||s(this,n,"f")&&!this.validity.valid&&!s(this,r,"f");return o&&this.internals.states?this.internals.states.add("--show-error"):this.internals.states&&this.internals.states.delete("--show-error"),o},S=function(o){let i=this.constructor,l={},c=i.validators,v=[],_=c.some(h=>h.isValid instanceof Promise);s(this,x,"f")||(d(this,E,new Promise(h=>{d(this,V,h,"f")}),"f"),d(this,x,!0,"f")),s(this,p,"f")&&(s(this,p,"f").abort(),d(this,w,s(this,p,"f"),"f"));let z=new AbortController;d(this,p,z,"f");let C,W=!1;c.length&&(c.forEach(h=>{let P=h.key||"customError",f=h.isValid(this,o,z.signal);f instanceof Promise?(v.push(f),f.then(O=>{O!=null&&(l[P]=!O,C=s(this,e,"m",T).call(this,h,o),s(this,e,"m",D).call(this,l,C))})):(l[P]=!f,this.validity[P]!==!f&&(W=!0),!f&&!C&&(C=s(this,e,"m",T).call(this,h,o)))}),Promise.allSettled(v).then(()=>{var h;z!=null&&z.signal.aborted||(d(this,x,!1,"f"),(h=s(this,V,"f"))===null||h===void 0||h.call(this))}),(W||!_)&&s(this,e,"m",D).call(this,l,C))},D=function(o,i){if(this.validationTarget)this.internals.setValidity(o,i,this.validationTarget),d(this,m,!1,"f");else{if(this.internals.setValidity(o,i),this.internals.validity.valid)return;d(this,m,!0,"f")}},T=function(o,i){if(this.validityCallback){let l=this.validityCallback(o.key||"customError");if(l)return l}return o.message instanceof Function?o.message(this,i):o.message},H}import{css as re,html as oe,LitElement as te}from"lit";import{property as A}from"lit/decorators.js";import{css as G}from"lit";var R=G`
2
2
  *,
3
3
  :before,
4
4
  :after {
@@ -271,7 +271,7 @@ var K=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var $=t=>{thro
271
271
  svg {
272
272
  pointer-events: none;
273
273
  }
274
- `,le=R`*, :before, :after {
274
+ `,de=G`*, :before, :after {
275
275
  --w-rotate: 0;
276
276
  --w-rotate-x: 0;
277
277
  --w-rotate-y: 0;
@@ -2437,14 +2437,13 @@ var K=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var $=t=>{thro
2437
2437
  display: none
2438
2438
  }
2439
2439
  }
2440
- `;import{css as ee}from"lit";var B=ee`*,:before,:after{--w-rotate:0;--w-rotate-x:0;--w-rotate-y:0;--w-rotate-z:0;--w-scale-x:1;--w-scale-y:1;--w-scale-z:1;--w-skew-x:0;--w-skew-y:0;--w-translate-x:0;--w-translate-y:0;--w-translate-z:0}.bg-\\[--w-s-color-border-strong\\]{background-color:var(--w-s-color-border-strong)}.group:hover .group-hover\\:bg-\\[--w-s-color-border-strong-hover\\]{background-color:var(--w-s-color-border-strong-hover)}.border{border-width:1px}.rounded-full{border-radius:9999px}.block{display:block}.focusable:focus{outline:2px solid var(--w-s-color-border-focus);outline-offset:var(--w-outline-offset,1px)}.focusable:focus-visible{outline:2px solid var(--w-s-color-border-focus);outline-offset:var(--w-outline-offset,1px)}.focusable:not(:focus-visible){outline:none}.left-0{left:0}.left-4{left:.4rem}.top-0{top:0}.top-4{top:.4rem}.absolute{position:absolute}.relative{position:relative}.static{position:static}.s-bg{background-color:var(--w-s-color-background)}.s-bg-disabled{background-color:var(--w-s-color-background-disabled)}.s-bg-disabled-subtle{background-color:var(--w-s-color-background-disabled-subtle)}.s-bg-primary{background-color:var(--w-s-color-background-primary)}.group:hover .group-hover\\:s-bg-hover{background-color:var(--w-s-color-background-hover)}.group:hover .group-hover\\:s-bg-primary-hover{background-color:var(--w-s-color-background-primary-hover)}.s-border-disabled{border-color:var(--w-s-color-border-disabled)}.s-border-strong{border-color:var(--w-s-color-border-strong)}.group:hover .group-hover\\:s-border-strong-hover{border-color:var(--w-s-color-border-strong-hover)}.h-16{height:1.6rem}.h-24{height:2.4rem}.h-full{height:100%}.w-16{width:1.6rem}.w-44{width:4.4rem}.w-full{width:100%}.cursor-pointer{cursor:pointer}.pointer-events-none{pointer-events:none}.sr-only{clip:rect(0,0,0,0);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.translate-x-20{--w-translate-x:2rem;transform:translateX(var(--w-translate-x))translateY(var(--w-translate-y))translateZ(var(--w-translate-z))rotate(var(--w-rotate))rotateX(var(--w-rotate-x))rotateY(var(--w-rotate-y))rotateZ(var(--w-rotate-z))skewX(var(--w-skew-x))skewY(var(--w-skew-y))scaleX(var(--w-scale-x))scaleY(var(--w-scale-y))scaleZ(var(--w-scale-z))}.transform-gpu{transform:translate3d(var(--w-translate-x),var(--w-translate-y),var(--w-translate-z))rotate(var(--w-rotate))rotateX(var(--w-rotate-x))rotateY(var(--w-rotate-y))rotateZ(var(--w-rotate-z))skewX(var(--w-skew-x))skewY(var(--w-skew-y))scaleX(var(--w-scale-x))scaleY(var(--w-scale-y))scaleZ(var(--w-scale-z))}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-duration:.15s;transition-timing-function:cubic-bezier(.4,0,.2,1)}.transition-transform{transition-property:transform;transition-duration:.15s;transition-timing-function:cubic-bezier(.4,0,.2,1)}`;var b={base:"block relative h-24 w-44 cursor-pointer group focusable rounded-full",disabled:"pointer-events-none",track:"absolute top-0 left-0 h-full w-full rounded-full transition-colors",trackActive:"s-bg-primary group-hover:s-bg-primary-hover",trackInactive:"s-bg border s-border-strong group-hover:s-bg-hover group-hover:s-border-strong-hover",trackDisabledOn:"s-bg-disabled",trackDisabledOff:"s-bg-disabled-subtle border s-border-disabled",handle:"absolute transform-gpu h-16 w-16 top-4 left-4 rounded-full transition-transform",handleSelected:"translate-x-20",handleActive:"s-bg",handleNotDisabled:"bg-[--w-s-color-border-strong] group-hover:bg-[--w-s-color-border-strong-hover]",handleDisabledOn:"s-bg-disabled-subtle",handleDisabledOff:"s-bg-disabled",a11y:"sr-only"},V,u=class extends I(oe){constructor(){super(...arguments);this.name="";this.value="";this.checked=!1;this.disabled=!1;L(this,V,null)}get _baseClasses(){return Y([b.base,this.disabled&&b.disabled])}get _trackClasses(){return Y([b.track,this.disabled?this.checked?b.trackDisabledOn:b.trackDisabledOff:this.checked?b.trackActive:b.trackInactive])}get _handleClasses(){return Y([b.handle,this.checked&&b.handleSelected,this.disabled?this.checked?b.handleDisabledOn:b.handleDisabledOff:this.checked?b.handleActive:b.handleNotDisabled])}_handleClick(){this.disabled||(this.checked=!this.checked,this.dispatchEvent(new CustomEvent("change",{detail:{checked:this.checked,value:this.value||null},bubbles:!0,composed:!0})))}connectedCallback(){G(this,V,this.checked),super.connectedCallback(),this.disabled||this.setValue(this.checked&&this.value?this.value:null)}willUpdate(a){a.has("checked")&&(this.disabled||this.setValue(this.checked&&this.value?this.value:null))}resetFormControl(){this.checked=U(this,V)}render(){return re`
2440
+ `;import{css as ee}from"lit";var q=ee`*,:before,:after{--w-rotate:0;--w-rotate-x:0;--w-rotate-y:0;--w-rotate-z:0;--w-scale-x:1;--w-scale-y:1;--w-scale-z:1;--w-skew-x:0;--w-skew-y:0;--w-translate-x:0;--w-translate-y:0;--w-translate-z:0}.bg-\\[--w-s-color-border-strong\\]{background-color:var(--w-s-color-border-strong)}.group:hover .group-hover\\:bg-\\[--w-s-color-border-strong-hover\\]{background-color:var(--w-s-color-border-strong-hover)}.border{border-width:1px}.rounded-full{border-radius:9999px}.block{display:block}.focusable:focus{outline:2px solid var(--w-s-color-border-focus);outline-offset:var(--w-outline-offset,1px)}.focusable:focus-visible{outline:2px solid var(--w-s-color-border-focus);outline-offset:var(--w-outline-offset,1px)}.focusable:not(:focus-visible){outline:none}.left-0{left:0}.left-4{left:.4rem}.top-0{top:0}.top-4{top:.4rem}.absolute{position:absolute}.relative{position:relative}.static{position:static}.s-bg{background-color:var(--w-s-color-background)}.s-bg-disabled{background-color:var(--w-s-color-background-disabled)}.s-bg-disabled-subtle{background-color:var(--w-s-color-background-disabled-subtle)}.s-bg-primary{background-color:var(--w-s-color-background-primary)}.group:hover .group-hover\\:s-bg-hover{background-color:var(--w-s-color-background-hover)}.group:hover .group-hover\\:s-bg-primary-hover{background-color:var(--w-s-color-background-primary-hover)}.s-border-disabled{border-color:var(--w-s-color-border-disabled)}.s-border-strong{border-color:var(--w-s-color-border-strong)}.group:hover .group-hover\\:s-border-strong-hover{border-color:var(--w-s-color-border-strong-hover)}.h-16{height:1.6rem}.h-24{height:2.4rem}.h-full{height:100%}.w-16{width:1.6rem}.w-44{width:4.4rem}.w-full{width:100%}.cursor-pointer{cursor:pointer}.pointer-events-none{pointer-events:none}.sr-only{clip:rect(0,0,0,0);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.translate-x-20{--w-translate-x:2rem;transform:translateX(var(--w-translate-x))translateY(var(--w-translate-y))translateZ(var(--w-translate-z))rotate(var(--w-rotate))rotateX(var(--w-rotate-x))rotateY(var(--w-rotate-y))rotateZ(var(--w-rotate-z))skewX(var(--w-skew-x))skewY(var(--w-skew-y))scaleX(var(--w-scale-x))scaleY(var(--w-scale-y))scaleZ(var(--w-scale-z))}.transform-gpu{transform:translate3d(var(--w-translate-x),var(--w-translate-y),var(--w-translate-z))rotate(var(--w-rotate))rotateX(var(--w-rotate-x))rotateY(var(--w-rotate-y))rotateZ(var(--w-rotate-z))skewX(var(--w-skew-x))skewY(var(--w-skew-y))scaleX(var(--w-scale-x))scaleY(var(--w-scale-y))scaleZ(var(--w-scale-z))}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-duration:.15s;transition-timing-function:cubic-bezier(.4,0,.2,1)}.transition-transform{transition-property:transform;transition-duration:.15s;transition-timing-function:cubic-bezier(.4,0,.2,1)}`;var b={base:"block relative h-24 w-44 cursor-pointer group focusable rounded-full",disabled:"pointer-events-none",track:"absolute top-0 left-0 h-full w-full rounded-full transition-colors",trackActive:"s-bg-primary group-hover:s-bg-primary-hover",trackInactive:"s-bg border s-border-strong group-hover:s-bg-hover group-hover:s-border-strong-hover",trackDisabledOn:"s-bg-disabled",trackDisabledOff:"s-bg-disabled-subtle border s-border-disabled",handle:"absolute transform-gpu h-16 w-16 top-4 left-4 rounded-full transition-transform",handleSelected:"translate-x-20",handleActive:"s-bg",handleNotDisabled:"bg-[--w-s-color-border-strong] group-hover:bg-[--w-s-color-border-strong-hover]",handleDisabledOn:"s-bg-disabled-subtle",handleDisabledOff:"s-bg-disabled",a11y:"sr-only"},M,u=class extends I(te){constructor(){super(...arguments);this.name="";this.value="";this.checked=!1;this.disabled=!1;U(this,M,null);this._handleHostClick=r=>{this.disabled||r.composedPath()[0]===this&&this._handleClick()};this._handleKeyDown=r=>{this.disabled||r.altKey||r.ctrlKey||r.metaKey||r.shiftKey||(r.key===" "||r.key==="Enter")&&(r.preventDefault(),this._handleClick())}}get _baseClasses(){return Y([b.base,this.disabled&&b.disabled])}get _trackClasses(){return Y([b.track,this.disabled?this.checked?b.trackDisabledOn:b.trackDisabledOff:this.checked?b.trackActive:b.trackInactive])}get _handleClasses(){return Y([b.handle,this.checked&&b.handleSelected,this.disabled?this.checked?b.handleDisabledOn:b.handleDisabledOff:this.checked?b.handleActive:b.handleNotDisabled])}_handleClick(){this.disabled||(this.checked=!this.checked,this.dispatchEvent(new CustomEvent("change",{detail:{checked:this.checked,value:this.value||null},bubbles:!0,composed:!0})))}_syncA11yState(){if(this.setAttribute("aria-checked",String(this.checked)),this.tabIndex=this.disabled?-1:0,this.disabled){this.setAttribute("aria-disabled","true");return}this.removeAttribute("aria-disabled")}connectedCallback(){$(this,M,this.checked),super.connectedCallback(),this.setAttribute("role","switch"),this.disabled||this.setValue(this.checked&&this.value?this.value:null),this._syncA11yState(),this.addEventListener("click",this._handleHostClick),this.addEventListener("keydown",this._handleKeyDown)}disconnectedCallback(){this.removeEventListener("click",this._handleHostClick),this.removeEventListener("keydown",this._handleKeyDown),super.disconnectedCallback()}willUpdate(r){r.has("checked")&&(this.disabled||this.setValue(this.checked&&this.value?this.value:null)),(r.has("checked")||r.has("disabled"))&&this._syncA11yState()}resetFormControl(){this.checked=N(this,M)}render(){return oe`
2441
2441
  <div>
2442
2442
  <button
2443
2443
  type="button"
2444
- role="switch"
2445
- aria-checked=${this.checked}
2444
+ role="none"
2445
+ tabindex="-1"
2446
2446
  class=${this._baseClasses}
2447
- aria-disabled=${this.disabled}
2448
2447
  ?disabled=${this.disabled}
2449
2448
  @click=${this._handleClick}
2450
2449
  >
@@ -2452,5 +2451,24 @@ var K=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var $=t=>{thro
2452
2451
  <span data-testid="handle" class=${this._handleClasses}></span>
2453
2452
  </button>
2454
2453
  </div>
2455
- `}};V=new WeakMap,u.styles=[q,B],F([j({type:String,reflect:!0})],u.prototype,"name",2),F([j({type:String,reflect:!0})],u.prototype,"value",2),F([j({type:Boolean,reflect:!0})],u.prototype,"checked",2),F([j({type:Boolean,reflect:!0})],u.prototype,"disabled",2);customElements.get("w-switch")||customElements.define("w-switch",u);export{u as WarpSwitch};
2454
+ `}};M=new WeakMap,u.styles=[R,q,re`
2455
+ :host {
2456
+ display: inline-block;
2457
+ }
2458
+
2459
+ :host(:focus),
2460
+ :host(:focus-visible) {
2461
+ outline: none;
2462
+ }
2463
+
2464
+ :host(:focus) button,
2465
+ :host(:focus-visible) button {
2466
+ outline: 2px solid var(--w-s-color-border-focus);
2467
+ outline-offset: var(--w-outline-offset, 1px);
2468
+ }
2469
+
2470
+ :host(:focus:not(:focus-visible)) button {
2471
+ outline: none;
2472
+ }
2473
+ `],F([A({type:String,reflect:!0})],u.prototype,"name",2),F([A({type:String,reflect:!0})],u.prototype,"value",2),F([A({type:Boolean,reflect:!0})],u.prototype,"checked",2),F([A({type:Boolean,reflect:!0})],u.prototype,"disabled",2);customElements.get("w-switch")||customElements.define("w-switch",u);export{u as WarpSwitch};
2456
2474
  //# sourceMappingURL=switch.js.map