@xylabs/react-scroll-to-top 3.1.0-rc.2 → 3.1.0-rc.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/dist/ScrollToTop.js +37 -0
- package/dist/ScrollToTop.js.map +1 -0
- package/dist/ScrollToTop.mjs +13 -0
- package/dist/ScrollToTop.mjs.map +1 -0
- package/dist/ScrollToTopButton.js +44 -0
- package/dist/ScrollToTopButton.js.map +1 -0
- package/dist/ScrollToTopButton.mjs +20 -0
- package/dist/ScrollToTopButton.mjs.map +1 -0
- package/dist/esm/ScrollToTop.d.ts +2 -0
- package/dist/esm/ScrollToTop.d.ts.map +1 -0
- package/dist/esm/ScrollToTop.js +13 -0
- package/dist/esm/ScrollToTop.js.map +1 -0
- package/dist/esm/ScrollToTopButton.d.ts +7 -0
- package/dist/esm/ScrollToTopButton.d.ts.map +1 -0
- package/dist/esm/ScrollToTopButton.js +20 -0
- package/dist/esm/ScrollToTopButton.js.map +1 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/index.js +9 -6537
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -6537
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var ScrollToTop_exports = {};
|
|
20
|
+
__export(ScrollToTop_exports, {
|
|
21
|
+
ScrollToTop: () => ScrollToTop
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(ScrollToTop_exports);
|
|
24
|
+
var import_react = require("react");
|
|
25
|
+
var import_react_router_dom = require("react-router-dom");
|
|
26
|
+
const ScrollToTop = () => {
|
|
27
|
+
const { pathname } = (0, import_react_router_dom.useLocation)();
|
|
28
|
+
(0, import_react.useEffect)(() => {
|
|
29
|
+
window.scrollTo(0, 0);
|
|
30
|
+
}, [pathname]);
|
|
31
|
+
return null;
|
|
32
|
+
};
|
|
33
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
34
|
+
0 && (module.exports = {
|
|
35
|
+
ScrollToTop
|
|
36
|
+
});
|
|
37
|
+
//# sourceMappingURL=ScrollToTop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/ScrollToTop.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"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA0B;AAC1B,8BAA4B;AAIrB,MAAM,cAAc,MAAM;AAC/B,QAAM,EAAE,SAAS,QAAI,qCAAY;AACjC,8BAAU,MAAM;AACd,WAAO,SAAS,GAAG,CAAC;AAAA,EACtB,GAAG,CAAC,QAAQ,CAAC;AAEb,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
import { useLocation } from "react-router-dom";
|
|
3
|
+
const ScrollToTop = () => {
|
|
4
|
+
const { pathname } = useLocation();
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
window.scrollTo(0, 0);
|
|
7
|
+
}, [pathname]);
|
|
8
|
+
return null;
|
|
9
|
+
};
|
|
10
|
+
export {
|
|
11
|
+
ScrollToTop
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=ScrollToTop.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/ScrollToTop.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"],"mappings":"AAAA,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAIrB,MAAM,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;","names":[]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var ScrollToTopButton_exports = {};
|
|
20
|
+
__export(ScrollToTopButton_exports, {
|
|
21
|
+
ScrollToTopButton: () => ScrollToTopButton
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(ScrollToTopButton_exports);
|
|
24
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
|
+
var import_material = require("@mui/material");
|
|
26
|
+
const ScrollToTopButton = ({ children, anchorId, ...props }) => {
|
|
27
|
+
const trigger = (0, import_material.useScrollTrigger)({
|
|
28
|
+
disableHysteresis: true,
|
|
29
|
+
threshold: 100
|
|
30
|
+
});
|
|
31
|
+
const handleClick = (event) => {
|
|
32
|
+
const anchor = (event.target.ownerDocument || document).querySelector(`#${anchorId}`);
|
|
33
|
+
if (anchor) {
|
|
34
|
+
anchor.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const theme = (0, import_material.useTheme)();
|
|
38
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Zoom, { in: trigger, ...props, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Box, { zIndex: 10, position: "fixed", right: theme.spacing(2), bottom: theme.spacing(2), onClick: handleClick, role: "presentation", children }) });
|
|
39
|
+
};
|
|
40
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
41
|
+
0 && (module.exports = {
|
|
42
|
+
ScrollToTopButton
|
|
43
|
+
});
|
|
44
|
+
//# sourceMappingURL=ScrollToTopButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/ScrollToTopButton.tsx"],"sourcesContent":["import { Box, useScrollTrigger, useTheme, Zoom, ZoomProps } from '@mui/material'\nimport React from 'react'\n\nexport interface ScrollToTopButtonProps extends ZoomProps {\n anchorId: string\n}\n\nexport const ScrollToTopButton: React.FC<ScrollToTopButtonProps> = ({ children, anchorId, ...props }) => {\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;AAAA;AAAA;AAAA;AAAA;AAyBM;AAzBN,sBAAiE;AAO1D,MAAM,oBAAsD,CAAC,EAAE,UAAU,UAAU,GAAG,MAAM,MAAM;AACvG,QAAM,cAAU,kCAAiB;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,YAAQ,0BAAS;AAEvB,SACE,4CAAC,wBAAK,IAAI,SAAU,GAAG,OACrB,sDAAC,uBAAI,QAAQ,IAAI,UAAS,SAAQ,OAAO,MAAM,QAAQ,CAAC,GAAG,QAAQ,MAAM,QAAQ,CAAC,GAAG,SAAS,aAAa,MAAK,gBAC7G,UACH,GACF;AAEJ;","names":[]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Box, useScrollTrigger, useTheme, Zoom } from "@mui/material";
|
|
3
|
+
const ScrollToTopButton = ({ children, anchorId, ...props }) => {
|
|
4
|
+
const trigger = useScrollTrigger({
|
|
5
|
+
disableHysteresis: true,
|
|
6
|
+
threshold: 100
|
|
7
|
+
});
|
|
8
|
+
const handleClick = (event) => {
|
|
9
|
+
const anchor = (event.target.ownerDocument || document).querySelector(`#${anchorId}`);
|
|
10
|
+
if (anchor) {
|
|
11
|
+
anchor.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
const theme = useTheme();
|
|
15
|
+
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 }) });
|
|
16
|
+
};
|
|
17
|
+
export {
|
|
18
|
+
ScrollToTopButton
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=ScrollToTopButton.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/ScrollToTopButton.tsx"],"sourcesContent":["import { Box, useScrollTrigger, useTheme, Zoom, ZoomProps } from '@mui/material'\nimport React from 'react'\n\nexport interface ScrollToTopButtonProps extends ZoomProps {\n anchorId: string\n}\n\nexport const ScrollToTopButton: React.FC<ScrollToTopButtonProps> = ({ children, anchorId, ...props }) => {\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":"AAyBM;AAzBN,SAAS,KAAK,kBAAkB,UAAU,YAAuB;AAO1D,MAAM,oBAAsD,CAAC,EAAE,UAAU,UAAU,GAAG,MAAM,MAAM;AACvG,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":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScrollToTop.d.ts","sourceRoot":"","sources":["../../src/ScrollToTop.tsx"],"names":[],"mappings":"AAKA,eAAO,MAAM,WAAW,YAOvB,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
import { useLocation } from "react-router-dom";
|
|
3
|
+
const ScrollToTop = () => {
|
|
4
|
+
const { pathname } = useLocation();
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
window.scrollTo(0, 0);
|
|
7
|
+
}, [pathname]);
|
|
8
|
+
return null;
|
|
9
|
+
};
|
|
10
|
+
export {
|
|
11
|
+
ScrollToTop
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=ScrollToTop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/ScrollToTop.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"],"mappings":"AAAA,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAIrB,MAAM,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;","names":[]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ZoomProps } from '@mui/material';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export interface ScrollToTopButtonProps extends ZoomProps {
|
|
4
|
+
anchorId: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const ScrollToTopButton: React.FC<ScrollToTopButtonProps>;
|
|
7
|
+
//# sourceMappingURL=ScrollToTopButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScrollToTopButton.d.ts","sourceRoot":"","sources":["../../src/ScrollToTopButton.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAyC,SAAS,EAAE,MAAM,eAAe,CAAA;AAChF,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,MAAM,WAAW,sBAAuB,SAAQ,SAAS;IACvD,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CAuB9D,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Box, useScrollTrigger, useTheme, Zoom } from "@mui/material";
|
|
3
|
+
const ScrollToTopButton = ({ children, anchorId, ...props }) => {
|
|
4
|
+
const trigger = useScrollTrigger({
|
|
5
|
+
disableHysteresis: true,
|
|
6
|
+
threshold: 100
|
|
7
|
+
});
|
|
8
|
+
const handleClick = (event) => {
|
|
9
|
+
const anchor = (event.target.ownerDocument || document).querySelector(`#${anchorId}`);
|
|
10
|
+
if (anchor) {
|
|
11
|
+
anchor.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
const theme = useTheme();
|
|
15
|
+
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 }) });
|
|
16
|
+
};
|
|
17
|
+
export {
|
|
18
|
+
ScrollToTopButton
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=ScrollToTopButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/ScrollToTopButton.tsx"],"sourcesContent":["import { Box, useScrollTrigger, useTheme, Zoom, ZoomProps } from '@mui/material'\nimport React from 'react'\n\nexport interface ScrollToTopButtonProps extends ZoomProps {\n anchorId: string\n}\n\nexport const ScrollToTopButton: React.FC<ScrollToTopButtonProps> = ({ children, anchorId, ...props }) => {\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":"AAyBM;AAzBN,SAAS,KAAK,kBAAkB,UAAU,YAAuB;AAO1D,MAAM,oBAAsD,CAAC,EAAE,UAAU,UAAU,GAAG,MAAM,MAAM;AACvG,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":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,qBAAqB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export * from './ScrollToTop'\nexport * from './ScrollToTopButton'\n"],"mappings":"AAAA,cAAc;AACd,cAAc;","names":[]}
|