@spscommerce/ds-react 5.16.0 → 5.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.cjs.js +1 -1
- package/lib/index.es.js +1 -1
- package/package.json +9 -9
package/lib/index.cjs.js
CHANGED
|
@@ -164,7 +164,7 @@
|
|
|
164
164
|
</SpsAdvancedSearch>
|
|
165
165
|
</>;
|
|
166
166
|
}
|
|
167
|
-
`}}}};var hv=self.crypto||self.msCrypto,mo="-_",xn=36;for(;xn--;)mo+=xn.toString(36);xn=36;for(;xn---10;)mo+=xn.toString(36).toUpperCase();var gv=function(e){var t="",n=hv.getRandomValues(new Uint8Array(e||21));for(xn=e||21;xn--;)t+=mo[n[xn]&63];return t},Dn=gv;function la(e){return $.useRef(e||Dn())}function Ft(e,t){const n=la(e),a=$.useRef(`${n.current}_ctrl`);return $.useEffect(()=>{t&&(t.id=a.current,t.update())},[t]),{wrapperId:n.current,controlId:a.current}}var Sv="[object Object]";function bv(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch{}return t}function vv(e,t){return function(n){return e(t(n))}}var yv=Function.prototype,$c=Object.prototype,Hc=yv.toString,Tv=$c.hasOwnProperty,wv=Hc.call(Object),Cv=$c.toString,Ev=vv(Object.getPrototypeOf,Object);function xv(e){return!!e&&typeof e=="object"}function Dv(e){if(!xv(e)||Cv.call(e)!=Sv||bv(e))return!1;var t=Ev(e);if(t===null)return!0;var n=Tv.call(t,"constructor")&&t.constructor;return typeof n=="function"&&n instanceof n&&Hc.call(n)==wv}var Wc=Dv;const Kt=new Set,ca=new Set,mn=new Set,Ba=new Set;function jc(e){Kt.has(e)||mn.has(e)||Ba.has(e)||ca.add(e)}function Yc(e){Kt.has(e)||mn.has(e)||ca.has(e)||Ba.add(e)}const fo=Ut.default||Ut,ws="MM/DD/YYYY",kv=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/,Gc=Symbol("Date Parse Error");function da(e){return e.year*1e4+e.month*100+e.date}const ge=Object.freeze({createFrom(e){if(!e)return null;if(typeof e=="string"){const t=kv.exec(e);if(t){const[,n,a,o]=t;return Object.freeze({year:Number(o),month:Number(n),date:Number(a)})}return Object.freeze({[Gc]:!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(ge.createFrom):null},isValid(e){return e&&typeof e=="object"&&typeof e.year=="number"&&typeof e.month=="number"&&typeof e.date=="number"&&ge.toMoment(e).isValid()},nullifyInvalidDate(e){return ge.isValid(e)?e:null},toMoment(e){return e?fo(H(I({},e),{month:e.month-1})):null},toString(e){const t=ge.toMoment(e);return t?t.format(ws):""},toStringRange(e){return e?e.map(ge.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:da(e)>da(t)},isBefore(e,t){return!e||!t?null:da(e)<da(t)},isInRange(e,t,n=!0){if(!e||!t||!t[0]||!t[1])return null;const a=da(e),[o,i]=t.map(da);return e&&o&&i&&(n&&a>=o&&a<=i||!n&&a>o&&a<i)},prevMonth(e){return Object.freeze({year:e.month===1?e.year-1:e.year,month:e.month-1||12,date:e.date})},nextMonth(e){return Object.freeze({year:e.month===12?e.year+1:e.year,month:e.month+1>12?1:e.month+1,date:e.date})},createRangeFromPreset(e){if(typeof e.definition=="function")return e.definition();const t=fo(),n=t.clone().subtract(fo.duration(e.definition));return[ge.createFrom(n),ge.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[Gc])return{dateFormat:ws};if(!ge.isValid(t))return{dateValidity:!0}}return null};Kt.add("dateFormat");Kt.add("dateValidity");const Uc=function(t){if(Array.isArray(t)){const n=Pa(t);if(n)return n;if(t&&ge.isBefore(t[1],t[0]))return{dateRangeOrder:!0}}return null};Kt.add("dateRangeOrder");const zc=function({minDate:t,maxDate:n}){function a(o){const i=ge.isBefore(o,t),l=ge.isAfter(o,n),c={minExceeded:i?ge.toString(t):null,maxExceeded:l?ge.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 Nv=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",date:Pa,dateRange:Uc,dateConstraint:zc});const Iv=function(t){return function(a){return Number(a)>=t?null:{min:t}}};Kt.add("min");const _v=function(t){return n=>Number(n)<=t?null:{max:t}};ca.add("max");const Mv=function(t){return typeof t=="undefined"||t===null||t===""||Number.isNaN(t)||(t==null?void 0:t.length)===0?{required:!0}:null};ca.add("required");const Ov=function(t){return function(a){return a.length>=t?null:{minLength:t}}};Kt.add("minLength");const Rv=function(t){return function(a){return a.length<=t?null:{maxLength:t}}};mn.add("maxLength");const Lv=function(t){const n=t instanceof RegExp?t:new RegExp(t);return function(o){return n.test(o)?null:{pattern:t}}};Kt.add("pattern");const Bv=function(t){return/^[A-Za-z]*$/.test(t)?null:{alpha:!0}};mn.add("alpha");const Pv=function(t){return/^[0-9,. ]*$/.test(t)?null:{numeric:!0}};mn.add("numeric");const Av=function(t){return/^[^0-9]*$/.test(t)?null:{nonNumeric:!0}};mn.add("nonNumeric");const Cs=Object.freeze(H(I({},Nv),{min:Iv,max:_v,required:Mv,minLength:Ov,maxLength:Rv,pattern:Lv,alpha:Bv,numeric:Pv,nonNumeric:Av,OnBlurErrorKeys:Kt}));function Aa(e,t=[]){const n=t.reduce((a,o)=>Object.assign(a,o(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=>ca.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(o=>mn.has(o)).length>0){this.preventativeErrors=Object.keys(n);return}}this.update(this.path,t)}isPristine(){return this.pristine}markAsPristine(){return this.pristine=!0,this.revealAllErrors=!1,this.update(null),this}markAsDirty(){return this.pristine=!1,this.update(null),this}isFocused(){return this.focused}markAsFocused(){return this.focused=!0,this.update(null),this.onFocus&&this.onFocus(),this}markAsBlurred(){return this.update(this.path,null,!0),this.onBlur&&this.onBlur(),this.preventativeErrors=[],this}markAsSubmitted(){return this.submitted=!0,this.update(null),this}}class Es extends Kn{constructor(t,n,a){const o=a?n:t,i=a||n;super(o,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 qc extends Es{inferMembers(t){this.fields={};for(const n of Object.keys(t))this.fields[n]=this.inferSpsControl(t[n],n)}}class Jc 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 Jc(e,t,n):Wc(e)?new qc(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(o=>e.fields[o]);return t.length===0?a:a.reduce((o,i)=>[...o,...go(i,t)],[])}return go(e.fields[n],t)}function Zc(e,t,n){for(const a of Object.keys(t)){const o=t[a];for(const i of go(e,a.split(".")))i&&o&&n(i,o)}}function So(e,t,n,a=!1){Zc(t,n,(o,i)=>{o.validators=typeof i=="function"?i(e):i,a&&(o.errors=Aa(D.getPath(e,o.path),o.validators))})}function bo(e,t){const n=t[0];return t=t.slice(1),Array.isArray(e)?e.map((a,o)=>o===Number(n)?bo(a,t):a):Wc(e)?Object.keys(e).reduce((a,o)=>Object.assign(a,{[o]:o===n?bo(e[o],t):e[o]}),{}):e}function Fv(e){if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError("The initial value of useSpsForm() hook must be an object.")}function Kv(e,t){Fv(e);const n=$.useMemo(()=>{D.deepFreeze(e);const f=xs(e,[],p);return t&&So(e,f,t,!0),f},[]),a=$.useRef();let o=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(o){const v=m.path.join("."),C=I({},o);C[v]=m.newValidators,o=C,So(f.formValue,f.formMeta,o,!0)}}else g=bo(f.formValue,m.path),D.setPath(g,m.path,m.value);else g=m.value;if(g){D.deepFreeze(g);const v=D.diff(f.formValue,g);for(const{type:C,key:E,parentPath:S,objects:[T,x]}of v){const y=ho(f.formMeta,S);if(typeof E!="symbol"&&y)switch(C){case D.DiffChange.ADDITION:y.fields[E]=xs(x[E],[...S,E],p);break;case D.DiffChange.DELETION:Array.isArray(y.fields)?y.fields.splice(Number(E),1):delete y.fields[E];break;case D.DiffChange.ALTERATION:if(!T[E]&&x[E]&&!(y.fields[E]instanceof Es)){const N=xs(x[E],[...S,E],p);N instanceof Kn&&y.fields[E]instanceof Kn&&(N.id=y.fields[E].id,N.focused=y.fields[E].focused,N.pristine=y.fields[E].pristine),y.fields[E]=N}break}}if(o){So(g,f.formMeta,o);const C=new Set;Zc(f.formMeta,t,(E,S)=>{typeof S=="function"&&(E.validate(D.getPath(g,E.path)),C.add(E))});for(const{type:E,key:S,parentPath:T,objects:[,x]}of v)if(typeof S!="symbol"){let y=f.formMeta,N=g;if(y){for(const _ of T)y=y.fields[_],N=N[_],C.has(y)||y.validate(N);if(E===D.DiffChange.ADDITION||E===D.DiffChange.ALTERATION){const _=y.fields[S];if(!C.has(_)&&(y.fields[S].validate(x[S]),E===D.DiffChange.ADDITION&&_.fields))for(const[R,O]of Object.entries(_.fields))O.validate(x[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 Vv=H(I({},J),{focusInputOnClick:w.exports.bool,formMeta:de(),formControl:de(),inputRef:Jt()}),yt=s.forwardRef((e,t)=>{const x=e,{className:n,children:a,focusInputOnClick:o,formControl:i,formMeta:l,inputRef:c,onClick:p}=x,u=Z(x,["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 E(){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 T(y){o&&v(),p&&p(y)}return s.createElement("div",H(I({},u),{className:S,ref:t,tabIndex:-1,onClick:T,onFocus:C,onBlur:E}),a)});Object.assign(yt,{spsFormComponentWrapperPropTypes:Vv,displayName:"SpsFormComponentWrapper"});function Xc(e){return typeof e=="object"&&e!=null&&e.nodeType===1}function Qc(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 Qc(n.overflowY,t)||Qc(n.overflowX,t)||function(a){var o=function(i){if(!i.ownerDocument||!i.ownerDocument.defaultView)return null;try{return i.ownerDocument.defaultView.frameElement}catch{return null}}(a);return!!o&&(o.clientHeight<a.scrollHeight||o.clientWidth<a.scrollWidth)}(e)}return!1}function Ds(e,t,n,a,o,i,l,c){return i<e&&l>t||i>e&&l<t?0:i<=e&&c<=n||l>=t&&c>=n?i-e-a:l>t&&c<n||i<e&&c>n?l-t+o:0}function ed(e,t){var n=window,a=t.scrollMode,o=t.block,i=t.inline,l=t.boundary,c=t.skipOverflowHiddenElements,p=typeof l=="function"?l:function(ze){return ze!==l};if(!Xc(e))throw new TypeError("Invalid target");for(var u=document.scrollingElement||document.documentElement,f=[],m=e;Xc(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,E=window.scrollY||pageYOffset,S=e.getBoundingClientRect(),T=S.height,x=S.width,y=S.top,N=S.right,_=S.bottom,R=S.left,O=o==="start"||o==="nearest"?y:o==="end"?_:y+T/2,B=i==="center"?R+x/2:i==="end"?N:R,K=[],P=0;P<f.length;P++){var G=f[P],F=G.getBoundingClientRect(),j=F.height,U=F.width,X=F.top,le=F.right,he=F.bottom,ce=F.left;if(a==="if-needed"&&y>=0&&R>=0&&_<=v&&N<=g&&y>=X&&_<=he&&R>=ce&&N<=le)return K;var z=getComputedStyle(G),Q=parseInt(z.borderLeftWidth,10),V=parseInt(z.borderTopWidth,10),se=parseInt(z.borderRightWidth,10),ne=parseInt(z.borderBottomWidth,10),ae=0,ee=0,Ie="offsetWidth"in G?G.offsetWidth-G.clientWidth-Q-se:0,Re="offsetHeight"in G?G.offsetHeight-G.clientHeight-V-ne:0;if(u===G)ae=o==="start"?O:o==="end"?O-v:o==="nearest"?Ds(E,E+v,v,V,ne,E+O,E+O+T,T):O-v/2,ee=i==="start"?B:i==="center"?B-g/2:i==="end"?B-g:Ds(C,C+g,g,Q,se,C+B,C+B+x,x),ae=Math.max(0,ae+E),ee=Math.max(0,ee+C);else{ae=o==="start"?O-X-V:o==="end"?O-he+ne+Re:o==="nearest"?Ds(X,he,j,V,ne+Re,O,O+T,T):O-(X+j/2)+Re/2,ee=i==="start"?B-ce-Q:i==="center"?B-(ce+U/2)+Ie/2:i==="end"?B-le+se+Ie:Ds(ce,le,U,Q,se+Ie,B,B+x,x);var Te=G.scrollLeft,Pe=G.scrollTop;O+=Pe-(ae=Math.max(0,Math.min(Pe+ae,G.scrollHeight-j+Re))),B+=Te-(ee=Math.max(0,Math.min(Te+ee,G.scrollWidth-U+Ie)))}K.push({el:G,top:ae,left:ee})}return K}function td(e){return e===Object(e)&&Object.keys(e).length!==0}function $v(e,t){t===void 0&&(t="auto");var n="scrollBehavior"in document.body.style;e.forEach(function(a){var o=a.el,i=a.top,l=a.left;o.scroll&&n?o.scroll({top:i,left:l,behavior:t}):(o.scrollTop=i,o.scrollLeft=l)})}function Hv(e){return e===!1?{block:"end",inline:"nearest"}:td(e)?e:{block:"start",inline:"nearest"}}function nd(e,t){var n=!e.ownerDocument.documentElement.contains(e);if(td(t)&&typeof t.behavior=="function")return t.behavior(n?[]:ed(e,t));if(!n){var a=Hv(t);return $v(ed(e,a),a.behavior)}}var Wv=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",default:nd});const jv={alt:"string",size:"SpinnerSize",title:"string"},Yv=H(I({},J),{alt:w.exports.string,size:ve(M.SpinnerSize),title:w.exports.string});function ks(e){const m=e,{alt:t,className:n,size:a=M.SpinnerSize.MEDIUM,"data-testid":o,title:i,unsafelyReplaceClassName:l}=m,c=Z(m,["alt","className","size","data-testid","title","unsafelyReplaceClassName"]),{t:p}=s.useContext(je),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":o,title:u},c))}Object.assign(ks,{props:jv,propTypes:Yv,displayName:"SpsSpinner"});const Gv=60;function Ns(e){return typeof e=="undefined"?"inherit":`${e}px`}function ad(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 Uv(e,t,n,a,o,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 E,S,T,x;switch(v){case"top":T=t.height-n.top-f-i[0];break;case"left":S=t.width-n.left-g-i[0];break;case"right":x=n.right+g-i[0];break;case"bottom":E=n.bottom+f-i[0];break;default:throw new Error(`Invalid position ${e}`)}switch(C){case"left":x=n.left+g+i[1];break;case"top":E=n.top+f+i[1];break;case"middle":v==="top"||v==="bottom"?x=n.left+g+n.width/2-o/2+i[1]:(v==="left"||v==="right")&&(E=n.top+f+n.height/2-a.height/2+i[1]);break;case"bottom":T=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[E,S,T,x]}function Fa(e,t,n,{altPosition:a,setMinWidth:o=!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(),[E]=n.split(" ");let S=n;a&&(E==="top"&&C.top-v.height<Gv||E==="right"&&C.right+v.width>f||E==="bottom"&&C.bottom+v.height>u||E==="left"&&C.left-v.width<0)&&(S=a);const T=o?Math.max(C.width,v.width):v.width,x=i?C.width:T,[y,N,_,R]=Uv(S,g,C,v,x,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),o&&(O.minWidth=`${C.width}px`),i&&(O.width=`${C.width}px`),[O,S===a]}return[{},!1]}const It=$.createContext(null);function pa(e,t=[]){const n=$.useContext(It);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 zv={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:w.exports.string,comparisonKey:w.exports.string,disabledOptions:w.exports.arrayOf(w.exports.any),options:w.exports.oneOfType([w.exports.array,w.exports.instanceOf(Promise),re()]).isRequired,tall:w.exports.bool,textKey:w.exports.string,valueKey:w.exports.string,zeroState:w.exports.string,maxHeightPx:w.exports.number,maxHeightRem:w.exports.number}},qv={hideInlineSearch:w.exports.bool,onSearchChange:re(),search:w.exports.string,searchDebounce:w.exports.number,searchPlaceholder:w.exports.string,searchInputRef:Jt()},Jv=H(I(I(I({},J),zv.propTypes),qv),{attachTo:Jt().isRequired,conformWidth:w.exports.bool,id:w.exports.string.isRequired,isOpen:w.exports.bool,keepOpen:w.exports.bool,keyDown:de(),nullOption:w.exports.string,offsets:w.exports.arrayOf(w.exports.number),onOptionListChanged:re(),onOptionSelected:re(),onPositionFlip:re(),onSelfToggle:re(),optionRole:w.exports.string,positionOverride:w.exports.arrayOf(ve(M.Position)),selectedOption:w.exports.any,specialAction:re(),ignoreWidthStyles:w.exports.bool,loading:w.exports.bool,filterByTextAndCaptionKey:w.exports.bool});async function sd(e,t,n,a,o,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),o(u.some(f=>f.value&&!!f.value.icon)),n({pending:!1})}function Zv(e,t,n){const[a,o]=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"?D.debounce(sd,typeof e.searchDebounce!="undefined"?e.searchDebounce:500):sd,[p.current,e.disabledOptions]);return s.useEffect(()=>{u(e,t,n,o,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 Xv(e,t){return I(I({},e),t)}function Zt(e){return $.useReducer(Xv,e)}function Qv({hideInlineSearch:e,options:t,onSearchChange:n,search:a="",searchPlaceholder:o="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:o,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 ey=nd||Wv,ty=["Tab","Escape","Enter","Up","ArrowUp","Down","ArrowDown"],ny=["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 ay(e,t,n){return n?(e&&e[n])===(t&&t[n]):e===t}function rd(e,t,n){return t?!!(e==null?void 0:e.find(a=>{var o;return a[t]&&a[t]===((o=n==null?void 0:n.value)==null?void 0:o[t])})):!1}const Ka=s.forwardRef((e,t)=>{const _n=e,{captionKey:n,comparisonKey:a,disabledOptions:o,options:i,tall:l,textKey:c,valueKey:p,zeroState:u,hideInlineSearch:f,onSearchChange:m,search:g,searchDebounce:v,searchPlaceholder:C,attachTo:E,className:S,conformWidth:T,id:x,ignoreWidthStyles:y,isOpen:N,keepOpen:_,keyDown:R,nullOption:O,onOptionListChanged:B,onOptionSelected:K,onPositionFlip:P,onSelfToggle:G,optionRole:F,positionOverride:j,selectedOption:U,specialAction:X,unsafelyReplaceClassName:le,loading:he,filterByTextAndCaptionKey:ce,maxHeightPx:z,maxHeightRem:Q,"data-testid":V}=_n,se=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(()=>X?new M.SpsOptionListOption(X,{textKey:"label",captionKey:"caption"}):null,[X]),[ae,ee]=s.useState(-1),[Ie,Re]=s.useState(N),Te=t||s.useRef(null),Pe=s.useRef(null),ze=s.useRef(null),Xe=pa("sps-option-list-portal"),Qe=s.useContext(It),[at,He]=j||[M.Position.BOTTOM_LEFT,M.Position.TOP_LEFT],[De,me]=Ie?Fa(Te,E,at,I({altPosition:He,setMinWidth:!y,setWidth:!y&&T},Qe)):[{},!1],Fe=s.useRef(null),[Ct,tt,dt]=Qv(H(I({},e),{searchInputRef:Fe})),[Ne,pt]=Zv(e,tt,dt);s.useEffect(()=>{ee(-1)},[tt]);const nn=A(le||"sps-option-list","z-stratum-dropdown",Ie&&"sps-option-list--open",tt.isAsync&&"sps-option-list--searchable",me&&"sps-option-list--opens-upward",X&&X.label&&"sps-option-list--has-special-action",S),yn=A(le||"sps-option-list__options",l&&"sps-option-list__options--tall"),Ze=s.useCallback(()=>{Ie||(Re(!0),Fe.current&&Fe.current.focus(),ee(-1),G&&G(!0))},[Ie,G]),an=s.useCallback(()=>{Ie&&(Re(!1),ee(-1),G&&G(!1))},[Ie,G]),Et=s.useCallback((ue,Ce)=>{Ce||ue&&!ue.disabled&&(typeof ue.value=="function"?ue.value():typeof K=="function"&&K(ue.value),_||an())},[K,an]),ut=s.useCallback((ue,Ce,st)=>{ue.stopPropagation(),Et(Ce,st)},[Et]),we=s.useRef(o||[]);we.current=o||[];const jt=s.useCallback(ue=>{switch(ue.key){case"Tab":case"Escape":an();break;case"Enter":if(ae>-1){const Ce=Ne[ae]||ne;ue.preventDefault();const st=!!Ce&&rd(we.current,a,Ce);!st&&Ce&&typeof K=="function"&&typeof Ce.value=="function"?Ce.value():Ce&&Et(Ce,st)}break;case"Up":case"ArrowUp":{let Ce=ae;me?ae<=-1?Ce=Ne.length-1:ae===0?X&&(Ce=Ne.length):ae<Ne.length&&(Ce=ae-1):ae>-1&&(Ce=ae-1),Ce!==ae&&(ue.preventDefault(),ee(Ce));break}case"Down":case"ArrowDown":{Ze();let Ce=ae;me?ae!==-1&&(ae>=Ne.length?Ce=0:ae===Ne.length-1?Ce=-1:Ce=ae+1):ae<Ne.length-1+Number(!!X)&&(Ce=ae+1),Ce!==ae&&(ue.preventDefault(),ee(Ce));break}default:Ze()}},[an,Ze,ae,Et,K,me,Ne]),Tn=s.useCallback(ue=>{const Ce=Ne.findIndex(st=>{if(st.textKey){const Lt=st.textKey;return st.value[Lt].toLowerCase().charAt([0])===ue.key.toLocaleLowerCase()}return st.value.toLowerCase().charAt([0])===ue.key.toLocaleLowerCase()});Ce>-1&&ee(Ce)},[Ne]),Xn=s.useCallback(ue=>{!ue||(ty.includes(ue.key)?jt(ue):ny.includes(ue.key)&&Tn(ue))},[an,Ze,ae,Et,K,me,Ne]);s.useEffect(()=>{if(Qe!==null&&document.getElementsByClassName("sps-modal__body").length>0){const ue=()=>{G(!1)},Ce=document.getElementsByClassName("sps-modal__body")[0];return Ce.addEventListener("scroll",ue),()=>{Ce.removeEventListener("scroll",ue)}}},[]),s.useEffect(()=>{ze.current&&ey(ze.current,{scrollMode:"if-needed",block:"nearest",inline:"nearest"})},[ae]),s.useEffect(()=>{Re(N),N?Fe.current&&Fe.current.focus():ee(-1)},[N]),s.useEffect(()=>{Xn(R)},[R]),s.useEffect(()=>{!Ie&&Pe.current&&(dt({value:""}),Pe.current.scrollTop=0),Ie&&P&&P(me)},[Ie]);const Qn=z?z/16:Q,ka=Qn?{maxHeight:`${Qn}rem`}:{};return Xe(s.createElement("div",I({className:nn,id:x,"aria-activedescendant":ae>-1?`${x}-option-${ae}`:null,tabIndex:-1,ref:Te,style:De,onMouseLeave:()=>ee(-1),"data-testid":V},se),Ct,s.createElement("div",{className:yn,ref:Pe,"data-testid":`${V}-options`,style:ka},!he&&!tt.pending&&u&&(tt.value||!tt.isAsync)&&Ne.length===0&&s.createElement("div",{className:"sps-option-list__zero-state"},u),(he||tt.pending)&&s.createElement("div",{className:"sps-option-list__loading"},s.createElement(ks,null)),!he&&!tt.pending&&Ne.map((ue,Ce)=>{const st=`${x}-option-${Ce}`,Lt=ay(ue.value,U,a),Le=rd(we.current,a,ue);return s.createElement("a",{key:st,id:st,role:F,"aria-selected":Lt,href:ue.href,className:A("sps-option-list__option",ue.caption&&"sps-option-list__option--has-caption",ue.disabled&&"sps-option-list__option--disabled",ue.bold&&"sps-option-list__option--bold",(Lt||Le)&&"sps-option-list__option--selected",ae===Ce&&"sps-option-list__option--highlighted"),onClick:Yt=>ut(Yt,ue,Le),onMouseOver:()=>ee(Ce),tabIndex:-1,ref:ae===Ce?ze:null,"data-testid":`${V}-option-${Ce}`},ue.value&&ue.value.icon&&s.createElement("i",{className:A("sps-icon","sps-option-list__option-icon",`sps-icon-${String(ue.value.icon)}`)}),(!ue.value||!ue.value.icon&&pt)&&s.createElement("span",{className:"sps-option-list__option-icon-spacer"}),s.createElement("span",{dangerouslySetInnerHTML:{__html:ue.getHtml(tt.replacementPattern)}}),ue.caption&&s.createElement("div",{className:"sps-option-list__option-caption"},s.createElement("span",{dangerouslySetInnerHTML:{__html:ue.caption.replace(tt.replacementPattern,"<u>$&</u>")}})))})),ne&&X.label&&s.createElement("a",{className:A("sps-option-list__option","sps-option-list__special-action",ae===Ne.length&&"sps-option-list__option--highlighted"),href:ne.href,onClick:ue=>ut(ue,ne),onMouseOver:()=>ee(Ne.length)},X.icon&&s.createElement("i",{className:A("sps-icon","sps-option-list__option-icon",`sps-icon-${String(X.icon)}`)}),!X.icon&&pt&&s.createElement("span",{className:"sps-option-list__option-icon-spacer"}),s.createElement("span",null,X.label))))});Object.assign(Ka,{propTypes:Jv,displayName:"SpsOptionList"});function Vt(e=[],t=[]){const n=Array.isArray(e)?D.flatten(e):[e],a=t.map(i=>Array.isArray(i)?i:[i]),o=new Array(a.length+1).fill(null).map(()=>[]);for(const i of n){let l=!1;for(let c=0;c<a.length;c+=1)for(const{type:p,props:u={}}of a[c])if(i.type===p&&Object.keys(u).every(m=>u[m]===i.props[m])){l=!0,o[c].push(i);break}l||o[o.length-1].push(i)}return o}function od(e,t,n){const a=Object.entries(t).filter(([,i])=>typeof i!="string"&&i.deprecated).map(([i])=>i),o=a.map(i=>n[i]);s.useEffect(()=>{o.find(i=>typeof i!="undefined")&&console.warn(`The following prop(s) of ${e} are deprecated: ${a.join(", ")}`)},o)}function id(e,t){const n=$.useRef(!1);$.useEffect(()=>{if(n.current)return e();n.current=!0},t)}function ld(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 sy(e,t,n){return function(o){!e.current.contains(o.target)&&!t.current.contains(o.target)&&n()}}function Va(e,t){const n=s.useRef(!1),[a,o]=s.useState(!1),i=s.useCallback(()=>{n.current?n.current=!1:o(!0)},[]),l=s.useCallback((c=!1)=>{o(!1),n.current=c},[]);return ld("click",sy,[e,t,l]),{showPopup:a,doShowPopup:i,doHidePopup:l}}const ry={debounce:"number",disabled:"boolean",formMeta:"SpsFormFieldMeta<string>",icon:"SpsIcon",onChange:"React.ChangeEventHandler",placeholder:"string",suggestions:{type:`
|
|
167
|
+
`}}}};var hv=self.crypto||self.msCrypto,mo="-_",xn=36;for(;xn--;)mo+=xn.toString(36);xn=36;for(;xn---10;)mo+=xn.toString(36).toUpperCase();var gv=function(e){var t="",n=hv.getRandomValues(new Uint8Array(e||21));for(xn=e||21;xn--;)t+=mo[n[xn]&63];return t},Dn=gv;function la(e){return $.useRef(e||Dn())}function Ft(e,t){const n=la(e),a=$.useRef(`${n.current}_ctrl`);return $.useEffect(()=>{t&&(t.id=a.current,t.update())},[t]),{wrapperId:n.current,controlId:a.current}}var Sv="[object Object]";function bv(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch{}return t}function vv(e,t){return function(n){return e(t(n))}}var yv=Function.prototype,$c=Object.prototype,Hc=yv.toString,Tv=$c.hasOwnProperty,wv=Hc.call(Object),Cv=$c.toString,Ev=vv(Object.getPrototypeOf,Object);function xv(e){return!!e&&typeof e=="object"}function Dv(e){if(!xv(e)||Cv.call(e)!=Sv||bv(e))return!1;var t=Ev(e);if(t===null)return!0;var n=Tv.call(t,"constructor")&&t.constructor;return typeof n=="function"&&n instanceof n&&Hc.call(n)==wv}var Wc=Dv;const Kt=new Set,ca=new Set,mn=new Set,Ba=new Set;function jc(e){Kt.has(e)||mn.has(e)||Ba.has(e)||ca.add(e)}function Yc(e){Kt.has(e)||mn.has(e)||ca.has(e)||Ba.add(e)}const fo=Ut.default||Ut,ws="MM/DD/YYYY",kv=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/,Gc=Symbol("Date Parse Error");function da(e){return e.year*1e4+e.month*100+e.date}const ge=Object.freeze({createFrom(e){if(!e)return null;if(typeof e=="string"){const t=kv.exec(e);if(t){const[,n,a,o]=t;return Object.freeze({year:Number(o),month:Number(n),date:Number(a)})}return Object.freeze({[Gc]:!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(ge.createFrom):null},isValid(e){return e&&typeof e=="object"&&typeof e.year=="number"&&typeof e.month=="number"&&typeof e.date=="number"&&ge.toMoment(e).isValid()},nullifyInvalidDate(e){return ge.isValid(e)?e:null},toMoment(e){return e?fo(H(I({},e),{month:e.month-1})):null},toString(e){const t=ge.toMoment(e);return t?t.format(ws):""},toStringRange(e){return e?e.map(ge.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:da(e)>da(t)},isBefore(e,t){return!e||!t?null:da(e)<da(t)},isInRange(e,t,n=!0){if(!e||!t||!t[0]||!t[1])return null;const a=da(e),[o,i]=t.map(da);return e&&o&&i&&(n&&a>=o&&a<=i||!n&&a>o&&a<i)},prevMonth(e){return Object.freeze({year:e.month===1?e.year-1:e.year,month:e.month-1||12,date:e.date})},nextMonth(e){return Object.freeze({year:e.month===12?e.year+1:e.year,month:e.month+1>12?1:e.month+1,date:e.date})},createRangeFromPreset(e){if(typeof e.definition=="function")return e.definition();const t=fo(),n=t.clone().subtract(fo.duration(e.definition));return[ge.createFrom(n),ge.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[Gc])return{dateFormat:ws};if(!ge.isValid(t))return{dateValidity:!0}}return null};Kt.add("dateFormat");Kt.add("dateValidity");const Uc=function(t){if(Array.isArray(t)){const n=Pa(t);if(n)return n;if(t&&ge.isBefore(t[1],t[0]))return{dateRangeOrder:!0}}return null};Kt.add("dateRangeOrder");const zc=function({minDate:t,maxDate:n}){function a(o){const i=ge.isBefore(o,t),l=ge.isAfter(o,n),c={minExceeded:i?ge.toString(t):null,maxExceeded:l?ge.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 Nv=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",date:Pa,dateRange:Uc,dateConstraint:zc});const Iv=function(t){return function(a){return Number(a)>=t?null:{min:t}}};Kt.add("min");const _v=function(t){return n=>Number(n)<=t?null:{max:t}};ca.add("max");const Mv=function(t){return typeof t=="undefined"||t===null||t===""||Number.isNaN(t)||(t==null?void 0:t.length)===0?{required:!0}:null};ca.add("required");const Ov=function(t){return function(a){return a.length>=t?null:{minLength:t}}};Kt.add("minLength");const Rv=function(t){return function(a){return a.length<=t?null:{maxLength:t}}};mn.add("maxLength");const Lv=function(t){const n=t instanceof RegExp?t:new RegExp(t);return function(o){return n.test(o)?null:{pattern:t}}};Kt.add("pattern");const Bv=function(t){return/^[A-Za-z]*$/.test(t)?null:{alpha:!0}};mn.add("alpha");const Pv=function(t){return/^[0-9,. ]*$/.test(t)?null:{numeric:!0}};mn.add("numeric");const Av=function(t){return/^[^0-9]*$/.test(t)?null:{nonNumeric:!0}};mn.add("nonNumeric");const Cs=Object.freeze(H(I({},Nv),{min:Iv,max:_v,required:Mv,minLength:Ov,maxLength:Rv,pattern:Lv,alpha:Bv,numeric:Pv,nonNumeric:Av,OnBlurErrorKeys:Kt}));function Aa(e,t=[]){const n=t.reduce((a,o)=>Object.assign(a,o(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=>ca.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(o=>mn.has(o)).length>0){this.preventativeErrors=Object.keys(n);return}}this.update(this.path,t)}isPristine(){return this.pristine}markAsPristine(){return this.pristine=!0,this.revealAllErrors=!1,this.update(null),this}markAsDirty(){return this.pristine=!1,this.update(null),this}isFocused(){return this.focused}markAsFocused(){return this.focused=!0,this.update(null),this.onFocus&&this.onFocus(),this}markAsBlurred(){return this.update(this.path,null,!0),this.onBlur&&this.onBlur(),this.preventativeErrors=[],this}markAsSubmitted(){return this.submitted=!0,this.update(null),this}}class Es extends Kn{constructor(t,n,a){const o=a?n:t,i=a||n;super(o,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 qc extends Es{inferMembers(t){this.fields={};for(const n of Object.keys(t))this.fields[n]=this.inferSpsControl(t[n],n)}}class Jc 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 Jc(e,t,n):Wc(e)?new qc(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(o=>e.fields[o]);return t.length===0?a:a.reduce((o,i)=>[...o,...go(i,t)],[])}return go(e.fields[n],t)}function Zc(e,t,n){for(const a of Object.keys(t)){const o=t[a];for(const i of go(e,a.split(".")))i&&o&&n(i,o)}}function So(e,t,n,a=!1){Zc(t,n,(o,i)=>{o.validators=typeof i=="function"?i(e):i,a&&(o.errors=Aa(D.getPath(e,o.path),o.validators))})}function bo(e,t){const n=t[0];return t=t.slice(1),Array.isArray(e)?e.map((a,o)=>o===Number(n)?bo(a,t):a):Wc(e)?Object.keys(e).reduce((a,o)=>Object.assign(a,{[o]:o===n?bo(e[o],t):e[o]}),{}):e}function Fv(e){if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError("The initial value of useSpsForm() hook must be an object.")}function Kv(e,t){Fv(e);const n=$.useMemo(()=>{D.deepFreeze(e);const f=xs(e,[],p);return t&&So(e,f,t,!0),f},[]),a=$.useRef();let o=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(o){const v=m.path.join("."),C=I({},o);C[v]=m.newValidators,o=C,So(f.formValue,f.formMeta,o,!0)}}else g=bo(f.formValue,m.path),D.setPath(g,m.path,m.value);else g=m.value;if(g){D.deepFreeze(g);const v=D.diff(f.formValue,g);for(const{type:C,key:E,parentPath:S,objects:[T,x]}of v){const y=ho(f.formMeta,S);if(typeof E!="symbol"&&y)switch(C){case D.DiffChange.ADDITION:y.fields[E]=xs(x[E],[...S,E],p);break;case D.DiffChange.DELETION:Array.isArray(y.fields)?y.fields.splice(Number(E),1):delete y.fields[E];break;case D.DiffChange.ALTERATION:if(!T[E]&&x[E]&&!(y.fields[E]instanceof Es)){const N=xs(x[E],[...S,E],p);N instanceof Kn&&y.fields[E]instanceof Kn&&(N.id=y.fields[E].id,N.focused=y.fields[E].focused,N.pristine=y.fields[E].pristine),y.fields[E]=N}break}}if(o){So(g,f.formMeta,o);const C=new Set;Zc(f.formMeta,t,(E,S)=>{typeof S=="function"&&(E.validate(D.getPath(g,E.path)),C.add(E))});for(const{type:E,key:S,parentPath:T,objects:[,x]}of v)if(typeof S!="symbol"){let y=f.formMeta,N=g;if(y){for(const _ of T)y=y.fields[_],N=N[_],C.has(y)||y.validate(N);if(E===D.DiffChange.ADDITION||E===D.DiffChange.ALTERATION){const _=y.fields[S];if(!C.has(_)&&(y.fields[S].validate(x[S]),E===D.DiffChange.ADDITION&&_.fields))for(const[R,O]of Object.entries(_.fields))O.validate(x[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 Vv=H(I({},J),{focusInputOnClick:w.exports.bool,formMeta:de(),formControl:de(),inputRef:Jt()}),yt=s.forwardRef((e,t)=>{const x=e,{className:n,children:a,focusInputOnClick:o,formControl:i,formMeta:l,inputRef:c,onClick:p}=x,u=Z(x,["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 E(){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 T(y){o&&v(),p&&p(y)}return s.createElement("div",H(I({},u),{className:S,ref:t,tabIndex:-1,onClick:T,onFocus:C,onBlur:E}),a)});Object.assign(yt,{spsFormComponentWrapperPropTypes:Vv,displayName:"SpsFormComponentWrapper"});function Xc(e){return typeof e=="object"&&e!=null&&e.nodeType===1}function Qc(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 Qc(n.overflowY,t)||Qc(n.overflowX,t)||function(a){var o=function(i){if(!i.ownerDocument||!i.ownerDocument.defaultView)return null;try{return i.ownerDocument.defaultView.frameElement}catch{return null}}(a);return!!o&&(o.clientHeight<a.scrollHeight||o.clientWidth<a.scrollWidth)}(e)}return!1}function Ds(e,t,n,a,o,i,l,c){return i<e&&l>t||i>e&&l<t?0:i<=e&&c<=n||l>=t&&c>=n?i-e-a:l>t&&c<n||i<e&&c>n?l-t+o:0}function ed(e,t){var n=window,a=t.scrollMode,o=t.block,i=t.inline,l=t.boundary,c=t.skipOverflowHiddenElements,p=typeof l=="function"?l:function(ze){return ze!==l};if(!Xc(e))throw new TypeError("Invalid target");for(var u=document.scrollingElement||document.documentElement,f=[],m=e;Xc(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,E=window.scrollY||pageYOffset,S=e.getBoundingClientRect(),T=S.height,x=S.width,y=S.top,N=S.right,_=S.bottom,R=S.left,O=o==="start"||o==="nearest"?y:o==="end"?_:y+T/2,B=i==="center"?R+x/2:i==="end"?N:R,K=[],P=0;P<f.length;P++){var G=f[P],F=G.getBoundingClientRect(),j=F.height,U=F.width,X=F.top,le=F.right,he=F.bottom,ce=F.left;if(a==="if-needed"&&y>=0&&R>=0&&_<=v&&N<=g&&y>=X&&_<=he&&R>=ce&&N<=le)return K;var z=getComputedStyle(G),Q=parseInt(z.borderLeftWidth,10),V=parseInt(z.borderTopWidth,10),se=parseInt(z.borderRightWidth,10),ne=parseInt(z.borderBottomWidth,10),ae=0,ee=0,Ie="offsetWidth"in G?G.offsetWidth-G.clientWidth-Q-se:0,Re="offsetHeight"in G?G.offsetHeight-G.clientHeight-V-ne:0;if(u===G)ae=o==="start"?O:o==="end"?O-v:o==="nearest"?Ds(E,E+v,v,V,ne,E+O,E+O+T,T):O-v/2,ee=i==="start"?B:i==="center"?B-g/2:i==="end"?B-g:Ds(C,C+g,g,Q,se,C+B,C+B+x,x),ae=Math.max(0,ae+E),ee=Math.max(0,ee+C);else{ae=o==="start"?O-X-V:o==="end"?O-he+ne+Re:o==="nearest"?Ds(X,he,j,V,ne+Re,O,O+T,T):O-(X+j/2)+Re/2,ee=i==="start"?B-ce-Q:i==="center"?B-(ce+U/2)+Ie/2:i==="end"?B-le+se+Ie:Ds(ce,le,U,Q,se+Ie,B,B+x,x);var Te=G.scrollLeft,Pe=G.scrollTop;O+=Pe-(ae=Math.max(0,Math.min(Pe+ae,G.scrollHeight-j+Re))),B+=Te-(ee=Math.max(0,Math.min(Te+ee,G.scrollWidth-U+Ie)))}K.push({el:G,top:ae,left:ee})}return K}function td(e){return e===Object(e)&&Object.keys(e).length!==0}function $v(e,t){t===void 0&&(t="auto");var n="scrollBehavior"in document.body.style;e.forEach(function(a){var o=a.el,i=a.top,l=a.left;o.scroll&&n?o.scroll({top:i,left:l,behavior:t}):(o.scrollTop=i,o.scrollLeft=l)})}function Hv(e){return e===!1?{block:"end",inline:"nearest"}:td(e)?e:{block:"start",inline:"nearest"}}function nd(e,t){var n=!e.ownerDocument.documentElement.contains(e);if(td(t)&&typeof t.behavior=="function")return t.behavior(n?[]:ed(e,t));if(!n){var a=Hv(t);return $v(ed(e,a),a.behavior)}}var Wv=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",default:nd});const jv={alt:"string",size:"SpinnerSize",title:"string"},Yv=H(I({},J),{alt:w.exports.string,size:ve(M.SpinnerSize),title:w.exports.string});function ks(e){const m=e,{alt:t,className:n,size:a=M.SpinnerSize.MEDIUM,"data-testid":o,title:i,unsafelyReplaceClassName:l}=m,c=Z(m,["alt","className","size","data-testid","title","unsafelyReplaceClassName"]),{t:p}=s.useContext(je),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":o,title:u},c))}Object.assign(ks,{props:jv,propTypes:Yv,displayName:"SpsSpinner"});const Gv=60;function Ns(e){return typeof e=="undefined"?"inherit":`${e}px`}function ad(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 Uv(e,t,n,a,o,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 E,S,T,x;switch(v){case"top":T=t.height-n.top-f-i[0];break;case"left":S=t.width-n.left-g-i[0];break;case"right":x=n.right+g-i[0];break;case"bottom":E=n.bottom+f-i[0];break;default:throw new Error(`Invalid position ${e}`)}switch(C){case"left":x=n.left+g+i[1];break;case"top":E=n.top+f+i[1];break;case"middle":v==="top"||v==="bottom"?x=n.left+g+n.width/2-o/2+i[1]:(v==="left"||v==="right")&&(E=n.top+f+n.height/2-a.height/2+i[1]);break;case"bottom":T=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[E,S,T,x]}function Fa(e,t,n,{altPosition:a,setMinWidth:o=!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(),[E]=n.split(" ");let S=n;a&&(E==="top"&&C.top-v.height<Gv||E==="right"&&C.right+v.width>f||E==="bottom"&&C.bottom+v.height>u||E==="left"&&C.left-v.width<0)&&(S=a);const T=o?Math.max(C.width,v.width):v.width,x=i?C.width:T,[y,N,_,R]=Uv(S,g,C,v,x,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),o&&(O.minWidth=`${C.width}px`),i&&(O.width=`${C.width}px`),[O,S===a]}return[{},!1]}const It=$.createContext(null);function pa(e,t=[]){const n=$.useContext(It);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 zv={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:w.exports.string,comparisonKey:w.exports.string,disabledOptions:w.exports.arrayOf(w.exports.any),options:w.exports.oneOfType([w.exports.array,w.exports.instanceOf(Promise),re()]).isRequired,tall:w.exports.bool,textKey:w.exports.string,valueKey:w.exports.string,zeroState:w.exports.string,maxHeightPx:w.exports.number,maxHeightRem:w.exports.number}},qv={hideInlineSearch:w.exports.bool,onSearchChange:re(),search:w.exports.string,searchDebounce:w.exports.number,searchPlaceholder:w.exports.string,searchInputRef:Jt()},Jv=H(I(I(I({},J),zv.propTypes),qv),{attachTo:Jt().isRequired,conformWidth:w.exports.bool,id:w.exports.string.isRequired,isOpen:w.exports.bool,keepOpen:w.exports.bool,keyDown:de(),nullOption:w.exports.string,offsets:w.exports.arrayOf(w.exports.number),onOptionListChanged:re(),onOptionSelected:re(),onPositionFlip:re(),onSelfToggle:re(),optionRole:w.exports.string,positionOverride:w.exports.arrayOf(ve(M.Position)),selectedOption:w.exports.any,specialAction:re(),ignoreWidthStyles:w.exports.bool,loading:w.exports.bool,filterByTextAndCaptionKey:w.exports.bool});async function sd(e,t,n,a,o,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),o(u.some(f=>f.value&&!!f.value.icon)),n({pending:!1})}function Zv(e,t,n){const[a,o]=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"?D.debounce(sd,typeof e.searchDebounce!="undefined"?e.searchDebounce:500):sd,[p.current,e.disabledOptions]);return s.useEffect(()=>{u(e,t,n,o,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 Xv(e,t){return I(I({},e),t)}function Zt(e){return $.useReducer(Xv,e)}function Qv({hideInlineSearch:e,options:t,onSearchChange:n,search:a="",searchPlaceholder:o="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:o,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 ey=nd||Wv,ty=["Tab","Escape","Enter","Up","ArrowUp","Down","ArrowDown"],ny=["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 ay(e,t,n){return n?(e&&e[n])===(t&&t[n]):e===t}function rd(e,t,n){return t?!!(e==null?void 0:e.find(a=>{var o;return a[t]&&a[t]===((o=n==null?void 0:n.value)==null?void 0:o[t])})):!1}const Ka=s.forwardRef((e,t)=>{const _n=e,{captionKey:n,comparisonKey:a,disabledOptions:o,options:i,tall:l,textKey:c,valueKey:p,zeroState:u,hideInlineSearch:f,onSearchChange:m,search:g,searchDebounce:v,searchPlaceholder:C,attachTo:E,className:S,conformWidth:T,id:x,ignoreWidthStyles:y,isOpen:N,keepOpen:_,keyDown:R,nullOption:O,onOptionListChanged:B,onOptionSelected:K,onPositionFlip:P,onSelfToggle:G,optionRole:F,positionOverride:j,selectedOption:U,specialAction:X,unsafelyReplaceClassName:le,loading:he,filterByTextAndCaptionKey:ce,maxHeightPx:z,maxHeightRem:Q,"data-testid":V}=_n,se=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(()=>X?new M.SpsOptionListOption(X,{textKey:"label",captionKey:"caption"}):null,[X]),[ae,ee]=s.useState(-1),[Ie,Re]=s.useState(N),Te=t||s.useRef(null),Pe=s.useRef(null),ze=s.useRef(null),Xe=pa("sps-option-list-portal"),Qe=s.useContext(It),[at,He]=j||[M.Position.BOTTOM_LEFT,M.Position.TOP_LEFT],[De,me]=Ie?Fa(Te,E,at,I({altPosition:He,setMinWidth:!y,setWidth:!y&&T},Qe)):[{},!1],Fe=s.useRef(null),[Ct,tt,dt]=Qv(H(I({},e),{searchInputRef:Fe})),[Ne,pt]=Zv(e,tt,dt);s.useEffect(()=>{ee(-1)},[tt]);const nn=A(le||"sps-option-list","z-stratum-dropdown",Ie&&"sps-option-list--open",tt.isAsync&&"sps-option-list--searchable",me&&"sps-option-list--opens-upward",X&&X.label&&"sps-option-list--has-special-action",S),yn=A(le||"sps-option-list__options",l&&"sps-option-list__options--tall"),Ze=s.useCallback(()=>{Ie||(Re(!0),Fe.current&&Fe.current.focus(),ee(-1),G&&G(!0))},[Ie,G]),an=s.useCallback(()=>{Ie&&(Re(!1),ee(-1),G&&G(!1))},[Ie,G]),Et=s.useCallback((ue,Ce)=>{Ce||ue&&!ue.disabled&&(typeof ue.value=="function"?ue.value():typeof K=="function"&&K(ue.value),_||an())},[K,an]),ut=s.useCallback((ue,Ce,st)=>{ue.stopPropagation(),Et(Ce,st)},[Et]),we=s.useRef(o||[]);we.current=o||[];const jt=s.useCallback(ue=>{switch(ue.key){case"Tab":case"Escape":an();break;case"Enter":if(ae>-1){const Ce=Ne[ae]||ne;ue.preventDefault();const st=!!Ce&&rd(we.current,a,Ce);!st&&Ce&&typeof K=="function"&&typeof Ce.value=="function"?Ce.value():Ce&&Et(Ce,st)}break;case"Up":case"ArrowUp":{let Ce=ae;me?ae<=-1?Ce=Ne.length-1:ae===0?X&&(Ce=Ne.length):ae<Ne.length&&(Ce=ae-1):ae>-1&&(Ce=ae-1),Ce!==ae&&(ue.preventDefault(),ee(Ce));break}case"Down":case"ArrowDown":{Ze();let Ce=ae;me?ae!==-1&&(ae>=Ne.length?Ce=0:ae===Ne.length-1?Ce=-1:Ce=ae+1):ae<Ne.length-1+Number(!!X)&&(Ce=ae+1),Ce!==ae&&(ue.preventDefault(),ee(Ce));break}default:Ze()}},[an,Ze,ae,Et,K,me,Ne]),Tn=s.useCallback(ue=>{const Ce=Ne.findIndex(st=>{if(st.textKey){const Lt=st.textKey;return st.value[Lt].toLowerCase().charAt([0])===ue.key.toLocaleLowerCase()}return st.value.toLowerCase().charAt([0])===ue.key.toLocaleLowerCase()});Ce>-1&&ee(Ce)},[Ne]),Xn=s.useCallback(ue=>{!ue||(ty.includes(ue.key)?jt(ue):ny.includes(ue.key)&&Tn(ue))},[an,Ze,ae,Et,K,me,Ne]);s.useEffect(()=>{if(Qe!==null&&document.getElementsByClassName("sps-modal__body").length>0){const ue=()=>{G(!1)},Ce=document.getElementsByClassName("sps-modal__body")[0];return Ce.addEventListener("scroll",ue),()=>{Ce.removeEventListener("scroll",ue)}}},[]),s.useEffect(()=>{ze.current&&ey(ze.current,{scrollMode:"if-needed",block:"nearest",inline:"nearest"})},[ae]),s.useEffect(()=>{Re(N),N?Fe.current&&Fe.current.focus():ee(-1)},[N]),s.useEffect(()=>{Xn(R)},[R]),s.useEffect(()=>{!Ie&&Pe.current&&(dt({value:""}),Pe.current.scrollTop=0),Ie&&P&&P(me)},[Ie]);const Qn=z?z/16:Q,ka=Qn?{maxHeight:`${Qn}rem`}:{};return Xe(s.createElement("div",I({className:nn,id:x,"aria-activedescendant":ae>-1?`${x}-option-${ae}`:null,tabIndex:-1,ref:Te,style:De,onMouseLeave:()=>ee(-1),"data-testid":V},se),Ct,s.createElement("div",{className:yn,ref:Pe,"data-testid":`${V}-options`,style:ka},!he&&!tt.pending&&u&&(tt.value||!tt.isAsync)&&Ne.length===0&&s.createElement("div",{className:"sps-option-list__zero-state"},u),(he||tt.pending)&&s.createElement("div",{className:"sps-option-list__loading"},s.createElement(ks,null)),!he&&!tt.pending&&Ne.map((ue,Ce)=>{const st=`${x}-option-${Ce}`,Lt=ay(ue.value,U,a),Le=rd(we.current,a,ue);return s.createElement("a",{key:st,id:st,role:F,"aria-selected":Lt,href:ue.href,className:A("sps-option-list__option",ue.caption&&"sps-option-list__option--has-caption",ue.disabled&&"sps-option-list__option--disabled",ue.bold&&"sps-option-list__option--bold",(Lt||Le)&&"sps-option-list__option--selected",ae===Ce&&"sps-option-list__option--highlighted"),onClick:Yt=>ut(Yt,ue,Le),onMouseOver:()=>ee(Ce),tabIndex:-1,ref:ae===Ce?ze:null,"data-testid":`${V}-option-${Ce}`},ue.value&&ue.value.icon&&s.createElement("i",{className:A("sps-icon","sps-option-list__option-icon",`sps-icon-${String(ue.value.icon)}`)}),(!ue.value||!ue.value.icon&&pt)&&s.createElement("span",{className:"sps-option-list__option-icon-spacer"}),s.createElement("span",{dangerouslySetInnerHTML:{__html:ue.getHtml(tt.replacementPattern)}}),ue.caption&&s.createElement("div",{className:"sps-option-list__option-caption"},s.createElement("span",{dangerouslySetInnerHTML:{__html:ue.caption.replace(tt.replacementPattern,"<u>$&</u>")}})))})),ne&&X.label&&s.createElement("a",{className:A("sps-option-list__option","sps-option-list__special-action",ae===Ne.length&&"sps-option-list__option--highlighted",X.disabled&&"sps-option-list__special-action--disabled"),href:ne.href,onClick:ue=>ut(ue,ne),onMouseOver:()=>ee(Ne.length)},X.icon&&s.createElement("i",{className:A("sps-icon","sps-option-list__option-icon",`sps-icon-${String(X.icon)}`)}),!X.icon&&pt&&s.createElement("span",{className:"sps-option-list__option-icon-spacer"}),s.createElement("span",null,X.label))))});Object.assign(Ka,{propTypes:Jv,displayName:"SpsOptionList"});function Vt(e=[],t=[]){const n=Array.isArray(e)?D.flatten(e):[e],a=t.map(i=>Array.isArray(i)?i:[i]),o=new Array(a.length+1).fill(null).map(()=>[]);for(const i of n){let l=!1;for(let c=0;c<a.length;c+=1)for(const{type:p,props:u={}}of a[c])if(i.type===p&&Object.keys(u).every(m=>u[m]===i.props[m])){l=!0,o[c].push(i);break}l||o[o.length-1].push(i)}return o}function od(e,t,n){const a=Object.entries(t).filter(([,i])=>typeof i!="string"&&i.deprecated).map(([i])=>i),o=a.map(i=>n[i]);s.useEffect(()=>{o.find(i=>typeof i!="undefined")&&console.warn(`The following prop(s) of ${e} are deprecated: ${a.join(", ")}`)},o)}function id(e,t){const n=$.useRef(!1);$.useEffect(()=>{if(n.current)return e();n.current=!0},t)}function ld(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 sy(e,t,n){return function(o){!e.current.contains(o.target)&&!t.current.contains(o.target)&&n()}}function Va(e,t){const n=s.useRef(!1),[a,o]=s.useState(!1),i=s.useCallback(()=>{n.current?n.current=!1:o(!0)},[]),l=s.useCallback((c=!1)=>{o(!1),n.current=c},[]);return ld("click",sy,[e,t,l]),{showPopup:a,doShowPopup:i,doHidePopup:l}}const ry={debounce:"number",disabled:"boolean",formMeta:"SpsFormFieldMeta<string>",icon:"SpsIcon",onChange:"React.ChangeEventHandler",placeholder:"string",suggestions:{type:`
|
|
168
168
|
Eventually<Iterable<string>>
|
|
169
169
|
| ((filter?: string) => Eventually<Iterable<string>>)
|
|
170
170
|
`,required:!0},tallOptionList:"boolean",value:"string",zeroState:"string",loading:"boolean",maxHeightOptionListPx:"number",maxHeightOptionListRem:"number"},oy=H(I({},J),{debounce:w.exports.number,disabled:w.exports.bool,formControl:de(),formMeta:de(),icon:ve(M.SpsIcon),onChange:re(),placeholder:w.exports.string,suggestions:w.exports.oneOfType([w.exports.arrayOf(w.exports.string),w.exports.instanceOf(Promise),re()]).isRequired,tallOptionList:w.exports.bool,value:w.exports.string,zeroState:w.exports.string,loading:w.exports.bool,maxHeightOptionListPx:w.exports.number,maxHeightOptionListRem:w.exports.number});function Is(y){var N=y,{className:e,debounce:t=0,disabled:n,formControl:a,formMeta:o,onChange:i,icon:l,id:c,placeholder:p="",suggestions:u,unsafelyReplaceClassName:f,tallOptionList:m,value:g="",zeroState:v,loading:C,maxHeightOptionListPx:E,maxHeightOptionListRem:S,"data-testid":T}=N,x=Z(N,["className","debounce","disabled","formControl","formMeta","onChange","icon","id","placeholder","suggestions","unsafelyReplaceClassName","tallOptionList","value","zeroState","loading","maxHeightOptionListPx","maxHeightOptionListRem","data-testid"]);const _=o||a,{wrapperId:R,controlId:O}=Ft(c,_),[B,K]=Zt({keyDown:null,opensUpward:!1}),P=s.useRef(),G=s.useRef(),F=s.useRef(),{showPopup:j,doShowPopup:U,doHidePopup:X}=Va(P,F);function le(ne,ae){_&&(_.setValue(ne),_.markAsDirty()),i&&i(ae||new Vn({value:ne}))}function he(ne){G.current.value="",le(""),ne.stopPropagation()}function ce(ne){le(ne.target.value,ne)}function z(ne){n||(["Up","ArrowUp","Down","ArrowDown","Enter"].indexOf(ne.key)>-1&&(ne.preventDefault(),ne.persist()),ne.stopPropagation(),K({keyDown:ne})),ne.key==="Tab"&&X()}function Q(ne){ne?U():X()}function V(ne){K({opensUpward:ne})}const se=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(yt,{id:R,className:se,formControl:a,formMeta:o,inputRef:G,ref:P,focusInputOnClick:!0,onClick:ne=>ne.nativeEvent.stopImmediatePropagation(),"data-testId":`${T}`},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:G,value:g,className:"sps-text-input__input",placeholder:p,onFocus:U,onClick:U,onChange:ce,onKeyDown:z,disabled:n,id:O,"data-testid":`${T}__input`},x)),g&&!n&&s.createElement("i",{"aria-label":"clear",className:"sps-icon sps-icon-x-circle sps-form-control__clear-btn",onClick:ne=>he(ne)}))),s.createElement(Ka,{id:`${R}_options`,ref:F,attachTo:P,isOpen:j,options:u,hideInlineSearch:!0,keyDown:B.keyDown,onOptionSelected:le,onPositionFlip:V,onSelfToggle:Q,offsets:[1,0],search:g,searchDebounce:t,tall:m,zeroState:v,loading:C,maxHeightPx:E,maxHeightRem:S}))}Object.assign(Is,{props:ry,propTypes:oy,displayName:"SpsAutocomplete"});const cd={basic:{label:"Basic",examples:{basic:{react:D.code`
|
package/lib/index.es.js
CHANGED
|
@@ -2387,7 +2387,7 @@ const SpsOptionList = React.forwardRef((props2, ref2) => {
|
|
|
2387
2387
|
}
|
|
2388
2388
|
})));
|
|
2389
2389
|
})), specialActionOption && specialAction.label && /* @__PURE__ */ React.createElement("a", {
|
|
2390
|
-
className: clsx("sps-option-list__option", "sps-option-list__special-action", highlightedOptionIndex === optionList.length && "sps-option-list__option--highlighted"),
|
|
2390
|
+
className: clsx("sps-option-list__option", "sps-option-list__special-action", highlightedOptionIndex === optionList.length && "sps-option-list__option--highlighted", specialAction.disabled && "sps-option-list__special-action--disabled"),
|
|
2391
2391
|
href: specialActionOption.href,
|
|
2392
2392
|
onClick: (event) => handleOptionClick(event, specialActionOption),
|
|
2393
2393
|
onMouseOver: () => setHighlightedOptionIndex(optionList.length)
|
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.16.
|
|
4
|
+
"version": "5.16.1",
|
|
5
5
|
"author": "SPS Commerce",
|
|
6
6
|
"license": "UNLICENSED",
|
|
7
7
|
"repository": "https://github.com/spscommerce/design-system/tree/main/packages/@spscommerce/ds-react",
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"@react-stately/collections": "^3.3.3",
|
|
31
|
-
"@spscommerce/ds-colors": "5.16.
|
|
32
|
-
"@spscommerce/ds-shared": "5.16.
|
|
33
|
-
"@spscommerce/positioning": "5.16.
|
|
34
|
-
"@spscommerce/utils": "5.16.
|
|
31
|
+
"@spscommerce/ds-colors": "5.16.1",
|
|
32
|
+
"@spscommerce/ds-shared": "5.16.1",
|
|
33
|
+
"@spscommerce/positioning": "5.16.1",
|
|
34
|
+
"@spscommerce/utils": "5.16.1",
|
|
35
35
|
"moment": "^2.25.3",
|
|
36
36
|
"moment-timezone": "^0.5.28",
|
|
37
37
|
"react": "^16.9.0",
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@react-stately/collections": "^3.3.3",
|
|
42
|
-
"@spscommerce/ds-colors": "5.16.
|
|
43
|
-
"@spscommerce/ds-shared": "5.16.
|
|
44
|
-
"@spscommerce/positioning": "5.16.
|
|
45
|
-
"@spscommerce/utils": "5.16.
|
|
42
|
+
"@spscommerce/ds-colors": "5.16.1",
|
|
43
|
+
"@spscommerce/ds-shared": "5.16.1",
|
|
44
|
+
"@spscommerce/positioning": "5.16.1",
|
|
45
|
+
"@spscommerce/utils": "5.16.1",
|
|
46
46
|
"@testing-library/react": "^9.3.2",
|
|
47
47
|
"@types/prop-types": "^15.7.1",
|
|
48
48
|
"@types/react": "^16.9.0",
|