@warp-ds/elements 2.9.0 → 2.9.1-next.2

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 (37) hide show
  1. package/dist/custom-elements.json +31 -0
  2. package/dist/docs/box/accessibility.md +29 -0
  3. package/dist/docs/box/api.md +16 -11
  4. package/dist/docs/box/box.md +189 -11
  5. package/dist/docs/box/examples.md +98 -0
  6. package/dist/docs/box/usage.md +47 -0
  7. package/dist/index.d.ts +40 -20
  8. package/dist/packages/box/box.d.ts +15 -14
  9. package/dist/packages/box/box.js +6 -6
  10. package/dist/packages/box/box.js.map +4 -4
  11. package/dist/packages/box/box.react.stories.d.ts +1 -1
  12. package/dist/packages/box/box.stories.d.ts +1 -0
  13. package/dist/packages/box/box.stories.js +12 -5
  14. package/dist/packages/checkbox/checkbox.js +3 -3
  15. package/dist/packages/checkbox/checkbox.js.map +2 -2
  16. package/dist/packages/checkbox/checkbox.test.js +20 -0
  17. package/dist/packages/datepicker/datepicker.js +6 -6
  18. package/dist/packages/datepicker/datepicker.js.map +2 -2
  19. package/dist/packages/datepicker/datepicker.stories.js +8 -1
  20. package/dist/packages/datepicker/datepicker.test.js +23 -1
  21. package/dist/packages/radio/radio.js +2 -2
  22. package/dist/packages/radio/radio.js.map +2 -2
  23. package/dist/packages/radio/radio.test.js +21 -1
  24. package/dist/packages/radio-group/radio-group.js +5 -5
  25. package/dist/packages/radio-group/radio-group.js.map +2 -2
  26. package/dist/packages/select/select.js +10 -10
  27. package/dist/packages/select/select.js.map +3 -3
  28. package/dist/packages/select/select.stories.js +7 -5
  29. package/dist/packages/select/select.test.js +23 -2
  30. package/dist/packages/slider/slider.stories.js +6 -3
  31. package/dist/packages/slider-thumb/slider-thumb.js +16 -16
  32. package/dist/packages/slider-thumb/slider-thumb.js.map +2 -2
  33. package/dist/packages/textfield/textfield.js +9 -8
  34. package/dist/packages/textfield/textfield.js.map +3 -3
  35. package/dist/packages/textfield/textfield.test.js +17 -0
  36. package/dist/web-types.json +35 -7
  37. package/package.json +1 -1
@@ -11,7 +11,14 @@ const meta = {
11
11
  return html `
12
12
  <!-- Workaround for Storybook's overflow hidden -->
13
13
  <div style="min-height: 400px">
14
- <w-datepicker ${spread(prespread(args))}></w-datepicker>
14
+ <form method="get">
15
+ <w-datepicker ${spread(prespread(args))}></w-datepicker>
16
+ <script type="module">
17
+ const picker = document.querySelector('w-datepicker');
18
+ picker.addEventListener('blur', console.log);
19
+ </script>
20
+ <input type="submit" hidden>
21
+ </form>
15
22
  </div>
16
23
  `;
17
24
  },
@@ -1,6 +1,6 @@
1
1
  import { server, userEvent } from '@vitest/browser/context';
2
2
  import { html } from 'lit';
3
- import { expect, test } from 'vitest';
3
+ import { expect, test, vi } from 'vitest';
4
4
  import { render } from 'vitest-browser-lit';
5
5
  import '../button/button.js';
6
6
  import './datepicker.js';
@@ -87,3 +87,25 @@ test('can reset datepicker by resetting surrounding form', async () => {
87
87
  // Value should be reset back to "2025-01-01"
88
88
  expect(wDatepicker.value).toBe('2025-01-01');
89
89
  });
