@spscommerce/ds-react 7.7.2 → 7.7.4

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
@@ -1845,7 +1845,7 @@ Valid keys: `+JSON.stringify(Object.keys(G),null," "));var Te=xe(le,re,ne,ee,U+
1845
1845
  </div>
1846
1846
  );
1847
1847
  }
1848
- `}}}},oN={disabled:"boolean",formMeta:"SpsFormFieldMeta<SimpleDateRange | DatePreset>",maxDate:"SimpleDate",minDate:"SimpleDate",onChange:"(newDateRange: SimpleDateRange | DatePreset) => void",presets:"Array<DatePreset>",value:"SimpleDateRange | DatePreset",showTwoMonths:"boolean"},Dd="sps-datepicker",xo=[{definition:"P0D",label:"design-system:datepicker.preset.today"},{definition:"() => [null, {month: 1, date: 1, year: 3000}]",label:"design-system:datepicker.preset.before"},{definition:"() => [{month: 1, date: 1, year: 1990}, null]",label:"design-system:datepicker.preset.after"},{definition:"P7D",label:"design-system:datepicker.preset.sevenDays"},{definition:"P30D",label:"design-system:datepicker.preset.thirtyDays"},{definition:"P60D",label:"design-system:datepicker.preset.sixtyDays"},{definition:"P90D",label:"design-system:datepicker.preset.ninetyDays"},{definition:"P1Y",label:"design-system:datepicker.preset.oneYear"}];function Mi({children:e,className:t,disabled:n,formMeta:r,id:a,maxDate:o,minDate:l,onChange:c,presets:p=xo,value:u,showTwoMonths:m=!1,"data-testid":f,...h}){const{t:g}=s.useContext(Re),{wrapperId:E,controlId:w}=vt(a,r),T=s.useRef(null),D=s.useRef(null),N=s.useRef(null),[k,b]=s.useState(Array.isArray(u)?oe.toStringRange(u):""),[I,L]=s.useState(null),[M,O]=s.useState(),{showPopup:R,doShowPopup:W,doHidePopup:_}=Hr(T,N);function V(A){r&&(r.setValue(A),r.markAsDirty()),c&&c(A)}function x(A){const q=u||[];let J;!q[0]||q[1]||oe.isBefore(A,q[0])?J=[A,null]:(J=[q[0],A],_(!0),D&&D.current&&D.current.focus()),I&&X(I)==="Before"&&q[0]===null&&q[1]===null&&(J=[null,A],_(!0),D&&D.current&&D.current.focus()),I&&X(I)==="After"&&(_(!0),D&&D.current&&D.current.focus()),V(J),b(oe.toStringRange(J)),O(void 0),(I&&X(I)==="Before"&&J&&J[0]!==null||I&&X(I)!=="Before"&&X(I)!=="After")&&L(null)}function F(A){b(A.target.value);const q=oe.createRangeFrom(A.target.value);V(q),O(void 0)}function Z(){b(""),V(),O(void 0),L(null)}function te(A){switch(A.key){case"Tab":_();break;case"Backspace":A.target.selectionStart===0&&u&&!Array.isArray(u)&&Z();break}}function z(A){if(!A){L(null),V(void 0);return}L(A);const q=oe.createRangeFromPreset(A);if(A&&X(A)==="Before")if(u&&u[0]&&u[1]){let J=oe.createRangeFrom("-");J&&V(J)}else{let J=oe.createRangeFrom(`-${oe.toString(u&&u[0])}`);J&&V(J)}else if(A&&X(A)==="After")if(u&&u[0]&&u[1]){let J=oe.createRangeFrom("-");J&&V(J)}else{let J=oe.createRangeFrom(`${oe.toString(u&&u[0])}-`);J&&V(J)}else JSON.stringify(u)!==JSON.stringify(q)&&V(q)}s.useEffect(()=>{if(!!u&&p!==xo&&Array.isArray(u)){const A=oe.toStringRange(u),q=p.find(J=>A===oe.toStringRange(oe.createRangeFromPreset(J)));q?z(q):L(null)}},[u]),s.useEffect(()=>{u?Array.isArray(u)&&!I?(u.every(A=>oe.isValid(A)||A===null)&&b(oe.toStringRange(u)),O(void 0)):Array.isArray(u)&&I&&X(I)==="Before"?u&&u[0]&&u[1]?L(null):u.every(A=>oe.isValid(A)||A===null)&&b(oe.toStringRange(u)):Array.isArray(u)&&I&&X(I)==="After"?u&&u[0]&&u[1]?L(null):u.every(A=>oe.isValid(A)||A===null)&&b(oe.toStringRange(u)):Array.isArray(u)&&I&&b(""):Z()},[u,I]);function X(A){return A&&/^design-system:/.test(A.label)?g(A.label):A.label}const G=H(Dd,"sps-text-input",R&&`${Dd}--open`,t);return s.createElement(s.Fragment,null,s.createElement(nt,{id:E,className:G,formMeta:r,inputRef:D,focusInputOnClick:!0,ref:T},s.createElement("div",{className:H("sps-form-control",n&&"disabled")},s.createElement("i",{className:H("sps-text-input__icon","sps-icon","sps-icon-calendar")}),I&&s.createElement("div",{"data-testid":`${f}_selected_preset`,className:"sps-datepicker__selected-preset"},s.createElement("span",{className:"sps-tag sps-tag--info"},X(I))),s.createElement("input",{type:"text",ref:D,className:"sps-text-input__input","data-testid":`${f}_date_input`,id:w,placeholder:!k&&!I?Ks:void 0,onChange:F,onClick:W,onFocus:W,onKeyDown:te,value:k,disabled:n,...h}),u&&!n&&s.createElement("i",{className:"sps-icon sps-icon-x-circle sps-form-control__clear-btn",onClick:Z}))),s.createElement(Ii,{isOpen:R,attachTo:T,ref:N},s.createElement("div",{className:"sps-datepicker__presets"},s.createElement("fieldset",null,s.createElement("legend",{className:"sps-datepicker__presets-label"},g("design-system:datepicker.presetsLabel")),s.createElement("div",{className:"sps-custom-control sps-custom-radio sps-custom-control--no-error"},s.createElement("input",{"data-testid":`${f}_presets_custom_input`,type:"radio",id:`sps-date-range-picker-${E}__range-custom`,className:"sps-custom-control__input",checked:!I,name:`sps-date-range-picker-${E}__range`,onChange:()=>z()}),s.createElement("label",{className:"sps-custom-control__label",htmlFor:`sps-date-range-picker-${E}__range-custom`},g("design-system:datepicker.preset.custom"))),p.map((A,q)=>s.createElement("div",{key:X(A),className:"sps-custom-control sps-custom-radio sps-custom-control--no-error"},s.createElement("input",{type:"radio","data-testid":`${f}_preset_option_${A.label}`,id:`sps-date-range-picker-${E}__range-${q}`,name:`sps-date-range-picker-${E}__range`,onChange:()=>z(A),checked:I!=null&&I.definition?I.definition===A.definition:!1,className:"sps-custom-control__input"}),s.createElement("label",{className:"sps-custom-control__label",htmlFor:`sps-date-range-picker-${E}__range-${q}`},X(A)))))),s.createElement(xi,{"data-testid":`${f}_calendar`,selectedRange:Array.isArray(u)?u:M,onNewSelection:x,minDate:l,maxDate:o,showTwoMonths:m,selectedPreset:I&&X(I)})))}Object.assign(Mi,{props:oN,displayName:"SpsDateRangePicker"});const om={basic:{label:"Basic",examples:{basic:{react:y.code`
1848
+ `}}}},oN={disabled:"boolean",formMeta:"SpsFormFieldMeta<SimpleDateRange | DatePreset>",maxDate:"SimpleDate",minDate:"SimpleDate",onChange:"(newDateRange: SimpleDateRange | DatePreset) => void",presets:"Array<DatePreset>",value:"SimpleDateRange | DatePreset",showTwoMonths:"boolean"},Dd="sps-datepicker",xo=[{definition:"P0D",label:"design-system:datepicker.preset.today"},{definition:"() => [null, {month: 1, date: 1, year: 3000}]",label:"design-system:datepicker.preset.before"},{definition:"() => [{month: 1, date: 1, year: 1990}, null]",label:"design-system:datepicker.preset.after"},{definition:"P7D",label:"design-system:datepicker.preset.sevenDays"},{definition:"P30D",label:"design-system:datepicker.preset.thirtyDays"},{definition:"P60D",label:"design-system:datepicker.preset.sixtyDays"},{definition:"P90D",label:"design-system:datepicker.preset.ninetyDays"},{definition:"P1Y",label:"design-system:datepicker.preset.oneYear"}];function Mi({children:e,className:t,disabled:n,formMeta:r,id:a,maxDate:o,minDate:l,onChange:c,presets:p=xo,value:u,showTwoMonths:m=!1,"data-testid":f,...h}){const{t:g}=s.useContext(Re),{wrapperId:E,controlId:w}=vt(a,r),T=s.useRef(null),D=s.useRef(null),N=s.useRef(null),[k,b]=s.useState(Array.isArray(u)?oe.toStringRange(u):""),[I,L]=s.useState(null),[M,O]=s.useState(),{showPopup:R,doShowPopup:W,doHidePopup:_}=Hr(T,N);function V(A){r&&(r.setValue(A),r.markAsDirty()),c&&c(A)}function x(A){const q=u||[];let J;!q[0]||q[1]||oe.isBefore(A,q[0])?J=[A,null]:(J=[q[0],A],_(!0),D&&D.current&&D.current.focus()),I&&X(I)==="Before"&&q[0]===null&&q[1]===null&&(J=[null,A],_(!0),D&&D.current&&D.current.focus()),I&&X(I)==="After"&&(_(!0),D&&D.current&&D.current.focus()),V(J),b(oe.toStringRange(J)),O(void 0),(I&&X(I)==="Before"&&J&&J[0]!==null||I&&X(I)!=="Before"&&X(I)!=="After")&&L(null)}function F(A){b(A.target.value);const q=oe.createRangeFrom(A.target.value);V(q),O(void 0)}function Z(){b(""),V(),O(void 0),L(null)}function te(A){switch(A.key){case"Tab":_();break;case"Backspace":A.target.selectionStart===0&&u&&!Array.isArray(u)&&Z();break}}function z(A){if(!A){L(null),V(void 0);return}L(A);const q=oe.createRangeFromPreset(A);if(A&&X(A)==="Before")if(u&&u[0]&&u[1]){let J=oe.createRangeFrom("-");J&&V(J)}else{let J=oe.createRangeFrom(`-${oe.toString(u&&u[0])}`);J&&V(J)}else if(A&&X(A)==="After")if(u&&u[0]&&u[1]){let J=oe.createRangeFrom("-");J&&V(J)}else{let J=oe.createRangeFrom(`${oe.toString(u&&u[0])}-`);J&&V(J)}else JSON.stringify(u)!==JSON.stringify(q)&&V(q)}s.useEffect(()=>{if(!!u&&p!==xo&&Array.isArray(u)){const A=oe.toStringRange(u),q=p.find(J=>A===oe.toStringRange(oe.createRangeFromPreset(J)));q?z(q):u[0]===null||u[1]===null||L(null)}},[u]),s.useEffect(()=>{u?Array.isArray(u)&&!I?(u.every(A=>oe.isValid(A)||A===null)&&b(oe.toStringRange(u)),O(void 0)):Array.isArray(u)&&I&&X(I)==="Before"?u&&u[0]&&u[1]?L(null):u.every(A=>oe.isValid(A)||A===null)&&b(oe.toStringRange(u)):Array.isArray(u)&&I&&X(I)==="After"?u&&u[0]&&u[1]?L(null):u.every(A=>oe.isValid(A)||A===null)&&b(oe.toStringRange(u)):Array.isArray(u)&&I&&b(""):Z()},[u,I]);function X(A){return A&&/^design-system:/.test(A.label)?g(A.label):A.label}const G=H(Dd,"sps-text-input",R&&`${Dd}--open`,t);return s.createElement(s.Fragment,null,s.createElement(nt,{id:E,className:G,formMeta:r,inputRef:D,focusInputOnClick:!0,ref:T},s.createElement("div",{className:H("sps-form-control",n&&"disabled")},s.createElement("i",{className:H("sps-text-input__icon","sps-icon","sps-icon-calendar")}),I&&s.createElement("div",{"data-testid":`${f}_selected_preset`,className:"sps-datepicker__selected-preset"},s.createElement("span",{className:"sps-tag sps-tag--info"},X(I))),s.createElement("input",{type:"text",ref:D,className:"sps-text-input__input","data-testid":`${f}_date_input`,id:w,placeholder:!k&&!I?Ks:void 0,onChange:F,onClick:W,onFocus:W,onKeyDown:te,value:k,disabled:n,...h}),u&&!n&&s.createElement("i",{className:"sps-icon sps-icon-x-circle sps-form-control__clear-btn",onClick:Z}))),s.createElement(Ii,{isOpen:R,attachTo:T,ref:N},s.createElement("div",{className:"sps-datepicker__presets"},s.createElement("fieldset",null,s.createElement("legend",{className:"sps-datepicker__presets-label"},g("design-system:datepicker.presetsLabel")),s.createElement("div",{className:"sps-custom-control sps-custom-radio sps-custom-control--no-error"},s.createElement("input",{"data-testid":`${f}_presets_custom_input`,type:"radio",id:`sps-date-range-picker-${E}__range-custom`,className:"sps-custom-control__input",checked:!I,name:`sps-date-range-picker-${E}__range`,onChange:()=>z()}),s.createElement("label",{className:"sps-custom-control__label",htmlFor:`sps-date-range-picker-${E}__range-custom`},g("design-system:datepicker.preset.custom"))),p.map((A,q)=>s.createElement("div",{key:X(A),className:"sps-custom-control sps-custom-radio sps-custom-control--no-error"},s.createElement("input",{type:"radio","data-testid":`${f}_preset_option_${A.label}`,id:`sps-date-range-picker-${E}__range-${q}`,name:`sps-date-range-picker-${E}__range`,onChange:()=>z(A),checked:I!=null&&I.definition?I.definition===A.definition:!1,className:"sps-custom-control__input"}),s.createElement("label",{className:"sps-custom-control__label",htmlFor:`sps-date-range-picker-${E}__range-${q}`},X(A)))))),s.createElement(xi,{"data-testid":`${f}_calendar`,selectedRange:Array.isArray(u)?u:M,onNewSelection:x,minDate:l,maxDate:o,showTwoMonths:m,selectedPreset:I&&X(I)})))}Object.assign(Mi,{props:oN,displayName:"SpsDateRangePicker"});const om={basic:{label:"Basic",examples:{basic:{react:y.code`
1849
1849
  import {
1850
1850
  useSpsForm,
1851
1851
  SpsLabel,
@@ -5788,7 +5788,7 @@ var r=n.defineLocale("zh-tw",{months:"\u4E00\u6708_\u4E8C\u6708_\u4E09\u6708_\u5
5788
5788
  import { FeedbackBlockKind } from "@spscommerce/ds-shared";
5789
5789
  `,jsx:y.code`
5790
5790
  <SpsMicroBlock kind={FeedbackBlockKind.TIP} message="Pro Tip: Don't be a loser."/>
5791
- `}}}},AN={kind:"ModalKind",size:"ModalSize",title:"string",onClose:"() => void",focusElementOnOpen:"React.MutableRefObject<HTMLElement>",fullHeight:"boolean"};function ca({children:e}){return s.createElement("div",{className:"sps-modal__footer"},e)}Object.assign(ca,{props:{},propTypes:{},displayName:"SpsModalFooter"});function Ki({children:e,className:t,id:n,kind:r=$.ModalKind.GENERAL,size:a=$.ModalSize.SMALL,onClose:o,focusElementOnOpen:l,title:c,fullHeight:p=!1,...u}){const m=Nn(n),f=H("sps-modal","z-stratum-dialog",`sps-modal--${r}`,`sps-modal--${a}`,t),{t:h}=s.useContext(Re),g=s.useRef(null),[E,w]=s.useState(!1);s.useEffect(()=>{const k=`${window.innerWidth-document.body.clientWidth}px`;return document.body.style.paddingRight=k,document.body.style.overflow="hidden",document.querySelectorAll(".z-stratum-bar").forEach(b=>{b.tempPaddingRightHolder=b.style.paddingRight,b.style.paddingRight=k}),w(!0),()=>{document.body.style.paddingRight="initial",document.body.style.overflow="auto",document.querySelectorAll(".z-stratum-bar").forEach(b=>{b.style.paddingRight=b.tempPaddingRightHolder||"",delete b.tempPaddingRightHolder})}},[]),s.useEffect(()=>{l&&l.current?l.current.focus():g.current&&g.current.focus()},[l,E]);const T=s.useCallback(k=>{if(k&&k.key==="Escape"&&o&&o(),k&&k.key==="Tab"&&g.current){const b=g.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),I=b[0],L=b[b.length-1];b.length===0?k.preventDefault():k.shiftKey&&k.target===I?(k.preventDefault(),L.focus()):!k.shiftKey&&k.target===L&&(k.preventDefault(),I.focus())}},[o]),[[D],N]=Et(e,[{type:ca}]);return E?s.createElement("div",{id:m.current,role:"dialog","aria-modal":!0,"aria-labelledby":`${m.current}-title`,className:f,onKeyDown:T,tabIndex:-1,ref:g},s.createElement("div",{...u,className:H("sps-modal__dialog",{"sps-modal__dialog-full-height":p})},s.createElement("div",{className:"sps-modal__titlebar"},s.createElement("div",{className:"sps-modal__title",id:`${m.current}-title`},c||h(`design-system:modal.defaultTitle.${r}`)),o&&s.createElement("div",{className:"sps-button sps-button--icon",onClick:o},s.createElement("button",{"aria-label":h("design-system:modal.close"),type:"button"},s.createElement("i",{className:"sps-icon sps-icon-x"})))),s.createElement("div",{className:"sps-modal__body"},s.createElement(yt.Provider,{value:{parentElementRef:g,fixed:!0}},N)),D||s.createElement("div",{className:"sps-modal__footer"},s.createElement($e,{kind:r===$.ModalKind.SERIOUS_WARNING?$.ButtonKind.DELETE:$.ButtonKind.KEY,onClick:o},h("design-system:modal.defaultButtonLabel"))))):s.createElement(s.Fragment,null)}Object.assign(Ki,{props:AN,displayName:"SpsModal"});const $N={title:"string",show:"boolean",closeOnEscapePressed:"boolean",onClose:"() => void",focusElementOnOpen:"React.MutableRefObject<HTMLElement>"};function Hi({children:e,className:t,id:n,show:r,closeOnEscapePressed:a=!0,onClose:o,focusElementOnOpen:l,title:c,...p}){const u=Nn(n),m=H("sps-slide-in-panel","z-stratum-dialog",r?"open":"",t),f=s.useRef(document.body.style.overflow||""),h=s.useRef(document.body.style.paddingRight||""),{t:g}=s.useContext(Re),E=s.useRef(null);s.useEffect(()=>{if(r){const D=`${window.innerWidth-document.body.clientWidth}px`;document.body.style.paddingRight=D,document.body.style.overflow="hidden"}else document.body.style.overflow=f.current,document.body.style.paddingRight=h.current;return()=>{document.body.style.overflow=f.current,document.body.style.paddingRight=h.current}},[r]),s.useEffect(()=>{l&&l.current?l.current.focus():E.current&&E.current.focus()},[l]);const w=s.useCallback(D=>{if(a&&D&&D.key==="Escape"&&o&&o(),D&&D.key==="Tab"&&E.current){const N=E.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),k=N[0],b=N[N.length-1];N.length===0?D.preventDefault():D.shiftKey&&D.target===k?(D.preventDefault(),b.focus()):!D.shiftKey&&D.target===b&&(D.preventDefault(),k.focus())}},[o]);s.useEffect(()=>(window.addEventListener("keydown",w),()=>{window.removeEventListener("keydown",w)}),[w]);const[T]=Et(e);return s.createElement("div",{id:u.current,role:"dialog","aria-labelledby":`${u.current}-title`,className:m,tabIndex:-1,ref:E},s.createElement("div",{...p,className:`sps-slide-in-panel__dialog ${r?"open":""}`},s.createElement("div",{className:"sps-slide-in-panel__titlebar"},s.createElement("div",{className:"sps-slide-in-panel__title",id:`${u.current}-title`},c||g("design-system:slideInPanel.defaultTitle")),o&&s.createElement("div",{className:"sps-button sps-button--icon",onClick:o},s.createElement("button",{"aria-label":g("design-system:slideInPanel.close"),type:"button"},s.createElement("i",{className:"sps-icon sps-icon-x"})))),s.createElement("div",{className:"sps-slide-in-panel__body"},s.createElement(yt.Provider,{value:{parentElementRef:E,fixed:!0}},T))))}Object.assign(Hi,{props:$N,displayName:"SpsSlideInPanel"});const Gm={generalUsage:{label:"General Usage",description:()=>s.createElement(s.Fragment,null),examples:{noCloseButton:{description:()=>s.createElement(s.Fragment,null,s.createElement("p",null,"Click on the button below to show the slide-in panel.")),react:y.code`
5791
+ `}}}},AN={kind:"ModalKind",size:"ModalSize",title:"string",onClose:"() => void",focusElementOnOpen:"React.MutableRefObject<HTMLElement>",fullHeight:"boolean"};function ca({children:e}){return s.createElement("div",{className:"sps-modal__footer"},e)}Object.assign(ca,{props:{},propTypes:{},displayName:"SpsModalFooter"});function Ki({children:e,className:t,id:n,kind:r=$.ModalKind.GENERAL,size:a=$.ModalSize.SMALL,onClose:o,focusElementOnOpen:l,title:c,fullHeight:p=!1,...u}){const m=Nn(n),f=H("sps-modal","z-stratum-dialog",`sps-modal--${r}`,`sps-modal--${a}`,t),{t:h}=s.useContext(Re),g=s.useRef(null),E=s.useRef(document.body.style.overflow||""),w=s.useRef(document.body.style.paddingRight||"");s.useLayoutEffect(()=>{let k=!1;if(document.body.style.overflow!=="hidden"){const b=`${window.innerWidth-document.body.clientWidth}px`;document.body.style.paddingRight=b,document.body.style.overflow="hidden",k=!0}return()=>{k&&(document.body.style.overflow=E.current,document.body.style.paddingRight=w.current)}},[]),s.useEffect(()=>{l&&l.current?l.current.focus():g.current&&g.current.focus()},[l]);const T=s.useCallback(k=>{if(k&&k.key==="Escape"&&o&&o(),k&&k.key==="Tab"&&g.current){const b=g.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),I=b[0],L=b[b.length-1];b.length===0?k.preventDefault():k.shiftKey&&k.target===I?(k.preventDefault(),L.focus()):!k.shiftKey&&k.target===L&&(k.preventDefault(),I.focus())}},[o]),[[D],N]=Et(e,[{type:ca}]);return s.createElement("div",{id:m.current,role:"dialog","aria-modal":!0,"aria-labelledby":`${m.current}-title`,className:f,onKeyDown:T,tabIndex:-1,ref:g},s.createElement("div",{...u,className:H("sps-modal__dialog",{"sps-modal__dialog-full-height":p})},s.createElement("div",{className:"sps-modal__titlebar"},s.createElement("div",{className:"sps-modal__title",id:`${m.current}-title`},c||h(`design-system:modal.defaultTitle.${r}`)),o&&s.createElement("div",{className:"sps-button sps-button--icon",onClick:o},s.createElement("button",{"aria-label":h("design-system:modal.close"),type:"button"},s.createElement("i",{className:"sps-icon sps-icon-x"})))),s.createElement("div",{className:"sps-modal__body"},s.createElement(yt.Provider,{value:{parentElementRef:g,fixed:!0}},N)),D||s.createElement("div",{className:"sps-modal__footer"},s.createElement($e,{kind:r===$.ModalKind.SERIOUS_WARNING?$.ButtonKind.DELETE:$.ButtonKind.KEY,onClick:o},h("design-system:modal.defaultButtonLabel")))))}Object.assign(Ki,{props:AN,displayName:"SpsModal"});const $N={title:"string",show:"boolean",closeOnEscapePressed:"boolean",onClose:"() => void",focusElementOnOpen:"React.MutableRefObject<HTMLElement>"};function Hi({children:e,className:t,id:n,show:r,closeOnEscapePressed:a=!0,onClose:o,focusElementOnOpen:l,title:c,...p}){const u=Nn(n),m=H("sps-slide-in-panel","z-stratum-dialog",r?"open":"",t),f=s.useRef(document.body.style.overflow||""),h=s.useRef(document.body.style.paddingRight||""),{t:g}=s.useContext(Re),E=s.useRef(null);s.useEffect(()=>{if(r){const D=`${window.innerWidth-document.body.clientWidth}px`;document.body.style.paddingRight=D,document.body.style.overflow="hidden"}else document.body.style.overflow=f.current,document.body.style.paddingRight=h.current;return()=>{document.body.style.overflow=f.current,document.body.style.paddingRight=h.current}},[r]),s.useEffect(()=>{l&&l.current?l.current.focus():E.current&&E.current.focus()},[l]);const w=s.useCallback(D=>{if(a&&D&&D.key==="Escape"&&o&&o(),D&&D.key==="Tab"&&E.current){const N=E.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),k=N[0],b=N[N.length-1];N.length===0?D.preventDefault():D.shiftKey&&D.target===k?(D.preventDefault(),b.focus()):!D.shiftKey&&D.target===b&&(D.preventDefault(),k.focus())}},[o]);s.useEffect(()=>(window.addEventListener("keydown",w),()=>{window.removeEventListener("keydown",w)}),[w]);const[T]=Et(e);return s.createElement("div",{id:u.current,role:"dialog","aria-labelledby":`${u.current}-title`,className:m,tabIndex:-1,ref:E},s.createElement("div",{...p,className:`sps-slide-in-panel__dialog ${r?"open":""}`},s.createElement("div",{className:"sps-slide-in-panel__titlebar"},s.createElement("div",{className:"sps-slide-in-panel__title",id:`${u.current}-title`},c||g("design-system:slideInPanel.defaultTitle")),o&&s.createElement("div",{className:"sps-button sps-button--icon",onClick:o},s.createElement("button",{"aria-label":g("design-system:slideInPanel.close"),type:"button"},s.createElement("i",{className:"sps-icon sps-icon-x"})))),s.createElement("div",{className:"sps-slide-in-panel__body"},s.createElement(yt.Provider,{value:{parentElementRef:E,fixed:!0}},T))))}Object.assign(Hi,{props:$N,displayName:"SpsSlideInPanel"});const Gm={generalUsage:{label:"General Usage",description:()=>s.createElement(s.Fragment,null),examples:{noCloseButton:{description:()=>s.createElement(s.Fragment,null,s.createElement("p",null,"Click on the button below to show the slide-in panel.")),react:y.code`
5792
5792
  import { SpsButton, SpsSlideInPanel } from "@spscommerce/ds-react";
5793
5793
  import { ButtonKind } from "@spscommerce/ds-shared";
5794
5794
  function Component() {
package/lib/index.es.js CHANGED
@@ -12367,7 +12367,7 @@ function Eu({
12367
12367
  se.createRangeFromPreset(j)
12368
12368
  )
12369
12369
  );
12370
- z ? U(z) : L(null);
12370
+ z ? U(z) : u[0] === null || u[1] === null || L(null);
12371
12371
  }
12372
12372
  }, [u]), s.useEffect(() => {
12373
12373
  u ? Array.isArray(u) && !I ? (u.every((F) => se.isValid(F) || F === null) && b(se.toStringRange(u)), O(void 0)) : Array.isArray(u) && I && J(I) === "Before" ? u && u[0] && u[1] ? L(null) : u.every((F) => se.isValid(F) || F === null) && b(se.toStringRange(u)) : Array.isArray(u) && I && J(I) === "After" ? u && u[0] && u[1] ? L(null) : u.every((F) => se.isValid(F) || F === null) && b(se.toStringRange(u)) : Array.isArray(u) && I && b("") : q();
@@ -22110,19 +22110,19 @@ function Wu({
22110
22110
  `sps-modal--${n}`,
22111
22111
  `sps-modal--${a}`,
22112
22112
  t
22113
- ), { t: h } = s.useContext(Ae), S = s.useRef(null), [y, w] = s.useState(!1);
22114
- s.useEffect(() => {
22115
- const k = `${window.innerWidth - document.body.clientWidth}px`;
22116
- return document.body.style.paddingRight = k, document.body.style.overflow = "hidden", document.querySelectorAll(".z-stratum-bar").forEach((b) => {
22117
- b.tempPaddingRightHolder = b.style.paddingRight, b.style.paddingRight = k;
22118
- }), w(!0), () => {
22119
- document.body.style.paddingRight = "initial", document.body.style.overflow = "auto", document.querySelectorAll(".z-stratum-bar").forEach((b) => {
22120
- b.style.paddingRight = b.tempPaddingRightHolder || "", delete b.tempPaddingRightHolder;
22121
- });
22113
+ ), { t: h } = s.useContext(Ae), S = s.useRef(null), y = s.useRef(document.body.style.overflow || ""), w = s.useRef(document.body.style.paddingRight || "");
22114
+ s.useLayoutEffect(() => {
22115
+ let k = !1;
22116
+ if (document.body.style.overflow !== "hidden") {
22117
+ const b = `${window.innerWidth - document.body.clientWidth}px`;
22118
+ document.body.style.paddingRight = b, document.body.style.overflow = "hidden", k = !0;
22119
+ }
22120
+ return () => {
22121
+ k && (document.body.style.overflow = y.current, document.body.style.paddingRight = w.current);
22122
22122
  };
22123
22123
  }, []), s.useEffect(() => {
22124
22124
  l && l.current ? l.current.focus() : S.current && S.current.focus();
22125
- }, [l, y]);
22125
+ }, [l]);
22126
22126
  const T = s.useCallback(
22127
22127
  (k) => {
22128
22128
  if (k && k.key === "Escape" && o && o(), k && k.key === "Tab" && S.current) {
@@ -22137,7 +22137,7 @@ function Wu({
22137
22137
  [D],
22138
22138
  N
22139
22139
  ] = Lt(e, [{ type: xi }]);
22140
- return y ? /* @__PURE__ */ s.createElement("div", {
22140
+ return /* @__PURE__ */ s.createElement("div", {
22141
22141
  id: m.current,
22142
22142
  role: "dialog",
22143
22143
  "aria-modal": !0,
@@ -22174,7 +22174,7 @@ function Wu({
22174
22174
  }, /* @__PURE__ */ s.createElement(He, {
22175
22175
  kind: n === Rl.SERIOUS_WARNING ? Ge.DELETE : Ge.KEY,
22176
22176
  onClick: o
22177
- }, h("design-system:modal.defaultButtonLabel"))))) : /* @__PURE__ */ s.createElement(s.Fragment, null);
22177
+ }, h("design-system:modal.defaultButtonLabel")))));
22178
22178
  }
22179
22179
  Object.assign(Wu, {
22180
22180
  props: MN,
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": "7.7.2",
4
+ "version": "7.7.4",
5
5
  "author": "SPS Commerce",
6
6
  "license": "UNLICENSED",
7
7
  "repository": "https://github.com/spscommerce/woodland/tree/main/packages/@spscommerce/ds-react",
@@ -41,11 +41,11 @@
41
41
  },
42
42
  "peerDependencies": {
43
43
  "@react-stately/collections": "^3.6.0",
44
- "@sps-woodland/illustrations": "7.7.2",
45
- "@sps-woodland/tabs": "7.7.2",
46
- "@spscommerce/ds-colors": "7.7.2",
47
- "@spscommerce/ds-shared": "7.7.2",
48
- "@spscommerce/positioning": "7.7.2",
44
+ "@sps-woodland/illustrations": "7.7.4",
45
+ "@sps-woodland/tabs": "7.7.4",
46
+ "@spscommerce/ds-colors": "7.7.4",
47
+ "@spscommerce/ds-shared": "7.7.4",
48
+ "@spscommerce/positioning": "7.7.4",
49
49
  "@spscommerce/utils": "^6.11.3",
50
50
  "moment": "^2.25.3",
51
51
  "moment-timezone": "^0.5.28",
@@ -59,11 +59,11 @@
59
59
  "@react-types/select": "^3.6.1",
60
60
  "@react-types/shared": "^3.8.0",
61
61
  "@react-types/tabs": "^3.0.1",
62
- "@sps-woodland/illustrations": "7.7.2",
63
- "@sps-woodland/tabs": "7.7.2",
64
- "@spscommerce/ds-colors": "7.7.2",
65
- "@spscommerce/ds-shared": "7.7.2",
66
- "@spscommerce/positioning": "7.7.2",
62
+ "@sps-woodland/illustrations": "7.7.4",
63
+ "@sps-woodland/tabs": "7.7.4",
64
+ "@spscommerce/ds-colors": "7.7.4",
65
+ "@spscommerce/ds-shared": "7.7.4",
66
+ "@spscommerce/positioning": "7.7.4",
67
67
  "@spscommerce/utils": "^6.12.1",
68
68
  "@testing-library/dom": "^8.17.1",
69
69
  "@testing-library/react": "^10.0.0",
@@ -77,7 +77,7 @@
77
77
  "raf-stub": "^2.0.2",
78
78
  "react": "^16.9.0",
79
79
  "react-dom": "^16.9.0",
80
- "test": "7.7.2"
80
+ "test": "7.7.4"
81
81
  },
82
82
  "scripts": {
83
83
  "build": "pnpm run build:js && pnpm run build:types",