@cfpb/cfpb-design-system 3.14.0 → 3.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -1
- package/dist/components/cfpb-expandables/index.js +1 -1
- package/dist/components/cfpb-expandables/index.js.map +4 -4
- package/dist/components/cfpb-forms/index.js +1 -1
- package/dist/components/cfpb-forms/index.js.map +4 -4
- package/dist/elements/cfpb-button/index.js +3 -3
- package/dist/elements/cfpb-button/index.js.map +2 -2
- package/dist/elements/cfpb-file-upload/index.js +4 -3
- package/dist/elements/cfpb-file-upload/index.js.map +4 -4
- package/dist/index.js +4 -4
- package/dist/index.js.map +2 -2
- package/package.json +2 -1
- package/src/elements/cfpb-button/index.js +5 -3
- package/src/elements/cfpb-file-upload/index.js +10 -3
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(()=>{var ve=Object.defineProperty;var ge=Object.getOwnPropertySymbols;var Be=Object.prototype.hasOwnProperty,Pe=Object.prototype.propertyIsEnumerable;var me=(t,r,e)=>r in t?ve(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,J=(t,r)=>{for(var e in r||(r={}))Be.call(r,e)&&me(t,e,r[e]);if(ge)for(var e of ge(r))Pe.call(r,e)&&me(t,e,r[e]);return t};var O=(t,r)=>{for(var e in r)ve(t,e,{get:r[e],enumerable:!0})};var W={};O(W,{default:()=>Fe});var Fe={};var Q={};O(Q,{default:()=>ze});var ze={};var ee={};O(ee,{default:()=>Ve});var Ve={};var te={};O(te,{default:()=>Ue});var Ue={};var re={};O(re,{default:()=>Ge});var Ge={};var ae={};O(ae,{default:()=>qe});var qe={};var oe={};O(oe,{default:()=>$e});var $e={};var ie={};O(ie,{default:()=>We});var We={};var ne={};O(ne,{default:()=>et});var et={};var le={};O(le,{default:()=>rt});var rt={};var N="data-js-hook",K="behavior_",ce="state_";function T(){let t={};function r(a,o){return{}.hasOwnProperty.call(t,a)?t[a].push(o):t[a]=[o],this}function e(a,o){if(!{}.hasOwnProperty.call(t,a))return this;let u=t[a].indexOf(o);return u!==-1&&t[a].splice(u,1),this}function n(a,o){if(!{}.hasOwnProperty.call(t,a))return this;o=o||{};let u=t[a];for(let s=0,d=u.length;s<d;s++)u[s].call(this,o);return this}return this.addEventListener=r,this.removeEventListener=e,this.dispatchEvent=n,this.getRegisteredEvents=()=>t,this}function R(t,r){if(!t)return!1;let e=t.getAttribute(N);return e?(e=e.split(" "),e.indexOf(r)>-1):!1}function de(t,r){if(R(t,r))return r;if(r.indexOf(" ")!==-1){let n=N+" values cannot contain spaces!";throw new Error(n)}let e=t.getAttribute(N);return e!==null&&(r=e+" "+r),t.setAttribute(N,r),r}var se=ce+"atomic_init";function at(t,r){if(!t||!t.classList){let e=t+' is not valid. Check that element is a DOM node with class "'+r+'"';throw new Error(e)}return t}function ot(t,r){let e=t.classList.contains(r)?t:t.querySelector("."+r);if(!e){let n=r+" not found on or in passed DOM node.";throw new Error(n)}return e}function ue(t,r){return at(t,r),ot(t,r)}function G(t){return R(t,se)?!1:(de(t,se),!0)}function fe(t,r,e,n={}){let o=(e||document).querySelectorAll(t),u=[],s,d;for(let h=0,x=o.length;h<x;h++)d=o[h],R(d,se)===!1&&(s=new r(d),s.init(n),u.push(s));return u}var it=Object.prototype.toString;var nt=Array.isArray||function(r){return it.call(r)==="[object Array]"};function pe(){return!!new RegExp(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i).test(navigator.userAgent)}function g(t,r,e){let n=r,a=t;if(!e)throw new Error("Child transition argument must be defined!");let o=e,u,s,d,h=!1,x=!1,w=!1;if(typeof n.CSS_PROPERTY=="undefined"||typeof n.BASE_CLASS=="undefined")throw new Error("Transitions require CSS_PROPERTY and BASE_CLASS to be passed into BaseTransition.");function y(){s&&h?(a.addEventListener(s,d),o.dispatchEvent(g.BEGIN_EVENT,{target:o,type:g.BEGIN_EVENT}),a.classList.add(g.ANIMATING_CLASS),x=!0):(o.dispatchEvent(g.BEGIN_EVENT,{target:o,type:g.BEGIN_EVENT}),d())}function m(){a.removeEventListener(s,d)}function C(b){return b&&b.propertyName!==n.CSS_PROPERTY?!1:(m(),a.classList.remove(g.ANIMATING_CLASS),o.dispatchEvent(g.END_EVENT,{target:o,type:g.END_EVENT}),x=!1,!0)}function k(){let b;for(b in n)({}).hasOwnProperty.call(n,b)&&n[b]!==n.BASE_CLASS&&a.classList.contains(n[b])&&a.classList.remove(n[b])}function P(){x&&(a.style.webkitTransitionDuration="0",a.style.mozTransitionDuration="0",a.style.oTransitionDuration="0",a.style.transitionDuration="0",a.removeEventListener(s,d),d(),a.style.webkitTransitionDuration="",a.style.mozTransitionDuration="",a.style.oTransitionDuration="",a.style.transitionDuration="")}function D(){P(),k(),a.classList.remove(n.BASE_CLASS)}function H(){a.classList.remove(g.NO_ANIMATION_CLASS),h=!0}function z(){a.classList.add(g.NO_ANIMATION_CLASS),h=!1}function j(b){if(!b){let U="Element does not have TransitionEnd event. It may be null!";throw new Error(U)}let L,I={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"},B;for(B in I)if({}.hasOwnProperty.call(I,B)&&typeof b.style[B]!="undefined"){L=I[B];break}return L}function p(b){D(),H(),a=b,a.classList.add(n.BASE_CLASS),s=j(a)}function v(b){if(h=!a.classList.contains(g.NO_ANIMATION_CLASS),d=C.bind(this),p(a),!b)throw new Error("Transition needs to be passed an initial CSS class on initialization!");return a.classList.add(b),this}function _(b){return w||(k(),w=!0),a.classList.contains(b)?!1:(m(),a.classList.remove(u),u=b,y(),a.classList.add(u),!0)}return this.animateOff=z,this.animateOn=H,this.applyClass=_,this.halt=P,this.init=v,this.isAnimated=()=>h,this.remove=D,this.setElement=p,this}g.BEGIN_EVENT="transitionbegin";g.END_EVENT="transitionend";g.NO_ANIMATION_CLASS="u-no-animation";g.ANIMATING_CLASS="u-is-animating";var dt=K+"flyout-menu",Gt="["+N+"="+dt;var Y={CSS_PROPERTY:"opacity",BASE_CLASS:"u-alpha-transition",ALPHA_100:"u-alpha-100",ALPHA_0:"u-alpha-0"};function xe(t){let r=new T,e=new g(t,Y,this);function n(u){return e.init(u),this}function a(){return e.applyClass(Y.ALPHA_100),this}function o(){return e.applyClass(Y.ALPHA_0),this}return this.addEventListener=r.addEventListener,this.dispatchEvent=r.dispatchEvent,this.removeEventListener=r.removeEventListener,this.animateOff=e.animateOff,this.animateOn=e.animateOn,this.halt=e.halt,this.isAnimated=e.isAnimated,this.remove=e.remove,this.setElement=e.setElement,this.fadeIn=a,this.fadeOut=o,this.init=n,this}xe.CLASSES=Y;var X={CSS_PROPERTY:"max-height",BASE_CLASS:"u-max-height-transition",MH_DEFAULT:"u-max-height-default",MH_SUMMARY:"u-max-height-summary",MH_ZERO:"u-max-height-zero"};function ye(t){let r=new T,e=new g(t,X,this),n=0;function a(){let y=t.scrollHeight+"px";t.style.maxHeight=y}function o(){window.removeEventListener("load",o),a()}function u(w){return e.init(w),window.addEventListener("load",o),window.addEventListener("resize",()=>{a()}),this}function s(){return a(),e.applyClass(X.MH_DEFAULT),(!n||t.scrollHeight>n)&&(n=t.scrollHeight),this}function d(){return e.applyClass(X.MH_SUMMARY),n=t.scrollHeight,this}function h(){return e.applyClass(X.MH_ZERO),n=t.scrollHeight,this}function x(){return t.style.maxHeight="",e.remove()}return this.addEventListener=r.addEventListener,this.dispatchEvent=r.dispatchEvent,this.removeEventListener=r.removeEventListener,this.animateOff=e.animateOff,this.animateOn=e.animateOn,this.halt=e.halt,this.isAnimated=e.isAnimated,this.setElement=e.setElement,this.refresh=a,this.remove=x,this.init=u,this.maxHeightDefault=s,this.maxHeightSummary=d,this.maxHeightZero=h,this}ye.CLASSES=X;var M={CSS_PROPERTY:"transform",BASE_CLASS:"u-move-transition",MOVE_TO_ORIGIN:"u-move-to-origin",MOVE_LEFT:"u-move-left",MOVE_LEFT_2X:"u-move-left-2x",MOVE_LEFT_3X:"u-move-left-3x",MOVE_RIGHT:"u-move-right",MOVE_UP:"u-move-up"};function we(t){let r=new T,e=new g(t,M,this);function n(d){return e.init(d),this}function a(){return e.applyClass(M.MOVE_TO_ORIGIN),this}function o(d){d=d||1;let h=[M.MOVE_LEFT,M.MOVE_LEFT_2X,M.MOVE_LEFT_3X];return e.applyClass(h[d-1]),this}function u(){return e.applyClass(M.MOVE_RIGHT),this}function s(){return e.applyClass(M.MOVE_UP),this}return this.addEventListener=r.addEventListener,this.dispatchEvent=r.dispatchEvent,this.removeEventListener=r.removeEventListener,this.animateOff=e.animateOff,this.animateOn=e.animateOn,this.halt=e.halt,this.isAnimated=e.isAnimated,this.setElement=e.setElement,this.remove=e.remove,this.init=n,this.moveLeft=()=>o(1),this.moveLeft2=()=>o(2),this.moveLeft3=()=>o(3),this.moveRight=u,this.moveToOrigin=a,this.moveUp=s,this}we.CLASSES=M;var st;function ut(t){return t.replace(/[-\\^$*+?.()|[\]{}]/g,"\\$&")}function ft(t,r){return RegExp(ut(r.trim()),"i").test(t)}function pt(t,r,e){let n=t,a=r,o=(e==null?void 0:e.maxSelections)||5,u=[],s=[],d=[],h=[],x=-1;function w(p){return a+"-"+p.value.trim().replace(/\s+/g,"-").toLowerCase()}function y(){return s.length>=o}function m(p){let v,_=[],b=!1;for(let L=0,I=p.length;L<I;L++)v=p[L],b=y()?!1:v.defaultSelected,_.push({id:w(v),value:v.value,text:v.text,checked:b}),b&&s.push(L);return _}function C(){return u=m(n),this}function k(p){return u[p].checked=!u[p].checked,s.length<o&&u[p].checked?(s.push(p),s.sort(),!0):(u[p].checked=!1,s=s.filter(function(v){return v!==p}),!1)}function P(p,v,_,b){return ft(v.text,b)&&p.push(_),p}function D(p){return Object.prototype.toString.call(p)!=="[object String]"&&(p=""),h=d,u.length>0&&(d=u.reduce(function(v,_,b){return P(v,_,b,p)},[])),x=-1,d}function H(p){return u[p]}function z(p){let v=d.length,_=v===0?u.length:v;p<0?x=-1:p>=_?x=_-1:x=p}function j(){return x}return this.init=C,this.toggleOption=k,this.getSelectedIndices=function(){return s},this.isAtMaxSelections=y,this.filterIndices=D,this.clearFilter=function(){return d=h=[],st},this.getFilterIndices=function(){return d},this.getLastFilterIndices=function(){return h},this.getIndex=j,this.setIndex=z,this.resetIndex=function(){return x=-1,x},this.getOption=H,this}var _e=pt;function S(t,r,e){let n=document.createElement(t);return Object.keys(e).forEach(a=>{let o=e[a];a in n?n[a]=o:n.setAttribute(a,o)}),r&&r.appendChild(n),n}var ke='<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" class="cf-icon-svg cf-icon-svg--error" viewBox="0 0 12 19"><path d="M11.383 13.644A1.03 1.03 0 0 1 9.928 15.1L6 11.172 2.072 15.1a1.03 1.03 0 1 1-1.455-1.456l3.928-3.928L.617 5.79a1.03 1.03 0 1 1 1.455-1.456L6 8.261l3.928-3.928a1.03 1.03 0 0 1 1.455 1.456L7.455 9.716z"/></svg>';var vt=ke,A="o-multiselect",xt="a-checkbox",yt="a-text-input",Ee="prev",q="next",be="Enter",wt=" ",Le="Escape",_t="ArrowUp",Se="ArrowDown",Ae="Tab",Oe={renderTags:!0,maxSelections:5};function Z(t){t.classList.add(A);let r=ue(t,A),e=!1,n,a,o,u,s,d,h,x,w,y,m,C=[],k;function P(){m.classList.remove("u-no-results"),m.classList.add("u-filtered");let l=o.getLastFilterIndices();for(let i=0,c=l.length;i<c;i++)C[l[i]].classList.remove("u-filter-match");l=o.getFilterIndices();for(let i=0,c=l.length;i<c;i++)C[l[i]].classList.add("u-filter-match")}function D(){m.classList.remove("u-filtered","u-no-results");for(let l=0,i=m.children.length;l<i;l++)m.children[l].classList.remove("u-filter-match");o.clearFilter()}function H(){m.classList.add("u-no-results"),m.classList.remove("u-filtered")}function z(l){return l.length>0?(P(),!0):(H(),!1)}function j(l){D(),o.resetIndex();let i=o.filterIndices(l);z(i)}function p(){return d.classList.add("u-active"),y.classList.remove("u-invisible"),y.setAttribute("aria-hidden",!1),k.dispatchEvent("expandbegin",{target:k}),k}function v(){return d.classList.remove("u-active"),y.classList.add("u-invisible"),y.setAttribute("aria-hidden",!0),o.resetIndex(),k.dispatchEvent("collapsebegin",{target:k}),k}function _(l){l===q?o.setIndex(o.getIndex()+1):l===Ee&&o.setIndex(o.getIndex()-1);let i=o.getIndex();if(i>-1){let c=i,f=o.getFilterIndices();f.length>0&&(c=f[i]);let V=o.getOption(c).value,De=m.querySelector('[data-option="'+V+'"]').querySelector("input");e=!0,De.focus()}else e=!1,w.focus()}function b(){w.value="",D()}function L(l){let i=l.target;i.tagName==="BUTTON"&&(l.preventDefault(),i.removeEventListener("click",L),i.querySelector("label").click())}function I(l){if(l.key===wt||l.key===be){let i=l.target.querySelector("label");m.querySelector("#"+i.getAttribute("for")).click()}}function B(l){return n+"-"+l.value.trim().replace(/[^\w]/g,"-").toLowerCase()}function U(l,i){let c=B(i),f=S("li",null,{"data-option":i.value}),E=S("button",f,{type:"button",class:"a-tag-filter",innerHTML:"<label for="+c+">"+i.text+vt+"</label>"});l.appendChild(f),E.addEventListener("click",L),E.addEventListener("keydown",I)}function he(l){let i=o.getOption(l)||o.getOption(o.getIndex());if(i){if(i.checked){m.classList.contains("u-max-selections")&&m.classList.remove("u-max-selections");let c='[data-option="'+i.value+'"]',f=h.querySelector(c);typeof f!="undefined"&&f&&(h==null||h.removeChild(f))}else s!=null&&s.renderTags&&h&&U(h,i);o.toggleOption(l),o.isAtMaxSelections()&&m.classList.add("u-max-selections"),k.dispatchEvent("selectionsupdated",{target:k})}o.resetIndex(),e=!1,y.getAttribute("aria-hidden")==="false"&&w.focus()}function Te(l){he(Number(l.target.getAttribute("data-index"))),b()}function Ie(){x.addEventListener("mousemove",function(c){let f=c.target;c.offsetX>f.offsetWidth-35?f.style.cursor="pointer":f.style.cursor="auto"}),x.addEventListener("mouseup",function(c){let f=c.target;c.offsetX>f.offsetWidth-35&&y.offsetHeight===140&&w.blur()}),w.addEventListener("input",function(){j(this.value)}),w.addEventListener("focus",function(){y.getAttribute("aria-hidden")==="true"&&p()}),w.addEventListener("blur",function(){!e&&y.getAttribute("aria-hidden")==="false"&&v()}),w.addEventListener("keydown",function(c){let f=c.key;y.getAttribute("aria-hidden")==="true"&&f!==Ae&&p(),f===be?(c.preventDefault(),_(q)):f===Le?(b(),v()):f===Se?_(q):f===Ae&&!c.shiftKey&&y.getAttribute("aria-hidden")==="false"&&v()}),m.addEventListener("mousedown",function(){e=!0}),m.addEventListener("keydown",function(c){let f=c.key,E=c.target,V=E.checked;if(f===be){c.preventDefault(),E.checked=!V;let F=new Event("change",{bubbles:!1,cancelable:!0});E.dispatchEvent(F)}else f===Le?(w.focus(),v()):f===_t?_(Ee):f===Se&&_(q)}),y.addEventListener("mousedown",function(c){c.target.tagName==="LABEL"&&(e=!0)});let l=m.querySelectorAll("input");for(let c=0,f=l.length;c<f;c++)l[c].addEventListener("change",Te);let i=h.querySelectorAll("button");for(let c=0,f=i.length;c<f;c++)i[c].addEventListener("click",L),i[c].addEventListener("keydown",I)}function Ne(){d=document.createElement("div"),d.className=A,h=S("ul",null,{className:"m-tag-group"}),x=S("header",d,{className:A+"__header"}),w=S("input",x,{className:A+"__search "+yt,type:"text",placeholder:a||"Select up to five",id:r.id,autocomplete:"off"}),y=S("fieldset",d,{className:A+"__fieldset u-invisible","aria-hidden":"true"});let l=A+"__options";o.isAtMaxSelections()&&(l+=" u-max-selections"),m=S("ul",y,{className:l});let i,c,f;for(let E=0,V=u.length;E<V;E++){i=u[E],c=B(i),f=o.getOption(E).checked;let F=S("li",m,{"data-option":i.value,"data-cy":"multiselect-option",class:"m-form-field m-form-field--checkbox"});S("input",F,{id:c,type:"checkbox",value:i.value,name:n,class:xt+" "+A+"__checkbox",checked:f,"data-index":E}),S("label",F,{for:c,textContent:i.text,className:A+"__label a-label"}),C.push(F),f&&(s!=null&&s.renderTags)&&U(h,i)}return d.insertBefore(h,x),r.parentNode.insertBefore(d,r),d.appendChild(r),d}function Me(l=Oe){if(!G(r))return this;if(pe())return this;if(k=this,n=r.name||r.id,a=r.getAttribute("placeholder"),u=r.options||[],s=J(J({},Oe),l),u.length>0){o=new _e(u,n,s).init();let i=Ne();r.parentNode.removeChild(r),r=i,G(r),Ie()}return this}function Ce(){return o}this.init=Me,this.expand=p,this.collapse=v;let $=new T;return this.addEventListener=$.addEventListener,this.removeEventListener=$.removeEventListener,this.dispatchEvent=$.dispatchEvent,this.getModel=Ce,this.updateSelections=he,this.selectionClickHandler=L,this.selectionKeyDownHandler=I,this}Z.BASE_CLASS=A;Z.init=t=>fe(`.${A}`,Z,void 0,t);})();
|
|
1
|
+
(()=>{var ue=Object.defineProperty;var ne=Object.getOwnPropertySymbols;var Se=Object.prototype.hasOwnProperty,Ae=Object.prototype.propertyIsEnumerable;var se=(e,r,a)=>r in e?ue(e,r,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[r]=a,X=(e,r)=>{for(var a in r||(r={}))Se.call(r,a)&&se(e,a,r[a]);if(ne)for(var a of ne(r))Ae.call(r,a)&&se(e,a,r[a]);return e};var I=(e,r)=>{for(var a in r)ue(e,a,{get:r[a],enumerable:!0})};var U={};I(U,{default:()=>Me});var Me={};var q={};I(q,{default:()=>ze});var ze={};var Y={};I(Y,{default:()=>Ne});var Ne={};var J={};I(J,{default:()=>Fe});var Fe={};var V={};I(V,{default:()=>je});var je={};var W={};I(W,{default:()=>Re});var Re={};var $={};I($,{default:()=>Ke});var Ke={};var G={};I(G,{default:()=>Ue});var Ue={};var Z={};I(Z,{default:()=>Ye});var Ye={};var Q={};I(Q,{default:()=>Ve});var Ve={};var z="data-js-hook";var fe="state_";function ee(){let e={};function r(f,o){return{}.hasOwnProperty.call(e,f)?e[f].push(o):e[f]=[o],this}function a(f,o){if(!{}.hasOwnProperty.call(e,f))return this;let s=e[f].indexOf(o);return s!==-1&&e[f].splice(s,1),this}function b(f,o){if(!{}.hasOwnProperty.call(e,f))return this;o=o||{};let s=e[f];for(let n=0,u=s.length;n<u;n++)s[n].call(this,o);return this}return this.addEventListener=r,this.removeEventListener=a,this.dispatchEvent=b,this.getRegisteredEvents=()=>e,this}function N(e,r){if(!e)return!1;let a=e.getAttribute(z);return a?(a=a.split(" "),a.indexOf(r)>-1):!1}function be(e,r){if(N(e,r))return r;if(r.indexOf(" ")!==-1){let b=z+" values cannot contain spaces!";throw new Error(b)}let a=e.getAttribute(z);return a!==null&&(r=a+" "+r),e.setAttribute(z,r),r}var re=fe+"atomic_init";function We(e,r){if(!e||!e.classList){let a=e+' is not valid. Check that element is a DOM node with class "'+r+'"';throw new Error(a)}return e}function $e(e,r){let a=e.classList.contains(r)?e:e.querySelector("."+r);if(!a){let b=r+" not found on or in passed DOM node.";throw new Error(b)}return a}function ae(e,r){return We(e,r),$e(e,r)}function C(e){return N(e,re)?!1:(be(e,re),!0)}function te(e,r,a,b={}){let o=(a||document).querySelectorAll(e),s=[],n,u;for(let g=0,v=o.length;g<v;g++)u=o[g],N(u,re)===!1&&(n=new r(u),n.init(b),s.push(n));return s}function oe(){return!!new RegExp(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i).test(navigator.userAgent)}var Ge;function Ze(e){return e.replace(/[-\\^$*+?.()|[\]{}]/g,"\\$&")}function Qe(e,r){return RegExp(Ze(r.trim()),"i").test(e)}function er(e,r,a){let b=e,f=r,o=(a==null?void 0:a.maxSelections)||5,s=[],n=[],u=[],g=[],v=-1;function y(d){return f+"-"+d.value.trim().replace(/\s+/g,"-").toLowerCase()}function m(){return n.length>=o}function h(d){let p,x=[],L=!1;for(let S=0,M=d.length;S<M;S++)p=d[S],L=m()?!1:p.defaultSelected,x.push({id:y(p),value:p.value,text:p.text,checked:L}),L&&n.push(S);return x}function O(){return s=h(b),this}function k(d){return s[d].checked=!s[d].checked,n.length<o&&s[d].checked?(n.push(d),n.sort(),!0):(s[d].checked=!1,n=n.filter(function(p){return p!==d}),!1)}function j(d,p,x,L){return Qe(p.text,L)&&d.push(x),d}function T(d){return Object.prototype.toString.call(d)!=="[object String]"&&(d=""),g=u,s.length>0&&(u=s.reduce(function(p,x,L){return j(p,x,L,d)},[])),v=-1,u}function P(d){return s[d]}function R(d){let p=u.length,x=p===0?s.length:p;d<0?v=-1:d>=x?v=x-1:v=d}function H(){return v}return this.init=O,this.toggleOption=k,this.getSelectedIndices=function(){return n},this.isAtMaxSelections=m,this.filterIndices=T,this.clearFilter=function(){return u=g=[],Ge},this.getFilterIndices=function(){return u},this.getLastFilterIndices=function(){return g},this.getIndex=H,this.setIndex=R,this.resetIndex=function(){return v=-1,v},this.getOption=P,this}var pe=er;function _(e,r,a){let b=document.createElement(e);return Object.keys(a).forEach(f=>{let o=a[f];f in b?b[f]=o:b.setAttribute(f,o)}),r&&r.appendChild(b),b}var he='<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" class="cf-icon-svg cf-icon-svg--error" viewBox="0 0 12 19"><path d="M11.383 13.644A1.03 1.03 0 0 1 9.928 15.1L6 11.172 2.072 15.1a1.03 1.03 0 1 1-1.455-1.456l3.928-3.928L.617 5.79a1.03 1.03 0 1 1 1.455-1.456L6 8.261l3.928-3.928a1.03 1.03 0 0 1 1.455 1.456L7.455 9.716z"/></svg>';var ir=he,E="o-multiselect",lr="a-checkbox",cr="a-text-input",ge="prev",F="next",ie="Enter",dr=" ",me="Escape",nr="ArrowUp",ve="ArrowDown",xe="Tab",we={renderTags:!0,maxSelections:5};function B(e){e.classList.add(E);let r=ae(e,E),a=!1,b,f,o,s,n,u,g,v,y,m,h,O=[],k;function j(){h.classList.remove("u-no-results"),h.classList.add("u-filtered");let i=o.getLastFilterIndices();for(let t=0,l=i.length;t<l;t++)O[i[t]].classList.remove("u-filter-match");i=o.getFilterIndices();for(let t=0,l=i.length;t<l;t++)O[i[t]].classList.add("u-filter-match")}function T(){h.classList.remove("u-filtered","u-no-results");for(let i=0,t=h.children.length;i<t;i++)h.children[i].classList.remove("u-filter-match");o.clearFilter()}function P(){h.classList.add("u-no-results"),h.classList.remove("u-filtered")}function R(i){return i.length>0?(j(),!0):(P(),!1)}function H(i){T(),o.resetIndex();let t=o.filterIndices(i);R(t)}function d(){return u.classList.add("u-active"),m.classList.remove("u-invisible"),m.setAttribute("aria-hidden",!1),k.dispatchEvent("expandbegin",{target:k}),k}function p(){return u.classList.remove("u-active"),m.classList.add("u-invisible"),m.setAttribute("aria-hidden",!0),o.resetIndex(),k.dispatchEvent("collapsebegin",{target:k}),k}function x(i){i===F?o.setIndex(o.getIndex()+1):i===ge&&o.setIndex(o.getIndex()-1);let t=o.getIndex();if(t>-1){let l=t,c=o.getFilterIndices();c.length>0&&(l=c[t]);let D=o.getOption(l).value,Ie=h.querySelector('[data-option="'+D+'"]').querySelector("input");a=!0,Ie.focus()}else a=!1,y.focus()}function L(){y.value="",T()}function S(i){let t=i.target;t.tagName==="BUTTON"&&(i.preventDefault(),t.removeEventListener("click",S),t.querySelector("label").click())}function M(i){if(i.key===dr||i.key===ie){let t=i.target.querySelector("label");h.querySelector("#"+t.getAttribute("for")).click()}}function le(i){return b+"-"+i.value.trim().replace(/[^\w]/g,"-").toLowerCase()}function ce(i,t){let l=le(t),c=_("li",null,{"data-option":t.value}),w=_("button",c,{type:"button",class:"a-tag-filter",innerHTML:"<label for="+l+">"+t.text+ir+"</label>"});i.appendChild(c),w.addEventListener("click",S),w.addEventListener("keydown",M)}function de(i){let t=o.getOption(i)||o.getOption(o.getIndex());if(t){if(t.checked){h.classList.contains("u-max-selections")&&h.classList.remove("u-max-selections");let l='[data-option="'+t.value+'"]',c=g.querySelector(l);typeof c!="undefined"&&c&&(g==null||g.removeChild(c))}else n!=null&&n.renderTags&&g&&ce(g,t);o.toggleOption(i),o.isAtMaxSelections()&&h.classList.add("u-max-selections"),k.dispatchEvent("selectionsupdated",{target:k})}o.resetIndex(),a=!1,m.getAttribute("aria-hidden")==="false"&&y.focus()}function ye(i){de(Number(i.target.getAttribute("data-index"))),L()}function ke(){v.addEventListener("mousemove",function(l){let c=l.target;l.offsetX>c.offsetWidth-35?c.style.cursor="pointer":c.style.cursor="auto"}),v.addEventListener("mouseup",function(l){let c=l.target;l.offsetX>c.offsetWidth-35&&m.offsetHeight===140&&y.blur()}),y.addEventListener("input",function(){H(this.value)}),y.addEventListener("focus",function(){m.getAttribute("aria-hidden")==="true"&&d()}),y.addEventListener("blur",function(){!a&&m.getAttribute("aria-hidden")==="false"&&p()}),y.addEventListener("keydown",function(l){let c=l.key;m.getAttribute("aria-hidden")==="true"&&c!==xe&&d(),c===ie?(l.preventDefault(),x(F)):c===me?(L(),p()):c===ve?x(F):c===xe&&!l.shiftKey&&m.getAttribute("aria-hidden")==="false"&&p()}),h.addEventListener("mousedown",function(){a=!0}),h.addEventListener("keydown",function(l){let c=l.key,w=l.target,D=w.checked;if(c===ie){l.preventDefault(),w.checked=!D;let A=new Event("change",{bubbles:!1,cancelable:!0});w.dispatchEvent(A)}else c===me?(y.focus(),p()):c===nr?x(ge):c===ve&&x(F)}),m.addEventListener("mousedown",function(l){l.target.tagName==="LABEL"&&(a=!0)});let i=h.querySelectorAll("input");for(let l=0,c=i.length;l<c;l++)i[l].addEventListener("change",ye);let t=g.querySelectorAll("button");for(let l=0,c=t.length;l<c;l++)t[l].addEventListener("click",S),t[l].addEventListener("keydown",M)}function _e(){u=document.createElement("div"),u.className=E,g=_("ul",null,{className:"m-tag-group"}),v=_("header",u,{className:E+"__header"}),y=_("input",v,{className:E+"__search "+cr,type:"text",placeholder:f||"Select up to five",id:r.id,autocomplete:"off"}),m=_("fieldset",u,{className:E+"__fieldset u-invisible","aria-hidden":"true"});let i=E+"__options";o.isAtMaxSelections()&&(i+=" u-max-selections"),h=_("ul",m,{className:i});let t,l,c;for(let w=0,D=s.length;w<D;w++){t=s[w],l=le(t),c=o.getOption(w).checked;let A=_("li",h,{"data-option":t.value,"data-cy":"multiselect-option",class:"m-form-field m-form-field--checkbox"});_("input",A,{id:l,type:"checkbox",value:t.value,name:b,class:lr+" "+E+"__checkbox",checked:c,"data-index":w}),_("label",A,{for:l,textContent:t.text,className:E+"__label a-label"}),O.push(A),c&&(n!=null&&n.renderTags)&&ce(g,t)}return u.insertBefore(g,v),r.parentNode.insertBefore(u,r),u.appendChild(r),u}function Ee(i=we){if(!C(r))return this;if(oe())return this;if(k=this,b=r.name||r.id,f=r.getAttribute("placeholder"),s=r.options||[],n=X(X({},we),i),s.length>0){o=new pe(s,b,n).init();let t=_e();r.parentNode.removeChild(r),r=t,C(r),ke()}return this}function Le(){return o}this.init=Ee,this.expand=d,this.collapse=p;let K=new ee;return this.addEventListener=K.addEventListener,this.removeEventListener=K.removeEventListener,this.dispatchEvent=K.dispatchEvent,this.getModel=Le,this.updateSelections=de,this.selectionClickHandler=S,this.selectionKeyDownHandler=M,this}B.BASE_CLASS=E;B.init=e=>te(`.${E}`,B,void 0,e);})();
|
|
2
2
|
//# sourceMappingURL=index.js.map
|