@warp-ds/elements 2.8.0-next.3 → 2.8.0-next.4
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 +6 -0
- package/dist/packages/combobox/combobox.a11y.test.d.ts +2 -0
- package/dist/packages/combobox/combobox.a11y.test.js +53 -0
- package/dist/packages/combobox/combobox.js +10 -8
- package/dist/packages/combobox/combobox.js.map +3 -3
- package/dist/packages/combobox/combobox.react.stories.d.ts +1 -1
- package/dist/packages/combobox/combobox.test.js +22 -0
- package/dist/packages/combobox/locales/da/messages.mjs +1 -1
- package/dist/packages/combobox/locales/en/messages.mjs +1 -1
- package/dist/packages/combobox/locales/fi/messages.mjs +1 -1
- package/dist/packages/combobox/locales/nb/messages.mjs +1 -1
- package/dist/packages/combobox/locales/sv/messages.mjs +1 -1
- package/dist/packages/textfield/textfield.react.stories.d.ts +1 -1
- package/dist/web-types.json +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { html } from 'lit';
|
|
2
|
+
import { describe, expect, test } from 'vitest';
|
|
3
|
+
import { render } from 'vitest-browser-lit';
|
|
4
|
+
import '../textfield/textfield.js';
|
|
5
|
+
import './combobox.js';
|
|
6
|
+
describe('w-combobox accessibility (WCAG 2.2)', () => {
|
|
7
|
+
describe('axe-core automated checks', () => {
|
|
8
|
+
const sampleOptions = [
|
|
9
|
+
{ value: 'apple', label: 'Apple' },
|
|
10
|
+
{ value: 'banana', label: 'Banana' },
|
|
11
|
+
{ value: 'orange', label: 'Orange' },
|
|
12
|
+
];
|
|
13
|
+
test('default state has no violations', async () => {
|
|
14
|
+
const page = render(html `<w-combobox label="Select a fruit" .options="${sampleOptions}"></w-combobox>`);
|
|
15
|
+
await expect(page).toHaveNoAxeViolations();
|
|
16
|
+
});
|
|
17
|
+
test('with help text has no violations', async () => {
|
|
18
|
+
const page = render(html `
|
|
19
|
+
<w-combobox
|
|
20
|
+
label="Select a fruit"
|
|
21
|
+
help-text="Start typing to filter options"
|
|
22
|
+
.options="${sampleOptions}"></w-combobox>
|
|
23
|
+
`);
|
|
24
|
+
await expect(page).toHaveNoAxeViolations();
|
|
25
|
+
});
|
|
26
|
+
test('invalid state has no violations', async () => {
|
|
27
|
+
const page = render(html `
|
|
28
|
+
<w-combobox
|
|
29
|
+
label="Select a fruit"
|
|
30
|
+
invalid
|
|
31
|
+
help-text="Please select a valid option"
|
|
32
|
+
.options="${sampleOptions}"></w-combobox>
|
|
33
|
+
`);
|
|
34
|
+
await expect(page).toHaveNoAxeViolations();
|
|
35
|
+
});
|
|
36
|
+
test('disabled state has no violations', async () => {
|
|
37
|
+
const page = render(html `<w-combobox label="Select a fruit" disabled .options="${sampleOptions}"></w-combobox>`);
|
|
38
|
+
await expect(page).toHaveNoAxeViolations();
|
|
39
|
+
});
|
|
40
|
+
test('required state has no violations', async () => {
|
|
41
|
+
const page = render(html `<w-combobox label="Select a fruit" required .options="${sampleOptions}"></w-combobox>`);
|
|
42
|
+
await expect(page).toHaveNoAxeViolations();
|
|
43
|
+
});
|
|
44
|
+
test('optional state has no violations', async () => {
|
|
45
|
+
const page = render(html `<w-combobox label="Select a fruit" optional .options="${sampleOptions}"></w-combobox>`);
|
|
46
|
+
await expect(page).toHaveNoAxeViolations();
|
|
47
|
+
});
|
|
48
|
+
test('open on focus state has no violations', async () => {
|
|
49
|
+
const page = render(html `<w-combobox label="Select a fruit" open-on-focus .options="${sampleOptions}"></w-combobox>`);
|
|
50
|
+
await expect(page).toHaveNoAxeViolations();
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var je=Object.create;var Q=Object.defineProperty;var le=Object.getOwnPropertyDescriptor;var Ue=Object.getOwnPropertyNames;var Ye=Object.getPrototypeOf,Be=Object.prototype.hasOwnProperty;var ce=o=>{throw TypeError(o)};var de=(o,r)=>()=>(r||o((r={exports:{}}).exports,r),r.exports);var qe=(o,r,e,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of Ue(r))!Be.call(o,a)&&a!==e&&Q(o,a,{get:()=>r[a],enumerable:!(t=le(r,a))||t.enumerable});return o};var He=(o,r,e)=>(e=o!=null?je(Ye(o)):{},qe(r||!o||!o.__esModule?Q(e,"default",{value:o,enumerable:!0}):e,o));var p=(o,r,e,t)=>{for(var a=t>1?void 0:t?le(r,e):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(a=(t?s(r,e,a):s(a))||a);return t&&a&&Q(r,e,a),a};var ue=(o,r,e)=>r.has(o)||ce("Cannot "+e);var he=(o,r,e)=>(ue(o,r,"read from private field"),e?e.call(o):r.get(o)),pe=(o,r,e)=>r.has(o)?ce("Cannot add the same private member more than once"):r instanceof WeakSet?r.add(o):r.set(o,e),
|
|
2
|
-
`],["r","\r"],["t"," "],["v","\v"],["0","\0"]]);function Qe(o){return We.get(o)||o}var er=/\\(?:(\\)|x([\s\S]{0,2})|u(\{[^}]*\}?)|u([\s\S]{4})\\u([^{][\s\S]{0,3})|u([\s\S]{0,4})|([0-3]?[0-7]{1,2})|([\s\S])|$)/g;function me(o,r=!1){return o.replace(er,function(e,t,a,i,s,n,c,v,O){if(t!==void 0)return"\\";if(a!==void 0)return Ze(a);if(i!==void 0)return Ge(i);if(s!==void 0)return ve(s,n);if(c!==void 0)return ve(c);if(v==="0")return"\0";if(v!==void 0)return Je(v,!r);if(O!==void 0)return Qe(O);throw new SyntaxError(f.errorMessages.get(f.ErrorType.EndOfString))})}M.unraw=me;M.default=me});var Y=function(){for(var o=[],r=arguments.length;r--;)o[r]=arguments[r];return o.reduce(function(e,t){return e.concat(typeof t=="string"?t:Array.isArray(t)?Y.apply(void 0,t):typeof t=="object"&&t?Object.keys(t).map(function(a){return t[a]?a:""}):"")},[]).join(" ")};var ke=He(fe(),1);var
|
|
1
|
+
var je=Object.create;var Q=Object.defineProperty;var le=Object.getOwnPropertyDescriptor;var Ue=Object.getOwnPropertyNames;var Ye=Object.getPrototypeOf,Be=Object.prototype.hasOwnProperty;var ce=o=>{throw TypeError(o)};var de=(o,r)=>()=>(r||o((r={exports:{}}).exports,r),r.exports);var qe=(o,r,e,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of Ue(r))!Be.call(o,a)&&a!==e&&Q(o,a,{get:()=>r[a],enumerable:!(t=le(r,a))||t.enumerable});return o};var He=(o,r,e)=>(e=o!=null?je(Ye(o)):{},qe(r||!o||!o.__esModule?Q(e,"default",{value:o,enumerable:!0}):e,o));var p=(o,r,e,t)=>{for(var a=t>1?void 0:t?le(r,e):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(a=(t?s(r,e,a):s(a))||a);return t&&a&&Q(r,e,a),a};var ue=(o,r,e)=>r.has(o)||ce("Cannot "+e);var he=(o,r,e)=>(ue(o,r,"read from private field"),e?e.call(o):r.get(o)),pe=(o,r,e)=>r.has(o)?ce("Cannot add the same private member more than once"):r instanceof WeakSet?r.add(o):r.set(o,e),ge=(o,r,e,t)=>(ue(o,r,"write to private field"),t?t.call(o,e):r.set(o,e),e);var be=de(L=>{"use strict";Object.defineProperty(L,"__esModule",{value:!0});L.errorMessages=L.ErrorType=void 0;var D;(function(o){o.MalformedUnicode="MALFORMED_UNICODE",o.MalformedHexadecimal="MALFORMED_HEXADECIMAL",o.CodePointLimit="CODE_POINT_LIMIT",o.OctalDeprecation="OCTAL_DEPRECATION",o.EndOfString="END_OF_STRING"})(D=L.ErrorType||(L.ErrorType={}));L.errorMessages=new Map([[D.MalformedUnicode,"malformed Unicode character escape sequence"],[D.MalformedHexadecimal,"malformed hexadecimal character escape sequence"],[D.CodePointLimit,"Unicode codepoint must not be greater than 0x10FFFF in escape sequence"],[D.OctalDeprecation,'"0"-prefixed octal literals and octal escape sequences are deprecated; for octal literals use the "0o" prefix instead'],[D.EndOfString,"malformed escape sequence at end of string"]])});var fe=de(M=>{"use strict";Object.defineProperty(M,"__esModule",{value:!0});M.unraw=M.errorMessages=M.ErrorType=void 0;var f=be();Object.defineProperty(M,"ErrorType",{enumerable:!0,get:function(){return f.ErrorType}});Object.defineProperty(M,"errorMessages",{enumerable:!0,get:function(){return f.errorMessages}});function Xe(o){return!o.match(/[^a-f0-9]/i)?parseInt(o,16):NaN}function H(o,r,e){let t=Xe(o);if(Number.isNaN(t)||e!==void 0&&e!==o.length)throw new SyntaxError(f.errorMessages.get(r));return t}function Ze(o){let r=H(o,f.ErrorType.MalformedHexadecimal,2);return String.fromCharCode(r)}function ve(o,r){let e=H(o,f.ErrorType.MalformedUnicode,4);if(r!==void 0){let t=H(r,f.ErrorType.MalformedUnicode,4);return String.fromCharCode(e,t)}return String.fromCharCode(e)}function Ke(o){return o.charAt(0)==="{"&&o.charAt(o.length-1)==="}"}function Ge(o){if(!Ke(o))throw new SyntaxError(f.errorMessages.get(f.ErrorType.MalformedUnicode));let r=o.slice(1,-1),e=H(r,f.ErrorType.MalformedUnicode);try{return String.fromCodePoint(e)}catch(t){throw t instanceof RangeError?new SyntaxError(f.errorMessages.get(f.ErrorType.CodePointLimit)):t}}function Je(o,r=!1){if(r)throw new SyntaxError(f.errorMessages.get(f.ErrorType.OctalDeprecation));let e=parseInt(o,8);return String.fromCharCode(e)}var We=new Map([["b","\b"],["f","\f"],["n",`
|
|
2
|
+
`],["r","\r"],["t"," "],["v","\v"],["0","\0"]]);function Qe(o){return We.get(o)||o}var er=/\\(?:(\\)|x([\s\S]{0,2})|u(\{[^}]*\}?)|u([\s\S]{4})\\u([^{][\s\S]{0,3})|u([\s\S]{0,4})|([0-3]?[0-7]{1,2})|([\s\S])|$)/g;function me(o,r=!1){return o.replace(er,function(e,t,a,i,s,n,c,v,O){if(t!==void 0)return"\\";if(a!==void 0)return Ze(a);if(i!==void 0)return Ge(i);if(s!==void 0)return ve(s,n);if(c!==void 0)return ve(c);if(v==="0")return"\0";if(v!==void 0)return Je(v,!r);if(O!==void 0)return Qe(O);throw new SyntaxError(f.errorMessages.get(f.ErrorType.EndOfString))})}M.unraw=me;M.default=me});var Y=function(){for(var o=[],r=arguments.length;r--;)o[r]=arguments[r];return o.reduce(function(e,t){return e.concat(typeof t=="string"?t:Array.isArray(t)?Y.apply(void 0,t):typeof t=="object"&&t?Object.keys(t).map(function(a){return t[a]?a:""}):"")},[]).join(" ")};var ke=He(fe(),1);var F=o=>typeof o=="string",rr=o=>typeof o=="function",we=new Map,ye="en";function oe(o){return[...Array.isArray(o)?o:[o],ye]}function ae(o,r,e){let t=oe(o);e||(e="default");let a;if(typeof e=="string")switch(a={day:"numeric",month:"short",year:"numeric"},e){case"full":a.weekday="long";case"long":a.month="long";break;case"short":a.month="numeric";break}else a=e;return X(()=>Z("date",t,e),()=>new Intl.DateTimeFormat(t,a)).format(F(r)?new Date(r):r)}function tr(o,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 ae(o,r,t)}function ee(o,r,e){let t=oe(o);return X(()=>Z("number",t,e),()=>new Intl.NumberFormat(t,e)).format(r)}function xe(o,r,e,{offset:t=0,...a}){var n,c;let i=oe(o),s=r?X(()=>Z("plural-ordinal",i),()=>new Intl.PluralRules(i,{type:"ordinal"})):X(()=>Z("plural-cardinal",i),()=>new Intl.PluralRules(i,{type:"cardinal"}));return(c=(n=a[e])!=null?n:a[s.select(e-t)])!=null?c:a.other}function X(o,r){let e=o(),t=we.get(e);return t||(t=r(),we.set(e,t)),t}function Z(o,r,e){let t=r.join("-");return`${o}-${t}-${JSON.stringify(e)}`}var _e=/\\u[a-fA-F0-9]{4}|\\x[a-fA-F0-9]{2}/,Oe="%__lingui_octothorpe__%",or=(o,r,e={})=>{let t=r||o,a=s=>typeof s=="object"?s:e[s],i=(s,n)=>{let c=Object.keys(e).length?a("number"):void 0,v=ee(t,s,c);return n.replace(new RegExp(Oe,"g"),v)};return{plural:(s,n)=>{let{offset:c=0}=n,v=xe(t,!1,s,n);return i(s-c,v)},selectordinal:(s,n)=>{let{offset:c=0}=n,v=xe(t,!0,s,n);return i(s-c,v)},select:ar,number:(s,n)=>ee(t,s,a(n)||{style:n}),date:(s,n)=>ae(t,s,a(n)||n),time:(s,n)=>tr(t,s,a(n)||n)}},ar=(o,r)=>{var e;return(e=r[o])!=null?e:r.other};function ir(o,r,e){return(t={},a)=>{let i=or(r,e,a),s=(c,v=!1)=>Array.isArray(c)?c.reduce((O,E)=>{if(E==="#"&&v)return O+Oe;if(F(E))return O+E;let[T,k,z]=E,S={};k==="plural"||k==="selectordinal"||k==="select"?Object.entries(z).forEach(([I,N])=>{S[I]=s(N,k==="plural"||k==="selectordinal")}):S=z;let x;if(k){let I=i[k];x=I(t[T],S)}else x=t[T];return x==null?O:O+x},""):c,n=s(o);return F(n)&&_e.test(n)?(0,ke.unraw)(n):F(n)?n:n?String(n):""}}var nr=Object.defineProperty,sr=(o,r,e)=>r in o?nr(o,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[r]=e,lr=(o,r,e)=>(sr(o,typeof r!="symbol"?r+"":r,e),e),re=class{constructor(){lr(this,"_events",{})}on(r,e){var a;var t;return(a=(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 a=t.indexOf(e);~a&&t.splice(a,1)}emit(r,...e){let t=this._getListeners(r);t&&t.map(a=>a.apply(this,e))}_getListeners(r){let e=this._events[r];return Array.isArray(e)?e:!1}},cr=Object.defineProperty,dr=(o,r,e)=>r in o?cr(o,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[r]=e,V=(o,r,e)=>(dr(o,typeof r!="symbol"?r+"":r,e),e),te=class extends re{constructor(r){var e;super(),V(this,"_locale",""),V(this,"_locales"),V(this,"_localeData",{}),V(this,"_messages",{}),V(this,"_missing"),V(this,"_messageCompiler"),V(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:ye,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,a])=>this._load(t,a)),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 a=t==null?void 0:t.message;r||(r=""),F(r)||(e=r.values||e,a=r.message,r=r.id);let i=this.messages[r],s=i===void 0,n=this._missing;if(n&&s)return rr(n)?n(this._locale,r):n;s&&this.emit("missing",{id:r,locale:this._locale});let c=i||a||r;return F(c)&&(this._messageCompiler?c=this._messageCompiler(c):console.warn(`Uncompiled message detected! Message:
|
|
3
3
|
|
|
4
4
|
> ${c}
|
|
5
5
|
|
|
@@ -7,7 +7,7 @@ That means you use raw catalog or your catalog doesn't have a translation for th
|
|
|
7
7
|
ICU features such as interpolation and plurals will not work properly for that message.
|
|
8
8
|
|
|
9
9
|
Please compile your catalog first.
|
|
10
|
-
`)),
|
|
10
|
+
`)),F(c)&&_e.test(c)?JSON.parse(`"${c}"`):F(c)?c:ir(c,this._locale,this._locales)(e,t==null?void 0:t.formats)}date(r,e){return ae(this._locales||this._locale,r,e)}number(r,e){return ee(this._locales||this._locale,r,e)}};function ur(o={}){return new te(o)}var _=ur();var u=function(o,r,e,t){if(e==="a"&&!t)throw new TypeError("Private accessor was defined without a getter");if(typeof r=="function"?o!==r||!t:!r.has(o))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?t:e==="a"?t.call(o):t?t.value:r.get(o)},b=function(o,r,e,t,a){if(t==="m")throw new TypeError("Private method is not writable");if(t==="a"&&!a)throw new TypeError("Private accessor was defined without a setter");if(typeof r=="function"?o!==r||!a:!r.has(o))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t==="a"?a.call(o,e):a?a.value=e:r.set(o,e),e};function Ce(o){var r,e,t,a,i,s,n,c,v,O,E,T,k,z,S,x,I,N,G;class Re extends o{constructor(...l){var d,g,m;super(...l),r.add(this),this.internals=this.attachInternals(),e.set(this,!1),t.set(this,!1),a.set(this,!1),i.set(this,void 0),s.set(this,void 0),n.set(this,!0),v.set(this,""),O.set(this,()=>{b(this,a,!0,"f"),b(this,e,!0,"f"),u(this,r,"m",x).call(this)}),E.set(this,()=>{b(this,e,!1,"f"),u(this,r,"m",I).call(this,this.shouldFormValueUpdate()?u(this,v,"f"):""),!this.validity.valid&&u(this,a,"f")&&b(this,t,!0,"f");let C=u(this,r,"m",x).call(this);this.validationMessageCallback&&this.validationMessageCallback(C?this.internals.validationMessage:"")}),T.set(this,()=>{var C;u(this,n,"f")&&this.validationTarget&&(this.internals.setValidity(this.validity,this.validationMessage,this.validationTarget),b(this,n,!1,"f")),b(this,a,!0,"f"),b(this,t,!0,"f"),u(this,r,"m",x).call(this),(C=this===null||this===void 0?void 0:this.validationMessageCallback)===null||C===void 0||C.call(this,this.showError?this.internals.validationMessage:"")}),k.set(this,void 0),z.set(this,!1),S.set(this,Promise.resolve()),(d=this.addEventListener)===null||d===void 0||d.call(this,"focus",u(this,O,"f")),(g=this.addEventListener)===null||g===void 0||g.call(this,"blur",u(this,E,"f")),(m=this.addEventListener)===null||m===void 0||m.call(this,"invalid",u(this,T,"f")),this.setValue(null)}static get formAssociated(){return!0}static get validators(){return this.formControlValidators||[]}static get observedAttributes(){let l=this.validators.map(m=>m.attribute).flat(),d=super.observedAttributes||[];return[...new Set([...d,...l])]}static getValidator(l){return this.validators.find(d=>d.attribute===l)||null}static getValidators(l){return this.validators.filter(d=>{var g;if(d.attribute===l||!((g=d.attribute)===null||g===void 0)&&g.includes(l))return!0})}get form(){return this.internals.form}get showError(){return u(this,r,"m",x).call(this)}checkValidity(){return this.internals.checkValidity()}get validity(){return this.internals.validity}get validationMessage(){return this.internals.validationMessage}attributeChangedCallback(l,d,g){var m;(m=super.attributeChangedCallback)===null||m===void 0||m.call(this,l,d,g);let R=this.constructor.getValidators(l);R!=null&&R.length&&this.validationTarget&&this.setValue(u(this,v,"f"))}setValue(l){var d;b(this,t,!1,"f"),(d=this.validationMessageCallback)===null||d===void 0||d.call(this,""),b(this,v,l,"f");let m=this.shouldFormValueUpdate()?l:null;this.internals.setFormValue(m),u(this,r,"m",I).call(this,m),this.valueChangedCallback&&this.valueChangedCallback(m),u(this,r,"m",x).call(this)}shouldFormValueUpdate(){return!0}get validationComplete(){return new Promise(l=>l(u(this,S,"f")))}formResetCallback(){var l,d;b(this,a,!1,"f"),b(this,t,!1,"f"),u(this,r,"m",x).call(this),(l=this.resetFormControl)===null||l===void 0||l.call(this),(d=this.validationMessageCallback)===null||d===void 0||d.call(this,u(this,r,"m",x).call(this)?this.validationMessage:"")}}return e=new WeakMap,t=new WeakMap,a=new WeakMap,i=new WeakMap,s=new WeakMap,n=new WeakMap,v=new WeakMap,O=new WeakMap,E=new WeakMap,T=new WeakMap,k=new WeakMap,z=new WeakMap,S=new WeakMap,r=new WeakSet,c=function(){let l=this.getRootNode(),d=`${this.localName}[name="${this.getAttribute("name")}"]`;return l.querySelectorAll(d)},x=function(){if(this.hasAttribute("disabled"))return!1;let l=u(this,t,"f")||u(this,a,"f")&&!this.validity.valid&&!u(this,e,"f");return l&&this.internals.states?this.internals.states.add("--show-error"):this.internals.states&&this.internals.states.delete("--show-error"),l},I=function(l){let d=this.constructor,g={},m=d.validators,C=[],R=m.some(y=>y.isValid instanceof Promise);u(this,z,"f")||(b(this,S,new Promise(y=>{b(this,k,y,"f")}),"f"),b(this,z,!0,"f")),u(this,i,"f")&&(u(this,i,"f").abort(),b(this,s,u(this,i,"f"),"f"));let j=new AbortController;b(this,i,j,"f");let U,se=!1;m.length&&(m.forEach(y=>{let J=y.key||"customError",$=y.isValid(this,l,j.signal);$ instanceof Promise?(C.push($),$.then(W=>{W!=null&&(g[J]=!W,U=u(this,r,"m",G).call(this,y,l),u(this,r,"m",N).call(this,g,U))})):(g[J]=!$,this.validity[J]!==!$&&(se=!0),!$&&!U&&(U=u(this,r,"m",G).call(this,y,l)))}),Promise.allSettled(C).then(()=>{var y;j!=null&&j.signal.aborted||(b(this,z,!1,"f"),(y=u(this,k,"f"))===null||y===void 0||y.call(this))}),(se||!R)&&u(this,r,"m",N).call(this,g,U))},N=function(l,d){if(this.validationTarget)this.internals.setValidity(l,d,this.validationTarget),b(this,n,!1,"f");else{if(this.internals.setValidity(l,d),this.internals.validity.valid)return;b(this,n,!0,"f")}},G=function(l,d){if(this.validityCallback){let g=this.validityCallback(l.key||"customError");if(g)return g}return l.message instanceof Function?l.message(this,d):l.message},Re}import{html as ne,LitElement as fr}from"lit";import{property as w,state as B}from"lit/decorators.js";import{repeat as wr}from"lit/directives/repeat.js";var hr=["en","nb","fi","da","sv"],ie="en",K=o=>hr.find(r=>o===r||o.toLowerCase().includes(r))||ie;function ze(){if(typeof window=="undefined"){let o=process.env.NMP_LANGUAGE||Intl.DateTimeFormat().resolvedOptions().locale;return K(o)}try{let o=Ee(document);if(o)return K(o);let r=vr();if(r)return K(r);let e=Ee(Ae());return e?K(e):ie}catch(o){return console.warn("could not detect locale, falling back to source locale",o),ie}}var Se=(o,r,e,t,a)=>{_.load("en",o),_.load("nb",r),_.load("fi",e),_.load("da",t),_.load("sv",a);let i=ze();_.activate(i),Fe(),gr()},pr="warp-i18n-change";function Fe(){typeof window!="undefined"&&window.dispatchEvent(new Event(pr))}var Me=!1;function gr(){if(Me||typeof window=="undefined"||!(document!=null&&document.documentElement))return;Me=!0;let o=()=>{let a=ze();_.locale!==a&&(_.activate(a),Fe())},r=new MutationObserver(a=>{for(let i of a)if(i.type==="attributes"&&i.attributeName==="lang"){o();break}});r.observe(document.documentElement,{attributes:!0,attributeFilter:["lang"]});let e=Ae();e&&e.documentElement&&e!==document&&r.observe(e.documentElement,{attributes:!0,attributeFilter:["lang"]});let t=br();t&&r.observe(t,{attributes:!0,attributeFilter:["lang"]})}function Ae(){var o,r;try{return(r=(o=window.parent)==null?void 0:o.document)!=null?r:null}catch(e){return null}}function Ee(o){var r,e;try{return(e=(r=o==null?void 0:o.documentElement)==null?void 0:r.lang)!=null?e:""}catch(t){return""}}function br(){var o;try{return(o=window.frameElement)!=null?o:null}catch(r){return null}}function vr(){var o,r,e;try{return(e=(r=(o=window.frameElement)==null?void 0:o.getAttribute)==null?void 0:r.call(o,"lang"))!=null?e:""}catch(t){return""}}import{css as Ie}from"lit";var Le=Ie`
|
|
11
11
|
*,
|
|
12
12
|
:before,
|
|
13
13
|
:after {
|
|
@@ -280,7 +280,7 @@ Please compile your catalog first.
|
|
|
280
280
|
svg {
|
|
281
281
|
pointer-events: none;
|
|
282
282
|
}
|
|
283
|
-
`,Ar=
|
|
283
|
+
`,Ar=Ie`*, :before, :after {
|
|
284
284
|
--w-rotate: 0;
|
|
285
285
|
--w-rotate-x: 0;
|
|
286
286
|
--w-rotate-y: 0;
|
|
@@ -2446,8 +2446,8 @@ Please compile your catalog first.
|
|
|
2446
2446
|
display: none
|
|
2447
2447
|
}
|
|
2448
2448
|
}
|
|
2449
|
-
`;var
|
|
2450
|
-
.z-0{z-index:0;}.z-20{z-index:20;}`;var A={wrapper:"relative z-0",base:"absolute z-20 left-0 right-0 s-bg pb-4 rounded-8 overflow-hidden shadow-m",listbox:"m-0 p-0 select-none list-none",option:"block cursor-pointer p-8",optionUnselected:"hover:s-bg-hover",optionSelected:"s-bg-selected hover:s-bg-selected-hover",textMatch:"font-bold",a11y:"sr-only"},q,h=class extends Ce(fr){constructor(){super();this.options=[];this.value="";this.openOnFocus=!1;this.selectOnBlur=!0;this.matchTextSegments=!1;this.disableStaticFiltering=!1;this.invalid=!1;this.disabled=!1;this.required=!1;this.optional=!1;this.autocomplete="off";this._isOpen=!1;this._navigationOption=null;this._currentOptions=[];this._optionIdCounter=0;this._displayValue="";pe(this,q,null);
|
|
2449
|
+
`;var Ve=JSON.parse('{"combobox.aria.pluralResults":[["numResults","plural",{"one":["#"," resultat"],"other":["#"," resultater"]}]],"combobox.aria.noResults":["Ingen resultater"],"combobox.aria.pluralSuggestions":[["numSuggestions","plural",{"one":["#"," forslag"],"other":["#"," forslag"]}]],"combobox.aria.noSuggestions":["Ingen forslag"]}');var Te=JSON.parse('{"combobox.aria.pluralResults":[["numResults","plural",{"one":["#"," result"],"other":["#"," results"]}]],"combobox.aria.noResults":["No results"],"combobox.aria.pluralSuggestions":[["numSuggestions","plural",{"one":["#"," suggestion"],"other":["#"," suggestions"]}]],"combobox.aria.noSuggestions":["No suggestions"]}');var $e=JSON.parse('{"combobox.aria.pluralResults":[["numResults","plural",{"one":["#"," tulos"],"other":["#"," tulosta"]}]],"combobox.aria.noResults":["Ei tuloksia"],"combobox.aria.pluralSuggestions":[["numSuggestions","plural",{"one":["#"," ehdotus"],"other":["#"," ehdotusta"]}]],"combobox.aria.noSuggestions":["Ei ehdotuksia"]}');var De=JSON.parse('{"combobox.aria.pluralResults":[["numResults","plural",{"one":["#"," resultat"],"other":["#"," resultater"]}]],"combobox.aria.noResults":["Ingen resultater"],"combobox.aria.pluralSuggestions":[["numSuggestions","plural",{"one":["#"," forslag"],"other":["#"," forslag"]}]],"combobox.aria.noSuggestions":["Ingen forslag"]}');var Ne=JSON.parse('{"combobox.aria.pluralResults":[["numResults","plural",{"one":["#"," resultat"],"other":["#"," resultat"]}]],"combobox.aria.noResults":["Inga resultat"],"combobox.aria.pluralSuggestions":[["numSuggestions","plural",{"one":["#"," f\xF6rslag"],"other":["#"," f\xF6rslag"]}]],"combobox.aria.noSuggestions":["Inga f\xF6rslag"]}');import{css as mr}from"lit";var Pe=mr`*,: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}.rounded-8{border-radius:8px}.block{display:block}.overflow-hidden{overflow:hidden}.list-none{list-style-type:none}.left-0{left:0}.right-0{right:0}.absolute{position:absolute}.relative{position:relative}.static{position:static}.s-bg{background-color:var(--w-s-color-background)}.s-bg-selected{background-color:var(--w-s-color-background-selected)}.hover\\:s-bg-hover:hover{background-color:var(--w-s-color-background-hover)}.hover\\:s-bg-selected-hover:hover{background-color:var(--w-s-color-background-selected-hover)}.shadow-m{box-shadow:var(--w-shadow-m)}.m-0{margin:0}.p-0{padding:0}.p-8{padding:.8rem}.pb-4{padding-bottom:.4rem}.cursor-pointer{cursor:pointer}.font-bold{font-weight:700}.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}.select-none{-webkit-user-select:none;user-select:none};
|
|
2450
|
+
.z-0{z-index:0;}.z-20{z-index:20;}`;var A={wrapper:"relative z-0",base:"absolute z-20 left-0 right-0 s-bg pb-4 rounded-8 overflow-hidden shadow-m",listbox:"m-0 p-0 select-none list-none",option:"block cursor-pointer p-8",optionUnselected:"hover:s-bg-hover",optionSelected:"s-bg-selected hover:s-bg-selected-hover",textMatch:"font-bold",a11y:"sr-only"},q,h=class extends Ce(fr){constructor(){super();this.options=[];this.value="";this.openOnFocus=!1;this.selectOnBlur=!0;this.matchTextSegments=!1;this.disableStaticFiltering=!1;this.invalid=!1;this.disabled=!1;this.required=!1;this.optional=!1;this.autocomplete="off";this._isOpen=!1;this._navigationOption=null;this._currentOptions=[];this._optionIdCounter=0;this._displayValue="";pe(this,q,null);Se(Te,De,$e,Ve,Ne)}firstUpdated(e){ge(this,q,this.value)}updated(e){e.has("value")&&this.setValue(this.value)}resetFormControl(){this.value=he(this,q)}get _listboxId(){return`${this._id}-listbox`}get _id(){return"combobox"}get _helpId(){return this.helpText?`${this._id}__hint`:void 0}get _navigationLabelOrDisplayValue(){return this._navigationOption?this._navigationOption.label||this._navigationOption.value:this._displayValue}get _navigationValueOrInputValue(){var e;return((e=this._navigationOption)==null?void 0:e.value)||this.value}_createOptionsWithIdAndMatch(e,t){return e.map((a,i)=>({...a,id:`${this._id}-option-${this._optionIdCounter+i}`,key:a.key||a.value,currentInputValue:t}))}_getAriaText(e,t,a){if(!e||!a)return"";let i=e.filter(c=>(c.label||c.value).toLowerCase().includes(t.toLowerCase())),s=_._({id:"combobox.aria.pluralSuggestions",message:"{numSuggestions, plural, one {# suggestion} other {# suggestions}}",comment:"Aria text for combobox when there are one or more suggestions",values:{numSuggestions:i.length}}),n=_._({id:"combobox.aria.noSuggestions",message:"No suggestions",comment:"Aria text for combobox when no suggestions"});return i.length?s:n}_getOptionClasses(e){var t;return Y(A.option,((t=this._navigationOption)==null?void 0:t.id)===(e==null?void 0:e.id)?A.optionSelected:A.optionUnselected)}_handleKeyDown(e){let t=["ArrowDown","ArrowUp","PageUp","PageDown","Home","End"].includes(e.key),a=["ArrowDown","ArrowLeft","ArrowUp","ArrowRight"];if(t&&!this._isOpen){this._isOpen=!0;return}if(t&&this._isOpen){this._findAndSetActiveOption(e);return}if(!(e.altKey||e.ctrlKey||e.metaKey||e.shiftKey))switch(e.key){case"Enter":this._navigationOption&&(e.preventDefault(),this._handleSelect(this._navigationOption),requestAnimationFrame(()=>{var n,c;let i=(n=this.shadowRoot)==null?void 0:n.querySelector("w-textfield"),s=(c=i==null?void 0:i.shadowRoot)==null?void 0:c.querySelector("input");s&&(s.value=this._displayValue)})),this._isOpen=!1;break;case"Tab":case"Delete":this._isOpen=!1;break;case"Escape":this._isOpen?this._isOpen=!1:this._handleChange(""),this._navigationOption=null;break;case"Backspace":this._handleChange(this._navigationLabelOrDisplayValue),this._navigationOption=null,this._isOpen=!0;break;default:if(a.includes(e.key))break;this._isOpen=!0,this._navigationOption?(this._handleChange(this._navigationOption.value),this._navigationOption=null):this._handleChange(this.value);break}}_findAndSetActiveOption(e){e.preventDefault();let t=this._currentOptions.findIndex(s=>{var n;return s.id===((n=this._navigationOption)==null?void 0:n.id)}),a=t+1,i=t-1;switch(e.key){case"ArrowDown":this._navigationOption=a>this._currentOptions.length-1?null:this._currentOptions[a];break;case"ArrowUp":this._navigationOption=i===-2?this._currentOptions[this._currentOptions.length-1]:i<0?null:this._currentOptions[i];break;case"PageUp":this._navigationOption=t-10<0?this._currentOptions[0]:this._currentOptions[t-10];break;case"PageDown":this._navigationOption=t+10>this._currentOptions.length-1?this._currentOptions[this._currentOptions.length-1]:this._currentOptions[t+10];break;case"Home":this._navigationOption=this._currentOptions[0];break;case"End":this._navigationOption=this._currentOptions[this._currentOptions.length-1];break}}_handleSelect(e){this.value=e.value,this._displayValue=e.label||e.value,this.setValue(this.value);let t=new CustomEvent("select",{detail:{value:e.value},bubbles:!0,composed:!0});this.dispatchEvent(t),this._isOpen=!1,this._navigationOption=null,this.disableStaticFiltering&&(this._currentOptions=[])}_handleChange(e){if(e===void 0)return;this.value=e,this._displayValue=e;let t=new CustomEvent("change",{detail:{value:e},bubbles:!0,composed:!0});this.dispatchEvent(t)}_handleFocus(){if(!this.openOnFocus)return;let e=new CustomEvent("focus",{bubbles:!0,composed:!0});this.dispatchEvent(e),this._isOpen=!0}_handleBlur(e){var i,s;let t=e.relatedTarget;if(t&&((i=this.shadowRoot)!=null&&i.contains(t)))return;if(this._isOpen=!1,this.selectOnBlur&&(this._navigationOption||!this._navigationOption&&this._currentOptions.findIndex(n=>n.value===this.value)!==-1)){let n=((s=this._navigationOption)==null?void 0:s.value)||this.value;this.value=n;let c=new CustomEvent("select",{detail:{value:n},bubbles:!0,composed:!0});this.dispatchEvent(c)}this._navigationOption=null;let a=new CustomEvent("blur",{detail:{value:this._navigationValueOrInputValue},bubbles:!0,composed:!0});this.dispatchEvent(a)}_handleOptionClick(e,t){this._handleSelect(t),requestAnimationFrame(()=>{var s,n;let a=(s=this.shadowRoot)==null?void 0:s.querySelector("w-textfield"),i=(n=a==null?void 0:a.shadowRoot)==null?void 0:n.querySelector("input");i&&(i.value=t.label||t.value)})}_handleContainerBlur(e){(!e.currentTarget||!e.currentTarget.contains(e.relatedTarget))&&(this._isOpen=!1)}_renderTextMatch(e,t){if(!this.matchTextSegments)return e;let a=e.toLowerCase().indexOf(t.currentInputValue.toLowerCase());if(a!==-1){let i=a+t.currentInputValue.length;return ne`${e.substring(0,a)}<span class="${A.textMatch}">${e.substring(a,i)}</span
|
|
2451
2451
|
>${e.substring(i)}`}return e}willUpdate(e){if(e.has("value")||e.has("options")){let t=this.options.find(i=>i.value===this.value),a=t?t.label||t.value:this.value;this._displayValue!==a&&this._displayValue!==this.value&&(this._displayValue=a),!this._displayValue&&this.value&&(this._displayValue=a)}(e.has("options")||e.has("value")||e.has("disableStaticFiltering")||e.has("_displayValue"))&&(this._optionIdCounter+=this.options.length,this._currentOptions=this._createOptionsWithIdAndMatch(this.options,this._displayValue).filter(t=>this.disableStaticFiltering?!0:(t.label||t.value).toLowerCase().includes(this._displayValue.toLowerCase()))),this.disableStaticFiltering&&this._currentOptions.length&&this._currentOptions.length===1&&!this._currentOptions.some(t=>t.value===this.value)&&!this._isOpen&&(this._isOpen=!0)}render(){var e;return ne`
|
|
2452
2452
|
<div class=${Y(A.wrapper)} @blur=${this._handleContainerBlur}>
|
|
2453
2453
|
<w-textfield
|
|
@@ -2472,7 +2472,9 @@ Please compile your catalog first.
|
|
|
2472
2472
|
@blur=${this._handleBlur}
|
|
2473
2473
|
@keydown=${this._handleKeyDown}></w-textfield>
|
|
2474
2474
|
|
|
2475
|
-
<span class="${A.a11y}" role="status">
|
|
2475
|
+
<span class="${A.a11y}" role="status">
|
|
2476
|
+
${this._getAriaText(this._currentOptions,this._displayValue,this._isOpen)}
|
|
2477
|
+
</span>
|
|
2476
2478
|
|
|
2477
2479
|
<div ?hidden=${!this._isOpen||!this._currentOptions.length} class=${Y(A.base)}>
|
|
2478
2480
|
<ul id=${this._listboxId} role="listbox" class="${A.listbox}">
|
|
@@ -2490,5 +2492,5 @@ Please compile your catalog first.
|
|
|
2490
2492
|
</ul>
|
|
2491
2493
|
</div>
|
|
2492
2494
|
</div>
|
|
2493
|
-
`}};q=new WeakMap,h.styles=[
|
|
2495
|
+
`}};q=new WeakMap,h.styles=[Le,Pe],p([w({type:Array})],h.prototype,"options",2),p([w({type:String,reflect:!0})],h.prototype,"label",2),p([w({type:String,reflect:!0})],h.prototype,"placeholder",2),p([w({type:String,reflect:!0})],h.prototype,"value",2),p([w({type:Boolean,attribute:"open-on-focus"})],h.prototype,"openOnFocus",2),p([w({type:Boolean,attribute:"select-on-blur"})],h.prototype,"selectOnBlur",2),p([w({type:Boolean,attribute:"match-text-segments"})],h.prototype,"matchTextSegments",2),p([w({type:Boolean,attribute:"disable-static-filtering"})],h.prototype,"disableStaticFiltering",2),p([w({type:Boolean,reflect:!0})],h.prototype,"invalid",2),p([w({type:String,attribute:"help-text",reflect:!0})],h.prototype,"helpText",2),p([w({type:Boolean,reflect:!0})],h.prototype,"disabled",2),p([w({type:Boolean,reflect:!0})],h.prototype,"required",2),p([w({type:Boolean,reflect:!0})],h.prototype,"optional",2),p([w({type:String,reflect:!0})],h.prototype,"name",2),p([w({type:String,reflect:!0})],h.prototype,"autocomplete",2),p([B()],h.prototype,"_isOpen",2),p([B()],h.prototype,"_navigationOption",2),p([B()],h.prototype,"_currentOptions",2),p([B()],h.prototype,"_optionIdCounter",2),p([B()],h.prototype,"_displayValue",2);customElements.get("w-combobox")||customElements.define("w-combobox",h);export{h as WarpCombobox};
|
|
2494
2496
|
//# sourceMappingURL=combobox.js.map
|