@spscommerce/ds-react 6.5.0 → 6.5.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/lib/index.cjs.js +1 -1
- package/lib/index.es.js +1 -1
- package/package.json +11 -11
package/lib/index.cjs.js
CHANGED
|
@@ -193,7 +193,7 @@
|
|
|
193
193
|
</SpsAdvancedSearch>
|
|
194
194
|
</>;
|
|
195
195
|
}
|
|
196
|
-
`}}}};var av=self.crypto||self.msCrypto,to="-_",dn=36;for(;dn--;)to+=dn.toString(36);dn=36;for(;dn---10;)to+=dn.toString(36).toUpperCase();var sv=function(e){var t="",n=av.getRandomValues(new Uint8Array(e||21));for(dn=e||21;dn--;)t+=to[n[dn]&63];return t},un=sv;function Gn(e){return V.useRef(e||un())}function Dt(e,t){const n=Gn(e),a=V.useRef(`${n.current}_ctrl`);return V.useEffect(()=>{t&&(t.id=a.current,t.update())},[t]),{wrapperId:n.current,controlId:a.current}}var rv="[object Object]";function ov(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch{}return t}function iv(e,t){return function(n){return e(t(n))}}var lv=Function.prototype,Nc=Object.prototype,Dc=lv.toString,cv=Nc.hasOwnProperty,dv=Dc.call(Object),uv=Nc.toString,pv=iv(Object.getPrototypeOf,Object);function mv(e){return!!e&&typeof e=="object"}function fv(e){if(!mv(e)||uv.call(e)!=rv||ov(e))return!1;var t=pv(e);if(t===null)return!0;var n=cv.call(t,"constructor")&&t.constructor;return typeof n=="function"&&n instanceof n&&Dc.call(n)==dv}var Ic=fv;const It=new Set,jn=new Set,Qt=new Set,ba=new Set;function kc(e){It.has(e)||Qt.has(e)||ba.has(e)||jn.add(e)}function _c(e){It.has(e)||Qt.has(e)||jn.has(e)||ba.add(e)}const no=Wn.default||Wn,ps="MM/DD/YYYY",hv=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/,Mc=Symbol("Date Parse Error");function Yn(e){return e.year*1e4+e.month*100+e.date}const pe=Object.freeze({createFrom(e){if(!e)return null;if(typeof e=="string"){const t=hv.exec(e);if(t){const[,n,a,o]=t;return Object.freeze({year:Number(o),month:Number(n),date:Number(a)})}return Object.freeze({[Mc]:!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(pe.createFrom):null},isValid(e){return e&&typeof e=="object"&&typeof e.year=="number"&&typeof e.month=="number"&&typeof e.date=="number"&&pe.toMoment(e).isValid()},nullifyInvalidDate(e){return pe.isValid(e)?e:null},toMoment(e){return e?no($(k({},e),{month:e.month-1})):null},toString(e){const t=pe.toMoment(e);return t?t.format(ps):""},toStringRange(e){return e?e.map(pe.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:Yn(e)>Yn(t)},isBefore(e,t){return!e||!t?null:Yn(e)<Yn(t)},isInRange(e,t,n=!0){if(!e||!t||!t[0]||!t[1])return null;const a=Yn(e),[o,i]=t.map(Yn);return e&&o&&i&&(n&&a>=o&&a<=i||!n&&a>o&&a<i)},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=no(),n=t.clone().subtract(no.duration(e.definition));return[pe.createFrom(n),pe.createFrom(t)]}}),va=function(t){if(Array.isArray(t)){const n=va(t[0]),a=va(t[1]);return n||a}if(t&&t.hasOwnProperty("year")){if(t[Mc])return{dateFormat:ps};if(!pe.isValid(t))return{dateValidity:!0}}return null};It.add("dateFormat");It.add("dateValidity");const Oc=function(t){if(Array.isArray(t)){const n=va(t);if(n)return n;if(t&&pe.isBefore(t[1],t[0]))return{dateRangeOrder:!0}}return null};It.add("dateRangeOrder");const Lc=function({minDate:t,maxDate:n}){function a(o){const i=pe.isBefore(o,t),l=pe.isAfter(o,n),c={minExceeded:i?pe.toString(t):null,maxExceeded:l?pe.toString(n):null};return i||l?{dateConstraint:c}:null}return function(i){if(!i)return null;if(Array.isArray(i)){const l=a(i[0]),c=a(i[1]);return l||c}return i.hasOwnProperty("year")?a(i):null}};It.add("dateConstraint");var gv=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",date:va,dateRange:Oc,dateConstraint:Lc});const Sv=function(t){return function(a){return Number(a)>=t?null:{min:t}}};It.add("min");const bv=function(t){return n=>Number(n)<=t?null:{max:t}};jn.add("max");const vv=function(t){return typeof t=="undefined"||t===null||t===""||Number.isNaN(t)||(t==null?void 0:t.length)===0?{required:!0}:null};jn.add("required");const yv=function(t){return function(a){return a.length>=t?null:{minLength:t}}};It.add("minLength");const Tv=function(t){return function(a){return a.length<=t?null:{maxLength:t}}};Qt.add("maxLength");const wv=function(t){const n=t instanceof RegExp?t:new RegExp(t);return function(o){return n.test(o)?null:{pattern:t}}};It.add("pattern");const Cv=function(t){return/^[A-Za-z]*$/.test(t)?null:{alpha:!0}};Qt.add("alpha");const Ev=function(t){return/^[0-9,. ]*$/.test(t)?null:{numeric:!0}};Qt.add("numeric");const xv=function(t){return/^[^0-9]*$/.test(t)?null:{nonNumeric:!0}};Qt.add("nonNumeric");const ms=Object.freeze($(k({},gv),{min:Sv,max:bv,required:vv,minLength:yv,maxLength:Tv,pattern:wv,alpha:Cv,numeric:Ev,nonNumeric:xv,OnBlurErrorKeys:It}));function ya(e,t=[]){const n=t.reduce((a,o)=>Object.assign(a,o(e)||{}),{});return Object.keys(n).length?n:null}class vn{constructor(t,n){this.path=t,this.update=n,this.validators=[],this.errors=null,this.revealAllErrors=!1,this.preventativeErrors=[],this.submitted=!1}setValidators(t){return this.update(this.path,null,null,t),this}validate(t){return this.validators&&this.validators.length>0?(this.errors=ya(t,this.validators),this.update(null),this.isFocused()&&this.onFocus&&this.onFocus()):this.errors&&(this.errors=null,this.update(null)),this}isValid(){return!this.errors||this.isPristine()}hasErrors(){return!!this.errors}isVisibilyInvalid(){return this.errors&&(this.revealAllErrors&&!Object.keys(this.errors).some(t=>ba.has(t))||this.revealAllErrors&&Object.keys(this.errors).some(t=>ba.has(t))&&this.isSubmitted()||!this.isPristine()&&Object.keys(this.errors).some(t=>jn.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(ms.required)>-1}isSubmitted(){return this.submitted}onFocus(){}onBlur(){}}class yn extends vn{constructor(){super(...arguments);this.id=un(),this.focused=!1,this.pristine=!0}setValue(t){if(this.revealAllErrors=!1,this.preventativeErrors=[],this.validators&&this.validators.length>0){const n=ya(t,this.validators);if(n&&Object.keys(n).filter(o=>Qt.has(o)).length>0){this.preventativeErrors=Object.keys(n);return}}this.update(this.path,t)}isPristine(){return this.pristine}markAsPristine(){return this.pristine=!0,this.revealAllErrors=!1,this.update(null),this}markAsDirty(){return this.pristine=!1,this.update(null),this}isFocused(){return this.focused}markAsFocused(){return this.focused=!0,this.update(null),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(null),this}}class fs extends yn{constructor(t,n,a){const o=a?n:t,i=a||n;super(o,i);a&&this.inferMembers(t)}inferSpsControl(t,n){return hs(t,[...this.path,n],this.update)}rollup(t){return Object.keys(this.fields).reduce((n,a)=>n&&(!this.fields[a][t]||this.fields[a][t]()),!0)}isFocused(){return super.isFocused()||this.rollup("isFocused")}isValid(){return super.isValid()&&this.rollup("isValid")}hasErrors(){return super.hasErrors()||Object.keys(this.fields).some(t=>this.fields[t].hasErrors())}contentsAreValid(){return this.rollup("isValid")&&this.rollup("contentsAreValid")}isPristine(){return super.isPristine()&&this.rollup("isPristine")}markAsPristine(){super.markAsPristine();for(const t of Object.keys(this.fields))this.fields[t].markAsPristine();return this}markAsDirty(){super.markAsDirty();for(const t of Object.keys(this.fields))this.fields[t].markAsDirty();return this}markAsBlurred(){super.markAsBlurred();for(const t of Object.keys(this.fields))this.fields[t].markAsBlurred();return this}markAsSubmitted(){super.markAsSubmitted();for(const t of Object.keys(this.fields))this.fields[t].markAsSubmitted();return this}}class Rc extends fs{inferMembers(t){this.fields={};for(const n of Object.keys(t))this.fields[n]=this.inferSpsControl(t[n],n)}}class Bc extends fs{inferMembers(t){this.fields=t.map((n,a)=>this.inferSpsControl(n,String(a)))}}function hs(e,t,n){return e instanceof vn?(e.path=t,e.update=n,e):Array.isArray(e)?new Bc(e,t,n):Ic(e)?new Rc(e,t,n):new yn(t,n)}function ao(e,t){return t.length===0||!e?e:ao(e.fields[t[0]],t.slice(1,t.length))}function so(e,t){if(t.length===0||!e)return[e];const n=t[0];if(t=t.slice(1,t.length),n==="*"){const a=Array.isArray(e.fields)?e.fields:Object.keys(e.fields).map(o=>e.fields[o]);return t.length===0?a:a.reduce((o,i)=>[...o,...so(i,t)],[])}return so(e.fields[n],t)}function Pc(e,t,n){for(const a of Object.keys(t)){const o=t[a];for(const i of so(e,a.split(".")))i&&o&&n(i,o)}}function gs(e,t,n,a=!1){Pc(t,n,(o,i)=>{o.validators=typeof i=="function"?i(e):i,a&&(o.errors=ya(C.getPath(e,o.path),o.validators))})}function ro(e,t){const n=t[0];return t=t.slice(1),Array.isArray(e)?e.map((a,o)=>o===Number(n)?ro(a,t):a):Ic(e)?Object.keys(e).reduce((a,o)=>Object.assign(a,{[o]:o===n?ro(e[o],t):e[o]}),{}):e}function Nv(e){if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError("The initial value of useSpsForm() hook must be an object.")}function Dv(e,t){Nv(e);const n=V.useMemo(()=>{C.deepFreeze(e);const f=hs(e,[],u);return t&&gs(e,f,t,!0),f},[]),a=V.useRef(),o=V.useRef(t),i=V.useCallback((f,m)=>{var S,E,D;let g;if(a.current=null,m)if(m.path)if(m.markAsBlurred){const T=ao(f.formMeta,m.path);T&&(T.focused=!1,T.revealAllErrors=!0)}else if(m.newValidators){if(o.current){const T=m.path.join(".");o.current=$(k({},o.current),{[T]:m.newValidators}),gs(f.formValue,f.formMeta,o.current,!0)}}else g=ro(f.formValue,m.path),C.setPath(g,m.path,m.value);else g=m.value;if(((S=m.updateFormOptions)==null?void 0:S.validators)&&(o.current=k(k({},o.current),m.updateFormOptions.validators),gs(f.formValue,f.formMeta,o.current,(D=(E=m.updateFormOptions)==null?void 0:E.runValidators)!=null?D:!0)),g){C.deepFreeze(g);const T=C.diff(f.formValue,g);for(const{type:y,key:x,parentPath:v,objects:[I,_]}of T){const R=ao(f.formMeta,v);if(typeof x!="symbol"&&R)switch(y){case C.DiffChange.ADDITION:R.fields[x]=hs(_[x],[...v,x],u);break;case C.DiffChange.DELETION:Array.isArray(R.fields)?R.fields.splice(Number(x),1):delete R.fields[x];break;case C.DiffChange.ALTERATION:if(!I[x]&&_[x]&&!(R.fields[x]instanceof fs)){const M=hs(_[x],[...v,x],u);M instanceof yn&&R.fields[x]instanceof yn&&(M.id=R.fields[x].id,M.focused=R.fields[x].focused,M.pristine=R.fields[x].pristine),R.fields[x]=M}break}}if(o.current){gs(g,f.formMeta,o.current);const y=new Set;Pc(f.formMeta,t,(x,v)=>{typeof v=="function"&&(x.validate(C.getPath(g,x.path)),y.add(x))});for(const{type:x,key:v,parentPath:I,objects:[,_]}of T)if(typeof v!="symbol"){let R=f.formMeta,M=g;if(R){for(const B of I)R=R.fields[B],M=M[B],y.has(R)||R.validate(M);if(x===C.DiffChange.ADDITION||x===C.DiffChange.ALTERATION){const B=R.fields[v];if(!y.has(B)&&(R.fields[v].validate(_[v]),x===C.DiffChange.ADDITION&&B.fields))for(const[A,P]of Object.entries(B.fields))P.validate(_[v][A])}}}}}return{formValue:g||f.formValue,formMeta:f.formMeta,updateForm:f.updateForm}},[]),[l,c]=V.useReducer(i,{formValue:e,formMeta:n,updateForm:p});function u(f,m,g=!1,S){f?c({path:f,value:m,markAsBlurred:g,newValidators:S}):p()}function p(f,m){if(f||m){a.current&&window.clearTimeout(a.current);const g=window.setTimeout(c,0,{value:f,updateFormOptions:m});a.current=g}else if(!a.current){const g=window.setTimeout(c,0,{});a.current=g}}return V.useEffect(()=>()=>{a.current&&window.clearTimeout(a.current)},[]),l}const Iv=$(k({},U),{focusInputOnClick:w.exports.bool,formMeta:oe(),formControl:oe(),inputRef:Kt()}),pt=s.forwardRef((e,t)=>{const x=e,{className:n,children:a,focusInputOnClick:o,formControl:i,formMeta:l,inputRef:c,onClick:u}=x,p=z(x,["className","children","focusInputOnClick","formControl","formMeta","inputRef","onClick"]),f=s.useRef(),g=c||(t||f);function S(){g&&g!==t&&g.current&&g.current.focus()}function E(){g&&g!==t&&g.current&&l&&l instanceof yn&&l.markAsFocused()}function D(){g&&g!==t&&g.current&&l&&l instanceof yn&&l.markAsBlurred()}const T=F("sps-form-group",(i&&i.isRequired()||l&&l.isRequired())&&"sps-form-group--required",(i&&!i.isValid()||l&&l.isVisibilyInvalid())&&"sps-form-group--error",l&&l.hasPreventativeErrors()&&"sps-form-group--preventative-error",n);function y(v){o&&S(),u&&u(v)}return s.useEffect(()=>{function v(I){I.target.classList.contains("sps-form-control__clear-btn")&&I.preventDefault()}return document.addEventListener("mousedown",v),()=>{document.removeEventListener("mousedown",v)}},[]),s.createElement("div",$(k({},p),{className:T,ref:t,tabIndex:-1,onClick:y,onFocus:E,onBlur:D}),a)});Object.assign(pt,{spsFormComponentWrapperPropTypes:Iv,displayName:"SpsFormComponentWrapper"});function Ac(e){return typeof e=="object"&&e!=null&&e.nodeType===1}function Fc(e,t){return(!t||e!=="hidden")&&e!=="visible"&&e!=="clip"}function oo(e,t){if(e.clientHeight<e.scrollHeight||e.clientWidth<e.scrollWidth){var n=getComputedStyle(e,null);return Fc(n.overflowY,t)||Fc(n.overflowX,t)||function(a){var o=function(i){if(!i.ownerDocument||!i.ownerDocument.defaultView)return null;try{return i.ownerDocument.defaultView.frameElement}catch{return null}}(a);return!!o&&(o.clientHeight<a.scrollHeight||o.clientWidth<a.scrollWidth)}(e)}return!1}function Ss(e,t,n,a,o,i,l,c){return i<e&&l>t||i>e&&l<t?0:i<=e&&c<=n||l>=t&&c>=n?i-e-a:l>t&&c<n||i<e&&c>n?l-t+o:0}function Kc(e,t){var n=window,a=t.scrollMode,o=t.block,i=t.inline,l=t.boundary,c=t.skipOverflowHiddenElements,u=typeof l=="function"?l:function(We){return We!==l};if(!Ac(e))throw new TypeError("Invalid target");for(var p=document.scrollingElement||document.documentElement,f=[],m=e;Ac(m)&&u(m);){if((m=m.parentElement)===p){f.push(m);break}m!=null&&m===document.body&&oo(m)&&!oo(document.documentElement)||m!=null&&oo(m,c)&&f.push(m)}for(var g=n.visualViewport?n.visualViewport.width:innerWidth,S=n.visualViewport?n.visualViewport.height:innerHeight,E=window.scrollX||pageXOffset,D=window.scrollY||pageYOffset,T=e.getBoundingClientRect(),y=T.height,x=T.width,v=T.top,I=T.right,_=T.bottom,R=T.left,M=o==="start"||o==="nearest"?v:o==="end"?_:v+y/2,B=i==="center"?R+x/2:i==="end"?I:R,A=[],P=0;P<f.length;P++){var j=f[P],K=j.getBoundingClientRect(),W=K.height,ce=K.width,Q=K.top,le=K.right,se=K.bottom,ue=K.left;if(a==="if-needed"&&v>=0&&R>=0&&_<=S&&I<=g&&v>=Q&&_<=se&&R>=ue&&I<=le)return A;var ne=getComputedStyle(j),ie=parseInt(ne.borderLeftWidth,10),X=parseInt(ne.borderTopWidth,10),J=parseInt(ne.borderRightWidth,10),Z=parseInt(ne.borderBottomWidth,10),te=0,Y=0,Ce="offsetWidth"in j?j.offsetWidth-j.clientWidth-ie-J:0,xe="offsetHeight"in j?j.offsetHeight-j.clientHeight-X-Z:0;if(p===j)te=o==="start"?M:o==="end"?M-S:o==="nearest"?Ss(D,D+S,S,X,Z,D+M,D+M+y,y):M-S/2,Y=i==="start"?B:i==="center"?B-g/2:i==="end"?B-g:Ss(E,E+g,g,ie,J,E+B,E+B+x,x),te=Math.max(0,te+D),Y=Math.max(0,Y+E);else{te=o==="start"?M-Q-X:o==="end"?M-se+Z+xe:o==="nearest"?Ss(Q,se,W,X,Z+xe,M,M+y,y):M-(Q+W/2)+xe/2,Y=i==="start"?B-ue-ie:i==="center"?B-(ue+ce/2)+Ce/2:i==="end"?B-le+J+Ce:Ss(ue,le,ce,ie,J+Ce,B,B+x,x);var Le=j.scrollLeft,ve=j.scrollTop;M+=ve-(te=Math.max(0,Math.min(ve+te,j.scrollHeight-W+xe))),B+=Le-(Y=Math.max(0,Math.min(Le+Y,j.scrollWidth-ce+Ce)))}A.push({el:j,top:te,left:Y})}return A}function Vc(e){return e===Object(e)&&Object.keys(e).length!==0}function kv(e,t){t===void 0&&(t="auto");var n="scrollBehavior"in document.body.style;e.forEach(function(a){var o=a.el,i=a.top,l=a.left;o.scroll&&n?o.scroll({top:i,left:l,behavior:t}):(o.scrollTop=i,o.scrollLeft=l)})}function _v(e){return e===!1?{block:"end",inline:"nearest"}:Vc(e)?e:{block:"start",inline:"nearest"}}function $c(e,t){var n=!e.ownerDocument.documentElement.contains(e);if(Vc(t)&&typeof t.behavior=="function")return t.behavior(n?[]:Kc(e,t));if(!n){var a=_v(t);return kv(Kc(e,a),a.behavior)}}var Mv=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",default:$c});const Ov={alt:"string",size:"SpinnerSize",title:"string"},Lv=$(k({},U),{alt:w.exports.string,size:fe(O.SpinnerSize),title:w.exports.string});function bs(e){const m=e,{alt:t,className:n,size:a=O.SpinnerSize.MEDIUM,"data-testid":o,title:i,unsafelyReplaceClassName:l}=m,c=z(m,["alt","className","size","data-testid","title","unsafelyReplaceClassName"]),{t:u}=s.useContext(Ae),p=t||i||u("design-system:spinner.defaultAltText"),f=F(l||"sps-spinner",`sps-spinner--${a}`,n);return s.createElement("i",k({className:f,"data-testid":o,title:p},c))}Object.assign(bs,{props:Ov,propTypes:Lv,displayName:"SpsSpinner"});const Rv=60;function vs(e){return typeof e=="undefined"?"inherit":`${e}px`}function Hc(e){switch(e){case O.Position.TOP_LEFT:return O.Position.BOTTOM_LEFT;case O.Position.TOP_MIDDLE:return O.Position.BOTTOM_MIDDLE;case O.Position.TOP_RIGHT:return O.Position.BOTTOM_RIGHT;case O.Position.RIGHT_TOP:return O.Position.LEFT_TOP;case O.Position.RIGHT_MIDDLE:return O.Position.LEFT_MIDDLE;case O.Position.RIGHT_BOTTOM:return O.Position.LEFT_BOTTOM;case O.Position.BOTTOM_RIGHT:return O.Position.TOP_RIGHT;case O.Position.BOTTOM_MIDDLE:return O.Position.TOP_MIDDLE;case O.Position.BOTTOM_LEFT:return O.Position.TOP_LEFT;case O.Position.LEFT_BOTTOM:return O.Position.RIGHT_BOTTOM;case O.Position.LEFT_MIDDLE:return O.Position.RIGHT_MIDDLE;case O.Position.LEFT_TOP:return O.Position.RIGHT_TOP}}function Bv(e,t,n,a,o,i,l,c){const u=l&&l.current,p=u?u.scrollTop:window.pageYOffset,f=c?0:p,m=u?u.scrollLeft:window.pageXOffset,g=c?0:m,[S,E]=e.split(" ");let D,T,y,x;switch(S){case"top":y=t.height-n.top-f-i[0];break;case"left":T=t.width-n.left-g-i[0];break;case"right":x=n.right+g-i[0];break;case"bottom":D=n.bottom+f-i[0];break;default:throw new Error(`Invalid position ${e}`)}switch(E){case"left":x=n.left+g+i[1];break;case"top":D=n.top+f+i[1];break;case"middle":S==="top"||S==="bottom"?x=n.left+g+n.width/2-o/2+i[1]:(S==="left"||S==="right")&&(D=n.top+f+n.height/2-a.height/2+i[1]);break;case"bottom":y=t.height-n.bottom-f+i[1];break;case"right":T=t.width-n.right-g+i[1];break;default:throw new Error(`Invalid position ${e}`)}return[D,T,y,x]}function Ta(e,t,n,{altPosition:a,setMinWidth:o=!1,setWidth:i=!1,parentElementRef:l,fixed:c=!1,offsets:u=[0,0]}){if(e.current&&t.current){const p=Math.max(document.documentElement.clientHeight,window.innerHeight||0),f=document.documentElement.getBoundingClientRect().width,m=l&&l.current?l.current:document.documentElement,g=c?{width:f,height:p,top:0,left:0,bottom:p,right:f}:m.getBoundingClientRect(),S=e.current.getBoundingClientRect(),E=t.current.getBoundingClientRect(),[D]=n.split(" ");let T=n;a&&(D==="top"&&E.top-S.height<Rv||D==="right"&&E.right+S.width>f||D==="bottom"&&E.bottom+S.height>p||D==="left"&&E.left-S.width<0)&&(T=a);const y=o?Math.max(E.width,S.width):S.width,x=i?E.width:y,[v,I,_,R]=Bv(T,g,E,S,x,u,l,c),M={top:vs(v),right:vs(I),bottom:vs(_),left:vs(R)};return c&&(M.position="fixed",M.zIndex=O.ZStratum.BAR),o&&(M.minWidth=`${E.width}px`),i&&(M.width=`${E.width}px`),[M,T===a]}return[{},!1]}const kt=V.createContext(null);function Un(e,t=[]){const n=V.useContext(kt);return V.useMemo(()=>a=>{const i=n&&n.parentElementRef&&n.parentElementRef.current||document.body;let l,c=i.lastElementChild;for(;c!==i.firstElementChild;){if(c.hasAttribute("data-portalid")&&c.getAttribute("data-portalid")===e){l=c;break}c=c.previousElementSibling}if(l)i.contains(l)||i.appendChild(l);else{l=document.createElement("div"),l.setAttribute("data-portalid",e);for(const u of t)l.classList.add(u);i.appendChild(l)}return gc.createPortal(a,l)},[n])}const Pv={docs:{options:"Eventually<any[]> | (filter?: string) => Eventually<any[]>",captionKey:"string",disabledOptions:"any[]",comparisonKey:"string",tall:"boolean",textKey:"string",valueKey:"string",zeroState:"string",maxHeightPx:"number",maxHeightRem:"number",disableOptionsMemoization:"boolean"},propTypes:{captionKey:w.exports.string,comparisonKey:w.exports.string,disabledOptions:w.exports.arrayOf(w.exports.any),options:w.exports.oneOfType([w.exports.array,w.exports.instanceOf(Promise),ae()]).isRequired,tall:w.exports.bool,textKey:w.exports.string,valueKey:w.exports.string,zeroState:w.exports.string,maxHeightPx:w.exports.number,maxHeightRem:w.exports.number}},Av={hideInlineSearch:w.exports.bool,onSearchChange:ae(),search:w.exports.string,searchDebounce:w.exports.number,searchPlaceholder:w.exports.string,searchInputRef:Kt()},Fv=$(k(k(k({},U),Pv.propTypes),Av),{attachTo:Kt().isRequired,conformWidth:w.exports.bool,id:w.exports.string.isRequired,isOpen:w.exports.bool,keepOpen:w.exports.bool,keyDown:oe(),nullOption:w.exports.string,offsets:w.exports.arrayOf(w.exports.number),onOptionListChanged:ae(),onOptionSelected:ae(),onPositionFlip:ae(),onSelfToggle:ae(),optionRole:w.exports.string,positionOverride:w.exports.arrayOf(fe(O.Position)),selectedOption:w.exports.any,specialAction:ae(),ignoreWidthStyles:w.exports.bool,loading:w.exports.bool,filterByTextAndCaptionKey:w.exports.bool,disableOptionsMemoization:w.exports.bool});async function Wc(e,t,n,a,o,i){const l=typeof e.options=="function"?e.options(t.value):e.options||[],c=l instanceof Promise,u=m=>m.replace(/([.?*+^$[\]\\(){}|-])/g,"");n({pending:c}),i.current=c?l:null;const p=c?await l||[]:l||[];if(c&&i.current!==l)return;let f=Array.from(p).filter(Boolean).map(m=>new O.SpsOptionListOption(m,typeof m=="function"?{textKey:"label",captionKey:"caption"}:{textKey:e.textKey,captionKey:e.captionKey}));if(e.nullOption&&f.unshift(new O.SpsOptionListOption(null,{text:e.nullOption})),t.value){const m=u(t.value);n({replacementPattern:new RegExp(m,"ig")}),f=f.filter(g=>{const S=new RegExp(m,"i"),E=u(g.text);return e.filterByTextAndCaptionKey?S.test(E)||S.test(u(g.caption)):S.test(E)})}else n({replacementPattern:null});if(e.disabledOptions)for(const m of f)e.disabledOptions.includes(m.value)&&(m.disabled=!0);a(Object.freeze(f)),e.onOptionListChanged&&e.onOptionListChanged(f.length),o(f.some(m=>m.value&&!!m.value.icon)),n({pending:!1})}function Kv(e,t,n){const[a,o]=s.useState(Object.freeze([])),[i,l]=s.useState(!1),c=s.useRef(null),u=s.useRef(e.options);(typeof e.options!="function"||e.disableOptionsMemoization)&&(u.current=e.options);const p=s.useMemo(()=>typeof u.current=="function"?C.debounce(Wc,typeof e.searchDebounce!="undefined"?e.searchDebounce:500):Wc,[u.current,e.disabledOptions]);return s.useEffect(()=>{p(e,t,n,o,l,c)},[u.current,t.value,e.disabledOptions]),[a,i]}class Tn{constructor(t,n){this.target=t,this.isPgStoppedInternal=!1,this.currentTarget=t,this.nativeEvent=new CustomEvent("change",n),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 Vv(e,t){return k(k({},e),t)}function en(e){return V.useReducer(Vv,e)}function $v({hideInlineSearch:e,options:t,onSearchChange:n,search:a="",searchPlaceholder:o="Search\u2026",searchInputRef:i}){const[l,c]=en({isAsync:typeof t=="function",pending:!1,value:a,replacementPattern:null}),u=s.useCallback(S=>{c({value:S.target.value}),n&&n(S)},[n]),p=s.useCallback(S=>{S.nativeEvent.stopImmediatePropagation(),S.stopPropagation()},[]),f=s.useCallback(S=>{S.nativeEvent.stopImmediatePropagation(),c({value:""}),n&&n(new Tn(i.current)),i.current&&i.current.focus()},[n]),m=S=>{!S||["Tab","Escape","Enter","Up","ArrowUp","Down","ArrowDown"].includes(S.key)||S.stopPropagation()};return s.useEffect(()=>{c({value:a})},[a]),[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:o,ref:i,value:l.value,onChange:u,onClick:p,onKeyDown:m}),l.value&&s.createElement("i",{className:"sps-icon sps-icon-x-circle sps-form-control__clear-btn",onClick:f}))),l,c]}const Hv=$c||Mv,Wv=["Tab","Escape","Enter","Up","ArrowUp","Down","ArrowDown"],Gv=["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 jv(e,t,n){return n?(e&&e[n])===(t&&t[n]):e===t}function Gc(e,t,n){return typeof n.value=="function"&&n.disabled?!0:t?!!(e==null?void 0:e.find(a=>{var o;return a[t]&&a[t]===((o=n==null?void 0:n.value)==null?void 0:o[t])})):!1}const wa=s.forwardRef((e,t)=>{const rt=e,{captionKey:n,comparisonKey:a,disabledOptions:o,options:i,tall:l,textKey:c,valueKey:u,zeroState:p,hideInlineSearch:f,onSearchChange:m,search:g,searchDebounce:S,searchPlaceholder:E,attachTo:D,className:T,conformWidth:y,id:x,ignoreWidthStyles:v,isOpen:I,keepOpen:_,keyDown:R,nullOption:M,onOptionListChanged:B,onOptionSelected:A,onPositionFlip:P,onSelfToggle:j,optionRole:K,positionOverride:W,selectedOption:ce,specialAction:Q,unsafelyReplaceClassName:le,loading:se,filterByTextAndCaptionKey:ue,maxHeightPx:ne,maxHeightRem:ie,disableOptionsMemoization:X,"data-testid":J}=rt,Z=z(rt,["captionKey","comparisonKey","disabledOptions","options","tall","textKey","valueKey","zeroState","hideInlineSearch","onSearchChange","search","searchDebounce","searchPlaceholder","attachTo","className","conformWidth","id","ignoreWidthStyles","isOpen","keepOpen","keyDown","nullOption","onOptionListChanged","onOptionSelected","onPositionFlip","onSelfToggle","optionRole","positionOverride","selectedOption","specialAction","unsafelyReplaceClassName","loading","filterByTextAndCaptionKey","maxHeightPx","maxHeightRem","disableOptionsMemoization","data-testid"]),te=s.useMemo(()=>Q?new O.SpsOptionListOption(Q,{textKey:"label",captionKey:"caption"}):null,[Q]),[Y,Ce]=s.useState(-1),[xe,Le]=s.useState(I),ve=t||s.useRef(null),We=s.useRef(null),Ge=s.useRef(null),Ue=Un("sps-option-list-portal"),Je=s.useContext(kt),[Ze,vt]=W||[O.Position.BOTTOM_LEFT,O.Position.TOP_LEFT],[yt,nt]=xe?Ta(ve,D,Ze,k({altPosition:vt,setMinWidth:!v,setWidth:!v&&y},Je)):[{},!1],be=s.useRef(null),[ge,De,He]=$v($(k({},e),{searchInputRef:be})),[ke,Rn]=Kv(e,De,He);s.useEffect(()=>{Ce(-1)},[De]);const Wa=F(le||"sps-option-list","z-stratum-dropdown",xe&&"sps-option-list--open",De.isAsync&&"sps-option-list--searchable",nt&&"sps-option-list--opens-upward",Q&&Q.label&&"sps-option-list--has-special-action",T),Xe=F(le||"sps-option-list__options",l&&"sps-option-list__options--tall"),Bn=s.useCallback(()=>{xe||(Le(!0),be.current&&be.current.focus(),Ce(-1),j&&j(!0))},[xe,j]),Lt=s.useCallback(()=>{xe&&(Le(!1),Ce(-1),j&&j(!1))},[xe,j]),Qe=s.useCallback((Se,Te)=>{Te||Se&&!Se.disabled&&(typeof Se.value=="function"?Se.value():typeof A=="function"&&A(Se.value),_||Lt())},[A,Lt]),ye=s.useCallback((Se,Te,at)=>{Se.stopPropagation(),Qe(Te,at)},[Qe]),Rt=s.useRef(o||[]);Rt.current=o||[];const Pn=s.useCallback(Se=>{switch(Se.key){case"Tab":case"Escape":Lt();break;case"Enter":if(Y>-1){const Te=ke[Y]||te;Se.preventDefault();const at=!!Te&&Gc(Rt.current,a,Te);!at&&Te&&typeof A=="function"&&typeof Te.value=="function"?Te.value():Te&&Qe(Te,at)}break;case"Up":case"ArrowUp":{let Te=Y;nt?Y<=-1?Te=ke.length-1:Y===0?Q&&(Te=ke.length):Y<ke.length&&(Te=Y-1):Y>-1&&(Te=Y-1),Te!==Y&&(Se.preventDefault(),Ce(Te));break}case"Down":case"ArrowDown":{Bn();let Te=Y;nt?Y!==-1&&(Y>=ke.length?Te=0:Y===ke.length-1?Te=-1:Te=Y+1):Y<ke.length-1+Number(!!Q)&&(Te=Y+1),Te!==Y&&(Se.preventDefault(),Ce(Te));break}default:Bn()}},[Lt,Bn,Y,Qe,A,nt,ke]),Ga=s.useCallback(Se=>{const Te=ke.findIndex(at=>{if(at.textKey){const _e=at.textKey;return at.value[_e].toLowerCase().charAt([0])===Se.key.toLocaleLowerCase()}return at.value.toLowerCase().charAt([0])===Se.key.toLocaleLowerCase()});Te>-1&&Ce(Te)},[ke]),Lr=s.useCallback(Se=>{!Se||(Wv.includes(Se.key)?Pn(Se):Gv.includes(Se.key)&&Ga(Se))},[Lt,Bn,Y,Qe,A,nt,ke]);s.useEffect(()=>{if(Je!==null&&document.getElementsByClassName("sps-modal__body").length>0){const Se=()=>{j(!1)},Te=document.getElementsByClassName("sps-modal__body")[0];return Te.addEventListener("scroll",Se),()=>{Te.removeEventListener("scroll",Se)}}},[]),s.useEffect(()=>{Ge.current&&Hv(Ge.current,{scrollMode:"if-needed",block:"nearest",inline:"nearest"})},[Y]),s.useEffect(()=>{Le(I),I?be.current&&be.current.focus():Ce(-1)},[I]),s.useEffect(()=>{Lr(R)},[R]),s.useEffect(()=>{!xe&&We.current&&(He({value:""}),We.current.scrollTop=0),xe&&P&&P(nt)},[xe]);const ja=ne?ne/16:ie,Ya=ja?{maxHeight:`${ja}rem`}:{};return Ue(s.createElement("div",k({className:Wa,id:x,"aria-activedescendant":Y>-1?`${x}-option-${Y}`:null,tabIndex:-1,ref:ve,style:yt,onMouseLeave:()=>Ce(-1),"data-testid":J},Z),ge,s.createElement("div",{className:Xe,ref:We,"data-testid":`${J}-options`,style:Ya},!se&&!De.pending&&p&&ke.length===0&&s.createElement("div",{className:"sps-option-list__zero-state"},p),(se||De.pending)&&s.createElement("div",{className:"sps-option-list__loading"},s.createElement(bs,null)),!se&&!De.pending&&ke.map((Se,Te)=>{const at=`${x}-option-${Te}`,_e=jv(Se.value,ce,a),la=Gc(Rt.current,a,Se);return s.createElement("a",{key:at,id:at,role:K,"aria-selected":_e,href:Se.href,className:F("sps-option-list__option",Se.caption&&"sps-option-list__option--has-caption",Se.disabled&&"sps-option-list__option--disabled",Se.bold&&"sps-option-list__option--bold",(_e||la)&&"sps-option-list__option--selected",Y===Te&&"sps-option-list__option--highlighted"),onClick:Ua=>ye(Ua,Se,la),onMouseOver:()=>Ce(Te),tabIndex:-1,ref:Y===Te?Ge:null,"data-testid":`${J}-option-${Te}`},Se.value&&Se.value.icon&&s.createElement("i",{className:F("sps-icon","sps-option-list__option-icon",`sps-icon-${String(Se.value.icon)}`)}),(!Se.value||!Se.value.icon&&Rn)&&s.createElement("span",{className:"sps-option-list__option-icon-spacer"}),s.createElement("span",{dangerouslySetInnerHTML:{__html:Se.getHtml(De.replacementPattern)}}),Se.caption&&s.createElement("div",{className:"sps-option-list__option-caption"},s.createElement("span",{dangerouslySetInnerHTML:{__html:Se.caption.replace(De.replacementPattern,"<u>$&</u>")}})))})),te&&Q.label&&s.createElement("a",{className:F("sps-option-list__option","sps-option-list__special-action",Y===ke.length&&"sps-option-list__option--highlighted",Q.disabled&&"sps-option-list__special-action--disabled"),href:te.href,target:te.href&&Q.newTab?"_blank":"_self",onClick:Se=>ye(Se,te),onMouseOver:()=>Ce(ke.length),"data-testid":`${J}-special-action`},Q.icon&&s.createElement("i",{className:F("sps-icon","sps-option-list__option-icon",`sps-icon-${String(Q.icon)}`)}),!Q.icon&&Rn&&s.createElement("span",{className:"sps-option-list__option-icon-spacer"}),s.createElement("span",null,Q.label))))});Object.assign(wa,{propTypes:Fv,displayName:"SpsOptionList"});function Yv(e,t,n=[]){return s.useMemo(()=>o=>s.createElement(e,k({},k(k({},o),t)),o.children),n)}const jc=function({children:e,elements:t}){if(t.length===0)return s.createElement(s.Fragment,null,e);const[n,a]=Array.isArray(t[0])?t[0]:[t[0]];return s.createElement(n,k({},a!=null?a:{}),s.createElement(jc,{elements:t.slice(1)},e))},Yc=function(a){var o=a,{children:e,providers:t=[]}=o,n=z(o,["children","providers"]);return s.createElement("div",k({},n),s.createElement(jc,{elements:t},e))},Uv=function(a){var o=a,{children:e,className:t}=o,n=z(o,["children","className"]);return s.createElement(Yc,k({className:`sps-app ${t}`},n),e)};function Vt(e=[],t=[]){const n=Array.isArray(e)?C.flatten(e):[e],a=t.map(i=>Array.isArray(i)?i:[i]),o=new Array(a.length+1).fill(null).map(()=>[]);for(const i of n){let l=!1;for(let c=0;c<a.length;c+=1)for(const{type:u,props:p={}}of a[c])if(i.type===u&&Object.keys(p).every(m=>p[m]===i.props[m])){l=!0,o[c].push(i);break}l||o[o.length-1].push(i)}return o}function Uc(e,t,n){const a=Object.entries(t).filter(([,i])=>typeof i!="string"&&i.deprecated).map(([i])=>i),o=a.map(i=>n[i]);s.useEffect(()=>{o.find(i=>typeof i!="undefined")&&console.warn(`The following prop(s) of ${e} are deprecated: ${a.join(", ")}`)},o)}function io(e,t){const n=V.useRef(!1);V.useEffect(()=>{if(n.current)return e();n.current=!0},t)}function zc(e,t,n){const a=s.useRef(t(...n));s.useEffect(()=>(document.addEventListener(e,a.current),()=>document.removeEventListener(e,a.current)),[]),s.useEffect(()=>{document.removeEventListener(e,a.current),a.current=t(...n),document.addEventListener(e,a.current)},n)}function zv(e,t,n){return function(o){var i,l;!((i=e.current)==null?void 0:i.contains(o.target))&&!((l=t.current)==null?void 0:l.contains(o.target))&&n()}}function Ca(e,t,n){const a=s.useRef(!1),[o,i]=s.useState(!1),l=s.useCallback(()=>{a.current?a.current=!1:i(!0)},[]),c=s.useCallback((u=!1)=>{i(!1),a.current=u,n&&n()},[]);return zc("mousedown",zv,[e,t,c]),{showPopup:o,doShowPopup:l,doHidePopup:c}}const qv={debounce:"number",disabled:"boolean",formMeta:"SpsFormFieldMeta<string>",icon:"SpsIcon",onChange:"React.ChangeEventHandler",placeholder:"string",suggestions:{type:`
|
|
196
|
+
`}}}};var av=self.crypto||self.msCrypto,to="-_",dn=36;for(;dn--;)to+=dn.toString(36);dn=36;for(;dn---10;)to+=dn.toString(36).toUpperCase();var sv=function(e){var t="",n=av.getRandomValues(new Uint8Array(e||21));for(dn=e||21;dn--;)t+=to[n[dn]&63];return t},un=sv;function Gn(e){return V.useRef(e||un())}function Dt(e,t){const n=Gn(e),a=V.useRef(`${n.current}_ctrl`);return V.useEffect(()=>{t&&(t.id=a.current,t.update())},[t]),{wrapperId:n.current,controlId:a.current}}var rv="[object Object]";function ov(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch{}return t}function iv(e,t){return function(n){return e(t(n))}}var lv=Function.prototype,Nc=Object.prototype,Dc=lv.toString,cv=Nc.hasOwnProperty,dv=Dc.call(Object),uv=Nc.toString,pv=iv(Object.getPrototypeOf,Object);function mv(e){return!!e&&typeof e=="object"}function fv(e){if(!mv(e)||uv.call(e)!=rv||ov(e))return!1;var t=pv(e);if(t===null)return!0;var n=cv.call(t,"constructor")&&t.constructor;return typeof n=="function"&&n instanceof n&&Dc.call(n)==dv}var Ic=fv;const It=new Set,jn=new Set,Qt=new Set,ba=new Set;function kc(e){It.has(e)||Qt.has(e)||ba.has(e)||jn.add(e)}function _c(e){It.has(e)||Qt.has(e)||jn.has(e)||ba.add(e)}const no=Wn.default||Wn,ps="MM/DD/YYYY",hv=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/,Mc=Symbol("Date Parse Error");function Yn(e){return e.year*1e4+e.month*100+e.date}const pe=Object.freeze({createFrom(e){if(!e)return null;if(typeof e=="string"){const t=hv.exec(e);if(t){const[,n,a,o]=t;return Object.freeze({year:Number(o),month:Number(n),date:Number(a)})}return Object.freeze({[Mc]:!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(pe.createFrom):null},isValid(e){return e&&typeof e=="object"&&typeof e.year=="number"&&typeof e.month=="number"&&typeof e.date=="number"&&pe.toMoment(e).isValid()},nullifyInvalidDate(e){return pe.isValid(e)?e:null},toMoment(e){return e?no($(k({},e),{month:e.month-1})):null},toString(e){const t=pe.toMoment(e);return t?t.format(ps):""},toStringRange(e){return e?e.map(pe.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:Yn(e)>Yn(t)},isBefore(e,t){return!e||!t?null:Yn(e)<Yn(t)},isInRange(e,t,n=!0){if(!e||!t||!t[0]||!t[1])return null;const a=Yn(e),[o,i]=t.map(Yn);return e&&o&&i&&(n&&a>=o&&a<=i||!n&&a>o&&a<i)},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=no(),n=t.clone().subtract(no.duration(e.definition));return[pe.createFrom(n),pe.createFrom(t)]}}),va=function(t){if(Array.isArray(t)){const n=va(t[0]),a=va(t[1]);return n||a}if(t&&t.hasOwnProperty("year")){if(t[Mc])return{dateFormat:ps};if(!pe.isValid(t))return{dateValidity:!0}}return null};It.add("dateFormat");It.add("dateValidity");const Oc=function(t){if(Array.isArray(t)){const n=va(t);if(n)return n;if(t&&pe.isBefore(t[1],t[0]))return{dateRangeOrder:!0}}return null};It.add("dateRangeOrder");const Lc=function({minDate:t,maxDate:n}){function a(o){const i=pe.isBefore(o,t),l=pe.isAfter(o,n),c={minExceeded:i?pe.toString(t):null,maxExceeded:l?pe.toString(n):null};return i||l?{dateConstraint:c}:null}return function(i){if(!i)return null;if(Array.isArray(i)){const l=a(i[0]),c=a(i[1]);return l||c}return i.hasOwnProperty("year")?a(i):null}};It.add("dateConstraint");var gv=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",date:va,dateRange:Oc,dateConstraint:Lc});const Sv=function(t){return function(a){return Number(a)>=t?null:{min:t}}};It.add("min");const bv=function(t){return n=>Number(n)<=t?null:{max:t}};jn.add("max");const vv=function(t){return typeof t=="undefined"||t===null||t===""||Number.isNaN(t)||(t==null?void 0:t.length)===0?{required:!0}:null};jn.add("required");const yv=function(t){return function(a){return a.length>=t?null:{minLength:t}}};It.add("minLength");const Tv=function(t){return function(a){return a.length<=t?null:{maxLength:t}}};Qt.add("maxLength");const wv=function(t){const n=t instanceof RegExp?t:new RegExp(t);return function(o){return n.test(o)?null:{pattern:t}}};It.add("pattern");const Cv=function(t){return/^[A-Za-z]*$/.test(t)?null:{alpha:!0}};Qt.add("alpha");const Ev=function(t){return/^[0-9,. ]*$/.test(t)?null:{numeric:!0}};Qt.add("numeric");const xv=function(t){return/^[^0-9]*$/.test(t)?null:{nonNumeric:!0}};Qt.add("nonNumeric");const ms=Object.freeze($(k({},gv),{min:Sv,max:bv,required:vv,minLength:yv,maxLength:Tv,pattern:wv,alpha:Cv,numeric:Ev,nonNumeric:xv,OnBlurErrorKeys:It}));function ya(e,t=[]){const n=t.reduce((a,o)=>Object.assign(a,o(e)||{}),{});return Object.keys(n).length?n:null}class vn{constructor(t,n){this.path=t,this.update=n,this.validators=[],this.errors=null,this.revealAllErrors=!1,this.preventativeErrors=[],this.submitted=!1}setValidators(t){return this.update(this.path,null,null,t),this}validate(t){return this.validators&&this.validators.length>0?(this.errors=ya(t,this.validators),this.update(null),this.isFocused()&&this.onFocus&&this.onFocus()):this.errors&&(this.errors=null,this.update(null)),this}isValid(){return!this.errors||this.isPristine()}hasErrors(){return!!this.errors}isVisibilyInvalid(){return this.errors&&(this.revealAllErrors&&!Object.keys(this.errors).some(t=>ba.has(t))||this.revealAllErrors&&Object.keys(this.errors).some(t=>ba.has(t))&&this.isSubmitted()||!this.isPristine()&&Object.keys(this.errors).some(t=>jn.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(ms.required)>-1}isSubmitted(){return this.submitted}onFocus(){}onBlur(){}}class yn extends vn{constructor(){super(...arguments);this.id=un(),this.focused=!1,this.pristine=!0}setValue(t){if(this.revealAllErrors=!1,this.preventativeErrors=[],this.validators&&this.validators.length>0){const n=ya(t,this.validators);if(n&&Object.keys(n).filter(o=>Qt.has(o)).length>0){this.preventativeErrors=Object.keys(n);return}}this.update(this.path,t)}isPristine(){return this.pristine}markAsPristine(){return this.pristine=!0,this.revealAllErrors=!1,this.update(null),this}markAsDirty(){return this.pristine=!1,this.update(null),this}isFocused(){return this.focused}markAsFocused(){return this.focused=!0,this.update(null),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(null),this}}class fs extends yn{constructor(t,n,a){const o=a?n:t,i=a||n;super(o,i);a&&this.inferMembers(t)}inferSpsControl(t,n){return hs(t,[...this.path,n],this.update)}rollup(t){return Object.keys(this.fields).reduce((n,a)=>n&&(!this.fields[a][t]||this.fields[a][t]()),!0)}isFocused(){return super.isFocused()||this.rollup("isFocused")}isValid(){return super.isValid()&&this.rollup("isValid")}hasErrors(){return super.hasErrors()||Object.keys(this.fields).some(t=>this.fields[t].hasErrors())}contentsAreValid(){return this.rollup("isValid")&&this.rollup("contentsAreValid")}isPristine(){return super.isPristine()&&this.rollup("isPristine")}markAsPristine(){super.markAsPristine();for(const t of Object.keys(this.fields))this.fields[t].markAsPristine();return this}markAsDirty(){super.markAsDirty();for(const t of Object.keys(this.fields))this.fields[t].markAsDirty();return this}markAsBlurred(){super.markAsBlurred();for(const t of Object.keys(this.fields))this.fields[t].markAsBlurred();return this}markAsSubmitted(){super.markAsSubmitted();for(const t of Object.keys(this.fields))this.fields[t].markAsSubmitted();return this}}class Rc extends fs{inferMembers(t){this.fields={};for(const n of Object.keys(t))this.fields[n]=this.inferSpsControl(t[n],n)}}class Bc extends fs{inferMembers(t){this.fields=t.map((n,a)=>this.inferSpsControl(n,String(a)))}}function hs(e,t,n){return e instanceof vn?(e.path=t,e.update=n,e):Array.isArray(e)?new Bc(e,t,n):Ic(e)?new Rc(e,t,n):new yn(t,n)}function ao(e,t){return t.length===0||!e?e:ao(e.fields[t[0]],t.slice(1,t.length))}function so(e,t){if(t.length===0||!e)return[e];const n=t[0];if(t=t.slice(1,t.length),n==="*"){const a=Array.isArray(e.fields)?e.fields:Object.keys(e.fields).map(o=>e.fields[o]);return t.length===0?a:a.reduce((o,i)=>[...o,...so(i,t)],[])}return so(e.fields[n],t)}function Pc(e,t,n){for(const a of Object.keys(t)){const o=t[a];for(const i of so(e,a.split(".")))i&&o&&n(i,o)}}function gs(e,t,n,a=!1){Pc(t,n,(o,i)=>{o.validators=typeof i=="function"?i(e):i,a&&(o.errors=ya(C.getPath(e,o.path),o.validators))})}function ro(e,t){const n=t[0];return t=t.slice(1),Array.isArray(e)?e.map((a,o)=>o===Number(n)?ro(a,t):a):Ic(e)?Object.keys(e).reduce((a,o)=>Object.assign(a,{[o]:o===n?ro(e[o],t):e[o]}),{}):e}function Nv(e){if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError("The initial value of useSpsForm() hook must be an object.")}function Dv(e,t){Nv(e);const n=V.useMemo(()=>{C.deepFreeze(e);const f=hs(e,[],u);return t&&gs(e,f,t,!0),f},[]),a=V.useRef(),o=V.useRef(t),i=V.useCallback((f,m)=>{var S,E,D;let g;if(a.current=null,m)if(m.path)if(m.markAsBlurred){const T=ao(f.formMeta,m.path);T&&(T.focused=!1,T.revealAllErrors=!0)}else if(m.newValidators){if(o.current){const T=m.path.join(".");o.current=$(k({},o.current),{[T]:m.newValidators}),gs(f.formValue,f.formMeta,o.current,!0)}}else g=ro(f.formValue,m.path),C.setPath(g,m.path,m.value);else g=m.value;if(((S=m.updateFormOptions)==null?void 0:S.validators)&&(o.current=k(k({},o.current),m.updateFormOptions.validators),gs(f.formValue,f.formMeta,o.current,(D=(E=m.updateFormOptions)==null?void 0:E.runValidators)!=null?D:!0)),g){C.deepFreeze(g);const T=C.diff(f.formValue,g);for(const{type:y,key:x,parentPath:v,objects:[I,_]}of T){const R=ao(f.formMeta,v);if(typeof x!="symbol"&&R)switch(y){case C.DiffChange.ADDITION:R.fields[x]=hs(_[x],[...v,x],u);break;case C.DiffChange.DELETION:Array.isArray(R.fields)?R.fields.splice(Number(x),1):delete R.fields[x];break;case C.DiffChange.ALTERATION:if(!I[x]&&_[x]&&!(R.fields[x]instanceof fs)){const M=hs(_[x],[...v,x],u);M instanceof yn&&R.fields[x]instanceof yn&&(M.id=R.fields[x].id,M.focused=R.fields[x].focused,M.pristine=R.fields[x].pristine),R.fields[x]=M}break}}if(o.current){gs(g,f.formMeta,o.current);const y=new Set;Pc(f.formMeta,t,(x,v)=>{typeof v=="function"&&(x.validate(C.getPath(g,x.path)),y.add(x))});for(const{type:x,key:v,parentPath:I,objects:[,_]}of T)if(typeof v!="symbol"){let R=f.formMeta,M=g;if(R){for(const B of I)R=R.fields[B],M=M[B],y.has(R)||R.validate(M);if(x===C.DiffChange.ADDITION||x===C.DiffChange.ALTERATION){const B=R.fields[v];if(!y.has(B)&&(R.fields[v].validate(_[v]),x===C.DiffChange.ADDITION&&B.fields))for(const[A,P]of Object.entries(B.fields))P.validate(_[v][A])}}}}}return{formValue:g||f.formValue,formMeta:f.formMeta,updateForm:f.updateForm}},[]),[l,c]=V.useReducer(i,{formValue:e,formMeta:n,updateForm:p});function u(f,m,g=!1,S){f?c({path:f,value:m,markAsBlurred:g,newValidators:S}):p()}function p(f,m){if(f||m){a.current&&window.clearTimeout(a.current);const g=window.setTimeout(c,0,{value:f,updateFormOptions:m});a.current=g}else if(!a.current){const g=window.setTimeout(c,0,{});a.current=g}}return V.useEffect(()=>()=>{a.current&&window.clearTimeout(a.current)},[]),l}const Iv=$(k({},U),{focusInputOnClick:w.exports.bool,formMeta:oe(),formControl:oe(),inputRef:Kt()}),pt=s.forwardRef((e,t)=>{const x=e,{className:n,children:a,focusInputOnClick:o,formControl:i,formMeta:l,inputRef:c,onClick:u}=x,p=z(x,["className","children","focusInputOnClick","formControl","formMeta","inputRef","onClick"]),f=s.useRef(),g=c||(t||f);function S(){g&&g!==t&&g.current&&g.current.focus()}function E(){g&&g!==t&&g.current&&l&&l instanceof yn&&l.markAsFocused()}function D(){g&&g!==t&&g.current&&l&&l instanceof yn&&l.markAsBlurred()}const T=F("sps-form-group",(i&&i.isRequired()||l&&l.isRequired())&&"sps-form-group--required",(i&&!i.isValid()||l&&l.isVisibilyInvalid())&&"sps-form-group--error",l&&l.hasPreventativeErrors()&&"sps-form-group--preventative-error",n);function y(v){o&&S(),u&&u(v)}return s.useEffect(()=>{function v(I){I.target.classList.contains("sps-form-control__clear-btn")&&I.preventDefault()}return document.addEventListener("mousedown",v),()=>{document.removeEventListener("mousedown",v)}},[]),s.createElement("div",$(k({},p),{className:T,ref:t,tabIndex:-1,onClick:y,onFocus:E,onBlur:D}),a)});Object.assign(pt,{spsFormComponentWrapperPropTypes:Iv,displayName:"SpsFormComponentWrapper"});function Ac(e){return typeof e=="object"&&e!=null&&e.nodeType===1}function Fc(e,t){return(!t||e!=="hidden")&&e!=="visible"&&e!=="clip"}function oo(e,t){if(e.clientHeight<e.scrollHeight||e.clientWidth<e.scrollWidth){var n=getComputedStyle(e,null);return Fc(n.overflowY,t)||Fc(n.overflowX,t)||function(a){var o=function(i){if(!i.ownerDocument||!i.ownerDocument.defaultView)return null;try{return i.ownerDocument.defaultView.frameElement}catch{return null}}(a);return!!o&&(o.clientHeight<a.scrollHeight||o.clientWidth<a.scrollWidth)}(e)}return!1}function Ss(e,t,n,a,o,i,l,c){return i<e&&l>t||i>e&&l<t?0:i<=e&&c<=n||l>=t&&c>=n?i-e-a:l>t&&c<n||i<e&&c>n?l-t+o:0}function Kc(e,t){var n=window,a=t.scrollMode,o=t.block,i=t.inline,l=t.boundary,c=t.skipOverflowHiddenElements,u=typeof l=="function"?l:function(We){return We!==l};if(!Ac(e))throw new TypeError("Invalid target");for(var p=document.scrollingElement||document.documentElement,f=[],m=e;Ac(m)&&u(m);){if((m=m.parentElement)===p){f.push(m);break}m!=null&&m===document.body&&oo(m)&&!oo(document.documentElement)||m!=null&&oo(m,c)&&f.push(m)}for(var g=n.visualViewport?n.visualViewport.width:innerWidth,S=n.visualViewport?n.visualViewport.height:innerHeight,E=window.scrollX||pageXOffset,D=window.scrollY||pageYOffset,T=e.getBoundingClientRect(),y=T.height,x=T.width,v=T.top,I=T.right,_=T.bottom,R=T.left,M=o==="start"||o==="nearest"?v:o==="end"?_:v+y/2,B=i==="center"?R+x/2:i==="end"?I:R,A=[],P=0;P<f.length;P++){var j=f[P],K=j.getBoundingClientRect(),W=K.height,ce=K.width,Q=K.top,le=K.right,se=K.bottom,ue=K.left;if(a==="if-needed"&&v>=0&&R>=0&&_<=S&&I<=g&&v>=Q&&_<=se&&R>=ue&&I<=le)return A;var ne=getComputedStyle(j),ie=parseInt(ne.borderLeftWidth,10),X=parseInt(ne.borderTopWidth,10),J=parseInt(ne.borderRightWidth,10),Z=parseInt(ne.borderBottomWidth,10),te=0,Y=0,Ce="offsetWidth"in j?j.offsetWidth-j.clientWidth-ie-J:0,xe="offsetHeight"in j?j.offsetHeight-j.clientHeight-X-Z:0;if(p===j)te=o==="start"?M:o==="end"?M-S:o==="nearest"?Ss(D,D+S,S,X,Z,D+M,D+M+y,y):M-S/2,Y=i==="start"?B:i==="center"?B-g/2:i==="end"?B-g:Ss(E,E+g,g,ie,J,E+B,E+B+x,x),te=Math.max(0,te+D),Y=Math.max(0,Y+E);else{te=o==="start"?M-Q-X:o==="end"?M-se+Z+xe:o==="nearest"?Ss(Q,se,W,X,Z+xe,M,M+y,y):M-(Q+W/2)+xe/2,Y=i==="start"?B-ue-ie:i==="center"?B-(ue+ce/2)+Ce/2:i==="end"?B-le+J+Ce:Ss(ue,le,ce,ie,J+Ce,B,B+x,x);var Le=j.scrollLeft,ve=j.scrollTop;M+=ve-(te=Math.max(0,Math.min(ve+te,j.scrollHeight-W+xe))),B+=Le-(Y=Math.max(0,Math.min(Le+Y,j.scrollWidth-ce+Ce)))}A.push({el:j,top:te,left:Y})}return A}function Vc(e){return e===Object(e)&&Object.keys(e).length!==0}function kv(e,t){t===void 0&&(t="auto");var n="scrollBehavior"in document.body.style;e.forEach(function(a){var o=a.el,i=a.top,l=a.left;o.scroll&&n?o.scroll({top:i,left:l,behavior:t}):(o.scrollTop=i,o.scrollLeft=l)})}function _v(e){return e===!1?{block:"end",inline:"nearest"}:Vc(e)?e:{block:"start",inline:"nearest"}}function $c(e,t){var n=!e.ownerDocument.documentElement.contains(e);if(Vc(t)&&typeof t.behavior=="function")return t.behavior(n?[]:Kc(e,t));if(!n){var a=_v(t);return kv(Kc(e,a),a.behavior)}}var Mv=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",default:$c});const Ov={alt:"string",size:"SpinnerSize",title:"string"},Lv=$(k({},U),{alt:w.exports.string,size:fe(O.SpinnerSize),title:w.exports.string});function bs(e){const m=e,{alt:t,className:n,size:a=O.SpinnerSize.MEDIUM,"data-testid":o,title:i,unsafelyReplaceClassName:l}=m,c=z(m,["alt","className","size","data-testid","title","unsafelyReplaceClassName"]),{t:u}=s.useContext(Ae),p=t||i||u("design-system:spinner.defaultAltText"),f=F(l||"sps-spinner",`sps-spinner--${a}`,n);return s.createElement("i",k({className:f,"data-testid":o,title:p},c))}Object.assign(bs,{props:Ov,propTypes:Lv,displayName:"SpsSpinner"});const Rv=60;function vs(e){return typeof e=="undefined"?"inherit":`${e}px`}function Hc(e){switch(e){case O.Position.TOP_LEFT:return O.Position.BOTTOM_LEFT;case O.Position.TOP_MIDDLE:return O.Position.BOTTOM_MIDDLE;case O.Position.TOP_RIGHT:return O.Position.BOTTOM_RIGHT;case O.Position.RIGHT_TOP:return O.Position.LEFT_TOP;case O.Position.RIGHT_MIDDLE:return O.Position.LEFT_MIDDLE;case O.Position.RIGHT_BOTTOM:return O.Position.LEFT_BOTTOM;case O.Position.BOTTOM_RIGHT:return O.Position.TOP_RIGHT;case O.Position.BOTTOM_MIDDLE:return O.Position.TOP_MIDDLE;case O.Position.BOTTOM_LEFT:return O.Position.TOP_LEFT;case O.Position.LEFT_BOTTOM:return O.Position.RIGHT_BOTTOM;case O.Position.LEFT_MIDDLE:return O.Position.RIGHT_MIDDLE;case O.Position.LEFT_TOP:return O.Position.RIGHT_TOP}}function Bv(e,t,n,a,o,i,l,c){const u=l&&l.current,p=u?u.scrollTop:window.pageYOffset,f=c?0:p,m=u?u.scrollLeft:window.pageXOffset,g=c?0:m,[S,E]=e.split(" ");let D,T,y,x;switch(S){case"top":y=t.height-n.top-f-i[0];break;case"left":T=t.width-n.left-g-i[0];break;case"right":x=n.right+g-i[0];break;case"bottom":D=n.bottom+f-i[0];break;default:throw new Error(`Invalid position ${e}`)}switch(E){case"left":x=n.left+g+i[1];break;case"top":D=n.top+f+i[1];break;case"middle":S==="top"||S==="bottom"?x=n.left+g+n.width/2-o/2+i[1]:(S==="left"||S==="right")&&(D=n.top+f+n.height/2-a.height/2+i[1]);break;case"bottom":y=t.height-n.bottom-f+i[1];break;case"right":T=t.width-n.right-g+i[1];break;default:throw new Error(`Invalid position ${e}`)}return[D,T,y,x]}function Ta(e,t,n,{altPosition:a,setMinWidth:o=!1,setWidth:i=!1,parentElementRef:l,fixed:c=!1,offsets:u=[0,0]}){if(e.current&&t.current){const p=Math.max(document.documentElement.clientHeight,window.innerHeight||0),f=document.documentElement.getBoundingClientRect().width,m=l&&l.current?l.current:document.documentElement,g=c?{width:f,height:p,top:0,left:0,bottom:p,right:f}:m.getBoundingClientRect(),S=e.current.getBoundingClientRect(),E=t.current.getBoundingClientRect(),[D]=n.split(" ");let T=n;a&&(D==="top"&&E.top-S.height<Rv||D==="right"&&E.right+S.width>f||D==="bottom"&&E.bottom+S.height>p||D==="left"&&E.left-S.width<0)&&(T=a);const y=o?Math.max(E.width,S.width):S.width,x=i?E.width:y,[v,I,_,R]=Bv(T,g,E,S,x,u,l,c),M={top:vs(v),right:vs(I),bottom:vs(_),left:vs(R)};return c&&(M.position="fixed",M.zIndex=O.ZStratum.BAR),o&&(M.minWidth=`${E.width}px`),i&&(M.width=`${E.width}px`),[M,T===a]}return[{},!1]}const kt=V.createContext(null);function Un(e,t=[]){const n=V.useContext(kt);return V.useMemo(()=>a=>{const i=n&&n.parentElementRef&&n.parentElementRef.current||document.body;let l,c=i.lastElementChild;for(;c!==i.firstElementChild;){if(c.hasAttribute("data-portalid")&&c.getAttribute("data-portalid")===e){l=c;break}c=c.previousElementSibling}if(l)i.contains(l)||i.appendChild(l);else{l=document.createElement("div"),l.setAttribute("data-portalid",e);for(const u of t)l.classList.add(u);i.appendChild(l)}return gc.createPortal(a,l)},[n])}const Pv={docs:{options:"Eventually<any[]> | (filter?: string) => Eventually<any[]>",captionKey:"string",disabledOptions:"any[]",comparisonKey:"string",tall:"boolean",textKey:"string",valueKey:"string",zeroState:"string",maxHeightPx:"number",maxHeightRem:"number",disableOptionsMemoization:"boolean"},propTypes:{captionKey:w.exports.string,comparisonKey:w.exports.string,disabledOptions:w.exports.arrayOf(w.exports.any),options:w.exports.oneOfType([w.exports.array,w.exports.instanceOf(Promise),ae()]).isRequired,tall:w.exports.bool,textKey:w.exports.string,valueKey:w.exports.string,zeroState:w.exports.string,maxHeightPx:w.exports.number,maxHeightRem:w.exports.number}},Av={hideInlineSearch:w.exports.bool,onSearchChange:ae(),search:w.exports.string,searchDebounce:w.exports.number,searchPlaceholder:w.exports.string,searchInputRef:Kt()},Fv=$(k(k(k({},U),Pv.propTypes),Av),{attachTo:Kt().isRequired,conformWidth:w.exports.bool,id:w.exports.string.isRequired,isOpen:w.exports.bool,keepOpen:w.exports.bool,keyDown:oe(),nullOption:w.exports.string,offsets:w.exports.arrayOf(w.exports.number),onOptionListChanged:ae(),onOptionSelected:ae(),onPositionFlip:ae(),onSelfToggle:ae(),optionRole:w.exports.string,positionOverride:w.exports.arrayOf(fe(O.Position)),selectedOption:w.exports.any,specialAction:ae(),ignoreWidthStyles:w.exports.bool,loading:w.exports.bool,filterByTextAndCaptionKey:w.exports.bool,disableOptionsMemoization:w.exports.bool});async function Wc(e,t,n,a,o,i){const l=typeof e.options=="function"?e.options(t.value):e.options||[],c=l instanceof Promise,u=m=>m.replace(/([.?*+^$[\]\\(){}|-])/g,"");n({pending:c}),i.current=c?l:null;const p=c?await l||[]:l||[];if(c&&i.current!==l)return;let f=Array.from(p).filter(Boolean).map(m=>new O.SpsOptionListOption(m,typeof m=="function"?{textKey:"label",captionKey:"caption"}:{textKey:e.textKey,captionKey:e.captionKey}));if(e.nullOption&&f.unshift(new O.SpsOptionListOption(null,{text:e.nullOption})),t.value){const m=u(t.value);n({replacementPattern:new RegExp(m,"ig")}),f=f.filter(g=>{const S=new RegExp(m,"i"),E=u(g.text);return e.filterByTextAndCaptionKey?S.test(E)||S.test(u(g.caption)):S.test(E)})}else n({replacementPattern:null});if(e.disabledOptions)for(const m of f)e.disabledOptions.includes(m.value)&&(m.disabled=!0);a(Object.freeze(f)),e.onOptionListChanged&&e.onOptionListChanged(f.length),o(f.some(m=>m.value&&!!m.value.icon)),n({pending:!1})}function Kv(e,t,n){const[a,o]=s.useState(Object.freeze([])),[i,l]=s.useState(!1),c=s.useRef(null),u=s.useRef(e.options);(typeof e.options!="function"||e.disableOptionsMemoization)&&(u.current=e.options);const p=s.useMemo(()=>typeof u.current=="function"?C.debounce(Wc,typeof e.searchDebounce!="undefined"?e.searchDebounce:500):Wc,[u.current,e.disabledOptions]);return s.useEffect(()=>{p(e,t,n,o,l,c)},[u.current,t.value,e.disabledOptions]),[a,i]}class Tn{constructor(t,n){this.target=t,this.isPgStoppedInternal=!1,this.currentTarget=t,this.nativeEvent=new CustomEvent("change",n),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 Vv(e,t){return k(k({},e),t)}function en(e){return V.useReducer(Vv,e)}function $v({hideInlineSearch:e,options:t,onSearchChange:n,search:a="",searchPlaceholder:o="Search\u2026",searchInputRef:i}){const[l,c]=en({isAsync:typeof t=="function",pending:!1,value:a,replacementPattern:null}),u=s.useCallback(S=>{c({value:S.target.value}),n&&n(S)},[n]),p=s.useCallback(S=>{S.nativeEvent.stopImmediatePropagation(),S.stopPropagation()},[]),f=s.useCallback(S=>{S.nativeEvent.stopImmediatePropagation(),c({value:""}),n&&n(new Tn(i.current)),i.current&&i.current.focus()},[n]),m=S=>{!S||["Tab","Escape","Enter","Up","ArrowUp","Down","ArrowDown"].includes(S.key)||S.stopPropagation()};return s.useEffect(()=>{c({value:a})},[a]),[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:o,ref:i,value:l.value,onChange:u,onClick:p,onKeyDown:m}),l.value&&s.createElement("i",{className:"sps-icon sps-icon-x-circle sps-form-control__clear-btn",onClick:f}))),l,c]}const Hv=$c||Mv,Wv=["Tab","Escape","Enter","Up","ArrowUp","Down","ArrowDown"],Gv=["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 jv(e,t,n){return n?(e&&e[n])===(t&&t[n]):e===t}function Gc(e,t,n){return typeof n.value=="function"&&n.disabled?!0:t?!!(e==null?void 0:e.find(a=>{var o;return a[t]&&a[t]===((o=n==null?void 0:n.value)==null?void 0:o[t])})):!1}const wa=s.forwardRef((e,t)=>{const rt=e,{captionKey:n,comparisonKey:a,disabledOptions:o,options:i,tall:l,textKey:c,valueKey:u,zeroState:p,hideInlineSearch:f,onSearchChange:m,search:g,searchDebounce:S,searchPlaceholder:E,attachTo:D,className:T,conformWidth:y,id:x,ignoreWidthStyles:v,isOpen:I,keepOpen:_,keyDown:R,nullOption:M,onOptionListChanged:B,onOptionSelected:A,onPositionFlip:P,onSelfToggle:j,optionRole:K,positionOverride:W,selectedOption:ce,specialAction:Q,unsafelyReplaceClassName:le,loading:se,filterByTextAndCaptionKey:ue,maxHeightPx:ne,maxHeightRem:ie,disableOptionsMemoization:X,"data-testid":J}=rt,Z=z(rt,["captionKey","comparisonKey","disabledOptions","options","tall","textKey","valueKey","zeroState","hideInlineSearch","onSearchChange","search","searchDebounce","searchPlaceholder","attachTo","className","conformWidth","id","ignoreWidthStyles","isOpen","keepOpen","keyDown","nullOption","onOptionListChanged","onOptionSelected","onPositionFlip","onSelfToggle","optionRole","positionOverride","selectedOption","specialAction","unsafelyReplaceClassName","loading","filterByTextAndCaptionKey","maxHeightPx","maxHeightRem","disableOptionsMemoization","data-testid"]),te=s.useMemo(()=>Q?new O.SpsOptionListOption(Q,{textKey:"label",captionKey:"caption"}):null,[Q]),[Y,Ce]=s.useState(-1),[xe,Le]=s.useState(I),ve=t||s.useRef(null),We=s.useRef(null),Ge=s.useRef(null),Ue=Un("sps-option-list-portal"),Je=s.useContext(kt),[Ze,vt]=W||[O.Position.BOTTOM_LEFT,O.Position.TOP_LEFT],[yt,nt]=xe?Ta(ve,D,Ze,k({altPosition:vt,setMinWidth:!v,setWidth:!v&&y},Je)):[{},!1],be=s.useRef(null),[ge,De,He]=$v($(k({},e),{searchInputRef:be})),[ke,Rn]=Kv(e,De,He);s.useEffect(()=>{Ce(-1)},[De]);const Wa=F(le||"sps-option-list","z-stratum-dropdown",xe&&"sps-option-list--open",De.isAsync&&"sps-option-list--searchable",nt&&"sps-option-list--opens-upward",Q&&Q.label&&"sps-option-list--has-special-action",T),Xe=F(le||"sps-option-list__options",l&&"sps-option-list__options--tall"),Bn=s.useCallback(()=>{xe||(Le(!0),be.current&&be.current.focus(),Ce(-1),j&&j(!0))},[xe,j]),Lt=s.useCallback(()=>{xe&&(Le(!1),Ce(-1),j&&j(!1))},[xe,j]),Qe=s.useCallback((Se,Te)=>{Te||Se&&!Se.disabled&&(typeof Se.value=="function"?Se.value():typeof A=="function"&&A(Se.value),_||Lt())},[A,Lt]),ye=s.useCallback((Se,Te,at)=>{Se.stopPropagation(),Qe(Te,at)},[Qe]),Rt=s.useRef(o||[]);Rt.current=o||[];const Pn=s.useCallback(Se=>{switch(Se.key){case"Tab":case"Escape":Lt();break;case"Enter":if(Y>-1){const Te=ke[Y]||te;Se.preventDefault();const at=!!Te&&Gc(Rt.current,a,Te);!at&&Te&&typeof A=="function"&&typeof Te.value=="function"?Te.value():Te&&Qe(Te,at)}break;case"Up":case"ArrowUp":{let Te=Y;nt?Y<=-1?Te=ke.length-1:Y===0?Q&&(Te=ke.length):Y<ke.length&&(Te=Y-1):Y>-1&&(Te=Y-1),Te!==Y&&(Se.preventDefault(),Ce(Te));break}case"Down":case"ArrowDown":{Bn();let Te=Y;nt?Y!==-1&&(Y>=ke.length?Te=0:Y===ke.length-1?Te=-1:Te=Y+1):Y<ke.length-1+Number(!!Q)&&(Te=Y+1),Te!==Y&&(Se.preventDefault(),Ce(Te));break}default:Bn()}},[Lt,Bn,Y,Qe,A,nt,ke]),Ga=s.useCallback(Se=>{const Te=ke.findIndex(at=>{if(at.textKey){const _e=at.textKey;return at.value[_e].toLowerCase().charAt([0])===Se.key.toLocaleLowerCase()}return at.value.toString().toLowerCase().charAt([0])===Se.key.toLocaleLowerCase()});Te>-1&&Ce(Te)},[ke]),Lr=s.useCallback(Se=>{!Se||(Wv.includes(Se.key)?Pn(Se):Gv.includes(Se.key)&&Ga(Se))},[Lt,Bn,Y,Qe,A,nt,ke]);s.useEffect(()=>{if(Je!==null&&document.getElementsByClassName("sps-modal__body").length>0){const Se=()=>{j(!1)},Te=document.getElementsByClassName("sps-modal__body")[0];return Te.addEventListener("scroll",Se),()=>{Te.removeEventListener("scroll",Se)}}},[]),s.useEffect(()=>{Ge.current&&Hv(Ge.current,{scrollMode:"if-needed",block:"nearest",inline:"nearest"})},[Y]),s.useEffect(()=>{Le(I),I?be.current&&be.current.focus():Ce(-1)},[I]),s.useEffect(()=>{Lr(R)},[R]),s.useEffect(()=>{!xe&&We.current&&(He({value:""}),We.current.scrollTop=0),xe&&P&&P(nt)},[xe]);const ja=ne?ne/16:ie,Ya=ja?{maxHeight:`${ja}rem`}:{};return Ue(s.createElement("div",k({className:Wa,id:x,"aria-activedescendant":Y>-1?`${x}-option-${Y}`:null,tabIndex:-1,ref:ve,style:yt,onMouseLeave:()=>Ce(-1),"data-testid":J},Z),ge,s.createElement("div",{className:Xe,ref:We,"data-testid":`${J}-options`,style:Ya},!se&&!De.pending&&p&&ke.length===0&&s.createElement("div",{className:"sps-option-list__zero-state"},p),(se||De.pending)&&s.createElement("div",{className:"sps-option-list__loading"},s.createElement(bs,null)),!se&&!De.pending&&ke.map((Se,Te)=>{const at=`${x}-option-${Te}`,_e=jv(Se.value,ce,a),la=Gc(Rt.current,a,Se);return s.createElement("a",{key:at,id:at,role:K,"aria-selected":_e,href:Se.href,className:F("sps-option-list__option",Se.caption&&"sps-option-list__option--has-caption",Se.disabled&&"sps-option-list__option--disabled",Se.bold&&"sps-option-list__option--bold",(_e||la)&&"sps-option-list__option--selected",Y===Te&&"sps-option-list__option--highlighted"),onClick:Ua=>ye(Ua,Se,la),onMouseOver:()=>Ce(Te),tabIndex:-1,ref:Y===Te?Ge:null,"data-testid":`${J}-option-${Te}`},Se.value&&Se.value.icon&&s.createElement("i",{className:F("sps-icon","sps-option-list__option-icon",`sps-icon-${String(Se.value.icon)}`)}),(!Se.value||!Se.value.icon&&Rn)&&s.createElement("span",{className:"sps-option-list__option-icon-spacer"}),s.createElement("span",{dangerouslySetInnerHTML:{__html:Se.getHtml(De.replacementPattern)}}),Se.caption&&s.createElement("div",{className:"sps-option-list__option-caption"},s.createElement("span",{dangerouslySetInnerHTML:{__html:Se.caption.replace(De.replacementPattern,"<u>$&</u>")}})))})),te&&Q.label&&s.createElement("a",{className:F("sps-option-list__option","sps-option-list__special-action",Y===ke.length&&"sps-option-list__option--highlighted",Q.disabled&&"sps-option-list__special-action--disabled"),href:te.href,target:te.href&&Q.newTab?"_blank":"_self",onClick:Se=>ye(Se,te),onMouseOver:()=>Ce(ke.length),"data-testid":`${J}-special-action`},Q.icon&&s.createElement("i",{className:F("sps-icon","sps-option-list__option-icon",`sps-icon-${String(Q.icon)}`)}),!Q.icon&&Rn&&s.createElement("span",{className:"sps-option-list__option-icon-spacer"}),s.createElement("span",null,Q.label))))});Object.assign(wa,{propTypes:Fv,displayName:"SpsOptionList"});function Yv(e,t,n=[]){return s.useMemo(()=>o=>s.createElement(e,k({},k(k({},o),t)),o.children),n)}const jc=function({children:e,elements:t}){if(t.length===0)return s.createElement(s.Fragment,null,e);const[n,a]=Array.isArray(t[0])?t[0]:[t[0]];return s.createElement(n,k({},a!=null?a:{}),s.createElement(jc,{elements:t.slice(1)},e))},Yc=function(a){var o=a,{children:e,providers:t=[]}=o,n=z(o,["children","providers"]);return s.createElement("div",k({},n),s.createElement(jc,{elements:t},e))},Uv=function(a){var o=a,{children:e,className:t}=o,n=z(o,["children","className"]);return s.createElement(Yc,k({className:`sps-app ${t}`},n),e)};function Vt(e=[],t=[]){const n=Array.isArray(e)?C.flatten(e):[e],a=t.map(i=>Array.isArray(i)?i:[i]),o=new Array(a.length+1).fill(null).map(()=>[]);for(const i of n){let l=!1;for(let c=0;c<a.length;c+=1)for(const{type:u,props:p={}}of a[c])if(i.type===u&&Object.keys(p).every(m=>p[m]===i.props[m])){l=!0,o[c].push(i);break}l||o[o.length-1].push(i)}return o}function Uc(e,t,n){const a=Object.entries(t).filter(([,i])=>typeof i!="string"&&i.deprecated).map(([i])=>i),o=a.map(i=>n[i]);s.useEffect(()=>{o.find(i=>typeof i!="undefined")&&console.warn(`The following prop(s) of ${e} are deprecated: ${a.join(", ")}`)},o)}function io(e,t){const n=V.useRef(!1);V.useEffect(()=>{if(n.current)return e();n.current=!0},t)}function zc(e,t,n){const a=s.useRef(t(...n));s.useEffect(()=>(document.addEventListener(e,a.current),()=>document.removeEventListener(e,a.current)),[]),s.useEffect(()=>{document.removeEventListener(e,a.current),a.current=t(...n),document.addEventListener(e,a.current)},n)}function zv(e,t,n){return function(o){var i,l;!((i=e.current)==null?void 0:i.contains(o.target))&&!((l=t.current)==null?void 0:l.contains(o.target))&&n()}}function Ca(e,t,n){const a=s.useRef(!1),[o,i]=s.useState(!1),l=s.useCallback(()=>{a.current?a.current=!1:i(!0)},[]),c=s.useCallback((u=!1)=>{i(!1),a.current=u,n&&n()},[]);return zc("mousedown",zv,[e,t,c]),{showPopup:o,doShowPopup:l,doHidePopup:c}}const qv={debounce:"number",disabled:"boolean",formMeta:"SpsFormFieldMeta<string>",icon:"SpsIcon",onChange:"React.ChangeEventHandler",placeholder:"string",suggestions:{type:`
|
|
197
197
|
Eventually<Iterable<string>>
|
|
198
198
|
| ((filter?: string) => Eventually<Iterable<string>>)
|
|
199
199
|
`,required:!0},tallOptionList:"boolean",value:"string",zeroState:"string",loading:"boolean",maxHeightOptionListPx:"number",maxHeightOptionListRem:"number",disableOptionsMemoization:"boolean"},Jv=$(k({},U),{debounce:w.exports.number,disabled:w.exports.bool,formControl:oe(),formMeta:oe(),icon:fe(O.SpsIcon),onChange:ae(),placeholder:w.exports.string,suggestions:w.exports.oneOfType([w.exports.arrayOf(w.exports.string),w.exports.instanceOf(Promise),ae()]).isRequired,tallOptionList:w.exports.bool,value:w.exports.string,zeroState:w.exports.string,loading:w.exports.bool,maxHeightOptionListPx:w.exports.number,maxHeightOptionListRem:w.exports.number,disableOptionsMemoization:w.exports.bool});function ys(I){var _=I,{className:e,debounce:t=0,disabled:n,formControl:a,formMeta:o,onChange:i,icon:l,id:c,placeholder:u="",suggestions:p,unsafelyReplaceClassName:f,tallOptionList:m,value:g="",zeroState:S,loading:E,maxHeightOptionListPx:D,maxHeightOptionListRem:T,disableOptionsMemoization:y,"data-testid":x}=_,v=z(_,["className","debounce","disabled","formControl","formMeta","onChange","icon","id","placeholder","suggestions","unsafelyReplaceClassName","tallOptionList","value","zeroState","loading","maxHeightOptionListPx","maxHeightOptionListRem","disableOptionsMemoization","data-testid"]);const R=o||a,{wrapperId:M,controlId:B}=Dt(c,R),[A,P]=en({keyDown:null,opensUpward:!1}),j=s.useRef(),K=s.useRef(),W=s.useRef(),{showPopup:ce,doShowPopup:Q,doHidePopup:le}=Ca(j,W);function se(te,Y){R&&(R.setValue(te),R.markAsDirty()),i&&i(Y||new Tn({value:te}))}function ue(te){K.current.value="",se(""),te.stopPropagation()}function ne(te){se(te.target.value,te)}function ie(te){n||(["Up","ArrowUp","Down","ArrowDown","Enter"].indexOf(te.key)>-1&&(te.preventDefault(),te.persist()),te.stopPropagation(),P({keyDown:te})),te.key==="Tab"&&le()}function X(te){te?Q():le()}function J(te){P({opensUpward:te})}const Z=F(f||"sps-autocomplete",ce&&"sps-autocomplete--open",ce&&"z-stratum-dropdown",A.opensUpward&&"sps-autocomplete--opens-upward",n&&"sps-form-control--disabled",e);return s.createElement(pt,{id:M,className:Z,formControl:a,formMeta:o,inputRef:K,ref:j,focusInputOnClick:!0,onClick:te=>te.nativeEvent.stopImmediatePropagation(),"data-testId":`${x}`},s.createElement("div",{className:"sps-text-input"},s.createElement("div",{className:"sps-form-control"},l&&s.createElement("i",{className:F("sps-text-input__icon","sps-icon",`sps-icon-${l}`)}),s.createElement("input",k({type:"text",ref:K,value:g,className:"sps-text-input__input",placeholder:u,onFocus:Q,onClick:Q,onChange:ne,onKeyDown:ie,disabled:n,id:B,"data-testid":`${x}__input`},v)),g&&!n&&s.createElement("i",{"aria-label":"clear",className:"sps-icon sps-icon-x-circle sps-form-control__clear-btn",onClick:te=>ue(te)}))),s.createElement(wa,{id:`${M}_options`,ref:W,attachTo:j,isOpen:ce,options:p,hideInlineSearch:!0,keyDown:A.keyDown,onOptionSelected:se,onPositionFlip:J,onSelfToggle:X,offsets:[1,0],search:g,searchDebounce:t,tall:m,zeroState:S,loading:E,maxHeightPx:D,maxHeightRem:T,disableOptionsMemoization:y}))}Object.assign(ys,{props:qv,propTypes:Jv,displayName:"SpsAutocomplete"});const qc={basic:{label:"Basic",examples:{basic:{react:C.code`
|
package/lib/index.es.js
CHANGED
|
@@ -2332,7 +2332,7 @@ const SpsOptionList = React.forwardRef((props2, ref2) => {
|
|
|
2332
2332
|
const key = item.textKey;
|
|
2333
2333
|
return item.value[key].toLowerCase().charAt([0]) === event.key.toLocaleLowerCase();
|
|
2334
2334
|
}
|
|
2335
|
-
return item.value.toLowerCase().charAt([0]) === event.key.toLocaleLowerCase();
|
|
2335
|
+
return item.value.toString().toLowerCase().charAt([0]) === event.key.toLocaleLowerCase();
|
|
2336
2336
|
});
|
|
2337
2337
|
if (newIndex > -1) {
|
|
2338
2338
|
setHighlightedOptionIndex(newIndex);
|
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": "6.5.
|
|
4
|
+
"version": "6.5.1",
|
|
5
5
|
"author": "SPS Commerce",
|
|
6
6
|
"license": "UNLICENSED",
|
|
7
7
|
"repository": "https://github.com/spscommerce/design-system/tree/main/packages/@spscommerce/ds-react",
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"@react-stately/collections": "^3.3.3",
|
|
31
|
-
"@spscommerce/ds-colors": "6.5.
|
|
32
|
-
"@spscommerce/ds-illustrations": "6.5.
|
|
33
|
-
"@spscommerce/ds-shared": "6.5.
|
|
34
|
-
"@spscommerce/positioning": "6.5.
|
|
35
|
-
"@spscommerce/utils": "6.5.
|
|
31
|
+
"@spscommerce/ds-colors": "6.5.1",
|
|
32
|
+
"@spscommerce/ds-illustrations": "6.5.1",
|
|
33
|
+
"@spscommerce/ds-shared": "6.5.1",
|
|
34
|
+
"@spscommerce/positioning": "6.5.1",
|
|
35
|
+
"@spscommerce/utils": "6.5.1",
|
|
36
36
|
"moment": "^2.25.3",
|
|
37
37
|
"moment-timezone": "^0.5.28",
|
|
38
38
|
"react": "^16.9.0",
|
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@react-stately/collections": "^3.3.3",
|
|
43
|
-
"@spscommerce/ds-colors": "6.5.
|
|
44
|
-
"@spscommerce/ds-illustrations": "6.5.
|
|
45
|
-
"@spscommerce/ds-shared": "6.5.
|
|
46
|
-
"@spscommerce/positioning": "6.5.
|
|
47
|
-
"@spscommerce/utils": "6.5.
|
|
43
|
+
"@spscommerce/ds-colors": "6.5.1",
|
|
44
|
+
"@spscommerce/ds-illustrations": "6.5.1",
|
|
45
|
+
"@spscommerce/ds-shared": "6.5.1",
|
|
46
|
+
"@spscommerce/positioning": "6.5.1",
|
|
47
|
+
"@spscommerce/utils": "6.5.1",
|
|
48
48
|
"@testing-library/react": "^9.3.2",
|
|
49
49
|
"@types/prop-types": "^15.7.1",
|
|
50
50
|
"@types/react": "^16.9.0",
|