@warp-ds/elements 2.9.0 → 2.9.1-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/custom-elements.json +31 -0
- package/dist/docs/box/accessibility.md +29 -0
- package/dist/docs/box/api.md +16 -11
- package/dist/docs/box/box.md +189 -11
- package/dist/docs/box/examples.md +98 -0
- package/dist/docs/box/usage.md +47 -0
- package/dist/index.d.ts +40 -20
- package/dist/packages/box/box.d.ts +15 -14
- package/dist/packages/box/box.js +6 -6
- package/dist/packages/box/box.js.map +4 -4
- package/dist/packages/box/box.react.stories.d.ts +1 -1
- package/dist/packages/box/box.stories.d.ts +1 -0
- package/dist/packages/box/box.stories.js +12 -5
- package/dist/packages/checkbox/checkbox.js +3 -3
- package/dist/packages/checkbox/checkbox.js.map +2 -2
- package/dist/packages/checkbox/checkbox.test.js +20 -0
- package/dist/packages/datepicker/datepicker.js +6 -6
- package/dist/packages/datepicker/datepicker.js.map +2 -2
- package/dist/packages/datepicker/datepicker.stories.js +8 -1
- package/dist/packages/datepicker/datepicker.test.js +23 -1
- package/dist/packages/radio/radio.js +2 -2
- package/dist/packages/radio/radio.js.map +2 -2
- package/dist/packages/radio/radio.test.js +21 -1
- package/dist/packages/radio-group/radio-group.js +5 -5
- package/dist/packages/radio-group/radio-group.js.map +2 -2
- package/dist/packages/select/select.js +10 -10
- package/dist/packages/select/select.js.map +3 -3
- package/dist/packages/select/select.stories.js +7 -5
- package/dist/packages/select/select.test.js +23 -2
- package/dist/packages/slider/slider.stories.js +6 -3
- package/dist/packages/slider-thumb/slider-thumb.js +16 -16
- package/dist/packages/slider-thumb/slider-thumb.js.map +2 -2
- package/dist/packages/textfield/textfield.js +9 -8
- package/dist/packages/textfield/textfield.js.map +3 -3
- package/dist/packages/textfield/textfield.test.js +17 -0
- package/dist/web-types.json +35 -7
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var cr=Object.create;var be=Object.defineProperty;var Le=Object.getOwnPropertyDescriptor;var dr=Object.getOwnPropertyNames;var ur=Object.getPrototypeOf,br=Object.prototype.hasOwnProperty;var Oe=
|
|
2
|
-
`],["r","\r"],["t"," "],["v","\v"],["0","\0"]]);function yr(
|
|
1
|
+
var cr=Object.create;var be=Object.defineProperty;var Le=Object.getOwnPropertyDescriptor;var dr=Object.getOwnPropertyNames;var ur=Object.getPrototypeOf,br=Object.prototype.hasOwnProperty;var Oe=t=>{throw TypeError(t)};var Te=(t,r)=>()=>(r||t((r={exports:{}}).exports,r),r.exports);var hr=(t,r,e,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of dr(r))!br.call(t,a)&&a!==e&&be(t,a,{get:()=>r[a],enumerable:!(o=Le(r,a))||o.enumerable});return t};var pr=(t,r,e)=>(e=t!=null?cr(ur(t)):{},hr(r||!t||!t.__esModule?be(e,"default",{value:t,enumerable:!0}):e,t));var p=(t,r,e,o)=>{for(var a=o>1?void 0:o?Le(r,e):r,i=t.length-1,s;i>=0;i--)(s=t[i])&&(a=(o?s(r,e,a):s(a))||a);return o&&a&&be(r,e,a),a};var he=(t,r,e)=>r.has(t)||Oe("Cannot "+e);var x=(t,r,e)=>(he(t,r,"read from private field"),e?e.call(t):r.get(t)),G=(t,r,e)=>r.has(t)?Oe("Cannot add the same private member more than once"):r instanceof WeakSet?r.add(t):r.set(t,e),pe=(t,r,e,o)=>(he(t,r,"write to private field"),o?o.call(t,e):r.set(t,e),e),w=(t,r,e)=>(he(t,r,"access private method"),e);var Se=Te(N=>{"use strict";Object.defineProperty(N,"__esModule",{value:!0});N.errorMessages=N.ErrorType=void 0;var R;(function(t){t.MalformedUnicode="MALFORMED_UNICODE",t.MalformedHexadecimal="MALFORMED_HEXADECIMAL",t.CodePointLimit="CODE_POINT_LIMIT",t.OctalDeprecation="OCTAL_DEPRECATION",t.EndOfString="END_OF_STRING"})(R=N.ErrorType||(N.ErrorType={}));N.errorMessages=new Map([[R.MalformedUnicode,"malformed Unicode character escape sequence"],[R.MalformedHexadecimal,"malformed hexadecimal character escape sequence"],[R.CodePointLimit,"Unicode codepoint must not be greater than 0x10FFFF in escape sequence"],[R.OctalDeprecation,'"0"-prefixed octal literals and octal escape sequences are deprecated; for octal literals use the "0o" prefix instead'],[R.EndOfString,"malformed escape sequence at end of string"]])});var Pe=Te(T=>{"use strict";Object.defineProperty(T,"__esModule",{value:!0});T.unraw=T.errorMessages=T.ErrorType=void 0;var y=Se();Object.defineProperty(T,"ErrorType",{enumerable:!0,get:function(){return y.ErrorType}});Object.defineProperty(T,"errorMessages",{enumerable:!0,get:function(){return y.errorMessages}});function gr(t){return!t.match(/[^a-f0-9]/i)?parseInt(t,16):NaN}function ee(t,r,e){let o=gr(t);if(Number.isNaN(o)||e!==void 0&&e!==t.length)throw new SyntaxError(y.errorMessages.get(r));return o}function mr(t){let r=ee(t,y.ErrorType.MalformedHexadecimal,2);return String.fromCharCode(r)}function Ve(t,r){let e=ee(t,y.ErrorType.MalformedUnicode,4);if(r!==void 0){let o=ee(r,y.ErrorType.MalformedUnicode,4);return String.fromCharCode(e,o)}return String.fromCharCode(e)}function vr(t){return t.charAt(0)==="{"&&t.charAt(t.length-1)==="}"}function fr(t){if(!vr(t))throw new SyntaxError(y.errorMessages.get(y.ErrorType.MalformedUnicode));let r=t.slice(1,-1),e=ee(r,y.ErrorType.MalformedUnicode);try{return String.fromCodePoint(e)}catch(o){throw o instanceof RangeError?new SyntaxError(y.errorMessages.get(y.ErrorType.CodePointLimit)):o}}function wr(t,r=!1){if(r)throw new SyntaxError(y.errorMessages.get(y.ErrorType.OctalDeprecation));let e=parseInt(t,8);return String.fromCharCode(e)}var xr=new Map([["b","\b"],["f","\f"],["n",`
|
|
2
|
+
`],["r","\r"],["t"," "],["v","\v"],["0","\0"]]);function yr(t){return xr.get(t)||t}var kr=/\\(?:(\\)|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 De(t,r=!1){return t.replace(kr,function(e,o,a,i,s,n,d,h,_){if(o!==void 0)return"\\";if(a!==void 0)return mr(a);if(i!==void 0)return fr(i);if(s!==void 0)return Ve(s,n);if(d!==void 0)return Ve(d);if(h==="0")return"\0";if(h!==void 0)return wr(h,!r);if(_!==void 0)return yr(_);throw new SyntaxError(y.errorMessages.get(y.ErrorType.EndOfString))})}T.unraw=De;T.default=De});var J=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return t.reduce(function(e,o){return e.concat(typeof o=="string"?o:Array.isArray(o)?J.apply(void 0,o):typeof o=="object"&&o?Object.keys(o).map(function(a){return o[a]?a:""}):"")},[]).join(" ")};var Ne=pr(Pe(),1);var P=t=>typeof t=="string",_r=t=>typeof t=="function",$e=new Map,je="en";function fe(t){return[...Array.isArray(t)?t:[t],je]}function we(t,r,e){let o=fe(t);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 re(()=>te("date",o,e),()=>new Intl.DateTimeFormat(o,a)).format(P(r)?new Date(r):r)}function Cr(t,r,e){let o;if(e||(e="default"),typeof e=="string")switch(o={second:"numeric",minute:"numeric",hour:"numeric"},e){case"full":case"long":o.timeZoneName="short";break;case"short":delete o.second}else o=e;return we(t,r,o)}function ge(t,r,e){let o=fe(t);return re(()=>te("number",o,e),()=>new Intl.NumberFormat(o,e)).format(r)}function Ae(t,r,e,{offset:o=0,...a}){var n,d;let i=fe(t),s=r?re(()=>te("plural-ordinal",i),()=>new Intl.PluralRules(i,{type:"ordinal"})):re(()=>te("plural-cardinal",i),()=>new Intl.PluralRules(i,{type:"cardinal"}));return(d=(n=a[e])!=null?n:a[s.select(e-o)])!=null?d:a.other}function re(t,r){let e=t(),o=$e.get(e);return o||(o=r(),$e.set(e,o)),o}function te(t,r,e){let o=r.join("-");return`${t}-${o}-${JSON.stringify(e)}`}var Ie=/\\u[a-fA-F0-9]{4}|\\x[a-fA-F0-9]{2}/,Re="%__lingui_octothorpe__%",zr=(t,r,e={})=>{let o=r||t,a=s=>typeof s=="object"?s:e[s],i=(s,n)=>{let d=Object.keys(e).length?a("number"):void 0,h=ge(o,s,d);return n.replace(new RegExp(Re,"g"),h)};return{plural:(s,n)=>{let{offset:d=0}=n,h=Ae(o,!1,s,n);return i(s-d,h)},selectordinal:(s,n)=>{let{offset:d=0}=n,h=Ae(o,!0,s,n);return i(s-d,h)},select:Mr,number:(s,n)=>ge(o,s,a(n)||{style:n}),date:(s,n)=>we(o,s,a(n)||n),time:(s,n)=>Cr(o,s,a(n)||n)}},Mr=(t,r)=>{var e;return(e=r[t])!=null?e:r.other};function Er(t,r,e){return(o={},a)=>{let i=zr(r,e,a),s=(d,h=!1)=>Array.isArray(d)?d.reduce((_,E)=>{if(E==="#"&&h)return _+Re;if(P(E))return _+E;let[L,z,V]=E,D={};z==="plural"||z==="selectordinal"||z==="select"?Object.entries(V).forEach(([A,H])=>{D[A]=s(H,z==="plural"||z==="selectordinal")}):D=V;let C;if(z){let A=i[z];C=A(o[L],D)}else C=o[L];return C==null?_:_+C},""):d,n=s(t);return P(n)&&Ie.test(n)?(0,Ne.unraw)(n):P(n)?n:n?String(n):""}}var Fr=Object.defineProperty,Lr=(t,r,e)=>r in t?Fr(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,Or=(t,r,e)=>(Lr(t,typeof r!="symbol"?r+"":r,e),e),me=class{constructor(){Or(this,"_events",{})}on(r,e){var a;var o;return(a=(o=this._events)[r])!=null||(o[r]=[]),this._events[r].push(e),()=>this.removeListener(r,e)}removeListener(r,e){let o=this._getListeners(r);if(!o)return;let a=o.indexOf(e);~a&&o.splice(a,1)}emit(r,...e){let o=this._getListeners(r);o&&o.map(a=>a.apply(this,e))}_getListeners(r){let e=this._events[r];return Array.isArray(e)?e:!1}},Tr=Object.defineProperty,Sr=(t,r,e)=>r in t?Tr(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,j=(t,r,e)=>(Sr(t,typeof r!="symbol"?r+"":r,e),e),ve=class extends me{constructor(r){var e;super(),j(this,"_locale",""),j(this,"_locales"),j(this,"_localeData",{}),j(this,"_messages",{}),j(this,"_missing"),j(this,"_messageCompiler"),j(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:je,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 o=this._localeData[r];o?Object.assign(o,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(o=>this._loadLocaleData(o,r[o])),this.emit("change")}_load(r,e){let o=this._messages[r];o?Object.assign(o,e):this._messages[r]=e}load(r,e){typeof r=="string"&&typeof e=="object"?this._load(r,e):Object.entries(r).forEach(([o,a])=>this._load(o,a)),this.emit("change")}loadAndActivate({locale:r,locales:e,messages:o}){this._locale=r,this._locales=e||void 0,this._messages[this._locale]=o,this.emit("change")}activate(r,e){this._locale=r,this._locales=e,this.emit("change")}_(r,e,o){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=o==null?void 0:o.message;r||(r=""),P(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 _r(n)?n(this._locale,r):n;s&&this.emit("missing",{id:r,locale:this._locale});let d=i||a||r;return P(d)&&(this._messageCompiler?d=this._messageCompiler(d):console.warn(`Uncompiled message detected! Message:
|
|
3
3
|
|
|
4
4
|
> ${d}
|
|
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
|
-
`)),P(d)&&Ie.test(d)?JSON.parse(`"${d}"`):P(d)?d:Er(d,this._locale,this._locales)(
|
|
10
|
+
`)),P(d)&&Ie.test(d)?JSON.parse(`"${d}"`):P(d)?d:Er(d,this._locale,this._locales)(e,o==null?void 0:o.formats)}date(r,e){return we(this._locales||this._locale,r,e)}number(r,e){return ge(this._locales||this._locale,r,e)}};function Vr(t={}){return new ve(t)}var F=Vr();var b=function(t,r,e,o){if(e==="a"&&!o)throw new TypeError("Private accessor was defined without a getter");if(typeof r=="function"?t!==r||!o:!r.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?o:e==="a"?o.call(t):o?o.value:r.get(t)},m=function(t,r,e,o,a){if(o==="m")throw new TypeError("Private method is not writable");if(o==="a"&&!a)throw new TypeError("Private accessor was defined without a setter");if(typeof r=="function"?t!==r||!a:!r.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return o==="a"?a.call(t,e):a?a.value=e:r.set(t,e),e};function Ye(t){var r,e,o,a,i,s,n,d,h,_,E,L,z,V,D,C,A,H,ce;class lr extends t{constructor(...c){var u,g,f;super(...c),r.add(this),this.internals=this.attachInternals(),e.set(this,!1),o.set(this,!1),a.set(this,!1),i.set(this,void 0),s.set(this,void 0),n.set(this,!0),h.set(this,""),_.set(this,()=>{m(this,a,!0,"f"),m(this,e,!0,"f"),b(this,r,"m",C).call(this)}),E.set(this,()=>{m(this,e,!1,"f"),b(this,r,"m",A).call(this,this.shouldFormValueUpdate()?b(this,h,"f"):""),!this.validity.valid&&b(this,a,"f")&&m(this,o,!0,"f");let O=b(this,r,"m",C).call(this);this.validationMessageCallback&&this.validationMessageCallback(O?this.internals.validationMessage:"")}),L.set(this,()=>{var O;b(this,n,"f")&&this.validationTarget&&(this.internals.setValidity(this.validity,this.validationMessage,this.validationTarget),m(this,n,!1,"f")),m(this,a,!0,"f"),m(this,o,!0,"f"),b(this,r,"m",C).call(this),(O=this===null||this===void 0?void 0:this.validationMessageCallback)===null||O===void 0||O.call(this,this.showError?this.internals.validationMessage:"")}),z.set(this,void 0),V.set(this,!1),D.set(this,Promise.resolve()),(u=this.addEventListener)===null||u===void 0||u.call(this,"focus",b(this,_,"f")),(g=this.addEventListener)===null||g===void 0||g.call(this,"blur",b(this,E,"f")),(f=this.addEventListener)===null||f===void 0||f.call(this,"invalid",b(this,L,"f")),this.setValue(null)}static get formAssociated(){return!0}static get validators(){return this.formControlValidators||[]}static get observedAttributes(){let c=this.validators.map(f=>f.attribute).flat(),u=super.observedAttributes||[];return[...new Set([...u,...c])]}static getValidator(c){return this.validators.find(u=>u.attribute===c)||null}static getValidators(c){return this.validators.filter(u=>{var g;if(u.attribute===c||!((g=u.attribute)===null||g===void 0)&&g.includes(c))return!0})}get form(){return this.internals.form}get showError(){return b(this,r,"m",C).call(this)}checkValidity(){return this.internals.checkValidity()}get validity(){return this.internals.validity}get validationMessage(){return this.internals.validationMessage}attributeChangedCallback(c,u,g){var f;(f=super.attributeChangedCallback)===null||f===void 0||f.call(this,c,u,g);let B=this.constructor.getValidators(c);B!=null&&B.length&&this.validationTarget&&this.setValue(b(this,h,"f"))}setValue(c){var u;m(this,o,!1,"f"),(u=this.validationMessageCallback)===null||u===void 0||u.call(this,""),m(this,h,c,"f");let f=this.shouldFormValueUpdate()?c:null;this.internals.setFormValue(f),b(this,r,"m",A).call(this,f),this.valueChangedCallback&&this.valueChangedCallback(f),b(this,r,"m",C).call(this)}shouldFormValueUpdate(){return!0}get validationComplete(){return new Promise(c=>c(b(this,D,"f")))}formResetCallback(){var c,u;m(this,a,!1,"f"),m(this,o,!1,"f"),b(this,r,"m",C).call(this),(c=this.resetFormControl)===null||c===void 0||c.call(this),(u=this.validationMessageCallback)===null||u===void 0||u.call(this,b(this,r,"m",C).call(this)?this.validationMessage:"")}}return e=new WeakMap,o=new WeakMap,a=new WeakMap,i=new WeakMap,s=new WeakMap,n=new WeakMap,h=new WeakMap,_=new WeakMap,E=new WeakMap,L=new WeakMap,z=new WeakMap,V=new WeakMap,D=new WeakMap,r=new WeakSet,d=function(){let c=this.getRootNode(),u=`${this.localName}[name="${this.getAttribute("name")}"]`;return c.querySelectorAll(u)},C=function(){if(this.hasAttribute("disabled"))return!1;let c=b(this,o,"f")||b(this,a,"f")&&!this.validity.valid&&!b(this,e,"f");return c&&this.internals.states?this.internals.states.add("--show-error"):this.internals.states&&this.internals.states.delete("--show-error"),c},A=function(c){let u=this.constructor,g={},f=u.validators,O=[],B=f.some(M=>M.isValid instanceof Promise);b(this,V,"f")||(m(this,D,new Promise(M=>{m(this,z,M,"f")}),"f"),m(this,V,!0,"f")),b(this,i,"f")&&(b(this,i,"f").abort(),m(this,s,b(this,i,"f"),"f"));let Z=new AbortController;m(this,i,Z,"f");let q,Fe=!1;f.length&&(f.forEach(M=>{let de=M.key||"customError",I=M.isValid(this,c,Z.signal);I instanceof Promise?(O.push(I),I.then(ue=>{ue!=null&&(g[de]=!ue,q=b(this,r,"m",ce).call(this,M,c),b(this,r,"m",H).call(this,g,q))})):(g[de]=!I,this.validity[de]!==!I&&(Fe=!0),!I&&!q&&(q=b(this,r,"m",ce).call(this,M,c)))}),Promise.allSettled(O).then(()=>{var M;Z!=null&&Z.signal.aborted||(m(this,V,!1,"f"),(M=b(this,z,"f"))===null||M===void 0||M.call(this))}),(Fe||!B)&&b(this,r,"m",H).call(this,g,q))},H=function(c,u){if(this.validationTarget)this.internals.setValidity(c,u,this.validationTarget),m(this,n,!1,"f");else{if(this.internals.setValidity(c,u),this.internals.validity.valid)return;m(this,n,!0,"f")}},ce=function(c,u){if(this.validityCallback){let g=this.validityCallback(c.key||"customError");if(g)return g}return c.message instanceof Function?c.message(this,u):c.message},lr}import{css as Zr,html as K,LitElement as qr}from"lit";import{property as k}from"lit/decorators.js";import{ifDefined as _e}from"lit/directives/if-defined.js";import{when as Ce}from"lit/directives/when.js";var Dr=["en","nb","fi","da","sv"],xe="en",oe=t=>Dr.find(r=>t===r||t.toLowerCase().includes(r))||xe;function ae(){if(typeof window=="undefined"){let t=process.env.NMP_LANGUAGE||Intl.DateTimeFormat().resolvedOptions().locale;return oe(t)}try{let t=He(document);if(t)return oe(t);let r=Nr();if(r)return oe(r);let e=He(Ze());return e?oe(e):xe}catch(t){return console.warn("could not detect locale, falling back to source locale",t),xe}}var Xe=(t,r,e,o,a)=>{F.load("en",t),F.load("nb",r),F.load("fi",e),F.load("da",o),F.load("sv",a);let i=ae();F.activate(i),Be(),$r()},Pr="warp-i18n-change";function Be(){typeof window!="undefined"&&window.dispatchEvent(new Event(Pr))}var Ue=!1;function $r(){if(Ue||typeof window=="undefined"||!(document!=null&&document.documentElement))return;Ue=!0;let t=()=>{let a=ae();F.locale!==a&&(F.activate(a),Be())},r=new MutationObserver(a=>{for(let i of a)if(i.type==="attributes"&&i.attributeName==="lang"){t();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 o=Ar();o&&r.observe(o,{attributes:!0,attributeFilter:["lang"]})}function Ze(){var t,r;try{return(r=(t=window.parent)==null?void 0:t.document)!=null?r:null}catch(e){return null}}function He(t){var r,e;try{return(e=(r=t==null?void 0:t.documentElement)==null?void 0:r.lang)!=null?e:""}catch(o){return""}}function Ar(){var t;try{return(t=window.frameElement)!=null?t:null}catch(r){return null}}function Nr(){var t,r,e;try{return(e=(r=(t=window.frameElement)==null?void 0:t.getAttribute)==null?void 0:r.call(t,"lang"))!=null?e:""}catch(o){return""}}import{css as qe}from"lit";var Ge=qe`
|
|
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
|
-
`,
|
|
283
|
+
`,st=qe`*, :before, :after {
|
|
284
284
|
--w-rotate: 0;
|
|
285
285
|
--w-rotate-x: 0;
|
|
286
286
|
--w-rotate-y: 0;
|
|
@@ -2446,7 +2446,7 @@ Please compile your catalog first.
|
|
|
2446
2446
|
display: none
|
|
2447
2447
|
}
|
|
2448
2448
|
}
|
|
2449
|
-
`;var Je=JSON.parse('{"select.label.optional":["(valgfrit)"]}');var Ke=JSON.parse('{"select.label.optional":["(optional)"]}');var Qe=JSON.parse('{"select.label.optional":["(vapaaehtoinen)"]}');var We=JSON.parse('{"select.label.optional":["(valgfritt)"]}');var er=JSON.parse('{"select.label.optional":["(valfritt)"]}');import{css as jr}from"lit";var rr=jr`*,: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}.focus\\:\\[--w-outline-offset\\:-2px\\]:focus{--w-outline-offset:-2px}.bg-transparent{background-color:#0000}.appearance-none{-webkit-appearance:none;appearance:none}.border-0{border-width:0}.border-1{border-width:1px}.rounded-4{border-radius:4px}.caret-current{caret-color:currentColor}.opacity-25{opacity:.25}.block,.before\\:block:before{display:block}.before\\:hidden:before{display:none}.focusable:focus{outline:2px solid var(--w-s-color-border-focus);outline-offset:var(--w-outline-offset,1px)}.focusable:focus-visible{outline:2px solid var(--w-s-color-border-focus);outline-offset:var(--w-outline-offset,1px)}.focusable:not(:focus-visible){outline:none}.outline-\\[--w-s-color-border-negative\\]\\!{outline-color:var(--w-s-color-border-negative)!important}.bottom-0{bottom:0}.right-0{right:0}.before\\:bottom-0:before{bottom:0}.before\\:right-0:before{right:0}.top-\\[30\\%\\]{top:30%}.absolute{position:absolute}.relative{position:relative}.static{position:static}.before\\:absolute:before{position:absolute}.s-bg{background-color:var(--w-s-color-background)}.s-bg-disabled-subtle{background-color:var(--w-s-color-background-disabled-subtle)}.s-text{color:var(--w-s-color-text)}.s-text-disabled{color:var(--w-s-color-text-disabled)}.s-text-negative{color:var(--w-s-color-text-negative)}.s-text-subtle{color:var(--w-s-color-text-subtle)}.s-icon{color:var(--w-s-color-icon)}.s-border-disabled{border-color:var(--w-s-color-border-disabled)}.s-border-negative{border-color:var(--w-s-color-border-negative)}.s-border-strong{border-color:var(--w-s-color-border-strong)}.hover\\:s-border-disabled:hover{border-color:var(--w-s-color-border-disabled)}.hover\\:s-border-negative-hover:hover{border-color:var(--w-s-color-border-negative-hover)}.hover\\:s-border-strong-hover:hover{border-color:var(--w-s-color-border-strong-hover)}.active\\:s-border-active:active{border-color:var(--w-s-color-border-active)}.active\\:s-border-disabled:active{border-color:var(--w-s-color-border-disabled)}.h-full{height:100%}.w-32{width:3.2rem}.w-full{width:100%}.before\\:h-full:before{height:100%}.before\\:w-32:before{width:3.2rem}.mb-0{margin-bottom:0}.mt-4{margin-top:.4rem}.py-12{padding-top:1.2rem;padding-bottom:1.2rem}.pb-4{padding-bottom:.4rem}.pl-0{padding-left:0}.pl-8{padding-left:.8rem}.pr-32{padding-right:3.2rem}.cursor-pointer{cursor:pointer}.antialiased{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-smoothing:grayscale}.font-bold{font-weight:700}.font-normal{font-weight:400}.pointer-events-none,.before\\:pointer-events-none:before{pointer-events:none}.text-m{font-size:var(--w-font-size-m);line-height:var(--w-line-height-m)}.text-s{font-size:var(--w-font-size-s);line-height:var(--w-line-height-s)}.text-xs{font-size:var(--w-font-size-xs);line-height:var(--w-line-height-xs)}`;import{html as Rr,LitElement as Yr}from"lit";import{property as ye,state as Ur}from"lit/decorators.js";import{classMap as Hr}from"lit/directives/class-map.js";import{css as Ir}from"lit";var
|
|
2449
|
+
`;var Je=JSON.parse('{"select.label.optional":["(valgfrit)"]}');var Ke=JSON.parse('{"select.label.optional":["(optional)"]}');var Qe=JSON.parse('{"select.label.optional":["(vapaaehtoinen)"]}');var We=JSON.parse('{"select.label.optional":["(valgfritt)"]}');var er=JSON.parse('{"select.label.optional":["(valfritt)"]}');import{css as jr}from"lit";var rr=jr`*,: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}.focus\\:\\[--w-outline-offset\\:-2px\\]:focus{--w-outline-offset:-2px}.bg-transparent{background-color:#0000}.appearance-none{-webkit-appearance:none;appearance:none}.border-0{border-width:0}.border-1{border-width:1px}.rounded-4{border-radius:4px}.caret-current{caret-color:currentColor}.opacity-25{opacity:.25}.block,.before\\:block:before{display:block}.before\\:hidden:before{display:none}.focusable:focus{outline:2px solid var(--w-s-color-border-focus);outline-offset:var(--w-outline-offset,1px)}.focusable:focus-visible{outline:2px solid var(--w-s-color-border-focus);outline-offset:var(--w-outline-offset,1px)}.focusable:not(:focus-visible){outline:none}.outline-\\[--w-s-color-border-negative\\]\\!{outline-color:var(--w-s-color-border-negative)!important}.bottom-0{bottom:0}.right-0{right:0}.before\\:bottom-0:before{bottom:0}.before\\:right-0:before{right:0}.top-\\[30\\%\\]{top:30%}.absolute{position:absolute}.relative{position:relative}.static{position:static}.before\\:absolute:before{position:absolute}.s-bg{background-color:var(--w-s-color-background)}.s-bg-disabled-subtle{background-color:var(--w-s-color-background-disabled-subtle)}.s-text{color:var(--w-s-color-text)}.s-text-disabled{color:var(--w-s-color-text-disabled)}.s-text-negative{color:var(--w-s-color-text-negative)}.s-text-subtle{color:var(--w-s-color-text-subtle)}.s-icon{color:var(--w-s-color-icon)}.s-border-disabled{border-color:var(--w-s-color-border-disabled)}.s-border-negative{border-color:var(--w-s-color-border-negative)}.s-border-strong{border-color:var(--w-s-color-border-strong)}.hover\\:s-border-disabled:hover{border-color:var(--w-s-color-border-disabled)}.hover\\:s-border-negative-hover:hover{border-color:var(--w-s-color-border-negative-hover)}.hover\\:s-border-strong-hover:hover{border-color:var(--w-s-color-border-strong-hover)}.active\\:s-border-active:active{border-color:var(--w-s-color-border-active)}.active\\:s-border-disabled:active{border-color:var(--w-s-color-border-disabled)}.h-full{height:100%}.w-32{width:3.2rem}.w-full{width:100%}.before\\:h-full:before{height:100%}.before\\:w-32:before{width:3.2rem}.mb-0{margin-bottom:0}.mt-4{margin-top:.4rem}.py-12{padding-top:1.2rem;padding-bottom:1.2rem}.pb-4{padding-bottom:.4rem}.pl-0{padding-left:0}.pl-8{padding-left:.8rem}.pr-32{padding-right:3.2rem}.cursor-pointer{cursor:pointer}.antialiased{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-smoothing:grayscale}.font-bold{font-weight:700}.font-normal{font-weight:400}.pointer-events-none,.before\\:pointer-events-none:before{pointer-events:none}.text-m{font-size:var(--w-font-size-m);line-height:var(--w-line-height-m)}.text-s{font-size:var(--w-font-size-s);line-height:var(--w-line-height-s)}.text-xs{font-size:var(--w-font-size-xs);line-height:var(--w-line-height-xs)}`;import{html as Rr,LitElement as Yr}from"lit";import{property as ye,state as Ur}from"lit/decorators.js";import{classMap as Hr}from"lit/directives/class-map.js";import{css as Ir}from"lit";var tr=Ir`
|
|
2450
2450
|
:host {
|
|
2451
2451
|
display: inline-block;
|
|
2452
2452
|
}
|
|
@@ -2471,10 +2471,10 @@ Please compile your catalog first.
|
|
|
2471
2471
|
--w-icon-size: 32px;
|
|
2472
2472
|
}
|
|
2473
2473
|
|
|
2474
|
-
`;var ke=new Map,Xr='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"></svg>';function Br(
|
|
2475
|
-
${Ce(this.label,()=>K`<label class="${
|
|
2474
|
+
`;var ke=new Map,Xr='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"></svg>';function Br(t,r={}){var o;let e=(o=r.responseParser)!=null?o:(a=>a.text());return ke.has(t)||ke.set(t,fetch(t).then(e)),ke.get(t)}var $=class extends Yr{constructor(){super(...arguments);this.locale=document.documentElement.lang||"en";this.svg=null}async fetchIcon(e){let o=`https://assets.finn.no/pkg/eikons/v1/${this.locale}/${e}.svg`;try{let a=await Br(o);return new DOMParser().parseFromString(a,"text/html").body.querySelector("svg")}catch(a){return null}}firstUpdated(){this.loadIcon()}updated(e){(e.has("name")||e.has("locale"))&&this.loadIcon()}async loadIcon(){if(!this.name){this.svg=null;return}let e=await this.fetchIcon(this.name);e||(e=new DOMParser().parseFromString(Xr,"text/html").body.firstElementChild),this.svg=e}render(){let e=this.size||"medium",o=this.name||"",a={"w-icon":!0,"w-icon--s":e==="small","w-icon--m":e==="medium","w-icon--l":e==="large"},i=typeof e=="string"&&e.endsWith("px")?`--w-icon-size: ${e};`:"";return Rr`<div class="${Hr(a)}" style="${i}" part="w-${o.toLowerCase()}">${this.svg}</div>`}};$.styles=[tr],p([ye({type:String,reflect:!0})],$.prototype,"name",2),p([ye({type:String,reflect:!0})],$.prototype,"size",2),p([ye({type:String,reflect:!0,useDefault:!0})],$.prototype,"locale",2),p([Ur()],$.prototype,"svg",2);customElements.get("w-icon")||customElements.define("w-icon",$);var S={base:"block text-m mb-0 py-12 pr-32 rounded-4 w-full focusable focus:[--w-outline-offset:-2px] appearance-none cursor-pointer caret-current",default:"s-text s-bg pl-8 border-1 s-border-strong hover:s-border-strong-hover active:s-border-active",disabled:"s-text-disabled s-bg-disabled-subtle pl-8 border-1 s-border-disabled hover:s-border-disabled active:s-border-disabled pointer-events-none",invalid:"s-text s-bg pl-8 border-1 s-border-negative hover:s-border-negative-hover active:s-border-active outline-[--w-s-color-border-negative]!",readOnly:"s-text bg-transparent pl-0 border-0 pointer-events-none before:hidden",wrapper:"relative",selectWrapper:"relative before:block before:absolute before:right-0 before:bottom-0 before:w-32 before:h-full before:pointer-events-none ",chevron:"block absolute top-[30%] right-0 bottom-0 w-32 h-full s-icon pointer-events-none cursor-pointer",chevronDisabled:"opacity-25"},or={base:"antialiased block relative text-s font-bold pb-4 cursor-pointer s-text",optional:"pl-8 font-normal text-s s-text-subtle"},ze={base:"text-xs mt-4 block",color:"s-text-subtle",colorInvalid:"s-text-negative"},Q,W,U,l,Me,ie,ar,Y,se,Ee,ir,sr,nr,ne,le,v=class extends Ye(qr){constructor(){super();G(this,l);this.autoFocus=!1;this.autofocus=!1;this.invalid=!1;this.always=!1;this.optional=!1;this.disabled=!1;this.readOnly=!1;this.readonly=!1;G(this,Q,null);G(this,W,()=>w(this,l,se).call(this));G(this,U);this._setValue=e=>{this.value=e,this.setValue(e)};Xe(Ke,We,Qe,Je,er)}resetFormControl(){this.value=x(this,Q)}connectedCallback(){var e,o;super.connectedCallback(),pe(this,Q,this.value),(this.autofocus||this.autoFocus)&&this.shadowRoot.querySelector("select").focus(),w(this,l,Ee).call(this,{syncValueFromSelected:!0}),(o=(e=this.ownerDocument)==null?void 0:e.defaultView)==null||o.addEventListener("pageshow",x(this,W)),pe(this,U,new MutationObserver(()=>{w(this,l,Ee).call(this,{syncValueFromSelected:!0})})),x(this,U).observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["selected","disabled","value"]})}disconnectedCallback(){var e,o,a;super.disconnectedCallback(),(o=(e=this.ownerDocument)==null?void 0:e.defaultView)==null||o.removeEventListener("pageshow",x(this,W)),(a=x(this,U))==null||a.disconnect()}firstUpdated(){this.value&&w(this,l,Y).call(this,this.value),w(this,l,se).call(this,{allowDefaultFirstOption:!1})}formStateRestoreCallback(e,o){if(typeof e=="string"&&e){this._setValue(e),w(this,l,Y).call(this,e);return}w(this,l,se).call(this,{allowDefaultFirstOption:!0})}willUpdate(e){e.has("value")&&this.setValue(this.value)}updated(e){var o,a;if(e.has("value")){let i=w(this,l,ie).call(this);i&&i.value!==this.value&&(i.value=(o=this.value)!=null?o:""),w(this,l,Y).call(this,(a=this.value)!=null?a:"")}}handleKeyDown(e){if((this.readonly||this.readOnly)&&(e.key===" "||e.key==="ArrowDown"||e.key==="ArrowUp")&&e.preventDefault(),e.key==="Enter"&&this.internals.form){this.internals.form.requestSubmit();return}}onChange(e){let a=e.currentTarget.value;e.stopPropagation(),this._setValue(a),w(this,l,Y).call(this,a),this.dispatchEvent(new CustomEvent("change",{detail:a,bubbles:!0,composed:!0}))}render(){return K`<div class="${S.wrapper}">
|
|
2475
|
+
${Ce(this.label,()=>K`<label class="${or.base}" for="${x(this,l,ne)}">
|
|
2476
2476
|
${this.label}
|
|
2477
|
-
${Ce(this.optional,()=>K`<span class="${
|
|
2477
|
+
${Ce(this.optional,()=>K`<span class="${or.optional}"
|
|
2478
2478
|
>${F._({id:"select.label.optional",message:"(optional)",comment:"Shown behind label when marked as optional"})}</span
|
|
2479
2479
|
>`)}</label
|
|
2480
2480
|
>`)}
|
|
@@ -2496,12 +2496,12 @@ Please compile your catalog first.
|
|
|
2496
2496
|
</div>
|
|
2497
2497
|
</div>
|
|
2498
2498
|
${Ce(this.helpText||this.always||this.invalid,()=>K`<div id="${x(this,l,le)}" class="${x(this,l,sr)}">${this.helpText||this.hint}</div>`)}
|
|
2499
|
-
</div>`}};Q=new WeakMap,W=new WeakMap,U=new WeakMap,l=new WeakSet,Me=function(){return Array.from(this.children).filter(
|
|
2499
|
+
</div>`}};Q=new WeakMap,W=new WeakMap,U=new WeakMap,l=new WeakSet,Me=function(){return Array.from(this.children).filter(e=>e.tagName.toLowerCase()==="option"||e.tagName.toLowerCase()==="w-option")},ie=function(){var e;return(e=this.shadowRoot)==null?void 0:e.querySelector("select")},ar=function(){return w(this,l,Me).call(this).some(e=>e.hasAttribute("selected"))},Y=function(e){let o=w(this,l,ie).call(this);if(!o)return;let a=!1;for(let i of Array.from(o.options)){let s=!a&&i.value===e;i.selected=s,i.toggleAttribute("selected",s),s&&(a=!0)}},se=function({allowDefaultFirstOption:e=!1}={}){let o=w(this,l,ie).call(this);if(!o)return;let a=o.value;!a||a===this.value||!e&&!this.value&&!w(this,l,ar).call(this)&&o.selectedIndex===0||(this._setValue(a),w(this,l,Y).call(this,a))},Ee=function({syncValueFromSelected:e=!1}={}){let o=w(this,l,Me).call(this),a,i=o.map(s=>{var E,L;let n=(E=s.getAttribute("value"))!=null?E:"",d=(L=s.textContent)!=null?L:"",h=s.hasAttribute("selected"),_=s.hasAttribute("disabled");return e&&a===void 0&&h&&(a=n),K`<option value="${n}" ?selected=${h} ?disabled=${_}>${d}</option>`});this._options=i,e&&a!==void 0&&a!==this.value&&this._setValue(a)},ir=function(){return J([S.base,!this.invalid&&!this.disabled&&!(this.readonly||this.readOnly)&&S.default,this.invalid&&S.invalid,this.disabled&&S.disabled,(this.readonly||this.readOnly)&&S.readOnly])},sr=function(){return J([ze.base,this.invalid?ze.colorInvalid:ze.color])},nr=function(){return J([S.chevron,this.disabled&&S.chevronDisabled])},ne=function(){return"select_id"},le=function(){return this.helpText||this.hint?`${x(this,l,ne)}__hint`:void 0},v.styles=[Ge,rr,Zr`
|
|
2500
2500
|
/* if there is an option with an empty value and it is selected */
|
|
2501
2501
|
select:has(option[value=""][selected]),
|
|
2502
2502
|
/* if there is an option with an empty value, and no other options are selected */
|
|
2503
2503
|
select:has(option[value=""]):not(:has(option[selected])) {
|
|
2504
2504
|
color: var(--w-s-color-text-placeholder);
|
|
2505
2505
|
}
|
|
2506
|
-
`],p([k({attribute:"auto-focus",type:Boolean,reflect:!0})],
|
|
2506
|
+
`],p([k({attribute:"auto-focus",type:Boolean,reflect:!0})],v.prototype,"autoFocus",2),p([k({type:Boolean,reflect:!0})],v.prototype,"autofocus",2),p([k({attribute:"help-text",reflect:!0})],v.prototype,"helpText",2),p([k({type:Boolean,reflect:!0})],v.prototype,"invalid",2),p([k({type:Boolean,reflect:!0})],v.prototype,"always",2),p([k({reflect:!0})],v.prototype,"hint",2),p([k({reflect:!0})],v.prototype,"label",2),p([k({type:Boolean,reflect:!0})],v.prototype,"optional",2),p([k({type:Boolean,reflect:!0})],v.prototype,"disabled",2),p([k({attribute:"read-only",type:Boolean,reflect:!0})],v.prototype,"readOnly",2),p([k({type:Boolean,reflect:!0})],v.prototype,"readonly",2),p([k({attribute:!1,state:!0})],v.prototype,"_options",2),p([k({reflect:!0})],v.prototype,"name",2),p([k({reflect:!0})],v.prototype,"value",2);customElements.get("w-select")||customElements.define("w-select",v);export{v as WarpSelect};
|
|
2507
2507
|
//# sourceMappingURL=select.js.map
|