@spscommerce/ds-react 8.53.13 → 8.53.15
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.js +1 -2
- package/lib/index.umd.cjs +1 -1
- package/package.json +13 -13
package/lib/index.js
CHANGED
|
@@ -21,8 +21,7 @@ function A() {
|
|
|
21
21
|
for (var e, t, n = 0, r = "", a = arguments.length; n < a; n++) (e = arguments[n]) && (t = Xl(e)) && (r && (r += " "), r += t);
|
|
22
22
|
return r;
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
let Qe = (e = 21) => {
|
|
24
|
+
let Hu = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", Qe = (e = 21) => {
|
|
26
25
|
let t = "", n = crypto.getRandomValues(new Uint8Array(e |= 0));
|
|
27
26
|
for (; e--; )
|
|
28
27
|
t += Hu[n[e] & 63];
|
package/lib/index.umd.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(x,T){typeof exports=="object"&&typeof module<"u"?T(exports,require("react"),require("@spscommerce/utils"),require("moment-timezone"),require("@spscommerce/ds-shared"),require("@spscommerce/i18n"),require("react-dom"),require("@spscommerce/ds-colors"),require("@sps-woodland/illustrations")):typeof define=="function"&&define.amd?define(["exports","react","@spscommerce/utils","moment-timezone","@spscommerce/ds-shared","@spscommerce/i18n","react-dom","@spscommerce/ds-colors","@sps-woodland/illustrations"],T):(x=typeof globalThis<"u"?globalThis:x||self,T(x.DSReact={},x.react,x.spscommerceUtils,x.momentTimezone,x.spscommerceDsShared,x.spscommerceI18n,x.reactDom,x.spscommerceDsColors,x.spsWoodlandIllustrations))})(this,(function(x,T,S,xe,A,Se,Ln,kr,bi){"use strict";function vi(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const r=vi(T),pn=vi(xe);function yi(e){var t,n,o="";if(typeof e=="string"||typeof e=="number")o+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(t=0;t<a;t++)e[t]&&(n=yi(e[t]))&&(o&&(o+=" "),o+=n)}else for(n in e)e[n]&&(o&&(o+=" "),o+=n);return o}function K(){for(var e,t,n=0,o="",a=arguments.length;n<a;n++)(e=arguments[n])&&(t=yi(e))&&(o&&(o+=" "),o+=t);return o}const Mm="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let We=(e=21)=>{let t="",n=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)t+=Mm[n[e]&63];return t};function Rt(e){return T.useRef(e||We())}function Ge(e,t){const n=Rt(e),o=T.useRef(`${n.current}_ctrl`);return T.useEffect(()=>{t&&(t.id=o.current,t.update())},[t]),{wrapperId:n.current||void 0,controlId:o.current}}function Mr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Lr,Ei;function Lm(){if(Ei)return Lr;Ei=1;var e="[object Object]";function t(p){var f=!1;if(p!=null&&typeof p.toString!="function")try{f=!!(p+"")}catch{}return f}function n(p,f){return function(g){return p(f(g))}}var o=Function.prototype,a=Object.prototype,s=o.toString,i=a.hasOwnProperty,l=s.call(Object),c=a.toString,d=n(Object.getPrototypeOf,Object);function m(p){return!!p&&typeof p=="object"}function u(p){if(!m(p)||c.call(p)!=e||t(p))return!1;var f=d(p);if(f===null)return!0;var g=i.call(f,"constructor")&&f.constructor;return typeof g=="function"&&g instanceof g&&s.call(g)==l}return Lr=u,Lr}var _m=Lm();const Ti=Mr(_m),Ze=new Set,un=new Set,wt=new Set,ho=new Set;function wi(e){Ze.has(e)||wt.has(e)||ho.has(e)||un.add(e)}function Ci(e){Ze.has(e)||wt.has(e)||un.has(e)||ho.add(e)}const Fe=pn.default||pn,mn="MM/DD/YYYY",Pm="MM/DD/YYYY hh:mm A",Bm="MM/DD/YYYY HH:mm",Om="hh:mm A",Rm="HH:mm",Fm=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/,_n=Symbol("Date Parse Error");function fn(e){return Fe.isMoment(e)?e.year()*1e4+(e.month()+1)*100+e.date():e.year*1e4+e.month*100+e.date}const j=Object.freeze({createFrom(e,t){if(!e)return null;if(typeof e=="string"){if(t){const n=Fe(e,t,!0);if(n.isValid())return Object.freeze({year:n.year(),month:n.month()+1,date:n.date()})}else{const n=Fm.exec(e);if(n){const[,o,a,s]=n;return Object.freeze({year:Number(s),month:Number(o),date:Number(a)})}}return Object.freeze({[_n]:!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,t){if(!e)return null;let n=null;return typeof e=="string"?t?n=Fe(e,t,!0):n=Fe(e):Fe.isMoment(e)?n=e:n=j.toMoment(e),n!==null&&Fe.isMoment(n)&&n.isValid()?n:Object.freeze({[_n]:!0,year:void 0,month:void 0,date:void 0})},getRangeSeparator(e){return e?.includes("-")?"/":"-"},createRangeFrom(e,t){if(!e)return null;if(t){const n=j.getRangeSeparator(t),o=new RegExp(`[^\\d]*${n}[^\\d]*`);return e.split(o).slice(0,2).map(a=>j.createFrom(a,t))}else return e.split(/[^\d]*-[^\d]*/).slice(0,2).map(n=>j.createFrom(n))},isValid(e){return e?Fe.isMoment(e)?e.isValid():typeof e=="object"&&typeof e.year=="number"&&typeof e.month=="number"&&typeof e.date=="number"&&j.toMoment(e)?.isValid():!1},nullifyInvalidDate(e){return j.isValid(e)?e:null},toMoment(e){return e?Fe.isMoment(e)?e:Fe({...e,month:e.month-1}):null},toString(e,t){const n=j.toMoment(e);return n&&n.isValid()?n.format(t||mn):""},toStringRange(e,t){if(!e)return"";const n=j.getRangeSeparator(t);return e.slice(0,2).map(o=>j.toString(o,t)).join(n)},toDateTimeString(e,t=!1,n){return e&&Fe.isMoment(e)&&e.isValid()?n?t?e.format(`${n} ${Rm}`):e.format(`${n} ${Om}`):t?e.format(Bm):e.format(Pm):""},toDateTimeStringRange(e,t=!1,n){if(!e)return"";const o=j.getRangeSeparator(n);return e.map(a=>j.toDateTimeString(a,t,n)).join(o)},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:fn(e)>fn(t)},isBefore(e,t){return!e||!t?null:fn(e)<fn(t)},isInRange(e,t,n=!0){if(!e||!t||!t[0]||!t[1])return null;const o=fn(e),[a,s]=t.map(fn);return a&&s&&(n&&o>=a&&o<=s||!n&&o>a&&o<s)},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,t){if(typeof e.definition=="function")return e.definition();const n=Fe(),o=n.clone().subtract(Fe.duration(e.definition));return[j.createFrom(o,t),j.createFrom(n,t)]},createDateTimeRangeFromPreset(e){if(typeof e.definition=="function")return e.definition();const t=Fe().subtract(Fe.duration(e.definition)).startOf("day"),n=Fe().endOf("day");return[t,n]},splitMomentInDateTimeParts(e,t=!1,n,o=!1){let a="";t?a=o?"23:59":"00:00":a=o?"11:59":"12:00";const s=o?"PM":"AM";return e&&Fe.isMoment(e)&&e.isValid()?j.toDateTimeString(e,t,n).split(" "):["",a,t?void 0:s]},getCurrentMoment(){return Fe()},validateTimeString(e,t=!1){if(!e)return!0;const n=e.split(":"),o=n[0]||"0",a=n[1]||"0",s=Number.isNaN(Number(o))?NaN:parseInt(o,10),i=Number.isNaN(Number(a))?NaN:parseInt(a,10),l=n.length<=2&&o.length<=2&&a.length<=2;return t?l&&s>=0&&s<=23&&i>=0&&i<=59:l&&(!Number.isNaN(s)&&o.length===1||s>=1)&&s<=12&&i>=0&&i<=59},padIncompleteTimeString(e,t=!1){if(!e)return"";const n=e.split(":"),o=parseInt(n[0]||"0",10),a=parseInt(n[1]||"0",10);if(t){const s=o<10?`0${o}`:`${o}`,i=a<10?`0${a}`:`${a}`;return`${s}:${i}`}else{const s=o===0?"12":o<10?`0${o}`:`${o}`,i=a<10?`0${a}`:`${a}`;return`${s}:${i}`}}}),_r=["01:00","02:00","03:00","04:00","05:00","06:00","07:00","08:00","09:00","10:00","11:00","12:00"],Pr=["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"];let bo=mn;function Di(e){bo=e}const Pn=function(t){if(Array.isArray(t)){const n=Pn(t[0]),o=Pn(t[1]);return n||o}if(t&&t.hasOwnProperty("year")){if(t[_n])return{dateFormat:bo};if(!j.isValid(t))return{dateValidity:!0}}return null};Ze.add("dateFormat"),Ze.add("dateValidity");const Ni=function(t){if(Array.isArray(t)){const n=Pn(t);if(n)return n;if(t&&j.isBefore(t[1],t[0]))return{dateRangeOrder:!0}}return null};Ze.add("dateRangeOrder");const Ii=function({minDate:t,maxDate:n}){function o(a){const s=j.isBefore(a,t),i=j.isAfter(a,n),l={minExceeded:s?j.toString(t,bo):null,maxExceeded:i?j.toString(n,bo):null};return s||i?{dateConstraint:l}:null}return function(s){if(!s)return null;if(Array.isArray(s)){const i=o(s[0]),l=o(s[1]);return i||l}return s.hasOwnProperty("year")?o(s):null}};Ze.add("dateConstraint");const Am=Object.freeze(Object.defineProperty({__proto__:null,date:Pn,dateConstraint:Ii,dateRange:Ni,setDateFormat:Di},Symbol.toStringTag,{value:"Module"}));function Mt(e,t){for(const n of[].concat(e)){const o=t(n);if(o)return o}return null}const $m=function(t){function n(o){return Number(o)>=t?null:{min:t}}return o=>Mt(o,n)};Ze.add("min");const Vm=function(t){function n(o){return Number(o)<=t?null:{max:t}}return o=>Mt(o,n)};un.add("max");const Km=function(t){return typeof t>"u"||t===null||t===""||Number.isNaN(t)||t?.length===0?{required:!0}:null};un.add("required");const Hm=function(t){function n(o){return o===void 0||o.toString().length<t?{minLength:t}:null}return o=>Mt(o,n)};Ze.add("minLength");const Wm=function(t){function n(o){return o==null||Array.isArray(o)&&o.length<t?{minLengthArray:t}:null}return o=>n(o)};Ze.add("minLengthArray");const Gm=function(t){function n(o){return o===void 0||o.toString().length<=t?null:{maxLength:t}}return o=>Mt(o,n)};wt.add("maxLength");const zm=function(t){function n(o){return o==null||Array.isArray(o)&&o.length<=t?null:{maxLengthArray:t}}return o=>n(o)};Ze.add("maxLengthArray");const Um=function(t){const n=t instanceof RegExp?t:new RegExp(t);function o(a){return n.test(a)?null:{pattern:t}}return a=>Mt(a,o)};Ze.add("pattern");const jm=function(e){function t(n){return new RegExp("^\\p{L}*$","u").test(n)?null:{alpha:!0}}return Mt(e,t)};wt.add("alpha");const Ym=function(e){function t(n){return/^[0-9,. ]*$/.test(n)?null:{numeric:!0}}return Mt(e,t)};wt.add("numeric");const qm=function(e){function t(n){return/^-?[0-9,. ]*$/.test(n)?null:{positiveOrNegativeNumber:!0}}return Mt(e,t)};wt.add("positiveOrNegativeNumber");const Jm=function(e){function t(n){return/^[^0-9]*$/.test(n)?null:{nonNumeric:!0}}return Mt(e,t)};wt.add("nonNumeric");const vo=Object.freeze({...Am,min:$m,max:Vm,required:Km,minLength:Hm,minLengthArray:Wm,maxLength:Gm,maxLengthArray:zm,pattern:Um,alpha:jm,numeric:Ym,nonNumeric:Jm,positiveOrNegativeNumber:qm,OnBlurErrorKeys:Ze});function yo(e,t=[]){const n=t.reduce((o,a)=>Object.assign(o,a(e)||{}),{});return Object.keys(n).length?n:null}var Ct=(e=>(e[e.ON_CHANGE=0]="ON_CHANGE",e[e.ON_BLUR=1]="ON_BLUR",e[e.ON_SUBMIT=2]="ON_SUBMIT",e))(Ct||{});function Xm(e,t={},n=[]){for(const[o,a]of Object.entries(t))a===0?wi(o):a===2&&Ci(o);return r.useCallback(e,n)}class Yt{constructor(t,n){this.path=t,this.update=n,this.validators=[],this.#e=null,this.#t=null,this.#n=null,this.preventativeErrors=[],this.submitted=!1}#e;#t;#n;get errors(){return this.#e===null&&this.#t===null&&this.#n===null?null:{...this.#e??{},...this.#t??{},...this.#n??{}}}setValidators(t){return this.update(this.path,null,void 0,t),this}validate(t,n,o=!1){if(this.validators&&this.validators.length>0){const a=yo(t,this.validators);let s={onSubmit:{},onChange:{},onBlur:{}};a&&(s=Object.keys(a).reduce((i,l)=>(ho.has(l)?i.onSubmit[l]=a[l]:un.has(l)?i.onChange[l]=a[l]:i.onBlur[l]=a[l],i),s)),(typeof n>"u"||n===Ct.ON_CHANGE)&&(this.#t=Object.keys(s.onChange).length===0?null:s.onChange),(typeof n>"u"||n===Ct.ON_BLUR)&&(this.#n=Object.keys(s.onBlur).length===0?null:s.onBlur),(typeof n>"u"||n===Ct.ON_SUBMIT)&&(this.#e=Object.keys(s.onSubmit).length===0?null:s.onSubmit,this.#t=Object.keys(s.onChange).length===0?null:s.onChange,this.#n=Object.keys(s.onBlur).length===0?null:s.onBlur),o||this.update(),this.isFocused()&&this.onFocus&&this.onFocus()}else this.errors&&(this.#e=null,this.#n=null,this.#t=null,o||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.includes(vo.required)}isSubmitted(){return this.submitted}onFocus(){}onBlur(){}}class Bn extends Yt{constructor(){super(...arguments),this.id=We(),this.focused=!1,this.pristine=!0}setValue(t){if(this.preventativeErrors=[],this.validators&&this.validators.length>0){const n=yo(t,this.validators);if(n&&Object.keys(n).filter(a=>wt.has(a)).length>0){this.preventativeErrors=Object.keys(n);return}}this.update(this.path,t)}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 qt extends Bn{constructor(t,n,o){const a=o?n:t,s=o||n;super(a,s),o&&this.inferMembers(t)}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}inferSpsControl(t,n){return Eo(t,[...this.path,n],this.update)}rollup(t){return Object.keys(this.fields).reduce((n,o)=>n&&(!this.fields[o][t]||this.fields[o][t]()),!0)}}class xi extends qt{inferMembers(t){this.fields={};for(const n of Object.keys(t))this.fields[n]=this.inferSpsControl(t[n],n)}}class ki extends qt{inferMembers(t){this.fields=t.map((n,o)=>this.inferSpsControl(n,String(o)))}}function Eo(e,t,n){return e instanceof Yt?(e.path=t,e.update=n,e):Array.isArray(e)?new ki(e,t,n):Ti(e)?new xi(e,t,n):new Bn(t,n)}function On(e,t){return t.length===0||!e?e:On(e.fields[t[0]],t.slice(1,t.length))}function Br(e,t){if(t.length===0||!e)return[e];const n=t[0];if(t=t.slice(1,t.length),n==="*"){const o=Array.isArray(e.fields)?e.fields:Object.keys(e.fields).map(a=>e.fields[a]);return t.length===0?o:o.reduce((a,s)=>[...a,...Br(s,t)],[])}return Br(e.fields[n],t)}function Or(e,t,n){for(const o of Object.keys(t)){const a=t[o];for(const s of Br(e,o.split(".")))s&&a&&n(s,a)}}function To(e,t,n,o=!1,a=!1){Or(t,n,(s,i)=>{s.validators=typeof i=="function"?i(e):i,o&&s.validate(S.getPath(e,s.path),void 0,a)})}function Rr(e,t){const n=t[0];return t=t.slice(1),Array.isArray(e)?e.map((o,a)=>a===Number(n)?Rr(o,t):o):Ti(e)?Object.keys(e).reduce((o,a)=>Object.assign(o,{[a]:a===n?Rr(e[a],t):e[a]}),{}):e}function Zm(e){if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError("The initial value of useSpsForm() hook must be an object.")}function Mi(e,t={}){Zm(e);const[,n]=T.useState({}),o=T.useRef(!1);o.current=!1;const a=T.useRef(t),s=T.useCallback(p=>{const f=u.current;let g;if(p)if(p.path)if(p.markAsBlurred){const b=On(f.formMeta,p.path);if(b){b.focused=!1;const v=S.getPath(f.formValue,p.path);b.validate(v,Ct.ON_BLUR)}}else if(p.newValidators){if(a.current){const b=p.path.join(".");a.current={...a.current,[b]:p.newValidators},To(f.formValue,f.formMeta,a.current,!0)}}else if(p.markAsSubmitted){const b=On(f.formMeta,p.path);if(b){b.submitted=!0;const v=S.getPath(f.formValue,p.path);b.validate(v,Ct.ON_SUBMIT)}}else g=Rr(f.formValue,p.path),S.setPath(g,p.path,p.value);else g=p.value;if(p?.updateFormOptions?.validators&&(a.current={...a.current,...p.updateFormOptions.validators},To(f.formValue,f.formMeta,a.current,p.updateFormOptions?.runValidators??!0)),g){f.formMeta.submitted=!1,S.deepFreeze(g);const b=S.diff(f.formValue,g);for(const{type:y,key:h,parentPath:I,objects:[,C]}of b){const D=On(f.formMeta,I);if(typeof h!="symbol"&&D){let L;switch(y){case S.DiffChange.ADDITION:D.fields[h]=Eo(C[h],[...I,h],l);break;case S.DiffChange.DELETION:Array.isArray(D.fields)?D.fields[h]=void 0:delete D.fields[h];break;case S.DiffChange.ALTERATION:L=Eo(C[h],[...I,h],l),(L instanceof qt&&!(D.fields[h]instanceof qt)||!(L instanceof qt)&&D.fields[h]instanceof qt)&&(L.pristine=!1,D.fields[h]=L);break}}}const v=new Set;if(b.filter(y=>y.type===S.DiffChange.DELETION).reduce((y,h)=>(y.has(h.parentPath)||y.add(h.parentPath),y),v),Array.from(v).forEach(y=>{const h=On(f.formMeta,y);Array.isArray(h.fields)&&(h.fields=h.fields.filter(I=>I!==void 0))}),a.current){To(g,f.formMeta,a.current);const y=new Set;t&&Or(f.formMeta,t,(h,I)=>{typeof I=="function"&&(h.validate(S.getPath(g,h.path)),y.add(h))});for(const{type:h,key:I,parentPath:C,objects:[,D]}of b)if(typeof I!="symbol"){let L=f.formMeta,F=g;if(L){for(const O of C)L=L.fields[O],F=F[O],y.has(L)||L.validate(F,Ct.ON_CHANGE);if(h===S.DiffChange.ADDITION||h===S.DiffChange.ALTERATION){const O=L.fields[I];if(!y.has(O)&&(L.fields[I].validate(D[I],Ct.ON_CHANGE),h===S.DiffChange.ADDITION&&O.fields))for(const[_,R]of Object.entries(O.fields))R.validate(D[I][_],Ct.ON_CHANGE)}}}}}u.current={...f,formValue:g||f.formValue},o.current||n({})},[]),i=T.useCallback((p,f)=>{p||f?s({value:p,updateFormOptions:f}):s()},[s]),l=T.useCallback((p,f,g=!1,b,v=!1)=>{p?s({path:p,value:f,markAsBlurred:g,newValidators:b,markAsSubmitted:v}):i()},[s,i]),c=T.useMemo(()=>{S.deepFreeze(e);const p=Eo(e,[],l);return t&&To(e,p,t,!1,!0),p},[]),d=T.useCallback(()=>(u.current.formMeta.markAsDirty(),a.current&&Or(u.current.formMeta,a.current,(p,f)=>{(typeof f=="function"||Array.isArray(f))&&p.validate(S.getPath(u.current.formValue,p.path))}),u.current.formMeta.isValid()),[]),m=T.useCallback(()=>u.current.formValue,[]),u=T.useRef({formValue:e,formMeta:c,updateForm:i,validateForm:d,getCurrentFormValue:m});return u.current}const Le=r.forwardRef((e,t)=>{const{className:n,children:o,focusInputOnClick:a,formControl:s,formMeta:i,inputRef:l,onClick:c,...d}=e,m=r.useRef(),p=l||(t||m);function f(){p&&p!==t&&p.current&&p.current.focus()}function g(){p&&p!==t&&p.current&&i&&i instanceof Bn&&i.markAsFocused()}function b(){p&&p!==t&&p.current&&i&&i instanceof Bn&&i.markAsBlurred()}const v=K("sps-form-group",(s&&s.isRequired()||i&&i.isRequired())&&"sps-form-group--required",(s&&!s.isValid()||i&&i.isVisibilyInvalid())&&"sps-form-group--error",i&&i.hasPreventativeErrors()&&"sps-form-group--preventative-error",n);function y(h){a&&f(),c&&c(h)}return r.useEffect(()=>{function h(I){I.target.classList.contains("sps-form-control__clear-btn")&&I.preventDefault()}return document.addEventListener("mousedown",h),()=>{document.removeEventListener("mousedown",h)}},[]),r.createElement("div",{...d,className:v,ref:t,tabIndex:-1,onClick:y,onFocus:g,onBlur:b},o)});Object.assign(Le,{displayName:"SpsFormComponentWrapper"});const Li=e=>typeof e=="object"&&e!=null&&e.nodeType===1,_i=(e,t)=>(!t||e!=="hidden")&&e!=="visible"&&e!=="clip",wo=(e,t)=>{if(e.clientHeight<e.scrollHeight||e.clientWidth<e.scrollWidth){const n=getComputedStyle(e,null);return _i(n.overflowY,t)||_i(n.overflowX,t)||(o=>{const a=(s=>{if(!s.ownerDocument||!s.ownerDocument.defaultView)return null;try{return s.ownerDocument.defaultView.frameElement}catch{return null}})(o);return!!a&&(a.clientHeight<o.scrollHeight||a.clientWidth<o.scrollWidth)})(e)}return!1},Co=(e,t,n,o,a,s,i,l)=>s<e&&i>t||s>e&&i<t?0:s<=e&&l<=n||i>=t&&l>=n?s-e-o:i>t&&l<n||s<e&&l>n?i-t+a:0,Qm=e=>{const t=e.parentElement;return t??(e.getRootNode().host||null)},Pi=(e,t)=>{var n,o,a,s;if(typeof document>"u")return[];const{scrollMode:i,block:l,inline:c,boundary:d,skipOverflowHiddenElements:m}=t,u=typeof d=="function"?d:B=>B!==d;if(!Li(e))throw new TypeError("Invalid target");const p=document.scrollingElement||document.documentElement,f=[];let g=e;for(;Li(g)&&u(g);){if(g=Qm(g),g===p){f.push(g);break}g!=null&&g===document.body&&wo(g)&&!wo(document.documentElement)||g!=null&&wo(g,m)&&f.push(g)}const b=(o=(n=window.visualViewport)==null?void 0:n.width)!=null?o:innerWidth,v=(s=(a=window.visualViewport)==null?void 0:a.height)!=null?s:innerHeight,{scrollX:y,scrollY:h}=window,{height:I,width:C,top:D,right:L,bottom:F,left:O}=e.getBoundingClientRect(),{top:_,right:R,bottom:H,left:Z}=(B=>{const M=window.getComputedStyle(B);return{top:parseFloat(M.scrollMarginTop)||0,right:parseFloat(M.scrollMarginRight)||0,bottom:parseFloat(M.scrollMarginBottom)||0,left:parseFloat(M.scrollMarginLeft)||0}})(e);let V=l==="start"||l==="nearest"?D-_:l==="end"?F+H:D+I/2-_+H,w=c==="center"?O+C/2-Z+R:c==="end"?L+R:O-Z;const $=[];for(let B=0;B<f.length;B++){const M=f[B],{height:q,width:N,top:E,right:k,bottom:z,left:J}=M.getBoundingClientRect();if(i==="if-needed"&&D>=0&&O>=0&&F<=v&&L<=b&&(M===p&&!wo(M)||D>=E&&F<=z&&O>=J&&L<=k))return $;const te=getComputedStyle(M),ne=parseInt(te.borderLeftWidth,10),W=parseInt(te.borderTopWidth,10),X=parseInt(te.borderRightWidth,10),Y=parseInt(te.borderBottomWidth,10);let G=0,ee=0;const U="offsetWidth"in M?M.offsetWidth-M.clientWidth-ne-X:0,Q="offsetHeight"in M?M.offsetHeight-M.clientHeight-W-Y:0,fe="offsetWidth"in M?M.offsetWidth===0?0:N/M.offsetWidth:0,se="offsetHeight"in M?M.offsetHeight===0?0:q/M.offsetHeight:0;if(p===M)G=l==="start"?V:l==="end"?V-v:l==="nearest"?Co(h,h+v,v,W,Y,h+V,h+V+I,I):V-v/2,ee=c==="start"?w:c==="center"?w-b/2:c==="end"?w-b:Co(y,y+b,b,ne,X,y+w,y+w+C,C),G=Math.max(0,G+h),ee=Math.max(0,ee+y);else{G=l==="start"?V-E-W:l==="end"?V-z+Y+Q:l==="nearest"?Co(E,z,q,W,Y+Q,V,V+I,I):V-(E+q/2)+Q/2,ee=c==="start"?w-J-ne:c==="center"?w-(J+N/2)+U/2:c==="end"?w-k+X+U:Co(J,k,N,ne,X+U,w,w+C,C);const{scrollLeft:pe,scrollTop:He}=M;G=se===0?0:Math.max(0,Math.min(He+G/se,M.scrollHeight-q/se+Q)),ee=fe===0?0:Math.max(0,Math.min(pe+ee/fe,M.scrollWidth-N/fe+U)),V+=He-G,w+=pe-ee}$.push({el:M,top:G,left:ee})}return $},ef=e=>e===!1?{block:"end",inline:"nearest"}:(t=>t===Object(t)&&Object.keys(t).length!==0)(e)?e:{block:"start",inline:"nearest"};function Do(e,t){if(!e.isConnected||!(a=>{let s=a;for(;s&&s.parentNode;){if(s.parentNode===document)return!0;s=s.parentNode instanceof ShadowRoot?s.parentNode.host:s.parentNode}return!1})(e))return;const n=(a=>{const s=window.getComputedStyle(a);return{top:parseFloat(s.scrollMarginTop)||0,right:parseFloat(s.scrollMarginRight)||0,bottom:parseFloat(s.scrollMarginBottom)||0,left:parseFloat(s.scrollMarginLeft)||0}})(e);if((a=>typeof a=="object"&&typeof a.behavior=="function")(t))return t.behavior(Pi(e,t));const o=typeof t=="boolean"||t==null?void 0:t.behavior;for(const{el:a,top:s,left:i}of Pi(e,ef(t))){const l=s-n.top+n.bottom,c=i-n.left+n.right;a.scroll({top:l,left:c,behavior:o})}}const Fr=Object.freeze(Object.defineProperty({__proto__:null,default:Do},Symbol.toStringTag,{value:"Module"})),tf={alt:"string",size:"SpinnerSize",title:"string"};function Ar(e){const{alt:t,className:n,size:o=A.SpinnerSize.MEDIUM,"data-testid":a,title:s,unsafelyReplaceClassName:i,...l}=e,{t:c}=Se.useWoodlandLanguage(),d=t||s||c("spinner.defaultAltText",{defaultValue:"Loading..."}),m=K(i||"sps-spinner",`sps-spinner--${o}`,n);return r.createElement("i",{className:m,"data-testid":a,title:d,...l})}Object.assign(Ar,{props:tf,displayName:"SpsSpinner"});const nf=60;function No(e){return typeof e>"u"?"inherit":`${e}px`}function $r(e){switch(e){case A.Position.TOP_LEFT:return A.Position.BOTTOM_LEFT;case A.Position.TOP_MIDDLE:return A.Position.BOTTOM_MIDDLE;case A.Position.TOP_RIGHT:return A.Position.BOTTOM_RIGHT;case A.Position.RIGHT_TOP:return A.Position.LEFT_TOP;case A.Position.RIGHT_MIDDLE:return A.Position.LEFT_MIDDLE;case A.Position.RIGHT_BOTTOM:return A.Position.LEFT_BOTTOM;case A.Position.BOTTOM_RIGHT:return A.Position.TOP_RIGHT;case A.Position.BOTTOM_MIDDLE:return A.Position.TOP_MIDDLE;case A.Position.BOTTOM_LEFT:return A.Position.TOP_LEFT;case A.Position.LEFT_BOTTOM:return A.Position.RIGHT_BOTTOM;case A.Position.LEFT_MIDDLE:return A.Position.RIGHT_MIDDLE;case A.Position.LEFT_TOP:return A.Position.RIGHT_TOP}}function of(e,t,n,o,a,s,i,l){const c=i&&i.current,d=c?c.scrollTop:window.pageYOffset,m=l?0:d,u=c?c.scrollLeft:window.pageXOffset,p=l?0:u,[f,g]=e.split(" ");let b,v,y,h;switch(f){case"top":y=t.height-n.top-m-s[0];break;case"left":v=t.width-n.left-p-s[0];break;case"right":h=n.right+p-s[0];break;case"bottom":b=n.bottom+m-s[0];break;default:throw new Error(`Invalid position ${e}`)}switch(g){case"left":h=n.left+p+s[1];break;case"top":b=n.top+m+s[1];break;case"middle":f==="top"||f==="bottom"?h=n.left+p+n.width/2-a/2+s[1]:(f==="left"||f==="right")&&(b=n.top+m+n.height/2-o.height/2+s[1]);break;case"bottom":y=t.height-n.bottom-m+s[1];break;case"right":v=t.width-n.right-p+s[1];break;default:throw new Error(`Invalid position ${e}`)}return[b,v,y,h]}function Sn(e,t,n,{altPosition:o,setMinWidth:a=!1,setWidth:s=!1,parentElementRef:i,fixed:l=!1,offsets:c=[0,0],altOffsets:d=c}){if(e.current&&t.current){const m=e.current.getBoundingClientRect(),u=t.current.getBoundingClientRect(),p=Math.max(document.documentElement.clientHeight,window.innerHeight||0),f=document.documentElement.getBoundingClientRect().width;let b=(i?.current??document.documentElement).getBoundingClientRect();l&&(b={x:0,y:0,width:f,height:p,top:0,left:0,bottom:p,right:f,toJSON(){return{width:f,height:p,top:0,left:0,bottom:p,right:f}}});const[v,y]=n.split(" ");let h=n;if(o&&(v==="top"&&u.top-m.height<nf||v==="right"&&u.right+m.width>f||v==="bottom"&&u.bottom+m.height>p||v==="left"&&u.left-m.width<0)&&(h=o),y==="left"&&u.left+m.width+(c?.[1]??0)>document.documentElement.getBoundingClientRect().right)switch(v){case"bottom":h=A.Position.BOTTOM_RIGHT;break;case"top":h=A.Position.TOP_RIGHT;break}const I=a?Math.max(u.width,m.width):m.width,C=s?u.width:I,[D,L,F,O]=of(h,b,u,m,C,h===o?d:c,i,l),_={top:No(D),right:No(L),bottom:No(F),left:No(O)};return l&&(_.position="fixed",_.zIndex=A.ZStratum.BAR),a&&(_.minWidth=`${u.width}px`),s&&(_.width=`${u.width}px`),[_,h===o]}return[{},!1]}const rt=T.createContext(null);function gn(e,t=[]){const n=T.useContext(rt);return T.useMemo(()=>o=>{const s=n&&n.parentElementRef&&n.parentElementRef.current||document.body;let i=null,l=s.lastElementChild;for(;l&&l!==s.firstElementChild;){if(l.hasAttribute("data-portalid")&&l.getAttribute("data-portalid")===e){i=l;break}l=l.previousElementSibling}if(i)s.contains(i)||s.appendChild(i);else{i=document.createElement("div"),i.setAttribute("data-portalid",e),i.setAttribute("data-react-aria-top-layer","true");for(const c of t)i.classList.add(c);s.appendChild(i)}return Ln.createPortal(o,i)},[n])}const Vr=["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","1","2","3","4","5","6","7","8","9","0"];async function Bi(e,t,n,o,a,s){const i=typeof e.options=="function"?e.options(t.value):e.options||[],l=i instanceof Promise,c=u=>u.replace(/([.?*+^$[\]\\(){}|-])/g,"");n({pending:l}),s.current=l?i:null;const d=l?await i||[]:i||[];if(l&&s.current!==i)return;let m=Array.from(d).filter(Boolean).map(u=>new A.SpsOptionListOption(u,typeof u=="function"?{textKey:"label",captionKey:"caption"}:{textKey:e.textKey,captionKey:e.captionKey}));if(e.nullOption&&m.unshift(new A.SpsOptionListOption(null,{text:e.nullOption})),t.value&&!e.disableDefaultOptionsFiltering){const u=c(t.value);n({replacementPattern:new RegExp(`(${u})`,"ig")}),m=m.filter(p=>{const f=new RegExp(u,"i"),g=c(p.text);return e.filterByTextAndCaptionKey?f.test(g)||f.test(c(p.caption)):f.test(g)})}else n({replacementPattern:null});if(e.disabledOptions)for(const u of m)e.disabledOptions.includes(u.value)&&(u.disabled=!0);o(Object.freeze(m)),e.onOptionListChanged&&e.onOptionListChanged(m.length),a(m.some(u=>u.value&&!!u.value.icon)),n({pending:!1})}function rf(e,t,n){const[o,a]=r.useState(Object.freeze([])),[s,i]=r.useState(!1),l=r.useRef(null),c=r.useRef(e.options);(typeof e.options!="function"||e.disableOptionsMemoization)&&(c.current=e.options);const d=r.useMemo(()=>typeof c.current=="function"?S.debounce(Bi,typeof e.searchDebounce<"u"?e.searchDebounce:500):Bi,[c.current,e.disabledOptions]);return r.useEffect(()=>{d(e,t,n,a,i,l)},[c.current,t.value,e.disabledOptions]),[o,s]}class Lt{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 af(e,t){return{...e,...t}}function Dt(e){return T.useReducer(af,e)}function sf({hideInlineSearch:e,showInlineSearch:t,options:n,onSearchChange:o,search:a="",searchPlaceholder:s,searchInputRef:i}){const{t:l}=Se.useWoodlandLanguage(),c=s??l("select.searchPlaceholder",{defaultValue:"Search…"}),[d,m]=Dt({isAsync:typeof n=="function",pending:!1,value:a,replacementPattern:null}),u=r.useCallback(v=>{m({value:v.target.value}),o&&o(v)},[o]),p=r.useCallback(v=>{v.nativeEvent.stopImmediatePropagation(),v.stopPropagation()},[]),f=r.useCallback(v=>{v.nativeEvent.stopImmediatePropagation(),m({value:""}),o&&o(new Lt({value:""})),i?.current&&i.current.focus()},[o,i]),g=v=>{v&&(["Tab","Escape","Enter","Up","ArrowUp","Down","ArrowDown"].includes(v.key)||v.stopPropagation())};return r.useEffect(()=>{m({value:a})},[a]),[(d.isAsync||t)&&!e?r.createElement("div",{className:"sps-option-list__search sps-form-group sps-text-input"},r.createElement("div",{className:"sps-form-control"},!d.value&&r.createElement("i",{className:"sps-icon sps-icon-filter sps-text-input__icon"}),r.createElement("input",{type:"text",className:"sps-text-input__input",placeholder:c,ref:i,value:d.value,onChange:u,onClick:p,onKeyDown:g}),d.value&&r.createElement("i",{className:"sps-icon sps-icon-x-circle sps-form-control__clear-btn",onClick:f}))):r.createElement(r.Fragment,null),d,m]}const lf=Do||Fr,cf=["Tab","Escape","Enter","Up","ArrowUp","Down","ArrowDown"];function df(e,t,n){return n?(e&&e[n])===(t&&t[n]):e===t}function Oi(e,t,n){return typeof n.value=="function"&&n.disabled?!0:t?!!e?.find(o=>o[t]&&o[t]===n?.value?.[t]):!1}const Rn=r.forwardRef((e,t)=>{const{captionKey:n,comparisonKey:o,disabledOptions:a,options:s,tall:i,textKey:l,valueKey:c,zeroState:d,hideInlineSearch:m,showInlineSearch:u,onSearchChange:p,search:f,searchDebounce:g,searchPlaceholder:b,onSpecialActionSelect:v,attachTo:y,className:h,conformWidth:I,id:C,ignoreWidthStyles:D,isOpen:L,keepOpen:F,keyDown:O,nullOption:_,onOptionListChanged:R,onOptionSelected:H,onPositionFlip:Z,onSelfToggle:V,optionRole:w,positionOverride:$,selectedOption:B,specialAction:M,unsafelyReplaceClassName:q,loading:N,filterByTextAndCaptionKey:E,maxHeightPx:k,maxHeightRem:z,disableOptionsMemoization:J,disableDefaultOptionsFiltering:te,"data-testid":ne,typeaheadEvent:W,...X}=e,Y=r.useMemo(()=>M?new A.SpsOptionListOption(M,{textKey:"label",captionKey:"caption"}):null,[M]),[G,ee]=r.useState(-1),[U,Q]=r.useState(L),fe=t||r.useRef(null),se=r.useRef(null),pe=r.useRef(null),He=gn("sps-option-list-portal"),$e=r.useContext(rt),[Xe,nt]=$||[A.Position.BOTTOM_LEFT,A.Position.TOP_LEFT],[[mt,ke],ot]=r.useState([{},!1]),Ve=r.useRef(null),[ft,_e,oe]=sf({...e,searchInputRef:Ve}),[ue,je]=rf(e,_e,oe);r.useEffect(()=>{W&&Ye(W)},[W]),r.useEffect(()=>{ot(U?Sn(fe,y,Xe,{altPosition:nt,setMinWidth:!D,setWidth:!D&&I,...$e}):[{},!1])},[U,Xe,nt,ue]),r.useEffect(()=>{let ie;return U&&(ie=()=>{U&&ot(Sn(fe,y,Xe,{altPosition:nt,setMinWidth:!D,setWidth:!D&&I,...$e}))},document.addEventListener("scroll",ie)),()=>{ie&&document.removeEventListener("scroll",ie)}},[U]),r.useEffect(()=>{ee(-1)},[_e]);const So=K(q||"sps-option-list","z-stratum-dropdown",U&&"sps-option-list--open",_e.isAsync&&"sps-option-list--searchable",ke&&"sps-option-list--opens-upward",M&&M.label&&"sps-option-list--has-special-action",h),xr=K(q||"sps-option-list__options",i&&"sps-option-list__options--tall"),xt=r.useCallback(()=>{U||(Q(!0),Ve.current&&Ve.current.focus(),ee(-1),V&&V(!0))},[U,V]),jt=r.useCallback(()=>{U&&(Q(!1),ee(-1),V&&V(!1))},[U,V]),yt=r.useCallback((ie,de)=>{de||ie&&!ie.disabled&&(typeof ie.value=="function"?(ie.value(),v&&v()):typeof H=="function"&&H(ie.value),F||jt())},[H,jt]),go=r.useCallback((ie,de,Me)=>{ie.stopPropagation(),yt(de,Me)},[yt]),ae=r.useRef(a||[]);ae.current=a||[];const we=r.useCallback(ie=>{switch(ie.key){case"Tab":case"Escape":jt();break;case"Enter":if(G>-1){const de=ue[G]||Y;ie.preventDefault();const Me=!!de&&Oi(ae.current,o||"",de);!Me&&de&&typeof H=="function"&&typeof de.value=="function"?de.value():de&&yt(de,Me)}break;case"Up":case"ArrowUp":{let de=G;ke?G<=-1?de=ue.length-1:G===0?M&&(de=ue.length):G<ue.length&&(de=G-1):G>-1&&(de=G-1),de!==G&&(ie.preventDefault(),ee(de));break}case"Down":case"ArrowDown":{xt();let de=G;ke?G!==-1&&(G>=ue.length?de=0:G===ue.length-1?de=-1:de=G+1):G<ue.length-1+ +!!M&&(de=G+1),de!==G&&(ie.preventDefault(),ee(de));break}default:xt()}},[jt,xt,G,yt,H,ke,ue]),Ke=r.useCallback(ie=>{xt();const de=ue.findIndex(Me=>{if(Me.textKey){const Tt=Me.textKey;return Me.value[Tt].toLowerCase().charAt([0])===ie.key.toLocaleLowerCase()}return Me.value.toString().toLowerCase().charAt([0])===ie.key.toLocaleLowerCase()});de>-1&&ee(de)},[ue]),Ye=r.useCallback(ie=>{ie&&(cf.includes(ie.key)?we(ie):Vr.includes(ie.key)&&!m&&Ke(ie))},[jt,xt,G,yt,H,ke,ue]);r.useEffect(()=>{if($e!==null&&document.getElementsByClassName("sps-modal__body").length>0){const ie=()=>{V&&V(!1)},de=document.getElementsByClassName("sps-modal__body")[0];return de.addEventListener("scroll",ie),()=>{de.removeEventListener("scroll",ie)}}},[]),r.useEffect(()=>{U&&pe.current&&lf(pe.current,{scrollMode:"if-needed",block:"nearest",inline:"nearest"})},[G,U]),r.useEffect(()=>{Q(L),L?Ve.current&&Ve.current.focus():ee(-1)},[L]),r.useEffect(()=>{O&&Ye(O)},[O]),r.useEffect(()=>{!U&&se.current&&(p&&_e.value&&p(new Lt({value:""})),oe({value:""}),se.current.scrollTop=0),U&&Z&&Z(ke)},[U]);const Ie=k?k/16:z,Et=Ie?{maxHeight:`${Ie}rem`}:{};function kt(ie,de){return de?r.createElement(r.Fragment,null,ie.split(de).map((Me,Tt)=>de.test(Me)?r.createElement("u",{key:Tt},Me):r.createElement(r.Fragment,{key:Tt},Me))):r.createElement(r.Fragment,null,ie)}return He(r.createElement("div",{className:So,id:C,"aria-activedescendant":G>-1?`${C}-option-${G}`:"",tabIndex:-1,ref:fe,style:mt,onMouseLeave:()=>ee(-1),"data-testid":ne,...X},ft,r.createElement("div",{className:xr,ref:se,"data-testid":`${ne}-options`,style:Et},!N&&!_e.pending&&d&&ue.length===0&&r.createElement("div",{className:"sps-option-list__zero-state"},d),(N||_e.pending)&&r.createElement("div",{className:"sps-option-list__loading"},r.createElement(Ar,null)),!N&&!_e.pending&&ue.map((ie,de)=>{const Me=`${C}-option-${de}`,Tt=df(ie.value,B,o),km=Oi(ae.current,o||"",ie);return r.createElement("a",{key:Me,id:Me,role:w,"aria-selected":Tt,href:ie.href,className:K("sps-option-list__option",ie.caption&&"sps-option-list__option--has-caption",ie.disabled&&"sps-option-list__option--disabled",ie.bold&&"sps-option-list__option--bold",(Tt||km)&&"sps-option-list__option--selected",G===de&&"sps-option-list__option--highlighted"),onClick:XC=>go(XC,ie,km),onMouseOver:()=>ee(de),tabIndex:-1,ref:G===de?pe:null,"data-testid":`${ne}-option-${de}`},ie.value&&ie.value.icon&&r.createElement("i",{className:K("sps-icon","sps-option-list__option-icon",`sps-icon-${String(ie.value.icon)}`)}),(!ie.value||!ie.value.icon&&je)&&r.createElement("span",{className:"sps-option-list__option-icon-spacer"}),r.createElement("span",null,kt(ie.text,_e.replacementPattern)),ie.caption&&r.createElement("div",{className:"sps-option-list__option-caption"},r.createElement("span",null,kt(ie.caption,_e.replacementPattern))))})),Y&&M?.label&&r.createElement("a",{className:K("sps-option-list__option","sps-option-list__special-action",G===ue.length&&"sps-option-list__option--highlighted",M.disabled&&"sps-option-list__special-action--disabled"),href:Y.href,target:Y.href&&M.newTab?"_blank":"_self",onClick:ie=>go(ie,Y),onMouseOver:()=>ee(ue.length),"data-testid":`${ne}-special-action`},M.icon&&r.createElement("i",{className:K("sps-icon","sps-option-list__option-icon",`sps-icon-${String(M.icon)}`)}),!M.icon&&je&&r.createElement("span",{className:"sps-option-list__option-icon-spacer"}),r.createElement("span",null,M.label))))});Object.assign(Rn,{displayName:"SpsOptionList"});function hn(e){return{key:e.key,preventDefault:()=>{}}}function pf(e,t,n=[]){return r.useMemo(()=>{function o(a){return r.createElement(e,{...a,...t},a.children)}return o},n)}function qe(e){return typeof e=="function"?e():e}const Ri=function({children:e,elements:t}){if(t.length===0)return r.createElement(r.Fragment,null,e);const[n,o]=Array.isArray(t[0])?t[0]:[t[0]];return r.createElement(n,{...o??{}},r.createElement(Ri,{elements:t.slice(1)},e))},Fi=function({children:e,providers:t=[],...n}){return r.createElement("div",{...n},r.createElement(Ri,{elements:t},e))},uf=function({children:e,className:t,...n}){return r.createElement(Fi,{className:`sps-app ${t}`,...n},e)};function mf(e,t){const{type:n,props:o={},custom:a}=t;return a?a(e.type):e.type!==n?!1:Object.keys(o).every(s=>o[s]===e.props[s])}function at(e=[],t=[]){const n=Array.isArray(e)?S.flatten(e):[e],o=t.map(s=>Array.isArray(s)?s:[s]),a=new Array(o.length+1).fill(null).map(()=>[]);for(const s of n){let i=!1;for(let l=0;l<o.length;l+=1)for(const c of o[l])if(mf(s,c)){i=!0,a[l].push(s);break}i||a[a.length-1].push(s)}return a}function Ai(e,t,n){const o=Object.entries(t).filter(([,s])=>typeof s!="string"&&s.deprecated).map(([s])=>s),a=o.map(s=>n[s]);r.useEffect(()=>{a.find(s=>typeof s<"u")&&console.warn(`The following prop(s) of ${e} are deprecated: ${o.join(", ")}`)},a)}function Kr(e,t){const n=T.useRef(!1);T.useEffect(()=>()=>{n.current=!1},[]),T.useEffect(()=>{if(n.current)return e();n.current=!0},t)}function Hr(e,t,n){const o=r.useRef(t(...n));r.useEffect(()=>(document.addEventListener(e,o.current,{capture:!0}),()=>document.removeEventListener(e,o.current)),[]),r.useEffect(()=>{document.removeEventListener(e,o.current),o.current=t(...n),document.addEventListener(e,o.current,{capture:!0})},n)}function $i(e,t,n){return function(a){!e.current?.contains(a.target)&&!t.current?.contains(a.target)&&n()}}function bn(e,t,n){const o=r.useRef(!1),[a,s]=r.useState(!1),i=r.useCallback(()=>{o.current?o.current=!1:s(!0)},[]),l=r.useCallback((c=!1)=>{s(!1),o.current=c,n&&n()},[]);return Hr("mousedown",$i,[e,t,l]),Hr("pointerdown",$i,[e,t,l]),{showPopup:a,doShowPopup:i,doHidePopup:l}}const Vi=e=>{const t=/(auto|scroll)/,n=(l,c)=>l.parentNode===null?c:n(l.parentNode,c.concat([l])),o=(l,c)=>getComputedStyle(l,null).getPropertyValue(c),a=l=>o(l,"overflow")+o(l,"overflow-y"),s=l=>t.test(a(l));return(l=>{if(!(l instanceof HTMLElement||l instanceof SVGElement))return;const c=n(l.parentNode,[]);for(let d=0;d<c.length;d+=1)if(s(c[d]))return c[d];return null})(e)};let Io=0,Fn=null,An=null;function $n({isOpen:e,rootRef:t}){r.useLayoutEffect(()=>{let n=!1;if(e&&t.current&&(n=!0,Io+=1,Io===1)){const o=Vi(t.current)||document.body;Fn=o;const a=o===document.body?window.innerWidth-document.documentElement.clientWidth:o.offsetWidth-o.clientWidth;o.style.overflow="hidden";const s=window.getComputedStyle(o).paddingRight;if(o.style.paddingRight=s&&s!=="0px"?`calc(${s} + ${a}px)`:`${a}px`,o===document.body){let i=document.getElementsByClassName("sps-navbar-container").item(0);if(i&&window.getComputedStyle(i).position==="fixed"){const l=window.getComputedStyle(i).paddingRight;i.style.paddingRight=l&&l!=="0px"?`calc(${l} + ${a}px)`:`${a}px`,An=i}else if(i=document.getElementsByTagName("nav").item(0)?.parentElement??null,i&&window.getComputedStyle(i).position==="fixed"){const c=window.getComputedStyle(i).paddingRight;i.style.paddingRight=c&&c!=="0px"?`calc(${c} + ${a}px)`:`${a}px`,An=i}}}return()=>{n&&(Io-=1,Io===0&&Fn&&(Fn.style.overflow="",Fn.style.paddingRight="",An&&(An.style.paddingRight="",An=null),Fn=null))}},[e])}const ff={debounce:"number",disabled:"boolean",conformWidth:"boolean",formMeta:"SpsFormFieldMeta<string>",icon:"SpsIcon",onChange:"React.ChangeEventHandler",onSelectionChange:"(newValue: string) => void",placeholder:"string",suggestions:{type:`
|
|
1
|
+
(function(x,T){typeof exports=="object"&&typeof module<"u"?T(exports,require("react"),require("@spscommerce/utils"),require("moment-timezone"),require("@spscommerce/ds-shared"),require("@spscommerce/i18n"),require("react-dom"),require("@spscommerce/ds-colors"),require("@sps-woodland/illustrations")):typeof define=="function"&&define.amd?define(["exports","react","@spscommerce/utils","moment-timezone","@spscommerce/ds-shared","@spscommerce/i18n","react-dom","@spscommerce/ds-colors","@sps-woodland/illustrations"],T):(x=typeof globalThis<"u"?globalThis:x||self,T(x.DSReact={},x.react,x.spscommerceUtils,x.momentTimezone,x.spscommerceDsShared,x.spscommerceI18n,x.reactDom,x.spscommerceDsColors,x.spsWoodlandIllustrations))})(this,(function(x,T,S,xe,A,Se,Ln,kr,bi){"use strict";function vi(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const r=vi(T),pn=vi(xe);function yi(e){var t,n,o="";if(typeof e=="string"||typeof e=="number")o+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(t=0;t<a;t++)e[t]&&(n=yi(e[t]))&&(o&&(o+=" "),o+=n)}else for(n in e)e[n]&&(o&&(o+=" "),o+=n);return o}function K(){for(var e,t,n=0,o="",a=arguments.length;n<a;n++)(e=arguments[n])&&(t=yi(e))&&(o&&(o+=" "),o+=t);return o}let Mm="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",We=(e=21)=>{let t="",n=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)t+=Mm[n[e]&63];return t};function Rt(e){return T.useRef(e||We())}function Ge(e,t){const n=Rt(e),o=T.useRef(`${n.current}_ctrl`);return T.useEffect(()=>{t&&(t.id=o.current,t.update())},[t]),{wrapperId:n.current||void 0,controlId:o.current}}function Mr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Lr,Ei;function Lm(){if(Ei)return Lr;Ei=1;var e="[object Object]";function t(p){var f=!1;if(p!=null&&typeof p.toString!="function")try{f=!!(p+"")}catch{}return f}function n(p,f){return function(g){return p(f(g))}}var o=Function.prototype,a=Object.prototype,s=o.toString,i=a.hasOwnProperty,l=s.call(Object),c=a.toString,d=n(Object.getPrototypeOf,Object);function m(p){return!!p&&typeof p=="object"}function u(p){if(!m(p)||c.call(p)!=e||t(p))return!1;var f=d(p);if(f===null)return!0;var g=i.call(f,"constructor")&&f.constructor;return typeof g=="function"&&g instanceof g&&s.call(g)==l}return Lr=u,Lr}var _m=Lm();const Ti=Mr(_m),Ze=new Set,un=new Set,wt=new Set,ho=new Set;function wi(e){Ze.has(e)||wt.has(e)||ho.has(e)||un.add(e)}function Ci(e){Ze.has(e)||wt.has(e)||un.has(e)||ho.add(e)}const Fe=pn.default||pn,mn="MM/DD/YYYY",Pm="MM/DD/YYYY hh:mm A",Bm="MM/DD/YYYY HH:mm",Om="hh:mm A",Rm="HH:mm",Fm=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/,_n=Symbol("Date Parse Error");function fn(e){return Fe.isMoment(e)?e.year()*1e4+(e.month()+1)*100+e.date():e.year*1e4+e.month*100+e.date}const j=Object.freeze({createFrom(e,t){if(!e)return null;if(typeof e=="string"){if(t){const n=Fe(e,t,!0);if(n.isValid())return Object.freeze({year:n.year(),month:n.month()+1,date:n.date()})}else{const n=Fm.exec(e);if(n){const[,o,a,s]=n;return Object.freeze({year:Number(s),month:Number(o),date:Number(a)})}}return Object.freeze({[_n]:!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,t){if(!e)return null;let n=null;return typeof e=="string"?t?n=Fe(e,t,!0):n=Fe(e):Fe.isMoment(e)?n=e:n=j.toMoment(e),n!==null&&Fe.isMoment(n)&&n.isValid()?n:Object.freeze({[_n]:!0,year:void 0,month:void 0,date:void 0})},getRangeSeparator(e){return e?.includes("-")?"/":"-"},createRangeFrom(e,t){if(!e)return null;if(t){const n=j.getRangeSeparator(t),o=new RegExp(`[^\\d]*${n}[^\\d]*`);return e.split(o).slice(0,2).map(a=>j.createFrom(a,t))}else return e.split(/[^\d]*-[^\d]*/).slice(0,2).map(n=>j.createFrom(n))},isValid(e){return e?Fe.isMoment(e)?e.isValid():typeof e=="object"&&typeof e.year=="number"&&typeof e.month=="number"&&typeof e.date=="number"&&j.toMoment(e)?.isValid():!1},nullifyInvalidDate(e){return j.isValid(e)?e:null},toMoment(e){return e?Fe.isMoment(e)?e:Fe({...e,month:e.month-1}):null},toString(e,t){const n=j.toMoment(e);return n&&n.isValid()?n.format(t||mn):""},toStringRange(e,t){if(!e)return"";const n=j.getRangeSeparator(t);return e.slice(0,2).map(o=>j.toString(o,t)).join(n)},toDateTimeString(e,t=!1,n){return e&&Fe.isMoment(e)&&e.isValid()?n?t?e.format(`${n} ${Rm}`):e.format(`${n} ${Om}`):t?e.format(Bm):e.format(Pm):""},toDateTimeStringRange(e,t=!1,n){if(!e)return"";const o=j.getRangeSeparator(n);return e.map(a=>j.toDateTimeString(a,t,n)).join(o)},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:fn(e)>fn(t)},isBefore(e,t){return!e||!t?null:fn(e)<fn(t)},isInRange(e,t,n=!0){if(!e||!t||!t[0]||!t[1])return null;const o=fn(e),[a,s]=t.map(fn);return a&&s&&(n&&o>=a&&o<=s||!n&&o>a&&o<s)},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,t){if(typeof e.definition=="function")return e.definition();const n=Fe(),o=n.clone().subtract(Fe.duration(e.definition));return[j.createFrom(o,t),j.createFrom(n,t)]},createDateTimeRangeFromPreset(e){if(typeof e.definition=="function")return e.definition();const t=Fe().subtract(Fe.duration(e.definition)).startOf("day"),n=Fe().endOf("day");return[t,n]},splitMomentInDateTimeParts(e,t=!1,n,o=!1){let a="";t?a=o?"23:59":"00:00":a=o?"11:59":"12:00";const s=o?"PM":"AM";return e&&Fe.isMoment(e)&&e.isValid()?j.toDateTimeString(e,t,n).split(" "):["",a,t?void 0:s]},getCurrentMoment(){return Fe()},validateTimeString(e,t=!1){if(!e)return!0;const n=e.split(":"),o=n[0]||"0",a=n[1]||"0",s=Number.isNaN(Number(o))?NaN:parseInt(o,10),i=Number.isNaN(Number(a))?NaN:parseInt(a,10),l=n.length<=2&&o.length<=2&&a.length<=2;return t?l&&s>=0&&s<=23&&i>=0&&i<=59:l&&(!Number.isNaN(s)&&o.length===1||s>=1)&&s<=12&&i>=0&&i<=59},padIncompleteTimeString(e,t=!1){if(!e)return"";const n=e.split(":"),o=parseInt(n[0]||"0",10),a=parseInt(n[1]||"0",10);if(t){const s=o<10?`0${o}`:`${o}`,i=a<10?`0${a}`:`${a}`;return`${s}:${i}`}else{const s=o===0?"12":o<10?`0${o}`:`${o}`,i=a<10?`0${a}`:`${a}`;return`${s}:${i}`}}}),_r=["01:00","02:00","03:00","04:00","05:00","06:00","07:00","08:00","09:00","10:00","11:00","12:00"],Pr=["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"];let bo=mn;function Di(e){bo=e}const Pn=function(t){if(Array.isArray(t)){const n=Pn(t[0]),o=Pn(t[1]);return n||o}if(t&&t.hasOwnProperty("year")){if(t[_n])return{dateFormat:bo};if(!j.isValid(t))return{dateValidity:!0}}return null};Ze.add("dateFormat"),Ze.add("dateValidity");const Ni=function(t){if(Array.isArray(t)){const n=Pn(t);if(n)return n;if(t&&j.isBefore(t[1],t[0]))return{dateRangeOrder:!0}}return null};Ze.add("dateRangeOrder");const Ii=function({minDate:t,maxDate:n}){function o(a){const s=j.isBefore(a,t),i=j.isAfter(a,n),l={minExceeded:s?j.toString(t,bo):null,maxExceeded:i?j.toString(n,bo):null};return s||i?{dateConstraint:l}:null}return function(s){if(!s)return null;if(Array.isArray(s)){const i=o(s[0]),l=o(s[1]);return i||l}return s.hasOwnProperty("year")?o(s):null}};Ze.add("dateConstraint");const Am=Object.freeze(Object.defineProperty({__proto__:null,date:Pn,dateConstraint:Ii,dateRange:Ni,setDateFormat:Di},Symbol.toStringTag,{value:"Module"}));function Mt(e,t){for(const n of[].concat(e)){const o=t(n);if(o)return o}return null}const $m=function(t){function n(o){return Number(o)>=t?null:{min:t}}return o=>Mt(o,n)};Ze.add("min");const Vm=function(t){function n(o){return Number(o)<=t?null:{max:t}}return o=>Mt(o,n)};un.add("max");const Km=function(t){return typeof t>"u"||t===null||t===""||Number.isNaN(t)||t?.length===0?{required:!0}:null};un.add("required");const Hm=function(t){function n(o){return o===void 0||o.toString().length<t?{minLength:t}:null}return o=>Mt(o,n)};Ze.add("minLength");const Wm=function(t){function n(o){return o==null||Array.isArray(o)&&o.length<t?{minLengthArray:t}:null}return o=>n(o)};Ze.add("minLengthArray");const Gm=function(t){function n(o){return o===void 0||o.toString().length<=t?null:{maxLength:t}}return o=>Mt(o,n)};wt.add("maxLength");const zm=function(t){function n(o){return o==null||Array.isArray(o)&&o.length<=t?null:{maxLengthArray:t}}return o=>n(o)};Ze.add("maxLengthArray");const Um=function(t){const n=t instanceof RegExp?t:new RegExp(t);function o(a){return n.test(a)?null:{pattern:t}}return a=>Mt(a,o)};Ze.add("pattern");const jm=function(e){function t(n){return new RegExp("^\\p{L}*$","u").test(n)?null:{alpha:!0}}return Mt(e,t)};wt.add("alpha");const Ym=function(e){function t(n){return/^[0-9,. ]*$/.test(n)?null:{numeric:!0}}return Mt(e,t)};wt.add("numeric");const qm=function(e){function t(n){return/^-?[0-9,. ]*$/.test(n)?null:{positiveOrNegativeNumber:!0}}return Mt(e,t)};wt.add("positiveOrNegativeNumber");const Jm=function(e){function t(n){return/^[^0-9]*$/.test(n)?null:{nonNumeric:!0}}return Mt(e,t)};wt.add("nonNumeric");const vo=Object.freeze({...Am,min:$m,max:Vm,required:Km,minLength:Hm,minLengthArray:Wm,maxLength:Gm,maxLengthArray:zm,pattern:Um,alpha:jm,numeric:Ym,nonNumeric:Jm,positiveOrNegativeNumber:qm,OnBlurErrorKeys:Ze});function yo(e,t=[]){const n=t.reduce((o,a)=>Object.assign(o,a(e)||{}),{});return Object.keys(n).length?n:null}var Ct=(e=>(e[e.ON_CHANGE=0]="ON_CHANGE",e[e.ON_BLUR=1]="ON_BLUR",e[e.ON_SUBMIT=2]="ON_SUBMIT",e))(Ct||{});function Xm(e,t={},n=[]){for(const[o,a]of Object.entries(t))a===0?wi(o):a===2&&Ci(o);return r.useCallback(e,n)}class Yt{constructor(t,n){this.path=t,this.update=n,this.validators=[],this.#e=null,this.#t=null,this.#n=null,this.preventativeErrors=[],this.submitted=!1}#e;#t;#n;get errors(){return this.#e===null&&this.#t===null&&this.#n===null?null:{...this.#e??{},...this.#t??{},...this.#n??{}}}setValidators(t){return this.update(this.path,null,void 0,t),this}validate(t,n,o=!1){if(this.validators&&this.validators.length>0){const a=yo(t,this.validators);let s={onSubmit:{},onChange:{},onBlur:{}};a&&(s=Object.keys(a).reduce((i,l)=>(ho.has(l)?i.onSubmit[l]=a[l]:un.has(l)?i.onChange[l]=a[l]:i.onBlur[l]=a[l],i),s)),(typeof n>"u"||n===Ct.ON_CHANGE)&&(this.#t=Object.keys(s.onChange).length===0?null:s.onChange),(typeof n>"u"||n===Ct.ON_BLUR)&&(this.#n=Object.keys(s.onBlur).length===0?null:s.onBlur),(typeof n>"u"||n===Ct.ON_SUBMIT)&&(this.#e=Object.keys(s.onSubmit).length===0?null:s.onSubmit,this.#t=Object.keys(s.onChange).length===0?null:s.onChange,this.#n=Object.keys(s.onBlur).length===0?null:s.onBlur),o||this.update(),this.isFocused()&&this.onFocus&&this.onFocus()}else this.errors&&(this.#e=null,this.#n=null,this.#t=null,o||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.includes(vo.required)}isSubmitted(){return this.submitted}onFocus(){}onBlur(){}}class Bn extends Yt{constructor(){super(...arguments),this.id=We(),this.focused=!1,this.pristine=!0}setValue(t){if(this.preventativeErrors=[],this.validators&&this.validators.length>0){const n=yo(t,this.validators);if(n&&Object.keys(n).filter(a=>wt.has(a)).length>0){this.preventativeErrors=Object.keys(n);return}}this.update(this.path,t)}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 qt extends Bn{constructor(t,n,o){const a=o?n:t,s=o||n;super(a,s),o&&this.inferMembers(t)}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}inferSpsControl(t,n){return Eo(t,[...this.path,n],this.update)}rollup(t){return Object.keys(this.fields).reduce((n,o)=>n&&(!this.fields[o][t]||this.fields[o][t]()),!0)}}class xi extends qt{inferMembers(t){this.fields={};for(const n of Object.keys(t))this.fields[n]=this.inferSpsControl(t[n],n)}}class ki extends qt{inferMembers(t){this.fields=t.map((n,o)=>this.inferSpsControl(n,String(o)))}}function Eo(e,t,n){return e instanceof Yt?(e.path=t,e.update=n,e):Array.isArray(e)?new ki(e,t,n):Ti(e)?new xi(e,t,n):new Bn(t,n)}function On(e,t){return t.length===0||!e?e:On(e.fields[t[0]],t.slice(1,t.length))}function Br(e,t){if(t.length===0||!e)return[e];const n=t[0];if(t=t.slice(1,t.length),n==="*"){const o=Array.isArray(e.fields)?e.fields:Object.keys(e.fields).map(a=>e.fields[a]);return t.length===0?o:o.reduce((a,s)=>[...a,...Br(s,t)],[])}return Br(e.fields[n],t)}function Or(e,t,n){for(const o of Object.keys(t)){const a=t[o];for(const s of Br(e,o.split(".")))s&&a&&n(s,a)}}function To(e,t,n,o=!1,a=!1){Or(t,n,(s,i)=>{s.validators=typeof i=="function"?i(e):i,o&&s.validate(S.getPath(e,s.path),void 0,a)})}function Rr(e,t){const n=t[0];return t=t.slice(1),Array.isArray(e)?e.map((o,a)=>a===Number(n)?Rr(o,t):o):Ti(e)?Object.keys(e).reduce((o,a)=>Object.assign(o,{[a]:a===n?Rr(e[a],t):e[a]}),{}):e}function Zm(e){if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError("The initial value of useSpsForm() hook must be an object.")}function Mi(e,t={}){Zm(e);const[,n]=T.useState({}),o=T.useRef(!1);o.current=!1;const a=T.useRef(t),s=T.useCallback(p=>{const f=u.current;let g;if(p)if(p.path)if(p.markAsBlurred){const b=On(f.formMeta,p.path);if(b){b.focused=!1;const v=S.getPath(f.formValue,p.path);b.validate(v,Ct.ON_BLUR)}}else if(p.newValidators){if(a.current){const b=p.path.join(".");a.current={...a.current,[b]:p.newValidators},To(f.formValue,f.formMeta,a.current,!0)}}else if(p.markAsSubmitted){const b=On(f.formMeta,p.path);if(b){b.submitted=!0;const v=S.getPath(f.formValue,p.path);b.validate(v,Ct.ON_SUBMIT)}}else g=Rr(f.formValue,p.path),S.setPath(g,p.path,p.value);else g=p.value;if(p?.updateFormOptions?.validators&&(a.current={...a.current,...p.updateFormOptions.validators},To(f.formValue,f.formMeta,a.current,p.updateFormOptions?.runValidators??!0)),g){f.formMeta.submitted=!1,S.deepFreeze(g);const b=S.diff(f.formValue,g);for(const{type:y,key:h,parentPath:I,objects:[,C]}of b){const D=On(f.formMeta,I);if(typeof h!="symbol"&&D){let L;switch(y){case S.DiffChange.ADDITION:D.fields[h]=Eo(C[h],[...I,h],l);break;case S.DiffChange.DELETION:Array.isArray(D.fields)?D.fields[h]=void 0:delete D.fields[h];break;case S.DiffChange.ALTERATION:L=Eo(C[h],[...I,h],l),(L instanceof qt&&!(D.fields[h]instanceof qt)||!(L instanceof qt)&&D.fields[h]instanceof qt)&&(L.pristine=!1,D.fields[h]=L);break}}}const v=new Set;if(b.filter(y=>y.type===S.DiffChange.DELETION).reduce((y,h)=>(y.has(h.parentPath)||y.add(h.parentPath),y),v),Array.from(v).forEach(y=>{const h=On(f.formMeta,y);Array.isArray(h.fields)&&(h.fields=h.fields.filter(I=>I!==void 0))}),a.current){To(g,f.formMeta,a.current);const y=new Set;t&&Or(f.formMeta,t,(h,I)=>{typeof I=="function"&&(h.validate(S.getPath(g,h.path)),y.add(h))});for(const{type:h,key:I,parentPath:C,objects:[,D]}of b)if(typeof I!="symbol"){let L=f.formMeta,F=g;if(L){for(const O of C)L=L.fields[O],F=F[O],y.has(L)||L.validate(F,Ct.ON_CHANGE);if(h===S.DiffChange.ADDITION||h===S.DiffChange.ALTERATION){const O=L.fields[I];if(!y.has(O)&&(L.fields[I].validate(D[I],Ct.ON_CHANGE),h===S.DiffChange.ADDITION&&O.fields))for(const[_,R]of Object.entries(O.fields))R.validate(D[I][_],Ct.ON_CHANGE)}}}}}u.current={...f,formValue:g||f.formValue},o.current||n({})},[]),i=T.useCallback((p,f)=>{p||f?s({value:p,updateFormOptions:f}):s()},[s]),l=T.useCallback((p,f,g=!1,b,v=!1)=>{p?s({path:p,value:f,markAsBlurred:g,newValidators:b,markAsSubmitted:v}):i()},[s,i]),c=T.useMemo(()=>{S.deepFreeze(e);const p=Eo(e,[],l);return t&&To(e,p,t,!1,!0),p},[]),d=T.useCallback(()=>(u.current.formMeta.markAsDirty(),a.current&&Or(u.current.formMeta,a.current,(p,f)=>{(typeof f=="function"||Array.isArray(f))&&p.validate(S.getPath(u.current.formValue,p.path))}),u.current.formMeta.isValid()),[]),m=T.useCallback(()=>u.current.formValue,[]),u=T.useRef({formValue:e,formMeta:c,updateForm:i,validateForm:d,getCurrentFormValue:m});return u.current}const Le=r.forwardRef((e,t)=>{const{className:n,children:o,focusInputOnClick:a,formControl:s,formMeta:i,inputRef:l,onClick:c,...d}=e,m=r.useRef(),p=l||(t||m);function f(){p&&p!==t&&p.current&&p.current.focus()}function g(){p&&p!==t&&p.current&&i&&i instanceof Bn&&i.markAsFocused()}function b(){p&&p!==t&&p.current&&i&&i instanceof Bn&&i.markAsBlurred()}const v=K("sps-form-group",(s&&s.isRequired()||i&&i.isRequired())&&"sps-form-group--required",(s&&!s.isValid()||i&&i.isVisibilyInvalid())&&"sps-form-group--error",i&&i.hasPreventativeErrors()&&"sps-form-group--preventative-error",n);function y(h){a&&f(),c&&c(h)}return r.useEffect(()=>{function h(I){I.target.classList.contains("sps-form-control__clear-btn")&&I.preventDefault()}return document.addEventListener("mousedown",h),()=>{document.removeEventListener("mousedown",h)}},[]),r.createElement("div",{...d,className:v,ref:t,tabIndex:-1,onClick:y,onFocus:g,onBlur:b},o)});Object.assign(Le,{displayName:"SpsFormComponentWrapper"});const Li=e=>typeof e=="object"&&e!=null&&e.nodeType===1,_i=(e,t)=>(!t||e!=="hidden")&&e!=="visible"&&e!=="clip",wo=(e,t)=>{if(e.clientHeight<e.scrollHeight||e.clientWidth<e.scrollWidth){const n=getComputedStyle(e,null);return _i(n.overflowY,t)||_i(n.overflowX,t)||(o=>{const a=(s=>{if(!s.ownerDocument||!s.ownerDocument.defaultView)return null;try{return s.ownerDocument.defaultView.frameElement}catch{return null}})(o);return!!a&&(a.clientHeight<o.scrollHeight||a.clientWidth<o.scrollWidth)})(e)}return!1},Co=(e,t,n,o,a,s,i,l)=>s<e&&i>t||s>e&&i<t?0:s<=e&&l<=n||i>=t&&l>=n?s-e-o:i>t&&l<n||s<e&&l>n?i-t+a:0,Qm=e=>{const t=e.parentElement;return t??(e.getRootNode().host||null)},Pi=(e,t)=>{var n,o,a,s;if(typeof document>"u")return[];const{scrollMode:i,block:l,inline:c,boundary:d,skipOverflowHiddenElements:m}=t,u=typeof d=="function"?d:B=>B!==d;if(!Li(e))throw new TypeError("Invalid target");const p=document.scrollingElement||document.documentElement,f=[];let g=e;for(;Li(g)&&u(g);){if(g=Qm(g),g===p){f.push(g);break}g!=null&&g===document.body&&wo(g)&&!wo(document.documentElement)||g!=null&&wo(g,m)&&f.push(g)}const b=(o=(n=window.visualViewport)==null?void 0:n.width)!=null?o:innerWidth,v=(s=(a=window.visualViewport)==null?void 0:a.height)!=null?s:innerHeight,{scrollX:y,scrollY:h}=window,{height:I,width:C,top:D,right:L,bottom:F,left:O}=e.getBoundingClientRect(),{top:_,right:R,bottom:H,left:Z}=(B=>{const M=window.getComputedStyle(B);return{top:parseFloat(M.scrollMarginTop)||0,right:parseFloat(M.scrollMarginRight)||0,bottom:parseFloat(M.scrollMarginBottom)||0,left:parseFloat(M.scrollMarginLeft)||0}})(e);let V=l==="start"||l==="nearest"?D-_:l==="end"?F+H:D+I/2-_+H,w=c==="center"?O+C/2-Z+R:c==="end"?L+R:O-Z;const $=[];for(let B=0;B<f.length;B++){const M=f[B],{height:q,width:N,top:E,right:k,bottom:z,left:J}=M.getBoundingClientRect();if(i==="if-needed"&&D>=0&&O>=0&&F<=v&&L<=b&&(M===p&&!wo(M)||D>=E&&F<=z&&O>=J&&L<=k))return $;const te=getComputedStyle(M),ne=parseInt(te.borderLeftWidth,10),W=parseInt(te.borderTopWidth,10),X=parseInt(te.borderRightWidth,10),Y=parseInt(te.borderBottomWidth,10);let G=0,ee=0;const U="offsetWidth"in M?M.offsetWidth-M.clientWidth-ne-X:0,Q="offsetHeight"in M?M.offsetHeight-M.clientHeight-W-Y:0,fe="offsetWidth"in M?M.offsetWidth===0?0:N/M.offsetWidth:0,se="offsetHeight"in M?M.offsetHeight===0?0:q/M.offsetHeight:0;if(p===M)G=l==="start"?V:l==="end"?V-v:l==="nearest"?Co(h,h+v,v,W,Y,h+V,h+V+I,I):V-v/2,ee=c==="start"?w:c==="center"?w-b/2:c==="end"?w-b:Co(y,y+b,b,ne,X,y+w,y+w+C,C),G=Math.max(0,G+h),ee=Math.max(0,ee+y);else{G=l==="start"?V-E-W:l==="end"?V-z+Y+Q:l==="nearest"?Co(E,z,q,W,Y+Q,V,V+I,I):V-(E+q/2)+Q/2,ee=c==="start"?w-J-ne:c==="center"?w-(J+N/2)+U/2:c==="end"?w-k+X+U:Co(J,k,N,ne,X+U,w,w+C,C);const{scrollLeft:pe,scrollTop:He}=M;G=se===0?0:Math.max(0,Math.min(He+G/se,M.scrollHeight-q/se+Q)),ee=fe===0?0:Math.max(0,Math.min(pe+ee/fe,M.scrollWidth-N/fe+U)),V+=He-G,w+=pe-ee}$.push({el:M,top:G,left:ee})}return $},ef=e=>e===!1?{block:"end",inline:"nearest"}:(t=>t===Object(t)&&Object.keys(t).length!==0)(e)?e:{block:"start",inline:"nearest"};function Do(e,t){if(!e.isConnected||!(a=>{let s=a;for(;s&&s.parentNode;){if(s.parentNode===document)return!0;s=s.parentNode instanceof ShadowRoot?s.parentNode.host:s.parentNode}return!1})(e))return;const n=(a=>{const s=window.getComputedStyle(a);return{top:parseFloat(s.scrollMarginTop)||0,right:parseFloat(s.scrollMarginRight)||0,bottom:parseFloat(s.scrollMarginBottom)||0,left:parseFloat(s.scrollMarginLeft)||0}})(e);if((a=>typeof a=="object"&&typeof a.behavior=="function")(t))return t.behavior(Pi(e,t));const o=typeof t=="boolean"||t==null?void 0:t.behavior;for(const{el:a,top:s,left:i}of Pi(e,ef(t))){const l=s-n.top+n.bottom,c=i-n.left+n.right;a.scroll({top:l,left:c,behavior:o})}}const Fr=Object.freeze(Object.defineProperty({__proto__:null,default:Do},Symbol.toStringTag,{value:"Module"})),tf={alt:"string",size:"SpinnerSize",title:"string"};function Ar(e){const{alt:t,className:n,size:o=A.SpinnerSize.MEDIUM,"data-testid":a,title:s,unsafelyReplaceClassName:i,...l}=e,{t:c}=Se.useWoodlandLanguage(),d=t||s||c("spinner.defaultAltText",{defaultValue:"Loading..."}),m=K(i||"sps-spinner",`sps-spinner--${o}`,n);return r.createElement("i",{className:m,"data-testid":a,title:d,...l})}Object.assign(Ar,{props:tf,displayName:"SpsSpinner"});const nf=60;function No(e){return typeof e>"u"?"inherit":`${e}px`}function $r(e){switch(e){case A.Position.TOP_LEFT:return A.Position.BOTTOM_LEFT;case A.Position.TOP_MIDDLE:return A.Position.BOTTOM_MIDDLE;case A.Position.TOP_RIGHT:return A.Position.BOTTOM_RIGHT;case A.Position.RIGHT_TOP:return A.Position.LEFT_TOP;case A.Position.RIGHT_MIDDLE:return A.Position.LEFT_MIDDLE;case A.Position.RIGHT_BOTTOM:return A.Position.LEFT_BOTTOM;case A.Position.BOTTOM_RIGHT:return A.Position.TOP_RIGHT;case A.Position.BOTTOM_MIDDLE:return A.Position.TOP_MIDDLE;case A.Position.BOTTOM_LEFT:return A.Position.TOP_LEFT;case A.Position.LEFT_BOTTOM:return A.Position.RIGHT_BOTTOM;case A.Position.LEFT_MIDDLE:return A.Position.RIGHT_MIDDLE;case A.Position.LEFT_TOP:return A.Position.RIGHT_TOP}}function of(e,t,n,o,a,s,i,l){const c=i&&i.current,d=c?c.scrollTop:window.pageYOffset,m=l?0:d,u=c?c.scrollLeft:window.pageXOffset,p=l?0:u,[f,g]=e.split(" ");let b,v,y,h;switch(f){case"top":y=t.height-n.top-m-s[0];break;case"left":v=t.width-n.left-p-s[0];break;case"right":h=n.right+p-s[0];break;case"bottom":b=n.bottom+m-s[0];break;default:throw new Error(`Invalid position ${e}`)}switch(g){case"left":h=n.left+p+s[1];break;case"top":b=n.top+m+s[1];break;case"middle":f==="top"||f==="bottom"?h=n.left+p+n.width/2-a/2+s[1]:(f==="left"||f==="right")&&(b=n.top+m+n.height/2-o.height/2+s[1]);break;case"bottom":y=t.height-n.bottom-m+s[1];break;case"right":v=t.width-n.right-p+s[1];break;default:throw new Error(`Invalid position ${e}`)}return[b,v,y,h]}function Sn(e,t,n,{altPosition:o,setMinWidth:a=!1,setWidth:s=!1,parentElementRef:i,fixed:l=!1,offsets:c=[0,0],altOffsets:d=c}){if(e.current&&t.current){const m=e.current.getBoundingClientRect(),u=t.current.getBoundingClientRect(),p=Math.max(document.documentElement.clientHeight,window.innerHeight||0),f=document.documentElement.getBoundingClientRect().width;let b=(i?.current??document.documentElement).getBoundingClientRect();l&&(b={x:0,y:0,width:f,height:p,top:0,left:0,bottom:p,right:f,toJSON(){return{width:f,height:p,top:0,left:0,bottom:p,right:f}}});const[v,y]=n.split(" ");let h=n;if(o&&(v==="top"&&u.top-m.height<nf||v==="right"&&u.right+m.width>f||v==="bottom"&&u.bottom+m.height>p||v==="left"&&u.left-m.width<0)&&(h=o),y==="left"&&u.left+m.width+(c?.[1]??0)>document.documentElement.getBoundingClientRect().right)switch(v){case"bottom":h=A.Position.BOTTOM_RIGHT;break;case"top":h=A.Position.TOP_RIGHT;break}const I=a?Math.max(u.width,m.width):m.width,C=s?u.width:I,[D,L,F,O]=of(h,b,u,m,C,h===o?d:c,i,l),_={top:No(D),right:No(L),bottom:No(F),left:No(O)};return l&&(_.position="fixed",_.zIndex=A.ZStratum.BAR),a&&(_.minWidth=`${u.width}px`),s&&(_.width=`${u.width}px`),[_,h===o]}return[{},!1]}const rt=T.createContext(null);function gn(e,t=[]){const n=T.useContext(rt);return T.useMemo(()=>o=>{const s=n&&n.parentElementRef&&n.parentElementRef.current||document.body;let i=null,l=s.lastElementChild;for(;l&&l!==s.firstElementChild;){if(l.hasAttribute("data-portalid")&&l.getAttribute("data-portalid")===e){i=l;break}l=l.previousElementSibling}if(i)s.contains(i)||s.appendChild(i);else{i=document.createElement("div"),i.setAttribute("data-portalid",e),i.setAttribute("data-react-aria-top-layer","true");for(const c of t)i.classList.add(c);s.appendChild(i)}return Ln.createPortal(o,i)},[n])}const Vr=["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","1","2","3","4","5","6","7","8","9","0"];async function Bi(e,t,n,o,a,s){const i=typeof e.options=="function"?e.options(t.value):e.options||[],l=i instanceof Promise,c=u=>u.replace(/([.?*+^$[\]\\(){}|-])/g,"");n({pending:l}),s.current=l?i:null;const d=l?await i||[]:i||[];if(l&&s.current!==i)return;let m=Array.from(d).filter(Boolean).map(u=>new A.SpsOptionListOption(u,typeof u=="function"?{textKey:"label",captionKey:"caption"}:{textKey:e.textKey,captionKey:e.captionKey}));if(e.nullOption&&m.unshift(new A.SpsOptionListOption(null,{text:e.nullOption})),t.value&&!e.disableDefaultOptionsFiltering){const u=c(t.value);n({replacementPattern:new RegExp(`(${u})`,"ig")}),m=m.filter(p=>{const f=new RegExp(u,"i"),g=c(p.text);return e.filterByTextAndCaptionKey?f.test(g)||f.test(c(p.caption)):f.test(g)})}else n({replacementPattern:null});if(e.disabledOptions)for(const u of m)e.disabledOptions.includes(u.value)&&(u.disabled=!0);o(Object.freeze(m)),e.onOptionListChanged&&e.onOptionListChanged(m.length),a(m.some(u=>u.value&&!!u.value.icon)),n({pending:!1})}function rf(e,t,n){const[o,a]=r.useState(Object.freeze([])),[s,i]=r.useState(!1),l=r.useRef(null),c=r.useRef(e.options);(typeof e.options!="function"||e.disableOptionsMemoization)&&(c.current=e.options);const d=r.useMemo(()=>typeof c.current=="function"?S.debounce(Bi,typeof e.searchDebounce<"u"?e.searchDebounce:500):Bi,[c.current,e.disabledOptions]);return r.useEffect(()=>{d(e,t,n,a,i,l)},[c.current,t.value,e.disabledOptions]),[o,s]}class Lt{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 af(e,t){return{...e,...t}}function Dt(e){return T.useReducer(af,e)}function sf({hideInlineSearch:e,showInlineSearch:t,options:n,onSearchChange:o,search:a="",searchPlaceholder:s,searchInputRef:i}){const{t:l}=Se.useWoodlandLanguage(),c=s??l("select.searchPlaceholder",{defaultValue:"Search…"}),[d,m]=Dt({isAsync:typeof n=="function",pending:!1,value:a,replacementPattern:null}),u=r.useCallback(v=>{m({value:v.target.value}),o&&o(v)},[o]),p=r.useCallback(v=>{v.nativeEvent.stopImmediatePropagation(),v.stopPropagation()},[]),f=r.useCallback(v=>{v.nativeEvent.stopImmediatePropagation(),m({value:""}),o&&o(new Lt({value:""})),i?.current&&i.current.focus()},[o,i]),g=v=>{v&&(["Tab","Escape","Enter","Up","ArrowUp","Down","ArrowDown"].includes(v.key)||v.stopPropagation())};return r.useEffect(()=>{m({value:a})},[a]),[(d.isAsync||t)&&!e?r.createElement("div",{className:"sps-option-list__search sps-form-group sps-text-input"},r.createElement("div",{className:"sps-form-control"},!d.value&&r.createElement("i",{className:"sps-icon sps-icon-filter sps-text-input__icon"}),r.createElement("input",{type:"text",className:"sps-text-input__input",placeholder:c,ref:i,value:d.value,onChange:u,onClick:p,onKeyDown:g}),d.value&&r.createElement("i",{className:"sps-icon sps-icon-x-circle sps-form-control__clear-btn",onClick:f}))):r.createElement(r.Fragment,null),d,m]}const lf=Do||Fr,cf=["Tab","Escape","Enter","Up","ArrowUp","Down","ArrowDown"];function df(e,t,n){return n?(e&&e[n])===(t&&t[n]):e===t}function Oi(e,t,n){return typeof n.value=="function"&&n.disabled?!0:t?!!e?.find(o=>o[t]&&o[t]===n?.value?.[t]):!1}const Rn=r.forwardRef((e,t)=>{const{captionKey:n,comparisonKey:o,disabledOptions:a,options:s,tall:i,textKey:l,valueKey:c,zeroState:d,hideInlineSearch:m,showInlineSearch:u,onSearchChange:p,search:f,searchDebounce:g,searchPlaceholder:b,onSpecialActionSelect:v,attachTo:y,className:h,conformWidth:I,id:C,ignoreWidthStyles:D,isOpen:L,keepOpen:F,keyDown:O,nullOption:_,onOptionListChanged:R,onOptionSelected:H,onPositionFlip:Z,onSelfToggle:V,optionRole:w,positionOverride:$,selectedOption:B,specialAction:M,unsafelyReplaceClassName:q,loading:N,filterByTextAndCaptionKey:E,maxHeightPx:k,maxHeightRem:z,disableOptionsMemoization:J,disableDefaultOptionsFiltering:te,"data-testid":ne,typeaheadEvent:W,...X}=e,Y=r.useMemo(()=>M?new A.SpsOptionListOption(M,{textKey:"label",captionKey:"caption"}):null,[M]),[G,ee]=r.useState(-1),[U,Q]=r.useState(L),fe=t||r.useRef(null),se=r.useRef(null),pe=r.useRef(null),He=gn("sps-option-list-portal"),$e=r.useContext(rt),[Xe,nt]=$||[A.Position.BOTTOM_LEFT,A.Position.TOP_LEFT],[[mt,ke],ot]=r.useState([{},!1]),Ve=r.useRef(null),[ft,_e,oe]=sf({...e,searchInputRef:Ve}),[ue,je]=rf(e,_e,oe);r.useEffect(()=>{W&&Ye(W)},[W]),r.useEffect(()=>{ot(U?Sn(fe,y,Xe,{altPosition:nt,setMinWidth:!D,setWidth:!D&&I,...$e}):[{},!1])},[U,Xe,nt,ue]),r.useEffect(()=>{let ie;return U&&(ie=()=>{U&&ot(Sn(fe,y,Xe,{altPosition:nt,setMinWidth:!D,setWidth:!D&&I,...$e}))},document.addEventListener("scroll",ie)),()=>{ie&&document.removeEventListener("scroll",ie)}},[U]),r.useEffect(()=>{ee(-1)},[_e]);const So=K(q||"sps-option-list","z-stratum-dropdown",U&&"sps-option-list--open",_e.isAsync&&"sps-option-list--searchable",ke&&"sps-option-list--opens-upward",M&&M.label&&"sps-option-list--has-special-action",h),xr=K(q||"sps-option-list__options",i&&"sps-option-list__options--tall"),xt=r.useCallback(()=>{U||(Q(!0),Ve.current&&Ve.current.focus(),ee(-1),V&&V(!0))},[U,V]),jt=r.useCallback(()=>{U&&(Q(!1),ee(-1),V&&V(!1))},[U,V]),yt=r.useCallback((ie,de)=>{de||ie&&!ie.disabled&&(typeof ie.value=="function"?(ie.value(),v&&v()):typeof H=="function"&&H(ie.value),F||jt())},[H,jt]),go=r.useCallback((ie,de,Me)=>{ie.stopPropagation(),yt(de,Me)},[yt]),ae=r.useRef(a||[]);ae.current=a||[];const we=r.useCallback(ie=>{switch(ie.key){case"Tab":case"Escape":jt();break;case"Enter":if(G>-1){const de=ue[G]||Y;ie.preventDefault();const Me=!!de&&Oi(ae.current,o||"",de);!Me&&de&&typeof H=="function"&&typeof de.value=="function"?de.value():de&&yt(de,Me)}break;case"Up":case"ArrowUp":{let de=G;ke?G<=-1?de=ue.length-1:G===0?M&&(de=ue.length):G<ue.length&&(de=G-1):G>-1&&(de=G-1),de!==G&&(ie.preventDefault(),ee(de));break}case"Down":case"ArrowDown":{xt();let de=G;ke?G!==-1&&(G>=ue.length?de=0:G===ue.length-1?de=-1:de=G+1):G<ue.length-1+ +!!M&&(de=G+1),de!==G&&(ie.preventDefault(),ee(de));break}default:xt()}},[jt,xt,G,yt,H,ke,ue]),Ke=r.useCallback(ie=>{xt();const de=ue.findIndex(Me=>{if(Me.textKey){const Tt=Me.textKey;return Me.value[Tt].toLowerCase().charAt([0])===ie.key.toLocaleLowerCase()}return Me.value.toString().toLowerCase().charAt([0])===ie.key.toLocaleLowerCase()});de>-1&&ee(de)},[ue]),Ye=r.useCallback(ie=>{ie&&(cf.includes(ie.key)?we(ie):Vr.includes(ie.key)&&!m&&Ke(ie))},[jt,xt,G,yt,H,ke,ue]);r.useEffect(()=>{if($e!==null&&document.getElementsByClassName("sps-modal__body").length>0){const ie=()=>{V&&V(!1)},de=document.getElementsByClassName("sps-modal__body")[0];return de.addEventListener("scroll",ie),()=>{de.removeEventListener("scroll",ie)}}},[]),r.useEffect(()=>{U&&pe.current&&lf(pe.current,{scrollMode:"if-needed",block:"nearest",inline:"nearest"})},[G,U]),r.useEffect(()=>{Q(L),L?Ve.current&&Ve.current.focus():ee(-1)},[L]),r.useEffect(()=>{O&&Ye(O)},[O]),r.useEffect(()=>{!U&&se.current&&(p&&_e.value&&p(new Lt({value:""})),oe({value:""}),se.current.scrollTop=0),U&&Z&&Z(ke)},[U]);const Ie=k?k/16:z,Et=Ie?{maxHeight:`${Ie}rem`}:{};function kt(ie,de){return de?r.createElement(r.Fragment,null,ie.split(de).map((Me,Tt)=>de.test(Me)?r.createElement("u",{key:Tt},Me):r.createElement(r.Fragment,{key:Tt},Me))):r.createElement(r.Fragment,null,ie)}return He(r.createElement("div",{className:So,id:C,"aria-activedescendant":G>-1?`${C}-option-${G}`:"",tabIndex:-1,ref:fe,style:mt,onMouseLeave:()=>ee(-1),"data-testid":ne,...X},ft,r.createElement("div",{className:xr,ref:se,"data-testid":`${ne}-options`,style:Et},!N&&!_e.pending&&d&&ue.length===0&&r.createElement("div",{className:"sps-option-list__zero-state"},d),(N||_e.pending)&&r.createElement("div",{className:"sps-option-list__loading"},r.createElement(Ar,null)),!N&&!_e.pending&&ue.map((ie,de)=>{const Me=`${C}-option-${de}`,Tt=df(ie.value,B,o),km=Oi(ae.current,o||"",ie);return r.createElement("a",{key:Me,id:Me,role:w,"aria-selected":Tt,href:ie.href,className:K("sps-option-list__option",ie.caption&&"sps-option-list__option--has-caption",ie.disabled&&"sps-option-list__option--disabled",ie.bold&&"sps-option-list__option--bold",(Tt||km)&&"sps-option-list__option--selected",G===de&&"sps-option-list__option--highlighted"),onClick:XC=>go(XC,ie,km),onMouseOver:()=>ee(de),tabIndex:-1,ref:G===de?pe:null,"data-testid":`${ne}-option-${de}`},ie.value&&ie.value.icon&&r.createElement("i",{className:K("sps-icon","sps-option-list__option-icon",`sps-icon-${String(ie.value.icon)}`)}),(!ie.value||!ie.value.icon&&je)&&r.createElement("span",{className:"sps-option-list__option-icon-spacer"}),r.createElement("span",null,kt(ie.text,_e.replacementPattern)),ie.caption&&r.createElement("div",{className:"sps-option-list__option-caption"},r.createElement("span",null,kt(ie.caption,_e.replacementPattern))))})),Y&&M?.label&&r.createElement("a",{className:K("sps-option-list__option","sps-option-list__special-action",G===ue.length&&"sps-option-list__option--highlighted",M.disabled&&"sps-option-list__special-action--disabled"),href:Y.href,target:Y.href&&M.newTab?"_blank":"_self",onClick:ie=>go(ie,Y),onMouseOver:()=>ee(ue.length),"data-testid":`${ne}-special-action`},M.icon&&r.createElement("i",{className:K("sps-icon","sps-option-list__option-icon",`sps-icon-${String(M.icon)}`)}),!M.icon&&je&&r.createElement("span",{className:"sps-option-list__option-icon-spacer"}),r.createElement("span",null,M.label))))});Object.assign(Rn,{displayName:"SpsOptionList"});function hn(e){return{key:e.key,preventDefault:()=>{}}}function pf(e,t,n=[]){return r.useMemo(()=>{function o(a){return r.createElement(e,{...a,...t},a.children)}return o},n)}function qe(e){return typeof e=="function"?e():e}const Ri=function({children:e,elements:t}){if(t.length===0)return r.createElement(r.Fragment,null,e);const[n,o]=Array.isArray(t[0])?t[0]:[t[0]];return r.createElement(n,{...o??{}},r.createElement(Ri,{elements:t.slice(1)},e))},Fi=function({children:e,providers:t=[],...n}){return r.createElement("div",{...n},r.createElement(Ri,{elements:t},e))},uf=function({children:e,className:t,...n}){return r.createElement(Fi,{className:`sps-app ${t}`,...n},e)};function mf(e,t){const{type:n,props:o={},custom:a}=t;return a?a(e.type):e.type!==n?!1:Object.keys(o).every(s=>o[s]===e.props[s])}function at(e=[],t=[]){const n=Array.isArray(e)?S.flatten(e):[e],o=t.map(s=>Array.isArray(s)?s:[s]),a=new Array(o.length+1).fill(null).map(()=>[]);for(const s of n){let i=!1;for(let l=0;l<o.length;l+=1)for(const c of o[l])if(mf(s,c)){i=!0,a[l].push(s);break}i||a[a.length-1].push(s)}return a}function Ai(e,t,n){const o=Object.entries(t).filter(([,s])=>typeof s!="string"&&s.deprecated).map(([s])=>s),a=o.map(s=>n[s]);r.useEffect(()=>{a.find(s=>typeof s<"u")&&console.warn(`The following prop(s) of ${e} are deprecated: ${o.join(", ")}`)},a)}function Kr(e,t){const n=T.useRef(!1);T.useEffect(()=>()=>{n.current=!1},[]),T.useEffect(()=>{if(n.current)return e();n.current=!0},t)}function Hr(e,t,n){const o=r.useRef(t(...n));r.useEffect(()=>(document.addEventListener(e,o.current,{capture:!0}),()=>document.removeEventListener(e,o.current)),[]),r.useEffect(()=>{document.removeEventListener(e,o.current),o.current=t(...n),document.addEventListener(e,o.current,{capture:!0})},n)}function $i(e,t,n){return function(a){!e.current?.contains(a.target)&&!t.current?.contains(a.target)&&n()}}function bn(e,t,n){const o=r.useRef(!1),[a,s]=r.useState(!1),i=r.useCallback(()=>{o.current?o.current=!1:s(!0)},[]),l=r.useCallback((c=!1)=>{s(!1),o.current=c,n&&n()},[]);return Hr("mousedown",$i,[e,t,l]),Hr("pointerdown",$i,[e,t,l]),{showPopup:a,doShowPopup:i,doHidePopup:l}}const Vi=e=>{const t=/(auto|scroll)/,n=(l,c)=>l.parentNode===null?c:n(l.parentNode,c.concat([l])),o=(l,c)=>getComputedStyle(l,null).getPropertyValue(c),a=l=>o(l,"overflow")+o(l,"overflow-y"),s=l=>t.test(a(l));return(l=>{if(!(l instanceof HTMLElement||l instanceof SVGElement))return;const c=n(l.parentNode,[]);for(let d=0;d<c.length;d+=1)if(s(c[d]))return c[d];return null})(e)};let Io=0,Fn=null,An=null;function $n({isOpen:e,rootRef:t}){r.useLayoutEffect(()=>{let n=!1;if(e&&t.current&&(n=!0,Io+=1,Io===1)){const o=Vi(t.current)||document.body;Fn=o;const a=o===document.body?window.innerWidth-document.documentElement.clientWidth:o.offsetWidth-o.clientWidth;o.style.overflow="hidden";const s=window.getComputedStyle(o).paddingRight;if(o.style.paddingRight=s&&s!=="0px"?`calc(${s} + ${a}px)`:`${a}px`,o===document.body){let i=document.getElementsByClassName("sps-navbar-container").item(0);if(i&&window.getComputedStyle(i).position==="fixed"){const l=window.getComputedStyle(i).paddingRight;i.style.paddingRight=l&&l!=="0px"?`calc(${l} + ${a}px)`:`${a}px`,An=i}else if(i=document.getElementsByTagName("nav").item(0)?.parentElement??null,i&&window.getComputedStyle(i).position==="fixed"){const c=window.getComputedStyle(i).paddingRight;i.style.paddingRight=c&&c!=="0px"?`calc(${c} + ${a}px)`:`${a}px`,An=i}}}return()=>{n&&(Io-=1,Io===0&&Fn&&(Fn.style.overflow="",Fn.style.paddingRight="",An&&(An.style.paddingRight="",An=null),Fn=null))}},[e])}const ff={debounce:"number",disabled:"boolean",conformWidth:"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
4
|
`,required:!0},textKey:"string",captionKey:"string",tallOptionList:"boolean",value:"string",zeroState:"string",loading:"boolean",maxHeightOptionListPx:"number",maxHeightOptionListRem:"number",disableOptionsMemoization:"boolean",inputNotClearable:"boolean",autoFocusOnSelection:"boolean"};function Nt({className:e,debounce:t=0,disabled:n,conformWidth:o,formControl:a,formMeta:s,onChange:i,onSelectionChange:l,icon:c,id:d,placeholder:m="",suggestions:u,unsafelyReplaceClassName:p,textKey:f,captionKey:g,tallOptionList:b,value:v="",zeroState:y,loading:h,maxHeightOptionListPx:I,maxHeightOptionListRem:C,disableOptionsMemoization:D,inputNotClearable:L,autoFocusOnSelection:F,"data-testid":O,..._}){const R=s||a,{wrapperId:H,controlId:Z}=Ge(d,R),[V,w]=Dt({keyDown:null,opensUpward:!1}),$=r.useRef(null),B=r.useRef(null),M=r.useRef(null),{showPopup:q,doShowPopup:N,doHidePopup:E}=bn($,M);function k(Y,G,ee=!1){R&&(R.setValue(Y),R.markAsDirty()),l&&ee?l(Y):i&&i(G||new Lt({value:Y}))}function z(Y){B.current&&(B.current.value="",k("")),Y.stopPropagation()}function J(Y){k(Y.target.value,Y)}function te(Y){n||(["Up","ArrowUp","Down","ArrowDown","Enter"].includes(Y.key)&&Y.preventDefault(),Y.stopPropagation(),w({keyDown:hn(Y)})),Y.key==="Tab"&&E()}function ne(Y){Y?N():E()}function W(Y){w({opensUpward:Y})}const X=K(p||"sps-autocomplete",q&&"sps-autocomplete--open",q&&"z-stratum-dropdown",V.opensUpward&&"sps-autocomplete--opens-upward",n&&"sps-form-control--disabled",e);return r.useEffect(()=>{let Y;return q&&(Y=()=>{E()},window.addEventListener("resize",Y)),()=>{Y&&window.removeEventListener("resize",Y)}},[q]),$n({isOpen:q,rootRef:$}),r.createElement(Le,{id:H,className:X,formControl:a,formMeta:s,inputRef:B,ref:$,focusInputOnClick:!0,onClick:Y=>Y.nativeEvent.stopImmediatePropagation(),"data-testid":`${O}`},r.createElement("div",{className:"sps-text-input"},r.createElement("div",{className:"sps-form-control"},c&&r.createElement("i",{className:K("sps-text-input__icon","sps-icon",`sps-icon-${c}`)}),r.createElement("input",{type:"text",ref:B,value:v,className:"sps-text-input__input",placeholder:m,onFocus:N,onClick:N,onChange:J,onKeyDown:te,disabled:n,id:Z,"data-testid":`${O}__input`,..._}),v&&!n&&!L&&r.createElement("i",{"aria-label":"clear",className:"sps-icon sps-icon-x-circle sps-form-control__clear-btn",onClick:Y=>z(Y)}))),r.createElement(Rn,{id:`${H}_options`,ref:M,attachTo:$,isOpen:q,options:u,hideInlineSearch:!0,keyDown:V.keyDown,onOptionSelected:Y=>{const G=f&&typeof Y=="object"&&Y!==null?Y[f]??"":Y;k(G,void 0,!0),F&&B.current?.focus()},onPositionFlip:W,onSelfToggle:ne,offsets:[1,0],search:v,searchDebounce:t,textKey:f,captionKey:g,tall:b,zeroState:y,loading:h,maxHeightPx:I,maxHeightRem:C,disableOptionsMemoization:D,conformWidth:o}))}Object.assign(Nt,{props:ff,displayName:"SpsAutocomplete"});const Ki={basic:{label:"Basic",examples:{basic:{react:S.code`
|
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.53.
|
|
4
|
+
"version": "8.53.15",
|
|
5
5
|
"author": "SPS Commerce",
|
|
6
6
|
"license": "UNLICENSED",
|
|
7
7
|
"repository": "https://github.com/spscommerce/woodland/tree/main/packages/@spscommerce/ds-react",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"axe-prop-types": "1.0.9",
|
|
34
34
|
"clsx": "2.1.1",
|
|
35
35
|
"lodash.isplainobject": "^4.0.6",
|
|
36
|
-
"nanoid": "5.1.
|
|
36
|
+
"nanoid": "5.1.16",
|
|
37
37
|
"prop-types": "^15.7.2",
|
|
38
38
|
"react-beautiful-dnd": "^13.1.0",
|
|
39
39
|
"scroll-into-view-if-needed": "^3.1.0",
|
|
@@ -46,11 +46,11 @@
|
|
|
46
46
|
"moment-timezone": "^0.6.0",
|
|
47
47
|
"react": "^16.14.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
48
48
|
"react-dom": "^16.14.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
49
|
-
"@sps-woodland/illustrations": "8.53.
|
|
50
|
-
"@spscommerce/ds-colors": "8.53.
|
|
51
|
-
"@spscommerce/
|
|
52
|
-
"@spscommerce/
|
|
53
|
-
"@spscommerce/
|
|
49
|
+
"@sps-woodland/illustrations": "8.53.15",
|
|
50
|
+
"@spscommerce/ds-colors": "8.53.15",
|
|
51
|
+
"@spscommerce/i18n": "8.53.15",
|
|
52
|
+
"@spscommerce/positioning": "8.53.15",
|
|
53
|
+
"@spscommerce/ds-shared": "8.53.15"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@react-stately/collections": "3.12.10",
|
|
@@ -70,12 +70,12 @@
|
|
|
70
70
|
"raf-stub": "3.0.0",
|
|
71
71
|
"react": "16.14.0",
|
|
72
72
|
"react-dom": "16.14.0",
|
|
73
|
-
"@sps-woodland/illustrations": "8.53.
|
|
74
|
-
"@spscommerce/ds-
|
|
75
|
-
"@spscommerce/ds-
|
|
76
|
-
"@spscommerce/i18n": "8.53.
|
|
77
|
-
"
|
|
78
|
-
"
|
|
73
|
+
"@sps-woodland/illustrations": "8.53.15",
|
|
74
|
+
"@spscommerce/ds-shared": "8.53.15",
|
|
75
|
+
"@spscommerce/ds-colors": "8.53.15",
|
|
76
|
+
"@spscommerce/i18n": "8.53.15",
|
|
77
|
+
"test": "8.53.15",
|
|
78
|
+
"@spscommerce/positioning": "8.53.15"
|
|
79
79
|
},
|
|
80
80
|
"scripts": {
|
|
81
81
|
"build": "pnpm run build:js && pnpm run build:types",
|