@spscommerce/ds-react 5.23.1 → 5.23.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 +7 -4
- package/package.json +11 -11
package/lib/index.cjs.js
CHANGED
|
@@ -193,7 +193,7 @@
|
|
|
193
193
|
</SpsAdvancedSearch>
|
|
194
194
|
</>;
|
|
195
195
|
}
|
|
196
|
-
`}}}};var Sv=self.crypto||self.msCrypto,mo="-_",xn=36;for(;xn--;)mo+=xn.toString(36);xn=36;for(;xn---10;)mo+=xn.toString(36).toUpperCase();var bv=function(e){var t="",n=Sv.getRandomValues(new Uint8Array(e||21));for(xn=e||21;xn--;)t+=mo[n[xn]&63];return t},Dn=bv;function ca(e){return H.useRef(e||Dn())}function Ft(e,t){const n=ca(e),a=H.useRef(`${n.current}_ctrl`);return H.useEffect(()=>{t&&(t.id=a.current,t.update())},[t]),{wrapperId:n.current,controlId:a.current}}var vv="[object Object]";function yv(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch{}return t}function Tv(e,t){return function(n){return e(t(n))}}var wv=Function.prototype,Wc=Object.prototype,jc=wv.toString,Cv=Wc.hasOwnProperty,Ev=jc.call(Object),xv=Wc.toString,Dv=Tv(Object.getPrototypeOf,Object);function kv(e){return!!e&&typeof e=="object"}function Nv(e){if(!kv(e)||xv.call(e)!=vv||yv(e))return!1;var t=Dv(e);if(t===null)return!0;var n=Cv.call(t,"constructor")&&t.constructor;return typeof n=="function"&&n instanceof n&&jc.call(n)==Ev}var Yc=Nv;const Kt=new Set,da=new Set,mn=new Set,Ba=new Set;function Gc(e){Kt.has(e)||mn.has(e)||Ba.has(e)||da.add(e)}function Uc(e){Kt.has(e)||mn.has(e)||da.has(e)||Ba.add(e)}const fo=Ut.default||Ut,ws="MM/DD/YYYY",Iv=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/,zc=Symbol("Date Parse Error");function pa(e){return e.year*1e4+e.month*100+e.date}const he=Object.freeze({createFrom(e){if(!e)return null;if(typeof e=="string"){const t=Iv.exec(e);if(t){const[,n,a,r]=t;return Object.freeze({year:Number(r),month:Number(n),date:Number(a)})}return Object.freeze({[zc]:!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(he.createFrom):null},isValid(e){return e&&typeof e=="object"&&typeof e.year=="number"&&typeof e.month=="number"&&typeof e.date=="number"&&he.toMoment(e).isValid()},nullifyInvalidDate(e){return he.isValid(e)?e:null},toMoment(e){return e?fo($(I({},e),{month:e.month-1})):null},toString(e){const t=he.toMoment(e);return t?t.format(ws):""},toStringRange(e){return e?e.map(he.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:pa(e)>pa(t)},isBefore(e,t){return!e||!t?null:pa(e)<pa(t)},isInRange(e,t,n=!0){if(!e||!t||!t[0]||!t[1])return null;const a=pa(e),[r,i]=t.map(pa);return e&&r&&i&&(n&&a>=r&&a<=i||!n&&a>r&&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=fo(),n=t.clone().subtract(fo.duration(e.definition));return[he.createFrom(n),he.createFrom(t)]}}),Pa=function(t){if(Array.isArray(t)){const n=Pa(t[0]),a=Pa(t[1]);return n||a}if(t&&t.hasOwnProperty("year")){if(t[zc])return{dateFormat:ws};if(!he.isValid(t))return{dateValidity:!0}}return null};Kt.add("dateFormat");Kt.add("dateValidity");const qc=function(t){if(Array.isArray(t)){const n=Pa(t);if(n)return n;if(t&&he.isBefore(t[1],t[0]))return{dateRangeOrder:!0}}return null};Kt.add("dateRangeOrder");const Jc=function({minDate:t,maxDate:n}){function a(r){const i=he.isBefore(r,t),l=he.isAfter(r,n),c={minExceeded:i?he.toString(t):null,maxExceeded:l?he.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}};Kt.add("dateConstraint");var _v=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",date:Pa,dateRange:qc,dateConstraint:Jc});const Mv=function(t){return function(a){return Number(a)>=t?null:{min:t}}};Kt.add("min");const Ov=function(t){return n=>Number(n)<=t?null:{max:t}};da.add("max");const Rv=function(t){return typeof t=="undefined"||t===null||t===""||Number.isNaN(t)||(t==null?void 0:t.length)===0?{required:!0}:null};da.add("required");const Lv=function(t){return function(a){return a.length>=t?null:{minLength:t}}};Kt.add("minLength");const Bv=function(t){return function(a){return a.length<=t?null:{maxLength:t}}};mn.add("maxLength");const Pv=function(t){const n=t instanceof RegExp?t:new RegExp(t);return function(r){return n.test(r)?null:{pattern:t}}};Kt.add("pattern");const Av=function(t){return/^[A-Za-z]*$/.test(t)?null:{alpha:!0}};mn.add("alpha");const Fv=function(t){return/^[0-9,. ]*$/.test(t)?null:{numeric:!0}};mn.add("numeric");const Kv=function(t){return/^[^0-9]*$/.test(t)?null:{nonNumeric:!0}};mn.add("nonNumeric");const Cs=Object.freeze($(I({},_v),{min:Mv,max:Ov,required:Rv,minLength:Lv,maxLength:Bv,pattern:Pv,alpha:Av,numeric:Fv,nonNumeric:Kv,OnBlurErrorKeys:Kt}));function Aa(e,t=[]){const n=t.reduce((a,r)=>Object.assign(a,r(e)||{}),{});return Object.keys(n).length?n:null}class Fn{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=Aa(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=>da.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(Cs.required)>-1}isSubmitted(){return this.submitted}onFocus(){}onBlur(){}}class Kn extends Fn{constructor(){super(...arguments);this.id=Dn(),this.focused=!1,this.pristine=!0}setValue(t){if(this.revealAllErrors=!1,this.preventativeErrors=[],this.validators&&this.validators.length>0){const n=Aa(t,this.validators);if(n&&Object.keys(n).filter(r=>mn.has(r)).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 Es extends Kn{constructor(t,n,a){const r=a?n:t,i=a||n;super(r,i);a&&this.inferMembers(t)}inferSpsControl(t,n){return xs(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 Zc extends Es{inferMembers(t){this.fields={};for(const n of Object.keys(t))this.fields[n]=this.inferSpsControl(t[n],n)}}class Xc extends Es{inferMembers(t){this.fields=t.map((n,a)=>this.inferSpsControl(n,String(a)))}}function xs(e,t,n){return e instanceof Fn?(e.path=t,e.update=n,e):Array.isArray(e)?new Xc(e,t,n):Yc(e)?new Zc(e,t,n):new Kn(t,n)}function ho(e,t){return t.length===0||!e?e:ho(e.fields[t[0]],t.slice(1,t.length))}function go(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(r=>e.fields[r]);return t.length===0?a:a.reduce((r,i)=>[...r,...go(i,t)],[])}return go(e.fields[n],t)}function Qc(e,t,n){for(const a of Object.keys(t)){const r=t[a];for(const i of go(e,a.split(".")))i&&r&&n(i,r)}}function So(e,t,n,a=!1){Qc(t,n,(r,i)=>{r.validators=typeof i=="function"?i(e):i,a&&(r.errors=Aa(x.getPath(e,r.path),r.validators))})}function bo(e,t){const n=t[0];return t=t.slice(1),Array.isArray(e)?e.map((a,r)=>r===Number(n)?bo(a,t):a):Yc(e)?Object.keys(e).reduce((a,r)=>Object.assign(a,{[r]:r===n?bo(e[r],t):e[r]}),{}):e}function Vv(e){if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError("The initial value of useSpsForm() hook must be an object.")}function $v(e,t){Vv(e);const n=H.useMemo(()=>{x.deepFreeze(e);const f=xs(e,[],p);return t&&So(e,f,t,!0),f},[]),a=H.useRef();let r=t;const i=H.useCallback((f,m)=>{let g;if(a.current=null,m)if(m.path)if(m.markAsBlurred){const v=ho(f.formMeta,m.path);v&&(v.focused=!1,v.revealAllErrors=!0)}else if(m.newValidators){if(r){const v=m.path.join("."),C=I({},r);C[v]=m.newValidators,r=C,So(f.formValue,f.formMeta,r,!0)}}else g=bo(f.formValue,m.path),x.setPath(g,m.path,m.value);else g=m.value;if(g){x.deepFreeze(g);const v=x.diff(f.formValue,g);for(const{type:C,key:k,parentPath:S,objects:[w,E]}of v){const y=ho(f.formMeta,S);if(typeof k!="symbol"&&y)switch(C){case x.DiffChange.ADDITION:y.fields[k]=xs(E[k],[...S,k],p);break;case x.DiffChange.DELETION:Array.isArray(y.fields)?y.fields.splice(Number(k),1):delete y.fields[k];break;case x.DiffChange.ALTERATION:if(!w[k]&&E[k]&&!(y.fields[k]instanceof Es)){const N=xs(E[k],[...S,k],p);N instanceof Kn&&y.fields[k]instanceof Kn&&(N.id=y.fields[k].id,N.focused=y.fields[k].focused,N.pristine=y.fields[k].pristine),y.fields[k]=N}break}}if(r){So(g,f.formMeta,r);const C=new Set;Qc(f.formMeta,t,(k,S)=>{typeof S=="function"&&(k.validate(x.getPath(g,k.path)),C.add(k))});for(const{type:k,key:S,parentPath:w,objects:[,E]}of v)if(typeof S!="symbol"){let y=f.formMeta,N=g;if(y){for(const _ of w)y=y.fields[_],N=N[_],C.has(y)||y.validate(N);if(k===x.DiffChange.ADDITION||k===x.DiffChange.ALTERATION){const _=y.fields[S];if(!C.has(_)&&(y.fields[S].validate(E[S]),k===x.DiffChange.ADDITION&&_.fields))for(const[R,O]of Object.entries(_.fields))O.validate(E[S][R])}}}}}return{formValue:g||f.formValue,formMeta:f.formMeta,updateForm:f.updateForm}},[]),[l,c]=H.useReducer(i,{formValue:e,formMeta:n,updateForm:u});function p(f,m,g=!1,v){f?c({path:f,value:m,markAsBlurred:g,newValidators:v}):u()}function u(f){if(f){a.current&&window.clearTimeout(a.current);const m=window.setTimeout(c,0,{value:f});a.current=m}else if(!a.current){const m=window.setTimeout(c,0,{});a.current=m}}return H.useEffect(()=>()=>{a.current&&window.clearTimeout(a.current)},[]),l}const Hv=$(I({},q),{focusInputOnClick:T.exports.bool,formMeta:de(),formControl:de(),inputRef:Jt()}),Tt=s.forwardRef((e,t)=>{const E=e,{className:n,children:a,focusInputOnClick:r,formControl:i,formMeta:l,inputRef:c,onClick:p}=E,u=Z(E,["className","children","focusInputOnClick","formControl","formMeta","inputRef","onClick"]),f=s.useRef(),g=c||(t||f);function v(){g&&g!==t&&g.current&&g.current.focus()}function C(){g&&g!==t&&g.current&&l&&l instanceof Kn&&l.markAsFocused()}function k(){g&&g!==t&&g.current&&l&&l instanceof Kn&&l.markAsBlurred()}const S=A("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 w(y){r&&v(),p&&p(y)}return s.createElement("div",$(I({},u),{className:S,ref:t,tabIndex:-1,onClick:w,onFocus:C,onBlur:k}),a)});Object.assign(Tt,{spsFormComponentWrapperPropTypes:Hv,displayName:"SpsFormComponentWrapper"});function ed(e){return typeof e=="object"&&e!=null&&e.nodeType===1}function td(e,t){return(!t||e!=="hidden")&&e!=="visible"&&e!=="clip"}function vo(e,t){if(e.clientHeight<e.scrollHeight||e.clientWidth<e.scrollWidth){var n=getComputedStyle(e,null);return td(n.overflowY,t)||td(n.overflowX,t)||function(a){var r=function(i){if(!i.ownerDocument||!i.ownerDocument.defaultView)return null;try{return i.ownerDocument.defaultView.frameElement}catch{return null}}(a);return!!r&&(r.clientHeight<a.scrollHeight||r.clientWidth<a.scrollWidth)}(e)}return!1}function Ds(e,t,n,a,r,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+r:0}function nd(e,t){var n=window,a=t.scrollMode,r=t.block,i=t.inline,l=t.boundary,c=t.skipOverflowHiddenElements,p=typeof l=="function"?l:function(Ve){return Ve!==l};if(!ed(e))throw new TypeError("Invalid target");for(var u=document.scrollingElement||document.documentElement,f=[],m=e;ed(m)&&p(m);){if((m=m.parentElement)===u){f.push(m);break}m!=null&&m===document.body&&vo(m)&&!vo(document.documentElement)||m!=null&&vo(m,c)&&f.push(m)}for(var g=n.visualViewport?n.visualViewport.width:innerWidth,v=n.visualViewport?n.visualViewport.height:innerHeight,C=window.scrollX||pageXOffset,k=window.scrollY||pageYOffset,S=e.getBoundingClientRect(),w=S.height,E=S.width,y=S.top,N=S.right,_=S.bottom,R=S.left,O=r==="start"||r==="nearest"?y:r==="end"?_:y+w/2,B=i==="center"?R+E/2:i==="end"?N:R,F=[],P=0;P<f.length;P++){var U=f[P],K=U.getBoundingClientRect(),j=K.height,J=K.width,ee=K.top,ae=K.right,pe=K.bottom,ce=K.left;if(a==="if-needed"&&y>=0&&R>=0&&_<=v&&N<=g&&y>=ee&&_<=pe&&R>=ce&&N<=ae)return F;var G=getComputedStyle(U),X=parseInt(G.borderLeftWidth,10),V=parseInt(G.borderTopWidth,10),oe=parseInt(G.borderRightWidth,10),ne=parseInt(G.borderBottomWidth,10),se=0,Q=0,Ie="offsetWidth"in U?U.offsetWidth-U.clientWidth-X-oe:0,Be="offsetHeight"in U?U.offsetHeight-U.clientHeight-V-ne:0;if(u===U)se=r==="start"?O:r==="end"?O-v:r==="nearest"?Ds(k,k+v,v,V,ne,k+O,k+O+w,w):O-v/2,Q=i==="start"?B:i==="center"?B-g/2:i==="end"?B-g:Ds(C,C+g,g,X,oe,C+B,C+B+E,E),se=Math.max(0,se+k),Q=Math.max(0,Q+C);else{se=r==="start"?O-ee-V:r==="end"?O-pe+ne+Be:r==="nearest"?Ds(ee,pe,j,V,ne+Be,O,O+w,w):O-(ee+j/2)+Be/2,Q=i==="start"?B-ce-X:i==="center"?B-(ce+J/2)+Ie/2:i==="end"?B-ae+oe+Ie:Ds(ce,ae,J,X,oe+Ie,B,B+E,E);var ve=U.scrollLeft,Fe=U.scrollTop;O+=Fe-(se=Math.max(0,Math.min(Fe+se,U.scrollHeight-j+Be))),B+=ve-(Q=Math.max(0,Math.min(ve+Q,U.scrollWidth-J+Ie)))}F.push({el:U,top:se,left:Q})}return F}function ad(e){return e===Object(e)&&Object.keys(e).length!==0}function Wv(e,t){t===void 0&&(t="auto");var n="scrollBehavior"in document.body.style;e.forEach(function(a){var r=a.el,i=a.top,l=a.left;r.scroll&&n?r.scroll({top:i,left:l,behavior:t}):(r.scrollTop=i,r.scrollLeft=l)})}function jv(e){return e===!1?{block:"end",inline:"nearest"}:ad(e)?e:{block:"start",inline:"nearest"}}function sd(e,t){var n=!e.ownerDocument.documentElement.contains(e);if(ad(t)&&typeof t.behavior=="function")return t.behavior(n?[]:nd(e,t));if(!n){var a=jv(t);return Wv(nd(e,a),a.behavior)}}var Yv=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",default:sd});const Gv={alt:"string",size:"SpinnerSize",title:"string"},Uv=$(I({},q),{alt:T.exports.string,size:be(M.SpinnerSize),title:T.exports.string});function ks(e){const m=e,{alt:t,className:n,size:a=M.SpinnerSize.MEDIUM,"data-testid":r,title:i,unsafelyReplaceClassName:l}=m,c=Z(m,["alt","className","size","data-testid","title","unsafelyReplaceClassName"]),{t:p}=s.useContext(Ye),u=t||i||p("design-system:spinner.defaultAltText"),f=A(l||"sps-spinner",`sps-spinner--${a}`,n);return s.createElement("i",I({className:f,"data-testid":r,title:u},c))}Object.assign(ks,{props:Gv,propTypes:Uv,displayName:"SpsSpinner"});const zv=60;function Ns(e){return typeof e=="undefined"?"inherit":`${e}px`}function rd(e){switch(e){case M.Position.TOP_LEFT:return M.Position.BOTTOM_LEFT;case M.Position.TOP_MIDDLE:return M.Position.BOTTOM_MIDDLE;case M.Position.TOP_RIGHT:return M.Position.BOTTOM_RIGHT;case M.Position.RIGHT_TOP:return M.Position.LEFT_TOP;case M.Position.RIGHT_MIDDLE:return M.Position.LEFT_MIDDLE;case M.Position.RIGHT_BOTTOM:return M.Position.LEFT_BOTTOM;case M.Position.BOTTOM_RIGHT:return M.Position.TOP_RIGHT;case M.Position.BOTTOM_MIDDLE:return M.Position.TOP_MIDDLE;case M.Position.BOTTOM_LEFT:return M.Position.TOP_LEFT;case M.Position.LEFT_BOTTOM:return M.Position.RIGHT_BOTTOM;case M.Position.LEFT_MIDDLE:return M.Position.RIGHT_MIDDLE;case M.Position.LEFT_TOP:return M.Position.RIGHT_TOP}}function qv(e,t,n,a,r,i,l,c){const p=l&&l.current,u=p?p.scrollTop:window.pageYOffset,f=c?0:u,m=p?p.scrollLeft:window.pageXOffset,g=c?0:m,[v,C]=e.split(" ");let k,S,w,E;switch(v){case"top":w=t.height-n.top-f-i[0];break;case"left":S=t.width-n.left-g-i[0];break;case"right":E=n.right+g-i[0];break;case"bottom":k=n.bottom+f-i[0];break;default:throw new Error(`Invalid position ${e}`)}switch(C){case"left":E=n.left+g+i[1];break;case"top":k=n.top+f+i[1];break;case"middle":v==="top"||v==="bottom"?E=n.left+g+n.width/2-r/2+i[1]:(v==="left"||v==="right")&&(k=n.top+f+n.height/2-a.height/2+i[1]);break;case"bottom":w=t.height-n.bottom-f+i[1];break;case"right":S=t.width-n.right-g+i[1];break;default:throw new Error(`Invalid position ${e}`)}return[k,S,w,E]}function Fa(e,t,n,{altPosition:a,setMinWidth:r=!1,setWidth:i=!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,g=c?{width:f,height:u,top:0,left:0,bottom:u,right:f}:m.getBoundingClientRect(),v=e.current.getBoundingClientRect(),C=t.current.getBoundingClientRect(),[k]=n.split(" ");let S=n;a&&(k==="top"&&C.top-v.height<zv||k==="right"&&C.right+v.width>f||k==="bottom"&&C.bottom+v.height>u||k==="left"&&C.left-v.width<0)&&(S=a);const w=r?Math.max(C.width,v.width):v.width,E=i?C.width:w,[y,N,_,R]=qv(S,g,C,v,E,p,l,c),O={top:Ns(y),right:Ns(N),bottom:Ns(_),left:Ns(R)};return c&&(O.position="fixed",O.zIndex=M.ZStratum.BAR),r&&(O.minWidth=`${C.width}px`),i&&(O.width=`${C.width}px`),[O,S===a]}return[{},!1]}const It=H.createContext(null);function ua(e,t=[]){const n=H.useContext(It);return H.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 p of t)l.classList.add(p);i.appendChild(l)}return co.createPortal(a,l)},[n])}const Jv={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"},propTypes:{captionKey:T.exports.string,comparisonKey:T.exports.string,disabledOptions:T.exports.arrayOf(T.exports.any),options:T.exports.oneOfType([T.exports.array,T.exports.instanceOf(Promise),re()]).isRequired,tall:T.exports.bool,textKey:T.exports.string,valueKey:T.exports.string,zeroState:T.exports.string,maxHeightPx:T.exports.number,maxHeightRem:T.exports.number}},Zv={hideInlineSearch:T.exports.bool,onSearchChange:re(),search:T.exports.string,searchDebounce:T.exports.number,searchPlaceholder:T.exports.string,searchInputRef:Jt()},Xv=$(I(I(I({},q),Jv.propTypes),Zv),{attachTo:Jt().isRequired,conformWidth:T.exports.bool,id:T.exports.string.isRequired,isOpen:T.exports.bool,keepOpen:T.exports.bool,keyDown:de(),nullOption:T.exports.string,offsets:T.exports.arrayOf(T.exports.number),onOptionListChanged:re(),onOptionSelected:re(),onPositionFlip:re(),onSelfToggle:re(),optionRole:T.exports.string,positionOverride:T.exports.arrayOf(be(M.Position)),selectedOption:T.exports.any,specialAction:re(),ignoreWidthStyles:T.exports.bool,loading:T.exports.bool,filterByTextAndCaptionKey:T.exports.bool});async function od(e,t,n,a,r,i){const l=typeof e.options=="function"?e.options(t.value):e.options||[],c=l instanceof Promise;n({pending:c}),i.current=c?l:null;const p=c?await l||[]:l||[];if(c&&i.current!==l)return;let u=Array.from(p).filter(Boolean).map(f=>new M.SpsOptionListOption(f,typeof f=="function"?{textKey:"label",captionKey:"caption"}:{textKey:e.textKey,captionKey:e.captionKey}));if(e.nullOption&&u.unshift(new M.SpsOptionListOption(null,{text:e.nullOption})),t.value?(n({replacementPattern:new RegExp(t.value,"ig")}),u=u.filter(f=>{const m=new RegExp(t.value,"i");return e.filterByTextAndCaptionKey?m.test(f.text)||m.test(f.caption):m.test(f.text)})):n({replacementPattern:null}),e.disabledOptions)for(const f of u)e.disabledOptions.includes(f.value)&&(f.disabled=!0);a(Object.freeze(u)),e.onOptionListChanged&&e.onOptionListChanged(u.length),r(u.some(f=>f.value&&!!f.value.icon)),n({pending:!1})}function Qv(e,t,n){const[a,r]=s.useState(Object.freeze([])),[i,l]=s.useState(!1),c=s.useRef(null),p=s.useRef(e.options);typeof e.options!="function"&&(p.current=e.options);const u=s.useMemo(()=>typeof p.current=="function"?x.debounce(od,typeof e.searchDebounce!="undefined"?e.searchDebounce:500):od,[p.current,e.disabledOptions]);return s.useEffect(()=>{u(e,t,n,r,l,c)},[p.current,t.value,e.disabledOptions]),[a,i]}class Vn{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 ey(e,t){return I(I({},e),t)}function Zt(e){return H.useReducer(ey,e)}function ty({hideInlineSearch:e,options:t,onSearchChange:n,search:a="",searchPlaceholder:r="Search\u2026",searchInputRef:i}){const[l,c]=Zt({isAsync:typeof t=="function",pending:!1,value:a,replacementPattern:null}),p=s.useCallback(v=>{c({value:v.target.value}),n&&n(v)},[n]),u=s.useCallback(v=>{v.nativeEvent.stopImmediatePropagation(),v.stopPropagation()},[]),f=s.useCallback(v=>{v.nativeEvent.stopImmediatePropagation(),c({value:""}),n&&n(new Vn(i.current)),i.current&&i.current.focus()},[n]),m=v=>{!v||["Tab","Escape","Enter","Up","ArrowUp","Down","ArrowDown"].includes(v.key)||v.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:r,ref:i,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}))),l,c]}const ny=sd||Yv,ay=["Tab","Escape","Enter","Up","ArrowUp","Down","ArrowDown"],sy=["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 ry(e,t,n){return n?(e&&e[n])===(t&&t[n]):e===t}function id(e,t,n){return typeof n.value=="function"&&n.disabled?!0:t?!!(e==null?void 0:e.find(a=>{var r;return a[t]&&a[t]===((r=n==null?void 0:n.value)==null?void 0:r[t])})):!1}const Ka=s.forwardRef((e,t)=>{const _n=e,{captionKey:n,comparisonKey:a,disabledOptions:r,options:i,tall:l,textKey:c,valueKey:p,zeroState:u,hideInlineSearch:f,onSearchChange:m,search:g,searchDebounce:v,searchPlaceholder:C,attachTo:k,className:S,conformWidth:w,id:E,ignoreWidthStyles:y,isOpen:N,keepOpen:_,keyDown:R,nullOption:O,onOptionListChanged:B,onOptionSelected:F,onPositionFlip:P,onSelfToggle:U,optionRole:K,positionOverride:j,selectedOption:J,specialAction:ee,unsafelyReplaceClassName:ae,loading:pe,filterByTextAndCaptionKey:ce,maxHeightPx:G,maxHeightRem:X,"data-testid":V}=_n,oe=Z(_n,["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","data-testid"]),ne=s.useMemo(()=>ee?new M.SpsOptionListOption(ee,{textKey:"label",captionKey:"caption"}):null,[ee]),[se,Q]=s.useState(-1),[Ie,Be]=s.useState(N),ve=t||s.useRef(null),Fe=s.useRef(null),Ve=s.useRef(null),Qe=ua("sps-option-list-portal"),Ze=s.useContext(It),[st,et]=j||[M.Position.BOTTOM_LEFT,M.Position.TOP_LEFT],[bt,ye]=Ie?Fa(ve,k,st,I({altPosition:et,setMinWidth:!y,setWidth:!y&&w},Ze)):[{},!1],Ae=s.useRef(null),[De,Oe,nt]=ty($(I({},e),{searchInputRef:Ae})),[ke,pt]=Qv(e,Oe,nt);s.useEffect(()=>{Q(-1)},[Oe]);const nn=A(ae||"sps-option-list","z-stratum-dropdown",Ie&&"sps-option-list--open",Oe.isAsync&&"sps-option-list--searchable",ye&&"sps-option-list--opens-upward",ee&&ee.label&&"sps-option-list--has-special-action",S),yn=A(ae||"sps-option-list__options",l&&"sps-option-list__options--tall"),Xe=s.useCallback(()=>{Ie||(Be(!0),Ae.current&&Ae.current.focus(),Q(-1),U&&U(!0))},[Ie,U]),an=s.useCallback(()=>{Ie&&(Be(!1),Q(-1),U&&U(!1))},[Ie,U]),Et=s.useCallback((me,Ce)=>{Ce||me&&!me.disabled&&(typeof me.value=="function"?me.value():typeof F=="function"&&F(me.value),_||an())},[F,an]),ut=s.useCallback((me,Ce,rt)=>{me.stopPropagation(),Et(Ce,rt)},[Et]),we=s.useRef(r||[]);we.current=r||[];const jt=s.useCallback(me=>{switch(me.key){case"Tab":case"Escape":an();break;case"Enter":if(se>-1){const Ce=ke[se]||ne;me.preventDefault();const rt=!!Ce&&id(we.current,a,Ce);!rt&&Ce&&typeof F=="function"&&typeof Ce.value=="function"?Ce.value():Ce&&Et(Ce,rt)}break;case"Up":case"ArrowUp":{let Ce=se;ye?se<=-1?Ce=ke.length-1:se===0?ee&&(Ce=ke.length):se<ke.length&&(Ce=se-1):se>-1&&(Ce=se-1),Ce!==se&&(me.preventDefault(),Q(Ce));break}case"Down":case"ArrowDown":{Xe();let Ce=se;ye?se!==-1&&(se>=ke.length?Ce=0:se===ke.length-1?Ce=-1:Ce=se+1):se<ke.length-1+Number(!!ee)&&(Ce=se+1),Ce!==se&&(me.preventDefault(),Q(Ce));break}default:Xe()}},[an,Xe,se,Et,F,ye,ke]),Tn=s.useCallback(me=>{const Ce=ke.findIndex(rt=>{if(rt.textKey){const Lt=rt.textKey;return rt.value[Lt].toLowerCase().charAt([0])===me.key.toLocaleLowerCase()}return rt.value.toLowerCase().charAt([0])===me.key.toLocaleLowerCase()});Ce>-1&&Q(Ce)},[ke]),Qn=s.useCallback(me=>{!me||(ay.includes(me.key)?jt(me):sy.includes(me.key)&&Tn(me))},[an,Xe,se,Et,F,ye,ke]);s.useEffect(()=>{if(Ze!==null&&document.getElementsByClassName("sps-modal__body").length>0){const me=()=>{U(!1)},Ce=document.getElementsByClassName("sps-modal__body")[0];return Ce.addEventListener("scroll",me),()=>{Ce.removeEventListener("scroll",me)}}},[]),s.useEffect(()=>{Ve.current&&ny(Ve.current,{scrollMode:"if-needed",block:"nearest",inline:"nearest"})},[se]),s.useEffect(()=>{Be(N),N?Ae.current&&Ae.current.focus():Q(-1)},[N]),s.useEffect(()=>{Qn(R)},[R]),s.useEffect(()=>{!Ie&&Fe.current&&(nt({value:""}),Fe.current.scrollTop=0),Ie&&P&&P(ye)},[Ie]);const ea=G?G/16:X,ka=ea?{maxHeight:`${ea}rem`}:{};return Qe(s.createElement("div",I({className:nn,id:E,"aria-activedescendant":se>-1?`${E}-option-${se}`:null,tabIndex:-1,ref:ve,style:bt,onMouseLeave:()=>Q(-1),"data-testid":V},oe),De,s.createElement("div",{className:yn,ref:Fe,"data-testid":`${V}-options`,style:ka},!pe&&!Oe.pending&&u&&(Oe.value||!Oe.isAsync)&&ke.length===0&&s.createElement("div",{className:"sps-option-list__zero-state"},u),(pe||Oe.pending)&&s.createElement("div",{className:"sps-option-list__loading"},s.createElement(ks,null)),!pe&&!Oe.pending&&ke.map((me,Ce)=>{const rt=`${E}-option-${Ce}`,Lt=ry(me.value,J,a),Le=id(we.current,a,me);return s.createElement("a",{key:rt,id:rt,role:K,"aria-selected":Lt,href:me.href,className:A("sps-option-list__option",me.caption&&"sps-option-list__option--has-caption",me.disabled&&"sps-option-list__option--disabled",me.bold&&"sps-option-list__option--bold",(Lt||Le)&&"sps-option-list__option--selected",se===Ce&&"sps-option-list__option--highlighted"),onClick:Yt=>ut(Yt,me,Le),onMouseOver:()=>Q(Ce),tabIndex:-1,ref:se===Ce?Ve:null,"data-testid":`${V}-option-${Ce}`},me.value&&me.value.icon&&s.createElement("i",{className:A("sps-icon","sps-option-list__option-icon",`sps-icon-${String(me.value.icon)}`)}),(!me.value||!me.value.icon&&pt)&&s.createElement("span",{className:"sps-option-list__option-icon-spacer"}),s.createElement("span",{dangerouslySetInnerHTML:{__html:me.getHtml(Oe.replacementPattern)}}),me.caption&&s.createElement("div",{className:"sps-option-list__option-caption"},s.createElement("span",{dangerouslySetInnerHTML:{__html:me.caption.replace(Oe.replacementPattern,"<u>$&</u>")}})))})),ne&&ee.label&&s.createElement("a",{className:A("sps-option-list__option","sps-option-list__special-action",se===ke.length&&"sps-option-list__option--highlighted",ee.disabled&&"sps-option-list__special-action--disabled"),href:ne.href,target:ne.href&&ee.newTab?"_blank":"_self",onClick:me=>ut(me,ne),onMouseOver:()=>Q(ke.length),"data-testid":`${V}-special-action`},ee.icon&&s.createElement("i",{className:A("sps-icon","sps-option-list__option-icon",`sps-icon-${String(ee.icon)}`)}),!ee.icon&&pt&&s.createElement("span",{className:"sps-option-list__option-icon-spacer"}),s.createElement("span",null,ee.label))))});Object.assign(Ka,{propTypes:Xv,displayName:"SpsOptionList"});function Vt(e=[],t=[]){const n=Array.isArray(e)?x.flatten(e):[e],a=t.map(i=>Array.isArray(i)?i:[i]),r=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:p,props:u={}}of a[c])if(i.type===p&&Object.keys(u).every(m=>u[m]===i.props[m])){l=!0,r[c].push(i);break}l||r[r.length-1].push(i)}return r}function ld(e,t,n){const a=Object.entries(t).filter(([,i])=>typeof i!="string"&&i.deprecated).map(([i])=>i),r=a.map(i=>n[i]);s.useEffect(()=>{r.find(i=>typeof i!="undefined")&&console.warn(`The following prop(s) of ${e} are deprecated: ${a.join(", ")}`)},r)}function cd(e,t){const n=H.useRef(!1);H.useEffect(()=>{if(n.current)return e();n.current=!0},t)}function dd(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 oy(e,t,n){return function(r){var i,l;!((i=e.current)==null?void 0:i.contains(r.target))&&!((l=t.current)==null?void 0:l.contains(r.target))&&n()}}function Va(e,t,n){const a=s.useRef(!1),[r,i]=s.useState(!1),l=s.useCallback(()=>{a.current?a.current=!1:i(!0)},[]),c=s.useCallback((p=!1)=>{i(!1),a.current=p,n&&n()},[]);return dd("mousedown",oy,[e,t,c]),{showPopup:r,doShowPopup:l,doHidePopup:c}}const iy={debounce:"number",disabled:"boolean",formMeta:"SpsFormFieldMeta<string>",icon:"SpsIcon",onChange:"React.ChangeEventHandler",placeholder:"string",suggestions:{type:`
|
|
196
|
+
`}}}};var Sv=self.crypto||self.msCrypto,mo="-_",xn=36;for(;xn--;)mo+=xn.toString(36);xn=36;for(;xn---10;)mo+=xn.toString(36).toUpperCase();var bv=function(e){var t="",n=Sv.getRandomValues(new Uint8Array(e||21));for(xn=e||21;xn--;)t+=mo[n[xn]&63];return t},Dn=bv;function ca(e){return H.useRef(e||Dn())}function Ft(e,t){const n=ca(e),a=H.useRef(`${n.current}_ctrl`);return H.useEffect(()=>{t&&(t.id=a.current,t.update())},[t]),{wrapperId:n.current,controlId:a.current}}var vv="[object Object]";function yv(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch{}return t}function Tv(e,t){return function(n){return e(t(n))}}var wv=Function.prototype,Wc=Object.prototype,jc=wv.toString,Cv=Wc.hasOwnProperty,Ev=jc.call(Object),xv=Wc.toString,Dv=Tv(Object.getPrototypeOf,Object);function kv(e){return!!e&&typeof e=="object"}function Nv(e){if(!kv(e)||xv.call(e)!=vv||yv(e))return!1;var t=Dv(e);if(t===null)return!0;var n=Cv.call(t,"constructor")&&t.constructor;return typeof n=="function"&&n instanceof n&&jc.call(n)==Ev}var Yc=Nv;const Kt=new Set,da=new Set,mn=new Set,Ba=new Set;function Gc(e){Kt.has(e)||mn.has(e)||Ba.has(e)||da.add(e)}function Uc(e){Kt.has(e)||mn.has(e)||da.has(e)||Ba.add(e)}const fo=Ut.default||Ut,ws="MM/DD/YYYY",Iv=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/,zc=Symbol("Date Parse Error");function pa(e){return e.year*1e4+e.month*100+e.date}const he=Object.freeze({createFrom(e){if(!e)return null;if(typeof e=="string"){const t=Iv.exec(e);if(t){const[,n,a,r]=t;return Object.freeze({year:Number(r),month:Number(n),date:Number(a)})}return Object.freeze({[zc]:!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(he.createFrom):null},isValid(e){return e&&typeof e=="object"&&typeof e.year=="number"&&typeof e.month=="number"&&typeof e.date=="number"&&he.toMoment(e).isValid()},nullifyInvalidDate(e){return he.isValid(e)?e:null},toMoment(e){return e?fo($(I({},e),{month:e.month-1})):null},toString(e){const t=he.toMoment(e);return t?t.format(ws):""},toStringRange(e){return e?e.map(he.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:pa(e)>pa(t)},isBefore(e,t){return!e||!t?null:pa(e)<pa(t)},isInRange(e,t,n=!0){if(!e||!t||!t[0]||!t[1])return null;const a=pa(e),[r,i]=t.map(pa);return e&&r&&i&&(n&&a>=r&&a<=i||!n&&a>r&&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=fo(),n=t.clone().subtract(fo.duration(e.definition));return[he.createFrom(n),he.createFrom(t)]}}),Pa=function(t){if(Array.isArray(t)){const n=Pa(t[0]),a=Pa(t[1]);return n||a}if(t&&t.hasOwnProperty("year")){if(t[zc])return{dateFormat:ws};if(!he.isValid(t))return{dateValidity:!0}}return null};Kt.add("dateFormat");Kt.add("dateValidity");const qc=function(t){if(Array.isArray(t)){const n=Pa(t);if(n)return n;if(t&&he.isBefore(t[1],t[0]))return{dateRangeOrder:!0}}return null};Kt.add("dateRangeOrder");const Jc=function({minDate:t,maxDate:n}){function a(r){const i=he.isBefore(r,t),l=he.isAfter(r,n),c={minExceeded:i?he.toString(t):null,maxExceeded:l?he.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}};Kt.add("dateConstraint");var _v=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",date:Pa,dateRange:qc,dateConstraint:Jc});const Mv=function(t){return function(a){return Number(a)>=t?null:{min:t}}};Kt.add("min");const Ov=function(t){return n=>Number(n)<=t?null:{max:t}};da.add("max");const Rv=function(t){return typeof t=="undefined"||t===null||t===""||Number.isNaN(t)||(t==null?void 0:t.length)===0?{required:!0}:null};da.add("required");const Lv=function(t){return function(a){return a.length>=t?null:{minLength:t}}};Kt.add("minLength");const Bv=function(t){return function(a){return a.length<=t?null:{maxLength:t}}};mn.add("maxLength");const Pv=function(t){const n=t instanceof RegExp?t:new RegExp(t);return function(r){return n.test(r)?null:{pattern:t}}};Kt.add("pattern");const Av=function(t){return/^[A-Za-z]*$/.test(t)?null:{alpha:!0}};mn.add("alpha");const Fv=function(t){return/^[0-9,. ]*$/.test(t)?null:{numeric:!0}};mn.add("numeric");const Kv=function(t){return/^[^0-9]*$/.test(t)?null:{nonNumeric:!0}};mn.add("nonNumeric");const Cs=Object.freeze($(I({},_v),{min:Mv,max:Ov,required:Rv,minLength:Lv,maxLength:Bv,pattern:Pv,alpha:Av,numeric:Fv,nonNumeric:Kv,OnBlurErrorKeys:Kt}));function Aa(e,t=[]){const n=t.reduce((a,r)=>Object.assign(a,r(e)||{}),{});return Object.keys(n).length?n:null}class Fn{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=Aa(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=>da.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(Cs.required)>-1}isSubmitted(){return this.submitted}onFocus(){}onBlur(){}}class Kn extends Fn{constructor(){super(...arguments);this.id=Dn(),this.focused=!1,this.pristine=!0}setValue(t){if(this.revealAllErrors=!1,this.preventativeErrors=[],this.validators&&this.validators.length>0){const n=Aa(t,this.validators);if(n&&Object.keys(n).filter(r=>mn.has(r)).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 Es extends Kn{constructor(t,n,a){const r=a?n:t,i=a||n;super(r,i);a&&this.inferMembers(t)}inferSpsControl(t,n){return xs(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 Zc extends Es{inferMembers(t){this.fields={};for(const n of Object.keys(t))this.fields[n]=this.inferSpsControl(t[n],n)}}class Xc extends Es{inferMembers(t){this.fields=t.map((n,a)=>this.inferSpsControl(n,String(a)))}}function xs(e,t,n){return e instanceof Fn?(e.path=t,e.update=n,e):Array.isArray(e)?new Xc(e,t,n):Yc(e)?new Zc(e,t,n):new Kn(t,n)}function ho(e,t){return t.length===0||!e?e:ho(e.fields[t[0]],t.slice(1,t.length))}function go(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(r=>e.fields[r]);return t.length===0?a:a.reduce((r,i)=>[...r,...go(i,t)],[])}return go(e.fields[n],t)}function Qc(e,t,n){for(const a of Object.keys(t)){const r=t[a];for(const i of go(e,a.split(".")))i&&r&&n(i,r)}}function So(e,t,n,a=!1){Qc(t,n,(r,i)=>{r.validators=typeof i=="function"?i(e):i,a&&(r.errors=Aa(x.getPath(e,r.path),r.validators))})}function bo(e,t){const n=t[0];return t=t.slice(1),Array.isArray(e)?e.map((a,r)=>r===Number(n)?bo(a,t):a):Yc(e)?Object.keys(e).reduce((a,r)=>Object.assign(a,{[r]:r===n?bo(e[r],t):e[r]}),{}):e}function Vv(e){if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError("The initial value of useSpsForm() hook must be an object.")}function $v(e,t){Vv(e);const n=H.useMemo(()=>{x.deepFreeze(e);const f=xs(e,[],p);return t&&So(e,f,t,!0),f},[]),a=H.useRef();let r=t;const i=H.useCallback((f,m)=>{let g;if(a.current=null,m)if(m.path)if(m.markAsBlurred){const v=ho(f.formMeta,m.path);v&&(v.focused=!1,v.revealAllErrors=!0)}else if(m.newValidators){if(r){const v=m.path.join("."),C=I({},r);C[v]=m.newValidators,r=C,So(f.formValue,f.formMeta,r,!0)}}else g=bo(f.formValue,m.path),x.setPath(g,m.path,m.value);else g=m.value;if(g){x.deepFreeze(g);const v=x.diff(f.formValue,g);for(const{type:C,key:k,parentPath:S,objects:[w,E]}of v){const y=ho(f.formMeta,S);if(typeof k!="symbol"&&y)switch(C){case x.DiffChange.ADDITION:y.fields[k]=xs(E[k],[...S,k],p);break;case x.DiffChange.DELETION:Array.isArray(y.fields)?y.fields.splice(Number(k),1):delete y.fields[k];break;case x.DiffChange.ALTERATION:if(!w[k]&&E[k]&&!(y.fields[k]instanceof Es)){const N=xs(E[k],[...S,k],p);N instanceof Kn&&y.fields[k]instanceof Kn&&(N.id=y.fields[k].id,N.focused=y.fields[k].focused,N.pristine=y.fields[k].pristine),y.fields[k]=N}break}}if(r){So(g,f.formMeta,r);const C=new Set;Qc(f.formMeta,t,(k,S)=>{typeof S=="function"&&(k.validate(x.getPath(g,k.path)),C.add(k))});for(const{type:k,key:S,parentPath:w,objects:[,E]}of v)if(typeof S!="symbol"){let y=f.formMeta,N=g;if(y){for(const _ of w)y=y.fields[_],N=N[_],C.has(y)||y.validate(N);if(k===x.DiffChange.ADDITION||k===x.DiffChange.ALTERATION){const _=y.fields[S];if(!C.has(_)&&(y.fields[S].validate(E[S]),k===x.DiffChange.ADDITION&&_.fields))for(const[R,O]of Object.entries(_.fields))O.validate(E[S][R])}}}}}return{formValue:g||f.formValue,formMeta:f.formMeta,updateForm:f.updateForm}},[]),[l,c]=H.useReducer(i,{formValue:e,formMeta:n,updateForm:u});function p(f,m,g=!1,v){f?c({path:f,value:m,markAsBlurred:g,newValidators:v}):u()}function u(f){if(f){a.current&&window.clearTimeout(a.current);const m=window.setTimeout(c,0,{value:f});a.current=m}else if(!a.current){const m=window.setTimeout(c,0,{});a.current=m}}return H.useEffect(()=>()=>{a.current&&window.clearTimeout(a.current)},[]),l}const Hv=$(I({},q),{focusInputOnClick:T.exports.bool,formMeta:de(),formControl:de(),inputRef:Jt()}),Tt=s.forwardRef((e,t)=>{const E=e,{className:n,children:a,focusInputOnClick:r,formControl:i,formMeta:l,inputRef:c,onClick:p}=E,u=Z(E,["className","children","focusInputOnClick","formControl","formMeta","inputRef","onClick"]),f=s.useRef(),g=c||(t||f);function v(){g&&g!==t&&g.current&&g.current.focus()}function C(){g&&g!==t&&g.current&&l&&l instanceof Kn&&l.markAsFocused()}function k(){g&&g!==t&&g.current&&l&&l instanceof Kn&&l.markAsBlurred()}const S=A("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 w(y){r&&v(),p&&p(y)}return s.createElement("div",$(I({},u),{className:S,ref:t,tabIndex:-1,onClick:w,onFocus:C,onBlur:k}),a)});Object.assign(Tt,{spsFormComponentWrapperPropTypes:Hv,displayName:"SpsFormComponentWrapper"});function ed(e){return typeof e=="object"&&e!=null&&e.nodeType===1}function td(e,t){return(!t||e!=="hidden")&&e!=="visible"&&e!=="clip"}function vo(e,t){if(e.clientHeight<e.scrollHeight||e.clientWidth<e.scrollWidth){var n=getComputedStyle(e,null);return td(n.overflowY,t)||td(n.overflowX,t)||function(a){var r=function(i){if(!i.ownerDocument||!i.ownerDocument.defaultView)return null;try{return i.ownerDocument.defaultView.frameElement}catch{return null}}(a);return!!r&&(r.clientHeight<a.scrollHeight||r.clientWidth<a.scrollWidth)}(e)}return!1}function Ds(e,t,n,a,r,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+r:0}function nd(e,t){var n=window,a=t.scrollMode,r=t.block,i=t.inline,l=t.boundary,c=t.skipOverflowHiddenElements,p=typeof l=="function"?l:function(Ve){return Ve!==l};if(!ed(e))throw new TypeError("Invalid target");for(var u=document.scrollingElement||document.documentElement,f=[],m=e;ed(m)&&p(m);){if((m=m.parentElement)===u){f.push(m);break}m!=null&&m===document.body&&vo(m)&&!vo(document.documentElement)||m!=null&&vo(m,c)&&f.push(m)}for(var g=n.visualViewport?n.visualViewport.width:innerWidth,v=n.visualViewport?n.visualViewport.height:innerHeight,C=window.scrollX||pageXOffset,k=window.scrollY||pageYOffset,S=e.getBoundingClientRect(),w=S.height,E=S.width,y=S.top,N=S.right,_=S.bottom,R=S.left,O=r==="start"||r==="nearest"?y:r==="end"?_:y+w/2,B=i==="center"?R+E/2:i==="end"?N:R,F=[],P=0;P<f.length;P++){var U=f[P],K=U.getBoundingClientRect(),j=K.height,J=K.width,ee=K.top,ae=K.right,pe=K.bottom,ce=K.left;if(a==="if-needed"&&y>=0&&R>=0&&_<=v&&N<=g&&y>=ee&&_<=pe&&R>=ce&&N<=ae)return F;var G=getComputedStyle(U),X=parseInt(G.borderLeftWidth,10),V=parseInt(G.borderTopWidth,10),oe=parseInt(G.borderRightWidth,10),ne=parseInt(G.borderBottomWidth,10),se=0,Q=0,Ie="offsetWidth"in U?U.offsetWidth-U.clientWidth-X-oe:0,Be="offsetHeight"in U?U.offsetHeight-U.clientHeight-V-ne:0;if(u===U)se=r==="start"?O:r==="end"?O-v:r==="nearest"?Ds(k,k+v,v,V,ne,k+O,k+O+w,w):O-v/2,Q=i==="start"?B:i==="center"?B-g/2:i==="end"?B-g:Ds(C,C+g,g,X,oe,C+B,C+B+E,E),se=Math.max(0,se+k),Q=Math.max(0,Q+C);else{se=r==="start"?O-ee-V:r==="end"?O-pe+ne+Be:r==="nearest"?Ds(ee,pe,j,V,ne+Be,O,O+w,w):O-(ee+j/2)+Be/2,Q=i==="start"?B-ce-X:i==="center"?B-(ce+J/2)+Ie/2:i==="end"?B-ae+oe+Ie:Ds(ce,ae,J,X,oe+Ie,B,B+E,E);var ve=U.scrollLeft,Fe=U.scrollTop;O+=Fe-(se=Math.max(0,Math.min(Fe+se,U.scrollHeight-j+Be))),B+=ve-(Q=Math.max(0,Math.min(ve+Q,U.scrollWidth-J+Ie)))}F.push({el:U,top:se,left:Q})}return F}function ad(e){return e===Object(e)&&Object.keys(e).length!==0}function Wv(e,t){t===void 0&&(t="auto");var n="scrollBehavior"in document.body.style;e.forEach(function(a){var r=a.el,i=a.top,l=a.left;r.scroll&&n?r.scroll({top:i,left:l,behavior:t}):(r.scrollTop=i,r.scrollLeft=l)})}function jv(e){return e===!1?{block:"end",inline:"nearest"}:ad(e)?e:{block:"start",inline:"nearest"}}function sd(e,t){var n=!e.ownerDocument.documentElement.contains(e);if(ad(t)&&typeof t.behavior=="function")return t.behavior(n?[]:nd(e,t));if(!n){var a=jv(t);return Wv(nd(e,a),a.behavior)}}var Yv=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",default:sd});const Gv={alt:"string",size:"SpinnerSize",title:"string"},Uv=$(I({},q),{alt:T.exports.string,size:be(M.SpinnerSize),title:T.exports.string});function ks(e){const m=e,{alt:t,className:n,size:a=M.SpinnerSize.MEDIUM,"data-testid":r,title:i,unsafelyReplaceClassName:l}=m,c=Z(m,["alt","className","size","data-testid","title","unsafelyReplaceClassName"]),{t:p}=s.useContext(Ye),u=t||i||p("design-system:spinner.defaultAltText"),f=A(l||"sps-spinner",`sps-spinner--${a}`,n);return s.createElement("i",I({className:f,"data-testid":r,title:u},c))}Object.assign(ks,{props:Gv,propTypes:Uv,displayName:"SpsSpinner"});const zv=60;function Ns(e){return typeof e=="undefined"?"inherit":`${e}px`}function rd(e){switch(e){case M.Position.TOP_LEFT:return M.Position.BOTTOM_LEFT;case M.Position.TOP_MIDDLE:return M.Position.BOTTOM_MIDDLE;case M.Position.TOP_RIGHT:return M.Position.BOTTOM_RIGHT;case M.Position.RIGHT_TOP:return M.Position.LEFT_TOP;case M.Position.RIGHT_MIDDLE:return M.Position.LEFT_MIDDLE;case M.Position.RIGHT_BOTTOM:return M.Position.LEFT_BOTTOM;case M.Position.BOTTOM_RIGHT:return M.Position.TOP_RIGHT;case M.Position.BOTTOM_MIDDLE:return M.Position.TOP_MIDDLE;case M.Position.BOTTOM_LEFT:return M.Position.TOP_LEFT;case M.Position.LEFT_BOTTOM:return M.Position.RIGHT_BOTTOM;case M.Position.LEFT_MIDDLE:return M.Position.RIGHT_MIDDLE;case M.Position.LEFT_TOP:return M.Position.RIGHT_TOP}}function qv(e,t,n,a,r,i,l,c){const p=l&&l.current,u=p?p.scrollTop:window.pageYOffset,f=c?0:u,m=p?p.scrollLeft:window.pageXOffset,g=c?0:m,[v,C]=e.split(" ");let k,S,w,E;switch(v){case"top":w=t.height-n.top-f-i[0];break;case"left":S=t.width-n.left-g-i[0];break;case"right":E=n.right+g-i[0];break;case"bottom":k=n.bottom+f-i[0];break;default:throw new Error(`Invalid position ${e}`)}switch(C){case"left":E=n.left+g+i[1];break;case"top":k=n.top+f+i[1];break;case"middle":v==="top"||v==="bottom"?E=n.left+g+n.width/2-r/2+i[1]:(v==="left"||v==="right")&&(k=n.top+f+n.height/2-a.height/2+i[1]);break;case"bottom":w=t.height-n.bottom-f+i[1];break;case"right":S=t.width-n.right-g+i[1];break;default:throw new Error(`Invalid position ${e}`)}return[k,S,w,E]}function Fa(e,t,n,{altPosition:a,setMinWidth:r=!1,setWidth:i=!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,g=c?{width:f,height:u,top:0,left:0,bottom:u,right:f}:m.getBoundingClientRect(),v=e.current.getBoundingClientRect(),C=t.current.getBoundingClientRect(),[k]=n.split(" ");let S=n;a&&(k==="top"&&C.top-v.height<zv||k==="right"&&C.right+v.width>f||k==="bottom"&&C.bottom+v.height>u||k==="left"&&C.left-v.width<0)&&(S=a);const w=r?Math.max(C.width,v.width):v.width,E=i?C.width:w,[y,N,_,R]=qv(S,g,C,v,E,p,l,c),O={top:Ns(y),right:Ns(N),bottom:Ns(_),left:Ns(R)};return c&&(O.position="fixed",O.zIndex=M.ZStratum.BAR),r&&(O.minWidth=`${C.width}px`),i&&(O.width=`${C.width}px`),[O,S===a]}return[{},!1]}const It=H.createContext(null);function ua(e,t=[]){const n=H.useContext(It);return H.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 p of t)l.classList.add(p);i.appendChild(l)}return co.createPortal(a,l)},[n])}const Jv={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"},propTypes:{captionKey:T.exports.string,comparisonKey:T.exports.string,disabledOptions:T.exports.arrayOf(T.exports.any),options:T.exports.oneOfType([T.exports.array,T.exports.instanceOf(Promise),re()]).isRequired,tall:T.exports.bool,textKey:T.exports.string,valueKey:T.exports.string,zeroState:T.exports.string,maxHeightPx:T.exports.number,maxHeightRem:T.exports.number}},Zv={hideInlineSearch:T.exports.bool,onSearchChange:re(),search:T.exports.string,searchDebounce:T.exports.number,searchPlaceholder:T.exports.string,searchInputRef:Jt()},Xv=$(I(I(I({},q),Jv.propTypes),Zv),{attachTo:Jt().isRequired,conformWidth:T.exports.bool,id:T.exports.string.isRequired,isOpen:T.exports.bool,keepOpen:T.exports.bool,keyDown:de(),nullOption:T.exports.string,offsets:T.exports.arrayOf(T.exports.number),onOptionListChanged:re(),onOptionSelected:re(),onPositionFlip:re(),onSelfToggle:re(),optionRole:T.exports.string,positionOverride:T.exports.arrayOf(be(M.Position)),selectedOption:T.exports.any,specialAction:re(),ignoreWidthStyles:T.exports.bool,loading:T.exports.bool,filterByTextAndCaptionKey:T.exports.bool});async function od(e,t,n,a,r,i){const l=typeof e.options=="function"?e.options(t.value):e.options||[],c=l instanceof Promise,p=m=>m.replace(/([.?*+^$[\]\\(){}|-])/g,"");n({pending:c}),i.current=c?l:null;const u=c?await l||[]:l||[];if(c&&i.current!==l)return;let f=Array.from(u).filter(Boolean).map(m=>new M.SpsOptionListOption(m,typeof m=="function"?{textKey:"label",captionKey:"caption"}:{textKey:e.textKey,captionKey:e.captionKey}));if(e.nullOption&&f.unshift(new M.SpsOptionListOption(null,{text:e.nullOption})),t.value){const m=p(t.value);n({replacementPattern:new RegExp(m,"ig")}),f=f.filter(g=>{const v=new RegExp(m,"i"),C=p(g.text);return e.filterByTextAndCaptionKey?v.test(C)||v.test(p(g.caption)):v.test(C)})}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),r(f.some(m=>m.value&&!!m.value.icon)),n({pending:!1})}function Qv(e,t,n){const[a,r]=s.useState(Object.freeze([])),[i,l]=s.useState(!1),c=s.useRef(null),p=s.useRef(e.options);typeof e.options!="function"&&(p.current=e.options);const u=s.useMemo(()=>typeof p.current=="function"?x.debounce(od,typeof e.searchDebounce!="undefined"?e.searchDebounce:500):od,[p.current,e.disabledOptions]);return s.useEffect(()=>{u(e,t,n,r,l,c)},[p.current,t.value,e.disabledOptions]),[a,i]}class Vn{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 ey(e,t){return I(I({},e),t)}function Zt(e){return H.useReducer(ey,e)}function ty({hideInlineSearch:e,options:t,onSearchChange:n,search:a="",searchPlaceholder:r="Search\u2026",searchInputRef:i}){const[l,c]=Zt({isAsync:typeof t=="function",pending:!1,value:a,replacementPattern:null}),p=s.useCallback(v=>{c({value:v.target.value}),n&&n(v)},[n]),u=s.useCallback(v=>{v.nativeEvent.stopImmediatePropagation(),v.stopPropagation()},[]),f=s.useCallback(v=>{v.nativeEvent.stopImmediatePropagation(),c({value:""}),n&&n(new Vn(i.current)),i.current&&i.current.focus()},[n]),m=v=>{!v||["Tab","Escape","Enter","Up","ArrowUp","Down","ArrowDown"].includes(v.key)||v.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:r,ref:i,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}))),l,c]}const ny=sd||Yv,ay=["Tab","Escape","Enter","Up","ArrowUp","Down","ArrowDown"],sy=["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 ry(e,t,n){return n?(e&&e[n])===(t&&t[n]):e===t}function id(e,t,n){return typeof n.value=="function"&&n.disabled?!0:t?!!(e==null?void 0:e.find(a=>{var r;return a[t]&&a[t]===((r=n==null?void 0:n.value)==null?void 0:r[t])})):!1}const Ka=s.forwardRef((e,t)=>{const _n=e,{captionKey:n,comparisonKey:a,disabledOptions:r,options:i,tall:l,textKey:c,valueKey:p,zeroState:u,hideInlineSearch:f,onSearchChange:m,search:g,searchDebounce:v,searchPlaceholder:C,attachTo:k,className:S,conformWidth:w,id:E,ignoreWidthStyles:y,isOpen:N,keepOpen:_,keyDown:R,nullOption:O,onOptionListChanged:B,onOptionSelected:F,onPositionFlip:P,onSelfToggle:U,optionRole:K,positionOverride:j,selectedOption:J,specialAction:ee,unsafelyReplaceClassName:ae,loading:pe,filterByTextAndCaptionKey:ce,maxHeightPx:G,maxHeightRem:X,"data-testid":V}=_n,oe=Z(_n,["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","data-testid"]),ne=s.useMemo(()=>ee?new M.SpsOptionListOption(ee,{textKey:"label",captionKey:"caption"}):null,[ee]),[se,Q]=s.useState(-1),[Ie,Be]=s.useState(N),ve=t||s.useRef(null),Fe=s.useRef(null),Ve=s.useRef(null),Qe=ua("sps-option-list-portal"),Ze=s.useContext(It),[st,et]=j||[M.Position.BOTTOM_LEFT,M.Position.TOP_LEFT],[bt,ye]=Ie?Fa(ve,k,st,I({altPosition:et,setMinWidth:!y,setWidth:!y&&w},Ze)):[{},!1],Ae=s.useRef(null),[De,Oe,nt]=ty($(I({},e),{searchInputRef:Ae})),[ke,pt]=Qv(e,Oe,nt);s.useEffect(()=>{Q(-1)},[Oe]);const nn=A(ae||"sps-option-list","z-stratum-dropdown",Ie&&"sps-option-list--open",Oe.isAsync&&"sps-option-list--searchable",ye&&"sps-option-list--opens-upward",ee&&ee.label&&"sps-option-list--has-special-action",S),yn=A(ae||"sps-option-list__options",l&&"sps-option-list__options--tall"),Xe=s.useCallback(()=>{Ie||(Be(!0),Ae.current&&Ae.current.focus(),Q(-1),U&&U(!0))},[Ie,U]),an=s.useCallback(()=>{Ie&&(Be(!1),Q(-1),U&&U(!1))},[Ie,U]),Et=s.useCallback((me,Ce)=>{Ce||me&&!me.disabled&&(typeof me.value=="function"?me.value():typeof F=="function"&&F(me.value),_||an())},[F,an]),ut=s.useCallback((me,Ce,rt)=>{me.stopPropagation(),Et(Ce,rt)},[Et]),we=s.useRef(r||[]);we.current=r||[];const jt=s.useCallback(me=>{switch(me.key){case"Tab":case"Escape":an();break;case"Enter":if(se>-1){const Ce=ke[se]||ne;me.preventDefault();const rt=!!Ce&&id(we.current,a,Ce);!rt&&Ce&&typeof F=="function"&&typeof Ce.value=="function"?Ce.value():Ce&&Et(Ce,rt)}break;case"Up":case"ArrowUp":{let Ce=se;ye?se<=-1?Ce=ke.length-1:se===0?ee&&(Ce=ke.length):se<ke.length&&(Ce=se-1):se>-1&&(Ce=se-1),Ce!==se&&(me.preventDefault(),Q(Ce));break}case"Down":case"ArrowDown":{Xe();let Ce=se;ye?se!==-1&&(se>=ke.length?Ce=0:se===ke.length-1?Ce=-1:Ce=se+1):se<ke.length-1+Number(!!ee)&&(Ce=se+1),Ce!==se&&(me.preventDefault(),Q(Ce));break}default:Xe()}},[an,Xe,se,Et,F,ye,ke]),Tn=s.useCallback(me=>{const Ce=ke.findIndex(rt=>{if(rt.textKey){const Lt=rt.textKey;return rt.value[Lt].toLowerCase().charAt([0])===me.key.toLocaleLowerCase()}return rt.value.toLowerCase().charAt([0])===me.key.toLocaleLowerCase()});Ce>-1&&Q(Ce)},[ke]),Qn=s.useCallback(me=>{!me||(ay.includes(me.key)?jt(me):sy.includes(me.key)&&Tn(me))},[an,Xe,se,Et,F,ye,ke]);s.useEffect(()=>{if(Ze!==null&&document.getElementsByClassName("sps-modal__body").length>0){const me=()=>{U(!1)},Ce=document.getElementsByClassName("sps-modal__body")[0];return Ce.addEventListener("scroll",me),()=>{Ce.removeEventListener("scroll",me)}}},[]),s.useEffect(()=>{Ve.current&&ny(Ve.current,{scrollMode:"if-needed",block:"nearest",inline:"nearest"})},[se]),s.useEffect(()=>{Be(N),N?Ae.current&&Ae.current.focus():Q(-1)},[N]),s.useEffect(()=>{Qn(R)},[R]),s.useEffect(()=>{!Ie&&Fe.current&&(nt({value:""}),Fe.current.scrollTop=0),Ie&&P&&P(ye)},[Ie]);const ea=G?G/16:X,ka=ea?{maxHeight:`${ea}rem`}:{};return Qe(s.createElement("div",I({className:nn,id:E,"aria-activedescendant":se>-1?`${E}-option-${se}`:null,tabIndex:-1,ref:ve,style:bt,onMouseLeave:()=>Q(-1),"data-testid":V},oe),De,s.createElement("div",{className:yn,ref:Fe,"data-testid":`${V}-options`,style:ka},!pe&&!Oe.pending&&u&&(Oe.value||!Oe.isAsync)&&ke.length===0&&s.createElement("div",{className:"sps-option-list__zero-state"},u),(pe||Oe.pending)&&s.createElement("div",{className:"sps-option-list__loading"},s.createElement(ks,null)),!pe&&!Oe.pending&&ke.map((me,Ce)=>{const rt=`${E}-option-${Ce}`,Lt=ry(me.value,J,a),Le=id(we.current,a,me);return s.createElement("a",{key:rt,id:rt,role:K,"aria-selected":Lt,href:me.href,className:A("sps-option-list__option",me.caption&&"sps-option-list__option--has-caption",me.disabled&&"sps-option-list__option--disabled",me.bold&&"sps-option-list__option--bold",(Lt||Le)&&"sps-option-list__option--selected",se===Ce&&"sps-option-list__option--highlighted"),onClick:Yt=>ut(Yt,me,Le),onMouseOver:()=>Q(Ce),tabIndex:-1,ref:se===Ce?Ve:null,"data-testid":`${V}-option-${Ce}`},me.value&&me.value.icon&&s.createElement("i",{className:A("sps-icon","sps-option-list__option-icon",`sps-icon-${String(me.value.icon)}`)}),(!me.value||!me.value.icon&&pt)&&s.createElement("span",{className:"sps-option-list__option-icon-spacer"}),s.createElement("span",{dangerouslySetInnerHTML:{__html:me.getHtml(Oe.replacementPattern)}}),me.caption&&s.createElement("div",{className:"sps-option-list__option-caption"},s.createElement("span",{dangerouslySetInnerHTML:{__html:me.caption.replace(Oe.replacementPattern,"<u>$&</u>")}})))})),ne&&ee.label&&s.createElement("a",{className:A("sps-option-list__option","sps-option-list__special-action",se===ke.length&&"sps-option-list__option--highlighted",ee.disabled&&"sps-option-list__special-action--disabled"),href:ne.href,target:ne.href&&ee.newTab?"_blank":"_self",onClick:me=>ut(me,ne),onMouseOver:()=>Q(ke.length),"data-testid":`${V}-special-action`},ee.icon&&s.createElement("i",{className:A("sps-icon","sps-option-list__option-icon",`sps-icon-${String(ee.icon)}`)}),!ee.icon&&pt&&s.createElement("span",{className:"sps-option-list__option-icon-spacer"}),s.createElement("span",null,ee.label))))});Object.assign(Ka,{propTypes:Xv,displayName:"SpsOptionList"});function Vt(e=[],t=[]){const n=Array.isArray(e)?x.flatten(e):[e],a=t.map(i=>Array.isArray(i)?i:[i]),r=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:p,props:u={}}of a[c])if(i.type===p&&Object.keys(u).every(m=>u[m]===i.props[m])){l=!0,r[c].push(i);break}l||r[r.length-1].push(i)}return r}function ld(e,t,n){const a=Object.entries(t).filter(([,i])=>typeof i!="string"&&i.deprecated).map(([i])=>i),r=a.map(i=>n[i]);s.useEffect(()=>{r.find(i=>typeof i!="undefined")&&console.warn(`The following prop(s) of ${e} are deprecated: ${a.join(", ")}`)},r)}function cd(e,t){const n=H.useRef(!1);H.useEffect(()=>{if(n.current)return e();n.current=!0},t)}function dd(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 oy(e,t,n){return function(r){var i,l;!((i=e.current)==null?void 0:i.contains(r.target))&&!((l=t.current)==null?void 0:l.contains(r.target))&&n()}}function Va(e,t,n){const a=s.useRef(!1),[r,i]=s.useState(!1),l=s.useCallback(()=>{a.current?a.current=!1:i(!0)},[]),c=s.useCallback((p=!1)=>{i(!1),a.current=p,n&&n()},[]);return dd("mousedown",oy,[e,t,c]),{showPopup:r,doShowPopup:l,doHidePopup:c}}const iy={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"},ly=$(I({},q),{debounce:T.exports.number,disabled:T.exports.bool,formControl:de(),formMeta:de(),icon:be(M.SpsIcon),onChange:re(),placeholder:T.exports.string,suggestions:T.exports.oneOfType([T.exports.arrayOf(T.exports.string),T.exports.instanceOf(Promise),re()]).isRequired,tallOptionList:T.exports.bool,value:T.exports.string,zeroState:T.exports.string,loading:T.exports.bool,maxHeightOptionListPx:T.exports.number,maxHeightOptionListRem:T.exports.number});function Is(y){var N=y,{className:e,debounce:t=0,disabled:n,formControl:a,formMeta:r,onChange:i,icon:l,id:c,placeholder:p="",suggestions:u,unsafelyReplaceClassName:f,tallOptionList:m,value:g="",zeroState:v,loading:C,maxHeightOptionListPx:k,maxHeightOptionListRem:S,"data-testid":w}=N,E=Z(N,["className","debounce","disabled","formControl","formMeta","onChange","icon","id","placeholder","suggestions","unsafelyReplaceClassName","tallOptionList","value","zeroState","loading","maxHeightOptionListPx","maxHeightOptionListRem","data-testid"]);const _=r||a,{wrapperId:R,controlId:O}=Ft(c,_),[B,F]=Zt({keyDown:null,opensUpward:!1}),P=s.useRef(),U=s.useRef(),K=s.useRef(),{showPopup:j,doShowPopup:J,doHidePopup:ee}=Va(P,K);function ae(ne,se){_&&(_.setValue(ne),_.markAsDirty()),i&&i(se||new Vn({value:ne}))}function pe(ne){U.current.value="",ae(""),ne.stopPropagation()}function ce(ne){ae(ne.target.value,ne)}function G(ne){n||(["Up","ArrowUp","Down","ArrowDown","Enter"].indexOf(ne.key)>-1&&(ne.preventDefault(),ne.persist()),ne.stopPropagation(),F({keyDown:ne})),ne.key==="Tab"&&ee()}function X(ne){ne?J():ee()}function V(ne){F({opensUpward:ne})}const oe=A(f||"sps-autocomplete",j&&"sps-autocomplete--open",j&&"z-stratum-dropdown",B.opensUpward&&"sps-autocomplete--opens-upward",n&&"sps-form-control--disabled",e);return s.createElement(Tt,{id:R,className:oe,formControl:a,formMeta:r,inputRef:U,ref:P,focusInputOnClick:!0,onClick:ne=>ne.nativeEvent.stopImmediatePropagation(),"data-testId":`${w}`},s.createElement("div",{className:"sps-text-input"},s.createElement("div",{className:"sps-form-control"},l&&s.createElement("i",{className:A("sps-text-input__icon","sps-icon",`sps-icon-${l}`)}),s.createElement("input",I({type:"text",ref:U,value:g,className:"sps-text-input__input",placeholder:p,onFocus:J,onClick:J,onChange:ce,onKeyDown:G,disabled:n,id:O,"data-testid":`${w}__input`},E)),g&&!n&&s.createElement("i",{"aria-label":"clear",className:"sps-icon sps-icon-x-circle sps-form-control__clear-btn",onClick:ne=>pe(ne)}))),s.createElement(Ka,{id:`${R}_options`,ref:K,attachTo:P,isOpen:j,options:u,hideInlineSearch:!0,keyDown:B.keyDown,onOptionSelected:ae,onPositionFlip:V,onSelfToggle:X,offsets:[1,0],search:g,searchDebounce:t,tall:m,zeroState:v,loading:C,maxHeightPx:k,maxHeightRem:S}))}Object.assign(Is,{props:iy,propTypes:ly,displayName:"SpsAutocomplete"});const pd={basic:{label:"Basic",examples:{basic:{react:x.code`
|
package/lib/index.es.js
CHANGED
|
@@ -1815,6 +1815,7 @@ const propTypes$1K = __spreadProps(__spreadValues(__spreadValues(__spreadValues(
|
|
|
1815
1815
|
async function updateOptions(props2, searchState, searchStatePatch, setOptionList, setAnyOptionHasIcon, promiseRef) {
|
|
1816
1816
|
const options = typeof props2.options === "function" ? props2.options(searchState.value) : props2.options || [];
|
|
1817
1817
|
const areOptionsPromise = options instanceof Promise;
|
|
1818
|
+
const removeSpecialSymbols = (value) => value.replace(/([.?*+^$[\]\\(){}|-])/g, "");
|
|
1818
1819
|
searchStatePatch({ pending: areOptionsPromise });
|
|
1819
1820
|
promiseRef.current = areOptionsPromise ? options : null;
|
|
1820
1821
|
const result = areOptionsPromise ? await options || [] : options || [];
|
|
@@ -1832,13 +1833,15 @@ async function updateOptions(props2, searchState, searchStatePatch, setOptionLis
|
|
|
1832
1833
|
newOpts.unshift(new SpsOptionListOption(null, { text: props2.nullOption }));
|
|
1833
1834
|
}
|
|
1834
1835
|
if (searchState.value) {
|
|
1835
|
-
|
|
1836
|
+
const searchValue = removeSpecialSymbols(searchState.value);
|
|
1837
|
+
searchStatePatch({ replacementPattern: new RegExp(searchValue, "ig") });
|
|
1836
1838
|
newOpts = newOpts.filter((o) => {
|
|
1837
|
-
const regEx = new RegExp(
|
|
1839
|
+
const regEx = new RegExp(searchValue, "i");
|
|
1840
|
+
const optionText = removeSpecialSymbols(o.text);
|
|
1838
1841
|
if (props2.filterByTextAndCaptionKey) {
|
|
1839
|
-
return regEx.test(
|
|
1842
|
+
return regEx.test(optionText) || regEx.test(removeSpecialSymbols(o.caption));
|
|
1840
1843
|
}
|
|
1841
|
-
return regEx.test(
|
|
1844
|
+
return regEx.test(optionText);
|
|
1842
1845
|
});
|
|
1843
1846
|
} else {
|
|
1844
1847
|
searchStatePatch({ replacementPattern: null });
|
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": "5.23.
|
|
4
|
+
"version": "5.23.2",
|
|
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": "5.23.
|
|
32
|
-
"@spscommerce/ds-illustrations": "5.23.
|
|
33
|
-
"@spscommerce/ds-shared": "5.23.
|
|
34
|
-
"@spscommerce/positioning": "5.23.
|
|
35
|
-
"@spscommerce/utils": "5.23.
|
|
31
|
+
"@spscommerce/ds-colors": "5.23.2",
|
|
32
|
+
"@spscommerce/ds-illustrations": "5.23.2",
|
|
33
|
+
"@spscommerce/ds-shared": "5.23.2",
|
|
34
|
+
"@spscommerce/positioning": "5.23.2",
|
|
35
|
+
"@spscommerce/utils": "5.23.2",
|
|
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": "5.23.
|
|
44
|
-
"@spscommerce/ds-illustrations": "5.23.
|
|
45
|
-
"@spscommerce/ds-shared": "5.23.
|
|
46
|
-
"@spscommerce/positioning": "5.23.
|
|
47
|
-
"@spscommerce/utils": "5.23.
|
|
43
|
+
"@spscommerce/ds-colors": "5.23.2",
|
|
44
|
+
"@spscommerce/ds-illustrations": "5.23.2",
|
|
45
|
+
"@spscommerce/ds-shared": "5.23.2",
|
|
46
|
+
"@spscommerce/positioning": "5.23.2",
|
|
47
|
+
"@spscommerce/utils": "5.23.2",
|
|
48
48
|
"@testing-library/react": "^9.3.2",
|
|
49
49
|
"@types/prop-types": "^15.7.1",
|
|
50
50
|
"@types/react": "^16.9.0",
|