90
+ test('submits the associated form when datepicker input field has focus and user presses Enter', async () => {
91
+ const screen = render(html `
92
+ <form>
93
+ <w-datepicker
94
+ label="Date"
95
+ data-testid="datepicker"
96
+ value="2025-01-01"
97
+ >
98
+ </w-datepicker>
99
+ <button type="submit">Submit</button>
100
+ </form>
101
+ `);
102
+ const onSubmit = vi.fn();
103
+ const form = document.querySelector('form');
104
+ form.addEventListener('submit', (event) => {
105
+ event.preventDefault();
106
+ onSubmit();
107
+ });
108
+ await userEvent.click(screen.getByTestId('datepicker'));
109
+ await userEvent.keyboard('[Enter]');
110
+ await vi.waitFor(() => expect(onSubmit).toHaveBeenCalled());
111
+ });
@@ -1,4 +1,4 @@
1
- var ee=Object.defineProperty;var re=Object.getOwnPropertyDescriptor;var D=i=>{throw TypeError(i)};var f=(i,r,e,o)=>{for(var a=o>1?void 0:o?re(r,e):r,l=i.length-1,u;l>=0;l--)(u=i[l])&&(a=(o?u(r,e,a):u(a))||a);return o&&a&&ee(r,e,a),a};var N=(i,r,e)=>r.has(i)||D("Cannot "+e);var F=(i,r,e)=>(N(i,r,"read from private field"),e?e.call(i):r.get(i)),G=(i,r,e)=>r.has(i)?D("Cannot add the same private member more than once"):r instanceof WeakSet?r.add(i):r.set(i,e),x=(i,r,e,o)=>(N(i,r,"write to private field"),o?o.call(i,e):r.set(i,e),e);var n=function(i,r,e,o){if(e==="a"&&!o)throw new TypeError("Private accessor was defined without a getter");if(typeof r=="function"?i!==r||!o:!r.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?o:e==="a"?o.call(i):o?o.value:r.get(i)},c=function(i,r,e,o,a){if(o==="m")throw new TypeError("Private method is not writable");if(o==="a"&&!a)throw new TypeError("Private accessor was defined without a setter");if(typeof r=="function"?i!==r||!a:!r.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return o==="a"?a.call(i,e):a?a.value=e:r.set(i,e),e};function W(i){var r,e,o,a,l,u,h,q,z,g,w,X,Y,T,j,k,Z,O,P;class Q extends i{constructor(...t){var s,d,b;super(...t),r.add(this),this.internals=this.attachInternals(),e.set(this,!1),o.set(this,!1),a.set(this,!1),l.set(this,void 0),u.set(this,void 0),h.set(this,!0),z.set(this,""),g.set(this,()=>{c(this,a,!0,"f"),c(this,e,!0,"f"),n(this,r,"m",k).call(this)}),w.set(this,()=>{c(this,e,!1,"f"),n(this,r,"m",Z).call(this,this.shouldFormValueUpdate()?n(this,z,"f"):""),!this.validity.valid&&n(this,a,"f")&&c(this,o,!0,"f");let m=n(this,r,"m",k).call(this);this.validationMessageCallback&&this.validationMessageCallback(m?this.internals.validationMessage:"")}),X.set(this,()=>{var m;n(this,h,"f")&&this.validationTarget&&(this.internals.setValidity(this.validity,this.validationMessage,this.validationTarget),c(this,h,!1,"f")),c(this,a,!0,"f"),c(this,o,!0,"f"),n(this,r,"m",k).call(this),(m=this===null||this===void 0?void 0:this.validationMessageCallback)===null||m===void 0||m.call(this,this.showError?this.internals.validationMessage:"")}),Y.set(this,void 0),T.set(this,!1),j.set(this,Promise.resolve()),(s=this.addEventListener)===null||s===void 0||s.call(this,"focus",n(this,g,"f")),(d=this.addEventListener)===null||d===void 0||d.call(this,"blur",n(this,w,"f")),(b=this.addEventListener)===null||b===void 0||b.call(this,"invalid",n(this,X,"f")),this.setValue(null)}static get formAssociated(){return!0}static get validators(){return this.formControlValidators||[]}static get observedAttributes(){let t=this.validators.map(b=>b.attribute).flat(),s=super.observedAttributes||[];return[...new Set([...s,...t])]}static getValidator(t){return this.validators.find(s=>s.attribute===t)||null}static getValidators(t){return this.validators.filter(s=>{var d;if(s.attribute===t||!((d=s.attribute)===null||d===void 0)&&d.includes(t))return!0})}get form(){return this.internals.form}get showError(){return n(this,r,"m",k).call(this)}checkValidity(){return this.internals.checkValidity()}get validity(){return this.internals.validity}get validationMessage(){return this.internals.validationMessage}attributeChangedCallback(t,s,d){var b;(b=super.attributeChangedCallback)===null||b===void 0||b.call(this,t,s,d);let S=this.constructor.getValidators(t);S!=null&&S.length&&this.validationTarget&&this.setValue(n(this,z,"f"))}setValue(t){var s;c(this,o,!1,"f"),(s=this.validationMessageCallback)===null||s===void 0||s.call(this,""),c(this,z,t,"f");let b=this.shouldFormValueUpdate()?t:null;this.internals.setFormValue(b),n(this,r,"m",Z).call(this,b),this.valueChangedCallback&&this.valueChangedCallback(b),n(this,r,"m",k).call(this)}shouldFormValueUpdate(){return!0}get validationComplete(){return new Promise(t=>t(n(this,j,"f")))}formResetCallback(){var t,s;c(this,a,!1,"f"),c(this,o,!1,"f"),n(this,r,"m",k).call(this),(t=this.resetFormControl)===null||t===void 0||t.call(this),(s=this.validationMessageCallback)===null||s===void 0||s.call(this,n(this,r,"m",k).call(this)?this.validationMessage:"")}}return e=new WeakMap,o=new WeakMap,a=new WeakMap,l=new WeakMap,u=new WeakMap,h=new WeakMap,z=new WeakMap,g=new WeakMap,w=new WeakMap,X=new WeakMap,Y=new WeakMap,T=new WeakMap,j=new WeakMap,r=new WeakSet,q=function(){let t=this.getRootNode(),s=`${this.localName}[name="${this.getAttribute("name")}"]`;return t.querySelectorAll(s)},k=function(){if(this.hasAttribute("disabled"))return!1;let t=n(this,o,"f")||n(this,a,"f")&&!this.validity.valid&&!n(this,e,"f");return t&&this.internals.states?this.internals.states.add("--show-error"):this.internals.states&&this.internals.states.delete("--show-error"),t},Z=function(t){let s=this.constructor,d={},b=s.validators,m=[],S=b.some(v=>v.isValid instanceof Promise);n(this,T,"f")||(c(this,j,new Promise(v=>{c(this,Y,v,"f")}),"f"),c(this,T,!0,"f")),n(this,l,"f")&&(n(this,l,"f").abort(),c(this,u,n(this,l,"f"),"f"));let I=new AbortController;c(this,l,I,"f");let A,U=!1;b.length&&(b.forEach(v=>{let R=v.key||"customError",V=v.isValid(this,t,I.signal);V instanceof Promise?(m.push(V),V.then(L=>{L!=null&&(d[R]=!L,A=n(this,r,"m",P).call(this,v,t),n(this,r,"m",O).call(this,d,A))})):(d[R]=!V,this.validity[R]!==!V&&(U=!0),!V&&!A&&(A=n(this,r,"m",P).call(this,v,t)))}),Promise.allSettled(m).then(()=>{var v;I!=null&&I.signal.aborted||(c(this,T,!1,"f"),(v=n(this,Y,"f"))===null||v===void 0||v.call(this))}),(U||!S)&&n(this,r,"m",O).call(this,d,A))},O=function(t,s){if(this.validationTarget)this.internals.setValidity(t,s,this.validationTarget),c(this,h,!1,"f");else{if(this.internals.setValidity(t,s),this.internals.validity.valid)return;c(this,h,!0,"f")}},P=function(t,s){if(this.validityCallback){let d=this.validityCallback(t.key||"customError");if(d)return d}return t.message instanceof Function?t.message(this,s):t.message},Q}import{html as ae,LitElement as J}from"lit";import{property as y}from"lit/decorators.js";import{css as B}from"lit";var $=B`
1
+ var ee=Object.defineProperty;var re=Object.getOwnPropertyDescriptor;var D=i=>{throw TypeError(i)};var f=(i,r,e,o)=>{for(var a=o>1?void 0:o?re(r,e):r,l=i.length-1,u;l>=0;l--)(u=i[l])&&(a=(o?u(r,e,a):u(a))||a);return o&&a&&ee(r,e,a),a};var N=(i,r,e)=>r.has(i)||D("Cannot "+e);var F=(i,r,e)=>(N(i,r,"read from private field"),e?e.call(i):r.get(i)),G=(i,r,e)=>r.has(i)?D("Cannot add the same private member more than once"):r instanceof WeakSet?r.add(i):r.set(i,e),x=(i,r,e,o)=>(N(i,r,"write to private field"),o?o.call(i,e):r.set(i,e),e);var n=function(i,r,e,o){if(e==="a"&&!o)throw new TypeError("Private accessor was defined without a getter");if(typeof r=="function"?i!==r||!o:!r.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?o:e==="a"?o.call(i):o?o.value:r.get(i)},c=function(i,r,e,o,a){if(o==="m")throw new TypeError("Private method is not writable");if(o==="a"&&!a)throw new TypeError("Private accessor was defined without a setter");if(typeof r=="function"?i!==r||!a:!r.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return o==="a"?a.call(i,e):a?a.value=e:r.set(i,e),e};function W(i){var r,e,o,a,l,u,h,q,z,g,m,X,Y,E,j,k,Z,L,O;class Q extends i{constructor(...t){var s,d,b;super(...t),r.add(this),this.internals=this.attachInternals(),e.set(this,!1),o.set(this,!1),a.set(this,!1),l.set(this,void 0),u.set(this,void 0),h.set(this,!0),z.set(this,""),g.set(this,()=>{c(this,a,!0,"f"),c(this,e,!0,"f"),n(this,r,"m",k).call(this)}),m.set(this,()=>{c(this,e,!1,"f"),n(this,r,"m",Z).call(this,this.shouldFormValueUpdate()?n(this,z,"f"):""),!this.validity.valid&&n(this,a,"f")&&c(this,o,!0,"f");let w=n(this,r,"m",k).call(this);this.validationMessageCallback&&this.validationMessageCallback(w?this.internals.validationMessage:"")}),X.set(this,()=>{var w;n(this,h,"f")&&this.validationTarget&&(this.internals.setValidity(this.validity,this.validationMessage,this.validationTarget),c(this,h,!1,"f")),c(this,a,!0,"f"),c(this,o,!0,"f"),n(this,r,"m",k).call(this),(w=this===null||this===void 0?void 0:this.validationMessageCallback)===null||w===void 0||w.call(this,this.showError?this.internals.validationMessage:"")}),Y.set(this,void 0),E.set(this,!1),j.set(this,Promise.resolve()),(s=this.addEventListener)===null||s===void 0||s.call(this,"focus",n(this,g,"f")),(d=this.addEventListener)===null||d===void 0||d.call(this,"blur",n(this,m,"f")),(b=this.addEventListener)===null||b===void 0||b.call(this,"invalid",n(this,X,"f")),this.setValue(null)}static get formAssociated(){return!0}static get validators(){return this.formControlValidators||[]}static get observedAttributes(){let t=this.validators.map(b=>b.attribute).flat(),s=super.observedAttributes||[];return[...new Set([...s,...t])]}static getValidator(t){return this.validators.find(s=>s.attribute===t)||null}static getValidators(t){return this.validators.filter(s=>{var d;if(s.attribute===t||!((d=s.attribute)===null||d===void 0)&&d.includes(t))return!0})}get form(){return this.internals.form}get showError(){return n(this,r,"m",k).call(this)}checkValidity(){return this.internals.checkValidity()}get validity(){return this.internals.validity}get validationMessage(){return this.internals.validationMessage}attributeChangedCallback(t,s,d){var b;(b=super.attributeChangedCallback)===null||b===void 0||b.call(this,t,s,d);let S=this.constructor.getValidators(t);S!=null&&S.length&&this.validationTarget&&this.setValue(n(this,z,"f"))}setValue(t){var s;c(this,o,!1,"f"),(s=this.validationMessageCallback)===null||s===void 0||s.call(this,""),c(this,z,t,"f");let b=this.shouldFormValueUpdate()?t:null;this.internals.setFormValue(b),n(this,r,"m",Z).call(this,b),this.valueChangedCallback&&this.valueChangedCallback(b),n(this,r,"m",k).call(this)}shouldFormValueUpdate(){return!0}get validationComplete(){return new Promise(t=>t(n(this,j,"f")))}formResetCallback(){var t,s;c(this,a,!1,"f"),c(this,o,!1,"f"),n(this,r,"m",k).call(this),(t=this.resetFormControl)===null||t===void 0||t.call(this),(s=this.validationMessageCallback)===null||s===void 0||s.call(this,n(this,r,"m",k).call(this)?this.validationMessage:"")}}return e=new WeakMap,o=new WeakMap,a=new WeakMap,l=new WeakMap,u=new WeakMap,h=new WeakMap,z=new WeakMap,g=new WeakMap,m=new WeakMap,X=new WeakMap,Y=new WeakMap,E=new WeakMap,j=new WeakMap,r=new WeakSet,q=function(){let t=this.getRootNode(),s=`${this.localName}[name="${this.getAttribute("name")}"]`;return t.querySelectorAll(s)},k=function(){if(this.hasAttribute("disabled"))return!1;let t=n(this,o,"f")||n(this,a,"f")&&!this.validity.valid&&!n(this,e,"f");return t&&this.internals.states?this.internals.states.add("--show-error"):this.internals.states&&this.internals.states.delete("--show-error"),t},Z=function(t){let s=this.constructor,d={},b=s.validators,w=[],S=b.some(v=>v.isValid instanceof Promise);n(this,E,"f")||(c(this,j,new Promise(v=>{c(this,Y,v,"f")}),"f"),c(this,E,!0,"f")),n(this,l,"f")&&(n(this,l,"f").abort(),c(this,u,n(this,l,"f"),"f"));let I=new AbortController;c(this,l,I,"f");let A,U=!1;b.length&&(b.forEach(v=>{let P=v.key||"customError",V=v.isValid(this,t,I.signal);V instanceof Promise?(w.push(V),V.then(R=>{R!=null&&(d[P]=!R,A=n(this,r,"m",O).call(this,v,t),n(this,r,"m",L).call(this,d,A))})):(d[P]=!V,this.validity[P]!==!V&&(U=!0),!V&&!A&&(A=n(this,r,"m",O).call(this,v,t)))}),Promise.allSettled(w).then(()=>{var v;I!=null&&I.signal.aborted||(c(this,E,!1,"f"),(v=n(this,Y,"f"))===null||v===void 0||v.call(this))}),(U||!S)&&n(this,r,"m",L).call(this,d,A))},L=function(t,s){if(this.validationTarget)this.internals.setValidity(t,s,this.validationTarget),c(this,h,!1,"f");else{if(this.internals.setValidity(t,s),this.internals.validity.valid)return;c(this,h,!0,"f")}},O=function(t,s){if(this.validityCallback){let d=this.validityCallback(t.key||"customError");if(d)return d}return t.message instanceof Function?t.message(this,s):t.message},Q}import{html as ae,LitElement as J}from"lit";import{property as y}from"lit/decorators.js";import{css as B}from"lit";var $=B`
2
2
  *,
3
3
  :before,
4
4
  :after {
@@ -2607,7 +2607,7 @@ var ee=Object.defineProperty;var re=Object.getOwnPropertyDescriptor;var D=i=>{th
2607
2607
  border-color: var(--_border-color-disabled);
2608
2608
  }
2609
2609
  }
2610
- `;var M,C,_,p=class extends W(J){constructor(){super();this.value=null;this.checked=!1;this.disabled=!1;this.required=!1;this.invalid=!1;G(this,M,!1);G(this,C,!1);G(this,_,!1);this.handleClick=()=>{this.isInGroup()||this.disabled||(x(this,_,!0),!this.checked&&(this.checked=!0,this.updateComplete.then(()=>{this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))})))};this.handleInvalid=()=>{x(this,_,!0),this.updateValidity()};this.handleKeyDown=e=>{var o,a;if(!this.isInGroup()&&!this.disabled&&!e.defaultPrevented){if(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(e.key)){let l=this.getStandaloneNamedRadios().filter(w=>!w.disabled);if(l.length<=1)return;e.preventDefault();let u=(a=(o=l.find(w=>w.checked))!=null?o:l.find(w=>w===this))!=null?a:l[0],h=e.key==="ArrowUp"||e.key==="ArrowLeft"?-1:1,z=(l.indexOf(u)+h+l.length)%l.length,g=l[z];x(g,_,!0),g.checked||(g.checked=!0,g.updateComplete.then(()=>{g.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))})),g.focus();return}e.key!==" "&&e.key!=="Spacebar"&&e.key!=="Enter"||(e.preventDefault(),this.click())}};this.addEventListener("click",this.handleClick),this.addEventListener("invalid",this.handleInvalid),this.addEventListener("keydown",this.handleKeyDown)}get tabIndex(){return this._internalTabIndex}set tabIndex(e){this._groupTabIndex=e}connectedCallback(){var e;super.connectedCallback(),this.value=(e=this.getAttribute("value"))!=null?e:"on",x(this,M,this.hasAttribute("checked")),this.checked=F(this,M),this.internals.role="radio",this.syncAriaDisabled(),this.syncFormValue(),this.updateValidity()}syncAriaDisabled(){this.internals.ariaDisabled=this.disabled?"true":"false"}syncAriaChecked(){this.internals.ariaChecked=this.checked?"true":"false"}willUpdate(e){this.shouldSyncFormState(e)&&(this.syncFormValue(),this.updateValidity())}updated(e){super.updated(e),e.has("checked")&&(this.syncAriaChecked(),this.checked&&!this.isInGroup()&&(this.uncheckOtherRadios(),this.syncStandaloneTabOrder())),e.has("disabled")&&(this.syncAriaDisabled(),this.isInGroup()||this.syncStandaloneTabOrder()),e.has("invalid")&&(this.internals.ariaInvalid=this.invalid?"true":null),e.has("name")&&this.checked&&!this.isInGroup()&&this.uncheckOtherRadios()}resetFormControl(){this.checked=F(this,M),this.syncFormValue(),this.updateValidity()}get validationMessage(){return this.internals.validationMessage}get validity(){return this.internals.validity}checkValidity(){return this.updateValidity(),this.internals.checkValidity()}reportValidity(){return x(this,_,!0),this.updateValidity(),this.internals.checkValidity()}isInGroup(){return!!this.closest("w-radio-group")}getRadioScope(){var e,o;return(o=(e=this.internals.form)!=null?e:this.closest("form"))!=null?o:document}getStandaloneNamedRadios(){if(!this.name)return[this];let e=this.getRadioScope();return Array.from(e.querySelectorAll(`w-radio[name="${this.name}"]`)).filter(o=>!o.closest("w-radio-group"))}syncStandaloneTabOrder(){var u;let e=this.getStandaloneNamedRadios(),o=e.filter(h=>!h.disabled),a=o.find(h=>h.checked),l=(u=a!=null?a:o[0])!=null?u:null;e.forEach(h=>{h._standaloneTabIndex=h===l?0:-1})}get _internalTabIndex(){return this.disabled?-1:this._groupTabIndex!==void 0?this._groupTabIndex:this._standaloneTabIndex!==void 0?this._standaloneTabIndex:0}firstUpdated(){this.isInGroup()||this.syncStandaloneTabOrder()}uncheckOtherRadios(){if(!this.name)return;let e=this.getRadioScope();Array.from(e.querySelectorAll(`w-radio[name="${this.name}"]`)).forEach(a=>{a!==this&&(a.closest("w-radio-group")||a.checked&&(a.checked=!1))})}updateValidity(){if(this.disabled||this.isInGroup()){this.internals.setValidity({});return}let e=this.required&&!this.checked,o=this.invalid&&!F(this,C);if(e){x(this,C,!0),this.invalid=F(this,_),this.internals.setValidity({valueMissing:!0},this.internals.validationMessage||" ");return}if(F(this,C)&&(this.invalid=!1,x(this,C,!1)),o){this.internals.setValidity({customError:!0},this.internals.validationMessage||" ");return}this.internals.setValidity({})}syncFormValue(){if(this.disabled){this.setValue(null);return}this.setValue(this.checked?this.value:null)}shouldSyncFormState(e){return e.has("checked")||e.has("value")||e.has("disabled")||e.has("required")||e.has("invalid")}render(){return ae`
2610
+ `;var M,C,_,p=class extends W(J){constructor(){super();this.value=null;this.checked=!1;this.disabled=!1;this.required=!1;this.invalid=!1;G(this,M,!1);G(this,C,!1);G(this,_,!1);this.handleClick=()=>{this.isInGroup()||this.disabled||(x(this,_,!0),!this.checked&&(this.checked=!0,this.updateComplete.then(()=>{this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))})))};this.handleInvalid=()=>{x(this,_,!0),this.updateValidity()};this.handleKeyDown=e=>{var o,a;if(!this.isInGroup()&&!this.disabled&&!e.defaultPrevented){if(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(e.key)){let l=this.getStandaloneNamedRadios().filter(m=>!m.disabled);if(l.length<=1)return;e.preventDefault();let u=(a=(o=l.find(m=>m.checked))!=null?o:l.find(m=>m===this))!=null?a:l[0],h=e.key==="ArrowUp"||e.key==="ArrowLeft"?-1:1,z=(l.indexOf(u)+h+l.length)%l.length,g=l[z];x(g,_,!0),g.checked||(g.checked=!0,g.updateComplete.then(()=>{g.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))})),g.focus();return}if(!(e.key!==" "&&e.key!=="Spacebar"&&e.key!=="Enter")){if(e.key==="Enter"&&this.internals.form){this.internals.form.requestSubmit();return}e.preventDefault(),this.click()}}};this.addEventListener("click",this.handleClick),this.addEventListener("invalid",this.handleInvalid),this.addEventListener("keydown",this.handleKeyDown)}get tabIndex(){return this._internalTabIndex}set tabIndex(e){this._groupTabIndex=e}connectedCallback(){var e;super.connectedCallback(),this.value=(e=this.getAttribute("value"))!=null?e:"on",x(this,M,this.hasAttribute("checked")),this.checked=F(this,M),this.internals.role="radio",this.syncAriaDisabled(),this.syncFormValue(),this.updateValidity()}syncAriaDisabled(){this.internals.ariaDisabled=this.disabled?"true":"false"}syncAriaChecked(){this.internals.ariaChecked=this.checked?"true":"false"}willUpdate(e){this.shouldSyncFormState(e)&&(this.syncFormValue(),this.updateValidity())}updated(e){super.updated(e),e.has("checked")&&(this.syncAriaChecked(),this.checked&&!this.isInGroup()&&(this.uncheckOtherRadios(),this.syncStandaloneTabOrder())),e.has("disabled")&&(this.syncAriaDisabled(),this.isInGroup()||this.syncStandaloneTabOrder()),e.has("invalid")&&(this.internals.ariaInvalid=this.invalid?"true":null),e.has("name")&&this.checked&&!this.isInGroup()&&this.uncheckOtherRadios()}resetFormControl(){this.checked=F(this,M),this.syncFormValue(),this.updateValidity()}get validationMessage(){return this.internals.validationMessage}get validity(){return this.internals.validity}checkValidity(){return this.updateValidity(),this.internals.checkValidity()}reportValidity(){return x(this,_,!0),this.updateValidity(),this.internals.checkValidity()}isInGroup(){return!!this.closest("w-radio-group")}getRadioScope(){var e,o;return(o=(e=this.internals.form)!=null?e:this.closest("form"))!=null?o:document}getStandaloneNamedRadios(){if(!this.name)return[this];let e=this.getRadioScope();return Array.from(e.querySelectorAll(`w-radio[name="${this.name}"]`)).filter(o=>!o.closest("w-radio-group"))}syncStandaloneTabOrder(){var u;let e=this.getStandaloneNamedRadios(),o=e.filter(h=>!h.disabled),a=o.find(h=>h.checked),l=(u=a!=null?a:o[0])!=null?u:null;e.forEach(h=>{h._standaloneTabIndex=h===l?0:-1})}get _internalTabIndex(){return this.disabled?-1:this._groupTabIndex!==void 0?this._groupTabIndex:this._standaloneTabIndex!==void 0?this._standaloneTabIndex:0}firstUpdated(){this.isInGroup()||this.syncStandaloneTabOrder()}uncheckOtherRadios(){if(!this.name)return;let e=this.getRadioScope();Array.from(e.querySelectorAll(`w-radio[name="${this.name}"]`)).forEach(a=>{a!==this&&(a.closest("w-radio-group")||a.checked&&(a.checked=!1))})}updateValidity(){if(this.disabled||this.isInGroup()){this.internals.setValidity({});return}let e=this.required&&!this.checked,o=this.invalid&&!F(this,C);if(e){x(this,C,!0),this.invalid=F(this,_),this.internals.setValidity({valueMissing:!0},this.internals.validationMessage||" ");return}if(F(this,C)&&(this.invalid=!1,x(this,C,!1)),o){this.internals.setValidity({customError:!0},this.internals.validationMessage||" ");return}this.internals.setValidity({})}syncFormValue(){if(this.disabled){this.setValue(null);return}this.setValue(this.checked?this.value:null)}shouldSyncFormState(e){return e.has("checked")||e.has("value")||e.has("disabled")||e.has("required")||e.has("invalid")}render(){return ae`
2611
2611
  <div class="wrapper" tabindex="${this._internalTabIndex}">
2612
2612
  <div part="control" class="control"></div>
2613
2613
  <slot part="label" class="label"></slot>