@spscommerce/ds-react 7.5.0 → 7.5.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/lib/index.cjs.js +1 -1
- package/lib/index.es.js +1 -1
- package/package.json +12 -12
package/lib/index.cjs.js
CHANGED
|
@@ -229,7 +229,7 @@
|
|
|
229
229
|
</SpsAdvancedSearch>
|
|
230
230
|
</>;
|
|
231
231
|
}
|
|
232
|
-
`}}}};let Ct=(e=21)=>crypto.getRandomValues(new Uint8Array(e)).reduce((t,r)=>(r&=63,r<36?t+=r.toString(36):r<62?t+=(r-26).toString(36).toUpperCase():r>62?t+="-":t+="_",t),"");function Dr(e){return V.useRef(e||Ct())}function gt(e,t){const r=Dr(e),n=V.useRef(`${r.current}_ctrl`);return V.useEffect(()=>{t&&(t.id=n.current,t.update())},[t]),{wrapperId:r.current||void 0,controlId:n.current}}var Ot=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},tv="[object Object]";function rv(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch{}return t}function nv(e,t){return function(r){return e(t(r))}}var sv=Function.prototype,lp=Object.prototype,cp=sv.toString,av=lp.hasOwnProperty,ov=cp.call(Object),iv=lp.toString,lv=nv(Object.getPrototypeOf,Object);function cv(e){return!!e&&typeof e=="object"}function dv(e){if(!cv(e)||iv.call(e)!=tv||rv(e))return!1;var t=lv(e);if(t===null)return!0;var r=av.call(t,"constructor")&&t.constructor;return typeof r=="function"&&r instanceof r&&cp.call(r)==ov}var dp=dv;const xt=new Set,rn=new Set,zt=new Set,In=new Set;function pp(e){xt.has(e)||zt.has(e)||In.has(e)||rn.add(e)}function up(e){xt.has(e)||zt.has(e)||rn.has(e)||In.add(e)}const Aa=Zr.default||Zr,Vs="MM/DD/YYYY",pv=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/,mp=Symbol("Date Parse Error");function Fr(e){return e.year*1e4+e.month*100+e.date}const me=Object.freeze({createFrom(e){if(!e)return null;if(typeof e=="string"){const t=pv.exec(e);if(t){const[,r,n,a]=t;return Object.freeze({year:Number(a),month:Number(r),date:Number(n)})}return Object.freeze({[mp]:!0,year:void 0,month:void 0,date:void 0})}return Object.freeze({year:e.year(),month:e.month()+1,date:e.date()})},createRangeFrom(e){return e?e.split(/[^\d]*-[^\d]*/).map(me.createFrom):null},isValid(e){var t;return e&&typeof e=="object"&&typeof e.year=="number"&&typeof e.month=="number"&&typeof e.date=="number"&&((t=me.toMoment(e))==null?void 0:t.isValid())},nullifyInvalidDate(e){return me.isValid(e)?e:null},toMoment(e){return e?Aa({...e,month:e.month-1}):null},toString(e){const t=me.toMoment(e);return t?t.format(Vs):""},toStringRange(e){return e?e.map(me.toString).join("-"):""},create(){const e=new Date;return Object.freeze({year:e.getFullYear(),month:e.getMonth()+1,date:e.getDate()})},isSameDate(e,t){return e&&t&&e.year===t.year&&e.month===t.month&&e.date===t.date},isSameMonth(e,t){return e&&t&&e.year===t.year&&e.month===t.month},isAfter(e,t){return!e||!t?null:Fr(e)>Fr(t)},isBefore(e,t){return!e||!t?null:Fr(e)<Fr(t)},isInRange(e,t,r=!0){if(!e||!t||!t[0]||!t[1])return null;const n=Fr(e),[a,o]=t.map(Fr);return e&&a&&o&&(r&&n>=a&&n<=o||!r&&n>a&&n<o)},prevMonth(e){return Object.freeze({year:e.month===1?e.year-1:e.year,month:e.month-1||12,date:e.date})},nextMonth(e){return Object.freeze({year:e.month===12?e.year+1:e.year,month:e.month+1>12?1:e.month+1,date:e.date})},createRangeFromPreset(e){if(typeof e.definition=="function")return e.definition();const t=Aa(),r=t.clone().subtract(Aa.duration(e.definition));return[me.createFrom(r),me.createFrom(t)]}}),kn=function(t){if(Array.isArray(t)){const r=kn(t[0]),n=kn(t[1]);return r||n}if(t&&t.hasOwnProperty("year")){if(t[mp])return{dateFormat:Vs};if(!me.isValid(t))return{dateValidity:!0}}return null};xt.add("dateFormat");xt.add("dateValidity");const fp=function(t){if(Array.isArray(t)){const r=kn(t);if(r)return r;if(t&&me.isBefore(t[1],t[0]))return{dateRangeOrder:!0}}return null};xt.add("dateRangeOrder");const hp=function({minDate:t,maxDate:r}){function n(a){const o=me.isBefore(a,t),l=me.isAfter(a,r),c={minExceeded:o?me.toString(t):null,maxExceeded:l?me.toString(r):null};return o||l?{dateConstraint:c}:null}return function(o){if(!o)return null;if(Array.isArray(o)){const l=n(o[0]),c=n(o[1]);return l||c}return o.hasOwnProperty("year")?n(o):null}};xt.add("dateConstraint");const uv=Object.freeze(Object.defineProperty({__proto__:null,date:kn,dateRange:fp,dateConstraint:hp},Symbol.toStringTag,{value:"Module"}));function nr(e,t){for(const r of[].concat(e)){const n=t(r);if(n)return n}return null}const mv=function(t){function r(n){return Number(n)>=t?null:{min:t}}return n=>nr(n,r)};xt.add("min");const fv=function(t){function r(n){return Number(n)<=t?null:{max:t}}return n=>nr(n,r)};rn.add("max");const hv=function(t){return typeof t>"u"||t===null||t===""||Number.isNaN(t)||(t==null?void 0:t.length)===0?{required:!0}:null};rn.add("required");const Sv=function(t){function r(n){return n===void 0||n.toString().length<t?{minLength:t}:null}return n=>nr(n,r)};xt.add("minLength");const gv=function(t){function r(n){return n===void 0||n.toString().length<=t?null:{maxLength:t}}return n=>nr(n,r)};zt.add("maxLength");const bv=function(t){const r=t instanceof RegExp?t:new RegExp(t);function n(a){return r.test(a)?null:{pattern:t}}return a=>nr(a,n)};xt.add("pattern");const vv=function(e){function t(r){return/^\p{L}*$/u.test(r)?null:{alpha:!0}}return nr(e,t)};zt.add("alpha");const yv=function(e){function t(r){return/^[0-9,. ]*$/.test(r)?null:{numeric:!0}}return nr(e,t)};zt.add("numeric");const Ev=function(e){function t(r){return/^[^0-9]*$/.test(r)?null:{nonNumeric:!0}}return nr(e,t)};zt.add("nonNumeric");const Ks=Object.freeze({...uv,min:mv,max:fv,required:hv,minLength:Sv,maxLength:gv,pattern:bv,alpha:vv,numeric:yv,nonNumeric:Ev,OnBlurErrorKeys:xt});function $n(e,t=[]){const r=t.reduce((n,a)=>Object.assign(n,a(e)||{}),{});return Object.keys(r).length?r:null}class gr{constructor(t,r){ot(this,"validators",[]);ot(this,"errors",null);ot(this,"revealAllErrors",!1);ot(this,"preventativeErrors",[]);ot(this,"submitted",!1);this.path=t,this.update=r}setValidators(t){return this.update(this.path,null,void 0,t),this}validate(t){return this.validators&&this.validators.length>0?(this.errors=$n(t,this.validators),this.update(),this.isFocused()&&this.onFocus&&this.onFocus()):this.errors&&(this.errors=null,this.update()),this}isValid(){return!this.errors||this.isPristine()}hasErrors(){return!!this.errors}isVisibilyInvalid(){return this.errors&&(this.revealAllErrors&&!Object.keys(this.errors).some(t=>In.has(t))||this.revealAllErrors&&Object.keys(this.errors).some(t=>In.has(t))&&this.isSubmitted()||!this.isPristine()&&Object.keys(this.errors).some(t=>rn.has(t)))}hasError(t){return this.errors&&Object.prototype.hasOwnProperty.call(this.errors,t)}hasPreventativeError(t){return this.preventativeErrors.includes(t)}hasPreventativeErrors(){return this.preventativeErrors.length>0}isRequired(){return this.validators&&this.validators.indexOf(Ks.required)>-1}isSubmitted(){return this.submitted}onFocus(){}onBlur(){}}class vr extends gr{constructor(){super(...arguments);ot(this,"id",Ct());ot(this,"focused",!1);ot(this,"pristine",!0)}setValue(r){if(this.revealAllErrors=!1,this.preventativeErrors=[],this.validators&&this.validators.length>0){const n=$n(r,this.validators);if(n&&Object.keys(n).filter(o=>zt.has(o)).length>0){this.preventativeErrors=Object.keys(n);return}}this.update(this.path,r)}isPristine(){return this.pristine}markAsPristine(){return this.pristine=!0,this.revealAllErrors=!1,this.update(),this}markAsDirty(){return this.pristine=!1,this.update(),this}isFocused(){return this.focused}markAsFocused(){return this.focused=!0,this.update(),this.onFocus&&this.onFocus(),this}markAsBlurred(){return this.update(this.path,null,!0),this.onBlur&&this.onBlur(),this.preventativeErrors=[],this}markAsSubmitted(){return this.submitted=!0,this.update(),this}}class Hs extends vr{constructor(r,n,a){super(a?n:r,a||n);ot(this,"fields");a&&this.inferMembers(r)}isFocused(){return super.isFocused()||this.rollup("isFocused")}isValid(){return super.isValid()&&this.rollup("isValid")}hasErrors(){return super.hasErrors()||Object.keys(this.fields).some(r=>this.fields[r].hasErrors())}contentsAreValid(){return this.rollup("isValid")&&this.rollup("contentsAreValid")}isPristine(){return super.isPristine()&&this.rollup("isPristine")}markAsPristine(){super.markAsPristine();for(const r of Object.keys(this.fields))this.fields[r].markAsPristine();return this}markAsDirty(){super.markAsDirty();for(const r of Object.keys(this.fields))this.fields[r].markAsDirty();return this}markAsBlurred(){super.markAsBlurred();for(const r of Object.keys(this.fields))this.fields[r].markAsBlurred();return this}markAsSubmitted(){super.markAsSubmitted();for(const r of Object.keys(this.fields))this.fields[r].markAsSubmitted();return this}inferSpsControl(r,n){return Ds(r,[...this.path,n],this.update)}rollup(r){return Object.keys(this.fields).reduce((n,a)=>n&&(!this.fields[a][r]||this.fields[a][r]()),!0)}}class Sp extends Hs{inferMembers(t){this.fields={};for(const r of Object.keys(t))this.fields[r]=this.inferSpsControl(t[r],r)}}class gp extends Hs{inferMembers(t){this.fields=t.map((r,n)=>this.inferSpsControl(r,String(n)))}}function Ds(e,t,r){return e instanceof gr?(e.path=t,e.update=r,e):Array.isArray(e)?new gp(e,t,r):dp(e)?new Sp(e,t,r):new vr(t,r)}function ho(e,t){return t.length===0||!e?e:ho(e.fields[t[0]],t.slice(1,t.length))}function So(e,t){if(t.length===0||!e)return[e];const r=t[0];if(t=t.slice(1,t.length),r==="*"){const n=Array.isArray(e.fields)?e.fields:Object.keys(e.fields).map(a=>e.fields[a]);return t.length===0?n:n.reduce((a,o)=>[...a,...So(o,t)],[])}return So(e.fields[r],t)}function bp(e,t,r){for(const n of Object.keys(t)){const a=t[n];for(const o of So(e,n.split(".")))o&&a&&r(o,a)}}function fs(e,t,r,n=!1){bp(t,r,(a,o)=>{a.validators=typeof o=="function"?o(e):o,n&&(a.errors=$n(y.getPath(e,a.path),a.validators))})}function go(e,t){const r=t[0];return t=t.slice(1),Array.isArray(e)?e.map((n,a)=>a===Number(r)?go(n,t):n):dp(e)?Object.keys(e).reduce((n,a)=>Object.assign(n,{[a]:a===r?go(e[a],t):e[a]}),{}):e}function Tv(e){if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError("The initial value of useSpsForm() hook must be an object.")}function vp(e,t={}){Tv(e);const r=V.useMemo(()=>{y.deepFreeze(e);const f=Ds(e,[],p);return t&&fs(e,f,t,!0),f},[]),n=V.useRef(),a=V.useRef(t),o=V.useCallback((f,m)=>{var g,E,C;let h;if(n.current=void 0,m)if(m.path)if(m.markAsBlurred){const T=ho(f.formMeta,m.path);T&&(T.focused=!1,T.revealAllErrors=!0)}else if(m.newValidators){if(a.current){const T=m.path.join(".");a.current={...a.current,[T]:m.newValidators},fs(f.formValue,f.formMeta,a.current,!0)}}else h=go(f.formValue,m.path),y.setPath(h,m.path,m.value);else h=m.value;if((g=m.updateFormOptions)!=null&&g.validators&&(a.current={...a.current,...m.updateFormOptions.validators},fs(f.formValue,f.formMeta,a.current,(C=(E=m.updateFormOptions)==null?void 0:E.runValidators)!=null?C:!0)),h){y.deepFreeze(h);const T=y.diff(f.formValue,h);for(const{type:D,key:N,parentPath:I,objects:[b,x]}of T){const L=ho(f.formMeta,I);if(typeof N!="symbol"&&L)switch(D){case y.DiffChange.ADDITION:L.fields[N]=Ds(x[N],[...I,N],p);break;case y.DiffChange.DELETION:Array.isArray(L.fields)?L.fields.splice(Number(N),1):delete L.fields[N];break;case y.DiffChange.ALTERATION:if(!b[N]&&x[N]&&!(L.fields[N]instanceof Hs)){const k=Ds(x[N],[...I,N],p);k instanceof vr&&L.fields[N]instanceof vr&&(k.id=L.fields[N].id,k.focused=L.fields[N].focused,k.pristine=L.fields[N].pristine),L.fields[N]=k}break}}if(a.current){fs(h,f.formMeta,a.current);const D=new Set;t&&bp(f.formMeta,t,(N,I)=>{typeof I=="function"&&(N.validate(y.getPath(h,N.path)),D.add(N))});for(const{type:N,key:I,parentPath:b,objects:[,x]}of T)if(typeof I!="symbol"){let L=f.formMeta,k=h;if(L){for(const O of b)L=L.fields[O],k=k[O],D.has(L)||L.validate(k);if(N===y.DiffChange.ADDITION||N===y.DiffChange.ALTERATION){const O=L.fields[I];if(!D.has(O)&&(L.fields[I].validate(x[I]),N===y.DiffChange.ADDITION&&O.fields))for(const[B,G]of Object.entries(O.fields))G.validate(x[I][B])}}}}}return{formValue:h||f.formValue,formMeta:f.formMeta,updateForm:f.updateForm}},[]),[l,c]=V.useReducer(o,{formValue:e,formMeta:r,updateForm:u});function p(f,m,h=!1,g){f?c({path:f,value:m,markAsBlurred:h,newValidators:g}):u()}function u(f,m){if(f||m){n.current&&window.clearTimeout(n.current);const h=window.setTimeout(c,0,{value:f,updateFormOptions:m});n.current=h}else if(!n.current){const h=window.setTimeout(c,0,{});n.current=h}}return V.useEffect(()=>()=>{n.current&&window.clearTimeout(n.current)},[]),l}const et=s.forwardRef((e,t)=>{const{className:r,children:n,focusInputOnClick:a,formControl:o,formMeta:l,inputRef:c,onClick:p,...u}=e,f=s.useRef(),h=c||(t||f);function g(){h&&h!==t&&h.current&&h.current.focus()}function E(){h&&h!==t&&h.current&&l&&l instanceof vr&&l.markAsFocused()}function C(){h&&h!==t&&h.current&&l&&l instanceof vr&&l.markAsBlurred()}const T=K("sps-form-group",(o&&o.isRequired()||l&&l.isRequired())&&"sps-form-group--required",(o&&!o.isValid()||l&&l.isVisibilyInvalid())&&"sps-form-group--error",l&&l.hasPreventativeErrors()&&"sps-form-group--preventative-error",r);function D(N){a&&g(),p&&p(N)}return s.useEffect(()=>{function N(I){I.target.classList.contains("sps-form-control__clear-btn")&&I.preventDefault()}return document.addEventListener("mousedown",N),()=>{document.removeEventListener("mousedown",N)}},[]),s.createElement("div",{...u,className:T,ref:t,tabIndex:-1,onClick:D,onFocus:E,onBlur:C},n)});Object.assign(et,{displayName:"SpsFormComponentWrapper"});function uc(e){return typeof e=="object"&&e!=null&&e.nodeType===1}function mc(e,t){return(!t||e!=="hidden")&&e!=="visible"&&e!=="clip"}function $a(e,t){if(e.clientHeight<e.scrollHeight||e.clientWidth<e.scrollWidth){var r=getComputedStyle(e,null);return mc(r.overflowY,t)||mc(r.overflowX,t)||function(n){var a=function(o){if(!o.ownerDocument||!o.ownerDocument.defaultView)return null;try{return o.ownerDocument.defaultView.frameElement}catch{return null}}(n);return!!a&&(a.clientHeight<n.scrollHeight||a.clientWidth<n.scrollWidth)}(e)}return!1}function hs(e,t,r,n,a,o,l,c){return o<e&&l>t||o>e&&l<t?0:o<=e&&c<=r||l>=t&&c>=r?o-e-n:l>t&&c<r||o<e&&c>r?l-t+a:0}function fc(e,t){var r=window,n=t.scrollMode,a=t.block,o=t.inline,l=t.boundary,c=t.skipOverflowHiddenElements,p=typeof l=="function"?l:function(xe){return xe!==l};if(!uc(e))throw new TypeError("Invalid target");for(var u=document.scrollingElement||document.documentElement,f=[],m=e;uc(m)&&p(m);){if((m=m.parentElement)===u){f.push(m);break}m!=null&&m===document.body&&$a(m)&&!$a(document.documentElement)||m!=null&&$a(m,c)&&f.push(m)}for(var h=r.visualViewport?r.visualViewport.width:innerWidth,g=r.visualViewport?r.visualViewport.height:innerHeight,E=window.scrollX||pageXOffset,C=window.scrollY||pageYOffset,T=e.getBoundingClientRect(),D=T.height,N=T.width,I=T.top,b=T.right,x=T.bottom,L=T.left,k=a==="start"||a==="nearest"?I:a==="end"?x:I+D/2,O=o==="center"?L+N/2:o==="end"?b:L,B=[],G=0;G<f.length;G++){var _=f[G],W=_.getBoundingClientRect(),M=W.height,F=W.width,J=W.top,ee=W.right,z=W.bottom,se=W.left;if(n==="if-needed"&&I>=0&&L>=0&&x<=g&&b<=h&&I>=J&&x<=z&&L>=se&&b<=ee)return B;var A=getComputedStyle(_),H=parseInt(A.borderLeftWidth,10),q=parseInt(A.borderTopWidth,10),Z=parseInt(A.borderRightWidth,10),te=parseInt(A.borderBottomWidth,10),Q=0,U=0,ie="offsetWidth"in _?_.offsetWidth-_.clientWidth-H-Z:0,ne="offsetHeight"in _?_.offsetHeight-_.clientHeight-q-te:0;if(u===_)Q=a==="start"?k:a==="end"?k-g:a==="nearest"?hs(C,C+g,g,q,te,C+k,C+k+D,D):k-g/2,U=o==="start"?O:o==="center"?O-h/2:o==="end"?O-h:hs(E,E+h,h,H,Z,E+O,E+O+N,N),Q=Math.max(0,Q+C),U=Math.max(0,U+E);else{Q=a==="start"?k-J-q:a==="end"?k-z+te+ne:a==="nearest"?hs(J,z,M,q,te+ne,k,k+D,D):k-(J+M/2)+ne/2,U=o==="start"?O-se-H:o==="center"?O-(se+F/2)+ie/2:o==="end"?O-ee+Z+ie:hs(se,ee,F,H,Z+ie,O,O+N,N);var ce=_.scrollLeft,re=_.scrollTop;k+=re-(Q=Math.max(0,Math.min(re+Q,_.scrollHeight-M+ne))),O+=ce-(U=Math.max(0,Math.min(ce+U,_.scrollWidth-F+ie)))}B.push({el:_,top:Q,left:U})}return B}function yp(e){return e===Object(e)&&Object.keys(e).length!==0}function wv(e,t){t===void 0&&(t="auto");var r="scrollBehavior"in document.body.style;e.forEach(function(n){var a=n.el,o=n.top,l=n.left;a.scroll&&r?a.scroll({top:o,left:l,behavior:t}):(a.scrollTop=o,a.scrollLeft=l)})}function Cv(e){return e===!1?{block:"end",inline:"nearest"}:yp(e)?e:{block:"start",inline:"nearest"}}function Ep(e,t){var r=!e.ownerDocument.documentElement.contains(e);if(yp(t)&&typeof t.behavior=="function")return t.behavior(r?[]:fc(e,t));if(!r){var n=Cv(t);return wv(fc(e,n),n.behavior)}}const Dv=Object.freeze(Object.defineProperty({__proto__:null,default:Ep},Symbol.toStringTag,{value:"Module"})),Nv={alt:"string",size:"SpinnerSize",title:"string"};function Ko(e){const{alt:t,className:r,size:n=$.SpinnerSize.MEDIUM,"data-testid":a,title:o,unsafelyReplaceClassName:l,...c}=e,{t:p}=s.useContext(Re),u=t||o||p("design-system:spinner.defaultAltText"),f=K(l||"sps-spinner",`sps-spinner--${n}`,r);return s.createElement("i",{className:f,"data-testid":a,title:u,...c})}Object.assign(Ko,{props:Nv,displayName:"SpsSpinner"});const xv=60;function Ss(e){return typeof e>"u"?"inherit":`${e}px`}function Tp(e){switch(e){case $.Position.TOP_LEFT:return $.Position.BOTTOM_LEFT;case $.Position.TOP_MIDDLE:return $.Position.BOTTOM_MIDDLE;case $.Position.TOP_RIGHT:return $.Position.BOTTOM_RIGHT;case $.Position.RIGHT_TOP:return $.Position.LEFT_TOP;case $.Position.RIGHT_MIDDLE:return $.Position.LEFT_MIDDLE;case $.Position.RIGHT_BOTTOM:return $.Position.LEFT_BOTTOM;case $.Position.BOTTOM_RIGHT:return $.Position.TOP_RIGHT;case $.Position.BOTTOM_MIDDLE:return $.Position.TOP_MIDDLE;case $.Position.BOTTOM_LEFT:return $.Position.TOP_LEFT;case $.Position.LEFT_BOTTOM:return $.Position.RIGHT_BOTTOM;case $.Position.LEFT_MIDDLE:return $.Position.RIGHT_MIDDLE;case $.Position.LEFT_TOP:return $.Position.RIGHT_TOP}}function Iv(e,t,r,n,a,o,l,c){const p=l&&l.current,u=p?p.scrollTop:window.pageYOffset,f=c?0:u,m=p?p.scrollLeft:window.pageXOffset,h=c?0:m,[g,E]=e.split(" ");let C,T,D,N;switch(g){case"top":D=t.height-r.top-f-o[0];break;case"left":T=t.width-r.left-h-o[0];break;case"right":N=r.right+h-o[0];break;case"bottom":C=r.bottom+f-o[0];break;default:throw new Error(`Invalid position ${e}`)}switch(E){case"left":N=r.left+h+o[1];break;case"top":C=r.top+f+o[1];break;case"middle":g==="top"||g==="bottom"?N=r.left+h+r.width/2-a/2+o[1]:(g==="left"||g==="right")&&(C=r.top+f+r.height/2-n.height/2+o[1]);break;case"bottom":D=t.height-r.bottom-f+o[1];break;case"right":T=t.width-r.right-h+o[1];break;default:throw new Error(`Invalid position ${e}`)}return[C,T,D,N]}function yr(e,t,r,{altPosition:n,setMinWidth:a=!1,setWidth:o=!1,parentElementRef:l,fixed:c=!1,offsets:p=[0,0]}){if(e.current&&t.current){const u=Math.max(document.documentElement.clientHeight,window.innerHeight||0),f=document.documentElement.getBoundingClientRect().width,m=l&&l.current?l.current:document.documentElement,h=c?{width:f,height:u,top:0,left:0,bottom:u,right:f}:m.getBoundingClientRect(),g=e.current.getBoundingClientRect(),E=t.current.getBoundingClientRect(),[C]=r.split(" ");let T=r;n&&(C==="top"&&E.top-g.height<xv||C==="right"&&E.right+g.width>f||C==="bottom"&&E.bottom+g.height>u||C==="left"&&E.left-g.width<0)&&(T=n);const D=a?Math.max(E.width,g.width):g.width,N=o?E.width:D,[I,b,x,L]=Iv(T,h,E,g,N,p,l,c),k={top:Ss(I),right:Ss(b),bottom:Ss(x),left:Ss(L)};return c&&(k.position="fixed",k.zIndex=$.ZStratum.BAR),a&&(k.minWidth=`${E.width}px`),o&&(k.width=`${E.width}px`),[k,T===n]}return[{},!1]}const bt=V.createContext(null);function nn(e,t=[]){const r=V.useContext(bt);return V.useMemo(()=>n=>{const o=r&&r.parentElementRef&&r.parentElementRef.current||document.body;let l=null,c=o.lastElementChild;for(;c&&c!==o.firstElementChild;){if(c.hasAttribute("data-portalid")&&c.getAttribute("data-portalid")===e){l=c;break}c=c.previousElementSibling}if(l)o.contains(l)||o.appendChild(l);else{l=document.createElement("div"),l.setAttribute("data-portalid",e);for(const p of t)l.classList.add(p);o.appendChild(l)}return Ao.createPortal(n,l)},[r])}async function hc(e,t,r,n,a,o){const l=typeof e.options=="function"?e.options(t.value):e.options||[],c=l instanceof Promise,p=m=>m.replace(/([.?*+^$[\]\\(){}|-])/g,"");r({pending:c}),o.current=c?l:null;const u=c?await l||[]:l||[];if(c&&o.current!==l)return;let f=Array.from(u).filter(Boolean).map(m=>new $.SpsOptionListOption(m,typeof m=="function"?{textKey:"label",captionKey:"caption"}:{textKey:e.textKey,captionKey:e.captionKey}));if(e.nullOption&&f.unshift(new $.SpsOptionListOption(null,{text:e.nullOption})),t.value&&!e.disableDefaultOptionsFiltering){const m=p(t.value);r({replacementPattern:new RegExp(m,"ig")}),f=f.filter(h=>{const g=new RegExp(m,"i"),E=p(h.text);return e.filterByTextAndCaptionKey?g.test(E)||g.test(p(h.caption)):g.test(E)})}else r({replacementPattern:null});if(e.disabledOptions)for(const m of f)e.disabledOptions.includes(m.value)&&(m.disabled=!0);n(Object.freeze(f)),e.onOptionListChanged&&e.onOptionListChanged(f.length),a(f.some(m=>m.value&&!!m.value.icon)),r({pending:!1})}function kv(e,t,r){const[n,a]=s.useState(Object.freeze([])),[o,l]=s.useState(!1),c=s.useRef(null),p=s.useRef(e.options);(typeof e.options!="function"||e.disableOptionsMemoization)&&(p.current=e.options);const u=s.useMemo(()=>typeof p.current=="function"?y.debounce(hc,typeof e.searchDebounce<"u"?e.searchDebounce:500):hc,[p.current,e.disabledOptions]);return s.useEffect(()=>{u(e,t,r,a,l,c)},[p.current,t.value,e.disabledOptions]),[n,o]}class sr{constructor(t,r){ot(this,"nativeEvent");ot(this,"currentTarget");ot(this,"isPgStoppedInternal",!1);this.target=t,this.currentTarget=t,this.nativeEvent=new CustomEvent("change",r),Object.defineProperty(this.nativeEvent,"target",{value:t,writable:!1,configurable:!1,enumerable:!0})}get bubbles(){return this.nativeEvent.bubbles}get cancelable(){return this.nativeEvent.cancelable}get defaultPrevented(){return this.nativeEvent.defaultPrevented}get eventPhase(){return this.nativeEvent.eventPhase}get isTrusted(){return this.nativeEvent.isTrusted}get timeStamp(){return this.nativeEvent.timeStamp}get type(){return this.nativeEvent.type}preventDefault(){this.nativeEvent.preventDefault()}isDefaultPrevented(){return this.defaultPrevented}stopPropagation(){this.nativeEvent.stopPropagation(),this.isPgStoppedInternal=!0}isPropagationStopped(){return this.isPgStoppedInternal}persist(){throw new Error("This is not a real React ChangeEvent. React does not permit the creation of SyntheticEvents in userland.")}}function Mv(e,t){return{...e,...t}}function Rt(e){return V.useReducer(Mv,e)}function _v({hideInlineSearch:e,options:t,onSearchChange:r,search:n="",searchPlaceholder:a="Search\u2026",searchInputRef:o}){const[l,c]=Rt({isAsync:typeof t=="function",pending:!1,value:n,replacementPattern:null}),p=s.useCallback(g=>{c({value:g.target.value}),r&&r(g)},[r]),u=s.useCallback(g=>{g.nativeEvent.stopImmediatePropagation(),g.stopPropagation()},[]),f=s.useCallback(g=>{g.nativeEvent.stopImmediatePropagation(),c({value:""}),o!=null&&o.current&&(r&&r(new sr(o.current)),o.current.focus())},[r]),m=g=>{!g||["Tab","Escape","Enter","Up","ArrowUp","Down","ArrowDown"].includes(g.key)||g.stopPropagation()};return s.useEffect(()=>{c({value:n})},[n]),[l.isAsync&&!e?s.createElement("div",{className:"sps-option-list__search sps-form-group sps-text-input"},s.createElement("div",{className:"sps-form-control"},!l.value&&s.createElement("i",{className:"sps-icon sps-icon-filter sps-text-input__icon"}),s.createElement("input",{type:"text",className:"sps-text-input__input",placeholder:a,ref:o,value:l.value,onChange:p,onClick:u,onKeyDown:m}),l.value&&s.createElement("i",{className:"sps-icon sps-icon-x-circle sps-form-control__clear-btn",onClick:f}))):s.createElement(s.Fragment,null),l,c]}const Lv=Ep||Dv,Ov=["Tab","Escape","Enter","Up","ArrowUp","Down","ArrowDown"],Rv=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];function Pv(e,t,r){return r?(e&&e[r])===(t&&t[r]):e===t}function Sc(e,t,r){return typeof r.value=="function"&&r.disabled?!0:t?!!(e!=null&&e.find(n=>{var a;return n[t]&&n[t]===((a=r==null?void 0:r.value)==null?void 0:a[t])})):!1}const Vn=s.forwardRef((e,t)=>{const{captionKey:r,comparisonKey:n,disabledOptions:a,options:o,tall:l,textKey:c,valueKey:p,zeroState:u,hideInlineSearch:f,onSearchChange:m,search:h,searchDebounce:g,searchPlaceholder:E,onSpecialActionSelect:C,attachTo:T,className:D,conformWidth:N,id:I,ignoreWidthStyles:b,isOpen:x,keepOpen:L,keyDown:k,nullOption:O,onOptionListChanged:B,onOptionSelected:G,onPositionFlip:_,onSelfToggle:W,optionRole:M,positionOverride:F,selectedOption:J,specialAction:ee,unsafelyReplaceClassName:z,loading:se,filterByTextAndCaptionKey:A,maxHeightPx:H,maxHeightRem:q,disableOptionsMemoization:Z,disableDefaultOptionsFiltering:te,"data-testid":Q,...U}=e,ie=s.useMemo(()=>ee?new $.SpsOptionListOption(ee,{textKey:"label",captionKey:"caption"}):null,[ee]),[ne,ce]=s.useState(-1),[re,xe]=s.useState(x),Te=t||s.useRef(null),ae=s.useRef(null),Ge=s.useRef(null),Ve=nn("sps-option-list-portal"),tt=s.useContext(bt),[pt,rt]=F||[$.Position.BOTTOM_LEFT,$.Position.TOP_LEFT],[[ge,_e],Se]=s.useState([{},!1]),ve=s.useRef(null),[Pe,Ke,Bt]=_v({...e,searchInputRef:ve}),[Ce,Jn]=kv(e,Ke,Bt);s.useEffect(()=>{Se(re?yr(Te,T,pt,{altPosition:rt,setMinWidth:!b,setWidth:!b&&N,...tt}):[{},!1])},[re,pt,rt,Ce]),s.useEffect(()=>{const he=()=>{re&&Se(yr(Te,T,pt,{altPosition:rt,setMinWidth:!b,setWidth:!b&&N,...tt}))};return document.addEventListener("scroll",he),()=>{document.removeEventListener("scroll",he)}},[re]),s.useEffect(()=>{ce(-1)},[Ke]);const Mr=K(z||"sps-option-list","z-stratum-dropdown",re&&"sps-option-list--open",Ke.isAsync&&"sps-option-list--searchable",_e&&"sps-option-list--opens-upward",ee&&ee.label&&"sps-option-list--has-special-action",D),nt=K(z||"sps-option-list__options",l&&"sps-option-list__options--tall"),be=s.useCallback(()=>{re||(xe(!0),ve.current&&ve.current.focus(),ce(-1),W&&W(!0))},[re,W]),ut=s.useCallback(()=>{re&&(xe(!1),ce(-1),W&&W(!1))},[re,W]),kt=s.useCallback((he,de)=>{de||he&&!he.disabled&&(typeof he.value=="function"?(he.value(),C&&C()):typeof G=="function"&&G(he.value),L||ut())},[G,ut]),ln=s.useCallback((he,de,Xe)=>{he.stopPropagation(),kt(de,Xe)},[kt]),cn=s.useRef(a||[]);cn.current=a||[];const va=s.useCallback(he=>{switch(he.key){case"Tab":case"Escape":ut();break;case"Enter":if(ne>-1){const de=Ce[ne]||ie;he.preventDefault();const Xe=!!de&&Sc(cn.current,n||"",de);!Xe&&de&&typeof G=="function"&&typeof de.value=="function"?de.value():de&&kt(de,Xe)}break;case"Up":case"ArrowUp":{let de=ne;_e?ne<=-1?de=Ce.length-1:ne===0?ee&&(de=Ce.length):ne<Ce.length&&(de=ne-1):ne>-1&&(de=ne-1),de!==ne&&(he.preventDefault(),ce(de));break}case"Down":case"ArrowDown":{be();let de=ne;_e?ne!==-1&&(ne>=Ce.length?de=0:ne===Ce.length-1?de=-1:de=ne+1):ne<Ce.length-1+Number(!!ee)&&(de=ne+1),de!==ne&&(he.preventDefault(),ce(de));break}default:be()}},[ut,be,ne,kt,G,_e,Ce]),Zn=s.useCallback(he=>{const de=Ce.findIndex(Xe=>{if(Xe.textKey){const lr=Xe.textKey;return Xe.value[lr].toLowerCase().charAt([0])===he.key.toLocaleLowerCase()}return Xe.value.toString().toLowerCase().charAt([0])===he.key.toLocaleLowerCase()});de>-1&&ce(de)},[Ce]),Ze=s.useCallback(he=>{!he||(Ov.includes(he.key)?va(he):Rv.includes(he.key)&&Zn(he))},[ut,be,ne,kt,G,_e,Ce]);s.useEffect(()=>{if(tt!==null&&document.getElementsByClassName("sps-modal__body").length>0){const he=()=>{W&&W(!1)},de=document.getElementsByClassName("sps-modal__body")[0];return de.addEventListener("scroll",he),()=>{de.removeEventListener("scroll",he)}}},[]),s.useEffect(()=>{Ge.current&&Lv(Ge.current,{scrollMode:"if-needed",block:"nearest",inline:"nearest"})},[ne]),s.useEffect(()=>{xe(x),x?ve.current&&ve.current.focus():ce(-1)},[x]),s.useEffect(()=>{k&&Ze(k)},[k]),s.useEffect(()=>{!re&&ae.current&&(Bt({value:""}),ae.current.scrollTop=0),re&&_&&_(_e)},[re]);const dn=H?H/16:q,pn=dn?{maxHeight:`${dn}rem`}:{};return Ve(s.createElement("div",{className:Mr,id:I,"aria-activedescendant":ne>-1?`${I}-option-${ne}`:"",tabIndex:-1,ref:Te,style:ge,onMouseLeave:()=>ce(-1),"data-testid":Q,...U},Pe,s.createElement("div",{className:nt,ref:ae,"data-testid":`${Q}-options`,style:pn},!se&&!Ke.pending&&u&&Ce.length===0&&s.createElement("div",{className:"sps-option-list__zero-state"},u),(se||Ke.pending)&&s.createElement("div",{className:"sps-option-list__loading"},s.createElement(Ko,null)),!se&&!Ke.pending&&Ce.map((he,de)=>{const Xe=`${I}-option-${de}`,lr=Pv(he.value,J,n),cr=Sc(cn.current,n||"",he);return s.createElement("a",{key:Xe,id:Xe,role:M,"aria-selected":lr,href:he.href,className:K("sps-option-list__option",he.caption&&"sps-option-list__option--has-caption",he.disabled&&"sps-option-list__option--disabled",he.bold&&"sps-option-list__option--bold",(lr||cr)&&"sps-option-list__option--selected",ne===de&&"sps-option-list__option--highlighted"),onClick:un=>ln(un,he,cr),onMouseOver:()=>ce(de),tabIndex:-1,ref:ne===de?Ge:null,"data-testid":`${Q}-option-${de}`},he.value&&he.value.icon&&s.createElement("i",{className:K("sps-icon","sps-option-list__option-icon",`sps-icon-${String(he.value.icon)}`)}),(!he.value||!he.value.icon&&Jn)&&s.createElement("span",{className:"sps-option-list__option-icon-spacer"}),s.createElement("span",{dangerouslySetInnerHTML:{__html:he.getHtml(Ke.replacementPattern)}}),he.caption&&s.createElement("div",{className:"sps-option-list__option-caption"},s.createElement("span",{dangerouslySetInnerHTML:{__html:Ke.replacementPattern?he.caption.replace(Ke.replacementPattern,"<u>$&</u>"):he.caption}})))})),ie&&(ee==null?void 0:ee.label)&&s.createElement("a",{className:K("sps-option-list__option","sps-option-list__special-action",ne===Ce.length&&"sps-option-list__option--highlighted",ee.disabled&&"sps-option-list__special-action--disabled"),href:ie.href,target:ie.href&&ee.newTab?"_blank":"_self",onClick:he=>ln(he,ie),onMouseOver:()=>ce(Ce.length),"data-testid":`${Q}-special-action`},ee.icon&&s.createElement("i",{className:K("sps-icon","sps-option-list__option-icon",`sps-icon-${String(ee.icon)}`)}),!ee.icon&&Jn&&s.createElement("span",{className:"sps-option-list__option-icon-spacer"}),s.createElement("span",null,ee.label))))});Object.assign(Vn,{displayName:"SpsOptionList"});function Bv(e,t,r=[]){return s.useMemo(()=>{function n(a){return s.createElement(e,{...a,...t},a.children)}return n},r)}const wp=function({children:e,elements:t}){if(t.length===0)return s.createElement(s.Fragment,null,e);const[r,n]=Array.isArray(t[0])?t[0]:[t[0]];return s.createElement(r,{...n!=null?n:{}},s.createElement(wp,{elements:t.slice(1)},e))},Cp=function({children:e,providers:t=[],...r}){return s.createElement("div",{...r},s.createElement(wp,{elements:t},e))},Fv=function({children:e,className:t,...r}){return s.createElement(Cp,{className:`sps-app ${t}`,...r},e)};function vt(e=[],t=[]){const r=Array.isArray(e)?y.flatten(e):[e],n=t.map(o=>Array.isArray(o)?o:[o]),a=new Array(n.length+1).fill(null).map(()=>[]);for(const o of r){let l=!1;for(let c=0;c<n.length;c+=1)for(const{type:p,props:u={}}of n[c])if(o.type===p&&Object.keys(u).every(m=>u[m]===o.props[m])){l=!0,a[c].push(o);break}l||a[a.length-1].push(o)}return a}function Dp(e,t,r){const n=Object.entries(t).filter(([,o])=>typeof o!="string"&&o.deprecated).map(([o])=>o),a=n.map(o=>r[o]);s.useEffect(()=>{a.find(o=>typeof o<"u")&&console.warn(`The following prop(s) of ${e} are deprecated: ${n.join(", ")}`)},a)}function Ho(e,t){const r=V.useRef(!1);V.useEffect(()=>{if(r.current)return e();r.current=!0},t)}function Np(e,t,r){const n=s.useRef(t(...r));s.useEffect(()=>(document.addEventListener(e,n.current),()=>document.removeEventListener(e,n.current)),[]),s.useEffect(()=>{document.removeEventListener(e,n.current),n.current=t(...r),document.addEventListener(e,n.current)},r)}function Av(e,t,r){return function(a){var o,l;!((o=e.current)!=null&&o.contains(a.target))&&!((l=t.current)!=null&&l.contains(a.target))&&r()}}function Kn(e,t,r){const n=s.useRef(!1),[a,o]=s.useState(!1),l=s.useCallback(()=>{n.current?n.current=!1:o(!0)},[]),c=s.useCallback((p=!1)=>{o(!1),n.current=p,r&&r()},[]);return Np("mousedown",Av,[e,t,c]),{showPopup:a,doShowPopup:l,doHidePopup:c}}const $v={debounce:"number",disabled:"boolean",formMeta:"SpsFormFieldMeta<string>",icon:"SpsIcon",onChange:"React.ChangeEventHandler",placeholder:"string",suggestions:{type:`
|
|
232
|
+
`}}}};let Ct=(e=21)=>crypto.getRandomValues(new Uint8Array(e)).reduce((t,r)=>(r&=63,r<36?t+=r.toString(36):r<62?t+=(r-26).toString(36).toUpperCase():r>62?t+="-":t+="_",t),"");function Dr(e){return V.useRef(e||Ct())}function gt(e,t){const r=Dr(e),n=V.useRef(`${r.current}_ctrl`);return V.useEffect(()=>{t&&(t.id=n.current,t.update())},[t]),{wrapperId:r.current||void 0,controlId:n.current}}var Ot=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},tv="[object Object]";function rv(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch{}return t}function nv(e,t){return function(r){return e(t(r))}}var sv=Function.prototype,lp=Object.prototype,cp=sv.toString,av=lp.hasOwnProperty,ov=cp.call(Object),iv=lp.toString,lv=nv(Object.getPrototypeOf,Object);function cv(e){return!!e&&typeof e=="object"}function dv(e){if(!cv(e)||iv.call(e)!=tv||rv(e))return!1;var t=lv(e);if(t===null)return!0;var r=av.call(t,"constructor")&&t.constructor;return typeof r=="function"&&r instanceof r&&cp.call(r)==ov}var dp=dv;const xt=new Set,rn=new Set,zt=new Set,In=new Set;function pp(e){xt.has(e)||zt.has(e)||In.has(e)||rn.add(e)}function up(e){xt.has(e)||zt.has(e)||rn.has(e)||In.add(e)}const Aa=Zr.default||Zr,Vs="MM/DD/YYYY",pv=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/,mp=Symbol("Date Parse Error");function Fr(e){return e.year*1e4+e.month*100+e.date}const me=Object.freeze({createFrom(e){if(!e)return null;if(typeof e=="string"){const t=pv.exec(e);if(t){const[,r,n,a]=t;return Object.freeze({year:Number(a),month:Number(r),date:Number(n)})}return Object.freeze({[mp]:!0,year:void 0,month:void 0,date:void 0})}return Object.freeze({year:e.year(),month:e.month()+1,date:e.date()})},createRangeFrom(e){return e?e.split(/[^\d]*-[^\d]*/).map(me.createFrom):null},isValid(e){var t;return e&&typeof e=="object"&&typeof e.year=="number"&&typeof e.month=="number"&&typeof e.date=="number"&&((t=me.toMoment(e))==null?void 0:t.isValid())},nullifyInvalidDate(e){return me.isValid(e)?e:null},toMoment(e){return e?Aa({...e,month:e.month-1}):null},toString(e){const t=me.toMoment(e);return t?t.format(Vs):""},toStringRange(e){return e?e.map(me.toString).join("-"):""},create(){const e=new Date;return Object.freeze({year:e.getFullYear(),month:e.getMonth()+1,date:e.getDate()})},isSameDate(e,t){return e&&t&&e.year===t.year&&e.month===t.month&&e.date===t.date},isSameMonth(e,t){return e&&t&&e.year===t.year&&e.month===t.month},isAfter(e,t){return!e||!t?null:Fr(e)>Fr(t)},isBefore(e,t){return!e||!t?null:Fr(e)<Fr(t)},isInRange(e,t,r=!0){if(!e||!t||!t[0]||!t[1])return null;const n=Fr(e),[a,o]=t.map(Fr);return e&&a&&o&&(r&&n>=a&&n<=o||!r&&n>a&&n<o)},prevMonth(e){return Object.freeze({year:e.month===1?e.year-1:e.year,month:e.month-1||12,date:e.date})},nextMonth(e){return Object.freeze({year:e.month===12?e.year+1:e.year,month:e.month+1>12?1:e.month+1,date:e.date})},createRangeFromPreset(e){if(typeof e.definition=="function")return e.definition();const t=Aa(),r=t.clone().subtract(Aa.duration(e.definition));return[me.createFrom(r),me.createFrom(t)]}}),kn=function(t){if(Array.isArray(t)){const r=kn(t[0]),n=kn(t[1]);return r||n}if(t&&t.hasOwnProperty("year")){if(t[mp])return{dateFormat:Vs};if(!me.isValid(t))return{dateValidity:!0}}return null};xt.add("dateFormat");xt.add("dateValidity");const fp=function(t){if(Array.isArray(t)){const r=kn(t);if(r)return r;if(t&&me.isBefore(t[1],t[0]))return{dateRangeOrder:!0}}return null};xt.add("dateRangeOrder");const hp=function({minDate:t,maxDate:r}){function n(a){const o=me.isBefore(a,t),l=me.isAfter(a,r),c={minExceeded:o?me.toString(t):null,maxExceeded:l?me.toString(r):null};return o||l?{dateConstraint:c}:null}return function(o){if(!o)return null;if(Array.isArray(o)){const l=n(o[0]),c=n(o[1]);return l||c}return o.hasOwnProperty("year")?n(o):null}};xt.add("dateConstraint");const uv=Object.freeze(Object.defineProperty({__proto__:null,date:kn,dateRange:fp,dateConstraint:hp},Symbol.toStringTag,{value:"Module"}));function nr(e,t){for(const r of[].concat(e)){const n=t(r);if(n)return n}return null}const mv=function(t){function r(n){return Number(n)>=t?null:{min:t}}return n=>nr(n,r)};xt.add("min");const fv=function(t){function r(n){return Number(n)<=t?null:{max:t}}return n=>nr(n,r)};rn.add("max");const hv=function(t){return typeof t>"u"||t===null||t===""||Number.isNaN(t)||(t==null?void 0:t.length)===0?{required:!0}:null};rn.add("required");const Sv=function(t){function r(n){return n===void 0||n.toString().length<t?{minLength:t}:null}return n=>nr(n,r)};xt.add("minLength");const gv=function(t){function r(n){return n===void 0||n.toString().length<=t?null:{maxLength:t}}return n=>nr(n,r)};zt.add("maxLength");const bv=function(t){const r=t instanceof RegExp?t:new RegExp(t);function n(a){return r.test(a)?null:{pattern:t}}return a=>nr(a,n)};xt.add("pattern");const vv=function(e){function t(r){return/^\p{L}*$/u.test(r)?null:{alpha:!0}}return nr(e,t)};zt.add("alpha");const yv=function(e){function t(r){return/^[0-9,. ]*$/.test(r)?null:{numeric:!0}}return nr(e,t)};zt.add("numeric");const Ev=function(e){function t(r){return/^[^0-9]*$/.test(r)?null:{nonNumeric:!0}}return nr(e,t)};zt.add("nonNumeric");const Ks=Object.freeze({...uv,min:mv,max:fv,required:hv,minLength:Sv,maxLength:gv,pattern:bv,alpha:vv,numeric:yv,nonNumeric:Ev,OnBlurErrorKeys:xt});function $n(e,t=[]){const r=t.reduce((n,a)=>Object.assign(n,a(e)||{}),{});return Object.keys(r).length?r:null}class gr{constructor(t,r){ot(this,"validators",[]);ot(this,"errors",null);ot(this,"revealAllErrors",!1);ot(this,"preventativeErrors",[]);ot(this,"submitted",!1);this.path=t,this.update=r}setValidators(t){return this.update(this.path,null,void 0,t),this}validate(t){return this.validators&&this.validators.length>0?(this.errors=$n(t,this.validators),this.update(),this.isFocused()&&this.onFocus&&this.onFocus()):this.errors&&(this.errors=null,this.update()),this}isValid(){return!this.errors||this.isPristine()}hasErrors(){return!!this.errors}isVisibilyInvalid(){return this.errors&&(this.revealAllErrors&&!Object.keys(this.errors).some(t=>In.has(t))||this.revealAllErrors&&Object.keys(this.errors).some(t=>In.has(t))&&this.isSubmitted()||!this.isPristine()&&Object.keys(this.errors).some(t=>rn.has(t)))}hasError(t){return this.errors&&Object.prototype.hasOwnProperty.call(this.errors,t)}hasPreventativeError(t){return this.preventativeErrors.includes(t)}hasPreventativeErrors(){return this.preventativeErrors.length>0}isRequired(){return this.validators&&this.validators.indexOf(Ks.required)>-1}isSubmitted(){return this.submitted}onFocus(){}onBlur(){}}class vr extends gr{constructor(){super(...arguments);ot(this,"id",Ct());ot(this,"focused",!1);ot(this,"pristine",!0)}setValue(r){if(this.revealAllErrors=!1,this.preventativeErrors=[],this.validators&&this.validators.length>0){const n=$n(r,this.validators);if(n&&Object.keys(n).filter(o=>zt.has(o)).length>0){this.preventativeErrors=Object.keys(n);return}}this.update(this.path,r)}isPristine(){return this.pristine}markAsPristine(){return this.pristine=!0,this.revealAllErrors=!1,this.update(),this}markAsDirty(){return this.pristine=!1,this.update(),this}isFocused(){return this.focused}markAsFocused(){return this.focused=!0,this.update(),this.onFocus&&this.onFocus(),this}markAsBlurred(){return this.update(this.path,null,!0),this.onBlur&&this.onBlur(),this.preventativeErrors=[],this}markAsSubmitted(){return this.submitted=!0,this.update(),this}}class Hs extends vr{constructor(r,n,a){super(a?n:r,a||n);ot(this,"fields");a&&this.inferMembers(r)}isFocused(){return super.isFocused()||this.rollup("isFocused")}isValid(){return super.isValid()&&this.rollup("isValid")}hasErrors(){return super.hasErrors()||Object.keys(this.fields).some(r=>this.fields[r].hasErrors())}contentsAreValid(){return this.rollup("isValid")&&this.rollup("contentsAreValid")}isPristine(){return super.isPristine()&&this.rollup("isPristine")}markAsPristine(){super.markAsPristine();for(const r of Object.keys(this.fields))this.fields[r].markAsPristine();return this}markAsDirty(){super.markAsDirty();for(const r of Object.keys(this.fields))this.fields[r].markAsDirty();return this}markAsBlurred(){super.markAsBlurred();for(const r of Object.keys(this.fields))this.fields[r].markAsBlurred();return this}markAsSubmitted(){super.markAsSubmitted();for(const r of Object.keys(this.fields))this.fields[r].markAsSubmitted();return this}inferSpsControl(r,n){return Ds(r,[...this.path,n],this.update)}rollup(r){return Object.keys(this.fields).reduce((n,a)=>n&&(!this.fields[a][r]||this.fields[a][r]()),!0)}}class Sp extends Hs{inferMembers(t){this.fields={};for(const r of Object.keys(t))this.fields[r]=this.inferSpsControl(t[r],r)}}class gp extends Hs{inferMembers(t){this.fields=t.map((r,n)=>this.inferSpsControl(r,String(n)))}}function Ds(e,t,r){return e instanceof gr?(e.path=t,e.update=r,e):Array.isArray(e)?new gp(e,t,r):dp(e)?new Sp(e,t,r):new vr(t,r)}function ho(e,t){return t.length===0||!e?e:ho(e.fields[t[0]],t.slice(1,t.length))}function So(e,t){if(t.length===0||!e)return[e];const r=t[0];if(t=t.slice(1,t.length),r==="*"){const n=Array.isArray(e.fields)?e.fields:Object.keys(e.fields).map(a=>e.fields[a]);return t.length===0?n:n.reduce((a,o)=>[...a,...So(o,t)],[])}return So(e.fields[r],t)}function bp(e,t,r){for(const n of Object.keys(t)){const a=t[n];for(const o of So(e,n.split(".")))o&&a&&r(o,a)}}function fs(e,t,r,n=!1){bp(t,r,(a,o)=>{a.validators=typeof o=="function"?o(e):o,n&&(a.errors=$n(y.getPath(e,a.path),a.validators))})}function go(e,t){const r=t[0];return t=t.slice(1),Array.isArray(e)?e.map((n,a)=>a===Number(r)?go(n,t):n):dp(e)?Object.keys(e).reduce((n,a)=>Object.assign(n,{[a]:a===r?go(e[a],t):e[a]}),{}):e}function Tv(e){if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError("The initial value of useSpsForm() hook must be an object.")}function vp(e,t={}){Tv(e);const r=V.useMemo(()=>{y.deepFreeze(e);const f=Ds(e,[],p);return t&&fs(e,f,t,!0),f},[]),n=V.useRef(),a=V.useRef(t),o=V.useCallback((f,m)=>{var g,E,C;let h;if(n.current=void 0,m)if(m.path)if(m.markAsBlurred){const T=ho(f.formMeta,m.path);T&&(T.focused=!1,T.revealAllErrors=!0)}else if(m.newValidators){if(a.current){const T=m.path.join(".");a.current={...a.current,[T]:m.newValidators},fs(f.formValue,f.formMeta,a.current,!0)}}else h=go(f.formValue,m.path),y.setPath(h,m.path,m.value);else h=m.value;if((g=m.updateFormOptions)!=null&&g.validators&&(a.current={...a.current,...m.updateFormOptions.validators},fs(f.formValue,f.formMeta,a.current,(C=(E=m.updateFormOptions)==null?void 0:E.runValidators)!=null?C:!0)),h){y.deepFreeze(h);const T=y.diff(f.formValue,h);for(const{type:D,key:N,parentPath:I,objects:[b,x]}of T){const L=ho(f.formMeta,I);if(typeof N!="symbol"&&L)switch(D){case y.DiffChange.ADDITION:L.fields[N]=Ds(x[N],[...I,N],p);break;case y.DiffChange.DELETION:Array.isArray(L.fields)?L.fields.splice(Number(N),1):delete L.fields[N];break;case y.DiffChange.ALTERATION:if(!b[N]&&x[N]&&!(L.fields[N]instanceof Hs)){const k=Ds(x[N],[...I,N],p);k instanceof vr&&L.fields[N]instanceof vr&&(k.id=L.fields[N].id,k.focused=L.fields[N].focused,k.pristine=L.fields[N].pristine),L.fields[N]=k}break}}if(a.current){fs(h,f.formMeta,a.current);const D=new Set;t&&bp(f.formMeta,t,(N,I)=>{typeof I=="function"&&(N.validate(y.getPath(h,N.path)),D.add(N))});for(const{type:N,key:I,parentPath:b,objects:[,x]}of T)if(typeof I!="symbol"){let L=f.formMeta,k=h;if(L){for(const O of b)L=L.fields[O],k=k[O],D.has(L)||L.validate(k);if(N===y.DiffChange.ADDITION||N===y.DiffChange.ALTERATION){const O=L.fields[I];if(!D.has(O)&&(L.fields[I].validate(x[I]),N===y.DiffChange.ADDITION&&O.fields))for(const[B,G]of Object.entries(O.fields))G.validate(x[I][B])}}}}}return{formValue:h||f.formValue,formMeta:f.formMeta,updateForm:f.updateForm}},[]),[l,c]=V.useReducer(o,{formValue:e,formMeta:r,updateForm:u});function p(f,m,h=!1,g){f?c({path:f,value:m,markAsBlurred:h,newValidators:g}):u()}function u(f,m){if(f||m){n.current&&window.clearTimeout(n.current);const h=window.setTimeout(c,0,{value:f,updateFormOptions:m});n.current=h}else if(!n.current){const h=window.setTimeout(c,0,{});n.current=h}}return V.useEffect(()=>()=>{n.current&&window.clearTimeout(n.current)},[]),l}const et=s.forwardRef((e,t)=>{const{className:r,children:n,focusInputOnClick:a,formControl:o,formMeta:l,inputRef:c,onClick:p,...u}=e,f=s.useRef(),h=c||(t||f);function g(){h&&h!==t&&h.current&&h.current.focus()}function E(){h&&h!==t&&h.current&&l&&l instanceof vr&&l.markAsFocused()}function C(){h&&h!==t&&h.current&&l&&l instanceof vr&&l.markAsBlurred()}const T=K("sps-form-group",(o&&o.isRequired()||l&&l.isRequired())&&"sps-form-group--required",(o&&!o.isValid()||l&&l.isVisibilyInvalid())&&"sps-form-group--error",l&&l.hasPreventativeErrors()&&"sps-form-group--preventative-error",r);function D(N){a&&g(),p&&p(N)}return s.useEffect(()=>{function N(I){I.target.classList.contains("sps-form-control__clear-btn")&&I.preventDefault()}return document.addEventListener("mousedown",N),()=>{document.removeEventListener("mousedown",N)}},[]),s.createElement("div",{...u,className:T,ref:t,tabIndex:-1,onClick:D,onFocus:E,onBlur:C},n)});Object.assign(et,{displayName:"SpsFormComponentWrapper"});function uc(e){return typeof e=="object"&&e!=null&&e.nodeType===1}function mc(e,t){return(!t||e!=="hidden")&&e!=="visible"&&e!=="clip"}function $a(e,t){if(e.clientHeight<e.scrollHeight||e.clientWidth<e.scrollWidth){var r=getComputedStyle(e,null);return mc(r.overflowY,t)||mc(r.overflowX,t)||function(n){var a=function(o){if(!o.ownerDocument||!o.ownerDocument.defaultView)return null;try{return o.ownerDocument.defaultView.frameElement}catch{return null}}(n);return!!a&&(a.clientHeight<n.scrollHeight||a.clientWidth<n.scrollWidth)}(e)}return!1}function hs(e,t,r,n,a,o,l,c){return o<e&&l>t||o>e&&l<t?0:o<=e&&c<=r||l>=t&&c>=r?o-e-n:l>t&&c<r||o<e&&c>r?l-t+a:0}function fc(e,t){var r=window,n=t.scrollMode,a=t.block,o=t.inline,l=t.boundary,c=t.skipOverflowHiddenElements,p=typeof l=="function"?l:function(xe){return xe!==l};if(!uc(e))throw new TypeError("Invalid target");for(var u=document.scrollingElement||document.documentElement,f=[],m=e;uc(m)&&p(m);){if((m=m.parentElement)===u){f.push(m);break}m!=null&&m===document.body&&$a(m)&&!$a(document.documentElement)||m!=null&&$a(m,c)&&f.push(m)}for(var h=r.visualViewport?r.visualViewport.width:innerWidth,g=r.visualViewport?r.visualViewport.height:innerHeight,E=window.scrollX||pageXOffset,C=window.scrollY||pageYOffset,T=e.getBoundingClientRect(),D=T.height,N=T.width,I=T.top,b=T.right,x=T.bottom,L=T.left,k=a==="start"||a==="nearest"?I:a==="end"?x:I+D/2,O=o==="center"?L+N/2:o==="end"?b:L,B=[],G=0;G<f.length;G++){var _=f[G],W=_.getBoundingClientRect(),M=W.height,F=W.width,J=W.top,ee=W.right,z=W.bottom,se=W.left;if(n==="if-needed"&&I>=0&&L>=0&&x<=g&&b<=h&&I>=J&&x<=z&&L>=se&&b<=ee)return B;var A=getComputedStyle(_),H=parseInt(A.borderLeftWidth,10),q=parseInt(A.borderTopWidth,10),Z=parseInt(A.borderRightWidth,10),te=parseInt(A.borderBottomWidth,10),Q=0,U=0,ie="offsetWidth"in _?_.offsetWidth-_.clientWidth-H-Z:0,ne="offsetHeight"in _?_.offsetHeight-_.clientHeight-q-te:0;if(u===_)Q=a==="start"?k:a==="end"?k-g:a==="nearest"?hs(C,C+g,g,q,te,C+k,C+k+D,D):k-g/2,U=o==="start"?O:o==="center"?O-h/2:o==="end"?O-h:hs(E,E+h,h,H,Z,E+O,E+O+N,N),Q=Math.max(0,Q+C),U=Math.max(0,U+E);else{Q=a==="start"?k-J-q:a==="end"?k-z+te+ne:a==="nearest"?hs(J,z,M,q,te+ne,k,k+D,D):k-(J+M/2)+ne/2,U=o==="start"?O-se-H:o==="center"?O-(se+F/2)+ie/2:o==="end"?O-ee+Z+ie:hs(se,ee,F,H,Z+ie,O,O+N,N);var ce=_.scrollLeft,re=_.scrollTop;k+=re-(Q=Math.max(0,Math.min(re+Q,_.scrollHeight-M+ne))),O+=ce-(U=Math.max(0,Math.min(ce+U,_.scrollWidth-F+ie)))}B.push({el:_,top:Q,left:U})}return B}function yp(e){return e===Object(e)&&Object.keys(e).length!==0}function wv(e,t){t===void 0&&(t="auto");var r="scrollBehavior"in document.body.style;e.forEach(function(n){var a=n.el,o=n.top,l=n.left;a.scroll&&r?a.scroll({top:o,left:l,behavior:t}):(a.scrollTop=o,a.scrollLeft=l)})}function Cv(e){return e===!1?{block:"end",inline:"nearest"}:yp(e)?e:{block:"start",inline:"nearest"}}function Ep(e,t){var r=!e.ownerDocument.documentElement.contains(e);if(yp(t)&&typeof t.behavior=="function")return t.behavior(r?[]:fc(e,t));if(!r){var n=Cv(t);return wv(fc(e,n),n.behavior)}}const Dv=Object.freeze(Object.defineProperty({__proto__:null,default:Ep},Symbol.toStringTag,{value:"Module"})),Nv={alt:"string",size:"SpinnerSize",title:"string"};function Ko(e){const{alt:t,className:r,size:n=$.SpinnerSize.MEDIUM,"data-testid":a,title:o,unsafelyReplaceClassName:l,...c}=e,{t:p}=s.useContext(Re),u=t||o||p("design-system:spinner.defaultAltText"),f=K(l||"sps-spinner",`sps-spinner--${n}`,r);return s.createElement("i",{className:f,"data-testid":a,title:u,...c})}Object.assign(Ko,{props:Nv,displayName:"SpsSpinner"});const xv=60;function Ss(e){return typeof e>"u"?"inherit":`${e}px`}function Tp(e){switch(e){case $.Position.TOP_LEFT:return $.Position.BOTTOM_LEFT;case $.Position.TOP_MIDDLE:return $.Position.BOTTOM_MIDDLE;case $.Position.TOP_RIGHT:return $.Position.BOTTOM_RIGHT;case $.Position.RIGHT_TOP:return $.Position.LEFT_TOP;case $.Position.RIGHT_MIDDLE:return $.Position.LEFT_MIDDLE;case $.Position.RIGHT_BOTTOM:return $.Position.LEFT_BOTTOM;case $.Position.BOTTOM_RIGHT:return $.Position.TOP_RIGHT;case $.Position.BOTTOM_MIDDLE:return $.Position.TOP_MIDDLE;case $.Position.BOTTOM_LEFT:return $.Position.TOP_LEFT;case $.Position.LEFT_BOTTOM:return $.Position.RIGHT_BOTTOM;case $.Position.LEFT_MIDDLE:return $.Position.RIGHT_MIDDLE;case $.Position.LEFT_TOP:return $.Position.RIGHT_TOP}}function Iv(e,t,r,n,a,o,l,c){const p=l&&l.current,u=p?p.scrollTop:window.pageYOffset,f=c?0:u,m=p?p.scrollLeft:window.pageXOffset,h=c?0:m,[g,E]=e.split(" ");let C,T,D,N;switch(g){case"top":D=t.height-r.top-f-o[0];break;case"left":T=t.width-r.left-h-o[0];break;case"right":N=r.right+h-o[0];break;case"bottom":C=r.bottom+f-o[0];break;default:throw new Error(`Invalid position ${e}`)}switch(E){case"left":N=r.left+h+o[1];break;case"top":C=r.top+f+o[1];break;case"middle":g==="top"||g==="bottom"?N=r.left+h+r.width/2-a/2+o[1]:(g==="left"||g==="right")&&(C=r.top+f+r.height/2-n.height/2+o[1]);break;case"bottom":D=t.height-r.bottom-f+o[1];break;case"right":T=t.width-r.right-h+o[1];break;default:throw new Error(`Invalid position ${e}`)}return[C,T,D,N]}function yr(e,t,r,{altPosition:n,setMinWidth:a=!1,setWidth:o=!1,parentElementRef:l,fixed:c=!1,offsets:p=[0,0]}){if(e.current&&t.current){const u=Math.max(document.documentElement.clientHeight,window.innerHeight||0),f=document.documentElement.getBoundingClientRect().width,m=l&&l.current?l.current:document.documentElement,h=c?{width:f,height:u,top:0,left:0,bottom:u,right:f}:m.getBoundingClientRect(),g=e.current.getBoundingClientRect(),E=t.current.getBoundingClientRect(),[C]=r.split(" ");let T=r;n&&(C==="top"&&E.top-g.height<xv||C==="right"&&E.right+g.width>f||C==="bottom"&&E.bottom+g.height>u||C==="left"&&E.left-g.width<0)&&(T=n);const D=a?Math.max(E.width,g.width):g.width,N=o?E.width:D,[I,b,x,L]=Iv(T,h,E,g,N,p,l,c),k={top:Ss(I),right:Ss(b),bottom:Ss(x),left:Ss(L)};return c&&(k.position="fixed",k.zIndex=$.ZStratum.BAR),a&&(k.minWidth=`${E.width}px`),o&&(k.width=`${E.width}px`),[k,T===n]}return[{},!1]}const bt=V.createContext(null);function nn(e,t=[]){const r=V.useContext(bt);return V.useMemo(()=>n=>{const o=r&&r.parentElementRef&&r.parentElementRef.current||document.body;let l=null,c=o.lastElementChild;for(;c&&c!==o.firstElementChild;){if(c.hasAttribute("data-portalid")&&c.getAttribute("data-portalid")===e){l=c;break}c=c.previousElementSibling}if(l)o.contains(l)||o.appendChild(l);else{l=document.createElement("div"),l.setAttribute("data-portalid",e);for(const p of t)l.classList.add(p);o.appendChild(l)}return Ao.createPortal(n,l)},[r])}async function hc(e,t,r,n,a,o){const l=typeof e.options=="function"?e.options(t.value):e.options||[],c=l instanceof Promise,p=m=>m.replace(/([.?*+^$[\]\\(){}|-])/g,"");r({pending:c}),o.current=c?l:null;const u=c?await l||[]:l||[];if(c&&o.current!==l)return;let f=Array.from(u).filter(Boolean).map(m=>new $.SpsOptionListOption(m,typeof m=="function"?{textKey:"label",captionKey:"caption"}:{textKey:e.textKey,captionKey:e.captionKey}));if(e.nullOption&&f.unshift(new $.SpsOptionListOption(null,{text:e.nullOption})),t.value&&!e.disableDefaultOptionsFiltering){const m=p(t.value);r({replacementPattern:new RegExp(m,"ig")}),f=f.filter(h=>{const g=new RegExp(m,"i"),E=p(h.text);return e.filterByTextAndCaptionKey?g.test(E)||g.test(p(h.caption)):g.test(E)})}else r({replacementPattern:null});if(e.disabledOptions)for(const m of f)e.disabledOptions.includes(m.value)&&(m.disabled=!0);n(Object.freeze(f)),e.onOptionListChanged&&e.onOptionListChanged(f.length),a(f.some(m=>m.value&&!!m.value.icon)),r({pending:!1})}function kv(e,t,r){const[n,a]=s.useState(Object.freeze([])),[o,l]=s.useState(!1),c=s.useRef(null),p=s.useRef(e.options);(typeof e.options!="function"||e.disableOptionsMemoization)&&(p.current=e.options);const u=s.useMemo(()=>typeof p.current=="function"?y.debounce(hc,typeof e.searchDebounce<"u"?e.searchDebounce:500):hc,[p.current,e.disabledOptions]);return s.useEffect(()=>{u(e,t,r,a,l,c)},[p.current,t.value,e.disabledOptions]),[n,o]}class sr{constructor(t,r){ot(this,"nativeEvent");ot(this,"currentTarget");ot(this,"isPgStoppedInternal",!1);this.target=t,this.currentTarget=t,this.nativeEvent=new CustomEvent("change",r),Object.defineProperty(this.nativeEvent,"target",{value:t,writable:!1,configurable:!1,enumerable:!0})}get bubbles(){return this.nativeEvent.bubbles}get cancelable(){return this.nativeEvent.cancelable}get defaultPrevented(){return this.nativeEvent.defaultPrevented}get eventPhase(){return this.nativeEvent.eventPhase}get isTrusted(){return this.nativeEvent.isTrusted}get timeStamp(){return this.nativeEvent.timeStamp}get type(){return this.nativeEvent.type}preventDefault(){this.nativeEvent.preventDefault()}isDefaultPrevented(){return this.defaultPrevented}stopPropagation(){this.nativeEvent.stopPropagation(),this.isPgStoppedInternal=!0}isPropagationStopped(){return this.isPgStoppedInternal}persist(){throw new Error("This is not a real React ChangeEvent. React does not permit the creation of SyntheticEvents in userland.")}}function Mv(e,t){return{...e,...t}}function Rt(e){return V.useReducer(Mv,e)}function _v({hideInlineSearch:e,options:t,onSearchChange:r,search:n="",searchPlaceholder:a="Search\u2026",searchInputRef:o}){const[l,c]=Rt({isAsync:typeof t=="function",pending:!1,value:n,replacementPattern:null}),p=s.useCallback(g=>{c({value:g.target.value}),r&&r(g)},[r]),u=s.useCallback(g=>{g.nativeEvent.stopImmediatePropagation(),g.stopPropagation()},[]),f=s.useCallback(g=>{g.nativeEvent.stopImmediatePropagation(),c({value:""}),o!=null&&o.current&&(r&&r(new sr(o.current)),o.current.focus())},[r]),m=g=>{!g||["Tab","Escape","Enter","Up","ArrowUp","Down","ArrowDown"].includes(g.key)||g.stopPropagation()};return s.useEffect(()=>{c({value:n})},[n]),[l.isAsync&&!e?s.createElement("div",{className:"sps-option-list__search sps-form-group sps-text-input"},s.createElement("div",{className:"sps-form-control"},!l.value&&s.createElement("i",{className:"sps-icon sps-icon-filter sps-text-input__icon"}),s.createElement("input",{type:"text",className:"sps-text-input__input",placeholder:a,ref:o,value:l.value,onChange:p,onClick:u,onKeyDown:m}),l.value&&s.createElement("i",{className:"sps-icon sps-icon-x-circle sps-form-control__clear-btn",onClick:f}))):s.createElement(s.Fragment,null),l,c]}const Lv=Ep||Dv,Ov=["Tab","Escape","Enter","Up","ArrowUp","Down","ArrowDown"],Rv=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];function Pv(e,t,r){return r?(e&&e[r])===(t&&t[r]):e===t}function Sc(e,t,r){return typeof r.value=="function"&&r.disabled?!0:t?!!(e!=null&&e.find(n=>{var a;return n[t]&&n[t]===((a=r==null?void 0:r.value)==null?void 0:a[t])})):!1}const Vn=s.forwardRef((e,t)=>{const{captionKey:r,comparisonKey:n,disabledOptions:a,options:o,tall:l,textKey:c,valueKey:p,zeroState:u,hideInlineSearch:f,onSearchChange:m,search:h,searchDebounce:g,searchPlaceholder:E,onSpecialActionSelect:C,attachTo:T,className:D,conformWidth:N,id:I,ignoreWidthStyles:b,isOpen:x,keepOpen:L,keyDown:k,nullOption:O,onOptionListChanged:B,onOptionSelected:G,onPositionFlip:_,onSelfToggle:W,optionRole:M,positionOverride:F,selectedOption:J,specialAction:ee,unsafelyReplaceClassName:z,loading:se,filterByTextAndCaptionKey:A,maxHeightPx:H,maxHeightRem:q,disableOptionsMemoization:Z,disableDefaultOptionsFiltering:te,"data-testid":Q,...U}=e,ie=s.useMemo(()=>ee?new $.SpsOptionListOption(ee,{textKey:"label",captionKey:"caption"}):null,[ee]),[ne,ce]=s.useState(-1),[re,xe]=s.useState(x),Te=t||s.useRef(null),ae=s.useRef(null),Ge=s.useRef(null),Ve=nn("sps-option-list-portal"),tt=s.useContext(bt),[pt,rt]=F||[$.Position.BOTTOM_LEFT,$.Position.TOP_LEFT],[[ge,_e],Se]=s.useState([{},!1]),ve=s.useRef(null),[Pe,Ke,Bt]=_v({...e,searchInputRef:ve}),[Ce,Jn]=kv(e,Ke,Bt);s.useEffect(()=>{Se(re?yr(Te,T,pt,{altPosition:rt,setMinWidth:!b,setWidth:!b&&N,...tt}):[{},!1])},[re,pt,rt,Ce]),s.useEffect(()=>{const he=()=>{re&&Se(yr(Te,T,pt,{altPosition:rt,setMinWidth:!b,setWidth:!b&&N,...tt}))};return document.addEventListener("scroll",he),()=>{document.removeEventListener("scroll",he)}},[re]),s.useEffect(()=>{ce(-1)},[Ke]);const Mr=K(z||"sps-option-list","z-stratum-dropdown",re&&"sps-option-list--open",Ke.isAsync&&"sps-option-list--searchable",_e&&"sps-option-list--opens-upward",ee&&ee.label&&"sps-option-list--has-special-action",D),nt=K(z||"sps-option-list__options",l&&"sps-option-list__options--tall"),be=s.useCallback(()=>{re||(xe(!0),ve.current&&ve.current.focus(),ce(-1),W&&W(!0))},[re,W]),ut=s.useCallback(()=>{re&&(xe(!1),ce(-1),W&&W(!1))},[re,W]),kt=s.useCallback((he,de)=>{de||he&&!he.disabled&&(typeof he.value=="function"?(he.value(),C&&C()):typeof G=="function"&&G(he.value),L||ut())},[G,ut]),ln=s.useCallback((he,de,Xe)=>{he.stopPropagation(),kt(de,Xe)},[kt]),cn=s.useRef(a||[]);cn.current=a||[];const va=s.useCallback(he=>{switch(he.key){case"Tab":case"Escape":ut();break;case"Enter":if(ne>-1){const de=Ce[ne]||ie;he.preventDefault();const Xe=!!de&&Sc(cn.current,n||"",de);!Xe&&de&&typeof G=="function"&&typeof de.value=="function"?de.value():de&&kt(de,Xe)}break;case"Up":case"ArrowUp":{let de=ne;_e?ne<=-1?de=Ce.length-1:ne===0?ee&&(de=Ce.length):ne<Ce.length&&(de=ne-1):ne>-1&&(de=ne-1),de!==ne&&(he.preventDefault(),ce(de));break}case"Down":case"ArrowDown":{be();let de=ne;_e?ne!==-1&&(ne>=Ce.length?de=0:ne===Ce.length-1?de=-1:de=ne+1):ne<Ce.length-1+Number(!!ee)&&(de=ne+1),de!==ne&&(he.preventDefault(),ce(de));break}default:be()}},[ut,be,ne,kt,G,_e,Ce]),Zn=s.useCallback(he=>{const de=Ce.findIndex(Xe=>{if(Xe.textKey){const lr=Xe.textKey;return Xe.value[lr].toLowerCase().charAt([0])===he.key.toLocaleLowerCase()}return Xe.value.toString().toLowerCase().charAt([0])===he.key.toLocaleLowerCase()});de>-1&&ce(de)},[Ce]),Ze=s.useCallback(he=>{!he||(Ov.includes(he.key)?va(he):Rv.includes(he.key)&&!f&&Zn(he))},[ut,be,ne,kt,G,_e,Ce]);s.useEffect(()=>{if(tt!==null&&document.getElementsByClassName("sps-modal__body").length>0){const he=()=>{W&&W(!1)},de=document.getElementsByClassName("sps-modal__body")[0];return de.addEventListener("scroll",he),()=>{de.removeEventListener("scroll",he)}}},[]),s.useEffect(()=>{Ge.current&&Lv(Ge.current,{scrollMode:"if-needed",block:"nearest",inline:"nearest"})},[ne]),s.useEffect(()=>{xe(x),x?ve.current&&ve.current.focus():ce(-1)},[x]),s.useEffect(()=>{k&&Ze(k)},[k]),s.useEffect(()=>{!re&&ae.current&&(Bt({value:""}),ae.current.scrollTop=0),re&&_&&_(_e)},[re]);const dn=H?H/16:q,pn=dn?{maxHeight:`${dn}rem`}:{};return Ve(s.createElement("div",{className:Mr,id:I,"aria-activedescendant":ne>-1?`${I}-option-${ne}`:"",tabIndex:-1,ref:Te,style:ge,onMouseLeave:()=>ce(-1),"data-testid":Q,...U},Pe,s.createElement("div",{className:nt,ref:ae,"data-testid":`${Q}-options`,style:pn},!se&&!Ke.pending&&u&&Ce.length===0&&s.createElement("div",{className:"sps-option-list__zero-state"},u),(se||Ke.pending)&&s.createElement("div",{className:"sps-option-list__loading"},s.createElement(Ko,null)),!se&&!Ke.pending&&Ce.map((he,de)=>{const Xe=`${I}-option-${de}`,lr=Pv(he.value,J,n),cr=Sc(cn.current,n||"",he);return s.createElement("a",{key:Xe,id:Xe,role:M,"aria-selected":lr,href:he.href,className:K("sps-option-list__option",he.caption&&"sps-option-list__option--has-caption",he.disabled&&"sps-option-list__option--disabled",he.bold&&"sps-option-list__option--bold",(lr||cr)&&"sps-option-list__option--selected",ne===de&&"sps-option-list__option--highlighted"),onClick:un=>ln(un,he,cr),onMouseOver:()=>ce(de),tabIndex:-1,ref:ne===de?Ge:null,"data-testid":`${Q}-option-${de}`},he.value&&he.value.icon&&s.createElement("i",{className:K("sps-icon","sps-option-list__option-icon",`sps-icon-${String(he.value.icon)}`)}),(!he.value||!he.value.icon&&Jn)&&s.createElement("span",{className:"sps-option-list__option-icon-spacer"}),s.createElement("span",{dangerouslySetInnerHTML:{__html:he.getHtml(Ke.replacementPattern)}}),he.caption&&s.createElement("div",{className:"sps-option-list__option-caption"},s.createElement("span",{dangerouslySetInnerHTML:{__html:Ke.replacementPattern?he.caption.replace(Ke.replacementPattern,"<u>$&</u>"):he.caption}})))})),ie&&(ee==null?void 0:ee.label)&&s.createElement("a",{className:K("sps-option-list__option","sps-option-list__special-action",ne===Ce.length&&"sps-option-list__option--highlighted",ee.disabled&&"sps-option-list__special-action--disabled"),href:ie.href,target:ie.href&&ee.newTab?"_blank":"_self",onClick:he=>ln(he,ie),onMouseOver:()=>ce(Ce.length),"data-testid":`${Q}-special-action`},ee.icon&&s.createElement("i",{className:K("sps-icon","sps-option-list__option-icon",`sps-icon-${String(ee.icon)}`)}),!ee.icon&&Jn&&s.createElement("span",{className:"sps-option-list__option-icon-spacer"}),s.createElement("span",null,ee.label))))});Object.assign(Vn,{displayName:"SpsOptionList"});function Bv(e,t,r=[]){return s.useMemo(()=>{function n(a){return s.createElement(e,{...a,...t},a.children)}return n},r)}const wp=function({children:e,elements:t}){if(t.length===0)return s.createElement(s.Fragment,null,e);const[r,n]=Array.isArray(t[0])?t[0]:[t[0]];return s.createElement(r,{...n!=null?n:{}},s.createElement(wp,{elements:t.slice(1)},e))},Cp=function({children:e,providers:t=[],...r}){return s.createElement("div",{...r},s.createElement(wp,{elements:t},e))},Fv=function({children:e,className:t,...r}){return s.createElement(Cp,{className:`sps-app ${t}`,...r},e)};function vt(e=[],t=[]){const r=Array.isArray(e)?y.flatten(e):[e],n=t.map(o=>Array.isArray(o)?o:[o]),a=new Array(n.length+1).fill(null).map(()=>[]);for(const o of r){let l=!1;for(let c=0;c<n.length;c+=1)for(const{type:p,props:u={}}of n[c])if(o.type===p&&Object.keys(u).every(m=>u[m]===o.props[m])){l=!0,a[c].push(o);break}l||a[a.length-1].push(o)}return a}function Dp(e,t,r){const n=Object.entries(t).filter(([,o])=>typeof o!="string"&&o.deprecated).map(([o])=>o),a=n.map(o=>r[o]);s.useEffect(()=>{a.find(o=>typeof o<"u")&&console.warn(`The following prop(s) of ${e} are deprecated: ${n.join(", ")}`)},a)}function Ho(e,t){const r=V.useRef(!1);V.useEffect(()=>{if(r.current)return e();r.current=!0},t)}function Np(e,t,r){const n=s.useRef(t(...r));s.useEffect(()=>(document.addEventListener(e,n.current),()=>document.removeEventListener(e,n.current)),[]),s.useEffect(()=>{document.removeEventListener(e,n.current),n.current=t(...r),document.addEventListener(e,n.current)},r)}function Av(e,t,r){return function(a){var o,l;!((o=e.current)!=null&&o.contains(a.target))&&!((l=t.current)!=null&&l.contains(a.target))&&r()}}function Kn(e,t,r){const n=s.useRef(!1),[a,o]=s.useState(!1),l=s.useCallback(()=>{n.current?n.current=!1:o(!0)},[]),c=s.useCallback((p=!1)=>{o(!1),n.current=p,r&&r()},[]);return Np("mousedown",Av,[e,t,c]),{showPopup:a,doShowPopup:l,doHidePopup:c}}const $v={debounce:"number",disabled:"boolean",formMeta:"SpsFormFieldMeta<string>",icon:"SpsIcon",onChange:"React.ChangeEventHandler",placeholder:"string",suggestions:{type:`
|
|
233
233
|
Eventually<Iterable<string>>
|
|
234
234
|
| ((filter?: string) => Eventually<Iterable<string>>)
|
|
235
235
|
`,required:!0},tallOptionList:"boolean",value:"string",zeroState:"string",loading:"boolean",maxHeightOptionListPx:"number",maxHeightOptionListRem:"number",disableOptionsMemoization:"boolean"};function Ws({className:e,debounce:t=0,disabled:r,formControl:n,formMeta:a,onChange:o,icon:l,id:c,placeholder:p="",suggestions:u,unsafelyReplaceClassName:f,tallOptionList:m,value:h="",zeroState:g,loading:E,maxHeightOptionListPx:C,maxHeightOptionListRem:T,disableOptionsMemoization:D,"data-testid":N,...I}){const b=a||n,{wrapperId:x,controlId:L}=gt(c,b),[k,O]=Rt({keyDown:null,opensUpward:!1}),B=s.useRef(null),G=s.useRef(null),_=s.useRef(null),{showPopup:W,doShowPopup:M,doHidePopup:F}=Kn(B,_);function J(Z,te){b&&(b.setValue(Z),b.markAsDirty()),o&&o(te||new sr({value:Z}))}function ee(Z){G.current&&(G.current.value="",J("")),Z.stopPropagation()}function z(Z){J(Z.target.value,Z)}function se(Z){r||(["Up","ArrowUp","Down","ArrowDown","Enter"].indexOf(Z.key)>-1&&(Z.preventDefault(),Z.persist()),Z.stopPropagation(),O({keyDown:Z})),Z.key==="Tab"&&F()}function A(Z){Z?M():F()}function H(Z){O({opensUpward:Z})}const q=K(f||"sps-autocomplete",W&&"sps-autocomplete--open",W&&"z-stratum-dropdown",k.opensUpward&&"sps-autocomplete--opens-upward",r&&"sps-form-control--disabled",e);return s.createElement(et,{id:x,className:q,formControl:n,formMeta:a,inputRef:G,ref:B,focusInputOnClick:!0,onClick:Z=>Z.nativeEvent.stopImmediatePropagation(),"data-testId":`${N}`},s.createElement("div",{className:"sps-text-input"},s.createElement("div",{className:"sps-form-control"},l&&s.createElement("i",{className:K("sps-text-input__icon","sps-icon",`sps-icon-${l}`)}),s.createElement("input",{type:"text",ref:G,value:h,className:"sps-text-input__input",placeholder:p,onFocus:M,onClick:M,onChange:z,onKeyDown:se,disabled:r,id:L,"data-testid":`${N}__input`,...I}),h&&!r&&s.createElement("i",{"aria-label":"clear",className:"sps-icon sps-icon-x-circle sps-form-control__clear-btn",onClick:Z=>ee(Z)}))),s.createElement(Vn,{id:`${x}_options`,ref:_,attachTo:B,isOpen:W,options:u,hideInlineSearch:!0,keyDown:k.keyDown,onOptionSelected:J,onPositionFlip:H,onSelfToggle:A,offsets:[1,0],search:h,searchDebounce:t,tall:m,zeroState:g,loading:E,maxHeightPx:C,maxHeightRem:T,disableOptionsMemoization:D}))}Object.assign(Ws,{props:$v,displayName:"SpsAutocomplete"});const xp={basic:{label:"Basic",examples:{basic:{react:y.code`
|
package/lib/index.es.js
CHANGED
|
@@ -1816,7 +1816,7 @@ const zn = s.forwardRef((e, t) => {
|
|
|
1816
1816
|
});
|
|
1817
1817
|
le > -1 && ie(le);
|
|
1818
1818
|
}, [Ce]), rt = s.useCallback((fe) => {
|
|
1819
|
-
!fe || (Yb.includes(fe.key) ? pa(fe) : zb.includes(fe.key) && rs(fe));
|
|
1819
|
+
!fe || (Yb.includes(fe.key) ? pa(fe) : zb.includes(fe.key) && !f && rs(fe));
|
|
1820
1820
|
}, [
|
|
1821
1821
|
gt,
|
|
1822
1822
|
ge,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spscommerce/ds-react",
|
|
3
3
|
"description": "SPS Design System React components",
|
|
4
|
-
"version": "7.5.
|
|
4
|
+
"version": "7.5.2",
|
|
5
5
|
"author": "SPS Commerce",
|
|
6
6
|
"license": "UNLICENSED",
|
|
7
7
|
"repository": "https://github.com/spscommerce/woodland/tree/main/packages/@spscommerce/ds-react",
|
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"@react-stately/collections": "^3.6.0",
|
|
43
|
-
"@sps-woodland/illustrations": "7.5.
|
|
44
|
-
"@sps-woodland/tabs": "7.5.
|
|
45
|
-
"@spscommerce/ds-colors": "7.5.
|
|
46
|
-
"@spscommerce/ds-shared": "7.5.
|
|
47
|
-
"@spscommerce/positioning": "7.5.
|
|
43
|
+
"@sps-woodland/illustrations": "7.5.2",
|
|
44
|
+
"@sps-woodland/tabs": "7.5.2",
|
|
45
|
+
"@spscommerce/ds-colors": "7.5.2",
|
|
46
|
+
"@spscommerce/ds-shared": "7.5.2",
|
|
47
|
+
"@spscommerce/positioning": "7.5.2",
|
|
48
48
|
"@spscommerce/utils": "^6.11.3",
|
|
49
49
|
"moment": "^2.25.3",
|
|
50
50
|
"moment-timezone": "^0.5.28",
|
|
@@ -58,11 +58,11 @@
|
|
|
58
58
|
"@react-types/select": "^3.6.1",
|
|
59
59
|
"@react-types/shared": "^3.8.0",
|
|
60
60
|
"@react-types/tabs": "^3.0.1",
|
|
61
|
-
"@sps-woodland/illustrations": "7.5.
|
|
62
|
-
"@sps-woodland/tabs": "7.5.
|
|
63
|
-
"@spscommerce/ds-colors": "7.5.
|
|
64
|
-
"@spscommerce/ds-shared": "7.5.
|
|
65
|
-
"@spscommerce/positioning": "7.5.
|
|
61
|
+
"@sps-woodland/illustrations": "7.5.2",
|
|
62
|
+
"@sps-woodland/tabs": "7.5.2",
|
|
63
|
+
"@spscommerce/ds-colors": "7.5.2",
|
|
64
|
+
"@spscommerce/ds-shared": "7.5.2",
|
|
65
|
+
"@spscommerce/positioning": "7.5.2",
|
|
66
66
|
"@spscommerce/utils": "^6.12.1",
|
|
67
67
|
"@testing-library/dom": "^8.17.1",
|
|
68
68
|
"@testing-library/react": "^10.0.0",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"raf-stub": "^2.0.2",
|
|
77
77
|
"react": "^16.9.0",
|
|
78
78
|
"react-dom": "^16.9.0",
|
|
79
|
-
"test": "7.5.
|
|
79
|
+
"test": "7.5.2"
|
|
80
80
|
},
|
|
81
81
|
"scripts": {
|
|
82
82
|
"build": "pnpm run build:js && pnpm run build:types",
|