@spscommerce/ds-react 7.4.9 → 7.4.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.cjs.js +1 -1
- package/lib/index.es.js +18 -20
- package/package.json +12 -12
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
|
-
`}}}},TN={kind:"ModalKind",size:"ModalSize",title:"string",onClose:"() => void",focusElementOnOpen:"React.MutableRefObject<HTMLElement>",fullHeight:"boolean"};function sa({children:e}){return s.createElement("div",{className:"sps-modal__footer"},e)}Object.assign(sa,{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,E]=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}),E(!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 C=s.useCallback(k=>{if(k&&k.key==="Escape"&&i&&i(),k&&k.key==="Tab"&&g.current){const b=g.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),I=b[0],O=b[b.length-1];b.length===0?k.preventDefault():k.shiftKey&&k.target===I?(k.preventDefault(),O.focus()):!k.shiftKey&&k.target===O&&(k.preventDefault(),I.focus())}},[i]),[[D],N]=yt(e,[{type:sa}]);return T?s.createElement("div",{id:f.current,role:"dialog","aria-modal":!0,"aria-labelledby":`${f.current}-title`,className:m,onKeyDown:C,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:TN,displayName:"SpsModal"});const EN={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),
|
|
5791
|
+
`}}}},TN={kind:"ModalKind",size:"ModalSize",title:"string",onClose:"() => void",focusElementOnOpen:"React.MutableRefObject<HTMLElement>",fullHeight:"boolean"};function sa({children:e}){return s.createElement("div",{className:"sps-modal__footer"},e)}Object.assign(sa,{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,E]=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}),E(!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 C=s.useCallback(k=>{if(k&&k.key==="Escape"&&i&&i(),k&&k.key==="Tab"&&g.current){const b=g.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),I=b[0],O=b[b.length-1];b.length===0?k.preventDefault():k.shiftKey&&k.target===I?(k.preventDefault(),O.focus()):!k.shiftKey&&k.target===O&&(k.preventDefault(),I.focus())}},[i]),[[D],N]=yt(e,[{type:sa}]);return T?s.createElement("div",{id:f.current,role:"dialog","aria-modal":!0,"aria-labelledby":`${f.current}-title`,className:m,onKeyDown:C,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:TN,displayName:"SpsModal"});const EN={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 E=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"])'),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())}},[i]),[C]=yt(e);return s.createElement("div",{id:u.current,role:"dialog","aria-labelledby":`${u.current}-title`,className:f,onKeyDown:E,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}},C))))}Object.assign(Pi,{props:EN,displayName:"SpsSlideInPanel"});const Cm={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
|
@@ -22039,25 +22039,23 @@ function Du({
|
|
|
22039
22039
|
title: c,
|
|
22040
22040
|
...p
|
|
22041
22041
|
}) {
|
|
22042
|
-
const u = ln(r), f = V("sps-slide-in-panel", "z-stratum-dialog", n ? "open" : "", t),
|
|
22042
|
+
const u = ln(r), f = V("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(Ae), y = s.useRef(null);
|
|
22043
22043
|
s.useEffect(() => {
|
|
22044
|
-
|
|
22045
|
-
|
|
22046
|
-
|
|
22047
|
-
}
|
|
22048
|
-
document.body.style.
|
|
22049
|
-
|
|
22050
|
-
|
|
22044
|
+
if (n) {
|
|
22045
|
+
const D = `${window.innerWidth - document.body.clientWidth}px`;
|
|
22046
|
+
document.body.style.paddingRight = D, document.body.style.overflow = "hidden";
|
|
22047
|
+
} else
|
|
22048
|
+
document.body.style.overflow = m.current, document.body.style.paddingRight = h.current;
|
|
22049
|
+
return () => {
|
|
22050
|
+
document.body.style.overflow = m.current, document.body.style.paddingRight = h.current;
|
|
22051
22051
|
};
|
|
22052
|
-
}, []), s.useEffect(() => {
|
|
22053
|
-
document.body.style.overflow = n ? "hidden" : "auto";
|
|
22054
22052
|
}, [n]), s.useEffect(() => {
|
|
22055
|
-
l && l.current ? l.current.focus() :
|
|
22056
|
-
}, [l
|
|
22053
|
+
l && l.current ? l.current.focus() : y.current && y.current.focus();
|
|
22054
|
+
}, [l]);
|
|
22057
22055
|
const T = s.useCallback(
|
|
22058
22056
|
(D) => {
|
|
22059
|
-
if (a && D && D.key === "Escape" && i && i(), D && D.key === "Tab" &&
|
|
22060
|
-
const N =
|
|
22057
|
+
if (a && D && D.key === "Escape" && i && i(), D && D.key === "Tab" && y.current) {
|
|
22058
|
+
const N = y.current.querySelectorAll(
|
|
22061
22059
|
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
|
|
22062
22060
|
), k = N[0], b = N[N.length - 1];
|
|
22063
22061
|
N.length === 0 ? D.preventDefault() : D.shiftKey && D.target === k ? (D.preventDefault(), b.focus()) : !D.shiftKey && D.target === b && (D.preventDefault(), k.focus());
|
|
@@ -22065,14 +22063,14 @@ function Du({
|
|
|
22065
22063
|
},
|
|
22066
22064
|
[i]
|
|
22067
22065
|
), [C] = Ot(e);
|
|
22068
|
-
return
|
|
22066
|
+
return /* @__PURE__ */ s.createElement("div", {
|
|
22069
22067
|
id: u.current,
|
|
22070
22068
|
role: "dialog",
|
|
22071
22069
|
"aria-labelledby": `${u.current}-title`,
|
|
22072
22070
|
className: f,
|
|
22073
22071
|
onKeyDown: T,
|
|
22074
22072
|
tabIndex: -1,
|
|
22075
|
-
ref:
|
|
22073
|
+
ref: y
|
|
22076
22074
|
}, /* @__PURE__ */ s.createElement("div", {
|
|
22077
22075
|
...p,
|
|
22078
22076
|
className: `sps-slide-in-panel__dialog ${n ? "open" : ""}`
|
|
@@ -22081,11 +22079,11 @@ function Du({
|
|
|
22081
22079
|
}, /* @__PURE__ */ s.createElement("div", {
|
|
22082
22080
|
className: "sps-slide-in-panel__title",
|
|
22083
22081
|
id: `${u.current}-title`
|
|
22084
|
-
}, c ||
|
|
22082
|
+
}, c || g("design-system:slideInPanel.defaultTitle")), i && /* @__PURE__ */ s.createElement("div", {
|
|
22085
22083
|
className: "sps-button sps-button--icon",
|
|
22086
22084
|
onClick: i
|
|
22087
22085
|
}, /* @__PURE__ */ s.createElement("button", {
|
|
22088
|
-
"aria-label":
|
|
22086
|
+
"aria-label": g("design-system:slideInPanel.close"),
|
|
22089
22087
|
type: "button"
|
|
22090
22088
|
}, /* @__PURE__ */ s.createElement("i", {
|
|
22091
22089
|
className: "sps-icon sps-icon-x"
|
|
@@ -22093,10 +22091,10 @@ function Du({
|
|
|
22093
22091
|
className: "sps-slide-in-panel__body"
|
|
22094
22092
|
}, /* @__PURE__ */ s.createElement(_t.Provider, {
|
|
22095
22093
|
value: {
|
|
22096
|
-
parentElementRef:
|
|
22094
|
+
parentElementRef: y,
|
|
22097
22095
|
fixed: !0
|
|
22098
22096
|
}
|
|
22099
|
-
}, C))))
|
|
22097
|
+
}, C))));
|
|
22100
22098
|
}
|
|
22101
22099
|
Object.assign(Du, {
|
|
22102
22100
|
props: fN,
|
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.
|
|
4
|
+
"version": "7.4.10",
|
|
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.
|
|
44
|
-
"@sps-woodland/tabs": "7.4.
|
|
45
|
-
"@spscommerce/ds-colors": "7.4.
|
|
46
|
-
"@spscommerce/ds-shared": "7.4.
|
|
47
|
-
"@spscommerce/positioning": "7.4.
|
|
43
|
+
"@sps-woodland/illustrations": "7.4.10",
|
|
44
|
+
"@sps-woodland/tabs": "7.4.10",
|
|
45
|
+
"@spscommerce/ds-colors": "7.4.10",
|
|
46
|
+
"@spscommerce/ds-shared": "7.4.10",
|
|
47
|
+
"@spscommerce/positioning": "7.4.10",
|
|
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.
|
|
62
|
-
"@sps-woodland/tabs": "7.4.
|
|
63
|
-
"@spscommerce/ds-colors": "7.4.
|
|
64
|
-
"@spscommerce/ds-shared": "7.4.
|
|
65
|
-
"@spscommerce/positioning": "7.4.
|
|
61
|
+
"@sps-woodland/illustrations": "7.4.10",
|
|
62
|
+
"@sps-woodland/tabs": "7.4.10",
|
|
63
|
+
"@spscommerce/ds-colors": "7.4.10",
|
|
64
|
+
"@spscommerce/ds-shared": "7.4.10",
|
|
65
|
+
"@spscommerce/positioning": "7.4.10",
|
|
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.
|
|
79
|
+
"test": "7.4.10"
|
|
80
80
|
},
|
|
81
81
|
"scripts": {
|
|
82
82
|
"build": "pnpm run build:js && pnpm run build:types",
|