@warp-ds/elements 2.3.0-next.24 → 2.3.0-next.26
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/custom-elements.json +311 -22
- package/dist/index.d.ts +261 -0
- package/dist/packages/attention/index.js +20 -20
- package/dist/packages/attention/index.js.map +3 -3
- package/dist/packages/button/button.react.stories.d.ts +1 -1
- package/dist/packages/button/button.test.js +30 -1
- package/dist/packages/button/index.d.ts +2 -0
- package/dist/packages/button/index.js +12 -12
- package/dist/packages/button/index.js.map +3 -3
- package/dist/packages/checkbox/checkbox-group.js +2 -2
- package/dist/packages/checkbox/checkbox-group.js.map +2 -2
- package/dist/packages/checkbox/checkbox.js +1 -1
- package/dist/packages/checkbox/checkbox.js.map +2 -2
- package/dist/packages/checkbox/index.d.ts +2 -1
- package/dist/packages/checkbox/index.js +2 -6
- package/dist/packages/combobox/combobox.react.stories.d.ts +1 -1
- package/dist/packages/combobox/combobox.stories.d.ts +1 -0
- package/dist/packages/combobox/combobox.stories.js +29 -3
- package/dist/packages/combobox/index.d.ts +7 -1
- package/dist/packages/combobox/index.js +19 -19
- package/dist/packages/combobox/index.js.map +4 -4
- package/dist/packages/datepicker/datepicker.d.ts +1 -0
- package/dist/packages/datepicker/datepicker.js +35 -35
- package/dist/packages/datepicker/datepicker.js.map +3 -3
- package/dist/packages/datepicker/datepicker.react.stories.d.ts +1 -1
- package/dist/packages/datepicker/datepicker.test.js +27 -0
- package/dist/packages/link/link.react.stories.d.ts +1 -1
- package/dist/packages/radio/index.d.ts +2 -1
- package/dist/packages/radio/index.js +2 -6
- package/dist/packages/radio/radio-group.js +5 -5
- package/dist/packages/radio/radio-group.js.map +2 -2
- package/dist/packages/radio/radio.js +1 -1
- package/dist/packages/radio/radio.js.map +2 -2
- package/dist/packages/radio/radio.stories.js +3 -3
- package/dist/packages/radio/radio.stories.js.map +4 -4
- package/dist/packages/select/index.d.ts +1 -0
- package/dist/packages/select/index.js +15 -15
- package/dist/packages/select/index.js.map +3 -3
- package/dist/packages/select/select.react.stories.d.ts +1 -1
- package/dist/packages/select/select.test.js +30 -0
- package/dist/packages/slider/slider-thumb.d.ts +1 -0
- package/dist/packages/slider/slider-thumb.js +23 -23
- package/dist/packages/slider/slider-thumb.js.map +3 -3
- package/dist/packages/slider/slider.d.ts +1 -2
- package/dist/packages/slider/slider.js +20 -20
- package/dist/packages/slider/slider.js.map +4 -4
- package/dist/packages/slider/slider.stories.js +2 -2
- package/dist/packages/slider/slider.test.js +28 -0
- package/dist/packages/switch/index.d.ts +10 -2
- package/dist/packages/switch/index.js +5 -5
- package/dist/packages/switch/index.js.map +4 -4
- package/dist/packages/switch/switch.react.stories.js +4 -4
- package/dist/packages/switch/switch.stories.js +6 -5
- package/dist/packages/switch/switch.test.d.ts +1 -0
- package/dist/packages/switch/switch.test.js +40 -0
- package/dist/packages/textarea/textarea.d.ts +1 -0
- package/dist/packages/textarea/textarea.js +14 -14
- package/dist/packages/textarea/textarea.js.map +3 -3
- package/dist/packages/textarea/textarea.react.stories.d.ts +1 -1
- package/dist/packages/textarea/textarea.test.js +19 -0
- package/dist/packages/textfield/index.d.ts +3 -0
- package/dist/packages/textfield/index.js +8 -8
- package/dist/packages/textfield/index.js.map +3 -3
- package/dist/packages/textfield/textfield.react.stories.d.ts +1 -1
- package/dist/packages/textfield/textfield.stories.d.ts +1 -0
- package/dist/packages/textfield/textfield.stories.js +17 -0
- package/dist/web-types.json +340 -3
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@ import { StoryObj } from '@storybook/react';
|
|
|
3
3
|
import { DatePicker } from './react';
|
|
4
4
|
declare const _default: {
|
|
5
5
|
title: string;
|
|
6
|
-
render(args: Omit<React.HTMLAttributes<import("./datepicker").WarpDatepicker>, "label" | "onchange" | "onChange" | "render" | "renderOptions" | "connectedCallback" | "disconnectedCallback" | "renderRoot" | "isUpdatePending" | "hasUpdated" | "addController" | "removeController" | "attributeChangedCallback" | "requestUpdate" | "updateComplete" | "form" | "input" | "name" | "value" | "updated" | "validationTarget" | "internals" | "showError" | "validationMessage" | "validity" | "validationComplete" | "checkValidity" | "formResetCallback" | "
|
|
6
|
+
render(args: Omit<React.HTMLAttributes<import("./datepicker").WarpDatepicker>, "label" | "onchange" | "onChange" | "render" | "renderOptions" | "connectedCallback" | "disconnectedCallback" | "renderRoot" | "isUpdatePending" | "hasUpdated" | "addController" | "removeController" | "attributeChangedCallback" | "requestUpdate" | "updateComplete" | "form" | "input" | "name" | "value" | "updated" | "resetFormControl" | "validationTarget" | "internals" | "showError" | "validationMessage" | "validity" | "validationComplete" | "checkValidity" | "formResetCallback" | "valueChangedCallback" | "validityCallback" | "validationMessageCallback" | "setValue" | "shouldFormValueUpdate" | "month" | "locale" | "calendar" | "wrapper" | "headerFormat" | "weekdayFormat" | "isDayDisabled" | "dayFormat" | "isCalendarOpen" | "navigationDate" | "selectedDate" | "weeks" | "toggleButton" | "previousMonthButton" | "todayCell" | "selectedCell"> & {
|
|
7
7
|
onChange?: (e: Event) => void;
|
|
8
8
|
onchange?: (e: Event) => void;
|
|
9
9
|
} & Partial<Omit<import("./datepicker").WarpDatepicker, keyof HTMLElement>> & React.RefAttributes<import("./datepicker").WarpDatepicker>): React.JSX.Element;
|
|
@@ -60,3 +60,30 @@ test('can pick a date by typing in the input field', async () => {
|
|
|
60
60
|
const formData = new FormData(page.getByTestId('flight').element());
|
|
61
61
|
expect(formData.get('from')).toBeTruthy();
|
|
62
62
|
});
|
|
63
|
+
test('can reset datepicker by resetting surrounding form', async () => {
|
|
64
|
+
const label = 'Test label';
|
|
65
|
+
render(html `
|
|
66
|
+
<form>
|
|
67
|
+
<w-datepicker
|
|
68
|
+
label=${label}
|
|
69
|
+
name="test"
|
|
70
|
+
value="2025-01-01"
|
|
71
|
+
>
|
|
72
|
+
</w-datepicker>
|
|
73
|
+
</form>
|
|
74
|
+
`);
|
|
75
|
+
const form = document.querySelector('form');
|
|
76
|
+
const wDatepicker = document.querySelector('w-datepicker');
|
|
77
|
+
// sanity
|
|
78
|
+
expect(form).not.toBeNull();
|
|
79
|
+
expect(wDatepicker).not.toBeNull();
|
|
80
|
+
// Initial value is "2025-01-01"
|
|
81
|
+
expect(wDatepicker.value).toBe('2025-01-01');
|
|
82
|
+
// Change the value to "definitely not 2025-01-01"
|
|
83
|
+
wDatepicker.value = 'definitely not 2025-01-01';
|
|
84
|
+
expect(wDatepicker.value).toBe('definitely not 2025-01-01');
|
|
85
|
+
// Reset the form
|
|
86
|
+
form.reset();
|
|
87
|
+
// Value should be reset back to "2025-01-01"
|
|
88
|
+
expect(wDatepicker.value).toBe('2025-01-01');
|
|
89
|
+
});
|
|
@@ -3,7 +3,7 @@ import { StoryObj } from '@storybook/react';
|
|
|
3
3
|
import { Link } from './react';
|
|
4
4
|
declare const _default: {
|
|
5
5
|
title: string;
|
|
6
|
-
render(args: Omit<React.HTMLAttributes<import(".").WarpLink>, "rel" | "render" | "renderOptions" | "connectedCallback" | "disconnectedCallback" | "renderRoot" | "isUpdatePending" | "hasUpdated" | "addController" | "removeController" | "attributeChangedCallback" | "requestUpdate" | "updateComplete" | "variant" | "form" | "small" | "quiet" | "href" | "disabled" | "target" | "fullWidth" | "buttonClass" | "name" | "firstUpdated" | "validationTarget" | "internals" | "showError" | "validationMessage" | "validity" | "validationComplete" | "checkValidity" | "formResetCallback" | "
|
|
6
|
+
render(args: Omit<React.HTMLAttributes<import(".").WarpLink>, "rel" | "render" | "renderOptions" | "connectedCallback" | "disconnectedCallback" | "renderRoot" | "isUpdatePending" | "hasUpdated" | "addController" | "removeController" | "attributeChangedCallback" | "requestUpdate" | "updateComplete" | "variant" | "form" | "small" | "quiet" | "href" | "disabled" | "target" | "fullWidth" | "buttonClass" | "name" | "firstUpdated" | "resetFormControl" | "validationTarget" | "internals" | "showError" | "validationMessage" | "validity" | "validationComplete" | "checkValidity" | "formResetCallback" | "valueChangedCallback" | "validityCallback" | "validationMessageCallback" | "setValue" | "shouldFormValueUpdate" | "classes"> & {} & Partial<Omit<import(".").WarpLink, keyof HTMLElement>> & React.RefAttributes<import(".").WarpLink>): React.JSX.Element;
|
|
7
7
|
component: import("@lit/react").ReactWebComponent<import(".").WarpLink, {}>;
|
|
8
8
|
};
|
|
9
9
|
export default _default;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export { WRadio } from './radio';
|
|
2
|
+
export { WRadioGroup } from './radio-group';
|
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (!customElements.get('w-radio')) {
|
|
4
|
-
customElements.define('w-radio', WRadio);
|
|
5
|
-
customElements.define('w-radio-group', WRadioGroup);
|
|
6
|
-
}
|
|
1
|
+
export { WRadio } from './radio';
|
|
2
|
+
export { WRadioGroup } from './radio-group';
|
|
@@ -8,7 +8,7 @@ var X=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var V=i=>{thro
|
|
|
8
8
|
:host *::after {
|
|
9
9
|
box-sizing: inherit !important;
|
|
10
10
|
}
|
|
11
|
-
`;var f,g=class extends Z{constructor(){super();A(this,f,!1);this.initialReflectedProperties=new Map;this.customStates={set:(e,r)=>{var t;(t=this.internals)!=null&&t.states&&(r?this.internals.states.add(e):this.internals.states.delete(e))},has:e=>{var r;return(r=this.internals)!=null&&r.states?this.internals.states.has(e):!1}};try{this.internals=this.attachInternals()}catch(r){console.error("Element internals are not supported in your browser. Consider using a polyfill")}this.customStates.set("wa-defined",!0);let e=this.constructor;for(let[r,t]of e.elementProperties)t.default==="inherit"&&t.initial!==void 0&&typeof r=="string"&&this.customStates.set(`initial-${r}-${t.initial}`,!0)}static get styles(){let e=Array.isArray(this.css)?this.css:this.css?[this.css]:[];return[L,...e].map(r=>typeof r=="string"?$(r):r)}attributeChangedCallback(e,r,t){S(this,f)||(this.constructor.elementProperties.forEach((a,s)=>{a.reflect&&this[s]!=null&&this.initialReflectedProperties.set(s,this[s])}),R(this,f,!0)),super.attributeChangedCallback(e,r,t)}willUpdate(e){super.willUpdate(e),this.initialReflectedProperties.forEach((r,t)=>{e.has(t)&&this[t]==null&&(this[t]=r)})}relayNativeEvent(e,r){e.stopImmediatePropagation(),this.dispatchEvent(new e.constructor(e.type,{...e,...r}))}};f=new WeakMap,n([T()],g.prototype,"dir",2),n([T()],g.prototype,"lang",2);var I=()=>({observedAttributes:["custom-error"],checkValidity(i){let o={message:"",isValid:!0,invalidKeys:[]};return i.customError&&(o.message=i.customError,o.isValid=!1,o.invalidKeys=["customError"]),o}});var x=class extends Event{constructor(){super("w-invalid",{bubbles:!0,cancelable:!1,composed:!0})}};var c=class extends g{constructor(){super();this.name=null;this.disabled=!1;this.required=!1;this.assumeInteractionOn=["input"];this.validators=[];this.valueHasChanged=!1;this.hasInteracted=!1;this.customError=null;this.emittedEvents=[];this.emitInvalid=e=>{e.target===this&&(this.hasInteracted=!0,this.dispatchEvent(new x))};this.handleInteraction=e=>{var t;let r=this.emittedEvents;r.includes(e.type)||r.push(e.type),r.length===((t=this.assumeInteractionOn)==null?void 0:t.length)&&(this.hasInteracted=!0)};E||this.addEventListener("invalid",this.emitInvalid)}static get validators(){return[I()]}static get observedAttributes(){let e=new Set(super.observedAttributes||[]);for(let r of this.validators)if(r.observedAttributes)for(let t of r.observedAttributes)e.add(t);return[...e]}connectedCallback(){super.connectedCallback(),this.updateValidity(),this.assumeInteractionOn.forEach(e=>{this.addEventListener(e,this.handleInteraction)})}firstUpdated(...e){super.firstUpdated(...e),this.updateValidity()}willUpdate(e){if(!E&&e.has("customError")&&(this.customError||(this.customError=null),this.setCustomValidity(this.customError||"")),e.has("value")||e.has("disabled")){let r=this.value;if(Array.isArray(r)){if(this.name){let t=new FormData;for(let a of r)t.append(this.name,a);this.setValue(t,t)}}else this.setValue(r,r)}e.has("disabled")&&(this.customStates.set("disabled",this.disabled),(this.hasAttribute("disabled")||!E&&!this.matches(":disabled"))&&this.toggleAttribute("disabled",this.disabled)),this.updateValidity(),super.willUpdate(e)}get labels(){return this.internals.labels}getForm(){return this.internals.form}get validity(){return this.internals.validity}get willValidate(){return this.internals.willValidate}get validationMessage(){return this.internals.validationMessage}checkValidity(){return this.updateValidity(),this.internals.checkValidity()}reportValidity(){return this.updateValidity(),this.hasInteracted=!0,this.internals.reportValidity()}get validationTarget(){return this.input||void 0}setValidity(...e){let r=e[0],t=e[1],a=e[2];a||(a=this.validationTarget),this.internals.setValidity(r,t,a||void 0),this.requestUpdate("validity"),this.setCustomStates()}setCustomStates(){let e=!!this.required,r=this.internals.validity.valid,t=this.hasInteracted;this.customStates.set("required",e),this.customStates.set("optional",!e),this.customStates.set("invalid",!r),this.customStates.set("valid",r),this.customStates.set("user-invalid",!r&&t),this.customStates.set("user-valid",r&&t)}setCustomValidity(e){if(!e){this.customError=null,this.setValidity({});return}this.customError=e,this.setValidity({customError:!0},e,this.validationTarget)}formResetCallback(){this.resetValidity(),this.hasInteracted=!1,this.valueHasChanged=!1,this.emittedEvents=[],this.updateValidity()}formDisabledCallback(e){this.disabled=e,this.updateValidity()}formStateRestoreCallback(e,r){this.value=e,r==="restore"&&this.resetValidity(),this.updateValidity()}setValue(...e){let[r,t]=e;this.internals.setFormValue(r,t)}get allValidators(){let e=this.constructor.validators||[],r=this.validators||[];return[...e,...r]}resetValidity(){this.setCustomValidity(""),this.setValidity({})}updateValidity(){if(this.disabled||this.hasAttribute("disabled")||!this.willValidate){this.resetValidity();return}let e=this.allValidators;if(!(e!=null&&e.length))return;let r={customError:!!this.customError},t=this.validationTarget||this.input||void 0,a="";for(let s of e){let{isValid:l,message:v,invalidKeys:
|
|
11
|
+
`;var f,g=class extends Z{constructor(){super();A(this,f,!1);this.initialReflectedProperties=new Map;this.customStates={set:(e,r)=>{var t;(t=this.internals)!=null&&t.states&&(r?this.internals.states.add(e):this.internals.states.delete(e))},has:e=>{var r;return(r=this.internals)!=null&&r.states?this.internals.states.has(e):!1}};try{this.internals=this.attachInternals()}catch(r){console.error("Element internals are not supported in your browser. Consider using a polyfill")}this.customStates.set("wa-defined",!0);let e=this.constructor;for(let[r,t]of e.elementProperties)t.default==="inherit"&&t.initial!==void 0&&typeof r=="string"&&this.customStates.set(`initial-${r}-${t.initial}`,!0)}static get styles(){let e=Array.isArray(this.css)?this.css:this.css?[this.css]:[];return[L,...e].map(r=>typeof r=="string"?$(r):r)}attributeChangedCallback(e,r,t){S(this,f)||(this.constructor.elementProperties.forEach((a,s)=>{a.reflect&&this[s]!=null&&this.initialReflectedProperties.set(s,this[s])}),R(this,f,!0)),super.attributeChangedCallback(e,r,t)}willUpdate(e){super.willUpdate(e),this.initialReflectedProperties.forEach((r,t)=>{e.has(t)&&this[t]==null&&(this[t]=r)})}relayNativeEvent(e,r){e.stopImmediatePropagation(),this.dispatchEvent(new e.constructor(e.type,{...e,...r}))}};f=new WeakMap,n([T()],g.prototype,"dir",2),n([T()],g.prototype,"lang",2);var I=()=>({observedAttributes:["custom-error"],checkValidity(i){let o={message:"",isValid:!0,invalidKeys:[]};return i.customError&&(o.message=i.customError,o.isValid=!1,o.invalidKeys=["customError"]),o}});var x=class extends Event{constructor(){super("w-invalid",{bubbles:!0,cancelable:!1,composed:!0})}};var c=class extends g{constructor(){super();this.name=null;this.disabled=!1;this.required=!1;this.assumeInteractionOn=["input"];this.validators=[];this.valueHasChanged=!1;this.hasInteracted=!1;this.customError=null;this.emittedEvents=[];this.emitInvalid=e=>{e.target===this&&(this.hasInteracted=!0,this.dispatchEvent(new x))};this.handleInteraction=e=>{var t;let r=this.emittedEvents;r.includes(e.type)||r.push(e.type),r.length===((t=this.assumeInteractionOn)==null?void 0:t.length)&&(this.hasInteracted=!0)};E||this.addEventListener("invalid",this.emitInvalid)}static get validators(){return[I()]}static get observedAttributes(){let e=new Set(super.observedAttributes||[]);for(let r of this.validators)if(r.observedAttributes)for(let t of r.observedAttributes)e.add(t);return[...e]}connectedCallback(){super.connectedCallback(),this.updateValidity(),this.assumeInteractionOn.forEach(e=>{this.addEventListener(e,this.handleInteraction)})}firstUpdated(...e){super.firstUpdated(...e),this.updateValidity()}willUpdate(e){if(!E&&e.has("customError")&&(this.customError||(this.customError=null),this.setCustomValidity(this.customError||"")),e.has("value")||e.has("disabled")){let r=this.value;if(Array.isArray(r)){if(this.name){let t=new FormData;for(let a of r)t.append(this.name,a);this.setValue(t,t)}}else this.setValue(r,r)}e.has("disabled")&&(this.customStates.set("disabled",this.disabled),(this.hasAttribute("disabled")||!E&&!this.matches(":disabled"))&&this.toggleAttribute("disabled",this.disabled)),this.updateValidity(),super.willUpdate(e)}get labels(){return this.internals.labels}getForm(){return this.internals.form}get validity(){return this.internals.validity}get willValidate(){return this.internals.willValidate}get validationMessage(){return this.internals.validationMessage}checkValidity(){return this.updateValidity(),this.internals.checkValidity()}reportValidity(){return this.updateValidity(),this.hasInteracted=!0,this.internals.reportValidity()}get validationTarget(){return this.input||void 0}setValidity(...e){let r=e[0],t=e[1],a=e[2];a||(a=this.validationTarget),this.internals.setValidity(r,t,a||void 0),this.requestUpdate("validity"),this.setCustomStates()}setCustomStates(){let e=!!this.required,r=this.internals.validity.valid,t=this.hasInteracted;this.customStates.set("required",e),this.customStates.set("optional",!e),this.customStates.set("invalid",!r),this.customStates.set("valid",r),this.customStates.set("user-invalid",!r&&t),this.customStates.set("user-valid",r&&t)}setCustomValidity(e){if(!e){this.customError=null,this.setValidity({});return}this.customError=e,this.setValidity({customError:!0},e,this.validationTarget)}formResetCallback(){this.resetValidity(),this.hasInteracted=!1,this.valueHasChanged=!1,this.emittedEvents=[],this.updateValidity()}formDisabledCallback(e){this.disabled=e,this.updateValidity()}formStateRestoreCallback(e,r){this.value=e,r==="restore"&&this.resetValidity(),this.updateValidity()}setValue(...e){let[r,t]=e;this.internals.setFormValue(r,t)}get allValidators(){let e=this.constructor.validators||[],r=this.validators||[];return[...e,...r]}resetValidity(){this.setCustomValidity(""),this.setValidity({})}updateValidity(){if(this.disabled||this.hasAttribute("disabled")||!this.willValidate){this.resetValidity();return}let e=this.allValidators;if(!(e!=null&&e.length))return;let r={customError:!!this.customError},t=this.validationTarget||this.input||void 0,a="";for(let s of e){let{isValid:l,message:v,invalidKeys:h}=s.checkValidity(this);l||(a||(a=v),(h==null?void 0:h.length)>=0&&h.forEach(k=>r[k]=!0))}a||(a=this.validationMessage),this.setValidity(r,a,t)}};c.formAssociated=!0,n([m({reflect:!0})],c.prototype,"name",2),n([m({type:Boolean})],c.prototype,"disabled",2),n([m({state:!0,attribute:!1})],c.prototype,"valueHasChanged",2),n([m({state:!0,attribute:!1})],c.prototype,"hasInteracted",2),n([m({attribute:"custom-error",reflect:!0})],c.prototype,"customError",2),n([m({attribute:!1,state:!0,type:Object})],c.prototype,"validity",1);var M="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var H=(i=21)=>{let o="",e=crypto.getRandomValues(new Uint8Array(i|=0));for(;i--;)o+=M[e[i]&63];return o};function q(i=""){return`${i}${H()}`}import{html as J}from"lit";import{property as w,state as j}from"lit/decorators.js";import{css as K}from"lit";var D=K`
|
|
12
12
|
[part~='label'] {
|
|
13
13
|
display: block;
|
|
14
14
|
font-size: var(--w-font-size-m);
|
|
@@ -2553,12 +2553,12 @@ var X=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var V=i=>{thro
|
|
|
2553
2553
|
display: none
|
|
2554
2554
|
}
|
|
2555
2555
|
}
|
|
2556
|
-
`;var
|
|
2556
|
+
`;var b=class extends c{constructor(){super();this.checked=!1;this.forceDisabled=!1;this.form=null;this.appearance="default";this.size="medium";this.disabled=!1;this.handleClick=()=>{!this.disabled&&!this.forceDisabled&&(this.checked=!0)};this.addEventListener("click",this.handleClick)}connectedCallback(){super.connectedCallback(),this.setInitialAttributes()}setInitialAttributes(){this.setAttribute("role","radio"),this.tabIndex=0,this.setAttribute("aria-disabled",this.disabled||this.forceDisabled?"true":"false")}updated(e){if(super.updated(e),e.has("checked")&&(this.customStates.set("checked",this.checked),this[this.checked?"setAttribute":"removeAttribute"]("checked-ui",""),this.setAttribute("aria-checked",this.checked?"true":"false"),!this.disabled&&!this.forceDisabled&&(this.tabIndex=this.checked?0:-1)),e.has("disabled")||e.has("forceDisabled")){let r=this.disabled||this.forceDisabled;this.customStates.set("disabled",r),this[r?"setAttribute":"removeAttribute"]("disabled-ui",""),this.setAttribute("aria-disabled",r?"true":"false"),r?this.tabIndex=-1:this.tabIndex=this.checked?0:-1}}setValue(){}render(){return J`
|
|
2557
2557
|
<div class="wrapper">
|
|
2558
2558
|
<div part="control" class="control"></div>
|
|
2559
2559
|
<slot part="label" class="label"></slot>
|
|
2560
2560
|
</div>
|
|
2561
|
-
`}};
|
|
2561
|
+
`}};b.css=[N,D],n([j()],b.prototype,"checked",2),n([j()],b.prototype,"forceDisabled",2),n([w({reflect:!0})],b.prototype,"form",2),n([w({reflect:!0})],b.prototype,"value",2),n([w({reflect:!0})],b.prototype,"appearance",2),n([w({reflect:!0})],b.prototype,"size",2),n([w({type:Boolean})],b.prototype,"disabled",2);customElements.get("w-radio")||customElements.define("w-radio",b);import{css as Q}from"lit";var _=Q`
|
|
2562
2562
|
:host {
|
|
2563
2563
|
display: block;
|
|
2564
2564
|
}
|
|
@@ -2615,7 +2615,7 @@ var X=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var V=i=>{thro
|
|
|
2615
2615
|
gap: 0;
|
|
2616
2616
|
}
|
|
2617
2617
|
}
|
|
2618
|
-
`;var U=(i={})=>{let{validationElement:o,validationProperty:e}=i;o||(o=Object.assign(document.createElement("input"),{required:!0})),e||(e="value");let r={observedAttributes:["required"],message:o.validationMessage,checkValidity(t){var
|
|
2618
|
+
`;var U=(i={})=>{let{validationElement:o,validationProperty:e}=i;o||(o=Object.assign(document.createElement("input"),{required:!0})),e||(e="value");let r={observedAttributes:["required"],message:o.validationMessage,checkValidity(t){var h;let a={message:"",isValid:!0,invalidKeys:[]};return((h=t.required)!=null?h:t.hasAttribute("required"))&&!t[e]&&(a.message=typeof r.message=="function"?r.message(t):r.message||"",a.isValid=!1,a.invalidKeys.push("valueMissing")),a}};return r};var y=class{constructor(o,...e){this.slotNames=[];this.handleSlotChange=o=>{let e=o.target;(this.slotNames.includes("[default]")&&!e.name||e.name&&this.slotNames.includes(e.name))&&this.host.requestUpdate()};(this.host=o).addController(this),this.slotNames=e}hasDefaultSlot(){return[...this.host.childNodes].some(o=>{var e;if(o.nodeType===Node.TEXT_NODE&&((e=o.textContent)==null?void 0:e.trim())!=="")return!0;if(o.nodeType===Node.ELEMENT_NODE){let r=o;if(r.tagName.toLowerCase()==="w-visually-hidden")return!1;if(!r.hasAttribute("slot"))return!0}return!1})}hasNamedSlot(o){return this.host.querySelector(`:scope > [slot="${o}"]`)!==null}test(o){return o==="[default]"?this.hasDefaultSlot():this.hasNamedSlot(o)}hostConnected(){var o;(o=this.host.shadowRoot)==null||o.addEventListener("slotchange",this.handleSlotChange)}hostDisconnected(){var o;(o=this.host.shadowRoot)==null||o.removeEventListener("slotchange",this.handleSlotChange)}};var d=class extends c{constructor(){super();this.hasSlotController=new y(this,"hint","label");this.hasRadioButtons=!1;this.label="";this.hint="";this.name=null;this.disabled=!1;this.orientation="vertical";this._value=null;this.defaultValue=this.getAttribute("value")||null;this.size="medium";this.required=!1;this.withLabel=!1;this.withHint=!1;this.handleRadioClick=e=>{let r=e.target.closest("w-radio");if(!r||r.disabled||r.forceDisabled||this.disabled)return;let t=this.value;this.value=r.value,r.checked=!0;let a=this.getAllRadios();for(let s of a)r!==s&&(s.checked=!1,s.setAttribute("tabindex","-1"));this.value!==t&&this.updateComplete.then(()=>{this.dispatchEvent(new InputEvent("input",{bubbles:!0,composed:!0})),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))})};this.addEventListener("keydown",this.handleKeyDown),this.addEventListener("click",this.handleRadioClick)}static get validators(){let e=[U({validationElement:Object.assign(document.createElement("input"),{required:!0,type:"radio",name:q("__w-radio")})})];return[...super.validators,...e]}get value(){var e;return this.valueHasChanged?this._value:(e=this._value)!=null?e:this.defaultValue}set value(e){typeof e=="number"&&(e=String(e)),this.valueHasChanged=!0,this._value=e}get validationTarget(){let e=this.querySelector(":is(w-radio):not([disabled])");if(e)return e}updated(e){(e.has("disabled")||e.has("value"))&&this.syncRadioElements()}formResetCallback(...e){this.value=this.defaultValue,super.formResetCallback(...e),this.syncRadioElements()}getAllRadios(){return[...this.querySelectorAll("w-radio")]}handleLabelClick(){this.focus()}async syncRadioElements(){let e=this.getAllRadios(),r=!1;if(e.forEach((t,a)=>{t.appearance==="button"&&(r=!0),t.setAttribute("size",this.size),t.toggleAttribute("data-w-radio-horizontal",this.orientation!=="vertical"),t.toggleAttribute("data-w-radio-vertical",this.orientation==="vertical"),t.toggleAttribute("data-w-radio-first",a===0),t.toggleAttribute("data-w-radio-inner",a!==0&&a!==e.length-1),t.toggleAttribute("data-w-radio-last",a===e.length-1),t.forceDisabled=this.disabled}),this.hasRadioButtons=r,await Promise.all(e.map(async t=>{await t.updateComplete,!t.disabled&&t.value===this.value?t.checked=!0:t.checked=!1})),this.disabled)e.forEach(t=>{t.tabIndex=-1});else{let t=e.filter(s=>!s.disabled),a=t.find(s=>s.checked);t.length>0&&(a?t.forEach(s=>{s.tabIndex=s.checked?0:-1}):t.forEach((s,l)=>{s.tabIndex=l===0?0:-1})),e.filter(s=>s.disabled).forEach(s=>{s.tabIndex=-1})}}handleKeyDown(e){var h,k,z;if(!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"," "].includes(e.key)||this.disabled)return;let r=this.getAllRadios().filter(p=>!p.disabled);if(r.length<=0)return;e.preventDefault();let t=this.value,a=(h=r.find(p=>p.checked))!=null?h:r[0],s=e.key===" "?0:["ArrowUp","ArrowLeft"].includes(e.key)?-1:1,l=r.indexOf(a)+s;l||(l=0),l<0&&(l=r.length-1),l>r.length-1&&(l=0);let v=r.some(p=>p.tagName.toLowerCase()==="w-radio-button");this.getAllRadios().forEach(p=>{p.checked=!1,v||p.setAttribute("tabindex","-1")}),this.value=r[l].value,r[l].checked=!0,v?(z=(k=r[l].shadowRoot)==null?void 0:k.querySelector("button"))==null||z.focus():(r[l].setAttribute("tabindex","0"),r[l].focus()),this.value!==t&&this.updateComplete.then(()=>{this.dispatchEvent(new InputEvent("input",{bubbles:!0,composed:!0})),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}),e.preventDefault()}focus(e){if(this.disabled)return;let r=this.getAllRadios(),t=r.find(l=>l.checked),a=r.find(l=>!l.disabled),s=t||a;s&&s.focus(e)}render(){let e=this.hasUpdated?this.hasSlotController.test("label"):this.withLabel,r=this.hasUpdated?this.hasSlotController.test("hint"):this.withHint,t=this.label?!0:!!e,a=this.hint?!0:!!r;return G`
|
|
2619
2619
|
<fieldset
|
|
2620
2620
|
part="form-control"
|
|
2621
2621
|
class=${O({"form-control":!0,"form-control-radio-group":!0,"form-control-has-label":t,"has-radio-buttons":this.hasRadioButtons})}
|
|
@@ -2644,5 +2644,5 @@ var X=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var V=i=>{thro
|
|
|
2644
2644
|
>${this.hint}</slot
|
|
2645
2645
|
>
|
|
2646
2646
|
</fieldset>
|
|
2647
|
-
`}};d.css=[_],d.shadowRootOptions={...c.shadowRootOptions,delegatesFocus:!0},n([F()],d.prototype,"hasRadioButtons",2),n([W("slot:not([name])")],d.prototype,"defaultSlot",2),n([u()],d.prototype,"label",2),n([u({attribute:"hint"})],d.prototype,"hint",2),n([u({reflect:!0})],d.prototype,"name",2),n([u({type:Boolean,reflect:!0})],d.prototype,"disabled",2),n([u({reflect:!0})],d.prototype,"orientation",2),n([F()],d.prototype,"value",1),n([u({attribute:"value",reflect:!0})],d.prototype,"defaultValue",2),n([u({reflect:!0})],d.prototype,"size",2),n([u({type:Boolean,reflect:!0})],d.prototype,"required",2),n([u({type:Boolean,attribute:"with-label"})],d.prototype,"withLabel",2),n([u({type:Boolean,attribute:"with-hint"})],d.prototype,"withHint",2);export{d as WRadioGroup};
|
|
2647
|
+
`}};d.css=[_],d.shadowRootOptions={...c.shadowRootOptions,delegatesFocus:!0},n([F()],d.prototype,"hasRadioButtons",2),n([W("slot:not([name])")],d.prototype,"defaultSlot",2),n([u()],d.prototype,"label",2),n([u({attribute:"hint"})],d.prototype,"hint",2),n([u({reflect:!0})],d.prototype,"name",2),n([u({type:Boolean,reflect:!0})],d.prototype,"disabled",2),n([u({reflect:!0})],d.prototype,"orientation",2),n([F()],d.prototype,"value",1),n([u({attribute:"value",reflect:!0})],d.prototype,"defaultValue",2),n([u({reflect:!0})],d.prototype,"size",2),n([u({type:Boolean,reflect:!0})],d.prototype,"required",2),n([u({type:Boolean,attribute:"with-label"})],d.prototype,"withLabel",2),n([u({type:Boolean,attribute:"with-hint"})],d.prototype,"withHint",2);customElements.get("w-radio-group")||customElements.define("w-radio-group",d);export{d as WRadioGroup};
|
|
2648
2648
|
//# sourceMappingURL=radio-group.js.map
|