@warp-ds/elements 2.10.0-next.2 → 2.10.0-next.3
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 +140 -69
- package/dist/docs/combobox/accessibility.md +71 -0
- package/dist/docs/combobox/api.md +60 -30
- package/dist/docs/combobox/combobox.md +203 -30
- package/dist/docs/combobox/examples.md +44 -0
- package/dist/docs/combobox/usage.md +28 -0
- package/dist/docs/icon/accessibility.md +5 -0
- package/dist/docs/icon/api.md +37 -0
- package/dist/docs/icon/examples.md +45 -0
- package/dist/docs/icon/icon.md +107 -0
- package/dist/docs/icon/usage.md +11 -0
- package/dist/docs/link/api.md +18 -22
- package/dist/docs/link/examples.md +75 -0
- package/dist/docs/link/link.md +111 -22
- package/dist/docs/link/usage.md +18 -0
- package/dist/index.d.ts +443 -171
- package/dist/packages/affix/affix.js +3 -3
- package/dist/packages/affix/affix.js.map +3 -3
- package/dist/packages/alert/alert.js +1 -1
- package/dist/packages/alert/alert.js.map +3 -3
- package/dist/packages/attention/attention.js.map +3 -3
- package/dist/packages/button/button.js.map +2 -2
- package/dist/packages/checkbox/checkbox.d.ts +40 -11
- package/dist/packages/checkbox/checkbox.js.map +2 -2
- package/dist/packages/checkbox-group/checkbox-group.d.ts +30 -5
- package/dist/packages/checkbox-group/checkbox-group.js.map +2 -2
- package/dist/packages/combobox/combobox.a11y.test.js +24 -0
- package/dist/packages/combobox/combobox.d.ts +65 -45
- package/dist/packages/combobox/combobox.hydration.test.js +39 -1
- package/dist/packages/combobox/combobox.js +13 -13
- package/dist/packages/combobox/combobox.js.map +3 -3
- package/dist/packages/combobox/combobox.stories.js +28 -15
- package/dist/packages/combobox/combobox.test.js +110 -0
- package/dist/packages/datepicker/datepicker.js.map +3 -3
- package/dist/packages/expandable/expandable.js +2 -2
- package/dist/packages/expandable/expandable.js.map +3 -3
- package/dist/packages/icon/icon.d.ts +13 -3
- package/dist/packages/icon/icon.js +2 -2
- package/dist/packages/icon/icon.js.map +3 -3
- package/dist/packages/icon/icon.react.stories.d.ts +1 -1
- package/dist/packages/icon/react.d.ts +2 -2
- package/dist/packages/link/link.d.ts +15 -16
- package/dist/packages/link/link.js.map +2 -2
- package/dist/packages/modal-header/modal-header.js +1 -1
- package/dist/packages/modal-header/modal-header.js.map +3 -3
- package/dist/packages/pagination/pagination.js.map +3 -3
- package/dist/packages/pill/pill.js.map +3 -3
- package/dist/packages/select/select.js.map +3 -3
- package/dist/packages/step/step.js +1 -1
- package/dist/packages/step/step.js.map +3 -3
- package/dist/packages/toast/toast.js +3 -3
- package/dist/packages/toast/toast.js.map +3 -3
- package/dist/packages/toast/toast.stories.d.ts +1 -5
- package/dist/packages/toast/toast.stories.js +0 -17
- package/dist/web-types.json +129 -72
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { describe, expect, test, beforeEach, afterEach } from 'vitest';
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import { hydrateRoot } from 'react-dom/client';
|
|
3
|
+
import { afterEach, beforeEach, describe, expect, test } from 'vitest';
|
|
4
4
|
import { setupHydrationWarningCapture, testHydration } from '../../tests/react-hydration';
|
|
5
5
|
import './combobox.js';
|
|
6
6
|
describe('w-combobox React SSR hydration', () => {
|
|
@@ -97,4 +97,42 @@ describe('w-combobox React SSR hydration', () => {
|
|
|
97
97
|
document.body.removeChild(container);
|
|
98
98
|
}
|
|
99
99
|
});
|
|
100
|
+
test('declarative option children hydrate without attribute mismatch warnings', async () => {
|
|
101
|
+
const container = document.createElement('div');
|
|
102
|
+
container.id = 'hydration-options-root';
|
|
103
|
+
document.body.appendChild(container);
|
|
104
|
+
const innerHtml = [
|
|
105
|
+
'<w-combobox id="demo-combobox" label="Search">',
|
|
106
|
+
'<option value="apple">Apple</option>',
|
|
107
|
+
'<option value="banana">Banana</option>',
|
|
108
|
+
'</w-combobox>',
|
|
109
|
+
].join('');
|
|
110
|
+
try {
|
|
111
|
+
container.innerHTML = `<section class="example">${innerHtml}</section>`;
|
|
112
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
113
|
+
function App() {
|
|
114
|
+
return React.createElement('section', {
|
|
115
|
+
className: 'example',
|
|
116
|
+
// biome-ignore lint/security/noDangerouslySetInnerHtml: test reproduces React hydration mismatch path
|
|
117
|
+
dangerouslySetInnerHTML: { __html: innerHtml },
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
hydrateRoot(container, React.createElement(App), {
|
|
121
|
+
onRecoverableError: (error) => {
|
|
122
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
123
|
+
if (msg.includes('Hydration') ||
|
|
124
|
+
msg.includes('hydrat') ||
|
|
125
|
+
msg.includes('did not match') ||
|
|
126
|
+
msg.includes("didn't match")) {
|
|
127
|
+
window.__HYDRATION_WARNINGS__.push(msg);
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
132
|
+
expect(window.__HYDRATION_WARNINGS__).toEqual([]);
|
|
133
|
+
}
|
|
134
|
+
finally {
|
|
135
|
+
document.body.removeChild(container);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
100
138
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
1
|
+
var Ie=Object.defineProperty;var De=Object.getOwnPropertyDescriptor;var de=o=>{throw TypeError(o)};var p=(o,r,e,t)=>{for(var a=t>1?void 0:t?De(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&&Ie(r,e,a),a};var Q=(o,r,e)=>r.has(o)||de("Cannot "+e);var B=(o,r,e)=>(Q(o,r,"read from private field"),e?e.call(o):r.get(o)),X=(o,r,e)=>r.has(o)?de("Cannot add the same private member more than once"):r instanceof WeakSet?r.add(o):r.set(o,e),ee=(o,r,e,t)=>(Q(o,r,"write to private field"),t?t.call(o,e):r.set(o,e),e),Z=(o,r,e)=>(Q(o,r,"access private method"),e);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 M=o=>typeof o=="string",$e=o=>typeof o=="function",ue=new Map,pe="en";function ae(o){return[...Array.isArray(o)?o:[o],pe]}function ie(o,r,e){let t=ae(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 q(()=>K("date",t,e),()=>new Intl.DateTimeFormat(t,a)).format(M(r)?new Date(r):r)}function Te(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 ie(o,r,t)}function re(o,r,e){let t=ae(o);return q(()=>K("number",t,e),()=>new Intl.NumberFormat(t,e)).format(r)}function he(o,r,e,{offset:t=0,...a}){var n,c;let i=ae(o),s=r?q(()=>K("plural-ordinal",i),()=>new Intl.PluralRules(i,{type:"ordinal"})):q(()=>K("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 q(o,r){let e=o(),t=ue.get(e);return t||(t=r(),ue.set(e,t)),t}function K(o,r,e){let t=r.join("-");return`${o}-${t}-${JSON.stringify(e)}`}var ge=/\\u[a-fA-F0-9]{4}|\\x[a-fA-F0-9]{2}/,be=o=>o.replace(/\\u([a-fA-F0-9]{4})|\\x([a-fA-F0-9]{2})/g,(r,e,t)=>{if(e){let a=parseInt(e,16);return String.fromCharCode(a)}else{let a=parseInt(t,16);return String.fromCharCode(a)}}),ve="%__lingui_octothorpe__%",Ne=(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,f=re(t,s,c);return n.replace(new RegExp(ve,"g"),f)};return{plural:(s,n)=>{let{offset:c=0}=n,f=he(t,!1,s,n);return i(s-c,f)},selectordinal:(s,n)=>{let{offset:c=0}=n,f=he(t,!0,s,n);return i(s-c,f)},select:Pe,number:(s,n)=>re(t,s,a(n)||{style:n}),date:(s,n)=>ie(t,s,a(n)||n),time:(s,n)=>Te(t,s,a(n)||n)}},Pe=(o,r)=>{var e;return(e=r[o])!=null?e:r.other};function Re(o,r,e){return(t={},a)=>{let i=Ne(r,e,a),s=(c,f=!1)=>Array.isArray(c)?c.reduce((O,C)=>{if(C==="#"&&f)return O+ve;if(M(C))return O+C;let[L,x,z]=C,E={};x==="plural"||x==="selectordinal"||x==="select"?Object.entries(z).forEach(([S,T])=>{E[S]=s(T,x==="plural"||x==="selectordinal")}):E=z;let w;if(x){let S=i[x];w=S(t[L],E)}else w=t[L];return w==null?O:O+w},""):c,n=s(o);return M(n)&&ge.test(n)?be(n):M(n)?n:n?String(n):""}}var je=Object.defineProperty,Ye=(o,r,e)=>r in o?je(o,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[r]=e,Ue=(o,r,e)=>(Ye(o,typeof r!="symbol"?r+"":r,e),e),te=class{constructor(){Ue(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}},Be=Object.defineProperty,Xe=(o,r,e)=>r in o?Be(o,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[r]=e,A=(o,r,e)=>(Xe(o,typeof r!="symbol"?r+"":r,e),e),oe=class extends te{constructor(r){var e;super(),A(this,"_locale",""),A(this,"_locales"),A(this,"_localeData",{}),A(this,"_messages",{}),A(this,"_missing"),A(this,"_messageCompiler"),A(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:pe,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=""),M(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 $e(n)?n(this._locale,r):n;s&&this.emit("missing",{id:r,locale:this._locale});let c=i||a||r;return M(c)&&(this._messageCompiler?c=this._messageCompiler(c):console.warn(`Uncompiled message detected! Message:
|
|
2
2
|
|
|
3
3
|
> ${c}
|
|
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
|
-
`)),M(c)&&
|
|
9
|
+
`)),M(c)&&ge.test(c)?be(c):M(c)?c:Re(c,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 Ze(o={}){return new oe(o)}var y=Ze();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 me(o){var r,e,t,a,i,s,n,c,f,O,C,L,x,z,E,w,S,T,H;class Le extends o{constructor(...l){var d,g,v;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),f.set(this,""),O.set(this,()=>{b(this,a,!0,"f"),b(this,e,!0,"f"),u(this,r,"m",w).call(this)}),C.set(this,()=>{b(this,e,!1,"f"),u(this,r,"m",S).call(this,this.shouldFormValueUpdate()?u(this,f,"f"):""),!this.validity.valid&&u(this,a,"f")&&b(this,t,!0,"f");let _=u(this,r,"m",w).call(this);this.validationMessageCallback&&this.validationMessageCallback(_?this.internals.validationMessage:"")}),L.set(this,()=>{var _;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",w).call(this),(_=this===null||this===void 0?void 0:this.validationMessageCallback)===null||_===void 0||_.call(this,this.showError?this.internals.validationMessage:"")}),x.set(this,void 0),z.set(this,!1),E.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,C,"f")),(v=this.addEventListener)===null||v===void 0||v.call(this,"invalid",u(this,L,"f")),this.setValue(null)}static get formAssociated(){return!0}static get validators(){return this.formControlValidators||[]}static get observedAttributes(){let l=this.validators.map(v=>v.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",w).call(this)}checkValidity(){return this.internals.checkValidity()}get validity(){return this.internals.validity}get validationMessage(){return this.internals.validationMessage}attributeChangedCallback(l,d,g){var v;(v=super.attributeChangedCallback)===null||v===void 0||v.call(this,l,d,g);let P=this.constructor.getValidators(l);P!=null&&P.length&&this.validationTarget&&this.setValue(u(this,f,"f"))}setValue(l){var d;b(this,t,!1,"f"),(d=this.validationMessageCallback)===null||d===void 0||d.call(this,""),b(this,f,l,"f");let v=this.shouldFormValueUpdate()?l:null;this.internals.setFormValue(v),u(this,r,"m",S).call(this,v),this.valueChangedCallback&&this.valueChangedCallback(v),u(this,r,"m",w).call(this)}shouldFormValueUpdate(){return!0}get validationComplete(){return new Promise(l=>l(u(this,E,"f")))}formResetCallback(){var l,d;b(this,a,!1,"f"),b(this,t,!1,"f"),u(this,r,"m",w).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",w).call(this)?this.validationMessage:"")}}return e=new WeakMap,t=new WeakMap,a=new WeakMap,i=new WeakMap,s=new WeakMap,n=new WeakMap,f=new WeakMap,O=new WeakMap,C=new WeakMap,L=new WeakMap,x=new WeakMap,z=new WeakMap,E=new WeakMap,r=new WeakSet,c=function(){let l=this.getRootNode(),d=`${this.localName}[name="${this.getAttribute("name")}"]`;return l.querySelectorAll(d)},w=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},S=function(l){let d=this.constructor,g={},v=d.validators,_=[],P=v.some(k=>k.isValid instanceof Promise);u(this,z,"f")||(b(this,E,new Promise(k=>{b(this,x,k,"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 R=new AbortController;b(this,i,R,"f");let j,ce=!1;v.length&&(v.forEach(k=>{let J=k.key||"customError",I=k.isValid(this,l,R.signal);I instanceof Promise?(_.push(I),I.then(W=>{W!=null&&(g[J]=!W,j=u(this,r,"m",H).call(this,k,l),u(this,r,"m",T).call(this,g,j))})):(g[J]=!I,this.validity[J]!==!I&&(ce=!0),!I&&!j&&(j=u(this,r,"m",H).call(this,k,l)))}),Promise.allSettled(_).then(()=>{var k;R!=null&&R.signal.aborted||(b(this,z,!1,"f"),(k=u(this,x,"f"))===null||k===void 0||k.call(this))}),(ce||!P)&&u(this,r,"m",T).call(this,g,j))},T=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")}},H=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},Le}import{html as se,LitElement as Qe}from"lit";import{property as m,state as D}from"lit/decorators.js";import{repeat as er}from"lit/directives/repeat.js";var qe=["en","nb","fi","da","sv"],ne="en",G=o=>qe.find(r=>o===r||o.toLowerCase().includes(r))||ne;function xe(){if(typeof window=="undefined"){let o=process.env.NMP_LANGUAGE||Intl.DateTimeFormat().resolvedOptions().locale;return G(o)}try{let o=we(document);if(o)return G(o);let r=Je();if(r)return G(r);let e=we(_e());return e?G(e):ne}catch(o){return console.warn("could not detect locale, falling back to source locale",o),ne}}var ke=(o,r,e,t,a)=>{y.load("en",o),y.load("nb",r),y.load("fi",e),y.load("da",t),y.load("sv",a);let i=xe();y.activate(i),ye(),Ge()},Ke="warp-i18n-change";function ye(){typeof window!="undefined"&&window.dispatchEvent(new Event(Ke))}var fe=!1;function Ge(){if(fe||typeof window=="undefined"||!(document!=null&&document.documentElement))return;fe=!0;let o=()=>{let a=xe();y.locale!==a&&(y.activate(a),ye())},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=_e();e&&e.documentElement&&e!==document&&r.observe(e.documentElement,{attributes:!0,attributeFilter:["lang"]});let t=He();t&&r.observe(t,{attributes:!0,attributeFilter:["lang"]})}function _e(){var o,r;try{return(r=(o=window.parent)==null?void 0:o.document)!=null?r:null}catch(e){return null}}function we(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 He(){var o;try{return(o=window.frameElement)!=null?o:null}catch(r){return null}}function Je(){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 Oe}from"lit";var Ce=Oe`
|
|
10
10
|
*,
|
|
11
11
|
:before,
|
|
12
12
|
:after {
|
|
@@ -279,7 +279,7 @@ Please compile your catalog first.
|
|
|
279
279
|
svg {
|
|
280
280
|
pointer-events: none;
|
|
281
281
|
}
|
|
282
|
-
`,
|
|
282
|
+
`,dr=Oe`*, :before, :after {
|
|
283
283
|
--w-rotate: 0;
|
|
284
284
|
--w-rotate-x: 0;
|
|
285
285
|
--w-rotate-y: 0;
|
|
@@ -2445,13 +2445,13 @@ Please compile your catalog first.
|
|
|
2445
2445
|
display: none
|
|
2446
2446
|
}
|
|
2447
2447
|
}
|
|
2448
|
-
`;var
|
|
2449
|
-
.z-0{z-index:0;}.z-20{z-index:20;}`;var
|
|
2450
|
-
class="${
|
|
2448
|
+
`;var ze=JSON.parse('{"combobox.aria.noResults":["Ingen resultater"],"combobox.aria.noSuggestions":["Ingen forslag"],"combobox.aria.pluralResults":[["numResults","plural",{"one":["#"," resultat"],"other":["#"," resultater"]}]],"combobox.aria.pluralSuggestions":[["numSuggestions","plural",{"one":["#"," forslag"],"other":["#"," forslag"]}]]}');var Ee=JSON.parse('{"combobox.aria.noResults":["No results"],"combobox.aria.noSuggestions":["No suggestions"],"combobox.aria.pluralResults":[["numResults","plural",{"one":["#"," result"],"other":["#"," results"]}]],"combobox.aria.pluralSuggestions":[["numSuggestions","plural",{"one":["#"," suggestion"],"other":["#"," suggestions"]}]]}');var Me=JSON.parse('{"combobox.aria.noResults":["Ei tuloksia"],"combobox.aria.noSuggestions":["Ei ehdotuksia"],"combobox.aria.pluralResults":[["numResults","plural",{"one":["#"," tulos"],"other":["#"," tulosta"]}]],"combobox.aria.pluralSuggestions":[["numSuggestions","plural",{"one":["#"," ehdotus"],"other":["#"," ehdotusta"]}]]}');var Fe=JSON.parse('{"combobox.aria.noResults":["Ingen resultater"],"combobox.aria.noSuggestions":["Ingen forslag"],"combobox.aria.pluralResults":[["numResults","plural",{"one":["#"," resultat"],"other":["#"," resultater"]}]],"combobox.aria.pluralSuggestions":[["numSuggestions","plural",{"one":["#"," forslag"],"other":["#"," forslag"]}]]}');var Se=JSON.parse('{"combobox.aria.noResults":["Inga resultat"],"combobox.aria.noSuggestions":["Inga f\xF6rslag"],"combobox.aria.pluralResults":[["numResults","plural",{"one":["#"," resultat"],"other":["#"," resultat"]}]],"combobox.aria.pluralSuggestions":[["numSuggestions","plural",{"one":["#"," f\xF6rslag"],"other":["#"," f\xF6rslag"]}]]}');import{css as We}from"lit";var Ae=We`*,: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};
|
|
2449
|
+
.z-0{z-index:0;}.z-20{z-index:20;}`;var F={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"},U,$,V,Ve,le,h=class extends me(Qe){constructor(){super();X(this,V);this.options=[];this.label="";this.placeholder="";this.value="";this.openOnFocus=!1;this.selectOnBlur=!0;this.matchTextSegments=!1;this.disableStaticFiltering=!1;this.invalid=!1;this.helpText="";this.disabled=!1;this.required=!1;this.optional=!1;this.name="";this.autocomplete="off";this._isOpen=!1;this._navigationOption=null;this._currentOptions=[];this._lightDomOptions=[];this._optionIdCounter=0;this._displayValue="";X(this,U,null);X(this,$);ke(Ee,Fe,Me,ze,Se)}firstUpdated(e){ee(this,U,this.value)}updated(e){e.has("value")&&this.setValue(this.value)}resetFormControl(){this.value=B(this,U)}connectedCallback(){super.connectedCallback(),Z(this,V,le).call(this),ee(this,$,new MutationObserver(()=>{Z(this,V,le).call(this)})),B(this,$).observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["label","value"]})}disconnectedCallback(){var e;super.disconnectedCallback(),(e=B(this,$))==null||e.disconnect()}get _listboxId(){return`${this._id}-listbox`}get _id(){return"combobox"}get _helpId(){return this.helpText?`${this._id}__hint`:void 0}get _sourceOptions(){return Array.isArray(this.options)&&this.options.length?this.options:this._lightDomOptions}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=y._({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=y._({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(F.option,((t=this._navigationOption)==null?void 0:t.id)===(e==null?void 0:e.id)?F.optionSelected:F.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 se`${e.substring(0,a)}<span
|
|
2450
|
+
class="${F.textMatch}"
|
|
2451
2451
|
>${e.substring(a,i)}</span
|
|
2452
|
-
>${e.substring(i)}`}return e}willUpdate(e){let t=
|
|
2452
|
+
>${e.substring(i)}`}return e}willUpdate(e){let t=this._sourceOptions,a=e.has("_lightDomOptions");if(e.has("value")||e.has("options")||a){let i=t.find(n=>n.value===this.value),s=i?i.label||i.value:this.value;this._displayValue!==s&&this._displayValue!==this.value&&(this._displayValue=s),!this._displayValue&&this.value&&(this._displayValue=s)}(e.has("options")||a||e.has("value")||e.has("disableStaticFiltering")||e.has("_displayValue"))&&(this._optionIdCounter+=t.length,this._currentOptions=this._createOptionsWithIdAndMatch(t,this._displayValue).filter(i=>this.disableStaticFiltering?!0:(i.label||i.value).toLowerCase().includes(this._displayValue.toLowerCase()))),this.disableStaticFiltering&&this._currentOptions.length&&this._currentOptions.length===1&&!this._currentOptions.some(i=>i.value===this.value)&&!this._isOpen&&(this._isOpen=!0)}render(){var e;return se`
|
|
2453
2453
|
<div
|
|
2454
|
-
class=${
|
|
2454
|
+
class=${Y(F.wrapper)}
|
|
2455
2455
|
@blur=${this._handleContainerBlur}
|
|
2456
2456
|
>
|
|
2457
2457
|
<w-textfield
|
|
@@ -2477,20 +2477,20 @@ Please compile your catalog first.
|
|
|
2477
2477
|
@keydown=${this._handleKeyDown}
|
|
2478
2478
|
></w-textfield>
|
|
2479
2479
|
|
|
2480
|
-
<span class="${
|
|
2480
|
+
<span class="${F.a11y}" role="status">
|
|
2481
2481
|
${this._getAriaText(this._currentOptions,this._displayValue,this._isOpen)}
|
|
2482
2482
|
</span>
|
|
2483
2483
|
|
|
2484
2484
|
<div
|
|
2485
2485
|
?hidden=${!this._isOpen||!this._currentOptions.length}
|
|
2486
|
-
class=${
|
|
2486
|
+
class=${Y(F.base)}
|
|
2487
2487
|
>
|
|
2488
2488
|
<ul
|
|
2489
2489
|
id=${this._listboxId}
|
|
2490
2490
|
role="listbox"
|
|
2491
|
-
class="${
|
|
2491
|
+
class="${F.listbox}"
|
|
2492
2492
|
>
|
|
2493
|
-
${
|
|
2493
|
+
${er(this._currentOptions,t=>t.key,t=>{var i;let a=t.label||t.value;return se`
|
|
2494
2494
|
<li
|
|
2495
2495
|
id=${t.id}
|
|
2496
2496
|
role="option"
|
|
@@ -2505,5 +2505,5 @@ Please compile your catalog first.
|
|
|
2505
2505
|
</ul>
|
|
2506
2506
|
</div>
|
|
2507
2507
|
</div>
|
|
2508
|
-
`}};
|
|
2508
|
+
`}};U=new WeakMap,$=new WeakMap,V=new WeakSet,Ve=function(){return Array.from(this.children).filter(e=>e.tagName.toLowerCase()==="option")},le=function(){this._lightDomOptions=Z(this,V,Ve).call(this).map(e=>{var i,s,n;let t=(i=e.getAttribute("value"))!=null?i:"",a=e.hasAttribute("label")?(s=e.getAttribute("label"))!=null?s:"":(n=e.textContent)!=null?n:"";return{value:t,label:a,key:t}})},h.styles=[Ce,Ae],p([m({type:Array})],h.prototype,"options",2),p([m({type:String,reflect:!0,useDefault:!0})],h.prototype,"label",2),p([m({type:String,reflect:!0,useDefault:!0})],h.prototype,"placeholder",2),p([m({type:String,reflect:!0,useDefault:!0})],h.prototype,"value",2),p([m({type:Boolean,attribute:"open-on-focus",reflect:!0})],h.prototype,"openOnFocus",2),p([m({type:Boolean,attribute:"select-on-blur",reflect:!0,useDefault:!0})],h.prototype,"selectOnBlur",2),p([m({type:Boolean,attribute:"match-text-segments",reflect:!0})],h.prototype,"matchTextSegments",2),p([m({type:Boolean,attribute:"disable-static-filtering",reflect:!0})],h.prototype,"disableStaticFiltering",2),p([m({type:Boolean,reflect:!0})],h.prototype,"invalid",2),p([m({type:String,attribute:"help-text",reflect:!0,useDefault:!0})],h.prototype,"helpText",2),p([m({type:Boolean,reflect:!0})],h.prototype,"disabled",2),p([m({type:Boolean,reflect:!0})],h.prototype,"required",2),p([m({type:Boolean,reflect:!0})],h.prototype,"optional",2),p([m({type:String,reflect:!0,useDefault:!0})],h.prototype,"name",2),p([m({type:String,reflect:!0,useDefault:!0})],h.prototype,"autocomplete",2),p([D()],h.prototype,"_isOpen",2),p([D()],h.prototype,"_navigationOption",2),p([D()],h.prototype,"_currentOptions",2),p([D()],h.prototype,"_lightDomOptions",2),p([D()],h.prototype,"_optionIdCounter",2),p([D()],h.prototype,"_displayValue",2);customElements.get("w-combobox")||customElements.define("w-combobox",h);export{h as WarpCombobox};
|
|
2509
2509
|
//# sourceMappingURL=combobox.js.map
|