@spscommerce/ds-react 5.33.5 → 5.33.8
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 +11 -0
- package/lib/utils/bindProps.d.ts +6 -6
- package/package.json +11 -11
package/lib/index.cjs.js
CHANGED
|
@@ -193,7 +193,7 @@
|
|
|
193
193
|
</SpsAdvancedSearch>
|
|
194
194
|
</>;
|
|
195
195
|
}
|
|
196
|
-
`}}}};var vv=self.crypto||self.msCrypto,mo="-_",xn=36;for(;xn--;)mo+=xn.toString(36);xn=36;for(;xn---10;)mo+=xn.toString(36).toUpperCase();var yv=function(e){var t="",n=vv.getRandomValues(new Uint8Array(e||21));for(xn=e||21;xn--;)t+=mo[n[xn]&63];return t},Dn=yv;function da(e){return $.useRef(e||Dn())}function Vt(e,t){const n=da(e),a=$.useRef(`${n.current}_ctrl`);return $.useEffect(()=>{t&&(t.id=a.current,t.update())},[t]),{wrapperId:n.current,controlId:a.current}}var Tv="[object Object]";function wv(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch{}return t}function Cv(e,t){return function(n){return e(t(n))}}var Ev=Function.prototype,Wc=Object.prototype,jc=Ev.toString,xv=Wc.hasOwnProperty,Dv=jc.call(Object),kv=Wc.toString,Nv=Cv(Object.getPrototypeOf,Object);function Iv(e){return!!e&&typeof e=="object"}function _v(e){if(!Iv(e)||kv.call(e)!=Tv||wv(e))return!1;var t=Nv(e);if(t===null)return!0;var n=xv.call(t,"constructor")&&t.constructor;return typeof n=="function"&&n instanceof n&&jc.call(n)==Dv}var Yc=_v;const $t=new Set,pa=new Set,un=new Set,Pa=new Set;function Gc(e){$t.has(e)||un.has(e)||Pa.has(e)||pa.add(e)}function Uc(e){$t.has(e)||un.has(e)||pa.has(e)||Pa.add(e)}const fo=zt.default||zt,ws="MM/DD/YYYY",Mv=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/,zc=Symbol("Date Parse Error");function ua(e){return e.year*1e4+e.month*100+e.date}const fe=Object.freeze({createFrom(e){if(!e)return null;if(typeof e=="string"){const t=Mv.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(fe.createFrom):null},isValid(e){return e&&typeof e=="object"&&typeof e.year=="number"&&typeof e.month=="number"&&typeof e.date=="number"&&fe.toMoment(e).isValid()},nullifyInvalidDate(e){return fe.isValid(e)?e:null},toMoment(e){return e?fo(V(I({},e),{month:e.month-1})):null},toString(e){const t=fe.toMoment(e);return t?t.format(ws):""},toStringRange(e){return e?e.map(fe.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:ua(e)>ua(t)},isBefore(e,t){return!e||!t?null:ua(e)<ua(t)},isInRange(e,t,n=!0){if(!e||!t||!t[0]||!t[1])return null;const a=ua(e),[r,i]=t.map(ua);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[fe.createFrom(n),fe.createFrom(t)]}}),Aa=function(t){if(Array.isArray(t)){const n=Aa(t[0]),a=Aa(t[1]);return n||a}if(t&&t.hasOwnProperty("year")){if(t[zc])return{dateFormat:ws};if(!fe.isValid(t))return{dateValidity:!0}}return null};$t.add("dateFormat");$t.add("dateValidity");const qc=function(t){if(Array.isArray(t)){const n=Aa(t);if(n)return n;if(t&&fe.isBefore(t[1],t[0]))return{dateRangeOrder:!0}}return null};$t.add("dateRangeOrder");const Jc=function({minDate:t,maxDate:n}){function a(r){const i=fe.isBefore(r,t),l=fe.isAfter(r,n),c={minExceeded:i?fe.toString(t):null,maxExceeded:l?fe.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}};$t.add("dateConstraint");var Ov=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",date:Aa,dateRange:qc,dateConstraint:Jc});const Rv=function(t){return function(a){return Number(a)>=t?null:{min:t}}};$t.add("min");const Lv=function(t){return n=>Number(n)<=t?null:{max:t}};pa.add("max");const Bv=function(t){return typeof t=="undefined"||t===null||t===""||Number.isNaN(t)||(t==null?void 0:t.length)===0?{required:!0}:null};pa.add("required");const Pv=function(t){return function(a){return a.length>=t?null:{minLength:t}}};$t.add("minLength");const Av=function(t){return function(a){return a.length<=t?null:{maxLength:t}}};un.add("maxLength");const Fv=function(t){const n=t instanceof RegExp?t:new RegExp(t);return function(r){return n.test(r)?null:{pattern:t}}};$t.add("pattern");const Kv=function(t){return/^[A-Za-z]*$/.test(t)?null:{alpha:!0}};un.add("alpha");const Vv=function(t){return/^[0-9,. ]*$/.test(t)?null:{numeric:!0}};un.add("numeric");const $v=function(t){return/^[^0-9]*$/.test(t)?null:{nonNumeric:!0}};un.add("nonNumeric");const Cs=Object.freeze(V(I({},Ov),{min:Rv,max:Lv,required:Bv,minLength:Pv,maxLength:Av,pattern:Fv,alpha:Kv,numeric:Vv,nonNumeric:$v,OnBlurErrorKeys:$t}));function Fa(e,t=[]){const n=t.reduce((a,r)=>Object.assign(a,r(e)||{}),{});return Object.keys(n).length?n:null}class An{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=Fa(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=>Pa.has(t))||this.revealAllErrors&&Object.keys(this.errors).some(t=>Pa.has(t))&&this.isSubmitted()||!this.isPristine()&&Object.keys(this.errors).some(t=>pa.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 Fn extends An{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=Fa(t,this.validators);if(n&&Object.keys(n).filter(r=>un.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 Fn{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 An?(e.path=t,e.update=n,e):Array.isArray(e)?new Xc(e,t,n):Yc(e)?new Zc(e,t,n):new Fn(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=Fa(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 Hv(e){if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError("The initial value of useSpsForm() hook must be an object.")}function Wv(e,t){Hv(e);const n=$.useMemo(()=>{x.deepFreeze(e);const f=xs(e,[],p);return t&&So(e,f,t,!0),f},[]),a=$.useRef();let r=t;const i=$.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:D,parentPath:S,objects:[w,E]}of v){const y=ho(f.formMeta,S);if(typeof D!="symbol"&&y)switch(C){case x.DiffChange.ADDITION:y.fields[D]=xs(E[D],[...S,D],p);break;case x.DiffChange.DELETION:Array.isArray(y.fields)?y.fields.splice(Number(D),1):delete y.fields[D];break;case x.DiffChange.ALTERATION:if(!w[D]&&E[D]&&!(y.fields[D]instanceof Es)){const N=xs(E[D],[...S,D],p);N instanceof Fn&&y.fields[D]instanceof Fn&&(N.id=y.fields[D].id,N.focused=y.fields[D].focused,N.pristine=y.fields[D].pristine),y.fields[D]=N}break}}if(r){So(g,f.formMeta,r);const C=new Set;Qc(f.formMeta,t,(D,S)=>{typeof S=="function"&&(D.validate(x.getPath(g,D.path)),C.add(D))});for(const{type:D,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(D===x.DiffChange.ADDITION||D===x.DiffChange.ALTERATION){const _=y.fields[S];if(!C.has(_)&&(y.fields[S].validate(E[S]),D===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]=$.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 $.useEffect(()=>()=>{a.current&&window.clearTimeout(a.current)},[]),l}const jv=V(I({},q),{focusInputOnClick:T.exports.bool,formMeta:de(),formControl:de(),inputRef:Zt()}),wt=s.forwardRef((e,t)=>{const E=e,{className:n,children:a,focusInputOnClick:r,formControl:i,formMeta:l,inputRef:c,onClick:p}=E,u=J(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 Fn&&l.markAsFocused()}function D(){g&&g!==t&&g.current&&l&&l instanceof Fn&&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",V(I({},u),{className:S,ref:t,tabIndex:-1,onClick:w,onFocus:C,onBlur:D}),a)});Object.assign(wt,{spsFormComponentWrapperPropTypes:jv,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(qe){return qe!==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,D=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 G=f[P],K=G.getBoundingClientRect(),W=K.height,Z=K.width,ee=K.top,ce=K.right,ie=K.bottom,pe=K.left;if(a==="if-needed"&&y>=0&&R>=0&&_<=v&&N<=g&&y>=ee&&_<=ie&&R>=pe&&N<=ce)return F;var j=getComputedStyle(G),X=parseInt(j.borderLeftWidth,10),Q=parseInt(j.borderTopWidth,10),se=parseInt(j.borderRightWidth,10),ae=parseInt(j.borderBottomWidth,10),ne=0,U=0,Ne="offsetWidth"in G?G.offsetWidth-G.clientWidth-X-se:0,_e="offsetHeight"in G?G.offsetHeight-G.clientHeight-Q-ae:0;if(u===G)ne=r==="start"?O:r==="end"?O-v:r==="nearest"?Ds(D,D+v,v,Q,ae,D+O,D+O+w,w):O-v/2,U=i==="start"?B:i==="center"?B-g/2:i==="end"?B-g:Ds(C,C+g,g,X,se,C+B,C+B+E,E),ne=Math.max(0,ne+D),U=Math.max(0,U+C);else{ne=r==="start"?O-ee-Q:r==="end"?O-ie+ae+_e:r==="nearest"?Ds(ee,ie,W,Q,ae+_e,O,O+w,w):O-(ee+W/2)+_e/2,U=i==="start"?B-pe-X:i==="center"?B-(pe+Z/2)+Ne/2:i==="end"?B-ce+se+Ne:Ds(pe,ce,Z,X,se+Ne,B,B+E,E);var Pe=G.scrollLeft,be=G.scrollTop;O+=be-(ne=Math.max(0,Math.min(be+ne,G.scrollHeight-W+_e))),B+=Pe-(U=Math.max(0,Math.min(Pe+U,G.scrollWidth-Z+Ne)))}F.push({el:G,top:ne,left:U})}return F}function ad(e){return e===Object(e)&&Object.keys(e).length!==0}function Yv(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 Gv(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=Gv(t);return Yv(nd(e,a),a.behavior)}}var Uv=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",default:sd});const zv={alt:"string",size:"SpinnerSize",title:"string"},qv=V(I({},q),{alt:T.exports.string,size:Se(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=J(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:zv,propTypes:qv,displayName:"SpsSpinner"});const Jv=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 Zv(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 D,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":D=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":D=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")&&(D=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[D,S,w,E]}function Ka(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(),[D]=n.split(" ");let S=n;a&&(D==="top"&&C.top-v.height<Jv||D==="right"&&C.right+v.width>f||D==="bottom"&&C.bottom+v.height>u||D==="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]=Zv(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 Mt=$.createContext(null);function ma(e,t=[]){const n=$.useContext(Mt);return $.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 Xv={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: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}},Qv={hideInlineSearch:T.exports.bool,onSearchChange:re(),search:T.exports.string,searchDebounce:T.exports.number,searchPlaceholder:T.exports.string,searchInputRef:Zt()},ey=V(I(I(I({},q),Xv.propTypes),Qv),{attachTo:Zt().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(Se(M.Position)),selectedOption:T.exports.any,specialAction:re(),ignoreWidthStyles:T.exports.bool,loading:T.exports.bool,filterByTextAndCaptionKey:T.exports.bool,disableOptionsMemoization: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 ty(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"||e.disableOptionsMemoization)&&(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 Kn{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 ny(e,t){return I(I({},e),t)}function Xt(e){return $.useReducer(ny,e)}function ay({hideInlineSearch:e,options:t,onSearchChange:n,search:a="",searchPlaceholder:r="Search\u2026",searchInputRef:i}){const[l,c]=Xt({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 Kn(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 sy=sd||Uv,ry=["Tab","Escape","Enter","Up","ArrowUp","Down","ArrowDown"],oy=["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 iy(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 Va=s.forwardRef((e,t)=>{const pt=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:D,className:S,conformWidth:w,id:E,ignoreWidthStyles:y,isOpen:N,keepOpen:_,keyDown:R,nullOption:O,onOptionListChanged:B,onOptionSelected:F,onPositionFlip:P,onSelfToggle:G,optionRole:K,positionOverride:W,selectedOption:Z,specialAction:ee,unsafelyReplaceClassName:ce,loading:ie,filterByTextAndCaptionKey:pe,maxHeightPx:j,maxHeightRem:X,disableOptionsMemoization:Q,"data-testid":se}=pt,ae=J(pt,["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"]),ne=s.useMemo(()=>ee?new M.SpsOptionListOption(ee,{textKey:"label",captionKey:"caption"}):null,[ee]),[U,Ne]=s.useState(-1),[_e,Pe]=s.useState(N),be=t||s.useRef(null),qe=s.useRef(null),He=s.useRef(null),Qe=ma("sps-option-list-portal"),Xe=s.useContext(Mt),[et,yt]=W||[M.Position.BOTTOM_LEFT,M.Position.TOP_LEFT],[bt,tt]=_e?Ka(be,D,et,I({altPosition:yt,setMinWidth:!y,setWidth:!y&&w},Xe)):[{},!1],ve=s.useRef(null),[Te,ke,We]=ay(V(I({},e),{searchInputRef:ve})),[Re,Gt]=ty(e,ke,We);s.useEffect(()=>{Ne(-1)},[ke]);const vn=A(ce||"sps-option-list","z-stratum-dropdown",_e&&"sps-option-list--open",ke.isAsync&&"sps-option-list--searchable",tt&&"sps-option-list--opens-upward",ee&&ee.label&&"sps-option-list--has-special-action",S),at=A(ce||"sps-option-list__options",l&&"sps-option-list__options--tall"),yn=s.useCallback(()=>{_e||(Pe(!0),ve.current&&ve.current.focus(),Ne(-1),G&&G(!0))},[_e,G]),xt=s.useCallback(()=>{_e&&(Pe(!1),Ne(-1),G&&G(!1))},[_e,G]),st=s.useCallback((ye,Ce)=>{Ce||ye&&!ye.disabled&&(typeof ye.value=="function"?ye.value():typeof F=="function"&&F(ye.value),_||xt())},[F,xt]),Ee=s.useCallback((ye,Ce,ot)=>{ye.stopPropagation(),st(Ce,ot)},[st]),It=s.useRef(r||[]);It.current=r||[];const Tn=s.useCallback(ye=>{switch(ye.key){case"Tab":case"Escape":xt();break;case"Enter":if(U>-1){const Ce=Re[U]||ne;ye.preventDefault();const ot=!!Ce&&id(It.current,a,Ce);!ot&&Ce&&typeof F=="function"&&typeof Ce.value=="function"?Ce.value():Ce&&st(Ce,ot)}break;case"Up":case"ArrowUp":{let Ce=U;tt?U<=-1?Ce=Re.length-1:U===0?ee&&(Ce=Re.length):U<Re.length&&(Ce=U-1):U>-1&&(Ce=U-1),Ce!==U&&(ye.preventDefault(),Ne(Ce));break}case"Down":case"ArrowDown":{yn();let Ce=U;tt?U!==-1&&(U>=Re.length?Ce=0:U===Re.length-1?Ce=-1:Ce=U+1):U<Re.length-1+Number(!!ee)&&(Ce=U+1),Ce!==U&&(ye.preventDefault(),Ne(Ce));break}default:yn()}},[xt,yn,U,st,F,tt,Re]),Xn=s.useCallback(ye=>{const Ce=Re.findIndex(ot=>{if(ot.textKey){const Le=ot.textKey;return ot.value[Le].toLowerCase().charAt([0])===ye.key.toLocaleLowerCase()}return ot.value.toLowerCase().charAt([0])===ye.key.toLocaleLowerCase()});Ce>-1&&Ne(Ce)},[Re]),Na=s.useCallback(ye=>{!ye||(ry.includes(ye.key)?Tn(ye):oy.includes(ye.key)&&Xn(ye))},[xt,yn,U,st,F,tt,Re]);s.useEffect(()=>{if(Xe!==null&&document.getElementsByClassName("sps-modal__body").length>0){const ye=()=>{G(!1)},Ce=document.getElementsByClassName("sps-modal__body")[0];return Ce.addEventListener("scroll",ye),()=>{Ce.removeEventListener("scroll",ye)}}},[]),s.useEffect(()=>{He.current&&sy(He.current,{scrollMode:"if-needed",block:"nearest",inline:"nearest"})},[U]),s.useEffect(()=>{Pe(N),N?ve.current&&ve.current.focus():Ne(-1)},[N]),s.useEffect(()=>{Na(R)},[R]),s.useEffect(()=>{!_e&&qe.current&&(We({value:""}),qe.current.scrollTop=0),_e&&P&&P(tt)},[_e]);const Qn=j?j/16:X,ea=Qn?{maxHeight:`${Qn}rem`}:{};return Qe(s.createElement("div",I({className:vn,id:E,"aria-activedescendant":U>-1?`${E}-option-${U}`:null,tabIndex:-1,ref:be,style:bt,onMouseLeave:()=>Ne(-1),"data-testid":se},ae),Te,s.createElement("div",{className:at,ref:qe,"data-testid":`${se}-options`,style:ea},!ie&&!ke.pending&&u&&(ke.value||!ke.isAsync)&&Re.length===0&&s.createElement("div",{className:"sps-option-list__zero-state"},u),(ie||ke.pending)&&s.createElement("div",{className:"sps-option-list__loading"},s.createElement(ks,null)),!ie&&!ke.pending&&Re.map((ye,Ce)=>{const ot=`${E}-option-${Ce}`,Le=iy(ye.value,Z,a),Pt=id(It.current,a,ye);return s.createElement("a",{key:ot,id:ot,role:K,"aria-selected":Le,href:ye.href,className:A("sps-option-list__option",ye.caption&&"sps-option-list__option--has-caption",ye.disabled&&"sps-option-list__option--disabled",ye.bold&&"sps-option-list__option--bold",(Le||Pt)&&"sps-option-list__option--selected",U===Ce&&"sps-option-list__option--highlighted"),onClick:ta=>Ee(ta,ye,Pt),onMouseOver:()=>Ne(Ce),tabIndex:-1,ref:U===Ce?He:null,"data-testid":`${se}-option-${Ce}`},ye.value&&ye.value.icon&&s.createElement("i",{className:A("sps-icon","sps-option-list__option-icon",`sps-icon-${String(ye.value.icon)}`)}),(!ye.value||!ye.value.icon&&Gt)&&s.createElement("span",{className:"sps-option-list__option-icon-spacer"}),s.createElement("span",{dangerouslySetInnerHTML:{__html:ye.getHtml(ke.replacementPattern)}}),ye.caption&&s.createElement("div",{className:"sps-option-list__option-caption"},s.createElement("span",{dangerouslySetInnerHTML:{__html:ye.caption.replace(ke.replacementPattern,"<u>$&</u>")}})))})),ne&&ee.label&&s.createElement("a",{className:A("sps-option-list__option","sps-option-list__special-action",U===Re.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:ye=>Ee(ye,ne),onMouseOver:()=>Ne(Re.length),"data-testid":`${se}-special-action`},ee.icon&&s.createElement("i",{className:A("sps-icon","sps-option-list__option-icon",`sps-icon-${String(ee.icon)}`)}),!ee.icon&&Gt&&s.createElement("span",{className:"sps-option-list__option-icon-spacer"}),s.createElement("span",null,ee.label))))});Object.assign(Va,{propTypes:ey,displayName:"SpsOptionList"});function ly(e,t,n=[]){return s.useMemo(()=>r=>s.createElement(e,I({},I(I({},r),t)),r.children),n)}const ld=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,I({},a!=null?a:{}),s.createElement(ld,{elements:t.slice(1)},e))},cd=function(a){var r=a,{children:e,providers:t=[]}=r,n=J(r,["children","providers"]);return s.createElement("div",I({},n),s.createElement(ld,{elements:t},e))},cy=function(a){var r=a,{children:e,className:t}=r,n=J(r,["children","className"]);return s.createElement(cd,I({className:`sps-app ${t}`},n),e)};function Ht(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 dd(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 pd(e,t){const n=$.useRef(!1);$.useEffect(()=>{if(n.current)return e();n.current=!0},t)}function ud(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 dy(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 $a(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 ud("mousedown",dy,[e,t,c]),{showPopup:r,doShowPopup:l,doHidePopup:c}}const py={debounce:"number",disabled:"boolean",formMeta:"SpsFormFieldMeta<string>",icon:"SpsIcon",onChange:"React.ChangeEventHandler",placeholder:"string",suggestions:{type:`
|
|
196
|
+
`}}}};var vv=self.crypto||self.msCrypto,mo="-_",xn=36;for(;xn--;)mo+=xn.toString(36);xn=36;for(;xn---10;)mo+=xn.toString(36).toUpperCase();var yv=function(e){var t="",n=vv.getRandomValues(new Uint8Array(e||21));for(xn=e||21;xn--;)t+=mo[n[xn]&63];return t},Dn=yv;function da(e){return $.useRef(e||Dn())}function Vt(e,t){const n=da(e),a=$.useRef(`${n.current}_ctrl`);return $.useEffect(()=>{t&&(t.id=a.current,t.update())},[t]),{wrapperId:n.current,controlId:a.current}}var Tv="[object Object]";function wv(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch{}return t}function Cv(e,t){return function(n){return e(t(n))}}var Ev=Function.prototype,Wc=Object.prototype,jc=Ev.toString,xv=Wc.hasOwnProperty,Dv=jc.call(Object),kv=Wc.toString,Nv=Cv(Object.getPrototypeOf,Object);function Iv(e){return!!e&&typeof e=="object"}function _v(e){if(!Iv(e)||kv.call(e)!=Tv||wv(e))return!1;var t=Nv(e);if(t===null)return!0;var n=xv.call(t,"constructor")&&t.constructor;return typeof n=="function"&&n instanceof n&&jc.call(n)==Dv}var Yc=_v;const $t=new Set,pa=new Set,un=new Set,Pa=new Set;function Gc(e){$t.has(e)||un.has(e)||Pa.has(e)||pa.add(e)}function Uc(e){$t.has(e)||un.has(e)||pa.has(e)||Pa.add(e)}const fo=zt.default||zt,ws="MM/DD/YYYY",Mv=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/,zc=Symbol("Date Parse Error");function ua(e){return e.year*1e4+e.month*100+e.date}const fe=Object.freeze({createFrom(e){if(!e)return null;if(typeof e=="string"){const t=Mv.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(fe.createFrom):null},isValid(e){return e&&typeof e=="object"&&typeof e.year=="number"&&typeof e.month=="number"&&typeof e.date=="number"&&fe.toMoment(e).isValid()},nullifyInvalidDate(e){return fe.isValid(e)?e:null},toMoment(e){return e?fo(V(I({},e),{month:e.month-1})):null},toString(e){const t=fe.toMoment(e);return t?t.format(ws):""},toStringRange(e){return e?e.map(fe.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:ua(e)>ua(t)},isBefore(e,t){return!e||!t?null:ua(e)<ua(t)},isInRange(e,t,n=!0){if(!e||!t||!t[0]||!t[1])return null;const a=ua(e),[r,i]=t.map(ua);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[fe.createFrom(n),fe.createFrom(t)]}}),Aa=function(t){if(Array.isArray(t)){const n=Aa(t[0]),a=Aa(t[1]);return n||a}if(t&&t.hasOwnProperty("year")){if(t[zc])return{dateFormat:ws};if(!fe.isValid(t))return{dateValidity:!0}}return null};$t.add("dateFormat");$t.add("dateValidity");const qc=function(t){if(Array.isArray(t)){const n=Aa(t);if(n)return n;if(t&&fe.isBefore(t[1],t[0]))return{dateRangeOrder:!0}}return null};$t.add("dateRangeOrder");const Jc=function({minDate:t,maxDate:n}){function a(r){const i=fe.isBefore(r,t),l=fe.isAfter(r,n),c={minExceeded:i?fe.toString(t):null,maxExceeded:l?fe.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}};$t.add("dateConstraint");var Ov=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",date:Aa,dateRange:qc,dateConstraint:Jc});const Rv=function(t){return function(a){return Number(a)>=t?null:{min:t}}};$t.add("min");const Lv=function(t){return n=>Number(n)<=t?null:{max:t}};pa.add("max");const Bv=function(t){return typeof t=="undefined"||t===null||t===""||Number.isNaN(t)||(t==null?void 0:t.length)===0?{required:!0}:null};pa.add("required");const Pv=function(t){return function(a){return a.length>=t?null:{minLength:t}}};$t.add("minLength");const Av=function(t){return function(a){return a.length<=t?null:{maxLength:t}}};un.add("maxLength");const Fv=function(t){const n=t instanceof RegExp?t:new RegExp(t);return function(r){return n.test(r)?null:{pattern:t}}};$t.add("pattern");const Kv=function(t){return/^[A-Za-z]*$/.test(t)?null:{alpha:!0}};un.add("alpha");const Vv=function(t){return/^[0-9,. ]*$/.test(t)?null:{numeric:!0}};un.add("numeric");const $v=function(t){return/^[^0-9]*$/.test(t)?null:{nonNumeric:!0}};un.add("nonNumeric");const Cs=Object.freeze(V(I({},Ov),{min:Rv,max:Lv,required:Bv,minLength:Pv,maxLength:Av,pattern:Fv,alpha:Kv,numeric:Vv,nonNumeric:$v,OnBlurErrorKeys:$t}));function Fa(e,t=[]){const n=t.reduce((a,r)=>Object.assign(a,r(e)||{}),{});return Object.keys(n).length?n:null}class An{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=Fa(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=>Pa.has(t))||this.revealAllErrors&&Object.keys(this.errors).some(t=>Pa.has(t))&&this.isSubmitted()||!this.isPristine()&&Object.keys(this.errors).some(t=>pa.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 Fn extends An{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=Fa(t,this.validators);if(n&&Object.keys(n).filter(r=>un.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 Fn{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 An?(e.path=t,e.update=n,e):Array.isArray(e)?new Xc(e,t,n):Yc(e)?new Zc(e,t,n):new Fn(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=Fa(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 Hv(e){if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError("The initial value of useSpsForm() hook must be an object.")}function Wv(e,t){Hv(e);const n=$.useMemo(()=>{x.deepFreeze(e);const f=xs(e,[],p);return t&&So(e,f,t,!0),f},[]),a=$.useRef();let r=t;const i=$.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:D,parentPath:S,objects:[w,E]}of v){const y=ho(f.formMeta,S);if(typeof D!="symbol"&&y)switch(C){case x.DiffChange.ADDITION:y.fields[D]=xs(E[D],[...S,D],p);break;case x.DiffChange.DELETION:Array.isArray(y.fields)?y.fields.splice(Number(D),1):delete y.fields[D];break;case x.DiffChange.ALTERATION:if(!w[D]&&E[D]&&!(y.fields[D]instanceof Es)){const N=xs(E[D],[...S,D],p);N instanceof Fn&&y.fields[D]instanceof Fn&&(N.id=y.fields[D].id,N.focused=y.fields[D].focused,N.pristine=y.fields[D].pristine),y.fields[D]=N}break}}if(r){So(g,f.formMeta,r);const C=new Set;Qc(f.formMeta,t,(D,S)=>{typeof S=="function"&&(D.validate(x.getPath(g,D.path)),C.add(D))});for(const{type:D,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(D===x.DiffChange.ADDITION||D===x.DiffChange.ALTERATION){const _=y.fields[S];if(!C.has(_)&&(y.fields[S].validate(E[S]),D===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]=$.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 $.useEffect(()=>()=>{a.current&&window.clearTimeout(a.current)},[]),l}const jv=V(I({},q),{focusInputOnClick:T.exports.bool,formMeta:de(),formControl:de(),inputRef:Zt()}),wt=s.forwardRef((e,t)=>{const E=e,{className:n,children:a,focusInputOnClick:r,formControl:i,formMeta:l,inputRef:c,onClick:p}=E,u=J(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 Fn&&l.markAsFocused()}function D(){g&&g!==t&&g.current&&l&&l instanceof Fn&&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.useEffect(()=>{function y(N){N.target.classList.contains("sps-form-control__clear-btn")&&N.preventDefault()}return document.addEventListener("mousedown",y),()=>{document.removeEventListener("mousedown",y)}},[]),s.createElement("div",V(I({},u),{className:S,ref:t,tabIndex:-1,onClick:w,onFocus:C,onBlur:D}),a)});Object.assign(wt,{spsFormComponentWrapperPropTypes:jv,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(qe){return qe!==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,D=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 G=f[P],K=G.getBoundingClientRect(),W=K.height,Z=K.width,ee=K.top,ce=K.right,ie=K.bottom,pe=K.left;if(a==="if-needed"&&y>=0&&R>=0&&_<=v&&N<=g&&y>=ee&&_<=ie&&R>=pe&&N<=ce)return F;var j=getComputedStyle(G),X=parseInt(j.borderLeftWidth,10),Q=parseInt(j.borderTopWidth,10),se=parseInt(j.borderRightWidth,10),ae=parseInt(j.borderBottomWidth,10),ne=0,U=0,Ne="offsetWidth"in G?G.offsetWidth-G.clientWidth-X-se:0,_e="offsetHeight"in G?G.offsetHeight-G.clientHeight-Q-ae:0;if(u===G)ne=r==="start"?O:r==="end"?O-v:r==="nearest"?Ds(D,D+v,v,Q,ae,D+O,D+O+w,w):O-v/2,U=i==="start"?B:i==="center"?B-g/2:i==="end"?B-g:Ds(C,C+g,g,X,se,C+B,C+B+E,E),ne=Math.max(0,ne+D),U=Math.max(0,U+C);else{ne=r==="start"?O-ee-Q:r==="end"?O-ie+ae+_e:r==="nearest"?Ds(ee,ie,W,Q,ae+_e,O,O+w,w):O-(ee+W/2)+_e/2,U=i==="start"?B-pe-X:i==="center"?B-(pe+Z/2)+Ne/2:i==="end"?B-ce+se+Ne:Ds(pe,ce,Z,X,se+Ne,B,B+E,E);var Pe=G.scrollLeft,be=G.scrollTop;O+=be-(ne=Math.max(0,Math.min(be+ne,G.scrollHeight-W+_e))),B+=Pe-(U=Math.max(0,Math.min(Pe+U,G.scrollWidth-Z+Ne)))}F.push({el:G,top:ne,left:U})}return F}function ad(e){return e===Object(e)&&Object.keys(e).length!==0}function Yv(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 Gv(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=Gv(t);return Yv(nd(e,a),a.behavior)}}var Uv=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",default:sd});const zv={alt:"string",size:"SpinnerSize",title:"string"},qv=V(I({},q),{alt:T.exports.string,size:Se(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=J(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:zv,propTypes:qv,displayName:"SpsSpinner"});const Jv=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 Zv(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 D,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":D=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":D=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")&&(D=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[D,S,w,E]}function Ka(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(),[D]=n.split(" ");let S=n;a&&(D==="top"&&C.top-v.height<Jv||D==="right"&&C.right+v.width>f||D==="bottom"&&C.bottom+v.height>u||D==="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]=Zv(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 Mt=$.createContext(null);function ma(e,t=[]){const n=$.useContext(Mt);return $.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 Xv={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: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}},Qv={hideInlineSearch:T.exports.bool,onSearchChange:re(),search:T.exports.string,searchDebounce:T.exports.number,searchPlaceholder:T.exports.string,searchInputRef:Zt()},ey=V(I(I(I({},q),Xv.propTypes),Qv),{attachTo:Zt().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(Se(M.Position)),selectedOption:T.exports.any,specialAction:re(),ignoreWidthStyles:T.exports.bool,loading:T.exports.bool,filterByTextAndCaptionKey:T.exports.bool,disableOptionsMemoization: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 ty(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"||e.disableOptionsMemoization)&&(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 Kn{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 ny(e,t){return I(I({},e),t)}function Xt(e){return $.useReducer(ny,e)}function ay({hideInlineSearch:e,options:t,onSearchChange:n,search:a="",searchPlaceholder:r="Search\u2026",searchInputRef:i}){const[l,c]=Xt({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 Kn(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 sy=sd||Uv,ry=["Tab","Escape","Enter","Up","ArrowUp","Down","ArrowDown"],oy=["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 iy(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 Va=s.forwardRef((e,t)=>{const pt=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:D,className:S,conformWidth:w,id:E,ignoreWidthStyles:y,isOpen:N,keepOpen:_,keyDown:R,nullOption:O,onOptionListChanged:B,onOptionSelected:F,onPositionFlip:P,onSelfToggle:G,optionRole:K,positionOverride:W,selectedOption:Z,specialAction:ee,unsafelyReplaceClassName:ce,loading:ie,filterByTextAndCaptionKey:pe,maxHeightPx:j,maxHeightRem:X,disableOptionsMemoization:Q,"data-testid":se}=pt,ae=J(pt,["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"]),ne=s.useMemo(()=>ee?new M.SpsOptionListOption(ee,{textKey:"label",captionKey:"caption"}):null,[ee]),[U,Ne]=s.useState(-1),[_e,Pe]=s.useState(N),be=t||s.useRef(null),qe=s.useRef(null),He=s.useRef(null),Qe=ma("sps-option-list-portal"),Xe=s.useContext(Mt),[et,yt]=W||[M.Position.BOTTOM_LEFT,M.Position.TOP_LEFT],[bt,tt]=_e?Ka(be,D,et,I({altPosition:yt,setMinWidth:!y,setWidth:!y&&w},Xe)):[{},!1],ve=s.useRef(null),[Te,ke,We]=ay(V(I({},e),{searchInputRef:ve})),[Re,Gt]=ty(e,ke,We);s.useEffect(()=>{Ne(-1)},[ke]);const vn=A(ce||"sps-option-list","z-stratum-dropdown",_e&&"sps-option-list--open",ke.isAsync&&"sps-option-list--searchable",tt&&"sps-option-list--opens-upward",ee&&ee.label&&"sps-option-list--has-special-action",S),at=A(ce||"sps-option-list__options",l&&"sps-option-list__options--tall"),yn=s.useCallback(()=>{_e||(Pe(!0),ve.current&&ve.current.focus(),Ne(-1),G&&G(!0))},[_e,G]),xt=s.useCallback(()=>{_e&&(Pe(!1),Ne(-1),G&&G(!1))},[_e,G]),st=s.useCallback((ye,Ce)=>{Ce||ye&&!ye.disabled&&(typeof ye.value=="function"?ye.value():typeof F=="function"&&F(ye.value),_||xt())},[F,xt]),Ee=s.useCallback((ye,Ce,ot)=>{ye.stopPropagation(),st(Ce,ot)},[st]),It=s.useRef(r||[]);It.current=r||[];const Tn=s.useCallback(ye=>{switch(ye.key){case"Tab":case"Escape":xt();break;case"Enter":if(U>-1){const Ce=Re[U]||ne;ye.preventDefault();const ot=!!Ce&&id(It.current,a,Ce);!ot&&Ce&&typeof F=="function"&&typeof Ce.value=="function"?Ce.value():Ce&&st(Ce,ot)}break;case"Up":case"ArrowUp":{let Ce=U;tt?U<=-1?Ce=Re.length-1:U===0?ee&&(Ce=Re.length):U<Re.length&&(Ce=U-1):U>-1&&(Ce=U-1),Ce!==U&&(ye.preventDefault(),Ne(Ce));break}case"Down":case"ArrowDown":{yn();let Ce=U;tt?U!==-1&&(U>=Re.length?Ce=0:U===Re.length-1?Ce=-1:Ce=U+1):U<Re.length-1+Number(!!ee)&&(Ce=U+1),Ce!==U&&(ye.preventDefault(),Ne(Ce));break}default:yn()}},[xt,yn,U,st,F,tt,Re]),Xn=s.useCallback(ye=>{const Ce=Re.findIndex(ot=>{if(ot.textKey){const Le=ot.textKey;return ot.value[Le].toLowerCase().charAt([0])===ye.key.toLocaleLowerCase()}return ot.value.toLowerCase().charAt([0])===ye.key.toLocaleLowerCase()});Ce>-1&&Ne(Ce)},[Re]),Na=s.useCallback(ye=>{!ye||(ry.includes(ye.key)?Tn(ye):oy.includes(ye.key)&&Xn(ye))},[xt,yn,U,st,F,tt,Re]);s.useEffect(()=>{if(Xe!==null&&document.getElementsByClassName("sps-modal__body").length>0){const ye=()=>{G(!1)},Ce=document.getElementsByClassName("sps-modal__body")[0];return Ce.addEventListener("scroll",ye),()=>{Ce.removeEventListener("scroll",ye)}}},[]),s.useEffect(()=>{He.current&&sy(He.current,{scrollMode:"if-needed",block:"nearest",inline:"nearest"})},[U]),s.useEffect(()=>{Pe(N),N?ve.current&&ve.current.focus():Ne(-1)},[N]),s.useEffect(()=>{Na(R)},[R]),s.useEffect(()=>{!_e&&qe.current&&(We({value:""}),qe.current.scrollTop=0),_e&&P&&P(tt)},[_e]);const Qn=j?j/16:X,ea=Qn?{maxHeight:`${Qn}rem`}:{};return Qe(s.createElement("div",I({className:vn,id:E,"aria-activedescendant":U>-1?`${E}-option-${U}`:null,tabIndex:-1,ref:be,style:bt,onMouseLeave:()=>Ne(-1),"data-testid":se},ae),Te,s.createElement("div",{className:at,ref:qe,"data-testid":`${se}-options`,style:ea},!ie&&!ke.pending&&u&&(ke.value||!ke.isAsync)&&Re.length===0&&s.createElement("div",{className:"sps-option-list__zero-state"},u),(ie||ke.pending)&&s.createElement("div",{className:"sps-option-list__loading"},s.createElement(ks,null)),!ie&&!ke.pending&&Re.map((ye,Ce)=>{const ot=`${E}-option-${Ce}`,Le=iy(ye.value,Z,a),Pt=id(It.current,a,ye);return s.createElement("a",{key:ot,id:ot,role:K,"aria-selected":Le,href:ye.href,className:A("sps-option-list__option",ye.caption&&"sps-option-list__option--has-caption",ye.disabled&&"sps-option-list__option--disabled",ye.bold&&"sps-option-list__option--bold",(Le||Pt)&&"sps-option-list__option--selected",U===Ce&&"sps-option-list__option--highlighted"),onClick:ta=>Ee(ta,ye,Pt),onMouseOver:()=>Ne(Ce),tabIndex:-1,ref:U===Ce?He:null,"data-testid":`${se}-option-${Ce}`},ye.value&&ye.value.icon&&s.createElement("i",{className:A("sps-icon","sps-option-list__option-icon",`sps-icon-${String(ye.value.icon)}`)}),(!ye.value||!ye.value.icon&&Gt)&&s.createElement("span",{className:"sps-option-list__option-icon-spacer"}),s.createElement("span",{dangerouslySetInnerHTML:{__html:ye.getHtml(ke.replacementPattern)}}),ye.caption&&s.createElement("div",{className:"sps-option-list__option-caption"},s.createElement("span",{dangerouslySetInnerHTML:{__html:ye.caption.replace(ke.replacementPattern,"<u>$&</u>")}})))})),ne&&ee.label&&s.createElement("a",{className:A("sps-option-list__option","sps-option-list__special-action",U===Re.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:ye=>Ee(ye,ne),onMouseOver:()=>Ne(Re.length),"data-testid":`${se}-special-action`},ee.icon&&s.createElement("i",{className:A("sps-icon","sps-option-list__option-icon",`sps-icon-${String(ee.icon)}`)}),!ee.icon&&Gt&&s.createElement("span",{className:"sps-option-list__option-icon-spacer"}),s.createElement("span",null,ee.label))))});Object.assign(Va,{propTypes:ey,displayName:"SpsOptionList"});function ly(e,t,n=[]){return s.useMemo(()=>r=>s.createElement(e,I({},I(I({},r),t)),r.children),n)}const ld=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,I({},a!=null?a:{}),s.createElement(ld,{elements:t.slice(1)},e))},cd=function(a){var r=a,{children:e,providers:t=[]}=r,n=J(r,["children","providers"]);return s.createElement("div",I({},n),s.createElement(ld,{elements:t},e))},cy=function(a){var r=a,{children:e,className:t}=r,n=J(r,["children","className"]);return s.createElement(cd,I({className:`sps-app ${t}`},n),e)};function Ht(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 dd(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 pd(e,t){const n=$.useRef(!1);$.useEffect(()=>{if(n.current)return e();n.current=!0},t)}function ud(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 dy(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 $a(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 ud("mousedown",dy,[e,t,c]),{showPopup:r,doShowPopup:l,doHidePopup:c}}const py={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"},uy=V(I({},q),{debounce:T.exports.number,disabled:T.exports.bool,formControl:de(),formMeta:de(),icon:Se(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,disableOptionsMemoization:T.exports.bool});function Is(N){var _=N,{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:D,maxHeightOptionListRem:S,disableOptionsMemoization:w,"data-testid":E}=_,y=J(_,["className","debounce","disabled","formControl","formMeta","onChange","icon","id","placeholder","suggestions","unsafelyReplaceClassName","tallOptionList","value","zeroState","loading","maxHeightOptionListPx","maxHeightOptionListRem","disableOptionsMemoization","data-testid"]);const R=r||a,{wrapperId:O,controlId:B}=Vt(c,R),[F,P]=Xt({keyDown:null,opensUpward:!1}),G=s.useRef(),K=s.useRef(),W=s.useRef(),{showPopup:Z,doShowPopup:ee,doHidePopup:ce}=$a(G,W);function ie(ne,U){R&&(R.setValue(ne),R.markAsDirty()),i&&i(U||new Kn({value:ne}))}function pe(ne){K.current.value="",ie(""),ne.stopPropagation()}function j(ne){ie(ne.target.value,ne)}function X(ne){n||(["Up","ArrowUp","Down","ArrowDown","Enter"].indexOf(ne.key)>-1&&(ne.preventDefault(),ne.persist()),ne.stopPropagation(),P({keyDown:ne})),ne.key==="Tab"&&ce()}function Q(ne){ne?ee():ce()}function se(ne){P({opensUpward:ne})}const ae=A(f||"sps-autocomplete",Z&&"sps-autocomplete--open",Z&&"z-stratum-dropdown",F.opensUpward&&"sps-autocomplete--opens-upward",n&&"sps-form-control--disabled",e);return s.createElement(wt,{id:O,className:ae,formControl:a,formMeta:r,inputRef:K,ref:G,focusInputOnClick:!0,onClick:ne=>ne.nativeEvent.stopImmediatePropagation(),"data-testId":`${E}`},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:K,value:g,className:"sps-text-input__input",placeholder:p,onFocus:ee,onClick:ee,onChange:j,onKeyDown:X,disabled:n,id:B,"data-testid":`${E}__input`},y)),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(Va,{id:`${O}_options`,ref:W,attachTo:G,isOpen:Z,options:u,hideInlineSearch:!0,keyDown:F.keyDown,onOptionSelected:ie,onPositionFlip:se,onSelfToggle:Q,offsets:[1,0],search:g,searchDebounce:t,tall:m,zeroState:v,loading:C,maxHeightPx:D,maxHeightRem:S,disableOptionsMemoization:w}))}Object.assign(Is,{props:py,propTypes:uy,displayName:"SpsAutocomplete"});const md={basic:{label:"Basic",examples:{basic:{react:x.code`
|
package/lib/index.es.js
CHANGED
|
@@ -1419,6 +1419,17 @@ const SpsFormComponentWrapper = React.forwardRef((props2, ref2) => {
|
|
|
1419
1419
|
onClick(event);
|
|
1420
1420
|
}
|
|
1421
1421
|
}
|
|
1422
|
+
React.useEffect(() => {
|
|
1423
|
+
function handleMouseDown(e2) {
|
|
1424
|
+
if (e2.target.classList.contains("sps-form-control__clear-btn")) {
|
|
1425
|
+
e2.preventDefault();
|
|
1426
|
+
}
|
|
1427
|
+
}
|
|
1428
|
+
document.addEventListener("mousedown", handleMouseDown);
|
|
1429
|
+
return () => {
|
|
1430
|
+
document.removeEventListener("mousedown", handleMouseDown);
|
|
1431
|
+
};
|
|
1432
|
+
}, []);
|
|
1422
1433
|
return /* @__PURE__ */ React.createElement("div", __spreadProps(__spreadValues({}, rest), {
|
|
1423
1434
|
className: classes,
|
|
1424
1435
|
ref: ref2,
|
package/lib/utils/bindProps.d.ts
CHANGED
|
@@ -2,8 +2,7 @@ import * as React from "react";
|
|
|
2
2
|
/**
|
|
3
3
|
* takes in an ElementType (e.g. a React component) and
|
|
4
4
|
* returns a new version of that component where certain
|
|
5
|
-
* props are ALWAYS set to predefined values
|
|
6
|
-
* what is passed in.
|
|
5
|
+
* props are ALWAYS set to predefined values.
|
|
7
6
|
*
|
|
8
7
|
* for example, consider the following component:
|
|
9
8
|
* const Foo: React.FC<{
|
|
@@ -22,12 +21,13 @@ import * as React from "react";
|
|
|
22
21
|
* But if you bind the prop a...
|
|
23
22
|
* const FooWithBoundA = bindProps(Foo, { a: "parakeet" });
|
|
24
23
|
*
|
|
25
|
-
* then <FooWithBoundA
|
|
24
|
+
* then <FooWithBoundA b="cat"/> will produce <span>a is parakeet and b is cat</span>
|
|
26
25
|
*
|
|
27
|
-
* The type of the props is the same,
|
|
28
|
-
*
|
|
26
|
+
* The type of the props is the same, except that prop a is pre-set and so no
|
|
27
|
+
* longer something that can be passed in.
|
|
29
28
|
*
|
|
30
29
|
* This was created to be used with <Provide> (see Provide.tsx in this same directory),
|
|
31
30
|
* but may have other use cases.
|
|
32
31
|
*/
|
|
33
|
-
export declare
|
|
32
|
+
export declare type BoundFC<T extends React.ElementType, K extends Partial<React.ComponentProps<T>>> = React.FC<Omit<React.ComponentProps<T>, keyof K>>;
|
|
33
|
+
export declare function bindProps<T extends React.ElementType, K extends Partial<React.ComponentProps<T>>>(E: T, boundProps: K, deps?: unknown[]): BoundFC<T, K>;
|
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.33.
|
|
4
|
+
"version": "5.33.8",
|
|
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.33.
|
|
32
|
-
"@spscommerce/ds-illustrations": "5.33.
|
|
33
|
-
"@spscommerce/ds-shared": "5.33.
|
|
34
|
-
"@spscommerce/positioning": "5.33.
|
|
35
|
-
"@spscommerce/utils": "5.33.
|
|
31
|
+
"@spscommerce/ds-colors": "5.33.8",
|
|
32
|
+
"@spscommerce/ds-illustrations": "5.33.8",
|
|
33
|
+
"@spscommerce/ds-shared": "5.33.8",
|
|
34
|
+
"@spscommerce/positioning": "5.33.8",
|
|
35
|
+
"@spscommerce/utils": "5.33.8",
|
|
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.33.
|
|
44
|
-
"@spscommerce/ds-illustrations": "5.33.
|
|
45
|
-
"@spscommerce/ds-shared": "5.33.
|
|
46
|
-
"@spscommerce/positioning": "5.33.
|
|
47
|
-
"@spscommerce/utils": "5.33.
|
|
43
|
+
"@spscommerce/ds-colors": "5.33.8",
|
|
44
|
+
"@spscommerce/ds-illustrations": "5.33.8",
|
|
45
|
+
"@spscommerce/ds-shared": "5.33.8",
|
|
46
|
+
"@spscommerce/positioning": "5.33.8",
|
|
47
|
+
"@spscommerce/utils": "5.33.8",
|
|
48
48
|
"@testing-library/react": "^9.3.2",
|
|
49
49
|
"@types/prop-types": "^15.7.1",
|
|
50
50
|
"@types/react": "^16.9.0",
|