@spscommerce/ds-react 8.4.6 → 8.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";var zb=Object.defineProperty;var qb=(e,t,n)=>t in e?zb(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Vt=(e,t,n)=>(qb(e,typeof t!="symbol"?t+"":t,n),n),fc=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)};var Bn=(e,t,n)=>(fc(e,t,"read from private field"),n?n.call(e):t.get(e)),Ns=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},ln=(e,t,n,r)=>(fc(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const U=require("react"),y=require("@spscommerce/utils"),tp=require("moment-timezone"),$=require("@spscommerce/ds-shared"),Qs=require("react-dom"),wo=require("@spscommerce/ds-colors"),Jb=require("@sps-woodland/tabs"),pr=require("@react-stately/collections"),np=require("@sps-woodland/illustrations"),jo=e=>e&&typeof e=="object"&&"default"in e?e:{default:e};function rp(e){if(e&&e.__esModule)return e;const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const s=rp(U),X=jo(U),Sr=rp(tp),pt=jo(tp),Zb=jo(Qs);function sp(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e))for(t=0;t<e.length;t++)e[t]&&(n=sp(e[t]))&&(r&&(r+=" "),r+=n);else for(t in e)e[t]&&(r&&(r+=" "),r+=t);return r}function H(){for(var e,t,n=0,r="";n<arguments.length;)(e=arguments[n++])&&(t=sp(e))&&(r&&(r+=" "),r+=t);return r}let St=(e=21)=>crypto.getRandomValues(new Uint8Array(e)).reduce((t,n)=>(n&=63,n<36?t+=n.toString(36):n<62?t+=(n-26).toString(36).toUpperCase():n>62?t+="-":t+="_",t),"");function wn(e){return U.useRef(e||St())}function vt(e,t){const n=wn(e),r=U.useRef(`${n.current}_ctrl`);return U.useEffect(()=>{t&&(t.id=r.current,t.update())},[t]),{wrapperId:n.current||void 0,controlId:r.current}}var qt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Xb="[object Object]";function Qb(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch{}return t}function ev(e,t){return function(n){return e(t(n))}}var tv=Function.prototype,ap=Object.prototype,op=tv.toString,nv=ap.hasOwnProperty,rv=op.call(Object),sv=ap.toString,av=ev(Object.getPrototypeOf,Object);function ov(e){return!!e&&typeof e=="object"}function iv(e){if(!ov(e)||sv.call(e)!=Xb||Qb(e))return!1;var t=av(e);if(t===null)return!0;var n=nv.call(t,"constructor")&&t.constructor;return typeof n=="function"&&n instanceof n&&op.call(n)==rv}var ip=iv;const Nt=new Set,Er=new Set,pn=new Set,ea=new Set;function lp(e){Nt.has(e)||pn.has(e)||ea.has(e)||Er.add(e)}function cp(e){Nt.has(e)||pn.has(e)||Er.has(e)||ea.add(e)}const dt=Sr.default||Sr,gr="MM/DD/YYYY",lv="MM/DD/YYYY hh:mm A",cv="MM/DD/YYYY HH:mm",dv=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/,Ur=Symbol("Date Parse Error");function lr(e){return dt.isMoment(e)?e.year()*1e4+(e.month()+1)*100+e.date():e.year*1e4+e.month*100+e.date}const Q=Object.freeze({createFrom(e){if(!e)return null;if(typeof e=="string"){const t=dv.exec(e);if(t){const[,n,r,a]=t;return Object.freeze({year:Number(a),month:Number(n),date:Number(r)})}return Object.freeze({[Ur]:!0,year:void 0,month:void 0,date:void 0})}return Object.freeze({year:e.year(),month:e.month()+1,date:e.date()})},createMomentFrom(e){if(!e)return null;let t=null;return typeof e=="string"?t=dt(e):dt.isMoment(e)?t=e:t=Q.toMoment(e),t!==null&&dt.isMoment(t)&&t.isValid()?t:Object.freeze({[Ur]:!0,year:void 0,month:void 0,date:void 0})},createRangeFrom(e){return e?e.split(/[^\d]*-[^\d]*/).slice(0,2).map(Q.createFrom):null},isValid(e){var t;return e?dt.isMoment(e)?e.isValid():typeof e=="object"&&typeof e.year=="number"&&typeof e.month=="number"&&typeof e.date=="number"&&((t=Q.toMoment(e))==null?void 0:t.isValid()):!1},nullifyInvalidDate(e){return Q.isValid(e)?e:null},toMoment(e){return e?dt.isMoment(e)?e:dt({...e,month:e.month-1}):null},toString(e){const t=Q.toMoment(e);return t&&t.isValid()?t.format(gr):""},toStringRange(e){return e?e.slice(0,2).map(Q.toString).join("-"):""},toDateTimeString(e,t=!1){return e&&dt.isMoment(e)&&e.isValid()?t?e.format(cv):e.format(lv):""},toDateTimeStringRange(e,t=!1){return e?e.map(n=>Q.toDateTimeString(n,t)).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:lr(e)>lr(t)},isBefore(e,t){return!e||!t?null:lr(e)<lr(t)},isInRange(e,t,n=!0){if(!e||!t||!t[0]||!t[1])return null;const r=lr(e),[a,o]=t.map(lr);return e&&a&&o&&(n&&r>=a&&r<=o||!n&&r>a&&r<o)},prevMonth(e){return Object.freeze({year:e.month===1?e.year-1:e.year,month:e.month-1||12,date:e.date})},nextMonth(e){return Object.freeze({year:e.month===12?e.year+1:e.year,month:e.month+1>12?1:e.month+1,date:e.date})},createRangeFromPreset(e){if(typeof e.definition=="function")return e.definition();const t=dt(),n=t.clone().subtract(dt.duration(e.definition));return[Q.createFrom(n),Q.createFrom(t)]},createDateTimeRangeFromPreset(e){if(typeof e.definition=="function")return e.definition();let t;e.definition==="P0D"?t=dt().startOf("day"):t=dt().subtract(dt.duration(e.definition));const n=dt().endOf("day");return[t,n]},splitMomentInDateTimeParts(e,t=!1){return e&&dt.isMoment(e)&&e.isValid()?Q.toDateTimeString(e,t).split(" "):["",t?"00:00":"12:00",t?void 0:"AM"]},getCurrentMoment(){return dt()},validateTimeString(e,t=!1){if(!e)return!0;const n=e.split(":"),r=n[0]||"0",a=n[1]||"0",o=Number.isNaN(Number(r))?NaN:parseInt(r,10),l=Number.isNaN(Number(a))?NaN:parseInt(a,10),c=n.length<=2&&r.length<=2&&a.length<=2;return t?c&&o>=0&&o<=23&&l>=0&&l<=59:c&&(!Number.isNaN(o)&&r.length===1||o>=1)&&o<=12&&l>=0&&l<=59},padIncompleteTimeString(e,t=!1){if(!e)return"";const n=e.split(":"),r=parseInt(n[0]||"0",10),a=parseInt(n[1]||"0",10);if(t){const o=r<10?`0${r}`:`${r}`,l=a<10?`0${a}`:`${a}`;return`${o}:${l}`}else{const o=r===0?"12":r<10?`0${r}`:`${r}`,l=a<10?`0${a}`:`${a}`;return`${o}:${l}`}}}),Co=["01:00","02:00","03:00","04:00","05:00","06:00","07:00","08:00","09:00","10:00","11:00","12:00"],Do=["00:00","01:00","02:00","03:00","04:00","05:00","06:00","07:00","08:00","09:00","10:00","11:00","12:00","13:00","14:00","15:00","16:00","17:00","18:00","19:00","20:00","21:00","22:00","23:00"],Yr=function(t){if(Array.isArray(t)){const n=Yr(t[0]),r=Yr(t[1]);return n||r}if(t&&t.hasOwnProperty("year")){if(t[Ur])return{dateFormat:gr};if(!Q.isValid(t))return{dateValidity:!0}}return null};Nt.add("dateFormat");Nt.add("dateValidity");const dp=function(t){if(Array.isArray(t)){const n=Yr(t);if(n)return n;if(t&&Q.isBefore(t[1],t[0]))return{dateRangeOrder:!0}}return null};Nt.add("dateRangeOrder");const pp=function({minDate:t,maxDate:n}){function r(a){const o=Q.isBefore(a,t),l=Q.isAfter(a,n),c={minExceeded:o?Q.toString(t):null,maxExceeded:l?Q.toString(n):null};return o||l?{dateConstraint:c}:null}return function(o){if(!o)return null;if(Array.isArray(o)){const l=r(o[0]),c=r(o[1]);return l||c}return o.hasOwnProperty("year")?r(o):null}};Nt.add("dateConstraint");const pv=Object.freeze(Object.defineProperty({__proto__:null,date:Yr,dateRange:dp,dateConstraint:pp},Symbol.toStringTag,{value:"Module"}));function Cn(e,t){for(const n of[].concat(e)){const r=t(n);if(r)return r}return null}const uv=function(t){function n(r){return Number(r)>=t?null:{min:t}}return r=>Cn(r,n)};Nt.add("min");const mv=function(t){function n(r){return Number(r)<=t?null:{max:t}}return r=>Cn(r,n)};Er.add("max");const fv=function(t){return typeof t>"u"||t===null||t===""||Number.isNaN(t)||(t==null?void 0:t.length)===0?{required:!0}:null};Er.add("required");const hv=function(t){function n(r){return r===void 0||r.toString().length<t?{minLength:t}:null}return r=>Cn(r,n)};Nt.add("minLength");const Sv=function(t){function n(r){return r==null||Array.isArray(r)&&r.length<t?{minLengthArray:t}:null}return r=>n(r)};Nt.add("minLengthArray");const gv=function(t){function n(r){return r===void 0||r.toString().length<=t?null:{maxLength:t}}return r=>Cn(r,n)};pn.add("maxLength");const bv=function(t){function n(r){return r==null||Array.isArray(r)&&r.length<=t?null:{maxLengthArray:t}}return r=>n(r)};Nt.add("maxLengthArray");const vv=function(t){const n=t instanceof RegExp?t:new RegExp(t);function r(a){return n.test(a)?null:{pattern:t}}return a=>Cn(a,r)};Nt.add("pattern");const yv=function(e){function t(n){return/^\p{L}*$/u.test(n)?null:{alpha:!0}}return Cn(e,t)};pn.add("alpha");const Tv=function(e){function t(n){return/^[0-9,. ]*$/.test(n)?null:{numeric:!0}}return Cn(e,t)};pn.add("numeric");const Ev=function(e){function t(n){return/^[^0-9]*$/.test(n)?null:{nonNumeric:!0}}return Cn(e,t)};pn.add("nonNumeric");const ta=Object.freeze({...pv,min:uv,max:mv,required:fv,minLength:hv,minLengthArray:Sv,maxLength:gv,maxLengthArray:bv,pattern:vv,alpha:yv,numeric:Tv,nonNumeric:Ev,OnBlurErrorKeys:Nt});function na(e,t=[]){const n=t.reduce((r,a)=>Object.assign(r,a(e)||{}),{});return Object.keys(n).length?n:null}var jt=(e=>(e[e.ON_CHANGE=0]="ON_CHANGE",e[e.ON_BLUR=1]="ON_BLUR",e[e.ON_SUBMIT=2]="ON_SUBMIT",e))(jt||{});function wv(e,t={},n=[]){for(const[r,a]of Object.entries(t))a===0?lp(r):a===2&&cp(r);return s.useCallback(e,n)}var Gn,gn,bn;class Kn{constructor(t,n){Vt(this,"validators",[]);Ns(this,Gn,null);Ns(this,gn,null);Ns(this,bn,null);Vt(this,"preventativeErrors",[]);Vt(this,"submitted",!1);this.path=t,this.update=n}get errors(){var t,n,r;return Bn(this,Gn)===null&&Bn(this,gn)===null&&Bn(this,bn)===null?null:{...(t=Bn(this,Gn))!=null?t:{},...(n=Bn(this,gn))!=null?n:{},...(r=Bn(this,bn))!=null?r:{}}}setValidators(t){return this.update(this.path,null,void 0,t),this}validate(t,n,r=!1){if(this.validators&&this.validators.length>0){const a=na(t,this.validators);let o={onSubmit:{},onChange:{},onBlur:{}};a&&(o=Object.keys(a).reduce((l,c)=>(ea.has(c)?l.onSubmit[c]=a[c]:Er.has(c)?l.onChange[c]=a[c]:l.onBlur[c]=a[c],l),o)),(typeof n>"u"||n===jt.ON_CHANGE)&&ln(this,gn,Object.keys(o.onChange).length===0?null:o.onChange),(typeof n>"u"||n===jt.ON_BLUR)&&ln(this,bn,Object.keys(o.onBlur).length===0?null:o.onBlur),(typeof n>"u"||n===jt.ON_SUBMIT)&&(ln(this,Gn,Object.keys(o.onSubmit).length===0?null:o.onSubmit),ln(this,gn,Object.keys(o.onChange).length===0?null:o.onChange),ln(this,bn,Object.keys(o.onBlur).length===0?null:o.onBlur)),r||this.update(),this.isFocused()&&this.onFocus&&this.onFocus()}else this.errors&&(ln(this,Gn,null),ln(this,bn,null),ln(this,gn,null),r||this.update());return this}isValid(){return!this.errors||this.isPristine()}hasErrors(){return!!this.errors}isVisibilyInvalid(){return!this.isValid()}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(ta.required)>-1}isSubmitted(){return this.submitted}onFocus(){}onBlur(){}}Gn=new WeakMap,gn=new WeakMap,bn=new WeakMap;class jr extends Kn{constructor(){super(...arguments);Vt(this,"id",St());Vt(this,"focused",!1);Vt(this,"pristine",!0)}setValue(n){if(this.preventativeErrors=[],this.validators&&this.validators.length>0){const r=na(n,this.validators);if(r&&Object.keys(r).filter(o=>pn.has(o)).length>0){this.preventativeErrors=Object.keys(r);return}}this.update(this.path,n)}isPristine(){return this.pristine}markAsPristine(){return this.pristine=!0,this.update(),this}markAsDirty(){return this.pristine=!1,this.update(),this}isFocused(){return this.focused}markAsFocused(){return this.focused=!0,this.update(),this.onFocus&&this.onFocus(),this}markAsBlurred(){return this.update(this.path,null,!0),this.onBlur&&this.onBlur(),this.preventativeErrors=[],this}markAsSubmitted(){return this.submitted=!0,this.update(this.path,null,!1,void 0,!0),this}}class Hn extends jr{constructor(n,r,a){super(a?r:n,a||r);Vt(this,"fields");a&&this.inferMembers(n)}isFocused(){return super.isFocused()||this.rollup("isFocused")}isValid(){return super.isValid()&&this.rollup("isValid")}hasErrors(){return super.hasErrors()||Object.keys(this.fields).some(n=>this.fields[n].hasErrors())}contentsAreValid(){return this.rollup("isValid")&&this.rollup("contentsAreValid")}isPristine(){return super.isPristine()&&this.rollup("isPristine")}markAsPristine(){super.markAsPristine();for(const n of Object.keys(this.fields))this.fields[n].markAsPristine();return this}markAsDirty(){super.markAsDirty();for(const n of Object.keys(this.fields))this.fields[n].markAsDirty();return this}markAsBlurred(){super.markAsBlurred();for(const n of Object.keys(this.fields))this.fields[n].markAsBlurred();return this}markAsSubmitted(){super.markAsSubmitted();for(const n of Object.keys(this.fields))this.fields[n].markAsSubmitted();return this}inferSpsControl(n,r){return Fs(n,[...this.path,r],this.update)}rollup(n){return Object.keys(this.fields).reduce((r,a)=>r&&(!this.fields[a][n]||this.fields[a][n]()),!0)}}class up extends Hn{inferMembers(t){this.fields={};for(const n of Object.keys(t))this.fields[n]=this.inferSpsControl(t[n],n)}}class mp extends Hn{inferMembers(t){this.fields=t.map((n,r)=>this.inferSpsControl(n,String(r)))}}function Fs(e,t,n){return e instanceof Kn?(e.path=t,e.update=n,e):Array.isArray(e)?new mp(e,t,n):ip(e)?new up(e,t,n):new jr(t,n)}function $r(e,t){return t.length===0||!e?e:$r(e.fields[t[0]],t.slice(1,t.length))}function No(e,t){if(t.length===0||!e)return[e];const n=t[0];if(t=t.slice(1,t.length),n==="*"){const r=Array.isArray(e.fields)?e.fields:Object.keys(e.fields).map(a=>e.fields[a]);return t.length===0?r:r.reduce((a,o)=>[...a,...No(o,t)],[])}return No(e.fields[n],t)}function fp(e,t,n){for(const r of Object.keys(t)){const a=t[r];for(const o of No(e,r.split(".")))o&&a&&n(o,a)}}function xs(e,t,n,r=!1,a=!1){fp(t,n,(o,l)=>{o.validators=typeof l=="function"?l(e):l,r&&o.validate(y.getPath(e,o.path),void 0,a)})}function xo(e,t){const n=t[0];return t=t.slice(1),Array.isArray(e)?e.map((r,a)=>a===Number(n)?xo(r,t):r):ip(e)?Object.keys(e).reduce((r,a)=>Object.assign(r,{[a]:a===n?xo(e[a],t):e[a]}),{}):e}function Cv(e){if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError("The initial value of useSpsForm() hook must be an object.")}function hp(e,t={}){Cv(e);const n=U.useMemo(()=>{y.deepFreeze(e);const m=Fs(e,[],p);return t&&xs(e,m,t,!1,!0),m},[]),r=U.useRef(),a=U.useRef(t),o=U.useCallback((m,u)=>{var g,v,w;let h;if(r.current=void 0,u)if(u.path)if(u.markAsBlurred){const T=$r(m.formMeta,u.path);if(T){T.focused=!1;const E=y.getPath(m.formValue,u.path);T.validate(E,jt.ON_BLUR)}}else if(u.newValidators){if(a.current){const T=u.path.join(".");a.current={...a.current,[T]:u.newValidators},xs(m.formValue,m.formMeta,a.current,!0)}}else if(u.markAsSubmitted){const T=$r(m.formMeta,u.path);if(T){T.submitted=!0;const E=y.getPath(m.formValue,u.path);T.validate(E,jt.ON_SUBMIT)}}else h=xo(m.formValue,u.path),y.setPath(h,u.path,u.value);else h=u.value;if((g=u.updateFormOptions)!=null&&g.validators&&(a.current={...a.current,...u.updateFormOptions.validators},xs(m.formValue,m.formMeta,a.current,(w=(v=u.updateFormOptions)==null?void 0:v.runValidators)!=null?w:!0)),h){m.formMeta.submitted=!1,y.deepFreeze(h);const T=y.diff(m.formValue,h);for(const{type:N,key:x,parentPath:I,objects:[,k]}of T){const P=$r(m.formMeta,I);if(typeof x!="symbol"&&P){let _;switch(N){case y.DiffChange.ADDITION:P.fields[x]=Fs(k[x],[...I,x],p);break;case y.DiffChange.DELETION:Array.isArray(P.fields)?P.fields[x]=void 0:delete P.fields[x];break;case y.DiffChange.ALTERATION:_=Fs(k[x],[...I,x],p),(_ instanceof Hn&&!(P.fields[x]instanceof Hn)||!(_ instanceof Hn)&&P.fields[x]instanceof Hn)&&(P.fields[x]=_);break}}}const E=new Set;if(T.filter(N=>N.type===y.DiffChange.DELETION).reduce((N,x)=>(N.has(x.parentPath)||N.add(x.parentPath),N),E),Array.from(E).forEach(N=>{const x=$r(m.formMeta,N);Array.isArray(x.fields)&&(x.fields=x.fields.filter(I=>I!==void 0))}),a.current){xs(h,m.formMeta,a.current);const N=new Set;t&&fp(m.formMeta,t,(x,I)=>{typeof I=="function"&&(x.validate(y.getPath(h,x.path)),N.add(x))});for(const{type:x,key:I,parentPath:k,objects:[,P]}of T)if(typeof I!="symbol"){let _=m.formMeta,C=h;if(_){for(const R of k)_=_.fields[R],C=C[R],N.has(_)||_.validate(C,jt.ON_CHANGE);if(x===y.DiffChange.ADDITION||x===y.DiffChange.ALTERATION){const R=_.fields[I];if(!N.has(R)&&(_.fields[I].validate(P[I],jt.ON_CHANGE),x===y.DiffChange.ADDITION&&R.fields))for(const[L,K]of Object.entries(R.fields))K.validate(P[I][L],jt.ON_CHANGE)}}}}}return{formValue:h||m.formValue,formMeta:m.formMeta,updateForm:m.updateForm}},[]),[l,c]=U.useReducer(o,{formValue:e,formMeta:n,updateForm:f});function p(m,u,h=!1,g,v=!1){m?c({path:m,value:u,markAsBlurred:h,newValidators:g,markAsSubmitted:v}):f()}function f(m,u){if(m||u){r.current&&window.clearTimeout(r.current);const h=window.setTimeout(c,0,{value:m,updateFormOptions:u});r.current=h}else if(!(r!=null&&r.current)){const h=window.setTimeout(c,0,{});r.current=h}}return U.useEffect(()=>()=>{r.current&&window.clearTimeout(r.current)},[]),l}const it=s.forwardRef((e,t)=>{const{className:n,children:r,focusInputOnClick:a,formControl:o,formMeta:l,inputRef:c,onClick:p,...f}=e,m=s.useRef(),h=c||(t||m);function g(){h&&h!==t&&h.current&&h.current.focus()}function v(){h&&h!==t&&h.current&&l&&l instanceof jr&&l.markAsFocused()}function w(){h&&h!==t&&h.current&&l&&l instanceof jr&&l.markAsBlurred()}const T=H("sps-form-group",(o&&o.isRequired()||l&&l.isRequired())&&"sps-form-group--required",(o&&!o.isValid()||l&&l.isVisibilyInvalid())&&"sps-form-group--error",l&&l.hasPreventativeErrors()&&"sps-form-group--preventative-error",n);function E(N){a&&g(),p&&p(N)}return s.useEffect(()=>{function N(x){x.target.classList.contains("sps-form-control__clear-btn")&&x.preventDefault()}return document.addEventListener("mousedown",N),()=>{document.removeEventListener("mousedown",N)}},[]),s.createElement("div",{...f,className:T,ref:t,tabIndex:-1,onClick:E,onFocus:v,onBlur:w},r)});Object.assign(it,{displayName:"SpsFormComponentWrapper"});function hc(e){return typeof e=="object"&&e!=null&&e.nodeType===1}function Sc(e,t){return(!t||e!=="hidden")&&e!=="visible"&&e!=="clip"}function ja(e,t){if(e.clientHeight<e.scrollHeight||e.clientWidth<e.scrollWidth){var n=getComputedStyle(e,null);return Sc(n.overflowY,t)||Sc(n.overflowX,t)||function(r){var a=function(o){if(!o.ownerDocument||!o.ownerDocument.defaultView)return null;try{return o.ownerDocument.defaultView.frameElement}catch{return null}}(r);return!!a&&(a.clientHeight<r.scrollHeight||a.clientWidth<r.scrollWidth)}(e)}return!1}function ks(e,t,n,r,a,o,l,c){return o<e&&l>t||o>e&&l<t?0:o<=e&&c<=n||l>=t&&c>=n?o-e-r:l>t&&c<n||o<e&&c>n?l-t+a:0}var gc=function(e,t){var n=window,r=t.scrollMode,a=t.block,o=t.inline,l=t.boundary,c=t.skipOverflowHiddenElements,p=typeof l=="function"?l:function(Re){return Re!==l};if(!hc(e))throw new TypeError("Invalid target");for(var f,m,u=document.scrollingElement||document.documentElement,h=[],g=e;hc(g)&&p(g);){if((g=(m=(f=g).parentElement)==null?f.getRootNode().host||null:m)===u){h.push(g);break}g!=null&&g===document.body&&ja(g)&&!ja(document.documentElement)||g!=null&&ja(g,c)&&h.push(g)}for(var v=n.visualViewport?n.visualViewport.width:innerWidth,w=n.visualViewport?n.visualViewport.height:innerHeight,T=window.scrollX||pageXOffset,E=window.scrollY||pageYOffset,N=e.getBoundingClientRect(),x=N.height,I=N.width,k=N.top,P=N.right,_=N.bottom,C=N.left,R=a==="start"||a==="nearest"?k:a==="end"?_:k+x/2,L=o==="center"?C+I/2:o==="end"?P:C,K=[],Y=0;Y<h.length;Y++){var M=h[Y],W=M.getBoundingClientRect(),G=W.height,J=W.width,A=W.top,re=W.right,ce=W.bottom,O=W.left;if(r==="if-needed"&&k>=0&&C>=0&&_<=w&&P<=v&&k>=A&&_<=ce&&C>=O&&P<=re)return K;var j=getComputedStyle(M),le=parseInt(j.borderLeftWidth,10),z=parseInt(j.borderTopWidth,10),q=parseInt(j.borderRightWidth,10),V=parseInt(j.borderBottomWidth,10),ee=0,te=0,pe="offsetWidth"in M?M.offsetWidth-M.clientWidth-le-q:0,ae="offsetHeight"in M?M.offsetHeight-M.clientHeight-z-V:0,fe="offsetWidth"in M?M.offsetWidth===0?0:J/M.offsetWidth:0,oe="offsetHeight"in M?M.offsetHeight===0?0:G/M.offsetHeight:0;if(u===M)ee=a==="start"?R:a==="end"?R-w:a==="nearest"?ks(E,E+w,w,z,V,E+R,E+R+x,x):R-w/2,te=o==="start"?L:o==="center"?L-v/2:o==="end"?L-v:ks(T,T+v,v,le,q,T+L,T+L+I,I),ee=Math.max(0,ee+E),te=Math.max(0,te+T);else{ee=a==="start"?R-A-z:a==="end"?R-ce+V+ae:a==="nearest"?ks(A,ce,G,z,V+ae,R,R+x,x):R-(A+G/2)+ae/2,te=o==="start"?L-O-le:o==="center"?L-(O+J/2)+pe/2:o==="end"?L-re+q+pe:ks(O,re,J,le,q+pe,L,L+I,I);var ne=M.scrollLeft,we=M.scrollTop;R+=we-(ee=Math.max(0,Math.min(we+ee/oe,M.scrollHeight-G/oe+ae))),L+=ne-(te=Math.max(0,Math.min(ne+te/fe,M.scrollWidth-J/fe+pe)))}K.push({el:M,top:ee,left:te})}return K};function Sp(e){return e===Object(e)&&Object.keys(e).length!==0}function Dv(e,t){t===void 0&&(t="auto");var n="scrollBehavior"in document.body.style;e.forEach(function(r){var a=r.el,o=r.top,l=r.left;a.scroll&&n?a.scroll({top:o,left:l,behavior:t}):(a.scrollTop=o,a.scrollLeft=l)})}function Nv(e){return e===!1?{block:"end",inline:"nearest"}:Sp(e)?e:{block:"start",inline:"nearest"}}function gp(e,t){var n=e.isConnected||e.ownerDocument.documentElement.contains(e);if(Sp(t)&&typeof t.behavior=="function")return t.behavior(n?gc(e,t):[]);if(!!n){var r=Nv(t);return Dv(gc(e,r),r.behavior)}}const xv=Object.freeze(Object.defineProperty({__proto__:null,default:gp},Symbol.toStringTag,{value:"Module"})),He=s.createContext($.noI18nI18n),kv={alt:"string",size:"SpinnerSize",title:"string"};function zo(e){const{alt:t,className:n,size:r=$.SpinnerSize.MEDIUM,"data-testid":a,title:o,unsafelyReplaceClassName:l,...c}=e,{t:p}=s.useContext(He),f=t||o||p("design-system:spinner.defaultAltText"),m=H(l||"sps-spinner",`sps-spinner--${r}`,n);return s.createElement("i",{className:m,"data-testid":a,title:f,...c})}Object.assign(zo,{props:kv,displayName:"SpsSpinner"});const Iv=60;function Is(e){return typeof e>"u"?"inherit":`${e}px`}function qo(e){switch(e){case $.Position.TOP_LEFT:return $.Position.BOTTOM_LEFT;case $.Position.TOP_MIDDLE:return $.Position.BOTTOM_MIDDLE;case $.Position.TOP_RIGHT:return $.Position.BOTTOM_RIGHT;case $.Position.RIGHT_TOP:return $.Position.LEFT_TOP;case $.Position.RIGHT_MIDDLE:return $.Position.LEFT_MIDDLE;case $.Position.RIGHT_BOTTOM:return $.Position.LEFT_BOTTOM;case $.Position.BOTTOM_RIGHT:return $.Position.TOP_RIGHT;case $.Position.BOTTOM_MIDDLE:return $.Position.TOP_MIDDLE;case $.Position.BOTTOM_LEFT:return $.Position.TOP_LEFT;case $.Position.LEFT_BOTTOM:return $.Position.RIGHT_BOTTOM;case $.Position.LEFT_MIDDLE:return $.Position.RIGHT_MIDDLE;case $.Position.LEFT_TOP:return $.Position.RIGHT_TOP}}function Mv(e,t,n,r,a,o,l,c){const p=l&&l.current,f=p?p.scrollTop:window.pageYOffset,m=c?0:f,u=p?p.scrollLeft:window.pageXOffset,h=c?0:u,[g,v]=e.split(" ");let w,T,E,N;switch(g){case"top":E=t.height-n.top-m-o[0];break;case"left":T=t.width-n.left-h-o[0];break;case"right":N=n.right+h-o[0];break;case"bottom":w=n.bottom+m-o[0];break;default:throw new Error(`Invalid position ${e}`)}switch(v){case"left":N=n.left+h+o[1];break;case"top":w=n.top+m+o[1];break;case"middle":g==="top"||g==="bottom"?N=n.left+h+n.width/2-a/2+o[1]:(g==="left"||g==="right")&&(w=n.top+m+n.height/2-r.height/2+o[1]);break;case"bottom":E=t.height-n.bottom-m+o[1];break;case"right":T=t.width-n.right-h+o[1];break;default:throw new Error(`Invalid position ${e}`)}return[w,T,E,N]}function Un(e,t,n,{altPosition:r,setMinWidth:a=!1,setWidth:o=!1,parentElementRef:l,fixed:c=!1,offsets:p=[0,0]}){if(e.current&&t.current){const f=Math.max(document.documentElement.clientHeight,window.innerHeight||0),m=document.documentElement.getBoundingClientRect().width,u=l&&l.current?l.current:document.documentElement,h=c?{width:m,height:f,top:0,left:0,bottom:f,right:m}:u.getBoundingClientRect(),g=e.current.getBoundingClientRect(),v=t.current.getBoundingClientRect(),[w]=n.split(" ");let T=n;r&&(w==="top"&&v.top-g.height<Iv||w==="right"&&v.right+g.width>m||w==="bottom"&&v.bottom+g.height>f||w==="left"&&v.left-g.width<0)&&(T=r);const E=a?Math.max(v.width,g.width):g.width,N=o?v.width:E,[x,I,k,P]=Mv(T,h,v,g,N,p,l,c),_={top:Is(x),right:Is(I),bottom:Is(k),left:Is(P)};return c&&(_.position="fixed",_.zIndex=$.ZStratum.BAR),a&&(_.minWidth=`${v.width}px`),o&&(_.width=`${v.width}px`),[_,T===r]}return[{},!1]}const Lt=U.createContext(null);function wr(e,t=[]){const n=U.useContext(Lt);return U.useMemo(()=>r=>{const o=n&&n.parentElementRef&&n.parentElementRef.current||document.body;let l=null,c=o.lastElementChild;for(;c&&c!==o.firstElementChild;){if(c.hasAttribute("data-portalid")&&c.getAttribute("data-portalid")===e){l=c;break}c=c.previousElementSibling}if(l)o.contains(l)||o.appendChild(l);else{l=document.createElement("div"),l.setAttribute("data-portalid",e);for(const p of t)l.classList.add(p);o.appendChild(l)}return Qs.createPortal(r,l)},[n])}async function bc(e,t,n,r,a,o){const l=typeof e.options=="function"?e.options(t.value):e.options||[],c=l instanceof Promise,p=u=>u.replace(/([.?*+^$[\]\\(){}|-])/g,"");n({pending:c}),o.current=c?l:null;const f=c?await l||[]:l||[];if(c&&o.current!==l)return;let m=Array.from(f).filter(Boolean).map(u=>new $.SpsOptionListOption(u,typeof u=="function"?{textKey:"label",captionKey:"caption"}:{textKey:e.textKey,captionKey:e.captionKey}));if(e.nullOption&&m.unshift(new $.SpsOptionListOption(null,{text:e.nullOption})),t.value&&!e.disableDefaultOptionsFiltering){const u=p(t.value);n({replacementPattern:new RegExp(`(${u})`,"ig")}),m=m.filter(h=>{const g=new RegExp(u,"i"),v=p(h.text);return e.filterByTextAndCaptionKey?g.test(v)||g.test(p(h.caption)):g.test(v)})}else n({replacementPattern:null});if(e.disabledOptions)for(const u of m)e.disabledOptions.includes(u.value)&&(u.disabled=!0);r(Object.freeze(m)),e.onOptionListChanged&&e.onOptionListChanged(m.length),a(m.some(u=>u.value&&!!u.value.icon)),n({pending:!1})}function _v(e,t,n){const[r,a]=s.useState(Object.freeze([])),[o,l]=s.useState(!1),c=s.useRef(null),p=s.useRef(e.options);(typeof e.options!="function"||e.disableOptionsMemoization)&&(p.current=e.options);const f=s.useMemo(()=>typeof p.current=="function"?y.debounce(bc,typeof e.searchDebounce<"u"?e.searchDebounce:500):bc,[p.current,e.disabledOptions]);return s.useEffect(()=>{f(e,t,n,a,l,c)},[p.current,t.value,e.disabledOptions]),[r,o]}class Dn{constructor(t,n){Vt(this,"nativeEvent");Vt(this,"currentTarget");Vt(this,"isPgStoppedInternal",!1);this.target=t,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 Rv(e,t){return{...e,...t}}function Jt(e){return U.useReducer(Rv,e)}function Ov({hideInlineSearch:e,options:t,onSearchChange:n,search:r="",searchPlaceholder:a="Search\u2026",searchInputRef:o}){const[l,c]=Jt({isAsync:typeof t=="function",pending:!1,value:r,replacementPattern:null}),p=s.useCallback(g=>{c({value:g.target.value}),n&&n(g)},[n]),f=s.useCallback(g=>{g.nativeEvent.stopImmediatePropagation(),g.stopPropagation()},[]),m=s.useCallback(g=>{g.nativeEvent.stopImmediatePropagation(),c({value:""}),o!=null&&o.current&&(n&&n(new Dn(o.current)),o.current.focus())},[n]),u=g=>{!g||["Tab","Escape","Enter","Up","ArrowUp","Down","ArrowDown"].includes(g.key)||g.stopPropagation()};return s.useEffect(()=>{c({value:r})},[r]),[l.isAsync&&!e?s.createElement("div",{className:"sps-option-list__search sps-form-group sps-text-input"},s.createElement("div",{className:"sps-form-control"},!l.value&&s.createElement("i",{className:"sps-icon sps-icon-filter sps-text-input__icon"}),s.createElement("input",{type:"text",className:"sps-text-input__input",placeholder:a,ref:o,value:l.value,onChange:p,onClick:f,onKeyDown:u}),l.value&&s.createElement("i",{className:"sps-icon sps-icon-x-circle sps-form-control__clear-btn",onClick:m}))):s.createElement(s.Fragment,null),l,c]}const Lv=gp||xv,Pv=["Tab","Escape","Enter","Up","ArrowUp","Down","ArrowDown"],Bv=["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 Av(e,t,n){return n?(e&&e[n])===(t&&t[n]):e===t}function vc(e,t,n){return typeof n.value=="function"&&n.disabled?!0:t?!!(e!=null&&e.find(r=>{var a;return r[t]&&r[t]===((a=n==null?void 0:n.value)==null?void 0:a[t])})):!1}const rs=s.forwardRef((e,t)=>{const{captionKey:n,comparisonKey:r,disabledOptions:a,options:o,tall:l,textKey:c,valueKey:p,zeroState:f,hideInlineSearch:m,onSearchChange:u,search:h,searchDebounce:g,searchPlaceholder:v,onSpecialActionSelect:w,attachTo:T,className:E,conformWidth:N,id:x,ignoreWidthStyles:I,isOpen:k,keepOpen:P,keyDown:_,nullOption:C,onOptionListChanged:R,onOptionSelected:L,onPositionFlip:K,onSelfToggle:Y,optionRole:M,positionOverride:W,selectedOption:G,specialAction:J,unsafelyReplaceClassName:A,loading:re,filterByTextAndCaptionKey:ce,maxHeightPx:O,maxHeightRem:j,disableOptionsMemoization:le,disableDefaultOptionsFiltering:z,"data-testid":q,...V}=e,ee=s.useMemo(()=>J?new $.SpsOptionListOption(J,{textKey:"label",captionKey:"caption"}):null,[J]),[te,pe]=s.useState(-1),[ae,fe]=s.useState(k),oe=t||s.useRef(null),ne=s.useRef(null),we=s.useRef(null),Re=wr("sps-option-list-portal"),st=s.useContext(Lt),[gt,at]=W||[$.Position.BOTTOM_LEFT,$.Position.TOP_LEFT],[[ye,Be],Xe]=s.useState([{},!1]),he=s.useRef(null),[Ke,Ae,lt]=Ov({...e,searchInputRef:he}),[qe,se]=_v(e,Ae,lt);s.useEffect(()=>{Xe(ae?Un(oe,T,gt,{altPosition:at,setMinWidth:!I,setWidth:!I&&N,...st}):[{},!1])},[ae,gt,at,qe]),s.useEffect(()=>{const ve=()=>{ae&&Xe(Un(oe,T,gt,{altPosition:at,setMinWidth:!I,setWidth:!I&&N,...st}))};return document.addEventListener("scroll",ve),()=>{document.removeEventListener("scroll",ve)}},[ae]),s.useEffect(()=>{pe(-1)},[Ae]);const ke=H(A||"sps-option-list","z-stratum-dropdown",ae&&"sps-option-list--open",Ae.isAsync&&"sps-option-list--searchable",Be&&"sps-option-list--opens-upward",J&&J.label&&"sps-option-list--has-special-action",E),Ne=H(A||"sps-option-list__options",l&&"sps-option-list__options--tall"),Je=s.useCallback(()=>{ae||(fe(!0),he.current&&he.current.focus(),pe(-1),Y&&Y(!0))},[ae,Y]),Se=s.useCallback(()=>{ae&&(fe(!1),pe(-1),Y&&Y(!1))},[ae,Y]),et=s.useCallback((ve,Te)=>{Te||ve&&!ve.disabled&&(typeof ve.value=="function"?(ve.value(),w&&w()):typeof L=="function"&&L(ve.value),P||Se())},[L,Se]),yt=s.useCallback((ve,Te,ze)=>{ve.stopPropagation(),et(Te,ze)},[et]),Oe=s.useRef(a||[]);Oe.current=a||[];const ut=s.useCallback(ve=>{switch(ve.key){case"Tab":case"Escape":Se();break;case"Enter":if(te>-1){const Te=qe[te]||ee;ve.preventDefault();const ze=!!Te&&vc(Oe.current,r||"",Te);!ze&&Te&&typeof L=="function"&&typeof Te.value=="function"?Te.value():Te&&et(Te,ze)}break;case"Up":case"ArrowUp":{let Te=te;Be?te<=-1?Te=qe.length-1:te===0?J&&(Te=qe.length):te<qe.length&&(Te=te-1):te>-1&&(Te=te-1),Te!==te&&(ve.preventDefault(),pe(Te));break}case"Down":case"ArrowDown":{Je();let Te=te;Be?te!==-1&&(te>=qe.length?Te=0:te===qe.length-1?Te=-1:Te=te+1):te<qe.length-1+Number(!!J)&&(Te=te+1),Te!==te&&(ve.preventDefault(),pe(Te));break}default:Je()}},[Se,Je,te,et,L,Be,qe]),Ut=s.useCallback(ve=>{const Te=qe.findIndex(ze=>{if(ze.textKey){const Bt=ze.textKey;return ze.value[Bt].toLowerCase().charAt([0])===ve.key.toLocaleLowerCase()}return ze.value.toString().toLowerCase().charAt([0])===ve.key.toLocaleLowerCase()});Te>-1&&pe(Te)},[qe]),xt=s.useCallback(ve=>{!ve||(Pv.includes(ve.key)?ut(ve):Bv.includes(ve.key)&&!m&&Ut(ve))},[Se,Je,te,et,L,Be,qe]);s.useEffect(()=>{if(st!==null&&document.getElementsByClassName("sps-modal__body").length>0){const ve=()=>{Y&&Y(!1)},Te=document.getElementsByClassName("sps-modal__body")[0];return Te.addEventListener("scroll",ve),()=>{Te.removeEventListener("scroll",ve)}}},[]),s.useEffect(()=>{we.current&&Lv(we.current,{scrollMode:"if-needed",block:"nearest",inline:"nearest"})},[te]),s.useEffect(()=>{fe(k),k?he.current&&he.current.focus():pe(-1)},[k]),s.useEffect(()=>{_&&xt(_)},[_]),s.useEffect(()=>{!ae&&ne.current&&(lt({value:""}),ne.current.scrollTop=0),ae&&K&&K(Be)},[ae]);const Mn=O?O/16:j,xa=Mn?{maxHeight:`${Mn}rem`}:{};function _n(ve,Te){return Te?s.createElement(s.Fragment,null,ve.split(Te).map((ze,Bt)=>Te.test(ze)?s.createElement("u",{key:Bt},ze):s.createElement(s.Fragment,{key:Bt},ze))):s.createElement(s.Fragment,null,ve)}return Re(s.createElement("div",{className:ke,id:x,"aria-activedescendant":te>-1?`${x}-option-${te}`:"",tabIndex:-1,ref:oe,style:ye,onMouseLeave:()=>pe(-1),"data-testid":q,...V},Ke,s.createElement("div",{className:Ne,ref:ne,"data-testid":`${q}-options`,style:xa},!re&&!Ae.pending&&f&&qe.length===0&&s.createElement("div",{className:"sps-option-list__zero-state"},f),(re||Ae.pending)&&s.createElement("div",{className:"sps-option-list__loading"},s.createElement(zo,null)),!re&&!Ae.pending&&qe.map((ve,Te)=>{const ze=`${x}-option-${Te}`,Bt=Av(ve.value,G,r),Rn=vc(Oe.current,r||"",ve);return s.createElement("a",{key:ze,id:ze,role:M,"aria-selected":Bt,href:ve.href,className:H("sps-option-list__option",ve.caption&&"sps-option-list__option--has-caption",ve.disabled&&"sps-option-list__option--disabled",ve.bold&&"sps-option-list__option--bold",(Bt||Rn)&&"sps-option-list__option--selected",te===Te&&"sps-option-list__option--highlighted"),onClick:ue=>yt(ue,ve,Rn),onMouseOver:()=>pe(Te),tabIndex:-1,ref:te===Te?we:null,"data-testid":`${q}-option-${Te}`},ve.value&&ve.value.icon&&s.createElement("i",{className:H("sps-icon","sps-option-list__option-icon",`sps-icon-${String(ve.value.icon)}`)}),(!ve.value||!ve.value.icon&&se)&&s.createElement("span",{className:"sps-option-list__option-icon-spacer"}),s.createElement("span",null,_n(ve.text,Ae.replacementPattern)),ve.caption&&s.createElement("div",{className:"sps-option-list__option-caption"},s.createElement("span",null,_n(ve.caption,Ae.replacementPattern))))})),ee&&(J==null?void 0:J.label)&&s.createElement("a",{className:H("sps-option-list__option","sps-option-list__special-action",te===qe.length&&"sps-option-list__option--highlighted",J.disabled&&"sps-option-list__special-action--disabled"),href:ee.href,target:ee.href&&J.newTab?"_blank":"_self",onClick:ve=>yt(ve,ee),onMouseOver:()=>pe(qe.length),"data-testid":`${q}-special-action`},J.icon&&s.createElement("i",{className:H("sps-icon","sps-option-list__option-icon",`sps-icon-${String(J.icon)}`)}),!J.icon&&se&&s.createElement("span",{className:"sps-option-list__option-icon-spacer"}),s.createElement("span",null,J.label))))});Object.assign(rs,{displayName:"SpsOptionList"});function Fv(e,t,n=[]){return s.useMemo(()=>{function r(a){return s.createElement(e,{...a,...t},a.children)}return r},n)}function wt(e){return typeof e=="function"?e():e}const bp=function({children:e,elements:t}){if(t.length===0)return s.createElement(s.Fragment,null,e);const[n,r]=Array.isArray(t[0])?t[0]:[t[0]];return s.createElement(n,{...r!=null?r:{}},s.createElement(bp,{elements:t.slice(1)},e))},vp=function({children:e,providers:t=[],...n}){return s.createElement("div",{...n},s.createElement(bp,{elements:t},e))},Vv=function({children:e,className:t,...n}){return s.createElement(vp,{className:`sps-app ${t}`,...n},e)};function Pt(e=[],t=[]){const n=Array.isArray(e)?y.flatten(e):[e],r=t.map(o=>Array.isArray(o)?o:[o]),a=new Array(r.length+1).fill(null).map(()=>[]);for(const o of n){let l=!1;for(let c=0;c<r.length;c+=1)for(const{type:p,props:f={}}of r[c])if(o.type===p&&Object.keys(f).every(u=>f[u]===o.props[u])){l=!0,a[c].push(o);break}l||a[a.length-1].push(o)}return a}function yp(e,t,n){const r=Object.entries(t).filter(([,o])=>typeof o!="string"&&o.deprecated).map(([o])=>o),a=r.map(o=>n[o]);s.useEffect(()=>{a.find(o=>typeof o<"u")&&console.warn(`The following prop(s) of ${e} are deprecated: ${r.join(", ")}`)},a)}function Jo(e,t){const n=U.useRef(!1);U.useEffect(()=>{if(n.current)return e();n.current=!0},t)}function ko(e,t,n){const r=s.useRef(t(...n));s.useEffect(()=>(document.addEventListener(e,r.current),()=>document.removeEventListener(e,r.current)),[]),s.useEffect(()=>{document.removeEventListener(e,r.current),r.current=t(...n),document.addEventListener(e,r.current)},n)}function yc(e,t,n){return function(a){var o,l;!((o=e.current)!=null&&o.contains(a.target))&&!((l=t.current)!=null&&l.contains(a.target))&&n()}}function Cr(e,t,n){const r=s.useRef(!1),[a,o]=s.useState(!1),l=s.useCallback(()=>{r.current?r.current=!1:o(!0)},[]),c=s.useCallback((p=!1)=>{o(!1),r.current=p,n&&n()},[]);return ko("mousedown",yc,[e,t,c]),ko("pointerdown",yc,[e,t,c]),{showPopup:a,doShowPopup:l,doHidePopup:c}}const $v={debounce:"number",disabled:"boolean",formMeta:"SpsFormFieldMeta<string>",icon:"SpsIcon",onChange:"React.ChangeEventHandler",onSelectionChange:"(newValue: string) => void",placeholder:"string",suggestions:{type:`
2
2
  Eventually<Iterable<string>>
3
3
  | ((filter?: string) => Eventually<Iterable<string>>)
4
- `,required:!0},tallOptionList:"boolean",value:"string",zeroState:"string",loading:"boolean",maxHeightOptionListPx:"number",maxHeightOptionListRem:"number",disableOptionsMemoization:"boolean",inputNotClearable:"boolean",autoFocusOnSelection:"boolean"};function zt({className:e,debounce:t=0,disabled:n,formControl:r,formMeta:a,onChange:o,onSelectionChange:l,icon:c,id:p,placeholder:f="",suggestions:m,unsafelyReplaceClassName:u,tallOptionList:h,value:g="",zeroState:v,loading:w,maxHeightOptionListPx:T,maxHeightOptionListRem:E,disableOptionsMemoization:N,inputNotClearable:x,autoFocusOnSelection:I,"data-testid":k,...P}){const _=a||r,{wrapperId:C,controlId:R}=vt(p,_),[L,K]=Jt({keyDown:null,opensUpward:!1}),Y=s.useRef(null),M=s.useRef(null),W=s.useRef(null),{showPopup:G,doShowPopup:J,doHidePopup:A}=Cr(Y,W);function re(V,ee,te=!1){_&&(_.setValue(V),_.markAsDirty()),l&&te?l(V):o&&o(ee||new Dn({value:V}))}function ce(V){M.current&&(M.current.value="",re("")),V.stopPropagation()}function O(V){re(V.target.value,V)}function j(V){n||(["Up","ArrowUp","Down","ArrowDown","Enter"].indexOf(V.key)>-1&&(V.preventDefault(),V.persist()),V.stopPropagation(),K({keyDown:V})),V.key==="Tab"&&A()}function le(V){V?J():A()}function z(V){K({opensUpward:V})}const q=H(u||"sps-autocomplete",G&&"sps-autocomplete--open",G&&"z-stratum-dropdown",L.opensUpward&&"sps-autocomplete--opens-upward",n&&"sps-form-control--disabled",e);return s.createElement(it,{id:C,className:q,formControl:r,formMeta:a,inputRef:M,ref:Y,focusInputOnClick:!0,onClick:V=>V.nativeEvent.stopImmediatePropagation(),"data-testId":`${k}`},s.createElement("div",{className:"sps-text-input"},s.createElement("div",{className:"sps-form-control"},c&&s.createElement("i",{className:H("sps-text-input__icon","sps-icon",`sps-icon-${c}`)}),s.createElement("input",{type:"text",ref:M,value:g,className:"sps-text-input__input",placeholder:f,onFocus:J,onClick:J,onChange:O,onKeyDown:j,disabled:n,id:R,"data-testid":`${k}__input`,...P}),g&&!n&&!x&&s.createElement("i",{"aria-label":"clear",className:"sps-icon sps-icon-x-circle sps-form-control__clear-btn",onClick:V=>ce(V)}))),s.createElement(rs,{id:`${C}_options`,ref:W,attachTo:Y,isOpen:G,options:m,hideInlineSearch:!0,keyDown:L.keyDown,onOptionSelected:V=>{var ee;re(V,void 0,!0),I&&((ee=M.current)==null||ee.focus())},onPositionFlip:z,onSelfToggle:le,offsets:[1,0],search:g,searchDebounce:t,tall:h,zeroState:v,loading:w,maxHeightPx:T,maxHeightRem:E,disableOptionsMemoization:N}))}Object.assign(zt,{props:$v,displayName:"SpsAutocomplete"});const Tp={basic:{label:"Basic",examples:{basic:{react:y.code`
4
+ `,required:!0},tallOptionList:"boolean",value:"string",zeroState:"string",loading:"boolean",maxHeightOptionListPx:"number",maxHeightOptionListRem:"number",disableOptionsMemoization:"boolean",inputNotClearable:"boolean",autoFocusOnSelection:"boolean"};function zt({className:e,debounce:t=0,disabled:n,formControl:r,formMeta:a,onChange:o,onSelectionChange:l,icon:c,id:p,placeholder:f="",suggestions:m,unsafelyReplaceClassName:u,tallOptionList:h,value:g="",zeroState:v,loading:w,maxHeightOptionListPx:T,maxHeightOptionListRem:E,disableOptionsMemoization:N,inputNotClearable:x,autoFocusOnSelection:I,"data-testid":k,...P}){const _=a||r,{wrapperId:C,controlId:R}=vt(p,_),[L,K]=Jt({keyDown:null,opensUpward:!1}),Y=s.useRef(null),M=s.useRef(null),W=s.useRef(null),{showPopup:G,doShowPopup:J,doHidePopup:A}=Cr(Y,W);function re(V,ee,te=!1){_&&(_.setValue(V),_.markAsDirty()),l&&te?l(V):o&&o(ee||new Dn({value:V}))}function ce(V){M.current&&(M.current.value="",re("")),V.stopPropagation()}function O(V){re(V.target.value,V)}function j(V){n||(["Up","ArrowUp","Down","ArrowDown","Enter"].indexOf(V.key)>-1&&(V.preventDefault(),V.persist()),V.stopPropagation(),K({keyDown:V})),V.key==="Tab"&&A()}function le(V){V?J():A()}function z(V){K({opensUpward:V})}const q=H(u||"sps-autocomplete",G&&"sps-autocomplete--open",G&&"z-stratum-dropdown",L.opensUpward&&"sps-autocomplete--opens-upward",n&&"sps-form-control--disabled",e);return s.createElement(it,{id:C,className:q,formControl:r,formMeta:a,inputRef:M,ref:Y,focusInputOnClick:!0,onClick:V=>V.nativeEvent.stopImmediatePropagation(),"data-testid":`${k}`},s.createElement("div",{className:"sps-text-input"},s.createElement("div",{className:"sps-form-control"},c&&s.createElement("i",{className:H("sps-text-input__icon","sps-icon",`sps-icon-${c}`)}),s.createElement("input",{type:"text",ref:M,value:g,className:"sps-text-input__input",placeholder:f,onFocus:J,onClick:J,onChange:O,onKeyDown:j,disabled:n,id:R,"data-testid":`${k}__input`,...P}),g&&!n&&!x&&s.createElement("i",{"aria-label":"clear",className:"sps-icon sps-icon-x-circle sps-form-control__clear-btn",onClick:V=>ce(V)}))),s.createElement(rs,{id:`${C}_options`,ref:W,attachTo:Y,isOpen:G,options:m,hideInlineSearch:!0,keyDown:L.keyDown,onOptionSelected:V=>{var ee;re(V,void 0,!0),I&&((ee=M.current)==null||ee.focus())},onPositionFlip:z,onSelfToggle:le,offsets:[1,0],search:g,searchDebounce:t,tall:h,zeroState:v,loading:w,maxHeightPx:T,maxHeightRem:E,disableOptionsMemoization:N}))}Object.assign(zt,{props:$v,displayName:"SpsAutocomplete"});const Tp={basic:{label:"Basic",examples:{basic:{react:y.code`
5
5
  import { SpsAutocomplete } from "@spscommerce/ds-react";
6
6
 
7
7
  function DemoComponent() {
package/lib/index.es.js CHANGED
@@ -1854,7 +1854,7 @@ function gn({
1854
1854
  ref: G,
1855
1855
  focusInputOnClick: !0,
1856
1856
  onClick: (V) => V.nativeEvent.stopImmediatePropagation(),
1857
- "data-testId": `${k}`
1857
+ "data-testid": `${k}`
1858
1858
  },
1859
1859
  /* @__PURE__ */ s.createElement("div", { className: "sps-text-input" }, /* @__PURE__ */ s.createElement("div", { className: "sps-form-control" }, c && /* @__PURE__ */ s.createElement("i", { className: K("sps-text-input__icon", "sps-icon", `sps-icon-${c}`) }), /* @__PURE__ */ s.createElement(
1860
1860
  "input",
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": "8.4.6",
4
+ "version": "8.4.8",
5
5
  "author": "SPS Commerce",
6
6
  "license": "UNLICENSED",
7
7
  "repository": "https://github.com/spscommerce/woodland/tree/main/packages/@spscommerce/ds-react",
@@ -46,11 +46,11 @@
46
46
  "moment-timezone": "^0.5.28",
47
47
  "react": "^16.9.0",
48
48
  "react-dom": "^16.9.0",
49
- "@sps-woodland/illustrations": "8.4.6",
50
- "@sps-woodland/tabs": "8.4.6",
51
- "@spscommerce/ds-colors": "8.4.6",
52
- "@spscommerce/ds-shared": "8.4.6",
53
- "@spscommerce/positioning": "8.4.6"
49
+ "@sps-woodland/illustrations": "8.4.8",
50
+ "@sps-woodland/tabs": "8.4.8",
51
+ "@spscommerce/ds-colors": "8.4.8",
52
+ "@spscommerce/ds-shared": "8.4.8",
53
+ "@spscommerce/positioning": "8.4.8"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@react-spectrum/provider": "^3.4.1",
@@ -72,12 +72,12 @@
72
72
  "raf-stub": "^2.0.2",
73
73
  "react": "^16.9.0",
74
74
  "react-dom": "^16.9.0",
75
- "@sps-woodland/illustrations": "8.4.6",
76
- "@sps-woodland/tabs": "8.4.6",
77
- "@spscommerce/ds-colors": "8.4.6",
78
- "@spscommerce/ds-shared": "8.4.6",
79
- "@spscommerce/positioning": "8.4.6",
80
- "test": "8.4.6"
75
+ "@sps-woodland/illustrations": "8.4.8",
76
+ "@sps-woodland/tabs": "8.4.8",
77
+ "@spscommerce/ds-colors": "8.4.8",
78
+ "@spscommerce/ds-shared": "8.4.8",
79
+ "@spscommerce/positioning": "8.4.8",
80
+ "test": "8.4.8"
81
81
  },
82
82
  "scripts": {
83
83
  "build": "pnpm run build:js && pnpm run build:types",