@spscommerce/ds-react 7.4.13 → 7.4.14

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
@@ -5788,7 +5788,7 @@ var n=r.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
- `}}}},EN={kind:"ModalKind",size:"ModalSize",title:"string",onClose:"() => void",focusElementOnOpen:"React.MutableRefObject<HTMLElement>",fullHeight:"boolean"};function aa({children:e}){return s.createElement("div",{className:"sps-modal__footer"},e)}Object.assign(aa,{props:{},propTypes:{},displayName:"SpsModalFooter"});function Ri({children:e,className:t,id:r,kind:n=V.ModalKind.GENERAL,size:a=V.ModalSize.SMALL,onClose:i,focusElementOnOpen:l,title:c,fullHeight:p=!1,...u}){const f=Dr(r),m=$("sps-modal","z-stratum-dialog",`sps-modal--${n}`,`sps-modal--${a}`,t),{t:h}=s.useContext(Re),g=s.useRef(null),[T,C]=s.useState(!1);s.useEffect(()=>{const I=`${window.innerWidth-document.body.clientWidth}px`;return document.body.style.paddingRight=I,document.body.style.overflow="hidden",document.querySelectorAll(".z-stratum-bar").forEach(b=>{b.tempPaddingRightHolder=b.style.paddingRight,b.style.paddingRight=I}),C(!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,T]);const E=s.useCallback(I=>{if(I&&I.key==="Escape"&&i&&i(),I&&I.key==="Tab"&&g.current){const b=g.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),x=b[0],O=b[b.length-1];b.length===0?I.preventDefault():I.shiftKey&&I.target===x?(I.preventDefault(),O.focus()):!I.shiftKey&&I.target===O&&(I.preventDefault(),x.focus())}},[i]),[[D],N]=yt(e,[{type:aa}]);return T?s.createElement("div",{id:f.current,role:"dialog","aria-modal":!0,"aria-labelledby":`${f.current}-title`,className:m,onKeyDown:E,tabIndex:-1,ref:g},s.createElement("div",{...u,className:$("sps-modal__dialog",{"sps-modal__dialog-full-height":p})},s.createElement("div",{className:"sps-modal__titlebar"},s.createElement("div",{className:"sps-modal__title",id:`${f.current}-title`},c||h(`design-system:modal.defaultTitle.${n}`)),i&&s.createElement("div",{className:"sps-button sps-button--icon",onClick:i},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(vt.Provider,{value:{parentElementRef:g,fixed:!0}},N)),D||s.createElement("div",{className:"sps-modal__footer"},s.createElement(Ve,{kind:n===V.ModalKind.SERIOUS_WARNING?V.ButtonKind.DELETE:V.ButtonKind.KEY,onClick:i},h("design-system:modal.defaultButtonLabel"))))):s.createElement(s.Fragment,null)}Object.assign(Ri,{props:EN,displayName:"SpsModal"});const wN={title:"string",show:"boolean",closeOnEscapePressed:"boolean",onClose:"() => void",focusElementOnOpen:"React.MutableRefObject<HTMLElement>"};function Pi({children:e,className:t,id:r,show:n,closeOnEscapePressed:a=!0,onClose:i,focusElementOnOpen:l,title:c,...p}){const u=Dr(r),f=$("sps-slide-in-panel","z-stratum-dialog",n?"open":"",t),m=s.useRef(document.body.style.overflow||""),h=s.useRef(document.body.style.paddingRight||""),{t:g}=s.useContext(Re),T=s.useRef(null);s.useEffect(()=>{if(n){const D=`${window.innerWidth-document.body.clientWidth}px`;document.body.style.paddingRight=D,document.body.style.overflow="hidden"}else document.body.style.overflow=m.current,document.body.style.paddingRight=h.current;return()=>{document.body.style.overflow=m.current,document.body.style.paddingRight=h.current}},[n]),s.useEffect(()=>{l&&l.current?l.current.focus():T.current&&T.current.focus()},[l]);const C=s.useCallback(D=>{if(a&&D&&D.key==="Escape"&&i&&i(),D&&D.key==="Tab"&&T.current){const N=T.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),I=N[0],b=N[N.length-1];N.length===0?D.preventDefault():D.shiftKey&&D.target===I?(D.preventDefault(),b.focus()):!D.shiftKey&&D.target===b&&(D.preventDefault(),I.focus())}},[i]),[E]=yt(e);return s.createElement("div",{id:u.current,role:"dialog","aria-labelledby":`${u.current}-title`,className:f,onKeyDown:C,tabIndex:-1,ref:T},s.createElement("div",{...p,className:`sps-slide-in-panel__dialog ${n?"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")),i&&s.createElement("div",{className:"sps-button sps-button--icon",onClick:i},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(vt.Provider,{value:{parentElementRef:T,fixed:!0}},E))))}Object.assign(Pi,{props:wN,displayName:"SpsSlideInPanel"});const Nm={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
+ `}}}},EN={kind:"ModalKind",size:"ModalSize",title:"string",onClose:"() => void",focusElementOnOpen:"React.MutableRefObject<HTMLElement>",fullHeight:"boolean"};function aa({children:e}){return s.createElement("div",{className:"sps-modal__footer"},e)}Object.assign(aa,{props:{},propTypes:{},displayName:"SpsModalFooter"});function Ri({children:e,className:t,id:r,kind:n=V.ModalKind.GENERAL,size:a=V.ModalSize.SMALL,onClose:i,focusElementOnOpen:l,title:c,fullHeight:p=!1,...u}){const f=Dr(r),m=$("sps-modal","z-stratum-dialog",`sps-modal--${n}`,`sps-modal--${a}`,t),{t:h}=s.useContext(Re),g=s.useRef(null),[T,C]=s.useState(!1);s.useEffect(()=>{const I=`${window.innerWidth-document.body.clientWidth}px`;return document.body.style.paddingRight=I,document.body.style.overflow="hidden",document.querySelectorAll(".z-stratum-bar").forEach(b=>{b.tempPaddingRightHolder=b.style.paddingRight,b.style.paddingRight=I}),C(!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,T]);const E=s.useCallback(I=>{if(I&&I.key==="Escape"&&i&&i(),I&&I.key==="Tab"&&g.current){const b=g.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),x=b[0],O=b[b.length-1];b.length===0?I.preventDefault():I.shiftKey&&I.target===x?(I.preventDefault(),O.focus()):!I.shiftKey&&I.target===O&&(I.preventDefault(),x.focus())}},[i]),[[D],N]=yt(e,[{type:aa}]);return T?s.createElement("div",{id:f.current,role:"dialog","aria-modal":!0,"aria-labelledby":`${f.current}-title`,className:m,onKeyDown:E,tabIndex:-1,ref:g},s.createElement("div",{...u,className:$("sps-modal__dialog",{"sps-modal__dialog-full-height":p})},s.createElement("div",{className:"sps-modal__titlebar"},s.createElement("div",{className:"sps-modal__title",id:`${f.current}-title`},c||h(`design-system:modal.defaultTitle.${n}`)),i&&s.createElement("div",{className:"sps-button sps-button--icon",onClick:i},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(vt.Provider,{value:{parentElementRef:g,fixed:!0}},N)),D||s.createElement("div",{className:"sps-modal__footer"},s.createElement(Ve,{kind:n===V.ModalKind.SERIOUS_WARNING?V.ButtonKind.DELETE:V.ButtonKind.KEY,onClick:i},h("design-system:modal.defaultButtonLabel"))))):s.createElement(s.Fragment,null)}Object.assign(Ri,{props:EN,displayName:"SpsModal"});const wN={title:"string",show:"boolean",closeOnEscapePressed:"boolean",onClose:"() => void",focusElementOnOpen:"React.MutableRefObject<HTMLElement>"};function Pi({children:e,className:t,id:r,show:n,closeOnEscapePressed:a=!0,onClose:i,focusElementOnOpen:l,title:c,...p}){const u=Dr(r),f=$("sps-slide-in-panel","z-stratum-dialog",n?"open":"",t),m=s.useRef(document.body.style.overflow||""),h=s.useRef(document.body.style.paddingRight||""),{t:g}=s.useContext(Re),T=s.useRef(null);s.useEffect(()=>{if(n){const D=`${window.innerWidth-document.body.clientWidth}px`;document.body.style.paddingRight=D,document.body.style.overflow="hidden"}else document.body.style.overflow=m.current,document.body.style.paddingRight=h.current;return()=>{document.body.style.overflow=m.current,document.body.style.paddingRight=h.current}},[n]),s.useEffect(()=>{l&&l.current?l.current.focus():T.current&&T.current.focus()},[l]);const C=s.useCallback(D=>{if(a&&D&&D.key==="Escape"&&i&&i(),D&&D.key==="Tab"&&T.current){const N=T.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),I=N[0],b=N[N.length-1];N.length===0?D.preventDefault():D.shiftKey&&D.target===I?(D.preventDefault(),b.focus()):!D.shiftKey&&D.target===b&&(D.preventDefault(),I.focus())}},[i]);s.useEffect(()=>(window.addEventListener("keydown",C),()=>{window.removeEventListener("keydown",C)}),[C]);const[E]=yt(e);return s.createElement("div",{id:u.current,role:"dialog","aria-labelledby":`${u.current}-title`,className:f,tabIndex:-1,ref:T},s.createElement("div",{...p,className:`sps-slide-in-panel__dialog ${n?"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")),i&&s.createElement("div",{className:"sps-button sps-button--icon",onClick:i},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(vt.Provider,{value:{parentElementRef:T,fixed:!0}},E))))}Object.assign(Pi,{props:wN,displayName:"SpsSlideInPanel"});const Nm={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
@@ -22087,13 +22087,16 @@ function Nu({
22087
22087
  }
22088
22088
  },
22089
22089
  [i]
22090
- ), [T] = Ot(e);
22090
+ );
22091
+ s.useEffect(() => (window.addEventListener("keydown", C), () => {
22092
+ window.removeEventListener("keydown", C);
22093
+ }), [C]);
22094
+ const [T] = Ot(e);
22091
22095
  return /* @__PURE__ */ s.createElement("div", {
22092
22096
  id: u.current,
22093
22097
  role: "dialog",
22094
22098
  "aria-labelledby": `${u.current}-title`,
22095
22099
  className: f,
22096
- onKeyDown: C,
22097
22100
  tabIndex: -1,
22098
22101
  ref: y
22099
22102
  }, /* @__PURE__ */ s.createElement("div", {
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.4.13",
4
+ "version": "7.4.14",
5
5
  "author": "SPS Commerce",
6
6
  "license": "UNLICENSED",
7
7
  "repository": "https://github.com/spscommerce/woodland/tree/main/packages/@spscommerce/ds-react",
@@ -40,11 +40,11 @@
40
40
  },
41
41
  "peerDependencies": {
42
42
  "@react-stately/collections": "^3.6.0",
43
- "@sps-woodland/illustrations": "7.4.13",
44
- "@sps-woodland/tabs": "7.4.13",
45
- "@spscommerce/ds-colors": "7.4.13",
46
- "@spscommerce/ds-shared": "7.4.13",
47
- "@spscommerce/positioning": "7.4.13",
43
+ "@sps-woodland/illustrations": "7.4.14",
44
+ "@sps-woodland/tabs": "7.4.14",
45
+ "@spscommerce/ds-colors": "7.4.14",
46
+ "@spscommerce/ds-shared": "7.4.14",
47
+ "@spscommerce/positioning": "7.4.14",
48
48
  "@spscommerce/utils": "^6.11.3",
49
49
  "moment": "^2.25.3",
50
50
  "moment-timezone": "^0.5.28",
@@ -58,11 +58,11 @@
58
58
  "@react-types/select": "^3.6.1",
59
59
  "@react-types/shared": "^3.8.0",
60
60
  "@react-types/tabs": "^3.0.1",
61
- "@sps-woodland/illustrations": "7.4.13",
62
- "@sps-woodland/tabs": "7.4.13",
63
- "@spscommerce/ds-colors": "7.4.13",
64
- "@spscommerce/ds-shared": "7.4.13",
65
- "@spscommerce/positioning": "7.4.13",
61
+ "@sps-woodland/illustrations": "7.4.14",
62
+ "@sps-woodland/tabs": "7.4.14",
63
+ "@spscommerce/ds-colors": "7.4.14",
64
+ "@spscommerce/ds-shared": "7.4.14",
65
+ "@spscommerce/positioning": "7.4.14",
66
66
  "@spscommerce/utils": "^6.12.1",
67
67
  "@testing-library/dom": "^8.17.1",
68
68
  "@testing-library/react": "^10.0.0",
@@ -76,7 +76,7 @@
76
76
  "raf-stub": "^2.0.2",
77
77
  "react": "^16.9.0",
78
78
  "react-dom": "^16.9.0",
79
- "test": "7.4.13"
79
+ "test": "7.4.14"
80
80
  },
81
81
  "scripts": {
82
82
  "build": "pnpm run build:js && pnpm run build:types",