@xylabs/react-scroll-to-top 7.0.0 → 7.0.2
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/dist/browser/index.mjs +20 -29
- package/dist/browser/index.mjs.map +1 -1
- package/package.json +12 -10
package/dist/browser/index.mjs
CHANGED
|
@@ -1,49 +1,40 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
1
|
// src/ScrollToTop.tsx
|
|
5
2
|
import { useEffect } from "react";
|
|
6
3
|
import { useLocation } from "react-router-dom";
|
|
7
|
-
var ScrollToTop =
|
|
4
|
+
var ScrollToTop = () => {
|
|
8
5
|
const { pathname } = useLocation();
|
|
9
6
|
useEffect(() => {
|
|
10
7
|
window.scrollTo(0, 0);
|
|
11
|
-
}, [
|
|
12
|
-
pathname
|
|
13
|
-
]);
|
|
8
|
+
}, [pathname]);
|
|
14
9
|
return null;
|
|
15
|
-
}
|
|
10
|
+
};
|
|
16
11
|
|
|
17
12
|
// src/ScrollToTopButton.tsx
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
import {
|
|
14
|
+
Box,
|
|
15
|
+
useScrollTrigger,
|
|
16
|
+
useTheme,
|
|
17
|
+
Zoom
|
|
18
|
+
} from "@mui/material";
|
|
19
|
+
import { jsx } from "react/jsx-runtime";
|
|
20
|
+
var ScrollToTopButton = ({
|
|
21
|
+
children,
|
|
22
|
+
anchorId,
|
|
23
|
+
...props
|
|
24
|
+
}) => {
|
|
21
25
|
const trigger = useScrollTrigger({
|
|
22
26
|
disableHysteresis: true,
|
|
23
27
|
threshold: 100
|
|
24
28
|
});
|
|
25
|
-
const handleClick =
|
|
29
|
+
const handleClick = (event) => {
|
|
26
30
|
const anchor = (event.target.ownerDocument || document).querySelector(`#${anchorId}`);
|
|
27
31
|
if (anchor) {
|
|
28
|
-
anchor.scrollIntoView({
|
|
29
|
-
behavior: "smooth",
|
|
30
|
-
block: "center"
|
|
31
|
-
});
|
|
32
|
+
anchor.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
32
33
|
}
|
|
33
|
-
}
|
|
34
|
+
};
|
|
34
35
|
const theme = useTheme();
|
|
35
|
-
return /* @__PURE__ */
|
|
36
|
-
|
|
37
|
-
...props
|
|
38
|
-
}, /* @__PURE__ */ React.createElement(Box, {
|
|
39
|
-
zIndex: 10,
|
|
40
|
-
position: "fixed",
|
|
41
|
-
right: theme.spacing(2),
|
|
42
|
-
bottom: theme.spacing(2),
|
|
43
|
-
onClick: handleClick,
|
|
44
|
-
role: "presentation"
|
|
45
|
-
}, children));
|
|
46
|
-
}, "ScrollToTopButton");
|
|
36
|
+
return /* @__PURE__ */ jsx(Zoom, { in: trigger, ...props, children: /* @__PURE__ */ jsx(Box, { zIndex: 10, position: "fixed", right: theme.spacing(2), bottom: theme.spacing(2), onClick: handleClick, role: "presentation", children }) });
|
|
37
|
+
};
|
|
47
38
|
export {
|
|
48
39
|
ScrollToTop,
|
|
49
40
|
ScrollToTopButton
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ScrollToTop.tsx","../../src/ScrollToTopButton.tsx"],"sourcesContent":["import { useEffect } from 'react'\nimport { useLocation } from 'react-router-dom'\n\n// The point of this component it to return to the top of the page on any router navigate\n\nexport const ScrollToTop = () => {\n const { pathname } = useLocation()\n useEffect(() => {\n window.scrollTo(0, 0)\n }, [pathname])\n\n return null\n}\n","import type { ZoomProps } from '@mui/material'\nimport {\n Box, useScrollTrigger, useTheme, Zoom,\n} from '@mui/material'\nimport React from 'react'\n\nexport interface ScrollToTopButtonProps extends ZoomProps {\n anchorId: string\n}\n\nexport const ScrollToTopButton: React.FC<ScrollToTopButtonProps> = ({\n children, anchorId, ...props\n}) => {\n const trigger = useScrollTrigger({\n disableHysteresis: true,\n threshold: 100,\n })\n\n const handleClick = (event: React.MouseEvent<HTMLDivElement>) => {\n const anchor = ((event.target as HTMLDivElement).ownerDocument || document).querySelector(`#${anchorId}`)\n\n if (anchor) {\n anchor.scrollIntoView({ behavior: 'smooth', block: 'center' })\n }\n }\n\n const theme = useTheme()\n\n return (\n <Zoom in={trigger} {...props}>\n <Box zIndex={10} position=\"fixed\" right={theme.spacing(2)} bottom={theme.spacing(2)} onClick={handleClick} role=\"presentation\">\n {children}\n </Box>\n </Zoom>\n )\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/ScrollToTop.tsx","../../src/ScrollToTopButton.tsx"],"sourcesContent":["import { useEffect } from 'react'\nimport { useLocation } from 'react-router-dom'\n\n// The point of this component it to return to the top of the page on any router navigate\n\nexport const ScrollToTop = () => {\n const { pathname } = useLocation()\n useEffect(() => {\n window.scrollTo(0, 0)\n }, [pathname])\n\n return null\n}\n","import type { ZoomProps } from '@mui/material'\nimport {\n Box, useScrollTrigger, useTheme, Zoom,\n} from '@mui/material'\nimport React from 'react'\n\nexport interface ScrollToTopButtonProps extends ZoomProps {\n anchorId: string\n}\n\nexport const ScrollToTopButton: React.FC<ScrollToTopButtonProps> = ({\n children, anchorId, ...props\n}) => {\n const trigger = useScrollTrigger({\n disableHysteresis: true,\n threshold: 100,\n })\n\n const handleClick = (event: React.MouseEvent<HTMLDivElement>) => {\n const anchor = ((event.target as HTMLDivElement).ownerDocument || document).querySelector(`#${anchorId}`)\n\n if (anchor) {\n anchor.scrollIntoView({ behavior: 'smooth', block: 'center' })\n }\n }\n\n const theme = useTheme()\n\n return (\n <Zoom in={trigger} {...props}>\n <Box zIndex={10} position=\"fixed\" right={theme.spacing(2)} bottom={theme.spacing(2)} onClick={handleClick} role=\"presentation\">\n {children}\n </Box>\n </Zoom>\n )\n}\n"],"mappings":";AAAA,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAIrB,IAAM,cAAc,MAAM;AAC/B,QAAM,EAAE,SAAS,IAAI,YAAY;AACjC,YAAU,MAAM;AACd,WAAO,SAAS,GAAG,CAAC;AAAA,EACtB,GAAG,CAAC,QAAQ,CAAC;AAEb,SAAO;AACT;;;ACXA;AAAA,EACE;AAAA,EAAK;AAAA,EAAkB;AAAA,EAAU;AAAA,OAC5B;AA2BD;AApBC,IAAM,oBAAsD,CAAC;AAAA,EAClE;AAAA,EAAU;AAAA,EAAU,GAAG;AACzB,MAAM;AACJ,QAAM,UAAU,iBAAiB;AAAA,IAC/B,mBAAmB;AAAA,IACnB,WAAW;AAAA,EACb,CAAC;AAED,QAAM,cAAc,CAAC,UAA4C;AAC/D,UAAM,UAAW,MAAM,OAA0B,iBAAiB,UAAU,cAAc,IAAI,QAAQ,EAAE;AAExG,QAAI,QAAQ;AACV,aAAO,eAAe,EAAE,UAAU,UAAU,OAAO,SAAS,CAAC;AAAA,IAC/D;AAAA,EACF;AAEA,QAAM,QAAQ,SAAS;AAEvB,SACE,oBAAC,QAAK,IAAI,SAAU,GAAG,OACrB,8BAAC,OAAI,QAAQ,IAAI,UAAS,SAAQ,OAAO,MAAM,QAAQ,CAAC,GAAG,QAAQ,MAAM,QAAQ,CAAC,GAAG,SAAS,aAAa,MAAK,gBAC7G,UACH,GACF;AAEJ;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xylabs/react-scroll-to-top",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.2",
|
|
4
4
|
"description": "Common React library for all XY Labs projects that use React",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"utility",
|
|
@@ -41,20 +41,22 @@
|
|
|
41
41
|
"packages/*"
|
|
42
42
|
],
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"react-router-dom": "
|
|
44
|
+
"react-router-dom": "~7.8.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@types/react": "
|
|
48
|
-
"@xylabs/ts-scripts-yarn3": "
|
|
49
|
-
"@xylabs/tsconfig
|
|
50
|
-
"
|
|
51
|
-
"react
|
|
52
|
-
"
|
|
47
|
+
"@types/react": "~19.1.10",
|
|
48
|
+
"@xylabs/ts-scripts-yarn3": "~7.1.1",
|
|
49
|
+
"@xylabs/tsconfig": "~7.1.1",
|
|
50
|
+
"@xylabs/tsconfig-dom": "~7.1.1",
|
|
51
|
+
"@xylabs/tsconfig-react": "~7.1.1",
|
|
52
|
+
"react": "~19.1.1",
|
|
53
|
+
"react-dom": "~19.1.1",
|
|
54
|
+
"typescript": "~5.9.2"
|
|
53
55
|
},
|
|
54
56
|
"peerDependencies": {
|
|
55
57
|
"@mui/material": ">=6 <8",
|
|
56
|
-
"react": "
|
|
57
|
-
"react-dom": "
|
|
58
|
+
"react": "~19",
|
|
59
|
+
"react-dom": "~19"
|
|
58
60
|
},
|
|
59
61
|
"publishConfig": {
|
|
60
62
|
"access": "public"
|