@warp-ds/elements 2.9.1-next.6 → 2.9.2-next.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.
- package/dist/custom-elements.json +72 -226
- package/dist/docs/radio/accessibility.md +1 -0
- package/dist/docs/radio/api.md +57 -0
- package/dist/docs/radio/examples.md +1 -0
- package/dist/docs/radio/radio.md +69 -0
- package/dist/docs/radio/usage.md +1 -0
- package/dist/docs/radio-group/accessibility.md +1 -0
- package/dist/docs/radio-group/api.md +69 -0
- package/dist/docs/radio-group/examples.md +68 -0
- package/dist/docs/radio-group/radio-group.md +311 -0
- package/dist/docs/radio-group/styling.md +118 -0
- package/dist/docs/radio-group/usage.md +44 -0
- package/dist/docs/select/accessibility.md +2 -0
- package/dist/docs/select/api.md +20 -16
- package/dist/docs/select/examples.md +116 -0
- package/dist/docs/select/select.md +168 -18
- package/dist/docs/select/usage.md +30 -0
- package/dist/index.d.ts +136 -185
- package/dist/packages/radio/radio.d.ts +51 -13
- package/dist/packages/radio/radio.js +3 -3
- package/dist/packages/radio/radio.js.map +3 -3
- package/dist/packages/radio/radio.react.stories.d.ts +1 -1
- package/dist/packages/radio/radio.stories.d.ts +2 -2
- package/dist/packages/radio/react.d.ts +2 -2
- package/dist/packages/radio-group/radio-group.d.ts +43 -5
- package/dist/packages/radio-group/radio-group.js +7 -7
- package/dist/packages/radio-group/radio-group.js.map +3 -3
- package/dist/packages/radio-group/react.d.ts +4 -4
- package/dist/packages/select/select.d.ts +32 -48
- package/dist/packages/select/select.js.map +2 -2
- package/dist/web-types.json +78 -46
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@ import { StoryObj } from '@storybook/react';
|
|
|
2
2
|
import { Radio } from './react';
|
|
3
3
|
declare const _default: {
|
|
4
4
|
title: string;
|
|
5
|
-
component: import("@lit/react").ReactWebComponent<import("./radio").
|
|
5
|
+
component: import("@lit/react").ReactWebComponent<import("./radio").WarpRadio, {}>;
|
|
6
6
|
};
|
|
7
7
|
export default _default;
|
|
8
8
|
export type Story = StoryObj<typeof Radio>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/web-components-vite';
|
|
2
|
-
import type {
|
|
2
|
+
import type { WarpRadioGroup } from '../radio-group/radio-group.js';
|
|
3
3
|
import './radio.js';
|
|
4
4
|
import '../radio-group/radio-group.js';
|
|
5
|
-
declare const args: Partial<
|
|
5
|
+
declare const args: Partial<WarpRadioGroup> & {
|
|
6
6
|
[key: string]: any;
|
|
7
7
|
};
|
|
8
8
|
declare const meta: Meta<typeof args>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const Radio: import("@lit/react").ReactWebComponent<
|
|
1
|
+
import { WarpRadio } from './radio.js';
|
|
2
|
+
export declare const Radio: import("@lit/react").ReactWebComponent<WarpRadio, {}>;
|
|
@@ -1,29 +1,58 @@
|
|
|
1
1
|
import type { PropertyValues } from 'lit';
|
|
2
2
|
import { LitElement } from 'lit';
|
|
3
3
|
import '../radio/radio.js';
|
|
4
|
-
import type {
|
|
5
|
-
declare const
|
|
4
|
+
import type { WarpRadio } from '../radio/radio.js';
|
|
5
|
+
declare const WarpRadioGroup_base: import("@open-wc/form-control").Constructor<import("@open-wc/form-control").FormControlInterface> & typeof LitElement;
|
|
6
6
|
/**
|
|
7
|
+
* Radios allow users to select a single option from a list of choices.
|
|
8
|
+
*
|
|
9
|
+
* Use with `w-radio`.
|
|
10
|
+
*
|
|
7
11
|
* @slot label - Alternative to the `label` attribute should you need custom HTML.
|
|
8
12
|
* @slot help-text - Alternative to the `help-text` attribute should you need custom HTML.
|
|
9
13
|
*/
|
|
10
|
-
export declare class
|
|
14
|
+
export declare class WarpRadioGroup extends WarpRadioGroup_base {
|
|
11
15
|
static styles: import("lit").CSSResult[];
|
|
16
|
+
/** @internal */
|
|
12
17
|
hasInteracted: boolean;
|
|
13
18
|
private hasWarnedMissingName;
|
|
14
19
|
private autoTabIndex;
|
|
20
|
+
/**
|
|
21
|
+
* Label for the radio group.
|
|
22
|
+
*/
|
|
15
23
|
label: string;
|
|
24
|
+
/**
|
|
25
|
+
* Help text for the radio group.
|
|
26
|
+
*
|
|
27
|
+
* If you set `required` and `invalid` the group gets a default error message, but you can override it with this attribute.
|
|
28
|
+
*/
|
|
16
29
|
helpText: string;
|
|
30
|
+
/**
|
|
31
|
+
* Whether to show optional text next to the label.
|
|
32
|
+
*/
|
|
17
33
|
optional: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Marks the radio group as invalid.
|
|
36
|
+
*/
|
|
18
37
|
invalid: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* The [name](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#name) of the select when submitting the form.
|
|
40
|
+
*/
|
|
19
41
|
name: string | null;
|
|
42
|
+
/**
|
|
43
|
+
* Disables the radio group and all child radios.
|
|
44
|
+
*/
|
|
20
45
|
disabled: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Makes selecting a radio in the the group required.
|
|
48
|
+
*/
|
|
21
49
|
required: boolean;
|
|
22
50
|
private defaultCheckedValue;
|
|
23
51
|
private slottedHelpText;
|
|
24
52
|
private readonly nameManagedRadios;
|
|
25
53
|
private readonly disabledManagedRadios;
|
|
26
54
|
private unsubscribeI18n?;
|
|
55
|
+
/** @internal */
|
|
27
56
|
static shadowRootOptions: {
|
|
28
57
|
delegatesFocus: boolean;
|
|
29
58
|
clonable?: boolean;
|
|
@@ -33,10 +62,12 @@ export declare class WRadioGroup extends WRadioGroup_base {
|
|
|
33
62
|
slotAssignment?: SlotAssignmentMode;
|
|
34
63
|
};
|
|
35
64
|
constructor();
|
|
36
|
-
|
|
65
|
+
/** @internal */
|
|
66
|
+
get validationTarget(): WarpRadio;
|
|
37
67
|
connectedCallback(): void;
|
|
38
68
|
disconnectedCallback(): void;
|
|
39
69
|
updated(changedProperties: PropertyValues<this>): Promise<void>;
|
|
70
|
+
/** @internal */
|
|
40
71
|
resetFormControl(): void;
|
|
41
72
|
private handleRadioClick;
|
|
42
73
|
private getAllRadios;
|
|
@@ -52,8 +83,11 @@ export declare class WRadioGroup extends WRadioGroup_base {
|
|
|
52
83
|
private syncTabOrder;
|
|
53
84
|
private emitSelectionChange;
|
|
54
85
|
private handleKeyDown;
|
|
86
|
+
/** @internal */
|
|
55
87
|
focus(options?: FocusOptions): void;
|
|
88
|
+
/** @internal */
|
|
56
89
|
checkValidity(): any;
|
|
90
|
+
/** @internal */
|
|
57
91
|
reportValidity(): any;
|
|
58
92
|
private hasSlottedContent;
|
|
59
93
|
private syncFormValue;
|
|
@@ -67,9 +101,13 @@ export declare class WRadioGroup extends WRadioGroup_base {
|
|
|
67
101
|
private warnIfMissingName;
|
|
68
102
|
render(): import("lit").TemplateResult<1>;
|
|
69
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* @deprecated Exported for backwards compatibility only, use `WarpRadioGroup`
|
|
106
|
+
*/
|
|
107
|
+
export declare const WRadioGroup: typeof WarpRadioGroup;
|
|
70
108
|
declare global {
|
|
71
109
|
interface HTMLElementTagNameMap {
|
|
72
|
-
'w-radio-group':
|
|
110
|
+
'w-radio-group': WarpRadioGroup;
|
|
73
111
|
}
|
|
74
112
|
}
|
|
75
113
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var Le=Object.defineProperty;var Ne=Object.getOwnPropertyDescriptor;var de=a=>{throw TypeError(a)};var m=(a,r,e,t)=>{for(var o=t>1?void 0:t?Ne(r,e):r,i=a.length-1,n;i>=0;i--)(n=a[i])&&(o=(t?n(r,e,o):n(o))||o);return t&&o&&Le(r,e,o),o};var ce=(a,r,e)=>r.has(a)||de("Cannot "+e);var O=(a,r,e)=>(ce(a,r,"read from private field"),e?e.call(a):r.get(a)),U=(a,r,e)=>r.has(a)?de("Cannot add the same private member more than once"):r instanceof WeakSet?r.add(a):r.set(a,e),
|
|
1
|
+
var Le=Object.defineProperty;var Ne=Object.getOwnPropertyDescriptor;var de=a=>{throw TypeError(a)};var m=(a,r,e,t)=>{for(var o=t>1?void 0:t?Ne(r,e):r,i=a.length-1,n;i>=0;i--)(n=a[i])&&(o=(t?n(r,e,o):n(o))||o);return t&&o&&Le(r,e,o),o};var ce=(a,r,e)=>r.has(a)||de("Cannot "+e);var O=(a,r,e)=>(ce(a,r,"read from private field"),e?e.call(a):r.get(a)),U=(a,r,e)=>r.has(a)?de("Cannot add the same private member more than once"):r instanceof WeakSet?r.add(a):r.set(a,e),T=(a,r,e,t)=>(ce(a,r,"write to private field"),t?t.call(a,e):r.set(a,e),e);import{html as K,LitElement as Ae}from"lit";var I=a=>typeof a=="string",De=a=>typeof a=="function",he=new Map,be="en";function ae(a){return[...Array.isArray(a)?a:[a],be]}function ie(a,r,e){let t=ae(a);e||(e="default");let o;if(typeof e=="string")switch(o={day:"numeric",month:"short",year:"numeric"},e){case"full":o.weekday="long";case"long":o.month="long";break;case"short":o.month="numeric";break}else o=e;return W(()=>X("date",t,e),()=>new Intl.DateTimeFormat(t,o)).format(I(r)?new Date(r):r)}function Oe(a,r,e){let t;if(e||(e="default"),typeof e=="string")switch(t={second:"numeric",minute:"numeric",hour:"numeric"},e){case"full":case"long":t.timeZoneName="short";break;case"short":delete t.second}else t=e;return ie(a,r,t)}function re(a,r,e){let t=ae(a);return W(()=>X("number",t,e),()=>new Intl.NumberFormat(t,e)).format(r)}function ue(a,r,e,{offset:t=0,...o}){var s,d;let i=ae(a),n=r?W(()=>X("plural-ordinal",i),()=>new Intl.PluralRules(i,{type:"ordinal"})):W(()=>X("plural-cardinal",i),()=>new Intl.PluralRules(i,{type:"cardinal"}));return(d=(s=o[e])!=null?s:o[n.select(e-t)])!=null?d:o.other}function W(a,r){let e=a(),t=he.get(e);return t||(t=r(),he.set(e,t)),t}function X(a,r,e){let t=r.join("-");return`${a}-${t}-${JSON.stringify(e)}`}var pe=/\\u[a-fA-F0-9]{4}|\\x[a-fA-F0-9]{2}/,ge=a=>a.replace(/\\u([a-fA-F0-9]{4})|\\x([a-fA-F0-9]{2})/g,(r,e,t)=>{if(e){let o=parseInt(e,16);return String.fromCharCode(o)}else{let o=parseInt(t,16);return String.fromCharCode(o)}}),ve="%__lingui_octothorpe__%",qe=(a,r,e={})=>{let t=r||a,o=n=>typeof n=="object"?n:e[n],i=(n,s)=>{let d=Object.keys(e).length?o("number"):void 0,u=re(t,n,d);return s.replace(new RegExp(ve,"g"),u)};return{plural:(n,s)=>{let{offset:d=0}=s,u=ue(t,!1,n,s);return i(n-d,u)},selectordinal:(n,s)=>{let{offset:d=0}=s,u=ue(t,!0,n,s);return i(n-d,u)},select:Pe,number:(n,s)=>re(t,n,o(s)||{style:s}),date:(n,s)=>ie(t,n,o(s)||s),time:(n,s)=>Oe(t,n,o(s)||s)}},Pe=(a,r)=>{var e;return(e=r[a])!=null?e:r.other};function je(a,r,e){return(t={},o)=>{let i=qe(r,e,o),n=(d,u=!1)=>Array.isArray(d)?d.reduce((b,p)=>{if(p==="#"&&u)return b+ve;if(I(p))return b+p;let[V,w,E]=p,M={};w==="plural"||w==="selectordinal"||w==="select"?Object.entries(E).forEach(([A,P])=>{M[A]=n(P,w==="plural"||w==="selectordinal")}):M=E;let k;if(w){let A=i[w];k=A(t[V],M)}else k=t[V];return k==null?b:b+k},""):d,s=n(a);return I(s)&&pe.test(s)?ge(s):I(s)?s:s?String(s):""}}var $e=Object.defineProperty,Ye=(a,r,e)=>r in a?$e(a,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[r]=e,He=(a,r,e)=>(Ye(a,typeof r!="symbol"?r+"":r,e),e),te=class{constructor(){He(this,"_events",{})}on(r,e){var o;var t;return(o=(t=this._events)[r])!=null||(t[r]=[]),this._events[r].push(e),()=>this.removeListener(r,e)}removeListener(r,e){let t=this._getListeners(r);if(!t)return;let o=t.indexOf(e);~o&&t.splice(o,1)}emit(r,...e){let t=this._getListeners(r);t&&t.map(o=>o.apply(this,e))}_getListeners(r){let e=this._events[r];return Array.isArray(e)?e:!1}},Ue=Object.defineProperty,We=(a,r,e)=>r in a?Ue(a,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[r]=e,R=(a,r,e)=>(We(a,typeof r!="symbol"?r+"":r,e),e),oe=class extends te{constructor(r){var e;super(),R(this,"_locale",""),R(this,"_locales"),R(this,"_localeData",{}),R(this,"_messages",{}),R(this,"_missing"),R(this,"_messageCompiler"),R(this,"t",this._.bind(this)),r.missing!=null&&(this._missing=r.missing),r.messages!=null&&this.load(r.messages),r.localeData!=null&&this.loadLocaleData(r.localeData),(typeof r.locale=="string"||r.locales)&&this.activate((e=r.locale)!=null?e:be,r.locales)}get locale(){return this._locale}get locales(){return this._locales}get messages(){var r;return(r=this._messages[this._locale])!=null?r:{}}get localeData(){var r;return(r=this._localeData[this._locale])!=null?r:{}}_loadLocaleData(r,e){let t=this._localeData[r];t?Object.assign(t,e):this._localeData[r]=e}setMessagesCompiler(r){return this._messageCompiler=r,this}loadLocaleData(r,e){typeof r=="string"?this._loadLocaleData(r,e):Object.keys(r).forEach(t=>this._loadLocaleData(t,r[t])),this.emit("change")}_load(r,e){let t=this._messages[r];t?Object.assign(t,e):this._messages[r]=e}load(r,e){typeof r=="string"&&typeof e=="object"?this._load(r,e):Object.entries(r).forEach(([t,o])=>this._load(t,o)),this.emit("change")}loadAndActivate({locale:r,locales:e,messages:t}){this._locale=r,this._locales=e||void 0,this._messages[this._locale]=t,this.emit("change")}activate(r,e){this._locale=r,this._locales=e,this.emit("change")}_(r,e,t){if(!this.locale)throw new Error("Lingui: Attempted to call a translation function without setting a locale.\nMake sure to call `i18n.activate(locale)` before using Lingui functions.\nThis issue may also occur due to a race condition in your initialization logic.");let o=t==null?void 0:t.message;r||(r=""),I(r)||(e=r.values||e,o=r.message,r=r.id);let i=this.messages[r],n=i===void 0,s=this._missing;if(s&&n)return De(s)?s(this._locale,r):s;n&&this.emit("missing",{id:r,locale:this._locale});let d=i||o||r;return I(d)&&(this._messageCompiler?d=this._messageCompiler(d):console.warn(`Uncompiled message detected! Message:
|
|
2
2
|
|
|
3
3
|
> ${d}
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@ That means you use raw catalog or your catalog doesn't have a translation for th
|
|
|
6
6
|
ICU features such as interpolation and plurals will not work properly for that message.
|
|
7
7
|
|
|
8
8
|
Please compile your catalog first.
|
|
9
|
-
`)),
|
|
9
|
+
`)),I(d)&&pe.test(d)?ge(d):I(d)?d:je(d,this._locale,this._locales)(e,t==null?void 0:t.formats)}date(r,e){return ie(this._locales||this._locale,r,e)}number(r,e){return re(this._locales||this._locale,r,e)}};function Xe(a={}){return new oe(a)}var y=Xe();var h=function(a,r,e,t){if(e==="a"&&!t)throw new TypeError("Private accessor was defined without a getter");if(typeof r=="function"?a!==r||!t:!r.has(a))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?t:e==="a"?t.call(a):t?t.value:r.get(a)},v=function(a,r,e,t,o){if(t==="m")throw new TypeError("Private method is not writable");if(t==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof r=="function"?a!==r||!o:!r.has(a))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t==="a"?o.call(a,e):o?o.value=e:r.set(a,e),e};function B(a){var r,e,t,o,i,n,s,d,u,b,p,V,w,E,M,k,A,P,J;class Re extends a{constructor(...l){var c,g,f;super(...l),r.add(this),this.internals=this.attachInternals(),e.set(this,!1),t.set(this,!1),o.set(this,!1),i.set(this,void 0),n.set(this,void 0),s.set(this,!0),u.set(this,""),b.set(this,()=>{v(this,o,!0,"f"),v(this,e,!0,"f"),h(this,r,"m",k).call(this)}),p.set(this,()=>{v(this,e,!1,"f"),h(this,r,"m",A).call(this,this.shouldFormValueUpdate()?h(this,u,"f"):""),!this.validity.valid&&h(this,o,"f")&&v(this,t,!0,"f");let z=h(this,r,"m",k).call(this);this.validationMessageCallback&&this.validationMessageCallback(z?this.internals.validationMessage:"")}),V.set(this,()=>{var z;h(this,s,"f")&&this.validationTarget&&(this.internals.setValidity(this.validity,this.validationMessage,this.validationTarget),v(this,s,!1,"f")),v(this,o,!0,"f"),v(this,t,!0,"f"),h(this,r,"m",k).call(this),(z=this===null||this===void 0?void 0:this.validationMessageCallback)===null||z===void 0||z.call(this,this.showError?this.internals.validationMessage:"")}),w.set(this,void 0),E.set(this,!1),M.set(this,Promise.resolve()),(c=this.addEventListener)===null||c===void 0||c.call(this,"focus",h(this,b,"f")),(g=this.addEventListener)===null||g===void 0||g.call(this,"blur",h(this,p,"f")),(f=this.addEventListener)===null||f===void 0||f.call(this,"invalid",h(this,V,"f")),this.setValue(null)}static get formAssociated(){return!0}static get validators(){return this.formControlValidators||[]}static get observedAttributes(){let l=this.validators.map(f=>f.attribute).flat(),c=super.observedAttributes||[];return[...new Set([...c,...l])]}static getValidator(l){return this.validators.find(c=>c.attribute===l)||null}static getValidators(l){return this.validators.filter(c=>{var g;if(c.attribute===l||!((g=c.attribute)===null||g===void 0)&&g.includes(l))return!0})}get form(){return this.internals.form}get showError(){return h(this,r,"m",k).call(this)}checkValidity(){return this.internals.checkValidity()}get validity(){return this.internals.validity}get validationMessage(){return this.internals.validationMessage}attributeChangedCallback(l,c,g){var f;(f=super.attributeChangedCallback)===null||f===void 0||f.call(this,l,c,g);let $=this.constructor.getValidators(l);$!=null&&$.length&&this.validationTarget&&this.setValue(h(this,u,"f"))}setValue(l){var c;v(this,t,!1,"f"),(c=this.validationMessageCallback)===null||c===void 0||c.call(this,""),v(this,u,l,"f");let f=this.shouldFormValueUpdate()?l:null;this.internals.setFormValue(f),h(this,r,"m",A).call(this,f),this.valueChangedCallback&&this.valueChangedCallback(f),h(this,r,"m",k).call(this)}shouldFormValueUpdate(){return!0}get validationComplete(){return new Promise(l=>l(h(this,M,"f")))}formResetCallback(){var l,c;v(this,o,!1,"f"),v(this,t,!1,"f"),h(this,r,"m",k).call(this),(l=this.resetFormControl)===null||l===void 0||l.call(this),(c=this.validationMessageCallback)===null||c===void 0||c.call(this,h(this,r,"m",k).call(this)?this.validationMessage:"")}}return e=new WeakMap,t=new WeakMap,o=new WeakMap,i=new WeakMap,n=new WeakMap,s=new WeakMap,u=new WeakMap,b=new WeakMap,p=new WeakMap,V=new WeakMap,w=new WeakMap,E=new WeakMap,M=new WeakMap,r=new WeakSet,d=function(){let l=this.getRootNode(),c=`${this.localName}[name="${this.getAttribute("name")}"]`;return l.querySelectorAll(c)},k=function(){if(this.hasAttribute("disabled"))return!1;let l=h(this,t,"f")||h(this,o,"f")&&!this.validity.valid&&!h(this,e,"f");return l&&this.internals.states?this.internals.states.add("--show-error"):this.internals.states&&this.internals.states.delete("--show-error"),l},A=function(l){let c=this.constructor,g={},f=c.validators,z=[],$=f.some(C=>C.isValid instanceof Promise);h(this,E,"f")||(v(this,M,new Promise(C=>{v(this,w,C,"f")}),"f"),v(this,E,!0,"f")),h(this,i,"f")&&(h(this,i,"f").abort(),v(this,n,h(this,i,"f"),"f"));let Y=new AbortController;v(this,i,Y,"f");let H,le=!1;f.length&&(f.forEach(C=>{let Q=C.key||"customError",D=C.isValid(this,l,Y.signal);D instanceof Promise?(z.push(D),D.then(ee=>{ee!=null&&(g[Q]=!ee,H=h(this,r,"m",J).call(this,C,l),h(this,r,"m",P).call(this,g,H))})):(g[Q]=!D,this.validity[Q]!==!D&&(le=!0),!D&&!H&&(H=h(this,r,"m",J).call(this,C,l)))}),Promise.allSettled(z).then(()=>{var C;Y!=null&&Y.signal.aborted||(v(this,E,!1,"f"),(C=h(this,w,"f"))===null||C===void 0||C.call(this))}),(le||!$)&&h(this,r,"m",P).call(this,g,H))},P=function(l,c){if(this.validationTarget)this.internals.setValidity(l,c,this.validationTarget),v(this,s,!1,"f");else{if(this.internals.setValidity(l,c),this.internals.validity.valid)return;v(this,s,!0,"f")}},J=function(l,c){if(this.validityCallback){let g=this.validityCallback(l.key||"customError");if(g)return g}return l.message instanceof Function?l.message(this,c):l.message},Re}import{property as N,state as or}from"lit/decorators.js";import{ifDefined as ne}from"lit/directives/if-defined.js";import{html as Ge,LitElement as xe}from"lit";import{property as S}from"lit/decorators.js";import{css as me}from"lit";var fe=me`
|
|
10
10
|
*,
|
|
11
11
|
:before,
|
|
12
12
|
:after {
|
|
@@ -2615,12 +2615,12 @@ Please compile your catalog first.
|
|
|
2615
2615
|
border-color: var(--_border-color-disabled);
|
|
2616
2616
|
}
|
|
2617
2617
|
}
|
|
2618
|
-
`;var q,L,F,
|
|
2618
|
+
`;var q,L,F,_=class extends B(xe){constructor(){super();this.value=null;this.checked=!1;this.disabled=!1;this.required=!1;this.invalid=!1;U(this,q,!1);U(this,L,!1);U(this,F,!1);this.handleClick=()=>{this.isInGroup()||this.disabled||(T(this,F,!0),!this.checked&&(this.checked=!0,this.updateComplete.then(()=>{this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))})))};this.handleInvalid=()=>{T(this,F,!0),this.updateValidity()};this.handleKeyDown=e=>{var t,o;if(!this.isInGroup()&&!this.disabled&&!e.defaultPrevented){if(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(e.key)){let i=this.getStandaloneNamedRadios().filter(p=>!p.disabled);if(i.length<=1)return;e.preventDefault();let n=(o=(t=i.find(p=>p.checked))!=null?t:i.find(p=>p===this))!=null?o:i[0],s=e.key==="ArrowUp"||e.key==="ArrowLeft"?-1:1,u=(i.indexOf(n)+s+i.length)%i.length,b=i[u];T(b,F,!0),b.checked||(b.checked=!0,b.updateComplete.then(()=>{b.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))})),b.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",T(this,q,this.hasAttribute("checked")),this.checked=O(this,q),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=O(this,q),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 T(this,F,!0),this.updateValidity(),this.internals.checkValidity()}isInGroup(){return!!this.closest("w-radio-group")}getRadioScope(){var e,t;return(t=(e=this.internals.form)!=null?e:this.closest("form"))!=null?t:document}getStandaloneNamedRadios(){if(!this.name)return[this];let e=this.getRadioScope();return Array.from(e.querySelectorAll(`w-radio[name="${this.name}"]`)).filter(t=>!t.closest("w-radio-group"))}syncStandaloneTabOrder(){var n;let e=this.getStandaloneNamedRadios(),t=e.filter(s=>!s.disabled),o=t.find(s=>s.checked),i=(n=o!=null?o:t[0])!=null?n:null;e.forEach(s=>{s._standaloneTabIndex=s===i?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(o=>{o!==this&&(o.closest("w-radio-group")||o.checked&&(o.checked=!1))})}updateValidity(){if(this.disabled||this.isInGroup()){this.internals.setValidity({});return}let e=this.required&&!this.checked,t=this.invalid&&!O(this,L);if(e){T(this,L,!0),this.invalid=O(this,F),this.internals.setValidity({valueMissing:!0},this.internals.validationMessage||" ");return}if(O(this,L)&&(this.invalid=!1,T(this,L,!1)),t){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 Ge`
|
|
2619
2619
|
<div class="wrapper" tabindex="${this._internalTabIndex}">
|
|
2620
2620
|
<div part="control" class="control"></div>
|
|
2621
2621
|
<slot part="label" class="label"></slot>
|
|
2622
2622
|
</div>
|
|
2623
|
-
`}};q=new WeakMap,L=new WeakMap,F=new WeakMap,
|
|
2623
|
+
`}};q=new WeakMap,L=new WeakMap,F=new WeakMap,_.styles=[Z,fe,we],_.shadowRootOptions={...xe.shadowRootOptions,delegatesFocus:!0},m([S({reflect:!0})],_.prototype,"name",2),m([S({reflect:!0})],_.prototype,"value",2),m([S({type:Boolean,reflect:!0})],_.prototype,"checked",2),m([S({type:Boolean,reflect:!0})],_.prototype,"disabled",2),m([S({type:Boolean,reflect:!0})],_.prototype,"required",2),m([S({type:Boolean,reflect:!0})],_.prototype,"invalid",2),m([S({attribute:!1})],_.prototype,"_groupTabIndex",2),m([S({attribute:!1})],_.prototype,"_standaloneTabIndex",2);customElements.get("w-radio")||customElements.define("w-radio",_);var Ke=["en","nb","fi","da","sv"],se="en",G=a=>Ke.find(r=>a===r||a.toLowerCase().includes(r))||se;function _e(){if(typeof window=="undefined"){let a=process.env.NMP_LANGUAGE||Intl.DateTimeFormat().resolvedOptions().locale;return G(a)}try{let a=ye(document);if(a)return G(a);let r=rr();if(r)return G(r);let e=ye(ze());return e?G(e):se}catch(a){return console.warn("could not detect locale, falling back to source locale",a),se}}var Ce=(a,r,e,t,o)=>{y.load("en",a),y.load("nb",r),y.load("fi",e),y.load("da",t),y.load("sv",o);let i=_e();y.activate(i),Ee(),Qe()},Je="warp-i18n-change";function Ee(){typeof window!="undefined"&&window.dispatchEvent(new Event(Je))}var ke=!1;function Qe(){if(ke||typeof window=="undefined"||!(document!=null&&document.documentElement))return;ke=!0;let a=()=>{let o=_e();y.locale!==o&&(y.activate(o),Ee())},r=new MutationObserver(o=>{for(let i of o)if(i.type==="attributes"&&i.attributeName==="lang"){a();break}});r.observe(document.documentElement,{attributes:!0,attributeFilter:["lang"]});let e=ze();e&&e.documentElement&&e!==document&&r.observe(e.documentElement,{attributes:!0,attributeFilter:["lang"]});let t=er();t&&r.observe(t,{attributes:!0,attributeFilter:["lang"]})}function ze(){var a,r;try{return(r=(a=window.parent)==null?void 0:a.document)!=null?r:null}catch(e){return null}}function ye(a){var r,e;try{return(e=(r=a==null?void 0:a.documentElement)==null?void 0:r.lang)!=null?e:""}catch(t){return""}}function er(){var a;try{return(a=window.frameElement)!=null?a:null}catch(r){return null}}function rr(){var a,r,e;try{return(e=(r=(a=window.frameElement)==null?void 0:a.getAttribute)==null?void 0:r.call(a,"lang"))!=null?e:""}catch(t){return""}}var Ve=JSON.parse('{"radio-group.label.optional":["Valgfri"],"radio-group.validation.required":["V\xE6lg en mulighed."]}');var Me=JSON.parse('{"radio-group.label.optional":["Optional"],"radio-group.validation.required":["Please select an option."]}');var Te=JSON.parse('{"radio-group.label.optional":["Valinnainen"],"radio-group.validation.required":["Valitse vaihtoehto."]}');var Ie=JSON.parse('{"radio-group.label.optional":["Valgfri"],"radio-group.validation.required":["Velg et alternativ."]}');var Se=JSON.parse('{"radio-group.label.optional":["Valfritt"],"radio-group.validation.required":["V\xE4lj ett alternativ."]}');import{css as tr}from"lit";var Fe=tr`
|
|
2624
2624
|
:host {
|
|
2625
2625
|
display: block;
|
|
2626
2626
|
|
|
@@ -2708,7 +2708,7 @@ Please compile your catalog first.
|
|
|
2708
2708
|
:host([data-show-error]) [part~='help-text'] {
|
|
2709
2709
|
color: var(--_help-text-color-error);
|
|
2710
2710
|
}
|
|
2711
|
-
`;Ce(Me,
|
|
2711
|
+
`;Ce(Me,Ie,Te,Ve,Se);var ar=()=>y._({id:"radio-group.validation.required",message:"Please select an option.",comment:"Shown when required radio group has no selections"}),x=class extends B(Ae){constructor(){super();this.hasInteracted=!1;this.hasWarnedMissingName=!1;this.autoTabIndex=!1;this.label="";this.helpText="";this.optional=!1;this.invalid=!1;this.name=null;this.disabled=!1;this.required=!1;this.defaultCheckedValue=void 0;this.slottedHelpText=null;this.nameManagedRadios=new WeakSet;this.disabledManagedRadios=new WeakSet;this.handleRadioClick=e=>{let t=e.target.closest("w-radio");if(!t||t.disabled||this.disabled)return;let o=this.getCheckedValue(),i=this.getAllRadios();this.selectSingleRadio(t,i),this.getCheckedValue()!==o&&this.updateComplete.then(this.emitSelectionChange)};this.handleInvalid=e=>{e.preventDefault(),this.hasInteracted=!0,this.updateValidity()};this.handleHelpTextSlotChange=()=>{this.syncSlottedHelpText(),this.requestUpdate()};this.handleI18nChange=()=>{this.requestUpdate()};this.emitSelectionChange=()=>{this.hasInteracted=!0,this.syncFormValue(),this.updateValidity(),this.requestUpdate(),this.dispatchEvent(new InputEvent("input",{bubbles:!0,composed:!0})),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))};this.captureDefaultSelection=()=>{this.defaultCheckedValue===void 0&&(this.defaultCheckedValue=this.getCheckedValue())};this.addEventListener("keydown",this.handleKeyDown),this.addEventListener("click",this.handleRadioClick),this.addEventListener("invalid",this.handleInvalid)}get validationTarget(){let e=this.querySelector(":is(w-radio):not([disabled])");return e!=null?e:void 0}connectedCallback(){super.connectedCallback(),this.syncSlottedHelpText(),this.syncFormValue(),this.updateValidity(),this.unsubscribeI18n=y.on("change",this.handleI18nChange),this.warnIfMissingName(),this.updateComplete.then(this.captureDefaultSelection)}disconnectedCallback(){var e;(e=this.unsubscribeI18n)==null||e.call(this),this.unsubscribeI18n=void 0,super.disconnectedCallback()}async updated(e){(e.has("disabled")||e.has("name")||e.has("required")||e.has("invalid")||e.has("helpText"))&&(this.syncFormValue(),this.updateValidity(),this.syncRadioElements(),this.syncFormValue(),this.updateValidity())}resetFormControl(){var t;let e=(t=this.defaultCheckedValue)!=null?t:null;this.getAllRadios().forEach(o=>{o.checked=e?o.value===e:!1}),this.syncRadioElements(),this.syncFormValue(),this.updateValidity()}getAllRadios(){return[...this.querySelectorAll("w-radio")]}getCheckedValue(){var t;let e=this.getAllRadios().find(o=>o.checked);return(t=e==null?void 0:e.value)!=null?t:null}getEnabledRadios(e=this.getAllRadios()){return e.filter(t=>!t.disabled)}selectSingleRadio(e,t=this.getAllRadios()){t.forEach(o=>{let i=o===e;o.checked=i,o._groupTabIndex=i?0:-1})}handleLabelClick(){this.focus()}async syncRadioElements(){let e=this.getAllRadios();e.forEach((t,o)=>{t.toggleAttribute("data-w-radio-first",o===0),t.toggleAttribute("data-w-radio-inner",o!==0&&o!==e.length-1),t.toggleAttribute("data-w-radio-last",o===e.length-1),this.syncRadioDisabledState(t),this.name?(!t.getAttribute("name")||this.nameManagedRadios.has(t))&&(t.setAttribute("name",this.name),this.nameManagedRadios.add(t)):this.nameManagedRadios.has(t)&&(t.removeAttribute("name"),this.nameManagedRadios.delete(t))}),await Promise.all(e.map(async t=>t.updateComplete)),this.normalizeCheckedRadios(e),this.syncTabOrder(e)}syncRadioDisabledState(e){if(this.disabled){e.disabled||(e.disabled=!0,this.disabledManagedRadios.add(e));return}this.disabledManagedRadios.has(e)&&(e.disabled=!1,this.disabledManagedRadios.delete(e))}syncTabOrder(e){if(this.disabled){e.forEach(i=>i._groupTabIndex=-1);return}let t=this.getEnabledRadios(e),o=t.find(i=>i.checked);t.length>0&&(o?t.forEach(i=>i._groupTabIndex=i.checked?0:-1):t.forEach((i,n)=>i._groupTabIndex=n===0?0:-1)),e.filter(i=>i.disabled).forEach(i=>i._groupTabIndex=-1)}handleKeyDown(e){var b;if(!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"," "].includes(e.key)||this.disabled)return;let t=this.getAllRadios(),o=this.getEnabledRadios(t);if(o.length<=0)return;e.preventDefault();let i=this.getCheckedValue(),n=(b=o.find(p=>p.checked))!=null?b:o[0],s=e.key===" "?0:["ArrowUp","ArrowLeft"].includes(e.key)?-1:1,d=o.indexOf(n)+s;d<0&&(d=o.length-1),d>=o.length&&(d=0),this.selectSingleRadio(o[d],t),o[d].focus(),this.getCheckedValue()!==i&&this.updateComplete.then(this.emitSelectionChange)}focus(e){if(this.disabled)return;let t=this.getAllRadios(),o=t.find(s=>s.checked),i=t.find(s=>!s.disabled),n=o||i;n&&n.focus(e)}checkValidity(){return this.updateValidity(),this.internals.checkValidity()}reportValidity(){return this.hasInteracted=!0,this.updateValidity(),this.internals.checkValidity()}hasSlottedContent(e){var o;if(this.querySelector(`[slot="${e}"]`))return!0;let t=(o=this.shadowRoot)==null?void 0:o.querySelector(`slot[name="${e}"]`);return t?t.assignedNodes({flatten:!0}).some(i=>{var n;return i.nodeType===Node.ELEMENT_NODE?!0:i.nodeType===Node.TEXT_NODE?!!((n=i.textContent)!=null&&n.trim()):!1}):!1}syncFormValue(){this.setValue(null)}syncSlottedHelpText(){var t;let e=this.querySelector('[slot="help-text"]');this.slottedHelpText=((t=e==null?void 0:e.textContent)==null?void 0:t.trim())||null}updateValidity(){this.warnIfMissingName();let e=this.required&&!this.getCheckedValue(),t=e&&this.hasInteracted,o=this.invalid||this.hasAttribute("invalid"),i=o||t;if(this.toggleAttribute("data-show-error",i),this.disabled){this.internals.setValidity({}),this.syncChildInvalid(!1),this.syncHostTabIndex(!1);return}if(this.syncHostTabIndex(i),e){this.setValidityState({valueMissing:!0}),this.syncChildInvalid(i);return}if(o){this.setValidityState({customError:!0}),this.syncChildInvalid(!0);return}this.internals.setValidity({}),this.syncChildInvalid(!1)}normalizeCheckedRadios(e){let t=e.find(o=>o.checked);t&&e.forEach(o=>{o!==t&&(o.checked=!1)})}syncChildInvalid(e){this.getAllRadios().forEach(t=>{t.invalid=e})}setValidityState(e){let t=this.validationTarget;this.internals.setValidity(e," ",t!=null?t:void 0)}syncHostTabIndex(e){if(!(this.hasAttribute("tabindex")&&!this.autoTabIndex)){if(e){this.setAttribute("tabindex","0"),this.autoTabIndex=!0;return}this.autoTabIndex&&(this.removeAttribute("tabindex"),this.autoTabIndex=!1)}}warnIfMissingName(){this.hasWarnedMissingName||this.internals.form&&(this.name&&this.name.trim().length>0||(console.warn('w-radio-group: "name" is required for form submission.'),this.hasWarnedMissingName=!0))}render(){let e=this.hasSlottedContent("label"),t=this.hasSlottedContent("help-text"),o=this.label?!0:!!e,i=this.helpText?!0:!!t,s=this.required&&!this.getCheckedValue()&&this.hasInteracted,d=this.invalid||this.hasAttribute("invalid"),u=d||s,b=u?d&&this.helpText?this.helpText:ar():this.helpText,p=u||i,V=o?"label":void 0,w=p?"help-text":void 0,E=this.slottedHelpText||void 0;return K`
|
|
2712
2712
|
<fieldset
|
|
2713
2713
|
part="form-control"
|
|
2714
2714
|
role="radiogroup"
|
|
@@ -2720,7 +2720,7 @@ Please compile your catalog first.
|
|
|
2720
2720
|
<label part="form-control-label" id="label" @click=${this.handleLabelClick}>
|
|
2721
2721
|
<slot name="label">${this.label}</slot>
|
|
2722
2722
|
${this.optional?K`<span class="optional">
|
|
2723
|
-
${
|
|
2723
|
+
${y._({id:"radio-group.label.optional",message:"Optional",comment:"Shown behind label when marked as optional"})}
|
|
2724
2724
|
</span>`:null}
|
|
2725
2725
|
</label>
|
|
2726
2726
|
`:null}
|
|
@@ -2733,5 +2733,5 @@ Please compile your catalog first.
|
|
|
2733
2733
|
</div>
|
|
2734
2734
|
`:null}
|
|
2735
2735
|
</fieldset>
|
|
2736
|
-
`}};
|
|
2736
|
+
`}};x.styles=[Z,Fe],x.shadowRootOptions={...Ae.shadowRootOptions,delegatesFocus:!0},m([or()],x.prototype,"hasInteracted",2),m([N()],x.prototype,"label",2),m([N({attribute:"help-text"})],x.prototype,"helpText",2),m([N({type:Boolean,reflect:!0})],x.prototype,"optional",2),m([N({type:Boolean,reflect:!0})],x.prototype,"invalid",2),m([N({reflect:!0})],x.prototype,"name",2),m([N({type:Boolean,reflect:!0})],x.prototype,"disabled",2),m([N({type:Boolean,reflect:!0})],x.prototype,"required",2);var Br=x;customElements.get("w-radio-group")||customElements.define("w-radio-group",x);export{Br as WRadioGroup,x as WarpRadioGroup};
|
|
2737
2737
|
//# sourceMappingURL=radio-group.js.map
|